diff --git a/mithril.js b/mithril.js index 7ec24ab1..7ab4dcd3 100644 --- a/mithril.js +++ b/mithril.js @@ -152,7 +152,7 @@ args[i - 1] = arguments[i] } - if (isObject(tag)) return parameterize(tag, args) + if (tag && isFunction(tag.view)) return parameterize(tag, args) if (!isString(tag)) { throw new Error("selector in m(selector, attrs, children) should " + diff --git a/test/mithril.js b/test/mithril.js index 88111f51..1e9cbcfa 100644 --- a/test/mithril.js +++ b/test/mithril.js @@ -217,4 +217,12 @@ describe("m()", function () { m.component(component, args).controller() 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() + }) })