@sankhyalabs/ezui 3.0.1 → 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 +5 -8
- 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 +11110 -6777
- 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.js +190 -186
- 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/mock/Server.js +1 -1
- package/dist/collection/components/ez-grid/ez-grid.js +365 -351
- 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 +11097 -6940
- 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 +5 -8
- 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 +11110 -6777
- 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-df20c613.entry.js → p-06b3e801.entry.js} +1 -1
- 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.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-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-b4ccb29c.entry.js +0 -304
- package/dist/ezui/p-b5557d33.entry.js +0 -1
- 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
|
@@ -22,6 +22,14 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'ezui';
|
|
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 scopeId;
|
|
26
34
|
let contentRef;
|
|
27
35
|
let hostTagName;
|
|
@@ -30,58 +38,6 @@ let checkSlotFallbackVisibility = false;
|
|
|
30
38
|
let checkSlotRelocate = false;
|
|
31
39
|
let isSvgMode = false;
|
|
32
40
|
let queuePending = false;
|
|
33
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
34
|
-
const doc = win.document || { head: {} };
|
|
35
|
-
const plt = {
|
|
36
|
-
$flags$: 0,
|
|
37
|
-
$resourcesUrl$: '',
|
|
38
|
-
jmp: (h) => h(),
|
|
39
|
-
raf: (h) => requestAnimationFrame(h),
|
|
40
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
41
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
42
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
43
|
-
};
|
|
44
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
45
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
46
|
-
try {
|
|
47
|
-
new CSSStyleSheet();
|
|
48
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
49
|
-
}
|
|
50
|
-
catch (e) { }
|
|
51
|
-
return false;
|
|
52
|
-
})()
|
|
53
|
-
;
|
|
54
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
55
|
-
if (listeners) {
|
|
56
|
-
listeners.map(([flags, name, method]) => {
|
|
57
|
-
const target = elm;
|
|
58
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
59
|
-
const opts = hostListenerOpts(flags);
|
|
60
|
-
plt.ael(target, name, handler, opts);
|
|
61
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
66
|
-
try {
|
|
67
|
-
{
|
|
68
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
69
|
-
// instance is ready, let's call it's member method for this event
|
|
70
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
consoleError(e);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
// prettier-ignore
|
|
82
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
83
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
84
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
85
41
|
const createTime = (fnName, tagName = '') => {
|
|
86
42
|
{
|
|
87
43
|
return () => {
|
|
@@ -96,74 +52,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
96
52
|
};
|
|
97
53
|
}
|
|
98
54
|
};
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
let style = styles.get(scopeId);
|
|
102
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
103
|
-
style = (style || new CSSStyleSheet());
|
|
104
|
-
style.replace(cssText);
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
style = cssText;
|
|
108
|
-
}
|
|
109
|
-
styles.set(scopeId, style);
|
|
110
|
-
};
|
|
111
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
112
|
-
let scopeId = getScopeId(cmpMeta);
|
|
113
|
-
let style = styles.get(scopeId);
|
|
114
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
115
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
116
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
117
|
-
if (style) {
|
|
118
|
-
if (typeof style === 'string') {
|
|
119
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
120
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
121
|
-
let styleElm;
|
|
122
|
-
if (!appliedStyles) {
|
|
123
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
124
|
-
}
|
|
125
|
-
if (!appliedStyles.has(scopeId)) {
|
|
126
|
-
{
|
|
127
|
-
{
|
|
128
|
-
styleElm = doc.createElement('style');
|
|
129
|
-
styleElm.innerHTML = style;
|
|
130
|
-
}
|
|
131
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
132
|
-
}
|
|
133
|
-
if (appliedStyles) {
|
|
134
|
-
appliedStyles.add(scopeId);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
139
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
return scopeId;
|
|
143
|
-
};
|
|
144
|
-
const attachStyles = (hostRef) => {
|
|
145
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
146
|
-
const elm = hostRef.$hostElement$;
|
|
147
|
-
const flags = cmpMeta.$flags$;
|
|
148
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
149
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
150
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
151
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
152
|
-
// or this browser doesn't support native shadow dom
|
|
153
|
-
// and this host element was NOT created with SSR
|
|
154
|
-
// let's pick out the inner content for slot projection
|
|
155
|
-
// create a node to represent where the original
|
|
156
|
-
// content was first placed, which is useful later on
|
|
157
|
-
// DOM WRITE!!
|
|
158
|
-
elm['s-sc'] = scopeId;
|
|
159
|
-
elm.classList.add(scopeId + '-h');
|
|
160
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
161
|
-
elm.classList.add(scopeId + '-s');
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
endAttachStyles();
|
|
165
|
-
};
|
|
166
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
55
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
56
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
167
57
|
/**
|
|
168
58
|
* Default style mode id
|
|
169
59
|
*/
|
|
@@ -183,6 +73,18 @@ const isComplexType = (o) => {
|
|
|
183
73
|
o = typeof o;
|
|
184
74
|
return o === 'object' || o === 'function';
|
|
185
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Helper method for querying a `meta` tag that contains a nonce value
|
|
78
|
+
* out of a DOM's head.
|
|
79
|
+
*
|
|
80
|
+
* @param doc The DOM containing the `head` to query against
|
|
81
|
+
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
82
|
+
* exists or the tag has no content.
|
|
83
|
+
*/
|
|
84
|
+
function queryNonceMetaTagContent(doc) {
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
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;
|
|
87
|
+
}
|
|
186
88
|
/**
|
|
187
89
|
* Production h() function based on Preact by
|
|
188
90
|
* Jason Miller (@developit)
|
|
@@ -191,7 +93,6 @@ const isComplexType = (o) => {
|
|
|
191
93
|
*
|
|
192
94
|
* Modified for Stencil's compiler and vdom
|
|
193
95
|
*/
|
|
194
|
-
// const stack: any[] = [];
|
|
195
96
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
196
97
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
197
98
|
const h = (nodeName, vnodeData, ...children) => {
|
|
@@ -200,7 +101,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
200
101
|
let slotName = null;
|
|
201
102
|
let simple = false;
|
|
202
103
|
let lastSimple = false;
|
|
203
|
-
|
|
104
|
+
const vNodeChildren = [];
|
|
204
105
|
const walk = (c) => {
|
|
205
106
|
for (let i = 0; i < c.length; i++) {
|
|
206
107
|
child = c[i];
|
|
@@ -261,6 +162,14 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
261
162
|
}
|
|
262
163
|
return vnode;
|
|
263
164
|
};
|
|
165
|
+
/**
|
|
166
|
+
* A utility function for creating a virtual DOM node from a tag and some
|
|
167
|
+
* possible text content.
|
|
168
|
+
*
|
|
169
|
+
* @param tag the tag for this element
|
|
170
|
+
* @param text possible text content for the node
|
|
171
|
+
* @returns a newly-minted virtual DOM node
|
|
172
|
+
*/
|
|
264
173
|
const newVNode = (tag, text) => {
|
|
265
174
|
const vnode = {
|
|
266
175
|
$flags$: 0,
|
|
@@ -281,11 +190,31 @@ const newVNode = (tag, text) => {
|
|
|
281
190
|
return vnode;
|
|
282
191
|
};
|
|
283
192
|
const Host = {};
|
|
193
|
+
/**
|
|
194
|
+
* Check whether a given node is a Host node or not
|
|
195
|
+
*
|
|
196
|
+
* @param node the virtual DOM node to check
|
|
197
|
+
* @returns whether it's a Host node or not
|
|
198
|
+
*/
|
|
284
199
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
200
|
+
/**
|
|
201
|
+
* Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
|
|
202
|
+
*
|
|
203
|
+
* Note that these functions convert from {@link d.VNode} to
|
|
204
|
+
* {@link d.ChildNode} to give functional component developers a friendly
|
|
205
|
+
* interface.
|
|
206
|
+
*/
|
|
285
207
|
const vdomFnUtils = {
|
|
286
208
|
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
287
209
|
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
288
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
213
|
+
* friendlier public interface (hence, 'convertToPublic').
|
|
214
|
+
*
|
|
215
|
+
* @param node the virtual DOM node to convert
|
|
216
|
+
* @returns a converted child node
|
|
217
|
+
*/
|
|
289
218
|
const convertToPublic = (node) => ({
|
|
290
219
|
vattrs: node.$attrs$,
|
|
291
220
|
vchildren: node.$children$,
|
|
@@ -294,6 +223,15 @@ const convertToPublic = (node) => ({
|
|
|
294
223
|
vtag: node.$tag$,
|
|
295
224
|
vtext: node.$text$,
|
|
296
225
|
});
|
|
226
|
+
/**
|
|
227
|
+
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
228
|
+
* order to use the resulting object in the virtual DOM. The initial object was
|
|
229
|
+
* likely created as part of presenting a public API, so converting it back
|
|
230
|
+
* involved making it 'private' again (hence, `convertToPrivate`).
|
|
231
|
+
*
|
|
232
|
+
* @param node the child node to convert
|
|
233
|
+
* @returns a converted virtual DOM node
|
|
234
|
+
*/
|
|
297
235
|
const convertToPrivate = (node) => {
|
|
298
236
|
if (typeof node.vtag === 'function') {
|
|
299
237
|
const vnodeData = Object.assign({}, node.vattrs);
|
|
@@ -312,6 +250,158 @@ const convertToPrivate = (node) => {
|
|
|
312
250
|
vnode.$name$ = node.vname;
|
|
313
251
|
return vnode;
|
|
314
252
|
};
|
|
253
|
+
/**
|
|
254
|
+
* Parse a new property value for a given property type.
|
|
255
|
+
*
|
|
256
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
257
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
258
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
259
|
+
* 2. the type stored from `propType`.
|
|
260
|
+
*
|
|
261
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
262
|
+
*
|
|
263
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
264
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
265
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
266
|
+
* ```tsx
|
|
267
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* HTML prop values on the other hand, will always a string
|
|
271
|
+
*
|
|
272
|
+
* @param propValue the new value to coerce to some type
|
|
273
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
274
|
+
* @returns the parsed/coerced value
|
|
275
|
+
*/
|
|
276
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
277
|
+
// ensure this value is of the correct prop type
|
|
278
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
279
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
280
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
281
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
282
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
283
|
+
}
|
|
284
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
285
|
+
// force it to be a number
|
|
286
|
+
return parseFloat(propValue);
|
|
287
|
+
}
|
|
288
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
289
|
+
// could have been passed as a number or boolean
|
|
290
|
+
// but we still want it as a string
|
|
291
|
+
return String(propValue);
|
|
292
|
+
}
|
|
293
|
+
// redundant return here for better minification
|
|
294
|
+
return propValue;
|
|
295
|
+
}
|
|
296
|
+
// not sure exactly what type we want
|
|
297
|
+
// so no need to change to a different type
|
|
298
|
+
return propValue;
|
|
299
|
+
};
|
|
300
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
301
|
+
const createEvent = (ref, name, flags) => {
|
|
302
|
+
const elm = getElement(ref);
|
|
303
|
+
return {
|
|
304
|
+
emit: (detail) => {
|
|
305
|
+
return emitEvent(elm, name, {
|
|
306
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
307
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
308
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
309
|
+
detail,
|
|
310
|
+
});
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
316
|
+
* @param elm the target of the Event
|
|
317
|
+
* @param name the name to give the custom Event
|
|
318
|
+
* @param opts options for configuring a custom Event
|
|
319
|
+
* @returns the custom Event
|
|
320
|
+
*/
|
|
321
|
+
const emitEvent = (elm, name, opts) => {
|
|
322
|
+
const ev = plt.ce(name, opts);
|
|
323
|
+
elm.dispatchEvent(ev);
|
|
324
|
+
return ev;
|
|
325
|
+
};
|
|
326
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
327
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
328
|
+
let style = styles.get(scopeId);
|
|
329
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
330
|
+
style = (style || new CSSStyleSheet());
|
|
331
|
+
if (typeof style === 'string') {
|
|
332
|
+
style = cssText;
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
style.replaceSync(cssText);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
style = cssText;
|
|
340
|
+
}
|
|
341
|
+
styles.set(scopeId, style);
|
|
342
|
+
};
|
|
343
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
344
|
+
var _a;
|
|
345
|
+
let scopeId = getScopeId(cmpMeta);
|
|
346
|
+
const style = styles.get(scopeId);
|
|
347
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
348
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
349
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
350
|
+
if (style) {
|
|
351
|
+
if (typeof style === 'string') {
|
|
352
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
353
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
354
|
+
let styleElm;
|
|
355
|
+
if (!appliedStyles) {
|
|
356
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
357
|
+
}
|
|
358
|
+
if (!appliedStyles.has(scopeId)) {
|
|
359
|
+
{
|
|
360
|
+
{
|
|
361
|
+
styleElm = doc.createElement('style');
|
|
362
|
+
styleElm.innerHTML = style;
|
|
363
|
+
}
|
|
364
|
+
// Apply CSP nonce to the style tag if it exists
|
|
365
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
366
|
+
if (nonce != null) {
|
|
367
|
+
styleElm.setAttribute('nonce', nonce);
|
|
368
|
+
}
|
|
369
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
370
|
+
}
|
|
371
|
+
if (appliedStyles) {
|
|
372
|
+
appliedStyles.add(scopeId);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
377
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
return scopeId;
|
|
381
|
+
};
|
|
382
|
+
const attachStyles = (hostRef) => {
|
|
383
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
384
|
+
const elm = hostRef.$hostElement$;
|
|
385
|
+
const flags = cmpMeta.$flags$;
|
|
386
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
387
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
388
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
389
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
390
|
+
// or this browser doesn't support native shadow dom
|
|
391
|
+
// and this host element was NOT created with SSR
|
|
392
|
+
// let's pick out the inner content for slot projection
|
|
393
|
+
// create a node to represent where the original
|
|
394
|
+
// content was first placed, which is useful later on
|
|
395
|
+
// DOM WRITE!!
|
|
396
|
+
elm['s-sc'] = scopeId;
|
|
397
|
+
elm.classList.add(scopeId + '-h');
|
|
398
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
399
|
+
elm.classList.add(scopeId + '-s');
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
endAttachStyles();
|
|
403
|
+
};
|
|
404
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
315
405
|
/**
|
|
316
406
|
* Production setAccessor() function based on Preact by
|
|
317
407
|
* Jason Miller (@developit)
|
|
@@ -409,7 +499,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
409
499
|
if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
|
|
410
500
|
try {
|
|
411
501
|
if (!elm.tagName.includes('-')) {
|
|
412
|
-
|
|
502
|
+
const n = newValue == null ? '' : newValue;
|
|
413
503
|
// Workaround for Safari, moving the <input> caret when re-assigning the same valued
|
|
414
504
|
if (memberName === 'list') {
|
|
415
505
|
isProp = false;
|
|
@@ -448,7 +538,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
448
538
|
}
|
|
449
539
|
}
|
|
450
540
|
}
|
|
451
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
541
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
452
542
|
newValue = newValue === true ? '' : newValue;
|
|
453
543
|
if (xlink) {
|
|
454
544
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -466,7 +556,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
466
556
|
// if the element passed in is a shadow root, which is a document fragment
|
|
467
557
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
468
558
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
469
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
559
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
470
560
|
? newVnode.$elm$.host
|
|
471
561
|
: newVnode.$elm$;
|
|
472
562
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -484,9 +574,19 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
484
574
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
485
575
|
}
|
|
486
576
|
};
|
|
577
|
+
/**
|
|
578
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
579
|
+
*
|
|
580
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
581
|
+
* @param newParentVNode the parent VNode from the current render
|
|
582
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
583
|
+
* children, for which we will create a new DOM node
|
|
584
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
585
|
+
* @returns the newly created node
|
|
586
|
+
*/
|
|
487
587
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
488
588
|
// tslint:disable-next-line: prefer-const
|
|
489
|
-
|
|
589
|
+
const newVNode = newParentVNode.$children$[childIndex];
|
|
490
590
|
let i = 0;
|
|
491
591
|
let elm;
|
|
492
592
|
let childNode;
|
|
@@ -501,16 +601,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
501
601
|
}
|
|
502
602
|
newVNode.$flags$ |= newVNode.$children$
|
|
503
603
|
? // slot element has fallback content
|
|
504
|
-
2 /* isSlotFallback */
|
|
604
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
505
605
|
: // slot element does not have fallback content
|
|
506
|
-
1 /* isSlotReference */;
|
|
606
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
507
607
|
}
|
|
508
608
|
}
|
|
509
609
|
if (newVNode.$text$ !== null) {
|
|
510
610
|
// create text node
|
|
511
611
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
512
612
|
}
|
|
513
|
-
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
613
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
514
614
|
// create a slot reference node
|
|
515
615
|
elm = newVNode.$elm$ =
|
|
516
616
|
doc.createTextNode('');
|
|
@@ -520,7 +620,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
520
620
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
521
621
|
}
|
|
522
622
|
// create element
|
|
523
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
|
|
623
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
524
624
|
? 'slot-fb'
|
|
525
625
|
: newVNode.$tag$)
|
|
526
626
|
);
|
|
@@ -560,7 +660,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
560
660
|
}
|
|
561
661
|
{
|
|
562
662
|
elm['s-hn'] = hostTagName;
|
|
563
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
663
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
564
664
|
// remember the content reference comment
|
|
565
665
|
elm['s-sr'] = true;
|
|
566
666
|
// remember the content reference comment
|
|
@@ -579,7 +679,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
579
679
|
return elm;
|
|
580
680
|
};
|
|
581
681
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
582
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
682
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
583
683
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
584
684
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
585
685
|
const childNode = oldSlotChildNodes[i];
|
|
@@ -600,8 +700,23 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
600
700
|
putBackInOriginalLocation(childNode, recursive);
|
|
601
701
|
}
|
|
602
702
|
}
|
|
603
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
703
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
604
704
|
};
|
|
705
|
+
/**
|
|
706
|
+
* Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
|
|
707
|
+
* add them to the DOM in the appropriate place.
|
|
708
|
+
*
|
|
709
|
+
* @param parentElm the DOM node which should be used as a parent for the new
|
|
710
|
+
* DOM nodes
|
|
711
|
+
* @param before a child of the `parentElm` which the new children should be
|
|
712
|
+
* inserted before (optional)
|
|
713
|
+
* @param parentVNode the parent virtual DOM node
|
|
714
|
+
* @param vnodes the new child virtual DOM nodes to produce DOM nodes for
|
|
715
|
+
* @param startIdx the index in the child virtual DOM nodes at which to start
|
|
716
|
+
* creating DOM nodes (inclusive)
|
|
717
|
+
* @param endIdx the index in the child virtual DOM nodes at which to stop
|
|
718
|
+
* creating DOM nodes (inclusive)
|
|
719
|
+
*/
|
|
605
720
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
606
721
|
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
607
722
|
let childNode;
|
|
@@ -618,6 +733,19 @@ const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) =>
|
|
|
618
733
|
}
|
|
619
734
|
}
|
|
620
735
|
};
|
|
736
|
+
/**
|
|
737
|
+
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
738
|
+
* This can be used to, for instance, clean up after a list of children which
|
|
739
|
+
* should no longer be shown.
|
|
740
|
+
*
|
|
741
|
+
* This function also handles some of Stencil's slot relocation logic.
|
|
742
|
+
*
|
|
743
|
+
* @param vnodes a list of virtual DOM nodes to remove
|
|
744
|
+
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
745
|
+
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
746
|
+
* @param vnode a VNode
|
|
747
|
+
* @param elm an element
|
|
748
|
+
*/
|
|
621
749
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
622
750
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
623
751
|
if ((vnode = vnodes[startIdx])) {
|
|
@@ -642,6 +770,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
642
770
|
}
|
|
643
771
|
}
|
|
644
772
|
};
|
|
773
|
+
/**
|
|
774
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
775
|
+
* traversing the two collections of children, identifying nodes that are
|
|
776
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
777
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
778
|
+
*
|
|
779
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
780
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
781
|
+
* 'windows' by storing start and end indices and references to the
|
|
782
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
783
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
784
|
+
* no children left to update by doing the following:
|
|
785
|
+
*
|
|
786
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
787
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
788
|
+
* only with a window bounded by the highlighted elements:
|
|
789
|
+
*
|
|
790
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
791
|
+
* ^^^^^^ ^^^^^^
|
|
792
|
+
*
|
|
793
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
794
|
+
* across the windows. This will basically detect elements which haven't
|
|
795
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
796
|
+
* VNode elements (represented as HTML):
|
|
797
|
+
*
|
|
798
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
799
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
800
|
+
*
|
|
801
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
802
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
803
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
804
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
805
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
806
|
+
*
|
|
807
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
808
|
+
* window corresponds to the element at the end of the other window. This is
|
|
809
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
810
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
811
|
+
* children nodes themselves have not changed but merely moved in the
|
|
812
|
+
* following example:
|
|
813
|
+
*
|
|
814
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
815
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
816
|
+
*
|
|
817
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
818
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
819
|
+
* DOM.
|
|
820
|
+
*
|
|
821
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
822
|
+
* nodes in the old children which have the same key as the first element in
|
|
823
|
+
* our window on the new children. If we find such a node we handle calling
|
|
824
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
825
|
+
* what we find.
|
|
826
|
+
*
|
|
827
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
828
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
829
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
830
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
831
|
+
* children has collapsed we still have more nodes on the new children that
|
|
832
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
833
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
834
|
+
* sure the corresponding DOM nodes are removed.
|
|
835
|
+
*
|
|
836
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
837
|
+
* @param oldCh the old children of the parent node
|
|
838
|
+
* @param newVNode the new VNode which will replace the parent
|
|
839
|
+
* @param newCh the new children of the parent node
|
|
840
|
+
*/
|
|
645
841
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
646
842
|
let oldStartIdx = 0;
|
|
647
843
|
let newStartIdx = 0;
|
|
@@ -657,7 +853,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
657
853
|
let elmToMove;
|
|
658
854
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
659
855
|
if (oldStartVnode == null) {
|
|
660
|
-
//
|
|
856
|
+
// VNode might have been moved left
|
|
661
857
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
662
858
|
}
|
|
663
859
|
else if (oldEndVnode == null) {
|
|
@@ -670,37 +866,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
670
866
|
newEndVnode = newCh[--newEndIdx];
|
|
671
867
|
}
|
|
672
868
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
869
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
870
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
871
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
872
|
+
// since things are matched up in order.
|
|
673
873
|
patch(oldStartVnode, newStartVnode);
|
|
674
874
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
675
875
|
newStartVnode = newCh[++newStartIdx];
|
|
676
876
|
}
|
|
677
877
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
878
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
879
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
880
|
+
// need to move any DOM Nodes.
|
|
678
881
|
patch(oldEndVnode, newEndVnode);
|
|
679
882
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
680
883
|
newEndVnode = newCh[--newEndIdx];
|
|
681
884
|
}
|
|
682
885
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
683
|
-
// Vnode moved right
|
|
886
|
+
// case: "Vnode moved right"
|
|
887
|
+
//
|
|
888
|
+
// We've found that the last node in our window on the new children is
|
|
889
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
890
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
891
|
+
// nodes:
|
|
892
|
+
//
|
|
893
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
894
|
+
// ^^^^^^^^^^^
|
|
895
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
896
|
+
// ^^^^^^^^^^^^^
|
|
897
|
+
//
|
|
898
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
899
|
+
// and move the DOM element for `oldStartVnode`.
|
|
684
900
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
685
901
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
686
902
|
}
|
|
687
903
|
patch(oldStartVnode, newEndVnode);
|
|
904
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
905
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
906
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
907
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
908
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
909
|
+
//
|
|
910
|
+
// <old-start-node />
|
|
911
|
+
// <some-intervening-node />
|
|
912
|
+
// <old-end-node />
|
|
913
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
914
|
+
// <next-sibling />
|
|
915
|
+
//
|
|
916
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
917
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
918
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
919
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
920
|
+
// append it to the children of the parent element.
|
|
688
921
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
689
922
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
690
923
|
newEndVnode = newCh[--newEndIdx];
|
|
691
924
|
}
|
|
692
925
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
693
|
-
// Vnode moved left
|
|
926
|
+
// case: "Vnode moved left"
|
|
927
|
+
//
|
|
928
|
+
// We've found that the first node in our window on the new children is
|
|
929
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
930
|
+
// Visually, this is the layout of these two nodes:
|
|
931
|
+
//
|
|
932
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
933
|
+
// ^^^^^^^^^^^^^
|
|
934
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
935
|
+
// ^^^^^^^^^^^
|
|
936
|
+
//
|
|
937
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
938
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
939
|
+
// children etc) but we also need to move the DOM node to which
|
|
940
|
+
// `oldEndVnode` corresponds.
|
|
694
941
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
695
942
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
696
943
|
}
|
|
697
944
|
patch(oldEndVnode, newStartVnode);
|
|
945
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
946
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
947
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
948
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
949
|
+
// future.
|
|
698
950
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
699
951
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
700
952
|
newStartVnode = newCh[++newStartIdx];
|
|
701
953
|
}
|
|
702
954
|
else {
|
|
703
|
-
//
|
|
955
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
956
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
957
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
958
|
+
// component.
|
|
959
|
+
//
|
|
960
|
+
// First we check to see if there are any nodes in the array of old
|
|
961
|
+
// children which have the same key as the first node in the new
|
|
962
|
+
// children.
|
|
704
963
|
idxInOld = -1;
|
|
705
964
|
{
|
|
706
965
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -711,23 +970,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
711
970
|
}
|
|
712
971
|
}
|
|
713
972
|
if (idxInOld >= 0) {
|
|
973
|
+
// We found a node in the old children which matches up with the first
|
|
974
|
+
// node in the new children! So let's deal with that
|
|
714
975
|
elmToMove = oldCh[idxInOld];
|
|
715
976
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
977
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
716
978
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
717
979
|
}
|
|
718
980
|
else {
|
|
719
981
|
patch(elmToMove, newStartVnode);
|
|
982
|
+
// invalidate the matching old node so that we won't try to update it
|
|
983
|
+
// again later on
|
|
720
984
|
oldCh[idxInOld] = undefined;
|
|
721
985
|
node = elmToMove.$elm$;
|
|
722
986
|
}
|
|
723
987
|
newStartVnode = newCh[++newStartIdx];
|
|
724
988
|
}
|
|
725
989
|
else {
|
|
726
|
-
//
|
|
990
|
+
// We either didn't find an element in the old children that matches
|
|
991
|
+
// the key of the first new child OR the build is not using `key`
|
|
992
|
+
// attributes at all. In either case we need to create a new element
|
|
993
|
+
// for the new node.
|
|
727
994
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
728
995
|
newStartVnode = newCh[++newStartIdx];
|
|
729
996
|
}
|
|
730
997
|
if (node) {
|
|
998
|
+
// if we created a new node then handle inserting it to the DOM
|
|
731
999
|
{
|
|
732
1000
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
733
1001
|
}
|
|
@@ -735,21 +1003,44 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
735
1003
|
}
|
|
736
1004
|
}
|
|
737
1005
|
if (oldStartIdx > oldEndIdx) {
|
|
1006
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
738
1007
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
739
1008
|
}
|
|
740
1009
|
else if (newStartIdx > newEndIdx) {
|
|
1010
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
1011
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
1012
|
+
// relevant DOM nodes)
|
|
741
1013
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
742
1014
|
}
|
|
743
1015
|
};
|
|
744
|
-
|
|
1016
|
+
/**
|
|
1017
|
+
* Compare two VNodes to determine if they are the same
|
|
1018
|
+
*
|
|
1019
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
1020
|
+
* information set on the two VNodes and can be misleading under certain
|
|
1021
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
1022
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
1023
|
+
* checking that they have the same tag.
|
|
1024
|
+
*
|
|
1025
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
1026
|
+
* changing order within a `children` array or something along those lines then
|
|
1027
|
+
* we could obtain a false negative and then have to do needless re-rendering
|
|
1028
|
+
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
1029
|
+
*
|
|
1030
|
+
* @param leftVNode the first VNode to check
|
|
1031
|
+
* @param rightVNode the second VNode to check
|
|
1032
|
+
* @returns whether they're equal or not
|
|
1033
|
+
*/
|
|
1034
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
745
1035
|
// compare if two vnode to see if they're "technically" the same
|
|
746
1036
|
// need to have the same element tag, and same key to be the same
|
|
747
|
-
if (
|
|
748
|
-
if (
|
|
749
|
-
return
|
|
1037
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
1038
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
1039
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
750
1040
|
}
|
|
1041
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
751
1042
|
{
|
|
752
|
-
return
|
|
1043
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
753
1044
|
}
|
|
754
1045
|
}
|
|
755
1046
|
return false;
|
|
@@ -762,6 +1053,14 @@ const referenceNode = (node) => {
|
|
|
762
1053
|
return (node && node['s-ol']) || node;
|
|
763
1054
|
};
|
|
764
1055
|
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
1056
|
+
/**
|
|
1057
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
1058
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
1059
|
+
* children of the two nodes (if any).
|
|
1060
|
+
*
|
|
1061
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
1062
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
1063
|
+
*/
|
|
765
1064
|
const patch = (oldVNode, newVNode) => {
|
|
766
1065
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
767
1066
|
const oldChildren = oldVNode.$children$;
|
|
@@ -775,7 +1074,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
775
1074
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
776
1075
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
777
1076
|
}
|
|
778
|
-
// element node
|
|
779
1077
|
{
|
|
780
1078
|
if (tag === 'slot')
|
|
781
1079
|
;
|
|
@@ -788,6 +1086,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
788
1086
|
}
|
|
789
1087
|
if (oldChildren !== null && newChildren !== null) {
|
|
790
1088
|
// looks like there's child vnodes for both the old and new vnodes
|
|
1089
|
+
// so we need to call `updateChildren` to reconcile them
|
|
791
1090
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
792
1091
|
}
|
|
793
1092
|
else if (newChildren !== null) {
|
|
@@ -819,7 +1118,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
819
1118
|
};
|
|
820
1119
|
const updateFallbackSlotVisibility = (elm) => {
|
|
821
1120
|
// tslint:disable-next-line: prefer-const
|
|
822
|
-
|
|
1121
|
+
const childNodes = elm.childNodes;
|
|
823
1122
|
let childNode;
|
|
824
1123
|
let i;
|
|
825
1124
|
let ilen;
|
|
@@ -828,7 +1127,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
828
1127
|
let nodeType;
|
|
829
1128
|
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
830
1129
|
childNode = childNodes[i];
|
|
831
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1130
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
832
1131
|
if (childNode['s-sr']) {
|
|
833
1132
|
// this is a slot fallback node
|
|
834
1133
|
// get the slot name for this slot reference node
|
|
@@ -840,7 +1139,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
840
1139
|
nodeType = childNodes[j].nodeType;
|
|
841
1140
|
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
842
1141
|
// this sibling node is from a different component OR is a named fallback slot node
|
|
843
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1142
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
844
1143
|
childNode.hidden = true;
|
|
845
1144
|
break;
|
|
846
1145
|
}
|
|
@@ -849,8 +1148,8 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
849
1148
|
// this is a default fallback slot node
|
|
850
1149
|
// any element or text node (with content)
|
|
851
1150
|
// should hide the default fallback slot node
|
|
852
|
-
if (nodeType === 1 /* ElementNode */ ||
|
|
853
|
-
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1151
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1152
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
854
1153
|
childNode.hidden = true;
|
|
855
1154
|
break;
|
|
856
1155
|
}
|
|
@@ -872,8 +1171,8 @@ const relocateSlotContent = (elm) => {
|
|
|
872
1171
|
let relocateNodeData;
|
|
873
1172
|
let j;
|
|
874
1173
|
let i = 0;
|
|
875
|
-
|
|
876
|
-
|
|
1174
|
+
const childNodes = elm.childNodes;
|
|
1175
|
+
const ilen = childNodes.length;
|
|
877
1176
|
for (; i < ilen; i++) {
|
|
878
1177
|
childNode = childNodes[i];
|
|
879
1178
|
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
@@ -928,13 +1227,13 @@ const relocateSlotContent = (elm) => {
|
|
|
928
1227
|
}
|
|
929
1228
|
}
|
|
930
1229
|
}
|
|
931
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1230
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
932
1231
|
relocateSlotContent(childNode);
|
|
933
1232
|
}
|
|
934
1233
|
}
|
|
935
1234
|
};
|
|
936
1235
|
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
937
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1236
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
938
1237
|
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
939
1238
|
return true;
|
|
940
1239
|
}
|
|
@@ -954,6 +1253,18 @@ const callNodeRefs = (vNode) => {
|
|
|
954
1253
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
955
1254
|
}
|
|
956
1255
|
};
|
|
1256
|
+
/**
|
|
1257
|
+
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
1258
|
+
*
|
|
1259
|
+
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
1260
|
+
* function will handle creating a virtual DOM tree with a single root, patching
|
|
1261
|
+
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
1262
|
+
* relocation, and reflecting attributes.
|
|
1263
|
+
*
|
|
1264
|
+
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
1265
|
+
* the DOM node into which it should be rendered.
|
|
1266
|
+
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
1267
|
+
*/
|
|
957
1268
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
958
1269
|
const hostElm = hostRef.$hostElement$;
|
|
959
1270
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
@@ -965,7 +1276,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
965
1276
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
966
1277
|
}
|
|
967
1278
|
rootVnode.$tag$ = null;
|
|
968
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1279
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
969
1280
|
hostRef.$vnode$ = rootVnode;
|
|
970
1281
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
971
1282
|
{
|
|
@@ -973,7 +1284,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
973
1284
|
}
|
|
974
1285
|
{
|
|
975
1286
|
contentRef = hostElm['s-cr'];
|
|
976
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
1287
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
977
1288
|
// always reset
|
|
978
1289
|
checkSlotFallbackVisibility = false;
|
|
979
1290
|
}
|
|
@@ -982,7 +1293,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
982
1293
|
{
|
|
983
1294
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
984
1295
|
// the disconnectCallback from working
|
|
985
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
1296
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
986
1297
|
if (checkSlotRelocate) {
|
|
987
1298
|
relocateSlotContent(rootVnode.$elm$);
|
|
988
1299
|
let relocateData;
|
|
@@ -1040,7 +1351,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1040
1351
|
}
|
|
1041
1352
|
else {
|
|
1042
1353
|
// this node doesn't have a slot home to go to, so let's hide it
|
|
1043
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1354
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1044
1355
|
nodeToRelocate.hidden = true;
|
|
1045
1356
|
}
|
|
1046
1357
|
}
|
|
@@ -1051,37 +1362,11 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1051
1362
|
}
|
|
1052
1363
|
// done moving nodes around
|
|
1053
1364
|
// allow the disconnect callback to work again
|
|
1054
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1365
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1055
1366
|
// always reset
|
|
1056
1367
|
relocateNodes.length = 0;
|
|
1057
1368
|
}
|
|
1058
1369
|
};
|
|
1059
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
1060
|
-
const createEvent = (ref, name, flags) => {
|
|
1061
|
-
const elm = getElement(ref);
|
|
1062
|
-
return {
|
|
1063
|
-
emit: (detail) => {
|
|
1064
|
-
return emitEvent(elm, name, {
|
|
1065
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
1066
|
-
composed: !!(flags & 2 /* Composed */),
|
|
1067
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
1068
|
-
detail,
|
|
1069
|
-
});
|
|
1070
|
-
},
|
|
1071
|
-
};
|
|
1072
|
-
};
|
|
1073
|
-
/**
|
|
1074
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
1075
|
-
* @param elm the target of the Event
|
|
1076
|
-
* @param name the name to give the custom Event
|
|
1077
|
-
* @param opts options for configuring a custom Event
|
|
1078
|
-
* @returns the custom Event
|
|
1079
|
-
*/
|
|
1080
|
-
const emitEvent = (elm, name, opts) => {
|
|
1081
|
-
const ev = plt.ce(name, opts);
|
|
1082
|
-
elm.dispatchEvent(ev);
|
|
1083
|
-
return ev;
|
|
1084
|
-
};
|
|
1085
1370
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1086
1371
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
1087
1372
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -1089,10 +1374,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
1089
1374
|
};
|
|
1090
1375
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1091
1376
|
{
|
|
1092
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1377
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1093
1378
|
}
|
|
1094
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1095
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1379
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1380
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
1096
1381
|
return;
|
|
1097
1382
|
}
|
|
1098
1383
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -1108,7 +1393,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1108
1393
|
let promise;
|
|
1109
1394
|
if (isInitialLoad) {
|
|
1110
1395
|
{
|
|
1111
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
1396
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1112
1397
|
if (hostRef.$queuedListeners$) {
|
|
1113
1398
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1114
1399
|
hostRef.$queuedListeners$ = null;
|
|
@@ -1154,7 +1439,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1154
1439
|
}
|
|
1155
1440
|
else {
|
|
1156
1441
|
Promise.all(childrenPromises).then(postUpdate);
|
|
1157
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1442
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
1158
1443
|
childrenPromises.length = 0;
|
|
1159
1444
|
}
|
|
1160
1445
|
}
|
|
@@ -1163,10 +1448,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1163
1448
|
try {
|
|
1164
1449
|
instance = instance.render() ;
|
|
1165
1450
|
{
|
|
1166
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1451
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1167
1452
|
}
|
|
1168
1453
|
{
|
|
1169
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1454
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1170
1455
|
}
|
|
1171
1456
|
{
|
|
1172
1457
|
{
|
|
@@ -1193,8 +1478,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1193
1478
|
{
|
|
1194
1479
|
safeCall(instance, 'componentDidRender');
|
|
1195
1480
|
}
|
|
1196
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1197
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1481
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1482
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1198
1483
|
{
|
|
1199
1484
|
// DOM WRITE!
|
|
1200
1485
|
addHydratedFlag(elm);
|
|
@@ -1226,10 +1511,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1226
1511
|
hostRef.$onRenderResolve$();
|
|
1227
1512
|
hostRef.$onRenderResolve$ = undefined;
|
|
1228
1513
|
}
|
|
1229
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1514
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1230
1515
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1231
1516
|
}
|
|
1232
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1517
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
1233
1518
|
}
|
|
1234
1519
|
// ( •_•)
|
|
1235
1520
|
// ( •_•)>⌐■-■
|
|
@@ -1240,7 +1525,7 @@ const forceUpdate = (ref) => {
|
|
|
1240
1525
|
const hostRef = getHostRef(ref);
|
|
1241
1526
|
const isConnected = hostRef.$hostElement$.isConnected;
|
|
1242
1527
|
if (isConnected &&
|
|
1243
|
-
(hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1528
|
+
(hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1244
1529
|
scheduleUpdate(hostRef, false);
|
|
1245
1530
|
}
|
|
1246
1531
|
// Returns "true" when the forced update was successfully scheduled
|
|
@@ -1271,30 +1556,6 @@ const then = (promise, thenFn) => {
|
|
|
1271
1556
|
};
|
|
1272
1557
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
1273
1558
|
;
|
|
1274
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
1275
|
-
// ensure this value is of the correct prop type
|
|
1276
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
1277
|
-
if (propType & 4 /* Boolean */) {
|
|
1278
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
1279
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1280
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1281
|
-
}
|
|
1282
|
-
if (propType & 2 /* Number */) {
|
|
1283
|
-
// force it to be a number
|
|
1284
|
-
return parseFloat(propValue);
|
|
1285
|
-
}
|
|
1286
|
-
if (propType & 1 /* String */) {
|
|
1287
|
-
// could have been passed as a number or boolean
|
|
1288
|
-
// but we still want it as a string
|
|
1289
|
-
return String(propValue);
|
|
1290
|
-
}
|
|
1291
|
-
// redundant return here for better minification
|
|
1292
|
-
return propValue;
|
|
1293
|
-
}
|
|
1294
|
-
// not sure exactly what type we want
|
|
1295
|
-
// so no need to change to a different type
|
|
1296
|
-
return propValue;
|
|
1297
|
-
};
|
|
1298
1559
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1299
1560
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1300
1561
|
// check our new property value against our internal value
|
|
@@ -1304,13 +1565,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1304
1565
|
const flags = hostRef.$flags$;
|
|
1305
1566
|
const instance = hostRef.$lazyInstance$ ;
|
|
1306
1567
|
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
1307
|
-
|
|
1568
|
+
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1569
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1570
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1571
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1308
1572
|
// gadzooks! the property's value has changed!!
|
|
1309
1573
|
// set our new value!
|
|
1310
1574
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1311
1575
|
if (instance) {
|
|
1312
1576
|
// get an array of method names of watch functions to call
|
|
1313
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1577
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1314
1578
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1315
1579
|
if (watchMethods) {
|
|
1316
1580
|
// this instance is watching for when this property changed
|
|
@@ -1325,7 +1589,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1325
1589
|
});
|
|
1326
1590
|
}
|
|
1327
1591
|
}
|
|
1328
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1592
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1329
1593
|
// looks like this value actually changed, so we've got work to do!
|
|
1330
1594
|
// but only if we've already rendered, otherwise just chill out
|
|
1331
1595
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1335,6 +1599,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1335
1599
|
}
|
|
1336
1600
|
}
|
|
1337
1601
|
};
|
|
1602
|
+
/**
|
|
1603
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1604
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1605
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1606
|
+
*
|
|
1607
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1608
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1609
|
+
* @param flags a number used to store a series of bit flags
|
|
1610
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1611
|
+
*/
|
|
1338
1612
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1339
1613
|
if (cmpMeta.$members$) {
|
|
1340
1614
|
if (Cstr.watchers) {
|
|
@@ -1344,8 +1618,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1344
1618
|
const members = Object.entries(cmpMeta.$members$);
|
|
1345
1619
|
const prototype = Cstr.prototype;
|
|
1346
1620
|
members.map(([memberName, [memberFlags]]) => {
|
|
1347
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1348
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1621
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1622
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1349
1623
|
// proxyComponent - prop
|
|
1350
1624
|
Object.defineProperty(prototype, memberName, {
|
|
1351
1625
|
get() {
|
|
@@ -1360,8 +1634,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1360
1634
|
enumerable: true,
|
|
1361
1635
|
});
|
|
1362
1636
|
}
|
|
1363
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1364
|
-
memberFlags & 64 /* Method */) {
|
|
1637
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1638
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1365
1639
|
// proxyComponent - method
|
|
1366
1640
|
Object.defineProperty(prototype, memberName, {
|
|
1367
1641
|
value(...args) {
|
|
@@ -1371,7 +1645,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1371
1645
|
});
|
|
1372
1646
|
}
|
|
1373
1647
|
});
|
|
1374
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1648
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1375
1649
|
const attrNameToPropName = new Map();
|
|
1376
1650
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1377
1651
|
plt.jmp(() => {
|
|
@@ -1427,11 +1701,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1427
1701
|
// create an array of attributes to observe
|
|
1428
1702
|
// and also create a map of html attribute name to js property name
|
|
1429
1703
|
Cstr.observedAttributes = members
|
|
1430
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1704
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1431
1705
|
.map(([propName, m]) => {
|
|
1432
1706
|
const attrName = m[1] || propName;
|
|
1433
1707
|
attrNameToPropName.set(attrName, propName);
|
|
1434
|
-
if (m[0] & 512 /* ReflectAttr */) {
|
|
1708
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1435
1709
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1436
1710
|
}
|
|
1437
1711
|
return attrName;
|
|
@@ -1442,10 +1716,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1442
1716
|
};
|
|
1443
1717
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1444
1718
|
// initializeComponent
|
|
1445
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1719
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1446
1720
|
{
|
|
1447
1721
|
// we haven't initialized this element yet
|
|
1448
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1722
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1449
1723
|
// lazy loaded components
|
|
1450
1724
|
// request the component's implementation to be
|
|
1451
1725
|
// wired up with the host element
|
|
@@ -1463,7 +1737,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1463
1737
|
{
|
|
1464
1738
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1465
1739
|
}
|
|
1466
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1740
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1467
1741
|
Cstr.isProxied = true;
|
|
1468
1742
|
}
|
|
1469
1743
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1471,7 +1745,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1471
1745
|
// but let's keep track of when we start and stop
|
|
1472
1746
|
// so that the getters/setters don't incorrectly step on data
|
|
1473
1747
|
{
|
|
1474
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1748
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1475
1749
|
}
|
|
1476
1750
|
// construct the lazy-loaded component implementation
|
|
1477
1751
|
// passing the hostRef is very important during
|
|
@@ -1484,10 +1758,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1484
1758
|
consoleError(e);
|
|
1485
1759
|
}
|
|
1486
1760
|
{
|
|
1487
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1761
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1488
1762
|
}
|
|
1489
1763
|
{
|
|
1490
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1764
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1491
1765
|
}
|
|
1492
1766
|
endNewInstance();
|
|
1493
1767
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -1498,7 +1772,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1498
1772
|
const scopeId = getScopeId(cmpMeta);
|
|
1499
1773
|
if (!styles.has(scopeId)) {
|
|
1500
1774
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1501
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1775
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1502
1776
|
endRegisterStyles();
|
|
1503
1777
|
}
|
|
1504
1778
|
}
|
|
@@ -1525,19 +1799,19 @@ const fireConnectedCallback = (instance) => {
|
|
|
1525
1799
|
}
|
|
1526
1800
|
};
|
|
1527
1801
|
const connectedCallback = (elm) => {
|
|
1528
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1802
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1529
1803
|
const hostRef = getHostRef(elm);
|
|
1530
1804
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1531
1805
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1532
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1806
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1533
1807
|
// first time this component has connected
|
|
1534
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1808
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1535
1809
|
{
|
|
1536
1810
|
// initUpdate
|
|
1537
1811
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1538
1812
|
// in here to act as original content anchors as we move nodes around
|
|
1539
1813
|
// host element has been connected to the DOM
|
|
1540
|
-
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1814
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1541
1815
|
setContentReference(elm);
|
|
1542
1816
|
}
|
|
1543
1817
|
}
|
|
@@ -1560,7 +1834,7 @@ const connectedCallback = (elm) => {
|
|
|
1560
1834
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1561
1835
|
if (cmpMeta.$members$) {
|
|
1562
1836
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1563
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1837
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1564
1838
|
const value = elm[memberName];
|
|
1565
1839
|
delete elm[memberName];
|
|
1566
1840
|
elm[memberName] = value;
|
|
@@ -1594,7 +1868,7 @@ const setContentReference = (elm) => {
|
|
|
1594
1868
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1595
1869
|
};
|
|
1596
1870
|
const disconnectedCallback = (elm) => {
|
|
1597
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1871
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1598
1872
|
const hostRef = getHostRef(elm);
|
|
1599
1873
|
const instance = hostRef.$lazyInstance$ ;
|
|
1600
1874
|
{
|
|
@@ -1609,6 +1883,7 @@ const disconnectedCallback = (elm) => {
|
|
|
1609
1883
|
}
|
|
1610
1884
|
};
|
|
1611
1885
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1886
|
+
var _a;
|
|
1612
1887
|
const endBootstrap = createTime();
|
|
1613
1888
|
const cmpTags = [];
|
|
1614
1889
|
const exclude = options.exclude || [];
|
|
@@ -1649,7 +1924,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1649
1924
|
super(self);
|
|
1650
1925
|
self = this;
|
|
1651
1926
|
registerHost(self, cmpMeta);
|
|
1652
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1927
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1653
1928
|
// this component is using shadow dom
|
|
1654
1929
|
// and this browser supports shadow dom
|
|
1655
1930
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1684,13 +1959,18 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1684
1959
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1685
1960
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1686
1961
|
cmpTags.push(tagName);
|
|
1687
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1962
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1688
1963
|
}
|
|
1689
1964
|
});
|
|
1690
1965
|
});
|
|
1691
1966
|
{
|
|
1692
1967
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1693
1968
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1969
|
+
// Apply CSP nonce to the style tag if it exists
|
|
1970
|
+
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1971
|
+
if (nonce != null) {
|
|
1972
|
+
visibilityStyle.setAttribute('nonce', nonce);
|
|
1973
|
+
}
|
|
1694
1974
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1695
1975
|
}
|
|
1696
1976
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1706,7 +1986,43 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1706
1986
|
// Fallback appLoad event
|
|
1707
1987
|
endBootstrap();
|
|
1708
1988
|
};
|
|
1709
|
-
const
|
|
1989
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1990
|
+
if (listeners) {
|
|
1991
|
+
listeners.map(([flags, name, method]) => {
|
|
1992
|
+
const target = elm;
|
|
1993
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1994
|
+
const opts = hostListenerOpts(flags);
|
|
1995
|
+
plt.ael(target, name, handler, opts);
|
|
1996
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
2001
|
+
try {
|
|
2002
|
+
{
|
|
2003
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
2004
|
+
// instance is ready, let's call it's member method for this event
|
|
2005
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
2006
|
+
}
|
|
2007
|
+
else {
|
|
2008
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
catch (e) {
|
|
2013
|
+
consoleError(e);
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
// prettier-ignore
|
|
2017
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
2018
|
+
/**
|
|
2019
|
+
* Assigns the given value to the nonce property on the runtime platform object.
|
|
2020
|
+
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
2021
|
+
* @param nonce The value to be assigned to the platform nonce property.
|
|
2022
|
+
* @returns void
|
|
2023
|
+
*/
|
|
2024
|
+
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
2025
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1710
2026
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1711
2027
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1712
2028
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1738,7 +2054,9 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1738
2054
|
if (module) {
|
|
1739
2055
|
return module[exportName];
|
|
1740
2056
|
}
|
|
2057
|
+
/*!__STENCIL_STATIC_IMPORT_SWITCH__*/
|
|
1741
2058
|
return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
|
|
2059
|
+
/* @vite-ignore */
|
|
1742
2060
|
/* webpackInclude: /\.entry\.js$/ */
|
|
1743
2061
|
/* webpackExclude: /\.system\.entry\.js$/ */
|
|
1744
2062
|
/* webpackMode: "lazy" */
|
|
@@ -1749,14 +2067,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1749
2067
|
return importedModule[exportName];
|
|
1750
2068
|
}, consoleError);
|
|
1751
2069
|
};
|
|
1752
|
-
const styles = new Map();
|
|
2070
|
+
const styles = /*@__PURE__*/ new Map();
|
|
2071
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
2072
|
+
const doc = win.document || { head: {} };
|
|
2073
|
+
const plt = {
|
|
2074
|
+
$flags$: 0,
|
|
2075
|
+
$resourcesUrl$: '',
|
|
2076
|
+
jmp: (h) => h(),
|
|
2077
|
+
raf: (h) => requestAnimationFrame(h),
|
|
2078
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
2079
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
2080
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
2081
|
+
};
|
|
2082
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
2083
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
2084
|
+
try {
|
|
2085
|
+
new CSSStyleSheet();
|
|
2086
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
2087
|
+
}
|
|
2088
|
+
catch (e) { }
|
|
2089
|
+
return false;
|
|
2090
|
+
})()
|
|
2091
|
+
;
|
|
1753
2092
|
const queueDomReads = [];
|
|
1754
2093
|
const queueDomWrites = [];
|
|
1755
2094
|
const queueTask = (queue, write) => (cb) => {
|
|
1756
2095
|
queue.push(cb);
|
|
1757
2096
|
if (!queuePending) {
|
|
1758
2097
|
queuePending = true;
|
|
1759
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
2098
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1760
2099
|
nextTick(flush);
|
|
1761
2100
|
}
|
|
1762
2101
|
else {
|
|
@@ -1801,3 +2140,4 @@ exports.getElement = getElement;
|
|
|
1801
2140
|
exports.h = h;
|
|
1802
2141
|
exports.promiseResolve = promiseResolve;
|
|
1803
2142
|
exports.registerInstance = registerInstance;
|
|
2143
|
+
exports.setNonce = setNonce;
|