Skip to content

Commit

Permalink
fix: fix #247
Browse files Browse the repository at this point in the history
  • Loading branch information
SSShooter committed Feb 24, 2024
1 parent 5548c7f commit cd638e7
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mind-elixir",
"version": "4.0.0",
"version": "4.0.1",
"type": "module",
"description": "Mind elixir is a free open source mind map core.",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ MindElixir.DARK_THEME = DARK_THEME
* @memberof MindElixir
* @static
*/
MindElixir.version = '4.0.0'
MindElixir.version = '4.0.1'
/**
* @function
* @memberof MindElixir
Expand Down
4 changes: 2 additions & 2 deletions src/utils/domManipulation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export const realAddChild = function (mei: MindElixirInstance, to: Topic, wrappe
} else if (top.tagName === 'ME-ROOT') {
const direction = judgeDirection(mei.direction, tpc.nodeObj)
if (direction === LEFT) {
document.querySelector('.lhs')?.appendChild(wrapper)
mei.container.querySelector('.lhs')?.appendChild(wrapper)
} else {
document.querySelector('.rhs')?.appendChild(wrapper)
mei.container.querySelector('.rhs')?.appendChild(wrapper)
}
mei.linkDiv()
}
Expand Down
52 changes: 52 additions & 0 deletions tests/multiple-instance.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { test, expect } from './mind-elixir-test'
import type MindElixir from '../src/index'

declare let window: {
E: typeof MindElixir.E
}

const data1 = {
nodeData: {
id: 'data1',
topic: 'new topic',
root: true,
children: [],
},
}

const data2 = {
nodeData: {
id: 'data2',
topic: 'new topic',
root: true,
children: [
{
id: 'child',
topic: 'child',
direction: 0,
},
],
},
}
test.beforeEach(async ({ me, page }) => {
await me.init(data1, '#map')
await me.init(data2, '#map2')
})

// fix: https://github.com/SSShooter/mind-elixir-core/issues/247
test('Add Child To Data2 Correctly', async ({ page, me }) => {
const handle = await me.getInstance('#map2')
handle.evaluateHandle(mei =>
mei.addChild(window.E('data2'), {
id: 'child2',
topic: 'child2',
})
)
handle.evaluateHandle(mei =>
mei.addChild(window.E('child'), {
id: 'child3',
topic: 'child3',
})
)
expect(await page.screenshot()).toMatchSnapshot()
})
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cd638e7

Please sign in to comment.