@xplortech/apollo-core 1.0.0-beta.7 → 1.0.0-beta.8
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/build/style.css +4 -55
- package/dist/apollo-core/apollo-core.css +5 -5
- package/dist/apollo-core/apollo-core.esm.js +1 -1
- package/dist/apollo-core/p-10f00380.entry.js +1 -0
- package/dist/apollo-core/p-26ec64fe.entry.js +1 -0
- package/dist/apollo-core/p-2f90296c.js +2 -2
- package/dist/apollo-core/p-31acfdb4.entry.js +1 -0
- package/dist/apollo-core/p-4184ac44.entry.js +1 -0
- package/dist/apollo-core/{p-dad11011.entry.js → p-4fa14839.entry.js} +1 -1
- package/dist/apollo-core/p-55b87345.js +2 -0
- package/dist/apollo-core/p-63a6c98a.entry.js +1 -0
- package/dist/apollo-core/p-68c33b77.entry.js +1 -0
- package/dist/apollo-core/{p-a7cc4114.entry.js → p-78d07caf.entry.js} +1 -1
- package/dist/apollo-core/p-796957d3.entry.js +1 -0
- package/dist/apollo-core/p-88160d68.entry.js +1 -0
- package/dist/apollo-core/p-9ec318bb.entry.js +1 -0
- package/dist/apollo-core/p-a2a34e44.entry.js +1 -0
- package/dist/apollo-core/p-beea2502.entry.js +1 -0
- package/dist/apollo-core/p-d499e43f.entry.js +1 -0
- package/dist/apollo-core/{p-c8af4ed6.entry.js → p-d8a3d94c.entry.js} +1 -1
- package/dist/apollo-core/p-e047b446.entry.js +1 -0
- package/dist/cjs/apollo-core.cjs.js +6 -2
- package/dist/cjs/{index-acf3dd7a.js → index-2ab4832e.js} +592 -215
- package/dist/cjs/loader.cjs.js +3 -2
- package/dist/cjs/xpl-application-shell.cjs.entry.js +2 -13
- package/dist/cjs/xpl-avatar_12.cjs.entry.js +72 -38
- package/dist/cjs/xpl-backdrop.cjs.entry.js +1 -5
- package/dist/cjs/xpl-button-row.cjs.entry.js +4 -1
- package/dist/cjs/xpl-choicelist.cjs.entry.js +8 -1
- package/dist/cjs/xpl-divider.cjs.entry.js +2 -1
- package/dist/cjs/xpl-dropdown-group_3.cjs.entry.js +7 -1
- package/dist/cjs/xpl-dropdown_2.cjs.entry.js +8 -9
- package/dist/cjs/xpl-grid-item.cjs.entry.js +1 -1
- package/dist/cjs/xpl-grid.cjs.entry.js +1 -1
- package/dist/cjs/xpl-input.cjs.entry.js +615 -501
- package/dist/cjs/xpl-list.cjs.entry.js +1 -23
- package/dist/cjs/xpl-main-nav.cjs.entry.js +1 -4
- package/dist/cjs/xpl-pagination.cjs.entry.js +5 -2
- package/dist/cjs/xpl-select.cjs.entry.js +7 -22
- package/dist/cjs/xpl-toggle.cjs.entry.js +7 -4
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/xpl-application-shell/xpl-application-shell.js +118 -132
- package/dist/collection/components/xpl-avatar/xpl-avatar.js +150 -144
- package/dist/collection/components/xpl-backdrop/xpl-backdrop.js +26 -28
- package/dist/collection/components/xpl-badge/xpl-badge.js +43 -39
- package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumb-item/xpl-breadcrumb-item.js +2 -5
- package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumbs/xpl-breadcrumbs.js +2 -5
- package/dist/collection/components/xpl-button/xpl-button.js +204 -205
- package/dist/collection/components/xpl-button-row/xpl-button-row.js +105 -104
- package/dist/collection/components/xpl-checkbox/xpl-checkbox.js +181 -171
- package/dist/collection/components/xpl-choicelist/xpl-choicelist.js +133 -126
- package/dist/collection/components/xpl-content-area/xpl-content-area.js +27 -31
- package/dist/collection/components/xpl-divider/xpl-divider.js +26 -23
- package/dist/collection/components/xpl-dropdown/xpl-dropdown-group/xpl-dropdown-group.js +46 -42
- package/dist/collection/components/xpl-dropdown/xpl-dropdown-heading/xpl-dropdown-heading.js +26 -22
- package/dist/collection/components/xpl-dropdown/xpl-dropdown-option/xpl-dropdown-option.js +60 -54
- package/dist/collection/components/xpl-dropdown/xpl-dropdown.js +170 -167
- package/dist/collection/components/xpl-grid/xpl-grid.js +1 -1
- package/dist/collection/components/xpl-grid-item/xpl-grid-item.js +75 -74
- package/dist/collection/components/xpl-input/xpl-input.js +404 -417
- package/dist/collection/components/xpl-list/xpl-list.js +42 -75
- package/dist/collection/components/xpl-main-nav/xpl-main-nav.js +47 -54
- package/dist/collection/components/xpl-nav-item/xpl-nav-item.js +47 -49
- package/dist/collection/components/xpl-pagination/xpl-pagination.js +116 -128
- package/dist/collection/components/xpl-radio/xpl-radio.js +157 -148
- package/dist/collection/components/xpl-secondary-nav/xpl-secondary-nav.js +2 -4
- package/dist/collection/components/xpl-select/xpl-select.js +212 -238
- package/dist/collection/components/xpl-table/xpl-table.js +168 -151
- package/dist/collection/components/xpl-tag/xpl-tag.js +24 -25
- package/dist/collection/components/xpl-toggle/xpl-toggle.js +137 -135
- package/dist/collection/components/xpl-utility-bar/xpl-utility-bar.js +73 -70
- package/dist/custom-elements/index.js +756 -641
- package/dist/esm/apollo-core.js +3 -2
- package/dist/esm/{index-e3c4bb97.js → index-392b5b96.js} +592 -216
- package/dist/esm/loader.js +3 -2
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/xpl-application-shell.entry.js +2 -13
- package/dist/esm/xpl-avatar_12.entry.js +72 -38
- package/dist/esm/xpl-backdrop.entry.js +1 -5
- package/dist/esm/xpl-button-row.entry.js +4 -1
- package/dist/esm/xpl-choicelist.entry.js +8 -1
- package/dist/esm/xpl-divider.entry.js +2 -1
- package/dist/esm/xpl-dropdown-group_3.entry.js +7 -1
- package/dist/esm/xpl-dropdown_2.entry.js +8 -9
- package/dist/esm/xpl-grid-item.entry.js +1 -1
- package/dist/esm/xpl-grid.entry.js +1 -1
- package/dist/esm/xpl-input.entry.js +615 -501
- package/dist/esm/xpl-list.entry.js +1 -23
- package/dist/esm/xpl-main-nav.entry.js +1 -4
- package/dist/esm/xpl-pagination.entry.js +5 -2
- package/dist/esm/xpl-select.entry.js +7 -22
- package/dist/esm/xpl-toggle.entry.js +7 -4
- package/dist/types/components/xpl-dropdown/dropdownoption.d.ts +1 -1
- package/dist/types/components/xpl-table/xpl-table.d.ts +2 -0
- package/dist/types/components.d.ts +47 -11
- package/dist/types/stencil-public-runtime.d.ts +85 -11
- package/loader/index.d.ts +9 -1
- package/loader/package.json +1 -0
- package/package.json +1 -1
- package/dist/apollo-core/p-25f84d39.entry.js +0 -1
- package/dist/apollo-core/p-2ce2fe5c.entry.js +0 -1
- package/dist/apollo-core/p-3ff1ff38.entry.js +0 -1
- package/dist/apollo-core/p-63dd9a65.entry.js +0 -1
- package/dist/apollo-core/p-6c3c1e3d.entry.js +0 -1
- package/dist/apollo-core/p-81a6ce4c.entry.js +0 -1
- package/dist/apollo-core/p-918b0731.entry.js +0 -1
- package/dist/apollo-core/p-a43e2d1f.entry.js +0 -1
- package/dist/apollo-core/p-b6d1b135.entry.js +0 -1
- package/dist/apollo-core/p-bc0ebed2.entry.js +0 -1
- package/dist/apollo-core/p-d4aa2fa9.js +0 -1
- package/dist/apollo-core/p-d4e5d3aa.entry.js +0 -1
- package/dist/apollo-core/p-db74c99c.entry.js +0 -1
- package/dist/apollo-core/p-ee16942f.entry.js +0 -1
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/application-shell.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/avatar.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/backdrop.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/badge.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/breadcrumbs.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/button-row.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/button.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/checkbox.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/choicelist.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/content-area.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/divider.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/dropdown.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/grid.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/input.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/list.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/main-nav.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/pagination.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/radio.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/secondary-nav.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/select.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/table.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/tabs.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/toggle.stories.d.ts +0 -0
- /package/dist/types/Users/{roc/Sites → fernandogelin/Xplor}/apollo/.stencil/stories/utility-bar.stories.d.ts +0 -0
|
@@ -22,6 +22,14 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'apollo-core';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
27
|
+
* Simon Friis Vindum (@paldepind)
|
|
28
|
+
* Licensed under the MIT License
|
|
29
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
30
|
+
*
|
|
31
|
+
* Modified for Stencil's renderer and slot projection
|
|
32
|
+
*/
|
|
25
33
|
let contentRef;
|
|
26
34
|
let hostTagName;
|
|
27
35
|
let useNativeShadowDom = false;
|
|
@@ -29,54 +37,6 @@ let checkSlotFallbackVisibility = false;
|
|
|
29
37
|
let checkSlotRelocate = false;
|
|
30
38
|
let isSvgMode = false;
|
|
31
39
|
let queuePending = false;
|
|
32
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
33
|
-
const doc = win.document || { head: {} };
|
|
34
|
-
const plt = {
|
|
35
|
-
$flags$: 0,
|
|
36
|
-
$resourcesUrl$: '',
|
|
37
|
-
jmp: (h) => h(),
|
|
38
|
-
raf: (h) => requestAnimationFrame(h),
|
|
39
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
40
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
41
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
42
|
-
};
|
|
43
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
44
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
45
|
-
if (listeners) {
|
|
46
|
-
listeners.map(([flags, name, method]) => {
|
|
47
|
-
const target = getHostListenerTarget(elm, flags) ;
|
|
48
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
49
|
-
const opts = hostListenerOpts(flags);
|
|
50
|
-
plt.ael(target, name, handler, opts);
|
|
51
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
56
|
-
try {
|
|
57
|
-
{
|
|
58
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
59
|
-
// instance is ready, let's call it's member method for this event
|
|
60
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
catch (e) {
|
|
68
|
-
consoleError(e);
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const getHostListenerTarget = (elm, flags) => {
|
|
72
|
-
if (flags & 8 /* TargetWindow */)
|
|
73
|
-
return win;
|
|
74
|
-
return elm;
|
|
75
|
-
};
|
|
76
|
-
// prettier-ignore
|
|
77
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
78
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
79
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
80
40
|
const createTime = (fnName, tagName = '') => {
|
|
81
41
|
{
|
|
82
42
|
return () => {
|
|
@@ -91,6 +51,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
91
51
|
};
|
|
92
52
|
}
|
|
93
53
|
};
|
|
54
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
55
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
94
56
|
/**
|
|
95
57
|
* Default style mode id
|
|
96
58
|
*/
|
|
@@ -109,6 +71,18 @@ const isComplexType = (o) => {
|
|
|
109
71
|
o = typeof o;
|
|
110
72
|
return o === 'object' || o === 'function';
|
|
111
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
76
|
+
* out of a DOM's head.
|
|
77
|
+
*
|
|
78
|
+
* @param doc The DOM containing the `head` to query against
|
|
79
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
80
|
+
* exists or the tag has no content.
|
|
81
|
+
*/
|
|
82
|
+
function queryNonceMetaTagContent(doc) {
|
|
83
|
+
var _a, _b, _c;
|
|
84
|
+
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;
|
|
85
|
+
}
|
|
112
86
|
/**
|
|
113
87
|
* Production h() function based on Preact by
|
|
114
88
|
* Jason Miller (@developit)
|
|
@@ -117,7 +91,6 @@ const isComplexType = (o) => {
|
|
|
117
91
|
*
|
|
118
92
|
* Modified for Stencil's compiler and vdom
|
|
119
93
|
*/
|
|
120
|
-
// const stack: any[] = [];
|
|
121
94
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
122
95
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
123
96
|
const h = (nodeName, vnodeData, ...children) => {
|
|
@@ -126,7 +99,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
126
99
|
let slotName = null;
|
|
127
100
|
let simple = false;
|
|
128
101
|
let lastSimple = false;
|
|
129
|
-
|
|
102
|
+
const vNodeChildren = [];
|
|
130
103
|
const walk = (c) => {
|
|
131
104
|
for (let i = 0; i < c.length; i++) {
|
|
132
105
|
child = c[i];
|
|
@@ -187,6 +160,14 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
187
160
|
}
|
|
188
161
|
return vnode;
|
|
189
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
165
|
+
* possible text content.
|
|
166
|
+
*
|
|
167
|
+
* @param tag the tag for this element
|
|
168
|
+
* @param text possible text content for the node
|
|
169
|
+
* @returns a newly-minted virtual DOM node
|
|
170
|
+
*/
|
|
190
171
|
const newVNode = (tag, text) => {
|
|
191
172
|
const vnode = {
|
|
192
173
|
$flags$: 0,
|
|
@@ -207,11 +188,31 @@ const newVNode = (tag, text) => {
|
|
|
207
188
|
return vnode;
|
|
208
189
|
};
|
|
209
190
|
const Host = {};
|
|
191
|
+
/**
|
|
192
|
+
* Check whether a given node is a Host node or not
|
|
193
|
+
*
|
|
194
|
+
* @param node the virtual DOM node to check
|
|
195
|
+
* @returns whether it's a Host node or not
|
|
196
|
+
*/
|
|
210
197
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
198
|
+
/**
|
|
199
|
+
* Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
|
|
200
|
+
*
|
|
201
|
+
* Note that these functions convert from {@link d.VNode} to
|
|
202
|
+
* {@link d.ChildNode} to give functional component developers a friendly
|
|
203
|
+
* interface.
|
|
204
|
+
*/
|
|
211
205
|
const vdomFnUtils = {
|
|
212
206
|
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
213
207
|
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
214
208
|
};
|
|
209
|
+
/**
|
|
210
|
+
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
211
|
+
* friendlier public interface (hence, 'convertToPublic').
|
|
212
|
+
*
|
|
213
|
+
* @param node the virtual DOM node to convert
|
|
214
|
+
* @returns a converted child node
|
|
215
|
+
*/
|
|
215
216
|
const convertToPublic = (node) => ({
|
|
216
217
|
vattrs: node.$attrs$,
|
|
217
218
|
vchildren: node.$children$,
|
|
@@ -220,6 +221,15 @@ const convertToPublic = (node) => ({
|
|
|
220
221
|
vtag: node.$tag$,
|
|
221
222
|
vtext: node.$text$,
|
|
222
223
|
});
|
|
224
|
+
/**
|
|
225
|
+
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
226
|
+
* order to use the resulting object in the virtual DOM. The initial object was
|
|
227
|
+
* likely created as part of presenting a public API, so converting it back
|
|
228
|
+
* involved making it 'private' again (hence, `convertToPrivate`).
|
|
229
|
+
*
|
|
230
|
+
* @param node the child node to convert
|
|
231
|
+
* @returns a converted virtual DOM node
|
|
232
|
+
*/
|
|
223
233
|
const convertToPrivate = (node) => {
|
|
224
234
|
if (typeof node.vtag === 'function') {
|
|
225
235
|
const vnodeData = Object.assign({}, node.vattrs);
|
|
@@ -238,6 +248,79 @@ const convertToPrivate = (node) => {
|
|
|
238
248
|
vnode.$name$ = node.vname;
|
|
239
249
|
return vnode;
|
|
240
250
|
};
|
|
251
|
+
/**
|
|
252
|
+
* Parse a new property value for a given property type.
|
|
253
|
+
*
|
|
254
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
255
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
256
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
257
|
+
* 2. the type stored from `propType`.
|
|
258
|
+
*
|
|
259
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
260
|
+
*
|
|
261
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
262
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
263
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
264
|
+
* ```tsx
|
|
265
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* HTML prop values on the other hand, will always a string
|
|
269
|
+
*
|
|
270
|
+
* @param propValue the new value to coerce to some type
|
|
271
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
272
|
+
* @returns the parsed/coerced value
|
|
273
|
+
*/
|
|
274
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
275
|
+
// ensure this value is of the correct prop type
|
|
276
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
277
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
278
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
279
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
280
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
281
|
+
}
|
|
282
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
283
|
+
// force it to be a number
|
|
284
|
+
return parseFloat(propValue);
|
|
285
|
+
}
|
|
286
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
287
|
+
// could have been passed as a number or boolean
|
|
288
|
+
// but we still want it as a string
|
|
289
|
+
return String(propValue);
|
|
290
|
+
}
|
|
291
|
+
// redundant return here for better minification
|
|
292
|
+
return propValue;
|
|
293
|
+
}
|
|
294
|
+
// not sure exactly what type we want
|
|
295
|
+
// so no need to change to a different type
|
|
296
|
+
return propValue;
|
|
297
|
+
};
|
|
298
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
299
|
+
const createEvent = (ref, name, flags) => {
|
|
300
|
+
const elm = getElement(ref);
|
|
301
|
+
return {
|
|
302
|
+
emit: (detail) => {
|
|
303
|
+
return emitEvent(elm, name, {
|
|
304
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
305
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
306
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
307
|
+
detail,
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
314
|
+
* @param elm the target of the Event
|
|
315
|
+
* @param name the name to give the custom Event
|
|
316
|
+
* @param opts options for configuring a custom Event
|
|
317
|
+
* @returns the custom Event
|
|
318
|
+
*/
|
|
319
|
+
const emitEvent = (elm, name, opts) => {
|
|
320
|
+
const ev = plt.ce(name, opts);
|
|
321
|
+
elm.dispatchEvent(ev);
|
|
322
|
+
return ev;
|
|
323
|
+
};
|
|
241
324
|
/**
|
|
242
325
|
* Production setAccessor() function based on Preact by
|
|
243
326
|
* Jason Miller (@developit)
|
|
@@ -335,11 +418,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
335
418
|
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
336
419
|
try {
|
|
337
420
|
if (!elm.tagName.includes('-')) {
|
|
338
|
-
|
|
421
|
+
const n = newValue == null ? '' : newValue;
|
|
339
422
|
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
340
423
|
if (memberName === 'list') {
|
|
341
424
|
isProp = false;
|
|
342
|
-
// tslint:disable-next-line: triple-equals
|
|
343
425
|
}
|
|
344
426
|
else if (oldValue == null || elm[memberName] != n) {
|
|
345
427
|
elm[memberName] = n;
|
|
@@ -375,7 +457,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
375
457
|
}
|
|
376
458
|
}
|
|
377
459
|
}
|
|
378
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
460
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
379
461
|
newValue = newValue === true ? '' : newValue;
|
|
380
462
|
if (xlink) {
|
|
381
463
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -393,7 +475,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
393
475
|
// if the element passed in is a shadow root, which is a document fragment
|
|
394
476
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
395
477
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
396
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
478
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
397
479
|
? newVnode.$elm$.host
|
|
398
480
|
: newVnode.$elm$;
|
|
399
481
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -411,9 +493,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
411
493
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
412
494
|
}
|
|
413
495
|
};
|
|
496
|
+
/**
|
|
497
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
498
|
+
*
|
|
499
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
500
|
+
* @param newParentVNode the parent VNode from the current render
|
|
501
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
502
|
+
* children, for which we will create a new DOM node
|
|
503
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
504
|
+
* @returns the newly created node
|
|
505
|
+
*/
|
|
414
506
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
415
507
|
// tslint:disable-next-line: prefer-const
|
|
416
|
-
|
|
508
|
+
const newVNode = newParentVNode.$children$[childIndex];
|
|
417
509
|
let i = 0;
|
|
418
510
|
let elm;
|
|
419
511
|
let childNode;
|
|
@@ -424,16 +516,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
424
516
|
if (newVNode.$tag$ === 'slot') {
|
|
425
517
|
newVNode.$flags$ |= newVNode.$children$
|
|
426
518
|
? // slot element has fallback content
|
|
427
|
-
2 /* isSlotFallback */
|
|
519
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
428
520
|
: // slot element does not have fallback content
|
|
429
|
-
1 /* isSlotReference */;
|
|
521
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
430
522
|
}
|
|
431
523
|
}
|
|
432
524
|
if (newVNode.$text$ !== null) {
|
|
433
525
|
// create text node
|
|
434
526
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
435
527
|
}
|
|
436
|
-
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
528
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
437
529
|
// create a slot reference node
|
|
438
530
|
elm = newVNode.$elm$ =
|
|
439
531
|
doc.createTextNode('');
|
|
@@ -443,7 +535,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
443
535
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
444
536
|
}
|
|
445
537
|
// create element
|
|
446
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
|
|
538
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
447
539
|
? 'slot-fb'
|
|
448
540
|
: newVNode.$tag$)
|
|
449
541
|
);
|
|
@@ -478,7 +570,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
478
570
|
}
|
|
479
571
|
{
|
|
480
572
|
elm['s-hn'] = hostTagName;
|
|
481
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
573
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
482
574
|
// remember the content reference comment
|
|
483
575
|
elm['s-sr'] = true;
|
|
484
576
|
// remember the content reference comment
|
|
@@ -497,7 +589,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
497
589
|
return elm;
|
|
498
590
|
};
|
|
499
591
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
500
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
592
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
501
593
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
502
594
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
503
595
|
const childNode = oldSlotChildNodes[i];
|
|
@@ -518,8 +610,23 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
518
610
|
putBackInOriginalLocation(childNode, recursive);
|
|
519
611
|
}
|
|
520
612
|
}
|
|
521
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
613
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
522
614
|
};
|
|
615
|
+
/**
|
|
616
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
617
|
+
* add them to the DOM in the appropriate place.
|
|
618
|
+
*
|
|
619
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
620
|
+
* DOM nodes
|
|
621
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
622
|
+
* inserted before (optional)
|
|
623
|
+
* @param parentVNode the parent virtual DOM node
|
|
624
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
625
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
626
|
+
* creating DOM nodes (inclusive)
|
|
627
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
628
|
+
* creating DOM nodes (inclusive)
|
|
629
|
+
*/
|
|
523
630
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
524
631
|
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
525
632
|
let childNode;
|
|
@@ -533,6 +640,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
533
640
|
}
|
|
534
641
|
}
|
|
535
642
|
};
|
|
643
|
+
/**
|
|
644
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
645
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
646
|
+
* should no longer be shown.
|
|
647
|
+
*
|
|
648
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
649
|
+
*
|
|
650
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
651
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
652
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
653
|
+
* @param vnode a VNode
|
|
654
|
+
* @param elm an element
|
|
655
|
+
*/
|
|
536
656
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
537
657
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
538
658
|
if ((vnode = vnodes[startIdx])) {
|
|
@@ -557,6 +677,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
557
677
|
}
|
|
558
678
|
}
|
|
559
679
|
};
|
|
680
|
+
/**
|
|
681
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
682
|
+
* traversing the two collections of children, identifying nodes that are
|
|
683
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
684
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
685
|
+
*
|
|
686
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
687
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
688
|
+
* 'windows' by storing start and end indices and references to the
|
|
689
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
690
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
691
|
+
* no children left to update by doing the following:
|
|
692
|
+
*
|
|
693
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
694
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
695
|
+
* only with a window bounded by the highlighted elements:
|
|
696
|
+
*
|
|
697
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
698
|
+
* ^^^^^^ ^^^^^^
|
|
699
|
+
*
|
|
700
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
701
|
+
* across the windows. This will basically detect elements which haven't
|
|
702
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
703
|
+
* VNode elements (represented as HTML):
|
|
704
|
+
*
|
|
705
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
706
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
707
|
+
*
|
|
708
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
709
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
710
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
711
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
712
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
713
|
+
*
|
|
714
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
715
|
+
* window corresponds to the element at the end of the other window. This is
|
|
716
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
717
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
718
|
+
* children nodes themselves have not changed but merely moved in the
|
|
719
|
+
* following example:
|
|
720
|
+
*
|
|
721
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
722
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
723
|
+
*
|
|
724
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
725
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
726
|
+
* DOM.
|
|
727
|
+
*
|
|
728
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
729
|
+
* nodes in the old children which have the same key as the first element in
|
|
730
|
+
* our window on the new children. If we find such a node we handle calling
|
|
731
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
732
|
+
* what we find.
|
|
733
|
+
*
|
|
734
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
735
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
736
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
737
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
738
|
+
* children has collapsed we still have more nodes on the new children that
|
|
739
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
740
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
741
|
+
* sure the corresponding DOM nodes are removed.
|
|
742
|
+
*
|
|
743
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
744
|
+
* @param oldCh the old children of the parent node
|
|
745
|
+
* @param newVNode the new VNode which will replace the parent
|
|
746
|
+
* @param newCh the new children of the parent node
|
|
747
|
+
*/
|
|
560
748
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
561
749
|
let oldStartIdx = 0;
|
|
562
750
|
let newStartIdx = 0;
|
|
@@ -572,7 +760,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
572
760
|
let elmToMove;
|
|
573
761
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
574
762
|
if (oldStartVnode == null) {
|
|
575
|
-
//
|
|
763
|
+
// VNode might have been moved left
|
|
576
764
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
577
765
|
}
|
|
578
766
|
else if (oldEndVnode == null) {
|
|
@@ -585,37 +773,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
585
773
|
newEndVnode = newCh[--newEndIdx];
|
|
586
774
|
}
|
|
587
775
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
776
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
777
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
778
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
779
|
+
// since things are matched up in order.
|
|
588
780
|
patch(oldStartVnode, newStartVnode);
|
|
589
781
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
590
782
|
newStartVnode = newCh[++newStartIdx];
|
|
591
783
|
}
|
|
592
784
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
785
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
786
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
787
|
+
// need to move any DOM Nodes.
|
|
593
788
|
patch(oldEndVnode, newEndVnode);
|
|
594
789
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
595
790
|
newEndVnode = newCh[--newEndIdx];
|
|
596
791
|
}
|
|
597
792
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
598
|
-
// Vnode moved right
|
|
793
|
+
// case: "Vnode moved right"
|
|
794
|
+
//
|
|
795
|
+
// We've found that the last node in our window on the new children is
|
|
796
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
797
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
798
|
+
// nodes:
|
|
799
|
+
//
|
|
800
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
801
|
+
// ^^^^^^^^^^^
|
|
802
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
803
|
+
// ^^^^^^^^^^^^^
|
|
804
|
+
//
|
|
805
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
806
|
+
// and move the DOM element for `oldStartVnode`.
|
|
599
807
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
600
808
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
601
809
|
}
|
|
602
810
|
patch(oldStartVnode, newEndVnode);
|
|
811
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
812
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
813
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
814
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
815
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
816
|
+
//
|
|
817
|
+
// <old-start-node />
|
|
818
|
+
// <some-intervening-node />
|
|
819
|
+
// <old-end-node />
|
|
820
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
821
|
+
// <next-sibling />
|
|
822
|
+
//
|
|
823
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
824
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
825
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
826
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
827
|
+
// append it to the children of the parent element.
|
|
603
828
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
604
829
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
605
830
|
newEndVnode = newCh[--newEndIdx];
|
|
606
831
|
}
|
|
607
832
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
608
|
-
// Vnode moved left
|
|
833
|
+
// case: "Vnode moved left"
|
|
834
|
+
//
|
|
835
|
+
// We've found that the first node in our window on the new children is
|
|
836
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
837
|
+
// Visually, this is the layout of these two nodes:
|
|
838
|
+
//
|
|
839
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
840
|
+
// ^^^^^^^^^^^^^
|
|
841
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
842
|
+
// ^^^^^^^^^^^
|
|
843
|
+
//
|
|
844
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
845
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
846
|
+
// children etc) but we also need to move the DOM node to which
|
|
847
|
+
// `oldEndVnode` corresponds.
|
|
609
848
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
610
849
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
611
850
|
}
|
|
612
851
|
patch(oldEndVnode, newStartVnode);
|
|
852
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
853
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
854
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
855
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
856
|
+
// future.
|
|
613
857
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
614
858
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
615
859
|
newStartVnode = newCh[++newStartIdx];
|
|
616
860
|
}
|
|
617
861
|
else {
|
|
618
|
-
//
|
|
862
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
863
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
864
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
865
|
+
// component.
|
|
866
|
+
//
|
|
867
|
+
// First we check to see if there are any nodes in the array of old
|
|
868
|
+
// children which have the same key as the first node in the new
|
|
869
|
+
// children.
|
|
619
870
|
idxInOld = -1;
|
|
620
871
|
{
|
|
621
872
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -626,23 +877,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
626
877
|
}
|
|
627
878
|
}
|
|
628
879
|
if (idxInOld >= 0) {
|
|
880
|
+
// We found a node in the old children which matches up with the first
|
|
881
|
+
// node in the new children! So let's deal with that
|
|
629
882
|
elmToMove = oldCh[idxInOld];
|
|
630
883
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
884
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
631
885
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld);
|
|
632
886
|
}
|
|
633
887
|
else {
|
|
634
888
|
patch(elmToMove, newStartVnode);
|
|
889
|
+
// invalidate the matching old node so that we won't try to update it
|
|
890
|
+
// again later on
|
|
635
891
|
oldCh[idxInOld] = undefined;
|
|
636
892
|
node = elmToMove.$elm$;
|
|
637
893
|
}
|
|
638
894
|
newStartVnode = newCh[++newStartIdx];
|
|
639
895
|
}
|
|
640
896
|
else {
|
|
641
|
-
//
|
|
897
|
+
// We either didn't find an element in the old children that matches
|
|
898
|
+
// the key of the first new child OR the build is not using `key`
|
|
899
|
+
// attributes at all. In either case we need to create a new element
|
|
900
|
+
// for the new node.
|
|
642
901
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
643
902
|
newStartVnode = newCh[++newStartIdx];
|
|
644
903
|
}
|
|
645
904
|
if (node) {
|
|
905
|
+
// if we created a new node then handle inserting it to the DOM
|
|
646
906
|
{
|
|
647
907
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
648
908
|
}
|
|
@@ -650,21 +910,44 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
650
910
|
}
|
|
651
911
|
}
|
|
652
912
|
if (oldStartIdx > oldEndIdx) {
|
|
913
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
653
914
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
654
915
|
}
|
|
655
916
|
else if (newStartIdx > newEndIdx) {
|
|
917
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
918
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
919
|
+
// relevant DOM nodes)
|
|
656
920
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
657
921
|
}
|
|
658
922
|
};
|
|
659
|
-
|
|
923
|
+
/**
|
|
924
|
+
* Compare two VNodes to determine if they are the same
|
|
925
|
+
*
|
|
926
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
927
|
+
* information set on the two VNodes and can be misleading under certain
|
|
928
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
929
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
930
|
+
* checking that they have the same tag.
|
|
931
|
+
*
|
|
932
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
933
|
+
* changing order within a `children` array or something along those lines then
|
|
934
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
935
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
936
|
+
*
|
|
937
|
+
* @param leftVNode the first VNode to check
|
|
938
|
+
* @param rightVNode the second VNode to check
|
|
939
|
+
* @returns whether they're equal or not
|
|
940
|
+
*/
|
|
941
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
660
942
|
// compare if two vnode to see if they're "technically" the same
|
|
661
943
|
// need to have the same element tag, and same key to be the same
|
|
662
|
-
if (
|
|
663
|
-
if (
|
|
664
|
-
return
|
|
944
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
945
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
946
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
665
947
|
}
|
|
948
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
666
949
|
{
|
|
667
|
-
return
|
|
950
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
668
951
|
}
|
|
669
952
|
}
|
|
670
953
|
return false;
|
|
@@ -677,6 +960,14 @@ const referenceNode = (node) => {
|
|
|
677
960
|
return (node && node['s-ol']) || node;
|
|
678
961
|
};
|
|
679
962
|
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
963
|
+
/**
|
|
964
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
965
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
966
|
+
* children of the two nodes (if any).
|
|
967
|
+
*
|
|
968
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
969
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
970
|
+
*/
|
|
680
971
|
const patch = (oldVNode, newVNode) => {
|
|
681
972
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
682
973
|
const oldChildren = oldVNode.$children$;
|
|
@@ -690,7 +981,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
690
981
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
691
982
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
692
983
|
}
|
|
693
|
-
// element node
|
|
694
984
|
{
|
|
695
985
|
if (tag === 'slot')
|
|
696
986
|
;
|
|
@@ -703,6 +993,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
703
993
|
}
|
|
704
994
|
if (oldChildren !== null && newChildren !== null) {
|
|
705
995
|
// looks like there's child vnodes for both the old and new vnodes
|
|
996
|
+
// so we need to call `updateChildren` to reconcile them
|
|
706
997
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
707
998
|
}
|
|
708
999
|
else if (newChildren !== null) {
|
|
@@ -734,7 +1025,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
734
1025
|
};
|
|
735
1026
|
const updateFallbackSlotVisibility = (elm) => {
|
|
736
1027
|
// tslint:disable-next-line: prefer-const
|
|
737
|
-
|
|
1028
|
+
const childNodes = elm.childNodes;
|
|
738
1029
|
let childNode;
|
|
739
1030
|
let i;
|
|
740
1031
|
let ilen;
|
|
@@ -743,7 +1034,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
743
1034
|
let nodeType;
|
|
744
1035
|
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
745
1036
|
childNode = childNodes[i];
|
|
746
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1037
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
747
1038
|
if (childNode['s-sr']) {
|
|
748
1039
|
// this is a slot fallback node
|
|
749
1040
|
// get the slot name for this slot reference node
|
|
@@ -755,7 +1046,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
755
1046
|
nodeType = childNodes[j].nodeType;
|
|
756
1047
|
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
757
1048
|
// this sibling node is from a different component OR is a named fallback slot node
|
|
758
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1049
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
759
1050
|
childNode.hidden = true;
|
|
760
1051
|
break;
|
|
761
1052
|
}
|
|
@@ -764,8 +1055,8 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
764
1055
|
// this is a default fallback slot node
|
|
765
1056
|
// any element or text node (with content)
|
|
766
1057
|
// should hide the default fallback slot node
|
|
767
|
-
if (nodeType === 1 /* ElementNode */ ||
|
|
768
|
-
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1058
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1059
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
769
1060
|
childNode.hidden = true;
|
|
770
1061
|
break;
|
|
771
1062
|
}
|
|
@@ -787,8 +1078,8 @@ const relocateSlotContent = (elm) => {
|
|
|
787
1078
|
let relocateNodeData;
|
|
788
1079
|
let j;
|
|
789
1080
|
let i = 0;
|
|
790
|
-
|
|
791
|
-
|
|
1081
|
+
const childNodes = elm.childNodes;
|
|
1082
|
+
const ilen = childNodes.length;
|
|
792
1083
|
for (; i < ilen; i++) {
|
|
793
1084
|
childNode = childNodes[i];
|
|
794
1085
|
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
@@ -843,13 +1134,13 @@ const relocateSlotContent = (elm) => {
|
|
|
843
1134
|
}
|
|
844
1135
|
}
|
|
845
1136
|
}
|
|
846
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1137
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
847
1138
|
relocateSlotContent(childNode);
|
|
848
1139
|
}
|
|
849
1140
|
}
|
|
850
1141
|
};
|
|
851
1142
|
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
852
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1143
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
853
1144
|
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
854
1145
|
return true;
|
|
855
1146
|
}
|
|
@@ -869,6 +1160,18 @@ const callNodeRefs = (vNode) => {
|
|
|
869
1160
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
870
1161
|
}
|
|
871
1162
|
};
|
|
1163
|
+
/**
|
|
1164
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
1165
|
+
*
|
|
1166
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
1167
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
1168
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
1169
|
+
* relocation, and reflecting attributes.
|
|
1170
|
+
*
|
|
1171
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
1172
|
+
* the DOM node into which it should be rendered.
|
|
1173
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
1174
|
+
*/
|
|
872
1175
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
873
1176
|
const hostElm = hostRef.$hostElement$;
|
|
874
1177
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
@@ -880,12 +1183,12 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
880
1183
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
881
1184
|
}
|
|
882
1185
|
rootVnode.$tag$ = null;
|
|
883
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1186
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
884
1187
|
hostRef.$vnode$ = rootVnode;
|
|
885
1188
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
|
|
886
1189
|
{
|
|
887
1190
|
contentRef = hostElm['s-cr'];
|
|
888
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
1191
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
889
1192
|
// always reset
|
|
890
1193
|
checkSlotFallbackVisibility = false;
|
|
891
1194
|
}
|
|
@@ -894,7 +1197,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
894
1197
|
{
|
|
895
1198
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
896
1199
|
// the disconnectCallback from working
|
|
897
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
1200
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
898
1201
|
if (checkSlotRelocate) {
|
|
899
1202
|
relocateSlotContent(rootVnode.$elm$);
|
|
900
1203
|
let relocateData;
|
|
@@ -952,7 +1255,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
952
1255
|
}
|
|
953
1256
|
else {
|
|
954
1257
|
// this node doesn't have a slot home to go to, so let's hide it
|
|
955
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1258
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
956
1259
|
nodeToRelocate.hidden = true;
|
|
957
1260
|
}
|
|
958
1261
|
}
|
|
@@ -963,30 +1266,11 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
963
1266
|
}
|
|
964
1267
|
// done moving nodes around
|
|
965
1268
|
// allow the disconnect callback to work again
|
|
966
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1269
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
967
1270
|
// always reset
|
|
968
1271
|
relocateNodes.length = 0;
|
|
969
1272
|
}
|
|
970
1273
|
};
|
|
971
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
972
|
-
const createEvent = (ref, name, flags) => {
|
|
973
|
-
const elm = getElement(ref);
|
|
974
|
-
return {
|
|
975
|
-
emit: (detail) => {
|
|
976
|
-
return emitEvent(elm, name, {
|
|
977
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
978
|
-
composed: !!(flags & 2 /* Composed */),
|
|
979
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
980
|
-
detail,
|
|
981
|
-
});
|
|
982
|
-
},
|
|
983
|
-
};
|
|
984
|
-
};
|
|
985
|
-
const emitEvent = (elm, name, opts) => {
|
|
986
|
-
const ev = plt.ce(name, opts);
|
|
987
|
-
elm.dispatchEvent(ev);
|
|
988
|
-
return ev;
|
|
989
|
-
};
|
|
990
1274
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
991
1275
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
992
1276
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -994,10 +1278,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
994
1278
|
};
|
|
995
1279
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
996
1280
|
{
|
|
997
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1281
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
998
1282
|
}
|
|
999
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1000
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1283
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1284
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
1001
1285
|
return;
|
|
1002
1286
|
}
|
|
1003
1287
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -1013,7 +1297,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1013
1297
|
let promise;
|
|
1014
1298
|
if (isInitialLoad) {
|
|
1015
1299
|
{
|
|
1016
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
1300
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1017
1301
|
if (hostRef.$queuedListeners$) {
|
|
1018
1302
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1019
1303
|
hostRef.$queuedListeners$ = null;
|
|
@@ -1052,7 +1336,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1052
1336
|
}
|
|
1053
1337
|
else {
|
|
1054
1338
|
Promise.all(childrenPromises).then(postUpdate);
|
|
1055
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1339
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
1056
1340
|
childrenPromises.length = 0;
|
|
1057
1341
|
}
|
|
1058
1342
|
}
|
|
@@ -1061,10 +1345,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1061
1345
|
try {
|
|
1062
1346
|
instance = instance.render() ;
|
|
1063
1347
|
{
|
|
1064
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1348
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1065
1349
|
}
|
|
1066
1350
|
{
|
|
1067
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1351
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1068
1352
|
}
|
|
1069
1353
|
{
|
|
1070
1354
|
{
|
|
@@ -1091,8 +1375,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1091
1375
|
{
|
|
1092
1376
|
safeCall(instance, 'componentDidRender');
|
|
1093
1377
|
}
|
|
1094
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1095
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1378
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1379
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1096
1380
|
{
|
|
1097
1381
|
// DOM WRITE!
|
|
1098
1382
|
addHydratedFlag(elm);
|
|
@@ -1124,10 +1408,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1124
1408
|
hostRef.$onRenderResolve$();
|
|
1125
1409
|
hostRef.$onRenderResolve$ = undefined;
|
|
1126
1410
|
}
|
|
1127
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1411
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1128
1412
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1129
1413
|
}
|
|
1130
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1414
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
1131
1415
|
}
|
|
1132
1416
|
// ( •_•)
|
|
1133
1417
|
// ( •_•)>⌐■-■
|
|
@@ -1157,44 +1441,40 @@ const then = (promise, thenFn) => {
|
|
|
1157
1441
|
};
|
|
1158
1442
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
1159
1443
|
;
|
|
1160
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
1161
|
-
// ensure this value is of the correct prop type
|
|
1162
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
1163
|
-
if (propType & 4 /* Boolean */) {
|
|
1164
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
1165
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1166
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1167
|
-
}
|
|
1168
|
-
if (propType & 2 /* Number */) {
|
|
1169
|
-
// force it to be a number
|
|
1170
|
-
return parseFloat(propValue);
|
|
1171
|
-
}
|
|
1172
|
-
if (propType & 1 /* String */) {
|
|
1173
|
-
// could have been passed as a number or boolean
|
|
1174
|
-
// but we still want it as a string
|
|
1175
|
-
return String(propValue);
|
|
1176
|
-
}
|
|
1177
|
-
// redundant return here for better minification
|
|
1178
|
-
return propValue;
|
|
1179
|
-
}
|
|
1180
|
-
// not sure exactly what type we want
|
|
1181
|
-
// so no need to change to a different type
|
|
1182
|
-
return propValue;
|
|
1183
|
-
};
|
|
1184
1444
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1185
1445
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1186
1446
|
// check our new property value against our internal value
|
|
1187
1447
|
const hostRef = getHostRef(ref);
|
|
1448
|
+
const elm = hostRef.$hostElement$ ;
|
|
1188
1449
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
1189
1450
|
const flags = hostRef.$flags$;
|
|
1190
1451
|
const instance = hostRef.$lazyInstance$ ;
|
|
1191
1452
|
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
1192
|
-
|
|
1453
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1454
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1455
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1456
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1193
1457
|
// gadzooks! the property's value has changed!!
|
|
1194
1458
|
// set our new value!
|
|
1195
1459
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1196
1460
|
if (instance) {
|
|
1197
|
-
|
|
1461
|
+
// get an array of method names of watch functions to call
|
|
1462
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1463
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1464
|
+
if (watchMethods) {
|
|
1465
|
+
// this instance is watching for when this property changed
|
|
1466
|
+
watchMethods.map((watchMethodName) => {
|
|
1467
|
+
try {
|
|
1468
|
+
// fire off each of the watch methods that are watching this property
|
|
1469
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
1470
|
+
}
|
|
1471
|
+
catch (e) {
|
|
1472
|
+
consoleError(e, elm);
|
|
1473
|
+
}
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1198
1478
|
// looks like this value actually changed, so we've got work to do!
|
|
1199
1479
|
// but only if we've already rendered, otherwise just chill out
|
|
1200
1480
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1204,14 +1484,27 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1204
1484
|
}
|
|
1205
1485
|
}
|
|
1206
1486
|
};
|
|
1487
|
+
/**
|
|
1488
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1489
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1490
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1491
|
+
*
|
|
1492
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1493
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1494
|
+
* @param flags a number used to store a series of bit flags
|
|
1495
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1496
|
+
*/
|
|
1207
1497
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1208
1498
|
if (cmpMeta.$members$) {
|
|
1499
|
+
if (Cstr.watchers) {
|
|
1500
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1501
|
+
}
|
|
1209
1502
|
// It's better to have a const than two Object.entries()
|
|
1210
1503
|
const members = Object.entries(cmpMeta.$members$);
|
|
1211
1504
|
const prototype = Cstr.prototype;
|
|
1212
1505
|
members.map(([memberName, [memberFlags]]) => {
|
|
1213
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1214
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1506
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1507
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1215
1508
|
// proxyComponent - prop
|
|
1216
1509
|
Object.defineProperty(prototype, memberName, {
|
|
1217
1510
|
get() {
|
|
@@ -1226,8 +1519,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1226
1519
|
enumerable: true,
|
|
1227
1520
|
});
|
|
1228
1521
|
}
|
|
1229
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1230
|
-
memberFlags & 64 /* Method */) {
|
|
1522
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1523
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1231
1524
|
// proxyComponent - method
|
|
1232
1525
|
Object.defineProperty(prototype, memberName, {
|
|
1233
1526
|
value(...args) {
|
|
@@ -1237,19 +1530,19 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1237
1530
|
});
|
|
1238
1531
|
}
|
|
1239
1532
|
});
|
|
1240
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1533
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1241
1534
|
const attrNameToPropName = new Map();
|
|
1242
1535
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1243
1536
|
plt.jmp(() => {
|
|
1244
1537
|
const propName = attrNameToPropName.get(attrName);
|
|
1245
|
-
// In a
|
|
1538
|
+
// In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
|
|
1246
1539
|
// in the case where an attribute was set inline.
|
|
1247
1540
|
// ```html
|
|
1248
1541
|
// <my-component some-attribute="some-value"></my-component>
|
|
1249
1542
|
// ```
|
|
1250
1543
|
//
|
|
1251
|
-
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
1252
|
-
// changes it before it has been upgraded as shown below:
|
|
1544
|
+
// There is an edge case where a developer sets the attribute inline on a custom element and then
|
|
1545
|
+
// programmatically changes it before it has been upgraded as shown below:
|
|
1253
1546
|
//
|
|
1254
1547
|
// ```html
|
|
1255
1548
|
// <!-- this component has _not_ been upgraded yet -->
|
|
@@ -1259,13 +1552,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1259
1552
|
// el = document.querySelector("#test");
|
|
1260
1553
|
// el.someAttribute = "another-value";
|
|
1261
1554
|
// // upgrade component
|
|
1262
|
-
//
|
|
1555
|
+
// customElements.define('my-component', MyComponent);
|
|
1263
1556
|
// </script>
|
|
1264
1557
|
// ```
|
|
1265
1558
|
// In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
|
|
1266
1559
|
// will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
|
|
1267
1560
|
// to the value that was set inline i.e. "some-value" from above example. When
|
|
1268
|
-
// the connectedCallback attempts to unshadow it will use "some-value" as the
|
|
1561
|
+
// the connectedCallback attempts to unshadow it will use "some-value" as the initial value rather than "another-value"
|
|
1269
1562
|
//
|
|
1270
1563
|
// The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
|
|
1271
1564
|
// by connectedCallback as this attributeChangedCallback will not fire.
|
|
@@ -1279,17 +1572,25 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1279
1572
|
newValue = this[propName];
|
|
1280
1573
|
delete this[propName];
|
|
1281
1574
|
}
|
|
1575
|
+
else if (prototype.hasOwnProperty(propName) &&
|
|
1576
|
+
typeof this[propName] === 'number' &&
|
|
1577
|
+
this[propName] == newValue) {
|
|
1578
|
+
// if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
|
|
1579
|
+
// APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
|
|
1580
|
+
// `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1282
1583
|
this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
|
|
1283
1584
|
});
|
|
1284
1585
|
};
|
|
1285
1586
|
// create an array of attributes to observe
|
|
1286
1587
|
// and also create a map of html attribute name to js property name
|
|
1287
1588
|
Cstr.observedAttributes = members
|
|
1288
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1589
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1289
1590
|
.map(([propName, m]) => {
|
|
1290
1591
|
const attrName = m[1] || propName;
|
|
1291
1592
|
attrNameToPropName.set(attrName, propName);
|
|
1292
|
-
if (m[0] & 512 /* ReflectAttr */) {
|
|
1593
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1293
1594
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1294
1595
|
}
|
|
1295
1596
|
return attrName;
|
|
@@ -1300,10 +1601,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1300
1601
|
};
|
|
1301
1602
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1302
1603
|
// initializeComponent
|
|
1303
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1604
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1304
1605
|
{
|
|
1305
1606
|
// we haven't initialized this element yet
|
|
1306
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1607
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1307
1608
|
// lazy loaded components
|
|
1308
1609
|
// request the component's implementation to be
|
|
1309
1610
|
// wired up with the host element
|
|
@@ -1315,7 +1616,13 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1315
1616
|
endLoad();
|
|
1316
1617
|
}
|
|
1317
1618
|
if (!Cstr.isProxied) {
|
|
1318
|
-
|
|
1619
|
+
// we've never proxied this Constructor before
|
|
1620
|
+
// let's add the getters/setters to its prototype before
|
|
1621
|
+
// the first time we create an instance of the implementation
|
|
1622
|
+
{
|
|
1623
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1624
|
+
}
|
|
1625
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1319
1626
|
Cstr.isProxied = true;
|
|
1320
1627
|
}
|
|
1321
1628
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1323,7 +1630,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1323
1630
|
// but let's keep track of when we start and stop
|
|
1324
1631
|
// so that the getters/setters don't incorrectly step on data
|
|
1325
1632
|
{
|
|
1326
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1633
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1327
1634
|
}
|
|
1328
1635
|
// construct the lazy-loaded component implementation
|
|
1329
1636
|
// passing the hostRef is very important during
|
|
@@ -1336,7 +1643,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1336
1643
|
consoleError(e);
|
|
1337
1644
|
}
|
|
1338
1645
|
{
|
|
1339
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1646
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1647
|
+
}
|
|
1648
|
+
{
|
|
1649
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1340
1650
|
}
|
|
1341
1651
|
endNewInstance();
|
|
1342
1652
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -1346,7 +1656,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1346
1656
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1347
1657
|
const schedule = () => scheduleUpdate(hostRef, true);
|
|
1348
1658
|
if (ancestorComponent && ancestorComponent['s-rc']) {
|
|
1349
|
-
// this is the
|
|
1659
|
+
// this is the initial load and this component it has an ancestor component
|
|
1350
1660
|
// but the ancestor component has NOT fired its will update lifecycle yet
|
|
1351
1661
|
// so let's just cool our jets and wait for the ancestor to continue first
|
|
1352
1662
|
// this will get fired off when the ancestor component
|
|
@@ -1364,19 +1674,19 @@ const fireConnectedCallback = (instance) => {
|
|
|
1364
1674
|
}
|
|
1365
1675
|
};
|
|
1366
1676
|
const connectedCallback = (elm) => {
|
|
1367
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1677
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1368
1678
|
const hostRef = getHostRef(elm);
|
|
1369
1679
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1370
1680
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1371
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1681
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1372
1682
|
// first time this component has connected
|
|
1373
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1683
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1374
1684
|
{
|
|
1375
1685
|
// initUpdate
|
|
1376
1686
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1377
1687
|
// in here to act as original content anchors as we move nodes around
|
|
1378
1688
|
// host element has been connected to the DOM
|
|
1379
|
-
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1689
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1380
1690
|
setContentReference(elm);
|
|
1381
1691
|
}
|
|
1382
1692
|
}
|
|
@@ -1399,7 +1709,7 @@ const connectedCallback = (elm) => {
|
|
|
1399
1709
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1400
1710
|
if (cmpMeta.$members$) {
|
|
1401
1711
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1402
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1712
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1403
1713
|
const value = elm[memberName];
|
|
1404
1714
|
delete elm[memberName];
|
|
1405
1715
|
elm[memberName] = value;
|
|
@@ -1433,7 +1743,7 @@ const setContentReference = (elm) => {
|
|
|
1433
1743
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1434
1744
|
};
|
|
1435
1745
|
const disconnectedCallback = (elm) => {
|
|
1436
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1746
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1437
1747
|
const hostRef = getHostRef(elm);
|
|
1438
1748
|
const instance = hostRef.$lazyInstance$ ;
|
|
1439
1749
|
{
|
|
@@ -1448,6 +1758,7 @@ const disconnectedCallback = (elm) => {
|
|
|
1448
1758
|
}
|
|
1449
1759
|
};
|
|
1450
1760
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1761
|
+
var _a;
|
|
1451
1762
|
const endBootstrap = createTime();
|
|
1452
1763
|
const cmpTags = [];
|
|
1453
1764
|
const exclude = options.exclude || [];
|
|
@@ -1460,60 +1771,70 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1460
1771
|
let isBootstrapping = true;
|
|
1461
1772
|
Object.assign(plt, options);
|
|
1462
1773
|
plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
|
|
1463
|
-
lazyBundles.map((lazyBundle) =>
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
constructor(self) {
|
|
1483
|
-
// @ts-ignore
|
|
1484
|
-
super(self);
|
|
1485
|
-
self = this;
|
|
1486
|
-
registerHost(self, cmpMeta);
|
|
1774
|
+
lazyBundles.map((lazyBundle) => {
|
|
1775
|
+
lazyBundle[1].map((compactMeta) => {
|
|
1776
|
+
const cmpMeta = {
|
|
1777
|
+
$flags$: compactMeta[0],
|
|
1778
|
+
$tagName$: compactMeta[1],
|
|
1779
|
+
$members$: compactMeta[2],
|
|
1780
|
+
$listeners$: compactMeta[3],
|
|
1781
|
+
};
|
|
1782
|
+
{
|
|
1783
|
+
cmpMeta.$members$ = compactMeta[2];
|
|
1784
|
+
}
|
|
1785
|
+
{
|
|
1786
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1787
|
+
}
|
|
1788
|
+
{
|
|
1789
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
1790
|
+
}
|
|
1791
|
+
{
|
|
1792
|
+
cmpMeta.$watchers$ = {};
|
|
1487
1793
|
}
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1794
|
+
const tagName = cmpMeta.$tagName$;
|
|
1795
|
+
const HostElement = class extends HTMLElement {
|
|
1796
|
+
// StencilLazyHost
|
|
1797
|
+
constructor(self) {
|
|
1798
|
+
// @ts-ignore
|
|
1799
|
+
super(self);
|
|
1800
|
+
self = this;
|
|
1801
|
+
registerHost(self, cmpMeta);
|
|
1492
1802
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1803
|
+
connectedCallback() {
|
|
1804
|
+
if (appLoadFallback) {
|
|
1805
|
+
clearTimeout(appLoadFallback);
|
|
1806
|
+
appLoadFallback = null;
|
|
1807
|
+
}
|
|
1808
|
+
if (isBootstrapping) {
|
|
1809
|
+
// connectedCallback will be processed once all components have been registered
|
|
1810
|
+
deferredConnectedCallbacks.push(this);
|
|
1811
|
+
}
|
|
1812
|
+
else {
|
|
1813
|
+
plt.jmp(() => connectedCallback(this));
|
|
1814
|
+
}
|
|
1496
1815
|
}
|
|
1497
|
-
|
|
1498
|
-
plt.jmp(() =>
|
|
1816
|
+
disconnectedCallback() {
|
|
1817
|
+
plt.jmp(() => disconnectedCallback(this));
|
|
1499
1818
|
}
|
|
1819
|
+
componentOnReady() {
|
|
1820
|
+
return getHostRef(this).$onReadyPromise$;
|
|
1821
|
+
}
|
|
1822
|
+
};
|
|
1823
|
+
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1824
|
+
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1825
|
+
cmpTags.push(tagName);
|
|
1826
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1500
1827
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
}
|
|
1504
|
-
componentOnReady() {
|
|
1505
|
-
return getHostRef(this).$onReadyPromise$;
|
|
1506
|
-
}
|
|
1507
|
-
};
|
|
1508
|
-
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1509
|
-
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1510
|
-
cmpTags.push(tagName);
|
|
1511
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1512
|
-
}
|
|
1513
|
-
}));
|
|
1828
|
+
});
|
|
1829
|
+
});
|
|
1514
1830
|
{
|
|
1515
1831
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1516
1832
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1833
|
+
// Apply CSP nonce to the style tag if it exists
|
|
1834
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1835
|
+
if (nonce != null) {
|
|
1836
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
1837
|
+
}
|
|
1517
1838
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1518
1839
|
}
|
|
1519
1840
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1530,7 +1851,48 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1530
1851
|
endBootstrap();
|
|
1531
1852
|
};
|
|
1532
1853
|
const Fragment = (_, children) => children;
|
|
1533
|
-
const
|
|
1854
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1855
|
+
if (listeners) {
|
|
1856
|
+
listeners.map(([flags, name, method]) => {
|
|
1857
|
+
const target = getHostListenerTarget(elm, flags) ;
|
|
1858
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1859
|
+
const opts = hostListenerOpts(flags);
|
|
1860
|
+
plt.ael(target, name, handler, opts);
|
|
1861
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
};
|
|
1865
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1866
|
+
try {
|
|
1867
|
+
{
|
|
1868
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1869
|
+
// instance is ready, let's call it's member method for this event
|
|
1870
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1871
|
+
}
|
|
1872
|
+
else {
|
|
1873
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
catch (e) {
|
|
1878
|
+
consoleError(e);
|
|
1879
|
+
}
|
|
1880
|
+
};
|
|
1881
|
+
const getHostListenerTarget = (elm, flags) => {
|
|
1882
|
+
if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
|
|
1883
|
+
return win;
|
|
1884
|
+
return elm;
|
|
1885
|
+
};
|
|
1886
|
+
// prettier-ignore
|
|
1887
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1888
|
+
/**
|
|
1889
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1890
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
1891
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
1892
|
+
* @returns void
|
|
1893
|
+
*/
|
|
1894
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1895
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1534
1896
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1535
1897
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1536
1898
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1562,7 +1924,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1562
1924
|
if (module) {
|
|
1563
1925
|
return module[exportName];
|
|
1564
1926
|
}
|
|
1927
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
1565
1928
|
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
|
|
1929
|
+
/* @vite-ignore */
|
|
1566
1930
|
/* webpackInclude: /\.entry\.js$/ */
|
|
1567
1931
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1568
1932
|
/* webpackMode: "lazy" */
|
|
@@ -1573,13 +1937,25 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1573
1937
|
return importedModule[exportName];
|
|
1574
1938
|
}, consoleError);
|
|
1575
1939
|
};
|
|
1940
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1941
|
+
const doc = win.document || { head: {} };
|
|
1942
|
+
const plt = {
|
|
1943
|
+
$flags$: 0,
|
|
1944
|
+
$resourcesUrl$: '',
|
|
1945
|
+
jmp: (h) => h(),
|
|
1946
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1947
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1948
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1949
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1950
|
+
};
|
|
1951
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1576
1952
|
const queueDomReads = [];
|
|
1577
1953
|
const queueDomWrites = [];
|
|
1578
1954
|
const queueTask = (queue, write) => (cb) => {
|
|
1579
1955
|
queue.push(cb);
|
|
1580
1956
|
if (!queuePending) {
|
|
1581
1957
|
queuePending = true;
|
|
1582
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1958
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1583
1959
|
nextTick(flush);
|
|
1584
1960
|
}
|
|
1585
1961
|
else {
|
|
@@ -1624,3 +2000,4 @@ exports.getElement = getElement;
|
|
|
1624
2000
|
exports.h = h;
|
|
1625
2001
|
exports.promiseResolve = promiseResolve;
|
|
1626
2002
|
exports.registerInstance = registerInstance;
|
|
2003
|
+
exports.setNonce = setNonce;
|