From 7a860031a469adda050aea1689221cbb690833e5 Mon Sep 17 00:00:00 2001 From: theboolean Date: Wed, 10 May 2017 22:47:35 +0200 Subject: [PATCH] Add an escape sequence to avoid polymer to bind the content of brackets --- lib/mixins/property-effects.html | 86 ++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 129cd73eb8..e9cf8e22ec 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -788,7 +788,7 @@ '(?:' + ARGUMENTS + '?' + ')' + '\\)\\s*' + ')'; const BINDING = '(' + IDENT + '\\s*' + ARGUMENT_LIST + '?' + ')'; // Group 3 - const OPEN_BRACKET = '(\\[\\[|{{)' + '\\s*'; + const OPEN_BRACKET = '(\\[\\[\\\\*|{{\\\\*)' + '\\s*'; const CLOSE_BRACKET = '(?:]]|}})'; const NEGATE = '(?:(!)\\s*)?'; // Group 2 const EXPRESSION = OPEN_BRACKET + NEGATE + BINDING + CLOSE_BRACKET; @@ -2290,51 +2290,63 @@ let parts = []; let lastIndex = 0; let m; - // Example: "literal1{{prop}}literal2[[!compute(foo,bar)]]final" - // Regex matches: - // Iteration 1: Iteration 2: - // m[1]: '{{' '[[' - // m[2]: '' '!' - // m[3]: 'prop' 'compute(foo,bar)' + // Example: "literal1{{prop}}literal2[[!compute(foo,bar)]]literal3{{\!prop}}final" + // Regex matches: + // Iteration 1: Iteration 2: Iteration 3: + // m[1]: '{{' '[[' '{{\' + // m[2]: '' '!' '!' + // m[3]: 'prop' 'compute(foo,bar)' 'prop' while ((m = bindingRegex.exec(text)) !== null) { // Add literal part if (m.index > lastIndex) { parts.push({literal: text.slice(lastIndex, m.index)}); } - // Add binding part - let mode = m[1][0]; - let negate = Boolean(m[2]); - let source = m[3].trim(); - let customEvent, notifyEvent, colon; - if (mode == '{' && (colon = source.indexOf('::')) > 0) { - notifyEvent = source.substring(colon + 2); - source = source.substring(0, colon); - customEvent = true; - } - let signature = parseMethod(source); - let dependencies = []; - if (signature) { - // Inline computed function - let {args, methodName} = signature; - for (let i=0; i 0) { + notifyEvent = source.substring(colon + 2); + source = source.substring(0, colon); + customEvent = true; } - let dynamicFns = templateInfo.dynamicFns; - if (dynamicFns && dynamicFns[methodName] || signature.static) { - dependencies.push(methodName); - signature.dynamicFn = true; + let signature = parseMethod(source); + let dependencies = []; + if (signature) { + // Inline computed function + let {args, methodName} = signature; + for (let i=0; i