happy-dom 13.8.2 → 13.8.4
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/cjs/browser/utilities/BrowserFrameURL.cjs +1 -11
- package/cjs/browser/utilities/BrowserFrameURL.cjs.map +1 -1
- package/cjs/browser/utilities/BrowserFrameURL.d.ts.map +1 -1
- package/cjs/config/HTMLElementConfig.cjs +714 -0
- package/cjs/config/HTMLElementConfig.cjs.map +1 -0
- package/cjs/config/HTMLElementConfig.d.ts +9 -0
- package/cjs/config/HTMLElementConfig.d.ts.map +1 -0
- package/cjs/config/HTMLElementConfigContentModelEnum.cjs +12 -0
- package/cjs/config/HTMLElementConfigContentModelEnum.cjs.map +1 -0
- package/cjs/config/HTMLElementConfigContentModelEnum.d.ts +9 -0
- package/cjs/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -0
- package/cjs/config/IHTMLElementConfigEntity.cjs +3 -0
- package/cjs/config/IHTMLElementConfigEntity.cjs.map +1 -0
- package/cjs/config/IHTMLElementConfigEntity.d.ts +8 -0
- package/cjs/config/IHTMLElementConfigEntity.d.ts.map +1 -0
- package/cjs/nodes/document/Document.cjs +4 -2
- package/cjs/nodes/document/Document.cjs.map +1 -1
- package/cjs/nodes/document/Document.d.ts.map +1 -1
- package/cjs/nodes/html-anchor-element/HTMLAnchorElement.cjs +157 -58
- package/cjs/nodes/html-anchor-element/HTMLAnchorElement.cjs.map +1 -1
- package/cjs/nodes/html-anchor-element/HTMLAnchorElement.d.ts +1 -3
- package/cjs/nodes/html-anchor-element/HTMLAnchorElement.d.ts.map +1 -1
- package/cjs/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.cjs +3 -12
- package/cjs/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.cjs.map +1 -1
- package/cjs/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.d.ts.map +1 -1
- package/cjs/nodes/html-button-element/HTMLButtonElement.cjs +1 -1
- package/cjs/nodes/html-button-element/HTMLButtonElement.cjs.map +1 -1
- package/cjs/nodes/html-form-element/HTMLFormElement.cjs +2 -1
- package/cjs/nodes/html-form-element/HTMLFormElement.cjs.map +1 -1
- package/cjs/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
- package/cjs/nodes/html-image-element/HTMLImageElement.cjs +11 -2
- package/cjs/nodes/html-image-element/HTMLImageElement.cjs.map +1 -1
- package/cjs/nodes/html-image-element/HTMLImageElement.d.ts +1 -1
- package/cjs/nodes/html-image-element/HTMLImageElement.d.ts.map +1 -1
- package/cjs/nodes/html-input-element/HTMLInputElement.cjs +1 -1
- package/cjs/nodes/html-input-element/HTMLInputElement.cjs.map +1 -1
- package/cjs/nodes/html-link-element/HTMLLinkElement.cjs +10 -1
- package/cjs/nodes/html-link-element/HTMLLinkElement.cjs.map +1 -1
- package/cjs/nodes/html-link-element/HTMLLinkElement.d.ts.map +1 -1
- package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.cjs +0 -2
- package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.cjs.map +1 -1
- package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.d.ts.map +1 -1
- package/cjs/nodes/html-script-element/HTMLScriptElement.cjs +11 -2
- package/cjs/nodes/html-script-element/HTMLScriptElement.cjs.map +1 -1
- package/cjs/nodes/html-script-element/HTMLScriptElement.d.ts +1 -1
- package/cjs/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
- package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.cjs +0 -2
- package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.cjs.map +1 -1
- package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.d.ts.map +1 -1
- package/cjs/version.cjs +1 -1
- package/cjs/xml-parser/XMLParser.cjs +33 -31
- package/cjs/xml-parser/XMLParser.cjs.map +1 -1
- package/cjs/xml-parser/XMLParser.d.ts +2 -0
- package/cjs/xml-parser/XMLParser.d.ts.map +1 -1
- package/cjs/xml-serializer/XMLSerializer.cjs +4 -2
- package/cjs/xml-serializer/XMLSerializer.cjs.map +1 -1
- package/cjs/xml-serializer/XMLSerializer.d.ts.map +1 -1
- package/lib/browser/utilities/BrowserFrameURL.d.ts.map +1 -1
- package/lib/browser/utilities/BrowserFrameURL.js +1 -8
- package/lib/browser/utilities/BrowserFrameURL.js.map +1 -1
- package/lib/config/HTMLElementConfig.d.ts +9 -0
- package/lib/config/HTMLElementConfig.d.ts.map +1 -0
- package/lib/config/HTMLElementConfig.js +709 -0
- package/lib/config/HTMLElementConfig.js.map +1 -0
- package/lib/config/HTMLElementConfigContentModelEnum.d.ts +9 -0
- package/lib/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -0
- package/lib/config/HTMLElementConfigContentModelEnum.js +10 -0
- package/lib/config/HTMLElementConfigContentModelEnum.js.map +1 -0
- package/lib/config/IHTMLElementConfigEntity.d.ts +8 -0
- package/lib/config/IHTMLElementConfigEntity.d.ts.map +1 -0
- package/lib/config/IHTMLElementConfigEntity.js +2 -0
- package/lib/config/IHTMLElementConfigEntity.js.map +1 -0
- package/lib/nodes/document/Document.d.ts.map +1 -1
- package/lib/nodes/document/Document.js +4 -2
- package/lib/nodes/document/Document.js.map +1 -1
- package/lib/nodes/html-anchor-element/HTMLAnchorElement.d.ts +1 -3
- package/lib/nodes/html-anchor-element/HTMLAnchorElement.d.ts.map +1 -1
- package/lib/nodes/html-anchor-element/HTMLAnchorElement.js +157 -58
- package/lib/nodes/html-anchor-element/HTMLAnchorElement.js.map +1 -1
- package/lib/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.d.ts.map +1 -1
- package/lib/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.js +3 -12
- package/lib/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.js.map +1 -1
- package/lib/nodes/html-button-element/HTMLButtonElement.js +1 -1
- package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
- package/lib/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
- package/lib/nodes/html-form-element/HTMLFormElement.js +2 -1
- package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
- package/lib/nodes/html-image-element/HTMLImageElement.d.ts +1 -1
- package/lib/nodes/html-image-element/HTMLImageElement.d.ts.map +1 -1
- package/lib/nodes/html-image-element/HTMLImageElement.js +11 -2
- package/lib/nodes/html-image-element/HTMLImageElement.js.map +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-link-element/HTMLLinkElement.d.ts.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.js +10 -1
- package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.d.ts.map +1 -1
- package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.js +0 -2
- package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.d.ts +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElement.js +11 -2
- package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.d.ts.map +1 -1
- package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.js +0 -2
- package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.js.map +1 -1
- package/lib/version.js +1 -1
- package/lib/xml-parser/XMLParser.d.ts +2 -0
- package/lib/xml-parser/XMLParser.d.ts.map +1 -1
- package/lib/xml-parser/XMLParser.js +33 -31
- package/lib/xml-parser/XMLParser.js.map +1 -1
- package/lib/xml-serializer/XMLSerializer.d.ts.map +1 -1
- package/lib/xml-serializer/XMLSerializer.js +4 -2
- package/lib/xml-serializer/XMLSerializer.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/utilities/BrowserFrameURL.ts +1 -13
- package/src/config/HTMLElementConfig.ts +710 -0
- package/src/config/HTMLElementConfigContentModelEnum.ts +9 -0
- package/src/config/IHTMLElementConfigEntity.ts +8 -0
- package/src/nodes/document/Document.ts +4 -2
- package/src/nodes/html-anchor-element/HTMLAnchorElement.ts +138 -66
- package/src/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.ts +5 -15
- package/src/nodes/html-button-element/HTMLButtonElement.ts +1 -1
- package/src/nodes/html-form-element/HTMLFormElement.ts +2 -4
- package/src/nodes/html-image-element/HTMLImageElement.ts +11 -2
- package/src/nodes/html-input-element/HTMLInputElement.ts +1 -1
- package/src/nodes/html-link-element/HTMLLinkElement.ts +10 -1
- package/src/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.ts +0 -2
- package/src/nodes/html-script-element/HTMLScriptElement.ts +11 -2
- package/src/nodes/html-script-element/HTMLScriptElementScriptLoader.ts +0 -2
- package/src/xml-parser/XMLParser.ts +38 -39
- package/src/xml-serializer/XMLSerializer.ts +4 -2
- package/cjs/config/HTMLElementLocalNameToClass.cjs +0 -122
- package/cjs/config/HTMLElementLocalNameToClass.cjs.map +0 -1
- package/cjs/config/HTMLElementLocalNameToClass.d.ts +0 -5
- package/cjs/config/HTMLElementLocalNameToClass.d.ts.map +0 -1
- package/cjs/config/HTMLElementPlainText.cjs +0 -7
- package/cjs/config/HTMLElementPlainText.cjs.map +0 -1
- package/cjs/config/HTMLElementPlainText.d.ts +0 -6
- package/cjs/config/HTMLElementPlainText.d.ts.map +0 -1
- package/cjs/config/HTMLElementUnnestable.cjs +0 -21
- package/cjs/config/HTMLElementUnnestable.cjs.map +0 -1
- package/cjs/config/HTMLElementUnnestable.d.ts +0 -20
- package/cjs/config/HTMLElementUnnestable.d.ts.map +0 -1
- package/cjs/config/HTMLElementVoid.cjs +0 -19
- package/cjs/config/HTMLElementVoid.cjs.map +0 -1
- package/cjs/config/HTMLElementVoid.d.ts +0 -18
- package/cjs/config/HTMLElementVoid.d.ts.map +0 -1
- package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.cjs +0 -48
- package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.cjs.map +0 -1
- package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts +0 -29
- package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts.map +0 -1
- package/lib/config/HTMLElementLocalNameToClass.d.ts +0 -5
- package/lib/config/HTMLElementLocalNameToClass.d.ts.map +0 -1
- package/lib/config/HTMLElementLocalNameToClass.js +0 -120
- package/lib/config/HTMLElementLocalNameToClass.js.map +0 -1
- package/lib/config/HTMLElementPlainText.d.ts +0 -6
- package/lib/config/HTMLElementPlainText.d.ts.map +0 -1
- package/lib/config/HTMLElementPlainText.js +0 -5
- package/lib/config/HTMLElementPlainText.js.map +0 -1
- package/lib/config/HTMLElementUnnestable.d.ts +0 -20
- package/lib/config/HTMLElementUnnestable.d.ts.map +0 -1
- package/lib/config/HTMLElementUnnestable.js +0 -19
- package/lib/config/HTMLElementUnnestable.js.map +0 -1
- package/lib/config/HTMLElementVoid.d.ts +0 -18
- package/lib/config/HTMLElementVoid.d.ts.map +0 -1
- package/lib/config/HTMLElementVoid.js +0 -17
- package/lib/config/HTMLElementVoid.js.map +0 -1
- package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts +0 -29
- package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts.map +0 -1
- package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.js +0 -42
- package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.js.map +0 -1
- package/src/config/HTMLElementLocalNameToClass.ts +0 -119
- package/src/config/HTMLElementPlainText.ts +0 -4
- package/src/config/HTMLElementUnnestable.ts +0 -18
- package/src/config/HTMLElementVoid.ts +0 -16
- package/src/nodes/html-anchor-element/HTMLAnchorElementUtility.ts +0 -48
@@ -8,7 +8,6 @@ import DocumentFragment from '../document-fragment/DocumentFragment.js';
|
|
8
8
|
import XMLParser from '../../xml-parser/XMLParser.js';
|
9
9
|
import Event from '../../event/Event.js';
|
10
10
|
import DOMImplementation from '../../dom-implementation/DOMImplementation.js';
|
11
|
-
import HTMLElementLocalNameToClass from '../../config/HTMLElementLocalNameToClass.js';
|
12
11
|
import INodeFilter from '../../tree-walker/INodeFilter.js';
|
13
12
|
import NamespaceURI from '../../config/NamespaceURI.js';
|
14
13
|
import DocumentType from '../document-type/DocumentType.js';
|
@@ -51,6 +50,7 @@ import ISVGElementTagNameMap from '../../config/ISVGElementTagNameMap.js';
|
|
51
50
|
import ISVGElement from '../svg-element/ISVGElement.js';
|
52
51
|
import IHTMLFormElement from '../html-form-element/IHTMLFormElement.js';
|
53
52
|
import IHTMLAnchorElement from '../html-anchor-element/IHTMLAnchorElement.js';
|
53
|
+
import HTMLElementConfig from '../../config/HTMLElementConfig.js';
|
54
54
|
|
55
55
|
const PROCESSING_INSTRUCTION_TARGET_REGEXP = /^[a-z][a-z0-9-]+$/;
|
56
56
|
|
@@ -1131,7 +1131,9 @@ export default class Document extends Node implements IDocument {
|
|
1131
1131
|
}
|
1132
1132
|
|
1133
1133
|
const localName = qualifiedName.toLowerCase();
|
1134
|
-
const elementClass =
|
1134
|
+
const elementClass = HTMLElementConfig[localName]
|
1135
|
+
? this[PropertySymbol.ownerWindow][HTMLElementConfig[localName].className]
|
1136
|
+
: null;
|
1135
1137
|
|
1136
1138
|
// Known HTML element
|
1137
1139
|
if (elementClass) {
|
@@ -4,7 +4,6 @@ import DOMTokenList from '../../dom-token-list/DOMTokenList.js';
|
|
4
4
|
import IDOMTokenList from '../../dom-token-list/IDOMTokenList.js';
|
5
5
|
import IHTMLAnchorElement from './IHTMLAnchorElement.js';
|
6
6
|
import URL from '../../url/URL.js';
|
7
|
-
import HTMLAnchorElementUtility from './HTMLAnchorElementUtility.js';
|
8
7
|
import INamedNodeMap from '../../named-node-map/INamedNodeMap.js';
|
9
8
|
import HTMLAnchorElementNamedNodeMap from './HTMLAnchorElementNamedNodeMap.js';
|
10
9
|
import Event from '../../event/Event.js';
|
@@ -22,7 +21,6 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
22
21
|
this
|
23
22
|
);
|
24
23
|
public [PropertySymbol.relList]: DOMTokenList = null;
|
25
|
-
public [PropertySymbol.url]: URL | null = null;
|
26
24
|
|
27
25
|
/**
|
28
26
|
* Returns download.
|
@@ -48,7 +46,17 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
48
46
|
* @returns Hash.
|
49
47
|
*/
|
50
48
|
public get hash(): string {
|
51
|
-
|
49
|
+
const href = this.getAttribute('href');
|
50
|
+
if (href.startsWith('#')) {
|
51
|
+
return href;
|
52
|
+
}
|
53
|
+
let url: URL;
|
54
|
+
try {
|
55
|
+
url = new URL(this.href);
|
56
|
+
} catch (e) {
|
57
|
+
return '';
|
58
|
+
}
|
59
|
+
return url.hash;
|
52
60
|
}
|
53
61
|
|
54
62
|
/**
|
@@ -57,10 +65,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
57
65
|
* @param hash Hash.
|
58
66
|
*/
|
59
67
|
public set hash(hash: string) {
|
60
|
-
|
61
|
-
|
62
|
-
this.
|
68
|
+
let url: URL;
|
69
|
+
try {
|
70
|
+
url = new URL(this.href);
|
71
|
+
} catch (e) {
|
72
|
+
return;
|
63
73
|
}
|
74
|
+
url.hash = hash;
|
75
|
+
this.href = url.href;
|
64
76
|
}
|
65
77
|
|
66
78
|
/**
|
@@ -68,12 +80,17 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
68
80
|
*
|
69
81
|
* @returns Href.
|
70
82
|
*/
|
71
|
-
public get href(): string
|
72
|
-
if (this
|
73
|
-
return
|
83
|
+
public get href(): string {
|
84
|
+
if (!this.hasAttribute('href')) {
|
85
|
+
return '';
|
74
86
|
}
|
75
87
|
|
76
|
-
|
88
|
+
try {
|
89
|
+
return new URL(this.getAttribute('href'), this[PropertySymbol.ownerDocument].location.href)
|
90
|
+
.href;
|
91
|
+
} catch (e) {
|
92
|
+
return this.getAttribute('href');
|
93
|
+
}
|
77
94
|
}
|
78
95
|
|
79
96
|
/**
|
@@ -109,7 +126,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
109
126
|
* @returns Origin.
|
110
127
|
*/
|
111
128
|
public get origin(): string {
|
112
|
-
|
129
|
+
try {
|
130
|
+
return new URL(this.href).origin;
|
131
|
+
} catch (e) {
|
132
|
+
return '';
|
133
|
+
}
|
113
134
|
}
|
114
135
|
|
115
136
|
/**
|
@@ -136,7 +157,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
136
157
|
* @returns Protocol.
|
137
158
|
*/
|
138
159
|
public get protocol(): string {
|
139
|
-
|
160
|
+
try {
|
161
|
+
return new URL(this.href).protocol;
|
162
|
+
} catch (e) {
|
163
|
+
return '';
|
164
|
+
}
|
140
165
|
}
|
141
166
|
|
142
167
|
/**
|
@@ -145,10 +170,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
145
170
|
* @param protocol Protocol.
|
146
171
|
*/
|
147
172
|
public set protocol(protocol: string) {
|
148
|
-
|
149
|
-
|
150
|
-
this.
|
173
|
+
let url: URL;
|
174
|
+
try {
|
175
|
+
url = new URL(this.href);
|
176
|
+
} catch (e) {
|
177
|
+
return;
|
151
178
|
}
|
179
|
+
url.protocol = protocol;
|
180
|
+
this.href = url.href;
|
152
181
|
}
|
153
182
|
|
154
183
|
/**
|
@@ -157,7 +186,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
157
186
|
* @returns Username.
|
158
187
|
*/
|
159
188
|
public get username(): string {
|
160
|
-
|
189
|
+
try {
|
190
|
+
return new URL(this.href).username;
|
191
|
+
} catch (e) {
|
192
|
+
return '';
|
193
|
+
}
|
161
194
|
}
|
162
195
|
|
163
196
|
/**
|
@@ -166,15 +199,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
166
199
|
* @param username Username.
|
167
200
|
*/
|
168
201
|
public set username(username: string) {
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
) {
|
175
|
-
this[PropertySymbol.url].username = username;
|
176
|
-
this.setAttribute('href', this[PropertySymbol.url].toString());
|
202
|
+
let url: URL;
|
203
|
+
try {
|
204
|
+
url = new URL(this.href);
|
205
|
+
} catch (e) {
|
206
|
+
return;
|
177
207
|
}
|
208
|
+
url.username = username;
|
209
|
+
this.href = url.href;
|
178
210
|
}
|
179
211
|
|
180
212
|
/**
|
@@ -183,7 +215,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
183
215
|
* @returns Password.
|
184
216
|
*/
|
185
217
|
public get password(): string {
|
186
|
-
|
218
|
+
try {
|
219
|
+
return new URL(this.href).password;
|
220
|
+
} catch (e) {
|
221
|
+
return '';
|
222
|
+
}
|
187
223
|
}
|
188
224
|
|
189
225
|
/**
|
@@ -192,15 +228,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
192
228
|
* @param password Password.
|
193
229
|
*/
|
194
230
|
public set password(password: string) {
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
) {
|
201
|
-
this[PropertySymbol.url].password = password;
|
202
|
-
this.setAttribute('href', this[PropertySymbol.url].toString());
|
231
|
+
let url: URL;
|
232
|
+
try {
|
233
|
+
url = new URL(this.href);
|
234
|
+
} catch (e) {
|
235
|
+
return;
|
203
236
|
}
|
237
|
+
url.password = password;
|
238
|
+
this.href = url.href;
|
204
239
|
}
|
205
240
|
|
206
241
|
/**
|
@@ -209,7 +244,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
209
244
|
* @returns Pathname.
|
210
245
|
*/
|
211
246
|
public get pathname(): string {
|
212
|
-
|
247
|
+
try {
|
248
|
+
return new URL(this.href).pathname;
|
249
|
+
} catch (e) {
|
250
|
+
return '';
|
251
|
+
}
|
213
252
|
}
|
214
253
|
|
215
254
|
/**
|
@@ -218,10 +257,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
218
257
|
* @param pathname Pathname.
|
219
258
|
*/
|
220
259
|
public set pathname(pathname: string) {
|
221
|
-
|
222
|
-
|
223
|
-
this.
|
260
|
+
let url: URL;
|
261
|
+
try {
|
262
|
+
url = new URL(this.href);
|
263
|
+
} catch (e) {
|
264
|
+
return;
|
224
265
|
}
|
266
|
+
url.pathname = pathname;
|
267
|
+
this.href = url.href;
|
225
268
|
}
|
226
269
|
|
227
270
|
/**
|
@@ -230,7 +273,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
230
273
|
* @returns Port.
|
231
274
|
*/
|
232
275
|
public get port(): string {
|
233
|
-
|
276
|
+
try {
|
277
|
+
return new URL(this.href).port;
|
278
|
+
} catch (e) {
|
279
|
+
return '';
|
280
|
+
}
|
234
281
|
}
|
235
282
|
|
236
283
|
/**
|
@@ -239,15 +286,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
239
286
|
* @param port Port.
|
240
287
|
*/
|
241
288
|
public set port(port: string) {
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
) {
|
248
|
-
this[PropertySymbol.url].port = port;
|
249
|
-
this.setAttribute('href', this[PropertySymbol.url].toString());
|
289
|
+
let url: URL;
|
290
|
+
try {
|
291
|
+
url = new URL(this.href);
|
292
|
+
} catch (e) {
|
293
|
+
return;
|
250
294
|
}
|
295
|
+
url.port = port;
|
296
|
+
this.href = url.href;
|
251
297
|
}
|
252
298
|
|
253
299
|
/**
|
@@ -256,7 +302,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
256
302
|
* @returns Host.
|
257
303
|
*/
|
258
304
|
public get host(): string {
|
259
|
-
|
305
|
+
try {
|
306
|
+
return new URL(this.href).host;
|
307
|
+
} catch (e) {
|
308
|
+
return '';
|
309
|
+
}
|
260
310
|
}
|
261
311
|
|
262
312
|
/**
|
@@ -265,10 +315,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
265
315
|
* @param host Host.
|
266
316
|
*/
|
267
317
|
public set host(host: string) {
|
268
|
-
|
269
|
-
|
270
|
-
this.
|
318
|
+
let url: URL;
|
319
|
+
try {
|
320
|
+
url = new URL(this.href);
|
321
|
+
} catch (e) {
|
322
|
+
return;
|
271
323
|
}
|
324
|
+
url.host = host;
|
325
|
+
this.href = url.href;
|
272
326
|
}
|
273
327
|
|
274
328
|
/**
|
@@ -277,7 +331,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
277
331
|
* @returns Hostname.
|
278
332
|
*/
|
279
333
|
public get hostname(): string {
|
280
|
-
|
334
|
+
try {
|
335
|
+
return new URL(this.href).hostname;
|
336
|
+
} catch (e) {
|
337
|
+
return '';
|
338
|
+
}
|
281
339
|
}
|
282
340
|
|
283
341
|
/**
|
@@ -286,10 +344,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
286
344
|
* @param hostname Hostname.
|
287
345
|
*/
|
288
346
|
public set hostname(hostname: string) {
|
289
|
-
|
290
|
-
|
291
|
-
this.
|
347
|
+
let url: URL;
|
348
|
+
try {
|
349
|
+
url = new URL(this.href);
|
350
|
+
} catch (e) {
|
351
|
+
return;
|
292
352
|
}
|
353
|
+
url.hostname = hostname;
|
354
|
+
this.href = url.href;
|
293
355
|
}
|
294
356
|
|
295
357
|
/**
|
@@ -346,7 +408,11 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
346
408
|
* @returns Search.
|
347
409
|
*/
|
348
410
|
public get search(): string {
|
349
|
-
|
411
|
+
try {
|
412
|
+
return new URL(this.href).search;
|
413
|
+
} catch (e) {
|
414
|
+
return '';
|
415
|
+
}
|
350
416
|
}
|
351
417
|
|
352
418
|
/**
|
@@ -355,10 +421,14 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
355
421
|
* @param search Search.
|
356
422
|
*/
|
357
423
|
public set search(search: string) {
|
358
|
-
|
359
|
-
|
360
|
-
this.
|
424
|
+
let url: URL;
|
425
|
+
try {
|
426
|
+
url = new URL(this.href);
|
427
|
+
} catch (e) {
|
428
|
+
return;
|
361
429
|
}
|
430
|
+
url.search = search;
|
431
|
+
this.href = url.href;
|
362
432
|
}
|
363
433
|
|
364
434
|
/**
|
@@ -433,15 +503,17 @@ export default class HTMLAnchorElement extends HTMLElement implements IHTMLAncho
|
|
433
503
|
event instanceof PointerEvent &&
|
434
504
|
(event.eventPhase === EventPhaseEnum.atTarget ||
|
435
505
|
event.eventPhase === EventPhaseEnum.bubbling) &&
|
436
|
-
!event.defaultPrevented
|
437
|
-
this[PropertySymbol.url]
|
506
|
+
!event.defaultPrevented
|
438
507
|
) {
|
439
|
-
this
|
440
|
-
|
441
|
-
this.
|
442
|
-
|
443
|
-
|
444
|
-
|
508
|
+
const href = this.href;
|
509
|
+
if (href) {
|
510
|
+
this[PropertySymbol.ownerDocument][PropertySymbol.ownerWindow].open(
|
511
|
+
href,
|
512
|
+
this.target || '_self'
|
513
|
+
);
|
514
|
+
if (this[PropertySymbol.ownerDocument][PropertySymbol.ownerWindow].closed) {
|
515
|
+
event.stopImmediatePropagation();
|
516
|
+
}
|
445
517
|
}
|
446
518
|
}
|
447
519
|
|
@@ -2,7 +2,6 @@ import IAttr from '../attr/IAttr.js';
|
|
2
2
|
import * as PropertySymbol from '../../PropertySymbol.js';
|
3
3
|
import HTMLElementNamedNodeMap from '../html-element/HTMLElementNamedNodeMap.js';
|
4
4
|
import HTMLAnchorElement from './HTMLAnchorElement.js';
|
5
|
-
import HTMLAnchorElementUtility from './HTMLAnchorElementUtility.js';
|
6
5
|
|
7
6
|
/**
|
8
7
|
* Named Node Map.
|
@@ -23,11 +22,6 @@ export default class HTMLAnchorElementNamedNodeMap extends HTMLElementNamedNodeM
|
|
23
22
|
this[PropertySymbol.ownerElement][PropertySymbol.relList]
|
24
23
|
) {
|
25
24
|
this[PropertySymbol.ownerElement][PropertySymbol.relList][PropertySymbol.updateIndices]();
|
26
|
-
} else if (item[PropertySymbol.name] === 'href') {
|
27
|
-
this[PropertySymbol.ownerElement][PropertySymbol.url] = HTMLAnchorElementUtility.getUrl(
|
28
|
-
this[PropertySymbol.ownerElement].ownerDocument,
|
29
|
-
item[PropertySymbol.value]
|
30
|
-
);
|
31
25
|
}
|
32
26
|
|
33
27
|
return replacedItem || null;
|
@@ -39,15 +33,11 @@ export default class HTMLAnchorElementNamedNodeMap extends HTMLElementNamedNodeM
|
|
39
33
|
public override [PropertySymbol.removeNamedItem](name: string): IAttr | null {
|
40
34
|
const removedItem = super[PropertySymbol.removeNamedItem](name);
|
41
35
|
|
42
|
-
if (
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
)
|
47
|
-
this[PropertySymbol.ownerElement][PropertySymbol.relList][PropertySymbol.updateIndices]();
|
48
|
-
} else if (removedItem[PropertySymbol.name] === 'href') {
|
49
|
-
this[PropertySymbol.ownerElement][PropertySymbol.url] = null;
|
50
|
-
}
|
36
|
+
if (
|
37
|
+
removedItem?.[PropertySymbol.name] === 'rel' &&
|
38
|
+
this[PropertySymbol.ownerElement][PropertySymbol.relList]
|
39
|
+
) {
|
40
|
+
this[PropertySymbol.ownerElement][PropertySymbol.relList][PropertySymbol.updateIndices]();
|
51
41
|
}
|
52
42
|
|
53
43
|
return removedItem;
|
@@ -136,7 +136,7 @@ export default class HTMLButtonElement extends HTMLElement implements IHTMLButto
|
|
136
136
|
|
137
137
|
try {
|
138
138
|
return new URL(
|
139
|
-
this.getAttribute('formaction')
|
139
|
+
this.getAttribute('formaction'),
|
140
140
|
this[PropertySymbol.ownerDocument].location.href
|
141
141
|
).href;
|
142
142
|
} catch (e) {
|
@@ -129,10 +129,8 @@ export default class HTMLFormElement extends HTMLElement implements IHTMLFormEle
|
|
129
129
|
}
|
130
130
|
|
131
131
|
try {
|
132
|
-
return new URL(
|
133
|
-
|
134
|
-
this[PropertySymbol.ownerDocument].location.href
|
135
|
-
).href;
|
132
|
+
return new URL(this.getAttribute('action'), this[PropertySymbol.ownerDocument].location.href)
|
133
|
+
.href;
|
136
134
|
} catch (e) {
|
137
135
|
return '';
|
138
136
|
}
|
@@ -244,13 +244,22 @@ export default class HTMLImageElement extends HTMLElement implements IHTMLImageE
|
|
244
244
|
* @returns Source.
|
245
245
|
*/
|
246
246
|
public get src(): string {
|
247
|
-
|
247
|
+
if (!this.hasAttribute('src')) {
|
248
|
+
return '';
|
249
|
+
}
|
250
|
+
|
251
|
+
try {
|
252
|
+
return new URL(this.getAttribute('src'), this[PropertySymbol.ownerDocument].location.href)
|
253
|
+
.href;
|
254
|
+
} catch (e) {
|
255
|
+
return this.getAttribute('src');
|
256
|
+
}
|
248
257
|
}
|
249
258
|
|
250
259
|
/**
|
251
260
|
* Sets source.
|
252
261
|
*
|
253
|
-
* @param
|
262
|
+
* @param src Source.
|
254
263
|
*/
|
255
264
|
public set src(src: string) {
|
256
265
|
this.setAttribute('src', src);
|
@@ -108,7 +108,7 @@ export default class HTMLInputElement extends HTMLElement implements IHTMLInputE
|
|
108
108
|
|
109
109
|
try {
|
110
110
|
return new URL(
|
111
|
-
this.getAttribute('formaction')
|
111
|
+
this.getAttribute('formaction'),
|
112
112
|
this[PropertySymbol.ownerDocument].location.href
|
113
113
|
).href;
|
114
114
|
} catch (e) {
|
@@ -107,7 +107,16 @@ export default class HTMLLinkElement extends HTMLElement implements IHTMLLinkEle
|
|
107
107
|
* @returns Href.
|
108
108
|
*/
|
109
109
|
public get href(): string {
|
110
|
-
|
110
|
+
if (!this.hasAttribute('href')) {
|
111
|
+
return '';
|
112
|
+
}
|
113
|
+
|
114
|
+
try {
|
115
|
+
return new URL(this.getAttribute('href'), this[PropertySymbol.ownerDocument].location.href)
|
116
|
+
.href;
|
117
|
+
} catch (e) {
|
118
|
+
return this.getAttribute('href');
|
119
|
+
}
|
111
120
|
}
|
112
121
|
|
113
122
|
/**
|
@@ -55,8 +55,6 @@ export default class HTMLLinkElementStyleSheetLoader {
|
|
55
55
|
element[PropertySymbol.ownerDocument][PropertySymbol.ownerWindow].location.href
|
56
56
|
).href;
|
57
57
|
} catch (error) {
|
58
|
-
this.#loadedStyleSheetURL = null;
|
59
|
-
element.dispatchEvent(new Event('error'));
|
60
58
|
return;
|
61
59
|
}
|
62
60
|
|
@@ -70,13 +70,22 @@ export default class HTMLScriptElement extends HTMLElement implements IHTMLScrip
|
|
70
70
|
* @returns Source.
|
71
71
|
*/
|
72
72
|
public get src(): string {
|
73
|
-
|
73
|
+
if (!this.hasAttribute('src')) {
|
74
|
+
return '';
|
75
|
+
}
|
76
|
+
|
77
|
+
try {
|
78
|
+
return new URL(this.getAttribute('src'), this[PropertySymbol.ownerDocument].location.href)
|
79
|
+
.href;
|
80
|
+
} catch (e) {
|
81
|
+
return this.getAttribute('src');
|
82
|
+
}
|
74
83
|
}
|
75
84
|
|
76
85
|
/**
|
77
86
|
* Sets source.
|
78
87
|
*
|
79
|
-
* @param
|
88
|
+
* @param src Source.
|
80
89
|
*/
|
81
90
|
public set src(src: string) {
|
82
91
|
this.setAttribute('src', src);
|
@@ -50,8 +50,6 @@ export default class HTMLScriptElementScriptLoader {
|
|
50
50
|
element[PropertySymbol.ownerDocument][PropertySymbol.ownerWindow].location.href
|
51
51
|
).href;
|
52
52
|
} catch (error) {
|
53
|
-
this.#loadedScriptURL = null;
|
54
|
-
element.dispatchEvent(new Event('error'));
|
55
53
|
return;
|
56
54
|
}
|
57
55
|
|