@schukai/monster 3.5.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/package.json +1 -1
  2. package/source/constants.mjs +4 -9
  3. package/source/constraints/abstract.mjs +4 -6
  4. package/source/constraints/abstractoperator.mjs +6 -12
  5. package/source/constraints/andoperator.mjs +3 -6
  6. package/source/constraints/invalid.mjs +3 -6
  7. package/source/constraints/isarray.mjs +6 -9
  8. package/source/constraints/isobject.mjs +4 -7
  9. package/source/constraints/namespace.mjs +1 -3
  10. package/source/constraints/oroperator.mjs +26 -25
  11. package/source/constraints/valid.mjs +3 -6
  12. package/source/data/buildmap.mjs +20 -36
  13. package/source/data/buildtree.mjs +29 -29
  14. package/source/data/datasource/namespace.mjs +1 -1
  15. package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
  16. package/source/data/datasource/server/restapi.mjs +51 -65
  17. package/source/data/datasource/server/webconnect.mjs +26 -35
  18. package/source/data/datasource/server.mjs +16 -20
  19. package/source/data/datasource/storage/localstorage.mjs +8 -11
  20. package/source/data/datasource/storage/sessionstorage.mjs +8 -10
  21. package/source/data/datasource/storage.mjs +18 -22
  22. package/source/data/datasource.mjs +27 -43
  23. package/source/data/diff.mjs +20 -32
  24. package/source/data/extend.mjs +20 -14
  25. package/source/data/namespace.mjs +1 -3
  26. package/source/data/pathfinder.mjs +40 -67
  27. package/source/data/pipe.mjs +6 -10
  28. package/source/data/transformer.mjs +141 -157
  29. package/source/dom/assembler.mjs +6 -9
  30. package/source/dom/attributes.mjs +36 -48
  31. package/source/dom/constants.mjs +55 -71
  32. package/source/dom/customcontrol.mjs +16 -21
  33. package/source/dom/customelement.mjs +140 -164
  34. package/source/dom/events.mjs +17 -24
  35. package/source/dom/focusmanager.mjs +30 -48
  36. package/source/dom/locale.mjs +16 -19
  37. package/source/dom/namespace.mjs +1 -1
  38. package/source/dom/ready.mjs +7 -10
  39. package/source/dom/resource/data.mjs +38 -46
  40. package/source/dom/resource/link/namespace.mjs +1 -3
  41. package/source/dom/resource/link/stylesheet.mjs +7 -11
  42. package/source/dom/resource/link.mjs +36 -17
  43. package/source/dom/resource/namespace.mjs +1 -1
  44. package/source/dom/resource/script.mjs +23 -13
  45. package/source/dom/resource.mjs +47 -60
  46. package/source/dom/resourcemanager.mjs +36 -43
  47. package/source/dom/template.mjs +17 -24
  48. package/source/dom/theme.mjs +8 -12
  49. package/source/dom/updater.mjs +150 -196
  50. package/source/dom/util.mjs +11 -12
  51. package/source/dom/worker/factory.mjs +21 -25
  52. package/source/dom/worker/namespace.mjs +1 -1
  53. package/source/i18n/formatter.mjs +20 -24
  54. package/source/i18n/locale.mjs +40 -42
  55. package/source/i18n/namespace.mjs +1 -1
  56. package/source/i18n/provider.mjs +4 -7
  57. package/source/i18n/providers/embed.mjs +16 -26
  58. package/source/i18n/providers/fetch.mjs +30 -36
  59. package/source/i18n/translations.mjs +15 -22
  60. package/source/logging/handler/console.mjs +6 -10
  61. package/source/logging/handler.mjs +15 -18
  62. package/source/logging/logentry.mjs +8 -9
  63. package/source/logging/logger.mjs +73 -55
  64. package/source/logging/namespace.mjs +1 -1
  65. package/source/math/namespace.mjs +1 -1
  66. package/source/math/random.mjs +13 -14
  67. package/source/monster.mjs +132 -100
  68. package/source/net/namespace.mjs +1 -3
  69. package/source/net/webconnect/message.mjs +6 -8
  70. package/source/net/webconnect/namespace.mjs +1 -3
  71. package/source/net/webconnect.mjs +28 -39
  72. package/source/text/formatter.mjs +44 -55
  73. package/source/types/base.mjs +16 -26
  74. package/source/types/basewithoptions.mjs +8 -14
  75. package/source/types/binary.mjs +4 -5
  76. package/source/types/dataurl.mjs +19 -27
  77. package/source/types/global.mjs +14 -26
  78. package/source/types/id.mjs +4 -6
  79. package/source/types/is.mjs +11 -16
  80. package/source/types/mediatype.mjs +29 -44
  81. package/source/types/namespace.mjs +0 -1
  82. package/source/types/node.mjs +16 -22
  83. package/source/types/nodelist.mjs +10 -14
  84. package/source/types/noderecursiveiterator.mjs +11 -14
  85. package/source/types/observablequeue.mjs +13 -16
  86. package/source/types/observer.mjs +16 -23
  87. package/source/types/observerlist.mjs +18 -21
  88. package/source/types/proxyobserver.mjs +24 -37
  89. package/source/types/queue.mjs +8 -13
  90. package/source/types/randomid.mjs +10 -10
  91. package/source/types/regex.mjs +3 -5
  92. package/source/types/stack.mjs +4 -8
  93. package/source/types/tokenlist.mjs +24 -31
  94. package/source/types/typeof.mjs +5 -7
  95. package/source/types/uniquequeue.mjs +8 -13
  96. package/source/types/uuid.mjs +18 -25
  97. package/source/types/validate.mjs +26 -27
  98. package/source/types/version.mjs +17 -25
  99. package/source/util/clone.mjs +23 -32
  100. package/source/util/comparator.mjs +7 -15
  101. package/source/util/deadmansswitch.mjs +16 -23
  102. package/source/util/freeze.mjs +5 -7
  103. package/source/util/namespace.mjs +1 -1
  104. package/source/util/processing.mjs +33 -39
  105. package/source/util/trimspaces.mjs +17 -24
  106. package/test/cases/monster.mjs +1 -1
@@ -5,28 +5,28 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- import {internalSymbol} from "../constants.mjs";
9
- import {extend} from "../data/extend.mjs";
10
- import {Pathfinder} from "../data/pathfinder.mjs";
11
-
12
- import {parseDataURL} from "../types/dataurl.mjs";
13
- import {getGlobalObject} from "../types/global.mjs";
14
- import {isArray, isFunction, isObject, isString} from "../types/is.mjs";
15
- import {Observer} from "../types/observer.mjs";
16
- import {ProxyObserver} from "../types/proxyobserver.mjs";
17
- import {validateFunction, validateInstance, validateObject, validateString} from "../types/validate.mjs";
18
- import {clone} from "../util/clone.mjs";
19
- import {addAttributeToken, getLinkedObjects, hasObjectLink} from "./attributes.mjs";
8
+ import { internalSymbol } from "../constants.mjs";
9
+ import { extend } from "../data/extend.mjs";
10
+ import { Pathfinder } from "../data/pathfinder.mjs";
11
+
12
+ import { parseDataURL } from "../types/dataurl.mjs";
13
+ import { getGlobalObject } from "../types/global.mjs";
14
+ import { isArray, isFunction, isObject, isString } from "../types/is.mjs";
15
+ import { Observer } from "../types/observer.mjs";
16
+ import { ProxyObserver } from "../types/proxyobserver.mjs";
17
+ import { validateFunction, validateInstance, validateObject, validateString } from "../types/validate.mjs";
18
+ import { clone } from "../util/clone.mjs";
19
+ import { addAttributeToken, getLinkedObjects, hasObjectLink } from "./attributes.mjs";
20
20
  import {
21
21
  ATTRIBUTE_DISABLED,
22
22
  ATTRIBUTE_ERRORMESSAGE,
23
23
  ATTRIBUTE_OPTIONS,
24
24
  ATTRIBUTE_OPTIONS_SELECTOR,
25
- customElementUpdaterLinkSymbol
25
+ customElementUpdaterLinkSymbol,
26
26
  } from "./constants.mjs";
27
- import {findDocumentTemplate, Template} from "./template.mjs";
28
- import {addObjectWithUpdaterToElement} from "./updater.mjs";
29
- import {instanceSymbol} from '../constants.mjs';
27
+ import { findDocumentTemplate, Template } from "./template.mjs";
28
+ import { addObjectWithUpdaterToElement } from "./updater.mjs";
29
+ import { instanceSymbol } from "../constants.mjs";
30
30
 
31
31
  export {
32
32
  CustomElement,
@@ -34,28 +34,27 @@ export {
34
34
  assembleMethodSymbol,
35
35
  attributeObserverSymbol,
36
36
  registerCustomElement,
37
- getSlottedElements
38
- }
37
+ getSlottedElements,
38
+ };
39
39
 
40
40
  /**
41
41
  * @memberOf Monster.DOM
42
42
  * @type {symbol}
43
43
  */
44
- const initMethodSymbol = Symbol.for('@schukai/monster/dom/@@initMethodSymbol');
44
+ const initMethodSymbol = Symbol.for("@schukai/monster/dom/@@initMethodSymbol");
45
45
 
46
46
  /**
47
47
  * @memberOf Monster.DOM
48
48
  * @type {symbol}
49
49
  */
50
- const assembleMethodSymbol = Symbol.for('@schukai/monster/dom/@@assembleMethodSymbol');
50
+ const assembleMethodSymbol = Symbol.for("@schukai/monster/dom/@@assembleMethodSymbol");
51
51
 
52
52
  /**
53
53
  * this symbol holds the attribute observer callbacks. The key is the attribute name.
54
54
  * @memberOf Monster.DOM
55
55
  * @type {symbol}
56
56
  */
57
- const attributeObserverSymbol = Symbol.for('@schukai/monster/dom/@@attributeObserver');
58
-
57
+ const attributeObserverSymbol = Symbol.for("@schukai/monster/dom/@@attributeObserver");
59
58
 
60
59
  /**
61
60
  * HTMLElement
@@ -100,7 +99,6 @@ const attributeObserverSymbol = Symbol.for('@schukai/monster/dom/@@attributeObse
100
99
  * @enduml
101
100
  */
102
101
 
103
-
104
102
  /**
105
103
  * To define a new HTML element we need the power of CustomElement
106
104
  *
@@ -187,7 +185,6 @@ const attributeObserverSymbol = Symbol.for('@schukai/monster/dom/@@attributeObse
187
185
  * @summary A base class for HTML5 customcontrols
188
186
  */
189
187
  class CustomElement extends HTMLElement {
190
-
191
188
  /**
192
189
  * A new object is created. First the `initOptions` method is called. Here the
193
190
  * options can be defined in derived classes. Subsequently, the shadowRoot is initialized.
@@ -197,7 +194,9 @@ class CustomElement extends HTMLElement {
197
194
  */
198
195
  constructor() {
199
196
  super();
200
- this[internalSymbol] = new ProxyObserver({'options': extend({}, this.defaults)});
197
+ this[internalSymbol] = new ProxyObserver({
198
+ options: extend({}, this.defaults),
199
+ });
201
200
  this[attributeObserverSymbol] = {};
202
201
  initOptionObserver.call(this);
203
202
  this[initMethodSymbol]();
@@ -212,7 +211,6 @@ class CustomElement extends HTMLElement {
212
211
  return Symbol.for("@schukai/monster/dom/custom-element");
213
212
  }
214
213
 
215
-
216
214
  /**
217
215
  * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
218
216
  *
@@ -275,11 +273,11 @@ class CustomElement extends HTMLElement {
275
273
  get defaults() {
276
274
  return {
277
275
  ATTRIBUTE_DISABLED: this.getAttribute(ATTRIBUTE_DISABLED),
278
- shadowMode: 'open',
276
+ shadowMode: "open",
279
277
  delegatesFocus: true,
280
278
  templates: {
281
- main: undefined
282
- }
279
+ main: undefined,
280
+ },
283
281
  };
284
282
  }
285
283
 
@@ -329,7 +327,7 @@ class CustomElement extends HTMLElement {
329
327
  * @returns {CustomElement}
330
328
  */
331
329
  attachObserver(observer) {
332
- this[internalSymbol].attachObserver(observer)
330
+ this[internalSymbol].attachObserver(observer);
333
331
  return this;
334
332
  }
335
333
 
@@ -340,7 +338,7 @@ class CustomElement extends HTMLElement {
340
338
  * @returns {CustomElement}
341
339
  */
342
340
  detachObserver(observer) {
343
- this[internalSymbol].detachObserver(observer)
341
+ this[internalSymbol].detachObserver(observer);
344
342
  return this;
345
343
  }
346
344
 
@@ -349,7 +347,7 @@ class CustomElement extends HTMLElement {
349
347
  * @returns {ProxyObserver}
350
348
  */
351
349
  containsObserver(observer) {
352
- return this[internalSymbol].containsObserver(observer)
350
+ return this[internalSymbol].containsObserver(observer);
353
351
  }
354
352
 
355
353
  /**
@@ -364,10 +362,8 @@ class CustomElement extends HTMLElement {
364
362
  let value;
365
363
 
366
364
  try {
367
- value = new Pathfinder(this[internalSymbol].getRealSubject()['options']).getVia(path);
368
- } catch (e) {
369
-
370
- }
365
+ value = new Pathfinder(this[internalSymbol].getRealSubject()["options"]).getVia(path);
366
+ } catch (e) {}
371
367
 
372
368
  if (value === undefined) return defaultValue;
373
369
  return value;
@@ -382,7 +378,7 @@ class CustomElement extends HTMLElement {
382
378
  * @since 1.14.0
383
379
  */
384
380
  setOption(path, value) {
385
- new Pathfinder(this[internalSymbol].getSubject()['options']).setVia(path, value);
381
+ new Pathfinder(this[internalSymbol].getSubject()["options"]).setVia(path, value);
386
382
  return this;
387
383
  }
388
384
 
@@ -392,13 +388,12 @@ class CustomElement extends HTMLElement {
392
388
  * @return {CustomElement}
393
389
  */
394
390
  setOptions(options) {
395
-
396
391
  if (isString(options)) {
397
- options = parseOptionsJSON.call(this, options)
392
+ options = parseOptionsJSON.call(this, options);
398
393
  }
399
394
 
400
395
  const self = this;
401
- extend(self[internalSymbol].getSubject()['options'], self.defaults, options);
396
+ extend(self[internalSymbol].getSubject()["options"], self.defaults, options);
402
397
 
403
398
  return self;
404
399
  }
@@ -420,9 +415,9 @@ class CustomElement extends HTMLElement {
420
415
  * @since 1.8.0
421
416
  */
422
417
  [assembleMethodSymbol]() {
423
-
424
418
  const self = this;
425
- let elements, nodeList;
419
+ let elements;
420
+ let nodeList;
426
421
 
427
422
  const AttributeOptions = getOptionsFromAttributes.call(self);
428
423
  if (isObject(AttributeOptions) && Object.keys(AttributeOptions).length > 0) {
@@ -434,15 +429,11 @@ class CustomElement extends HTMLElement {
434
429
  self.setOptions(ScriptOptions);
435
430
  }
436
431
 
437
-
438
- if (self.getOption('shadowMode', false) !== false) {
432
+ if (self.getOption("shadowMode", false) !== false) {
439
433
  try {
440
434
  initShadowRoot.call(self);
441
435
  elements = self.shadowRoot.childNodes;
442
-
443
- } catch (e) {
444
-
445
- }
436
+ } catch (e) {}
446
437
 
447
438
  try {
448
439
  initCSSStylesheet.call(this);
@@ -459,15 +450,17 @@ class CustomElement extends HTMLElement {
459
450
  }
460
451
 
461
452
  try {
462
- nodeList = new Set([
463
- ...elements,
464
- ...getSlottedElements.call(self)
465
- ])
453
+ nodeList = new Set([...elements, ...getSlottedElements.call(self)]);
466
454
  } catch (e) {
467
- nodeList = elements
455
+ nodeList = elements;
468
456
  }
469
457
 
470
- addObjectWithUpdaterToElement.call(self, nodeList, customElementUpdaterLinkSymbol, clone(self[internalSymbol].getRealSubject()['options']))
458
+ addObjectWithUpdaterToElement.call(
459
+ self,
460
+ nodeList,
461
+ customElementUpdaterLinkSymbol,
462
+ clone(self[internalSymbol].getRealSubject()["options"]),
463
+ );
471
464
  return self;
472
465
  }
473
466
 
@@ -481,7 +474,7 @@ class CustomElement extends HTMLElement {
481
474
  connectedCallback() {
482
475
  let self = this;
483
476
  if (!hasObjectLink(self, customElementUpdaterLinkSymbol)) {
484
- self[assembleMethodSymbol]()
477
+ self[assembleMethodSymbol]();
485
478
  }
486
479
  }
487
480
 
@@ -491,9 +484,7 @@ class CustomElement extends HTMLElement {
491
484
  * @return {void}
492
485
  * @since 1.7.0
493
486
  */
494
- disconnectedCallback() {
495
-
496
- }
487
+ disconnectedCallback() {}
497
488
 
498
489
  /**
499
490
  * The custom element has been moved into a new document (e.g. someone called document.adoptNode(el)).
@@ -501,9 +492,7 @@ class CustomElement extends HTMLElement {
501
492
  * @return {void}
502
493
  * @since 1.7.0
503
494
  */
504
- adoptedCallback() {
505
-
506
- }
495
+ adoptedCallback() {}
507
496
 
508
497
  /**
509
498
  * Called when an observed attribute has been added, removed, updated, or replaced. Also called for initial
@@ -524,7 +513,6 @@ class CustomElement extends HTMLElement {
524
513
  if (isFunction(callback)) {
525
514
  callback.call(self, newVal, oldVal);
526
515
  }
527
-
528
516
  }
529
517
 
530
518
  /**
@@ -546,9 +534,7 @@ class CustomElement extends HTMLElement {
546
534
  }
547
535
 
548
536
  return containChildNode.call(self.shadowRoot, node);
549
-
550
537
  }
551
-
552
538
  }
553
539
 
554
540
  /**
@@ -563,27 +549,25 @@ class CustomElement extends HTMLElement {
563
549
  */
564
550
  function getSlottedElements(query, name) {
565
551
  const self = this;
566
- const result = new Set;
552
+ const result = new Set();
567
553
 
568
554
  if (!(self.shadowRoot instanceof ShadowRoot)) {
569
555
  return result;
570
556
  }
571
557
 
572
- let selector = 'slot';
558
+ let selector = "slot";
573
559
  if (name !== undefined) {
574
560
  if (name === null) {
575
- selector += ':not([name])';
561
+ selector += ":not([name])";
576
562
  } else {
577
- selector += '[name=' + validateString(name) + ']';
563
+ selector += `[name=${validateString(name)}]`;
578
564
  }
579
-
580
565
  }
581
566
 
582
567
  const slots = self.shadowRoot.querySelectorAll(selector);
583
568
 
584
569
  for (const [, slot] of Object.entries(slots)) {
585
570
  slot.assignedElements().forEach(function (node) {
586
-
587
571
  if (!(node instanceof HTMLElement)) return;
588
572
 
589
573
  if (isString(query)) {
@@ -594,13 +578,12 @@ function getSlottedElements(query, name) {
594
578
  if (node.matches(query)) {
595
579
  result.add(node);
596
580
  }
597
-
598
581
  } else if (query !== undefined) {
599
- throw new Error('query must be a string')
582
+ throw new Error("query must be a string");
600
583
  } else {
601
584
  result.add(node);
602
585
  }
603
- })
586
+ });
604
587
  }
605
588
 
606
589
  return result;
@@ -627,7 +610,6 @@ function containChildNode(node) {
627
610
  containChildNode.call(e, node);
628
611
  }
629
612
 
630
-
631
613
  return false;
632
614
  }
633
615
 
@@ -641,59 +623,58 @@ function initOptionObserver() {
641
623
  const self = this;
642
624
 
643
625
  let lastDisabledValue = undefined;
644
- self.attachObserver(new Observer(function () {
645
- const flag = self.getOption('disabled');
646
-
647
- if (flag === lastDisabledValue) {
648
- return;
649
- }
626
+ self.attachObserver(
627
+ new Observer(function () {
628
+ const flag = self.getOption("disabled");
650
629
 
651
- lastDisabledValue = flag;
652
-
653
- if (!(self.shadowRoot instanceof ShadowRoot)) {
654
- return;
655
- }
656
-
657
- const query = 'button, command, fieldset, keygen, optgroup, option, select, textarea, input, [data-monster-objectlink]';
658
- const elements = self.shadowRoot.querySelectorAll(query);
630
+ if (flag === lastDisabledValue) {
631
+ return;
632
+ }
659
633
 
660
- let nodeList;
661
- try {
662
- nodeList = new Set([
663
- ...elements,
664
- ...getSlottedElements.call(self, query)
665
- ])
666
- } catch (e) {
667
- nodeList = elements
668
- }
634
+ lastDisabledValue = flag;
669
635
 
670
- for (const element of [...nodeList]) {
671
- if (flag === true) {
672
- element.setAttribute(ATTRIBUTE_DISABLED, '');
673
- } else {
674
- element.removeAttribute(ATTRIBUTE_DISABLED);
636
+ if (!(self.shadowRoot instanceof ShadowRoot)) {
637
+ return;
675
638
  }
676
- }
677
-
678
- }));
679
639
 
680
- self.attachObserver(new Observer(function () {
640
+ const query =
641
+ "button, command, fieldset, keygen, optgroup, option, select, textarea, input, [data-monster-objectlink]";
642
+ const elements = self.shadowRoot.querySelectorAll(query);
681
643
 
682
- // not initialised
683
- if (!hasObjectLink(self, customElementUpdaterLinkSymbol)) {
684
- return;
685
- }
686
- // inform every element
687
- const updaters = getLinkedObjects(self, customElementUpdaterLinkSymbol);
644
+ let nodeList;
645
+ try {
646
+ nodeList = new Set([...elements, ...getSlottedElements.call(self, query)]);
647
+ } catch (e) {
648
+ nodeList = elements;
649
+ }
688
650
 
689
- for (const list of updaters) {
690
- for (const updater of list) {
691
- let d = clone(self[internalSymbol].getRealSubject()['options']);
692
- Object.assign(updater.getSubject(), d);
651
+ for (const element of [...nodeList]) {
652
+ if (flag === true) {
653
+ element.setAttribute(ATTRIBUTE_DISABLED, "");
654
+ } else {
655
+ element.removeAttribute(ATTRIBUTE_DISABLED);
656
+ }
693
657
  }
694
- }
658
+ }),
659
+ );
660
+
661
+ self.attachObserver(
662
+ new Observer(function () {
663
+ // not initialised
664
+ if (!hasObjectLink(self, customElementUpdaterLinkSymbol)) {
665
+ return;
666
+ }
667
+ // inform every element
668
+ const updaters = getLinkedObjects(self, customElementUpdaterLinkSymbol);
695
669
 
696
- }));
670
+ for (const list of updaters) {
671
+ for (const updater of list) {
672
+ let d = clone(self[internalSymbol].getRealSubject()["options"]);
673
+ Object.assign(updater.getSubject(), d);
674
+ }
675
+ }
676
+ }),
677
+ );
697
678
 
698
679
  // disabled
699
680
  self[attributeObserverSymbol][ATTRIBUTE_DISABLED] = () => {
@@ -702,7 +683,7 @@ function initOptionObserver() {
702
683
  } else {
703
684
  self.setOption(ATTRIBUTE_DISABLED, undefined);
704
685
  }
705
- }
686
+ };
706
687
 
707
688
  // data-monster-options
708
689
  self[attributeObserverSymbol][ATTRIBUTE_OPTIONS] = () => {
@@ -710,7 +691,7 @@ function initOptionObserver() {
710
691
  if (isObject(options) && Object.keys(options).length > 0) {
711
692
  self.setOptions(options);
712
693
  }
713
- }
694
+ };
714
695
 
715
696
  // data-monster-options-selector
716
697
  self[attributeObserverSymbol][ATTRIBUTE_OPTIONS_SELECTOR] = () => {
@@ -718,9 +699,7 @@ function initOptionObserver() {
718
699
  if (isObject(options) && Object.keys(options).length > 0) {
719
700
  self.setOptions(options);
720
701
  }
721
- }
722
-
723
-
702
+ };
724
703
  }
725
704
 
726
705
  /**
@@ -737,20 +716,29 @@ function getOptionsFromScriptTag() {
737
716
 
738
717
  const node = document.querySelector(self.getAttribute(ATTRIBUTE_OPTIONS_SELECTOR));
739
718
  if (!(node instanceof HTMLScriptElement)) {
740
- addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, 'the selector ' + ATTRIBUTE_OPTIONS_SELECTOR + ' for options was specified (' + self.getAttribute(ATTRIBUTE_OPTIONS_SELECTOR) + ') but not found.');
719
+ addAttributeToken(
720
+ self,
721
+ ATTRIBUTE_ERRORMESSAGE,
722
+ `the selector ${ATTRIBUTE_OPTIONS_SELECTOR} for options was specified (${self.getAttribute(
723
+ ATTRIBUTE_OPTIONS_SELECTOR,
724
+ )}) but not found.`,
725
+ );
741
726
  return {};
742
727
  }
743
728
 
744
729
  let obj = {};
745
730
 
746
731
  try {
747
- obj = parseOptionsJSON.call(this, node.textContent.trim())
732
+ obj = parseOptionsJSON.call(this, node.textContent.trim());
748
733
  } catch (e) {
749
- addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, 'when analyzing the configuration from the script tag there was an error. ' + e);
734
+ addAttributeToken(
735
+ self,
736
+ ATTRIBUTE_ERRORMESSAGE,
737
+ `when analyzing the configuration from the script tag there was an error. ${e}`,
738
+ );
750
739
  }
751
740
 
752
741
  return obj;
753
-
754
742
  }
755
743
 
756
744
  /**
@@ -762,9 +750,15 @@ function getOptionsFromAttributes() {
762
750
 
763
751
  if (this.hasAttribute(ATTRIBUTE_OPTIONS)) {
764
752
  try {
765
- return parseOptionsJSON.call(self, this.getAttribute(ATTRIBUTE_OPTIONS))
753
+ return parseOptionsJSON.call(self, this.getAttribute(ATTRIBUTE_OPTIONS));
766
754
  } catch (e) {
767
- addAttributeToken(self, ATTRIBUTE_ERRORMESSAGE, 'the options attribute ' + ATTRIBUTE_OPTIONS + ' does not contain a valid json definition (actual: ' + this.getAttribute(ATTRIBUTE_OPTIONS) + ').' + e);
755
+ addAttributeToken(
756
+ self,
757
+ ATTRIBUTE_ERRORMESSAGE,
758
+ `the options attribute ${ATTRIBUTE_OPTIONS} does not contain a valid json definition (actual: ${this.getAttribute(
759
+ ATTRIBUTE_OPTIONS,
760
+ )}).${e}`,
761
+ );
768
762
  }
769
763
  }
770
764
 
@@ -777,8 +771,7 @@ function getOptionsFromAttributes() {
777
771
  * @return {Object}
778
772
  */
779
773
  function parseOptionsJSON(data) {
780
-
781
- const self = this, obj = {};
774
+ let obj = {};
782
775
 
783
776
  if (!isString(data)) {
784
777
  return obj;
@@ -788,19 +781,15 @@ function parseOptionsJSON(data) {
788
781
  try {
789
782
  let dataUrl = parseDataURL(data);
790
783
  data = dataUrl.content;
791
- } catch (e) {
792
-
793
- }
784
+ } catch (e) {}
794
785
 
795
786
  try {
796
- let obj = JSON.parse(data);
797
- return validateObject(obj);
787
+ obj = JSON.parse(data);
798
788
  } catch (e) {
799
789
  throw e;
800
790
  }
801
791
 
802
-
803
- return obj;
792
+ return validateObject(obj);
804
793
  }
805
794
 
806
795
  /**
@@ -808,21 +797,17 @@ function parseOptionsJSON(data) {
808
797
  * @return {initHtmlContent}
809
798
  */
810
799
  function initHtmlContent() {
811
-
812
800
  try {
813
801
  let template = findDocumentTemplate(this.constructor.getTag());
814
802
  this.appendChild(template.createDocumentFragment());
815
803
  } catch (e) {
816
-
817
- let html = this.getOption('templates.main', '');
804
+ let html = this.getOption("templates.main", "");
818
805
  if (isString(html) && html.length > 0) {
819
806
  this.innerHTML = html;
820
807
  }
821
-
822
808
  }
823
809
 
824
810
  return this;
825
-
826
811
  }
827
812
 
828
813
  /**
@@ -850,11 +835,10 @@ function initCSSStylesheet() {
850
835
  } else if (isArray(styleSheet)) {
851
836
  const assign = [];
852
837
  for (let s of styleSheet) {
853
-
854
838
  if (isString(s)) {
855
- let trimedStyleSheet = s.trim()
856
- if (trimedStyleSheet !== '') {
857
- const style = document.createElement('style')
839
+ let trimedStyleSheet = s.trim();
840
+ if (trimedStyleSheet !== "") {
841
+ const style = document.createElement("style");
858
842
  style.innerHTML = trimedStyleSheet;
859
843
  self.shadowRoot.prepend(style);
860
844
  }
@@ -866,26 +850,21 @@ function initCSSStylesheet() {
866
850
  if (s.cssRules.length > 0) {
867
851
  assign.push(s);
868
852
  }
869
-
870
853
  }
871
854
 
872
855
  if (assign.length > 0) {
873
856
  this.shadowRoot.adoptedStyleSheets = assign;
874
857
  }
875
-
876
858
  } else if (isString(styleSheet)) {
877
-
878
- let trimedStyleSheet = styleSheet.trim()
879
- if (trimedStyleSheet !== '') {
880
- const style = document.createElement('style')
859
+ let trimedStyleSheet = styleSheet.trim();
860
+ if (trimedStyleSheet !== "") {
861
+ const style = document.createElement("style");
881
862
  style.innerHTML = styleSheet;
882
863
  self.shadowRoot.prepend(style);
883
864
  }
884
-
885
865
  }
886
866
 
887
867
  return self;
888
-
889
868
  }
890
869
 
891
870
  /**
@@ -898,23 +877,21 @@ function initCSSStylesheet() {
898
877
  * @since 1.8.0
899
878
  */
900
879
  function initShadowRoot() {
901
-
902
- let template, html;
880
+ let template;
881
+ let html;
903
882
 
904
883
  try {
905
884
  template = findDocumentTemplate(this.constructor.getTag());
906
885
  } catch (e) {
907
-
908
- html = this.getOption('templates.main', '');
886
+ html = this.getOption("templates.main", "");
909
887
  if (!isString(html) || html === undefined || html === "") {
910
888
  throw new Error("html is not set.");
911
889
  }
912
-
913
890
  }
914
891
 
915
892
  this.attachShadow({
916
- mode: this.getOption('shadowMode', 'open'),
917
- delegatesFocus: this.getOption('delegatesFocus', true)
893
+ mode: this.getOption("shadowMode", "open"),
894
+ delegatesFocus: this.getOption("delegatesFocus", true),
918
895
  });
919
896
 
920
897
  if (template instanceof Template) {
@@ -939,6 +916,5 @@ function initShadowRoot() {
939
916
  */
940
917
  function registerCustomElement(element) {
941
918
  validateFunction(element);
942
- getGlobalObject('customElements').define(element.getTag(), element);
919
+ getGlobalObject("customElements").define(element.getTag(), element);
943
920
  }
944
-