Summary: | Qualified names used for all TagName access, yet namespace usage is rare | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Michael Saboff <msaboff> | ||||||
Component: | WebCore JavaScript | Assignee: | Michael Saboff <msaboff> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | ap | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | All | ||||||||
OS: | OS X 10.5 | ||||||||
Attachments: |
|
Description
Michael Saboff
2011-04-20 08:50:37 PDT
Created attachment 90347 [details]
Patch to use only local name when namespace is empty or "*"
Comment on attachment 90347 [details] Patch to use only local name when namespace is empty or "*" View in context: https://bugs.webkit.org/attachment.cgi?id=90347&action=review r- > Source/WebCore/dom/Node.cpp:1736 > + if (namespaceURI.isEmpty() || namespaceURI == starAtom) > + return getElementsByTagName(localName); I'm not sure that this is correct. getElementsByTagName is supposed to return all elements with a given localName, so forwarding the "*" namespace URI to getElementsByTagName is right. However, getElementsByTagName with an empty namespace URI is only supposed to match elements with the given localName in the null namespace. That is not the same behavior as getElementsByTagName. Here is a test case that illustrates the difference: <div id="testContainer"> </div> <pre> <script> var testContainer = document.getElementById("testContainer"); var div1 = document.createElementNS(null, "div"); var div2 = document.createElementNS("http://madeupnamespace.com", "div"); testContainer.appendChild(div1); testContainer.appendChild(div2); document.writeln(testContainer.getElementsByTagName("div").length); document.writeln(testContainer.getElementsByTagNameNS("*", "div").length); document.writeln(testContainer.getElementsByTagNameNS(null, "div").length); </script> </pre> Created attachment 90513 [details]
Patch with updates to address reviewer's issues
Changed Node:getElementsByTagName to process namespace with implied "*" and changed Node::getElementsByTagNameNS to handle null namespaces.
No apparent impact on performance speed up.
Comment on attachment 90513 [details]
Patch with updates to address reviewer's issues
r=me
Committed r84586: <http://trac.webkit.org/changeset/84586> |