Skip to content

Commit

Permalink
Remove each child of element, which uses html() function to prevent p…
Browse files Browse the repository at this point in the history
…erformance issues.
  • Loading branch information
tvrzna committed Nov 11, 2021
1 parent ef6ed40 commit d0b7086
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions nunjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ Nunjs = {
if (matchesSelector) return matchesSelector.call(obj, selector);
return false;
},
removeWithChildren : function (i, el) {
$(el).find('*').each(Nunjs.removeWithChildren);
$(el).remove();
},
'_events' : {}
};

Expand Down Expand Up @@ -142,6 +146,7 @@ window.$ = function(selector) {
if (content === undefined) {
return this[0].innerHTML;
}
this.find('*').each(Nunjs.removeWithChildren);
this.each(function() {
this.innerHTML = content;
});
Expand Down
2 changes: 1 addition & 1 deletion nunjs.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d0b7086

Please sign in to comment.