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.

Files changed (119) hide show
  1. package/cjs/browser/utilities/BrowserFrameURL.cjs +1 -11
  2. package/cjs/browser/utilities/BrowserFrameURL.cjs.map +1 -1
  3. package/cjs/browser/utilities/BrowserFrameURL.d.ts.map +1 -1
  4. package/cjs/config/HTMLElementConfig.cjs +11 -11
  5. package/cjs/config/HTMLElementConfig.cjs.map +1 -1
  6. package/cjs/config/HTMLElementConfigContentModelEnum.cjs +1 -1
  7. package/cjs/config/HTMLElementConfigContentModelEnum.cjs.map +1 -1
  8. package/cjs/config/HTMLElementConfigContentModelEnum.d.ts +1 -1
  9. package/cjs/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -1
  10. package/cjs/nodes/html-anchor-element/HTMLAnchorElement.cjs +157 -58
  11. package/cjs/nodes/html-anchor-element/HTMLAnchorElement.cjs.map +1 -1
  12. package/cjs/nodes/html-anchor-element/HTMLAnchorElement.d.ts +1 -3
  13. package/cjs/nodes/html-anchor-element/HTMLAnchorElement.d.ts.map +1 -1
  14. package/cjs/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.cjs +3 -12
  15. package/cjs/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.cjs.map +1 -1
  16. package/cjs/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.d.ts.map +1 -1
  17. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs +1 -1
  18. package/cjs/nodes/html-button-element/HTMLButtonElement.cjs.map +1 -1
  19. package/cjs/nodes/html-form-element/HTMLFormElement.cjs +2 -1
  20. package/cjs/nodes/html-form-element/HTMLFormElement.cjs.map +1 -1
  21. package/cjs/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
  22. package/cjs/nodes/html-image-element/HTMLImageElement.cjs +11 -2
  23. package/cjs/nodes/html-image-element/HTMLImageElement.cjs.map +1 -1
  24. package/cjs/nodes/html-image-element/HTMLImageElement.d.ts +1 -1
  25. package/cjs/nodes/html-image-element/HTMLImageElement.d.ts.map +1 -1
  26. package/cjs/nodes/html-input-element/HTMLInputElement.cjs +1 -1
  27. package/cjs/nodes/html-input-element/HTMLInputElement.cjs.map +1 -1
  28. package/cjs/nodes/html-link-element/HTMLLinkElement.cjs +10 -1
  29. package/cjs/nodes/html-link-element/HTMLLinkElement.cjs.map +1 -1
  30. package/cjs/nodes/html-link-element/HTMLLinkElement.d.ts.map +1 -1
  31. package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.cjs +0 -2
  32. package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.cjs.map +1 -1
  33. package/cjs/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.d.ts.map +1 -1
  34. package/cjs/nodes/html-script-element/HTMLScriptElement.cjs +11 -2
  35. package/cjs/nodes/html-script-element/HTMLScriptElement.cjs.map +1 -1
  36. package/cjs/nodes/html-script-element/HTMLScriptElement.d.ts +1 -1
  37. package/cjs/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
  38. package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.cjs +0 -2
  39. package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.cjs.map +1 -1
  40. package/cjs/nodes/html-script-element/HTMLScriptElementScriptLoader.d.ts.map +1 -1
  41. package/cjs/query-selector/SelectorItem.cjs +90 -76
  42. package/cjs/query-selector/SelectorItem.cjs.map +1 -1
  43. package/cjs/query-selector/SelectorItem.d.ts +9 -1
  44. package/cjs/query-selector/SelectorItem.d.ts.map +1 -1
  45. package/cjs/version.cjs +1 -1
  46. package/cjs/xml-parser/XMLParser.cjs +1 -1
  47. package/cjs/xml-parser/XMLParser.cjs.map +1 -1
  48. package/lib/browser/utilities/BrowserFrameURL.d.ts.map +1 -1
  49. package/lib/browser/utilities/BrowserFrameURL.js +1 -8
  50. package/lib/browser/utilities/BrowserFrameURL.js.map +1 -1
  51. package/lib/config/HTMLElementConfig.js +11 -11
  52. package/lib/config/HTMLElementConfig.js.map +1 -1
  53. package/lib/config/HTMLElementConfigContentModelEnum.d.ts +1 -1
  54. package/lib/config/HTMLElementConfigContentModelEnum.d.ts.map +1 -1
  55. package/lib/config/HTMLElementConfigContentModelEnum.js +1 -1
  56. package/lib/config/HTMLElementConfigContentModelEnum.js.map +1 -1
  57. package/lib/nodes/html-anchor-element/HTMLAnchorElement.d.ts +1 -3
  58. package/lib/nodes/html-anchor-element/HTMLAnchorElement.d.ts.map +1 -1
  59. package/lib/nodes/html-anchor-element/HTMLAnchorElement.js +157 -58
  60. package/lib/nodes/html-anchor-element/HTMLAnchorElement.js.map +1 -1
  61. package/lib/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.d.ts.map +1 -1
  62. package/lib/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.js +3 -12
  63. package/lib/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.js.map +1 -1
  64. package/lib/nodes/html-button-element/HTMLButtonElement.js +1 -1
  65. package/lib/nodes/html-button-element/HTMLButtonElement.js.map +1 -1
  66. package/lib/nodes/html-form-element/HTMLFormElement.d.ts.map +1 -1
  67. package/lib/nodes/html-form-element/HTMLFormElement.js +2 -1
  68. package/lib/nodes/html-form-element/HTMLFormElement.js.map +1 -1
  69. package/lib/nodes/html-image-element/HTMLImageElement.d.ts +1 -1
  70. package/lib/nodes/html-image-element/HTMLImageElement.d.ts.map +1 -1
  71. package/lib/nodes/html-image-element/HTMLImageElement.js +11 -2
  72. package/lib/nodes/html-image-element/HTMLImageElement.js.map +1 -1
  73. package/lib/nodes/html-input-element/HTMLInputElement.js +1 -1
  74. package/lib/nodes/html-input-element/HTMLInputElement.js.map +1 -1
  75. package/lib/nodes/html-link-element/HTMLLinkElement.d.ts.map +1 -1
  76. package/lib/nodes/html-link-element/HTMLLinkElement.js +10 -1
  77. package/lib/nodes/html-link-element/HTMLLinkElement.js.map +1 -1
  78. package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.d.ts.map +1 -1
  79. package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.js +0 -2
  80. package/lib/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.js.map +1 -1
  81. package/lib/nodes/html-script-element/HTMLScriptElement.d.ts +1 -1
  82. package/lib/nodes/html-script-element/HTMLScriptElement.d.ts.map +1 -1
  83. package/lib/nodes/html-script-element/HTMLScriptElement.js +11 -2
  84. package/lib/nodes/html-script-element/HTMLScriptElement.js.map +1 -1
  85. package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.d.ts.map +1 -1
  86. package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.js +0 -2
  87. package/lib/nodes/html-script-element/HTMLScriptElementScriptLoader.js.map +1 -1
  88. package/lib/query-selector/SelectorItem.d.ts +9 -1
  89. package/lib/query-selector/SelectorItem.d.ts.map +1 -1
  90. package/lib/query-selector/SelectorItem.js +90 -76
  91. package/lib/query-selector/SelectorItem.js.map +1 -1
  92. package/lib/version.js +1 -1
  93. package/lib/xml-parser/XMLParser.js +1 -1
  94. package/lib/xml-parser/XMLParser.js.map +1 -1
  95. package/package.json +1 -1
  96. package/src/browser/utilities/BrowserFrameURL.ts +1 -13
  97. package/src/config/HTMLElementConfig.ts +11 -11
  98. package/src/config/HTMLElementConfigContentModelEnum.ts +1 -1
  99. package/src/nodes/html-anchor-element/HTMLAnchorElement.ts +138 -66
  100. package/src/nodes/html-anchor-element/HTMLAnchorElementNamedNodeMap.ts +5 -15
  101. package/src/nodes/html-button-element/HTMLButtonElement.ts +1 -1
  102. package/src/nodes/html-form-element/HTMLFormElement.ts +2 -4
  103. package/src/nodes/html-image-element/HTMLImageElement.ts +11 -2
  104. package/src/nodes/html-input-element/HTMLInputElement.ts +1 -1
  105. package/src/nodes/html-link-element/HTMLLinkElement.ts +10 -1
  106. package/src/nodes/html-link-element/HTMLLinkElementStyleSheetLoader.ts +0 -2
  107. package/src/nodes/html-script-element/HTMLScriptElement.ts +11 -2
  108. package/src/nodes/html-script-element/HTMLScriptElementScriptLoader.ts +0 -2
  109. package/src/query-selector/SelectorItem.ts +97 -80
  110. package/src/xml-parser/XMLParser.ts +1 -1
  111. package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.cjs +0 -48
  112. package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.cjs.map +0 -1
  113. package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts +0 -29
  114. package/cjs/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts.map +0 -1
  115. package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts +0 -29
  116. package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.d.ts.map +0 -1
  117. package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.js +0 -42
  118. package/lib/nodes/html-anchor-element/HTMLAnchorElementUtility.js.map +0 -1
  119. 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 psuedo selector.
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 psuedo of this.pseudos) {
124
+ for (const pseudo of this.pseudos) {
125
125
  // Validation
126
- switch (psuedo.name) {
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 (!psuedo.arguments) {
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 (psuedo.name) {
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
- switch (psuedo.name) {
156
- case 'first-child':
157
- return parentChildren[0] === element;
158
- case 'last-child':
159
- return parentChildren.length && parentChildren[parentChildren.length - 1] === element;
160
- case 'only-child':
161
- return parentChildren.length === 1 && parentChildren[0] === element;
162
- case 'first-of-type':
163
- for (const child of parentChildren) {
164
- if (child[PropertySymbol.tagName] === element[PropertySymbol.tagName]) {
165
- return child === element;
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
- return false;
169
- case 'last-of-type':
170
- for (let i = parentChildren.length - 1; i >= 0; i--) {
171
- const child = parentChildren[i];
172
- if (child[PropertySymbol.tagName] === element[PropertySymbol.tagName]) {
173
- return child === element;
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
- return false;
177
- case 'only-of-type':
178
- let isFound = false;
179
- for (const child of parentChildren) {
180
- if (child[PropertySymbol.tagName] === element[PropertySymbol.tagName]) {
181
- if (isFound || child !== element) {
182
- return false;
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
- return isFound;
188
- case 'checked':
189
- return (
190
- element[PropertySymbol.tagName] === 'INPUT' && (<IHTMLInputElement>element).checked
191
- );
192
- case 'empty':
193
- return !(<Element>element)[PropertySymbol.children].length;
194
- case 'root':
195
- return element[PropertySymbol.tagName] === 'HTML';
196
- case 'not':
197
- return !psuedo.selectorItem.match(element);
198
- case 'nth-child':
199
- const nthChildIndex = psuedo.selectorItem
200
- ? parentChildren.filter((child) => psuedo.selectorItem.match(child)).indexOf(element)
201
- : parentChildren.indexOf(element);
202
- return nthChildIndex !== -1 && psuedo.nthFunction(nthChildIndex + 1);
203
- case 'nth-of-type':
204
- if (!element[PropertySymbol.parentNode]) {
205
- return false;
206
- }
207
- const nthOfTypeIndex = parentChildren
208
- .filter((child) => child[PropertySymbol.tagName] === element[PropertySymbol.tagName])
209
- .indexOf(element);
210
- return nthOfTypeIndex !== -1 && psuedo.nthFunction(nthOfTypeIndex + 1);
211
- case 'nth-last-child':
212
- const nthLastChildIndex = psuedo.selectorItem
213
- ? parentChildren
214
- .filter((child) => psuedo.selectorItem.match(child))
215
- .reverse()
216
- .indexOf(element)
217
- : parentChildren.reverse().indexOf(element);
218
- return nthLastChildIndex !== -1 && psuedo.nthFunction(nthLastChildIndex + 1);
219
- case 'nth-last-of-type':
220
- const nthLastOfTypeIndex = parentChildren
221
- .filter((child) => child[PropertySymbol.tagName] === element[PropertySymbol.tagName])
222
- .reverse()
223
- .indexOf(element);
224
- return nthLastOfTypeIndex !== -1 && psuedo.nthFunction(nthLastOfTypeIndex + 1);
225
- case 'target':
226
- const hash = element[PropertySymbol.ownerDocument].location.hash;
227
- if (!hash) {
228
- return false;
229
- }
230
- return element.isConnected && element.id === hash.slice(1);
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.noFirsLevelSelfDescendants &&
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
- }