-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
popover*targetElement IDL attributes can be misleading #8894
Comments
I think a better design would be either:
|
We generally want to have a reflecting IDL attribute for every content attribute. So we shouldn't get rid of them. We could add
though in addition, if that seems useful.
But, it should still set the attr-associated element, which (I hope) is what the rest of the spec consults, right? |
The IDL attribute can just reflect the ID string.
That's not the case: https://html.spec.whatwg.org/#popover-target-element Note that Chrome's implementation is different from the spec:
popovershowtarget & popoverhidetarget both seem to work, though according to the spec, only popovershowtarget is supposed to work, since popover in https://html.spec.whatwg.org/#popover-target-attribute-activation-behavior is the one from popovershowtarget. |
But it's better if it reflects the actual element.
Then we should fix that! |
I don't think it makes a lot of sense with the current spec, if someone does:
button will only act on foo (it'll act as a toggle for foo). In Chrome, the button will act on both at once (show foo, hide bar), so maybe it makes more sense with that behavior at least. |
I agree with @domenic that I guess then there is a separate question with regards to what happens when multiple are set. I tend to prefer only activating a single one, in line with |
There are several things going on here:
There might be bugs in the implementation and/or spec, but the above was the intention.
I like this idea a lot - it seems valuable to provide the one target element, regardless of which attribute(s) were used. It must be |
From what I'm seeing in the spec & Chrome, popovertoggletarget wins over popovershowtarget/hidetarget, but popovershowtarget/hidetarget can be used together. So IIUC, If only one target wins, then So I'm suggesting 2 changes:
What do you think? (I got confused now, I thought my example here worked, but it did for the wrong reasons: |
I just added IDL equivalents to the demo, and I believe Chromium's behavior looks ok there also. Please correct me if I'm wrong! |
I agree with this statement: if attributes point to different elements, only one "winning" argument works. In the example above, it should behave as if the It does seem like we need some spec clarification/fixes here. @josepharhar |
The only intended case where both can work together is this one: <button popovershowtarget=foo popoverhidetarget=foo>Show and hide foo</button> In that case, since they point to the same element, that should behave like a toggle. It's semantically the same - "toggle" both hides and shows an element.
I agree with this - it would make it easier for developers to understand what's going on. But @domenic @annevk there might be spec issues for it? Perhaps not. If it's spec-possible, I'm in favor. |
As far as I can tell we'd need to create an extension for "reflect" so you can run some custom setter steps (that would null out the other references). It's possible, but novel. And might create a nice merge conflict for #8496. |
It doesn't read the same to me. To me, this reads as:
whereas
@mfreed7 I'd prefer to not special case the case where |
Even though it doesn't behave that way, I think special casing the case where both attribute values is equal just adds more confusion. |
So
otherwise, it'd have to throw an exception if the popover was already open. But I don't disagree that it's a bit confusing when more than one attribute is in use at a time. So you're proposing to only "allow" one of the three attributes at a time, right? What happens if more than one is used, just no behavior at all and perhaps a console warning? If so, I don't think that breaks any "real" use cases, but @jh3y can you double-check me? If not, I think I'm supportive of this change. I suppose in this case we'd also want all three IDL reflections to return null? |
@nt1m and I discussed this and it would be rather involved to keep the current design and use reflect. We'd essentially need custom getter steps (to return null if there are multiple attributes set) and custom setter steps (to null out the other internal slots and delete the other attributes). Could we perhaps consider an alternative design with two attributes:
This is slightly more verbose, though less verbose in what is likely the common case. And it fits a lot better with existing attribute patterns and reflect. |
Yep, that's a good point. That'd apply to Chromium also.
Just to clarify the proposal, the above two are the content attributes. For IDL:
Does that sound like what you're proposing? |
Maybe we need a |
(but yes the rest is accurate) |
Thinking more, it's probably fine too if the default is I was mostly thinking of the case where both attributes weren't set, but I guess the user activation behavior can just check if |
The reason I didn't include a
Right - if you don't have a |
@mfreed7 I agree with you, no need for a none state. The only slight change to your earlier comment is that the type would be If you could make it more explicit whether that works for you all I'm happy to do the spec work (middle of next week most likely). |
Yep, good catch, I'm not sure why I made it nullable, since I then said the missing value default was "toggle".
I'm convinced that this is a better shape for this feature, and I've put up a PR to change Chromium accordingly. That includes new WPTs that test the new behavior. The WPT PR isn't up yet, but it should be later today. I appreciate you offering to do the corresponding spec work, thanks! |
See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b
WPT updates are here: web-platform-tests/wpt#38701 |
See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b
See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288730 Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1109867}
See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288730 Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1109867}
See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288730 Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1109867}
Instead of popoverhidetarget, popovershowtarget, and popovertoggletarget, we will now have popovertarget and popovertargetaction. The former for targeting an element and the latter for determining what to do with the target. Tests: web-platform-tests/wpt#38701. Fixes #8894.
Instead of popoverhidetarget, popovershowtarget, and popovertoggletarget, we will now have popovertarget and popovertargetaction. The former for targeting an element and the latter for determining what to do with the target. Tests: web-platform-tests/wpt#38701. Fixes #8894.
Instead of popoverhidetarget, popovershowtarget, and popovertoggletarget, we will now have popovertarget and popovertargetaction. The former for targeting an element and the latter for determining what to do with the target. Tests: web-platform-tests/wpt#38701. Fixes #8894.
…stonly Automatic update from web-platform-tests Change popover invoking attributes See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288730 Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1109867} -- wpt-commits: 588e82830bb860050168fa89eddc93ac32293662 wpt-pr: 38701
Instead of popoverhidetarget, popovershowtarget, and popovertoggletarget, we will now have popovertarget and popovertargetaction. The former for targeting an element and the latter for determining what to do with the target. This also corrects popover validity checks in activation behavior and consistifies the popover attribute. Tests: web-platform-tests/wpt#38701. HTML-AAM: w3c/html-aam#446. Fixes #8894, fixes #8983, and fixes #8979.
See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288730 Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1109867}
…stonly Automatic update from web-platform-tests Change popover invoking attributes See [1] for discussion. This changes the Popover invoking attribute behavior. Previously, three attributes were used to set the invoking relationship and behavior: - popovertoggletarget - popovershowtarget - popoverhidetarget Those each could point to an idref for a popover, and the behavior would be controlled by which attribute was used. However, there was a confusing situation in the case that multiple such attributes were used on a single element, and even more so when they pointed to different elements. While there was concrete logic for resolving that situation, it was confusing at best. The new logic is controlled by two attributes: - popovertarget - popovertargetaction The element reference is dictated by `popovertarget`, via an idref or through element reflection (via `foo.popoverTargetElement = bar`). The behavior is dictated by the (string valued) popovertargetaction attribute, which can be one of "toggle", "show", or "hide". If any other value is used (including missing attribute or invalid value), the behavior and IDL reflected value is "toggle". [1] whatwg/html#8894 (comment) Bug: 1307772 Change-Id: I2e530efe26032599f9376c8d5f4fe2a7f430a26b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4288730 Auto-Submit: Mason Freed <masonf@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Commit-Queue: Mason Freed <masonf@chromium.org> Commit-Queue: Joey Arhar <jarhar@chromium.org> Cr-Commit-Position: refs/heads/main@{#1109867} -- wpt-commits: 588e82830bb860050168fa89eddc93ac32293662 wpt-pr: 38701
The popover*targetElement won't necessarily point to the popover being toggled for 2 reasons:
The text was updated successfully, but these errors were encountered: