diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 2321826b7e..4d92e7703b 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -189,7 +189,7 @@ let changedProp = info.property; if (fn) { fn.call(inst, inst.__data[changedProp], oldProps[changedProp]); - } else { + } else if (!info.dynamicFn) { console.warn('observer method `' + info.methodName + '` not defined'); } } @@ -1905,7 +1905,7 @@ * @protected */ _createPropertyObserver(property, methodName, dynamicFn) { - let info = { property, methodName }; + let info = { property, methodName, dynamicFn }; this._addPropertyEffect(property, TYPES.OBSERVE, { fn: runObserverEffect, info, trigger: {name: property} }); @@ -2317,6 +2317,7 @@ let dynamicFns = templateInfo.dynamicFns; if (dynamicFns && dynamicFns[methodName] || signature.static) { dependencies.push(methodName); + signature.dynamicFn = true; } } else { // Property or path diff --git a/test/unit/property-effects.html b/test/unit/property-effects.html index 1310ef0365..01761095e4 100644 --- a/test/unit/property-effects.html +++ b/test/unit/property-effects.html @@ -392,8 +392,13 @@ var el; + setup(function() { + sinon.spy(console, 'warn'); + }); + teardown(function() { document.body.removeChild(el); + console.warn.restore(); }); test('annotated computation with dynamic function', function() { @@ -407,6 +412,7 @@ }; assert.equal(el.$.check.textContent, 'changed: Hello World.'); + assert.equal(console.warn.callCount, 0); }); test('annotated computation / late resolved dynamic function', function() { @@ -420,6 +426,7 @@ }; assert.equal(el.$.check.textContent, 'translated: Hello'); + assert.equal(console.warn.callCount, 0); }); test('method observer with dynamic function', function() { @@ -444,7 +451,7 @@ el.translateMessage = sinon.spy(); assert.equal(el.translateMessage.callCount, 1); - + assert.equal(console.warn.callCount, 0); }); test('observer with dynamic function', function() { @@ -468,7 +475,7 @@ el.messageChanged = sinon.spy(); assert.equal(el.messageChanged.callCount, 1); - + assert.equal(console.warn.callCount, 0); }); test('computed property with dynamic function', function() { @@ -497,7 +504,7 @@ assert.equal(called, 1); assert.equal(el.computedValue, 'translated: Hello'); - + assert.equal(console.warn.callCount, 0); }); test('ensure annotator can pass dynamic fn to parent props', function(done) { @@ -507,6 +514,7 @@ setTimeout(function() { var check = el.root.querySelector('p'); assert.equal(check.textContent, 'text'); + assert.equal(console.warn.callCount, 0); done(); });