@stencil/core 5.0.0-beta.9 → 5.0.0-rc.0
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/dist/app-data/index.d.ts +1 -1
- package/dist/app-data/index.js +1 -0
- package/dist/{client-BRu0GtRn.mjs → client-ClM4H9-P.mjs} +204 -76
- package/dist/compiler/browser.d.ts +120 -81
- package/dist/compiler/browser.js +964 -402
- package/dist/compiler/index.d.mts +110 -2
- package/dist/compiler/index.mjs +3 -3
- package/dist/compiler/utils/index.d.mts +2 -2
- package/dist/compiler/utils/index.mjs +3 -3
- package/dist/{compiler-wLrjuSOK.mjs → compiler-DFanjq9z.mjs} +5300 -3005
- package/dist/declarations/stencil-public-compiler.d.ts +178 -133
- package/dist/declarations/stencil-public-docs.d.ts +23 -0
- package/dist/declarations/stencil-public-runtime.d.ts +81 -59
- package/dist/{index-BvF31nqP.d.mts → index-DvfFOkiJ.d.mts} +220 -133
- package/dist/{index-BXAcVN2j.d.ts → index-XQHZl0MW.d.ts} +70 -57
- package/dist/{index-BAP9T4CB.d.mts → index-aBMJC5F9.d.mts} +6 -2
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.d.mts +6 -0
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-75gQKkFz.mjs → node-DJP8JuAS.mjs} +42 -48
- package/dist/runtime/client/lazy.js +522 -262
- package/dist/runtime/client/runtime.d.ts +100 -68
- package/dist/runtime/client/runtime.js +522 -262
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +521 -261
- package/dist/runtime/server/index.d.mts +36 -12
- package/dist/runtime/server/index.mjs +635 -304
- package/dist/runtime/server/runner.d.mts +49 -6
- package/dist/runtime/server/runner.mjs +385 -87
- package/dist/signals/index.d.ts +11 -2
- package/dist/signals/index.js +15 -35
- package/dist/sys/node/index.d.mts +1 -1
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.mjs +2 -2
- package/dist/testing/index.d.mts +152 -124
- package/dist/testing/index.mjs +535 -269
- package/dist/{util-IKfWWLJo.mjs → util-C-H1H84W.mjs} +8 -1
- package/dist/{validation-DAdGTrys.mjs → validation-ByYYKvnS.mjs} +37 -3
- package/package.json +8 -4
|
@@ -1,18 +1,95 @@
|
|
|
1
1
|
import { BUILD as BUILD$1, Env, NAMESPACE } from "@stencil/core/app-data";
|
|
2
2
|
import { globalStyles } from "@stencil/core/app-globals";
|
|
3
|
-
import
|
|
3
|
+
import * as SignalsCore from "@preact/signals-core";
|
|
4
4
|
//#region src/app-data/lazy.ts
|
|
5
5
|
const BUILD = {
|
|
6
6
|
...BUILD$1,
|
|
7
7
|
lazyLoad: true
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
10
|
+
//#region src/runtime/runtime-constants.ts
|
|
11
|
+
/**
|
|
12
|
+
* Bit flags for recording various properties of VDom nodes
|
|
13
|
+
*/
|
|
14
|
+
const VNODE_FLAGS = {
|
|
15
|
+
/**
|
|
16
|
+
* Whether or not a vdom node is a slot reference
|
|
17
|
+
*/
|
|
18
|
+
isSlotReference: 1,
|
|
19
|
+
/**
|
|
20
|
+
* Whether or not a slot element has fallback content
|
|
21
|
+
*/
|
|
22
|
+
isSlotFallback: 2,
|
|
23
|
+
/**
|
|
24
|
+
* Whether or not an element is a host element
|
|
25
|
+
*/
|
|
26
|
+
isHost: 4
|
|
27
|
+
};
|
|
28
|
+
const PROXY_FLAGS = {
|
|
29
|
+
isElementConstructor: 1,
|
|
30
|
+
proxyState: 2
|
|
31
|
+
};
|
|
32
|
+
const PLATFORM_FLAGS = {
|
|
33
|
+
/**
|
|
34
|
+
* designates a node in the DOM as being actively moved by the runtime
|
|
35
|
+
*/
|
|
36
|
+
isTmpDisconnected: 1,
|
|
37
|
+
appLoaded: 2,
|
|
38
|
+
queueSync: 4,
|
|
39
|
+
queueMask: 6
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
43
|
+
* values are based on the values which can possibly be returned by the
|
|
44
|
+
* `.nodeType` property of a DOM node. See here for details:
|
|
45
|
+
*
|
|
46
|
+
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
47
|
+
*/
|
|
48
|
+
const NODE_TYPE = {
|
|
49
|
+
ElementNode: 1,
|
|
50
|
+
TextNode: 3,
|
|
51
|
+
CommentNode: 8,
|
|
52
|
+
DocumentNode: 9,
|
|
53
|
+
DocumentTypeNode: 10,
|
|
54
|
+
DocumentFragment: 11
|
|
55
|
+
};
|
|
56
|
+
const HYDRATE_ID = "s-id";
|
|
57
|
+
const HYDRATED_STYLE_ID = "sty-id";
|
|
58
|
+
const HYDRATE_CHILD_ID = "c-id";
|
|
59
|
+
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
60
|
+
/**
|
|
61
|
+
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
62
|
+
*
|
|
63
|
+
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
64
|
+
* support as of Stencil v4.
|
|
65
|
+
*/
|
|
66
|
+
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
67
|
+
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
68
|
+
/**
|
|
69
|
+
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
70
|
+
*/
|
|
71
|
+
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
72
|
+
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
73
|
+
"formAssociatedCallback",
|
|
74
|
+
"formResetCallback",
|
|
75
|
+
"formDisabledCallback",
|
|
76
|
+
"formStateRestoreCallback"
|
|
77
|
+
];
|
|
78
|
+
//#endregion
|
|
10
79
|
//#region src/client/client-build.ts
|
|
80
|
+
/**
|
|
81
|
+
* `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
|
|
82
|
+
* sets `BUILD.*` overrides from each component module, which runs after this module is evaluated.
|
|
83
|
+
*/
|
|
11
84
|
const Build = {
|
|
12
|
-
isDev: BUILD.isDev,
|
|
13
85
|
isBrowser: true,
|
|
14
86
|
isServer: false,
|
|
15
|
-
|
|
87
|
+
get isDev() {
|
|
88
|
+
return BUILD.isDev;
|
|
89
|
+
},
|
|
90
|
+
get isTesting() {
|
|
91
|
+
return BUILD.isTesting;
|
|
92
|
+
}
|
|
16
93
|
};
|
|
17
94
|
//#endregion
|
|
18
95
|
//#region src/client/client-decorators.ts
|
|
@@ -485,6 +562,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
485
562
|
).then(onLoad, onError);
|
|
486
563
|
return import(
|
|
487
564
|
/* @vite-ignore */
|
|
565
|
+
/* turbopackIgnore: true */
|
|
488
566
|
/* webpackInclude: /\.entry\.js$/ */
|
|
489
567
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
490
568
|
/* webpackMode: "lazy" */
|
|
@@ -494,79 +572,10 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
494
572
|
//#endregion
|
|
495
573
|
//#region src/client/client-style.ts
|
|
496
574
|
const styles = /*@__PURE__*/ new Map();
|
|
497
|
-
const
|
|
498
|
-
const
|
|
575
|
+
const modeResolver = [];
|
|
576
|
+
const setScopedSSR = (_opts) => {};
|
|
499
577
|
const needsScopedSSR = () => false;
|
|
500
578
|
//#endregion
|
|
501
|
-
//#region src/runtime/runtime-constants.ts
|
|
502
|
-
/**
|
|
503
|
-
* Bit flags for recording various properties of VDom nodes
|
|
504
|
-
*/
|
|
505
|
-
const VNODE_FLAGS = {
|
|
506
|
-
/**
|
|
507
|
-
* Whether or not a vdom node is a slot reference
|
|
508
|
-
*/
|
|
509
|
-
isSlotReference: 1,
|
|
510
|
-
/**
|
|
511
|
-
* Whether or not a slot element has fallback content
|
|
512
|
-
*/
|
|
513
|
-
isSlotFallback: 2,
|
|
514
|
-
/**
|
|
515
|
-
* Whether or not an element is a host element
|
|
516
|
-
*/
|
|
517
|
-
isHost: 4
|
|
518
|
-
};
|
|
519
|
-
const PROXY_FLAGS = {
|
|
520
|
-
isElementConstructor: 1,
|
|
521
|
-
proxyState: 2
|
|
522
|
-
};
|
|
523
|
-
const PLATFORM_FLAGS = {
|
|
524
|
-
/**
|
|
525
|
-
* designates a node in the DOM as being actively moved by the runtime
|
|
526
|
-
*/
|
|
527
|
-
isTmpDisconnected: 1,
|
|
528
|
-
appLoaded: 2,
|
|
529
|
-
queueSync: 4,
|
|
530
|
-
queueMask: 6
|
|
531
|
-
};
|
|
532
|
-
/**
|
|
533
|
-
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
534
|
-
* values are based on the values which can possibly be returned by the
|
|
535
|
-
* `.nodeType` property of a DOM node. See here for details:
|
|
536
|
-
*
|
|
537
|
-
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
538
|
-
*/
|
|
539
|
-
const NODE_TYPE = {
|
|
540
|
-
ElementNode: 1,
|
|
541
|
-
TextNode: 3,
|
|
542
|
-
CommentNode: 8,
|
|
543
|
-
DocumentNode: 9,
|
|
544
|
-
DocumentTypeNode: 10,
|
|
545
|
-
DocumentFragment: 11
|
|
546
|
-
};
|
|
547
|
-
const HYDRATE_ID = "s-id";
|
|
548
|
-
const HYDRATED_STYLE_ID = "sty-id";
|
|
549
|
-
const HYDRATE_CHILD_ID = "c-id";
|
|
550
|
-
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
551
|
-
/**
|
|
552
|
-
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
553
|
-
*
|
|
554
|
-
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
555
|
-
* support as of Stencil v4.
|
|
556
|
-
*/
|
|
557
|
-
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
558
|
-
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
559
|
-
/**
|
|
560
|
-
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
561
|
-
*/
|
|
562
|
-
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
563
|
-
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
564
|
-
"formAssociatedCallback",
|
|
565
|
-
"formResetCallback",
|
|
566
|
-
"formDisabledCallback",
|
|
567
|
-
"formStateRestoreCallback"
|
|
568
|
-
];
|
|
569
|
-
//#endregion
|
|
570
579
|
//#region src/client/client-window.ts
|
|
571
580
|
const win = typeof window !== "undefined" ? window : {};
|
|
572
581
|
const H = win.HTMLElement || class {};
|
|
@@ -607,12 +616,12 @@ let queuePending = false;
|
|
|
607
616
|
const queueDomReads = [];
|
|
608
617
|
const queueDomWrites = [];
|
|
609
618
|
const queueDomWritesLow = [];
|
|
610
|
-
const scheduleFlush = () => win.document?.hidden ?
|
|
619
|
+
const scheduleFlush = () => win.document?.hidden ? setTimeout(flush$1, 16) : plt.raf(flush$1);
|
|
611
620
|
const queueTask = (queue, write) => (cb) => {
|
|
612
621
|
queue.push(cb);
|
|
613
622
|
if (!queuePending) {
|
|
614
623
|
queuePending = true;
|
|
615
|
-
if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush);
|
|
624
|
+
if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush$1);
|
|
616
625
|
else scheduleFlush();
|
|
617
626
|
}
|
|
618
627
|
};
|
|
@@ -635,7 +644,7 @@ const consumeTimeout = (queue, timeout) => {
|
|
|
635
644
|
if (i === queue.length) queue.length = 0;
|
|
636
645
|
else if (i !== 0) queue.splice(0, i);
|
|
637
646
|
};
|
|
638
|
-
const flush = () => {
|
|
647
|
+
const flush$1 = () => {
|
|
639
648
|
if (BUILD.asyncQueue) queueCongestion++;
|
|
640
649
|
consume(queueDomReads);
|
|
641
650
|
if (BUILD.asyncQueue) {
|
|
@@ -694,6 +703,7 @@ function createShadowRoot(cmpMeta) {
|
|
|
694
703
|
}
|
|
695
704
|
if (BUILD.shadowClonable) opts.clonable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowClonable);
|
|
696
705
|
if (BUILD.shadowSerializable) opts.serializable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowSerializable);
|
|
706
|
+
if (BUILD.shadowReferenceTarget && cmpMeta.$referenceTarget$) opts.referenceTarget = cmpMeta.$referenceTarget$;
|
|
697
707
|
const shadowRoot = this.attachShadow(opts);
|
|
698
708
|
if (BUILD.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
|
|
699
709
|
if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported(globalStyles) ?? null;
|
|
@@ -772,6 +782,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
|
772
782
|
if (typeof slotName !== "undefined") return slottedNodes;
|
|
773
783
|
}
|
|
774
784
|
slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
|
|
785
|
+
if (typeof slotName !== "undefined" && slottedNodes.length) return slottedNodes;
|
|
775
786
|
}
|
|
776
787
|
return slottedNodes;
|
|
777
788
|
}
|
|
@@ -906,6 +917,7 @@ const applyLightDomPatches = (hostElementPrototype) => {
|
|
|
906
917
|
patchSlotInsertAdjacentHTML(hostElementPrototype);
|
|
907
918
|
patchInsertBefore(hostElementPrototype);
|
|
908
919
|
patchTextContent(hostElementPrototype);
|
|
920
|
+
patchInnerContentSetters(hostElementPrototype);
|
|
909
921
|
patchChildSlotNodes(hostElementPrototype);
|
|
910
922
|
patchSlotRemoveChild(hostElementPrototype);
|
|
911
923
|
};
|
|
@@ -970,11 +982,13 @@ const patchSlotAppendChild = (HostElementPrototype) => {
|
|
|
970
982
|
const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
|
|
971
983
|
if (slotNode) {
|
|
972
984
|
addSlotRelocateNode(newChild, slotNode);
|
|
985
|
+
patchSlottedNode(newChild);
|
|
973
986
|
const slotChildNodes = getSlotChildSiblings(slotNode, slotName);
|
|
974
987
|
const appendAfter = slotChildNodes[slotChildNodes.length - 1];
|
|
988
|
+
const slotWasEmpty = slotChildNodes.every((node) => node["s-sr"]);
|
|
975
989
|
const insertedNode = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, appendAfter.nextSibling);
|
|
976
990
|
dispatchSlotChangeEvent(slotNode);
|
|
977
|
-
updateFallbackSlotVisibility(this);
|
|
991
|
+
if (slotWasEmpty) updateFallbackSlotVisibility(this);
|
|
978
992
|
return insertedNode;
|
|
979
993
|
}
|
|
980
994
|
return this.__appendChild(newChild);
|
|
@@ -992,8 +1006,10 @@ const patchSlotRemoveChild = (ElementPrototype) => {
|
|
|
992
1006
|
ElementPrototype.__removeChild = ElementPrototype.removeChild;
|
|
993
1007
|
ElementPrototype.removeChild = function(toRemove) {
|
|
994
1008
|
if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
|
|
995
|
-
|
|
996
|
-
|
|
1009
|
+
const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, toRemove["s-sn"])[0];
|
|
1010
|
+
if (slotNode && toRemove.isConnected) {
|
|
1011
|
+
removeSlottedNode(toRemove);
|
|
1012
|
+
dispatchSlotChangeEvent(slotNode);
|
|
997
1013
|
updateFallbackSlotVisibility(this);
|
|
998
1014
|
return;
|
|
999
1015
|
}
|
|
@@ -1016,6 +1032,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
1016
1032
|
const slotNode = getHostSlotNodes(internalCall(this, "childNodes"), this.tagName, slotName)[0];
|
|
1017
1033
|
if (slotNode) {
|
|
1018
1034
|
addSlotRelocateNode(newChild, slotNode, true);
|
|
1035
|
+
patchSlottedNode(newChild);
|
|
1019
1036
|
const appendAfter = getSlotChildSiblings(slotNode, slotName)[0];
|
|
1020
1037
|
const toReturn = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, internalCall(appendAfter, "nextSibling"));
|
|
1021
1038
|
dispatchSlotChangeEvent(slotNode);
|
|
@@ -1079,25 +1096,21 @@ const patchInsertBefore = (HostElementPrototype) => {
|
|
|
1079
1096
|
eleProto.__insertBefore = HostElementPrototype.insertBefore;
|
|
1080
1097
|
HostElementPrototype.insertBefore = function(newChild, currentChild) {
|
|
1081
1098
|
const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
|
|
1082
|
-
const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
|
|
1083
1099
|
if (slotNode) {
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
dispatchSlotChangeEvent(slotNode);
|
|
1096
|
-
}
|
|
1097
|
-
return;
|
|
1100
|
+
if (currentChild === null) {
|
|
1101
|
+
this.appendChild(newChild);
|
|
1102
|
+
return newChild;
|
|
1103
|
+
}
|
|
1104
|
+
if ((this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).includes(currentChild)) {
|
|
1105
|
+
if (slotName !== currentChild["s-sn"]) this.appendChild(newChild);
|
|
1106
|
+
else {
|
|
1107
|
+
addSlotRelocateNode(newChild, slotNode);
|
|
1108
|
+
patchSlottedNode(newChild);
|
|
1109
|
+
internalCall(internalCall(currentChild, "parentNode"), "insertBefore")(newChild, currentChild);
|
|
1110
|
+
dispatchSlotChangeEvent(slotNode);
|
|
1098
1111
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1112
|
+
return newChild;
|
|
1113
|
+
}
|
|
1101
1114
|
}
|
|
1102
1115
|
/**
|
|
1103
1116
|
* Fixes an issue where slotted elements are dynamically relocated in React, such as after data fetch.
|
|
@@ -1124,18 +1137,55 @@ const patchTextContent = (hostElementPrototype) => {
|
|
|
1124
1137
|
Object.defineProperty(hostElementPrototype, "textContent", {
|
|
1125
1138
|
get: function() {
|
|
1126
1139
|
let text = "";
|
|
1127
|
-
(this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) =>
|
|
1140
|
+
(this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) => {
|
|
1141
|
+
if (node.nodeType !== NODE_TYPE.CommentNode) text += node.textContent || "";
|
|
1142
|
+
});
|
|
1128
1143
|
return text;
|
|
1129
1144
|
},
|
|
1130
1145
|
set: function(value) {
|
|
1131
|
-
(this
|
|
1132
|
-
|
|
1133
|
-
node.remove();
|
|
1134
|
-
});
|
|
1135
|
-
this.insertAdjacentHTML("beforeend", value);
|
|
1146
|
+
removeSlottedNodes(this);
|
|
1147
|
+
if (value != null && value !== "") this.append(this.ownerDocument.createTextNode(String(value)));
|
|
1136
1148
|
}
|
|
1137
1149
|
});
|
|
1138
1150
|
};
|
|
1151
|
+
/**
|
|
1152
|
+
* Patches the `innerHTML` and `innerText` setters of a scoped component so they replace only
|
|
1153
|
+
* the slotted content. Natively they would also remove the component's rendered nodes and its
|
|
1154
|
+
* content reference node, leaving nothing for the next render to relocate into the slot.
|
|
1155
|
+
* The getters are left as they are.
|
|
1156
|
+
*
|
|
1157
|
+
* @param hostElementPrototype the `Element` to be patched
|
|
1158
|
+
*/
|
|
1159
|
+
const patchInnerContentSetters = (hostElementPrototype) => {
|
|
1160
|
+
if (!globalThis.HTMLElement) return;
|
|
1161
|
+
const patchSetter = (proto, name, insert) => {
|
|
1162
|
+
const get = Object.getOwnPropertyDescriptor(proto, name)?.get;
|
|
1163
|
+
if (!get) return;
|
|
1164
|
+
Object.defineProperty(hostElementPrototype, name, {
|
|
1165
|
+
get,
|
|
1166
|
+
set: function(value) {
|
|
1167
|
+
removeSlottedNodes(this);
|
|
1168
|
+
Array.from(internalCall(this, "childNodes")).forEach((node) => {
|
|
1169
|
+
if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== this.tagName) node.remove();
|
|
1170
|
+
});
|
|
1171
|
+
insert(this, value ?? "");
|
|
1172
|
+
}
|
|
1173
|
+
});
|
|
1174
|
+
};
|
|
1175
|
+
patchSetter(Element.prototype, "innerHTML", (host, value) => host.insertAdjacentHTML("beforeend", value));
|
|
1176
|
+
patchSetter(HTMLElement.prototype, "innerText", (host, value) => host.append(value));
|
|
1177
|
+
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Removes the slotted nodes of a scoped component, along with their original location markers.
|
|
1180
|
+
*
|
|
1181
|
+
* @param host the host element of the component
|
|
1182
|
+
*/
|
|
1183
|
+
const removeSlottedNodes = (host) => {
|
|
1184
|
+
(host.__childNodes ? host.childNodes : getSlottedChildNodes(host.childNodes)).forEach((node) => {
|
|
1185
|
+
if (node["s-ol"]) node["s-ol"].remove();
|
|
1186
|
+
node.remove();
|
|
1187
|
+
});
|
|
1188
|
+
};
|
|
1139
1189
|
const patchChildSlotNodes = (elm) => {
|
|
1140
1190
|
class FakeNodeList extends Array {
|
|
1141
1191
|
item(n) {
|
|
@@ -1169,10 +1219,21 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1169
1219
|
} });
|
|
1170
1220
|
};
|
|
1171
1221
|
/**
|
|
1172
|
-
* Patches
|
|
1173
|
-
*
|
|
1174
|
-
*
|
|
1175
|
-
*
|
|
1222
|
+
* Patches a node slotted into a non-shadow component so it behaves as it would in a native slot:
|
|
1223
|
+
* - `parentNode` returns the host element
|
|
1224
|
+
* - `remove()` fires `slotchange` on the node's slot
|
|
1225
|
+
*
|
|
1226
|
+
* @param node the slotted node to be patched
|
|
1227
|
+
*/
|
|
1228
|
+
const patchSlottedNode = (node) => {
|
|
1229
|
+
patchParentNode(node);
|
|
1230
|
+
patchSlottedRemove(node);
|
|
1231
|
+
};
|
|
1232
|
+
/**
|
|
1233
|
+
* Patches a slotted node from SSR markup: everything {@link patchSlottedNode} does, plus its
|
|
1234
|
+
* sibling accessors, so whilst stepping through a non-shadow element's nodes only the mock
|
|
1235
|
+
* 'lightDOM' nodes are returned. Frameworks hydrating SSR output often reconcile their VDOM with
|
|
1236
|
+
* the real DOM by stepping through nodes with 'nextSibling' et al.
|
|
1176
1237
|
* - `nextSibling`
|
|
1177
1238
|
* - `nextElementSibling`
|
|
1178
1239
|
* - `previousSibling`
|
|
@@ -1180,11 +1241,11 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1180
1241
|
*
|
|
1181
1242
|
* @param node the slotted node to be patched
|
|
1182
1243
|
*/
|
|
1183
|
-
const
|
|
1244
|
+
const patchSsrSlottedNode = (node) => {
|
|
1184
1245
|
if (!node || node.__nextSibling !== void 0 || !globalThis.Node) return;
|
|
1185
1246
|
patchNextSibling(node);
|
|
1186
1247
|
patchPreviousSibling(node);
|
|
1187
|
-
|
|
1248
|
+
patchSlottedNode(node);
|
|
1188
1249
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1189
1250
|
patchNextElementSibling(node);
|
|
1190
1251
|
patchPreviousElementSibling(node);
|
|
@@ -1251,6 +1312,39 @@ const patchPreviousElementSibling = (element) => {
|
|
|
1251
1312
|
} });
|
|
1252
1313
|
};
|
|
1253
1314
|
/**
|
|
1315
|
+
* Detaches a slotted node from where it physically sits in the component's rendered DOM, through
|
|
1316
|
+
* the unpatched accessors. Not via `remove()`: mock-doc's `remove()` calls
|
|
1317
|
+
* `parentNode.removeChild()`, and a slotted node's patched `parentNode` is the host, whose patched
|
|
1318
|
+
* `removeChild()` would come straight back here.
|
|
1319
|
+
*
|
|
1320
|
+
* @param node the slotted node to detach
|
|
1321
|
+
*/
|
|
1322
|
+
const removeSlottedNode = (node) => {
|
|
1323
|
+
const parent = internalCall(node, "parentNode");
|
|
1324
|
+
if (parent) internalCall(parent, "removeChild")(node);
|
|
1325
|
+
};
|
|
1326
|
+
/**
|
|
1327
|
+
* Patches `remove()` on a node slotted into a non-shadow component, so that removing it fires
|
|
1328
|
+
* `slotchange` on its slot (and updates fallback content), as removing a node from a native slot
|
|
1329
|
+
* does. Stencil's own node moves, while `isTmpDisconnected` is set, don't fire it.
|
|
1330
|
+
*
|
|
1331
|
+
* @param node the slotted node to patch
|
|
1332
|
+
*/
|
|
1333
|
+
const patchSlottedRemove = (node) => {
|
|
1334
|
+
const child = node;
|
|
1335
|
+
if (!child || child.__remove || typeof child.remove !== "function") return;
|
|
1336
|
+
child.__remove = child.remove;
|
|
1337
|
+
child.remove = function() {
|
|
1338
|
+
const host = this["s-ol"]?.parentElement;
|
|
1339
|
+
const { slotNode } = findSlotFromSlottedNode(this);
|
|
1340
|
+
removeSlottedNode(this);
|
|
1341
|
+
if (slotNode && !(plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected)) {
|
|
1342
|
+
dispatchSlotChangeEvent(slotNode);
|
|
1343
|
+
updateFallbackSlotVisibility(host);
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
};
|
|
1347
|
+
/**
|
|
1254
1348
|
* Patches the `parentNode` accessor of a non-shadow slotted node
|
|
1255
1349
|
*
|
|
1256
1350
|
* @param node the slotted node to be patched
|
|
@@ -1521,13 +1615,15 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
1521
1615
|
const appliedStyles = getAppliedStyles(styleContainerNode);
|
|
1522
1616
|
let styleElm;
|
|
1523
1617
|
const existingStyleElm = (BUILD.hydrateClientSide || BUILD.hotModuleReplacement) && styleContainerNode.querySelector(`[sty-id="${scopeId}"]`);
|
|
1524
|
-
if (existingStyleElm)
|
|
1525
|
-
|
|
1618
|
+
if (existingStyleElm) {
|
|
1619
|
+
if (BUILD.hotModuleReplacement) existingStyleElm.textContent = style;
|
|
1620
|
+
appliedStyles.add(scopeId);
|
|
1621
|
+
} else if (!appliedStyles.has(scopeId)) {
|
|
1526
1622
|
styleElm = win.document.createElement("style");
|
|
1527
1623
|
styleElm.textContent = style;
|
|
1528
1624
|
const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
|
|
1529
1625
|
if (nonce != null) styleElm.setAttribute("nonce", nonce);
|
|
1530
|
-
if (BUILD.hydrateServerSide
|
|
1626
|
+
if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
|
|
1531
1627
|
if (BUILD.hotModuleReplacement && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.setAttribute("data-slot-fb", "");
|
|
1532
1628
|
/**
|
|
1533
1629
|
* attach styles at the end of the head tag if we render scoped components
|
|
@@ -1654,20 +1750,28 @@ const getScopeId = (cmp, mode) => "sc-" + (BUILD.mode && mode && cmp.$flags$ & C
|
|
|
1654
1750
|
*/
|
|
1655
1751
|
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^/]+)\*\/[^{]+\{/g, "$1{");
|
|
1656
1752
|
/**
|
|
1657
|
-
* Hydrate styles after SSR for components
|
|
1658
|
-
* and add them to a constructable stylesheet.
|
|
1753
|
+
* Hydrate styles after SSR for shadow components that were serialized as 'scoped' (not DSD).
|
|
1754
|
+
* Convert their 'scoped' styles back to 'shadow' and add them to a constructable stylesheet.
|
|
1659
1755
|
*
|
|
1660
|
-
*
|
|
1756
|
+
* Sheets of scoped and non-encapsulated components are left alone so they stay in the
|
|
1757
|
+
* document head, where `addStyle()` reuses them.
|
|
1758
|
+
*
|
|
1759
|
+
* @param cmpMetas the components whose server-rendered styles may need converting
|
|
1661
1760
|
*/
|
|
1662
|
-
const hydrateScopedToShadow = () => {
|
|
1761
|
+
const hydrateScopedToShadow = (cmpMetas) => {
|
|
1663
1762
|
if (!win.document) return;
|
|
1664
|
-
const
|
|
1763
|
+
const styleElms = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
1665
1764
|
let i = 0;
|
|
1666
|
-
for (; i <
|
|
1667
|
-
const scopeId =
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1765
|
+
for (; i < styleElms.length; i++) {
|
|
1766
|
+
const scopeId = styleElms[i].getAttribute(HYDRATED_STYLE_ID);
|
|
1767
|
+
if (cmpMetas.some((cmpMeta) => {
|
|
1768
|
+
const cmpScopeId = "sc-" + cmpMeta.$tagName$;
|
|
1769
|
+
return cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation && (scopeId === cmpScopeId || BUILD.mode && cmpMeta.$flags$ & CMP_FLAGS.hasMode && scopeId.startsWith(cmpScopeId + "-"));
|
|
1770
|
+
})) {
|
|
1771
|
+
const existing = styles.get(scopeId);
|
|
1772
|
+
const allowCS = existing !== void 0 ? existing instanceof CSSStyleSheet : true;
|
|
1773
|
+
registerStyle(scopeId, convertScopedToShadow(styleElms[i].innerHTML), allowCS);
|
|
1774
|
+
}
|
|
1671
1775
|
}
|
|
1672
1776
|
};
|
|
1673
1777
|
//#endregion
|
|
@@ -1691,6 +1795,13 @@ const isComplexType = (o) => {
|
|
|
1691
1795
|
return o === "object" || o === "function";
|
|
1692
1796
|
};
|
|
1693
1797
|
//#endregion
|
|
1798
|
+
//#region src/runtime/signals-core.ts
|
|
1799
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
1800
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
1801
|
+
function signal(value, options) {
|
|
1802
|
+
return getCore().signal(value, options);
|
|
1803
|
+
}
|
|
1804
|
+
//#endregion
|
|
1694
1805
|
//#region src/runtime/event-emitter.ts
|
|
1695
1806
|
const createEvent = (ref, name, flags) => {
|
|
1696
1807
|
const elm = getElement(ref);
|
|
@@ -1722,7 +1833,12 @@ let _registry;
|
|
|
1722
1833
|
const setRegistry = (registry) => {
|
|
1723
1834
|
_registry = registry;
|
|
1724
1835
|
};
|
|
1725
|
-
const getRegistry = () => _registry ?? customElements;
|
|
1836
|
+
const getRegistry = () => _registry ?? globalThis.customElements;
|
|
1837
|
+
/**
|
|
1838
|
+
* @param elm a defined component host
|
|
1839
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
1840
|
+
*/
|
|
1841
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
1726
1842
|
//#endregion
|
|
1727
1843
|
//#region src/runtime/vdom/set-accessor.ts
|
|
1728
1844
|
/**
|
|
@@ -1766,7 +1882,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1766
1882
|
attrMap.get(memberName)?.();
|
|
1767
1883
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
1768
1884
|
let prevVal = oldValue;
|
|
1769
|
-
attrMap.set(memberName, effect
|
|
1885
|
+
attrMap.set(memberName, effect(() => {
|
|
1770
1886
|
const curVal = newValue.value;
|
|
1771
1887
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
1772
1888
|
prevVal = curVal;
|
|
@@ -1846,10 +1962,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1846
1962
|
const isComplex = isComplexType(newValue);
|
|
1847
1963
|
if (!BUILD.lazyLoad) {
|
|
1848
1964
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1849
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1965
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1850
1966
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1851
1967
|
elm["s-pp"].set(memberName, newValue);
|
|
1852
|
-
return;
|
|
1968
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1853
1969
|
}
|
|
1854
1970
|
}
|
|
1855
1971
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -1876,7 +1992,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1876
1992
|
xlink = true;
|
|
1877
1993
|
}
|
|
1878
1994
|
}
|
|
1879
|
-
if (newValue == null || newValue === false) {
|
|
1995
|
+
if (newValue == null || newValue === false || isComplex) {
|
|
1880
1996
|
if (newValue !== false || elm.getAttribute(memberName) === "" || flags & VNODE_FLAGS.isHost && !isEnumeratedAttribute(memberName)) {
|
|
1881
1997
|
if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
|
|
1882
1998
|
else elm.removeAttribute(memberName);
|
|
@@ -1967,8 +2083,10 @@ function sortedAttrNames(attrNames) {
|
|
|
1967
2083
|
let scopeId;
|
|
1968
2084
|
let contentRef;
|
|
1969
2085
|
let hostTagName;
|
|
2086
|
+
let hostRegistry;
|
|
1970
2087
|
let useNativeShadowDom = false;
|
|
1971
2088
|
let checkSlotFallbackVisibility = false;
|
|
2089
|
+
/** Whether the current render has slotted content to relocate. Set at the start of each render. */
|
|
1972
2090
|
let checkSlotRelocate = false;
|
|
1973
2091
|
let isSvgMode = false;
|
|
1974
2092
|
/**
|
|
@@ -1976,6 +2094,7 @@ let isSvgMode = false;
|
|
|
1976
2094
|
* These ensure that ref callbacks are called in the correct order:
|
|
1977
2095
|
* first all removal callbacks (with null), then all attachment callbacks (with elements).
|
|
1978
2096
|
*/
|
|
2097
|
+
const initialSlotChanges = /* @__PURE__ */ new Set();
|
|
1979
2098
|
const refCallbacksToRemove = [];
|
|
1980
2099
|
const refCallbacksToAttach = [];
|
|
1981
2100
|
/** Disposers for signal subscriptions on individual DOM nodes (text nodes, <s-show> wrappers). */
|
|
@@ -1983,16 +2102,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
1983
2102
|
const disposeSignalVNode = (vnode) => {
|
|
1984
2103
|
const elm = vnode.$elm$;
|
|
1985
2104
|
if (elm) {
|
|
1986
|
-
|
|
1987
|
-
if (dispose) {
|
|
1988
|
-
dispose();
|
|
1989
|
-
signalNodeDisposers.delete(elm);
|
|
1990
|
-
}
|
|
2105
|
+
disposeTextSignal(elm);
|
|
1991
2106
|
disposeAllSignalAttrs(elm);
|
|
1992
2107
|
}
|
|
1993
2108
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
1994
2109
|
};
|
|
1995
2110
|
/**
|
|
2111
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
2112
|
+
* @param textNode the text node to unsubscribe
|
|
2113
|
+
*/
|
|
2114
|
+
const disposeTextSignal = (textNode) => {
|
|
2115
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
2116
|
+
if (dispose) {
|
|
2117
|
+
dispose();
|
|
2118
|
+
signalNodeDisposers.delete(textNode);
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
/**
|
|
2122
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
2123
|
+
* @param textNode the text node to keep in sync
|
|
2124
|
+
* @param textSig the signal to subscribe to
|
|
2125
|
+
*/
|
|
2126
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
2127
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
2128
|
+
textNode.data = String(textSig.value);
|
|
2129
|
+
}));
|
|
2130
|
+
};
|
|
2131
|
+
/**
|
|
1996
2132
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
1997
2133
|
*
|
|
1998
2134
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -2014,13 +2150,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2014
2150
|
if (BUILD.isDev && newVNode.$elm$) consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${String(newVNode.$tag$)}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
|
|
2015
2151
|
if (BUILD.vdomText && newVNode.$text$ != null) {
|
|
2016
2152
|
elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
|
|
2017
|
-
if (BUILD.vdomSignals && newVNode.$signal$)
|
|
2018
|
-
const textSig = newVNode.$signal$;
|
|
2019
|
-
const textNode = elm;
|
|
2020
|
-
signalNodeDisposers.set(textNode, effect$1(() => {
|
|
2021
|
-
textNode.data = String(textSig.value);
|
|
2022
|
-
}));
|
|
2023
|
-
}
|
|
2153
|
+
if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
2024
2154
|
} else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
2025
2155
|
elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
2026
2156
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -2029,8 +2159,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2029
2159
|
if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
2030
2160
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
2031
2161
|
const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
2032
|
-
const
|
|
2033
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
2162
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
2034
2163
|
elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
2035
2164
|
if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
2036
2165
|
if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -2288,7 +2417,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2288
2417
|
}
|
|
2289
2418
|
if (BUILD.vdomKey && idxInOld >= 0) {
|
|
2290
2419
|
elmToMove = oldCh[idxInOld];
|
|
2291
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
2420
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2292
2421
|
else {
|
|
2293
2422
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
2294
2423
|
oldCh[idxInOld] = void 0;
|
|
@@ -2381,7 +2510,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2381
2510
|
else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
2382
2511
|
if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
2383
2512
|
} else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
2384
|
-
else if (BUILD.vdomText
|
|
2513
|
+
else if (BUILD.vdomText) {
|
|
2514
|
+
if (BUILD.vdomSignals && newVNode.$signal$) {
|
|
2515
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2516
|
+
disposeTextSignal(elm);
|
|
2517
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2518
|
+
}
|
|
2519
|
+
} else {
|
|
2520
|
+
if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2521
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2385
2524
|
};
|
|
2386
2525
|
/**
|
|
2387
2526
|
* Component-global information about nodes which are either currently being
|
|
@@ -2507,13 +2646,17 @@ const flushQueuedRefCallbacks = () => {
|
|
|
2507
2646
|
*/
|
|
2508
2647
|
const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
2509
2648
|
if (BUILD.slotRelocation) {
|
|
2649
|
+
if (parent?.["s-cr"]) checkSlotRelocate = true;
|
|
2510
2650
|
if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
|
|
2511
2651
|
else if (typeof newNode["s-sn"] === "string") {
|
|
2512
2652
|
const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
|
|
2513
|
-
if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE)
|
|
2653
|
+
if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE) patchSlottedNode(newNode);
|
|
2514
2654
|
parent.insertBefore(newNode, reference);
|
|
2515
2655
|
const { slotNode } = findSlotFromSlottedNode(newNode);
|
|
2516
|
-
if (slotNode
|
|
2656
|
+
if (slotNode) {
|
|
2657
|
+
if (isInitialLoad) initialSlotChanges.add(slotNode);
|
|
2658
|
+
else dispatchSlotChangeEvent(slotNode);
|
|
2659
|
+
}
|
|
2517
2660
|
return newNode;
|
|
2518
2661
|
}
|
|
2519
2662
|
}
|
|
@@ -2569,6 +2712,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2569
2712
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2570
2713
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2571
2714
|
hostTagName = hostElm.tagName;
|
|
2715
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2572
2716
|
if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2573
2717
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2574
2718
|
|
|
@@ -2605,6 +2749,7 @@ render() {
|
|
|
2605
2749
|
if (BUILD.slotRelocation) {
|
|
2606
2750
|
contentRef = hostElm["s-cr"];
|
|
2607
2751
|
checkSlotFallbackVisibility = false;
|
|
2752
|
+
checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
|
|
2608
2753
|
}
|
|
2609
2754
|
patch(oldVNode, rootVnode, isInitialLoad);
|
|
2610
2755
|
if (BUILD.slotRelocation) {
|
|
@@ -2668,8 +2813,13 @@ render() {
|
|
|
2668
2813
|
if (checkSlotFallbackVisibility) updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
2669
2814
|
plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
|
|
2670
2815
|
relocateNodes.length = 0;
|
|
2816
|
+
if (initialSlotChanges.size) {
|
|
2817
|
+
const slotNodes = [...initialSlotChanges];
|
|
2818
|
+
initialSlotChanges.clear();
|
|
2819
|
+
nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
|
|
2820
|
+
}
|
|
2671
2821
|
}
|
|
2672
|
-
if (BUILD.slotRelocation && !
|
|
2822
|
+
if (BUILD.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
|
|
2673
2823
|
const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
|
|
2674
2824
|
for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
|
|
2675
2825
|
if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
|
|
@@ -2721,11 +2871,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
2721
2871
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
2722
2872
|
*
|
|
2723
2873
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2874
|
+
* @param registry the registry the waiting component is defined in
|
|
2724
2875
|
*/
|
|
2725
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2876
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
2726
2877
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2727
2878
|
if (!BUILD.lazyLoad && !ancestorHostRef) {
|
|
2728
|
-
await
|
|
2879
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2729
2880
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
2730
2881
|
}
|
|
2731
2882
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -3081,8 +3232,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3081
3232
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3082
3233
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
3083
3234
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
3084
|
-
const
|
|
3085
|
-
const sig = signal(initialVal);
|
|
3235
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
3086
3236
|
hostRef.$signalValues$.set(memberName, sig);
|
|
3087
3237
|
let prevScheduleVal = sig.peek();
|
|
3088
3238
|
disposers.push(effect(() => {
|
|
@@ -3210,9 +3360,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3210
3360
|
if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
3211
3361
|
}
|
|
3212
3362
|
}
|
|
3213
|
-
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component
|
|
3214
|
-
- You are NOT using hostData() and <Host> in the same component.
|
|
3215
|
-
- <Host> is used once, and it's the single root component of the render() function.`);
|
|
3363
|
+
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
|
|
3216
3364
|
if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
3217
3365
|
const vnode = newVNode(nodeName, null);
|
|
3218
3366
|
vnode.$attrs$ = vnodeData;
|
|
@@ -3265,17 +3413,23 @@ const vdomFnUtils = {
|
|
|
3265
3413
|
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
3266
3414
|
* friendlier public interface (hence, 'convertToPublic').
|
|
3267
3415
|
*
|
|
3268
|
-
*
|
|
3416
|
+
* Functional components receive primitive children unwrapped, so those
|
|
3417
|
+
* become text-only child nodes.
|
|
3418
|
+
*
|
|
3419
|
+
* @param node the virtual DOM node (or primitive child) to convert
|
|
3269
3420
|
* @returns a converted child node
|
|
3270
3421
|
*/
|
|
3271
|
-
const convertToPublic = (node) =>
|
|
3422
|
+
const convertToPublic = (node) => typeof node !== "object" ? {
|
|
3423
|
+
vtag: null,
|
|
3424
|
+
vtext: String(node)
|
|
3425
|
+
} : {
|
|
3272
3426
|
vattrs: node.$attrs$,
|
|
3273
3427
|
vchildren: node.$children$,
|
|
3274
3428
|
vkey: node.$key$,
|
|
3275
3429
|
vname: node.$name$,
|
|
3276
3430
|
vtag: node.$tag$,
|
|
3277
3431
|
vtext: node.$text$
|
|
3278
|
-
}
|
|
3432
|
+
};
|
|
3279
3433
|
/**
|
|
3280
3434
|
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
3281
3435
|
* order to use the resulting object in the virtual DOM. The initial object was
|
|
@@ -3292,11 +3446,11 @@ const convertToPrivate = (node) => {
|
|
|
3292
3446
|
if (node.vname) vnodeData.name = node.vname;
|
|
3293
3447
|
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
3294
3448
|
}
|
|
3295
|
-
const vnode = newVNode(node.vtag, node.vtext);
|
|
3296
|
-
vnode.$attrs$ = node.vattrs;
|
|
3297
|
-
vnode.$children$ = node.vchildren;
|
|
3298
|
-
vnode.$key$ = node.vkey;
|
|
3299
|
-
vnode.$name$ = node.vname;
|
|
3449
|
+
const vnode = newVNode(node.vtag ?? null, node.vtext);
|
|
3450
|
+
vnode.$attrs$ = node.vattrs ?? null;
|
|
3451
|
+
vnode.$children$ = node.vchildren ?? null;
|
|
3452
|
+
vnode.$key$ = node.vkey ?? null;
|
|
3453
|
+
vnode.$name$ = node.vname ?? null;
|
|
3300
3454
|
return vnode;
|
|
3301
3455
|
};
|
|
3302
3456
|
/**
|
|
@@ -3346,7 +3500,10 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3346
3500
|
hostElm.classList.add(scopeId + "-h");
|
|
3347
3501
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
3348
3502
|
}
|
|
3349
|
-
if (win.document &&
|
|
3503
|
+
if (win.document && !plt.$orgLocNodes$?.has(hostId)) {
|
|
3504
|
+
initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ ??= /* @__PURE__ */ new Map());
|
|
3505
|
+
plt.$orgLocNodes$.set(hostId, hostElm);
|
|
3506
|
+
}
|
|
3350
3507
|
hostElm[HYDRATE_ID] = hostId;
|
|
3351
3508
|
hostElm.removeAttribute(HYDRATE_ID);
|
|
3352
3509
|
hostRef.$vnode$ = clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId, slottedNodes);
|
|
@@ -3359,7 +3516,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3359
3516
|
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
3360
3517
|
const node = childRenderNode.$elm$;
|
|
3361
3518
|
if (!shadowRoot) {
|
|
3362
|
-
node["s-hn"] = transformTag(tagName).toUpperCase();
|
|
3519
|
+
if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
|
|
3363
3520
|
if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
|
|
3364
3521
|
} else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
|
|
3365
3522
|
const cmpMeta = getHostRef(childRenderNode.$elm$);
|
|
@@ -3409,14 +3566,10 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3409
3566
|
const siSlot = slottedItem.slot;
|
|
3410
3567
|
if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
|
|
3411
3568
|
if (!hostEle.shadowRoot || !shadowRoot) {
|
|
3412
|
-
if (!siSlot["s-cr"])
|
|
3413
|
-
siSlot["s-cr"] = hostEle["s-cr"];
|
|
3414
|
-
if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
|
|
3415
|
-
else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
|
|
3416
|
-
}
|
|
3569
|
+
if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
|
|
3417
3570
|
addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
|
|
3418
3571
|
if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
|
|
3419
|
-
if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)
|
|
3572
|
+
if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
|
|
3420
3573
|
}
|
|
3421
3574
|
currentPos = (siNode["s-oo"] || currentPos) + 1;
|
|
3422
3575
|
}
|
|
@@ -3476,7 +3629,7 @@ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes
|
|
|
3476
3629
|
const scopeId = hostElm["s-sc"];
|
|
3477
3630
|
if (node.nodeType === NODE_TYPE.ElementNode) {
|
|
3478
3631
|
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
3479
|
-
if (childNodeType) {
|
|
3632
|
+
if (childNodeType && node !== hostElm) {
|
|
3480
3633
|
childIdSplt = childNodeType.split(".");
|
|
3481
3634
|
if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
|
|
3482
3635
|
childVNode = createSimpleVNode({
|
|
@@ -3594,6 +3747,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
|
3594
3747
|
const createSimpleVNode = (vnode) => ({
|
|
3595
3748
|
$flags$: 0,
|
|
3596
3749
|
$index$: "0",
|
|
3750
|
+
$children$: null,
|
|
3597
3751
|
...vnode
|
|
3598
3752
|
});
|
|
3599
3753
|
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
|
|
@@ -3657,6 +3811,11 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
3657
3811
|
* @returns the first corresponding node of the type
|
|
3658
3812
|
*/
|
|
3659
3813
|
const findCorrespondingNode = (node, type) => {
|
|
3814
|
+
if (type === NODE_TYPE.TextNode) {
|
|
3815
|
+
const next = node.nextSibling;
|
|
3816
|
+
if (next?.nodeType === NODE_TYPE.TextNode) return next;
|
|
3817
|
+
return node.parentNode.insertBefore(node.ownerDocument.createTextNode(""), next);
|
|
3818
|
+
}
|
|
3660
3819
|
let sibling = node;
|
|
3661
3820
|
do
|
|
3662
3821
|
sibling = sibling.nextSibling;
|
|
@@ -3988,7 +4147,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
3988
4147
|
else return shallowPart.trim();
|
|
3989
4148
|
}).join(", ");
|
|
3990
4149
|
};
|
|
3991
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
4150
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
3992
4151
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
3993
4152
|
return processRules(cssText, (rule) => {
|
|
3994
4153
|
let selector = rule.selector;
|
|
@@ -4107,8 +4266,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4107
4266
|
};
|
|
4108
4267
|
//#endregion
|
|
4109
4268
|
//#region src/runtime/mode.ts
|
|
4110
|
-
const computeMode = (elm) =>
|
|
4111
|
-
const setMode = (handler) =>
|
|
4269
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4270
|
+
const setMode = (handler) => {
|
|
4271
|
+
modeResolver.length = 0;
|
|
4272
|
+
modeResolver.push(handler);
|
|
4273
|
+
};
|
|
4112
4274
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
4113
4275
|
//#endregion
|
|
4114
4276
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4173,23 +4335,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4173
4335
|
*
|
|
4174
4336
|
* @param propValue the new value to coerce to some type
|
|
4175
4337
|
* @param propType the type of the prop, expressed as a binary number
|
|
4176
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4177
4338
|
* @returns the parsed/coerced value
|
|
4178
4339
|
*/
|
|
4179
|
-
const parsePropertyValue = (propValue, propType
|
|
4340
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4180
4341
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4181
4342
|
/**
|
|
4182
4343
|
* ensure this value is of the correct prop type
|
|
4183
4344
|
*/
|
|
4184
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4185
|
-
/**
|
|
4186
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4187
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4188
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4189
|
-
*/
|
|
4190
|
-
if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4191
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4192
|
-
}
|
|
4345
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4193
4346
|
/**
|
|
4194
4347
|
* force it to be a number
|
|
4195
4348
|
*/
|
|
@@ -4231,7 +4384,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4231
4384
|
if (BUILD.signalBacking) {
|
|
4232
4385
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4233
4386
|
if (sig !== void 0) {
|
|
4234
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4387
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4235
4388
|
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4236
4389
|
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4237
4390
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4249,7 +4402,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4249
4402
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4250
4403
|
const flags = hostRef.$flags$;
|
|
4251
4404
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4252
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4405
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4253
4406
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4254
4407
|
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4255
4408
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4298,6 +4451,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4298
4451
|
*/
|
|
4299
4452
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4300
4453
|
/**
|
|
4454
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4455
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4456
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4457
|
+
*
|
|
4458
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4459
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4460
|
+
*/
|
|
4461
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4462
|
+
const instance = hostRef.$lazyInstance$;
|
|
4463
|
+
if (!instance) return;
|
|
4464
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4465
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4466
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4467
|
+
}
|
|
4468
|
+
};
|
|
4469
|
+
/**
|
|
4301
4470
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4302
4471
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4303
4472
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4354,9 +4523,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4354
4523
|
if (BUILD.lazyLoad) {
|
|
4355
4524
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4356
4525
|
const ref = getHostRef(this);
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
return instance[memberName];
|
|
4526
|
+
if (!ref) return prototype[memberName];
|
|
4527
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4360
4528
|
}
|
|
4361
4529
|
if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4362
4530
|
},
|
|
@@ -4371,7 +4539,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4371
4539
|
}
|
|
4372
4540
|
if (origSetter) {
|
|
4373
4541
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4374
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4542
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4375
4543
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4376
4544
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4377
4545
|
return;
|
|
@@ -4383,21 +4551,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4383
4551
|
if (BUILD.lazyLoad) {
|
|
4384
4552
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4385
4553
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4386
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4387
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4388
|
-
});
|
|
4389
4554
|
return;
|
|
4390
4555
|
}
|
|
4391
|
-
const
|
|
4556
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4557
|
+
if (ref.$lazyInstance$) {
|
|
4392
4558
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4393
4559
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4394
|
-
ref.$lazyInstance$[memberName] =
|
|
4560
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4395
4561
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4396
|
-
};
|
|
4397
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4398
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4399
|
-
setterSetVal();
|
|
4400
|
-
});
|
|
4562
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4401
4563
|
}
|
|
4402
4564
|
} });
|
|
4403
4565
|
} else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4439,7 +4601,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4439
4601
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4440
4602
|
(cmpMeta.$watchers$?.[attrName])?.forEach((watcher) => {
|
|
4441
4603
|
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4442
|
-
if (instance[watchMethodName] != null && (hostFlags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate)) instance[watchMethodName](newValue, oldValue, attrName);
|
|
4604
|
+
if (instance?.[watchMethodName] != null && (hostFlags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate)) instance[watchMethodName](newValue, oldValue, attrName);
|
|
4443
4605
|
});
|
|
4444
4606
|
}
|
|
4445
4607
|
return;
|
|
@@ -4449,9 +4611,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4449
4611
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4450
4612
|
if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4451
4613
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4452
|
-
if (isBooleanTarget)
|
|
4614
|
+
if (isBooleanTarget) {
|
|
4615
|
+
if (BUILD.isDev && newValue === "false") consoleDevWarn(`<${cmpMeta.$tagName$} ${attrName}="false">: boolean attributes are true when present, regardless of value. Remove the attribute or set the "${propName}" property to false instead.`);
|
|
4616
|
+
newValue = newValue !== null;
|
|
4617
|
+
}
|
|
4453
4618
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4454
|
-
|
|
4619
|
+
const isUnchanged = newValue === this[propName] || newValue == null && this[propName] == null;
|
|
4620
|
+
if (!isSpuriousBooleanRemoval && !isUnchanged && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4455
4621
|
});
|
|
4456
4622
|
};
|
|
4457
4623
|
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
@@ -4512,9 +4678,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4512
4678
|
} catch (e) {
|
|
4513
4679
|
consoleError(e, elm);
|
|
4514
4680
|
}
|
|
4515
|
-
if (BUILD.member)
|
|
4681
|
+
if (BUILD.member) {
|
|
4682
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4683
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4684
|
+
}
|
|
4516
4685
|
endNewInstance();
|
|
4517
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4686
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4518
4687
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4519
4688
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4520
4689
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4614,9 +4783,16 @@ const connectedCallback = (elm) => {
|
|
|
4614
4783
|
}
|
|
4615
4784
|
if (BUILD.asyncLoading) {
|
|
4616
4785
|
let ancestorComponent = elm;
|
|
4617
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4618
|
-
|
|
4619
|
-
|
|
4786
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
4787
|
+
if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
4788
|
+
ancestorComponent["s-p"] = [];
|
|
4789
|
+
ancestorComponent["s-rc"] = [];
|
|
4790
|
+
ancestorComponent["s-pc"] = [];
|
|
4791
|
+
}
|
|
4792
|
+
if (ancestorComponent["s-p"]) {
|
|
4793
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
4794
|
+
break;
|
|
4795
|
+
}
|
|
4620
4796
|
}
|
|
4621
4797
|
}
|
|
4622
4798
|
if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -4732,48 +4908,112 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4732
4908
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4733
4909
|
);
|
|
4734
4910
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4735
|
-
if (
|
|
4736
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4737
|
-
if (ctor) {
|
|
4738
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4739
|
-
if (key === "constructor") continue;
|
|
4740
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4741
|
-
}
|
|
4742
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4743
|
-
if (styleDesc) {
|
|
4744
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
4745
|
-
const newStyle = NewClass.style;
|
|
4746
|
-
if (newStyle) {
|
|
4747
|
-
const scopeId = getScopeId(cmpMeta);
|
|
4748
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4749
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
4750
|
-
tag: cmpMeta.$tagName$,
|
|
4751
|
-
scopeId,
|
|
4752
|
-
isShadow,
|
|
4753
|
-
cssLen: newStyle.length
|
|
4754
|
-
});
|
|
4755
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
4756
|
-
}
|
|
4757
|
-
}
|
|
4758
|
-
}
|
|
4759
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4760
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4761
|
-
const hostRef = getHostRef(el);
|
|
4762
|
-
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4763
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4764
|
-
hostRef.$rmListeners$ = void 0;
|
|
4765
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4766
|
-
}
|
|
4767
|
-
if (!isShadow && hostRef) {
|
|
4768
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4769
|
-
attachStyles(hostRef);
|
|
4770
|
-
}
|
|
4771
|
-
forceUpdate(el);
|
|
4772
|
-
});
|
|
4911
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4773
4912
|
} catch (e) {
|
|
4774
4913
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4775
4914
|
}
|
|
4776
4915
|
};
|
|
4916
|
+
/**
|
|
4917
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4918
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4919
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4920
|
+
*
|
|
4921
|
+
* @param cmpMeta runtime metadata for the component
|
|
4922
|
+
* @param NewClass the component's newly executed class
|
|
4923
|
+
*/
|
|
4924
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4925
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4926
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4927
|
+
if (ctor && ctor !== NewClass) {
|
|
4928
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4929
|
+
if (key === "constructor") continue;
|
|
4930
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4931
|
+
}
|
|
4932
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4933
|
+
if (styleDesc) {
|
|
4934
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4935
|
+
const newStyle = NewClass.style;
|
|
4936
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4940
|
+
const hostRef = getHostRef(el);
|
|
4941
|
+
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4942
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4943
|
+
hostRef.$rmListeners$ = void 0;
|
|
4944
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4945
|
+
}
|
|
4946
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4947
|
+
forceUpdate(el);
|
|
4948
|
+
});
|
|
4949
|
+
};
|
|
4950
|
+
//#endregion
|
|
4951
|
+
//#region src/runtime/parse-gate.ts
|
|
4952
|
+
/**
|
|
4953
|
+
* SSR hosts connected while the HTML parser is still inside them (streamed documents),
|
|
4954
|
+
* in connection order - which is document order. Each is held until its subtree is
|
|
4955
|
+
* parsed so hydration sees its declarative shadow root and children.
|
|
4956
|
+
*/
|
|
4957
|
+
const pending = /* @__PURE__ */ new Set();
|
|
4958
|
+
let observer;
|
|
4959
|
+
const parentOf = (node) => node.parentNode ?? (node.nodeType === NODE_TYPE.DocumentFragment ? node.host : null);
|
|
4960
|
+
/**
|
|
4961
|
+
* The parser has finished with `elm` once it, or any ancestor, has a following sibling.
|
|
4962
|
+
* @param elm the element to check
|
|
4963
|
+
* @returns whether the element's subtree is fully parsed
|
|
4964
|
+
*/
|
|
4965
|
+
const isParsed = (elm) => {
|
|
4966
|
+
if (win.document.readyState !== "loading") return true;
|
|
4967
|
+
for (let n = elm; n; n = parentOf(n)) if (n.nextSibling) return true;
|
|
4968
|
+
return false;
|
|
4969
|
+
};
|
|
4970
|
+
const hasPendingAncestor = (elm) => {
|
|
4971
|
+
for (let n = parentOf(elm); n; n = parentOf(n)) if (pending.has(n)) return true;
|
|
4972
|
+
return false;
|
|
4973
|
+
};
|
|
4974
|
+
const flush = () => {
|
|
4975
|
+
for (const elm of pending) if (!elm.isConnected) pending.delete(elm);
|
|
4976
|
+
else if (isParsed(elm)) elm.__attachShadow?.();
|
|
4977
|
+
for (const elm of pending) if (isParsed(elm) && !hasPendingAncestor(elm)) {
|
|
4978
|
+
pending.delete(elm);
|
|
4979
|
+
elm.connectedCallback?.();
|
|
4980
|
+
}
|
|
4981
|
+
if (!pending.size) {
|
|
4982
|
+
observer?.disconnect();
|
|
4983
|
+
observer = void 0;
|
|
4984
|
+
}
|
|
4985
|
+
};
|
|
4986
|
+
/**
|
|
4987
|
+
* Whether the parser may still be adding children (including a declarative shadow root)
|
|
4988
|
+
* to `elm`: it was just created by the parser, or it's an SSR host the parser is still inside.
|
|
4989
|
+
* @param elm the host element
|
|
4990
|
+
* @returns `true` if the element's subtree may be incomplete
|
|
4991
|
+
*/
|
|
4992
|
+
const mayStillBeParsing = (elm) => win.document?.readyState === "loading" && (!elm.parentNode || elm.hasAttribute("s-id") && !isParsed(elm));
|
|
4993
|
+
/**
|
|
4994
|
+
* Holds back `elm`'s `connectedCallback` while it's an SSR host the parser hasn't finished
|
|
4995
|
+
* with, or one nested inside such a host. Its shadow root is attached once its own subtree
|
|
4996
|
+
* is parsed; `connectedCallback` is re-called once no ancestor host is still held.
|
|
4997
|
+
* @param elm the host element being connected
|
|
4998
|
+
* @returns `true` if processing was deferred
|
|
4999
|
+
*/
|
|
5000
|
+
const deferUntilParsed = (elm) => {
|
|
5001
|
+
if (pending.has(elm)) return true;
|
|
5002
|
+
if (!win.document || !elm.hasAttribute("s-id")) return false;
|
|
5003
|
+
const parsed = isParsed(elm);
|
|
5004
|
+
if (parsed && !hasPendingAncestor(elm)) return false;
|
|
5005
|
+
if (parsed) elm.__attachShadow?.();
|
|
5006
|
+
pending.add(elm);
|
|
5007
|
+
if (!observer) {
|
|
5008
|
+
observer = new MutationObserver(flush);
|
|
5009
|
+
observer.observe(win.document, {
|
|
5010
|
+
childList: true,
|
|
5011
|
+
subtree: true
|
|
5012
|
+
});
|
|
5013
|
+
win.document.addEventListener("DOMContentLoaded", flush, { once: true });
|
|
5014
|
+
}
|
|
5015
|
+
return true;
|
|
5016
|
+
};
|
|
4777
5017
|
//#endregion
|
|
4778
5018
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4779
5019
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4796,9 +5036,13 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4796
5036
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4797
5037
|
}
|
|
4798
5038
|
if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4799
|
-
if (BUILD.
|
|
4800
|
-
|
|
4801
|
-
|
|
5039
|
+
if (BUILD.shadowReferenceTarget) cmpMeta.$referenceTarget$ = compactMeta[7];
|
|
5040
|
+
if (BUILD.hotModuleReplacement) {
|
|
5041
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
5042
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
5043
|
+
};
|
|
5044
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
5045
|
+
}
|
|
4802
5046
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4803
5047
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4804
5048
|
if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
@@ -4811,11 +5055,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4811
5055
|
patchSlotInsertAdjacentHTML(Cstr.prototype);
|
|
4812
5056
|
patchInsertBefore(Cstr.prototype);
|
|
4813
5057
|
patchSlotRemoveChild(Cstr.prototype);
|
|
5058
|
+
patchInnerContentSetters(Cstr.prototype);
|
|
4814
5059
|
}
|
|
4815
5060
|
if (BUILD.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4816
5061
|
}
|
|
4817
5062
|
}
|
|
4818
|
-
if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow();
|
|
5063
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow([cmpMeta]);
|
|
4819
5064
|
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
4820
5065
|
const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
|
|
4821
5066
|
Object.assign(Cstr.prototype, {
|
|
@@ -4827,6 +5072,8 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4827
5072
|
return getHostRef(this)?.$onReadyPromise$;
|
|
4828
5073
|
},
|
|
4829
5074
|
async connectedCallback() {
|
|
5075
|
+
if (BUILD.hydrateClientSide && deferUntilParsed(this)) return;
|
|
5076
|
+
if (BUILD.shadowDom) this.__attachShadow();
|
|
4830
5077
|
const isFirstConnect = !this.__hasHostListenerAttached;
|
|
4831
5078
|
let hostRef;
|
|
4832
5079
|
if (isFirstConnect) {
|
|
@@ -4837,7 +5084,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4837
5084
|
}
|
|
4838
5085
|
connectedCallback(this);
|
|
4839
5086
|
if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4840
|
-
await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
5087
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
4841
5088
|
if (!this.isConnected) return;
|
|
4842
5089
|
}
|
|
4843
5090
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
@@ -4848,11 +5095,10 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4848
5095
|
if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
|
|
4849
5096
|
},
|
|
4850
5097
|
__attachShadow() {
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
if (BUILD.shadowModeClosed && isClosed) existingRoot = this.__shadowRoot ?? null;
|
|
5098
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) || BUILD.hydrateClientSide && mayStillBeParsing(this)) return;
|
|
5099
|
+
const existingRoot = getShadowRoot(this);
|
|
4854
5100
|
if (!existingRoot) createShadowRoot.call(this, cmpMeta);
|
|
4855
|
-
else if (BUILD.isDev && BUILD.shadowModeClosed &&
|
|
5101
|
+
else if (BUILD.isDev && BUILD.shadowModeClosed && cmpMeta.$flags$ & CMP_FLAGS.shadowModeClosed && existingRoot.mode !== "closed") throw new Error(`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${existingRoot.mode} but expected closed.`);
|
|
4856
5102
|
}
|
|
4857
5103
|
});
|
|
4858
5104
|
Object.defineProperty(Cstr, "is", {
|
|
@@ -4907,7 +5153,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4907
5153
|
Object.assign(plt, options);
|
|
4908
5154
|
if (BUILD.asyncQueue && options.syncQueue) plt.$flags$ |= PLATFORM_FLAGS.queueSync;
|
|
4909
5155
|
if (BUILD.hydrateClientSide) plt.$flags$ |= PLATFORM_FLAGS.appLoaded;
|
|
4910
|
-
if (BUILD.hydrateClientSide && BUILD.shadowDom)
|
|
5156
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) {
|
|
5157
|
+
const cmpMetas = [];
|
|
5158
|
+
lazyBundles.map((lazyBundle) => lazyBundle[1].map(([$flags$, $tagName$]) => cmpMetas.push({
|
|
5159
|
+
$flags$,
|
|
5160
|
+
$tagName$
|
|
5161
|
+
})));
|
|
5162
|
+
hydrateScopedToShadow(cmpMetas);
|
|
5163
|
+
}
|
|
4911
5164
|
lazyBundles.map((lazyBundle) => {
|
|
4912
5165
|
lazyBundle[1].map((compactMeta) => {
|
|
4913
5166
|
const cmpMeta = {
|
|
@@ -4924,7 +5177,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4924
5177
|
cmpMeta.$serializers$ = compactMeta[5] ?? {};
|
|
4925
5178
|
cmpMeta.$deserializers$ = compactMeta[6] ?? {};
|
|
4926
5179
|
}
|
|
5180
|
+
if (BUILD.shadowReferenceTarget) cmpMeta.$referenceTarget$ = compactMeta[7];
|
|
4927
5181
|
const tagName = transformTag(cmpMeta.$tagName$);
|
|
5182
|
+
const attachShadowRoot = (elm) => {
|
|
5183
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) && !getShadowRoot(elm)) createShadowRoot.call(elm, cmpMeta);
|
|
5184
|
+
};
|
|
4928
5185
|
const HostElement = class extends HTMLElement {
|
|
4929
5186
|
["s-p"];
|
|
4930
5187
|
["s-rc"];
|
|
@@ -4933,14 +5190,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4933
5190
|
super(self);
|
|
4934
5191
|
self = this;
|
|
4935
5192
|
registerHost(self, cmpMeta);
|
|
4936
|
-
if (BUILD.shadowDom &&
|
|
4937
|
-
if (!self.shadowRoot) createShadowRoot.call(self, cmpMeta);
|
|
4938
|
-
else if (BUILD.isDev && self.shadowRoot.mode !== "open") throw new Error(`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${self.shadowRoot.mode} but DSD shadow roots must use open mode.`);
|
|
4939
|
-
}
|
|
5193
|
+
if (BUILD.shadowDom && !(BUILD.hydrateClientSide && mayStillBeParsing(self))) attachShadowRoot(self);
|
|
4940
5194
|
}
|
|
4941
5195
|
connectedCallback() {
|
|
4942
5196
|
const hostRef = getHostRef(this);
|
|
4943
5197
|
if (!hostRef) return;
|
|
5198
|
+
if (BUILD.hydrateClientSide && deferUntilParsed(this)) return;
|
|
5199
|
+
if (BUILD.shadowDom) attachShadowRoot(this);
|
|
4944
5200
|
/**
|
|
4945
5201
|
* The `connectedCallback` lifecycle event can potentially be fired multiple times
|
|
4946
5202
|
* if the element is removed from the DOM and re-inserted. This is not a common use case,
|
|
@@ -4996,10 +5252,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4996
5252
|
patchSlotInsertAdjacentHTML(HostElement.prototype);
|
|
4997
5253
|
patchInsertBefore(HostElement.prototype);
|
|
4998
5254
|
patchSlotRemoveChild(HostElement.prototype);
|
|
5255
|
+
patchInnerContentSetters(HostElement.prototype);
|
|
4999
5256
|
}
|
|
5000
5257
|
if (BUILD.slotTextContent) patchTextContent(HostElement.prototype);
|
|
5001
5258
|
}
|
|
5002
5259
|
}
|
|
5260
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) HostElement.prototype.__attachShadow = function() {
|
|
5261
|
+
attachShadowRoot(this);
|
|
5262
|
+
};
|
|
5003
5263
|
if (BUILD.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
|
|
5004
5264
|
if (BUILD.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
|
|
5005
5265
|
hmrStart(this, cmpMeta, hmrVersionId);
|
|
@@ -5152,7 +5412,7 @@ function Mixin(...mixins) {
|
|
|
5152
5412
|
//#region src/runtime/nonce.ts
|
|
5153
5413
|
/**
|
|
5154
5414
|
* Assigns the given value to the nonce property on the runtime platform object.
|
|
5155
|
-
* During runtime, this value is used to set the nonce attribute on all dynamically created
|
|
5415
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
|
|
5156
5416
|
* @param nonce The value to be assigned to the platform nonce property.
|
|
5157
5417
|
* @returns void
|
|
5158
5418
|
*/
|
|
@@ -5314,4 +5574,4 @@ function hasKeys(obj) {
|
|
|
5314
5574
|
return false;
|
|
5315
5575
|
}
|
|
5316
5576
|
//#endregion
|
|
5317
|
-
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule,
|
|
5577
|
+
export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, ReactiveControllerHost, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, applySerializers, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, isMemberInElement, jsx, jsxDEV, jsxs, loadModule, modeResolver, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, registerSideEffectStyleTarget, render, resolveVar, setAssetPath, setErrorHandler, setLazyLoadBasePath, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setRegistry, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, transformTag, unregisterSideEffectStyleTarget, win, writeTask };
|