@maxelms/create-plugin-cli 1.1.19 → 1.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxelms/create-plugin-cli",
3
- "version": "1.1.19",
3
+ "version": "1.1.20",
4
4
  "main": "./bin/index.js",
5
5
  "author": "jackc_001",
6
6
  "bin": {
@@ -10,19 +10,21 @@ const render = (container: string, props?: any) => {
10
10
  const container = '#root';
11
11
 
12
12
  if (poweredByMaxelms) {
13
+ let $root: any
13
14
  registerPlugin({
14
15
  bootstrap() {
15
16
  },
16
17
  mount(props: any) {
17
18
  render(`#${props.containerId} ${container}`, props);
19
+ $root = document.querySelector(`#${props.containerId} ${container}`);
18
20
  },
19
21
  update(props: any) {
20
22
  render(`#${props.containerId} ${container}`, props);
21
23
  },
22
24
  unmount(props: any) {
23
- const element = document.querySelector(`#${props.containerId} ${container}`)
25
+ const element = document.querySelector(`#${props.containerId} ${container}`) || $root;
24
26
  element && ReactDOM.unmountComponentAtNode(element);
25
- }
27
+ },
26
28
  });
27
29
  } else {
28
30
  render(container);
@@ -31,7 +31,7 @@ export const render = (oldRender: any) => {
31
31
  },
32
32
  unmount(props) {
33
33
  setMasterProps(props.containerId, undefined)
34
- const unmountRootElement = document.querySelector(`#${props.containerId} #${defaultRootElement}`);
34
+ const unmountRootElement = document.querySelector(`#${props.containerId} #${defaultRootElement}`) || rootElement;
35
35
  unmountRootElement && ReactDom.unmountComponentAtNode(unmountRootElement)
36
36
  }
37
37
  })
@@ -10,19 +10,21 @@ const render = (container: string, props?: any) => {
10
10
  const container = '#root';
11
11
 
12
12
  if (poweredByMaxelms) {
13
+ let $root: any
13
14
  registerPlugin({
14
15
  bootstrap() {
15
16
  },
16
17
  mount(props: any) {
17
18
  render(`#${props.containerId} ${container}`, props);
19
+ $root = document.querySelector(`#${props.containerId} ${container}`);
18
20
  },
19
21
  update(props: any) {
20
22
  render(`#${props.containerId} ${container}`, props);
21
23
  },
22
- unmount(props) {
23
- const element = document.querySelector(`#${props.containerId} ${container}`)
24
+ unmount(props: any) {
25
+ const element = document.querySelector(`#${props.containerId} ${container}`) || $root;
24
26
  element && ReactDOM.unmountComponentAtNode(element);
25
- }
27
+ },
26
28
  });
27
29
  } else {
28
30
  render(container);
@@ -31,7 +31,7 @@ export const render = (oldRender: any) => {
31
31
  },
32
32
  unmount(props) {
33
33
  setMasterProps(props.containerId, undefined)
34
- const unmountRootElement = document.querySelector(`#${props.containerId} #${defaultRootElement}`);
34
+ const unmountRootElement = document.querySelector(`#${props.containerId} #${defaultRootElement}`) || rootElement;
35
35
  unmountRootElement && ReactDom.unmountComponentAtNode(unmountRootElement)
36
36
  }
37
37
  })