zrender-nightly 5.5.0-dev.20221127 → 5.5.0-dev.20221129

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/zrender.js CHANGED
@@ -124,8 +124,8 @@
124
124
  else {
125
125
  text = text || '';
126
126
  font = font || DEFAULT_FONT;
127
- var res = /^([0-9]*?)px$/.exec(font);
128
- var fontSize = +(res && res[1]) || DEFAULT_FONT_SIZE;
127
+ var res = /(\d+)px/.exec(font);
128
+ var fontSize = res && +res[1] || DEFAULT_FONT_SIZE;
129
129
  var width = 0;
130
130
  if (font.indexOf('mono') >= 0) {
131
131
  width = fontSize * text.length;
@@ -578,11 +578,48 @@
578
578
  function isPrimitive(obj) {
579
579
  return obj[primitiveKey];
580
580
  }
581
+ var MapPolyfill = (function () {
582
+ function MapPolyfill() {
583
+ this.data = {};
584
+ }
585
+ MapPolyfill.prototype["delete"] = function (key) {
586
+ var existed = this.has(key);
587
+ if (existed) {
588
+ delete this.data[key];
589
+ }
590
+ return existed;
591
+ };
592
+ MapPolyfill.prototype.has = function (key) {
593
+ return this.data.hasOwnProperty(key);
594
+ };
595
+ MapPolyfill.prototype.get = function (key) {
596
+ return this.data[key];
597
+ };
598
+ MapPolyfill.prototype.set = function (key, value) {
599
+ this.data[key] = value;
600
+ return this;
601
+ };
602
+ MapPolyfill.prototype.keys = function () {
603
+ return keys(this.data);
604
+ };
605
+ MapPolyfill.prototype.forEach = function (callback) {
606
+ var data = this.data;
607
+ for (var key in data) {
608
+ if (data.hasOwnProperty(key)) {
609
+ callback(data[key], key);
610
+ }
611
+ }
612
+ };
613
+ return MapPolyfill;
614
+ }());
615
+ var isNativeMapSupported = typeof Map === 'function';
616
+ function maybeNativeMap() {
617
+ return (isNativeMapSupported ? new Map() : new MapPolyfill());
618
+ }
581
619
  var HashMap = (function () {
582
620
  function HashMap(obj) {
583
- this.data = {};
584
621
  var isArr = isArray(obj);
585
- this.data = {};
622
+ this.data = maybeNativeMap();
586
623
  var thisMap = this;
587
624
  (obj instanceof HashMap)
588
625
  ? obj.each(visit)
@@ -591,24 +628,29 @@
591
628
  isArr ? thisMap.set(value, key) : thisMap.set(key, value);
592
629
  }
593
630
  }
631
+ HashMap.prototype.hasKey = function (key) {
632
+ return this.data.has(key);
633
+ };
594
634
  HashMap.prototype.get = function (key) {
595
- return this.data.hasOwnProperty(key) ? this.data[key] : null;
635
+ return this.data.get(key);
596
636
  };
597
637
  HashMap.prototype.set = function (key, value) {
598
- return (this.data[key] = value);
638
+ this.data.set(key, value);
639
+ return value;
599
640
  };
600
641
  HashMap.prototype.each = function (cb, context) {
601
- for (var key in this.data) {
602
- if (this.data.hasOwnProperty(key)) {
603
- cb.call(context, this.data[key], key);
604
- }
605
- }
642
+ this.data.forEach(function (value, key) {
643
+ cb.call(context, value, key);
644
+ });
606
645
  };
607
646
  HashMap.prototype.keys = function () {
608
- return keys(this.data);
647
+ var keys = this.data.keys();
648
+ return isNativeMapSupported
649
+ ? Array.from(keys)
650
+ : keys;
609
651
  };
610
652
  HashMap.prototype.removeKey = function (key) {
611
- delete this.data[key];
653
+ this.data["delete"](key);
612
654
  };
613
655
  return HashMap;
614
656
  }());
@@ -7196,7 +7238,7 @@
7196
7238
  function registerPainter(name, Ctor) {
7197
7239
  painterCtors[name] = Ctor;
7198
7240
  }
7199
- var version = '5.5.0-dev.20221127';
7241
+ var version = '5.5.0-dev.20221129';
7200
7242
 
7201
7243
  var STYLE_MAGIC_KEY = '__zr_style_' + Math.round((Math.random() * 10));
7202
7244
  var DEFAULT_COMMON_STYLE = {
@@ -16285,11 +16327,12 @@
16285
16327
  builtinShpDef[0](shape, attrs, mul);
16286
16328
  }
16287
16329
  else {
16330
+ var needBuildPath = !el.path || el.shapeChanged();
16288
16331
  if (!el.path) {
16289
16332
  el.createPathProxy();
16290
16333
  }
16291
16334
  var path = el.path;
16292
- if (el.shapeChanged()) {
16335
+ if (needBuildPath) {
16293
16336
  path.beginPath();
16294
16337
  el.buildPath(path, el.shape);
16295
16338
  el.pathUpdated();
@@ -17143,7 +17186,7 @@
17143
17186
  else {
17144
17187
  var _a = normalizeColor(backgroundColor), color = _a.color, opacity = _a.opacity;
17145
17188
  bgVNode.attrs.fill = color;
17146
- opacity < 1 && (bgVNode.attrs.fillOpacity = opacity);
17189
+ opacity < 1 && (bgVNode.attrs['fill-opacity'] = opacity);
17147
17190
  }
17148
17191
  }
17149
17192
  return bgVNode;