Bug 3330

Summary: REGRESSION (125-300): JavaScript "children" array includes all descendants, not just immediate children
Product: WebKit Reporter: Timothy Hatcher <timothy>
Component: DOMAssignee: Maciej Stachowiak <mjs>
Status: VERIFIED FIXED    
Severity: Critical CC: hyatt
Priority: P2    
Version: 412   
Hardware: Mac   
OS: OS X 10.4   
URL: http://colloquy.info/test/children.html
Attachments:
Description Flags
Fix none

Timothy Hatcher
Reported 2005-06-07 20:42:30 PDT
Radar: 4063841 Summary: The "children" array on nodes returns children's children in on flattened array. This is a regression from Safari 1.2 and from the DOM specs. A test case is setup here. It "children.length" should return 5 for the number of div elements. http://colloquy.info/test/children.html Steps to Reproduce: 1) Access the children array on a DOM node with JavaScript. Expected Results: Only immediate children should be in the array, not the children's children, etc. Actual Results: The array has more elements than expected if the immediate children have children elements also. They all get flattened out into the main array (a recursive behavior). Regression: This is a regression from Safari 1.2 builds. Notes: Test case at: http://colloquy.info/test/children.html
Attachments
Fix (1.35 KB, patch)
2005-06-08 22:35 PDT, Timothy Hatcher
no flags
Dave Hyatt
Comment 1 2005-06-07 20:45:35 PDT
This is actually a bug with collections in general. traverseNextItem begins by calling traverseNextNode, but traverseNextNode is a deep traversal. This means that shallow traversals like children are deep when they should not be when you make repeated calls to traverseNextItem to iterate (as calcLength does). The same is true of some of the other collections that should not be deep, and so this bug could be the cause of other HTML collection DOM bugs.
Timothy Hatcher
Comment 2 2005-06-08 22:35:51 PDT
Maciej Stachowiak
Comment 3 2005-06-08 23:33:21 PDT
I sent review comment to Timothy by email.
Timothy Hatcher
Comment 4 2005-06-20 07:55:59 PDT
This was fixed with the attached patch, and landed by Maciej. Thought I would close this and help out.
Note You need to log in before you can comment on or make changes to this bug.