Add mechanism for custom built-in elements

Note: Fuck Javascript
This commit is contained in:
Talia 2022-03-26 14:12:09 +01:00
parent 16ac15b7c3
commit 4621790fbd
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E

View file

@ -71,13 +71,16 @@ const parseArgs = (element, before, ...args) => {
element.setAttribute(key, parseAttribute(arg[key])) element.setAttribute(key, parseAttribute(arg[key]))
} }
const node = (name, args, options) => { const nop = object => object
const node = (_name, args, options) => {
let element let element
if (options.nameFilter) name = options.nameFilter(name) const [name, custom] = _name
.match(/[^$]+/g)
.map(options.nameFilter ?? nop)
if (options.xmlns) if (options.xmlns)
element = document.createElementNS(options.xmlns, name) element = document.createElementNS(options.xmlns, name, {is: custom})
else else
element = document.createElement(name) element = document.createElement(name, {is: custom})
parseArgs(element, null, args) parseArgs(element, null, args)
return element return element
} }