@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.
- package/CHANGELOG +56 -0
- package/README.md +4 -4
- package/dist/modules/constants.js +2 -2
- package/dist/modules/constraints/abstract.js +1 -1
- package/dist/modules/constraints/abstractoperator.js +1 -1
- package/dist/modules/constraints/andoperator.js +1 -1
- package/dist/modules/constraints/invalid.js +1 -1
- package/dist/modules/constraints/isarray.js +1 -1
- package/dist/modules/constraints/isobject.js +1 -1
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +1 -1
- package/dist/modules/constraints/valid.js +1 -1
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/buildtree.js +2 -0
- package/dist/modules/data/datasource/namespace.js +1 -1
- package/dist/modules/data/datasource/restapi/writeerror.js +2 -0
- package/dist/modules/data/datasource/restapi.js +2 -2
- package/dist/modules/data/datasource/storage/localstorage.js +2 -2
- package/dist/modules/data/datasource/storage/namespace.js +1 -1
- package/dist/modules/data/datasource/storage/sessionstorage.js +2 -2
- package/dist/modules/data/datasource/storage.js +2 -2
- package/dist/modules/data/datasource.js +2 -2
- package/dist/modules/data/diff.js +2 -2
- package/dist/modules/data/extend.js +1 -1
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +2 -2
- package/dist/modules/data/pipe.js +1 -1
- package/dist/modules/data/transformer.js +2 -2
- package/dist/modules/dom/assembler.js +1 -1
- package/dist/modules/dom/attributes.js +1 -1
- package/dist/modules/dom/constants.js +2 -2
- package/dist/modules/dom/customcontrol.js +2 -2
- package/dist/modules/dom/customelement.js +2 -2
- package/dist/modules/dom/events.js +1 -1
- package/dist/modules/dom/focusmanager.js +2 -0
- package/dist/modules/dom/locale.js +1 -1
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/resource/data.js +2 -0
- package/dist/modules/dom/resource/link/stylesheet.js +2 -0
- package/dist/modules/dom/resource/link.js +2 -0
- package/dist/modules/dom/resource/script.js +2 -0
- package/dist/modules/dom/resource.js +2 -0
- package/dist/modules/dom/resourcemanager.js +2 -0
- package/dist/modules/dom/template.js +1 -1
- package/dist/modules/dom/theme.js +1 -1
- package/dist/modules/dom/updater.js +2 -2
- package/dist/modules/dom/util.js +1 -1
- package/dist/modules/dom/worker/factory.js +2 -0
- package/dist/modules/i18n/formatter.js +2 -0
- package/dist/modules/i18n/locale.js +1 -1
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +1 -1
- package/dist/modules/i18n/providers/fetch.js +2 -2
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +1 -1
- package/dist/modules/logging/handler/console.js +1 -1
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +1 -1
- package/dist/modules/logging/logentry.js +1 -1
- package/dist/modules/logging/logger.js +1 -1
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +2 -2
- package/dist/modules/monster.js +1 -1
- package/dist/modules/namespace.js +1 -1
- package/dist/modules/text/formatter.js +2 -2
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +1 -1
- package/dist/modules/types/basewithoptions.js +2 -2
- package/dist/modules/types/binary.js +1 -1
- package/dist/modules/types/dataurl.js +1 -1
- package/dist/modules/types/global.js +1 -1
- package/dist/modules/types/id.js +1 -1
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/mediatype.js +1 -1
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/node.js +2 -0
- package/dist/modules/types/nodelist.js +2 -0
- package/dist/modules/types/noderecursiveiterator.js +2 -0
- package/dist/modules/types/observer.js +1 -1
- package/dist/modules/types/observerlist.js +2 -2
- package/dist/modules/types/proxyobserver.js +2 -2
- package/dist/modules/types/queue.js +1 -1
- package/dist/modules/types/randomid.js +1 -1
- package/dist/modules/types/regex.js +2 -0
- package/dist/modules/types/stack.js +1 -1
- package/dist/modules/types/tokenlist.js +2 -2
- package/dist/modules/types/typeof.js +1 -1
- package/dist/modules/types/uniquequeue.js +1 -1
- package/dist/modules/types/uuid.js +2 -0
- package/dist/modules/types/validate.js +1 -1
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +2 -2
- package/dist/modules/util/comparator.js +2 -2
- package/dist/modules/util/freeze.js +1 -1
- package/dist/modules/util/namespace.js +1 -1
- package/dist/modules/util/processing.js +2 -2
- package/dist/modules/util/trimspaces.js +2 -0
- package/dist/monster.dev.js +1838 -792
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -2
- package/package.json +13 -2
- package/source/constants.js +16 -7
- package/source/constraints/abstract.js +5 -0
- package/source/constraints/abstractoperator.js +5 -0
- package/source/constraints/andoperator.js +10 -5
- package/source/constraints/invalid.js +8 -3
- package/source/constraints/isarray.js +9 -4
- package/source/constraints/isobject.js +8 -3
- package/source/constraints/oroperator.js +10 -5
- package/source/constraints/valid.js +8 -3
- package/source/data/buildmap.js +27 -11
- package/source/data/buildtree.js +95 -0
- package/source/data/datasource/restapi/writeerror.js +49 -0
- package/source/data/datasource/restapi.js +95 -11
- package/source/data/datasource/storage/localstorage.js +15 -8
- package/source/data/datasource/storage/sessionstorage.js +16 -12
- package/source/data/datasource/storage.js +16 -7
- package/source/data/datasource.js +60 -16
- package/source/data/diff.js +8 -8
- package/source/data/extend.js +5 -5
- package/source/data/pathfinder.js +12 -6
- package/source/data/pipe.js +6 -5
- package/source/data/transformer.js +131 -24
- package/source/dom/assembler.js +2 -2
- package/source/dom/attributes.js +24 -24
- package/source/dom/constants.js +305 -12
- package/source/dom/customcontrol.js +40 -19
- package/source/dom/customelement.js +182 -102
- package/source/dom/events.js +6 -6
- package/source/dom/focusmanager.js +250 -0
- package/source/dom/locale.js +10 -5
- package/source/dom/resource/data.js +170 -0
- package/source/dom/resource/link/stylesheet.js +54 -0
- package/source/dom/resource/link.js +125 -0
- package/source/dom/resource/script.js +112 -0
- package/source/dom/resource.js +268 -0
- package/source/dom/resourcemanager.js +214 -0
- package/source/dom/template.js +40 -10
- package/source/dom/theme.js +3 -3
- package/source/dom/updater.js +115 -39
- package/source/dom/util.js +6 -6
- package/source/dom/worker/factory.js +134 -0
- package/source/i18n/formatter.js +140 -0
- package/source/i18n/locale.js +10 -8
- package/source/i18n/provider.js +4 -4
- package/source/i18n/providers/fetch.js +24 -14
- package/source/i18n/translations.js +20 -10
- package/source/logging/handler/console.js +2 -2
- package/source/logging/handler.js +2 -2
- package/source/logging/logentry.js +2 -2
- package/source/logging/logger.js +4 -4
- package/source/math/random.js +11 -5
- package/source/namespace.js +1 -1
- package/source/text/formatter.js +244 -27
- package/source/types/base.js +4 -4
- package/source/types/basewithoptions.js +10 -15
- package/source/types/binary.js +8 -8
- package/source/types/dataurl.js +6 -6
- package/source/types/global.js +9 -7
- package/source/types/id.js +6 -3
- package/source/types/is.js +103 -85
- package/source/types/mediatype.js +4 -4
- package/source/types/node.js +179 -0
- package/source/types/nodelist.js +125 -0
- package/source/types/noderecursiveiterator.js +126 -0
- package/source/types/observer.js +3 -3
- package/source/types/observerlist.js +3 -3
- package/source/types/proxyobserver.js +24 -7
- package/source/types/queue.js +6 -6
- package/source/types/randomid.js +2 -2
- package/source/types/regex.js +49 -0
- package/source/types/stack.js +2 -2
- package/source/types/tokenlist.js +8 -9
- package/source/types/typeof.js +3 -3
- package/source/types/uniquequeue.js +4 -4
- package/source/types/uuid.js +102 -0
- package/source/types/validate.js +20 -20
- package/source/types/version.js +6 -6
- package/source/util/clone.js +5 -6
- package/source/util/comparator.js +5 -5
- package/source/util/freeze.js +5 -5
- package/source/util/processing.js +33 -36
- package/source/util/trimspaces.js +85 -0
- package/test/cases/data/buildtree.js +149 -0
- package/test/cases/data/datasource/restapi.js +1 -1
- package/test/cases/data/datasource.js +4 -4
- package/test/cases/data/diff.js +4 -4
- package/test/cases/data/pathfinder.js +18 -9
- package/test/cases/data/pipe.js +26 -2
- package/test/cases/data/transformer.js +41 -10
- package/test/cases/dom/attributes.js +18 -14
- package/test/cases/dom/customcontrol.js +6 -5
- package/test/cases/dom/customelement.js +25 -26
- package/test/cases/dom/focusmanager.js +111 -0
- package/test/cases/dom/locale.js +1 -4
- package/test/cases/dom/resource/data.js +129 -0
- package/test/cases/dom/resource/link/stylesheet.js +101 -0
- package/test/cases/dom/resource/link.js +101 -0
- package/test/cases/dom/resource/script.js +115 -0
- package/test/cases/dom/resourcemanager.js +118 -0
- package/test/cases/dom/updater.js +42 -19
- package/test/cases/dom/worker/factory.js +63 -0
- package/test/cases/i18n/formatter.js +66 -0
- package/test/cases/monster.js +1 -1
- package/test/cases/text/formatter.js +71 -8
- package/test/cases/types/node.js +196 -0
- package/test/cases/types/nodelist.js +64 -0
- package/test/cases/types/noderecursiveiterator.js +54 -0
- package/test/cases/types/proxyobserver.js +55 -11
- package/test/cases/types/regex.js +32 -0
- package/test/cases/types/uuid.js +42 -0
- package/test/cases/util/freeze.js +30 -4
- package/test/cases/util/trimspaces.js +24 -0
- package/test/util/cleanupdom.js +48 -0
- package/test/util/jsdom.js +22 -9
- package/test/web/import.js +15 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +7 -7
package/source/dom/constants.js
CHANGED
@@ -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
|
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
|
23
|
-
|
21
|
+
const ATTRIBUTE_PREFIX = 'data-monster-';
|
24
22
|
|
25
23
|
/**
|
26
|
-
*
|
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
|
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.
|
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
|
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
|
-
|
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 {
|
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
|
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
|
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.
|
33
|
-
*
|
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[
|
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 (!(
|
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[
|
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);
|