@schukai/monster 1.12.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. package/CHANGELOG +40 -1
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +2 -0
  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 -0
  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 -0
  33. package/dist/modules/i18n/namespace.js +2 -0
  34. package/dist/modules/i18n/provider.js +2 -0
  35. package/dist/modules/i18n/providers/fetch.js +2 -0
  36. package/dist/modules/i18n/providers/namespace.js +2 -0
  37. package/dist/modules/i18n/translations.js +2 -0
  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 +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 -0
  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 +8692 -6669
  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 +22 -0
  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/namespace.js +2 -0
  83. package/source/constraints/oroperator.js +8 -8
  84. package/source/constraints/valid.js +6 -6
  85. package/source/data/buildmap.js +15 -15
  86. package/source/data/diff.js +6 -6
  87. package/source/data/extend.js +55 -13
  88. package/source/data/namespace.js +2 -0
  89. package/source/data/pathfinder.js +6 -7
  90. package/source/data/pipe.js +5 -5
  91. package/source/data/transformer.js +6 -6
  92. package/source/dom/assembler.js +5 -5
  93. package/source/dom/attributes.js +89 -45
  94. package/source/dom/constants.js +8 -9
  95. package/source/dom/customcontrol.js +301 -0
  96. package/source/dom/customelement.js +149 -31
  97. package/source/dom/events.js +58 -8
  98. package/source/dom/locale.js +59 -0
  99. package/source/dom/namespace.js +2 -0
  100. package/source/dom/template.js +7 -7
  101. package/source/dom/theme.js +6 -6
  102. package/source/dom/updater.js +38 -11
  103. package/source/dom/util.js +10 -10
  104. package/source/i18n/locale.js +322 -0
  105. package/source/i18n/namespace.js +15 -0
  106. package/source/i18n/provider.js +58 -0
  107. package/source/i18n/providers/fetch.js +121 -0
  108. package/source/i18n/providers/namespace.js +15 -0
  109. package/source/i18n/translations.js +209 -0
  110. package/source/logging/handler/console.js +4 -4
  111. package/source/logging/handler.js +4 -4
  112. package/source/logging/logentry.js +4 -4
  113. package/source/logging/logger.js +4 -4
  114. package/source/logging/namespace.js +2 -0
  115. package/source/math/namespace.js +2 -0
  116. package/source/math/random.js +5 -5
  117. package/source/monster.js +26 -16
  118. package/source/namespace.js +10 -8
  119. package/source/text/formatter.js +4 -5
  120. package/source/text/namespace.js +1 -1
  121. package/source/types/base.js +4 -7
  122. package/source/types/basewithoptions.js +97 -0
  123. package/source/types/global.js +6 -6
  124. package/source/types/id.js +6 -6
  125. package/source/types/is.js +22 -22
  126. package/source/types/namespace.js +3 -1
  127. package/source/types/observer.js +5 -5
  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 +5 -5
  132. package/source/types/stack.js +11 -4
  133. package/source/types/tokenlist.js +4 -4
  134. package/source/types/typeof.js +5 -5
  135. package/source/types/uniquequeue.js +11 -4
  136. package/source/types/validate.js +22 -22
  137. package/source/types/version.js +9 -9
  138. package/source/util/clone.js +4 -4
  139. package/source/util/comparator.js +6 -6
  140. package/source/util/freeze.js +4 -4
  141. package/source/util/namespace.js +2 -0
  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/locale.js +44 -0
  148. package/test/cases/i18n/locale.js +80 -0
  149. package/test/cases/i18n/provider.js +15 -0
  150. package/test/cases/i18n/providers/fetch.js +65 -0
  151. package/test/cases/i18n/translations.js +57 -0
  152. package/test/cases/monster.js +3 -1
  153. package/test/cases/{util → text}/formatter.js +2 -0
  154. package/test/cases/types/basewithoptions.js +25 -0
  155. package/test/cases/types/proxyobserver.js +9 -0
  156. package/test/cases/{text → util}/clone.js +0 -0
  157. package/test/cases/{text → util}/comparator.js +0 -0
  158. package/test/util/jsdom.js +4 -0
  159. package/test/web/import.js +10 -3
  160. package/test/web/monster-dev.html +3 -3
  161. package/test/web/monster.html +3 -3
  162. package/test/web/test.html +3 -3
  163. package/test/web/tests.js +3 -3
@@ -7,6 +7,23 @@ describe('extend', function () {
7
7
 
8
8
  [
9
9
  [
10
+ '{"a":{"b":["1","2","3"]}}',
11
+ {
12
+ a: {
13
+ b: [
14
+ "1",
15
+ "2",
16
+ "3"
17
+ ]
18
+ }
19
+ },
20
+ {
21
+ a: {
22
+ b: []
23
+ }
24
+ },
25
+ ], [
26
+ '{"a":{"b":1,"d":1}}',
10
27
  {
11
28
  a: {
12
29
  b: 1
@@ -17,43 +34,79 @@ describe('extend', function () {
17
34
  d: 1
18
35
  }
19
36
  },
20
- undefined,
21
- '{"a":{"b":1,"d":1}}'
22
37
  ],
23
38
 
24
39
  [
40
+ '{"a":{"b":1,"d":{"x":["car"],"f":true,"g":[]}}}',
41
+ {},
25
42
  {
26
43
  a: {
27
44
  b: 1,
28
- d:["car"]
45
+ d: {x: ["car"]}
29
46
  }
30
47
  },
31
48
  {
32
49
  a: {
33
50
  d: {
34
- f:true,
51
+ f: true,
35
52
  g: []
36
53
  }
37
54
  }
38
55
  },
39
- undefined,
40
- '{"a":{"b":1,"d":{"0":"car","f":true,"g":[]}}}'
41
56
  ]
42
-
57
+
43
58
  ].forEach(function (data) {
44
59
 
45
- let a = data.shift()
46
- let b = data.shift()
47
- let c = data.shift()
48
60
  let d = data.shift()
61
+ let a = data
49
62
 
50
-
51
- it('.extend(' + JSON.stringify(a) + ', ' + JSON.stringify(b) + ', ' + JSON.stringify(c) + ') should result in ' + d, function () {
52
- let x = extend(a, b, c);
63
+ it('.extend(' + JSON.stringify(a) + ') should result in ' + d, function () {
64
+ let x = extend.apply(this, a);
53
65
  expect(JSON.stringify(x)).is.equal(d);
54
66
  });
55
67
 
56
68
 
57
69
  });
58
70
 
71
+
72
+ [
73
+
74
+
75
+ [
76
+ {},
77
+ {
78
+ a: {
79
+ b: 1,
80
+ d: ["car"]
81
+ }
82
+ },
83
+ {
84
+ a: {
85
+ d: {
86
+ f: true,
87
+ g: []
88
+ }
89
+ }
90
+ },
91
+ ],
92
+ [
93
+ {
94
+ a: {}
95
+ },
96
+ {
97
+ a: []
98
+ }
99
+ ]
100
+
101
+ ].forEach(function (data) {
102
+
103
+ let a = data
104
+
105
+ it('.extend(' + JSON.stringify(a) + ') should throw Error ', function () {
106
+ expect(() => extend.apply(this, a)).to.throw(Error);
107
+ });
108
+
109
+
110
+ });
111
+
59
112
  })
@@ -8,7 +8,13 @@ import {
8
8
  containsAttributeToken,
9
9
  replaceAttributeToken,
10
10
  clearAttributeTokens,
11
- removeAttributeToken, hasObjectLink, addToObjectLink, removeObjectLink, getLinkedObjects, findClosestObjectLink
11
+ removeAttributeToken,
12
+ hasObjectLink,
13
+ addToObjectLink,
14
+ removeObjectLink,
15
+ getLinkedObjects,
16
+ findClosestObjectLink,
17
+ findClosestByAttribute
12
18
  } from "../../../source/dom/attributes.js";
13
19
 
14
20
  import {initJSDOM} from "../../util/jsdom.js";
@@ -26,6 +32,18 @@ let html2 = `<div id="test1">
26
32
  </div>
27
33
  </div>
28
34
  `;
35
+ let html3 = `<div data-monster-role="test1">
36
+ <div data-monster-role="sub1" id="a1">
37
+ <div data-monster-role="sub2" id="a2">
38
+ <div data-monster-role="sub3" id="a3">
39
+ <div data-monster-role="sub4" id="a4">
40
+ <div data-monster-role="sub5" id="a5"></div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ `;
29
47
 
30
48
  describe('Attributes', function () {
31
49
  before(function (done) {
@@ -99,6 +117,43 @@ describe('Attributes', function () {
99
117
 
100
118
  });
101
119
 
120
+ describe('Attributes', function () {
121
+ beforeEach(() => {
122
+ let mocks = document.getElementById('mocks');
123
+ mocks.innerHTML = html3;
124
+ })
125
+
126
+ afterEach(() => {
127
+ let mocks = document.getElementById('mocks');
128
+ mocks.innerHTML = "";
129
+ })
130
+
131
+ describe('find closest Attributes', function () {
132
+
133
+ [
134
+ ['a5', 'data-monster-role', undefined, 'sub5'],
135
+ ['a5', 'data-monster-role', 'sub3', 'sub3'],
136
+ ['a5', 'data-monster-role', 'sub1', 'sub1'],
137
+ ['a4', 'data-monster-role', 'sub1', 'sub1'],
138
+ ['a3', 'data-monster-role', 'sub1', 'sub1'],
139
+ ['a2', 'data-monster-role', undefined, 'sub2'],
140
+ ['a5', 'data-monster-role', 'sub5', 'sub5']
141
+ ].forEach(function (data) {
142
+
143
+ let a = data.shift()
144
+ let b = data.shift()
145
+ let c = data.shift()
146
+ let d = data.shift()
147
+
148
+ it('findClosestByAttribute(' + a + ', ' + b + ',' + c + ') should return ' + d, function () {
149
+ expect(findClosestByAttribute(document.getElementById(a), b, c).getAttribute('data-monster-role')).to.be.equal(d);
150
+ })
151
+
152
+
153
+ });
154
+ });
155
+ });
156
+
102
157
  describe('Attributes', function () {
103
158
 
104
159
  beforeEach(() => {
@@ -0,0 +1,264 @@
1
+ 'use strict';
2
+
3
+ import {ATTRIBUTE_OPTIONS} from "../../../source/dom/constants.js";
4
+ import {getDocument} from "../../../source/dom/util.js";
5
+ import {ID} from "../../../source/types/id.js";
6
+ import {initJSDOM} from "../../util/jsdom.js";
7
+ import chai from "chai"
8
+ import {chaiDom} from "../../util/chai-dom.js";
9
+
10
+
11
+ let expect = chai.expect;
12
+ chai.use(chaiDom);
13
+
14
+ let html1 = `
15
+ <div id="test1">
16
+ </div>
17
+ `;
18
+
19
+ describe('DOM', function () {
20
+
21
+ let CustomControl, registerCustomElement, TestComponent, document, jsdomFlag;
22
+
23
+ describe('CustomControl()', function () {
24
+
25
+ before(function (done) {
26
+ initJSDOM().then(() => {
27
+
28
+ // jsdom does not support ElementInternals
29
+ jsdomFlag = navigator.userAgent.includes("jsdom");
30
+
31
+ import("../../../source/dom/customelement.js").then((m) => {
32
+ registerCustomElement = m['registerCustomElement'];
33
+
34
+
35
+ import("../../../source/dom/customcontrol.js").then((m) => {
36
+
37
+ document = getDocument();
38
+
39
+ try {
40
+ CustomControl = m['CustomControl'];
41
+
42
+ TestComponent = class extends CustomControl {
43
+ static getTag() {
44
+ return "monster-customcontrol"
45
+ }
46
+ }
47
+ registerCustomElement(TestComponent)
48
+
49
+
50
+ done()
51
+ } catch (e) {
52
+ done(e);
53
+ }
54
+
55
+
56
+ });
57
+ });
58
+ });
59
+ })
60
+
61
+ beforeEach(() => {
62
+ let mocks = document.getElementById('mocks');
63
+ mocks.innerHTML = html1;
64
+ })
65
+
66
+ afterEach(() => {
67
+ let mocks = document.getElementById('mocks');
68
+ mocks.innerHTML = "";
69
+ })
70
+
71
+ describe('create', function () {
72
+ it('should return custom-element object', function () {
73
+ let d = new TestComponent();
74
+ expect(typeof d).is.equal('object');
75
+ });
76
+ });
77
+
78
+ describe('connect empty element', function () {
79
+ it('document should contain monster-customcontrol', function () {
80
+ let d = document.createElement('monster-customcontrol');
81
+ document.getElementById('test1').appendChild(d);
82
+ expect(document.getElementsByTagName('monster-customcontrol').length).is.equal(1);
83
+ expect(document.getElementById('test1')).contain.html('<monster-customcontrol></monster-customcontrol>');
84
+ });
85
+ });
86
+
87
+ describe('Options change', function () {
88
+
89
+ it('delegatesFocus should change from true to false', function () {
90
+ let element = document.createElement('monster-customcontrol')
91
+
92
+ expect(element.getOption('delegatesFocus')).to.be.true;
93
+ element.setAttribute(ATTRIBUTE_OPTIONS, JSON.stringify({delegatesFocus: false}));
94
+ expect(element.getOption('delegatesFocus')).to.be.false;
95
+
96
+ })
97
+
98
+
99
+ })
100
+
101
+ describe('Test ElementInternals', function () {
102
+
103
+ let form;
104
+
105
+ beforeEach(() => {
106
+ form = document.createElement('form');
107
+ })
108
+
109
+ it('formAssociated', function () {
110
+
111
+ let d = document.createElement('monster-customcontrol');
112
+ form.appendChild(d);
113
+
114
+ expect(d.constructor.formAssociated).to.be.true;
115
+
116
+ });
117
+ it('form', function () {
118
+
119
+ let d = document.createElement('monster-customcontrol');
120
+ form.appendChild(d);
121
+
122
+ if (jsdomFlag) {
123
+ expect(() => d.form).to.throw(Error);
124
+ } else {
125
+ expect(d.form).to.be.instanceof(HTMLFormElement)
126
+ }
127
+
128
+
129
+ });
130
+
131
+ it('value getter', function () {
132
+
133
+ let d = document.createElement('monster-customcontrol');
134
+ form.appendChild(d);
135
+
136
+ expect(() => d.value).to.throw(Error);
137
+
138
+ });
139
+
140
+ it('value setter', function () {
141
+
142
+ let d = document.createElement('monster-customcontrol');
143
+ form.appendChild(d);
144
+
145
+ expect(() => d.value = 4).to.throw(Error);
146
+
147
+ });
148
+
149
+
150
+ it('setFormValue', function () {
151
+
152
+ let d = document.createElement('monster-customcontrol');
153
+ form.appendChild(d);
154
+
155
+ if (jsdomFlag) {
156
+ expect(() => d.setFormValue()).to.throw(Error);
157
+ } else {
158
+
159
+ }
160
+
161
+ });
162
+
163
+
164
+ it('name getter', function () {
165
+
166
+ let d = document.createElement('monster-customcontrol');
167
+ form.appendChild(d);
168
+
169
+ expect(d.name).to.be.null;
170
+
171
+ });
172
+
173
+ it('type getter', function () {
174
+
175
+ let d = document.createElement('monster-customcontrol');
176
+ form.appendChild(d);
177
+
178
+ expect(d.type).to.be.equal('monster-customcontrol');
179
+
180
+ });
181
+
182
+ it('validity getter', function () {
183
+
184
+ let d = document.createElement('monster-customcontrol');
185
+ form.appendChild(d);
186
+ if (jsdomFlag) {
187
+ expect(() => d.validity).to.throw(Error);
188
+ } else {
189
+
190
+ }
191
+
192
+ });
193
+
194
+ it('validationMessage getter', function () {
195
+
196
+ let d = document.createElement('monster-customcontrol');
197
+ form.appendChild(d);
198
+
199
+ if (jsdomFlag) {
200
+ expect(() => d.validity).to.throw(Error);
201
+ } else {
202
+
203
+ }
204
+
205
+ });
206
+
207
+ it('willValidate getter', function () {
208
+
209
+ let d = document.createElement('monster-customcontrol');
210
+ form.appendChild(d);
211
+
212
+ if (jsdomFlag) {
213
+ expect(() => d.willValidate).to.throw(Error);
214
+ } else {
215
+
216
+ }
217
+
218
+ });
219
+ it('checkValidity()', function () {
220
+
221
+ let d = document.createElement('monster-customcontrol');
222
+ form.appendChild(d);
223
+
224
+ if (jsdomFlag) {
225
+ expect(() => d.checkValidity()).to.throw(Error);
226
+ } else {
227
+
228
+ }
229
+
230
+ });
231
+
232
+ it('reportValidity()', function () {
233
+
234
+ let d = document.createElement('monster-customcontrol');
235
+ form.appendChild(d);
236
+
237
+ if (jsdomFlag) {
238
+ expect(() => d.reportValidity()).to.throw(Error);
239
+ } else {
240
+
241
+ }
242
+
243
+ });
244
+
245
+
246
+ it('setValidity()', function () {
247
+
248
+ let d = document.createElement('monster-customcontrol');
249
+ form.appendChild(d);
250
+ if (jsdomFlag) {
251
+ expect(() => d.setValidity()).to.throw(Error);
252
+ } else {
253
+ expect(d.setValidity({'valueMissing': true}, "my message")).to.be.undefined;
254
+ }
255
+
256
+ });
257
+
258
+
259
+ });
260
+ });
261
+
262
+ });
263
+
264
+
@@ -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,70 +16,75 @@ 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;
20
24
 
21
- before(function (done) {
22
- initJSDOM().then(() => {
23
25
 
24
- import("../../../source/dom/customelement.js").then((m) => {
26
+ describe('CustomElement()', function () {
25
27
 
26
- try {
27
- CustomElement = m['CustomElement'];
28
- registerCustomElement = m['registerCustomElement'];
29
- TestComponent = class extends CustomElement {
30
- static getTag() {
31
- return "monster-testclass"
32
- }
33
- }
34
- registerCustomElement(TestComponent)
35
28
 
36
- TestComponent2 = class extends CustomElement {
37
- static getTag() {
38
- return "monster-testclass2"
39
- }
29
+ before(function (done) {
30
+ initJSDOM().then(() => {
31
+
32
+ import("../../../source/dom/customelement.js").then((m) => {
40
33
 
41
- /**
42
- *
43
- * @return {Object}
44
- */
45
- get defaults() {
46
-
47
- return Object.assign({}, super.defaults, {
48
- templates: {
49
- main: '<h1></h1><article><p>test</p></article>'
50
- },
51
- })
34
+ try {
35
+ CustomElement = m['CustomElement'];
36
+ registerCustomElement = m['registerCustomElement'];
37
+ TestComponent = class extends CustomElement {
38
+ static getTag() {
39
+ return "monster-testclass"
40
+ }
52
41
  }
53
42
 
54
- }
43
+ registerCustomElement(TestComponent)
55
44
 
56
- registerCustomElement(TestComponent2)
45
+ TestComponent2 = class extends CustomElement {
46
+ static getTag() {
47
+ return "monster-testclass2"
48
+ }
57
49
 
58
- document = getDocument();
59
- done()
60
- } catch (e) {
61
- done(e);
62
- }
50
+ /**
51
+ *
52
+ * @return {Object}
53
+ */
54
+ get defaults() {
63
55
 
56
+ return Object.assign({}, super.defaults, {
57
+ templates: {
58
+ main: '<h1></h1><article><p>test</p></article>'
59
+ },
60
+ })
61
+ }
64
62
 
65
- });
63
+ }
66
64
 
67
- });
68
- })
65
+ registerCustomElement(TestComponent2)
69
66
 
70
- beforeEach(() => {
71
- let mocks = document.getElementById('mocks');
72
- mocks.innerHTML = html1;
73
- })
67
+ document = getDocument();
68
+ done()
69
+ } catch (e) {
70
+ done(e);
71
+ }
74
72
 
75
- afterEach(() => {
76
- let mocks = document.getElementById('mocks');
77
- mocks.innerHTML = "";
78
- })
79
73
 
80
- describe('CustomElement()', function () {
74
+ });
75
+
76
+ });
77
+ })
78
+
79
+ beforeEach(() => {
80
+ let mocks = document.getElementById('mocks');
81
+ mocks.innerHTML = html1;
82
+ })
83
+
84
+ afterEach(() => {
85
+ let mocks = document.getElementById('mocks');
86
+ mocks.innerHTML = "";
87
+ })
81
88
 
82
89
  describe('create', function () {
83
90
  it('should return custom-element object', function () {
@@ -99,22 +106,76 @@ describe('DOM', function () {
99
106
  it('document should contain monster-testclass2', function (done) {
100
107
  let d = document.createElement('monster-testclass2');
101
108
  document.getElementById('test1').appendChild(d);
102
-
109
+
103
110
  // insert DOM run in extra process via setTimeout!
104
- setTimeout(function(){
111
+ setTimeout(function () {
105
112
  try {
106
113
  expect(document.getElementsByTagName('monster-testclass2').length).is.equal(1);
107
114
  expect(document.getElementsByTagName('monster-testclass2').item(0).shadowRoot.innerHTML).is.equal('<h1></h1><article><p>test</p></article>');
108
115
  expect(document.getElementById('test1')).contain.html('<monster-testclass2 data-monster-objectlink="Symbol(monsterUpdater)"></monster-testclass2>');
109
- } catch(e) {
116
+ } catch (e) {
110
117
  done(e);
111
118
  }
112
119
  done();
113
- },100);
114
-
120
+ }, 100);
121
+
115
122
  });
116
123
  });
117
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
+
118
179
  describe('getOptions()', function () {
119
180
 
120
181
  [