From cdaeac1a9fb63de025b14aca4ebd71d3733281ba Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Sat, 26 Mar 2022 14:12:09 +0100 Subject: [PATCH] Add mechanism for custom built-in elements Note: Fuck Javascript --- skooma.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/skooma.js b/skooma.js index 6e3c477..c28d691 100644 --- a/skooma.js +++ b/skooma.js @@ -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 }