Merge pull request #1144 from ludbek/proper.component
proper component check at m()
This commit is contained in:
commit
0039a0b4a5
2 changed files with 9 additions and 1 deletions
|
|
@ -152,7 +152,7 @@
|
||||||
args[i - 1] = arguments[i]
|
args[i - 1] = arguments[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isObject(tag)) return parameterize(tag, args)
|
if (tag && isFunction(tag.view)) return parameterize(tag, args)
|
||||||
|
|
||||||
if (!isString(tag)) {
|
if (!isString(tag)) {
|
||||||
throw new Error("selector in m(selector, attrs, children) should " +
|
throw new Error("selector in m(selector, attrs, children) should " +
|
||||||
|
|
|
||||||
|
|
@ -217,4 +217,12 @@ describe("m()", function () {
|
||||||
m.component(component, args).controller()
|
m.component(component, args).controller()
|
||||||
expect(spy.secondCall).to.have.been.calledWith(args)
|
expect(spy.secondCall).to.have.been.calledWith(args)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("does not proxy to m.component() if the object does not have .view() method", function () {
|
||||||
|
var component = {}
|
||||||
|
|
||||||
|
var args = {age: 12}
|
||||||
|
|
||||||
|
expect(m.bind(m, component, args)).to.throw()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue