It is now safe to use Node::remove.

This commit is contained in:
Mayhem 2014-01-26 21:25:18 +01:00
parent 24f93da8e7
commit 06e5ce4ef6

View File

@ -99,16 +99,12 @@ $.rmClass = (el, className...) ->
el.classList.remove className... el.classList.remove className...
$.hasClass = (el, className) -> $.hasClass = (el, className) ->
el.classList.contains className el.classList.contains className
$.rm = do -> $.rm = (el) ->
if 'remove' of Element.prototype el.remove()
(el) -> el.remove()
else
(el) -> el.parentNode?.removeChild el
$.rmAll = (root) -> $.rmAll = (root) ->
# jsperf.com/emptify-element # jsperf.com/emptify-element
for node in [root.childNodes...] for node in [root.childNodes...]
# HTMLSelectElement.remove !== Element.remove node.remove()
root.removeChild node
return return
$.tn = (s) -> $.tn = (s) ->
d.createTextNode s d.createTextNode s