Optimize Element#immediateDescendants.
This commit is contained in:
parent
82c9b9c783
commit
18f2ac65c3
@ -1,3 +1,5 @@
|
||||
* Optimize Element#immediateDescendants. (kangax, Tobie Langel)
|
||||
|
||||
* Remove unnecessary function object creation and `Number#times` in `Element._getContentFromAnonymousElement`. (kangax)
|
||||
|
||||
* Eliminate runtime forking and long method lookup in `Element.hasAttribute`. (kangax)
|
||||
|
@ -536,10 +536,14 @@ Element.Methods = {
|
||||
* **This method is deprecated, please see [[Element.childElements]]**.
|
||||
**/
|
||||
immediateDescendants: function(element) {
|
||||
if (!(element = $(element).firstChild)) return [];
|
||||
while (element && element.nodeType != 1) element = element.nextSibling;
|
||||
if (element) return [element].concat($(element).nextSiblings());
|
||||
return [];
|
||||
var results = [], child = $(element).firstChild;
|
||||
while (child) {
|
||||
if (child.nodeType === 1) {
|
||||
results.push(Element.extend(child));
|
||||
}
|
||||
child = child.nextSibling;
|
||||
}
|
||||
return results;
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user