Better $.rmAll
I verified an issue with the previous benchmark and even wrote a more efficient method based off el.cloneNode(false);, which I would use if cloneNode could inherit eventListeners Speaking of events. there is still no interface for gather all eventListeners on a given element (or its children). Apparently the issue is that the w3c doesn't think there is a legitimate use case for it. Heh.
This commit is contained in:
parent
b62d82bed0
commit
51ba83538a
@ -575,12 +575,7 @@
|
||||
})();
|
||||
|
||||
$.rmAll = function(root) {
|
||||
var node, _i, _len, _ref;
|
||||
_ref = __slice.call(root.childNodes);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
node = _ref[_i];
|
||||
root.removeChild(node);
|
||||
}
|
||||
return root.textContent = '';
|
||||
};
|
||||
|
||||
$.tn = function(s) {
|
||||
@ -12156,13 +12151,11 @@
|
||||
}
|
||||
},
|
||||
clean: function() {
|
||||
var board;
|
||||
g.threads.forEach(function(thread) {
|
||||
return thread.collect();
|
||||
});
|
||||
QuoteBacklink.containers = {};
|
||||
board = $('.board');
|
||||
return $.replace(board, board.cloneNode(false));
|
||||
return $.rmAll($('.board'));
|
||||
},
|
||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||
disconnect: function() {
|
||||
|
||||
@ -552,12 +552,7 @@
|
||||
})();
|
||||
|
||||
$.rmAll = function(root) {
|
||||
var node, _i, _len, _ref;
|
||||
_ref = __slice.call(root.childNodes);
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
node = _ref[_i];
|
||||
root.removeChild(node);
|
||||
}
|
||||
return root.textContent = '';
|
||||
};
|
||||
|
||||
$.tn = function(s) {
|
||||
@ -12155,13 +12150,11 @@
|
||||
}
|
||||
},
|
||||
clean: function() {
|
||||
var board;
|
||||
g.threads.forEach(function(thread) {
|
||||
return thread.collect();
|
||||
});
|
||||
QuoteBacklink.containers = {};
|
||||
board = $('.board');
|
||||
return $.replace(board, board.cloneNode(false));
|
||||
return $.rmAll($('.board'));
|
||||
},
|
||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||
disconnect: function() {
|
||||
|
||||
@ -37,8 +37,7 @@ Navigate =
|
||||
g.threads.forEach (thread) -> thread.collect()
|
||||
QuoteBacklink.containers = {}
|
||||
|
||||
board = $('.board')
|
||||
$.replace board, board.cloneNode false
|
||||
$.rmAll $('.board')
|
||||
|
||||
features: [
|
||||
['Thread Excerpt', ThreadExcerpt]
|
||||
|
||||
@ -133,12 +133,8 @@ $.rm = do ->
|
||||
else
|
||||
(el) -> el.parentNode?.removeChild el
|
||||
|
||||
$.rmAll = (root) ->
|
||||
# jsperf.com/emptify-element
|
||||
for node in [root.childNodes...]
|
||||
# HTMLSelectElement.remove !== Element.remove
|
||||
root.removeChild node
|
||||
return
|
||||
# jsperf.com/emptify-element/9
|
||||
$.rmAll = (root) -> root.textContent = ''
|
||||
|
||||
$.tn = (s) ->
|
||||
d.createTextNode s
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user