-
Notifications
You must be signed in to change notification settings - Fork 34
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
Use localName instead of nodeName #37
Conversation
@eps1lon |
@@ -534,7 +534,7 @@ | |||
// contentType not in IE <= 11 | |||
'contentType' in doc ? | |||
doc.contentType.indexOf('/html') > 0 : | |||
doc.createElement('DiV').nodeName == 'DIV'; | |||
doc.createElement('DiV').localName == 'DIV'; |
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.
localName
reflects the element name without ASCII upper‑casing, so it will be "DiV"
and not "DIV"
.
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.
@ExE-Boss
Thank you for the help following with us.
In both Firefox and Chrome (latest versions):
document.createElement('DiV').localName == 'div'
instead of 'DiV'. Any thought ?
If this is true then `localName' is the lower-casing version of the tag name.
Recall that this differentiation was introduced to support mixed namespaces in the same document (SGV mostly).
Do you believe we are at risk of introducing regressions related to that multi-namespaces support with these changes ?
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.
Seems like we could just switch to
doc.createElement('DiV').localName == 'DIV'; | |
doc.createElement('DiV').localName == 'div'; |
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.
The lowercasing of localName
only happens in HTML documents:
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.
@ExE-Boss
Ok, by reading that I understand that the functionality of localName
depends on the document type.
@eps1lon |
We had pretty big gains in
What commit? I see this PR now has conflicts. Should I resolve these and is there anything else I should be doing? |
@eps1lon |
No worries. Whatever makes your life easier. |
…ome case-sensitive against the spec
…istake while attempting to restore lost case-sensitive regression
Due to heave usage of
getComputedStyle
injsdom
we discovered thatElement.prototype.nodeName
was a bottleneck. It seems like this isn't the correct property to use for selectors butElement.prototype.localName
(which is way cheaper injsdom
).See:
CSS type selectors
CSS qualified names
-- @domenic feat: Cache Element.prototype.tagName jsdom/jsdom#3008 (comment)
It isn't clear to me how to test these changes extensively. I quickly verified it in
./test/jquery/jquery
,./test/html5/
,./test/slick/Runner/runner
(all in Chrome 84) and by using this PR injsdom
'syarn test-wpt
. All test suites still pass with these changes.