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) {
|
$.rmAll = function(root) {
|
||||||
var node, _i, _len, _ref;
|
return root.textContent = '';
|
||||||
_ref = __slice.call(root.childNodes);
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
node = _ref[_i];
|
|
||||||
root.removeChild(node);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$.tn = function(s) {
|
$.tn = function(s) {
|
||||||
@ -12156,13 +12151,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
var board;
|
|
||||||
g.threads.forEach(function(thread) {
|
g.threads.forEach(function(thread) {
|
||||||
return thread.collect();
|
return thread.collect();
|
||||||
});
|
});
|
||||||
QuoteBacklink.containers = {};
|
QuoteBacklink.containers = {};
|
||||||
board = $('.board');
|
return $.rmAll($('.board'));
|
||||||
return $.replace(board, board.cloneNode(false));
|
|
||||||
},
|
},
|
||||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
|
|||||||
@ -552,12 +552,7 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
$.rmAll = function(root) {
|
$.rmAll = function(root) {
|
||||||
var node, _i, _len, _ref;
|
return root.textContent = '';
|
||||||
_ref = __slice.call(root.childNodes);
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
node = _ref[_i];
|
|
||||||
root.removeChild(node);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$.tn = function(s) {
|
$.tn = function(s) {
|
||||||
@ -12155,13 +12150,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
clean: function() {
|
clean: function() {
|
||||||
var board;
|
|
||||||
g.threads.forEach(function(thread) {
|
g.threads.forEach(function(thread) {
|
||||||
return thread.collect();
|
return thread.collect();
|
||||||
});
|
});
|
||||||
QuoteBacklink.containers = {};
|
QuoteBacklink.containers = {};
|
||||||
board = $('.board');
|
return $.rmAll($('.board'));
|
||||||
return $.replace(board, board.cloneNode(false));
|
|
||||||
},
|
},
|
||||||
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
features: [['Thread Excerpt', ThreadExcerpt], ['Unread Count', Unread], ['Quote Threading', QuoteThreading], ['Thread Stats', ThreadStats], ['Thread Updater', ThreadUpdater], ['Thread Expansion', ExpandThread]],
|
||||||
disconnect: function() {
|
disconnect: function() {
|
||||||
|
|||||||
@ -37,8 +37,7 @@ Navigate =
|
|||||||
g.threads.forEach (thread) -> thread.collect()
|
g.threads.forEach (thread) -> thread.collect()
|
||||||
QuoteBacklink.containers = {}
|
QuoteBacklink.containers = {}
|
||||||
|
|
||||||
board = $('.board')
|
$.rmAll $('.board')
|
||||||
$.replace board, board.cloneNode false
|
|
||||||
|
|
||||||
features: [
|
features: [
|
||||||
['Thread Excerpt', ThreadExcerpt]
|
['Thread Excerpt', ThreadExcerpt]
|
||||||
|
|||||||
@ -133,12 +133,8 @@ $.rm = do ->
|
|||||||
else
|
else
|
||||||
(el) -> el.parentNode?.removeChild el
|
(el) -> el.parentNode?.removeChild el
|
||||||
|
|
||||||
$.rmAll = (root) ->
|
# jsperf.com/emptify-element/9
|
||||||
# jsperf.com/emptify-element
|
$.rmAll = (root) -> root.textContent = ''
|
||||||
for node in [root.childNodes...]
|
|
||||||
# HTMLSelectElement.remove !== Element.remove
|
|
||||||
root.removeChild node
|
|
||||||
return
|
|
||||||
|
|
||||||
$.tn = (s) ->
|
$.tn = (s) ->
|
||||||
d.createTextNode s
|
d.createTextNode s
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user