@schukai/monster 3.44.0 → 3.44.1

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schukai/monster",
3
- "version": "3.44.0",
3
+ "version": "3.44.1",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -60,6 +60,12 @@ const assembleMethodSymbol = Symbol.for("@schukai/monster/dom/@@assembleMethodSy
60
60
  */
61
61
  const attributeObserverSymbol = Symbol.for("@schukai/monster/dom/@@attributeObserver");
62
62
 
63
+ /**
64
+ * @private
65
+ * @type {symbol}
66
+ */
67
+ const attributeMutationObserverSymbol = Symbol("@schukai/monster/dom/@@mutationObserver");
68
+
63
69
  /**
64
70
  * HTMLElement
65
71
  * @external HTMLElement
@@ -205,7 +211,7 @@ class CustomElement extends HTMLElement {
205
211
  });
206
212
  this[initMethodSymbol]();
207
213
  initOptionObserver.call(this);
208
- initAttributeChangeMutationObserver.call(this);
214
+
209
215
  }
210
216
 
211
217
  /**
@@ -230,7 +236,7 @@ class CustomElement extends HTMLElement {
230
236
  }
231
237
 
232
238
  /**
233
- *
239
+ *
234
240
  * @param attribute
235
241
  * @param callback
236
242
  * @returns {Monster.DOM.CustomElement}
@@ -242,7 +248,7 @@ class CustomElement extends HTMLElement {
242
248
  }
243
249
 
244
250
  /**
245
- *
251
+ *
246
252
  * @param attribute
247
253
  * @returns {Monster.DOM.CustomElement}
248
254
  */
@@ -546,6 +552,9 @@ class CustomElement extends HTMLElement {
546
552
  customElementUpdaterLinkSymbol,
547
553
  clone(self[internalSymbol].getRealSubject()["options"]),
548
554
  );
555
+
556
+ attachAttributeChangeMutationObserver.call(this);
557
+
549
558
  return self;
550
559
  }
551
560
 
@@ -561,6 +570,7 @@ class CustomElement extends HTMLElement {
561
570
  if (!hasObjectLink(self, customElementUpdaterLinkSymbol)) {
562
571
  self[assembleMethodSymbol]();
563
572
  }
573
+
564
574
  }
565
575
 
566
576
  /**
@@ -598,7 +608,12 @@ class CustomElement extends HTMLElement {
598
608
  const callback = self[attributeObserverSymbol]?.[attrName];
599
609
 
600
610
  if (isFunction(callback)) {
601
- callback.call(self, newVal, oldVal);
611
+ try {
612
+ callback.call(self, newVal, oldVal);
613
+ } catch (e) {
614
+ addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.toString());
615
+ }
616
+
602
617
  }
603
618
  }
604
619
 
@@ -626,23 +641,34 @@ class CustomElement extends HTMLElement {
626
641
 
627
642
  /**
628
643
  * This method is called when the element is first created.
629
- *
644
+ *
630
645
  * @private
631
646
  * @this CustomElement
632
647
  */
633
- function initAttributeChangeMutationObserver() {
648
+ function attachAttributeChangeMutationObserver() {
634
649
  const self = this;
635
650
 
636
- new MutationObserver(function (mutations) {
651
+ if (typeof self[attributeMutationObserverSymbol] !== "undefined") {
652
+ return;
653
+ }
654
+
655
+ self[attributeMutationObserverSymbol] = new MutationObserver(function (mutations, observer) {
637
656
  for (const mutation of mutations) {
638
657
  if (mutation.type === "attributes") {
639
658
  self.attributeChangedCallback(mutation.attributeName, mutation.oldValue, mutation.target.getAttribute(mutation.attributeName));
640
659
  }
641
660
  }
642
- }).observe(self, {
643
- attributes: true,
644
- attributeOldValue: true,
645
661
  });
662
+
663
+ try {
664
+ self[attributeMutationObserverSymbol].observe(self, {
665
+ attributes: true,
666
+ attributeOldValue: true,
667
+ });
668
+
669
+ } catch (e) {
670
+ addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, e.toString());
671
+ }
646
672
  }
647
673
 
648
674
  /**
@@ -142,7 +142,7 @@ function getMonsterVersion() {
142
142
  }
143
143
 
144
144
  /** don't touch, replaced by make with package.json version */
145
- monsterVersion = new Version("3.44.0");
145
+ monsterVersion = new Version("3.44.1");
146
146
 
147
147
  return monsterVersion;
148
148
  }
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version("3.44.0")
10
+ monsterVersion = new Version("3.44.1")
11
11
 
12
12
  let m = getMonsterVersion();
13
13