-
-
Notifications
You must be signed in to change notification settings - Fork 929
[refactor] Limit the condition of the option tag to selected
attribute in isFormAttribute()
#3011
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
Conversation
…ute in isFormAttribute() The condition of the option tag is intended to fix MithrilJS#1916 and should be evaluated in conjunction with the "selected" attribute. This commit will improve code readability a bit, reduce the number of times to evaluate tags and also reduce the number of times to set the same attribute in option elements redundantly.
(memo) Although I think this current PR is still meaningful,
(attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected") && vnode.dom === $doc.activeElement Therefore, based on 1., 2. above, it may be a good idea to simply remove the check for whether an element is active, as follows function isFormAttribute(attr) {
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected"
} With this change, Edit: The fix for the optgroup in the other code part also seemed to eliminate the condition of whether the parent node was active. (The same idea may or may not be apply.) Edit: blink-repro for |
The test for #1916 was left as FIXME, so the test was fixed to take into account DomMock's limitations. |
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 have a nagging feeling that was a mistake, but I'm not sure by who.
Edit: I see you made the same assessment.
I'd like to see some HTML spec digging to confirm that. And if we do reduce it to just strings, we should just reduce the whole thing to a static array of strings we just |
@dead-claudia |
This PR limits the evaluation of whether a tag is
option
to only when setting theselected
attribute.Description
This PR changes the condition of
vnode.tag === "option" && vnode.dom.parentNode === activeElement(vnode.dom)
within isFormAttribute() to be likeattr === "selected" && vnode.tag === "option" && vnode.dom.parentNode === activeElement(vnode.dom)
. The only change to the code is addition of a parenthesis.The condition of the
option
tag is intended to fix #1916 and should be evaluated in conjunction with theselected
attribute. This commit will improve code readability a bit, reduce the number of times to evaluate tags and also reduce the number of times to set the same attributes inoption
elements redundantly.This PR is expected to improve performance when many
option
elements with attributes are listed.(There are not many attributes for
option
elements that can be used other thanselected
, though.)Motivation and Context
I was wondering about isFormAttribute()'s evaluation of
option
tag without an attribute. I looked into the code history of this condition, and found that it was forselected
attributes, and that the parentheses were maybe simply forgotten.How Has This Been Tested?
npm run test
Types of changes
Checklist