Fix unnecessary "is" attribute being added to nodes
This commit is contained in:
parent
0bb3bd4631
commit
bc1383f07d
1 changed files with 11 additions and 11 deletions
22
skooma.js
22
skooma.js
|
@ -33,15 +33,13 @@ const parseAttribute = (attribute) => {
|
||||||
|
|
||||||
|
|
||||||
const defined = (value, fallback) => typeof value != "undefined" ? value : fallback
|
const defined = (value, fallback) => typeof value != "undefined" ? value : fallback
|
||||||
const getCustom = args => String(
|
const getCustom = args => args.reduce(
|
||||||
args.reduce(
|
(current, argument) => Array.isArray(argument)
|
||||||
(current, argument) => Array.isArray(argument)
|
? defined(getCustom(argument), current)
|
||||||
? defined(getCustom(argument), current)
|
: (argument && typeof argument == "object")
|
||||||
: (argument && typeof argument == "object")
|
? defined(argument.is, current)
|
||||||
? defined(argument.is, current)
|
: current
|
||||||
: current
|
,undefined
|
||||||
,null
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const parseArgs = (element, before, ...args) => {
|
const parseArgs = (element, before, ...args) => {
|
||||||
|
@ -79,11 +77,13 @@ const parseArgs = (element, before, ...args) => {
|
||||||
const node = (name, args, options) => {
|
const node = (name, args, options) => {
|
||||||
let element
|
let element
|
||||||
const custom = getCustom(args)
|
const custom = getCustom(args)
|
||||||
|
const opts = custom && {is: String(custom)}
|
||||||
|
|
||||||
if ("nameFilter" in options) name = options.nameFilter(name)
|
if ("nameFilter" in options) name = options.nameFilter(name)
|
||||||
if (options.xmlns)
|
if (options.xmlns)
|
||||||
element = document.createElementNS(options.xmlns, name, custom ?? {is: custom})
|
element = document.createElementNS(options.xmlns, name, opts)
|
||||||
else
|
else
|
||||||
element = document.createElement(name, custom ?? {is: custom})
|
element = document.createElement(name, opts)
|
||||||
parseArgs(element, null, args)
|
parseArgs(element, null, args)
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue