@stencil/core 4.18.3-dev.1718168510.0a11aac → 4.18.3-dev.1718220868.532557e
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 +43 -44
- 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 +32 -19
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/hydrate/index.js +62 -28
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.d.ts +19 -1
- package/internal/hydrate/runner.js +222 -249
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +5 -0
- package/internal/stencil-public-compiler.d.ts +13 -0
- package/internal/testing/index.js +30 -14
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +127 -125
- package/mock-doc/index.d.ts +17 -3
- package/mock-doc/index.js +127 -125
- 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 +10 -10
- 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
package/internal/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/core/internal",
|
|
3
|
-
"version": "4.18.3-dev.
|
|
3
|
+
"version": "4.18.3-dev.1718220868.532557e",
|
|
4
4
|
"description": "Stencil internals only to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -1707,6 +1707,11 @@ export interface PackageJsonData {
|
|
|
1707
1707
|
name?: string;
|
|
1708
1708
|
version?: string;
|
|
1709
1709
|
main?: string;
|
|
1710
|
+
exports?: {
|
|
1711
|
+
[key: string]: string | {
|
|
1712
|
+
[key: string]: string;
|
|
1713
|
+
};
|
|
1714
|
+
};
|
|
1710
1715
|
description?: string;
|
|
1711
1716
|
bin?: {
|
|
1712
1717
|
[key: string]: string;
|
|
@@ -838,6 +838,19 @@ export interface SerializeDocumentOptions extends HydrateDocumentOptions {
|
|
|
838
838
|
* Remove HTML comments. Defaults to `true`.
|
|
839
839
|
*/
|
|
840
840
|
removeHtmlComments?: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* If set to `false` Stencil will ignore the fact that a component has a `shadow: true`
|
|
843
|
+
* flag and serializes it as a scoped component. If set to `true` the component will
|
|
844
|
+
* be rendered within a Declarative Shadow DOM.
|
|
845
|
+
* @default false
|
|
846
|
+
*/
|
|
847
|
+
serializeShadowRoot?: boolean;
|
|
848
|
+
/**
|
|
849
|
+
* The `fullDocument` flag determines the format of the rendered output. Set it to true to
|
|
850
|
+
* generate a complete HTML document, or false to render only the component.
|
|
851
|
+
* @default true
|
|
852
|
+
*/
|
|
853
|
+
fullDocument?: boolean;
|
|
841
854
|
}
|
|
842
855
|
export interface HydrateFactoryOptions extends SerializeDocumentOptions {
|
|
843
856
|
serializeToHtml: boolean;
|
|
@@ -966,9 +966,9 @@ var createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
966
966
|
}
|
|
967
967
|
elm = newVNode2.$elm$ = import_app_data10.BUILD.svg ? doc.createElementNS(
|
|
968
968
|
isSvgMode ? SVG_NS : HTML_NS,
|
|
969
|
-
import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
|
|
969
|
+
!useNativeShadowDom && import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
|
|
970
970
|
) : doc.createElement(
|
|
971
|
-
import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
|
|
971
|
+
!useNativeShadowDom && import_app_data10.BUILD.slotRelocation && newVNode2.$flags$ & 2 /* isSlotFallback */ ? "slot-fb" : newVNode2.$tag$
|
|
972
972
|
);
|
|
973
973
|
if (import_app_data10.BUILD.svg && isSvgMode && newVNode2.$tag$ === "foreignObject") {
|
|
974
974
|
isSvgMode = false;
|
|
@@ -2520,13 +2520,21 @@ var proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
2520
2520
|
},
|
|
2521
2521
|
__attachShadow() {
|
|
2522
2522
|
if (supportsShadow) {
|
|
2523
|
-
if (
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2523
|
+
if (!this.shadowRoot) {
|
|
2524
|
+
if (import_app_data18.BUILD.shadowDelegatesFocus) {
|
|
2525
|
+
this.attachShadow({
|
|
2526
|
+
mode: "open",
|
|
2527
|
+
delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
|
|
2528
|
+
});
|
|
2529
|
+
} else {
|
|
2530
|
+
this.attachShadow({ mode: "open" });
|
|
2531
|
+
}
|
|
2528
2532
|
} else {
|
|
2529
|
-
this.
|
|
2533
|
+
if (this.shadowRoot.mode !== "open") {
|
|
2534
|
+
throw new Error(
|
|
2535
|
+
`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
|
|
2536
|
+
);
|
|
2537
|
+
}
|
|
2530
2538
|
}
|
|
2531
2539
|
} else {
|
|
2532
2540
|
this.shadowRoot = this;
|
|
@@ -2640,13 +2648,21 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
2640
2648
|
registerHost(self, cmpMeta);
|
|
2641
2649
|
if (import_app_data19.BUILD.shadowDom && cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
2642
2650
|
if (supportsShadow) {
|
|
2643
|
-
if (
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2651
|
+
if (!self.shadowRoot) {
|
|
2652
|
+
if (import_app_data19.BUILD.shadowDelegatesFocus) {
|
|
2653
|
+
self.attachShadow({
|
|
2654
|
+
mode: "open",
|
|
2655
|
+
delegatesFocus: !!(cmpMeta.$flags$ & 16 /* shadowDelegatesFocus */)
|
|
2656
|
+
});
|
|
2657
|
+
} else {
|
|
2658
|
+
self.attachShadow({ mode: "open" });
|
|
2659
|
+
}
|
|
2648
2660
|
} else {
|
|
2649
|
-
self.
|
|
2661
|
+
if (self.shadowRoot.mode !== "open") {
|
|
2662
|
+
throw new Error(
|
|
2663
|
+
`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but Stencil only supports open shadow roots.`
|
|
2664
|
+
);
|
|
2665
|
+
}
|
|
2650
2666
|
}
|
|
2651
2667
|
} else if (!import_app_data19.BUILD.hydrateServerSide && !("shadowRoot" in self)) {
|
|
2652
2668
|
self.shadowRoot = self;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/core/internal/testing",
|
|
3
|
-
"version": "4.18.3-dev.
|
|
3
|
+
"version": "4.18.3-dev.1718220868.532557e",
|
|
4
4
|
"description": "Stencil internal testing platform to be imported by the Stencil Compiler. Breaking changes can and will happen at any time.",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"private": true
|
package/mock-doc/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil Mock Doc (CommonJS) v4.18.3-dev.
|
|
2
|
+
Stencil Mock Doc (CommonJS) v4.18.3-dev.1718220868.532557e | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
"use strict";
|
|
5
5
|
var __defProp = Object.defineProperty;
|
|
@@ -6270,67 +6270,50 @@ function humanReadableList(items) {
|
|
|
6270
6270
|
}
|
|
6271
6271
|
|
|
6272
6272
|
// src/mock-doc/serialize-node.ts
|
|
6273
|
-
function
|
|
6273
|
+
function normalizeSerializationOptions(opts = {}) {
|
|
6274
|
+
return {
|
|
6275
|
+
...opts,
|
|
6276
|
+
outerHtml: typeof opts.outerHtml !== "boolean" ? false : opts.outerHtml,
|
|
6277
|
+
...opts.prettyHtml ? {
|
|
6278
|
+
indentSpaces: typeof opts.indentSpaces !== "number" ? 2 : opts.indentSpaces,
|
|
6279
|
+
newLines: typeof opts.newLines !== "boolean" ? true : opts.newLines
|
|
6280
|
+
} : {
|
|
6281
|
+
prettyHtml: false,
|
|
6282
|
+
indentSpaces: typeof opts.indentSpaces !== "number" ? 0 : opts.indentSpaces,
|
|
6283
|
+
newLines: typeof opts.newLines !== "boolean" ? false : opts.newLines
|
|
6284
|
+
},
|
|
6285
|
+
approximateLineWidth: typeof opts.approximateLineWidth !== "number" ? -1 : opts.approximateLineWidth,
|
|
6286
|
+
removeEmptyAttributes: typeof opts.removeEmptyAttributes !== "boolean" ? true : opts.removeEmptyAttributes,
|
|
6287
|
+
removeAttributeQuotes: typeof opts.removeAttributeQuotes !== "boolean" ? false : opts.removeAttributeQuotes,
|
|
6288
|
+
removeBooleanAttributeQuotes: typeof opts.removeBooleanAttributeQuotes !== "boolean" ? false : opts.removeBooleanAttributeQuotes,
|
|
6289
|
+
removeHtmlComments: typeof opts.removeHtmlComments !== "boolean" ? false : opts.removeHtmlComments,
|
|
6290
|
+
serializeShadowRoot: typeof opts.serializeShadowRoot !== "boolean" ? false : opts.serializeShadowRoot,
|
|
6291
|
+
fullDocument: typeof opts.fullDocument !== "boolean" ? true : opts.fullDocument
|
|
6292
|
+
};
|
|
6293
|
+
}
|
|
6294
|
+
function serializeNodeToHtml(elm, serializationOptions = {}) {
|
|
6295
|
+
const opts = normalizeSerializationOptions(serializationOptions);
|
|
6274
6296
|
const output = {
|
|
6275
6297
|
currentLineWidth: 0,
|
|
6276
6298
|
indent: 0,
|
|
6277
6299
|
isWithinBody: false,
|
|
6278
6300
|
text: []
|
|
6279
6301
|
};
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
}
|
|
6287
|
-
opts.approximateLineWidth = -1;
|
|
6288
|
-
} else {
|
|
6289
|
-
opts.prettyHtml = false;
|
|
6290
|
-
if (typeof opts.newLines !== "boolean") {
|
|
6291
|
-
opts.newLines = false;
|
|
6292
|
-
}
|
|
6293
|
-
if (typeof opts.indentSpaces !== "number") {
|
|
6294
|
-
opts.indentSpaces = 0;
|
|
6295
|
-
}
|
|
6296
|
-
}
|
|
6297
|
-
if (typeof opts.approximateLineWidth !== "number") {
|
|
6298
|
-
opts.approximateLineWidth = -1;
|
|
6299
|
-
}
|
|
6300
|
-
if (typeof opts.removeEmptyAttributes !== "boolean") {
|
|
6301
|
-
opts.removeEmptyAttributes = true;
|
|
6302
|
-
}
|
|
6303
|
-
if (typeof opts.removeAttributeQuotes !== "boolean") {
|
|
6304
|
-
opts.removeAttributeQuotes = false;
|
|
6305
|
-
}
|
|
6306
|
-
if (typeof opts.removeBooleanAttributeQuotes !== "boolean") {
|
|
6307
|
-
opts.removeBooleanAttributeQuotes = false;
|
|
6308
|
-
}
|
|
6309
|
-
if (typeof opts.removeHtmlComments !== "boolean") {
|
|
6310
|
-
opts.removeHtmlComments = false;
|
|
6311
|
-
}
|
|
6312
|
-
if (typeof opts.serializeShadowRoot !== "boolean") {
|
|
6313
|
-
opts.serializeShadowRoot = false;
|
|
6314
|
-
}
|
|
6315
|
-
if (opts.outerHtml) {
|
|
6316
|
-
serializeToHtml(elm, opts, output, false);
|
|
6317
|
-
} else {
|
|
6318
|
-
for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
|
|
6319
|
-
serializeToHtml(elm.childNodes[i], opts, output, false);
|
|
6320
|
-
}
|
|
6321
|
-
}
|
|
6322
|
-
if (output.text[0] === "\n") {
|
|
6323
|
-
output.text.shift();
|
|
6324
|
-
}
|
|
6325
|
-
if (output.text[output.text.length - 1] === "\n") {
|
|
6326
|
-
output.text.pop();
|
|
6302
|
+
let renderedNode = "";
|
|
6303
|
+
const children = !opts.fullDocument && elm.body ? Array.from(elm.body.childNodes) : opts.outerHtml ? [elm] : Array.from(elm.childNodes);
|
|
6304
|
+
for (let i = 0, ii = children.length; i < ii; i++) {
|
|
6305
|
+
const child = children[i];
|
|
6306
|
+
const chunks = Array.from(streamToHtml(child, opts, output));
|
|
6307
|
+
renderedNode += chunks.join("");
|
|
6327
6308
|
}
|
|
6328
|
-
return
|
|
6309
|
+
return renderedNode.trim();
|
|
6329
6310
|
}
|
|
6330
|
-
|
|
6311
|
+
var shadowRootTag = "mock:shadow-root";
|
|
6312
|
+
function* streamToHtml(node, opts, output) {
|
|
6331
6313
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
6314
|
+
const isShadowRoot = node.nodeType === 11 /* DOCUMENT_FRAGMENT_NODE */;
|
|
6332
6315
|
if (node.nodeType === 1 /* ELEMENT_NODE */ || isShadowRoot) {
|
|
6333
|
-
const tagName = isShadowRoot ?
|
|
6316
|
+
const tagName = isShadowRoot ? shadowRootTag : getTagName(node);
|
|
6334
6317
|
if (tagName === "body") {
|
|
6335
6318
|
output.isWithinBody = true;
|
|
6336
6319
|
}
|
|
@@ -6338,17 +6321,23 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
|
|
|
6338
6321
|
if (ignoreTag === false) {
|
|
6339
6322
|
const isWithinWhitespaceSensitiveNode = opts.newLines || ((_a = opts.indentSpaces) != null ? _a : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
|
|
6340
6323
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
6341
|
-
|
|
6324
|
+
yield "\n";
|
|
6342
6325
|
output.currentLineWidth = 0;
|
|
6343
6326
|
}
|
|
6344
6327
|
if (((_b = opts.indentSpaces) != null ? _b : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
6345
6328
|
for (let i = 0; i < output.indent; i++) {
|
|
6346
|
-
|
|
6329
|
+
yield " ";
|
|
6347
6330
|
}
|
|
6348
6331
|
output.currentLineWidth += output.indent;
|
|
6349
6332
|
}
|
|
6350
|
-
|
|
6351
|
-
|
|
6333
|
+
const tag = tagName === shadowRootTag ? "template" : tagName;
|
|
6334
|
+
yield "<" + tag;
|
|
6335
|
+
output.currentLineWidth += tag.length + 1;
|
|
6336
|
+
if (tag === "template") {
|
|
6337
|
+
const mode = ` shadowrootmode="open"`;
|
|
6338
|
+
yield mode;
|
|
6339
|
+
output.currentLineWidth += mode.length;
|
|
6340
|
+
}
|
|
6352
6341
|
const attrsLength = node.attributes.length;
|
|
6353
6342
|
const attributes = opts.prettyHtml && attrsLength > 1 ? cloneAttributes(node.attributes, true) : node.attributes;
|
|
6354
6343
|
for (let i = 0; i < attrsLength; i++) {
|
|
@@ -6365,27 +6354,27 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
|
|
|
6365
6354
|
if (attrNamespaceURI == null) {
|
|
6366
6355
|
output.currentLineWidth += attrName.length + 1;
|
|
6367
6356
|
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
|
|
6368
|
-
|
|
6357
|
+
yield "\n" + attrName;
|
|
6369
6358
|
output.currentLineWidth = 0;
|
|
6370
6359
|
} else {
|
|
6371
|
-
|
|
6360
|
+
yield " " + attrName;
|
|
6372
6361
|
}
|
|
6373
6362
|
} else if (attrNamespaceURI === "http://www.w3.org/XML/1998/namespace") {
|
|
6374
|
-
|
|
6363
|
+
yield " xml:" + attrName;
|
|
6375
6364
|
output.currentLineWidth += attrName.length + 5;
|
|
6376
6365
|
} else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/") {
|
|
6377
6366
|
if (attrName !== "xmlns") {
|
|
6378
|
-
|
|
6367
|
+
yield " xmlns:" + attrName;
|
|
6379
6368
|
output.currentLineWidth += attrName.length + 7;
|
|
6380
6369
|
} else {
|
|
6381
|
-
|
|
6370
|
+
yield " " + attrName;
|
|
6382
6371
|
output.currentLineWidth += attrName.length + 1;
|
|
6383
6372
|
}
|
|
6384
6373
|
} else if (attrNamespaceURI === XLINK_NS) {
|
|
6385
|
-
|
|
6374
|
+
yield " xlink:" + attrName;
|
|
6386
6375
|
output.currentLineWidth += attrName.length + 7;
|
|
6387
6376
|
} else {
|
|
6388
|
-
|
|
6377
|
+
yield " " + attrNamespaceURI + ":" + attrName;
|
|
6389
6378
|
output.currentLineWidth += attrNamespaceURI.length + attrName.length + 2;
|
|
6390
6379
|
}
|
|
6391
6380
|
if (opts.prettyHtml && attrName === "class") {
|
|
@@ -6400,43 +6389,45 @@ function serializeToHtml(node, opts, output, isShadowRoot) {
|
|
|
6400
6389
|
}
|
|
6401
6390
|
}
|
|
6402
6391
|
if (opts.removeAttributeQuotes && CAN_REMOVE_ATTR_QUOTES.test(attrValue)) {
|
|
6403
|
-
|
|
6392
|
+
yield "=" + escapeString(attrValue, true);
|
|
6404
6393
|
output.currentLineWidth += attrValue.length + 1;
|
|
6405
6394
|
} else {
|
|
6406
|
-
|
|
6395
|
+
yield '="' + escapeString(attrValue, true) + '"';
|
|
6407
6396
|
output.currentLineWidth += attrValue.length + 3;
|
|
6408
6397
|
}
|
|
6409
6398
|
}
|
|
6410
6399
|
if (node.hasAttribute("style")) {
|
|
6411
6400
|
const cssText = node.style.cssText;
|
|
6412
6401
|
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + cssText.length + 10 > opts.approximateLineWidth) {
|
|
6413
|
-
|
|
6414
|
-
style="${cssText}"
|
|
6402
|
+
yield `
|
|
6403
|
+
style="${cssText}">`;
|
|
6415
6404
|
output.currentLineWidth = 0;
|
|
6416
6405
|
} else {
|
|
6417
|
-
|
|
6406
|
+
yield ` style="${cssText}">`;
|
|
6418
6407
|
output.currentLineWidth += cssText.length + 10;
|
|
6419
6408
|
}
|
|
6420
6409
|
} else {
|
|
6421
|
-
|
|
6410
|
+
yield ">";
|
|
6422
6411
|
output.currentLineWidth += 1;
|
|
6423
6412
|
}
|
|
6424
6413
|
}
|
|
6425
6414
|
if (EMPTY_ELEMENTS.has(tagName) === false) {
|
|
6426
|
-
|
|
6415
|
+
const shadowRoot = node.shadowRoot;
|
|
6416
|
+
if (opts.serializeShadowRoot && shadowRoot != null) {
|
|
6427
6417
|
output.indent = output.indent + ((_c = opts.indentSpaces) != null ? _c : 0);
|
|
6428
|
-
|
|
6418
|
+
yield* streamToHtml(shadowRoot, opts, output);
|
|
6429
6419
|
output.indent = output.indent - ((_d = opts.indentSpaces) != null ? _d : 0);
|
|
6430
6420
|
if (opts.newLines && (node.childNodes.length === 0 || node.childNodes.length === 1 && node.childNodes[0].nodeType === 3 /* TEXT_NODE */ && ((_e = node.childNodes[0].nodeValue) == null ? void 0 : _e.trim()) === "")) {
|
|
6431
|
-
|
|
6421
|
+
yield "\n";
|
|
6432
6422
|
output.currentLineWidth = 0;
|
|
6433
6423
|
for (let i = 0; i < output.indent; i++) {
|
|
6434
|
-
|
|
6424
|
+
yield " ";
|
|
6435
6425
|
}
|
|
6436
6426
|
output.currentLineWidth += output.indent;
|
|
6437
6427
|
}
|
|
6438
6428
|
}
|
|
6439
6429
|
if (opts.excludeTagContent == null || opts.excludeTagContent.includes(tagName) === false) {
|
|
6430
|
+
const tag = tagName === shadowRootTag ? "template" : tagName;
|
|
6440
6431
|
const childNodes = tagName === "template" ? node.content.childNodes : node.childNodes;
|
|
6441
6432
|
const childNodeLength = childNodes.length;
|
|
6442
6433
|
if (childNodeLength > 0) {
|
|
@@ -6447,17 +6438,17 @@ style="${cssText}">`);
|
|
|
6447
6438
|
output.indent = output.indent + ((_h = opts.indentSpaces) != null ? _h : 0);
|
|
6448
6439
|
}
|
|
6449
6440
|
for (let i = 0; i < childNodeLength; i++) {
|
|
6450
|
-
|
|
6441
|
+
yield* streamToHtml(childNodes[i], opts, output);
|
|
6451
6442
|
}
|
|
6452
6443
|
if (ignoreTag === false) {
|
|
6453
6444
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
6454
|
-
|
|
6445
|
+
yield "\n";
|
|
6455
6446
|
output.currentLineWidth = 0;
|
|
6456
6447
|
}
|
|
6457
6448
|
if (((_i = opts.indentSpaces) != null ? _i : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
6458
6449
|
output.indent = output.indent - ((_j = opts.indentSpaces) != null ? _j : 0);
|
|
6459
6450
|
for (let i = 0; i < output.indent; i++) {
|
|
6460
|
-
|
|
6451
|
+
yield " ";
|
|
6461
6452
|
}
|
|
6462
6453
|
output.currentLineWidth += output.indent;
|
|
6463
6454
|
}
|
|
@@ -6465,13 +6456,13 @@ style="${cssText}">`);
|
|
|
6465
6456
|
}
|
|
6466
6457
|
}
|
|
6467
6458
|
if (ignoreTag === false) {
|
|
6468
|
-
|
|
6469
|
-
output.currentLineWidth +=
|
|
6459
|
+
yield "</" + tag + ">";
|
|
6460
|
+
output.currentLineWidth += tag.length + 3;
|
|
6470
6461
|
}
|
|
6471
6462
|
}
|
|
6472
6463
|
}
|
|
6473
6464
|
if (((_k = opts.approximateLineWidth) != null ? _k : 0) > 0 && STRUCTURE_ELEMENTS.has(tagName)) {
|
|
6474
|
-
|
|
6465
|
+
yield "\n";
|
|
6475
6466
|
output.currentLineWidth = 0;
|
|
6476
6467
|
}
|
|
6477
6468
|
if (tagName === "body") {
|
|
@@ -6483,27 +6474,27 @@ style="${cssText}">`);
|
|
|
6483
6474
|
const trimmedTextContent = textContent.trim();
|
|
6484
6475
|
if (trimmedTextContent === "") {
|
|
6485
6476
|
if (isWithinWhitespaceSensitive(node)) {
|
|
6486
|
-
|
|
6477
|
+
yield textContent;
|
|
6487
6478
|
output.currentLineWidth += textContent.length;
|
|
6488
6479
|
} else if (((_l = opts.approximateLineWidth) != null ? _l : 0) > 0 && !output.isWithinBody) {
|
|
6489
6480
|
} else if (!opts.prettyHtml) {
|
|
6490
6481
|
output.currentLineWidth += 1;
|
|
6491
6482
|
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth > opts.approximateLineWidth) {
|
|
6492
|
-
|
|
6483
|
+
yield "\n";
|
|
6493
6484
|
output.currentLineWidth = 0;
|
|
6494
6485
|
} else {
|
|
6495
|
-
|
|
6486
|
+
yield " ";
|
|
6496
6487
|
}
|
|
6497
6488
|
}
|
|
6498
6489
|
} else {
|
|
6499
6490
|
const isWithinWhitespaceSensitiveNode = opts.newLines || ((_m = opts.indentSpaces) != null ? _m : 0) > 0 || opts.prettyHtml ? isWithinWhitespaceSensitive(node) : false;
|
|
6500
6491
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
6501
|
-
|
|
6492
|
+
yield "\n";
|
|
6502
6493
|
output.currentLineWidth = 0;
|
|
6503
6494
|
}
|
|
6504
6495
|
if (((_n = opts.indentSpaces) != null ? _n : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
6505
6496
|
for (let i = 0; i < output.indent; i++) {
|
|
6506
|
-
|
|
6497
|
+
yield " ";
|
|
6507
6498
|
}
|
|
6508
6499
|
output.currentLineWidth += output.indent;
|
|
6509
6500
|
}
|
|
@@ -6512,15 +6503,15 @@ style="${cssText}">`);
|
|
|
6512
6503
|
const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 /* ELEMENT_NODE */ ? node.parentNode.nodeName : null;
|
|
6513
6504
|
if (typeof parentTagName === "string" && NON_ESCAPABLE_CONTENT.has(parentTagName)) {
|
|
6514
6505
|
if (isWithinWhitespaceSensitive(node)) {
|
|
6515
|
-
|
|
6506
|
+
yield textContent;
|
|
6516
6507
|
} else {
|
|
6517
|
-
|
|
6508
|
+
yield trimmedTextContent;
|
|
6518
6509
|
textContentLength = trimmedTextContent.length;
|
|
6519
6510
|
}
|
|
6520
6511
|
output.currentLineWidth += textContentLength;
|
|
6521
6512
|
} else {
|
|
6522
6513
|
if (opts.prettyHtml && !isWithinWhitespaceSensitiveNode) {
|
|
6523
|
-
|
|
6514
|
+
yield escapeString(textContent.replace(/\s\s+/g, " ").trim(), false);
|
|
6524
6515
|
output.currentLineWidth += textContentLength;
|
|
6525
6516
|
} else {
|
|
6526
6517
|
if (isWithinWhitespaceSensitive(node)) {
|
|
@@ -6542,7 +6533,7 @@ style="${cssText}">`);
|
|
|
6542
6533
|
}
|
|
6543
6534
|
output.currentLineWidth += textContentLength;
|
|
6544
6535
|
}
|
|
6545
|
-
|
|
6536
|
+
yield escapeString(textContent, false);
|
|
6546
6537
|
}
|
|
6547
6538
|
}
|
|
6548
6539
|
}
|
|
@@ -6550,27 +6541,25 @@ style="${cssText}">`);
|
|
|
6550
6541
|
}
|
|
6551
6542
|
} else if (node.nodeType === 8 /* COMMENT_NODE */) {
|
|
6552
6543
|
const nodeValue = node.nodeValue;
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
return;
|
|
6557
|
-
}
|
|
6544
|
+
const isHydrateAnnotation = (nodeValue == null ? void 0 : nodeValue.startsWith(CONTENT_REF_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(ORG_LOCATION_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(SLOT_NODE_ID + ".")) || (nodeValue == null ? void 0 : nodeValue.startsWith(TEXT_NODE_ID + "."));
|
|
6545
|
+
if (opts.removeHtmlComments && !isHydrateAnnotation) {
|
|
6546
|
+
return;
|
|
6558
6547
|
}
|
|
6559
6548
|
const isWithinWhitespaceSensitiveNode = opts.newLines || ((_o = opts.indentSpaces) != null ? _o : 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
|
|
6560
6549
|
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
6561
|
-
|
|
6550
|
+
yield "\n";
|
|
6562
6551
|
output.currentLineWidth = 0;
|
|
6563
6552
|
}
|
|
6564
6553
|
if (((_p = opts.indentSpaces) != null ? _p : 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
6565
6554
|
for (let i = 0; i < output.indent; i++) {
|
|
6566
|
-
|
|
6555
|
+
yield " ";
|
|
6567
6556
|
}
|
|
6568
6557
|
output.currentLineWidth += output.indent;
|
|
6569
6558
|
}
|
|
6570
|
-
|
|
6559
|
+
yield "<!--" + nodeValue + "-->";
|
|
6571
6560
|
output.currentLineWidth += nodeValue.length + 7;
|
|
6572
6561
|
} else if (node.nodeType === 10 /* DOCUMENT_TYPE_NODE */) {
|
|
6573
|
-
|
|
6562
|
+
yield "<!doctype html>";
|
|
6574
6563
|
}
|
|
6575
6564
|
}
|
|
6576
6565
|
var AMP_REGEX = /&/g;
|
|
@@ -6911,6 +6900,10 @@ Testing components with ElementInternals is fully supported in e2e tests.`
|
|
|
6911
6900
|
get shadowRoot() {
|
|
6912
6901
|
return this.__shadowRoot || null;
|
|
6913
6902
|
}
|
|
6903
|
+
/**
|
|
6904
|
+
* Set shadow root for element
|
|
6905
|
+
* @param shadowRoot - ShadowRoot to set
|
|
6906
|
+
*/
|
|
6914
6907
|
set shadowRoot(shadowRoot) {
|
|
6915
6908
|
if (shadowRoot != null) {
|
|
6916
6909
|
shadowRoot.host = this;
|
|
@@ -8958,6 +8951,7 @@ var nativeClearTimeout = clearTimeout;
|
|
|
8958
8951
|
var nativeSetInterval = setInterval;
|
|
8959
8952
|
var nativeSetTimeout = setTimeout;
|
|
8960
8953
|
var nativeURL = URL;
|
|
8954
|
+
var nativeWindow = globalThis.window;
|
|
8961
8955
|
var MockWindow = class {
|
|
8962
8956
|
constructor(html = null) {
|
|
8963
8957
|
if (html !== false) {
|
|
@@ -8984,10 +8978,10 @@ var MockWindow = class {
|
|
|
8984
8978
|
blur() {
|
|
8985
8979
|
}
|
|
8986
8980
|
cancelAnimationFrame(id) {
|
|
8987
|
-
this.__clearTimeout(id);
|
|
8981
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
8988
8982
|
}
|
|
8989
8983
|
cancelIdleCallback(id) {
|
|
8990
|
-
this.__clearTimeout(id);
|
|
8984
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
8991
8985
|
}
|
|
8992
8986
|
get CharacterData() {
|
|
8993
8987
|
if (this.__charDataCstr == null) {
|
|
@@ -9005,10 +8999,10 @@ var MockWindow = class {
|
|
|
9005
8999
|
this.__charDataCstr = charDataCstr;
|
|
9006
9000
|
}
|
|
9007
9001
|
clearInterval(id) {
|
|
9008
|
-
this.__clearInterval(id);
|
|
9002
|
+
this.__clearInterval.call(nativeWindow || this, id);
|
|
9009
9003
|
}
|
|
9010
9004
|
clearTimeout(id) {
|
|
9011
|
-
this.__clearTimeout(id);
|
|
9005
|
+
this.__clearTimeout.call(nativeWindow || this, id);
|
|
9012
9006
|
}
|
|
9013
9007
|
close() {
|
|
9014
9008
|
resetWindow(this);
|
|
@@ -9308,20 +9302,24 @@ var MockWindow = class {
|
|
|
9308
9302
|
}
|
|
9309
9303
|
return intervalId;
|
|
9310
9304
|
}
|
|
9311
|
-
const timeoutId = this.__setTimeout(
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9305
|
+
const timeoutId = this.__setTimeout.call(
|
|
9306
|
+
nativeWindow || this,
|
|
9307
|
+
() => {
|
|
9308
|
+
if (this.__timeouts) {
|
|
9309
|
+
this.__timeouts.delete(timeoutId);
|
|
9310
|
+
try {
|
|
9311
|
+
callback(...args);
|
|
9312
|
+
} catch (e2) {
|
|
9313
|
+
if (this.console) {
|
|
9314
|
+
this.console.error(e2);
|
|
9315
|
+
} else {
|
|
9316
|
+
console.error(e2);
|
|
9317
|
+
}
|
|
9321
9318
|
}
|
|
9322
9319
|
}
|
|
9323
|
-
}
|
|
9324
|
-
|
|
9320
|
+
},
|
|
9321
|
+
ms
|
|
9322
|
+
);
|
|
9325
9323
|
if (this.__timeouts) {
|
|
9326
9324
|
this.__timeouts.add(timeoutId);
|
|
9327
9325
|
}
|
|
@@ -9332,20 +9330,24 @@ var MockWindow = class {
|
|
|
9332
9330
|
this.__timeouts = /* @__PURE__ */ new Set();
|
|
9333
9331
|
}
|
|
9334
9332
|
ms = Math.min(ms, this.__maxTimeout);
|
|
9335
|
-
const timeoutId = this.__setTimeout(
|
|
9336
|
-
|
|
9337
|
-
|
|
9338
|
-
|
|
9339
|
-
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
|
|
9343
|
-
|
|
9344
|
-
|
|
9333
|
+
const timeoutId = this.__setTimeout.call(
|
|
9334
|
+
nativeWindow || this,
|
|
9335
|
+
() => {
|
|
9336
|
+
if (this.__timeouts) {
|
|
9337
|
+
this.__timeouts.delete(timeoutId);
|
|
9338
|
+
try {
|
|
9339
|
+
callback(...args);
|
|
9340
|
+
} catch (e2) {
|
|
9341
|
+
if (this.console) {
|
|
9342
|
+
this.console.error(e2);
|
|
9343
|
+
} else {
|
|
9344
|
+
console.error(e2);
|
|
9345
|
+
}
|
|
9345
9346
|
}
|
|
9346
9347
|
}
|
|
9347
|
-
}
|
|
9348
|
-
|
|
9348
|
+
},
|
|
9349
|
+
ms
|
|
9350
|
+
);
|
|
9349
9351
|
if (this.__timeouts) {
|
|
9350
9352
|
this.__timeouts.add(timeoutId);
|
|
9351
9353
|
}
|
package/mock-doc/index.d.ts
CHANGED
|
@@ -538,6 +538,10 @@ declare class MockElement extends MockNode {
|
|
|
538
538
|
get localName(): string;
|
|
539
539
|
get namespaceURI(): string;
|
|
540
540
|
get shadowRoot(): any;
|
|
541
|
+
/**
|
|
542
|
+
* Set shadow root for element
|
|
543
|
+
* @param shadowRoot - ShadowRoot to set
|
|
544
|
+
*/
|
|
541
545
|
set shadowRoot(shadowRoot: any);
|
|
542
546
|
get attributes(): MockAttributeMap;
|
|
543
547
|
set attributes(attrs: MockAttributeMap);
|
|
@@ -852,19 +856,28 @@ declare function selectAll(selector: string, elm: MockElement): any;
|
|
|
852
856
|
*/
|
|
853
857
|
declare const PROBLEMATIC_SELECTORS: readonly [":scope", ":where", ":is"];
|
|
854
858
|
/**
|
|
855
|
-
* Serialize a node (either a DOM node or a mock-doc node) to an HTML string
|
|
859
|
+
* Serialize a node (either a DOM node or a mock-doc node) to an HTML string.
|
|
860
|
+
* This operation is similar to `outerHTML` but allows for more control over the
|
|
861
|
+
* serialization process. It is fully synchronous meaning that it will not
|
|
862
|
+
* wait for a component to be fully rendered before serializing it. Use `streamToHtml`
|
|
863
|
+
* for a streaming version of this function.
|
|
856
864
|
*
|
|
857
865
|
* @param elm the node to serialize
|
|
858
|
-
* @param
|
|
866
|
+
* @param serializationOptions options to control serialization behavior
|
|
859
867
|
* @returns an html string
|
|
860
868
|
*/
|
|
861
|
-
declare function serializeNodeToHtml(elm: Node | MockNode,
|
|
869
|
+
declare function serializeNodeToHtml(elm: Node | MockNode, serializationOptions?: SerializeNodeToHtmlOptions): string;
|
|
862
870
|
declare const NON_ESCAPABLE_CONTENT: Set<string>;
|
|
863
871
|
/**
|
|
864
872
|
* A list of whitespace sensitive tag names, such as `code`, `pre`, etc.
|
|
865
873
|
*/
|
|
866
874
|
declare const WHITESPACE_SENSITIVE: Set<string>;
|
|
867
875
|
declare const EMPTY_ELEMENTS: Set<string>;
|
|
876
|
+
/**
|
|
877
|
+
* Partially duplicate of https://github.com/ionic-team/stencil/blob/6017dad2cb6fe366242e2e0594f82c8e3a3b5d15/src/declarations/stencil-public-compiler.ts#L895
|
|
878
|
+
* Types can't be imported in this documented as Eslint will not embed the types
|
|
879
|
+
* in the d.ts file.
|
|
880
|
+
*/
|
|
868
881
|
interface SerializeNodeToHtmlOptions {
|
|
869
882
|
approximateLineWidth?: number;
|
|
870
883
|
excludeTagContent?: string[];
|
|
@@ -878,6 +891,7 @@ interface SerializeNodeToHtmlOptions {
|
|
|
878
891
|
removeEmptyAttributes?: boolean;
|
|
879
892
|
removeHtmlComments?: boolean;
|
|
880
893
|
serializeShadowRoot?: boolean;
|
|
894
|
+
fullDocument?: boolean;
|
|
881
895
|
}
|
|
882
896
|
declare class MockStorage {
|
|
883
897
|
key(_value: number): void;
|