Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Element#subNodes() major bug

#160

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.

Reported by Douwe M. · January 6th, 2010 @ 12:57 AM

State: resolved
Milestone: 1.5.3 Release
Assigned to: MadRabbit MadRabbit

Activity

  1. MadRabbit
    MadRabbit
    1. did you put your element on the page before the select?
    2. which browser is that?

    January 6th, 2010 @ 01:04 AM

  2. Douwe M.
    Douwe M.

    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.

    January 6th, 2010 @ 01:08 AM

  3. Douwe M.
    Douwe M.

    Fixed version, called Element#subNodes2() (edited the line starting with return)

          Element.addMethods({

        subNodes2: function(css_rule) {
          var first_child = this.firstChild;
          return first_child ? ((first_child.tagName &amp;&amp; first_child.match(css_rule)) ? [$(first_child)] : []
            ).concat(this.rCollect.call(first_child, 'nextSibling', css_rule)) : [];
        },
      });</code>
    
    
    
    

    January 6th, 2010 @ 01:28 AM

  4. MadRabbit
    MadRabbit
    • Tag changed from bug, element#subnodes to bug, element
    • State changed from new to resolved

    pushed the fix on the server

    January 8th, 2010 @ 05:33 PM

  5. MadRabbit
    MadRabbit
    • Milestone set to 1.5.3 Release

    January 10th, 2010 @ 02:07 PM

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.