Add text wrapper to skooma.js

This commit is contained in:
Talia 2021-11-23 16:27:25 +01:00
parent 6094fd602d
commit b440eec373
Signed by: darkwiiplayer
GPG key ID: 7808674088232B3E
2 changed files with 9 additions and 0 deletions

View file

@ -87,3 +87,5 @@ 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 text = (data="") => document.createTextNode(data)

View file

@ -38,6 +38,13 @@ html.div({foo: "bar"}, {foo: false})
html.div(dataset: {foo: 1, bar: 2}) // Creates a <div> with the attributes "data-foo" and "data-bar" set to 1 and 2 html.div(style: {color: 'red'}) // Creates a <div> with the "style" attribute set to "color: red" html.div(dataset: {foo: 1, bar: 2}) // Creates a <div> with the attributes "data-foo" and "data-bar" set to 1 and 2 html.div(style: {color: 'red'}) // Creates a <div> with the "style" attribute set to "color: red"
``` ```
```js
text("Hello, World")
// Wraps document.createTextNode
text()
// Defaults to empty string
```
Generators can be called with many arguments. Arrays get iterated recursively as Generators can be called with many arguments. Arrays get iterated recursively as
if they were part of a flat argument list. if they were part of a flat argument list.