From 4f8ad863ea08dd0225eea4b58d8c2f7aaebc0879 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Tue, 2 Nov 2021 14:55:06 +0800 Subject: [PATCH] wip(mp): support dynamicSlotNames --- packages/uni-mp-baidu/__tests__/vFor.spec.ts | 4 +- packages/uni-mp-baidu/__tests__/vSlot.spec.ts | 95 +++++++++++++++++++ packages/uni-mp-baidu/dist/uni.compiler.js | 9 +- packages/uni-mp-baidu/src/compiler/options.ts | 1 + .../src/compiler/transforms/vFor.ts | 8 +- .../src/transforms/transformSlot.ts | 48 ++++++---- .../uni-mp-compiler/src/transforms/vSlot.ts | 10 +- 7 files changed, 146 insertions(+), 29 deletions(-) create mode 100644 packages/uni-mp-baidu/__tests__/vSlot.spec.ts diff --git a/packages/uni-mp-baidu/__tests__/vFor.spec.ts b/packages/uni-mp-baidu/__tests__/vFor.spec.ts index 2d4a84b76b..08f87d4168 100644 --- a/packages/uni-mp-baidu/__tests__/vFor.spec.ts +++ b/packages/uni-mp-baidu/__tests__/vFor.spec.ts @@ -4,7 +4,7 @@ describe(`mp-baidu: transform v-for`, () => { test(`with key`, () => { assert( ``, - ``, + ``, `(_ctx, _cache) => { return { a: _f(_ctx.items, (item, k0, i0) => { return { a: item.id }; }) } }` @@ -13,7 +13,7 @@ describe(`mp-baidu: transform v-for`, () => { test(`without key`, () => { assert( ``, - ``, + ``, `(_ctx, _cache) => { return { a: _f(_ctx.items, (item, k0, i0) => { return {}; }) } }` diff --git a/packages/uni-mp-baidu/__tests__/vSlot.spec.ts b/packages/uni-mp-baidu/__tests__/vSlot.spec.ts new file mode 100644 index 0000000000..a65562839e --- /dev/null +++ b/packages/uni-mp-baidu/__tests__/vSlot.spec.ts @@ -0,0 +1,95 @@ +import { assert } from './testUtils' + +describe('compiler: transform v-slot', () => { + test('default slot', () => { + assert( + `