@schukai/monster 3.43.0 → 3.44.0

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": "@schukai/monster",
3
- "version": "3.43.0",
3
+ "version": "3.44.0",
4
4
  "description": "Monster is a simple library for creating fast, robust and lightweight websites.",
5
5
  "keywords": [
6
6
  "framework",
@@ -203,9 +203,9 @@ class CustomElement extends HTMLElement {
203
203
  this[internalSymbol] = new ProxyObserver({
204
204
  options: initOptionsFromAttributes(this, extend({}, this.defaults)),
205
205
  });
206
- initAttributeChangeMutationObserver.call(this);
207
- initOptionObserver.call(this);
208
206
  this[initMethodSymbol]();
207
+ initOptionObserver.call(this);
208
+ initAttributeChangeMutationObserver.call(this);
209
209
  }
210
210
 
211
211
  /**
@@ -229,6 +229,28 @@ class CustomElement extends HTMLElement {
229
229
  return [ATTRIBUTE_OPTIONS, ATTRIBUTE_DISABLED];
230
230
  }
231
231
 
232
+ /**
233
+ *
234
+ * @param attribute
235
+ * @param callback
236
+ * @returns {Monster.DOM.CustomElement}
237
+ */
238
+ addAttributeObserver(attribute, callback) {
239
+ validateFunction(callback);
240
+ this[attributeObserverSymbol][attribute] = callback;
241
+ return this;
242
+ }
243
+
244
+ /**
245
+ *
246
+ * @param attribute
247
+ * @returns {Monster.DOM.CustomElement}
248
+ */
249
+ removeAttributeObserver(attribute) {
250
+ delete this[attributeObserverSymbol][attribute];
251
+ return this;
252
+ }
253
+
232
254
  /**
233
255
  * Derived classes can override and extend this method as follows.
234
256
  *
@@ -611,14 +633,6 @@ class CustomElement extends HTMLElement {
611
633
  function initAttributeChangeMutationObserver() {
612
634
  const self = this;
613
635
 
614
- if (self[attributeObserverSymbol] === undefined) {
615
- self[attributeObserverSymbol] = {};
616
- }
617
-
618
- if(Object.keys(self[attributeObserverSymbol]).length === 0) {
619
- return;
620
- }
621
-
622
636
  new MutationObserver(function (mutations) {
623
637
  for (const mutation of mutations) {
624
638
  if (mutation.type === "attributes") {
@@ -628,7 +642,6 @@ function initAttributeChangeMutationObserver() {
628
642
  }).observe(self, {
629
643
  attributes: true,
630
644
  attributeOldValue: true,
631
- attributeFilter: Object.keys(self[attributeObserverSymbol]),
632
645
  });
633
646
  }
634
647
 
@@ -37,7 +37,7 @@ export { Updater, addObjectWithUpdaterToElement };
37
37
  * The updater class connects an object with the dom. In this way, structures and contents in the DOM can be programmatically adapted via attributes.
38
38
  *
39
39
  * For example, to include a string from an object, the attribute `data-monster-replace` can be used.
40
- * a further explanation can be found under {@tutorial dom-based-templating-implementation}.
40
+ * a further explanation can be found under [monsterjs.org](https://monsterjs.org/)
41
41
  *
42
42
  * Changes to attributes are made only when the direct values are changed. If you want to assign changes to other values
43
43
  * as well, you have to insert the attribute `data-monster-select-this`. This should be done with care, as it can reduce performance.
@@ -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.43.0");
145
+ monsterVersion = new Version("3.44.0");
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.43.0")
10
+ monsterVersion = new Version("3.44.0")
11
11
 
12
12
  let m = getMonsterVersion();
13
13