Optimize Element#up/down/next/previous. Closes #10353. [Dylan Bruzenak, Nick Stackenburg, Andrew Dupont]
This commit is contained in:
parent
6f0e0ad649
commit
cb239625b3
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Optimize Element#up/down/next/previous. [Dylan Bruzenak, Nick Stackenburg, Andrew Dupont]
|
||||
|
||||
* Handle case-sensitivity in Selector tag names better. Closes #5052. [mexx, Andrew Dupont]
|
||||
|
||||
*1.6.0.1* (December 4, 2007)
|
||||
|
|
17
src/dom.js
17
src/dom.js
|
@ -220,32 +220,31 @@ Element.Methods = {
|
|||
element = $(element);
|
||||
if (arguments.length == 1) return $(element.parentNode);
|
||||
var ancestors = element.ancestors();
|
||||
return expression ? Selector.findElement(ancestors, expression, index) :
|
||||
ancestors[index || 0];
|
||||
return Object.isNumber(expression) ? ancestors[expression] :
|
||||
Selector.findElement(ancestors, expression, index);
|
||||
},
|
||||
|
||||
down: function(element, expression, index) {
|
||||
element = $(element);
|
||||
if (arguments.length == 1) return element.firstDescendant();
|
||||
var descendants = element.descendants();
|
||||
return expression ? Selector.findElement(descendants, expression, index) :
|
||||
descendants[index || 0];
|
||||
return Object.isNumber(expression) ? element.descendants()[expression] :
|
||||
element.select(expression)[index || 0];
|
||||
},
|
||||
|
||||
previous: function(element, expression, index) {
|
||||
element = $(element);
|
||||
if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
|
||||
var previousSiblings = element.previousSiblings();
|
||||
return expression ? Selector.findElement(previousSiblings, expression, index) :
|
||||
previousSiblings[index || 0];
|
||||
return Object.isNumber(expression) ? previousSiblings[expression] :
|
||||
Selector.findElement(previousSiblings, expression, index);
|
||||
},
|
||||
|
||||
next: function(element, expression, index) {
|
||||
element = $(element);
|
||||
if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
|
||||
var nextSiblings = element.nextSiblings();
|
||||
return expression ? Selector.findElement(nextSiblings, expression, index) :
|
||||
nextSiblings[index || 0];
|
||||
return Object.isNumber(expression) ? nextSiblings[expression] :
|
||||
Selector.findElement(nextSiblings, expression, index);
|
||||
},
|
||||
|
||||
select: function() {
|
||||
|
|
Loading…
Reference in New Issue