ublo-lib 1.31.39 → 1.31.40

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.
@@ -2,7 +2,6 @@ import * as React from "react";
2
2
  import * as Utils from "./utils";
3
3
  import * as Plausible from "../plausible";
4
4
  export default React.memo(Tunnel);
5
- let started = false;
6
5
  function Tunnel({
7
6
  options,
8
7
  presets,
@@ -20,10 +19,7 @@ function Tunnel({
20
19
  Plausible.callback.apply(null, args);
21
20
  }
22
21
  };
23
- if (!started) {
24
- Utils.loadWidget("tunnel", patchedOptions, presets);
25
- started = true;
26
- }
22
+ Utils.loadWidget("tunnel", patchedOptions, presets);
27
23
  }, [options, presets]);
28
24
  return children;
29
25
  }
@@ -1,9 +1,17 @@
1
1
  export function loadWidget(widget, options = {}, presets = {}) {
2
+ const isGroundedTo = ("groundedTo" in options);
2
3
  if (window.MseMLoaded) {
3
- window.requestAnimationFrame(() => window.requestAnimationFrame(() => window.MseM?.onLoad(() => window.MseM[widget](options, presets))));
4
+ window.MseM?.onLoad(() => {
5
+ if (isGroundedTo) {
6
+ const container = document.querySelector(options.groundedTo);
7
+ try {
8
+ container.unmount();
9
+ } catch {}
10
+ }
11
+ window.MseM[widget](options, presets);
12
+ });
4
13
  } else {
5
14
  setTimeout(() => {
6
- const isGroundedTo = ("groundedTo" in options);
7
15
  if (isGroundedTo) {
8
16
  const selector = options.groundedTo;
9
17
  const widgetStillHasTarget = document.querySelector(selector);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.31.39",
3
+ "version": "1.31.40",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.8.3",
6
6
  "leaflet": "^1.9.1",