From 02a189ded80b576e37243f6614d8e65dbd9eb4fd Mon Sep 17 00:00:00 2001 From: qiang Date: Wed, 19 Aug 2020 17:27:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=8D=E6=9D=82?= =?UTF-8?q?=E7=9A=84=E4=BA=8B=E4=BB=B6=E8=A1=A8=E8=BE=BE=E5=BC=8F=E4=B8=AD?= =?UTF-8?q?=E5=90=AB=E6=9C=89=20undefined=20=E6=97=B6=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=BC=96=E8=AF=91=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-template-compiler/__tests__/compiler-extra.spec.js | 5 +++++ .../uni-template-compiler/lib/script/traverse/data/event.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js index dfbb7be2c..b38ae059e 100644 --- a/packages/uni-template-compiler/__tests__/compiler-extra.spec.js +++ b/packages/uni-template-compiler/__tests__/compiler-extra.spec.js @@ -332,6 +332,11 @@ describe('mp:compiler-extra', () => { '', 'with(this){if(!_isMounted){e0=function($event,item){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=_temp.eventParams||_temp["event-params"],item=_temp2.item;var _temp,_temp2;return $test.test(item,item.length)}}}' ) + assertCodegen( + '', + '', + 'with(this){if(!_isMounted){e0=function($event,item){var _temp=arguments[arguments.length-1].currentTarget.dataset,_temp2=_temp.eventParams||_temp["event-params"],item=_temp2.item;var _temp,_temp2;return $test.test(item,item.length,undefined)}}}' + ) }) it('generate class binding', () => { diff --git a/packages/uni-template-compiler/lib/script/traverse/data/event.js b/packages/uni-template-compiler/lib/script/traverse/data/event.js index c5e9dc25e..cfc01a9b7 100644 --- a/packages/uni-template-compiler/lib/script/traverse/data/event.js +++ b/packages/uni-template-compiler/lib/script/traverse/data/event.js @@ -335,7 +335,7 @@ function parseEvent (keyPath, valuePath, state, isComponent, isNativeOn = false, const scope = path.scope const node = path.node const name = node.name - if (path.key !== 'key' && (path.key !== 'property' || path.parent.computed) && scope && !scope.hasOwnBinding(name) && scope.hasBinding(name) && !params.includes(name)) { + if (path.key !== 'key' && (path.key !== 'property' || path.parent.computed) && scope && !scope.hasOwnBinding(name) && scope.hasBinding(name) && !params.includes(name) && name !== 'undefined') { params.push(name) } } -- GitLab