mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3354 from kaste/patch-1
Fix: There is no effect of kind 'computedAnnotation'
This commit is contained in:
commit
de039f8603
@ -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,
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user