diff --git a/src/image-preview/ImagePreview.js b/src/image-preview/ImagePreview.js index ea2074a73..41bdcc286 100644 --- a/src/image-preview/ImagePreview.js +++ b/src/image-preview/ImagePreview.js @@ -162,7 +162,6 @@ export default createComponent({ const deltaTime = new Date() - this.touchStartTime; const { offsetX = 0, offsetY = 0 } = this.$refs.swipe || {}; - console.log('deltaTime', deltaTime); // prevent long tap to close component if (deltaTime < DOUBLE_CLICK_INTERVAL && offsetX < 10 && offsetY < 10) { if (!this.doubleClickTimer) { diff --git a/src/tab/test/__snapshots__/insert.spec.js.snap b/src/tab/test/__snapshots__/insert.spec.js.snap index 8718f18e6..b94a0a83a 100644 --- a/src/tab/test/__snapshots__/insert.spec.js.snap +++ b/src/tab/test/__snapshots__/insert.spec.js.snap @@ -21,3 +21,25 @@ exports[`insert tab dynamically 1`] = ` `; + +exports[`insert tab with child component 1`] = ` +
+
+
+ + + +
+
+
+
+
1
+ + +
+
+`; diff --git a/src/tab/test/insert.spec.js b/src/tab/test/insert.spec.js index ba7f9f478..bfd4a3edb 100644 --- a/src/tab/test/insert.spec.js +++ b/src/tab/test/insert.spec.js @@ -25,3 +25,25 @@ test('insert tab dynamically', async () => { wrapper.setData({ insert: true }); expect(wrapper).toMatchSnapshot(); }); + +// this case will throw wierd error in index.spec.js +// so separate it +test('insert tab with child component', async () => { + const wrapper = mount({ + template: ` + + 1 + + 3 + + `, + components: { + 'my-tab': { + template: `2`, + }, + }, + }); + + await later(); + expect(wrapper).toMatchSnapshot(); +}); diff --git a/src/utils/vnodes.ts b/src/utils/vnodes.ts index 516f40717..471d2ea38 100644 --- a/src/utils/vnodes.ts +++ b/src/utils/vnodes.ts @@ -7,6 +7,10 @@ function flattenVNodes(vnodes: VNode[]) { vnodes.forEach((vnode) => { result.push(vnode); + if (vnode.componentInstance) { + traverse(vnode.componentInstance.$children.map((item) => item.$vnode)); + } + if (vnode.children) { traverse(vnode.children); } @@ -17,12 +21,8 @@ function flattenVNodes(vnodes: VNode[]) { return result; } -type VueInstance = { - $vnode: VNode; -}; - // sort children instances by vnodes order -export function sortChildren(children: VueInstance[], parent: VueInstance) { +export function sortChildren(children: Vue[], parent: Vue) { const { componentOptions } = parent.$vnode; if (!componentOptions || !componentOptions.children) { return;