Improve skooma attribute handling

This commit is contained in:
Talia 2021-08-16 18:03:43 +02:00
parent 864cf22f5f
commit 326a17f4e1
No known key found for this signature in database
GPG key ID: AD727AD22802D0D6

View file

@ -46,6 +46,10 @@ const parseArgs = (element, ...args) => {
parseArgs((element.shadowRoot || element.attachShadow({mode: "open"})), arg[key]) parseArgs((element.shadowRoot || element.attachShadow({mode: "open"})), arg[key])
else if (typeof arg[key] == "function") else if (typeof arg[key] == "function")
element.addEventListener(key.replace(/^on[A-Z]/, x => x.charAt(x.length-1).toLowerCase()), e => e.preventDefault() || arg[key](e)) element.addEventListener(key.replace(/^on[A-Z]/, x => x.charAt(x.length-1).toLowerCase()), e => e.preventDefault() || arg[key](e))
else if (arg[key] === true)
{if (!element.hasAttribute(key)) element.setAttribute(key, '')}
else if (arg[key] === false)
element.removeAttribute(key)
else else
element.setAttribute(key, parseAttribute(arg[key])) element.setAttribute(key, parseAttribute(arg[key]))
} }