Skip to content

Commit

Permalink
Merge pull request #3354 from kaste/patch-1
Browse files Browse the repository at this point in the history
Fix: There is no effect of kind 'computedAnnotation'
  • Loading branch information
kevinpschaaf committed Feb 12, 2016
2 parents a4cc272 + db7c324 commit de039f8
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/bind/accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
var EFFECT_ORDER = {
'compute': 0,
'annotation': 1,
'computedAnnotation': 2,
'annotatedComputation': 2,
'reflect': 3,
'notify': 4,
'observer': 5,
Expand Down
90 changes: 90 additions & 0 deletions test/unit/bind-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
26 changes: 26 additions & 0 deletions test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,32 @@

});

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>
Expand Down

0 comments on commit de039f8

Please sign in to comment.