Add event listeners to skooma.js

This commit is contained in:
Talia 2021-05-26 11:26:44 +02:00
parent 62f974b878
commit 124857f7f8
No known key found for this signature in database
GPG key ID: AD727AD22802D0D6

View file

@ -18,7 +18,10 @@ const parseArgs = (element, args) => {
parseArgs(element, arg) parseArgs(element, arg)
else else
for (let key in arg) for (let key in arg)
element.setAttribute(key, parseAttribute(arg[key])) if (typeof arg[key] == "function")
element.addEventListener(key.replace(/^on[A-Z]/, x => x.charAt(x.length-1).toLowerCase()), arg[key])
else
element.setAttribute(key, parseAttribute(arg[key]))
} }
const node = (name, args, xmlns) => { const node = (name, args, xmlns) => {