Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10010: selector-nth.diff

File selector-nth.diff, 1.6 kB (added by jdalton, 7 months ago)

in diff form

  • test/unit/selector.html

    old new  
    333333      assertEnumEqual([$('link_2')], $$('#p a:nth-child(3)'), 'nth-child'); 
    334334      assertEnumEqual($('item_2', 'item_3'), $$('#list > li:nth-child(n+2)')); 
    335335      assertEnumEqual($('item_1', 'item_2'), $$('#list > li:nth-child(-n+2)')); 
     336      assertEnumEqual($('level3_2', 'level2_2'), $$('span:nth-child(2)')); 
    336337      $RunBenchmarks && wait(500, function() { 
    337338        benchmark(function() { $$('#level1 *:first-child') }, 1000, ':first-child'); 
    338339        benchmark(function() { $$('#level1 *:last-child') }, 1000, ':last-child'); 
  • src/selector.js

    old new  
    522522      var h = Selector.handlers, results = [], indexed = [], m; 
    523523      h.mark(nodes); 
    524524      for (var i = 0, node; node = nodes[i]; i++) { 
    525         if (!node.parentNode._counted) { 
    526           h.index(node.parentNode, reverse, ofType); 
    527           indexed.push(node.parentNode); 
    528         } 
     525        h.index(node.parentNode, reverse, ofType); 
     526        indexed.push(node.parentNode); 
    529527      } 
    530528      if (formula.match(/^\d+$/)) { // just a number 
    531529        formula = Number(formula);