提交 77160252 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -183,7 +183,7 @@ const tags = require('@dcloudio/uni-cli-shared/lib/tags')
const {
isBuiltInComponent
} = require('@dcloudio/uni-cli-shared/lib/pages')
} = require('@dcloudio/uni-cli-shared/lib/pages')
const {
getTagName
......@@ -223,7 +223,7 @@ function makeMap (str, expectsLowerCase) {
* @param {*} node
*/
function isSimpleObjectExpression (node) {
return t.isObjectExpression(node) && !node.properties.find(({
return t.isObjectExpression(node) && node.properties.length && !node.properties.find(({
key,
value
}) => !t.isIdentifier(key) || !(t.isIdentifier(value) || t.isStringLiteral(value) || t.isBooleanLiteral(value) ||
......@@ -261,4 +261,4 @@ module.exports = {
processMemberExpression,
getForIndexIdentifier,
isSimpleObjectExpression
}
}
......@@ -8,7 +8,7 @@ const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]
function isFunction (expr) {
try {
const body = parser.parse(expr).program.body[0]
const body = parser.parse(`(${expr})`).program.body[0]
const expression = body.expression
return t.isFunctionDeclaration(body) || t.isArrowFunctionExpression(expression) || t.isFunctionExpression(expression)
} catch (error) { }
......@@ -16,15 +16,14 @@ function isFunction (expr) {
function processEvent (expr, filterModules) {
const isMethodPath = simplePathRE.test(expr)
expr = `(${expr})`
if (isMethodPath || isFunction(expr)) {
if (filterModules.find(name => expr.indexOf(name + '.') === 0)) {
return `
$event = $handleWxsEvent($event);
${expr}($event, $getComponentDescriptor())
(${expr})($event, $getComponentDescriptor())
`
} else {
expr = `${expr}(...arguments)`
expr = `(${expr})(...arguments)`
}
}
return `
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册