@schukai/monster 1.13.0 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. package/CHANGELOG +46 -1
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +2 -2
  4. package/dist/modules/constraints/abstract.js +2 -2
  5. package/dist/modules/constraints/abstractoperator.js +2 -2
  6. package/dist/modules/constraints/andoperator.js +2 -2
  7. package/dist/modules/constraints/invalid.js +2 -2
  8. package/dist/modules/constraints/isarray.js +2 -2
  9. package/dist/modules/constraints/isobject.js +2 -2
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +2 -2
  12. package/dist/modules/constraints/valid.js +2 -2
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/diff.js +2 -2
  15. package/dist/modules/data/extend.js +2 -2
  16. package/dist/modules/data/namespace.js +1 -1
  17. package/dist/modules/data/pathfinder.js +2 -2
  18. package/dist/modules/data/pipe.js +2 -2
  19. package/dist/modules/data/transformer.js +2 -2
  20. package/dist/modules/dom/assembler.js +2 -2
  21. package/dist/modules/dom/attributes.js +2 -2
  22. package/dist/modules/dom/constants.js +2 -2
  23. package/dist/modules/dom/customcontrol.js +2 -0
  24. package/dist/modules/dom/customelement.js +2 -2
  25. package/dist/modules/dom/events.js +2 -2
  26. package/dist/modules/dom/locale.js +2 -2
  27. package/dist/modules/dom/namespace.js +1 -1
  28. package/dist/modules/dom/template.js +2 -2
  29. package/dist/modules/dom/theme.js +2 -2
  30. package/dist/modules/dom/updater.js +2 -2
  31. package/dist/modules/dom/util.js +2 -2
  32. package/dist/modules/i18n/locale.js +2 -2
  33. package/dist/modules/i18n/namespace.js +1 -1
  34. package/dist/modules/i18n/provider.js +2 -2
  35. package/dist/modules/i18n/providers/fetch.js +2 -2
  36. package/dist/modules/i18n/providers/namespace.js +1 -1
  37. package/dist/modules/i18n/translations.js +2 -2
  38. package/dist/modules/logging/handler/console.js +2 -2
  39. package/dist/modules/logging/handler/namespace.js +1 -1
  40. package/dist/modules/logging/handler.js +2 -2
  41. package/dist/modules/logging/logentry.js +2 -2
  42. package/dist/modules/logging/logger.js +2 -2
  43. package/dist/modules/logging/namespace.js +1 -1
  44. package/dist/modules/math/namespace.js +1 -1
  45. package/dist/modules/math/random.js +2 -2
  46. package/dist/modules/monster.js +2 -2
  47. package/dist/modules/namespace.js +2 -2
  48. package/dist/modules/text/formatter.js +2 -2
  49. package/dist/modules/text/namespace.js +1 -1
  50. package/dist/modules/types/base.js +2 -2
  51. package/dist/modules/types/basewithoptions.js +2 -2
  52. package/dist/modules/types/global.js +2 -2
  53. package/dist/modules/types/id.js +2 -2
  54. package/dist/modules/types/is.js +2 -2
  55. package/dist/modules/types/namespace.js +1 -1
  56. package/dist/modules/types/observer.js +2 -2
  57. package/dist/modules/types/observerlist.js +2 -2
  58. package/dist/modules/types/proxyobserver.js +2 -2
  59. package/dist/modules/types/queue.js +2 -2
  60. package/dist/modules/types/randomid.js +2 -2
  61. package/dist/modules/types/stack.js +2 -2
  62. package/dist/modules/types/tokenlist.js +2 -2
  63. package/dist/modules/types/typeof.js +2 -2
  64. package/dist/modules/types/uniquequeue.js +2 -2
  65. package/dist/modules/types/validate.js +2 -2
  66. package/dist/modules/types/version.js +2 -2
  67. package/dist/modules/util/clone.js +2 -2
  68. package/dist/modules/util/comparator.js +2 -2
  69. package/dist/modules/util/freeze.js +2 -2
  70. package/dist/modules/util/namespace.js +1 -1
  71. package/dist/monster.dev.js +8622 -7709
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +2 -9
  74. package/package.json +1 -1
  75. package/source/constants.js +7 -6
  76. package/source/constraints/abstract.js +2 -2
  77. package/source/constraints/abstractoperator.js +4 -4
  78. package/source/constraints/andoperator.js +8 -8
  79. package/source/constraints/invalid.js +6 -6
  80. package/source/constraints/isarray.js +7 -7
  81. package/source/constraints/isobject.js +7 -7
  82. package/source/constraints/namespace.js +2 -2
  83. package/source/constraints/oroperator.js +8 -8
  84. package/source/constraints/valid.js +7 -7
  85. package/source/data/buildmap.js +15 -15
  86. package/source/data/diff.js +9 -9
  87. package/source/data/extend.js +55 -13
  88. package/source/data/namespace.js +2 -2
  89. package/source/data/pathfinder.js +13 -14
  90. package/source/data/pipe.js +8 -8
  91. package/source/data/transformer.js +11 -11
  92. package/source/dom/assembler.js +7 -7
  93. package/source/dom/attributes.js +89 -46
  94. package/source/dom/constants.js +9 -2
  95. package/source/dom/customcontrol.js +299 -0
  96. package/source/dom/customelement.js +181 -66
  97. package/source/dom/events.js +58 -8
  98. package/source/dom/locale.js +5 -5
  99. package/source/dom/namespace.js +2 -2
  100. package/source/dom/template.js +24 -19
  101. package/source/dom/theme.js +8 -9
  102. package/source/dom/updater.js +46 -24
  103. package/source/dom/util.js +10 -10
  104. package/source/i18n/locale.js +7 -7
  105. package/source/i18n/namespace.js +1 -1
  106. package/source/i18n/provider.js +6 -6
  107. package/source/i18n/providers/fetch.js +10 -10
  108. package/source/i18n/translations.js +5 -5
  109. package/source/logging/handler/console.js +5 -5
  110. package/source/logging/handler/namespace.js +1 -1
  111. package/source/logging/handler.js +8 -8
  112. package/source/logging/logentry.js +5 -5
  113. package/source/logging/logger.js +5 -5
  114. package/source/logging/namespace.js +2 -2
  115. package/source/math/namespace.js +2 -2
  116. package/source/math/random.js +5 -5
  117. package/source/monster.js +48 -44
  118. package/source/namespace.js +2 -2
  119. package/source/text/formatter.js +6 -7
  120. package/source/text/namespace.js +1 -1
  121. package/source/types/base.js +4 -5
  122. package/source/types/basewithoptions.js +10 -9
  123. package/source/types/global.js +7 -7
  124. package/source/types/id.js +7 -7
  125. package/source/types/is.js +22 -22
  126. package/source/types/namespace.js +2 -2
  127. package/source/types/observer.js +7 -7
  128. package/source/types/observerlist.js +4 -4
  129. package/source/types/proxyobserver.js +32 -26
  130. package/source/types/queue.js +13 -7
  131. package/source/types/randomid.js +6 -6
  132. package/source/types/stack.js +11 -4
  133. package/source/types/tokenlist.js +9 -9
  134. package/source/types/typeof.js +5 -5
  135. package/source/types/uniquequeue.js +14 -7
  136. package/source/types/validate.js +27 -27
  137. package/source/types/version.js +9 -9
  138. package/source/util/clone.js +6 -6
  139. package/source/util/comparator.js +7 -7
  140. package/source/util/freeze.js +7 -7
  141. package/source/util/namespace.js +2 -2
  142. package/test/cases/data/extend.js +66 -13
  143. package/test/cases/dom/attributes.js +56 -1
  144. package/test/cases/dom/customcontrol.js +264 -0
  145. package/test/cases/dom/customelement.js +112 -51
  146. package/test/cases/dom/events.js +32 -14
  147. package/test/cases/dom/template.js +40 -1
  148. package/test/cases/monster.js +1 -1
  149. package/test/cases/types/proxyobserver.js +9 -0
  150. package/test/util/jsdom.js +3 -0
  151. package/test/web/import.js +1 -0
  152. package/test/web/monster-dev.html +3 -3
  153. package/test/web/monster.html +2 -2
  154. package/test/web/test.html +3 -3
  155. package/test/web/tests.js +3 -3
@@ -2,7 +2,7 @@
2
2
 
3
3
  import {expect} from "chai"
4
4
 
5
- import {fireEvent} from "../../../source/dom/events.js";
5
+ import {fireEvent, findTargetElementFromEvent} from "../../../source/dom/events.js";
6
6
  import {initJSDOM} from "../../util/jsdom.js";
7
7
 
8
8
  describe('Events', function () {
@@ -11,6 +11,24 @@ describe('Events', function () {
11
11
  initJSDOM();
12
12
  })
13
13
 
14
+ describe('findTargetElementFromEvent()', function () {
15
+
16
+ it('find object', function (done) {
17
+ let container = document.createElement('div');
18
+ container.setAttribute('data-monster', 'hello');
19
+ let div = document.createElement('div');
20
+ container.appendChild(div);
21
+ div.addEventListener('click', (event) => {
22
+
23
+ let e = findTargetElementFromEvent(event, 'data-monster');
24
+ expect(e.getAttribute('data-monster')).to.be.equal('hello')
25
+ done();
26
+ })
27
+ fireEvent(div, 'click');
28
+ });
29
+
30
+ });
31
+
14
32
  describe('fireEvent()', function () {
15
33
  it('should fire a click event', function (done) {
16
34
  let div = document.createElement('div');
@@ -19,7 +37,7 @@ describe('Events', function () {
19
37
  })
20
38
  fireEvent(div, 'click');
21
39
  });
22
-
40
+
23
41
  it('should fire a touch event', function (done) {
24
42
  let div = document.createElement('div');
25
43
  div.addEventListener('touch', () => {
@@ -27,36 +45,36 @@ describe('Events', function () {
27
45
  })
28
46
  fireEvent(div, 'touch');
29
47
  });
30
-
48
+
31
49
  it('should fire a touch event on collection', function (done) {
32
50
  let div = document.createElement('div');
33
51
  div.addEventListener('touch', () => {
34
52
  done();
35
53
  })
36
-
54
+
37
55
  div.appendChild(document.createElement('div'));
38
56
  let collection = div.querySelectorAll('div');
39
-
40
-
57
+
58
+
41
59
  fireEvent(collection, 'touch');
42
60
  });
43
-
61
+
44
62
  it('should fire a touch event', function (done) {
45
63
  let div = document.createElement('div');
46
64
  div.addEventListener('touch', () => {
47
65
  done();
48
66
  })
49
-
67
+
50
68
  div.appendChild(document.createElement('div'));
51
69
  let collection = div.querySelectorAll('div');
52
-
53
-
70
+
71
+
54
72
  fireEvent(collection, 'touch');
55
- });
56
-
73
+ });
74
+
57
75
  it('should throw error', function () {
58
- expect(() => fireEvent({}, 'touch')).to.throw(Error);
59
- ;
76
+ expect(() => fireEvent({}, 'touch')).to.throw(Error);
77
+ ;
60
78
  });
61
79
  });
62
80
 
@@ -2,13 +2,32 @@
2
2
 
3
3
  import {expect} from "chai"
4
4
 
5
- import {Template} from "../../../source/dom/template.js";
5
+ import {findDocumentTemplate, Template} from "../../../source/dom/template.js";
6
6
  import {initJSDOM} from "../../util/jsdom.js";
7
7
 
8
+ const html1 = `
9
+
10
+ <template id="mytemplate"></template>
11
+
12
+ `;
13
+
14
+
8
15
  describe('Template', function () {
16
+
9
17
  before(async function () {
10
18
  initJSDOM();
11
19
  })
20
+
21
+ beforeEach(() => {
22
+ let mocks = document.getElementById('mocks');
23
+ mocks.innerHTML = html1;
24
+ })
25
+
26
+ afterEach(() => {
27
+ let mocks = document.getElementById('mocks');
28
+ mocks.innerHTML = "";
29
+ })
30
+
12
31
  describe('create HTMLFragment', function () {
13
32
  [
14
33
  ["<div>first</div><div>second</div>"],
@@ -46,4 +65,24 @@ describe('Template', function () {
46
65
  });
47
66
  });
48
67
 
68
+ describe('.findDocumentTemplate()', function () {
69
+ it('should throw Template not found', function () {
70
+ const div = document.createElement('div');
71
+ expect(() => {
72
+ findDocumentTemplate("noway", div)
73
+ }).to.throws(Error);
74
+ })
75
+ });
76
+
77
+ describe('.findDocumentTemplate()', function () {
78
+ it('should throw Template not found', function () {
79
+ const div = document.createElement('div');
80
+ div.remove();
81
+ let t = findDocumentTemplate("mytemplate", div);
82
+ expect(t).is.instanceof(Template);
83
+
84
+ })
85
+ });
86
+
87
+
49
88
  });
@@ -9,7 +9,7 @@ describe('Monster', function () {
9
9
  let monsterVersion
10
10
 
11
11
  /**#@+ dont touch, replaced by make with package.json version */
12
- monsterVersion = new Version('1.13.0')
12
+ monsterVersion = new Version('1.15.2')
13
13
  /**#@-*/
14
14
 
15
15
  let m = Monster.getVersion();
@@ -12,6 +12,15 @@ describe('ProxyObserver', function () {
12
12
  expect(o).is.instanceOf(ProxyObserver);
13
13
  });
14
14
  });
15
+
16
+ describe('proxy objects', function () {
17
+ it('Proxy objects should not be recommitted', function () {
18
+ let o = new ProxyObserver({a:{b:true}});
19
+ o.getSubject().a.b=o.getSubject();
20
+ o.getSubject().a.b.a.b=false;
21
+ //expect(o.getSubject()===p.getSubject()).to.be.true;
22
+ });
23
+ });
15
24
 
16
25
  describe('notify observer', function () {
17
26
  it('should inform observer', function (done) {
@@ -34,6 +34,8 @@ function initJSDOM() {
34
34
  'self',
35
35
  'HTMLCollection',
36
36
  'NodeList',
37
+ 'ElementInternals',
38
+ 'HTMLFormElement',
37
39
  'HTMLInputElement',
38
40
  'HTMLSelectElement',
39
41
  'HTMLTextAreaElement',
@@ -54,6 +56,7 @@ function initJSDOM() {
54
56
  'HTMLTemplateElement',
55
57
  'XMLSerializer',
56
58
  'NodeFilter',
59
+ 'navigator',
57
60
  'InputEvent',
58
61
  'CustomEvent'
59
62
  ].forEach(key => (g[key] = window[key]));
@@ -9,6 +9,7 @@ import "../cases/dom/attributes.js";
9
9
  import "../cases/dom/template.js";
10
10
  import "../cases/dom/util.js";
11
11
  import "../cases/dom/locale.js";
12
+ import "../cases/dom/customcontrol.js";
12
13
  import "../cases/dom/assembler.js";
13
14
  import "../cases/dom/theme.js";
14
15
  import "../cases/dom/events.js";
@@ -10,13 +10,13 @@
10
10
  crossorigin="anonymous"
11
11
  referrerpolicy="no-referrer"></script>
12
12
 
13
- <script src="https://monsterjs.org/dist/1.13.0/dist/monster.dev.js"></script>
13
+ <script src="https://monsterjs.org/dist/1.15.2/dist/monster.dev.js"></script>
14
14
 
15
15
  </head>
16
16
  <body>
17
17
  <div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
18
- <h1 style='margin-bottom: 0.1em;'>Monster 1.13.0</h1>
19
- <div id="lastupdate" style='font-size:0.7em'>last update Mo 6. Sep 15:27:48 CEST 2021</div>
18
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.15.2</h1>
19
+ <div id="lastupdate" style='font-size:0.7em'>last update Mo 20. Sep 14:28:00 CEST 2021</div>
20
20
  </div>
21
21
  </body>
22
22
  </html>
@@ -14,8 +14,8 @@
14
14
  </head>
15
15
  <body>
16
16
  <div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
17
- <h1 style='margin-bottom: 0.1em;'>Monster 1.13.0</h1>
18
- <div id="lastupdate" style='font-size:0.7em'>last update Mo 6. Sep 15:27:48 CEST 2021</div>
17
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.15.2</h1>
18
+ <div id="lastupdate" style='font-size:0.7em'>last update Mo 20. Sep 14:28:00 CEST 2021</div>
19
19
  </div>
20
20
  </body>
21
21
  </html>
@@ -5,15 +5,15 @@
5
5
  <title>Mocha Monster</title>
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
7
7
  <link rel="stylesheet" href="mocha.css"/>
8
- <script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.map,Array.prototype.reduce,ArrayBuffer,DataView,document,DocumentFragment,Element,Event,globalThis,HTMLDocument,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.trim,Symbol,Symbol.for,Symbol.iterator,Uint8Array,URL,WeakMap,WeakSet"
8
+ <script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.map,Array.prototype.reduce,ArrayBuffer,DataView,document,Document,DocumentFragment,Element,Event,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.trim,Symbol,Symbol.for,Symbol.iterator,Uint8Array,URL,WeakMap,WeakSet"
9
9
  crossorigin="anonymous"
10
10
  referrerpolicy="no-referrer"></script>
11
11
 
12
12
  </head>
13
13
  <body>
14
14
  <div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
15
- <h1 style='margin-bottom: 0.1em;'>Monster 1.13.0</h1>
16
- <div id="lastupdate" style='font-size:0.7em'>last update Mo 6. Sep 15:27:48 CEST 2021</div>
15
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.15.2</h1>
16
+ <div id="lastupdate" style='font-size:0.7em'>last update Mo 20. Sep 14:28:00 CEST 2021</div>
17
17
  </div>
18
18
  <div id="mocks"></div>
19
19
  <div id="mocha"></div>