Add fragment helper to skooma.js

This commit is contained in:
Talia 2022-06-22 15:51:03 +02:00
parent 0f2e596c54
commit 4128cb53aa
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E

View file

@ -113,6 +113,13 @@ export const handle = fn => event => { event.preventDefault(); return fn(event)
export const html = nameSpacedProxy({nameFilter: name => name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}) export const html = nameSpacedProxy({nameFilter: name => name.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()})
export const svg = nameSpacedProxy({xmlns: "http://www.w3.org/2000/svg"}) export const svg = nameSpacedProxy({xmlns: "http://www.w3.org/2000/svg"})
export const fragment = (...elements) => {
const fragment = new DocumentFragment()
for (element of elements)
fragment.append(element)
return fragment
}
const textFromTemplate = (literals, items) => { const textFromTemplate = (literals, items) => {
const fragment = new DocumentFragment() const fragment = new DocumentFragment()
for (const key in items) { for (const key in items) {