diff --git a/lib/mixins/property-effects.html b/lib/mixins/property-effects.html index 5d78c7cda8..032bc7797a 100644 --- a/lib/mixins/property-effects.html +++ b/lib/mixins/property-effects.html @@ -821,24 +821,6 @@ const emptyArray = []; - // Regular expressions used for binding - const IDENT = '(?:' + '[a-zA-Z_$][\\w.:$\\-*]*' + ')'; - const NUMBER = '(?:' + '[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?' + ')'; - const SQUOTE_STRING = '(?:' + '\'(?:[^\'\\\\]|\\\\.)*\'' + ')'; - const DQUOTE_STRING = '(?:' + '"(?:[^"\\\\]|\\\\.)*"' + ')'; - const STRING = '(?:' + SQUOTE_STRING + '|' + DQUOTE_STRING + ')'; - const ARGUMENT = '(?:(' + IDENT + '|' + NUMBER + '|' + STRING + ')\\s*' + ')'; - const ARGUMENTS = '(?:' + ARGUMENT + '(?:,\\s*' + ARGUMENT + ')*' + ')'; - const ARGUMENT_LIST = '(?:' + '\\(\\s*' + - '(?:' + ARGUMENTS + '?' + ')' + - '\\)\\s*' + ')'; - const BINDING = '(' + IDENT + '\\s*' + ARGUMENT_LIST + '?' + ')'; // Group 3 - const OPEN_BRACKET = '(\\[\\[|{{)' + '\\s*'; - const CLOSE_BRACKET = '(?:]]|}})'; - const NEGATE = '(?:(!)\\s*)?'; // Group 2 - const EXPRESSION = OPEN_BRACKET + NEGATE + BINDING + CLOSE_BRACKET; - const bindingRegex = new RegExp(EXPRESSION, "g"); - /** * Create a string from binding parts of all the literal parts * diff --git a/lib/utils/binding-parser.html b/lib/utils/binding-parser.html index 43cfbdda61..06ea6b86c3 100644 --- a/lib/utils/binding-parser.html +++ b/lib/utils/binding-parser.html @@ -37,6 +37,7 @@ this.bindingData = { dependencies: [] }; + /* eslint-disable no-fallthrough */ const STATE = { INITIAL: (char, i) => { @@ -172,52 +173,49 @@ } } }, - METHOD: (binding) => { - let escaped = false; - return (char, i) => { - //console.log('METHOD') - switch (char) { - case ')': { - const methodName = this.bindingData.signature.methodName; - const dynamicFns = templateInfo.dynamicFns; - if (dynamicFns && dynamicFns[methodName] || this.bindingData.signature.static) { - this.bindingData.dependencies.push(methodName); - this.bindingData.signature.dynamicFn = true; - } - const name = text.substring(this._startChar, i).trim(); - this.bindingData.mode = binding; - if (name) { - this.bindingData.signature.args.push({ - name - }); - this.bindingData.dependencies.push(name) - } - this._storeBindingData(); - return STATE.METHODCLOSED(binding) + METHOD: (binding) => (char, i) => { + //console.log('METHOD') + switch (char) { + case ')': { + const methodName = this.bindingData.signature.methodName; + const dynamicFns = templateInfo.dynamicFns; + if (dynamicFns && dynamicFns[methodName] || this.bindingData.signature.static) { + this.bindingData.dependencies.push(methodName); + this.bindingData.signature.dynamicFn = true; } - case ',': { - const name = text.substring(this._startChar, i).trim(); - if (name) { - this.bindingData.signature.args.push({ - name - }); - this.bindingData.dependencies.push(name) - } - this._startChar = i + 1; - break; + const name = text.substring(this._startChar, i).trim(); + this.bindingData.mode = binding; + if (name) { + this.bindingData.signature.args.push({ + name + }); + this.bindingData.dependencies.push(name) } - case '\'': - case '"': { - return STATE.STRINGARG(binding, char); + this._storeBindingData(); + return STATE.METHODCLOSED(binding) + } + case ',': { + const name = text.substring(this._startChar, i).trim(); + if (name) { + this.bindingData.signature.args.push({ + name + }); + this.bindingData.dependencies.push(name) + } + this._startChar = i + 1; + break; + } + case '\'': + case '"': { + return STATE.STRINGARG(binding, char); + } + default: { + if (char >= '0' && char <= '9' || char === '-') { + return STATE.NUMBERARG(binding) } - default: { - if (char >= '0' && char <= '9' || char === '-') { - return STATE.NUMBERARG(binding) - } - if (char != ' ' && char != '\n') { - return STATE.VARIABLEARG(binding) - } + if (char != ' ' && char != '\n') { + return STATE.VARIABLEARG(binding) } } } @@ -358,6 +356,7 @@ } } } + /* eslint-enable no-fallthrough */ let state = STATE.INITIAL; let i,l; @@ -390,7 +389,7 @@ }; } - }; + } Polymer.BindingParser = BindingParser; })();