@schukai/monster 1.14.1 → 1.15.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.
Files changed (139) hide show
  1. package/CHANGELOG +14 -0
  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 -2
  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 +1 -1
  47. package/dist/modules/namespace.js +1 -1
  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 +1096 -844
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +3 -3
  74. package/package.json +1 -1
  75. package/source/constants.js +6 -5
  76. package/source/constraints/abstract.js +2 -2
  77. package/source/constraints/abstractoperator.js +3 -3
  78. package/source/constraints/andoperator.js +7 -7
  79. package/source/constraints/invalid.js +6 -6
  80. package/source/constraints/isarray.js +6 -6
  81. package/source/constraints/isobject.js +6 -6
  82. package/source/constraints/oroperator.js +8 -8
  83. package/source/constraints/valid.js +6 -6
  84. package/source/data/buildmap.js +15 -15
  85. package/source/data/diff.js +6 -6
  86. package/source/data/extend.js +55 -13
  87. package/source/data/pathfinder.js +6 -7
  88. package/source/data/pipe.js +5 -5
  89. package/source/data/transformer.js +5 -6
  90. package/source/dom/assembler.js +5 -5
  91. package/source/dom/attributes.js +26 -26
  92. package/source/dom/constants.js +1 -2
  93. package/source/dom/customcontrol.js +14 -50
  94. package/source/dom/customelement.js +125 -28
  95. package/source/dom/events.js +7 -7
  96. package/source/dom/locale.js +5 -5
  97. package/source/dom/template.js +7 -7
  98. package/source/dom/theme.js +6 -6
  99. package/source/dom/updater.js +35 -13
  100. package/source/dom/util.js +9 -9
  101. package/source/i18n/locale.js +7 -7
  102. package/source/i18n/provider.js +5 -5
  103. package/source/i18n/providers/fetch.js +10 -10
  104. package/source/i18n/translations.js +5 -5
  105. package/source/logging/handler/console.js +4 -4
  106. package/source/logging/handler.js +4 -4
  107. package/source/logging/logentry.js +4 -4
  108. package/source/logging/logger.js +4 -4
  109. package/source/math/random.js +5 -5
  110. package/source/namespace.js +1 -1
  111. package/source/text/formatter.js +4 -5
  112. package/source/types/base.js +4 -5
  113. package/source/types/basewithoptions.js +9 -8
  114. package/source/types/global.js +6 -6
  115. package/source/types/id.js +6 -6
  116. package/source/types/is.js +22 -22
  117. package/source/types/observer.js +5 -5
  118. package/source/types/observerlist.js +4 -4
  119. package/source/types/proxyobserver.js +32 -26
  120. package/source/types/queue.js +13 -7
  121. package/source/types/randomid.js +5 -5
  122. package/source/types/stack.js +11 -4
  123. package/source/types/tokenlist.js +4 -4
  124. package/source/types/typeof.js +5 -5
  125. package/source/types/uniquequeue.js +11 -4
  126. package/source/types/validate.js +22 -22
  127. package/source/types/version.js +9 -9
  128. package/source/util/clone.js +4 -4
  129. package/source/util/comparator.js +6 -6
  130. package/source/util/freeze.js +4 -4
  131. package/test/cases/data/extend.js +66 -13
  132. package/test/cases/dom/customcontrol.js +16 -2
  133. package/test/cases/dom/customelement.js +64 -6
  134. package/test/cases/monster.js +1 -1
  135. package/test/cases/types/proxyobserver.js +9 -0
  136. package/test/web/monster-dev.html +3 -3
  137. package/test/web/monster.html +2 -2
  138. package/test/web/test.html +3 -3
  139. package/test/web/tests.js +3 -3
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ import {PROPERTY_KEY_INTERNALDATA} from "../../../source/constants.js";
4
+ import {ATTRIBUTE_OPTIONS} from "../../../source/dom/constants.js";
3
5
  import {getDocument} from "../../../source/dom/util.js";
4
6
  import {initJSDOM} from "../../util/jsdom.js";
5
7
  import chai from "chai"
@@ -14,6 +16,8 @@ let html1 = `
14
16
  </div>
15
17
  `;
16
18
 
19
+ const internalDataSymbol = Symbol.for(PROPERTY_KEY_INTERNALDATA);
20
+
17
21
  describe('DOM', function () {
18
22
 
19
23
  let CustomElement, registerCustomElement, TestComponent, document, TestComponent2;
@@ -80,7 +84,7 @@ describe('DOM', function () {
80
84
  afterEach(() => {
81
85
  let mocks = document.getElementById('mocks');
82
86
  mocks.innerHTML = "";
83
- })
87
+ })
84
88
 
85
89
  describe('create', function () {
86
90
  it('should return custom-element object', function () {
@@ -102,22 +106,76 @@ describe('DOM', function () {
102
106
  it('document should contain monster-testclass2', function (done) {
103
107
  let d = document.createElement('monster-testclass2');
104
108
  document.getElementById('test1').appendChild(d);
105
-
109
+
106
110
  // insert DOM run in extra process via setTimeout!
107
- setTimeout(function(){
111
+ setTimeout(function () {
108
112
  try {
109
113
  expect(document.getElementsByTagName('monster-testclass2').length).is.equal(1);
110
114
  expect(document.getElementsByTagName('monster-testclass2').item(0).shadowRoot.innerHTML).is.equal('<h1></h1><article><p>test</p></article>');
111
115
  expect(document.getElementById('test1')).contain.html('<monster-testclass2 data-monster-objectlink="Symbol(monsterUpdater)"></monster-testclass2>');
112
- } catch(e) {
116
+ } catch (e) {
113
117
  done(e);
114
118
  }
115
119
  done();
116
- },100);
117
-
120
+ }, 100);
121
+
118
122
  });
119
123
  });
120
124
 
125
+ describe('Options change', function () {
126
+
127
+ it('delegatesFocus should change from true to false', function () {
128
+ let element = document.createElement('monster-testclass')
129
+
130
+ const o = element[internalDataSymbol].realSubject;
131
+ expect(Object.is(element[internalDataSymbol].realSubject, o)).to.be.true;
132
+
133
+ expect(element[internalDataSymbol].realSubject.options.delegatesFocus).to.be.true;
134
+ expect(element[internalDataSymbol].subject.options.delegatesFocus).to.be.true;
135
+ expect(element.getOption('delegatesFocus')).to.be.true;
136
+ expect(Object.is(element[internalDataSymbol].realSubject, o)).to.be.true;
137
+
138
+ element.setAttribute(ATTRIBUTE_OPTIONS, JSON.stringify({delegatesFocus: false}));
139
+ expect(Object.is(element[internalDataSymbol].realSubject, o)).to.be.true;
140
+
141
+ expect(element.getOption('delegatesFocus')).to.be.false;
142
+ expect(element[internalDataSymbol].realSubject.options.delegatesFocus).to.be.false;
143
+ expect(Object.is(element[internalDataSymbol].realSubject, o)).to.be.true;
144
+
145
+ })
146
+
147
+
148
+ })
149
+
150
+ describe('setOptions()', function () {
151
+ [
152
+ ['shadowMode', 'x1'],
153
+ ['templates.main', 'x2'], // is explicitly set to undefined
154
+ ['delegatesFocus', 'x4'],
155
+ ].forEach(function (data) {
156
+
157
+
158
+ let key = data.shift()
159
+ let newValue = data.shift()
160
+
161
+ let text = key + ' should return ' + newValue;
162
+ if (newValue !== undefined) {
163
+ text = key + ' was not set, therefore default ' + newValue;
164
+ }
165
+
166
+
167
+ it(text, function () {
168
+
169
+ let d = document.createElement('monster-testclass');
170
+ expect(d.getOption(key)).to.be.not.equal(newValue);
171
+ let x = d.setOption(key, newValue);
172
+ expect(d.getOption(key)).to.be.equal(newValue);
173
+ })
174
+
175
+
176
+ })
177
+ });
178
+
121
179
  describe('getOptions()', function () {
122
180
 
123
181
  [
@@ -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.14.1')
12
+ monsterVersion = new Version('1.15.0')
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) {
@@ -10,13 +10,13 @@
10
10
  crossorigin="anonymous"
11
11
  referrerpolicy="no-referrer"></script>
12
12
 
13
- <script src="https://monsterjs.org/dist/1.14.1/dist/monster.dev.js"></script>
13
+ <script src="https://monsterjs.org/dist/1.15.0/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.14.1</h1>
19
- <div id="lastupdate" style='font-size:0.7em'>last update So 12. Sep 17:46:14 CEST 2021</div>
18
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.15.0</h1>
19
+ <div id="lastupdate" style='font-size:0.7em'>last update So 19. Sep 14:41:13 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.14.1</h1>
18
- <div id="lastupdate" style='font-size:0.7em'>last update So 12. Sep 17:46:14 CEST 2021</div>
17
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.15.0</h1>
18
+ <div id="lastupdate" style='font-size:0.7em'>last update So 19. Sep 14:41:13 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,console,DataView,document,DocumentFragment,Element,Event,globalThis,HTMLDocument,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"
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,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.14.1</h1>
16
- <div id="lastupdate" style='font-size:0.7em'>last update So 12. Sep 17:46:14 CEST 2021</div>
15
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.15.0</h1>
16
+ <div id="lastupdate" style='font-size:0.7em'>last update So 19. Sep 14:41:13 CEST 2021</div>
17
17
  </div>
18
18
  <div id="mocks"></div>
19
19
  <div id="mocha"></div>