Skip to content

Commit cd638e7

Browse files
committed
fix: fix #247
1 parent 5548c7f commit cd638e7

File tree

5 files changed

+56
-4
lines changed

5 files changed

+56
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mind-elixir",
3-
"version": "4.0.0",
3+
"version": "4.0.1",
44
"type": "module",
55
"description": "Mind elixir is a free open source mind map core.",
66
"keywords": [

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ MindElixir.DARK_THEME = DARK_THEME
129129
* @memberof MindElixir
130130
* @static
131131
*/
132-
MindElixir.version = '4.0.0'
132+
MindElixir.version = '4.0.1'
133133
/**
134134
* @function
135135
* @memberof MindElixir

src/utils/domManipulation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export const realAddChild = function (mei: MindElixirInstance, to: Topic, wrappe
4040
} else if (top.tagName === 'ME-ROOT') {
4141
const direction = judgeDirection(mei.direction, tpc.nodeObj)
4242
if (direction === LEFT) {
43-
document.querySelector('.lhs')?.appendChild(wrapper)
43+
mei.container.querySelector('.lhs')?.appendChild(wrapper)
4444
} else {
45-
document.querySelector('.rhs')?.appendChild(wrapper)
45+
mei.container.querySelector('.rhs')?.appendChild(wrapper)
4646
}
4747
mei.linkDiv()
4848
}

tests/multiple-instance.spec.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { test, expect } from './mind-elixir-test'
2+
import type MindElixir from '../src/index'
3+
4+
declare let window: {
5+
E: typeof MindElixir.E
6+
}
7+
8+
const data1 = {
9+
nodeData: {
10+
id: 'data1',
11+
topic: 'new topic',
12+
root: true,
13+
children: [],
14+
},
15+
}
16+
17+
const data2 = {
18+
nodeData: {
19+
id: 'data2',
20+
topic: 'new topic',
21+
root: true,
22+
children: [
23+
{
24+
id: 'child',
25+
topic: 'child',
26+
direction: 0,
27+
},
28+
],
29+
},
30+
}
31+
test.beforeEach(async ({ me, page }) => {
32+
await me.init(data1, '#map')
33+
await me.init(data2, '#map2')
34+
})
35+
36+
// fix: https://github.com/SSShooter/mind-elixir-core/issues/247
37+
test('Add Child To Data2 Correctly', async ({ page, me }) => {
38+
const handle = await me.getInstance('#map2')
39+
handle.evaluateHandle(mei =>
40+
mei.addChild(window.E('data2'), {
41+
id: 'child2',
42+
topic: 'child2',
43+
})
44+
)
45+
handle.evaluateHandle(mei =>
46+
mei.addChild(window.E('child'), {
47+
id: 'child3',
48+
topic: 'child3',
49+
})
50+
)
51+
expect(await page.screenshot()).toMatchSnapshot()
52+
})
28.6 KB
Loading

0 commit comments

Comments
 (0)