Remove listener.bindContent function

Not only was this function really ugly and complicated to use, it also
does essentially the same as the new listener.text function.
This commit is contained in:
Talia 2021-12-26 17:49:49 +01:00
parent b060b5eb09
commit 4a473df213
No known key found for this signature in database
GPG key ID: AD727AD22802D0D6
2 changed files with 0 additions and 33 deletions

View file

@ -39,24 +39,6 @@ export const listener = (target={}) => {
return proxy return proxy
} }
export const bindContent = (listener, prop="value", target=document.createTextNode(""), filter) => {
const run = data => {
data = filter
? filter(data)
: data
if ("innerText" in target)
if (typeof data == "string")
target.innerText = data
else
target.replaceChildren(data)
else
target.data = data
}
listener.listen(prop, run)
run(listener[prop])
return target
}
export const text = (listener, prop) => { export const text = (listener, prop) => {
if (prop) { if (prop) {
const node = document.createTextNode(listener[prop]) const node = document.createTextNode(listener[prop])

View file

@ -33,21 +33,6 @@ property name.
Note that repeatedly indexing the proxy will return a new text node each time. Note that repeatedly indexing the proxy will return a new text node each time.
```js
bindContent(listener, "value")
// Returns a text node with listener.value as its content
// that will change whenever the value is changed
bindContent(listener, "value", html_element)
// Binds an existng HTML or Text node
bindContent(listener, "value", html_element, value => value.toUpperCase())
// Accepts a function to transform the value
bindContent(listener, "value", html_element, value => document.createElement("hr"))
// Also accepts HTML elements when the target is not a text node
```
This function *may* be **removed** in the future if it doesn't show any
usefullnes that isn't already provided by the skooma bind function.
## Example ## Example
```js ```js