From 3f1bc4e33a63ef3517f61003f77212faac5f74d7 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Mon, 1 Feb 2016 23:31:03 +0100 Subject: [PATCH 1/5] Support dynamic functions for computed annotations. Alternate take for #3299 --- src/standard/annotations.html | 13 +++++++++++-- test/unit/bind-elements.html | 32 ++++++++++++++++++++++++++++++++ test/unit/bind.html | 30 ++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/standard/annotations.html b/src/standard/annotations.html index 7c845c67..7ec8548f 100644 --- a/src/standard/annotations.html +++ b/src/standard/annotations.html @@ -145,8 +145,17 @@ TODO(sjmiles): this module should produce either syntactic metadata for (var k=0; k + + + + + diff --git a/test/unit/bind.html b/test/unit/bind.html index 1bd95331..752b5cfe 100644 --- a/test/unit/bind.html +++ b/test/unit/bind.html @@ -285,6 +285,36 @@ suite('single-element binding effects', function() { + + From b6abf26fdaf669451d1cfdbc20b735d9cc8be41b Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 12 Feb 2016 13:30:08 +0100 Subject: [PATCH 4/5] Add support for properties defined in a behavior. For correctness this is implemented using `getPropertyInfo()` though this is not optimized at all. Note that `_propertyInfo` is not ready when we parse the annotations (which is the earliest call to `_parseMethod` right now). There are several options to make this right, but these are not part of this feature PR. --- src/standard/effectBuilder.html | 3 +- test/unit/bind-elements.html | 49 +++++++++++++++++++-------------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/standard/effectBuilder.html b/src/standard/effectBuilder.html index 749addc0..a932974c 100644 --- a/src/standard/effectBuilder.html +++ b/src/standard/effectBuilder.html @@ -227,7 +227,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN var m = expression.match(/([^\s]+?)\(([\s\S]*)\)/); if (m) { var sig = { method: m[1], static: true }; - if (this.properties[sig.method]) { + // TODO(kaste): Optimize/memoize `getPropertyInfo`. + if (this.getPropertyInfo(sig.method) !== Polymer.nob) { sig.static = false; sig.dynamicFn = true; } diff --git a/test/unit/bind-elements.html b/test/unit/bind-elements.html index a39e9858..b7f61ca6 100644 --- a/test/unit/bind-elements.html +++ b/test/unit/bind-elements.html @@ -588,29 +588,36 @@
[[translate('Hello World.')]]
- + \ No newline at end of file From 0037c535c84d2f8f226625cb7a0288f2a3583e01 Mon Sep 17 00:00:00 2001 From: herr kaste Date: Fri, 12 Feb 2016 22:38:20 +0100 Subject: [PATCH 5/5] Add test that late resolved functions don't warn --- test/unit/bind-elements.html | 31 +++++++++++++++++++++++++++++++ test/unit/bind.html | 13 +++++++++++++ 2 files changed, 44 insertions(+) diff --git a/test/unit/bind-elements.html b/test/unit/bind-elements.html index b7f61ca6..f2ae5034 100644 --- a/test/unit/bind-elements.html +++ b/test/unit/bind-elements.html @@ -620,4 +620,35 @@ }); })(); + + + + + \ No newline at end of file diff --git a/test/unit/bind.html b/test/unit/bind.html index a7f853f8..2f3f1160 100644 --- a/test/unit/bind.html +++ b/test/unit/bind.html @@ -310,6 +310,19 @@ suite('computed bindings with dynamic functions', function() { assert.equal(el.$.check.textContent, 'changed: Hello World.'); }); + test('annotated computation / late resolved dynamic function', function() { + el = document.createElement('x-bind-computed-property-late-translator'); + document.body.appendChild(el); + + assert.equal(el.$.check.textContent.trim(), ''); + + el.translator = function(message) { + return 'translated: ' + message; + }; + + assert.equal(el.$.check.textContent, 'translated: Hello'); + }); + test('observer with dynamic function', function() { Polymer({ is: 'x-observer-with-dynamic-function',