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
|
|
@ -1,17 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<script src="../../module/module.js"></script>
|
||||
<script src="../../ospec/ospec.js"></script>
|
||||
|
||||
<script src="../../util/withAttr.js"></script>
|
||||
<script src="../../util/prop.js"></script>
|
||||
<script src="test-withAttr.js"></script>
|
||||
<script src="test-prop.js"></script>
|
||||
|
||||
<script>require("../../ospec/ospec").run()</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
"use strict"
|
||||
|
||||
var o = require("../../ospec/ospec")
|
||||
var prop = require("../../util/prop")
|
||||
|
||||
o.spec("prop", function() {
|
||||
o("works", function() {
|
||||
var p = prop(1)
|
||||
|
||||
o(p.get()).equals(1)
|
||||
o(p.toJSON()).equals(1)
|
||||
o(p.set(2)).equals(2)
|
||||
o(p.get()).equals(2)
|
||||
o(p.toJSON()).equals(2)
|
||||
})
|
||||
})
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
"use strict"
|
||||
|
||||
var o = require("../../ospec/ospec")
|
||||
var withAttr = require("../../util/withAttr")
|
||||
|
||||
o.spec("withAttr", function() {
|
||||
o("works", function() {
|
||||
var spy = o.spy()
|
||||
var context = {
|
||||
handler: withAttr("value", spy)
|
||||
}
|
||||
context.handler({currentTarget: {value: 1}})
|
||||
|
||||
o(spy.args).deepEquals([1])
|
||||
o(spy.this).equals(context)
|
||||
})
|
||||
o("works with attribute", function() {
|
||||
var target = {
|
||||
getAttribute: function() {return "readonly"}
|
||||
}
|
||||
var spy = o.spy()
|
||||
var context = {
|
||||
handler: withAttr("readonly", spy)
|
||||
}
|
||||
context.handler({currentTarget: target})
|
||||
|
||||
o(spy.args).deepEquals(["readonly"])
|
||||
o(spy.this).equals(context)
|
||||
})
|
||||
o("context arg works", function() {
|
||||
var spy = o.spy()
|
||||
var context = {}
|
||||
var handler = withAttr("value", spy, context)
|
||||
handler({currentTarget: {value: 1}})
|
||||
|
||||
o(spy.this).equals(context)
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue