@sankhyalabs/ezui 3.0.0 → 3.0.2
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/ez-actions-button.cjs.entry.js +12 -26
- package/dist/cjs/ez-alert.cjs.entry.js +2 -5
- package/dist/cjs/ez-application.cjs.entry.js +2 -2
- package/dist/cjs/ez-breadcrumb.cjs.entry.js +2 -5
- package/dist/cjs/ez-button.cjs.entry.js +6 -8
- package/dist/cjs/ez-calendar.cjs.entry.js +2 -14
- package/dist/cjs/ez-card-item.cjs.entry.js +3 -2
- package/dist/cjs/ez-check.cjs.entry.js +5 -8
- package/dist/cjs/ez-chip.cjs.entry.js +8 -11
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +4 -20
- package/dist/cjs/ez-combo-box.cjs.entry.js +11 -23
- package/dist/cjs/ez-date-input.cjs.entry.js +5 -8
- package/dist/cjs/ez-date-time-input.cjs.entry.js +5 -11
- package/dist/cjs/ez-dialog.cjs.entry.js +7 -9
- package/dist/cjs/ez-dropdown.cjs.entry.js +4 -5
- package/dist/cjs/ez-file-item.cjs.entry.js +5 -8
- package/dist/cjs/ez-filter-input_4.cjs.entry.js +14 -23
- package/dist/cjs/ez-form-view.cjs.entry.js +3 -2
- package/dist/cjs/ez-form.cjs.entry.js +26 -20
- package/dist/cjs/ez-grid.cjs.entry.js +11131 -6779
- package/dist/cjs/ez-guide-navigator.cjs.entry.js +3 -11
- package/dist/cjs/ez-icon.cjs.entry.js +4 -5
- package/dist/cjs/ez-list.cjs.entry.js +4 -15
- package/dist/cjs/ez-loading-bar.cjs.entry.js +2 -2
- package/dist/cjs/ez-modal-container.cjs.entry.js +8 -5
- package/dist/cjs/ez-modal.cjs.entry.js +7 -14
- package/dist/cjs/ez-number-input.cjs.entry.js +7 -8
- package/dist/cjs/ez-popover.cjs.entry.js +11 -30
- package/dist/cjs/ez-popup.cjs.entry.js +3 -14
- package/dist/cjs/ez-radio-button.cjs.entry.js +4 -11
- package/dist/cjs/ez-search.cjs.entry.js +6 -17
- package/dist/cjs/ez-tabselector.cjs.entry.js +6 -2
- package/dist/cjs/ez-text-area.cjs.entry.js +5 -14
- package/dist/cjs/ez-text-edit.cjs.entry.js +5 -2
- package/dist/cjs/ez-text-input.cjs.entry.js +7 -14
- package/dist/cjs/ez-time-input.cjs.entry.js +5 -11
- package/dist/cjs/ez-toast.cjs.entry.js +3 -11
- package/dist/cjs/ez-upload.cjs.entry.js +9 -5
- package/dist/cjs/ez-view-stack.cjs.entry.js +2 -2
- package/dist/cjs/ezui.cjs.js +6 -2
- package/dist/cjs/{index-5e208fa5.js → index-892780f1.js} +588 -248
- package/dist/cjs/loader.cjs.js +3 -2
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/ez-actions-button/ez-actions-button.js +248 -256
- package/dist/collection/components/ez-alert/ez-alert.js +34 -36
- package/dist/collection/components/ez-application/ez-application.js +29 -23
- package/dist/collection/components/ez-breadcrumb/ez-breadcrumb.js +61 -60
- package/dist/collection/components/ez-button/ez-button.js +159 -159
- package/dist/collection/components/ez-calendar/ez-calendar.js +214 -244
- package/dist/collection/components/ez-card-item/ez-card-item.js +60 -58
- package/dist/collection/components/ez-check/ez-check.js +164 -157
- package/dist/collection/components/ez-chip/ez-chip.css +4 -0
- package/dist/collection/components/ez-chip/ez-chip.js +192 -188
- package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +282 -293
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +348 -361
- package/dist/collection/components/ez-date-input/ez-date-input.js +213 -207
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +233 -228
- package/dist/collection/components/ez-dialog/ez-dialog.js +203 -209
- package/dist/collection/components/ez-dropdown/ez-dropdown.js +128 -127
- package/dist/collection/components/ez-dropdown/structure/DropdownItem.js +1 -4
- package/dist/collection/components/ez-file-item/ez-file-item.js +144 -142
- package/dist/collection/components/ez-filter-input/ez-filter-input.js +197 -188
- package/dist/collection/components/ez-form/DataBinder.js +12 -6
- package/dist/collection/components/ez-form/ez-form.js +191 -177
- package/dist/collection/components/ez-form-view/ez-form-view.js +38 -29
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/CheckBox.tpl.js +1 -2
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/ComboBox.tpl.js +1 -2
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/DateInput.tpl.js +3 -6
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/FileInput.tpl.js +1 -2
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/NumberInput.tpl.js +1 -2
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/SearchInput.tpl.js +1 -2
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/TextArea.tpl.js +1 -2
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/TextInput.tpl.js +1 -2
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +20 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/mock/Server.js +1 -1
- package/dist/collection/components/ez-grid/ez-grid.js +366 -352
- package/dist/collection/components/ez-guide-navigator/ez-guide-navigator.js +120 -125
- package/dist/collection/components/ez-icon/ez-icon.js +68 -64
- package/dist/collection/components/ez-list/ez-list.js +246 -266
- package/dist/collection/components/ez-loading-bar/ez-loading-bar.js +49 -42
- package/dist/collection/components/ez-modal/ez-modal.js +143 -143
- package/dist/collection/components/ez-modal-container/ez-modal-container.js +153 -155
- package/dist/collection/components/ez-number-input/ez-number-input.js +246 -233
- package/dist/collection/components/ez-popover/ez-popover.js +273 -283
- package/dist/collection/components/ez-popup/ez-popup.js +121 -133
- package/dist/collection/components/ez-radio-button/ez-radio-button.js +123 -126
- package/dist/collection/components/ez-scroller/ez-scroller.js +104 -100
- package/dist/collection/components/ez-search/ez-search.js +260 -259
- package/dist/collection/components/ez-sidebar-button/ez-sidebar-button.js +30 -25
- package/dist/collection/components/ez-tabselector/ez-tabselector.js +115 -106
- package/dist/collection/components/ez-text-area/ez-text-area.js +217 -218
- package/dist/collection/components/ez-text-edit/ez-text-edit.js +109 -96
- package/dist/collection/components/ez-text-input/ez-text-input.js +248 -248
- package/dist/collection/components/ez-time-input/ez-time-input.js +227 -223
- package/dist/collection/components/ez-toast/ez-toast.js +117 -121
- package/dist/collection/components/ez-tree/ez-tree.js +289 -275
- package/dist/collection/components/ez-tree/subcomponents/TreeItem.js +7 -11
- package/dist/collection/components/ez-upload/ez-upload.js +283 -281
- package/dist/collection/components/ez-view-stack/ez-view-stack.js +46 -40
- package/dist/custom-elements/index.js +11121 -6945
- package/dist/esm/ez-actions-button.entry.js +12 -26
- package/dist/esm/ez-alert.entry.js +2 -5
- package/dist/esm/ez-application.entry.js +2 -2
- package/dist/esm/ez-breadcrumb.entry.js +2 -5
- package/dist/esm/ez-button.entry.js +6 -8
- package/dist/esm/ez-calendar.entry.js +2 -14
- package/dist/esm/ez-card-item.entry.js +3 -2
- package/dist/esm/ez-check.entry.js +5 -8
- package/dist/esm/ez-chip.entry.js +8 -11
- package/dist/esm/ez-collapsible-box.entry.js +4 -20
- package/dist/esm/ez-combo-box.entry.js +11 -23
- package/dist/esm/ez-date-input.entry.js +5 -8
- package/dist/esm/ez-date-time-input.entry.js +5 -11
- package/dist/esm/ez-dialog.entry.js +7 -9
- package/dist/esm/ez-dropdown.entry.js +4 -5
- package/dist/esm/ez-file-item.entry.js +5 -8
- package/dist/esm/ez-filter-input_4.entry.js +14 -23
- package/dist/esm/ez-form-view.entry.js +3 -2
- package/dist/esm/ez-form.entry.js +26 -20
- package/dist/esm/ez-grid.entry.js +11131 -6779
- package/dist/esm/ez-guide-navigator.entry.js +3 -11
- package/dist/esm/ez-icon.entry.js +4 -5
- package/dist/esm/ez-list.entry.js +4 -15
- package/dist/esm/ez-loading-bar.entry.js +2 -2
- package/dist/esm/ez-modal-container.entry.js +8 -5
- package/dist/esm/ez-modal.entry.js +7 -14
- package/dist/esm/ez-number-input.entry.js +7 -8
- package/dist/esm/ez-popover.entry.js +11 -30
- package/dist/esm/ez-popup.entry.js +3 -14
- package/dist/esm/ez-radio-button.entry.js +4 -11
- package/dist/esm/ez-search.entry.js +6 -17
- package/dist/esm/ez-tabselector.entry.js +6 -2
- package/dist/esm/ez-text-area.entry.js +5 -14
- package/dist/esm/ez-text-edit.entry.js +5 -2
- package/dist/esm/ez-text-input.entry.js +7 -14
- package/dist/esm/ez-time-input.entry.js +5 -11
- package/dist/esm/ez-toast.entry.js +3 -11
- package/dist/esm/ez-upload.entry.js +9 -5
- package/dist/esm/ez-view-stack.entry.js +2 -2
- package/dist/esm/ezui.js +3 -2
- package/dist/esm/{index-c5203f95.js → index-de655f48.js} +588 -249
- package/dist/esm/loader.js +3 -2
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-06b3e801.entry.js +1 -0
- package/dist/ezui/p-07b99b94.entry.js +1 -0
- package/dist/ezui/p-0c7e81fe.entry.js +1 -0
- package/dist/ezui/p-1581fece.entry.js +1 -0
- package/dist/ezui/p-1b95836f.entry.js +1 -0
- package/dist/ezui/p-36f7ec68.entry.js +1 -0
- package/dist/ezui/p-37b4bf04.entry.js +1 -0
- package/dist/ezui/p-493e2af4.entry.js +1 -0
- package/dist/ezui/p-4bfed869.entry.js +1 -0
- package/dist/ezui/p-600f1732.entry.js +1 -0
- package/dist/ezui/p-62481744.entry.js +1 -0
- package/dist/ezui/p-6818dd0a.entry.js +1 -0
- package/dist/ezui/p-695facd0.entry.js +1 -0
- package/dist/ezui/p-7ffd12e7.js +2 -0
- package/dist/ezui/p-82db6de7.entry.js +1 -0
- package/dist/ezui/p-86d29565.entry.js +1 -0
- package/dist/ezui/p-8ca4750d.entry.js +1 -0
- package/dist/ezui/p-9613fae6.entry.js +1 -0
- package/dist/ezui/{p-fc97f773.entry.js → p-a323b415.entry.js} +1 -1
- package/dist/ezui/p-a4b281ca.entry.js +1 -0
- package/dist/ezui/p-a67e056f.entry.js +1 -0
- package/dist/ezui/p-a8c7355e.entry.js +1 -0
- package/dist/ezui/p-ada6e6b0.entry.js +1 -0
- package/dist/ezui/p-b1e4ccf4.entry.js +1 -0
- package/dist/ezui/p-b3c7b243.entry.js +1 -0
- package/dist/ezui/p-b405d9b6.entry.js +304 -0
- package/dist/ezui/p-b941aeee.entry.js +1 -0
- package/dist/ezui/p-c0184982.entry.js +1 -0
- package/dist/ezui/p-c1300e84.entry.js +1 -0
- package/dist/ezui/p-c98e571a.entry.js +1 -0
- package/dist/ezui/p-cc40fcb3.entry.js +1 -0
- package/dist/ezui/p-cc5cfcb7.entry.js +1 -0
- package/dist/ezui/p-d6dd32b2.entry.js +1 -0
- package/dist/ezui/p-db131605.entry.js +1 -0
- package/dist/ezui/{p-ba03ac61.entry.js → p-e0d756d9.entry.js} +1 -1
- package/dist/ezui/p-eceb9382.entry.js +1 -0
- package/dist/ezui/p-f18d39e6.entry.js +1 -0
- package/dist/ezui/p-f670bd32.entry.js +1 -0
- package/dist/ezui/p-fcf6cf57.entry.js +1 -0
- package/dist/ezui/p-fd87638e.entry.js +1 -0
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +5 -1
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
- package/dist/types/components.d.ts +195 -63
- package/dist/types/stencil-public-runtime.d.ts +79 -7
- package/loader/index.d.ts +9 -0
- package/loader/package.json +1 -0
- package/package.json +4 -4
- package/react/components.d.ts +0 -1
- package/dist/ezui/p-0cd0545d.entry.js +0 -1
- package/dist/ezui/p-1a27bb9f.entry.js +0 -1
- package/dist/ezui/p-1b94b9dc.entry.js +0 -1
- package/dist/ezui/p-20c01161.entry.js +0 -1
- package/dist/ezui/p-24717f87.entry.js +0 -1
- package/dist/ezui/p-3320768e.entry.js +0 -1
- package/dist/ezui/p-368037b9.entry.js +0 -1
- package/dist/ezui/p-47bcc678.entry.js +0 -1
- package/dist/ezui/p-47ca5e09.entry.js +0 -1
- package/dist/ezui/p-4c444816.entry.js +0 -1
- package/dist/ezui/p-608d13e8.entry.js +0 -1
- package/dist/ezui/p-626b8940.entry.js +0 -1
- package/dist/ezui/p-6414e7cb.entry.js +0 -1
- package/dist/ezui/p-6630eca2.entry.js +0 -1
- package/dist/ezui/p-67b9a2cb.entry.js +0 -1
- package/dist/ezui/p-6f9aba86.entry.js +0 -1
- package/dist/ezui/p-7b80df03.js +0 -1
- package/dist/ezui/p-7d42065a.entry.js +0 -1
- package/dist/ezui/p-97d2d2f6.entry.js +0 -1
- package/dist/ezui/p-99aea44b.entry.js +0 -1
- package/dist/ezui/p-a4b4645d.entry.js +0 -1
- package/dist/ezui/p-ab5eee38.entry.js +0 -1
- package/dist/ezui/p-ad7151e0.entry.js +0 -1
- package/dist/ezui/p-ad8b7412.entry.js +0 -1
- package/dist/ezui/p-ae168e45.entry.js +0 -1
- package/dist/ezui/p-b2e861cb.entry.js +0 -1
- package/dist/ezui/p-b2efb22c.entry.js +0 -1
- package/dist/ezui/p-b5557d33.entry.js +0 -1
- package/dist/ezui/p-bc324ee8.entry.js +0 -304
- package/dist/ezui/p-bd9792e2.entry.js +0 -1
- package/dist/ezui/p-bf8a633d.entry.js +0 -1
- package/dist/ezui/p-c071db26.entry.js +0 -1
- package/dist/ezui/p-c3529df3.entry.js +0 -1
- package/dist/ezui/p-c53b2db8.entry.js +0 -1
- package/dist/ezui/p-ca7435a6.entry.js +0 -1
- package/dist/ezui/p-cc038b32.entry.js +0 -1
- package/dist/ezui/p-e203c89f.entry.js +0 -1
- package/dist/ezui/p-f08de60b.entry.js +0 -1
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
const NAMESPACE = 'ezui';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
5
|
+
* Simon Friis Vindum (@paldepind)
|
|
6
|
+
* Licensed under the MIT License
|
|
7
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
8
|
+
*
|
|
9
|
+
* Modified for Stencil's renderer and slot projection
|
|
10
|
+
*/
|
|
3
11
|
let scopeId;
|
|
4
12
|
let contentRef;
|
|
5
13
|
let hostTagName;
|
|
@@ -8,58 +16,6 @@ let checkSlotFallbackVisibility = false;
|
|
|
8
16
|
let checkSlotRelocate = false;
|
|
9
17
|
let isSvgMode = false;
|
|
10
18
|
let queuePending = false;
|
|
11
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
12
|
-
const doc = win.document || { head: {} };
|
|
13
|
-
const plt = {
|
|
14
|
-
$flags$: 0,
|
|
15
|
-
$resourcesUrl$: '',
|
|
16
|
-
jmp: (h) => h(),
|
|
17
|
-
raf: (h) => requestAnimationFrame(h),
|
|
18
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
19
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
20
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
21
|
-
};
|
|
22
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
23
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
24
|
-
try {
|
|
25
|
-
new CSSStyleSheet();
|
|
26
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
27
|
-
}
|
|
28
|
-
catch (e) { }
|
|
29
|
-
return false;
|
|
30
|
-
})()
|
|
31
|
-
;
|
|
32
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
33
|
-
if (listeners) {
|
|
34
|
-
listeners.map(([flags, name, method]) => {
|
|
35
|
-
const target = elm;
|
|
36
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
37
|
-
const opts = hostListenerOpts(flags);
|
|
38
|
-
plt.ael(target, name, handler, opts);
|
|
39
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
44
|
-
try {
|
|
45
|
-
{
|
|
46
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
47
|
-
// instance is ready, let's call it's member method for this event
|
|
48
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
consoleError(e);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
// prettier-ignore
|
|
60
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
61
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
62
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
63
19
|
const createTime = (fnName, tagName = '') => {
|
|
64
20
|
{
|
|
65
21
|
return () => {
|
|
@@ -74,74 +30,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
74
30
|
};
|
|
75
31
|
}
|
|
76
32
|
};
|
|
77
|
-
const
|
|
78
|
-
const
|
|
79
|
-
let style = styles.get(scopeId);
|
|
80
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
81
|
-
style = (style || new CSSStyleSheet());
|
|
82
|
-
style.replace(cssText);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
style = cssText;
|
|
86
|
-
}
|
|
87
|
-
styles.set(scopeId, style);
|
|
88
|
-
};
|
|
89
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
90
|
-
let scopeId = getScopeId(cmpMeta);
|
|
91
|
-
let style = styles.get(scopeId);
|
|
92
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
93
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
94
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
95
|
-
if (style) {
|
|
96
|
-
if (typeof style === 'string') {
|
|
97
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
98
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
99
|
-
let styleElm;
|
|
100
|
-
if (!appliedStyles) {
|
|
101
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
102
|
-
}
|
|
103
|
-
if (!appliedStyles.has(scopeId)) {
|
|
104
|
-
{
|
|
105
|
-
{
|
|
106
|
-
styleElm = doc.createElement('style');
|
|
107
|
-
styleElm.innerHTML = style;
|
|
108
|
-
}
|
|
109
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
110
|
-
}
|
|
111
|
-
if (appliedStyles) {
|
|
112
|
-
appliedStyles.add(scopeId);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
117
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
return scopeId;
|
|
121
|
-
};
|
|
122
|
-
const attachStyles = (hostRef) => {
|
|
123
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
124
|
-
const elm = hostRef.$hostElement$;
|
|
125
|
-
const flags = cmpMeta.$flags$;
|
|
126
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
127
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
128
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
129
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
130
|
-
// or this browser doesn't support native shadow dom
|
|
131
|
-
// and this host element was NOT created with SSR
|
|
132
|
-
// let's pick out the inner content for slot projection
|
|
133
|
-
// create a node to represent where the original
|
|
134
|
-
// content was first placed, which is useful later on
|
|
135
|
-
// DOM WRITE!!
|
|
136
|
-
elm['s-sc'] = scopeId;
|
|
137
|
-
elm.classList.add(scopeId + '-h');
|
|
138
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
139
|
-
elm.classList.add(scopeId + '-s');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
endAttachStyles();
|
|
143
|
-
};
|
|
144
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
33
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
34
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
145
35
|
/**
|
|
146
36
|
* Default style mode id
|
|
147
37
|
*/
|
|
@@ -161,6 +51,18 @@ const isComplexType = (o) => {
|
|
|
161
51
|
o = typeof o;
|
|
162
52
|
return o === 'object' || o === 'function';
|
|
163
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
56
|
+
* out of a DOM's head.
|
|
57
|
+
*
|
|
58
|
+
* @param doc The DOM containing the `head` to query against
|
|
59
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
60
|
+
* exists or the tag has no content.
|
|
61
|
+
*/
|
|
62
|
+
function queryNonceMetaTagContent(doc) {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
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;
|
|
65
|
+
}
|
|
164
66
|
/**
|
|
165
67
|
* Production h() function based on Preact by
|
|
166
68
|
* Jason Miller (@developit)
|
|
@@ -169,7 +71,6 @@ const isComplexType = (o) => {
|
|
|
169
71
|
*
|
|
170
72
|
* Modified for Stencil's compiler and vdom
|
|
171
73
|
*/
|
|
172
|
-
// const stack: any[] = [];
|
|
173
74
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
174
75
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
175
76
|
const h = (nodeName, vnodeData, ...children) => {
|
|
@@ -178,7 +79,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
178
79
|
let slotName = null;
|
|
179
80
|
let simple = false;
|
|
180
81
|
let lastSimple = false;
|
|
181
|
-
|
|
82
|
+
const vNodeChildren = [];
|
|
182
83
|
const walk = (c) => {
|
|
183
84
|
for (let i = 0; i < c.length; i++) {
|
|
184
85
|
child = c[i];
|
|
@@ -239,6 +140,14 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
239
140
|
}
|
|
240
141
|
return vnode;
|
|
241
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
145
|
+
* possible text content.
|
|
146
|
+
*
|
|
147
|
+
* @param tag the tag for this element
|
|
148
|
+
* @param text possible text content for the node
|
|
149
|
+
* @returns a newly-minted virtual DOM node
|
|
150
|
+
*/
|
|
242
151
|
const newVNode = (tag, text) => {
|
|
243
152
|
const vnode = {
|
|
244
153
|
$flags$: 0,
|
|
@@ -259,11 +168,31 @@ const newVNode = (tag, text) => {
|
|
|
259
168
|
return vnode;
|
|
260
169
|
};
|
|
261
170
|
const Host = {};
|
|
171
|
+
/**
|
|
172
|
+
* Check whether a given node is a Host node or not
|
|
173
|
+
*
|
|
174
|
+
* @param node the virtual DOM node to check
|
|
175
|
+
* @returns whether it's a Host node or not
|
|
176
|
+
*/
|
|
262
177
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
178
|
+
/**
|
|
179
|
+
* Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
|
|
180
|
+
*
|
|
181
|
+
* Note that these functions convert from {@link d.VNode} to
|
|
182
|
+
* {@link d.ChildNode} to give functional component developers a friendly
|
|
183
|
+
* interface.
|
|
184
|
+
*/
|
|
263
185
|
const vdomFnUtils = {
|
|
264
186
|
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
265
187
|
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
266
188
|
};
|
|
189
|
+
/**
|
|
190
|
+
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
191
|
+
* friendlier public interface (hence, 'convertToPublic').
|
|
192
|
+
*
|
|
193
|
+
* @param node the virtual DOM node to convert
|
|
194
|
+
* @returns a converted child node
|
|
195
|
+
*/
|
|
267
196
|
const convertToPublic = (node) => ({
|
|
268
197
|
vattrs: node.$attrs$,
|
|
269
198
|
vchildren: node.$children$,
|
|
@@ -272,6 +201,15 @@ const convertToPublic = (node) => ({
|
|
|
272
201
|
vtag: node.$tag$,
|
|
273
202
|
vtext: node.$text$,
|
|
274
203
|
});
|
|
204
|
+
/**
|
|
205
|
+
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
206
|
+
* order to use the resulting object in the virtual DOM. The initial object was
|
|
207
|
+
* likely created as part of presenting a public API, so converting it back
|
|
208
|
+
* involved making it 'private' again (hence, `convertToPrivate`).
|
|
209
|
+
*
|
|
210
|
+
* @param node the child node to convert
|
|
211
|
+
* @returns a converted virtual DOM node
|
|
212
|
+
*/
|
|
275
213
|
const convertToPrivate = (node) => {
|
|
276
214
|
if (typeof node.vtag === 'function') {
|
|
277
215
|
const vnodeData = Object.assign({}, node.vattrs);
|
|
@@ -290,6 +228,158 @@ const convertToPrivate = (node) => {
|
|
|
290
228
|
vnode.$name$ = node.vname;
|
|
291
229
|
return vnode;
|
|
292
230
|
};
|
|
231
|
+
/**
|
|
232
|
+
* Parse a new property value for a given property type.
|
|
233
|
+
*
|
|
234
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
235
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
236
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
237
|
+
* 2. the type stored from `propType`.
|
|
238
|
+
*
|
|
239
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
240
|
+
*
|
|
241
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
242
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
243
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
244
|
+
* ```tsx
|
|
245
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
246
|
+
* ```
|
|
247
|
+
*
|
|
248
|
+
* HTML prop values on the other hand, will always a string
|
|
249
|
+
*
|
|
250
|
+
* @param propValue the new value to coerce to some type
|
|
251
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
252
|
+
* @returns the parsed/coerced value
|
|
253
|
+
*/
|
|
254
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
255
|
+
// ensure this value is of the correct prop type
|
|
256
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
257
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
258
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
259
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
260
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
261
|
+
}
|
|
262
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
263
|
+
// force it to be a number
|
|
264
|
+
return parseFloat(propValue);
|
|
265
|
+
}
|
|
266
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
267
|
+
// could have been passed as a number or boolean
|
|
268
|
+
// but we still want it as a string
|
|
269
|
+
return String(propValue);
|
|
270
|
+
}
|
|
271
|
+
// redundant return here for better minification
|
|
272
|
+
return propValue;
|
|
273
|
+
}
|
|
274
|
+
// not sure exactly what type we want
|
|
275
|
+
// so no need to change to a different type
|
|
276
|
+
return propValue;
|
|
277
|
+
};
|
|
278
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
279
|
+
const createEvent = (ref, name, flags) => {
|
|
280
|
+
const elm = getElement(ref);
|
|
281
|
+
return {
|
|
282
|
+
emit: (detail) => {
|
|
283
|
+
return emitEvent(elm, name, {
|
|
284
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
285
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
286
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
287
|
+
detail,
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
294
|
+
* @param elm the target of the Event
|
|
295
|
+
* @param name the name to give the custom Event
|
|
296
|
+
* @param opts options for configuring a custom Event
|
|
297
|
+
* @returns the custom Event
|
|
298
|
+
*/
|
|
299
|
+
const emitEvent = (elm, name, opts) => {
|
|
300
|
+
const ev = plt.ce(name, opts);
|
|
301
|
+
elm.dispatchEvent(ev);
|
|
302
|
+
return ev;
|
|
303
|
+
};
|
|
304
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
305
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
306
|
+
let style = styles.get(scopeId);
|
|
307
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
308
|
+
style = (style || new CSSStyleSheet());
|
|
309
|
+
if (typeof style === 'string') {
|
|
310
|
+
style = cssText;
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
style.replaceSync(cssText);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
style = cssText;
|
|
318
|
+
}
|
|
319
|
+
styles.set(scopeId, style);
|
|
320
|
+
};
|
|
321
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
322
|
+
var _a;
|
|
323
|
+
let scopeId = getScopeId(cmpMeta);
|
|
324
|
+
const style = styles.get(scopeId);
|
|
325
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
326
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
327
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
328
|
+
if (style) {
|
|
329
|
+
if (typeof style === 'string') {
|
|
330
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
331
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
332
|
+
let styleElm;
|
|
333
|
+
if (!appliedStyles) {
|
|
334
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
335
|
+
}
|
|
336
|
+
if (!appliedStyles.has(scopeId)) {
|
|
337
|
+
{
|
|
338
|
+
{
|
|
339
|
+
styleElm = doc.createElement('style');
|
|
340
|
+
styleElm.innerHTML = style;
|
|
341
|
+
}
|
|
342
|
+
// Apply CSP nonce to the style tag if it exists
|
|
343
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
344
|
+
if (nonce != null) {
|
|
345
|
+
styleElm.setAttribute('nonce', nonce);
|
|
346
|
+
}
|
|
347
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
348
|
+
}
|
|
349
|
+
if (appliedStyles) {
|
|
350
|
+
appliedStyles.add(scopeId);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
355
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return scopeId;
|
|
359
|
+
};
|
|
360
|
+
const attachStyles = (hostRef) => {
|
|
361
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
362
|
+
const elm = hostRef.$hostElement$;
|
|
363
|
+
const flags = cmpMeta.$flags$;
|
|
364
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
365
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
366
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
367
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
368
|
+
// or this browser doesn't support native shadow dom
|
|
369
|
+
// and this host element was NOT created with SSR
|
|
370
|
+
// let's pick out the inner content for slot projection
|
|
371
|
+
// create a node to represent where the original
|
|
372
|
+
// content was first placed, which is useful later on
|
|
373
|
+
// DOM WRITE!!
|
|
374
|
+
elm['s-sc'] = scopeId;
|
|
375
|
+
elm.classList.add(scopeId + '-h');
|
|
376
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
377
|
+
elm.classList.add(scopeId + '-s');
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
endAttachStyles();
|
|
381
|
+
};
|
|
382
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
293
383
|
/**
|
|
294
384
|
* Production setAccessor() function based on Preact by
|
|
295
385
|
* Jason Miller (@developit)
|
|
@@ -387,7 +477,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
387
477
|
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
388
478
|
try {
|
|
389
479
|
if (!elm.tagName.includes('-')) {
|
|
390
|
-
|
|
480
|
+
const n = newValue == null ? '' : newValue;
|
|
391
481
|
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
392
482
|
if (memberName === 'list') {
|
|
393
483
|
isProp = false;
|
|
@@ -426,7 +516,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
426
516
|
}
|
|
427
517
|
}
|
|
428
518
|
}
|
|
429
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
519
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
430
520
|
newValue = newValue === true ? '' : newValue;
|
|
431
521
|
if (xlink) {
|
|
432
522
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -444,7 +534,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
444
534
|
// if the element passed in is a shadow root, which is a document fragment
|
|
445
535
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
446
536
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
447
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
537
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
448
538
|
? newVnode.$elm$.host
|
|
449
539
|
: newVnode.$elm$;
|
|
450
540
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -462,9 +552,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
462
552
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
463
553
|
}
|
|
464
554
|
};
|
|
555
|
+
/**
|
|
556
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
557
|
+
*
|
|
558
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
559
|
+
* @param newParentVNode the parent VNode from the current render
|
|
560
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
561
|
+
* children, for which we will create a new DOM node
|
|
562
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
563
|
+
* @returns the newly created node
|
|
564
|
+
*/
|
|
465
565
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
466
566
|
// tslint:disable-next-line: prefer-const
|
|
467
|
-
|
|
567
|
+
const newVNode = newParentVNode.$children$[childIndex];
|
|
468
568
|
let i = 0;
|
|
469
569
|
let elm;
|
|
470
570
|
let childNode;
|
|
@@ -479,16 +579,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
479
579
|
}
|
|
480
580
|
newVNode.$flags$ |= newVNode.$children$
|
|
481
581
|
? // slot element has fallback content
|
|
482
|
-
2 /* isSlotFallback */
|
|
582
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
483
583
|
: // slot element does not have fallback content
|
|
484
|
-
1 /* isSlotReference */;
|
|
584
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
485
585
|
}
|
|
486
586
|
}
|
|
487
587
|
if (newVNode.$text$ !== null) {
|
|
488
588
|
// create text node
|
|
489
589
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
490
590
|
}
|
|
491
|
-
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
591
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
492
592
|
// create a slot reference node
|
|
493
593
|
elm = newVNode.$elm$ =
|
|
494
594
|
doc.createTextNode('');
|
|
@@ -498,7 +598,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
498
598
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
499
599
|
}
|
|
500
600
|
// create element
|
|
501
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
|
|
601
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
502
602
|
? 'slot-fb'
|
|
503
603
|
: newVNode.$tag$)
|
|
504
604
|
);
|
|
@@ -538,7 +638,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
538
638
|
}
|
|
539
639
|
{
|
|
540
640
|
elm['s-hn'] = hostTagName;
|
|
541
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
641
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
542
642
|
// remember the content reference comment
|
|
543
643
|
elm['s-sr'] = true;
|
|
544
644
|
// remember the content reference comment
|
|
@@ -557,7 +657,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
557
657
|
return elm;
|
|
558
658
|
};
|
|
559
659
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
560
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
660
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
561
661
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
562
662
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
563
663
|
const childNode = oldSlotChildNodes[i];
|
|
@@ -578,8 +678,23 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
578
678
|
putBackInOriginalLocation(childNode, recursive);
|
|
579
679
|
}
|
|
580
680
|
}
|
|
581
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
681
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
582
682
|
};
|
|
683
|
+
/**
|
|
684
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
685
|
+
* add them to the DOM in the appropriate place.
|
|
686
|
+
*
|
|
687
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
688
|
+
* DOM nodes
|
|
689
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
690
|
+
* inserted before (optional)
|
|
691
|
+
* @param parentVNode the parent virtual DOM node
|
|
692
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
693
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
694
|
+
* creating DOM nodes (inclusive)
|
|
695
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
696
|
+
* creating DOM nodes (inclusive)
|
|
697
|
+
*/
|
|
583
698
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
584
699
|
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
585
700
|
let childNode;
|
|
@@ -596,6 +711,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
596
711
|
}
|
|
597
712
|
}
|
|
598
713
|
};
|
|
714
|
+
/**
|
|
715
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
716
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
717
|
+
* should no longer be shown.
|
|
718
|
+
*
|
|
719
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
720
|
+
*
|
|
721
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
722
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
723
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
724
|
+
* @param vnode a VNode
|
|
725
|
+
* @param elm an element
|
|
726
|
+
*/
|
|
599
727
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
600
728
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
601
729
|
if ((vnode = vnodes[startIdx])) {
|
|
@@ -620,6 +748,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
620
748
|
}
|
|
621
749
|
}
|
|
622
750
|
};
|
|
751
|
+
/**
|
|
752
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
753
|
+
* traversing the two collections of children, identifying nodes that are
|
|
754
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
755
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
756
|
+
*
|
|
757
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
758
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
759
|
+
* 'windows' by storing start and end indices and references to the
|
|
760
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
761
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
762
|
+
* no children left to update by doing the following:
|
|
763
|
+
*
|
|
764
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
765
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
766
|
+
* only with a window bounded by the highlighted elements:
|
|
767
|
+
*
|
|
768
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
769
|
+
* ^^^^^^ ^^^^^^
|
|
770
|
+
*
|
|
771
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
772
|
+
* across the windows. This will basically detect elements which haven't
|
|
773
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
774
|
+
* VNode elements (represented as HTML):
|
|
775
|
+
*
|
|
776
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
777
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
778
|
+
*
|
|
779
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
780
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
781
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
782
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
783
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
784
|
+
*
|
|
785
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
786
|
+
* window corresponds to the element at the end of the other window. This is
|
|
787
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
788
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
789
|
+
* children nodes themselves have not changed but merely moved in the
|
|
790
|
+
* following example:
|
|
791
|
+
*
|
|
792
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
793
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
794
|
+
*
|
|
795
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
796
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
797
|
+
* DOM.
|
|
798
|
+
*
|
|
799
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
800
|
+
* nodes in the old children which have the same key as the first element in
|
|
801
|
+
* our window on the new children. If we find such a node we handle calling
|
|
802
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
803
|
+
* what we find.
|
|
804
|
+
*
|
|
805
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
806
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
807
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
808
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
809
|
+
* children has collapsed we still have more nodes on the new children that
|
|
810
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
811
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
812
|
+
* sure the corresponding DOM nodes are removed.
|
|
813
|
+
*
|
|
814
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
815
|
+
* @param oldCh the old children of the parent node
|
|
816
|
+
* @param newVNode the new VNode which will replace the parent
|
|
817
|
+
* @param newCh the new children of the parent node
|
|
818
|
+
*/
|
|
623
819
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
624
820
|
let oldStartIdx = 0;
|
|
625
821
|
let newStartIdx = 0;
|
|
@@ -635,7 +831,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
635
831
|
let elmToMove;
|
|
636
832
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
637
833
|
if (oldStartVnode == null) {
|
|
638
|
-
//
|
|
834
|
+
// VNode might have been moved left
|
|
639
835
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
640
836
|
}
|
|
641
837
|
else if (oldEndVnode == null) {
|
|
@@ -648,37 +844,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
648
844
|
newEndVnode = newCh[--newEndIdx];
|
|
649
845
|
}
|
|
650
846
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
847
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
848
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
849
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
850
|
+
// since things are matched up in order.
|
|
651
851
|
patch(oldStartVnode, newStartVnode);
|
|
652
852
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
653
853
|
newStartVnode = newCh[++newStartIdx];
|
|
654
854
|
}
|
|
655
855
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
856
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
857
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
858
|
+
// need to move any DOM Nodes.
|
|
656
859
|
patch(oldEndVnode, newEndVnode);
|
|
657
860
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
658
861
|
newEndVnode = newCh[--newEndIdx];
|
|
659
862
|
}
|
|
660
863
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
661
|
-
// Vnode moved right
|
|
864
|
+
// case: "Vnode moved right"
|
|
865
|
+
//
|
|
866
|
+
// We've found that the last node in our window on the new children is
|
|
867
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
868
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
869
|
+
// nodes:
|
|
870
|
+
//
|
|
871
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
872
|
+
// ^^^^^^^^^^^
|
|
873
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
874
|
+
// ^^^^^^^^^^^^^
|
|
875
|
+
//
|
|
876
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
877
|
+
// and move the DOM element for `oldStartVnode`.
|
|
662
878
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
663
879
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
664
880
|
}
|
|
665
881
|
patch(oldStartVnode, newEndVnode);
|
|
882
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
883
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
884
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
885
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
886
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
887
|
+
//
|
|
888
|
+
// <old-start-node />
|
|
889
|
+
// <some-intervening-node />
|
|
890
|
+
// <old-end-node />
|
|
891
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
892
|
+
// <next-sibling />
|
|
893
|
+
//
|
|
894
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
895
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
896
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
897
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
898
|
+
// append it to the children of the parent element.
|
|
666
899
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
667
900
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
668
901
|
newEndVnode = newCh[--newEndIdx];
|
|
669
902
|
}
|
|
670
903
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
671
|
-
// Vnode moved left
|
|
904
|
+
// case: "Vnode moved left"
|
|
905
|
+
//
|
|
906
|
+
// We've found that the first node in our window on the new children is
|
|
907
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
908
|
+
// Visually, this is the layout of these two nodes:
|
|
909
|
+
//
|
|
910
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
911
|
+
// ^^^^^^^^^^^^^
|
|
912
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
913
|
+
// ^^^^^^^^^^^
|
|
914
|
+
//
|
|
915
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
916
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
917
|
+
// children etc) but we also need to move the DOM node to which
|
|
918
|
+
// `oldEndVnode` corresponds.
|
|
672
919
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
673
920
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
674
921
|
}
|
|
675
922
|
patch(oldEndVnode, newStartVnode);
|
|
923
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
924
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
925
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
926
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
927
|
+
// future.
|
|
676
928
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
677
929
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
678
930
|
newStartVnode = newCh[++newStartIdx];
|
|
679
931
|
}
|
|
680
932
|
else {
|
|
681
|
-
//
|
|
933
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
934
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
935
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
936
|
+
// component.
|
|
937
|
+
//
|
|
938
|
+
// First we check to see if there are any nodes in the array of old
|
|
939
|
+
// children which have the same key as the first node in the new
|
|
940
|
+
// children.
|
|
682
941
|
idxInOld = -1;
|
|
683
942
|
{
|
|
684
943
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -689,23 +948,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
689
948
|
}
|
|
690
949
|
}
|
|
691
950
|
if (idxInOld >= 0) {
|
|
951
|
+
// We found a node in the old children which matches up with the first
|
|
952
|
+
// node in the new children! So let's deal with that
|
|
692
953
|
elmToMove = oldCh[idxInOld];
|
|
693
954
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
955
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
694
956
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
695
957
|
}
|
|
696
958
|
else {
|
|
697
959
|
patch(elmToMove, newStartVnode);
|
|
960
|
+
// invalidate the matching old node so that we won't try to update it
|
|
961
|
+
// again later on
|
|
698
962
|
oldCh[idxInOld] = undefined;
|
|
699
963
|
node = elmToMove.$elm$;
|
|
700
964
|
}
|
|
701
965
|
newStartVnode = newCh[++newStartIdx];
|
|
702
966
|
}
|
|
703
967
|
else {
|
|
704
|
-
//
|
|
968
|
+
// We either didn't find an element in the old children that matches
|
|
969
|
+
// the key of the first new child OR the build is not using `key`
|
|
970
|
+
// attributes at all. In either case we need to create a new element
|
|
971
|
+
// for the new node.
|
|
705
972
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
706
973
|
newStartVnode = newCh[++newStartIdx];
|
|
707
974
|
}
|
|
708
975
|
if (node) {
|
|
976
|
+
// if we created a new node then handle inserting it to the DOM
|
|
709
977
|
{
|
|
710
978
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
711
979
|
}
|
|
@@ -713,21 +981,44 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
713
981
|
}
|
|
714
982
|
}
|
|
715
983
|
if (oldStartIdx > oldEndIdx) {
|
|
984
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
716
985
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
717
986
|
}
|
|
718
987
|
else if (newStartIdx > newEndIdx) {
|
|
988
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
989
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
990
|
+
// relevant DOM nodes)
|
|
719
991
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
720
992
|
}
|
|
721
993
|
};
|
|
722
|
-
|
|
994
|
+
/**
|
|
995
|
+
* Compare two VNodes to determine if they are the same
|
|
996
|
+
*
|
|
997
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
998
|
+
* information set on the two VNodes and can be misleading under certain
|
|
999
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
1000
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
1001
|
+
* checking that they have the same tag.
|
|
1002
|
+
*
|
|
1003
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
1004
|
+
* changing order within a `children` array or something along those lines then
|
|
1005
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
1006
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
1007
|
+
*
|
|
1008
|
+
* @param leftVNode the first VNode to check
|
|
1009
|
+
* @param rightVNode the second VNode to check
|
|
1010
|
+
* @returns whether they're equal or not
|
|
1011
|
+
*/
|
|
1012
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
723
1013
|
// compare if two vnode to see if they're "technically" the same
|
|
724
1014
|
// need to have the same element tag, and same key to be the same
|
|
725
|
-
if (
|
|
726
|
-
if (
|
|
727
|
-
return
|
|
1015
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
1016
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
1017
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
728
1018
|
}
|
|
1019
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
729
1020
|
{
|
|
730
|
-
return
|
|
1021
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
731
1022
|
}
|
|
732
1023
|
}
|
|
733
1024
|
return false;
|
|
@@ -740,6 +1031,14 @@ const referenceNode = (node) => {
|
|
|
740
1031
|
return (node && node['s-ol']) || node;
|
|
741
1032
|
};
|
|
742
1033
|
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
1034
|
+
/**
|
|
1035
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
1036
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
1037
|
+
* children of the two nodes (if any).
|
|
1038
|
+
*
|
|
1039
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
1040
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
1041
|
+
*/
|
|
743
1042
|
const patch = (oldVNode, newVNode) => {
|
|
744
1043
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
745
1044
|
const oldChildren = oldVNode.$children$;
|
|
@@ -753,7 +1052,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
753
1052
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
754
1053
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
755
1054
|
}
|
|
756
|
-
// element node
|
|
757
1055
|
{
|
|
758
1056
|
if (tag === 'slot')
|
|
759
1057
|
;
|
|
@@ -766,6 +1064,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
766
1064
|
}
|
|
767
1065
|
if (oldChildren !== null && newChildren !== null) {
|
|
768
1066
|
// looks like there's child vnodes for both the old and new vnodes
|
|
1067
|
+
// so we need to call `updateChildren` to reconcile them
|
|
769
1068
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
770
1069
|
}
|
|
771
1070
|
else if (newChildren !== null) {
|
|
@@ -797,7 +1096,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
797
1096
|
};
|
|
798
1097
|
const updateFallbackSlotVisibility = (elm) => {
|
|
799
1098
|
// tslint:disable-next-line: prefer-const
|
|
800
|
-
|
|
1099
|
+
const childNodes = elm.childNodes;
|
|
801
1100
|
let childNode;
|
|
802
1101
|
let i;
|
|
803
1102
|
let ilen;
|
|
@@ -806,7 +1105,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
806
1105
|
let nodeType;
|
|
807
1106
|
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
808
1107
|
childNode = childNodes[i];
|
|
809
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1108
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
810
1109
|
if (childNode['s-sr']) {
|
|
811
1110
|
// this is a slot fallback node
|
|
812
1111
|
// get the slot name for this slot reference node
|
|
@@ -818,7 +1117,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
818
1117
|
nodeType = childNodes[j].nodeType;
|
|
819
1118
|
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
820
1119
|
// this sibling node is from a different component OR is a named fallback slot node
|
|
821
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1120
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
822
1121
|
childNode.hidden = true;
|
|
823
1122
|
break;
|
|
824
1123
|
}
|
|
@@ -827,8 +1126,8 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
827
1126
|
// this is a default fallback slot node
|
|
828
1127
|
// any element or text node (with content)
|
|
829
1128
|
// should hide the default fallback slot node
|
|
830
|
-
if (nodeType === 1 /* ElementNode */ ||
|
|
831
|
-
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1129
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1130
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
832
1131
|
childNode.hidden = true;
|
|
833
1132
|
break;
|
|
834
1133
|
}
|
|
@@ -850,8 +1149,8 @@ const relocateSlotContent = (elm) => {
|
|
|
850
1149
|
let relocateNodeData;
|
|
851
1150
|
let j;
|
|
852
1151
|
let i = 0;
|
|
853
|
-
|
|
854
|
-
|
|
1152
|
+
const childNodes = elm.childNodes;
|
|
1153
|
+
const ilen = childNodes.length;
|
|
855
1154
|
for (; i < ilen; i++) {
|
|
856
1155
|
childNode = childNodes[i];
|
|
857
1156
|
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
@@ -906,13 +1205,13 @@ const relocateSlotContent = (elm) => {
|
|
|
906
1205
|
}
|
|
907
1206
|
}
|
|
908
1207
|
}
|
|
909
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1208
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
910
1209
|
relocateSlotContent(childNode);
|
|
911
1210
|
}
|
|
912
1211
|
}
|
|
913
1212
|
};
|
|
914
1213
|
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
915
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1214
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
916
1215
|
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
917
1216
|
return true;
|
|
918
1217
|
}
|
|
@@ -932,6 +1231,18 @@ const callNodeRefs = (vNode) => {
|
|
|
932
1231
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
933
1232
|
}
|
|
934
1233
|
};
|
|
1234
|
+
/**
|
|
1235
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
1236
|
+
*
|
|
1237
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
1238
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
1239
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
1240
|
+
* relocation, and reflecting attributes.
|
|
1241
|
+
*
|
|
1242
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
1243
|
+
* the DOM node into which it should be rendered.
|
|
1244
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
1245
|
+
*/
|
|
935
1246
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
936
1247
|
const hostElm = hostRef.$hostElement$;
|
|
937
1248
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
@@ -943,7 +1254,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
943
1254
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
944
1255
|
}
|
|
945
1256
|
rootVnode.$tag$ = null;
|
|
946
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1257
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
947
1258
|
hostRef.$vnode$ = rootVnode;
|
|
948
1259
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
949
1260
|
{
|
|
@@ -951,7 +1262,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
951
1262
|
}
|
|
952
1263
|
{
|
|
953
1264
|
contentRef = hostElm['s-cr'];
|
|
954
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
1265
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
955
1266
|
// always reset
|
|
956
1267
|
checkSlotFallbackVisibility = false;
|
|
957
1268
|
}
|
|
@@ -960,7 +1271,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
960
1271
|
{
|
|
961
1272
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
962
1273
|
// the disconnectCallback from working
|
|
963
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
1274
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
964
1275
|
if (checkSlotRelocate) {
|
|
965
1276
|
relocateSlotContent(rootVnode.$elm$);
|
|
966
1277
|
let relocateData;
|
|
@@ -1018,7 +1329,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1018
1329
|
}
|
|
1019
1330
|
else {
|
|
1020
1331
|
// this node doesn't have a slot home to go to, so let's hide it
|
|
1021
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1332
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1022
1333
|
nodeToRelocate.hidden = true;
|
|
1023
1334
|
}
|
|
1024
1335
|
}
|
|
@@ -1029,37 +1340,11 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1029
1340
|
}
|
|
1030
1341
|
// done moving nodes around
|
|
1031
1342
|
// allow the disconnect callback to work again
|
|
1032
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1343
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1033
1344
|
// always reset
|
|
1034
1345
|
relocateNodes.length = 0;
|
|
1035
1346
|
}
|
|
1036
1347
|
};
|
|
1037
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
1038
|
-
const createEvent = (ref, name, flags) => {
|
|
1039
|
-
const elm = getElement(ref);
|
|
1040
|
-
return {
|
|
1041
|
-
emit: (detail) => {
|
|
1042
|
-
return emitEvent(elm, name, {
|
|
1043
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
1044
|
-
composed: !!(flags & 2 /* Composed */),
|
|
1045
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
1046
|
-
detail,
|
|
1047
|
-
});
|
|
1048
|
-
},
|
|
1049
|
-
};
|
|
1050
|
-
};
|
|
1051
|
-
/**
|
|
1052
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
1053
|
-
* @param elm the target of the Event
|
|
1054
|
-
* @param name the name to give the custom Event
|
|
1055
|
-
* @param opts options for configuring a custom Event
|
|
1056
|
-
* @returns the custom Event
|
|
1057
|
-
*/
|
|
1058
|
-
const emitEvent = (elm, name, opts) => {
|
|
1059
|
-
const ev = plt.ce(name, opts);
|
|
1060
|
-
elm.dispatchEvent(ev);
|
|
1061
|
-
return ev;
|
|
1062
|
-
};
|
|
1063
1348
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1064
1349
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
1065
1350
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -1067,10 +1352,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
1067
1352
|
};
|
|
1068
1353
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1069
1354
|
{
|
|
1070
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1355
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1071
1356
|
}
|
|
1072
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1073
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1357
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1358
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
1074
1359
|
return;
|
|
1075
1360
|
}
|
|
1076
1361
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -1086,7 +1371,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1086
1371
|
let promise;
|
|
1087
1372
|
if (isInitialLoad) {
|
|
1088
1373
|
{
|
|
1089
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
1374
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1090
1375
|
if (hostRef.$queuedListeners$) {
|
|
1091
1376
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1092
1377
|
hostRef.$queuedListeners$ = null;
|
|
@@ -1132,7 +1417,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1132
1417
|
}
|
|
1133
1418
|
else {
|
|
1134
1419
|
Promise.all(childrenPromises).then(postUpdate);
|
|
1135
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1420
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
1136
1421
|
childrenPromises.length = 0;
|
|
1137
1422
|
}
|
|
1138
1423
|
}
|
|
@@ -1141,10 +1426,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1141
1426
|
try {
|
|
1142
1427
|
instance = instance.render() ;
|
|
1143
1428
|
{
|
|
1144
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1429
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1145
1430
|
}
|
|
1146
1431
|
{
|
|
1147
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1432
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1148
1433
|
}
|
|
1149
1434
|
{
|
|
1150
1435
|
{
|
|
@@ -1171,8 +1456,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1171
1456
|
{
|
|
1172
1457
|
safeCall(instance, 'componentDidRender');
|
|
1173
1458
|
}
|
|
1174
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1175
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1459
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1460
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1176
1461
|
{
|
|
1177
1462
|
// DOM WRITE!
|
|
1178
1463
|
addHydratedFlag(elm);
|
|
@@ -1204,10 +1489,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1204
1489
|
hostRef.$onRenderResolve$();
|
|
1205
1490
|
hostRef.$onRenderResolve$ = undefined;
|
|
1206
1491
|
}
|
|
1207
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1492
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1208
1493
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1209
1494
|
}
|
|
1210
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1495
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
1211
1496
|
}
|
|
1212
1497
|
// ( •_•)
|
|
1213
1498
|
// ( •_•)>⌐■-■
|
|
@@ -1218,7 +1503,7 @@ const forceUpdate = (ref) => {
|
|
|
1218
1503
|
const hostRef = getHostRef(ref);
|
|
1219
1504
|
const isConnected = hostRef.$hostElement$.isConnected;
|
|
1220
1505
|
if (isConnected &&
|
|
1221
|
-
(hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1506
|
+
(hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1222
1507
|
scheduleUpdate(hostRef, false);
|
|
1223
1508
|
}
|
|
1224
1509
|
// Returns "true" when the forced update was successfully scheduled
|
|
@@ -1249,30 +1534,6 @@ const then = (promise, thenFn) => {
|
|
|
1249
1534
|
};
|
|
1250
1535
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
1251
1536
|
;
|
|
1252
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
1253
|
-
// ensure this value is of the correct prop type
|
|
1254
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
1255
|
-
if (propType & 4 /* Boolean */) {
|
|
1256
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
1257
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1258
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1259
|
-
}
|
|
1260
|
-
if (propType & 2 /* Number */) {
|
|
1261
|
-
// force it to be a number
|
|
1262
|
-
return parseFloat(propValue);
|
|
1263
|
-
}
|
|
1264
|
-
if (propType & 1 /* String */) {
|
|
1265
|
-
// could have been passed as a number or boolean
|
|
1266
|
-
// but we still want it as a string
|
|
1267
|
-
return String(propValue);
|
|
1268
|
-
}
|
|
1269
|
-
// redundant return here for better minification
|
|
1270
|
-
return propValue;
|
|
1271
|
-
}
|
|
1272
|
-
// not sure exactly what type we want
|
|
1273
|
-
// so no need to change to a different type
|
|
1274
|
-
return propValue;
|
|
1275
|
-
};
|
|
1276
1537
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1277
1538
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1278
1539
|
// check our new property value against our internal value
|
|
@@ -1282,13 +1543,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1282
1543
|
const flags = hostRef.$flags$;
|
|
1283
1544
|
const instance = hostRef.$lazyInstance$ ;
|
|
1284
1545
|
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
1285
|
-
|
|
1546
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1547
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1548
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1549
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1286
1550
|
// gadzooks! the property's value has changed!!
|
|
1287
1551
|
// set our new value!
|
|
1288
1552
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1289
1553
|
if (instance) {
|
|
1290
1554
|
// get an array of method names of watch functions to call
|
|
1291
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1555
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1292
1556
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1293
1557
|
if (watchMethods) {
|
|
1294
1558
|
// this instance is watching for when this property changed
|
|
@@ -1303,7 +1567,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1303
1567
|
});
|
|
1304
1568
|
}
|
|
1305
1569
|
}
|
|
1306
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1570
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1307
1571
|
// looks like this value actually changed, so we've got work to do!
|
|
1308
1572
|
// but only if we've already rendered, otherwise just chill out
|
|
1309
1573
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1313,6 +1577,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1313
1577
|
}
|
|
1314
1578
|
}
|
|
1315
1579
|
};
|
|
1580
|
+
/**
|
|
1581
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1582
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1583
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1584
|
+
*
|
|
1585
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1586
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1587
|
+
* @param flags a number used to store a series of bit flags
|
|
1588
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1589
|
+
*/
|
|
1316
1590
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1317
1591
|
if (cmpMeta.$members$) {
|
|
1318
1592
|
if (Cstr.watchers) {
|
|
@@ -1322,8 +1596,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1322
1596
|
const members = Object.entries(cmpMeta.$members$);
|
|
1323
1597
|
const prototype = Cstr.prototype;
|
|
1324
1598
|
members.map(([memberName, [memberFlags]]) => {
|
|
1325
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1326
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1599
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1600
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1327
1601
|
// proxyComponent - prop
|
|
1328
1602
|
Object.defineProperty(prototype, memberName, {
|
|
1329
1603
|
get() {
|
|
@@ -1338,8 +1612,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1338
1612
|
enumerable: true,
|
|
1339
1613
|
});
|
|
1340
1614
|
}
|
|
1341
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1342
|
-
memberFlags & 64 /* Method */) {
|
|
1615
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1616
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1343
1617
|
// proxyComponent - method
|
|
1344
1618
|
Object.defineProperty(prototype, memberName, {
|
|
1345
1619
|
value(...args) {
|
|
@@ -1349,7 +1623,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1349
1623
|
});
|
|
1350
1624
|
}
|
|
1351
1625
|
});
|
|
1352
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1626
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1353
1627
|
const attrNameToPropName = new Map();
|
|
1354
1628
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1355
1629
|
plt.jmp(() => {
|
|
@@ -1405,11 +1679,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1405
1679
|
// create an array of attributes to observe
|
|
1406
1680
|
// and also create a map of html attribute name to js property name
|
|
1407
1681
|
Cstr.observedAttributes = members
|
|
1408
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1682
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1409
1683
|
.map(([propName, m]) => {
|
|
1410
1684
|
const attrName = m[1] || propName;
|
|
1411
1685
|
attrNameToPropName.set(attrName, propName);
|
|
1412
|
-
if (m[0] & 512 /* ReflectAttr */) {
|
|
1686
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1413
1687
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1414
1688
|
}
|
|
1415
1689
|
return attrName;
|
|
@@ -1420,10 +1694,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1420
1694
|
};
|
|
1421
1695
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1422
1696
|
// initializeComponent
|
|
1423
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1697
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1424
1698
|
{
|
|
1425
1699
|
// we haven't initialized this element yet
|
|
1426
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1700
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1427
1701
|
// lazy loaded components
|
|
1428
1702
|
// request the component's implementation to be
|
|
1429
1703
|
// wired up with the host element
|
|
@@ -1441,7 +1715,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1441
1715
|
{
|
|
1442
1716
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1443
1717
|
}
|
|
1444
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1718
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1445
1719
|
Cstr.isProxied = true;
|
|
1446
1720
|
}
|
|
1447
1721
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1449,7 +1723,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1449
1723
|
// but let's keep track of when we start and stop
|
|
1450
1724
|
// so that the getters/setters don't incorrectly step on data
|
|
1451
1725
|
{
|
|
1452
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1726
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1453
1727
|
}
|
|
1454
1728
|
// construct the lazy-loaded component implementation
|
|
1455
1729
|
// passing the hostRef is very important during
|
|
@@ -1462,10 +1736,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1462
1736
|
consoleError(e);
|
|
1463
1737
|
}
|
|
1464
1738
|
{
|
|
1465
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1739
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1466
1740
|
}
|
|
1467
1741
|
{
|
|
1468
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1742
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1469
1743
|
}
|
|
1470
1744
|
endNewInstance();
|
|
1471
1745
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -1476,7 +1750,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1476
1750
|
const scopeId = getScopeId(cmpMeta);
|
|
1477
1751
|
if (!styles.has(scopeId)) {
|
|
1478
1752
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1479
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1753
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1480
1754
|
endRegisterStyles();
|
|
1481
1755
|
}
|
|
1482
1756
|
}
|
|
@@ -1503,19 +1777,19 @@ const fireConnectedCallback = (instance) => {
|
|
|
1503
1777
|
}
|
|
1504
1778
|
};
|
|
1505
1779
|
const connectedCallback = (elm) => {
|
|
1506
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1780
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1507
1781
|
const hostRef = getHostRef(elm);
|
|
1508
1782
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1509
1783
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1510
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1784
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1511
1785
|
// first time this component has connected
|
|
1512
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1786
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1513
1787
|
{
|
|
1514
1788
|
// initUpdate
|
|
1515
1789
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1516
1790
|
// in here to act as original content anchors as we move nodes around
|
|
1517
1791
|
// host element has been connected to the DOM
|
|
1518
|
-
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1792
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1519
1793
|
setContentReference(elm);
|
|
1520
1794
|
}
|
|
1521
1795
|
}
|
|
@@ -1538,7 +1812,7 @@ const connectedCallback = (elm) => {
|
|
|
1538
1812
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1539
1813
|
if (cmpMeta.$members$) {
|
|
1540
1814
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1541
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1815
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1542
1816
|
const value = elm[memberName];
|
|
1543
1817
|
delete elm[memberName];
|
|
1544
1818
|
elm[memberName] = value;
|
|
@@ -1572,7 +1846,7 @@ const setContentReference = (elm) => {
|
|
|
1572
1846
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1573
1847
|
};
|
|
1574
1848
|
const disconnectedCallback = (elm) => {
|
|
1575
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1849
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1576
1850
|
const hostRef = getHostRef(elm);
|
|
1577
1851
|
const instance = hostRef.$lazyInstance$ ;
|
|
1578
1852
|
{
|
|
@@ -1587,6 +1861,7 @@ const disconnectedCallback = (elm) => {
|
|
|
1587
1861
|
}
|
|
1588
1862
|
};
|
|
1589
1863
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1864
|
+
var _a;
|
|
1590
1865
|
const endBootstrap = createTime();
|
|
1591
1866
|
const cmpTags = [];
|
|
1592
1867
|
const exclude = options.exclude || [];
|
|
@@ -1627,7 +1902,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1627
1902
|
super(self);
|
|
1628
1903
|
self = this;
|
|
1629
1904
|
registerHost(self, cmpMeta);
|
|
1630
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1905
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1631
1906
|
// this component is using shadow dom
|
|
1632
1907
|
// and this browser supports shadow dom
|
|
1633
1908
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1662,13 +1937,18 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1662
1937
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1663
1938
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1664
1939
|
cmpTags.push(tagName);
|
|
1665
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1940
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1666
1941
|
}
|
|
1667
1942
|
});
|
|
1668
1943
|
});
|
|
1669
1944
|
{
|
|
1670
1945
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1671
1946
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1947
|
+
// Apply CSP nonce to the style tag if it exists
|
|
1948
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1949
|
+
if (nonce != null) {
|
|
1950
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
1951
|
+
}
|
|
1672
1952
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1673
1953
|
}
|
|
1674
1954
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1684,7 +1964,43 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1684
1964
|
// Fallback appLoad event
|
|
1685
1965
|
endBootstrap();
|
|
1686
1966
|
};
|
|
1687
|
-
const
|
|
1967
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1968
|
+
if (listeners) {
|
|
1969
|
+
listeners.map(([flags, name, method]) => {
|
|
1970
|
+
const target = elm;
|
|
1971
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1972
|
+
const opts = hostListenerOpts(flags);
|
|
1973
|
+
plt.ael(target, name, handler, opts);
|
|
1974
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1979
|
+
try {
|
|
1980
|
+
{
|
|
1981
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1982
|
+
// instance is ready, let's call it's member method for this event
|
|
1983
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1984
|
+
}
|
|
1985
|
+
else {
|
|
1986
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
catch (e) {
|
|
1991
|
+
consoleError(e);
|
|
1992
|
+
}
|
|
1993
|
+
};
|
|
1994
|
+
// prettier-ignore
|
|
1995
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1996
|
+
/**
|
|
1997
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1998
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
1999
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
2000
|
+
* @returns void
|
|
2001
|
+
*/
|
|
2002
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
2003
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1688
2004
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1689
2005
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1690
2006
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1716,7 +2032,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1716
2032
|
if (module) {
|
|
1717
2033
|
return module[exportName];
|
|
1718
2034
|
}
|
|
2035
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
1719
2036
|
return import(
|
|
2037
|
+
/* @vite-ignore */
|
|
1720
2038
|
/* webpackInclude: /\.entry\.js$/ */
|
|
1721
2039
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1722
2040
|
/* webpackMode: "lazy" */
|
|
@@ -1727,14 +2045,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1727
2045
|
return importedModule[exportName];
|
|
1728
2046
|
}, consoleError);
|
|
1729
2047
|
};
|
|
1730
|
-
const styles = new Map();
|
|
2048
|
+
const styles = /*@__PURE__*/ new Map();
|
|
2049
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
2050
|
+
const doc = win.document || { head: {} };
|
|
2051
|
+
const plt = {
|
|
2052
|
+
$flags$: 0,
|
|
2053
|
+
$resourcesUrl$: '',
|
|
2054
|
+
jmp: (h) => h(),
|
|
2055
|
+
raf: (h) => requestAnimationFrame(h),
|
|
2056
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
2057
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
2058
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
2059
|
+
};
|
|
2060
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
2061
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
2062
|
+
try {
|
|
2063
|
+
new CSSStyleSheet();
|
|
2064
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
2065
|
+
}
|
|
2066
|
+
catch (e) { }
|
|
2067
|
+
return false;
|
|
2068
|
+
})()
|
|
2069
|
+
;
|
|
1731
2070
|
const queueDomReads = [];
|
|
1732
2071
|
const queueDomWrites = [];
|
|
1733
2072
|
const queueTask = (queue, write) => (cb) => {
|
|
1734
2073
|
queue.push(cb);
|
|
1735
2074
|
if (!queuePending) {
|
|
1736
2075
|
queuePending = true;
|
|
1737
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
2076
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1738
2077
|
nextTick(flush);
|
|
1739
2078
|
}
|
|
1740
2079
|
else {
|
|
@@ -1771,4 +2110,4 @@ const flush = () => {
|
|
|
1771
2110
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1772
2111
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1773
2112
|
|
|
1774
|
-
export { Host as H, bootstrapLazy as b, createEvent as c, forceUpdate as f, getElement as g, h, promiseResolve as p, registerInstance as r };
|
|
2113
|
+
export { Host as H, bootstrapLazy as b, createEvent as c, forceUpdate as f, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|