diff --git a/src/view/is-node.js b/src/view/is-node.js index b50225ba..dc1a1577 100644 --- a/src/view/is-node.js +++ b/src/view/is-node.js @@ -39,7 +39,7 @@ function IsNode(aNode, parent, scope, owner, hydrateWalker) { this.tagName = this.aNode.tagName; // #[begin] hydrate if (hydrateWalker) { - this.cmpt = evalExpr(this.aNode.directives.is.value, this.scope) || this.tagName; + this.cmpt = evalExpr(this.aNode.directives.is.value, this.scope, this.owner) || this.tagName; this.children[0] = createHydrateNode( this.aNode.isRinsed, this, @@ -63,7 +63,7 @@ IsNode.prototype.dispose = nodeOwnSimpleDispose; * @param {HTMLElement=} beforeEl 要添加到哪个元素之前 */ IsNode.prototype.attach = function (parentEl, beforeEl) { - this.cmpt = evalExpr(this.aNode.directives.is.value, this.scope) || this.tagName; + this.cmpt = evalExpr(this.aNode.directives.is.value, this.scope, this.owner) || this.tagName; var child = createNode(this.aNode.isRinsed, this, this.scope, this.owner, this.cmpt); this.children[0] = child; @@ -77,7 +77,7 @@ IsNode.prototype.attach = function (parentEl, beforeEl) { */ IsNode.prototype._update = function (changes) { var child = this.children[0]; - var cmpt = evalExpr(this.aNode.directives.is.value, this.scope) || this.tagName; + var cmpt = evalExpr(this.aNode.directives.is.value, this.scope, this.owner) || this.tagName; if (cmpt === this.cmpt) { child._update(changes); diff --git a/test/component.spec.js b/test/component.spec.js index 8289f7ec..8e0caab4 100644 --- a/test/component.spec.js +++ b/test/component.spec.js @@ -966,6 +966,99 @@ describe("Component", function () { }); }); + it("s-is use component method", function () { + var Label = san.defineComponent({ + template: '{{text}}', + initData: function () { + return { + text: 'erik' + } + } + }); + + var MyComponent = san.defineComponent({ + components: { + 'x-label': Label + }, + initData: function () { + return { + type: 'label' + } + }, + getComponentName: function (type) { + return 'x-' + type; + }, + template: '