| OLD | NEW |
| (Empty) |
| 1 | |
| 2 | |
| 3 Polymer.Base.extend(Polymer.Bind, { | |
| 4 | |
| 5 _shouldAddListener: function(effect) { | |
| 6 return effect.name && | |
| 7 effect.mode === '{' && | |
| 8 !effect.negate && | |
| 9 effect.kind != 'attribute' | |
| 10 ; | |
| 11 }, | |
| 12 | |
| 13 annotationEffect: function(source, value, effect) { | |
| 14 if (source != effect.value) { | |
| 15 value = this.getPathValue(effect.value); | |
| 16 this._data[effect.value] = value; | |
| 17 } | |
| 18 var calc = effect.negate ? !value : value; | |
| 19 return this._applyEffectValue(calc, effect); | |
| 20 }, | |
| 21 | |
| 22 reflectEffect: function(source) { | |
| 23 this.reflectPropertyToAttribute(source); | |
| 24 }, | |
| 25 | |
| 26 notifyEffect: function(source) { | |
| 27 this._notifyChange(source); | |
| 28 }, | |
| 29 | |
| 30 // Raw effect for extension; effect.function is an actual function | |
| 31 functionEffect: function(source, value, effect, old) { | |
| 32 effect.function.call(this, source, value, effect, old); | |
| 33 }, | |
| 34 | |
| 35 observerEffect: function(source, value, effect, old) { | |
| 36 this[effect.method](value, old); | |
| 37 }, | |
| 38 | |
| 39 complexObserverEffect: function(source, value, effect) { | |
| 40 var args = Polymer.Bind._marshalArgs(this._data, effect, source, value); | |
| 41 if (args) { | |
| 42 this[effect.method].apply(this, args); | |
| 43 } | |
| 44 }, | |
| 45 | |
| 46 computeEffect: function(source, value, effect) { | |
| 47 var args = Polymer.Bind._marshalArgs(this._data, effect, source, value); | |
| 48 if (args) { | |
| 49 this[effect.property] = this[effect.method].apply(this, args); | |
| 50 } | |
| 51 }, | |
| 52 | |
| 53 annotatedComputationEffect: function(source, value, effect) { | |
| 54 var args = Polymer.Bind._marshalArgs(this._data, effect, source, value); | |
| 55 if (args) { | |
| 56 var computedHost = this._rootDataHost || this; | |
| 57 var computedvalue = | |
| 58 computedHost[effect.method].apply(computedHost, args); | |
| 59 this._applyEffectValue(computedvalue, effect); | |
| 60 } | |
| 61 }, | |
| 62 | |
| 63 // path & value are used to fill in wildcard descriptor when effect is | |
| 64 // being called as a result of a path notification | |
| 65 _marshalArgs: function(model, effect, path, value) { | |
| 66 var values = []; | |
| 67 var args = effect.args; | |
| 68 for (var i=0, l=args.length; i<l; i++) { | |
| 69 var arg = args[i]; | |
| 70 var name = arg.name; | |
| 71 var v = arg.structured ? | |
| 72 Polymer.Base.getPathValue(name, model) : model[name]; | |
| 73 if (v === undefined) { | |
| 74 return; | |
| 75 } | |
| 76 if (arg.wildcard) { | |
| 77 // Only send the actual path changed info if the change that | |
| 78 // caused the observer to run matched the wildcard | |
| 79 var baseChanged = (name.indexOf(path + '.') === 0); | |
| 80 var matches = (effect.arg.name.indexOf(name) === 0 && !baseChanged); | |
| 81 values[i] = { | |
| 82 path: matches ? path : name, | |
| 83 value: matches ? value : v, | |
| 84 base: v | |
| 85 }; | |
| 86 } else { | |
| 87 values[i] = v; | |
| 88 } | |
| 89 } | |
| 90 return values; | |
| 91 } | |
| 92 | |
| 93 }); | |
| 94 | |
| OLD | NEW |