Allow returning text in skooma bind method
This commit is contained in:
parent
633332d4ea
commit
e7afbaf3c1
1 changed files with 10 additions and 5 deletions
15
skooma.js
15
skooma.js
|
@ -81,9 +81,9 @@ const node = (name, args, options) => {
|
||||||
const custom = getCustom(args)
|
const custom = getCustom(args)
|
||||||
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, {is: custom})
|
element = document.createElementNS(options.xmlns, name, custom ?? {is: custom})
|
||||||
else
|
else
|
||||||
element = document.createElement(name, {is: custom})
|
element = document.createElement(name, custom ?? {is: custom})
|
||||||
parseArgs(element, null, args)
|
parseArgs(element, null, args)
|
||||||
return element
|
return element
|
||||||
}
|
}
|
||||||
|
@ -104,9 +104,14 @@ export const bind = transform => {
|
||||||
const update = (...data) => {
|
const update = (...data) => {
|
||||||
const next = transform(...data)
|
const next = transform(...data)
|
||||||
if (next) {
|
if (next) {
|
||||||
if (element) element.replaceWith(next)
|
if (typeof next == "string") {
|
||||||
element = inject(next)
|
element.innerText = next
|
||||||
return element
|
return element
|
||||||
|
} else {
|
||||||
|
if (element) element.replaceWith(next)
|
||||||
|
element = inject(next)
|
||||||
|
return element
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return update
|
return update
|
||||||
|
|
Loading…
Reference in a new issue