From c3a19d7af8ade85146fff86dd423485b473ae784 Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Sat, 12 Mar 2022 19:09:08 +0100 Subject: [PATCH] Add insert and replace methods to element --- element.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/element.js b/element.js index 23e5b9a..dee8cbb 100644 --- a/element.js +++ b/element.js @@ -56,6 +56,13 @@ export default Class => { } } + proto.insert = function(...args) { + return (this.shadowRoot || this).append(...args) + } + proto.replace = function(...args) { + return (this.shadowRoot || this).replaceChildren(...args) + } + Object.prototype[Symbol.toPrimitive] = function(hint) { const name = `to${hint.replace(/./, e => e.toUpperCase())}` return name in this