Add insert and replace methods to element

This commit is contained in:
Talia 2022-03-12 19:09:08 +01:00
parent 70c702efc7
commit c3a19d7af8
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E

View file

@ -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