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

Commit 6c2cb15

Browse files
committed
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 1e18af4 commit 6c2cb15

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
@@ -240,8 +240,10 @@ function jqLiteClone(element) {
240240

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

0 commit comments

Comments
 (0)