Skip to content

Commit de039f8

Browse files
committed
Merge pull request #3354 from kaste/patch-1
Fix: There is no effect of kind 'computedAnnotation'
2 parents a4cc272 + db7c324 commit de039f8

File tree

3 files changed

+117
-1
lines changed

3 files changed

+117
-1
lines changed

src/lib/bind/accessors.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
var EFFECT_ORDER = {
144144
'compute': 0,
145145
'annotation': 1,
146-
'computedAnnotation': 2,
146+
'annotatedComputation': 2,
147147
'reflect': 3,
148148
'notify': 4,
149149
'observer': 5,

test/unit/bind-elements.html

+90
Original file line numberDiff line numberDiff line change
@@ -492,3 +492,93 @@
492492
});
493493
</script>
494494
</dom-module>
495+
496+
<dom-module id="x-order-of-effects-grand-parent">
497+
<template>
498+
<x-order-of-effects id="child" base="{{base}}"></x-order-of-effects>
499+
</template>
500+
</dom-module>
501+
502+
<dom-module id="x-order-of-effects">
503+
<template>
504+
<x-order-of-effects-child
505+
prop1="[[base]]"
506+
prop2="[[_computedAnnotation(base)]]"
507+
></x-order-of-effects-child>
508+
</template>
509+
<script>
510+
(function() {
511+
var invocations = [];
512+
Polymer({
513+
is: 'x-order-of-effects-grand-parent',
514+
properties: {
515+
base: {
516+
observer: '_childPropertyChanged'
517+
}
518+
},
519+
_childPropertyChanged: function() {
520+
invocations.push('notify');
521+
}
522+
});
523+
Polymer({
524+
is: 'x-order-of-effects',
525+
properties: {
526+
base: {
527+
type: String,
528+
observer: '_observer',
529+
notify: true,
530+
reflectToAttribute: true
531+
},
532+
computed: {
533+
type: String,
534+
computed: '_computed(base)'
535+
},
536+
complex: {
537+
type: String,
538+
value: 'complex'
539+
}
540+
},
541+
observers: ['_complexObserver(complex, base)'],
542+
ready: function() {
543+
this.invocations = invocations;
544+
545+
var old = this.reflectPropertyToAttribute.bind(this);
546+
this.reflectPropertyToAttribute = function(property, attribute, value) {
547+
invocations.push('reflect');
548+
old(property, attribute, value);
549+
};
550+
},
551+
_computed: function(base) {
552+
invocations.push('compute');
553+
return base;
554+
},
555+
_computedAnnotation: function(base) {
556+
return base;
557+
},
558+
_observer: function() {
559+
invocations.push('observer');
560+
},
561+
_complexObserver: function() {
562+
invocations.push('complexObserver');
563+
}
564+
});
565+
Polymer({
566+
is: 'x-order-of-effects-child',
567+
properties: {
568+
prop1: {
569+
observer: '_prop1Changed'
570+
},
571+
prop2: {
572+
observer: '_prop2Changed'
573+
}
574+
},
575+
_prop1Changed: function() {
576+
invocations.push('annotation');
577+
},
578+
_prop2Changed: function() {
579+
invocations.push('annotatedComputation');
580+
}
581+
});
582+
})();
583+
</script>
584+
</dom-module>

test/unit/bind.html

+26
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,32 @@
859859

860860
});
861861

862+
suite('order of effects', function() {
863+
864+
var el;
865+
866+
setup(function() {
867+
el = document.createElement('x-order-of-effects-grand-parent').$.child;
868+
});
869+
870+
test('effects are sorted', function() {
871+
assert.equal(el.invocations.length, 0);
872+
el.base = 'changed';
873+
874+
var expected = [
875+
'compute',
876+
'annotation', // as observed by child
877+
'annotatedComputation', // as observed by child
878+
'reflect',
879+
'notify', // as observed by grand-parent
880+
'observer',
881+
'complexObserver'
882+
];
883+
884+
assert.deepEqual(el.invocations, expected);
885+
});
886+
});
887+
862888
</script>
863889

864890
</body>

0 commit comments

Comments
 (0)