#160 ✓resolved
Douwe M.

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

    MadRabbit January 6th, 2010 @ 01:04 AM

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

    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.

    Douwe M. January 6th, 2010 @ 01:28 AM

    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>
    
    
    
    
  • MadRabbit

    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

  • MadRabbit

    MadRabbit January 10th, 2010 @ 02:07 PM

    • Milestone set to 1.5.3 Release

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

RightJS Core Tickets

Shared Ticket Bins

People watching this ticket

Tags

Pages