Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit e35abc9

Browse files
IgorMinarrodyhaddad
authored andcommitted
perf(jqLite): optimize element dealocation
Iterate only over elements and not nodes since we don't attach data or handlers to text/comment nodes.
1 parent a196c8b commit e35abc9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/jqLite.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,10 @@ function jqLiteClone(element) {
241241

242242
function jqLiteDealoc(element){
243243
jqLiteRemoveData(element);
244-
for ( var i = 0, children = element.childNodes || []; i < children.length; i++) {
245-
jqLiteDealoc(children[i]);
244+
var childElement;
245+
for ( var i = 0, children = element.children, l = (children && children.length) || 0; i < l; i++) {
246+
childElement = children[i];
247+
jqLiteDealoc(childElement);
246248
}
247249
}
248250

0 commit comments

Comments
 (0)