Ticket #10010: selector-nth.diff
| File selector-nth.diff, 1.6 kB (added by jdalton, 7 months ago) |
|---|
-
test/unit/selector.html
old new 333 333 assertEnumEqual([$('link_2')], $$('#p a:nth-child(3)'), 'nth-child'); 334 334 assertEnumEqual($('item_2', 'item_3'), $$('#list > li:nth-child(n+2)')); 335 335 assertEnumEqual($('item_1', 'item_2'), $$('#list > li:nth-child(-n+2)')); 336 assertEnumEqual($('level3_2', 'level2_2'), $$('span:nth-child(2)')); 336 337 $RunBenchmarks && wait(500, function() { 337 338 benchmark(function() { $$('#level1 *:first-child') }, 1000, ':first-child'); 338 339 benchmark(function() { $$('#level1 *:last-child') }, 1000, ':last-child'); -
src/selector.js
old new 522 522 var h = Selector.handlers, results = [], indexed = [], m; 523 523 h.mark(nodes); 524 524 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); 529 527 } 530 528 if (formula.match(/^\d+$/)) { // just a number 531 529 formula = Number(formula);