diff --git a/src/lib/bind/effects.html b/src/lib/bind/effects.html index 2f987fa1..52ed42ed 100644 --- a/src/lib/bind/effects.html +++ b/src/lib/bind/effects.html @@ -66,6 +66,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN if (args) { fn.apply(this, args); } + } else if (effect.dynamicFn) { + // dynamic functions can be just like every other property `undefined` + // so we MUST ignore an undefined value here. (That's totally the + // same guard we use within `_marshalArgs` and part of the spec.) } else { this._warn(this._logf('_complexObserverEffect', 'observer method `' + effect.method + '` not defined')); @@ -73,15 +77,20 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN }, _computeEffect: function(source, value, effect) { - var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value); - if (args) { - var fn = this[effect.method]; - if (fn) { - this.__setProperty(effect.name, fn.apply(this, args)); - } else { - this._warn(this._logf('_computeEffect', 'compute method `' + - effect.method + '` not defined')); + var fn = this[effect.method]; + if (fn) { + var args = Polymer.Bind._marshalArgs(this.__data__, effect, source, value); + if (args) { + var computedvalue = fn.apply(this, args); + this.__setProperty(effect.name, computedvalue); } + } else if (effect.dynamicFn) { + // dynamic functions can be just like every other property `undefined` + // so we MUST ignore an undefined value here. (That's totally the + // same guard we use within `_marshalArgs` and part of the spec.) + } else { + this._warn(this._logf('_computeEffect', 'compute method `' + + effect.method + '` not defined')); } }, @@ -97,6 +106,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN } this._applyEffectValue(effect, computedvalue); } + } else if (effect.dynamicFn) { + // dynamic functions can be just like every other property `undefined` + // so we MUST ignore an undefined value here. (That's totally the + // same guard we use within `_marshalArgs` and part of the spec.) } else { computedHost._warn(computedHost._logf('_annotatedComputationEffect', 'compute method `' + effect.method + '` not defined')); @@ -108,6 +121,9 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN _marshalArgs: function(model, effect, path, value) { var values = []; var args = effect.args; + // Actually we should return early as soon as we see an `undefined`, + // but dom-repeat relies on this behavior. + var bailoutEarly = (args.length > 1 || effect.dynamicFn); for (var i=0, l=args.length; i 1 && v === undefined) { + if (bailoutEarly && v === undefined) { return; } if (arg.wildcard) { diff --git a/src/standard/annotations.html b/src/standard/annotations.html index 7c845c67..3743c48a 100644 --- a/src/standard/annotations.html +++ b/src/standard/annotations.html @@ -145,8 +145,10 @@ TODO(sjmiles): this module should produce either syntactic metadata for (var k=0; k + + + + + + + + + + \ No newline at end of file diff --git a/test/unit/bind.html b/test/unit/bind.html index fcc31d15..d744ac07 100644 --- a/test/unit/bind.html +++ b/test/unit/bind.html @@ -285,6 +285,107 @@ suite('single-element binding effects', function() { + +