@antv/g-lite 2.0.11-alpha.3 → 2.0.11-alpha.5

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/dist/index.js CHANGED
@@ -7501,20 +7501,19 @@ var CSSPropertyTextTransform = /** @class */ (function () {
7501
7501
  return CSSPropertyTextTransform;
7502
7502
  }());
7503
7503
 
7504
- var canvasMap = {};
7505
- var defaultCanvasIdCounter = 0;
7504
+ var CANVAS_Map = new WeakMap();
7506
7505
  /**
7507
7506
  * destroy existed canvas with the same id
7508
7507
  */
7509
7508
  function cleanExistedCanvas(container, canvas, fast) {
7510
7509
  if (container) {
7511
- var id = typeof container === 'string'
7512
- ? container
7513
- : container.id || defaultCanvasIdCounter++;
7514
- if (canvasMap[id]) {
7515
- canvasMap[id].destroy(true, !!fast);
7516
- }
7517
- canvasMap[id] = canvas;
7510
+ var $dom = typeof container === 'string'
7511
+ ? document.getElementById(container)
7512
+ : container;
7513
+ if (CANVAS_Map.has($dom))
7514
+ CANVAS_Map.get($dom).destroy(true, !!fast);
7515
+ else
7516
+ CANVAS_Map.set($dom, canvas);
7518
7517
  }
7519
7518
  }
7520
7519
  var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
@@ -15091,8 +15090,9 @@ var Canvas = /** @class */ (function (_super) {
15091
15090
  */
15092
15091
  Canvas.prototype.destroy = function (cleanUp, skipTriggerEvent) {
15093
15092
  if (cleanUp === void 0) { cleanUp = true; }
15093
+ var fastCleanExistingCanvas = this.getConfig().fastCleanExistingCanvas;
15094
15094
  if (skipTriggerEvent === undefined)
15095
- skipTriggerEvent = this.getConfig().fastCleanExistingCanvas;
15095
+ skipTriggerEvent = fastCleanExistingCanvas;
15096
15096
  if (!skipTriggerEvent) {
15097
15097
  this.dispatchEvent(new CustomEvent(exports.CanvasEvent.BEFORE_DESTROY));
15098
15098
  }
@@ -15103,7 +15103,7 @@ var Canvas = /** @class */ (function (_super) {
15103
15103
  // unmount all children
15104
15104
  var root = this.getRoot();
15105
15105
  this.unmountChildren(root);
15106
- if (cleanUp) {
15106
+ if (cleanUp && !fastCleanExistingCanvas) {
15107
15107
  // destroy Document
15108
15108
  this.document.destroy();
15109
15109
  this.getEventService().destroy();