happy-dom 5.0.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/lib/config/ElementTag.d.ts +6 -3
- package/lib/config/ElementTag.js +6 -3
- package/lib/config/ElementTag.js.map +1 -1
- package/lib/config/NonImplemenetedElementClasses.js +0 -3
- package/lib/config/NonImplemenetedElementClasses.js.map +1 -1
- package/lib/dom-token-list/DOMTokenList.d.ts +4 -0
- package/lib/dom-token-list/DOMTokenList.js +6 -0
- package/lib/dom-token-list/DOMTokenList.js.map +1 -1
- package/lib/dom-token-list/IDOMTokenList.d.ts +1 -0
- package/lib/exception/DOMExceptionNameEnum.d.ts +2 -1
- package/lib/exception/DOMExceptionNameEnum.js +1 -0
- package/lib/exception/DOMExceptionNameEnum.js.map +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.d.ts +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.js +1 -1
- package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
- package/lib/nodes/html-input-element/IHTMLInputElement.d.ts +1 -1
- package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.d.ts +34 -0
- package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js +58 -0
- package/lib/nodes/html-opt-group-element/HTMLOptGroupElement.js.map +1 -0
- package/lib/nodes/html-opt-group-element/IHTMLOptGroupElement.d.ts +11 -0
- package/lib/nodes/html-opt-group-element/IHTMLOptGroupElement.js +3 -0
- package/lib/nodes/html-opt-group-element/IHTMLOptGroupElement.js.map +1 -0
- package/lib/nodes/html-option-element/HTMLOptionElement.d.ts +72 -0
- package/lib/nodes/html-option-element/HTMLOptionElement.js +111 -0
- package/lib/nodes/html-option-element/HTMLOptionElement.js.map +1 -0
- package/lib/nodes/html-option-element/HTMLOptionElementValueSanitizer.d.ts +11 -0
- package/lib/nodes/html-option-element/HTMLOptionElementValueSanitizer.js +18 -0
- package/lib/nodes/html-option-element/HTMLOptionElementValueSanitizer.js.map +1 -0
- package/lib/nodes/html-option-element/HTMLOptionsCollection.d.ts +43 -0
- package/lib/nodes/html-option-element/HTMLOptionsCollection.js +80 -0
- package/lib/nodes/html-option-element/HTMLOptionsCollection.js.map +1 -0
- package/lib/nodes/html-option-element/IHTMLOptionElement.d.ts +16 -0
- package/lib/nodes/html-option-element/IHTMLOptionElement.js +3 -0
- package/lib/nodes/html-option-element/IHTMLOptionElement.js.map +1 -0
- package/lib/nodes/html-option-element/IHTMLOptionsCollection.d.ts +26 -0
- package/lib/nodes/html-option-element/IHTMLOptionsCollection.js +3 -0
- package/lib/nodes/html-option-element/IHTMLOptionsCollection.js.map +1 -0
- package/lib/nodes/html-select-element/HTMLSelectElement.d.ts +128 -0
- package/lib/nodes/html-select-element/HTMLSelectElement.js +215 -0
- package/lib/nodes/html-select-element/HTMLSelectElement.js.map +1 -0
- package/lib/nodes/html-select-element/HTMLSelectElementValueSanitizer.d.ts +11 -0
- package/lib/nodes/html-select-element/HTMLSelectElementValueSanitizer.js +18 -0
- package/lib/nodes/html-select-element/HTMLSelectElementValueSanitizer.js.map +1 -0
- package/lib/nodes/html-select-element/IHTMLSelectElement.d.ts +26 -0
- package/lib/nodes/html-select-element/IHTMLSelectElement.js +3 -0
- package/lib/nodes/html-select-element/IHTMLSelectElement.js.map +1 -0
- package/lib/nodes/{html-input-element → validity-state}/ValidityState.d.ts +3 -2
- package/lib/nodes/{html-input-element → validity-state}/ValidityState.js +12 -2
- package/lib/nodes/validity-state/ValidityState.js.map +1 -0
- package/lib/window/Window.d.ts +2 -0
- package/lib/window/Window.js +4 -0
- package/lib/window/Window.js.map +1 -1
- package/lib/window/WindowBase64.d.ts +19 -0
- package/lib/window/WindowBase64.js +88 -0
- package/lib/window/WindowBase64.js.map +1 -0
- package/package.json +2 -2
- package/src/config/ElementTag.ts +6 -3
- package/src/config/NonImplemenetedElementClasses.ts +0 -3
- package/src/dom-token-list/DOMTokenList.ts +7 -0
- package/src/dom-token-list/IDOMTokenList.ts +1 -0
- package/src/exception/DOMExceptionNameEnum.ts +2 -1
- package/src/nodes/html-input-element/HTMLInputElement.ts +1 -1
- package/src/nodes/html-input-element/IHTMLInputElement.ts +1 -1
- package/src/nodes/html-opt-group-element/HTMLOptGroupElement.ts +54 -0
- package/src/nodes/html-opt-group-element/IHTMLOptGroupElement.ts +12 -0
- package/src/nodes/html-option-element/HTMLOptionElement.ts +117 -0
- package/src/nodes/html-option-element/HTMLOptionElementValueSanitizer.ts +15 -0
- package/src/nodes/html-option-element/HTMLOptionsCollection.ts +94 -0
- package/src/nodes/html-option-element/IHTMLOptionElement.ts +17 -0
- package/src/nodes/html-option-element/IHTMLOptionsCollection.ts +33 -0
- package/src/nodes/html-select-element/HTMLSelectElement.ts +239 -0
- package/src/nodes/html-select-element/HTMLSelectElementValueSanitizer.ts +15 -0
- package/src/nodes/html-select-element/IHTMLSelectElement.ts +27 -0
- package/src/nodes/{html-input-element → validity-state}/ValidityState.ts +13 -5
- package/src/window/Window.ts +5 -0
- package/src/window/WindowBase64.ts +95 -0
- package/lib/nodes/html-input-element/ValidityState.js.map +0 -1
package/lib/window/Window.js
CHANGED
@@ -112,6 +112,7 @@ const VMGlobalPropertyScript_1 = __importDefault(require("./VMGlobalPropertyScri
|
|
112
112
|
const PerfHooks = __importStar(require("perf_hooks"));
|
113
113
|
const vm_1 = __importDefault(require("vm"));
|
114
114
|
const buffer_1 = require("buffer");
|
115
|
+
const WindowBase64_1 = require("./WindowBase64");
|
115
116
|
/**
|
116
117
|
* Browser window.
|
117
118
|
*
|
@@ -232,6 +233,9 @@ class Window extends EventTarget_1.default {
|
|
232
233
|
this.sessionStorage = new Storage_1.default();
|
233
234
|
this.localStorage = new Storage_1.default();
|
234
235
|
this.performance = PerfHooks.performance;
|
236
|
+
// Atob & btoa
|
237
|
+
this.atob = WindowBase64_1.atob;
|
238
|
+
this.btoa = WindowBase64_1.btoa;
|
235
239
|
this.Buffer = buffer_1.Buffer;
|
236
240
|
// Private properties
|
237
241
|
this._setTimeout = setTimeout;
|
package/lib/window/Window.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Window.js","sourceRoot":"","sources":["../../src/window/Window.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oGAA4E;AAC5E,0EAAkD;AAClD,uFAA+D;AAC/D,oFAA4D;AAC5D,oFAA4D;AAC5D,8DAAsC;AACtC,2EAAmD;AACnD,8DAAsC;AACtC,uEAA+C;AAC/C,iFAAyD;AACzD,uEAA+C;AAC/C,6GAAqF;AACrF,iGAAyE;AACzE,oFAA4D;AAC5D,0GAAkF;AAClF,oGAA4E;AAC5E,8GAAsF;AACtF,iGAAyE;AACzE,oGAA4E;AAC5E,iGAAyE;AACzE,oGAA4E;AAC5E,iGAAyE;AACzE,iGAAyE;AACzE,uFAA+D;AAC/D,iFAAyD;AACzD,uGAA+E;AAC/E,oGAA4E;AAC5E,8EAAsD;AACtD,mGAA2E;AAC3E,0FAAkE;AAClE,2EAAmD;AACnD,2DAAmC;AACnC,8EAAsD;AACtD,oFAA4D;AAC5D,kFAA0D;AAC1D,kFAA0D;AAC1D,uEAA+C;AAC/C,0DAAkC;AAClC,oEAA4C;AAC5C,iGAAyE;AACzE,6FAAqE;AACrE,4GAAoF;AACpF,wEAAgD;AAChD,oFAA4D;AAC5D,uFAA+D;AAC/D,wDAAgC;AAChC,wDAAgC;AAChC,6EAAqD;AACrD,oEAA4C;AAC5C,iEAAyC;AACzC,yEAAiD;AACjD,qFAA6D;AAC7D,qDAA6B;AAC7B,uEAA+C;AAC/C,4EAAoD;AACpD,gFAAwD;AACxD,4EAAoD;AACpD,4EAAoD;AACpD,yEAAiD;AACjD,iFAAyD;AACzD,yFAAiE;AACjE,4EAAoD;AACpD,+DAAuC;AACvC,4EAAoD;AACpD,gFAAwD;AACxD,8DAAsC;AACtC,8FAAsE;AAOtE,+DAAuC;AACvC,+DA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qC;QACjE,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE;YAC3B,QAAQ,CAAC,CAAC,CAAC,CAAC;QACb,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,oBAAoB,CAAC,EAAkB;QAC7C,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IACvB,CAAC;IAED;;;;;;;OAOG;IACI,KAAK,CAAC,KAAK,CAAC,GAAW,EAAE,IAAmB;QAClD,OAAO,MAAM,sBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACO,eAAe;QACxB,IAAI,CAAC,YAAE,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;YACxB,YAAE,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YAEvB,2DAA2D;YAC3D,wDAAwD;YACxD,YAAE,CAAC,YAAY,CAAC,gCAAsB,EAAE,IAAI,CAAC,CAAC;SAC9C;IACF,CAAC;CACD;AAvbD,yBAubC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* Btoa.
|
3
|
+
*
|
4
|
+
* Reference:
|
5
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/btoa.
|
6
|
+
*
|
7
|
+
* @param data
|
8
|
+
*/
|
9
|
+
export declare const btoa: (data: unknown) => string;
|
10
|
+
/**
|
11
|
+
* Atob.
|
12
|
+
*
|
13
|
+
* Reference:
|
14
|
+
* https://infra.spec.whatwg.org/#forgiving-base64-encode.
|
15
|
+
* Https://html.spec.whatwg.org/multipage/webappapis.html#btoa.
|
16
|
+
*
|
17
|
+
* @param data
|
18
|
+
*/
|
19
|
+
export declare const atob: (data: unknown) => string;
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.atob = exports.btoa = void 0;
|
7
|
+
const DOMException_1 = __importDefault(require("../exception/DOMException"));
|
8
|
+
const DOMExceptionNameEnum_1 = __importDefault(require("../exception/DOMExceptionNameEnum"));
|
9
|
+
const base64list = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
10
|
+
/**
|
11
|
+
* Btoa.
|
12
|
+
*
|
13
|
+
* Reference:
|
14
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/btoa.
|
15
|
+
*
|
16
|
+
* @param data
|
17
|
+
*/
|
18
|
+
const btoa = (data) => {
|
19
|
+
const str = data.toString();
|
20
|
+
if (/[^\u0000-\u00ff]/.test(str)) {
|
21
|
+
throw new DOMException_1.default("Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range.", DOMExceptionNameEnum_1.default.invalidCharacterError);
|
22
|
+
}
|
23
|
+
let t = '';
|
24
|
+
let p = -6;
|
25
|
+
let a = 0;
|
26
|
+
let i = 0;
|
27
|
+
let v = 0;
|
28
|
+
let c;
|
29
|
+
while (i < str.length || p > -6) {
|
30
|
+
if (p < 0) {
|
31
|
+
if (i < str.length) {
|
32
|
+
c = str.charCodeAt(i++);
|
33
|
+
v += 8;
|
34
|
+
}
|
35
|
+
else {
|
36
|
+
c = 0;
|
37
|
+
}
|
38
|
+
a = ((a & 255) << 8) | (c & 255);
|
39
|
+
p += 8;
|
40
|
+
}
|
41
|
+
t += base64list.charAt(v > 0 ? (a >> p) & 63 : 64);
|
42
|
+
p -= 6;
|
43
|
+
v -= 6;
|
44
|
+
}
|
45
|
+
return t;
|
46
|
+
};
|
47
|
+
exports.btoa = btoa;
|
48
|
+
/**
|
49
|
+
* Atob.
|
50
|
+
*
|
51
|
+
* Reference:
|
52
|
+
* https://infra.spec.whatwg.org/#forgiving-base64-encode.
|
53
|
+
* Https://html.spec.whatwg.org/multipage/webappapis.html#btoa.
|
54
|
+
*
|
55
|
+
* @param data
|
56
|
+
*/
|
57
|
+
const atob = (data) => {
|
58
|
+
const str = data.toString();
|
59
|
+
if (/[^\u0000-\u00ff]/.test(str)) {
|
60
|
+
throw new DOMException_1.default("Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range.", DOMExceptionNameEnum_1.default.invalidCharacterError);
|
61
|
+
}
|
62
|
+
if (/[^A-Za-z\d+/=]/.test(str) || str.length % 4 == 1) {
|
63
|
+
throw new DOMException_1.default("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.", DOMExceptionNameEnum_1.default.invalidCharacterError);
|
64
|
+
}
|
65
|
+
let t = '';
|
66
|
+
let p = -8;
|
67
|
+
let a = 0;
|
68
|
+
let c;
|
69
|
+
let d;
|
70
|
+
for (let i = 0; i < str.length; i++) {
|
71
|
+
if ((c = base64list.indexOf(str.charAt(i))) < 0) {
|
72
|
+
continue;
|
73
|
+
}
|
74
|
+
a = (a << 6) | (c & 63);
|
75
|
+
if ((p += 6) >= 0) {
|
76
|
+
d = (a >> p) & 255;
|
77
|
+
if (c !== 64) {
|
78
|
+
t += String.fromCharCode(d);
|
79
|
+
}
|
80
|
+
a &= 63;
|
81
|
+
p -= 8;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
return t;
|
85
|
+
};
|
86
|
+
exports.atob = atob;
|
87
|
+
exports = { btoa: exports.btoa, atob: exports.atob };
|
88
|
+
//# sourceMappingURL=WindowBase64.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"WindowBase64.js","sourceRoot":"","sources":["../../src/window/WindowBase64.ts"],"names":[],"mappings":";;;;;;AAAA,6EAAqD;AACrD,6FAAqE;AAErE,MAAM,UAAU,GAAG,mEAAmE,CAAC;AAEvF;;;;;;;GAOG;AACI,MAAM,IAAI,GAAG,CAAC,IAAa,EAAU,EAAE;IAC7C,MAAM,GAAG,GAAY,IAAK,CAAC,QAAQ,EAAE,CAAC;IACtC,I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package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "happy-dom",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.3.0",
|
4
4
|
"license": "MIT",
|
5
5
|
"homepage": "https://github.com/capricorn86/happy-dom",
|
6
6
|
"repository": "https://github.com/capricorn86/happy-dom",
|
@@ -75,5 +75,5 @@
|
|
75
75
|
"ts-jest": "^27.1.3",
|
76
76
|
"typescript": "^4.6.2"
|
77
77
|
},
|
78
|
-
"gitHead": "
|
78
|
+
"gitHead": "bea5ee66d4bdeb806c6f452690fef1aa744039d9"
|
79
79
|
}
|
package/src/config/ElementTag.ts
CHANGED
@@ -13,6 +13,9 @@ import HTMLLabelElement from '../nodes/html-label-element/HTMLLabelElement';
|
|
13
13
|
import HTMLSlotElement from '../nodes/html-slot-element/HTMLSlotElement';
|
14
14
|
import HTMLMetaElement from '../nodes/html-meta-element/HTMLMetaElement';
|
15
15
|
import HTMLBaseElement from '../nodes/html-base-element/HTMLBaseElement';
|
16
|
+
import HTMLSelectElement from '../nodes/html-select-element/HTMLSelectElement';
|
17
|
+
import HTMLOptionElement from '../nodes/html-option-element/HTMLOptionElement';
|
18
|
+
import HTMLOptGroupElement from '../nodes/html-opt-group-element/HTMLOptGroupElement';
|
16
19
|
|
17
20
|
export default {
|
18
21
|
A: HTMLElement,
|
@@ -102,8 +105,8 @@ export default {
|
|
102
105
|
NOSCRIPT: HTMLElement,
|
103
106
|
OBJECT: HTMLElement,
|
104
107
|
OL: HTMLElement,
|
105
|
-
OPTGROUP:
|
106
|
-
OPTION:
|
108
|
+
OPTGROUP: HTMLOptGroupElement,
|
109
|
+
OPTION: HTMLOptionElement,
|
107
110
|
OUTPUT: HTMLElement,
|
108
111
|
P: HTMLElement,
|
109
112
|
PARAM: HTMLElement,
|
@@ -119,7 +122,7 @@ export default {
|
|
119
122
|
S: HTMLElement,
|
120
123
|
SAMP: HTMLElement,
|
121
124
|
SECTION: HTMLElement,
|
122
|
-
SELECT:
|
125
|
+
SELECT: HTMLSelectElement,
|
123
126
|
SMALL: HTMLElement,
|
124
127
|
SOURCE: HTMLElement,
|
125
128
|
SPAN: HTMLElement,
|
@@ -32,13 +32,10 @@ export default [
|
|
32
32
|
'HTMLMediaElement',
|
33
33
|
'HTMLMeterElement',
|
34
34
|
'HTMLModElement',
|
35
|
-
'HTMLOptGroupElement',
|
36
|
-
'HTMLOptionElement',
|
37
35
|
'HTMLOutputElement',
|
38
36
|
'HTMLPictureElement',
|
39
37
|
'HTMLProgressElement',
|
40
38
|
'HTMLQuoteElement',
|
41
|
-
'HTMLSelectElement',
|
42
39
|
'HTMLSourceElement',
|
43
40
|
'HTMLSpanElement',
|
44
41
|
'HTMLTableCaptionElement',
|
@@ -2,6 +2,7 @@ enum DOMExceptionNameEnum {
|
|
2
2
|
invalidStateError = 'InvalidStateError',
|
3
3
|
indexSizeError = 'IndexSizeError',
|
4
4
|
syntaxError = 'SyntaxError',
|
5
|
-
hierarchyRequestError = 'HierarchyRequestError'
|
5
|
+
hierarchyRequestError = 'HierarchyRequestError',
|
6
|
+
invalidCharacterError = 'InvalidCharacterError'
|
6
7
|
}
|
7
8
|
export default DOMExceptionNameEnum;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import File from '../../file/File';
|
2
2
|
import HTMLElement from '../html-element/HTMLElement';
|
3
|
-
import ValidityState from '
|
3
|
+
import ValidityState from '../validity-state/ValidityState';
|
4
4
|
import DOMException from '../../exception/DOMException';
|
5
5
|
import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum';
|
6
6
|
import Event from '../../event/Event';
|
@@ -2,7 +2,7 @@ import File from '../../file/File';
|
|
2
2
|
import IHTMLElement from '../html-element/IHTMLElement';
|
3
3
|
import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
|
4
4
|
import HTMLInputElementSelectionModeEnum from './HTMLInputElementSelectionModeEnum';
|
5
|
-
import ValidityState from '
|
5
|
+
import ValidityState from '../validity-state/ValidityState';
|
6
6
|
|
7
7
|
/**
|
8
8
|
* HTML Input Element.
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import HTMLElement from '../html-element/HTMLElement';
|
2
|
+
import IHTMLOptGroupElement from './IHTMLOptGroupElement';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* HTML Opt Group Element.
|
6
|
+
*
|
7
|
+
* Reference:
|
8
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptGroupElement.
|
9
|
+
*/
|
10
|
+
export default class HTMLOptGroupElement extends HTMLElement implements IHTMLOptGroupElement {
|
11
|
+
/**
|
12
|
+
* Returns label.
|
13
|
+
*
|
14
|
+
* @returns Label.
|
15
|
+
*/
|
16
|
+
public get label(): string {
|
17
|
+
return this.getAttributeNS(null, 'label') || '';
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Sets label.
|
22
|
+
*
|
23
|
+
* @param label Label.
|
24
|
+
*/
|
25
|
+
public set label(label: string) {
|
26
|
+
if (!label) {
|
27
|
+
this.removeAttributeNS(null, 'label');
|
28
|
+
} else {
|
29
|
+
this.setAttributeNS(null, 'label', label);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Returns disabled.
|
35
|
+
*
|
36
|
+
* @returns Disabled.
|
37
|
+
*/
|
38
|
+
public get disabled(): boolean {
|
39
|
+
return this.getAttributeNS(null, 'disabled') !== null;
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Sets disabled.
|
44
|
+
*
|
45
|
+
* @param disabled Disabled.
|
46
|
+
*/
|
47
|
+
public set disabled(disabled: boolean) {
|
48
|
+
if (!disabled) {
|
49
|
+
this.removeAttributeNS(null, 'disabled');
|
50
|
+
} else {
|
51
|
+
this.setAttributeNS(null, 'disabled', '');
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import IHTMLElement from '../html-element/IHTMLElement';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* HTML Opt Group Element.
|
5
|
+
*
|
6
|
+
* Reference:
|
7
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptGroupElement.
|
8
|
+
*/
|
9
|
+
export default interface IHTMLOptGroupElement extends IHTMLElement {
|
10
|
+
disabled: boolean;
|
11
|
+
label: string;
|
12
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
import HTMLElement from '../html-element/HTMLElement';
|
2
|
+
import IHTMLElement from '../html-element/IHTMLElement';
|
3
|
+
import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
|
4
|
+
import HTMLOptionElementValueSanitizer from './HTMLOptionElementValueSanitizer';
|
5
|
+
import IHTMLOptionElement from './IHTMLOptionElement';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* HTML Option Element.
|
9
|
+
*
|
10
|
+
* Reference:
|
11
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement.
|
12
|
+
*/
|
13
|
+
export default class HTMLOptionElement extends HTMLElement implements IHTMLOptionElement {
|
14
|
+
public _index: number;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Returns inner text, which is the rendered appearance of text.
|
18
|
+
*
|
19
|
+
* @returns Inner text.
|
20
|
+
*/
|
21
|
+
public get text(): string {
|
22
|
+
return this.innerText;
|
23
|
+
}
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Sets the inner text, which is the rendered appearance of text.
|
27
|
+
*
|
28
|
+
* @param innerText Inner text.
|
29
|
+
*/
|
30
|
+
public set text(text: string) {
|
31
|
+
this.innerText = text;
|
32
|
+
}
|
33
|
+
|
34
|
+
/**
|
35
|
+
* Returns index.
|
36
|
+
*
|
37
|
+
* @returns Index.
|
38
|
+
*/
|
39
|
+
public get index(): number {
|
40
|
+
return this._index;
|
41
|
+
}
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Returns the parent form element.
|
45
|
+
*
|
46
|
+
* @returns Form.
|
47
|
+
*/
|
48
|
+
public get form(): IHTMLFormElement {
|
49
|
+
let parent = <IHTMLElement>this.parentNode;
|
50
|
+
while (parent && parent.tagName !== 'FORM') {
|
51
|
+
parent = <IHTMLElement>parent.parentNode;
|
52
|
+
}
|
53
|
+
return <IHTMLFormElement>parent;
|
54
|
+
}
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Returns selected.
|
58
|
+
*
|
59
|
+
* @returns Selected.
|
60
|
+
*/
|
61
|
+
public get selected(): boolean {
|
62
|
+
return this.getAttributeNS(null, 'selected') !== null;
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Sets selected.
|
67
|
+
*
|
68
|
+
* @param selected Selected.
|
69
|
+
*/
|
70
|
+
public set selected(selected: boolean) {
|
71
|
+
if (!selected) {
|
72
|
+
this.removeAttributeNS(null, 'selected');
|
73
|
+
} else {
|
74
|
+
this.setAttributeNS(null, 'selected', '');
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Returns disabled.
|
80
|
+
*
|
81
|
+
* @returns Disabled.
|
82
|
+
*/
|
83
|
+
public get disabled(): boolean {
|
84
|
+
return this.getAttributeNS(null, 'disabled') !== null;
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Sets disabled.
|
89
|
+
*
|
90
|
+
* @param disabled Disabled.
|
91
|
+
*/
|
92
|
+
public set disabled(disabled: boolean) {
|
93
|
+
if (!disabled) {
|
94
|
+
this.removeAttributeNS(null, 'disabled');
|
95
|
+
} else {
|
96
|
+
this.setAttributeNS(null, 'disabled', '');
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Returns value.
|
102
|
+
*
|
103
|
+
* @returns Value.
|
104
|
+
*/
|
105
|
+
public get value(): string {
|
106
|
+
return this.getAttributeNS(null, 'value') || '';
|
107
|
+
}
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Sets value.
|
111
|
+
*
|
112
|
+
* @param value Value.
|
113
|
+
*/
|
114
|
+
public set value(value: string) {
|
115
|
+
this.setAttributeNS(null, 'value', HTMLOptionElementValueSanitizer.sanitize(value));
|
116
|
+
}
|
117
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const NEW_LINES_REGEXP = /[\n\r]/gm;
|
2
|
+
|
3
|
+
/**
|
4
|
+
* HTML select element value sanitizer.
|
5
|
+
*/
|
6
|
+
export default class HTMLOptionElementValueSanitizer {
|
7
|
+
/**
|
8
|
+
* Sanitizes a value.
|
9
|
+
*
|
10
|
+
* @param value Value.
|
11
|
+
*/
|
12
|
+
public static sanitize(value: string): string {
|
13
|
+
return value.trim().replace(NEW_LINES_REGEXP, '');
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
import DOMException from '../../exception/DOMException';
|
2
|
+
import HTMLCollection from '../element/HTMLCollection';
|
3
|
+
import HTMLOptGroupElement from '../html-opt-group-element/HTMLOptGroupElement';
|
4
|
+
import HTMLOptionElement from './HTMLOptionElement';
|
5
|
+
import IHTMLOptionsCollection from './IHTMLOptionsCollection';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* HTML Options Collection.
|
9
|
+
*
|
10
|
+
* Reference:
|
11
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionsCollection.
|
12
|
+
*/
|
13
|
+
export default class HTMLOptionsCollection
|
14
|
+
extends HTMLCollection
|
15
|
+
implements IHTMLOptionsCollection
|
16
|
+
{
|
17
|
+
public _selectedIndex: number;
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Returns selectedIndex.
|
21
|
+
*
|
22
|
+
* @returns SelectedIndex.
|
23
|
+
*/
|
24
|
+
public get selectedIndex(): number {
|
25
|
+
return this._selectedIndex;
|
26
|
+
}
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Sets selectedIndex.
|
30
|
+
*
|
31
|
+
* @param selectedIndex SelectedIndex.
|
32
|
+
*/
|
33
|
+
public set selectedIndex(selectedIndex: number) {
|
34
|
+
this._selectedIndex = selectedIndex;
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Returns item by index.
|
39
|
+
*
|
40
|
+
* @param index Index.
|
41
|
+
*/
|
42
|
+
public item(index: number): HTMLOptionElement | HTMLOptGroupElement {
|
43
|
+
return this[index];
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
*
|
48
|
+
* @param element
|
49
|
+
* @param before
|
50
|
+
*/
|
51
|
+
public add(
|
52
|
+
element: HTMLOptionElement | HTMLOptGroupElement,
|
53
|
+
before?: number | HTMLOptionElement | HTMLOptGroupElement
|
54
|
+
): void {
|
55
|
+
if (!before && before !== 0) {
|
56
|
+
this.push(element);
|
57
|
+
return;
|
58
|
+
}
|
59
|
+
|
60
|
+
if (!Number.isNaN(Number(before))) {
|
61
|
+
if (before < 0) {
|
62
|
+
return;
|
63
|
+
}
|
64
|
+
|
65
|
+
this.splice(<number>before, 0, element);
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
|
69
|
+
const idx = this.findIndex((element) => element === before);
|
70
|
+
if (idx === -1) {
|
71
|
+
throw new DOMException(
|
72
|
+
"Failed to execute 'add' on 'DOMException': The node before which the new node is to be inserted is not a child of this node."
|
73
|
+
);
|
74
|
+
}
|
75
|
+
|
76
|
+
this.splice(idx, 0, element);
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Removes indexed element from collection.
|
81
|
+
*
|
82
|
+
* @param index Index.
|
83
|
+
*/
|
84
|
+
public remove(index: number): void {
|
85
|
+
this.splice(index, 1);
|
86
|
+
if (index === this.selectedIndex) {
|
87
|
+
if (this.length) {
|
88
|
+
this.selectedIndex = 0;
|
89
|
+
} else {
|
90
|
+
this.selectedIndex = -1;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import IHTMLElement from '../html-element/IHTMLElement';
|
2
|
+
import IHTMLFormElement from '../html-form-element/IHTMLFormElement';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* HTML Option Element.
|
6
|
+
*
|
7
|
+
* Reference:
|
8
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement.
|
9
|
+
*/
|
10
|
+
export default interface IHTMLOptionElement extends IHTMLElement {
|
11
|
+
readonly form: IHTMLFormElement;
|
12
|
+
readonly index: number;
|
13
|
+
selected: boolean;
|
14
|
+
value: string;
|
15
|
+
text: string;
|
16
|
+
disabled: boolean;
|
17
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import IHTMLCollection from '../element/IHTMLCollection';
|
2
|
+
import IHTMLOptGroupElement from '../html-opt-group-element/IHTMLOptGroupElement';
|
3
|
+
import IHTMLOptionElement from './IHTMLOptionElement';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* HTML Options Collection.
|
7
|
+
*
|
8
|
+
* Reference:
|
9
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionsCollection.
|
10
|
+
*/
|
11
|
+
export default interface IHTMLOptionsCollection
|
12
|
+
extends IHTMLCollection<IHTMLOptionElement | IHTMLOptGroupElement> {
|
13
|
+
selectedIndex: number;
|
14
|
+
length: number;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Adds new option to collection.
|
18
|
+
*
|
19
|
+
* @param element HTMLOptionElement or HTMLOptGroupElement to add.
|
20
|
+
* @param before HTMLOptionElement or index number.
|
21
|
+
*/
|
22
|
+
add(
|
23
|
+
element: IHTMLOptionElement | IHTMLOptGroupElement,
|
24
|
+
before?: number | IHTMLOptionElement | IHTMLOptGroupElement
|
25
|
+
): void;
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Removes option element from the collection.
|
29
|
+
*
|
30
|
+
* @param index Index.
|
31
|
+
*/
|
32
|
+
remove(index: number): void;
|
33
|
+
}
|