Skip to content

Commit

Permalink
Only store method once for dynamic functions
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Feb 25, 2018
1 parent a4d4eb9 commit 0f0ccda
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/mixins/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -2797,4 +2797,4 @@
};

})();
</script>
</script>
1 change: 0 additions & 1 deletion lib/mixins/strict-binding-parser.html
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
storeMethodVariable(bindingData, text, i);
storeMethod(bindingData, templateInfo);
bindingData.startChar = i + 1;
storeMethod(bindingData, templateInfo);
state = STATE.METHODCLOSED;
break;
}
Expand Down
10 changes: 8 additions & 2 deletions test/unit/property-effects-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
compoundAttr2$="literal1 {{cpnd1}} literal2 {{cpnd2}}{{cpnd3.prop}} literal3 {{computeCompound(cpnd4, cpnd5, 'literalComputed')}} literal4"
compoundAttr3$="[yes/no]: {{cpnd1}}, {{computeCompound('world', 'username ', 'Hello {0} ')}}"
computed-from-behavior="{{computeFromBehavior(value)}}"
computed-dynamic-fn="{{dynamicFn('hello', 'username')}}"
>
Test
<!-- Malformed bindings to be ignored -->
Expand Down Expand Up @@ -82,7 +83,7 @@
content: '[[binding]]'
}
</style>
<span id="boundWithSlash">[[objectWithSlash.binding/with/slash]]</span>
<span id="boundWithSlash">[[objectWithSlash.binding/with/slash]]</span>
<span id="jsonContent">[["Jan", 31],["Feb", 28],["Mar", 31]]</span>
<span id="nonEnglishUnicode">{{objectWithNonEnglishUnicode.商品名}}</span>
<span id="booleanTrue">foo(field, true): {{computeWithBoolean(otherValue, true)}}</span>
Expand Down Expand Up @@ -181,6 +182,9 @@
},
title: {
observer: 'titleChanged'
},
dynamicFn: {
type: Function
}
},
observers: [
Expand All @@ -202,6 +206,7 @@
notifierWithoutComputingChanged: 0
};
this.titleChanged = sinon.spy();
this._dynamicFnCalled = false;
},
ready: function() {
this.isReady = true;
Expand Down Expand Up @@ -328,7 +333,8 @@
this.customNotifyingValue = 'changed!';
this.dispatchEvent(new CustomEvent('custom-notifying-value-changed'),
{value: this.customNotifyingValue});
}
},
dynamicFn: function() {}
});

HTMLImports.whenReady(() => {
Expand Down
7 changes: 7 additions & 0 deletions test/unit/property-effects.html
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,13 @@
}
});

test('only calls dynamic functions once', function() {
el.dynamicFn = function() {
assert.isFalse(this._dynamicFnCalled);
this._dynamicFnCalled = true;
};
});

suite('observer inheritance', function() {
setup(function() {
el = document.createElement('sub-observer-element');
Expand Down

0 comments on commit 0f0ccda

Please sign in to comment.