@stencil/core 4.27.0 → 4.27.1
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/cli/index.cjs +1 -1
- package/cli/index.js +1 -1
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +10 -10
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/index.js +80 -53
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +3 -3
- package/internal/hydrate/index.js +79 -53
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.js +105 -106
- package/internal/package.json +1 -1
- package/internal/testing/index.js +77 -52
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +1 -1
- package/mock-doc/index.js +1 -1
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- package/screenshot/index.js +1 -1
- package/screenshot/package.json +1 -1
- package/screenshot/pixel-match.js +1 -1
- package/sys/node/index.js +1 -1
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +1 -1
- package/testing/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Stencil Hydrate Runner v4.27.
|
|
2
|
+
Stencil Hydrate Runner v4.27.1 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
@@ -345,19 +345,19 @@ var MockCustomElementRegistry = class {
|
|
|
345
345
|
this.__whenDefined.delete(tagName);
|
|
346
346
|
}
|
|
347
347
|
}
|
|
348
|
-
const
|
|
349
|
-
if (
|
|
350
|
-
const hosts =
|
|
348
|
+
const doc = this.win.document;
|
|
349
|
+
if (doc != null) {
|
|
350
|
+
const hosts = doc.querySelectorAll(tagName);
|
|
351
351
|
hosts.forEach((host) => {
|
|
352
352
|
if (upgradedElements.has(host) === false) {
|
|
353
|
-
tempDisableCallbacks.add(
|
|
354
|
-
const upgradedCmp = createCustomElement(this,
|
|
353
|
+
tempDisableCallbacks.add(doc);
|
|
354
|
+
const upgradedCmp = createCustomElement(this, doc, tagName);
|
|
355
355
|
for (let i = 0; i < host.childNodes.length; i++) {
|
|
356
356
|
const childNode = host.childNodes[i];
|
|
357
357
|
childNode.remove();
|
|
358
358
|
upgradedCmp.appendChild(childNode);
|
|
359
359
|
}
|
|
360
|
-
tempDisableCallbacks.delete(
|
|
360
|
+
tempDisableCallbacks.delete(doc);
|
|
361
361
|
if (proxyElements.has(host)) {
|
|
362
362
|
proxyElements.set(host, upgradedCmp);
|
|
363
363
|
}
|
|
@@ -8801,11 +8801,11 @@ function parseFragment(fragmentContext, html, options) {
|
|
|
8801
8801
|
// src/mock-doc/parse-util.ts
|
|
8802
8802
|
var docParser = /* @__PURE__ */ new WeakMap();
|
|
8803
8803
|
function parseDocumentUtil(ownerDocument, html) {
|
|
8804
|
-
const
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
return
|
|
8804
|
+
const doc = parse(html.trim(), getParser(ownerDocument));
|
|
8805
|
+
doc.documentElement = doc.firstElementChild;
|
|
8806
|
+
doc.head = doc.documentElement.firstElementChild;
|
|
8807
|
+
doc.body = doc.head.nextElementSibling;
|
|
8808
|
+
return doc;
|
|
8809
8809
|
}
|
|
8810
8810
|
function parseFragmentUtil(ownerDocument, html) {
|
|
8811
8811
|
if (typeof html === "string") {
|
|
@@ -8823,9 +8823,9 @@ function getParser(ownerDocument) {
|
|
|
8823
8823
|
}
|
|
8824
8824
|
const treeAdapter = {
|
|
8825
8825
|
createDocument() {
|
|
8826
|
-
const
|
|
8827
|
-
|
|
8828
|
-
return
|
|
8826
|
+
const doc = ownerDocument.createElement("#document" /* DOCUMENT_NODE */);
|
|
8827
|
+
doc["x-mode"] = "no-quirks";
|
|
8828
|
+
return doc;
|
|
8829
8829
|
},
|
|
8830
8830
|
setNodeSourceCodeLocation(node, location2) {
|
|
8831
8831
|
node.sourceCodeLocation = location2;
|
|
@@ -8863,22 +8863,22 @@ function getParser(ownerDocument) {
|
|
|
8863
8863
|
getTemplateContent(templateElement) {
|
|
8864
8864
|
return templateElement.content;
|
|
8865
8865
|
},
|
|
8866
|
-
setDocumentType(
|
|
8867
|
-
let doctypeNode =
|
|
8866
|
+
setDocumentType(doc, name, publicId, systemId) {
|
|
8867
|
+
let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10 /* DOCUMENT_TYPE_NODE */);
|
|
8868
8868
|
if (doctypeNode == null) {
|
|
8869
8869
|
doctypeNode = ownerDocument.createDocumentTypeNode();
|
|
8870
|
-
|
|
8870
|
+
doc.insertBefore(doctypeNode, doc.firstChild);
|
|
8871
8871
|
}
|
|
8872
8872
|
doctypeNode.nodeValue = "!DOCTYPE";
|
|
8873
8873
|
doctypeNode["x-name"] = name;
|
|
8874
8874
|
doctypeNode["x-publicId"] = publicId;
|
|
8875
8875
|
doctypeNode["x-systemId"] = systemId;
|
|
8876
8876
|
},
|
|
8877
|
-
setDocumentMode(
|
|
8878
|
-
|
|
8877
|
+
setDocumentMode(doc, mode) {
|
|
8878
|
+
doc["x-mode"] = mode;
|
|
8879
8879
|
},
|
|
8880
|
-
getDocumentMode(
|
|
8881
|
-
return
|
|
8880
|
+
getDocumentMode(doc) {
|
|
8881
|
+
return doc["x-mode"];
|
|
8882
8882
|
},
|
|
8883
8883
|
detachNode(node) {
|
|
8884
8884
|
node.remove();
|
|
@@ -9054,9 +9054,9 @@ var jquery_default = (
|
|
|
9054
9054
|
nonce: true,
|
|
9055
9055
|
noModule: true
|
|
9056
9056
|
};
|
|
9057
|
-
function DOMEval(code, node,
|
|
9058
|
-
|
|
9059
|
-
var i2, script =
|
|
9057
|
+
function DOMEval(code, node, doc) {
|
|
9058
|
+
doc = doc || document2;
|
|
9059
|
+
var i2, script = doc.createElement("script");
|
|
9060
9060
|
script.text = code;
|
|
9061
9061
|
if (node) {
|
|
9062
9062
|
for (i2 in preservedScriptAttributes) {
|
|
@@ -9065,7 +9065,7 @@ var jquery_default = (
|
|
|
9065
9065
|
}
|
|
9066
9066
|
}
|
|
9067
9067
|
}
|
|
9068
|
-
|
|
9068
|
+
doc.head.appendChild(script).parentNode.removeChild(script);
|
|
9069
9069
|
}
|
|
9070
9070
|
const jQuery = {};
|
|
9071
9071
|
var version = "4.0.0-pre+9352011a7.dirty +selector", rhtmlSuffix = /HTML$/i, jQueryOrig = function(selector, context) {
|
|
@@ -9202,8 +9202,8 @@ var jquery_default = (
|
|
|
9202
9202
|
},
|
|
9203
9203
|
// Evaluates a script in a provided context; falls back to the global one
|
|
9204
9204
|
// if not specified.
|
|
9205
|
-
globalEval: function(code, options,
|
|
9206
|
-
DOMEval(code, { nonce: options && options.nonce },
|
|
9205
|
+
globalEval: function(code, options, doc) {
|
|
9206
|
+
DOMEval(code, { nonce: options && options.nonce }, doc);
|
|
9207
9207
|
},
|
|
9208
9208
|
each: function(obj, callback) {
|
|
9209
9209
|
var length, i2 = 0;
|
|
@@ -9692,11 +9692,11 @@ var jquery_default = (
|
|
|
9692
9692
|
});
|
|
9693
9693
|
}
|
|
9694
9694
|
function setDocument(node) {
|
|
9695
|
-
var subWindow,
|
|
9696
|
-
if (
|
|
9695
|
+
var subWindow, doc = node ? node.ownerDocument || node : document2;
|
|
9696
|
+
if (doc == document$1 || doc.nodeType !== 9) {
|
|
9697
9697
|
return;
|
|
9698
9698
|
}
|
|
9699
|
-
document$1 =
|
|
9699
|
+
document$1 = doc;
|
|
9700
9700
|
documentElement$1 = document$1.documentElement;
|
|
9701
9701
|
documentIsHTML = !jQuery.isXMLDoc(document$1);
|
|
9702
9702
|
if (isIE && document2 != document$1 && (subWindow = document$1.defaultView) && subWindow.top !== subWindow) {
|
|
@@ -14041,10 +14041,10 @@ var MockDocument = class _MockDocument extends MockHTMLElement {
|
|
|
14041
14041
|
}
|
|
14042
14042
|
createElement(tagName) {
|
|
14043
14043
|
if (tagName === "#document" /* DOCUMENT_NODE */) {
|
|
14044
|
-
const
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
return
|
|
14044
|
+
const doc = new _MockDocument(false);
|
|
14045
|
+
doc.nodeName = tagName;
|
|
14046
|
+
doc.parentNode = null;
|
|
14047
|
+
return doc;
|
|
14048
14048
|
}
|
|
14049
14049
|
return createElement(this, tagName);
|
|
14050
14050
|
}
|
|
@@ -14084,10 +14084,10 @@ var MockDocument = class _MockDocument extends MockHTMLElement {
|
|
|
14084
14084
|
title.textContent = value;
|
|
14085
14085
|
}
|
|
14086
14086
|
};
|
|
14087
|
-
function resetDocument(
|
|
14088
|
-
if (
|
|
14089
|
-
resetEventListeners(
|
|
14090
|
-
const documentElement =
|
|
14087
|
+
function resetDocument(doc) {
|
|
14088
|
+
if (doc != null) {
|
|
14089
|
+
resetEventListeners(doc);
|
|
14090
|
+
const documentElement = doc.documentElement;
|
|
14091
14091
|
if (documentElement != null) {
|
|
14092
14092
|
resetElement(documentElement);
|
|
14093
14093
|
for (let i = 0, ii = documentElement.childNodes.length; i < ii; i++) {
|
|
@@ -14096,25 +14096,25 @@ function resetDocument(doc2) {
|
|
|
14096
14096
|
childNode.childNodes.length = 0;
|
|
14097
14097
|
}
|
|
14098
14098
|
}
|
|
14099
|
-
for (const key in
|
|
14100
|
-
if (
|
|
14101
|
-
delete
|
|
14099
|
+
for (const key in doc) {
|
|
14100
|
+
if (doc.hasOwnProperty(key) && !DOC_KEY_KEEPERS.has(key)) {
|
|
14101
|
+
delete doc[key];
|
|
14102
14102
|
}
|
|
14103
14103
|
}
|
|
14104
14104
|
try {
|
|
14105
|
-
|
|
14105
|
+
doc.nodeName = "#document" /* DOCUMENT_NODE */;
|
|
14106
14106
|
} catch (e) {
|
|
14107
14107
|
}
|
|
14108
14108
|
try {
|
|
14109
|
-
|
|
14109
|
+
doc.nodeType = 9 /* DOCUMENT_NODE */;
|
|
14110
14110
|
} catch (e) {
|
|
14111
14111
|
}
|
|
14112
14112
|
try {
|
|
14113
|
-
|
|
14113
|
+
doc.cookie = "";
|
|
14114
14114
|
} catch (e) {
|
|
14115
14115
|
}
|
|
14116
14116
|
try {
|
|
14117
|
-
|
|
14117
|
+
doc.referrer = "";
|
|
14118
14118
|
} catch (e) {
|
|
14119
14119
|
}
|
|
14120
14120
|
}
|
|
@@ -14212,7 +14212,6 @@ import { BUILD as BUILD7 } from "@stencil/core/internal/app-data";
|
|
|
14212
14212
|
// src/client/client-window.ts
|
|
14213
14213
|
import { BUILD as BUILD6 } from "@stencil/core/internal/app-data";
|
|
14214
14214
|
var win = typeof window !== "undefined" ? window : {};
|
|
14215
|
-
var doc = win.document || { head: {} };
|
|
14216
14215
|
var H = win.HTMLElement || class {
|
|
14217
14216
|
};
|
|
14218
14217
|
var supportsShadow = BUILD6.shadowDom;
|
|
@@ -14412,14 +14411,14 @@ import { BUILD as BUILD27 } from "@stencil/core/internal/app-data";
|
|
|
14412
14411
|
import { BUILD as BUILD28 } from "@stencil/core/internal/app-data";
|
|
14413
14412
|
|
|
14414
14413
|
// src/compiler/html/canonical-link.ts
|
|
14415
|
-
var updateCanonicalLink = (
|
|
14414
|
+
var updateCanonicalLink = (doc, href) => {
|
|
14416
14415
|
var _a2;
|
|
14417
|
-
let canonicalLinkElm =
|
|
14416
|
+
let canonicalLinkElm = doc.head.querySelector('link[rel="canonical"]');
|
|
14418
14417
|
if (typeof href === "string") {
|
|
14419
14418
|
if (canonicalLinkElm == null) {
|
|
14420
|
-
canonicalLinkElm =
|
|
14419
|
+
canonicalLinkElm = doc.createElement("link");
|
|
14421
14420
|
canonicalLinkElm.setAttribute("rel", "canonical");
|
|
14422
|
-
|
|
14421
|
+
doc.head.appendChild(canonicalLinkElm);
|
|
14423
14422
|
}
|
|
14424
14423
|
canonicalLinkElm.setAttribute("href", href);
|
|
14425
14424
|
} else {
|
|
@@ -14433,11 +14432,11 @@ var updateCanonicalLink = (doc2, href) => {
|
|
|
14433
14432
|
};
|
|
14434
14433
|
|
|
14435
14434
|
// src/compiler/html/relocate-meta-charset.ts
|
|
14436
|
-
var relocateMetaCharset = (
|
|
14437
|
-
const head =
|
|
14435
|
+
var relocateMetaCharset = (doc) => {
|
|
14436
|
+
const head = doc.head;
|
|
14438
14437
|
let charsetElm = head.querySelector("meta[charset]");
|
|
14439
14438
|
if (charsetElm == null) {
|
|
14440
|
-
charsetElm =
|
|
14439
|
+
charsetElm = doc.createElement("meta");
|
|
14441
14440
|
charsetElm.setAttribute("charset", "utf-8");
|
|
14442
14441
|
} else {
|
|
14443
14442
|
charsetElm.remove();
|
|
@@ -14712,13 +14711,13 @@ var parseCss = (css, filePath) => {
|
|
|
14712
14711
|
const m = match(/^@([-\w]+)?document *([^{]+)/);
|
|
14713
14712
|
if (!m) return null;
|
|
14714
14713
|
const vendor = trim(m[1]);
|
|
14715
|
-
const
|
|
14714
|
+
const doc = trim(m[2]);
|
|
14716
14715
|
if (!open()) return error(`@document missing '{'`);
|
|
14717
14716
|
const style = comments().concat(rules());
|
|
14718
14717
|
if (!close()) return error(`@document missing '}'`);
|
|
14719
14718
|
return pos({
|
|
14720
14719
|
type: 3 /* Document */,
|
|
14721
|
-
document:
|
|
14720
|
+
document: doc,
|
|
14722
14721
|
vendor,
|
|
14723
14722
|
rules: style
|
|
14724
14723
|
});
|
|
@@ -15044,11 +15043,11 @@ var serializeCssPage = (opts, node) => {
|
|
|
15044
15043
|
};
|
|
15045
15044
|
var serializeCssDocument = (opts, node) => {
|
|
15046
15045
|
const documentCss = serializeCssMapVisit(opts, node.rules);
|
|
15047
|
-
const
|
|
15046
|
+
const doc = "@" + (node.vendor || "") + "document " + node.document;
|
|
15048
15047
|
if (documentCss === "") {
|
|
15049
15048
|
return "";
|
|
15050
15049
|
}
|
|
15051
|
-
return
|
|
15050
|
+
return doc + "{" + documentCss + "}";
|
|
15052
15051
|
};
|
|
15053
15052
|
var serializeCssMapVisit = (opts, nodes) => {
|
|
15054
15053
|
let rtn = "";
|
|
@@ -15146,12 +15145,12 @@ var collectUsedSelectors = (usedSelectors, elm) => {
|
|
|
15146
15145
|
};
|
|
15147
15146
|
|
|
15148
15147
|
// src/compiler/html/remove-unused-styles.ts
|
|
15149
|
-
var removeUnusedStyles = (
|
|
15148
|
+
var removeUnusedStyles = (doc, diagnostics) => {
|
|
15150
15149
|
try {
|
|
15151
|
-
const styleElms =
|
|
15150
|
+
const styleElms = doc.head.querySelectorAll(`style[data-styles]`);
|
|
15152
15151
|
const styleLen = styleElms.length;
|
|
15153
15152
|
if (styleLen > 0) {
|
|
15154
|
-
const usedSelectors = getUsedSelectors(
|
|
15153
|
+
const usedSelectors = getUsedSelectors(doc.documentElement);
|
|
15155
15154
|
for (let i = 0; i < styleLen; i++) {
|
|
15156
15155
|
removeUnusedStyleText(usedSelectors, diagnostics, styleElms[i]);
|
|
15157
15156
|
}
|
|
@@ -15284,41 +15283,41 @@ function collectAttributes(node) {
|
|
|
15284
15283
|
var SKIP_ATTRS = /* @__PURE__ */ new Set(["s-id", "c-id"]);
|
|
15285
15284
|
|
|
15286
15285
|
// src/hydrate/runner/patch-dom-implementation.ts
|
|
15287
|
-
function patchDomImplementation(
|
|
15286
|
+
function patchDomImplementation(doc, opts) {
|
|
15288
15287
|
let win2;
|
|
15289
|
-
if (
|
|
15288
|
+
if (doc.defaultView != null) {
|
|
15290
15289
|
opts.destroyWindow = true;
|
|
15291
|
-
patchWindow(
|
|
15292
|
-
win2 =
|
|
15290
|
+
patchWindow(doc.defaultView);
|
|
15291
|
+
win2 = doc.defaultView;
|
|
15293
15292
|
} else {
|
|
15294
15293
|
opts.destroyWindow = true;
|
|
15295
15294
|
opts.destroyDocument = false;
|
|
15296
15295
|
win2 = new MockWindow(false);
|
|
15297
15296
|
}
|
|
15298
|
-
if (win2.document !==
|
|
15299
|
-
win2.document =
|
|
15297
|
+
if (win2.document !== doc) {
|
|
15298
|
+
win2.document = doc;
|
|
15300
15299
|
}
|
|
15301
|
-
if (
|
|
15302
|
-
|
|
15300
|
+
if (doc.defaultView !== win2) {
|
|
15301
|
+
doc.defaultView = win2;
|
|
15303
15302
|
}
|
|
15304
|
-
const HTMLElement2 =
|
|
15303
|
+
const HTMLElement2 = doc.documentElement.constructor.prototype;
|
|
15305
15304
|
if (typeof HTMLElement2.getRootNode !== "function") {
|
|
15306
|
-
const elm =
|
|
15305
|
+
const elm = doc.createElement("unknown-element");
|
|
15307
15306
|
const HTMLUnknownElement = elm.constructor.prototype;
|
|
15308
15307
|
HTMLUnknownElement.getRootNode = getRootNode;
|
|
15309
15308
|
}
|
|
15310
|
-
if (typeof
|
|
15311
|
-
const CustomEvent2 =
|
|
15309
|
+
if (typeof doc.createEvent === "function") {
|
|
15310
|
+
const CustomEvent2 = doc.createEvent("CustomEvent").constructor;
|
|
15312
15311
|
if (win2.CustomEvent !== CustomEvent2) {
|
|
15313
15312
|
win2.CustomEvent = CustomEvent2;
|
|
15314
15313
|
}
|
|
15315
15314
|
}
|
|
15316
15315
|
try {
|
|
15317
|
-
win2.__stencil_baseURI =
|
|
15316
|
+
win2.__stencil_baseURI = doc.baseURI;
|
|
15318
15317
|
} catch (e) {
|
|
15319
|
-
Object.defineProperty(
|
|
15318
|
+
Object.defineProperty(doc, "baseURI", {
|
|
15320
15319
|
get() {
|
|
15321
|
-
const baseElm =
|
|
15320
|
+
const baseElm = doc.querySelector("base[href]");
|
|
15322
15321
|
if (baseElm) {
|
|
15323
15322
|
return new URL(baseElm.getAttribute("href"), win2.location.href).href;
|
|
15324
15323
|
}
|
|
@@ -15529,7 +15528,7 @@ var docData = {
|
|
|
15529
15528
|
rootLevelIds: 0,
|
|
15530
15529
|
staticComponents: /* @__PURE__ */ new Set()
|
|
15531
15530
|
};
|
|
15532
|
-
function initializeWindow(win2,
|
|
15531
|
+
function initializeWindow(win2, doc, opts, results) {
|
|
15533
15532
|
if (typeof opts.url === "string") {
|
|
15534
15533
|
try {
|
|
15535
15534
|
win2.location.href = opts.url;
|
|
@@ -15544,31 +15543,31 @@ function initializeWindow(win2, doc2, opts, results) {
|
|
|
15544
15543
|
}
|
|
15545
15544
|
if (typeof opts.cookie === "string") {
|
|
15546
15545
|
try {
|
|
15547
|
-
|
|
15546
|
+
doc.cookie = opts.cookie;
|
|
15548
15547
|
} catch (e) {
|
|
15549
15548
|
}
|
|
15550
15549
|
}
|
|
15551
15550
|
if (typeof opts.referrer === "string") {
|
|
15552
15551
|
try {
|
|
15553
|
-
|
|
15552
|
+
doc.referrer = opts.referrer;
|
|
15554
15553
|
} catch (e) {
|
|
15555
15554
|
}
|
|
15556
15555
|
}
|
|
15557
15556
|
if (typeof opts.direction === "string") {
|
|
15558
15557
|
try {
|
|
15559
|
-
|
|
15558
|
+
doc.documentElement.setAttribute("dir", opts.direction);
|
|
15560
15559
|
} catch (e) {
|
|
15561
15560
|
}
|
|
15562
15561
|
}
|
|
15563
15562
|
if (typeof opts.language === "string") {
|
|
15564
15563
|
try {
|
|
15565
|
-
|
|
15564
|
+
doc.documentElement.setAttribute("lang", opts.language);
|
|
15566
15565
|
} catch (e) {
|
|
15567
15566
|
}
|
|
15568
15567
|
}
|
|
15569
15568
|
if (typeof opts.buildId === "string") {
|
|
15570
15569
|
try {
|
|
15571
|
-
|
|
15570
|
+
doc.documentElement.setAttribute("data-stencil-build", opts.buildId);
|
|
15572
15571
|
} catch (e) {
|
|
15573
15572
|
}
|
|
15574
15573
|
}
|
|
@@ -15580,7 +15579,7 @@ function initializeWindow(win2, doc2, opts, results) {
|
|
|
15580
15579
|
constrainTimeouts(win2);
|
|
15581
15580
|
}
|
|
15582
15581
|
runtimeLogging(win2, opts, results);
|
|
15583
|
-
|
|
15582
|
+
doc[STENCIL_DOC_DATA] = docData;
|
|
15584
15583
|
return win2;
|
|
15585
15584
|
}
|
|
15586
15585
|
|
|
@@ -15598,18 +15597,18 @@ function renderToString(html, options, asStream) {
|
|
|
15598
15597
|
opts.constrainTimeouts = false;
|
|
15599
15598
|
return hydrateDocument(html, opts, asStream);
|
|
15600
15599
|
}
|
|
15601
|
-
function hydrateDocument(
|
|
15600
|
+
function hydrateDocument(doc, options, asStream) {
|
|
15602
15601
|
const opts = normalizeHydrateOptions(options);
|
|
15603
15602
|
let win2 = null;
|
|
15604
15603
|
const results = generateHydrateResults(opts);
|
|
15605
15604
|
if (hasError(results.diagnostics)) {
|
|
15606
15605
|
return Promise.resolve(results);
|
|
15607
15606
|
}
|
|
15608
|
-
if (typeof
|
|
15607
|
+
if (typeof doc === "string") {
|
|
15609
15608
|
try {
|
|
15610
15609
|
opts.destroyWindow = true;
|
|
15611
15610
|
opts.destroyDocument = true;
|
|
15612
|
-
win2 = new MockWindow(
|
|
15611
|
+
win2 = new MockWindow(doc);
|
|
15613
15612
|
if (!asStream) {
|
|
15614
15613
|
return render(win2, opts, results).then(() => results);
|
|
15615
15614
|
}
|
|
@@ -15623,10 +15622,10 @@ function hydrateDocument(doc2, options, asStream) {
|
|
|
15623
15622
|
return Promise.resolve(results);
|
|
15624
15623
|
}
|
|
15625
15624
|
}
|
|
15626
|
-
if (isValidDocument(
|
|
15625
|
+
if (isValidDocument(doc)) {
|
|
15627
15626
|
try {
|
|
15628
15627
|
opts.destroyDocument = false;
|
|
15629
|
-
win2 = patchDomImplementation(
|
|
15628
|
+
win2 = patchDomImplementation(doc, opts);
|
|
15630
15629
|
if (!asStream) {
|
|
15631
15630
|
return render(win2, opts, results).then(() => results);
|
|
15632
15631
|
}
|
|
@@ -15683,41 +15682,41 @@ async function afterHydrate(win2, opts, results, resolve) {
|
|
|
15683
15682
|
return resolve(finalizeHydrate(win2, win2.document, opts, results));
|
|
15684
15683
|
}
|
|
15685
15684
|
}
|
|
15686
|
-
function finalizeHydrate(win2,
|
|
15685
|
+
function finalizeHydrate(win2, doc, opts, results) {
|
|
15687
15686
|
try {
|
|
15688
|
-
inspectElement(results,
|
|
15687
|
+
inspectElement(results, doc.documentElement, 0);
|
|
15689
15688
|
if (opts.removeUnusedStyles !== false) {
|
|
15690
15689
|
try {
|
|
15691
|
-
removeUnusedStyles(
|
|
15690
|
+
removeUnusedStyles(doc, results.diagnostics);
|
|
15692
15691
|
} catch (e) {
|
|
15693
15692
|
renderCatchError(results, e);
|
|
15694
15693
|
}
|
|
15695
15694
|
}
|
|
15696
15695
|
if (typeof opts.title === "string") {
|
|
15697
15696
|
try {
|
|
15698
|
-
|
|
15697
|
+
doc.title = opts.title;
|
|
15699
15698
|
} catch (e) {
|
|
15700
15699
|
renderCatchError(results, e);
|
|
15701
15700
|
}
|
|
15702
15701
|
}
|
|
15703
|
-
results.title =
|
|
15702
|
+
results.title = doc.title;
|
|
15704
15703
|
if (opts.removeScripts) {
|
|
15705
|
-
removeScripts(
|
|
15704
|
+
removeScripts(doc.documentElement);
|
|
15706
15705
|
}
|
|
15707
15706
|
try {
|
|
15708
|
-
updateCanonicalLink(
|
|
15707
|
+
updateCanonicalLink(doc, opts.canonicalUrl);
|
|
15709
15708
|
} catch (e) {
|
|
15710
15709
|
renderCatchError(results, e);
|
|
15711
15710
|
}
|
|
15712
15711
|
try {
|
|
15713
|
-
relocateMetaCharset(
|
|
15712
|
+
relocateMetaCharset(doc);
|
|
15714
15713
|
} catch (e) {
|
|
15715
15714
|
}
|
|
15716
15715
|
if (!hasError(results.diagnostics)) {
|
|
15717
15716
|
results.httpStatus = 200;
|
|
15718
15717
|
}
|
|
15719
15718
|
try {
|
|
15720
|
-
const metaStatus =
|
|
15719
|
+
const metaStatus = doc.head.querySelector('meta[http-equiv="status"]');
|
|
15721
15720
|
if (metaStatus != null) {
|
|
15722
15721
|
const metaStatusContent = metaStatus.getAttribute("content");
|
|
15723
15722
|
if (metaStatusContent && metaStatusContent.length > 0) {
|
|
@@ -15727,25 +15726,25 @@ function finalizeHydrate(win2, doc2, opts, results) {
|
|
|
15727
15726
|
} catch (e) {
|
|
15728
15727
|
}
|
|
15729
15728
|
if (opts.clientHydrateAnnotations) {
|
|
15730
|
-
|
|
15729
|
+
doc.documentElement.classList.add("hydrated");
|
|
15731
15730
|
}
|
|
15732
15731
|
if (opts.serializeToHtml) {
|
|
15733
|
-
results.html = serializeDocumentToString(
|
|
15732
|
+
results.html = serializeDocumentToString(doc, opts);
|
|
15734
15733
|
}
|
|
15735
15734
|
} catch (e) {
|
|
15736
15735
|
renderCatchError(results, e);
|
|
15737
15736
|
}
|
|
15738
|
-
destroyWindow(win2,
|
|
15737
|
+
destroyWindow(win2, doc, opts, results);
|
|
15739
15738
|
return results;
|
|
15740
15739
|
}
|
|
15741
|
-
function destroyWindow(win2,
|
|
15740
|
+
function destroyWindow(win2, doc, opts, results) {
|
|
15742
15741
|
if (!opts.destroyWindow) {
|
|
15743
15742
|
return;
|
|
15744
15743
|
}
|
|
15745
15744
|
try {
|
|
15746
15745
|
if (!opts.destroyDocument) {
|
|
15747
15746
|
win2.document = null;
|
|
15748
|
-
|
|
15747
|
+
doc.defaultView = null;
|
|
15749
15748
|
}
|
|
15750
15749
|
if (win2.close) {
|
|
15751
15750
|
win2.close();
|
|
@@ -15754,8 +15753,8 @@ function destroyWindow(win2, doc2, opts, results) {
|
|
|
15754
15753
|
renderCatchError(results, e);
|
|
15755
15754
|
}
|
|
15756
15755
|
}
|
|
15757
|
-
function serializeDocumentToString(
|
|
15758
|
-
return serializeNodeToHtml(
|
|
15756
|
+
function serializeDocumentToString(doc, opts) {
|
|
15757
|
+
return serializeNodeToHtml(doc, {
|
|
15759
15758
|
approximateLineWidth: opts.approximateLineWidth,
|
|
15760
15759
|
outerHtml: false,
|
|
15761
15760
|
prettyHtml: opts.prettyHtml,
|
|
@@ -15767,8 +15766,8 @@ function serializeDocumentToString(doc2, opts) {
|
|
|
15767
15766
|
fullDocument: opts.fullDocument
|
|
15768
15767
|
});
|
|
15769
15768
|
}
|
|
15770
|
-
function isValidDocument(
|
|
15771
|
-
return
|
|
15769
|
+
function isValidDocument(doc) {
|
|
15770
|
+
return doc != null && doc.nodeType === 9 && doc.documentElement != null && doc.documentElement.nodeType === 1 && doc.body != null && doc.body.nodeType === 1;
|
|
15772
15771
|
}
|
|
15773
15772
|
function removeScripts(elm) {
|
|
15774
15773
|
const children = elm.children;
|
package/internal/package.json
CHANGED