happy-dom 13.8.3 → 13.8.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.
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 +11 -11
- package/cjs/config/HTMLElementConfig.cjs.map +1 -1
- package/cjs/config/HTMLElementConfigContentModelEnum.cjs +1 -1
- package/cjs/config/HTMLElementConfigContentModelEnum.cjs.map +1 -1
- package/cjs/config/HTMLElementConfigContentModelEnum.d.ts +1 -1
- package/cjs/config/HTMLElementConfigContentModelEnum.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/query-selector/SelectorItem.cjs +90 -76
- package/cjs/query-selector/SelectorItem.cjs.map +1 -1
- package/cjs/query-selector/SelectorItem.d.ts +9 -1
- package/cjs/query-selector/SelectorItem.d.ts.map +1 -1
- package/cjs/version.cjs +1 -1
- package/cjs/xml-parser/XMLParser.cjs +1 -1
- package/cjs/xml-parser/XMLParser.cjs.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.js +11 -11
- package/lib/config/HTMLElementConfig.js.map +1 -1
- package/lib/config/HTMLElementConfigContentModelEnum.d.ts +1 -1
- package/lib/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -1
- package/lib/config/HTMLElementConfigContentModelEnum.js +1 -1
- package/lib/config/HTMLElementConfigContentModelEnum.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/query-selector/SelectorItem.d.ts +9 -1
- package/lib/query-selector/SelectorItem.d.ts.map +1 -1
- package/lib/query-selector/SelectorItem.js +90 -76
- package/lib/query-selector/SelectorItem.js.map +1 -1
- package/lib/version.js +1 -1
- package/lib/xml-parser/XMLParser.js +1 -1
- package/lib/xml-parser/XMLParser.js.map +1 -1
- package/package.json +1 -1
- package/src/browser/utilities/BrowserFrameURL.ts +1 -13
- package/src/config/HTMLElementConfig.ts +11 -11
- package/src/config/HTMLElementConfigContentModelEnum.ts +1 -1
- 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/query-selector/SelectorItem.ts +97 -80
- package/src/xml-parser/XMLParser.ts +1 -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/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/nodes/html-anchor-element/HTMLAnchorElementUtility.ts +0 -48
@@ -106,7 +106,7 @@ export default class SelectorItem {
|
|
106
106
|
}
|
107
107
|
|
108
108
|
/**
|
109
|
-
* Matches a
|
109
|
+
* Matches a pseudo selector.
|
110
110
|
*
|
111
111
|
* @param element Element.
|
112
112
|
* @returns Result.
|
@@ -121,15 +121,15 @@ export default class SelectorItem {
|
|
121
121
|
return true;
|
122
122
|
}
|
123
123
|
|
124
|
-
for (const
|
124
|
+
for (const pseudo of this.pseudos) {
|
125
125
|
// Validation
|
126
|
-
switch (
|
126
|
+
switch (pseudo.name) {
|
127
127
|
case 'not':
|
128
128
|
case 'nth-child':
|
129
129
|
case 'nth-of-type':
|
130
130
|
case 'nth-last-child':
|
131
131
|
case 'nth-last-of-type':
|
132
|
-
if (!
|
132
|
+
if (!pseudo.arguments) {
|
133
133
|
throw new DOMException(`The selector "${this.getSelectorString()}" is not valid.`);
|
134
134
|
}
|
135
135
|
break;
|
@@ -137,7 +137,7 @@ export default class SelectorItem {
|
|
137
137
|
|
138
138
|
// Check if parent exists
|
139
139
|
if (!parent) {
|
140
|
-
switch (
|
140
|
+
switch (pseudo.name) {
|
141
141
|
case 'first-child':
|
142
142
|
case 'last-child':
|
143
143
|
case 'only-child':
|
@@ -152,86 +152,103 @@ export default class SelectorItem {
|
|
152
152
|
}
|
153
153
|
}
|
154
154
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
155
|
+
if (!this.matchPseudoItem(element, parentChildren, pseudo)) {
|
156
|
+
return false;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
return true;
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Matches a pseudo selector.
|
165
|
+
*
|
166
|
+
* @param element Element.
|
167
|
+
* @param parentChildren Parent children.
|
168
|
+
* @param pseudo Pseudo.
|
169
|
+
*/
|
170
|
+
private matchPseudoItem(
|
171
|
+
element: IElement,
|
172
|
+
parentChildren: IElement[],
|
173
|
+
pseudo: ISelectorPseudo
|
174
|
+
): boolean {
|
175
|
+
switch (pseudo.name) {
|
176
|
+
case 'first-child':
|
177
|
+
return parentChildren[0] === element;
|
178
|
+
case 'last-child':
|
179
|
+
return parentChildren.length && parentChildren[parentChildren.length - 1] === element;
|
180
|
+
case 'only-child':
|
181
|
+
return parentChildren.length === 1 && parentChildren[0] === element;
|
182
|
+
case 'first-of-type':
|
183
|
+
for (const child of parentChildren) {
|
184
|
+
if (child[PropertySymbol.tagName] === element[PropertySymbol.tagName]) {
|
185
|
+
return child === element;
|
167
186
|
}
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
187
|
+
}
|
188
|
+
return false;
|
189
|
+
case 'last-of-type':
|
190
|
+
for (let i = parentChildren.length - 1; i >= 0; i--) {
|
191
|
+
const child = parentChildren[i];
|
192
|
+
if (child[PropertySymbol.tagName] === element[PropertySymbol.tagName]) {
|
193
|
+
return child === element;
|
175
194
|
}
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
isFound = true;
|
195
|
+
}
|
196
|
+
return false;
|
197
|
+
case 'only-of-type':
|
198
|
+
let isFound = false;
|
199
|
+
for (const child of parentChildren) {
|
200
|
+
if (child[PropertySymbol.tagName] === element[PropertySymbol.tagName]) {
|
201
|
+
if (isFound || child !== element) {
|
202
|
+
return false;
|
185
203
|
}
|
204
|
+
isFound = true;
|
186
205
|
}
|
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
|
-
|
206
|
+
}
|
207
|
+
return isFound;
|
208
|
+
case 'checked':
|
209
|
+
return element[PropertySymbol.tagName] === 'INPUT' && (<IHTMLInputElement>element).checked;
|
210
|
+
case 'empty':
|
211
|
+
return !(<Element>element)[PropertySymbol.children].length;
|
212
|
+
case 'root':
|
213
|
+
return element[PropertySymbol.tagName] === 'HTML';
|
214
|
+
case 'not':
|
215
|
+
return !pseudo.selectorItem.match(element);
|
216
|
+
case 'nth-child':
|
217
|
+
const nthChildIndex = pseudo.selectorItem
|
218
|
+
? parentChildren.filter((child) => pseudo.selectorItem.match(child)).indexOf(element)
|
219
|
+
: parentChildren.indexOf(element);
|
220
|
+
return nthChildIndex !== -1 && pseudo.nthFunction(nthChildIndex + 1);
|
221
|
+
case 'nth-of-type':
|
222
|
+
if (!element[PropertySymbol.parentNode]) {
|
223
|
+
return false;
|
224
|
+
}
|
225
|
+
const nthOfTypeIndex = parentChildren
|
226
|
+
.filter((child) => child[PropertySymbol.tagName] === element[PropertySymbol.tagName])
|
227
|
+
.indexOf(element);
|
228
|
+
return nthOfTypeIndex !== -1 && pseudo.nthFunction(nthOfTypeIndex + 1);
|
229
|
+
case 'nth-last-child':
|
230
|
+
const nthLastChildIndex = pseudo.selectorItem
|
231
|
+
? parentChildren
|
232
|
+
.filter((child) => pseudo.selectorItem.match(child))
|
233
|
+
.reverse()
|
234
|
+
.indexOf(element)
|
235
|
+
: parentChildren.reverse().indexOf(element);
|
236
|
+
return nthLastChildIndex !== -1 && pseudo.nthFunction(nthLastChildIndex + 1);
|
237
|
+
case 'nth-last-of-type':
|
238
|
+
const nthLastOfTypeIndex = parentChildren
|
239
|
+
.filter((child) => child[PropertySymbol.tagName] === element[PropertySymbol.tagName])
|
240
|
+
.reverse()
|
241
|
+
.indexOf(element);
|
242
|
+
return nthLastOfTypeIndex !== -1 && pseudo.nthFunction(nthLastOfTypeIndex + 1);
|
243
|
+
case 'target':
|
244
|
+
const hash = element[PropertySymbol.ownerDocument].location.hash;
|
245
|
+
if (!hash) {
|
246
|
+
return false;
|
247
|
+
}
|
248
|
+
return element.isConnected && element.id === hash.slice(1);
|
249
|
+
default:
|
250
|
+
return false;
|
232
251
|
}
|
233
|
-
|
234
|
-
return true;
|
235
252
|
}
|
236
253
|
|
237
254
|
/**
|
@@ -114,7 +114,7 @@ export default class XMLParser {
|
|
114
114
|
// Therefore we need to auto-close the tag, so that it become valid (e.g. "<a></a><a></a>").
|
115
115
|
if (
|
116
116
|
config?.contentModel ===
|
117
|
-
HTMLElementConfigContentModelEnum.
|
117
|
+
HTMLElementConfigContentModelEnum.noFirstLevelSelfDescendants &&
|
118
118
|
stackTagNames[stackTagNames.length - 1] === tagName
|
119
119
|
) {
|
120
120
|
stack.pop();
|
@@ -1,48 +0,0 @@
|
|
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
|
-
const URL_js_1 = __importDefault(require("../../url/URL.cjs"));
|
7
|
-
/**
|
8
|
-
* HTML Anchor Element utility.
|
9
|
-
*/
|
10
|
-
class HTMLAnchorElementUtility {
|
11
|
-
/**
|
12
|
-
* Returns "true" if it is a blob URL.
|
13
|
-
*
|
14
|
-
* According to spec, if element's url is non-null, its scheme is "blob", and it has an opaque path, then the process of updating properties on the URL should be terminated.
|
15
|
-
*
|
16
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#reinitialise-url
|
17
|
-
* @param url
|
18
|
-
* @param url URL.
|
19
|
-
* @returns "true" if blob URL.
|
20
|
-
*/
|
21
|
-
static isBlobURL(url) {
|
22
|
-
return (url && url.protocol === 'blob:' && url.pathname.length > 1 && url.pathname.includes('://'));
|
23
|
-
}
|
24
|
-
/**
|
25
|
-
* Returns URL.
|
26
|
-
*
|
27
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-href
|
28
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#hyperlink
|
29
|
-
* @param document Document.
|
30
|
-
* @param href Href.
|
31
|
-
* @returns URL.
|
32
|
-
*/
|
33
|
-
static getUrl(document, href) {
|
34
|
-
if (!href) {
|
35
|
-
return null;
|
36
|
-
}
|
37
|
-
const documentUrl = document.location.href;
|
38
|
-
try {
|
39
|
-
return new URL_js_1.default(href.trim(), documentUrl);
|
40
|
-
}
|
41
|
-
catch (TypeError) {
|
42
|
-
// Ignore error
|
43
|
-
}
|
44
|
-
return null;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
exports.default = HTMLAnchorElementUtility;
|
48
|
-
//# sourceMappingURL=HTMLAnchorElementUtility.cjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"HTMLAnchorElementUtility.cjs","sourceRoot":"","sources":["../../../src/nodes/html-anchor-element/HTMLAnchorElementUtility.ts"],"names":[],"mappings":";;;;;AACA,8DAAmC;AAEnC;;GAEG;AACH,MAAqB,wBAAwB;IAC5C;;;;;;;;;OASG;IACI,MAAM,CAAC,SAAS,CAAC,GAAQ;QAC/B,OAAO,CACN,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAC1F,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,MAAM,CAAC,QAAmB,EAAE,IAAmB;QAC5D,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QAE3C,IAAI,CAAC;YACJ,OAAO,IAAI,gBAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,WAAW,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACpB,eAAe;QAChB,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAzCD,2CAyCC"}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import IDocument from '../document/IDocument.cjs';
|
2
|
-
import URL from '../../url/URL.cjs';
|
3
|
-
/**
|
4
|
-
* HTML Anchor Element utility.
|
5
|
-
*/
|
6
|
-
export default class HTMLAnchorElementUtility {
|
7
|
-
/**
|
8
|
-
* Returns "true" if it is a blob URL.
|
9
|
-
*
|
10
|
-
* According to spec, if element's url is non-null, its scheme is "blob", and it has an opaque path, then the process of updating properties on the URL should be terminated.
|
11
|
-
*
|
12
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#reinitialise-url
|
13
|
-
* @param url
|
14
|
-
* @param url URL.
|
15
|
-
* @returns "true" if blob URL.
|
16
|
-
*/
|
17
|
-
static isBlobURL(url: URL): boolean;
|
18
|
-
/**
|
19
|
-
* Returns URL.
|
20
|
-
*
|
21
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-href
|
22
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#hyperlink
|
23
|
-
* @param document Document.
|
24
|
-
* @param href Href.
|
25
|
-
* @returns URL.
|
26
|
-
*/
|
27
|
-
static getUrl(document: IDocument, href: string | null): URL;
|
28
|
-
}
|
29
|
-
//# sourceMappingURL=HTMLAnchorElementUtility.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"HTMLAnchorElementUtility.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-anchor-element/HTMLAnchorElementUtility.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAC5C;;;;;;;;;OASG;WACW,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;IAM1C;;;;;;;;OAQG;WACW,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,GAAG;CAenE"}
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import IDocument from '../document/IDocument.js';
|
2
|
-
import URL from '../../url/URL.js';
|
3
|
-
/**
|
4
|
-
* HTML Anchor Element utility.
|
5
|
-
*/
|
6
|
-
export default class HTMLAnchorElementUtility {
|
7
|
-
/**
|
8
|
-
* Returns "true" if it is a blob URL.
|
9
|
-
*
|
10
|
-
* According to spec, if element's url is non-null, its scheme is "blob", and it has an opaque path, then the process of updating properties on the URL should be terminated.
|
11
|
-
*
|
12
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#reinitialise-url
|
13
|
-
* @param url
|
14
|
-
* @param url URL.
|
15
|
-
* @returns "true" if blob URL.
|
16
|
-
*/
|
17
|
-
static isBlobURL(url: URL): boolean;
|
18
|
-
/**
|
19
|
-
* Returns URL.
|
20
|
-
*
|
21
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-href
|
22
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#hyperlink
|
23
|
-
* @param document Document.
|
24
|
-
* @param href Href.
|
25
|
-
* @returns URL.
|
26
|
-
*/
|
27
|
-
static getUrl(document: IDocument, href: string | null): URL;
|
28
|
-
}
|
29
|
-
//# sourceMappingURL=HTMLAnchorElementUtility.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"HTMLAnchorElementUtility.d.ts","sourceRoot":"","sources":["../../../src/nodes/html-anchor-element/HTMLAnchorElementUtility.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAC5C;;;;;;;;;OASG;WACW,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO;IAM1C;;;;;;;;OAQG;WACW,MAAM,CAAC,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,GAAG;CAenE"}
|
@@ -1,42 +0,0 @@
|
|
1
|
-
import URL from '../../url/URL.js';
|
2
|
-
/**
|
3
|
-
* HTML Anchor Element utility.
|
4
|
-
*/
|
5
|
-
export default class HTMLAnchorElementUtility {
|
6
|
-
/**
|
7
|
-
* Returns "true" if it is a blob URL.
|
8
|
-
*
|
9
|
-
* According to spec, if element's url is non-null, its scheme is "blob", and it has an opaque path, then the process of updating properties on the URL should be terminated.
|
10
|
-
*
|
11
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#reinitialise-url
|
12
|
-
* @param url
|
13
|
-
* @param url URL.
|
14
|
-
* @returns "true" if blob URL.
|
15
|
-
*/
|
16
|
-
static isBlobURL(url) {
|
17
|
-
return (url && url.protocol === 'blob:' && url.pathname.length > 1 && url.pathname.includes('://'));
|
18
|
-
}
|
19
|
-
/**
|
20
|
-
* Returns URL.
|
21
|
-
*
|
22
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-href
|
23
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#hyperlink
|
24
|
-
* @param document Document.
|
25
|
-
* @param href Href.
|
26
|
-
* @returns URL.
|
27
|
-
*/
|
28
|
-
static getUrl(document, href) {
|
29
|
-
if (!href) {
|
30
|
-
return null;
|
31
|
-
}
|
32
|
-
const documentUrl = document.location.href;
|
33
|
-
try {
|
34
|
-
return new URL(href.trim(), documentUrl);
|
35
|
-
}
|
36
|
-
catch (TypeError) {
|
37
|
-
// Ignore error
|
38
|
-
}
|
39
|
-
return null;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
//# sourceMappingURL=HTMLAnchorElementUtility.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"HTMLAnchorElementUtility.js","sourceRoot":"","sources":["../../../src/nodes/html-anchor-element/HTMLAnchorElementUtility.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAEnC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,wBAAwB;IAC5C;;;;;;;;;OASG;IACI,MAAM,CAAC,SAAS,CAAC,GAAQ;QAC/B,OAAO,CACN,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAC1F,CAAC;IACH,CAAC;IAED;;;;;;;;OAQG;IACI,MAAM,CAAC,MAAM,CAAC,QAAmB,EAAE,IAAmB;QAC5D,IAAI,CAAC,IAAI,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACb,CAAC;QAED,MAAM,WAAW,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;QAE3C,IAAI,CAAC;YACJ,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,WAAW,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACpB,eAAe;QAChB,CAAC;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import IDocument from '../document/IDocument.js';
|
2
|
-
import URL from '../../url/URL.js';
|
3
|
-
|
4
|
-
/**
|
5
|
-
* HTML Anchor Element utility.
|
6
|
-
*/
|
7
|
-
export default class HTMLAnchorElementUtility {
|
8
|
-
/**
|
9
|
-
* Returns "true" if it is a blob URL.
|
10
|
-
*
|
11
|
-
* According to spec, if element's url is non-null, its scheme is "blob", and it has an opaque path, then the process of updating properties on the URL should be terminated.
|
12
|
-
*
|
13
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#reinitialise-url
|
14
|
-
* @param url
|
15
|
-
* @param url URL.
|
16
|
-
* @returns "true" if blob URL.
|
17
|
-
*/
|
18
|
-
public static isBlobURL(url: URL): boolean {
|
19
|
-
return (
|
20
|
-
url && url.protocol === 'blob:' && url.pathname.length > 1 && url.pathname.includes('://')
|
21
|
-
);
|
22
|
-
}
|
23
|
-
|
24
|
-
/**
|
25
|
-
* Returns URL.
|
26
|
-
*
|
27
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#dom-hyperlink-href
|
28
|
-
* @see https://html.spec.whatwg.org/multipage/links.html#hyperlink
|
29
|
-
* @param document Document.
|
30
|
-
* @param href Href.
|
31
|
-
* @returns URL.
|
32
|
-
*/
|
33
|
-
public static getUrl(document: IDocument, href: string | null): URL {
|
34
|
-
if (!href) {
|
35
|
-
return null;
|
36
|
-
}
|
37
|
-
|
38
|
-
const documentUrl = document.location.href;
|
39
|
-
|
40
|
-
try {
|
41
|
-
return new URL(href.trim(), documentUrl);
|
42
|
-
} catch (TypeError) {
|
43
|
-
// Ignore error
|
44
|
-
}
|
45
|
-
|
46
|
-
return null;
|
47
|
-
}
|
48
|
-
}
|