This repository was archived by the owner on Mar 13, 2018. It is now read-only.
File tree 2 files changed +37
-1
lines changed
2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 437
437
return this . getValue ( model , undefined , filterRegistry ) ;
438
438
439
439
var observer = new CompoundObserver ( ) ;
440
- this . getValue ( model , observer , filterRegistry ) ; // captures deps.
440
+ // captures deps.
441
+ var firstValue = this . getValue ( model , observer , filterRegistry ) ;
442
+ var firstTime = true ;
441
443
var self = this ;
442
444
443
445
function valueFn ( ) {
446
+ // deps cannot have changed on first value retrieval.
447
+ if ( firstTime ) {
448
+ firstTime = false ;
449
+ return firstValue ;
450
+ }
451
+
444
452
if ( self . dynamicDeps )
445
453
observer . startReset ( ) ;
446
454
Original file line number Diff line number Diff line change @@ -106,6 +106,9 @@ suite('PolymerExpressions', function() {
106
106
delegate . upperCase = function ( value ) {
107
107
return String ( value ) . toUpperCase ( ) ;
108
108
} ;
109
+ delegate . incrProp = function ( value , obj , propName ) {
110
+ obj [ propName ] ++ ;
111
+ } ;
109
112
// filter as full object with toDOM and toModel properties
110
113
delegate . plusN = {
111
114
toDOM : function ( value , n ) {
@@ -918,6 +921,31 @@ suite('PolymerExpressions', function() {
918
921
} ) ;
919
922
} ) ;
920
923
924
+ test ( 'Expression execution count' , function ( done ) {
925
+ var div = createTestHtml (
926
+ '<template bind>' +
927
+ '{{ dep | incrProp(obj, "count") }}' +
928
+ '</template>' ) ;
929
+
930
+ var model = {
931
+ dep : 1 ,
932
+ obj : { count : 0 }
933
+ } ;
934
+
935
+ recursivelySetTemplateModel ( div , model ) ;
936
+
937
+ then ( function ( ) {
938
+ assert . equal ( 1 , model . obj . count ) ;
939
+ model . dep ++ ;
940
+
941
+ } ) . then ( function ( ) {
942
+ assert . equal ( 2 , model . obj . count ) ;
943
+
944
+ done ( ) ;
945
+ } ) ;
946
+ } ) ;
947
+
948
+
921
949
test ( 'chained filters' , function ( done ) {
922
950
var div = createTestHtml (
923
951
'<template bind="{{ }}">' +
You can’t perform that action at this time.
0 commit comments