Element#subNodes() major bug
Reported by Douwe M. | January 6th, 2010 @ 12:57 AM | in 1.5.3 Release
Using Element#subNodes()
with a
css_rule
always returns the firstChild
if
it has a tagName
(i.e. isn't whitespace), plus the
childs matching the css_rule
, not only those matching
the given css_rule
.
This code for example, returns [<div
id="a">, <div
id="b">]
:
$E('div').insert(
$E('div', {id: 'a'})
).insert(
$E('div', {id: 'b'})
).subNodes('#b');</code>
While it should of course return
[<div id="b">]
,
because only this child matches the given css_rule
.Comments and changes to this ticket
-
MadRabbit January 6th, 2010 @ 01:04 AM
- did you put your element on the page before the
select?
- which browser is that?
- did you put your element on the page before the
select?
-
Douwe M. January 6th, 2010 @ 01:08 AM
1) What exactly do you mean?
2) This is Safari (so probably Chrome too), but looking at the code for Element#subNodes() it think it behaves like this in every browser (that you can count on, i.e. not IE). Haven't checked Firefox yet. -
Douwe M. January 6th, 2010 @ 01:28 AM
Fixed version, called
Element#subNodes2()
(edited the line starting withreturn
)Element.addMethods({
subNodes2: function(css_rule) { var first_child = this.firstChild; return first_child ? ((first_child.tagName && first_child.match(css_rule)) ? [$(first_child)] : [] ).concat(this.rCollect.call(first_child, 'nextSibling', css_rule)) : []; }, });</code>
-
MadRabbit January 8th, 2010 @ 05:33 PM
- Tag changed from bug, element#subnodes to bug, element
- State changed from new to resolved
pushed the fix on the server
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.