Open Bug 286033 Opened 20 years ago Updated 3 years ago

DOM Walking Recursive Functions results in ReferenceError for function

Categories

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

x86
Windows XP
defect

Tracking

()

People

(Reporter: zebziggle, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050223 Firefox/1.0.1 The following snippit was intended to walk the DOM tree. Try the following javascript snippit in an HTML page. The initial call into findText() works fine, but the subsequent call attempt into findText() fails with "ReferenceError: findText not found". function findText(x) { try { document.writeln('In:' + x); while (x != null) { document.writeln('NODE NAME: ' + x.nodeName + ' NODE TYPE: ' + x.nodeType + ' = ' + x.nodeValue); if (x.childNodes != null) { document.writeln('Children=' + x.childNodes); for (var i=0; i < x.childNodes.length; i++) { var e = x.childNodes[i]; document.writeln('i=' + e); findText(e); // This generates ReferenceError. } } document.writeln('After'); x = x.nextSibling; } document.writeln('Out'); } catch(e) { document.writeln('Exception: ' + e); } }; ... findText(document.documentElement); ... Reproducible: Always Steps to Reproduce: 1. Put the above javascript in an HTML page and call it. Actual Results: You should see the something like: In:[object HTMLHtmlElement] InZ:0 NODE NAME: HTML NODE TYPE: 1 = null Children=[object NodeList] i=[object HTMLHeadElement] Exception: ReferenceError: findText is not defined Expected Results: Walked the child nodes.
Product=Rhino has nothing to do with JavaScript or DOM implementations in mozilla based browsers.
Component: Core → DOM
Product: Rhino → Core
Version: other → Trunk
Assignee: igor → general
QA Contact: core → ian
Assignee: general → nobody
QA Contact: ian → general
https://bugzilla.mozilla.org/show_bug.cgi?id=1472046 Move all DOM bugs that haven’t been updated in more than 3 years and has no one currently assigned to P5. If you have questions, please contact :mdaly.
Priority: -- → P5
Component: DOM → DOM: Core & HTML
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.