Ticket #5740 (closed enhancement: invalid)
each method should support XML
| Reported by: | sephr | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.4 |
| Component: | core | Version: | 1.4 |
| Keywords: | e4x, xml, each | Cc: | |
| Blocking: | Blocked by: |
Description
When I say XML, I mean native XML via E4X (ECMA-357) which is implemented by SpiderMonkey and Rhino. If typeof this === "xml" for the each method, then the following algorithm should be used.
If xml.length() === 1, then let len = xml.*.length() and iterate over xml.*
If xml.length() !== 1 (do not use > 1 as it can also be 0), then let len = xml.length() and iterate over xml.
Of course, using xml.* is invalid ECMAScript 3 which would throw a SyntaxError on most JavaScript engines so the syntactic equivalent would be to use xml.children() instead.
This algorithm would iterate over XML nodes in XMLLists and XML child nodes in an XML node.
Attachments
Change History
Changed 3 years ago by sephr
-
attachment
jquery-each-xml.xhtml
added
comment:1 Changed 3 years ago by dmethvin
- Status changed from new to closed
- Resolution set to invalid
Since E4X is an evolutionary dead end it doesn't seem worth complicating the code for it. These kind of traversals would be best done by separate code to prevent them slowing down the common cases that $.each handles the other 99% of the time.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Testcase