From 95040ed3a881a9bf61d3b3a2203eec9db4a3b263 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Mon, 16 Dec 2019 17:22:29 +0800 Subject: [PATCH] chore(release): vue-template-compiler(2.6.11) --- .../lib/app/pre-transform-node.js | 2 +- .../packages/vue-template-compiler/README.md | 2 +- .../packages/vue-template-compiler/browser.js | 29 ++++++++++++++----- .../packages/vue-template-compiler/build.js | 29 ++++++++++++++----- .../vue-template-compiler/package.json | 2 +- 5 files changed, 47 insertions(+), 17 deletions(-) diff --git a/packages/uni-template-compiler/lib/app/pre-transform-node.js b/packages/uni-template-compiler/lib/app/pre-transform-node.js index ebc81fec6..9c3b298ab 100644 --- a/packages/uni-template-compiler/lib/app/pre-transform-node.js +++ b/packages/uni-template-compiler/lib/app/pre-transform-node.js @@ -4,7 +4,7 @@ const { addRawAttr } = require('./util') -const dirRE = /^v-|^@|^:/ +const dirRE = /^v-|^@|^:|^#/ /** * 兼容小程序Boolean属性的怪异行为(为true,为false) * @param {Object} el diff --git a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/README.md b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/README.md index e84aab824..fa0a64bb7 100644 --- a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/README.md +++ b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/README.md @@ -81,7 +81,7 @@ Note the returned function code uses `with` and thus cannot be used in strict mo It's possible to hook into the compilation process to support custom template features. **However, beware that by injecting custom compile-time modules, your templates will not work with other build tools built on standard built-in modules, e.g `vue-loader` and `vueify`.** - An array of compiler modules. For details on compiler modules, refer to the `ModuleOptions` type in [flow declarations](https://github.com/vuejs/vue/blob/dev/flow/compiler.js#L38-L45) and the [built-in modules](https://github.com/vuejs/vue/tree/dev/src/platforms/web/compiler/modules). + An array of compiler modules. For details on compiler modules, refer to the `ModuleOptions` type in [flow declarations](https://github.com/vuejs/vue/blob/dev/flow/compiler.js#L47-L59) and the [built-in modules](https://github.com/vuejs/vue/tree/dev/src/platforms/web/compiler/modules). - `directives` diff --git a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/browser.js b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/browser.js index 36aa2b46c..4ea5a4341 100644 --- a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/browser.js +++ b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/browser.js @@ -310,7 +310,7 @@ var startTagClose = /^\s*(\/?)>/; var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>")); var doctype = /^]+>/i; - // #7298: escape - to avoid being pased as HTML comment when inlined in page + // #7298: escape - to avoid being passed as HTML comment when inlined in page var comment = /^ can only appear at the root level inside " + - "the receiving the component", + "the receiving component", el ); } @@ -4134,7 +4134,7 @@ /* */ - var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/; + var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/; var fnInvokeRE = /\([^)]*?\);*$/; var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; @@ -4903,6 +4903,8 @@ var range = node.rawAttrsMap[name]; if (name === 'v-for') { checkFor(node, ("v-for=\"" + value + "\""), warn, range); + } else if (name === 'v-slot' || name[0] === '#') { + checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range); } else if (onRE.test(name)) { checkEvent(value, (name + "=\"" + value + "\""), warn, range); } else { @@ -4922,9 +4924,9 @@ } function checkEvent (exp, text, warn, range) { - var stipped = exp.replace(stripStringRE, ''); - var keywordMatch = stipped.match(unaryOperatorsRE); - if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') { + var stripped = exp.replace(stripStringRE, ''); + var keywordMatch = stripped.match(unaryOperatorsRE); + if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') { warn( "avoid using JavaScript unary operator as property name: " + "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()), @@ -4979,6 +4981,19 @@ } } + function checkFunctionParameterExpression (exp, text, warn, range) { + try { + new Function(exp, ''); + } catch (e) { + warn( + "invalid function parameter expression: " + (e.message) + " in\n\n" + + " " + exp + "\n\n" + + " Raw expression: " + (text.trim()) + "\n", + range + ); + } + } + /* */ var range = 2; diff --git a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/build.js b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/build.js index 8edad1dcf..ef7a2a806 100644 --- a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/build.js +++ b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/build.js @@ -267,7 +267,7 @@ var startTagOpen = new RegExp(("^<" + qnameCapture)); var startTagClose = /^\s*(\/?)>/; var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>")); var doctype = /^]+>/i; -// #7298: escape - to avoid being pased as HTML comment when inlined in page +// #7298: escape - to avoid being passed as HTML comment when inlined in page var comment = /^ can only appear at the root level inside " + - "the receiving the component", + "the receiving component", el ); } @@ -3764,7 +3764,7 @@ function isDirectChildOfTemplateFor (node) { /* */ -var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/; +var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function(?:\s+[\w$]+)?\s*\(/; var fnInvokeRE = /\([^)]*?\);*$/; var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/; @@ -4536,6 +4536,8 @@ function checkNode (node, warn) { var range = node.rawAttrsMap[name]; if (name === 'v-for') { checkFor(node, ("v-for=\"" + value + "\""), warn, range); + } else if (name === 'v-slot' || name[0] === '#') { + checkFunctionParameterExpression(value, (name + "=\"" + value + "\""), warn, range); } else if (onRE.test(name)) { checkEvent(value, (name + "=\"" + value + "\""), warn, range); } else { @@ -4555,9 +4557,9 @@ function checkNode (node, warn) { } function checkEvent (exp, text, warn, range) { - var stipped = exp.replace(stripStringRE, ''); - var keywordMatch = stipped.match(unaryOperatorsRE); - if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') { + var stripped = exp.replace(stripStringRE, ''); + var keywordMatch = stripped.match(unaryOperatorsRE); + if (keywordMatch && stripped.charAt(keywordMatch.index - 1) !== '$') { warn( "avoid using JavaScript unary operator as property name: " + "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()), @@ -4612,6 +4614,19 @@ function checkExpression (exp, text, warn, range) { } } +function checkFunctionParameterExpression (exp, text, warn, range) { + try { + new Function(exp, ''); + } catch (e) { + warn( + "invalid function parameter expression: " + (e.message) + " in\n\n" + + " " + exp + "\n\n" + + " Raw expression: " + (text.trim()) + "\n", + range + ); + } +} + /* */ var range = 2; diff --git a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/package.json b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/package.json index c545f587a..40da8a011 100644 --- a/packages/vue-cli-plugin-uni/packages/vue-template-compiler/package.json +++ b/packages/vue-cli-plugin-uni/packages/vue-template-compiler/package.json @@ -1,6 +1,6 @@ { "name": "vue-template-compiler", - "version": "2.6.10", + "version": "2.6.11", "description": "template compiler for Vue 2.0", "main": "index.js", "unpkg": "browser.js", -- GitLab