-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Fixing button command early-bail steps #12021
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
base: main
Are you sure you want to change the base?
Conversation
keithamus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. LGTM.
|
Good catch! |
|
Thanks! LGTM. |
source
Outdated
| <div algorithm> | ||
| <p>To <dfn data-x="determine-if-command-is-valid">determine if a command is valid for a | ||
| target</dfn> given a <code data-x="attr-button-command">command</code> attribute | ||
| <var>command</var> and an <code>HTMLElement</code> <var>target</var>:</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <var>command</var> and an <code>HTMLElement</code> <var>target</var>:</p> | |
| <var>command</var> and an element <var>target</var>:</p> |
As far as I can tell it's not restricted to an HTML element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was an assert in the other algorithm. But maybe that was an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so. [CEReactions, Reflect] attribute Element? commandForElement; suggests to me anyway that any kind of element can be assigned here.
Perhaps this is lacking test coverage @keithamus?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom commands work for non-HTML elements, previously there was an assert but importantly it was in a conditional.
If isPopover is false and command is not in the Custom state:
- Assert: target's namespace is the HTML namespace.
Custom commands never went down the branch of checking for valid commands, so it was fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this suggested change + my extra step below should fix this.
source
Outdated
| <li><p><span data-x="attr-button-command-hide-popover-state">Hide Popover</span></p></li> | ||
| </ul> | ||
|
|
||
| <p>Then return true.</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <p>Then return true.</p> | |
| <p>then return true.</p> |
| <li><p>If this standard does not define <span>is valid command steps</span> for | ||
| <var>target</var>'s <span data-x="concept-element-local-name">local name</span>, then return | ||
| false.</p></li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there's a problem as these steps are restricted to HTML elements.
Also, it would have been better if we always defined these steps. They just return false unless overridden.
|
|
||
| <li><p>If <var>command</var> is in the <span | ||
| data-x="attr-button-command-custom-state">Custom</span> state, then return true.</p></li> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add an extra step here (so it would become step 3) that says if target's namespace is not the HTML namespace then return false.
|
I think I've addressed the feedback. I've also made my Mozilla membership public, which should sort out the participation thing. The build failure seems unrelated. |
|
@annevk finally got the participation stuff sorted |
The previous spec seemed to allow all commands through if the element was a popover, whereas it was only intended to allow popover commands through.
Firefox and Safari follow the intent of the spec. Chrome kinda gets it wrong but wasn't following the previous wording of the spec either. I'll file a bug with them.
(See WHATWG Working Mode: Changes for more details.)
/form-elements.html ( diff )