@rededor/cura 0.3.2 → 0.3.4-alpha.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/cjs/{app-globals-0f70160b.js → app-globals-a41d7f40.js} +40 -17
- package/dist/cjs/app-globals-a41d7f40.js.map +1 -0
- package/dist/cjs/css-shim-83cf0349.js +8 -0
- package/dist/cjs/css-shim-83cf0349.js.map +1 -0
- package/dist/cjs/{cura-display_4.cjs.entry.js → cura-button_6.cjs.entry.js} +115 -50
- package/dist/cjs/cura-button_6.cjs.entry.js.map +1 -0
- package/dist/cjs/cura-icons-view.cjs.entry.js +4 -2
- package/dist/cjs/cura-icons-view.cjs.entry.js.map +1 -0
- package/dist/cjs/cura.cjs.js +19 -4
- package/dist/cjs/cura.cjs.js.map +1 -0
- package/dist/cjs/{index-8686299e.js → index-29633529.js} +829 -29
- package/dist/cjs/index-29633529.js.map +1 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +23 -4
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/shadow-css-8baae635.js +391 -0
- package/dist/cjs/shadow-css-8baae635.js.map +1 -0
- package/dist/collection/api/cura-api.js +1 -0
- package/dist/collection/api/cura-api.js.map +1 -0
- package/dist/collection/api/cura-api.type.js +1 -0
- package/dist/collection/api/cura-api.type.js.map +1 -0
- package/dist/collection/api/modules/cura-theme-colors-module.js +1 -0
- package/dist/collection/api/modules/cura-theme-colors-module.js.map +1 -0
- package/dist/collection/api/modules/cura-theme-fonts-module.js +1 -0
- package/dist/collection/api/modules/cura-theme-fonts-module.js.map +1 -0
- package/dist/collection/api/modules/cura-theme-module.js +1 -0
- package/dist/collection/api/modules/cura-theme-module.js.map +1 -0
- package/dist/collection/api/modules/cura-theme-spacing-module.js +1 -0
- package/dist/collection/api/modules/cura-theme-spacing-module.js.map +1 -0
- package/dist/collection/api/theme-presets/static.js +1 -0
- package/dist/collection/api/theme-presets/static.js.map +1 -0
- package/dist/collection/api/theme-presets/theme-default.js +6 -5
- package/dist/collection/api/theme-presets/theme-default.js.map +1 -0
- package/dist/collection/api/theme-presets/theme-maternity.js +8 -0
- package/dist/collection/api/theme-presets/theme-maternity.js.map +1 -0
- package/dist/collection/api/theme-presets/theme-oncology.js +27 -12
- package/dist/collection/api/theme-presets/theme-oncology.js.map +1 -0
- package/dist/collection/api/theme-presets/theme-presets.js +1 -0
- package/dist/collection/api/theme-presets/theme-presets.js.map +1 -0
- package/dist/collection/assets/icons/iconset-default-list.js +1 -0
- package/dist/collection/assets/icons/iconset-default-list.js.map +1 -0
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/buttons/cura-button/cura-button.css +70 -0
- package/dist/collection/components/buttons/cura-button/cura-button.js +255 -0
- package/dist/collection/components/buttons/cura-button/cura-button.js.map +1 -0
- package/dist/collection/components/cura-icon/cura-icon.js +6 -4
- package/dist/collection/components/cura-icon/cura-icon.js.map +1 -0
- package/dist/collection/components/cura-icons-view/cura-icons-view.js +2 -1
- package/dist/collection/components/cura-icons-view/cura-icons-view.js.map +1 -0
- package/dist/collection/components/cura-page-template/cura-page-template.css +6 -24
- package/dist/collection/components/cura-page-template/cura-page-template.js +1 -0
- package/dist/collection/components/cura-page-template/cura-page-template.js.map +1 -0
- package/dist/collection/components/text/cura-display/cura-display.js +1 -16
- package/dist/collection/components/text/cura-display/cura-display.js.map +1 -0
- package/dist/collection/components/text/cura-heading/cura-heading.js +1 -20
- package/dist/collection/components/text/cura-heading/cura-heading.js.map +1 -0
- package/dist/collection/components/text/cura-paragraph/cura-paragraph.js +1 -12
- package/dist/collection/components/text/cura-paragraph/cura-paragraph.js.map +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/rededor-cura-start.js +1 -0
- package/dist/collection/rededor-cura-start.js.map +1 -0
- package/dist/collection/utils/utils.js +1 -0
- package/dist/collection/utils/utils.js.map +1 -0
- package/dist/collection/utils/utils.spec.js +16 -0
- package/dist/collection/utils/utils.spec.js.map +1 -0
- package/dist/components/cura-button.d.ts +11 -0
- package/dist/components/cura-button.js +97 -0
- package/dist/components/cura-button.js.map +1 -0
- package/dist/components/cura-display.js +3 -17
- package/dist/components/cura-display.js.map +1 -0
- package/dist/components/cura-heading.js +3 -21
- package/dist/components/cura-heading.js.map +1 -0
- package/dist/components/cura-icon.js +2 -0
- package/dist/components/cura-icon.js.map +1 -0
- package/dist/components/cura-icon2.js +8 -5
- package/dist/components/cura-icon2.js.map +1 -0
- package/dist/components/cura-icons-view.js +4 -2
- package/dist/components/cura-icons-view.js.map +1 -0
- package/dist/components/cura-page-template.js +4 -2
- package/dist/components/cura-page-template.js.map +1 -0
- package/dist/components/cura-paragraph.js +3 -13
- package/dist/components/cura-paragraph.js.map +1 -0
- package/dist/components/index.d.ts +21 -9
- package/dist/components/index.js +67 -24
- package/dist/components/index.js.map +1 -0
- package/dist/cura/cura.esm.js +2 -1
- package/dist/cura/cura.esm.js.map +1 -0
- package/dist/cura/cura.js +3 -1
- package/dist/cura/index.esm.js +2 -0
- package/dist/cura/index.esm.js.map +1 -0
- package/dist/cura/p-118112e5.system.js +14 -0
- package/dist/cura/p-118112e5.system.js.map +1 -0
- package/dist/cura/p-183305c3.js +2 -0
- package/dist/cura/p-183305c3.js.map +1 -0
- package/dist/cura/p-3f6aaefc.system.js +2 -0
- package/dist/cura/p-3f6aaefc.system.js.map +1 -0
- package/dist/cura/p-4c60d085.entry.js +2 -0
- package/dist/cura/p-4c60d085.entry.js.map +1 -0
- package/dist/cura/p-4fc49972.system.js +2 -0
- package/dist/cura/p-4fc49972.system.js.map +1 -0
- package/dist/cura/p-50ea2036.system.js +2 -1
- package/dist/cura/p-50ea2036.system.js.map +1 -0
- package/dist/cura/p-61953b75.system.js +2 -0
- package/dist/cura/p-61953b75.system.js.map +1 -0
- package/dist/cura/p-731abb13.entry.js +2 -0
- package/dist/cura/p-731abb13.entry.js.map +1 -0
- package/dist/cura/{p-5b5cf2e4.system.entry.js → p-958c8695.system.entry.js} +2 -1
- package/dist/cura/p-958c8695.system.entry.js.map +1 -0
- package/dist/cura/p-b5872ed0.system.entry.js +2 -0
- package/dist/cura/p-b5872ed0.system.entry.js.map +1 -0
- package/dist/cura/p-bac0b4ab.js +2 -0
- package/dist/cura/p-bac0b4ab.js.map +1 -0
- package/dist/cura/p-beab48cd.js +13 -0
- package/dist/cura/p-beab48cd.js.map +1 -0
- package/dist/cura/p-c30e14d5.system.js +3 -0
- package/dist/cura/p-c30e14d5.system.js.map +1 -0
- package/dist/cura/p-d5990392.js +3 -0
- package/dist/cura/p-d5990392.js.map +1 -0
- package/dist/dist/loader/index.d.ts +9 -0
- package/dist/esm/{app-globals-cb45bff3.js → app-globals-8ed931e6.js} +40 -17
- package/dist/esm/app-globals-8ed931e6.js.map +1 -0
- package/dist/esm/css-shim-d13f0738.js +6 -0
- package/dist/esm/css-shim-d13f0738.js.map +1 -0
- package/dist/esm/{cura-display_4.entry.js → cura-button_6.entry.js} +114 -51
- package/dist/esm/cura-button_6.entry.js.map +1 -0
- package/dist/esm/cura-icons-view.entry.js +4 -2
- package/dist/esm/cura-icons-view.entry.js.map +1 -0
- package/dist/esm/cura.js +16 -4
- package/dist/esm/cura.js.map +1 -0
- package/dist/esm/{index-c3d31886.js → index-e11775ce.js} +826 -30
- package/dist/esm/index-e11775ce.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +23 -4
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/shadow-css-07b0c8c8.js +389 -0
- package/dist/esm/shadow-css-07b0c8c8.js.map +1 -0
- package/dist/esm-es5/app-globals-8ed931e6.js +2 -0
- package/dist/esm-es5/app-globals-8ed931e6.js.map +1 -0
- package/dist/esm-es5/css-shim-d13f0738.js +2 -0
- package/dist/esm-es5/css-shim-d13f0738.js.map +1 -0
- package/dist/esm-es5/cura-button_6.entry.js +2 -0
- package/dist/esm-es5/cura-button_6.entry.js.map +1 -0
- package/dist/esm-es5/cura-icons-view.entry.js +2 -1
- package/dist/esm-es5/cura-icons-view.entry.js.map +1 -0
- package/dist/esm-es5/cura.js +2 -1
- package/dist/esm-es5/cura.js.map +1 -0
- package/dist/esm-es5/index-e11775ce.js +3 -0
- package/dist/esm-es5/index-e11775ce.js.map +1 -0
- package/dist/esm-es5/index.js +2 -0
- package/dist/esm-es5/index.js.map +1 -0
- package/dist/esm-es5/loader.js +2 -1
- package/dist/esm-es5/loader.js.map +1 -0
- package/dist/esm-es5/shadow-css-07b0c8c8.js +13 -0
- package/dist/esm-es5/shadow-css-07b0c8c8.js.map +1 -0
- package/dist/types/api/theme-presets/theme-maternity.d.ts +7 -0
- package/dist/types/api/theme-presets/theme-oncology.d.ts +5 -5
- package/dist/types/api/theme-presets/theme-presets.d.ts +12 -5
- package/dist/types/components/buttons/cura-button/cura-button.d.ts +49 -0
- package/dist/types/components.d.ts +93 -0
- package/dist/types/stencil-public-runtime.d.ts +77 -15
- package/package.json +7 -7
- package/dist/cjs/cura-icon.cjs.entry.js +0 -59
- package/dist/cura/p-22290742.entry.js +0 -1
- package/dist/cura/p-32769783.system.js +0 -1
- package/dist/cura/p-84b2ad25.entry.js +0 -1
- package/dist/cura/p-8b416bc6.system.js +0 -1
- package/dist/cura/p-a50716bc.js +0 -2
- package/dist/cura/p-aca36c98.js +0 -1
- package/dist/cura/p-e3facf6a.system.entry.js +0 -1
- package/dist/cura/p-e447016d.system.js +0 -2
- package/dist/cura/p-e8fadcfa.system.entry.js +0 -1
- package/dist/cura/p-fbcea891.entry.js +0 -1
- package/dist/esm/cura-icon.entry.js +0 -55
- package/dist/esm-es5/app-globals-cb45bff3.js +0 -1
- package/dist/esm-es5/cura-display_4.entry.js +0 -1
- package/dist/esm-es5/cura-icon.entry.js +0 -1
- package/dist/esm-es5/index-c3d31886.js +0 -2
|
@@ -9,7 +9,11 @@ const NAMESPACE = 'cura';
|
|
|
9
9
|
* Modified for Stencil's renderer and slot projection
|
|
10
10
|
*/
|
|
11
11
|
let scopeId;
|
|
12
|
+
let contentRef;
|
|
12
13
|
let hostTagName;
|
|
14
|
+
let useNativeShadowDom = false;
|
|
15
|
+
let checkSlotFallbackVisibility = false;
|
|
16
|
+
let checkSlotRelocate = false;
|
|
13
17
|
let isSvgMode = false;
|
|
14
18
|
let queuePending = false;
|
|
15
19
|
const createTime = (fnName, tagName = '') => {
|
|
@@ -26,6 +30,13 @@ const uniqueTime = (key, measureText) => {
|
|
|
26
30
|
};
|
|
27
31
|
}
|
|
28
32
|
};
|
|
33
|
+
const CONTENT_REF_ID = 'r';
|
|
34
|
+
const ORG_LOCATION_ID = 'o';
|
|
35
|
+
const SLOT_NODE_ID = 's';
|
|
36
|
+
const TEXT_NODE_ID = 't';
|
|
37
|
+
const HYDRATE_ID = 's-id';
|
|
38
|
+
const HYDRATED_STYLE_ID = 'sty-id';
|
|
39
|
+
const HYDRATE_CHILD_ID = 'c-id';
|
|
29
40
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
30
41
|
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
31
42
|
/**
|
|
@@ -42,11 +53,30 @@ const EMPTY_OBJ = {};
|
|
|
42
53
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
43
54
|
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
44
55
|
const isDef = (v) => v != null;
|
|
56
|
+
/**
|
|
57
|
+
* Check whether a value is a 'complex type', defined here as an object or a
|
|
58
|
+
* function.
|
|
59
|
+
*
|
|
60
|
+
* @param o the value to check
|
|
61
|
+
* @returns whether it's a complex type or not
|
|
62
|
+
*/
|
|
45
63
|
const isComplexType = (o) => {
|
|
46
64
|
// https://jsperf.com/typeof-fn-object/5
|
|
47
65
|
o = typeof o;
|
|
48
66
|
return o === 'object' || o === 'function';
|
|
49
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
70
|
+
* out of a DOM's head.
|
|
71
|
+
*
|
|
72
|
+
* @param doc The DOM containing the `head` to query against
|
|
73
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
74
|
+
* exists or the tag has no content.
|
|
75
|
+
*/
|
|
76
|
+
function queryNonceMetaTagContent(doc) {
|
|
77
|
+
var _a, _b, _c;
|
|
78
|
+
return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
|
|
79
|
+
}
|
|
50
80
|
/**
|
|
51
81
|
* Production h() function based on Preact by
|
|
52
82
|
* Jason Miller (@developit)
|
|
@@ -55,11 +85,11 @@ const isComplexType = (o) => {
|
|
|
55
85
|
*
|
|
56
86
|
* Modified for Stencil's compiler and vdom
|
|
57
87
|
*/
|
|
58
|
-
// const stack: any[] = [];
|
|
59
88
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
60
89
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
61
90
|
const h = (nodeName, vnodeData, ...children) => {
|
|
62
91
|
let child = null;
|
|
92
|
+
let slotName = null;
|
|
63
93
|
let simple = false;
|
|
64
94
|
let lastSimple = false;
|
|
65
95
|
const vNodeChildren = [];
|
|
@@ -87,6 +117,9 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
87
117
|
};
|
|
88
118
|
walk(children);
|
|
89
119
|
if (vnodeData) {
|
|
120
|
+
if (vnodeData.name) {
|
|
121
|
+
slotName = vnodeData.name;
|
|
122
|
+
}
|
|
90
123
|
{
|
|
91
124
|
const classData = vnodeData.className || vnodeData.class;
|
|
92
125
|
if (classData) {
|
|
@@ -104,8 +137,19 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
104
137
|
if (vNodeChildren.length > 0) {
|
|
105
138
|
vnode.$children$ = vNodeChildren;
|
|
106
139
|
}
|
|
140
|
+
{
|
|
141
|
+
vnode.$name$ = slotName;
|
|
142
|
+
}
|
|
107
143
|
return vnode;
|
|
108
144
|
};
|
|
145
|
+
/**
|
|
146
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
147
|
+
* possible text content.
|
|
148
|
+
*
|
|
149
|
+
* @param tag the tag for this element
|
|
150
|
+
* @param text possible text content for the node
|
|
151
|
+
* @returns a newly-minted virtual DOM node
|
|
152
|
+
*/
|
|
109
153
|
const newVNode = (tag, text) => {
|
|
110
154
|
const vnode = {
|
|
111
155
|
$flags$: 0,
|
|
@@ -117,10 +161,224 @@ const newVNode = (tag, text) => {
|
|
|
117
161
|
{
|
|
118
162
|
vnode.$attrs$ = null;
|
|
119
163
|
}
|
|
164
|
+
{
|
|
165
|
+
vnode.$name$ = null;
|
|
166
|
+
}
|
|
120
167
|
return vnode;
|
|
121
168
|
};
|
|
122
169
|
const Host = {};
|
|
170
|
+
/**
|
|
171
|
+
* Check whether a given node is a Host node or not
|
|
172
|
+
*
|
|
173
|
+
* @param node the virtual DOM node to check
|
|
174
|
+
* @returns whether it's a Host node or not
|
|
175
|
+
*/
|
|
123
176
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
177
|
+
const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
178
|
+
const endHydrate = createTime('hydrateClient', tagName);
|
|
179
|
+
const shadowRoot = hostElm.shadowRoot;
|
|
180
|
+
const childRenderNodes = [];
|
|
181
|
+
const slotNodes = [];
|
|
182
|
+
const shadowRootNodes = shadowRoot ? [] : null;
|
|
183
|
+
const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
|
184
|
+
if (!plt.$orgLocNodes$) {
|
|
185
|
+
initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
|
186
|
+
}
|
|
187
|
+
hostElm[HYDRATE_ID] = hostId;
|
|
188
|
+
hostElm.removeAttribute(HYDRATE_ID);
|
|
189
|
+
clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
|
190
|
+
childRenderNodes.map((c) => {
|
|
191
|
+
const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
|
192
|
+
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
193
|
+
const node = c.$elm$;
|
|
194
|
+
if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
|
195
|
+
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
|
196
|
+
}
|
|
197
|
+
if (!shadowRoot) {
|
|
198
|
+
node['s-hn'] = tagName;
|
|
199
|
+
if (orgLocationNode) {
|
|
200
|
+
node['s-ol'] = orgLocationNode;
|
|
201
|
+
node['s-ol']['s-nr'] = node;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
plt.$orgLocNodes$.delete(orgLocationId);
|
|
205
|
+
});
|
|
206
|
+
if (shadowRoot) {
|
|
207
|
+
shadowRootNodes.map((shadowRootNode) => {
|
|
208
|
+
if (shadowRootNode) {
|
|
209
|
+
shadowRoot.appendChild(shadowRootNode);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
endHydrate();
|
|
214
|
+
};
|
|
215
|
+
const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
|
216
|
+
let childNodeType;
|
|
217
|
+
let childIdSplt;
|
|
218
|
+
let childVNode;
|
|
219
|
+
let i;
|
|
220
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
221
|
+
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
222
|
+
if (childNodeType) {
|
|
223
|
+
// got the node data from the element's attribute
|
|
224
|
+
// `${hostId}.${nodeId}.${depth}.${index}`
|
|
225
|
+
childIdSplt = childNodeType.split('.');
|
|
226
|
+
if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
|
227
|
+
childVNode = {
|
|
228
|
+
$flags$: 0,
|
|
229
|
+
$hostId$: childIdSplt[0],
|
|
230
|
+
$nodeId$: childIdSplt[1],
|
|
231
|
+
$depth$: childIdSplt[2],
|
|
232
|
+
$index$: childIdSplt[3],
|
|
233
|
+
$tag$: node.tagName.toLowerCase(),
|
|
234
|
+
$elm$: node,
|
|
235
|
+
$attrs$: null,
|
|
236
|
+
$children$: null,
|
|
237
|
+
$key$: null,
|
|
238
|
+
$name$: null,
|
|
239
|
+
$text$: null,
|
|
240
|
+
};
|
|
241
|
+
childRenderNodes.push(childVNode);
|
|
242
|
+
node.removeAttribute(HYDRATE_CHILD_ID);
|
|
243
|
+
// this is a new child vnode
|
|
244
|
+
// so ensure its parent vnode has the vchildren array
|
|
245
|
+
if (!parentVNode.$children$) {
|
|
246
|
+
parentVNode.$children$ = [];
|
|
247
|
+
}
|
|
248
|
+
// add our child vnode to a specific index of the vnode's children
|
|
249
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
250
|
+
// this is now the new parent vnode for all the next child checks
|
|
251
|
+
parentVNode = childVNode;
|
|
252
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
253
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
// recursively drill down, end to start so we can remove nodes
|
|
258
|
+
for (i = node.childNodes.length - 1; i >= 0; i--) {
|
|
259
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
|
260
|
+
}
|
|
261
|
+
if (node.shadowRoot) {
|
|
262
|
+
// keep drilling down through the shadow root nodes
|
|
263
|
+
for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
|
264
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
269
|
+
// `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
|
|
270
|
+
childIdSplt = node.nodeValue.split('.');
|
|
271
|
+
if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
|
272
|
+
// comment node for either the host id or a 0 host id
|
|
273
|
+
childNodeType = childIdSplt[0];
|
|
274
|
+
childVNode = {
|
|
275
|
+
$flags$: 0,
|
|
276
|
+
$hostId$: childIdSplt[1],
|
|
277
|
+
$nodeId$: childIdSplt[2],
|
|
278
|
+
$depth$: childIdSplt[3],
|
|
279
|
+
$index$: childIdSplt[4],
|
|
280
|
+
$elm$: node,
|
|
281
|
+
$attrs$: null,
|
|
282
|
+
$children$: null,
|
|
283
|
+
$key$: null,
|
|
284
|
+
$name$: null,
|
|
285
|
+
$tag$: null,
|
|
286
|
+
$text$: null,
|
|
287
|
+
};
|
|
288
|
+
if (childNodeType === TEXT_NODE_ID) {
|
|
289
|
+
childVNode.$elm$ = node.nextSibling;
|
|
290
|
+
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
|
|
291
|
+
childVNode.$text$ = childVNode.$elm$.textContent;
|
|
292
|
+
childRenderNodes.push(childVNode);
|
|
293
|
+
// remove the text comment since it's no longer needed
|
|
294
|
+
node.remove();
|
|
295
|
+
if (!parentVNode.$children$) {
|
|
296
|
+
parentVNode.$children$ = [];
|
|
297
|
+
}
|
|
298
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
299
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
300
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
else if (childVNode.$hostId$ === hostId) {
|
|
305
|
+
// this comment node is specifcally for this host id
|
|
306
|
+
if (childNodeType === SLOT_NODE_ID) {
|
|
307
|
+
// `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
|
|
308
|
+
childVNode.$tag$ = 'slot';
|
|
309
|
+
if (childIdSplt[5]) {
|
|
310
|
+
node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
node['s-sn'] = '';
|
|
314
|
+
}
|
|
315
|
+
node['s-sr'] = true;
|
|
316
|
+
if (shadowRootNodes) {
|
|
317
|
+
// browser support shadowRoot and this is a shadow dom component
|
|
318
|
+
// create an actual slot element
|
|
319
|
+
childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
|
320
|
+
if (childVNode.$name$) {
|
|
321
|
+
// add the slot name attribute
|
|
322
|
+
childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
|
323
|
+
}
|
|
324
|
+
// insert the new slot element before the slot comment
|
|
325
|
+
node.parentNode.insertBefore(childVNode.$elm$, node);
|
|
326
|
+
// remove the slot comment since it's not needed for shadow
|
|
327
|
+
node.remove();
|
|
328
|
+
if (childVNode.$depth$ === '0') {
|
|
329
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
slotNodes.push(childVNode);
|
|
333
|
+
if (!parentVNode.$children$) {
|
|
334
|
+
parentVNode.$children$ = [];
|
|
335
|
+
}
|
|
336
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
337
|
+
}
|
|
338
|
+
else if (childNodeType === CONTENT_REF_ID) {
|
|
339
|
+
// `${CONTENT_REF_ID}.${hostId}`;
|
|
340
|
+
if (shadowRootNodes) {
|
|
341
|
+
// remove the content ref comment since it's not needed for shadow
|
|
342
|
+
node.remove();
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
hostElm['s-cr'] = node;
|
|
346
|
+
node['s-cn'] = true;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else if (parentVNode && parentVNode.$tag$ === 'style') {
|
|
353
|
+
const vnode = newVNode(null, node.textContent);
|
|
354
|
+
vnode.$elm$ = node;
|
|
355
|
+
vnode.$index$ = '0';
|
|
356
|
+
parentVNode.$children$ = [vnode];
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
360
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
361
|
+
let i = 0;
|
|
362
|
+
for (; i < node.childNodes.length; i++) {
|
|
363
|
+
initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
|
364
|
+
}
|
|
365
|
+
if (node.shadowRoot) {
|
|
366
|
+
for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
|
367
|
+
initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
372
|
+
const childIdSplt = node.nodeValue.split('.');
|
|
373
|
+
if (childIdSplt[0] === ORG_LOCATION_ID) {
|
|
374
|
+
orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
|
375
|
+
node.nodeValue = '';
|
|
376
|
+
// useful to know if the original location is
|
|
377
|
+
// the root light-dom of a shadow dom component
|
|
378
|
+
node['s-en'] = childIdSplt[3];
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
};
|
|
124
382
|
/**
|
|
125
383
|
* Parse a new property value for a given property type.
|
|
126
384
|
*
|
|
@@ -199,6 +457,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
199
457
|
styles.set(scopeId, style);
|
|
200
458
|
};
|
|
201
459
|
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
460
|
+
var _a;
|
|
202
461
|
let scopeId = getScopeId(cmpMeta);
|
|
203
462
|
const style = styles.get(scopeId);
|
|
204
463
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
@@ -213,11 +472,36 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
213
472
|
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
214
473
|
}
|
|
215
474
|
if (!appliedStyles.has(scopeId)) {
|
|
216
|
-
|
|
217
|
-
{
|
|
475
|
+
if (styleContainerNode.host &&
|
|
476
|
+
(styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
|
477
|
+
// This is only happening on native shadow-dom, do not needs CSS var shim
|
|
478
|
+
styleElm.innerHTML = style;
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
482
|
+
if (plt.$cssShim$) {
|
|
483
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
484
|
+
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style,
|
|
485
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
486
|
+
!!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
|
|
487
|
+
const newScopeId = styleElm['s-sc'];
|
|
488
|
+
if (newScopeId) {
|
|
489
|
+
scopeId = newScopeId;
|
|
490
|
+
// we don't want to add this styleID to the appliedStyles Set
|
|
491
|
+
// since the cssVarShim might need to apply several different
|
|
492
|
+
// stylesheets for the same component
|
|
493
|
+
appliedStyles = null;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
218
497
|
styleElm = doc.createElement('style');
|
|
219
498
|
styleElm.innerHTML = style;
|
|
220
499
|
}
|
|
500
|
+
// Apply CSP nonce to the style tag if it exists
|
|
501
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
502
|
+
if (nonce != null) {
|
|
503
|
+
styleElm.setAttribute('nonce', nonce);
|
|
504
|
+
}
|
|
221
505
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
222
506
|
}
|
|
223
507
|
if (appliedStyles) {
|
|
@@ -236,7 +520,8 @@ const attachStyles = (hostRef) => {
|
|
|
236
520
|
const elm = hostRef.$hostElement$;
|
|
237
521
|
const flags = cmpMeta.$flags$;
|
|
238
522
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
239
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
523
|
+
const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
|
524
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
240
525
|
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
241
526
|
// only required when we're NOT using native shadow dom (slot)
|
|
242
527
|
// or this browser doesn't support native shadow dom
|
|
@@ -251,6 +536,7 @@ const attachStyles = (hostRef) => {
|
|
|
251
536
|
endAttachStyles();
|
|
252
537
|
};
|
|
253
538
|
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
539
|
+
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
|
254
540
|
/**
|
|
255
541
|
* Production setAccessor() function based on Preact by
|
|
256
542
|
* Jason Miller (@developit)
|
|
@@ -431,16 +717,39 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
431
717
|
let i = 0;
|
|
432
718
|
let elm;
|
|
433
719
|
let childNode;
|
|
720
|
+
let oldVNode;
|
|
721
|
+
if (!useNativeShadowDom) {
|
|
722
|
+
// remember for later we need to check to relocate nodes
|
|
723
|
+
checkSlotRelocate = true;
|
|
724
|
+
if (newVNode.$tag$ === 'slot') {
|
|
725
|
+
if (scopeId) {
|
|
726
|
+
// scoped css needs to add its scoped id to the parent element
|
|
727
|
+
parentElm.classList.add(scopeId + '-s');
|
|
728
|
+
}
|
|
729
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
730
|
+
? // slot element has fallback content
|
|
731
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
732
|
+
: // slot element does not have fallback content
|
|
733
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
434
736
|
if (newVNode.$text$ !== null) {
|
|
435
737
|
// create text node
|
|
436
738
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
437
739
|
}
|
|
740
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
741
|
+
// create a slot reference node
|
|
742
|
+
elm = newVNode.$elm$ =
|
|
743
|
+
doc.createTextNode('');
|
|
744
|
+
}
|
|
438
745
|
else {
|
|
439
746
|
if (!isSvgMode) {
|
|
440
747
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
441
748
|
}
|
|
442
749
|
// create element
|
|
443
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$
|
|
750
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
751
|
+
? 'slot-fb'
|
|
752
|
+
: newVNode.$tag$)
|
|
444
753
|
);
|
|
445
754
|
if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
|
446
755
|
isSvgMode = false;
|
|
@@ -457,7 +766,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
457
766
|
if (newVNode.$children$) {
|
|
458
767
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
459
768
|
// create the node
|
|
460
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
769
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
461
770
|
// return node could have been null
|
|
462
771
|
if (childNode) {
|
|
463
772
|
// append our new node
|
|
@@ -476,30 +785,115 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
476
785
|
}
|
|
477
786
|
}
|
|
478
787
|
}
|
|
788
|
+
{
|
|
789
|
+
elm['s-hn'] = hostTagName;
|
|
790
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
791
|
+
// remember the content reference comment
|
|
792
|
+
elm['s-sr'] = true;
|
|
793
|
+
// remember the content reference comment
|
|
794
|
+
elm['s-cr'] = contentRef;
|
|
795
|
+
// remember the slot name, or empty string for default slot
|
|
796
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
797
|
+
// check if we've got an old vnode for this slot
|
|
798
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
799
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
800
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
801
|
+
// so let's move the old slot content back to it's original location
|
|
802
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
}
|
|
479
806
|
return elm;
|
|
480
807
|
};
|
|
808
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
809
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
810
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
811
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
812
|
+
const childNode = oldSlotChildNodes[i];
|
|
813
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
814
|
+
// // this child node in the old element is from another component
|
|
815
|
+
// // remove this node from the old slot's parent
|
|
816
|
+
// childNode.remove();
|
|
817
|
+
// and relocate it back to it's original location
|
|
818
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
819
|
+
// remove the old original location comment entirely
|
|
820
|
+
// later on the patch function will know what to do
|
|
821
|
+
// and move this to the correct spot in need be
|
|
822
|
+
childNode['s-ol'].remove();
|
|
823
|
+
childNode['s-ol'] = undefined;
|
|
824
|
+
checkSlotRelocate = true;
|
|
825
|
+
}
|
|
826
|
+
if (recursive) {
|
|
827
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
831
|
+
};
|
|
832
|
+
/**
|
|
833
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
834
|
+
* add them to the DOM in the appropriate place.
|
|
835
|
+
*
|
|
836
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
837
|
+
* DOM nodes
|
|
838
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
839
|
+
* inserted before (optional)
|
|
840
|
+
* @param parentVNode the parent virtual DOM node
|
|
841
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
842
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
843
|
+
* creating DOM nodes (inclusive)
|
|
844
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
845
|
+
* creating DOM nodes (inclusive)
|
|
846
|
+
*/
|
|
481
847
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
482
|
-
let containerElm = (parentElm);
|
|
848
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
483
849
|
let childNode;
|
|
484
850
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
485
851
|
containerElm = containerElm.shadowRoot;
|
|
486
852
|
}
|
|
487
853
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
488
854
|
if (vnodes[startIdx]) {
|
|
489
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
855
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
490
856
|
if (childNode) {
|
|
491
857
|
vnodes[startIdx].$elm$ = childNode;
|
|
492
|
-
containerElm.insertBefore(childNode, before);
|
|
858
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
493
859
|
}
|
|
494
860
|
}
|
|
495
861
|
}
|
|
496
862
|
};
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
863
|
+
/**
|
|
864
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
865
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
866
|
+
* should no longer be shown.
|
|
867
|
+
*
|
|
868
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
869
|
+
*
|
|
870
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
871
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
872
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
873
|
+
*/
|
|
874
|
+
const removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
875
|
+
for (let index = startIdx; index <= endIdx; ++index) {
|
|
876
|
+
const vnode = vnodes[index];
|
|
877
|
+
if (vnode) {
|
|
878
|
+
const elm = vnode.$elm$;
|
|
879
|
+
if (elm) {
|
|
880
|
+
{
|
|
881
|
+
// we're removing this element
|
|
882
|
+
// so it's possible we need to show slot fallback content now
|
|
883
|
+
checkSlotFallbackVisibility = true;
|
|
884
|
+
if (elm['s-ol']) {
|
|
885
|
+
// remove the original location comment
|
|
886
|
+
elm['s-ol'].remove();
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
// it's possible that child nodes of the node
|
|
890
|
+
// that's being removed are slot nodes
|
|
891
|
+
putBackInOriginalLocation(elm, true);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
// remove the vnode's element from the dom
|
|
895
|
+
elm.remove();
|
|
896
|
+
}
|
|
503
897
|
}
|
|
504
898
|
}
|
|
505
899
|
};
|
|
@@ -613,6 +1007,23 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
613
1007
|
newEndVnode = newCh[--newEndIdx];
|
|
614
1008
|
}
|
|
615
1009
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
1010
|
+
// case: "Vnode moved right"
|
|
1011
|
+
//
|
|
1012
|
+
// We've found that the last node in our window on the new children is
|
|
1013
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
1014
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
1015
|
+
// nodes:
|
|
1016
|
+
//
|
|
1017
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
1018
|
+
// ^^^^^^^^^^^
|
|
1019
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
1020
|
+
// ^^^^^^^^^^^^^
|
|
1021
|
+
//
|
|
1022
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
1023
|
+
// and move the DOM element for `oldStartVnode`.
|
|
1024
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
1025
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
1026
|
+
}
|
|
616
1027
|
patch(oldStartVnode, newEndVnode);
|
|
617
1028
|
// We need to move the element for `oldStartVnode` into a position which
|
|
618
1029
|
// will be appropriate for `newEndVnode`. For this we can use
|
|
@@ -636,6 +1047,24 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
636
1047
|
newEndVnode = newCh[--newEndIdx];
|
|
637
1048
|
}
|
|
638
1049
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
1050
|
+
// case: "Vnode moved left"
|
|
1051
|
+
//
|
|
1052
|
+
// We've found that the first node in our window on the new children is
|
|
1053
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
1054
|
+
// Visually, this is the layout of these two nodes:
|
|
1055
|
+
//
|
|
1056
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
1057
|
+
// ^^^^^^^^^^^^^
|
|
1058
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
1059
|
+
// ^^^^^^^^^^^
|
|
1060
|
+
//
|
|
1061
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
1062
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
1063
|
+
// children etc) but we also need to move the DOM node to which
|
|
1064
|
+
// `oldEndVnode` corresponds.
|
|
1065
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
1066
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
1067
|
+
}
|
|
639
1068
|
patch(oldEndVnode, newStartVnode);
|
|
640
1069
|
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
641
1070
|
// the same node, so since we're here we know that they are not. Thus we
|
|
@@ -652,13 +1081,13 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
652
1081
|
// the key of the first new child OR the build is not using `key`
|
|
653
1082
|
// attributes at all. In either case we need to create a new element
|
|
654
1083
|
// for the new node.
|
|
655
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
1084
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
656
1085
|
newStartVnode = newCh[++newStartIdx];
|
|
657
1086
|
}
|
|
658
1087
|
if (node) {
|
|
659
1088
|
// if we created a new node then handle inserting it to the DOM
|
|
660
1089
|
{
|
|
661
|
-
oldStartVnode.$elm
|
|
1090
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
662
1091
|
}
|
|
663
1092
|
}
|
|
664
1093
|
}
|
|
@@ -685,7 +1114,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
685
1114
|
*
|
|
686
1115
|
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
687
1116
|
* changing order within a `children` array or something along those lines then
|
|
688
|
-
* we could obtain a false
|
|
1117
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
1118
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
689
1119
|
*
|
|
690
1120
|
* @param leftVNode the first VNode to check
|
|
691
1121
|
* @param rightVNode the second VNode to check
|
|
@@ -695,10 +1125,21 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
695
1125
|
// compare if two vnode to see if they're "technically" the same
|
|
696
1126
|
// need to have the same element tag, and same key to be the same
|
|
697
1127
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
1128
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
1129
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
1130
|
+
}
|
|
698
1131
|
return true;
|
|
699
1132
|
}
|
|
700
1133
|
return false;
|
|
701
1134
|
};
|
|
1135
|
+
const referenceNode = (node) => {
|
|
1136
|
+
// this node was relocated to a new location in the dom
|
|
1137
|
+
// because of some other component's slot
|
|
1138
|
+
// but we still have an html comment in place of where
|
|
1139
|
+
// it's original location was according to it's original vdom
|
|
1140
|
+
return (node && node['s-ol']) || node;
|
|
1141
|
+
};
|
|
1142
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
702
1143
|
/**
|
|
703
1144
|
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
704
1145
|
* it. This function handles flushing updates to the DOM and reconciling the
|
|
@@ -713,6 +1154,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
713
1154
|
const newChildren = newVNode.$children$;
|
|
714
1155
|
const tag = newVNode.$tag$;
|
|
715
1156
|
const text = newVNode.$text$;
|
|
1157
|
+
let defaultHolder;
|
|
716
1158
|
if (text === null) {
|
|
717
1159
|
{
|
|
718
1160
|
// test if we're rendering an svg element, or still rendering nodes inside of one
|
|
@@ -751,12 +1193,159 @@ const patch = (oldVNode, newVNode) => {
|
|
|
751
1193
|
isSvgMode = false;
|
|
752
1194
|
}
|
|
753
1195
|
}
|
|
1196
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
1197
|
+
// this element has slotted content
|
|
1198
|
+
defaultHolder.parentNode.textContent = text;
|
|
1199
|
+
}
|
|
754
1200
|
else if (oldVNode.$text$ !== text) {
|
|
755
1201
|
// update the text content for the text only vnode
|
|
756
1202
|
// and also only if the text is different than before
|
|
757
1203
|
elm.data = text;
|
|
758
1204
|
}
|
|
759
1205
|
};
|
|
1206
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
1207
|
+
// tslint:disable-next-line: prefer-const
|
|
1208
|
+
const childNodes = elm.childNodes;
|
|
1209
|
+
let childNode;
|
|
1210
|
+
let i;
|
|
1211
|
+
let ilen;
|
|
1212
|
+
let j;
|
|
1213
|
+
let slotNameAttr;
|
|
1214
|
+
let nodeType;
|
|
1215
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
1216
|
+
childNode = childNodes[i];
|
|
1217
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1218
|
+
if (childNode['s-sr']) {
|
|
1219
|
+
// this is a slot fallback node
|
|
1220
|
+
// get the slot name for this slot reference node
|
|
1221
|
+
slotNameAttr = childNode['s-sn'];
|
|
1222
|
+
// by default always show a fallback slot node
|
|
1223
|
+
// then hide it if there are other slots in the light dom
|
|
1224
|
+
childNode.hidden = false;
|
|
1225
|
+
for (j = 0; j < ilen; j++) {
|
|
1226
|
+
nodeType = childNodes[j].nodeType;
|
|
1227
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
1228
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
1229
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1230
|
+
childNode.hidden = true;
|
|
1231
|
+
break;
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
else {
|
|
1235
|
+
// this is a default fallback slot node
|
|
1236
|
+
// any element or text node (with content)
|
|
1237
|
+
// should hide the default fallback slot node
|
|
1238
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1239
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1240
|
+
childNode.hidden = true;
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
// keep drilling down
|
|
1247
|
+
updateFallbackSlotVisibility(childNode);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
const relocateNodes = [];
|
|
1252
|
+
const relocateSlotContent = (elm) => {
|
|
1253
|
+
// tslint:disable-next-line: prefer-const
|
|
1254
|
+
let childNode;
|
|
1255
|
+
let node;
|
|
1256
|
+
let hostContentNodes;
|
|
1257
|
+
let slotNameAttr;
|
|
1258
|
+
let relocateNodeData;
|
|
1259
|
+
let j;
|
|
1260
|
+
let i = 0;
|
|
1261
|
+
const childNodes = elm.childNodes;
|
|
1262
|
+
const ilen = childNodes.length;
|
|
1263
|
+
for (; i < ilen; i++) {
|
|
1264
|
+
childNode = childNodes[i];
|
|
1265
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
1266
|
+
// first got the content reference comment node
|
|
1267
|
+
// then we got it's parent, which is where all the host content is in now
|
|
1268
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
1269
|
+
slotNameAttr = childNode['s-sn'];
|
|
1270
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
1271
|
+
node = hostContentNodes[j];
|
|
1272
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
1273
|
+
// let's do some relocating to its new home
|
|
1274
|
+
// but never relocate a content reference node
|
|
1275
|
+
// that is suppose to always represent the original content location
|
|
1276
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
1277
|
+
// it's possible we've already decided to relocate this node
|
|
1278
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1279
|
+
// made some changes to slots
|
|
1280
|
+
// let's make sure we also double check
|
|
1281
|
+
// fallbacks are correctly hidden or shown
|
|
1282
|
+
checkSlotFallbackVisibility = true;
|
|
1283
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
1284
|
+
if (relocateNodeData) {
|
|
1285
|
+
// previously we never found a slot home for this node
|
|
1286
|
+
// but turns out we did, so let's remember it now
|
|
1287
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
1288
|
+
}
|
|
1289
|
+
else {
|
|
1290
|
+
// add to our list of nodes to relocate
|
|
1291
|
+
relocateNodes.push({
|
|
1292
|
+
$slotRefNode$: childNode,
|
|
1293
|
+
$nodeToRelocate$: node,
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
if (node['s-sr']) {
|
|
1297
|
+
relocateNodes.map((relocateNode) => {
|
|
1298
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
1299
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1300
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
1301
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
1308
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
1309
|
+
// if we never find a home for this element then we'll need to hide it
|
|
1310
|
+
relocateNodes.push({
|
|
1311
|
+
$nodeToRelocate$: node,
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
}
|
|
1317
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1318
|
+
relocateSlotContent(childNode);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
1323
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1324
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
1325
|
+
return true;
|
|
1326
|
+
}
|
|
1327
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
1328
|
+
return true;
|
|
1329
|
+
}
|
|
1330
|
+
return false;
|
|
1331
|
+
}
|
|
1332
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
return slotNameAttr === '';
|
|
1336
|
+
};
|
|
1337
|
+
/**
|
|
1338
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
1339
|
+
*
|
|
1340
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
1341
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
1342
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
1343
|
+
* relocation, and reflecting attributes.
|
|
1344
|
+
*
|
|
1345
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
1346
|
+
* the DOM node into which it should be rendered.
|
|
1347
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
1348
|
+
*/
|
|
760
1349
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
761
1350
|
const hostElm = hostRef.$hostElement$;
|
|
762
1351
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
@@ -774,8 +1363,90 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
774
1363
|
{
|
|
775
1364
|
scopeId = hostElm['s-sc'];
|
|
776
1365
|
}
|
|
1366
|
+
{
|
|
1367
|
+
contentRef = hostElm['s-cr'];
|
|
1368
|
+
useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
1369
|
+
// always reset
|
|
1370
|
+
checkSlotFallbackVisibility = false;
|
|
1371
|
+
}
|
|
777
1372
|
// synchronous patch
|
|
778
1373
|
patch(oldVNode, rootVnode);
|
|
1374
|
+
{
|
|
1375
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
1376
|
+
// the disconnectCallback from working
|
|
1377
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1378
|
+
if (checkSlotRelocate) {
|
|
1379
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
1380
|
+
let relocateData;
|
|
1381
|
+
let nodeToRelocate;
|
|
1382
|
+
let orgLocationNode;
|
|
1383
|
+
let parentNodeRef;
|
|
1384
|
+
let insertBeforeNode;
|
|
1385
|
+
let refNode;
|
|
1386
|
+
let i = 0;
|
|
1387
|
+
for (; i < relocateNodes.length; i++) {
|
|
1388
|
+
relocateData = relocateNodes[i];
|
|
1389
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1390
|
+
if (!nodeToRelocate['s-ol']) {
|
|
1391
|
+
// add a reference node marking this node's original location
|
|
1392
|
+
// keep a reference to this node for later lookups
|
|
1393
|
+
orgLocationNode =
|
|
1394
|
+
doc.createTextNode('');
|
|
1395
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
1396
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
1400
|
+
relocateData = relocateNodes[i];
|
|
1401
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1402
|
+
if (relocateData.$slotRefNode$) {
|
|
1403
|
+
// by default we're just going to insert it directly
|
|
1404
|
+
// after the slot reference node
|
|
1405
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
1406
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
1407
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
1408
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
1409
|
+
refNode = orgLocationNode['s-nr'];
|
|
1410
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
1411
|
+
refNode = refNode.nextSibling;
|
|
1412
|
+
if (!refNode || !refNode['s-nr']) {
|
|
1413
|
+
insertBeforeNode = refNode;
|
|
1414
|
+
break;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
1419
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
1420
|
+
// we've checked that it's worth while to relocate
|
|
1421
|
+
// since that the node to relocate
|
|
1422
|
+
// has a different next sibling or parent relocated
|
|
1423
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
1424
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1425
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
1426
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1427
|
+
}
|
|
1428
|
+
// add it back to the dom but in its new home
|
|
1429
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
else {
|
|
1434
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
1435
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1436
|
+
nodeToRelocate.hidden = true;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
if (checkSlotFallbackVisibility) {
|
|
1442
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1443
|
+
}
|
|
1444
|
+
// done moving nodes around
|
|
1445
|
+
// allow the disconnect callback to work again
|
|
1446
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1447
|
+
// always reset
|
|
1448
|
+
relocateNodes.length = 0;
|
|
1449
|
+
}
|
|
779
1450
|
};
|
|
780
1451
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
781
1452
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -797,15 +1468,54 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
797
1468
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
798
1469
|
return writeTask(dispatch) ;
|
|
799
1470
|
};
|
|
1471
|
+
/**
|
|
1472
|
+
* Dispatch initial-render and update lifecycle hooks, enqueuing calls to
|
|
1473
|
+
* component lifecycle methods like `componentWillLoad` as well as
|
|
1474
|
+
* {@link updateComponent}, which will kick off the virtual DOM re-render.
|
|
1475
|
+
*
|
|
1476
|
+
* @param hostRef a reference to a host DOM node
|
|
1477
|
+
* @param isInitialLoad whether we're on the initial load or not
|
|
1478
|
+
* @returns an empty Promise which is used to enqueue a series of operations for
|
|
1479
|
+
* the component
|
|
1480
|
+
*/
|
|
800
1481
|
const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
801
1482
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
802
1483
|
const instance = hostRef.$lazyInstance$ ;
|
|
803
|
-
|
|
1484
|
+
// We're going to use this variable together with `enqueue` to implement a
|
|
1485
|
+
// little promise-based queue. We start out with it `undefined`. When we add
|
|
1486
|
+
// the first function to the queue we'll set this variable to be that
|
|
1487
|
+
// function's return value. When we attempt to add subsequent values to the
|
|
1488
|
+
// queue we'll check that value and, if it was a `Promise`, we'll then chain
|
|
1489
|
+
// the new function off of that `Promise` using `.then()`. This will give our
|
|
1490
|
+
// queue two nice properties:
|
|
1491
|
+
//
|
|
1492
|
+
// 1. If all functions added to the queue are synchronous they'll be called
|
|
1493
|
+
// synchronously right away.
|
|
1494
|
+
// 2. If all functions added to the queue are asynchronous they'll all be
|
|
1495
|
+
// called in order after `dispatchHooks` exits.
|
|
1496
|
+
let maybePromise;
|
|
804
1497
|
endSchedule();
|
|
805
|
-
return
|
|
1498
|
+
return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
806
1499
|
};
|
|
1500
|
+
/**
|
|
1501
|
+
* This function uses a Promise to implement a simple first-in, first-out queue
|
|
1502
|
+
* of functions to be called.
|
|
1503
|
+
*
|
|
1504
|
+
* The queue is ordered on the basis of the first argument. If it's
|
|
1505
|
+
* `undefined`, then nothing is on the queue yet, so the provided function can
|
|
1506
|
+
* be called synchronously (although note that this function may return a
|
|
1507
|
+
* `Promise`). The idea is that then the return value of that enqueueing
|
|
1508
|
+
* operation is kept around, so that if it was a `Promise` then subsequent
|
|
1509
|
+
* functions can be enqueued by calling this function again with that `Promise`
|
|
1510
|
+
* as the first argument.
|
|
1511
|
+
*
|
|
1512
|
+
* @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
|
|
1513
|
+
* @param fn a function to enqueue
|
|
1514
|
+
* @returns either a `Promise` or the return value of the provided function
|
|
1515
|
+
*/
|
|
1516
|
+
const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
|
|
807
1517
|
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
808
|
-
|
|
1518
|
+
var _a;
|
|
809
1519
|
const elm = hostRef.$hostElement$;
|
|
810
1520
|
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
|
811
1521
|
const rc = elm['s-rc'];
|
|
@@ -817,6 +1527,11 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
817
1527
|
{
|
|
818
1528
|
callRender(hostRef, instance);
|
|
819
1529
|
}
|
|
1530
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1531
|
+
if (plt.$cssShim$) {
|
|
1532
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1533
|
+
plt.$cssShim$.updateHost(elm);
|
|
1534
|
+
}
|
|
820
1535
|
if (rc) {
|
|
821
1536
|
// ok, so turns out there are some child host elements
|
|
822
1537
|
// waiting on this parent element to load
|
|
@@ -827,7 +1542,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
827
1542
|
endRender();
|
|
828
1543
|
endUpdate();
|
|
829
1544
|
{
|
|
830
|
-
const childrenPromises = elm['s-p'];
|
|
1545
|
+
const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
|
|
831
1546
|
const postUpdate = () => postUpdateComponent(hostRef);
|
|
832
1547
|
if (childrenPromises.length === 0) {
|
|
833
1548
|
postUpdate();
|
|
@@ -921,9 +1636,6 @@ const safeCall = (instance, method, arg) => {
|
|
|
921
1636
|
}
|
|
922
1637
|
return undefined;
|
|
923
1638
|
};
|
|
924
|
-
const then = (promise, thenFn) => {
|
|
925
|
-
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
926
|
-
};
|
|
927
1639
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
928
1640
|
;
|
|
929
1641
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
@@ -1077,9 +1789,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1077
1789
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1078
1790
|
// initializeComponent
|
|
1079
1791
|
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1792
|
+
// Let the runtime know that the component has been initialized
|
|
1793
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1080
1794
|
{
|
|
1081
|
-
// we haven't initialized this element yet
|
|
1082
|
-
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1083
1795
|
// lazy loaded components
|
|
1084
1796
|
// request the component's implementation to be
|
|
1085
1797
|
// wired up with the host element
|
|
@@ -1132,6 +1844,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1132
1844
|
const scopeId = getScopeId(cmpMeta);
|
|
1133
1845
|
if (!styles.has(scopeId)) {
|
|
1134
1846
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1847
|
+
if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
1848
|
+
style = await import('./shadow-css-07b0c8c8.js').then((m) => m.scopeCss(style, scopeId, false));
|
|
1849
|
+
}
|
|
1135
1850
|
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1136
1851
|
endRegisterStyles();
|
|
1137
1852
|
}
|
|
@@ -1166,6 +1881,27 @@ const connectedCallback = (elm) => {
|
|
|
1166
1881
|
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1167
1882
|
// first time this component has connected
|
|
1168
1883
|
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1884
|
+
let hostId;
|
|
1885
|
+
{
|
|
1886
|
+
hostId = elm.getAttribute(HYDRATE_ID);
|
|
1887
|
+
if (hostId) {
|
|
1888
|
+
if (supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1889
|
+
const scopeId = addStyle(elm.shadowRoot, cmpMeta);
|
|
1890
|
+
elm.classList.remove(scopeId + '-h', scopeId + '-s');
|
|
1891
|
+
}
|
|
1892
|
+
initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
if (!hostId) {
|
|
1896
|
+
// initUpdate
|
|
1897
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1898
|
+
// in here to act as original content anchors as we move nodes around
|
|
1899
|
+
// host element has been connected to the DOM
|
|
1900
|
+
if ((// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
1901
|
+
cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1902
|
+
setContentReference(elm);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1169
1905
|
{
|
|
1170
1906
|
// find the first ancestor component (if there is one) and register
|
|
1171
1907
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1173,7 +1909,10 @@ const connectedCallback = (elm) => {
|
|
|
1173
1909
|
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
|
1174
1910
|
// climb up the ancestors looking for the first
|
|
1175
1911
|
// component that hasn't finished its lifecycle update yet
|
|
1176
|
-
if (ancestorComponent
|
|
1912
|
+
if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
|
|
1913
|
+
ancestorComponent.hasAttribute('s-id') &&
|
|
1914
|
+
ancestorComponent['s-p']) ||
|
|
1915
|
+
ancestorComponent['s-p']) {
|
|
1177
1916
|
// we found this components first ancestor component
|
|
1178
1917
|
// keep a reference to this component's ancestor component
|
|
1179
1918
|
attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
|
@@ -1203,12 +1942,30 @@ const connectedCallback = (elm) => {
|
|
|
1203
1942
|
endConnected();
|
|
1204
1943
|
}
|
|
1205
1944
|
};
|
|
1945
|
+
const setContentReference = (elm) => {
|
|
1946
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1947
|
+
// or this browser doesn't support native shadow dom
|
|
1948
|
+
// and this host element was NOT created with SSR
|
|
1949
|
+
// let's pick out the inner content for slot projection
|
|
1950
|
+
// create a node to represent where the original
|
|
1951
|
+
// content was first placed, which is useful later on
|
|
1952
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1953
|
+
contentRefElm['s-cn'] = true;
|
|
1954
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1955
|
+
};
|
|
1206
1956
|
const disconnectedCallback = (elm) => {
|
|
1207
1957
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1208
1958
|
getHostRef(elm);
|
|
1959
|
+
// clear CSS var-shim tracking
|
|
1960
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1961
|
+
if (plt.$cssShim$) {
|
|
1962
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1963
|
+
plt.$cssShim$.removeHost(elm);
|
|
1964
|
+
}
|
|
1209
1965
|
}
|
|
1210
1966
|
};
|
|
1211
1967
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1968
|
+
var _a;
|
|
1212
1969
|
const endBootstrap = createTime();
|
|
1213
1970
|
const cmpTags = [];
|
|
1214
1971
|
const exclude = options.exclude || [];
|
|
@@ -1217,10 +1974,22 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1217
1974
|
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
1218
1975
|
const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
|
|
1219
1976
|
const deferredConnectedCallbacks = [];
|
|
1977
|
+
const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
1220
1978
|
let appLoadFallback;
|
|
1221
1979
|
let isBootstrapping = true;
|
|
1980
|
+
let i = 0;
|
|
1222
1981
|
Object.assign(plt, options);
|
|
1223
1982
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1983
|
+
{
|
|
1984
|
+
// If the app is already hydrated there is not point to disable the
|
|
1985
|
+
// async queue. This will improve the first input delay
|
|
1986
|
+
plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
|
|
1987
|
+
}
|
|
1988
|
+
{
|
|
1989
|
+
for (; i < styles.length; i++) {
|
|
1990
|
+
registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1224
1993
|
lazyBundles.map((lazyBundle) => {
|
|
1225
1994
|
lazyBundle[1].map((compactMeta) => {
|
|
1226
1995
|
const cmpMeta = {
|
|
@@ -1238,6 +2007,10 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1238
2007
|
{
|
|
1239
2008
|
cmpMeta.$watchers$ = {};
|
|
1240
2009
|
}
|
|
2010
|
+
if (!supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
2011
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
2012
|
+
cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
|
|
2013
|
+
}
|
|
1241
2014
|
const tagName = cmpMeta.$tagName$;
|
|
1242
2015
|
const HostElement = class extends HTMLElement {
|
|
1243
2016
|
// StencilLazyHost
|
|
@@ -1251,11 +2024,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1251
2024
|
// and this browser supports shadow dom
|
|
1252
2025
|
// add the read-only property "shadowRoot" to the host element
|
|
1253
2026
|
// adding the shadow root build conditionals to minimize runtime
|
|
1254
|
-
{
|
|
2027
|
+
if (supportsShadow) {
|
|
1255
2028
|
{
|
|
1256
2029
|
self.attachShadow({ mode: 'open' });
|
|
1257
2030
|
}
|
|
1258
2031
|
}
|
|
2032
|
+
else if (!('shadowRoot' in self)) {
|
|
2033
|
+
self.shadowRoot = self;
|
|
2034
|
+
}
|
|
1259
2035
|
}
|
|
1260
2036
|
}
|
|
1261
2037
|
connectedCallback() {
|
|
@@ -1288,6 +2064,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1288
2064
|
{
|
|
1289
2065
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1290
2066
|
visibilityStyle.setAttribute('data-styles', '');
|
|
2067
|
+
// Apply CSP nonce to the style tag if it exists
|
|
2068
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
2069
|
+
if (nonce != null) {
|
|
2070
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
2071
|
+
}
|
|
1291
2072
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1292
2073
|
}
|
|
1293
2074
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1303,6 +2084,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1303
2084
|
// Fallback appLoad event
|
|
1304
2085
|
endBootstrap();
|
|
1305
2086
|
};
|
|
2087
|
+
/**
|
|
2088
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
2089
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
2090
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
2091
|
+
* @returns void
|
|
2092
|
+
*/
|
|
2093
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1306
2094
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1307
2095
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1308
2096
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
@@ -1346,6 +2134,8 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1346
2134
|
};
|
|
1347
2135
|
const styles = /*@__PURE__*/ new Map();
|
|
1348
2136
|
const win = typeof window !== 'undefined' ? window : {};
|
|
2137
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
2138
|
+
const CSS = win.CSS ;
|
|
1349
2139
|
const doc = win.document || { head: {} };
|
|
1350
2140
|
const plt = {
|
|
1351
2141
|
$flags$: 0,
|
|
@@ -1356,6 +2146,10 @@ const plt = {
|
|
|
1356
2146
|
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1357
2147
|
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1358
2148
|
};
|
|
2149
|
+
const supportsShadow =
|
|
2150
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
2151
|
+
/*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
|
|
2152
|
+
;
|
|
1359
2153
|
const promiseResolve = (v) => Promise.resolve(v);
|
|
1360
2154
|
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1361
2155
|
try {
|
|
@@ -1409,4 +2203,6 @@ const flush = () => {
|
|
|
1409
2203
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1410
2204
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1411
2205
|
|
|
1412
|
-
export { Host as H, bootstrapLazy as b, getElement as g, h,
|
|
2206
|
+
export { CSS as C, Host as H, promiseResolve as a, bootstrapLazy as b, getElement as g, h, plt as p, registerInstance as r, setNonce as s, win as w };
|
|
2207
|
+
|
|
2208
|
+
//# sourceMappingURL=index-e11775ce.js.map
|