Re: [whatwg/dom] Add before removing steps (PR #1185)

> An alternative idea: when https://html.spec.whatwg.org/#hide-popover-algorithm is invoked, instead of invoking https://html.spec.whatwg.org/#check-popover-validity from there, check only if https://html.spec.whatwg.org/#popover-visibility-state is "hidden" and if so return early.

If we don't call check popover validity as the first thing in hide popover algorithm, then we would be skipping opportunities to throw exceptions. For example, this should throw an exception:
```javascript
const div = document.createElement('div');
// don't add the popover attribute
div.hidePopover(); // throws because there is no popover attribute
```

> https://html.spec.whatwg.org/#dom-hidepopover would need to be extended to check whether the popover attribute is not present and throw in that case. Similar adaptations might be needed for other callers of https://html.spec.whatwg.org/#hide-popover-algorithm, but it might overall be a simpler solution than https://github.com/whatwg/dom/pull/1185#issuecomment-1579186990.

I see, yeah I guess that in the case where we want to hide a popover regardless of the dom state, the only relevant check in the check popover algorithm is whether or not the popover is in the showing or hidden state, so we could conditionally replace calls to the check popover algorithm with checks for the popover visibility state. Sounds good to me, and it could also be used to fix https://github.com/whatwg/html/issues/9367

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/pull/1185#issuecomment-1581546146
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/pull/1185/c1581546146@github.com>

Received on Wednesday, 7 June 2023 21:39:46 UTC