@schukai/monster 1.22.0 → 1.26.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (221) hide show
  1. package/CHANGELOG +56 -0
  2. package/README.md +4 -4
  3. package/dist/modules/constants.js +2 -2
  4. package/dist/modules/constraints/abstract.js +1 -1
  5. package/dist/modules/constraints/abstractoperator.js +1 -1
  6. package/dist/modules/constraints/andoperator.js +1 -1
  7. package/dist/modules/constraints/invalid.js +1 -1
  8. package/dist/modules/constraints/isarray.js +1 -1
  9. package/dist/modules/constraints/isobject.js +1 -1
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +1 -1
  12. package/dist/modules/constraints/valid.js +1 -1
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/buildtree.js +2 -0
  15. package/dist/modules/data/datasource/namespace.js +1 -1
  16. package/dist/modules/data/datasource/restapi/writeerror.js +2 -0
  17. package/dist/modules/data/datasource/restapi.js +2 -2
  18. package/dist/modules/data/datasource/storage/localstorage.js +2 -2
  19. package/dist/modules/data/datasource/storage/namespace.js +1 -1
  20. package/dist/modules/data/datasource/storage/sessionstorage.js +2 -2
  21. package/dist/modules/data/datasource/storage.js +2 -2
  22. package/dist/modules/data/datasource.js +2 -2
  23. package/dist/modules/data/diff.js +2 -2
  24. package/dist/modules/data/extend.js +1 -1
  25. package/dist/modules/data/namespace.js +1 -1
  26. package/dist/modules/data/pathfinder.js +2 -2
  27. package/dist/modules/data/pipe.js +1 -1
  28. package/dist/modules/data/transformer.js +2 -2
  29. package/dist/modules/dom/assembler.js +1 -1
  30. package/dist/modules/dom/attributes.js +1 -1
  31. package/dist/modules/dom/constants.js +2 -2
  32. package/dist/modules/dom/customcontrol.js +2 -2
  33. package/dist/modules/dom/customelement.js +2 -2
  34. package/dist/modules/dom/events.js +1 -1
  35. package/dist/modules/dom/focusmanager.js +2 -0
  36. package/dist/modules/dom/locale.js +1 -1
  37. package/dist/modules/dom/namespace.js +1 -1
  38. package/dist/modules/dom/resource/data.js +2 -0
  39. package/dist/modules/dom/resource/link/stylesheet.js +2 -0
  40. package/dist/modules/dom/resource/link.js +2 -0
  41. package/dist/modules/dom/resource/script.js +2 -0
  42. package/dist/modules/dom/resource.js +2 -0
  43. package/dist/modules/dom/resourcemanager.js +2 -0
  44. package/dist/modules/dom/template.js +1 -1
  45. package/dist/modules/dom/theme.js +1 -1
  46. package/dist/modules/dom/updater.js +2 -2
  47. package/dist/modules/dom/util.js +1 -1
  48. package/dist/modules/dom/worker/factory.js +2 -0
  49. package/dist/modules/i18n/formatter.js +2 -0
  50. package/dist/modules/i18n/locale.js +1 -1
  51. package/dist/modules/i18n/namespace.js +1 -1
  52. package/dist/modules/i18n/provider.js +1 -1
  53. package/dist/modules/i18n/providers/fetch.js +2 -2
  54. package/dist/modules/i18n/providers/namespace.js +1 -1
  55. package/dist/modules/i18n/translations.js +1 -1
  56. package/dist/modules/logging/handler/console.js +1 -1
  57. package/dist/modules/logging/handler/namespace.js +1 -1
  58. package/dist/modules/logging/handler.js +1 -1
  59. package/dist/modules/logging/logentry.js +1 -1
  60. package/dist/modules/logging/logger.js +1 -1
  61. package/dist/modules/logging/namespace.js +1 -1
  62. package/dist/modules/math/namespace.js +1 -1
  63. package/dist/modules/math/random.js +2 -2
  64. package/dist/modules/monster.js +1 -1
  65. package/dist/modules/namespace.js +1 -1
  66. package/dist/modules/text/formatter.js +2 -2
  67. package/dist/modules/text/namespace.js +1 -1
  68. package/dist/modules/types/base.js +1 -1
  69. package/dist/modules/types/basewithoptions.js +2 -2
  70. package/dist/modules/types/binary.js +1 -1
  71. package/dist/modules/types/dataurl.js +1 -1
  72. package/dist/modules/types/global.js +1 -1
  73. package/dist/modules/types/id.js +1 -1
  74. package/dist/modules/types/is.js +2 -2
  75. package/dist/modules/types/mediatype.js +1 -1
  76. package/dist/modules/types/namespace.js +1 -1
  77. package/dist/modules/types/node.js +2 -0
  78. package/dist/modules/types/nodelist.js +2 -0
  79. package/dist/modules/types/noderecursiveiterator.js +2 -0
  80. package/dist/modules/types/observer.js +1 -1
  81. package/dist/modules/types/observerlist.js +2 -2
  82. package/dist/modules/types/proxyobserver.js +2 -2
  83. package/dist/modules/types/queue.js +1 -1
  84. package/dist/modules/types/randomid.js +1 -1
  85. package/dist/modules/types/regex.js +2 -0
  86. package/dist/modules/types/stack.js +1 -1
  87. package/dist/modules/types/tokenlist.js +2 -2
  88. package/dist/modules/types/typeof.js +1 -1
  89. package/dist/modules/types/uniquequeue.js +1 -1
  90. package/dist/modules/types/uuid.js +2 -0
  91. package/dist/modules/types/validate.js +1 -1
  92. package/dist/modules/types/version.js +2 -2
  93. package/dist/modules/util/clone.js +2 -2
  94. package/dist/modules/util/comparator.js +2 -2
  95. package/dist/modules/util/freeze.js +1 -1
  96. package/dist/modules/util/namespace.js +1 -1
  97. package/dist/modules/util/processing.js +2 -2
  98. package/dist/modules/util/trimspaces.js +2 -0
  99. package/dist/monster.dev.js +1838 -792
  100. package/dist/monster.dev.js.map +1 -1
  101. package/dist/monster.js +2 -2
  102. package/package.json +13 -2
  103. package/source/constants.js +16 -7
  104. package/source/constraints/abstract.js +5 -0
  105. package/source/constraints/abstractoperator.js +5 -0
  106. package/source/constraints/andoperator.js +10 -5
  107. package/source/constraints/invalid.js +8 -3
  108. package/source/constraints/isarray.js +9 -4
  109. package/source/constraints/isobject.js +8 -3
  110. package/source/constraints/oroperator.js +10 -5
  111. package/source/constraints/valid.js +8 -3
  112. package/source/data/buildmap.js +27 -11
  113. package/source/data/buildtree.js +95 -0
  114. package/source/data/datasource/restapi/writeerror.js +49 -0
  115. package/source/data/datasource/restapi.js +95 -11
  116. package/source/data/datasource/storage/localstorage.js +15 -8
  117. package/source/data/datasource/storage/sessionstorage.js +16 -12
  118. package/source/data/datasource/storage.js +16 -7
  119. package/source/data/datasource.js +60 -16
  120. package/source/data/diff.js +8 -8
  121. package/source/data/extend.js +5 -5
  122. package/source/data/pathfinder.js +12 -6
  123. package/source/data/pipe.js +6 -5
  124. package/source/data/transformer.js +131 -24
  125. package/source/dom/assembler.js +2 -2
  126. package/source/dom/attributes.js +24 -24
  127. package/source/dom/constants.js +305 -12
  128. package/source/dom/customcontrol.js +40 -19
  129. package/source/dom/customelement.js +182 -102
  130. package/source/dom/events.js +6 -6
  131. package/source/dom/focusmanager.js +250 -0
  132. package/source/dom/locale.js +10 -5
  133. package/source/dom/resource/data.js +170 -0
  134. package/source/dom/resource/link/stylesheet.js +54 -0
  135. package/source/dom/resource/link.js +125 -0
  136. package/source/dom/resource/script.js +112 -0
  137. package/source/dom/resource.js +268 -0
  138. package/source/dom/resourcemanager.js +214 -0
  139. package/source/dom/template.js +40 -10
  140. package/source/dom/theme.js +3 -3
  141. package/source/dom/updater.js +115 -39
  142. package/source/dom/util.js +6 -6
  143. package/source/dom/worker/factory.js +134 -0
  144. package/source/i18n/formatter.js +140 -0
  145. package/source/i18n/locale.js +10 -8
  146. package/source/i18n/provider.js +4 -4
  147. package/source/i18n/providers/fetch.js +24 -14
  148. package/source/i18n/translations.js +20 -10
  149. package/source/logging/handler/console.js +2 -2
  150. package/source/logging/handler.js +2 -2
  151. package/source/logging/logentry.js +2 -2
  152. package/source/logging/logger.js +4 -4
  153. package/source/math/random.js +11 -5
  154. package/source/namespace.js +1 -1
  155. package/source/text/formatter.js +244 -27
  156. package/source/types/base.js +4 -4
  157. package/source/types/basewithoptions.js +10 -15
  158. package/source/types/binary.js +8 -8
  159. package/source/types/dataurl.js +6 -6
  160. package/source/types/global.js +9 -7
  161. package/source/types/id.js +6 -3
  162. package/source/types/is.js +103 -85
  163. package/source/types/mediatype.js +4 -4
  164. package/source/types/node.js +179 -0
  165. package/source/types/nodelist.js +125 -0
  166. package/source/types/noderecursiveiterator.js +126 -0
  167. package/source/types/observer.js +3 -3
  168. package/source/types/observerlist.js +3 -3
  169. package/source/types/proxyobserver.js +24 -7
  170. package/source/types/queue.js +6 -6
  171. package/source/types/randomid.js +2 -2
  172. package/source/types/regex.js +49 -0
  173. package/source/types/stack.js +2 -2
  174. package/source/types/tokenlist.js +8 -9
  175. package/source/types/typeof.js +3 -3
  176. package/source/types/uniquequeue.js +4 -4
  177. package/source/types/uuid.js +102 -0
  178. package/source/types/validate.js +20 -20
  179. package/source/types/version.js +6 -6
  180. package/source/util/clone.js +5 -6
  181. package/source/util/comparator.js +5 -5
  182. package/source/util/freeze.js +5 -5
  183. package/source/util/processing.js +33 -36
  184. package/source/util/trimspaces.js +85 -0
  185. package/test/cases/data/buildtree.js +149 -0
  186. package/test/cases/data/datasource/restapi.js +1 -1
  187. package/test/cases/data/datasource.js +4 -4
  188. package/test/cases/data/diff.js +4 -4
  189. package/test/cases/data/pathfinder.js +18 -9
  190. package/test/cases/data/pipe.js +26 -2
  191. package/test/cases/data/transformer.js +41 -10
  192. package/test/cases/dom/attributes.js +18 -14
  193. package/test/cases/dom/customcontrol.js +6 -5
  194. package/test/cases/dom/customelement.js +25 -26
  195. package/test/cases/dom/focusmanager.js +111 -0
  196. package/test/cases/dom/locale.js +1 -4
  197. package/test/cases/dom/resource/data.js +129 -0
  198. package/test/cases/dom/resource/link/stylesheet.js +101 -0
  199. package/test/cases/dom/resource/link.js +101 -0
  200. package/test/cases/dom/resource/script.js +115 -0
  201. package/test/cases/dom/resourcemanager.js +118 -0
  202. package/test/cases/dom/updater.js +42 -19
  203. package/test/cases/dom/worker/factory.js +63 -0
  204. package/test/cases/i18n/formatter.js +66 -0
  205. package/test/cases/monster.js +1 -1
  206. package/test/cases/text/formatter.js +71 -8
  207. package/test/cases/types/node.js +196 -0
  208. package/test/cases/types/nodelist.js +64 -0
  209. package/test/cases/types/noderecursiveiterator.js +54 -0
  210. package/test/cases/types/proxyobserver.js +55 -11
  211. package/test/cases/types/regex.js +32 -0
  212. package/test/cases/types/uuid.js +42 -0
  213. package/test/cases/util/freeze.js +30 -4
  214. package/test/cases/util/trimspaces.js +24 -0
  215. package/test/util/cleanupdom.js +48 -0
  216. package/test/util/jsdom.js +22 -9
  217. package/test/web/import.js +15 -0
  218. package/test/web/monster-dev.html +3 -3
  219. package/test/web/monster.html +2 -2
  220. package/test/web/test.html +3 -3
  221. package/test/web/tests.js +7 -7
@@ -5,29 +5,29 @@ import {Monster} from '../namespace.js';
5
5
  * @author schukai GmbH
6
6
  */
7
7
 
8
+
8
9
  /**
10
+ * default theme
9
11
  * @memberOf Monster.DOM
10
- * @since 1.8.0
11
12
  * @type {string}
12
13
  */
13
- const ATTRIBUTE_PREFIX = 'data-monster-';
14
+ const DEFAULT_THEME = 'monster';
14
15
 
15
16
  /**
16
- * This is the name of the attribute to pass options to a control
17
- *
18
17
  * @memberOf Monster.DOM
19
18
  * @since 1.8.0
20
19
  * @type {string}
21
20
  */
22
- const ATTRIBUTE_OPTIONS = ATTRIBUTE_PREFIX + 'options';
23
-
21
+ const ATTRIBUTE_PREFIX = 'data-monster-';
24
22
 
25
23
  /**
26
- * default theme
24
+ * This is the name of the attribute to pass options to a control
25
+ *
27
26
  * @memberOf Monster.DOM
27
+ * @since 1.8.0
28
28
  * @type {string}
29
29
  */
30
- const DEFAULT_THEME = 'monster';
30
+ const ATTRIBUTE_OPTIONS = ATTRIBUTE_PREFIX + 'options';
31
31
 
32
32
  /**
33
33
  * @memberOf Monster.DOM
@@ -91,6 +91,20 @@ const ATTRIBUTE_UPDATER_BIND = ATTRIBUTE_PREFIX + 'bind';
91
91
  */
92
92
  const ATTRIBUTE_ROLE = ATTRIBUTE_PREFIX + 'role';
93
93
 
94
+ /**
95
+ * @memberOf Monster.DOM
96
+ * @type {string}
97
+ * @since 1.24.0
98
+ */
99
+ const ATTRIBUTE_DISABLED = 'disabled';
100
+
101
+ /**
102
+ * @memberOf Monster.DOM
103
+ * @type {string}
104
+ * @since 1.24.0
105
+ */
106
+ const ATTRIBUTE_VALUE = 'value';
107
+
94
108
  /**
95
109
  * @memberOf Monster.DOM
96
110
  * @type {string}
@@ -101,13 +115,289 @@ const ATTRIBUTE_OBJECTLINK = ATTRIBUTE_PREFIX + 'objectlink';
101
115
  /**
102
116
  * @memberOf Monster.DOM
103
117
  * @type {string}
104
- * @since 1.10.0
118
+ * @since 1.24.0
119
+ */
120
+ const ATTRIBUTE_ERRORMESSAGE = ATTRIBUTE_PREFIX + 'error';
121
+
122
+ /**
123
+ * @memberOf Monster.DOM
124
+ * @type {symbol}
125
+ * @since 1.24.0
126
+ */
127
+ const objectUpdaterLinkSymbol = Symbol('monsterUpdater');
128
+
129
+ /**
130
+ * @memberOf Monster.DOM
131
+ * @type {string}
132
+ * @since 1.25.0
133
+ */
134
+ const TAG_SCRIPT = 'script';
135
+
136
+ /**
137
+ * @memberOf Monster.DOM
138
+ * @type {string}
139
+ * @since 1.25.0
140
+ */
141
+ const TAG_STYLE = 'style';
142
+
143
+ /**
144
+ * @memberOf Monster.DOM
145
+ * @type {string}
146
+ * @since 1.25.0
147
+ */
148
+ const TAG_LINK = 'link';
149
+
150
+ /**
151
+ * @memberOf Monster.DOM
152
+ * @type {string}
153
+ * @since 1.25.0
154
+ */
155
+
156
+ const ATTRIBUTE_ID = 'id';
157
+
158
+ /**
159
+ * @memberOf Monster.DOM
160
+ * @type {string}
161
+ * @since 1.25.0
162
+ */
163
+
164
+ const ATTRIBUTE_CLASS = 'class';
165
+
166
+ /**
167
+ * @memberOf Monster.DOM
168
+ * @type {string}
169
+ * @since 1.25.0
170
+ */
171
+ const ATTRIBUTE_TITLE = 'title';
172
+
173
+ /**
174
+ * @memberOf Monster.DOM
175
+ * @type {string}
176
+ * @since 1.25.0
177
+ */
178
+ const ATTRIBUTE_SRC = 'src';
179
+ /**
180
+ * @memberOf Monster.DOM
181
+ * @type {string}
182
+ * @since 1.25.0
183
+ */
184
+ const ATTRIBUTE_HREF = 'href';
185
+
186
+ /**
187
+ * @memberOf Monster.DOM
188
+ * @type {string}
189
+ * @since 1.25.0
190
+ */
191
+ const ATTRIBUTE_TYPE = 'type';
192
+
193
+ /**
194
+ * @memberOf Monster.DOM
195
+ * @type {string}
196
+ * @since 1.25.0
197
+ */
198
+ const ATTRIBUTE_NONCE = 'nonce';
199
+
200
+ /**
201
+ * @memberOf Monster.DOM
202
+ * @type {string}
203
+ * @since 1.25.0
204
+ */
205
+ const ATTRIBUTE_TRANSLATE = 'translate';
206
+
207
+
208
+ /**
209
+ * @memberOf Monster.DOM
210
+ * @type {string}
211
+ * @since 1.25.0
212
+ */
213
+ const ATTRIBUTE_TABINDEX = 'tabindex';
214
+
215
+
216
+ /**
217
+ * @memberOf Monster.DOM
218
+ * @type {string}
219
+ * @since 1.25.0
220
+ */
221
+ const ATTRIBUTE_SPELLCHECK = 'spellcheck';
222
+
223
+
224
+ /**
225
+ * @memberOf Monster.DOM
226
+ * @type {string}
227
+ * @since 1.25.0
228
+ */
229
+ const ATTRIBUTE_SLOT = 'slot';
230
+
231
+
232
+ /**
233
+ * @memberOf Monster.DOM
234
+ * @type {string}
235
+ * @since 1.25.0
236
+ */
237
+ const ATTRIBUTE_PART = 'part';
238
+
239
+
240
+ /**
241
+ * @memberOf Monster.DOM
242
+ * @type {string}
243
+ * @since 1.25.0
244
+ */
245
+ const ATTRIBUTE_LANG = 'lang';
246
+
247
+
248
+ /**
249
+ * @memberOf Monster.DOM
250
+ * @type {string}
251
+ * @since 1.25.0
252
+ */
253
+ const ATTRIBUTE_ITEMTYPE = 'itemtype';
254
+
255
+
256
+ /**
257
+ * @memberOf Monster.DOM
258
+ * @type {string}
259
+ * @since 1.25.0
260
+ */
261
+ const ATTRIBUTE_ITEMSCOPE = 'itemscope';
262
+
263
+
264
+ /**
265
+ * @memberOf Monster.DOM
266
+ * @type {string}
267
+ * @since 1.25.0
268
+ */
269
+ const ATTRIBUTE_ITEMREF = 'itemref';
270
+
271
+
272
+ /**
273
+ * @memberOf Monster.DOM
274
+ * @type {string}
275
+ * @since 1.25.0
276
+ */
277
+ const ATTRIBUTE_ITEMID = 'itemid';
278
+
279
+
280
+ /**
281
+ * @memberOf Monster.DOM
282
+ * @type {string}
283
+ * @since 1.25.0
284
+ */
285
+ const ATTRIBUTE_ITEMPROP = 'itemprop';
286
+
287
+
288
+ /**
289
+ * @memberOf Monster.DOM
290
+ * @type {string}
291
+ * @since 1.25.0
292
+ */
293
+ const ATTRIBUTE_IS = 'is';
294
+
295
+
296
+ /**
297
+ * @memberOf Monster.DOM
298
+ * @type {string}
299
+ * @since 1.25.0
300
+ */
301
+ const ATTRIBUTE_INPUTMODE = 'inputmode';
302
+
303
+
304
+ /**
305
+ * @memberOf Monster.DOM
306
+ * @type {string}
307
+ * @since 1.25.0
308
+ */
309
+ const ATTRIBUTE_ACCESSKEY = 'accesskey';
310
+
311
+ /**
312
+ * @memberOf Monster.DOM
313
+ * @type {string}
314
+ * @since 1.25.0
315
+ */
316
+ const ATTRIBUTE_AUTOCAPITALIZE = 'autocapitalize';
317
+
318
+ /**
319
+ * @memberOf Monster.DOM
320
+ * @type {string}
321
+ * @since 1.25.0
322
+ */
323
+ const ATTRIBUTE_AUTOFOCUS = 'autofocus';
324
+
325
+ /**
326
+ * @memberOf Monster.DOM
327
+ * @type {string}
328
+ * @since 1.25.0
329
+ */
330
+ const ATTRIBUTE_CONTENTEDITABLE = 'contenteditable';
331
+
332
+ /**
333
+ * @memberOf Monster.DOM
334
+ * @type {string}
335
+ * @since 1.25.0
336
+ */
337
+ const ATTRIBUTE_DIR = 'dir';
338
+
339
+ /**
340
+ * @memberOf Monster.DOM
341
+ * @type {string}
342
+ * @since 1.25.0
343
+ */
344
+ const ATTRIBUTE_DRAGGABLE = 'draggable';
345
+
346
+
347
+ /**
348
+ * @memberOf Monster.DOM
349
+ * @type {string}
350
+ * @since 1.25.0
351
+ */
352
+ const ATTRIBUTE_ENTERKEYHINT = 'enterkeyhint';
353
+ /**
354
+ * @memberOf Monster.DOM
355
+ * @type {string}
356
+ * @since 1.25.0
357
+ */
358
+ const ATTRIBUTE_EXPORTPARTS = 'exportparts';
359
+ /**
360
+ * @memberOf Monster.DOM
361
+ * @type {string}
362
+ * @since 1.25.0
105
363
  */
106
- const OBJECTLINK_KEY_UPDATER = 'monsterUpdater';
364
+ const ATTRIBUTE_HIDDEN = 'hidden';
107
365
 
108
366
 
109
367
  export {
110
368
  Monster,
369
+ ATTRIBUTE_HIDDEN,
370
+ ATTRIBUTE_EXPORTPARTS,
371
+ ATTRIBUTE_ENTERKEYHINT,
372
+ ATTRIBUTE_DRAGGABLE,
373
+ ATTRIBUTE_DIR,
374
+ ATTRIBUTE_CONTENTEDITABLE,
375
+ ATTRIBUTE_AUTOFOCUS,
376
+ ATTRIBUTE_AUTOCAPITALIZE,
377
+ ATTRIBUTE_ACCESSKEY,
378
+ TAG_SCRIPT,
379
+ TAG_LINK,
380
+ ATTRIBUTE_INPUTMODE,
381
+ ATTRIBUTE_IS,
382
+ ATTRIBUTE_ITEMPROP,
383
+ ATTRIBUTE_ITEMID,
384
+ ATTRIBUTE_ITEMREF,
385
+ ATTRIBUTE_ITEMSCOPE,
386
+ TAG_STYLE,
387
+ ATTRIBUTE_ITEMTYPE,
388
+ ATTRIBUTE_HREF,
389
+ ATTRIBUTE_LANG,
390
+ ATTRIBUTE_PART,
391
+ ATTRIBUTE_SLOT,
392
+ ATTRIBUTE_SPELLCHECK,
393
+ ATTRIBUTE_SRC,
394
+ ATTRIBUTE_TABINDEX,
395
+ ATTRIBUTE_TRANSLATE,
396
+ ATTRIBUTE_NONCE,
397
+ ATTRIBUTE_TYPE,
398
+ ATTRIBUTE_TITLE,
399
+ ATTRIBUTE_CLASS,
400
+ ATTRIBUTE_ID,
111
401
  ATTRIBUTE_PREFIX,
112
402
  ATTRIBUTE_OPTIONS,
113
403
  DEFAULT_THEME,
@@ -121,5 +411,8 @@ export {
121
411
  ATTRIBUTE_UPDATER_REMOVE,
122
412
  ATTRIBUTE_UPDATER_BIND,
123
413
  ATTRIBUTE_OBJECTLINK,
124
- OBJECTLINK_KEY_UPDATER
125
- }
414
+ ATTRIBUTE_DISABLED,
415
+ ATTRIBUTE_ERRORMESSAGE,
416
+ ATTRIBUTE_VALUE,
417
+ objectUpdaterLinkSymbol
418
+ }
@@ -5,14 +5,15 @@ import {extend} from "../data/extend.js";
5
5
  * @author schukai GmbH
6
6
  */
7
7
  import {assignToNamespace, Monster} from '../namespace.js';
8
- import {CustomElement} from "./customelement.js";
8
+ import {ATTRIBUTE_VALUE} from "./constants.js";
9
+ import {CustomElement, attributeObserverSymbol} from "./customelement.js";
9
10
 
10
11
 
11
12
  /**
12
13
  * @private
13
14
  * @type {symbol}
14
15
  */
15
- const internalSymbol = Symbol('internalSymbol');
16
+ const attachedInternalSymbol = Symbol('attachedInternal');
16
17
 
17
18
  /**
18
19
  * To define a new HTML control we need the power of CustomElement
@@ -21,35 +22,26 @@ const internalSymbol = Symbol('internalSymbol');
21
22
  * with the new class name. only then will the tag defined via the `getTag` method be made known to the DOM.
22
23
  *
23
24
  * <img src="./images/customcontrol-class.png">
24
- *
25
+ *
25
26
  * This control uses `attachInternals()` to integrate the control into a form.
26
27
  * If the target environment does not support this method, the [polyfill](https://www.npmjs.com/package/element-internals-polyfill ) can be used.
27
28
  *
28
- * You can create the object via the monster namespace `new Monster.DOM.CustomControl()`.
29
+ * You can create the object via the function `document.createElement()`.
29
30
  *
30
31
  * ```
31
32
  * <script type="module">
32
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.22.0/dist/modules/dom/customcontrol.js';
33
- * console.log(new Monster.DOM.CustomControl())
33
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.26.0/dist/monster.js';
34
+ * document.createElement('monster-')
34
35
  * </script>
35
36
  * ```
36
37
  *
37
- * Alternatively, you can also integrate this function individually.
38
- *
39
- * ```
40
- * <script type="module">
41
- * import {CustomControl} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.22.0/dist/modules/dom/customcontrol.js';
42
- * console.log(new CustomControl())
43
- * </script>
44
- * ```
45
- *
46
38
  * @startuml customcontrol-class.png
47
39
  * skinparam monochrome true
48
40
  * skinparam shadowing false
49
41
  * HTMLElement <|-- CustomElement
50
42
  * CustomElement <|-- CustomControl
51
43
  * @enduml
52
- *
44
+ *
53
45
  * @summary A base class for customcontrols based on CustomElement
54
46
  * @see {@link https://www.npmjs.com/package/element-internals-polyfill}
55
47
  * @see {@link https://github.com/WICG/webcomponents}
@@ -75,11 +67,25 @@ class CustomControl extends CustomElement {
75
67
  * @property {Object}
76
68
  * @private
77
69
  */
78
- this[internalSymbol] = this.attachInternals();
70
+ this[attachedInternalSymbol] = this.attachInternals();
79
71
  }
80
72
 
73
+ initObserver.call(this);
74
+
81
75
  }
82
76
 
77
+ /**
78
+ * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
79
+ *
80
+ * @return {string[]}
81
+ * @since 1.15.0
82
+ */
83
+ static get observedAttributes() {
84
+ const list = super.observedAttributes;
85
+ list.push(ATTRIBUTE_VALUE);
86
+ return list;
87
+ }
88
+
83
89
  /**
84
90
  *
85
91
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
@@ -301,11 +307,26 @@ class CustomControl extends CustomElement {
301
307
  function getInternal() {
302
308
  const self = this;
303
309
 
304
- if (!(internalSymbol in this)) {
310
+ if (!(attachedInternalSymbol in this)) {
305
311
  throw new Error('ElementInternals is not supported and a polyfill is necessary');
306
312
  }
307
313
 
308
- return this[internalSymbol];
314
+ return this[attachedInternalSymbol];
315
+ }
316
+
317
+ /**
318
+ * @private
319
+ * @return {object}
320
+ * @this CustomControl
321
+ */
322
+ function initObserver() {
323
+ const self = this;
324
+
325
+ // value
326
+ self[attributeObserverSymbol]['value'] = () => {
327
+ self.setOption('value', self.getAttribute('value'));
328
+ }
329
+
309
330
  }
310
331
 
311
332
  assignToNamespace('Monster.DOM', CustomControl);