@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
|
@@ -31,7 +31,11 @@ const NAMESPACE = 'cura';
|
|
|
31
31
|
* Modified for Stencil's renderer and slot projection
|
|
32
32
|
*/
|
|
33
33
|
let scopeId;
|
|
34
|
+
let contentRef;
|
|
34
35
|
let hostTagName;
|
|
36
|
+
let useNativeShadowDom = false;
|
|
37
|
+
let checkSlotFallbackVisibility = false;
|
|
38
|
+
let checkSlotRelocate = false;
|
|
35
39
|
let isSvgMode = false;
|
|
36
40
|
let queuePending = false;
|
|
37
41
|
const createTime = (fnName, tagName = '') => {
|
|
@@ -48,6 +52,13 @@ const uniqueTime = (key, measureText) => {
|
|
|
48
52
|
};
|
|
49
53
|
}
|
|
50
54
|
};
|
|
55
|
+
const CONTENT_REF_ID = 'r';
|
|
56
|
+
const ORG_LOCATION_ID = 'o';
|
|
57
|
+
const SLOT_NODE_ID = 's';
|
|
58
|
+
const TEXT_NODE_ID = 't';
|
|
59
|
+
const HYDRATE_ID = 's-id';
|
|
60
|
+
const HYDRATED_STYLE_ID = 'sty-id';
|
|
61
|
+
const HYDRATE_CHILD_ID = 'c-id';
|
|
51
62
|
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
52
63
|
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
53
64
|
/**
|
|
@@ -64,11 +75,30 @@ const EMPTY_OBJ = {};
|
|
|
64
75
|
const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
65
76
|
const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
66
77
|
const isDef = (v) => v != null;
|
|
78
|
+
/**
|
|
79
|
+
* Check whether a value is a 'complex type', defined here as an object or a
|
|
80
|
+
* function.
|
|
81
|
+
*
|
|
82
|
+
* @param o the value to check
|
|
83
|
+
* @returns whether it's a complex type or not
|
|
84
|
+
*/
|
|
67
85
|
const isComplexType = (o) => {
|
|
68
86
|
// https://jsperf.com/typeof-fn-object/5
|
|
69
87
|
o = typeof o;
|
|
70
88
|
return o === 'object' || o === 'function';
|
|
71
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
92
|
+
* out of a DOM's head.
|
|
93
|
+
*
|
|
94
|
+
* @param doc The DOM containing the `head` to query against
|
|
95
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
96
|
+
* exists or the tag has no content.
|
|
97
|
+
*/
|
|
98
|
+
function queryNonceMetaTagContent(doc) {
|
|
99
|
+
var _a, _b, _c;
|
|
100
|
+
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;
|
|
101
|
+
}
|
|
72
102
|
/**
|
|
73
103
|
* Production h() function based on Preact by
|
|
74
104
|
* Jason Miller (@developit)
|
|
@@ -77,11 +107,11 @@ const isComplexType = (o) => {
|
|
|
77
107
|
*
|
|
78
108
|
* Modified for Stencil's compiler and vdom
|
|
79
109
|
*/
|
|
80
|
-
// const stack: any[] = [];
|
|
81
110
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
82
111
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
83
112
|
const h = (nodeName, vnodeData, ...children) => {
|
|
84
113
|
let child = null;
|
|
114
|
+
let slotName = null;
|
|
85
115
|
let simple = false;
|
|
86
116
|
let lastSimple = false;
|
|
87
117
|
const vNodeChildren = [];
|
|
@@ -109,6 +139,9 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
109
139
|
};
|
|
110
140
|
walk(children);
|
|
111
141
|
if (vnodeData) {
|
|
142
|
+
if (vnodeData.name) {
|
|
143
|
+
slotName = vnodeData.name;
|
|
144
|
+
}
|
|
112
145
|
{
|
|
113
146
|
const classData = vnodeData.className || vnodeData.class;
|
|
114
147
|
if (classData) {
|
|
@@ -126,8 +159,19 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
126
159
|
if (vNodeChildren.length > 0) {
|
|
127
160
|
vnode.$children$ = vNodeChildren;
|
|
128
161
|
}
|
|
162
|
+
{
|
|
163
|
+
vnode.$name$ = slotName;
|
|
164
|
+
}
|
|
129
165
|
return vnode;
|
|
130
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
169
|
+
* possible text content.
|
|
170
|
+
*
|
|
171
|
+
* @param tag the tag for this element
|
|
172
|
+
* @param text possible text content for the node
|
|
173
|
+
* @returns a newly-minted virtual DOM node
|
|
174
|
+
*/
|
|
131
175
|
const newVNode = (tag, text) => {
|
|
132
176
|
const vnode = {
|
|
133
177
|
$flags$: 0,
|
|
@@ -139,10 +183,224 @@ const newVNode = (tag, text) => {
|
|
|
139
183
|
{
|
|
140
184
|
vnode.$attrs$ = null;
|
|
141
185
|
}
|
|
186
|
+
{
|
|
187
|
+
vnode.$name$ = null;
|
|
188
|
+
}
|
|
142
189
|
return vnode;
|
|
143
190
|
};
|
|
144
191
|
const Host = {};
|
|
192
|
+
/**
|
|
193
|
+
* Check whether a given node is a Host node or not
|
|
194
|
+
*
|
|
195
|
+
* @param node the virtual DOM node to check
|
|
196
|
+
* @returns whether it's a Host node or not
|
|
197
|
+
*/
|
|
145
198
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
199
|
+
const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
200
|
+
const endHydrate = createTime('hydrateClient', tagName);
|
|
201
|
+
const shadowRoot = hostElm.shadowRoot;
|
|
202
|
+
const childRenderNodes = [];
|
|
203
|
+
const slotNodes = [];
|
|
204
|
+
const shadowRootNodes = shadowRoot ? [] : null;
|
|
205
|
+
const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
|
206
|
+
if (!plt.$orgLocNodes$) {
|
|
207
|
+
initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
|
208
|
+
}
|
|
209
|
+
hostElm[HYDRATE_ID] = hostId;
|
|
210
|
+
hostElm.removeAttribute(HYDRATE_ID);
|
|
211
|
+
clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
|
212
|
+
childRenderNodes.map((c) => {
|
|
213
|
+
const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
|
214
|
+
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
215
|
+
const node = c.$elm$;
|
|
216
|
+
if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
|
217
|
+
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
|
218
|
+
}
|
|
219
|
+
if (!shadowRoot) {
|
|
220
|
+
node['s-hn'] = tagName;
|
|
221
|
+
if (orgLocationNode) {
|
|
222
|
+
node['s-ol'] = orgLocationNode;
|
|
223
|
+
node['s-ol']['s-nr'] = node;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
plt.$orgLocNodes$.delete(orgLocationId);
|
|
227
|
+
});
|
|
228
|
+
if (shadowRoot) {
|
|
229
|
+
shadowRootNodes.map((shadowRootNode) => {
|
|
230
|
+
if (shadowRootNode) {
|
|
231
|
+
shadowRoot.appendChild(shadowRootNode);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
endHydrate();
|
|
236
|
+
};
|
|
237
|
+
const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
|
238
|
+
let childNodeType;
|
|
239
|
+
let childIdSplt;
|
|
240
|
+
let childVNode;
|
|
241
|
+
let i;
|
|
242
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
243
|
+
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
244
|
+
if (childNodeType) {
|
|
245
|
+
// got the node data from the element's attribute
|
|
246
|
+
// `${hostId}.${nodeId}.${depth}.${index}`
|
|
247
|
+
childIdSplt = childNodeType.split('.');
|
|
248
|
+
if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
|
249
|
+
childVNode = {
|
|
250
|
+
$flags$: 0,
|
|
251
|
+
$hostId$: childIdSplt[0],
|
|
252
|
+
$nodeId$: childIdSplt[1],
|
|
253
|
+
$depth$: childIdSplt[2],
|
|
254
|
+
$index$: childIdSplt[3],
|
|
255
|
+
$tag$: node.tagName.toLowerCase(),
|
|
256
|
+
$elm$: node,
|
|
257
|
+
$attrs$: null,
|
|
258
|
+
$children$: null,
|
|
259
|
+
$key$: null,
|
|
260
|
+
$name$: null,
|
|
261
|
+
$text$: null,
|
|
262
|
+
};
|
|
263
|
+
childRenderNodes.push(childVNode);
|
|
264
|
+
node.removeAttribute(HYDRATE_CHILD_ID);
|
|
265
|
+
// this is a new child vnode
|
|
266
|
+
// so ensure its parent vnode has the vchildren array
|
|
267
|
+
if (!parentVNode.$children$) {
|
|
268
|
+
parentVNode.$children$ = [];
|
|
269
|
+
}
|
|
270
|
+
// add our child vnode to a specific index of the vnode's children
|
|
271
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
272
|
+
// this is now the new parent vnode for all the next child checks
|
|
273
|
+
parentVNode = childVNode;
|
|
274
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
275
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
// recursively drill down, end to start so we can remove nodes
|
|
280
|
+
for (i = node.childNodes.length - 1; i >= 0; i--) {
|
|
281
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
|
282
|
+
}
|
|
283
|
+
if (node.shadowRoot) {
|
|
284
|
+
// keep drilling down through the shadow root nodes
|
|
285
|
+
for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
|
286
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
291
|
+
// `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
|
|
292
|
+
childIdSplt = node.nodeValue.split('.');
|
|
293
|
+
if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
|
294
|
+
// comment node for either the host id or a 0 host id
|
|
295
|
+
childNodeType = childIdSplt[0];
|
|
296
|
+
childVNode = {
|
|
297
|
+
$flags$: 0,
|
|
298
|
+
$hostId$: childIdSplt[1],
|
|
299
|
+
$nodeId$: childIdSplt[2],
|
|
300
|
+
$depth$: childIdSplt[3],
|
|
301
|
+
$index$: childIdSplt[4],
|
|
302
|
+
$elm$: node,
|
|
303
|
+
$attrs$: null,
|
|
304
|
+
$children$: null,
|
|
305
|
+
$key$: null,
|
|
306
|
+
$name$: null,
|
|
307
|
+
$tag$: null,
|
|
308
|
+
$text$: null,
|
|
309
|
+
};
|
|
310
|
+
if (childNodeType === TEXT_NODE_ID) {
|
|
311
|
+
childVNode.$elm$ = node.nextSibling;
|
|
312
|
+
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
|
|
313
|
+
childVNode.$text$ = childVNode.$elm$.textContent;
|
|
314
|
+
childRenderNodes.push(childVNode);
|
|
315
|
+
// remove the text comment since it's no longer needed
|
|
316
|
+
node.remove();
|
|
317
|
+
if (!parentVNode.$children$) {
|
|
318
|
+
parentVNode.$children$ = [];
|
|
319
|
+
}
|
|
320
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
321
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
322
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else if (childVNode.$hostId$ === hostId) {
|
|
327
|
+
// this comment node is specifcally for this host id
|
|
328
|
+
if (childNodeType === SLOT_NODE_ID) {
|
|
329
|
+
// `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
|
|
330
|
+
childVNode.$tag$ = 'slot';
|
|
331
|
+
if (childIdSplt[5]) {
|
|
332
|
+
node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
node['s-sn'] = '';
|
|
336
|
+
}
|
|
337
|
+
node['s-sr'] = true;
|
|
338
|
+
if (shadowRootNodes) {
|
|
339
|
+
// browser support shadowRoot and this is a shadow dom component
|
|
340
|
+
// create an actual slot element
|
|
341
|
+
childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
|
342
|
+
if (childVNode.$name$) {
|
|
343
|
+
// add the slot name attribute
|
|
344
|
+
childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
|
345
|
+
}
|
|
346
|
+
// insert the new slot element before the slot comment
|
|
347
|
+
node.parentNode.insertBefore(childVNode.$elm$, node);
|
|
348
|
+
// remove the slot comment since it's not needed for shadow
|
|
349
|
+
node.remove();
|
|
350
|
+
if (childVNode.$depth$ === '0') {
|
|
351
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
slotNodes.push(childVNode);
|
|
355
|
+
if (!parentVNode.$children$) {
|
|
356
|
+
parentVNode.$children$ = [];
|
|
357
|
+
}
|
|
358
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
359
|
+
}
|
|
360
|
+
else if (childNodeType === CONTENT_REF_ID) {
|
|
361
|
+
// `${CONTENT_REF_ID}.${hostId}`;
|
|
362
|
+
if (shadowRootNodes) {
|
|
363
|
+
// remove the content ref comment since it's not needed for shadow
|
|
364
|
+
node.remove();
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
hostElm['s-cr'] = node;
|
|
368
|
+
node['s-cn'] = true;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
else if (parentVNode && parentVNode.$tag$ === 'style') {
|
|
375
|
+
const vnode = newVNode(null, node.textContent);
|
|
376
|
+
vnode.$elm$ = node;
|
|
377
|
+
vnode.$index$ = '0';
|
|
378
|
+
parentVNode.$children$ = [vnode];
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
382
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
383
|
+
let i = 0;
|
|
384
|
+
for (; i < node.childNodes.length; i++) {
|
|
385
|
+
initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
|
386
|
+
}
|
|
387
|
+
if (node.shadowRoot) {
|
|
388
|
+
for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
|
389
|
+
initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
394
|
+
const childIdSplt = node.nodeValue.split('.');
|
|
395
|
+
if (childIdSplt[0] === ORG_LOCATION_ID) {
|
|
396
|
+
orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
|
397
|
+
node.nodeValue = '';
|
|
398
|
+
// useful to know if the original location is
|
|
399
|
+
// the root light-dom of a shadow dom component
|
|
400
|
+
node['s-en'] = childIdSplt[3];
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
};
|
|
146
404
|
/**
|
|
147
405
|
* Parse a new property value for a given property type.
|
|
148
406
|
*
|
|
@@ -221,6 +479,7 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
221
479
|
styles.set(scopeId, style);
|
|
222
480
|
};
|
|
223
481
|
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
482
|
+
var _a;
|
|
224
483
|
let scopeId = getScopeId(cmpMeta);
|
|
225
484
|
const style = styles.get(scopeId);
|
|
226
485
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
@@ -235,11 +494,36 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
235
494
|
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
236
495
|
}
|
|
237
496
|
if (!appliedStyles.has(scopeId)) {
|
|
238
|
-
|
|
239
|
-
{
|
|
497
|
+
if (styleContainerNode.host &&
|
|
498
|
+
(styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
|
499
|
+
// This is only happening on native shadow-dom, do not needs CSS var shim
|
|
500
|
+
styleElm.innerHTML = style;
|
|
501
|
+
}
|
|
502
|
+
else {
|
|
503
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
504
|
+
if (plt.$cssShim$) {
|
|
505
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
506
|
+
styleElm = plt.$cssShim$.createHostStyle(hostElm, scopeId, style,
|
|
507
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
508
|
+
!!(cmpMeta.$flags$ & 10 /* CMP_FLAGS.needsScopedEncapsulation */));
|
|
509
|
+
const newScopeId = styleElm['s-sc'];
|
|
510
|
+
if (newScopeId) {
|
|
511
|
+
scopeId = newScopeId;
|
|
512
|
+
// we don't want to add this styleID to the appliedStyles Set
|
|
513
|
+
// since the cssVarShim might need to apply several different
|
|
514
|
+
// stylesheets for the same component
|
|
515
|
+
appliedStyles = null;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
240
519
|
styleElm = doc.createElement('style');
|
|
241
520
|
styleElm.innerHTML = style;
|
|
242
521
|
}
|
|
522
|
+
// Apply CSP nonce to the style tag if it exists
|
|
523
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
524
|
+
if (nonce != null) {
|
|
525
|
+
styleElm.setAttribute('nonce', nonce);
|
|
526
|
+
}
|
|
243
527
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
244
528
|
}
|
|
245
529
|
if (appliedStyles) {
|
|
@@ -258,7 +542,8 @@ const attachStyles = (hostRef) => {
|
|
|
258
542
|
const elm = hostRef.$hostElement$;
|
|
259
543
|
const flags = cmpMeta.$flags$;
|
|
260
544
|
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
261
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
545
|
+
const scopeId = addStyle(supportsShadow && elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$, elm);
|
|
546
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
262
547
|
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
263
548
|
// only required when we're NOT using native shadow dom (slot)
|
|
264
549
|
// or this browser doesn't support native shadow dom
|
|
@@ -273,6 +558,7 @@ const attachStyles = (hostRef) => {
|
|
|
273
558
|
endAttachStyles();
|
|
274
559
|
};
|
|
275
560
|
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
561
|
+
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
|
276
562
|
/**
|
|
277
563
|
* Production setAccessor() function based on Preact by
|
|
278
564
|
* Jason Miller (@developit)
|
|
@@ -453,16 +739,39 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
453
739
|
let i = 0;
|
|
454
740
|
let elm;
|
|
455
741
|
let childNode;
|
|
742
|
+
let oldVNode;
|
|
743
|
+
if (!useNativeShadowDom) {
|
|
744
|
+
// remember for later we need to check to relocate nodes
|
|
745
|
+
checkSlotRelocate = true;
|
|
746
|
+
if (newVNode.$tag$ === 'slot') {
|
|
747
|
+
if (scopeId) {
|
|
748
|
+
// scoped css needs to add its scoped id to the parent element
|
|
749
|
+
parentElm.classList.add(scopeId + '-s');
|
|
750
|
+
}
|
|
751
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
752
|
+
? // slot element has fallback content
|
|
753
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
754
|
+
: // slot element does not have fallback content
|
|
755
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
456
758
|
if (newVNode.$text$ !== null) {
|
|
457
759
|
// create text node
|
|
458
760
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
459
761
|
}
|
|
762
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
763
|
+
// create a slot reference node
|
|
764
|
+
elm = newVNode.$elm$ =
|
|
765
|
+
doc.createTextNode('');
|
|
766
|
+
}
|
|
460
767
|
else {
|
|
461
768
|
if (!isSvgMode) {
|
|
462
769
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
463
770
|
}
|
|
464
771
|
// create element
|
|
465
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$
|
|
772
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
773
|
+
? 'slot-fb'
|
|
774
|
+
: newVNode.$tag$)
|
|
466
775
|
);
|
|
467
776
|
if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
|
|
468
777
|
isSvgMode = false;
|
|
@@ -479,7 +788,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
479
788
|
if (newVNode.$children$) {
|
|
480
789
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
481
790
|
// create the node
|
|
482
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
791
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
483
792
|
// return node could have been null
|
|
484
793
|
if (childNode) {
|
|
485
794
|
// append our new node
|
|
@@ -498,30 +807,115 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
498
807
|
}
|
|
499
808
|
}
|
|
500
809
|
}
|
|
810
|
+
{
|
|
811
|
+
elm['s-hn'] = hostTagName;
|
|
812
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
813
|
+
// remember the content reference comment
|
|
814
|
+
elm['s-sr'] = true;
|
|
815
|
+
// remember the content reference comment
|
|
816
|
+
elm['s-cr'] = contentRef;
|
|
817
|
+
// remember the slot name, or empty string for default slot
|
|
818
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
819
|
+
// check if we've got an old vnode for this slot
|
|
820
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
821
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
822
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
823
|
+
// so let's move the old slot content back to it's original location
|
|
824
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
501
828
|
return elm;
|
|
502
829
|
};
|
|
830
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
831
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
832
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
833
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
834
|
+
const childNode = oldSlotChildNodes[i];
|
|
835
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
836
|
+
// // this child node in the old element is from another component
|
|
837
|
+
// // remove this node from the old slot's parent
|
|
838
|
+
// childNode.remove();
|
|
839
|
+
// and relocate it back to it's original location
|
|
840
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
841
|
+
// remove the old original location comment entirely
|
|
842
|
+
// later on the patch function will know what to do
|
|
843
|
+
// and move this to the correct spot in need be
|
|
844
|
+
childNode['s-ol'].remove();
|
|
845
|
+
childNode['s-ol'] = undefined;
|
|
846
|
+
checkSlotRelocate = true;
|
|
847
|
+
}
|
|
848
|
+
if (recursive) {
|
|
849
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
853
|
+
};
|
|
854
|
+
/**
|
|
855
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
856
|
+
* add them to the DOM in the appropriate place.
|
|
857
|
+
*
|
|
858
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
859
|
+
* DOM nodes
|
|
860
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
861
|
+
* inserted before (optional)
|
|
862
|
+
* @param parentVNode the parent virtual DOM node
|
|
863
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
864
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
865
|
+
* creating DOM nodes (inclusive)
|
|
866
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
867
|
+
* creating DOM nodes (inclusive)
|
|
868
|
+
*/
|
|
503
869
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
504
|
-
let containerElm = (parentElm);
|
|
870
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
505
871
|
let childNode;
|
|
506
872
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
507
873
|
containerElm = containerElm.shadowRoot;
|
|
508
874
|
}
|
|
509
875
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
510
876
|
if (vnodes[startIdx]) {
|
|
511
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
877
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
512
878
|
if (childNode) {
|
|
513
879
|
vnodes[startIdx].$elm$ = childNode;
|
|
514
|
-
containerElm.insertBefore(childNode, before);
|
|
880
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
515
881
|
}
|
|
516
882
|
}
|
|
517
883
|
}
|
|
518
884
|
};
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
885
|
+
/**
|
|
886
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
887
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
888
|
+
* should no longer be shown.
|
|
889
|
+
*
|
|
890
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
891
|
+
*
|
|
892
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
893
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
894
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
895
|
+
*/
|
|
896
|
+
const removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
897
|
+
for (let index = startIdx; index <= endIdx; ++index) {
|
|
898
|
+
const vnode = vnodes[index];
|
|
899
|
+
if (vnode) {
|
|
900
|
+
const elm = vnode.$elm$;
|
|
901
|
+
if (elm) {
|
|
902
|
+
{
|
|
903
|
+
// we're removing this element
|
|
904
|
+
// so it's possible we need to show slot fallback content now
|
|
905
|
+
checkSlotFallbackVisibility = true;
|
|
906
|
+
if (elm['s-ol']) {
|
|
907
|
+
// remove the original location comment
|
|
908
|
+
elm['s-ol'].remove();
|
|
909
|
+
}
|
|
910
|
+
else {
|
|
911
|
+
// it's possible that child nodes of the node
|
|
912
|
+
// that's being removed are slot nodes
|
|
913
|
+
putBackInOriginalLocation(elm, true);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
// remove the vnode's element from the dom
|
|
917
|
+
elm.remove();
|
|
918
|
+
}
|
|
525
919
|
}
|
|
526
920
|
}
|
|
527
921
|
};
|
|
@@ -635,6 +1029,23 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
635
1029
|
newEndVnode = newCh[--newEndIdx];
|
|
636
1030
|
}
|
|
637
1031
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
1032
|
+
// case: "Vnode moved right"
|
|
1033
|
+
//
|
|
1034
|
+
// We've found that the last node in our window on the new children is
|
|
1035
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
1036
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
1037
|
+
// nodes:
|
|
1038
|
+
//
|
|
1039
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
1040
|
+
// ^^^^^^^^^^^
|
|
1041
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
1042
|
+
// ^^^^^^^^^^^^^
|
|
1043
|
+
//
|
|
1044
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
1045
|
+
// and move the DOM element for `oldStartVnode`.
|
|
1046
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
1047
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
1048
|
+
}
|
|
638
1049
|
patch(oldStartVnode, newEndVnode);
|
|
639
1050
|
// We need to move the element for `oldStartVnode` into a position which
|
|
640
1051
|
// will be appropriate for `newEndVnode`. For this we can use
|
|
@@ -658,6 +1069,24 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
658
1069
|
newEndVnode = newCh[--newEndIdx];
|
|
659
1070
|
}
|
|
660
1071
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
1072
|
+
// case: "Vnode moved left"
|
|
1073
|
+
//
|
|
1074
|
+
// We've found that the first node in our window on the new children is
|
|
1075
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
1076
|
+
// Visually, this is the layout of these two nodes:
|
|
1077
|
+
//
|
|
1078
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
1079
|
+
// ^^^^^^^^^^^^^
|
|
1080
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
1081
|
+
// ^^^^^^^^^^^
|
|
1082
|
+
//
|
|
1083
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
1084
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
1085
|
+
// children etc) but we also need to move the DOM node to which
|
|
1086
|
+
// `oldEndVnode` corresponds.
|
|
1087
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
1088
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
1089
|
+
}
|
|
661
1090
|
patch(oldEndVnode, newStartVnode);
|
|
662
1091
|
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
663
1092
|
// the same node, so since we're here we know that they are not. Thus we
|
|
@@ -674,13 +1103,13 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
674
1103
|
// the key of the first new child OR the build is not using `key`
|
|
675
1104
|
// attributes at all. In either case we need to create a new element
|
|
676
1105
|
// for the new node.
|
|
677
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
1106
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
678
1107
|
newStartVnode = newCh[++newStartIdx];
|
|
679
1108
|
}
|
|
680
1109
|
if (node) {
|
|
681
1110
|
// if we created a new node then handle inserting it to the DOM
|
|
682
1111
|
{
|
|
683
|
-
oldStartVnode.$elm
|
|
1112
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
684
1113
|
}
|
|
685
1114
|
}
|
|
686
1115
|
}
|
|
@@ -707,7 +1136,8 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
707
1136
|
*
|
|
708
1137
|
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
709
1138
|
* changing order within a `children` array or something along those lines then
|
|
710
|
-
* we could obtain a false
|
|
1139
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
1140
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
711
1141
|
*
|
|
712
1142
|
* @param leftVNode the first VNode to check
|
|
713
1143
|
* @param rightVNode the second VNode to check
|
|
@@ -717,10 +1147,21 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
717
1147
|
// compare if two vnode to see if they're "technically" the same
|
|
718
1148
|
// need to have the same element tag, and same key to be the same
|
|
719
1149
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
1150
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
1151
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
1152
|
+
}
|
|
720
1153
|
return true;
|
|
721
1154
|
}
|
|
722
1155
|
return false;
|
|
723
1156
|
};
|
|
1157
|
+
const referenceNode = (node) => {
|
|
1158
|
+
// this node was relocated to a new location in the dom
|
|
1159
|
+
// because of some other component's slot
|
|
1160
|
+
// but we still have an html comment in place of where
|
|
1161
|
+
// it's original location was according to it's original vdom
|
|
1162
|
+
return (node && node['s-ol']) || node;
|
|
1163
|
+
};
|
|
1164
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
724
1165
|
/**
|
|
725
1166
|
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
726
1167
|
* it. This function handles flushing updates to the DOM and reconciling the
|
|
@@ -735,6 +1176,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
735
1176
|
const newChildren = newVNode.$children$;
|
|
736
1177
|
const tag = newVNode.$tag$;
|
|
737
1178
|
const text = newVNode.$text$;
|
|
1179
|
+
let defaultHolder;
|
|
738
1180
|
if (text === null) {
|
|
739
1181
|
{
|
|
740
1182
|
// test if we're rendering an svg element, or still rendering nodes inside of one
|
|
@@ -773,12 +1215,159 @@ const patch = (oldVNode, newVNode) => {
|
|
|
773
1215
|
isSvgMode = false;
|
|
774
1216
|
}
|
|
775
1217
|
}
|
|
1218
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
1219
|
+
// this element has slotted content
|
|
1220
|
+
defaultHolder.parentNode.textContent = text;
|
|
1221
|
+
}
|
|
776
1222
|
else if (oldVNode.$text$ !== text) {
|
|
777
1223
|
// update the text content for the text only vnode
|
|
778
1224
|
// and also only if the text is different than before
|
|
779
1225
|
elm.data = text;
|
|
780
1226
|
}
|
|
781
1227
|
};
|
|
1228
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
1229
|
+
// tslint:disable-next-line: prefer-const
|
|
1230
|
+
const childNodes = elm.childNodes;
|
|
1231
|
+
let childNode;
|
|
1232
|
+
let i;
|
|
1233
|
+
let ilen;
|
|
1234
|
+
let j;
|
|
1235
|
+
let slotNameAttr;
|
|
1236
|
+
let nodeType;
|
|
1237
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
1238
|
+
childNode = childNodes[i];
|
|
1239
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1240
|
+
if (childNode['s-sr']) {
|
|
1241
|
+
// this is a slot fallback node
|
|
1242
|
+
// get the slot name for this slot reference node
|
|
1243
|
+
slotNameAttr = childNode['s-sn'];
|
|
1244
|
+
// by default always show a fallback slot node
|
|
1245
|
+
// then hide it if there are other slots in the light dom
|
|
1246
|
+
childNode.hidden = false;
|
|
1247
|
+
for (j = 0; j < ilen; j++) {
|
|
1248
|
+
nodeType = childNodes[j].nodeType;
|
|
1249
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
1250
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
1251
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1252
|
+
childNode.hidden = true;
|
|
1253
|
+
break;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
else {
|
|
1257
|
+
// this is a default fallback slot node
|
|
1258
|
+
// any element or text node (with content)
|
|
1259
|
+
// should hide the default fallback slot node
|
|
1260
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1261
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1262
|
+
childNode.hidden = true;
|
|
1263
|
+
break;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
// keep drilling down
|
|
1269
|
+
updateFallbackSlotVisibility(childNode);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
};
|
|
1273
|
+
const relocateNodes = [];
|
|
1274
|
+
const relocateSlotContent = (elm) => {
|
|
1275
|
+
// tslint:disable-next-line: prefer-const
|
|
1276
|
+
let childNode;
|
|
1277
|
+
let node;
|
|
1278
|
+
let hostContentNodes;
|
|
1279
|
+
let slotNameAttr;
|
|
1280
|
+
let relocateNodeData;
|
|
1281
|
+
let j;
|
|
1282
|
+
let i = 0;
|
|
1283
|
+
const childNodes = elm.childNodes;
|
|
1284
|
+
const ilen = childNodes.length;
|
|
1285
|
+
for (; i < ilen; i++) {
|
|
1286
|
+
childNode = childNodes[i];
|
|
1287
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
1288
|
+
// first got the content reference comment node
|
|
1289
|
+
// then we got it's parent, which is where all the host content is in now
|
|
1290
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
1291
|
+
slotNameAttr = childNode['s-sn'];
|
|
1292
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
1293
|
+
node = hostContentNodes[j];
|
|
1294
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
1295
|
+
// let's do some relocating to its new home
|
|
1296
|
+
// but never relocate a content reference node
|
|
1297
|
+
// that is suppose to always represent the original content location
|
|
1298
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
1299
|
+
// it's possible we've already decided to relocate this node
|
|
1300
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1301
|
+
// made some changes to slots
|
|
1302
|
+
// let's make sure we also double check
|
|
1303
|
+
// fallbacks are correctly hidden or shown
|
|
1304
|
+
checkSlotFallbackVisibility = true;
|
|
1305
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
1306
|
+
if (relocateNodeData) {
|
|
1307
|
+
// previously we never found a slot home for this node
|
|
1308
|
+
// but turns out we did, so let's remember it now
|
|
1309
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
1310
|
+
}
|
|
1311
|
+
else {
|
|
1312
|
+
// add to our list of nodes to relocate
|
|
1313
|
+
relocateNodes.push({
|
|
1314
|
+
$slotRefNode$: childNode,
|
|
1315
|
+
$nodeToRelocate$: node,
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
if (node['s-sr']) {
|
|
1319
|
+
relocateNodes.map((relocateNode) => {
|
|
1320
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
1321
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1322
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
1323
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
1330
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
1331
|
+
// if we never find a home for this element then we'll need to hide it
|
|
1332
|
+
relocateNodes.push({
|
|
1333
|
+
$nodeToRelocate$: node,
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1340
|
+
relocateSlotContent(childNode);
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
1345
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1346
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
1347
|
+
return true;
|
|
1348
|
+
}
|
|
1349
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
1350
|
+
return true;
|
|
1351
|
+
}
|
|
1352
|
+
return false;
|
|
1353
|
+
}
|
|
1354
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
1355
|
+
return true;
|
|
1356
|
+
}
|
|
1357
|
+
return slotNameAttr === '';
|
|
1358
|
+
};
|
|
1359
|
+
/**
|
|
1360
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
1361
|
+
*
|
|
1362
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
1363
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
1364
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
1365
|
+
* relocation, and reflecting attributes.
|
|
1366
|
+
*
|
|
1367
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
1368
|
+
* the DOM node into which it should be rendered.
|
|
1369
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
1370
|
+
*/
|
|
782
1371
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
783
1372
|
const hostElm = hostRef.$hostElement$;
|
|
784
1373
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
@@ -796,8 +1385,90 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
796
1385
|
{
|
|
797
1386
|
scopeId = hostElm['s-sc'];
|
|
798
1387
|
}
|
|
1388
|
+
{
|
|
1389
|
+
contentRef = hostElm['s-cr'];
|
|
1390
|
+
useNativeShadowDom = supportsShadow && (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
1391
|
+
// always reset
|
|
1392
|
+
checkSlotFallbackVisibility = false;
|
|
1393
|
+
}
|
|
799
1394
|
// synchronous patch
|
|
800
1395
|
patch(oldVNode, rootVnode);
|
|
1396
|
+
{
|
|
1397
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
1398
|
+
// the disconnectCallback from working
|
|
1399
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1400
|
+
if (checkSlotRelocate) {
|
|
1401
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
1402
|
+
let relocateData;
|
|
1403
|
+
let nodeToRelocate;
|
|
1404
|
+
let orgLocationNode;
|
|
1405
|
+
let parentNodeRef;
|
|
1406
|
+
let insertBeforeNode;
|
|
1407
|
+
let refNode;
|
|
1408
|
+
let i = 0;
|
|
1409
|
+
for (; i < relocateNodes.length; i++) {
|
|
1410
|
+
relocateData = relocateNodes[i];
|
|
1411
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1412
|
+
if (!nodeToRelocate['s-ol']) {
|
|
1413
|
+
// add a reference node marking this node's original location
|
|
1414
|
+
// keep a reference to this node for later lookups
|
|
1415
|
+
orgLocationNode =
|
|
1416
|
+
doc.createTextNode('');
|
|
1417
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
1418
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
1422
|
+
relocateData = relocateNodes[i];
|
|
1423
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1424
|
+
if (relocateData.$slotRefNode$) {
|
|
1425
|
+
// by default we're just going to insert it directly
|
|
1426
|
+
// after the slot reference node
|
|
1427
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
1428
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
1429
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
1430
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
1431
|
+
refNode = orgLocationNode['s-nr'];
|
|
1432
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
1433
|
+
refNode = refNode.nextSibling;
|
|
1434
|
+
if (!refNode || !refNode['s-nr']) {
|
|
1435
|
+
insertBeforeNode = refNode;
|
|
1436
|
+
break;
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
1441
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
1442
|
+
// we've checked that it's worth while to relocate
|
|
1443
|
+
// since that the node to relocate
|
|
1444
|
+
// has a different next sibling or parent relocated
|
|
1445
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
1446
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1447
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
1448
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1449
|
+
}
|
|
1450
|
+
// add it back to the dom but in its new home
|
|
1451
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
else {
|
|
1456
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
1457
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1458
|
+
nodeToRelocate.hidden = true;
|
|
1459
|
+
}
|
|
1460
|
+
}
|
|
1461
|
+
}
|
|
1462
|
+
}
|
|
1463
|
+
if (checkSlotFallbackVisibility) {
|
|
1464
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1465
|
+
}
|
|
1466
|
+
// done moving nodes around
|
|
1467
|
+
// allow the disconnect callback to work again
|
|
1468
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1469
|
+
// always reset
|
|
1470
|
+
relocateNodes.length = 0;
|
|
1471
|
+
}
|
|
801
1472
|
};
|
|
802
1473
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
803
1474
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -819,15 +1490,54 @@ const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
|
819
1490
|
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
820
1491
|
return writeTask(dispatch) ;
|
|
821
1492
|
};
|
|
1493
|
+
/**
|
|
1494
|
+
* Dispatch initial-render and update lifecycle hooks, enqueuing calls to
|
|
1495
|
+
* component lifecycle methods like `componentWillLoad` as well as
|
|
1496
|
+
* {@link updateComponent}, which will kick off the virtual DOM re-render.
|
|
1497
|
+
*
|
|
1498
|
+
* @param hostRef a reference to a host DOM node
|
|
1499
|
+
* @param isInitialLoad whether we're on the initial load or not
|
|
1500
|
+
* @returns an empty Promise which is used to enqueue a series of operations for
|
|
1501
|
+
* the component
|
|
1502
|
+
*/
|
|
822
1503
|
const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
823
1504
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
824
1505
|
const instance = hostRef.$lazyInstance$ ;
|
|
825
|
-
|
|
1506
|
+
// We're going to use this variable together with `enqueue` to implement a
|
|
1507
|
+
// little promise-based queue. We start out with it `undefined`. When we add
|
|
1508
|
+
// the first function to the queue we'll set this variable to be that
|
|
1509
|
+
// function's return value. When we attempt to add subsequent values to the
|
|
1510
|
+
// queue we'll check that value and, if it was a `Promise`, we'll then chain
|
|
1511
|
+
// the new function off of that `Promise` using `.then()`. This will give our
|
|
1512
|
+
// queue two nice properties:
|
|
1513
|
+
//
|
|
1514
|
+
// 1. If all functions added to the queue are synchronous they'll be called
|
|
1515
|
+
// synchronously right away.
|
|
1516
|
+
// 2. If all functions added to the queue are asynchronous they'll all be
|
|
1517
|
+
// called in order after `dispatchHooks` exits.
|
|
1518
|
+
let maybePromise;
|
|
826
1519
|
endSchedule();
|
|
827
|
-
return
|
|
1520
|
+
return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
828
1521
|
};
|
|
1522
|
+
/**
|
|
1523
|
+
* This function uses a Promise to implement a simple first-in, first-out queue
|
|
1524
|
+
* of functions to be called.
|
|
1525
|
+
*
|
|
1526
|
+
* The queue is ordered on the basis of the first argument. If it's
|
|
1527
|
+
* `undefined`, then nothing is on the queue yet, so the provided function can
|
|
1528
|
+
* be called synchronously (although note that this function may return a
|
|
1529
|
+
* `Promise`). The idea is that then the return value of that enqueueing
|
|
1530
|
+
* operation is kept around, so that if it was a `Promise` then subsequent
|
|
1531
|
+
* functions can be enqueued by calling this function again with that `Promise`
|
|
1532
|
+
* as the first argument.
|
|
1533
|
+
*
|
|
1534
|
+
* @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
|
|
1535
|
+
* @param fn a function to enqueue
|
|
1536
|
+
* @returns either a `Promise` or the return value of the provided function
|
|
1537
|
+
*/
|
|
1538
|
+
const enqueue = (maybePromise, fn) => maybePromise instanceof Promise ? maybePromise.then(fn) : fn();
|
|
829
1539
|
const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
830
|
-
|
|
1540
|
+
var _a;
|
|
831
1541
|
const elm = hostRef.$hostElement$;
|
|
832
1542
|
const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
|
|
833
1543
|
const rc = elm['s-rc'];
|
|
@@ -839,6 +1549,11 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
839
1549
|
{
|
|
840
1550
|
callRender(hostRef, instance);
|
|
841
1551
|
}
|
|
1552
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1553
|
+
if (plt.$cssShim$) {
|
|
1554
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1555
|
+
plt.$cssShim$.updateHost(elm);
|
|
1556
|
+
}
|
|
842
1557
|
if (rc) {
|
|
843
1558
|
// ok, so turns out there are some child host elements
|
|
844
1559
|
// waiting on this parent element to load
|
|
@@ -849,7 +1564,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
849
1564
|
endRender();
|
|
850
1565
|
endUpdate();
|
|
851
1566
|
{
|
|
852
|
-
const childrenPromises = elm['s-p'];
|
|
1567
|
+
const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
|
|
853
1568
|
const postUpdate = () => postUpdateComponent(hostRef);
|
|
854
1569
|
if (childrenPromises.length === 0) {
|
|
855
1570
|
postUpdate();
|
|
@@ -943,9 +1658,6 @@ const safeCall = (instance, method, arg) => {
|
|
|
943
1658
|
}
|
|
944
1659
|
return undefined;
|
|
945
1660
|
};
|
|
946
|
-
const then = (promise, thenFn) => {
|
|
947
|
-
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
948
|
-
};
|
|
949
1661
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
950
1662
|
;
|
|
951
1663
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
@@ -1099,9 +1811,9 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1099
1811
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1100
1812
|
// initializeComponent
|
|
1101
1813
|
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1814
|
+
// Let the runtime know that the component has been initialized
|
|
1815
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1102
1816
|
{
|
|
1103
|
-
// we haven't initialized this element yet
|
|
1104
|
-
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1105
1817
|
// lazy loaded components
|
|
1106
1818
|
// request the component's implementation to be
|
|
1107
1819
|
// wired up with the host element
|
|
@@ -1154,6 +1866,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1154
1866
|
const scopeId = getScopeId(cmpMeta);
|
|
1155
1867
|
if (!styles.has(scopeId)) {
|
|
1156
1868
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1869
|
+
if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
|
|
1870
|
+
style = await Promise.resolve().then(function () { return require('./shadow-css-8baae635.js'); }).then((m) => m.scopeCss(style, scopeId, false));
|
|
1871
|
+
}
|
|
1157
1872
|
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1158
1873
|
endRegisterStyles();
|
|
1159
1874
|
}
|
|
@@ -1188,6 +1903,27 @@ const connectedCallback = (elm) => {
|
|
|
1188
1903
|
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1189
1904
|
// first time this component has connected
|
|
1190
1905
|
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1906
|
+
let hostId;
|
|
1907
|
+
{
|
|
1908
|
+
hostId = elm.getAttribute(HYDRATE_ID);
|
|
1909
|
+
if (hostId) {
|
|
1910
|
+
if (supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1911
|
+
const scopeId = addStyle(elm.shadowRoot, cmpMeta);
|
|
1912
|
+
elm.classList.remove(scopeId + '-h', scopeId + '-s');
|
|
1913
|
+
}
|
|
1914
|
+
initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
if (!hostId) {
|
|
1918
|
+
// initUpdate
|
|
1919
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1920
|
+
// in here to act as original content anchors as we move nodes around
|
|
1921
|
+
// host element has been connected to the DOM
|
|
1922
|
+
if ((// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
1923
|
+
cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1924
|
+
setContentReference(elm);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1191
1927
|
{
|
|
1192
1928
|
// find the first ancestor component (if there is one) and register
|
|
1193
1929
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1195,7 +1931,10 @@ const connectedCallback = (elm) => {
|
|
|
1195
1931
|
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
|
1196
1932
|
// climb up the ancestors looking for the first
|
|
1197
1933
|
// component that hasn't finished its lifecycle update yet
|
|
1198
|
-
if (ancestorComponent
|
|
1934
|
+
if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
|
|
1935
|
+
ancestorComponent.hasAttribute('s-id') &&
|
|
1936
|
+
ancestorComponent['s-p']) ||
|
|
1937
|
+
ancestorComponent['s-p']) {
|
|
1199
1938
|
// we found this components first ancestor component
|
|
1200
1939
|
// keep a reference to this component's ancestor component
|
|
1201
1940
|
attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
|
|
@@ -1225,12 +1964,30 @@ const connectedCallback = (elm) => {
|
|
|
1225
1964
|
endConnected();
|
|
1226
1965
|
}
|
|
1227
1966
|
};
|
|
1967
|
+
const setContentReference = (elm) => {
|
|
1968
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1969
|
+
// or this browser doesn't support native shadow dom
|
|
1970
|
+
// and this host element was NOT created with SSR
|
|
1971
|
+
// let's pick out the inner content for slot projection
|
|
1972
|
+
// create a node to represent where the original
|
|
1973
|
+
// content was first placed, which is useful later on
|
|
1974
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1975
|
+
contentRefElm['s-cn'] = true;
|
|
1976
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1977
|
+
};
|
|
1228
1978
|
const disconnectedCallback = (elm) => {
|
|
1229
1979
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1230
1980
|
getHostRef(elm);
|
|
1981
|
+
// clear CSS var-shim tracking
|
|
1982
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1983
|
+
if (plt.$cssShim$) {
|
|
1984
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
1985
|
+
plt.$cssShim$.removeHost(elm);
|
|
1986
|
+
}
|
|
1231
1987
|
}
|
|
1232
1988
|
};
|
|
1233
1989
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1990
|
+
var _a;
|
|
1234
1991
|
const endBootstrap = createTime();
|
|
1235
1992
|
const cmpTags = [];
|
|
1236
1993
|
const exclude = options.exclude || [];
|
|
@@ -1239,10 +1996,22 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1239
1996
|
const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
|
|
1240
1997
|
const visibilityStyle = /*@__PURE__*/ doc.createElement('style');
|
|
1241
1998
|
const deferredConnectedCallbacks = [];
|
|
1999
|
+
const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
|
|
1242
2000
|
let appLoadFallback;
|
|
1243
2001
|
let isBootstrapping = true;
|
|
2002
|
+
let i = 0;
|
|
1244
2003
|
Object.assign(plt, options);
|
|
1245
2004
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
2005
|
+
{
|
|
2006
|
+
// If the app is already hydrated there is not point to disable the
|
|
2007
|
+
// async queue. This will improve the first input delay
|
|
2008
|
+
plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
|
|
2009
|
+
}
|
|
2010
|
+
{
|
|
2011
|
+
for (; i < styles.length; i++) {
|
|
2012
|
+
registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
1246
2015
|
lazyBundles.map((lazyBundle) => {
|
|
1247
2016
|
lazyBundle[1].map((compactMeta) => {
|
|
1248
2017
|
const cmpMeta = {
|
|
@@ -1260,6 +2029,10 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1260
2029
|
{
|
|
1261
2030
|
cmpMeta.$watchers$ = {};
|
|
1262
2031
|
}
|
|
2032
|
+
if (!supportsShadow && cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
2033
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
2034
|
+
cmpMeta.$flags$ |= 8 /* CMP_FLAGS.needsShadowDomShim */;
|
|
2035
|
+
}
|
|
1263
2036
|
const tagName = cmpMeta.$tagName$;
|
|
1264
2037
|
const HostElement = class extends HTMLElement {
|
|
1265
2038
|
// StencilLazyHost
|
|
@@ -1273,11 +2046,14 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1273
2046
|
// and this browser supports shadow dom
|
|
1274
2047
|
// add the read-only property "shadowRoot" to the host element
|
|
1275
2048
|
// adding the shadow root build conditionals to minimize runtime
|
|
1276
|
-
{
|
|
2049
|
+
if (supportsShadow) {
|
|
1277
2050
|
{
|
|
1278
2051
|
self.attachShadow({ mode: 'open' });
|
|
1279
2052
|
}
|
|
1280
2053
|
}
|
|
2054
|
+
else if (!('shadowRoot' in self)) {
|
|
2055
|
+
self.shadowRoot = self;
|
|
2056
|
+
}
|
|
1281
2057
|
}
|
|
1282
2058
|
}
|
|
1283
2059
|
connectedCallback() {
|
|
@@ -1310,6 +2086,11 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1310
2086
|
{
|
|
1311
2087
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1312
2088
|
visibilityStyle.setAttribute('data-styles', '');
|
|
2089
|
+
// Apply CSP nonce to the style tag if it exists
|
|
2090
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
2091
|
+
if (nonce != null) {
|
|
2092
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
2093
|
+
}
|
|
1313
2094
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1314
2095
|
}
|
|
1315
2096
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1325,6 +2106,13 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1325
2106
|
// Fallback appLoad event
|
|
1326
2107
|
endBootstrap();
|
|
1327
2108
|
};
|
|
2109
|
+
/**
|
|
2110
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
2111
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
2112
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
2113
|
+
* @returns void
|
|
2114
|
+
*/
|
|
2115
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1328
2116
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1329
2117
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1330
2118
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
@@ -1368,6 +2156,8 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1368
2156
|
};
|
|
1369
2157
|
const styles = /*@__PURE__*/ new Map();
|
|
1370
2158
|
const win = typeof window !== 'undefined' ? window : {};
|
|
2159
|
+
// TODO(STENCIL-659): Remove code implementing the CSS variable shim
|
|
2160
|
+
const CSS = win.CSS ;
|
|
1371
2161
|
const doc = win.document || { head: {} };
|
|
1372
2162
|
const plt = {
|
|
1373
2163
|
$flags$: 0,
|
|
@@ -1378,6 +2168,10 @@ const plt = {
|
|
|
1378
2168
|
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1379
2169
|
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1380
2170
|
};
|
|
2171
|
+
const supportsShadow =
|
|
2172
|
+
// TODO(STENCIL-662): Remove code related to deprecated shadowDomShim field
|
|
2173
|
+
/*@__PURE__*/ (() => (doc.head.attachShadow + '').indexOf('[native') > -1)()
|
|
2174
|
+
;
|
|
1381
2175
|
const promiseResolve = (v) => Promise.resolve(v);
|
|
1382
2176
|
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1383
2177
|
try {
|
|
@@ -1431,9 +2225,15 @@ const flush = () => {
|
|
|
1431
2225
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1432
2226
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1433
2227
|
|
|
2228
|
+
exports.CSS = CSS;
|
|
1434
2229
|
exports.Host = Host;
|
|
1435
2230
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1436
2231
|
exports.getElement = getElement;
|
|
1437
2232
|
exports.h = h;
|
|
2233
|
+
exports.plt = plt;
|
|
1438
2234
|
exports.promiseResolve = promiseResolve;
|
|
1439
2235
|
exports.registerInstance = registerInstance;
|
|
2236
|
+
exports.setNonce = setNonce;
|
|
2237
|
+
exports.win = win;
|
|
2238
|
+
|
|
2239
|
+
//# sourceMappingURL=index-29633529.js.map
|