Add mechanism for custom built-in elements
Note: Fuck Javascript
This commit is contained in:
parent
16ac15b7c3
commit
4621790fbd
1 changed files with 7 additions and 4 deletions
11
skooma.js
11
skooma.js
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue