From 74744fe74be17e0cde370a0fd56df3c91aa64254 Mon Sep 17 00:00:00 2001 From: Amour1688 Date: Sun, 21 Jun 2020 17:06:37 +0800 Subject: [PATCH] fix: skip normalizeObjectSlots in runtime-core --- packages/babel-plugin-jsx/src/transform-vue-jsx.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/babel-plugin-jsx/src/transform-vue-jsx.js b/packages/babel-plugin-jsx/src/transform-vue-jsx.js index 0e8cbb7..ded0d00 100644 --- a/packages/babel-plugin-jsx/src/transform-vue-jsx.js +++ b/packages/babel-plugin-jsx/src/transform-vue-jsx.js @@ -265,12 +265,12 @@ const buildProps = (t, path, state, hasContainer) => { if ( (patchFlag === 0 || patchFlag === PatchFlags.HYDRATE_EVENTS) - && hasRef + && (hasRef || directives.length > 0) ) { patchFlag |= PatchFlags.NEED_PATCH; } - let propsExpression; + let propsExpression = t.nullLiteral(); if (mergeArgs.length) { if (properties.length) { @@ -368,7 +368,9 @@ const transformJSXElement = (t, path, state) => { const isComponent = checkIsComponent(t, path.get('openingElement')); const child = children.length === 1 && t.isStringLiteral(children[0]) ? children[0] : t.arrayExpression(children); - if (state.opts.compatibleProps && !state.get('compatibleProps')) { + + const { compatibleProps } = state.opts; + if (compatibleProps && !state.get('compatibleProps')) { state.set('compatibleProps', addDefault( path, '@ant-design-vue/babel-helper-vue-compatible-props', { nameHint: '_compatibleProps' }, )); @@ -376,7 +378,7 @@ const transformJSXElement = (t, path, state) => { const createVNode = t.callExpression(createIdentifier(t, state, 'createVNode'), [ tag, - state.opts.compatibleProps ? t.callExpression(state.get('compatibleProps'), [props]) : props, + compatibleProps ? t.callExpression(state.get('compatibleProps'), [props]) : props, children[0] ? ( isComponent @@ -395,10 +397,6 @@ const transformJSXElement = (t, path, state) => { ), ]), ), - t.objectProperty( - t.identifier('_'), - t.numericLiteral(1), - ), ]) : child ) : t.nullLiteral(),