@native-dom/runtime 0.0.3 → 0.0.5
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.
- package/README.md +1 -1
- package/dist/attributes.d.ts +21 -18
- package/dist/attributes.d.ts.map +1 -1
- package/dist/attributes.js +115 -137
- package/dist/attributes.js.map +1 -1
- package/dist/css.d.ts +137 -133
- package/dist/css.d.ts.map +1 -1
- package/dist/css.js +495 -555
- package/dist/css.js.map +1 -1
- package/dist/custom-elements.d.ts +22 -18
- package/dist/custom-elements.d.ts.map +1 -1
- package/dist/custom-elements.js +58 -58
- package/dist/custom-elements.js.map +1 -1
- package/dist/errors.d.ts +5 -2
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +10 -6
- package/dist/errors.js.map +1 -1
- package/dist/event-init.d.ts +81 -77
- package/dist/event-init.d.ts.map +1 -1
- package/dist/events.d.ts +164 -161
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +417 -462
- package/dist/events.js.map +1 -1
- package/dist/geometry.d.ts +44 -41
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +68 -72
- package/dist/geometry.js.map +1 -1
- package/dist/history.d.ts +17 -13
- package/dist/history.d.ts.map +1 -1
- package/dist/history.js +67 -62
- package/dist/history.js.map +1 -1
- package/dist/index.d.ts +795 -798
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3020 -3597
- package/dist/index.js.map +1 -1
- package/dist/observers.d.ts +46 -42
- package/dist/observers.d.ts.map +1 -1
- package/dist/observers.js +59 -57
- package/dist/observers.js.map +1 -1
- package/dist/platform.d.ts +71 -67
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +204 -212
- package/dist/platform.js.map +1 -1
- package/dist/stats.d.ts +18 -31
- package/dist/stats.d.ts.map +1 -1
- package/dist/stats.js +75 -87
- package/dist/stats.js.map +1 -1
- package/package.json +6 -7
- package/dist/event-init.js +0 -2
- package/dist/event-init.js.map +0 -1
package/dist/css.js
CHANGED
|
@@ -1,573 +1,513 @@
|
|
|
1
1
|
import { DOMException } from "./errors.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
constructor(cssText = "") {
|
|
425
|
-
if (cssText) {
|
|
426
|
-
this.replaceSync(cssText);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
insertRule(ruleText, index = this.cssRules.length) {
|
|
430
|
-
const normalizedIndex = Number(index);
|
|
431
|
-
if (!Number.isInteger(normalizedIndex) ||
|
|
432
|
-
normalizedIndex < 0 ||
|
|
433
|
-
normalizedIndex > this.cssRules.length) {
|
|
434
|
-
throw new DOMException("The index provided is outside the rule list.", "IndexSizeError");
|
|
435
|
-
}
|
|
436
|
-
const rules = parseCssRules(String(ruleText), this);
|
|
437
|
-
if (rules.length !== 1) {
|
|
438
|
-
throw new DOMException(`Failed to parse the rule '${String(ruleText)}'.`, "SyntaxError");
|
|
439
|
-
}
|
|
440
|
-
this.cssRules.splice(normalizedIndex, 0, rules[0]);
|
|
441
|
-
return normalizedIndex;
|
|
442
|
-
}
|
|
443
|
-
deleteRule(index = 0) {
|
|
444
|
-
const normalizedIndex = Number(index);
|
|
445
|
-
if (Number.isInteger(normalizedIndex) &&
|
|
446
|
-
normalizedIndex >= 0 &&
|
|
447
|
-
normalizedIndex < this.cssRules.length) {
|
|
448
|
-
this.cssRules.splice(normalizedIndex, 1);
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
replaceSync(cssText) {
|
|
452
|
-
this.cssRules.splice(0, this.cssRules.length, ...parseCssRules(String(cssText), this));
|
|
453
|
-
}
|
|
454
|
-
}
|
|
2
|
+
//#region src/css.ts
|
|
3
|
+
var CSSStyleDeclaration = class {
|
|
4
|
+
parentRule = null;
|
|
5
|
+
#properties = /* @__PURE__ */ new Map();
|
|
6
|
+
#element;
|
|
7
|
+
#outlineNone = false;
|
|
8
|
+
constructor(cssText = "", element = null) {
|
|
9
|
+
this.#element = element;
|
|
10
|
+
this.cssText = cssText;
|
|
11
|
+
}
|
|
12
|
+
get cssText() {
|
|
13
|
+
return this.#orderedProperties().map(([name, value]) => `${name}: ${value};`).join(" ");
|
|
14
|
+
}
|
|
15
|
+
set cssText(value) {
|
|
16
|
+
this.#properties.clear();
|
|
17
|
+
this.#outlineNone = false;
|
|
18
|
+
for (const declaration of value.split(";")) {
|
|
19
|
+
const [name, ...rest] = declaration.split(":");
|
|
20
|
+
if (!name || rest.length === 0) continue;
|
|
21
|
+
this.#properties.set(normalizeStyleName(name), rest.join(":").trim());
|
|
22
|
+
}
|
|
23
|
+
this.#sync();
|
|
24
|
+
}
|
|
25
|
+
get length() {
|
|
26
|
+
return this.#orderedProperties().length;
|
|
27
|
+
}
|
|
28
|
+
get display() {
|
|
29
|
+
return this.getPropertyValue("display");
|
|
30
|
+
}
|
|
31
|
+
set display(value) {
|
|
32
|
+
this.setProperty("display", value);
|
|
33
|
+
}
|
|
34
|
+
get flexDirection() {
|
|
35
|
+
return this.getPropertyValue("flex-direction");
|
|
36
|
+
}
|
|
37
|
+
set flexDirection(value) {
|
|
38
|
+
this.setProperty("flex-direction", value);
|
|
39
|
+
}
|
|
40
|
+
get backgroundColor() {
|
|
41
|
+
return this.getPropertyValue("background-color");
|
|
42
|
+
}
|
|
43
|
+
set backgroundColor(value) {
|
|
44
|
+
this.setProperty("background-color", value);
|
|
45
|
+
}
|
|
46
|
+
get color() {
|
|
47
|
+
return this.getPropertyValue("color");
|
|
48
|
+
}
|
|
49
|
+
set color(value) {
|
|
50
|
+
this.setProperty("color", value);
|
|
51
|
+
}
|
|
52
|
+
get visibility() {
|
|
53
|
+
return this.getPropertyValue("visibility");
|
|
54
|
+
}
|
|
55
|
+
set visibility(value) {
|
|
56
|
+
this.setProperty("visibility", value);
|
|
57
|
+
}
|
|
58
|
+
get pointerEvents() {
|
|
59
|
+
return this.getPropertyValue("pointer-events");
|
|
60
|
+
}
|
|
61
|
+
set pointerEvents(value) {
|
|
62
|
+
this.setProperty("pointer-events", value);
|
|
63
|
+
}
|
|
64
|
+
get opacity() {
|
|
65
|
+
return this.getPropertyValue("opacity");
|
|
66
|
+
}
|
|
67
|
+
set opacity(value) {
|
|
68
|
+
this.setProperty("opacity", value);
|
|
69
|
+
}
|
|
70
|
+
get outlineColor() {
|
|
71
|
+
return this.getPropertyValue("outline-color");
|
|
72
|
+
}
|
|
73
|
+
set outlineColor(value) {
|
|
74
|
+
this.setProperty("outline-color", value);
|
|
75
|
+
}
|
|
76
|
+
get outlineStyle() {
|
|
77
|
+
return this.getPropertyValue("outline-style");
|
|
78
|
+
}
|
|
79
|
+
set outlineStyle(value) {
|
|
80
|
+
this.setProperty("outline-style", value);
|
|
81
|
+
}
|
|
82
|
+
get outlineWidth() {
|
|
83
|
+
return this.getPropertyValue("outline-width");
|
|
84
|
+
}
|
|
85
|
+
set outlineWidth(value) {
|
|
86
|
+
this.setProperty("outline-width", value);
|
|
87
|
+
}
|
|
88
|
+
get outline() {
|
|
89
|
+
return this.getPropertyValue("outline");
|
|
90
|
+
}
|
|
91
|
+
set outline(value) {
|
|
92
|
+
if (String(value).trim() === "none") {
|
|
93
|
+
this.#properties.delete("outline");
|
|
94
|
+
this.#properties.delete("outline-color");
|
|
95
|
+
this.#properties.delete("outline-style");
|
|
96
|
+
this.#properties.delete("outline-width");
|
|
97
|
+
this.#outlineNone = true;
|
|
98
|
+
this.#sync();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
this.setProperty("outline", value);
|
|
102
|
+
}
|
|
103
|
+
get animation() {
|
|
104
|
+
return this.getPropertyValue("animation");
|
|
105
|
+
}
|
|
106
|
+
set animation(value) {
|
|
107
|
+
this.setProperty("animation", value);
|
|
108
|
+
}
|
|
109
|
+
get content() {
|
|
110
|
+
return this.getPropertyValue("content");
|
|
111
|
+
}
|
|
112
|
+
set content(value) {
|
|
113
|
+
this.setProperty("content", value);
|
|
114
|
+
}
|
|
115
|
+
get width() {
|
|
116
|
+
return this.getPropertyValue("width");
|
|
117
|
+
}
|
|
118
|
+
set width(value) {
|
|
119
|
+
this.setProperty("width", value);
|
|
120
|
+
}
|
|
121
|
+
get inlineSize() {
|
|
122
|
+
return this.getPropertyValue("inline-size");
|
|
123
|
+
}
|
|
124
|
+
set inlineSize(value) {
|
|
125
|
+
this.setProperty("inline-size", value);
|
|
126
|
+
}
|
|
127
|
+
get minWidth() {
|
|
128
|
+
return this.getPropertyValue("min-width");
|
|
129
|
+
}
|
|
130
|
+
set minWidth(value) {
|
|
131
|
+
this.setProperty("min-width", value);
|
|
132
|
+
}
|
|
133
|
+
get height() {
|
|
134
|
+
return this.getPropertyValue("height");
|
|
135
|
+
}
|
|
136
|
+
set height(value) {
|
|
137
|
+
this.setProperty("height", value);
|
|
138
|
+
}
|
|
139
|
+
get blockSize() {
|
|
140
|
+
return this.getPropertyValue("block-size");
|
|
141
|
+
}
|
|
142
|
+
set blockSize(value) {
|
|
143
|
+
this.setProperty("block-size", value);
|
|
144
|
+
}
|
|
145
|
+
get border() {
|
|
146
|
+
return this.getPropertyValue("border");
|
|
147
|
+
}
|
|
148
|
+
set border(value) {
|
|
149
|
+
this.setProperty("border", value);
|
|
150
|
+
}
|
|
151
|
+
get clip() {
|
|
152
|
+
return this.getPropertyValue("clip");
|
|
153
|
+
}
|
|
154
|
+
set clip(value) {
|
|
155
|
+
this.setProperty("clip", value);
|
|
156
|
+
}
|
|
157
|
+
get clipPath() {
|
|
158
|
+
return this.getPropertyValue("clip-path");
|
|
159
|
+
}
|
|
160
|
+
set clipPath(value) {
|
|
161
|
+
this.setProperty("clip-path", value);
|
|
162
|
+
}
|
|
163
|
+
get caretColor() {
|
|
164
|
+
return this.getPropertyValue("caret-color");
|
|
165
|
+
}
|
|
166
|
+
set caretColor(value) {
|
|
167
|
+
this.setProperty("caret-color", value);
|
|
168
|
+
}
|
|
169
|
+
get margin() {
|
|
170
|
+
return this.getPropertyValue("margin");
|
|
171
|
+
}
|
|
172
|
+
set margin(value) {
|
|
173
|
+
this.setProperty("margin", value);
|
|
174
|
+
}
|
|
175
|
+
get overflow() {
|
|
176
|
+
return this.getPropertyValue("overflow");
|
|
177
|
+
}
|
|
178
|
+
set overflow(value) {
|
|
179
|
+
this.setProperty("overflow", value);
|
|
180
|
+
}
|
|
181
|
+
get padding() {
|
|
182
|
+
return this.getPropertyValue("padding");
|
|
183
|
+
}
|
|
184
|
+
set padding(value) {
|
|
185
|
+
this.setProperty("padding", value);
|
|
186
|
+
}
|
|
187
|
+
get whiteSpace() {
|
|
188
|
+
return this.getPropertyValue("white-space");
|
|
189
|
+
}
|
|
190
|
+
set whiteSpace(value) {
|
|
191
|
+
this.setProperty("white-space", value);
|
|
192
|
+
}
|
|
193
|
+
get wordWrap() {
|
|
194
|
+
return this.getPropertyValue("word-wrap");
|
|
195
|
+
}
|
|
196
|
+
set wordWrap(value) {
|
|
197
|
+
this.setProperty("word-wrap", value);
|
|
198
|
+
}
|
|
199
|
+
get transitionDuration() {
|
|
200
|
+
return this.getPropertyValue("transition-duration");
|
|
201
|
+
}
|
|
202
|
+
set transitionDuration(value) {
|
|
203
|
+
this.setProperty("transition-duration", value);
|
|
204
|
+
}
|
|
205
|
+
get animationDuration() {
|
|
206
|
+
return this.getPropertyValue("animation-duration");
|
|
207
|
+
}
|
|
208
|
+
set animationDuration(value) {
|
|
209
|
+
this.setProperty("animation-duration", value);
|
|
210
|
+
}
|
|
211
|
+
get animationName() {
|
|
212
|
+
return this.getPropertyValue("animation-name");
|
|
213
|
+
}
|
|
214
|
+
set animationName(value) {
|
|
215
|
+
this.setProperty("animation-name", value);
|
|
216
|
+
}
|
|
217
|
+
get top() {
|
|
218
|
+
return this.getPropertyValue("top");
|
|
219
|
+
}
|
|
220
|
+
set top(value) {
|
|
221
|
+
this.setProperty("top", value);
|
|
222
|
+
}
|
|
223
|
+
get right() {
|
|
224
|
+
return this.getPropertyValue("right");
|
|
225
|
+
}
|
|
226
|
+
set right(value) {
|
|
227
|
+
this.setProperty("right", value);
|
|
228
|
+
}
|
|
229
|
+
get bottom() {
|
|
230
|
+
return this.getPropertyValue("bottom");
|
|
231
|
+
}
|
|
232
|
+
set bottom(value) {
|
|
233
|
+
this.setProperty("bottom", value);
|
|
234
|
+
}
|
|
235
|
+
get left() {
|
|
236
|
+
return this.getPropertyValue("left");
|
|
237
|
+
}
|
|
238
|
+
set left(value) {
|
|
239
|
+
this.setProperty("left", value);
|
|
240
|
+
}
|
|
241
|
+
get position() {
|
|
242
|
+
return this.getPropertyValue("position");
|
|
243
|
+
}
|
|
244
|
+
set position(value) {
|
|
245
|
+
this.setProperty("position", value);
|
|
246
|
+
}
|
|
247
|
+
get transform() {
|
|
248
|
+
return this.getPropertyValue("transform");
|
|
249
|
+
}
|
|
250
|
+
set transform(value) {
|
|
251
|
+
this.setProperty("transform", value);
|
|
252
|
+
}
|
|
253
|
+
get transformOrigin() {
|
|
254
|
+
return this.getPropertyValue("transform-origin");
|
|
255
|
+
}
|
|
256
|
+
set transformOrigin(value) {
|
|
257
|
+
this.setProperty("transform-origin", value);
|
|
258
|
+
}
|
|
259
|
+
get WebkitTransform() {
|
|
260
|
+
return this.getPropertyValue("WebkitTransform");
|
|
261
|
+
}
|
|
262
|
+
set WebkitTransform(value) {
|
|
263
|
+
this.setProperty("WebkitTransform", value);
|
|
264
|
+
}
|
|
265
|
+
get MozTransform() {
|
|
266
|
+
return this.getPropertyValue("MozTransform");
|
|
267
|
+
}
|
|
268
|
+
set MozTransform(value) {
|
|
269
|
+
this.setProperty("MozTransform", value);
|
|
270
|
+
}
|
|
271
|
+
get msTransform() {
|
|
272
|
+
return this.getPropertyValue("msTransform");
|
|
273
|
+
}
|
|
274
|
+
set msTransform(value) {
|
|
275
|
+
this.setProperty("msTransform", value);
|
|
276
|
+
}
|
|
277
|
+
get OTransform() {
|
|
278
|
+
return this.getPropertyValue("OTransform");
|
|
279
|
+
}
|
|
280
|
+
set OTransform(value) {
|
|
281
|
+
this.setProperty("OTransform", value);
|
|
282
|
+
}
|
|
283
|
+
get boxSizing() {
|
|
284
|
+
return this.getPropertyValue("boxSizing");
|
|
285
|
+
}
|
|
286
|
+
set boxSizing(value) {
|
|
287
|
+
this.setProperty("boxSizing", value);
|
|
288
|
+
}
|
|
289
|
+
get zIndex() {
|
|
290
|
+
return this.getPropertyValue("zIndex");
|
|
291
|
+
}
|
|
292
|
+
set zIndex(value) {
|
|
293
|
+
this.setProperty("zIndex", value);
|
|
294
|
+
}
|
|
295
|
+
get touchAction() {
|
|
296
|
+
return this.getPropertyValue("touchAction");
|
|
297
|
+
}
|
|
298
|
+
set touchAction(value) {
|
|
299
|
+
this.setProperty("touchAction", value);
|
|
300
|
+
}
|
|
301
|
+
get userSelect() {
|
|
302
|
+
return this.getPropertyValue("userSelect");
|
|
303
|
+
}
|
|
304
|
+
set userSelect(value) {
|
|
305
|
+
this.setProperty("userSelect", value);
|
|
306
|
+
}
|
|
307
|
+
item(index) {
|
|
308
|
+
return this.#orderedProperties()[index]?.[0] ?? "";
|
|
309
|
+
}
|
|
310
|
+
getPropertyValue(name) {
|
|
311
|
+
const normalized = normalizeStyleName(name);
|
|
312
|
+
if (this.#outlineNone) {
|
|
313
|
+
if (normalized === "outline-color" || normalized === "outline-style") return "none";
|
|
314
|
+
if (normalized === "outline-width") return "initial";
|
|
315
|
+
}
|
|
316
|
+
return this.#properties.get(normalized) ?? "";
|
|
317
|
+
}
|
|
318
|
+
setProperty(name, value) {
|
|
319
|
+
const normalized = normalizeStyleName(name);
|
|
320
|
+
if (normalized === "outline" && String(value).trim() === "none") {
|
|
321
|
+
this.outline = "none";
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
if (isOutlineProperty(normalized)) this.#outlineNone = false;
|
|
325
|
+
if (value == null || String(value).trim() === "") this.#properties.delete(normalized);
|
|
326
|
+
else this.#properties.set(normalized, normalizeStyleValue(normalized, value));
|
|
327
|
+
this.#sync();
|
|
328
|
+
}
|
|
329
|
+
removeProperty(name) {
|
|
330
|
+
const normalized = normalizeStyleName(name);
|
|
331
|
+
const previous = this.getPropertyValue(normalized);
|
|
332
|
+
if (isOutlineProperty(normalized)) this.#outlineNone = false;
|
|
333
|
+
this.#properties.delete(normalized);
|
|
334
|
+
this.#sync();
|
|
335
|
+
return previous;
|
|
336
|
+
}
|
|
337
|
+
#orderedProperties() {
|
|
338
|
+
const entries = [...this.#properties];
|
|
339
|
+
if (this.#outlineNone) {
|
|
340
|
+
entries.push(["outline-color", "none"]);
|
|
341
|
+
entries.push(["outline-style", "none"]);
|
|
342
|
+
entries.push(["outline-width", "initial"]);
|
|
343
|
+
}
|
|
344
|
+
return entries;
|
|
345
|
+
}
|
|
346
|
+
#sync() {
|
|
347
|
+
if (this.#element) {
|
|
348
|
+
const cssText = this.cssText;
|
|
349
|
+
if (cssText) this.#element.setAttribute("style", cssText);
|
|
350
|
+
else this.#element.removeAttribute("style");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var CSSRule = class {
|
|
355
|
+
static STYLE_RULE = 1;
|
|
356
|
+
static MEDIA_RULE = 4;
|
|
357
|
+
type;
|
|
358
|
+
parentRule = null;
|
|
359
|
+
parentStyleSheet = null;
|
|
360
|
+
constructor(type) {
|
|
361
|
+
this.type = type;
|
|
362
|
+
}
|
|
363
|
+
get cssText() {
|
|
364
|
+
return "";
|
|
365
|
+
}
|
|
366
|
+
};
|
|
367
|
+
var CSSStyleRule = class extends CSSRule {
|
|
368
|
+
selectorText;
|
|
369
|
+
style;
|
|
370
|
+
constructor(selectorText, styleText) {
|
|
371
|
+
super(CSSRule.STYLE_RULE);
|
|
372
|
+
this.selectorText = selectorText.trim();
|
|
373
|
+
this.style = new CSSStyleDeclaration(styleText);
|
|
374
|
+
this.style.parentRule = this;
|
|
375
|
+
}
|
|
376
|
+
get cssText() {
|
|
377
|
+
const declarations = this.style.cssText;
|
|
378
|
+
return `${this.selectorText} {${declarations ? ` ${declarations} ` : " "}}`;
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
var CSSMediaRule = class extends CSSRule {
|
|
382
|
+
conditionText;
|
|
383
|
+
cssRules = [];
|
|
384
|
+
media;
|
|
385
|
+
constructor(conditionText, rules = []) {
|
|
386
|
+
super(CSSRule.MEDIA_RULE);
|
|
387
|
+
this.conditionText = conditionText.trim();
|
|
388
|
+
this.media = Object.assign([this.conditionText], { mediaText: this.conditionText });
|
|
389
|
+
for (const rule of rules) {
|
|
390
|
+
rule.parentRule = this;
|
|
391
|
+
this.cssRules.push(rule);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
get cssText() {
|
|
395
|
+
const inner = this.cssRules.map((rule) => ` ${rule.cssText}`).join("\n");
|
|
396
|
+
return `@media ${this.conditionText} {\n${inner}\n}`;
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
var CSSStyleSheet = class {
|
|
400
|
+
cssRules = [];
|
|
401
|
+
disabled = false;
|
|
402
|
+
href = null;
|
|
403
|
+
ownerRule = null;
|
|
404
|
+
title = null;
|
|
405
|
+
constructor(cssText = "") {
|
|
406
|
+
if (cssText) this.replaceSync(cssText);
|
|
407
|
+
}
|
|
408
|
+
insertRule(ruleText, index = this.cssRules.length) {
|
|
409
|
+
const normalizedIndex = Number(index);
|
|
410
|
+
if (!Number.isInteger(normalizedIndex) || normalizedIndex < 0 || normalizedIndex > this.cssRules.length) throw new DOMException("The index provided is outside the rule list.", "IndexSizeError");
|
|
411
|
+
const rules = parseCssRules(String(ruleText), this);
|
|
412
|
+
if (rules.length !== 1) throw new DOMException(`Failed to parse the rule '${String(ruleText)}'.`, "SyntaxError");
|
|
413
|
+
this.cssRules.splice(normalizedIndex, 0, rules[0]);
|
|
414
|
+
return normalizedIndex;
|
|
415
|
+
}
|
|
416
|
+
deleteRule(index = 0) {
|
|
417
|
+
const normalizedIndex = Number(index);
|
|
418
|
+
if (Number.isInteger(normalizedIndex) && normalizedIndex >= 0 && normalizedIndex < this.cssRules.length) this.cssRules.splice(normalizedIndex, 1);
|
|
419
|
+
}
|
|
420
|
+
replaceSync(cssText) {
|
|
421
|
+
this.cssRules.splice(0, this.cssRules.length, ...parseCssRules(String(cssText), this));
|
|
422
|
+
}
|
|
423
|
+
};
|
|
455
424
|
function parseCssRules(cssText, sheet) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
if (closeBrace === -1) {
|
|
472
|
-
throw new DOMException(`Failed to parse the rule '${cssText}'.`, "SyntaxError");
|
|
473
|
-
}
|
|
474
|
-
const prelude = source.slice(cursor, openBrace).trim();
|
|
475
|
-
const block = source.slice(openBrace + 1, closeBrace).trim();
|
|
476
|
-
const rule = createCssRule(prelude, block, sheet, cssText);
|
|
477
|
-
rules.push(rule);
|
|
478
|
-
cursor = closeBrace + 1;
|
|
479
|
-
}
|
|
480
|
-
return rules;
|
|
425
|
+
const rules = [];
|
|
426
|
+
const source = stripCssComments(cssText);
|
|
427
|
+
let cursor = 0;
|
|
428
|
+
while (cursor < source.length) {
|
|
429
|
+
while (/\s/.test(source[cursor] ?? "")) cursor++;
|
|
430
|
+
if (cursor >= source.length) break;
|
|
431
|
+
const openBrace = source.indexOf("{", cursor);
|
|
432
|
+
if (openBrace === -1) throw new DOMException(`Failed to parse the rule '${cssText}'.`, "SyntaxError");
|
|
433
|
+
const closeBrace = findMatchingCssBrace(source, openBrace);
|
|
434
|
+
if (closeBrace === -1) throw new DOMException(`Failed to parse the rule '${cssText}'.`, "SyntaxError");
|
|
435
|
+
const rule = createCssRule(source.slice(cursor, openBrace).trim(), source.slice(openBrace + 1, closeBrace).trim(), sheet, cssText);
|
|
436
|
+
rules.push(rule);
|
|
437
|
+
cursor = closeBrace + 1;
|
|
438
|
+
}
|
|
439
|
+
return rules;
|
|
481
440
|
}
|
|
482
441
|
function createCssRule(prelude, block, sheet, sourceText) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
}
|
|
498
|
-
const rule = new CSSStyleRule(prelude, block);
|
|
499
|
-
rule.parentStyleSheet = sheet;
|
|
500
|
-
return rule;
|
|
442
|
+
if (!prelude) throw new DOMException(`Failed to parse the rule '${sourceText}'.`, "SyntaxError");
|
|
443
|
+
if (prelude.toLowerCase().startsWith("@media ")) {
|
|
444
|
+
const mediaRule = new CSSMediaRule(prelude.slice(7), parseCssRules(block, sheet));
|
|
445
|
+
mediaRule.parentStyleSheet = sheet;
|
|
446
|
+
for (const child of mediaRule.cssRules) {
|
|
447
|
+
child.parentRule = mediaRule;
|
|
448
|
+
child.parentStyleSheet = sheet;
|
|
449
|
+
}
|
|
450
|
+
return mediaRule;
|
|
451
|
+
}
|
|
452
|
+
if (prelude.startsWith("@") || !block.includes(":")) throw new DOMException(`Failed to parse the rule '${sourceText}'.`, "SyntaxError");
|
|
453
|
+
const rule = new CSSStyleRule(prelude, block);
|
|
454
|
+
rule.parentStyleSheet = sheet;
|
|
455
|
+
return rule;
|
|
501
456
|
}
|
|
502
457
|
function findMatchingCssBrace(source, openBrace) {
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
if (depth === 0) {
|
|
527
|
-
return index;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
return -1;
|
|
458
|
+
let depth = 0;
|
|
459
|
+
let quote = null;
|
|
460
|
+
for (let index = openBrace; index < source.length; index++) {
|
|
461
|
+
const character = source[index];
|
|
462
|
+
if (quote) {
|
|
463
|
+
if (character === "\\" && index + 1 < source.length) index++;
|
|
464
|
+
else if (character === quote) quote = null;
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
if (character === "\"" || character === "'") {
|
|
468
|
+
quote = character;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (character === "{") {
|
|
472
|
+
depth++;
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
if (character === "}") {
|
|
476
|
+
depth--;
|
|
477
|
+
if (depth === 0) return index;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return -1;
|
|
532
481
|
}
|
|
533
482
|
function stripCssComments(cssText) {
|
|
534
|
-
|
|
483
|
+
return cssText.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
535
484
|
}
|
|
536
485
|
function isOutlineProperty(name) {
|
|
537
|
-
|
|
538
|
-
name === "outline-color" ||
|
|
539
|
-
name === "outline-style" ||
|
|
540
|
-
name === "outline-width");
|
|
486
|
+
return name === "outline" || name === "outline-color" || name === "outline-style" || name === "outline-width";
|
|
541
487
|
}
|
|
542
488
|
function normalizeStyleName(name) {
|
|
543
|
-
|
|
544
|
-
.trim()
|
|
545
|
-
.replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`)
|
|
546
|
-
.toLowerCase();
|
|
489
|
+
return name.trim().replace(/[A-Z]/g, (character) => `-${character.toLowerCase()}`).toLowerCase();
|
|
547
490
|
}
|
|
548
491
|
const numericLengthProperties = new Set([
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
492
|
+
"block-size",
|
|
493
|
+
"border",
|
|
494
|
+
"bottom",
|
|
495
|
+
"height",
|
|
496
|
+
"inline-size",
|
|
497
|
+
"left",
|
|
498
|
+
"margin",
|
|
499
|
+
"min-width",
|
|
500
|
+
"padding",
|
|
501
|
+
"right",
|
|
502
|
+
"top",
|
|
503
|
+
"width"
|
|
561
504
|
]);
|
|
562
505
|
function normalizeStyleValue(name, value) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (typeof value === "string" &&
|
|
567
|
-
numericLengthProperties.has(name) &&
|
|
568
|
-
/^-?\d+(?:\.\d+)?$/.test(value.trim())) {
|
|
569
|
-
return `${value.trim()}px`;
|
|
570
|
-
}
|
|
571
|
-
return String(value).trim();
|
|
506
|
+
if (typeof value === "number" && numericLengthProperties.has(name)) return `${value}px`;
|
|
507
|
+
if (typeof value === "string" && numericLengthProperties.has(name) && /^-?\d+(?:\.\d+)?$/.test(value.trim())) return `${value.trim()}px`;
|
|
508
|
+
return String(value).trim();
|
|
572
509
|
}
|
|
510
|
+
//#endregion
|
|
511
|
+
export { CSSMediaRule, CSSRule, CSSStyleDeclaration, CSSStyleRule, CSSStyleSheet };
|
|
512
|
+
|
|
573
513
|
//# sourceMappingURL=css.js.map
|