diff --git a/bower.json b/bower.json index ae2bcf5033..ea5e637ce2 100644 --- a/bower.json +++ b/bower.json @@ -26,7 +26,8 @@ "devDependencies": { "web-component-tester": "^6.0.0", "test-fixture": "PolymerElements/test-fixture#3.0.0-rc.1", - "iron-component-page": "PolymerElements/iron-component-page#^3.0.1" + "iron-component-page": "PolymerElements/iron-component-page#^3.0.1", + "perf-tester": "polymerlabs/perf-tester" }, "private": true, "resolutions": { diff --git a/externs/closure-types.js b/externs/closure-types.js index e97a702165..8e7f3dd19a 100644 --- a/externs/closure-types.js +++ b/externs/closure-types.js @@ -1379,6 +1379,17 @@ Polymer_ArraySelectorMixin.prototype.select = function(item){}; Polymer_ArraySelectorMixin.prototype.selectIndex = function(idx){}; /** * @interface +* @extends {Polymer_PropertyEffects} +*/ +function Polymer_StrictBindingParser(){} +/** +* @param {string} text Text to parse from attribute or textContent +* @param {Object} templateInfo Current template metadata +* @return {Array.} +*/ +Polymer_StrictBindingParser._parseBindings = function(text, templateInfo){}; +/** +* @interface * @extends {Polymer_ElementMixin} */ function Polymer_DisableUpgradeMixin(){} diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 0feb7c9e41..d5c60613e2 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -2629,6 +2629,17 @@ * - Inline computed method (supports negation): * `[[compute(a, 'literal', b)]]`, `[[!compute(a, 'literal', b)]]` * + * The default implementation uses a regular expression for best + * performance. However, the regular expression uses a white-list of + * allowed characters in a data-binding, which causes problems for + * data-bindings that do use characters not in this white-list. + * + * Instead of updating the white-list with all allowed characters, + * there is a StrictBindingParser (see lib/mixins/strict-binding-parser) + * that uses a state machine instead. This state machine is able to handle + * all characters. However, it is slightly less performant, therefore we + * extracted it into a separate optional mixin. + * * @param {string} text Text to parse from attribute or textContent * @param {Object} templateInfo Current template metadata * @return {Array} Array of binding part metadata diff --git a/lib/mixins/strict-binding-parser.html b/lib/mixins/strict-binding-parser.html new file mode 100644 index 0000000000..03a3b3d278 --- /dev/null +++ b/lib/mixins/strict-binding-parser.html @@ -0,0 +1,419 @@ + + + + + + + diff --git a/test/perf/binding-expressions.html b/test/perf/binding-expressions.html new file mode 100644 index 0000000000..177a41f249 --- /dev/null +++ b/test/perf/binding-expressions.html @@ -0,0 +1,78 @@ + + +
+ + + + + + + + + + + + + + {{foo}} {{foo.bar}} {{foo.bar.zot}} + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non + proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + {{compute(tricky, 'literal\,\'zot\'')}} + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non + proident, sunt in culpa qui officia deserunt mollit anim id est laborum. + {{compute(tricky, 'literal\,\'zot\'', this.has.a.bogus.ending.bracket)]} + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non + proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +