RESOLVED CONFIGURATION CHANGED 117766
Make createNodeIterator() and createTreeWalker() accept default arguments
https://bugs.webkit.org/show_bug.cgi?id=117766
Summary Make createNodeIterator() and createTreeWalker() accept default arguments
Ryosuke Niwa
Reported 2013-06-18 18:36:36 PDT
Consider merging https://chromium.googlesource.com/chromium/blink/+/f428315bba882a4ba1b2af42869e477b86b51bf1 In DOM Level 2 Traversal and Range, the arguments to these methods were all mandatory. In DOM4, however, the arguments except the first one (root node) became optional. Especially, the |whatToShow| argument has the default value of 0xFFFFFFFF, which is a bitmask meaning that the all kinds of nodes will be accepted. In contrast, in our current implementation, |whatToShow| argument is defaulted to zero when it is omitted. This means that all kinds of nodes should be filtered, which is totally useless for users. This change updates Document.createNodeIterator() and createTreeWalker() so they can accept default arguments properly. The potential risk of this change is low, because omitting the |whatToShow| argument was meaningless with our old implementation. Mozilla also implements this default argument, so I assume it is safe to follow the recent specification. Additionally, this change removes |expandEntityReferences| flag from these methods' implementation. This flag first appeared in the DOM2 Traversal specification, but later got removed in DOM4. This flag was never implemented and was actually ignored. To keep compatibility, this flag is still accepted when specified in createNodeIterator() and createTreeWalker() methods, so this change does not affect the behavior.
Attachments
Test Case - NodeIterator-basic.html (66.58 KB, text/html)
2022-08-20 04:37 PDT, Ahmad Saleem
no flags
Test Case - TreeWalker-basic.html (64.24 KB, text/html)
2022-08-20 04:37 PDT, Ahmad Saleem
no flags
Ahmad Saleem
Comment 1 2022-08-20 04:36:31 PDT
Test Cases Results: <<< TreeWalker-basic.html >>> **** Safari Technology Preview 151 **** PASS Construct a TreeWalker by document.createTreeWalker(). FAIL Give an invalid root node to document.createTreeWalker(). assert_throws: function "function () { document.createTreeWalker(null); }" threw object "TypeError: Argument 1 ('root') to Document.createTreeWalk..." that is not a DOMException NOT_SUPPORTED_ERR: property "code" is equal to undefined, expected 9 PASS Walk over nodes. **** Chrome Canary 106 **** PASS Construct a TreeWalker by document.createTreeWalker(). FAIL Give an invalid root node to document.createTreeWalker(). assert_throws: function "function () { document.createTreeWalker(null); }" threw object "TypeError: Failed to execute 'createTreeWalker' on 'Docum..." that is not a DOMException NOT_SUPPORTED_ERR: property "code" is equal to undefined, expected 9 PASS Walk over nodes. **** Firefox Nightly 105 **** PASS Construct a TreeWalker by document.createTreeWalker(). FAIL Give an invalid root node to document.createTreeWalker(). assert_throws: function "function () { document.createTreeWalker(null); }" threw object "TypeError: Document.createTreeWalker: Argument 1 is not a..." that is not a DOMException NOT_SUPPORTED_ERR: property "code" is equal to undefined, expected 9 PASS Walk over nodes. <<< NodeIterator-basic.html >>> **** Safari Technology Preview 151 **** PASS Construct a NodeIterator by document.createNodeIterator(). FAIL Give an invalid root node to document.createNodeIterator(). assert_throws: function "function () { document.createNodeIterator(null); }" threw object "TypeError: Argument 1 ('root') to Document.createNodeIter..." that is not a DOMException NOT_SUPPORTED_ERR: property "code" is equal to undefined, expected 9 PASS Iterate over all nodes forward then backward. PASS Iterate over all elements forward then backward. PASS Iterate over all text nodes forward then backward. PASS Iterate over all comment nodes forward then backward. PASS Test the behavior of NodeIterator when no nodes match with the given filter. PASS Test the behavior of NodeIterator when NodeFilter is specified. *** Firefox Nightly 105 *** PASS Construct a NodeIterator by document.createNodeIterator(). FAIL Give an invalid root node to document.createNodeIterator(). assert_throws: function "function () { document.createNodeIterator(null); }" threw object "TypeError: Document.createNodeIterator: Argument 1 is not..." that is not a DOMException NOT_SUPPORTED_ERR: property "code" is equal to undefined, expected 9 PASS Iterate over all nodes forward then backward. PASS Iterate over all elements forward then backward. PASS Iterate over all text nodes forward then backward. PASS Iterate over all comment nodes forward then backward. PASS Test the behavior of NodeIterator when no nodes match with the given filter. PASS Test the behavior of NodeIterator when NodeFilter is specified. *** Chrome Canary 106 *** PASS Construct a NodeIterator by document.createNodeIterator(). FAIL Give an invalid root node to document.createNodeIterator(). assert_throws: function "function () { document.createNodeIterator(null); }" threw object "TypeError: Failed to execute 'createNodeIterator' on 'Doc..." that is not a DOMException NOT_SUPPORTED_ERR: property "code" is equal to undefined, expected 9 PASS Iterate over all nodes forward then backward. PASS Iterate over all elements forward then backward. PASS Iterate over all text nodes forward then backward. PASS Iterate over all comment nodes forward then backward. PASS Test the behavior of NodeIterator when no nodes match with the given filter. PASS Test the behavior of NodeIterator when NodeFilter is specified. ________________ Just wanted to update test results. Thanks!
Ahmad Saleem
Comment 2 2022-08-20 04:37:02 PDT
Created attachment 461757 [details] Test Case - NodeIterator-basic.html NodeIterator-basic.html Test Case
Ahmad Saleem
Comment 3 2022-08-20 04:37:40 PDT
Created attachment 461758 [details] Test Case - TreeWalker-basic.html TreeWalker-basic.html
Ryosuke Niwa
Comment 4 2022-08-20 15:32:29 PDT
All browsers' behavior match.
Note You need to log in before you can comment on or make changes to this bug.