1 line
No EOL
1.2 KiB
JavaScript
1 line
No EOL
1.2 KiB
JavaScript
Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(s){var matches=(this.document||this.ownerDocument).querySelectorAll(s);let i=matches.length;for(;0<=--i&&matches.item(i)!==this;);return-1<i}),Element.prototype.closest||(Element.prototype.closest=function(s){let el=this;do{if(Element.prototype.matches.call(el,s))return el}while(null!==(el=el.parentElement||el.parentNode)&&1===el.nodeType);return null}),Element.prototype.remove||(Element.prototype.remove=function(s){var parentNode=this.parentNode;parentNode&&parentNode.removeChild(this)}),Element.prototype.replaceChildren||(Element.prototype.replaceChildren=function(addNodes){for(;this.lastChild;)this.removeChild(this.lastChild);addNodes&&this.append(addNodes)}),Element.prototype.append||(Element.prototype.append=function(){var fragment=document.createDocumentFragment();for(let i=0,len=arguments.length;i<len;i++)fragment.appendChild(arguments[i]instanceof Node?arguments[i]:document.createTextNode(String(arguments[i])));this.appendChild(fragment)}); |