Closed Bug 279929 Opened 20 years ago Closed 20 years ago

TreeWalker.nextNode() returns nodes outside the target subtree when no matches in subtree

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 260293

People

(Reporter: rcm, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

When a TreeWalker is created over a subtree that contains no nodes matching the
whatToShow filter (e.g. SHOW_TEXT on a subtree with no text nodes in it), then
calling TreeWalker.nextNode() will exit the subtree and start returning matching
nodes from the rest of the document.

Correct behavior should be for nextNode() to return null, according to
http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html#Traversal-TreeWalker


Reproducible: Always

Steps to Reproduce:
1. Go to the URL referenced in this bug report.  It contains some Javascript
that creates TreeWalkers and pops up their results in alert() dialogs.  

Actual Results:  
The alert dialogs show text and elements from the rest of the document,
indicating that TreeWalker.nextNode() blew past the desired subtree.

Expected Results:  
The alerts should be empty, showing that TreeWalker.nextNode() immediately
returned null.

*** This bug has been marked as a duplicate of 260293 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → DUPLICATE
Component: DOM: Traversal-Range → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.