Merge pull request #3354 from kaste/patch-1

Fix: There is no effect of kind 'computedAnnotation'
This commit is contained in:
Kevin Schaaf 2016-02-12 09:45:35 -08:00
commit de039f8603
3 changed files with 117 additions and 1 deletions

View File

@ -143,7 +143,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var EFFECT_ORDER = {
'compute': 0,
'annotation': 1,
'computedAnnotation': 2,
'annotatedComputation': 2,
'reflect': 3,
'notify': 4,
'observer': 5,

View File

@ -492,3 +492,93 @@
});
</script>
</dom-module>
<dom-module id="x-order-of-effects-grand-parent">
<template>
<x-order-of-effects id="child" base="{{base}}"></x-order-of-effects>
</template>
</dom-module>
<dom-module id="x-order-of-effects">
<template>
<x-order-of-effects-child
prop1="[[base]]"
prop2="[[_computedAnnotation(base)]]"
></x-order-of-effects-child>
</template>
<script>
(function() {
var invocations = [];
Polymer({
is: 'x-order-of-effects-grand-parent',
properties: {
base: {
observer: '_childPropertyChanged'
}
},
_childPropertyChanged: function() {
invocations.push('notify');
}
});
Polymer({
is: 'x-order-of-effects',
properties: {
base: {
type: String,
observer: '_observer',
notify: true,
reflectToAttribute: true
},
computed: {
type: String,
computed: '_computed(base)'
},
complex: {
type: String,
value: 'complex'
}
},
observers: ['_complexObserver(complex, base)'],
ready: function() {
this.invocations = invocations;
var old = this.reflectPropertyToAttribute.bind(this);
this.reflectPropertyToAttribute = function(property, attribute, value) {
invocations.push('reflect');
old(property, attribute, value);
};
},
_computed: function(base) {
invocations.push('compute');
return base;
},
_computedAnnotation: function(base) {
return base;
},
_observer: function() {
invocations.push('observer');
},
_complexObserver: function() {
invocations.push('complexObserver');
}
});
Polymer({
is: 'x-order-of-effects-child',
properties: {
prop1: {
observer: '_prop1Changed'
},
prop2: {
observer: '_prop2Changed'
}
},
_prop1Changed: function() {
invocations.push('annotation');
},
_prop2Changed: function() {
invocations.push('annotatedComputation');
}
});
})();
</script>
</dom-module>

View File

@ -859,6 +859,32 @@ suite('compound binding / string interpolation', function() {
});
suite('order of effects', function() {
var el;
setup(function() {
el = document.createElement('x-order-of-effects-grand-parent').$.child;
});
test('effects are sorted', function() {
assert.equal(el.invocations.length, 0);
el.base = 'changed';
var expected = [
'compute',
'annotation', // as observed by child
'annotatedComputation', // as observed by child
'reflect',
'notify', // as observed by grand-parent
'observer',
'complexObserver'
];
assert.deepEqual(el.invocations, expected);
});
});
</script>
</body>