html-get 2.24.5 → 2.24.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +18 -3
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "html-get",
|
|
3
3
|
"description": "Get the HTML from any website, fine-tuned for correction & speed",
|
|
4
4
|
"homepage": "https://nicedoc.com/microlinkhq/html-get",
|
|
5
|
-
"version": "2.24.
|
|
5
|
+
"version": "2.24.6",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"bin": {
|
package/src/index.js
CHANGED
|
@@ -194,10 +194,22 @@ const prerender = PCancelable.fn(
|
|
|
194
194
|
|
|
195
195
|
const modes = { fetch, prerender }
|
|
196
196
|
|
|
197
|
+
const isInsideEmbeddedDocument = el => {
|
|
198
|
+
let node = el.parent
|
|
199
|
+
while (node) {
|
|
200
|
+
const tag = node.tagName
|
|
201
|
+
if (tag === 'svg' || tag === 'math') return true
|
|
202
|
+
node = node.parent
|
|
203
|
+
}
|
|
204
|
+
return false
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Custom element names must contain a hyphen, but SVG/MathML also use
|
|
208
|
+
// hyphenated tags (e.g. font-face) that are not shadow hosts.
|
|
197
209
|
const hasShadowDOM = $ =>
|
|
198
210
|
$('*')
|
|
199
211
|
.toArray()
|
|
200
|
-
.some(el => el.tagName?.includes('-'))
|
|
212
|
+
.some(el => el.tagName?.includes('-') && !isInsideEmbeddedDocument(el))
|
|
201
213
|
|
|
202
214
|
const isFetchMode = url => {
|
|
203
215
|
const parsedUrl = parseUrl(url)
|
|
@@ -334,8 +346,11 @@ module.exports = PCancelable.fn(
|
|
|
334
346
|
toEncode
|
|
335
347
|
})
|
|
336
348
|
onCancel(() => prerenderPromise.cancel())
|
|
337
|
-
|
|
338
|
-
|
|
349
|
+
const prerenderResult = await prerenderPromise
|
|
350
|
+
if (prerenderResult.html) {
|
|
351
|
+
;({ mode, html, $, ...payload } = prerenderResult)
|
|
352
|
+
shadowDOM = hasShadowDOM($)
|
|
353
|
+
}
|
|
339
354
|
}
|
|
340
355
|
|
|
341
356
|
return Object.assign(payload, {
|