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 3724b3e25d
commit cdaeac1a9f
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E

View file

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