@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
package/dist/runtime/index.js
CHANGED
|
@@ -1,12 +1,89 @@
|
|
|
1
1
|
import { BUILD } from "../app-data/index.js";
|
|
2
2
|
import "../app-globals/index.js";
|
|
3
|
-
import
|
|
3
|
+
import * as SignalsCore from "@preact/signals-core";
|
|
4
|
+
//#region src/runtime/runtime-constants.ts
|
|
5
|
+
/**
|
|
6
|
+
* Bit flags for recording various properties of VDom nodes
|
|
7
|
+
*/
|
|
8
|
+
const VNODE_FLAGS = {
|
|
9
|
+
/**
|
|
10
|
+
* Whether or not a vdom node is a slot reference
|
|
11
|
+
*/
|
|
12
|
+
isSlotReference: 1,
|
|
13
|
+
/**
|
|
14
|
+
* Whether or not a slot element has fallback content
|
|
15
|
+
*/
|
|
16
|
+
isSlotFallback: 2,
|
|
17
|
+
/**
|
|
18
|
+
* Whether or not an element is a host element
|
|
19
|
+
*/
|
|
20
|
+
isHost: 4
|
|
21
|
+
};
|
|
22
|
+
const PROXY_FLAGS = {
|
|
23
|
+
isElementConstructor: 1,
|
|
24
|
+
proxyState: 2
|
|
25
|
+
};
|
|
26
|
+
const PLATFORM_FLAGS = {
|
|
27
|
+
/**
|
|
28
|
+
* designates a node in the DOM as being actively moved by the runtime
|
|
29
|
+
*/
|
|
30
|
+
isTmpDisconnected: 1,
|
|
31
|
+
appLoaded: 2,
|
|
32
|
+
queueSync: 4,
|
|
33
|
+
queueMask: 6
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
37
|
+
* values are based on the values which can possibly be returned by the
|
|
38
|
+
* `.nodeType` property of a DOM node. See here for details:
|
|
39
|
+
*
|
|
40
|
+
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
41
|
+
*/
|
|
42
|
+
const NODE_TYPE = {
|
|
43
|
+
ElementNode: 1,
|
|
44
|
+
TextNode: 3,
|
|
45
|
+
CommentNode: 8,
|
|
46
|
+
DocumentNode: 9,
|
|
47
|
+
DocumentTypeNode: 10,
|
|
48
|
+
DocumentFragment: 11
|
|
49
|
+
};
|
|
50
|
+
const HYDRATE_ID = "s-id";
|
|
51
|
+
const HYDRATED_STYLE_ID = "sty-id";
|
|
52
|
+
const HYDRATE_CHILD_ID = "c-id";
|
|
53
|
+
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
54
|
+
/**
|
|
55
|
+
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
56
|
+
*
|
|
57
|
+
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
58
|
+
* support as of Stencil v4.
|
|
59
|
+
*/
|
|
60
|
+
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
61
|
+
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
62
|
+
/**
|
|
63
|
+
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
64
|
+
*/
|
|
65
|
+
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
66
|
+
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
67
|
+
"formAssociatedCallback",
|
|
68
|
+
"formResetCallback",
|
|
69
|
+
"formDisabledCallback",
|
|
70
|
+
"formStateRestoreCallback"
|
|
71
|
+
];
|
|
72
|
+
//#endregion
|
|
4
73
|
//#region src/client/client-build.ts
|
|
74
|
+
/**
|
|
75
|
+
* `isDev` / `isTesting` are getters, not copies: the transpile path (e.g. `@stencil/unplugin`)
|
|
76
|
+
* sets `BUILD.*` overrides from each component module, which runs after this module is evaluated.
|
|
77
|
+
*/
|
|
5
78
|
const Build = {
|
|
6
|
-
isDev: BUILD.isDev,
|
|
7
79
|
isBrowser: true,
|
|
8
80
|
isServer: false,
|
|
9
|
-
|
|
81
|
+
get isDev() {
|
|
82
|
+
return BUILD.isDev;
|
|
83
|
+
},
|
|
84
|
+
get isTesting() {
|
|
85
|
+
return BUILD.isTesting;
|
|
86
|
+
}
|
|
10
87
|
};
|
|
11
88
|
const MEMBER_FLAGS = {
|
|
12
89
|
String: 1,
|
|
@@ -362,6 +439,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
362
439
|
const entryFile = `${bundleId}.entry.js${cacheBustParams ? "?" + cacheBustParams : ""}`;
|
|
363
440
|
return import(
|
|
364
441
|
/* @vite-ignore */
|
|
442
|
+
/* turbopackIgnore: true */
|
|
365
443
|
/* webpackInclude: /\.entry\.js$/ */
|
|
366
444
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
367
445
|
/* webpackMode: "lazy" */
|
|
@@ -371,78 +449,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
371
449
|
//#endregion
|
|
372
450
|
//#region src/client/client-style.ts
|
|
373
451
|
const styles = /*@__PURE__*/ new Map();
|
|
374
|
-
const
|
|
452
|
+
const modeResolver = [];
|
|
375
453
|
const needsScopedSSR = () => false;
|
|
376
454
|
//#endregion
|
|
377
|
-
//#region src/runtime/runtime-constants.ts
|
|
378
|
-
/**
|
|
379
|
-
* Bit flags for recording various properties of VDom nodes
|
|
380
|
-
*/
|
|
381
|
-
const VNODE_FLAGS = {
|
|
382
|
-
/**
|
|
383
|
-
* Whether or not a vdom node is a slot reference
|
|
384
|
-
*/
|
|
385
|
-
isSlotReference: 1,
|
|
386
|
-
/**
|
|
387
|
-
* Whether or not a slot element has fallback content
|
|
388
|
-
*/
|
|
389
|
-
isSlotFallback: 2,
|
|
390
|
-
/**
|
|
391
|
-
* Whether or not an element is a host element
|
|
392
|
-
*/
|
|
393
|
-
isHost: 4
|
|
394
|
-
};
|
|
395
|
-
const PROXY_FLAGS = {
|
|
396
|
-
isElementConstructor: 1,
|
|
397
|
-
proxyState: 2
|
|
398
|
-
};
|
|
399
|
-
const PLATFORM_FLAGS = {
|
|
400
|
-
/**
|
|
401
|
-
* designates a node in the DOM as being actively moved by the runtime
|
|
402
|
-
*/
|
|
403
|
-
isTmpDisconnected: 1,
|
|
404
|
-
appLoaded: 2,
|
|
405
|
-
queueSync: 4,
|
|
406
|
-
queueMask: 6
|
|
407
|
-
};
|
|
408
|
-
/**
|
|
409
|
-
* A (subset) of node types which are relevant for the Stencil runtime. These
|
|
410
|
-
* values are based on the values which can possibly be returned by the
|
|
411
|
-
* `.nodeType` property of a DOM node. See here for details:
|
|
412
|
-
*
|
|
413
|
-
* {@link https://dom.spec.whatwg.org/#ref-for-dom-node-nodetype%E2%91%A0}
|
|
414
|
-
*/
|
|
415
|
-
const NODE_TYPE = {
|
|
416
|
-
ElementNode: 1,
|
|
417
|
-
TextNode: 3,
|
|
418
|
-
CommentNode: 8,
|
|
419
|
-
DocumentNode: 9,
|
|
420
|
-
DocumentTypeNode: 10,
|
|
421
|
-
DocumentFragment: 11
|
|
422
|
-
};
|
|
423
|
-
const HYDRATE_ID = "s-id";
|
|
424
|
-
const HYDRATED_STYLE_ID = "sty-id";
|
|
425
|
-
const HYDRATE_CHILD_ID = "c-id";
|
|
426
|
-
const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
|
|
427
|
-
/**
|
|
428
|
-
* Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
|
|
429
|
-
*
|
|
430
|
-
* Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
|
|
431
|
-
* support as of Stencil v4.
|
|
432
|
-
*/
|
|
433
|
-
const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
434
|
-
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
435
|
-
/**
|
|
436
|
-
* Minimum delay, in milliseconds, before retrying a failed lazy component load.
|
|
437
|
-
*/
|
|
438
|
-
const LAZY_LOAD_RETRY_INTERVAL_MS = 1e3;
|
|
439
|
-
const FORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS = [
|
|
440
|
-
"formAssociatedCallback",
|
|
441
|
-
"formResetCallback",
|
|
442
|
-
"formDisabledCallback",
|
|
443
|
-
"formStateRestoreCallback"
|
|
444
|
-
];
|
|
445
|
-
//#endregion
|
|
446
455
|
//#region src/client/client-window.ts
|
|
447
456
|
const win = typeof window !== "undefined" ? window : {};
|
|
448
457
|
win.HTMLElement;
|
|
@@ -480,12 +489,12 @@ let queuePending = false;
|
|
|
480
489
|
const queueDomReads = [];
|
|
481
490
|
const queueDomWrites = [];
|
|
482
491
|
const queueDomWritesLow = [];
|
|
483
|
-
const scheduleFlush = () => win.document?.hidden ?
|
|
492
|
+
const scheduleFlush = () => win.document?.hidden ? setTimeout(flush$1, 16) : plt.raf(flush$1);
|
|
484
493
|
const queueTask = (queue, write) => (cb) => {
|
|
485
494
|
queue.push(cb);
|
|
486
495
|
if (!queuePending) {
|
|
487
496
|
queuePending = true;
|
|
488
|
-
if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush);
|
|
497
|
+
if (write && plt.$flags$ & PLATFORM_FLAGS.queueSync) nextTick(flush$1);
|
|
489
498
|
else scheduleFlush();
|
|
490
499
|
}
|
|
491
500
|
};
|
|
@@ -508,7 +517,7 @@ const consumeTimeout = (queue, timeout) => {
|
|
|
508
517
|
if (i === queue.length) queue.length = 0;
|
|
509
518
|
else if (i !== 0) queue.splice(0, i);
|
|
510
519
|
};
|
|
511
|
-
const flush = () => {
|
|
520
|
+
const flush$1 = () => {
|
|
512
521
|
if (BUILD.asyncQueue) queueCongestion++;
|
|
513
522
|
consume(queueDomReads);
|
|
514
523
|
if (BUILD.asyncQueue) {
|
|
@@ -565,6 +574,7 @@ function createShadowRoot(cmpMeta) {
|
|
|
565
574
|
}
|
|
566
575
|
if (BUILD.shadowClonable) opts.clonable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowClonable);
|
|
567
576
|
if (BUILD.shadowSerializable) opts.serializable = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowSerializable);
|
|
577
|
+
if (BUILD.shadowReferenceTarget && cmpMeta.$referenceTarget$) opts.referenceTarget = cmpMeta.$referenceTarget$;
|
|
568
578
|
const shadowRoot = this.attachShadow(opts);
|
|
569
579
|
if (BUILD.shadowModeClosed && isClosed) this.__shadowRoot = shadowRoot;
|
|
570
580
|
if (globalStyleSheet === void 0) globalStyleSheet = createStyleSheetIfNeededAndSupported("") ?? null;
|
|
@@ -638,6 +648,7 @@ function getHostSlotNodes(childNodes, hostName, slotName) {
|
|
|
638
648
|
if (typeof slotName !== "undefined") return slottedNodes;
|
|
639
649
|
}
|
|
640
650
|
slottedNodes = [...slottedNodes, ...getHostSlotNodes(internalCall(childNode, "childNodes"), hostName, slotName)];
|
|
651
|
+
if (typeof slotName !== "undefined" && slottedNodes.length) return slottedNodes;
|
|
641
652
|
}
|
|
642
653
|
return slottedNodes;
|
|
643
654
|
}
|
|
@@ -772,6 +783,7 @@ const applyLightDomPatches = (hostElementPrototype) => {
|
|
|
772
783
|
patchSlotInsertAdjacentHTML(hostElementPrototype);
|
|
773
784
|
patchInsertBefore(hostElementPrototype);
|
|
774
785
|
patchTextContent(hostElementPrototype);
|
|
786
|
+
patchInnerContentSetters(hostElementPrototype);
|
|
775
787
|
patchChildSlotNodes(hostElementPrototype);
|
|
776
788
|
patchSlotRemoveChild(hostElementPrototype);
|
|
777
789
|
};
|
|
@@ -836,11 +848,13 @@ const patchSlotAppendChild = (HostElementPrototype) => {
|
|
|
836
848
|
const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
|
|
837
849
|
if (slotNode) {
|
|
838
850
|
addSlotRelocateNode(newChild, slotNode);
|
|
851
|
+
patchSlottedNode(newChild);
|
|
839
852
|
const slotChildNodes = getSlotChildSiblings(slotNode, slotName);
|
|
840
853
|
const appendAfter = slotChildNodes[slotChildNodes.length - 1];
|
|
854
|
+
const slotWasEmpty = slotChildNodes.every((node) => node["s-sr"]);
|
|
841
855
|
const insertedNode = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, appendAfter.nextSibling);
|
|
842
856
|
dispatchSlotChangeEvent(slotNode);
|
|
843
|
-
updateFallbackSlotVisibility(this);
|
|
857
|
+
if (slotWasEmpty) updateFallbackSlotVisibility(this);
|
|
844
858
|
return insertedNode;
|
|
845
859
|
}
|
|
846
860
|
return this.__appendChild(newChild);
|
|
@@ -858,8 +872,10 @@ const patchSlotRemoveChild = (ElementPrototype) => {
|
|
|
858
872
|
ElementPrototype.__removeChild = ElementPrototype.removeChild;
|
|
859
873
|
ElementPrototype.removeChild = function(toRemove) {
|
|
860
874
|
if (toRemove && typeof toRemove["s-sn"] !== "undefined") {
|
|
861
|
-
|
|
862
|
-
|
|
875
|
+
const slotNode = getHostSlotNodes(this.__childNodes || this.childNodes, this.tagName, toRemove["s-sn"])[0];
|
|
876
|
+
if (slotNode && toRemove.isConnected) {
|
|
877
|
+
removeSlottedNode(toRemove);
|
|
878
|
+
dispatchSlotChangeEvent(slotNode);
|
|
863
879
|
updateFallbackSlotVisibility(this);
|
|
864
880
|
return;
|
|
865
881
|
}
|
|
@@ -882,6 +898,7 @@ const patchSlotPrepend = (HostElementPrototype) => {
|
|
|
882
898
|
const slotNode = getHostSlotNodes(internalCall(this, "childNodes"), this.tagName, slotName)[0];
|
|
883
899
|
if (slotNode) {
|
|
884
900
|
addSlotRelocateNode(newChild, slotNode, true);
|
|
901
|
+
patchSlottedNode(newChild);
|
|
885
902
|
const appendAfter = getSlotChildSiblings(slotNode, slotName)[0];
|
|
886
903
|
const toReturn = internalCall(internalCall(appendAfter, "parentNode"), "insertBefore")(newChild, internalCall(appendAfter, "nextSibling"));
|
|
887
904
|
dispatchSlotChangeEvent(slotNode);
|
|
@@ -945,25 +962,21 @@ const patchInsertBefore = (HostElementPrototype) => {
|
|
|
945
962
|
eleProto.__insertBefore = HostElementPrototype.insertBefore;
|
|
946
963
|
HostElementPrototype.insertBefore = function(newChild, currentChild) {
|
|
947
964
|
const { slotName, slotNode } = findSlotFromSlottedNode(newChild, this);
|
|
948
|
-
const slottedNodes = this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes);
|
|
949
965
|
if (slotNode) {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
dispatchSlotChangeEvent(slotNode);
|
|
962
|
-
}
|
|
963
|
-
return;
|
|
966
|
+
if (currentChild === null) {
|
|
967
|
+
this.appendChild(newChild);
|
|
968
|
+
return newChild;
|
|
969
|
+
}
|
|
970
|
+
if ((this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).includes(currentChild)) {
|
|
971
|
+
if (slotName !== currentChild["s-sn"]) this.appendChild(newChild);
|
|
972
|
+
else {
|
|
973
|
+
addSlotRelocateNode(newChild, slotNode);
|
|
974
|
+
patchSlottedNode(newChild);
|
|
975
|
+
internalCall(internalCall(currentChild, "parentNode"), "insertBefore")(newChild, currentChild);
|
|
976
|
+
dispatchSlotChangeEvent(slotNode);
|
|
964
977
|
}
|
|
965
|
-
|
|
966
|
-
|
|
978
|
+
return newChild;
|
|
979
|
+
}
|
|
967
980
|
}
|
|
968
981
|
/**
|
|
969
982
|
* Fixes an issue where slotted elements are dynamically relocated in React, such as after data fetch.
|
|
@@ -990,18 +1003,55 @@ const patchTextContent = (hostElementPrototype) => {
|
|
|
990
1003
|
Object.defineProperty(hostElementPrototype, "textContent", {
|
|
991
1004
|
get: function() {
|
|
992
1005
|
let text = "";
|
|
993
|
-
(this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) =>
|
|
1006
|
+
(this.__childNodes ? this.childNodes : getSlottedChildNodes(this.childNodes)).forEach((node) => {
|
|
1007
|
+
if (node.nodeType !== NODE_TYPE.CommentNode) text += node.textContent || "";
|
|
1008
|
+
});
|
|
994
1009
|
return text;
|
|
995
1010
|
},
|
|
996
1011
|
set: function(value) {
|
|
997
|
-
(this
|
|
998
|
-
|
|
999
|
-
node.remove();
|
|
1000
|
-
});
|
|
1001
|
-
this.insertAdjacentHTML("beforeend", value);
|
|
1012
|
+
removeSlottedNodes(this);
|
|
1013
|
+
if (value != null && value !== "") this.append(this.ownerDocument.createTextNode(String(value)));
|
|
1002
1014
|
}
|
|
1003
1015
|
});
|
|
1004
1016
|
};
|
|
1017
|
+
/**
|
|
1018
|
+
* Patches the `innerHTML` and `innerText` setters of a scoped component so they replace only
|
|
1019
|
+
* the slotted content. Natively they would also remove the component's rendered nodes and its
|
|
1020
|
+
* content reference node, leaving nothing for the next render to relocate into the slot.
|
|
1021
|
+
* The getters are left as they are.
|
|
1022
|
+
*
|
|
1023
|
+
* @param hostElementPrototype the `Element` to be patched
|
|
1024
|
+
*/
|
|
1025
|
+
const patchInnerContentSetters = (hostElementPrototype) => {
|
|
1026
|
+
if (!globalThis.HTMLElement) return;
|
|
1027
|
+
const patchSetter = (proto, name, insert) => {
|
|
1028
|
+
const get = Object.getOwnPropertyDescriptor(proto, name)?.get;
|
|
1029
|
+
if (!get) return;
|
|
1030
|
+
Object.defineProperty(hostElementPrototype, name, {
|
|
1031
|
+
get,
|
|
1032
|
+
set: function(value) {
|
|
1033
|
+
removeSlottedNodes(this);
|
|
1034
|
+
Array.from(internalCall(this, "childNodes")).forEach((node) => {
|
|
1035
|
+
if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== this.tagName) node.remove();
|
|
1036
|
+
});
|
|
1037
|
+
insert(this, value ?? "");
|
|
1038
|
+
}
|
|
1039
|
+
});
|
|
1040
|
+
};
|
|
1041
|
+
patchSetter(Element.prototype, "innerHTML", (host, value) => host.insertAdjacentHTML("beforeend", value));
|
|
1042
|
+
patchSetter(HTMLElement.prototype, "innerText", (host, value) => host.append(value));
|
|
1043
|
+
};
|
|
1044
|
+
/**
|
|
1045
|
+
* Removes the slotted nodes of a scoped component, along with their original location markers.
|
|
1046
|
+
*
|
|
1047
|
+
* @param host the host element of the component
|
|
1048
|
+
*/
|
|
1049
|
+
const removeSlottedNodes = (host) => {
|
|
1050
|
+
(host.__childNodes ? host.childNodes : getSlottedChildNodes(host.childNodes)).forEach((node) => {
|
|
1051
|
+
if (node["s-ol"]) node["s-ol"].remove();
|
|
1052
|
+
node.remove();
|
|
1053
|
+
});
|
|
1054
|
+
};
|
|
1005
1055
|
const patchChildSlotNodes = (elm) => {
|
|
1006
1056
|
class FakeNodeList extends Array {
|
|
1007
1057
|
item(n) {
|
|
@@ -1035,10 +1085,21 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1035
1085
|
} });
|
|
1036
1086
|
};
|
|
1037
1087
|
/**
|
|
1038
|
-
* Patches
|
|
1039
|
-
*
|
|
1040
|
-
*
|
|
1041
|
-
*
|
|
1088
|
+
* Patches a node slotted into a non-shadow component so it behaves as it would in a native slot:
|
|
1089
|
+
* - `parentNode` returns the host element
|
|
1090
|
+
* - `remove()` fires `slotchange` on the node's slot
|
|
1091
|
+
*
|
|
1092
|
+
* @param node the slotted node to be patched
|
|
1093
|
+
*/
|
|
1094
|
+
const patchSlottedNode = (node) => {
|
|
1095
|
+
patchParentNode(node);
|
|
1096
|
+
patchSlottedRemove(node);
|
|
1097
|
+
};
|
|
1098
|
+
/**
|
|
1099
|
+
* Patches a slotted node from SSR markup: everything {@link patchSlottedNode} does, plus its
|
|
1100
|
+
* sibling accessors, so whilst stepping through a non-shadow element's nodes only the mock
|
|
1101
|
+
* 'lightDOM' nodes are returned. Frameworks hydrating SSR output often reconcile their VDOM with
|
|
1102
|
+
* the real DOM by stepping through nodes with 'nextSibling' et al.
|
|
1042
1103
|
* - `nextSibling`
|
|
1043
1104
|
* - `nextElementSibling`
|
|
1044
1105
|
* - `previousSibling`
|
|
@@ -1046,11 +1107,11 @@ const patchChildSlotNodes = (elm) => {
|
|
|
1046
1107
|
*
|
|
1047
1108
|
* @param node the slotted node to be patched
|
|
1048
1109
|
*/
|
|
1049
|
-
const
|
|
1110
|
+
const patchSsrSlottedNode = (node) => {
|
|
1050
1111
|
if (!node || node.__nextSibling !== void 0 || !globalThis.Node) return;
|
|
1051
1112
|
patchNextSibling(node);
|
|
1052
1113
|
patchPreviousSibling(node);
|
|
1053
|
-
|
|
1114
|
+
patchSlottedNode(node);
|
|
1054
1115
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
1055
1116
|
patchNextElementSibling(node);
|
|
1056
1117
|
patchPreviousElementSibling(node);
|
|
@@ -1117,6 +1178,39 @@ const patchPreviousElementSibling = (element) => {
|
|
|
1117
1178
|
} });
|
|
1118
1179
|
};
|
|
1119
1180
|
/**
|
|
1181
|
+
* Detaches a slotted node from where it physically sits in the component's rendered DOM, through
|
|
1182
|
+
* the unpatched accessors. Not via `remove()`: mock-doc's `remove()` calls
|
|
1183
|
+
* `parentNode.removeChild()`, and a slotted node's patched `parentNode` is the host, whose patched
|
|
1184
|
+
* `removeChild()` would come straight back here.
|
|
1185
|
+
*
|
|
1186
|
+
* @param node the slotted node to detach
|
|
1187
|
+
*/
|
|
1188
|
+
const removeSlottedNode = (node) => {
|
|
1189
|
+
const parent = internalCall(node, "parentNode");
|
|
1190
|
+
if (parent) internalCall(parent, "removeChild")(node);
|
|
1191
|
+
};
|
|
1192
|
+
/**
|
|
1193
|
+
* Patches `remove()` on a node slotted into a non-shadow component, so that removing it fires
|
|
1194
|
+
* `slotchange` on its slot (and updates fallback content), as removing a node from a native slot
|
|
1195
|
+
* does. Stencil's own node moves, while `isTmpDisconnected` is set, don't fire it.
|
|
1196
|
+
*
|
|
1197
|
+
* @param node the slotted node to patch
|
|
1198
|
+
*/
|
|
1199
|
+
const patchSlottedRemove = (node) => {
|
|
1200
|
+
const child = node;
|
|
1201
|
+
if (!child || child.__remove || typeof child.remove !== "function") return;
|
|
1202
|
+
child.__remove = child.remove;
|
|
1203
|
+
child.remove = function() {
|
|
1204
|
+
const host = this["s-ol"]?.parentElement;
|
|
1205
|
+
const { slotNode } = findSlotFromSlottedNode(this);
|
|
1206
|
+
removeSlottedNode(this);
|
|
1207
|
+
if (slotNode && !(plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected)) {
|
|
1208
|
+
dispatchSlotChangeEvent(slotNode);
|
|
1209
|
+
updateFallbackSlotVisibility(host);
|
|
1210
|
+
}
|
|
1211
|
+
};
|
|
1212
|
+
};
|
|
1213
|
+
/**
|
|
1120
1214
|
* Patches the `parentNode` accessor of a non-shadow slotted node
|
|
1121
1215
|
*
|
|
1122
1216
|
* @param node the slotted node to be patched
|
|
@@ -1387,13 +1481,15 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
1387
1481
|
const appliedStyles = getAppliedStyles(styleContainerNode);
|
|
1388
1482
|
let styleElm;
|
|
1389
1483
|
const existingStyleElm = (BUILD.hydrateClientSide || BUILD.hotModuleReplacement) && styleContainerNode.querySelector(`[sty-id="${scopeId}"]`);
|
|
1390
|
-
if (existingStyleElm)
|
|
1391
|
-
|
|
1484
|
+
if (existingStyleElm) {
|
|
1485
|
+
if (BUILD.hotModuleReplacement) existingStyleElm.textContent = style;
|
|
1486
|
+
appliedStyles.add(scopeId);
|
|
1487
|
+
} else if (!appliedStyles.has(scopeId)) {
|
|
1392
1488
|
styleElm = win.document.createElement("style");
|
|
1393
1489
|
styleElm.textContent = style;
|
|
1394
1490
|
const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
|
|
1395
1491
|
if (nonce != null) styleElm.setAttribute("nonce", nonce);
|
|
1396
|
-
if (BUILD.hydrateServerSide
|
|
1492
|
+
if (BUILD.hydrateServerSide || BUILD.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
|
|
1397
1493
|
if (BUILD.hotModuleReplacement && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.setAttribute("data-slot-fb", "");
|
|
1398
1494
|
/**
|
|
1399
1495
|
* attach styles at the end of the head tag if we render scoped components
|
|
@@ -1520,20 +1616,28 @@ const getScopeId = (cmp, mode) => "sc-" + (BUILD.mode && mode && cmp.$flags$ & C
|
|
|
1520
1616
|
*/
|
|
1521
1617
|
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^/]+)\*\/[^{]+\{/g, "$1{");
|
|
1522
1618
|
/**
|
|
1523
|
-
* Hydrate styles after SSR for components
|
|
1524
|
-
* and add them to a constructable stylesheet.
|
|
1619
|
+
* Hydrate styles after SSR for shadow components that were serialized as 'scoped' (not DSD).
|
|
1620
|
+
* Convert their 'scoped' styles back to 'shadow' and add them to a constructable stylesheet.
|
|
1525
1621
|
*
|
|
1526
|
-
*
|
|
1622
|
+
* Sheets of scoped and non-encapsulated components are left alone so they stay in the
|
|
1623
|
+
* document head, where `addStyle()` reuses them.
|
|
1624
|
+
*
|
|
1625
|
+
* @param cmpMetas the components whose server-rendered styles may need converting
|
|
1527
1626
|
*/
|
|
1528
|
-
const hydrateScopedToShadow = () => {
|
|
1627
|
+
const hydrateScopedToShadow = (cmpMetas) => {
|
|
1529
1628
|
if (!win.document) return;
|
|
1530
|
-
const
|
|
1629
|
+
const styleElms = win.document.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
1531
1630
|
let i = 0;
|
|
1532
|
-
for (; i <
|
|
1533
|
-
const scopeId =
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1631
|
+
for (; i < styleElms.length; i++) {
|
|
1632
|
+
const scopeId = styleElms[i].getAttribute(HYDRATED_STYLE_ID);
|
|
1633
|
+
if (cmpMetas.some((cmpMeta) => {
|
|
1634
|
+
const cmpScopeId = "sc-" + cmpMeta.$tagName$;
|
|
1635
|
+
return cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation && (scopeId === cmpScopeId || BUILD.mode && cmpMeta.$flags$ & CMP_FLAGS.hasMode && scopeId.startsWith(cmpScopeId + "-"));
|
|
1636
|
+
})) {
|
|
1637
|
+
const existing = styles.get(scopeId);
|
|
1638
|
+
const allowCS = existing !== void 0 ? existing instanceof CSSStyleSheet : true;
|
|
1639
|
+
registerStyle(scopeId, convertScopedToShadow(styleElms[i].innerHTML), allowCS);
|
|
1640
|
+
}
|
|
1537
1641
|
}
|
|
1538
1642
|
};
|
|
1539
1643
|
//#endregion
|
|
@@ -1557,6 +1661,13 @@ const isComplexType = (o) => {
|
|
|
1557
1661
|
return o === "object" || o === "function";
|
|
1558
1662
|
};
|
|
1559
1663
|
//#endregion
|
|
1664
|
+
//#region src/runtime/signals-core.ts
|
|
1665
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
1666
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
1667
|
+
function signal(value, options) {
|
|
1668
|
+
return getCore().signal(value, options);
|
|
1669
|
+
}
|
|
1670
|
+
//#endregion
|
|
1560
1671
|
//#region src/runtime/event-emitter.ts
|
|
1561
1672
|
const createEvent = (ref, name, flags) => {
|
|
1562
1673
|
const elm = getElement(ref);
|
|
@@ -1588,7 +1699,12 @@ let _registry;
|
|
|
1588
1699
|
const setRegistry = (registry) => {
|
|
1589
1700
|
_registry = registry;
|
|
1590
1701
|
};
|
|
1591
|
-
const getRegistry = () => _registry ?? customElements;
|
|
1702
|
+
const getRegistry = () => _registry ?? globalThis.customElements;
|
|
1703
|
+
/**
|
|
1704
|
+
* @param elm a defined component host
|
|
1705
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
1706
|
+
*/
|
|
1707
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
1592
1708
|
//#endregion
|
|
1593
1709
|
//#region src/runtime/vdom/set-accessor.ts
|
|
1594
1710
|
/**
|
|
@@ -1632,7 +1748,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1632
1748
|
attrMap.get(memberName)?.();
|
|
1633
1749
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
1634
1750
|
let prevVal = oldValue;
|
|
1635
|
-
attrMap.set(memberName, effect
|
|
1751
|
+
attrMap.set(memberName, effect(() => {
|
|
1636
1752
|
const curVal = newValue.value;
|
|
1637
1753
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
1638
1754
|
prevVal = curVal;
|
|
@@ -1712,10 +1828,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1712
1828
|
const isComplex = isComplexType(newValue);
|
|
1713
1829
|
if (!BUILD.lazyLoad) {
|
|
1714
1830
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
1715
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
1831
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
1716
1832
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
1717
1833
|
elm["s-pp"].set(memberName, newValue);
|
|
1718
|
-
return;
|
|
1834
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
1719
1835
|
}
|
|
1720
1836
|
}
|
|
1721
1837
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -1742,7 +1858,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
1742
1858
|
xlink = true;
|
|
1743
1859
|
}
|
|
1744
1860
|
}
|
|
1745
|
-
if (newValue == null || newValue === false) {
|
|
1861
|
+
if (newValue == null || newValue === false || isComplex) {
|
|
1746
1862
|
if (newValue !== false || elm.getAttribute(memberName) === "" || flags & VNODE_FLAGS.isHost && !isEnumeratedAttribute(memberName)) {
|
|
1747
1863
|
if (BUILD.vdomXlink && xlink) elm.removeAttributeNS(XLINK_NS, memberName);
|
|
1748
1864
|
else elm.removeAttribute(memberName);
|
|
@@ -1833,8 +1949,10 @@ function sortedAttrNames(attrNames) {
|
|
|
1833
1949
|
let scopeId;
|
|
1834
1950
|
let contentRef;
|
|
1835
1951
|
let hostTagName;
|
|
1952
|
+
let hostRegistry;
|
|
1836
1953
|
let useNativeShadowDom = false;
|
|
1837
1954
|
let checkSlotFallbackVisibility = false;
|
|
1955
|
+
/** Whether the current render has slotted content to relocate. Set at the start of each render. */
|
|
1838
1956
|
let checkSlotRelocate = false;
|
|
1839
1957
|
let isSvgMode = false;
|
|
1840
1958
|
/**
|
|
@@ -1842,6 +1960,7 @@ let isSvgMode = false;
|
|
|
1842
1960
|
* These ensure that ref callbacks are called in the correct order:
|
|
1843
1961
|
* first all removal callbacks (with null), then all attachment callbacks (with elements).
|
|
1844
1962
|
*/
|
|
1963
|
+
const initialSlotChanges = /* @__PURE__ */ new Set();
|
|
1845
1964
|
const refCallbacksToRemove = [];
|
|
1846
1965
|
const refCallbacksToAttach = [];
|
|
1847
1966
|
/** Disposers for signal subscriptions on individual DOM nodes (text nodes, <s-show> wrappers). */
|
|
@@ -1849,16 +1968,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
1849
1968
|
const disposeSignalVNode = (vnode) => {
|
|
1850
1969
|
const elm = vnode.$elm$;
|
|
1851
1970
|
if (elm) {
|
|
1852
|
-
|
|
1853
|
-
if (dispose) {
|
|
1854
|
-
dispose();
|
|
1855
|
-
signalNodeDisposers.delete(elm);
|
|
1856
|
-
}
|
|
1971
|
+
disposeTextSignal(elm);
|
|
1857
1972
|
disposeAllSignalAttrs(elm);
|
|
1858
1973
|
}
|
|
1859
1974
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
1860
1975
|
};
|
|
1861
1976
|
/**
|
|
1977
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
1978
|
+
* @param textNode the text node to unsubscribe
|
|
1979
|
+
*/
|
|
1980
|
+
const disposeTextSignal = (textNode) => {
|
|
1981
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
1982
|
+
if (dispose) {
|
|
1983
|
+
dispose();
|
|
1984
|
+
signalNodeDisposers.delete(textNode);
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
/**
|
|
1988
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
1989
|
+
* @param textNode the text node to keep in sync
|
|
1990
|
+
* @param textSig the signal to subscribe to
|
|
1991
|
+
*/
|
|
1992
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
1993
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
1994
|
+
textNode.data = String(textSig.value);
|
|
1995
|
+
}));
|
|
1996
|
+
};
|
|
1997
|
+
/**
|
|
1862
1998
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
1863
1999
|
*
|
|
1864
2000
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -1880,13 +2016,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1880
2016
|
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`);
|
|
1881
2017
|
if (BUILD.vdomText && newVNode.$text$ != null) {
|
|
1882
2018
|
elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
|
|
1883
|
-
if (BUILD.vdomSignals && newVNode.$signal$)
|
|
1884
|
-
const textSig = newVNode.$signal$;
|
|
1885
|
-
const textNode = elm;
|
|
1886
|
-
signalNodeDisposers.set(textNode, effect$1(() => {
|
|
1887
|
-
textNode.data = String(textSig.value);
|
|
1888
|
-
}));
|
|
1889
|
-
}
|
|
2019
|
+
if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
1890
2020
|
} else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
1891
2021
|
elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
1892
2022
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -1895,8 +2025,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
1895
2025
|
if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
1896
2026
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
1897
2027
|
const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
1898
|
-
const
|
|
1899
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
2028
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
1900
2029
|
elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
1901
2030
|
if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
1902
2031
|
if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -2154,7 +2283,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2154
2283
|
}
|
|
2155
2284
|
if (BUILD.vdomKey && idxInOld >= 0) {
|
|
2156
2285
|
elmToMove = oldCh[idxInOld];
|
|
2157
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
2286
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2158
2287
|
else {
|
|
2159
2288
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
2160
2289
|
oldCh[idxInOld] = void 0;
|
|
@@ -2247,7 +2376,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2247
2376
|
else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
2248
2377
|
if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
2249
2378
|
} else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
2250
|
-
else if (BUILD.vdomText
|
|
2379
|
+
else if (BUILD.vdomText) {
|
|
2380
|
+
if (BUILD.vdomSignals && newVNode.$signal$) {
|
|
2381
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2382
|
+
disposeTextSignal(elm);
|
|
2383
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2384
|
+
}
|
|
2385
|
+
} else {
|
|
2386
|
+
if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2387
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2251
2390
|
};
|
|
2252
2391
|
/**
|
|
2253
2392
|
* Component-global information about nodes which are either currently being
|
|
@@ -2373,13 +2512,17 @@ const flushQueuedRefCallbacks = () => {
|
|
|
2373
2512
|
*/
|
|
2374
2513
|
const insertBefore = (parent, newNode, reference, isInitialLoad) => {
|
|
2375
2514
|
if (BUILD.slotRelocation) {
|
|
2515
|
+
if (parent?.["s-cr"]) checkSlotRelocate = true;
|
|
2376
2516
|
if (BUILD.scoped && typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
|
|
2377
2517
|
else if (typeof newNode["s-sn"] === "string") {
|
|
2378
2518
|
const hostElm = newNode["s-hn"] && parent.closest?.(newNode["s-hn"]);
|
|
2379
|
-
if ((BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && !!(hostElm && getHostRef(hostElm)?.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)) && parent.getRootNode().nodeType !== NODE_TYPES.DOCUMENT_FRAGMENT_NODE)
|
|
2519
|
+
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);
|
|
2380
2520
|
parent.insertBefore(newNode, reference);
|
|
2381
2521
|
const { slotNode } = findSlotFromSlottedNode(newNode);
|
|
2382
|
-
if (slotNode
|
|
2522
|
+
if (slotNode) {
|
|
2523
|
+
if (isInitialLoad) initialSlotChanges.add(slotNode);
|
|
2524
|
+
else dispatchSlotChangeEvent(slotNode);
|
|
2525
|
+
}
|
|
2383
2526
|
return newNode;
|
|
2384
2527
|
}
|
|
2385
2528
|
}
|
|
@@ -2435,6 +2578,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2435
2578
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2436
2579
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2437
2580
|
hostTagName = hostElm.tagName;
|
|
2581
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2438
2582
|
if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2439
2583
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2440
2584
|
|
|
@@ -2471,6 +2615,7 @@ render() {
|
|
|
2471
2615
|
if (BUILD.slotRelocation) {
|
|
2472
2616
|
contentRef = hostElm["s-cr"];
|
|
2473
2617
|
checkSlotFallbackVisibility = false;
|
|
2618
|
+
checkSlotRelocate = !useNativeShadowDom && !!(cmpMeta.$flags$ & CMP_FLAGS.hasSlot);
|
|
2474
2619
|
}
|
|
2475
2620
|
patch(oldVNode, rootVnode, isInitialLoad);
|
|
2476
2621
|
if (BUILD.slotRelocation) {
|
|
@@ -2534,8 +2679,13 @@ render() {
|
|
|
2534
2679
|
if (checkSlotFallbackVisibility) updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
2535
2680
|
plt.$flags$ &= ~PLATFORM_FLAGS.isTmpDisconnected;
|
|
2536
2681
|
relocateNodes.length = 0;
|
|
2682
|
+
if (initialSlotChanges.size) {
|
|
2683
|
+
const slotNodes = [...initialSlotChanges];
|
|
2684
|
+
initialSlotChanges.clear();
|
|
2685
|
+
nextTick(() => slotNodes.forEach(dispatchSlotChangeEvent));
|
|
2686
|
+
}
|
|
2537
2687
|
}
|
|
2538
|
-
if (BUILD.slotRelocation && !
|
|
2688
|
+
if (BUILD.slotRelocation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && hostElm["s-cr"]) {
|
|
2539
2689
|
const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
|
|
2540
2690
|
for (const childNode of children) if (childNode["s-hn"] !== hostTagName && childNode["s-sh"] !== hostTagName) {
|
|
2541
2691
|
if (isInitialLoad && childNode["s-ih"] == null) childNode["s-ih"] = childNode.hidden ?? false;
|
|
@@ -2587,11 +2737,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
2587
2737
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
2588
2738
|
*
|
|
2589
2739
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
2740
|
+
* @param registry the registry the waiting component is defined in
|
|
2590
2741
|
*/
|
|
2591
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
2742
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
2592
2743
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
2593
2744
|
if (!BUILD.lazyLoad && !ancestorHostRef) {
|
|
2594
|
-
await
|
|
2745
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
2595
2746
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
2596
2747
|
}
|
|
2597
2748
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -2947,8 +3098,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
2947
3098
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
2948
3099
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
2949
3100
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
2950
|
-
const
|
|
2951
|
-
const sig = signal(initialVal);
|
|
3101
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
2952
3102
|
hostRef.$signalValues$.set(memberName, sig);
|
|
2953
3103
|
let prevScheduleVal = sig.peek();
|
|
2954
3104
|
disposers.push(effect(() => {
|
|
@@ -3076,9 +3226,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3076
3226
|
if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
3077
3227
|
}
|
|
3078
3228
|
}
|
|
3079
|
-
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component
|
|
3080
|
-
- You are NOT using hostData() and <Host> in the same component.
|
|
3081
|
-
- <Host> is used once, and it's the single root component of the render() function.`);
|
|
3229
|
+
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
|
|
3082
3230
|
if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
3083
3231
|
const vnode = newVNode(nodeName, null);
|
|
3084
3232
|
vnode.$attrs$ = vnodeData;
|
|
@@ -3131,17 +3279,23 @@ const vdomFnUtils = {
|
|
|
3131
3279
|
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
3132
3280
|
* friendlier public interface (hence, 'convertToPublic').
|
|
3133
3281
|
*
|
|
3134
|
-
*
|
|
3282
|
+
* Functional components receive primitive children unwrapped, so those
|
|
3283
|
+
* become text-only child nodes.
|
|
3284
|
+
*
|
|
3285
|
+
* @param node the virtual DOM node (or primitive child) to convert
|
|
3135
3286
|
* @returns a converted child node
|
|
3136
3287
|
*/
|
|
3137
|
-
const convertToPublic = (node) =>
|
|
3288
|
+
const convertToPublic = (node) => typeof node !== "object" ? {
|
|
3289
|
+
vtag: null,
|
|
3290
|
+
vtext: String(node)
|
|
3291
|
+
} : {
|
|
3138
3292
|
vattrs: node.$attrs$,
|
|
3139
3293
|
vchildren: node.$children$,
|
|
3140
3294
|
vkey: node.$key$,
|
|
3141
3295
|
vname: node.$name$,
|
|
3142
3296
|
vtag: node.$tag$,
|
|
3143
3297
|
vtext: node.$text$
|
|
3144
|
-
}
|
|
3298
|
+
};
|
|
3145
3299
|
/**
|
|
3146
3300
|
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
3147
3301
|
* order to use the resulting object in the virtual DOM. The initial object was
|
|
@@ -3158,11 +3312,11 @@ const convertToPrivate = (node) => {
|
|
|
3158
3312
|
if (node.vname) vnodeData.name = node.vname;
|
|
3159
3313
|
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
3160
3314
|
}
|
|
3161
|
-
const vnode = newVNode(node.vtag, node.vtext);
|
|
3162
|
-
vnode.$attrs$ = node.vattrs;
|
|
3163
|
-
vnode.$children$ = node.vchildren;
|
|
3164
|
-
vnode.$key$ = node.vkey;
|
|
3165
|
-
vnode.$name$ = node.vname;
|
|
3315
|
+
const vnode = newVNode(node.vtag ?? null, node.vtext);
|
|
3316
|
+
vnode.$attrs$ = node.vattrs ?? null;
|
|
3317
|
+
vnode.$children$ = node.vchildren ?? null;
|
|
3318
|
+
vnode.$key$ = node.vkey ?? null;
|
|
3319
|
+
vnode.$name$ = node.vname ?? null;
|
|
3166
3320
|
return vnode;
|
|
3167
3321
|
};
|
|
3168
3322
|
/**
|
|
@@ -3212,7 +3366,10 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3212
3366
|
hostElm.classList.add(scopeId + "-h");
|
|
3213
3367
|
} else if (hostElm["s-sc"]) delete hostElm["s-sc"];
|
|
3214
3368
|
}
|
|
3215
|
-
if (win.document &&
|
|
3369
|
+
if (win.document && !plt.$orgLocNodes$?.has(hostId)) {
|
|
3370
|
+
initializeDocumentHydrate(win.document.body, plt.$orgLocNodes$ ??= /* @__PURE__ */ new Map());
|
|
3371
|
+
plt.$orgLocNodes$.set(hostId, hostElm);
|
|
3372
|
+
}
|
|
3216
3373
|
hostElm[HYDRATE_ID] = hostId;
|
|
3217
3374
|
hostElm.removeAttribute(HYDRATE_ID);
|
|
3218
3375
|
hostRef.$vnode$ = clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId, slottedNodes);
|
|
@@ -3225,7 +3382,7 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3225
3382
|
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
3226
3383
|
const node = childRenderNode.$elm$;
|
|
3227
3384
|
if (!shadowRoot) {
|
|
3228
|
-
node["s-hn"] = transformTag(tagName).toUpperCase();
|
|
3385
|
+
if (childRenderNode.$hostId$ === hostId) node["s-hn"] = transformTag(tagName).toUpperCase();
|
|
3229
3386
|
if (childRenderNode.$tag$ === "slot") node["s-cr"] = hostElm["s-cr"];
|
|
3230
3387
|
} else if (childRenderNode.$tag$?.toString().includes("-") && childRenderNode.$tag$ !== "slot-fb" && !childRenderNode.$elm$.shadowRoot) {
|
|
3231
3388
|
const cmpMeta = getHostRef(childRenderNode.$elm$);
|
|
@@ -3275,14 +3432,10 @@ const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
|
3275
3432
|
const siSlot = slottedItem.slot;
|
|
3276
3433
|
if (hostEle.shadowRoot && siNode.parentElement !== hostEle) hostEle.insertBefore(siNode, slotGroup[snGroupIdx - 1]?.node?.nextSibling);
|
|
3277
3434
|
if (!hostEle.shadowRoot || !shadowRoot) {
|
|
3278
|
-
if (!siSlot["s-cr"])
|
|
3279
|
-
siSlot["s-cr"] = hostEle["s-cr"];
|
|
3280
|
-
if (!siSlot["s-cr"] && hostEle.shadowRoot) siSlot["s-cr"] = hostEle;
|
|
3281
|
-
else siSlot["s-cr"] = (hostEle.__childNodes || hostEle.childNodes)[0];
|
|
3282
|
-
}
|
|
3435
|
+
if (!siSlot["s-cr"]) siSlot["s-cr"] = hostEle["s-cr"] || (hostEle.shadowRoot ? hostEle : (hostEle.__childNodes || hostEle.childNodes)[0]);
|
|
3283
3436
|
addSlotRelocateNode(siNode, siSlot, false, siNode["s-oo"] || currentPos);
|
|
3284
3437
|
if (siNode.parentElement?.shadowRoot && siNode["getAttribute"] && siNode.getAttribute("slot")) siNode.removeAttribute("slot");
|
|
3285
|
-
if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll)
|
|
3438
|
+
if (BUILD.lightDomPatches || BUILD.slotChildNodes || BUILD.patchAll && hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.patchAll) patchSsrSlottedNode(siNode);
|
|
3286
3439
|
}
|
|
3287
3440
|
currentPos = (siNode["s-oo"] || currentPos) + 1;
|
|
3288
3441
|
}
|
|
@@ -3342,7 +3495,7 @@ const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes
|
|
|
3342
3495
|
const scopeId = hostElm["s-sc"];
|
|
3343
3496
|
if (node.nodeType === NODE_TYPE.ElementNode) {
|
|
3344
3497
|
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
3345
|
-
if (childNodeType) {
|
|
3498
|
+
if (childNodeType && node !== hostElm) {
|
|
3346
3499
|
childIdSplt = childNodeType.split(".");
|
|
3347
3500
|
if (childIdSplt[0] === hostId || childIdSplt[0] === "0") {
|
|
3348
3501
|
childVNode = createSimpleVNode({
|
|
@@ -3460,6 +3613,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
|
3460
3613
|
const createSimpleVNode = (vnode) => ({
|
|
3461
3614
|
$flags$: 0,
|
|
3462
3615
|
$index$: "0",
|
|
3616
|
+
$children$: null,
|
|
3463
3617
|
...vnode
|
|
3464
3618
|
});
|
|
3465
3619
|
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
|
|
@@ -3523,6 +3677,11 @@ const addSlottedNodes = (slottedNodes, slotNodeId, slotName, slotNode, hostId) =
|
|
|
3523
3677
|
* @returns the first corresponding node of the type
|
|
3524
3678
|
*/
|
|
3525
3679
|
const findCorrespondingNode = (node, type) => {
|
|
3680
|
+
if (type === NODE_TYPE.TextNode) {
|
|
3681
|
+
const next = node.nextSibling;
|
|
3682
|
+
if (next?.nodeType === NODE_TYPE.TextNode) return next;
|
|
3683
|
+
return node.parentNode.insertBefore(node.ownerDocument.createTextNode(""), next);
|
|
3684
|
+
}
|
|
3526
3685
|
let sibling = node;
|
|
3527
3686
|
do
|
|
3528
3687
|
sibling = sibling.nextSibling;
|
|
@@ -3854,7 +4013,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
3854
4013
|
else return shallowPart.trim();
|
|
3855
4014
|
}).join(", ");
|
|
3856
4015
|
};
|
|
3857
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
4016
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
3858
4017
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
3859
4018
|
return processRules(cssText, (rule) => {
|
|
3860
4019
|
let selector = rule.selector;
|
|
@@ -3973,8 +4132,11 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
3973
4132
|
};
|
|
3974
4133
|
//#endregion
|
|
3975
4134
|
//#region src/runtime/mode.ts
|
|
3976
|
-
const computeMode = (elm) =>
|
|
3977
|
-
const setMode = (handler) =>
|
|
4135
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4136
|
+
const setMode = (handler) => {
|
|
4137
|
+
modeResolver.length = 0;
|
|
4138
|
+
modeResolver.push(handler);
|
|
4139
|
+
};
|
|
3978
4140
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
3979
4141
|
//#endregion
|
|
3980
4142
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4039,23 +4201,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4039
4201
|
*
|
|
4040
4202
|
* @param propValue the new value to coerce to some type
|
|
4041
4203
|
* @param propType the type of the prop, expressed as a binary number
|
|
4042
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4043
4204
|
* @returns the parsed/coerced value
|
|
4044
4205
|
*/
|
|
4045
|
-
const parsePropertyValue = (propValue, propType
|
|
4206
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4046
4207
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4047
4208
|
/**
|
|
4048
4209
|
* ensure this value is of the correct prop type
|
|
4049
4210
|
*/
|
|
4050
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4051
|
-
/**
|
|
4052
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4053
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4054
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4055
|
-
*/
|
|
4056
|
-
if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4057
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4058
|
-
}
|
|
4211
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4059
4212
|
/**
|
|
4060
4213
|
* force it to be a number
|
|
4061
4214
|
*/
|
|
@@ -4097,7 +4250,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4097
4250
|
if (BUILD.signalBacking) {
|
|
4098
4251
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4099
4252
|
if (sig !== void 0) {
|
|
4100
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4253
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4101
4254
|
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4102
4255
|
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4103
4256
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4115,7 +4268,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4115
4268
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4116
4269
|
const flags = hostRef.$flags$;
|
|
4117
4270
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4118
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4271
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4119
4272
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4120
4273
|
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4121
4274
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4164,6 +4317,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4164
4317
|
*/
|
|
4165
4318
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4166
4319
|
/**
|
|
4320
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4321
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4322
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4323
|
+
*
|
|
4324
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4325
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4326
|
+
*/
|
|
4327
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4328
|
+
const instance = hostRef.$lazyInstance$;
|
|
4329
|
+
if (!instance) return;
|
|
4330
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4331
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4332
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4333
|
+
}
|
|
4334
|
+
};
|
|
4335
|
+
/**
|
|
4167
4336
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4168
4337
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4169
4338
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4220,9 +4389,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4220
4389
|
if (BUILD.lazyLoad) {
|
|
4221
4390
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4222
4391
|
const ref = getHostRef(this);
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
return instance[memberName];
|
|
4392
|
+
if (!ref) return prototype[memberName];
|
|
4393
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4226
4394
|
}
|
|
4227
4395
|
if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4228
4396
|
},
|
|
@@ -4237,7 +4405,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4237
4405
|
}
|
|
4238
4406
|
if (origSetter) {
|
|
4239
4407
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4240
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4408
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4241
4409
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4242
4410
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4243
4411
|
return;
|
|
@@ -4249,21 +4417,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4249
4417
|
if (BUILD.lazyLoad) {
|
|
4250
4418
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4251
4419
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4252
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4253
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4254
|
-
});
|
|
4255
4420
|
return;
|
|
4256
4421
|
}
|
|
4257
|
-
const
|
|
4422
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4423
|
+
if (ref.$lazyInstance$) {
|
|
4258
4424
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4259
4425
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4260
|
-
ref.$lazyInstance$[memberName] =
|
|
4426
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4261
4427
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4262
|
-
};
|
|
4263
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4264
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4265
|
-
setterSetVal();
|
|
4266
|
-
});
|
|
4428
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4267
4429
|
}
|
|
4268
4430
|
} });
|
|
4269
4431
|
} else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4305,7 +4467,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4305
4467
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4306
4468
|
(cmpMeta.$watchers$?.[attrName])?.forEach((watcher) => {
|
|
4307
4469
|
const [[watchMethodName, watcherFlags]] = Object.entries(watcher);
|
|
4308
|
-
if (instance[watchMethodName] != null && (hostFlags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate)) instance[watchMethodName](newValue, oldValue, attrName);
|
|
4470
|
+
if (instance?.[watchMethodName] != null && (hostFlags & HOST_FLAGS.isWatchReady || watcherFlags & WATCH_FLAGS.Immediate)) instance[watchMethodName](newValue, oldValue, attrName);
|
|
4309
4471
|
});
|
|
4310
4472
|
}
|
|
4311
4473
|
return;
|
|
@@ -4315,9 +4477,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4315
4477
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4316
4478
|
if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4317
4479
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4318
|
-
if (isBooleanTarget)
|
|
4480
|
+
if (isBooleanTarget) {
|
|
4481
|
+
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.`);
|
|
4482
|
+
newValue = newValue !== null;
|
|
4483
|
+
}
|
|
4319
4484
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4320
|
-
|
|
4485
|
+
const isUnchanged = newValue === this[propName] || newValue == null && this[propName] == null;
|
|
4486
|
+
if (!isSpuriousBooleanRemoval && !isUnchanged && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4321
4487
|
});
|
|
4322
4488
|
};
|
|
4323
4489
|
Cstr.observedAttributes = Array.from(/* @__PURE__ */ new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
@@ -4378,9 +4544,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4378
4544
|
} catch (e) {
|
|
4379
4545
|
consoleError(e, elm);
|
|
4380
4546
|
}
|
|
4381
|
-
if (BUILD.member)
|
|
4547
|
+
if (BUILD.member) {
|
|
4548
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4549
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4550
|
+
}
|
|
4382
4551
|
endNewInstance();
|
|
4383
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4552
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4384
4553
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4385
4554
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4386
4555
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4480,9 +4649,16 @@ const connectedCallback = (elm) => {
|
|
|
4480
4649
|
}
|
|
4481
4650
|
if (BUILD.asyncLoading) {
|
|
4482
4651
|
let ancestorComponent = elm;
|
|
4483
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4484
|
-
|
|
4485
|
-
|
|
4652
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
4653
|
+
if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
4654
|
+
ancestorComponent["s-p"] = [];
|
|
4655
|
+
ancestorComponent["s-rc"] = [];
|
|
4656
|
+
ancestorComponent["s-pc"] = [];
|
|
4657
|
+
}
|
|
4658
|
+
if (ancestorComponent["s-p"]) {
|
|
4659
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
4660
|
+
break;
|
|
4661
|
+
}
|
|
4486
4662
|
}
|
|
4487
4663
|
}
|
|
4488
4664
|
if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -4598,48 +4774,112 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
4598
4774
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
4599
4775
|
);
|
|
4600
4776
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
4601
|
-
if (
|
|
4602
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4603
|
-
if (ctor) {
|
|
4604
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4605
|
-
if (key === "constructor") continue;
|
|
4606
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4607
|
-
}
|
|
4608
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4609
|
-
if (styleDesc) {
|
|
4610
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
4611
|
-
const newStyle = NewClass.style;
|
|
4612
|
-
if (newStyle) {
|
|
4613
|
-
const scopeId = getScopeId(cmpMeta);
|
|
4614
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4615
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
4616
|
-
tag: cmpMeta.$tagName$,
|
|
4617
|
-
scopeId,
|
|
4618
|
-
isShadow,
|
|
4619
|
-
cssLen: newStyle.length
|
|
4620
|
-
});
|
|
4621
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
4622
|
-
}
|
|
4623
|
-
}
|
|
4624
|
-
}
|
|
4625
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4626
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4627
|
-
const hostRef = getHostRef(el);
|
|
4628
|
-
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4629
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4630
|
-
hostRef.$rmListeners$ = void 0;
|
|
4631
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4632
|
-
}
|
|
4633
|
-
if (!isShadow && hostRef) {
|
|
4634
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
4635
|
-
attachStyles(hostRef);
|
|
4636
|
-
}
|
|
4637
|
-
forceUpdate(el);
|
|
4638
|
-
});
|
|
4777
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
4639
4778
|
} catch (e) {
|
|
4640
4779
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
4641
4780
|
}
|
|
4642
4781
|
};
|
|
4782
|
+
/**
|
|
4783
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
4784
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
4785
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
4786
|
+
*
|
|
4787
|
+
* @param cmpMeta runtime metadata for the component
|
|
4788
|
+
* @param NewClass the component's newly executed class
|
|
4789
|
+
*/
|
|
4790
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
4791
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
4792
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
4793
|
+
if (ctor && ctor !== NewClass) {
|
|
4794
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
4795
|
+
if (key === "constructor") continue;
|
|
4796
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
4797
|
+
}
|
|
4798
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
4799
|
+
if (styleDesc) {
|
|
4800
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
4801
|
+
const newStyle = NewClass.style;
|
|
4802
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
4806
|
+
const hostRef = getHostRef(el);
|
|
4807
|
+
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
4808
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
4809
|
+
hostRef.$rmListeners$ = void 0;
|
|
4810
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
4811
|
+
}
|
|
4812
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
4813
|
+
forceUpdate(el);
|
|
4814
|
+
});
|
|
4815
|
+
};
|
|
4816
|
+
//#endregion
|
|
4817
|
+
//#region src/runtime/parse-gate.ts
|
|
4818
|
+
/**
|
|
4819
|
+
* SSR hosts connected while the HTML parser is still inside them (streamed documents),
|
|
4820
|
+
* in connection order - which is document order. Each is held until its subtree is
|
|
4821
|
+
* parsed so hydration sees its declarative shadow root and children.
|
|
4822
|
+
*/
|
|
4823
|
+
const pending = /* @__PURE__ */ new Set();
|
|
4824
|
+
let observer;
|
|
4825
|
+
const parentOf = (node) => node.parentNode ?? (node.nodeType === NODE_TYPE.DocumentFragment ? node.host : null);
|
|
4826
|
+
/**
|
|
4827
|
+
* The parser has finished with `elm` once it, or any ancestor, has a following sibling.
|
|
4828
|
+
* @param elm the element to check
|
|
4829
|
+
* @returns whether the element's subtree is fully parsed
|
|
4830
|
+
*/
|
|
4831
|
+
const isParsed = (elm) => {
|
|
4832
|
+
if (win.document.readyState !== "loading") return true;
|
|
4833
|
+
for (let n = elm; n; n = parentOf(n)) if (n.nextSibling) return true;
|
|
4834
|
+
return false;
|
|
4835
|
+
};
|
|
4836
|
+
const hasPendingAncestor = (elm) => {
|
|
4837
|
+
for (let n = parentOf(elm); n; n = parentOf(n)) if (pending.has(n)) return true;
|
|
4838
|
+
return false;
|
|
4839
|
+
};
|
|
4840
|
+
const flush = () => {
|
|
4841
|
+
for (const elm of pending) if (!elm.isConnected) pending.delete(elm);
|
|
4842
|
+
else if (isParsed(elm)) elm.__attachShadow?.();
|
|
4843
|
+
for (const elm of pending) if (isParsed(elm) && !hasPendingAncestor(elm)) {
|
|
4844
|
+
pending.delete(elm);
|
|
4845
|
+
elm.connectedCallback?.();
|
|
4846
|
+
}
|
|
4847
|
+
if (!pending.size) {
|
|
4848
|
+
observer?.disconnect();
|
|
4849
|
+
observer = void 0;
|
|
4850
|
+
}
|
|
4851
|
+
};
|
|
4852
|
+
/**
|
|
4853
|
+
* Whether the parser may still be adding children (including a declarative shadow root)
|
|
4854
|
+
* to `elm`: it was just created by the parser, or it's an SSR host the parser is still inside.
|
|
4855
|
+
* @param elm the host element
|
|
4856
|
+
* @returns `true` if the element's subtree may be incomplete
|
|
4857
|
+
*/
|
|
4858
|
+
const mayStillBeParsing = (elm) => win.document?.readyState === "loading" && (!elm.parentNode || elm.hasAttribute("s-id") && !isParsed(elm));
|
|
4859
|
+
/**
|
|
4860
|
+
* Holds back `elm`'s `connectedCallback` while it's an SSR host the parser hasn't finished
|
|
4861
|
+
* with, or one nested inside such a host. Its shadow root is attached once its own subtree
|
|
4862
|
+
* is parsed; `connectedCallback` is re-called once no ancestor host is still held.
|
|
4863
|
+
* @param elm the host element being connected
|
|
4864
|
+
* @returns `true` if processing was deferred
|
|
4865
|
+
*/
|
|
4866
|
+
const deferUntilParsed = (elm) => {
|
|
4867
|
+
if (pending.has(elm)) return true;
|
|
4868
|
+
if (!win.document || !elm.hasAttribute("s-id")) return false;
|
|
4869
|
+
const parsed = isParsed(elm);
|
|
4870
|
+
if (parsed && !hasPendingAncestor(elm)) return false;
|
|
4871
|
+
if (parsed) elm.__attachShadow?.();
|
|
4872
|
+
pending.add(elm);
|
|
4873
|
+
if (!observer) {
|
|
4874
|
+
observer = new MutationObserver(flush);
|
|
4875
|
+
observer.observe(win.document, {
|
|
4876
|
+
childList: true,
|
|
4877
|
+
subtree: true
|
|
4878
|
+
});
|
|
4879
|
+
win.document.addEventListener("DOMContentLoaded", flush, { once: true });
|
|
4880
|
+
}
|
|
4881
|
+
return true;
|
|
4882
|
+
};
|
|
4643
4883
|
//#endregion
|
|
4644
4884
|
//#region src/runtime/bootstrap-standalone.ts
|
|
4645
4885
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
@@ -4662,9 +4902,13 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4662
4902
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
4663
4903
|
}
|
|
4664
4904
|
if (BUILD.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4665
|
-
if (BUILD.
|
|
4666
|
-
|
|
4667
|
-
|
|
4905
|
+
if (BUILD.shadowReferenceTarget) cmpMeta.$referenceTarget$ = compactMeta[7];
|
|
4906
|
+
if (BUILD.hotModuleReplacement) {
|
|
4907
|
+
Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4908
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
4909
|
+
};
|
|
4910
|
+
Cstr["s-hmr-apply"] = (NewClass) => hmrApplyClass(cmpMeta, NewClass);
|
|
4911
|
+
}
|
|
4668
4912
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && (BUILD.slotCloneNode || BUILD.patchClone && cmpMeta.$flags$ & CMP_FLAGS.patchClone)) patchCloneNode(Cstr.prototype);
|
|
4669
4913
|
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) {
|
|
4670
4914
|
if (BUILD.lightDomPatches || BUILD.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) applyLightDomPatches(Cstr.prototype);
|
|
@@ -4677,11 +4921,12 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4677
4921
|
patchSlotInsertAdjacentHTML(Cstr.prototype);
|
|
4678
4922
|
patchInsertBefore(Cstr.prototype);
|
|
4679
4923
|
patchSlotRemoveChild(Cstr.prototype);
|
|
4924
|
+
patchInnerContentSetters(Cstr.prototype);
|
|
4680
4925
|
}
|
|
4681
4926
|
if (BUILD.slotTextContent) patchTextContent(Cstr.prototype);
|
|
4682
4927
|
}
|
|
4683
4928
|
}
|
|
4684
|
-
if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow();
|
|
4929
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) hydrateScopedToShadow([cmpMeta]);
|
|
4685
4930
|
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
4686
4931
|
const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
|
|
4687
4932
|
Object.assign(Cstr.prototype, {
|
|
@@ -4693,6 +4938,8 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4693
4938
|
return getHostRef(this)?.$onReadyPromise$;
|
|
4694
4939
|
},
|
|
4695
4940
|
async connectedCallback() {
|
|
4941
|
+
if (BUILD.hydrateClientSide && deferUntilParsed(this)) return;
|
|
4942
|
+
if (BUILD.shadowDom) this.__attachShadow();
|
|
4696
4943
|
const isFirstConnect = !this.__hasHostListenerAttached;
|
|
4697
4944
|
let hostRef;
|
|
4698
4945
|
if (isFirstConnect) {
|
|
@@ -4703,7 +4950,7 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4703
4950
|
}
|
|
4704
4951
|
connectedCallback(this);
|
|
4705
4952
|
if (BUILD.asyncLoading && hostRef && hostRef.$ancestorComponent$) {
|
|
4706
|
-
await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4953
|
+
await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(this));
|
|
4707
4954
|
if (!this.isConnected) return;
|
|
4708
4955
|
}
|
|
4709
4956
|
if (originalConnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalConnectedCallback.call(this);
|
|
@@ -4714,11 +4961,10 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
4714
4961
|
if (originalDisconnectedCallback && (plt.$flags$ & PLATFORM_FLAGS.isTmpDisconnected) === 0) originalDisconnectedCallback.call(this);
|
|
4715
4962
|
},
|
|
4716
4963
|
__attachShadow() {
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
if (BUILD.shadowModeClosed && isClosed) existingRoot = this.__shadowRoot ?? null;
|
|
4964
|
+
if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) || BUILD.hydrateClientSide && mayStillBeParsing(this)) return;
|
|
4965
|
+
const existingRoot = getShadowRoot(this);
|
|
4720
4966
|
if (!existingRoot) createShadowRoot.call(this, cmpMeta);
|
|
4721
|
-
else if (BUILD.isDev && BUILD.shadowModeClosed &&
|
|
4967
|
+
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.`);
|
|
4722
4968
|
}
|
|
4723
4969
|
});
|
|
4724
4970
|
Object.defineProperty(Cstr, "is", {
|
|
@@ -4773,7 +5019,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4773
5019
|
Object.assign(plt, options);
|
|
4774
5020
|
if (BUILD.asyncQueue && options.syncQueue) plt.$flags$ |= PLATFORM_FLAGS.queueSync;
|
|
4775
5021
|
if (BUILD.hydrateClientSide) plt.$flags$ |= PLATFORM_FLAGS.appLoaded;
|
|
4776
|
-
if (BUILD.hydrateClientSide && BUILD.shadowDom)
|
|
5022
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) {
|
|
5023
|
+
const cmpMetas = [];
|
|
5024
|
+
lazyBundles.map((lazyBundle) => lazyBundle[1].map(([$flags$, $tagName$]) => cmpMetas.push({
|
|
5025
|
+
$flags$,
|
|
5026
|
+
$tagName$
|
|
5027
|
+
})));
|
|
5028
|
+
hydrateScopedToShadow(cmpMetas);
|
|
5029
|
+
}
|
|
4777
5030
|
lazyBundles.map((lazyBundle) => {
|
|
4778
5031
|
lazyBundle[1].map((compactMeta) => {
|
|
4779
5032
|
const cmpMeta = {
|
|
@@ -4790,7 +5043,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4790
5043
|
cmpMeta.$serializers$ = compactMeta[5] ?? {};
|
|
4791
5044
|
cmpMeta.$deserializers$ = compactMeta[6] ?? {};
|
|
4792
5045
|
}
|
|
5046
|
+
if (BUILD.shadowReferenceTarget) cmpMeta.$referenceTarget$ = compactMeta[7];
|
|
4793
5047
|
const tagName = transformTag(cmpMeta.$tagName$);
|
|
5048
|
+
const attachShadowRoot = (elm) => {
|
|
5049
|
+
if (cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation && !(cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss) && !getShadowRoot(elm)) createShadowRoot.call(elm, cmpMeta);
|
|
5050
|
+
};
|
|
4794
5051
|
const HostElement = class extends HTMLElement {
|
|
4795
5052
|
["s-p"];
|
|
4796
5053
|
["s-rc"];
|
|
@@ -4799,14 +5056,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4799
5056
|
super(self);
|
|
4800
5057
|
self = this;
|
|
4801
5058
|
registerHost(self, cmpMeta);
|
|
4802
|
-
if (BUILD.shadowDom &&
|
|
4803
|
-
if (!self.shadowRoot) createShadowRoot.call(self, cmpMeta);
|
|
4804
|
-
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.`);
|
|
4805
|
-
}
|
|
5059
|
+
if (BUILD.shadowDom && !(BUILD.hydrateClientSide && mayStillBeParsing(self))) attachShadowRoot(self);
|
|
4806
5060
|
}
|
|
4807
5061
|
connectedCallback() {
|
|
4808
5062
|
const hostRef = getHostRef(this);
|
|
4809
5063
|
if (!hostRef) return;
|
|
5064
|
+
if (BUILD.hydrateClientSide && deferUntilParsed(this)) return;
|
|
5065
|
+
if (BUILD.shadowDom) attachShadowRoot(this);
|
|
4810
5066
|
/**
|
|
4811
5067
|
* The `connectedCallback` lifecycle event can potentially be fired multiple times
|
|
4812
5068
|
* if the element is removed from the DOM and re-inserted. This is not a common use case,
|
|
@@ -4862,10 +5118,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4862
5118
|
patchSlotInsertAdjacentHTML(HostElement.prototype);
|
|
4863
5119
|
patchInsertBefore(HostElement.prototype);
|
|
4864
5120
|
patchSlotRemoveChild(HostElement.prototype);
|
|
5121
|
+
patchInnerContentSetters(HostElement.prototype);
|
|
4865
5122
|
}
|
|
4866
5123
|
if (BUILD.slotTextContent) patchTextContent(HostElement.prototype);
|
|
4867
5124
|
}
|
|
4868
5125
|
}
|
|
5126
|
+
if (BUILD.hydrateClientSide && BUILD.shadowDom) HostElement.prototype.__attachShadow = function() {
|
|
5127
|
+
attachShadowRoot(this);
|
|
5128
|
+
};
|
|
4869
5129
|
if (BUILD.formAssociated && cmpMeta.$flags$ & CMP_FLAGS.formAssociated) HostElement.formAssociated = true;
|
|
4870
5130
|
if (BUILD.hotModuleReplacement) HostElement.prototype["s-hmr"] = function(hmrVersionId) {
|
|
4871
5131
|
hmrStart(this, cmpMeta, hmrVersionId);
|
|
@@ -5018,7 +5278,7 @@ function Mixin(...mixins) {
|
|
|
5018
5278
|
//#region src/runtime/nonce.ts
|
|
5019
5279
|
/**
|
|
5020
5280
|
* Assigns the given value to the nonce property on the runtime platform object.
|
|
5021
|
-
* During runtime, this value is used to set the nonce attribute on all dynamically created
|
|
5281
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created style tags.
|
|
5022
5282
|
* @param nonce The value to be assigned to the platform nonce property.
|
|
5023
5283
|
* @returns void
|
|
5024
5284
|
*/
|
|
@@ -5180,4 +5440,4 @@ function hasKeys(obj) {
|
|
|
5180
5440
|
return false;
|
|
5181
5441
|
}
|
|
5182
5442
|
//#endregion
|
|
5183
|
-
export { Fragment, HYDRATED_STYLE_ID, Host, Mixin, ReactiveControllerHost, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, jsx, jsxDEV, jsxs, normalizeWatchers, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, registerSideEffectStyleTarget, render, setAssetPath, setMode, setNonce, setPlatformOptions, setRegistry, setTagTransformer, setValue, transformTag, unregisterSideEffectStyleTarget };
|
|
5443
|
+
export { Fragment, HYDRATED_STYLE_ID, Host, Mixin, ReactiveControllerHost, addHostEventListeners, applySerializers, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRegistry, getRenderingRef, getShadowRoot, getValue, h, injectSideEffectStyle, jsx, jsxDEV, jsxs, normalizeWatchers, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, registerSideEffectStyleTarget, render, setAssetPath, setMode, setNonce, setPlatformOptions, setRegistry, setTagTransformer, setValue, transformTag, unregisterSideEffectStyleTarget };
|