Remove m.prop + m.withAttr (#2317)
* Remove `m.prop` + `m.withAttr` - For many uses, `m.withAttr` is *more* verbose than just directly using an event handler - If you're using it with a bound callback, you're literally wasting a single character in the human readable version (and you're *saving* them in the minified output). - It sometimes obscures your intent, if overused. - Functions are easier to compress than `m.withAttr`, resulting in slightly smaller bundles. - `m.withAttr` is overused anyways. - `m.prop` is basically useless without `m.withAttr`, and the API doesn't have the same benefits it had with 0.2.x. * Update changelog
This commit is contained in:
parent
86c16820f7
commit
26b8d994ce
18 changed files with 28 additions and 445 deletions
42
docs/api.md
42
docs/api.md
|
|
@ -121,48 +121,6 @@ var querystring = m.buildQueryString({a: "1", b: "2"})
|
|||
|
||||
---
|
||||
|
||||
#### m.withAttr(attrName, callback) - [docs](withAttr.md)
|
||||
|
||||
```javascript
|
||||
var state = {
|
||||
value: "",
|
||||
setValue: function(v) {state.value = v}
|
||||
}
|
||||
|
||||
var Component = {
|
||||
view: function() {
|
||||
return m("input", {
|
||||
oninput: m.withAttr("value", state.setValue),
|
||||
value: state.value,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
m.mount(document.body, Component)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### m.prop(initial) - [docs](prop.md)
|
||||
|
||||
```javascript
|
||||
var Component = {
|
||||
oninit: function(vnode) {
|
||||
vnode.state.current = m.prop("")
|
||||
},
|
||||
view: function(vnode) {
|
||||
return m("input", {
|
||||
oninput: function(ev) { vnode.state.current.set(ev.target.value) },
|
||||
value: vnode.state.current.get(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
m.mount(document.body, Component)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### m.trust(htmlString) - [docs](trust.md)
|
||||
|
||||
```javascript
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue