smoothly 0.3.5 → 0.3.6
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/{index-3efe2a41.js → index-3fb97927.js} +467 -269
- package/dist/cjs/{index-2a011313.js → index-7b75b331.js} +1 -1
- package/dist/cjs/index.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/smoothly-accordion_53.cjs.entry.js +68 -26
- package/dist/cjs/smoothly-google-font.cjs.entry.js +1 -1
- package/dist/cjs/smoothly-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/smoothly-reorder.cjs.entry.js +1 -1
- package/dist/cjs/smoothly-trigger-sink.cjs.entry.js +1 -1
- package/dist/cjs/smoothly-trigger-source.cjs.entry.js +1 -1
- package/dist/cjs/smoothly.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/App.js +38 -46
- package/dist/collection/components/accordion/index.js +65 -55
- package/dist/collection/components/accordion-item/index.js +133 -131
- package/dist/collection/components/app/index.js +37 -32
- package/dist/collection/components/app-demo/index.js +39 -68
- package/dist/collection/components/backtotop/index.js +73 -66
- package/dist/collection/components/button/index.js +144 -141
- package/dist/collection/components/calendar/index.js +277 -268
- package/dist/collection/components/checkbox/index.js +120 -110
- package/dist/collection/components/dialog/index.js +97 -93
- package/dist/collection/components/dialog-demo/index.js +2 -3
- package/dist/collection/components/display/index.js +108 -102
- package/dist/collection/components/display-amount/index.js +68 -63
- package/dist/collection/components/display-date-time/index.js +35 -30
- package/dist/collection/components/display-demo/index.js +23 -129
- package/dist/collection/components/frame/index.js +134 -124
- package/dist/collection/components/google-font/index.js +26 -24
- package/dist/collection/components/icon/index.js +116 -107
- package/dist/collection/components/icon-demo/index.js +11 -7
- package/dist/collection/components/input/index.js +364 -355
- package/dist/collection/components/input-date/index.js +165 -156
- package/dist/collection/components/input-date-range/index.js +220 -213
- package/dist/collection/components/input-demo/index.js +2 -87
- package/dist/collection/components/input-month/index.js +65 -57
- package/dist/collection/components/item/index.js +101 -87
- package/dist/collection/components/menu-options/index.js +287 -275
- package/dist/collection/components/notification/index.js +74 -63
- package/dist/collection/components/notifier/index.js +31 -23
- package/dist/collection/components/option/index.js +227 -223
- package/dist/collection/components/picker/index.js +404 -397
- package/dist/collection/components/popup/index.js +73 -69
- package/dist/collection/components/quiet/index.js +33 -28
- package/dist/collection/components/radio/index.js +98 -91
- package/dist/collection/components/radio-button/index.js +92 -83
- package/dist/collection/components/radio-button/item/index.js +91 -66
- package/dist/collection/components/radio-button/item/style.css +11 -14
- package/dist/collection/components/radio-group/index.js +33 -27
- package/dist/collection/components/reorder/index.js +28 -23
- package/dist/collection/components/room/index.js +73 -71
- package/dist/collection/components/select/index.js +82 -75
- package/dist/collection/components/select-demo/index.js +24 -42
- package/dist/collection/components/selector/index.js +71 -68
- package/dist/collection/components/skeleton/index.js +112 -106
- package/dist/collection/components/spinner/index.js +50 -46
- package/dist/collection/components/submit/index.js +174 -163
- package/dist/collection/components/svg/index.js +65 -60
- package/dist/collection/components/tab/index.js +84 -75
- package/dist/collection/components/tab-switch/index.js +32 -23
- package/dist/collection/components/table/cell/index.js +12 -9
- package/dist/collection/components/table/demo/index.js +13 -59
- package/dist/collection/components/table/expandable/cell/index.js +100 -95
- package/dist/collection/components/table/expandable/row/index.js +85 -79
- package/dist/collection/components/table/header/index.js +33 -28
- package/dist/collection/components/table/index.js +44 -36
- package/dist/collection/components/table/row/index.js +26 -20
- package/dist/collection/components/trigger/index.js +174 -166
- package/dist/collection/components/trigger-sink/index.js +73 -65
- package/dist/collection/components/trigger-source/index.js +71 -63
- package/dist/collection/components/tuple/index.js +19 -17
- package/dist/collection/components/urlencoded/index.js +22 -20
- package/dist/collection/model/Listenable.js +4 -2
- package/dist/custom-elements/index.js +67 -25
- package/dist/esm/{index-1d438ba2.js → index-3b463176.js} +1 -1
- package/dist/esm/{index-4d9efff8.js → index-fcf8bdd3.js} +467 -269
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/smoothly-accordion_53.entry.js +68 -26
- package/dist/esm/smoothly-google-font.entry.js +1 -1
- package/dist/esm/smoothly-radio-group.entry.js +1 -1
- package/dist/esm/smoothly-reorder.entry.js +1 -1
- package/dist/esm/smoothly-trigger-sink.entry.js +1 -1
- package/dist/esm/smoothly-trigger-source.entry.js +1 -1
- package/dist/esm/smoothly.js +3 -3
- package/dist/smoothly/index.esm.js +1 -1
- package/dist/smoothly/{p-d5d4832d.entry.js → p-0833f25c.entry.js} +1 -1
- package/dist/smoothly/{p-919ae3e8.entry.js → p-2bf8c660.entry.js} +1 -1
- package/dist/smoothly/{p-8e4e941e.entry.js → p-3bd18eea.entry.js} +1 -1
- package/dist/smoothly/p-8ab82f55.entry.js +1 -0
- package/dist/smoothly/{p-9bc77fba.entry.js → p-a1c137fc.entry.js} +1 -1
- package/dist/smoothly/p-af90d05a.js +2 -0
- package/dist/smoothly/{p-76e88859.js → p-e5191036.js} +1 -1
- package/dist/smoothly/{p-7a5eda51.entry.js → p-f67259c5.entry.js} +1 -1
- package/dist/smoothly/smoothly.esm.js +1 -1
- package/dist/types/components/radio-button/item/index.d.ts +2 -0
- package/dist/types/components.d.ts +3 -1
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +6 -6
- package/dist/smoothly/p-191ee4b8.js +0 -2
- package/dist/smoothly/p-78b676aa.entry.js +0 -1
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
const NAMESPACE = 'smoothly';
|
|
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;
|
|
@@ -9,58 +17,6 @@ let checkSlotRelocate = false;
|
|
|
9
17
|
let isSvgMode = false;
|
|
10
18
|
let renderingRef = null;
|
|
11
19
|
let queuePending = false;
|
|
12
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
13
|
-
const doc = win.document || { head: {} };
|
|
14
|
-
const plt = {
|
|
15
|
-
$flags$: 0,
|
|
16
|
-
$resourcesUrl$: '',
|
|
17
|
-
jmp: (h) => h(),
|
|
18
|
-
raf: (h) => requestAnimationFrame(h),
|
|
19
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
20
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
21
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
22
|
-
};
|
|
23
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
24
|
-
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
25
|
-
try {
|
|
26
|
-
new CSSStyleSheet();
|
|
27
|
-
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
28
|
-
}
|
|
29
|
-
catch (e) { }
|
|
30
|
-
return false;
|
|
31
|
-
})()
|
|
32
|
-
;
|
|
33
|
-
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
34
|
-
if (listeners) {
|
|
35
|
-
listeners.map(([flags, name, method]) => {
|
|
36
|
-
const target = elm;
|
|
37
|
-
const handler = hostListenerProxy(hostRef, method);
|
|
38
|
-
const opts = hostListenerOpts(flags);
|
|
39
|
-
plt.ael(target, name, handler, opts);
|
|
40
|
-
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
45
|
-
try {
|
|
46
|
-
{
|
|
47
|
-
if (hostRef.$flags$ & 256 /* isListenReady */) {
|
|
48
|
-
// instance is ready, let's call it's member method for this event
|
|
49
|
-
hostRef.$lazyInstance$[methodName](ev);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (e) {
|
|
57
|
-
consoleError(e);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
// prettier-ignore
|
|
61
|
-
const hostListenerOpts = (flags) => (flags & 2 /* Capture */) !== 0;
|
|
62
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
63
|
-
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
64
20
|
const createTime = (fnName, tagName = '') => {
|
|
65
21
|
{
|
|
66
22
|
return () => {
|
|
@@ -75,79 +31,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
75
31
|
};
|
|
76
32
|
}
|
|
77
33
|
};
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
let style = styles.get(scopeId);
|
|
81
|
-
if (supportsConstructableStylesheets && allowCS) {
|
|
82
|
-
style = (style || new CSSStyleSheet());
|
|
83
|
-
if (typeof style === 'string') {
|
|
84
|
-
style = cssText;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
style.replaceSync(cssText);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
style = cssText;
|
|
92
|
-
}
|
|
93
|
-
styles.set(scopeId, style);
|
|
94
|
-
};
|
|
95
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
96
|
-
let scopeId = getScopeId(cmpMeta);
|
|
97
|
-
const style = styles.get(scopeId);
|
|
98
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
99
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
100
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
101
|
-
if (style) {
|
|
102
|
-
if (typeof style === 'string') {
|
|
103
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
104
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
105
|
-
let styleElm;
|
|
106
|
-
if (!appliedStyles) {
|
|
107
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
108
|
-
}
|
|
109
|
-
if (!appliedStyles.has(scopeId)) {
|
|
110
|
-
{
|
|
111
|
-
{
|
|
112
|
-
styleElm = doc.createElement('style');
|
|
113
|
-
styleElm.innerHTML = style;
|
|
114
|
-
}
|
|
115
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
116
|
-
}
|
|
117
|
-
if (appliedStyles) {
|
|
118
|
-
appliedStyles.add(scopeId);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
123
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return scopeId;
|
|
127
|
-
};
|
|
128
|
-
const attachStyles = (hostRef) => {
|
|
129
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
130
|
-
const elm = hostRef.$hostElement$;
|
|
131
|
-
const flags = cmpMeta.$flags$;
|
|
132
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
133
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
134
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
135
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
136
|
-
// or this browser doesn't support native shadow dom
|
|
137
|
-
// and this host element was NOT created with SSR
|
|
138
|
-
// let's pick out the inner content for slot projection
|
|
139
|
-
// create a node to represent where the original
|
|
140
|
-
// content was first placed, which is useful later on
|
|
141
|
-
// DOM WRITE!!
|
|
142
|
-
elm['s-sc'] = scopeId;
|
|
143
|
-
elm.classList.add(scopeId + '-h');
|
|
144
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
145
|
-
elm.classList.add(scopeId + '-s');
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
endAttachStyles();
|
|
149
|
-
};
|
|
150
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
34
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
35
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
151
36
|
/**
|
|
152
37
|
* Default style mode id
|
|
153
38
|
*/
|
|
@@ -296,6 +181,152 @@ const convertToPrivate = (node) => {
|
|
|
296
181
|
vnode.$name$ = node.vname;
|
|
297
182
|
return vnode;
|
|
298
183
|
};
|
|
184
|
+
/**
|
|
185
|
+
* Parse a new property value for a given property type.
|
|
186
|
+
*
|
|
187
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
188
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
189
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
190
|
+
* 2. the type stored from `propType`.
|
|
191
|
+
*
|
|
192
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
193
|
+
*
|
|
194
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
195
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
196
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
197
|
+
* ```tsx
|
|
198
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* HTML prop values on the other hand, will always a string
|
|
202
|
+
*
|
|
203
|
+
* @param propValue the new value to coerce to some type
|
|
204
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
205
|
+
* @returns the parsed/coerced value
|
|
206
|
+
*/
|
|
207
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
208
|
+
// ensure this value is of the correct prop type
|
|
209
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
210
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
211
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
212
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
213
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
214
|
+
}
|
|
215
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
216
|
+
// force it to be a number
|
|
217
|
+
return parseFloat(propValue);
|
|
218
|
+
}
|
|
219
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
220
|
+
// could have been passed as a number or boolean
|
|
221
|
+
// but we still want it as a string
|
|
222
|
+
return String(propValue);
|
|
223
|
+
}
|
|
224
|
+
// redundant return here for better minification
|
|
225
|
+
return propValue;
|
|
226
|
+
}
|
|
227
|
+
// not sure exactly what type we want
|
|
228
|
+
// so no need to change to a different type
|
|
229
|
+
return propValue;
|
|
230
|
+
};
|
|
231
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
232
|
+
const createEvent = (ref, name, flags) => {
|
|
233
|
+
const elm = getElement(ref);
|
|
234
|
+
return {
|
|
235
|
+
emit: (detail) => {
|
|
236
|
+
return emitEvent(elm, name, {
|
|
237
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
238
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
239
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
240
|
+
detail,
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
247
|
+
* @param elm the target of the Event
|
|
248
|
+
* @param name the name to give the custom Event
|
|
249
|
+
* @param opts options for configuring a custom Event
|
|
250
|
+
* @returns the custom Event
|
|
251
|
+
*/
|
|
252
|
+
const emitEvent = (elm, name, opts) => {
|
|
253
|
+
const ev = plt.ce(name, opts);
|
|
254
|
+
elm.dispatchEvent(ev);
|
|
255
|
+
return ev;
|
|
256
|
+
};
|
|
257
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
258
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
259
|
+
let style = styles.get(scopeId);
|
|
260
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
261
|
+
style = (style || new CSSStyleSheet());
|
|
262
|
+
if (typeof style === 'string') {
|
|
263
|
+
style = cssText;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
style.replaceSync(cssText);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
style = cssText;
|
|
271
|
+
}
|
|
272
|
+
styles.set(scopeId, style);
|
|
273
|
+
};
|
|
274
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
275
|
+
let scopeId = getScopeId(cmpMeta);
|
|
276
|
+
const style = styles.get(scopeId);
|
|
277
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
278
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
279
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
280
|
+
if (style) {
|
|
281
|
+
if (typeof style === 'string') {
|
|
282
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
283
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
284
|
+
let styleElm;
|
|
285
|
+
if (!appliedStyles) {
|
|
286
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
287
|
+
}
|
|
288
|
+
if (!appliedStyles.has(scopeId)) {
|
|
289
|
+
{
|
|
290
|
+
{
|
|
291
|
+
styleElm = doc.createElement('style');
|
|
292
|
+
styleElm.innerHTML = style;
|
|
293
|
+
}
|
|
294
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
295
|
+
}
|
|
296
|
+
if (appliedStyles) {
|
|
297
|
+
appliedStyles.add(scopeId);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
302
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return scopeId;
|
|
306
|
+
};
|
|
307
|
+
const attachStyles = (hostRef) => {
|
|
308
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
309
|
+
const elm = hostRef.$hostElement$;
|
|
310
|
+
const flags = cmpMeta.$flags$;
|
|
311
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
312
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
313
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
314
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
315
|
+
// or this browser doesn't support native shadow dom
|
|
316
|
+
// and this host element was NOT created with SSR
|
|
317
|
+
// let's pick out the inner content for slot projection
|
|
318
|
+
// create a node to represent where the original
|
|
319
|
+
// content was first placed, which is useful later on
|
|
320
|
+
// DOM WRITE!!
|
|
321
|
+
elm['s-sc'] = scopeId;
|
|
322
|
+
elm.classList.add(scopeId + '-h');
|
|
323
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
324
|
+
elm.classList.add(scopeId + '-s');
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
endAttachStyles();
|
|
328
|
+
};
|
|
329
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
299
330
|
/**
|
|
300
331
|
* Production setAccessor() function based on Preact by
|
|
301
332
|
* Jason Miller (@developit)
|
|
@@ -432,7 +463,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
432
463
|
}
|
|
433
464
|
}
|
|
434
465
|
}
|
|
435
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
466
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
436
467
|
newValue = newValue === true ? '' : newValue;
|
|
437
468
|
if (xlink) {
|
|
438
469
|
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
@@ -450,7 +481,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
450
481
|
// if the element passed in is a shadow root, which is a document fragment
|
|
451
482
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
452
483
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
453
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
484
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
454
485
|
? newVnode.$elm$.host
|
|
455
486
|
: newVnode.$elm$;
|
|
456
487
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -468,6 +499,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
468
499
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
469
500
|
}
|
|
470
501
|
};
|
|
502
|
+
/**
|
|
503
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
504
|
+
*
|
|
505
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
506
|
+
* @param newParentVNode the parent VNode from the current render
|
|
507
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
508
|
+
* children, for which we will create a new DOM node
|
|
509
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
510
|
+
* @returns the newly created node
|
|
511
|
+
*/
|
|
471
512
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
472
513
|
// tslint:disable-next-line: prefer-const
|
|
473
514
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -485,16 +526,16 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
485
526
|
}
|
|
486
527
|
newVNode.$flags$ |= newVNode.$children$
|
|
487
528
|
? // slot element has fallback content
|
|
488
|
-
2 /* isSlotFallback */
|
|
529
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
489
530
|
: // slot element does not have fallback content
|
|
490
|
-
1 /* isSlotReference */;
|
|
531
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
491
532
|
}
|
|
492
533
|
}
|
|
493
534
|
if (newVNode.$text$ !== null) {
|
|
494
535
|
// create text node
|
|
495
536
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
496
537
|
}
|
|
497
|
-
else if (newVNode.$flags$ & 1 /* isSlotReference */) {
|
|
538
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
498
539
|
// create a slot reference node
|
|
499
540
|
elm = newVNode.$elm$ =
|
|
500
541
|
doc.createTextNode('');
|
|
@@ -504,7 +545,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
504
545
|
isSvgMode = newVNode.$tag$ === 'svg';
|
|
505
546
|
}
|
|
506
547
|
// create element
|
|
507
|
-
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
|
|
548
|
+
elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
508
549
|
? 'slot-fb'
|
|
509
550
|
: newVNode.$tag$)
|
|
510
551
|
);
|
|
@@ -544,7 +585,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
544
585
|
}
|
|
545
586
|
{
|
|
546
587
|
elm['s-hn'] = hostTagName;
|
|
547
|
-
if (newVNode.$flags$ & (2 /* isSlotFallback */ | 1 /* isSlotReference */)) {
|
|
588
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
548
589
|
// remember the content reference comment
|
|
549
590
|
elm['s-sr'] = true;
|
|
550
591
|
// remember the content reference comment
|
|
@@ -563,7 +604,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
563
604
|
return elm;
|
|
564
605
|
};
|
|
565
606
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
566
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
607
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
567
608
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
568
609
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
569
610
|
const childNode = oldSlotChildNodes[i];
|
|
@@ -584,7 +625,7 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
584
625
|
putBackInOriginalLocation(childNode, recursive);
|
|
585
626
|
}
|
|
586
627
|
}
|
|
587
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
628
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
588
629
|
};
|
|
589
630
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
590
631
|
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
@@ -626,6 +667,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
626
667
|
}
|
|
627
668
|
}
|
|
628
669
|
};
|
|
670
|
+
/**
|
|
671
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
672
|
+
* traversing the two collections of children, identifying nodes that are
|
|
673
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
674
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
675
|
+
*
|
|
676
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
677
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
678
|
+
* 'windows' by storing start and end indices and references to the
|
|
679
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
680
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
681
|
+
* no children left to update by doing the following:
|
|
682
|
+
*
|
|
683
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
684
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
685
|
+
* only with a window bounded by the highlighted elements:
|
|
686
|
+
*
|
|
687
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
688
|
+
* ^^^^^^ ^^^^^^
|
|
689
|
+
*
|
|
690
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
691
|
+
* across the windows. This will basically detect elements which haven't
|
|
692
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
693
|
+
* VNode elements (represented as HTML):
|
|
694
|
+
*
|
|
695
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
696
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
697
|
+
*
|
|
698
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
699
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
700
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
701
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
702
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
703
|
+
*
|
|
704
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
705
|
+
* window corresponds to the element at the end of the other window. This is
|
|
706
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
707
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
708
|
+
* children nodes themselves have not changed but merely moved in the
|
|
709
|
+
* following example:
|
|
710
|
+
*
|
|
711
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
712
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
713
|
+
*
|
|
714
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
715
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
716
|
+
* DOM.
|
|
717
|
+
*
|
|
718
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
719
|
+
* nodes in the old children which have the same key as the first element in
|
|
720
|
+
* our window on the new children. If we find such a node we handle calling
|
|
721
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
722
|
+
* what we find.
|
|
723
|
+
*
|
|
724
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
725
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
726
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
727
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
728
|
+
* children has collapsed we still have more nodes on the new children that
|
|
729
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
730
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
731
|
+
* sure the corresponding DOM nodes are removed.
|
|
732
|
+
*
|
|
733
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
734
|
+
* @param oldCh the old children of the parent node
|
|
735
|
+
* @param newVNode the new VNode which will replace the parent
|
|
736
|
+
* @param newCh the new children of the parent node
|
|
737
|
+
*/
|
|
629
738
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
630
739
|
let oldStartIdx = 0;
|
|
631
740
|
let newStartIdx = 0;
|
|
@@ -641,7 +750,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
641
750
|
let elmToMove;
|
|
642
751
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
643
752
|
if (oldStartVnode == null) {
|
|
644
|
-
//
|
|
753
|
+
// VNode might have been moved left
|
|
645
754
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
646
755
|
}
|
|
647
756
|
else if (oldEndVnode == null) {
|
|
@@ -654,37 +763,100 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
654
763
|
newEndVnode = newCh[--newEndIdx];
|
|
655
764
|
}
|
|
656
765
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
766
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
767
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
768
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
769
|
+
// since things are matched up in order.
|
|
657
770
|
patch(oldStartVnode, newStartVnode);
|
|
658
771
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
659
772
|
newStartVnode = newCh[++newStartIdx];
|
|
660
773
|
}
|
|
661
774
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
775
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
776
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
777
|
+
// need to move any DOM Nodes.
|
|
662
778
|
patch(oldEndVnode, newEndVnode);
|
|
663
779
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
664
780
|
newEndVnode = newCh[--newEndIdx];
|
|
665
781
|
}
|
|
666
782
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
667
|
-
// Vnode moved right
|
|
783
|
+
// case: "Vnode moved right"
|
|
784
|
+
//
|
|
785
|
+
// We've found that the last node in our window on the new children is
|
|
786
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
787
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
788
|
+
// nodes:
|
|
789
|
+
//
|
|
790
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
791
|
+
// ^^^^^^^^^^^
|
|
792
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
793
|
+
// ^^^^^^^^^^^^^
|
|
794
|
+
//
|
|
795
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
796
|
+
// and move the DOM element for `oldStartVnode`.
|
|
668
797
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
669
798
|
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
670
799
|
}
|
|
671
800
|
patch(oldStartVnode, newEndVnode);
|
|
801
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
802
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
803
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
804
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
805
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
806
|
+
//
|
|
807
|
+
// <old-start-node />
|
|
808
|
+
// <some-intervening-node />
|
|
809
|
+
// <old-end-node />
|
|
810
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
811
|
+
// <next-sibling />
|
|
812
|
+
//
|
|
813
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
814
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
815
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
816
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
817
|
+
// append it to the children of the parent element.
|
|
672
818
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
673
819
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
674
820
|
newEndVnode = newCh[--newEndIdx];
|
|
675
821
|
}
|
|
676
822
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
677
|
-
// Vnode moved left
|
|
823
|
+
// case: "Vnode moved left"
|
|
824
|
+
//
|
|
825
|
+
// We've found that the first node in our window on the new children is
|
|
826
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
827
|
+
// Visually, this is the layout of these two nodes:
|
|
828
|
+
//
|
|
829
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
830
|
+
// ^^^^^^^^^^^^^
|
|
831
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
832
|
+
// ^^^^^^^^^^^
|
|
833
|
+
//
|
|
834
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
835
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
836
|
+
// children etc) but we also need to move the DOM node to which
|
|
837
|
+
// `oldEndVnode` corresponds.
|
|
678
838
|
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
679
839
|
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
680
840
|
}
|
|
681
841
|
patch(oldEndVnode, newStartVnode);
|
|
842
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
843
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
844
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
845
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
846
|
+
// future.
|
|
682
847
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
683
848
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
684
849
|
newStartVnode = newCh[++newStartIdx];
|
|
685
850
|
}
|
|
686
851
|
else {
|
|
687
|
-
//
|
|
852
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
853
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
854
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
855
|
+
// component.
|
|
856
|
+
//
|
|
857
|
+
// First we check to see if there are any nodes in the array of old
|
|
858
|
+
// children which have the same key as the first node in the new
|
|
859
|
+
// children.
|
|
688
860
|
idxInOld = -1;
|
|
689
861
|
{
|
|
690
862
|
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
@@ -695,23 +867,32 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
695
867
|
}
|
|
696
868
|
}
|
|
697
869
|
if (idxInOld >= 0) {
|
|
870
|
+
// We found a node in the old children which matches up with the first
|
|
871
|
+
// node in the new children! So let's deal with that
|
|
698
872
|
elmToMove = oldCh[idxInOld];
|
|
699
873
|
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
874
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
700
875
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
701
876
|
}
|
|
702
877
|
else {
|
|
703
878
|
patch(elmToMove, newStartVnode);
|
|
879
|
+
// invalidate the matching old node so that we won't try to update it
|
|
880
|
+
// again later on
|
|
704
881
|
oldCh[idxInOld] = undefined;
|
|
705
882
|
node = elmToMove.$elm$;
|
|
706
883
|
}
|
|
707
884
|
newStartVnode = newCh[++newStartIdx];
|
|
708
885
|
}
|
|
709
886
|
else {
|
|
710
|
-
//
|
|
887
|
+
// We either didn't find an element in the old children that matches
|
|
888
|
+
// the key of the first new child OR the build is not using `key`
|
|
889
|
+
// attributes at all. In either case we need to create a new element
|
|
890
|
+
// for the new node.
|
|
711
891
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
712
892
|
newStartVnode = newCh[++newStartIdx];
|
|
713
893
|
}
|
|
714
894
|
if (node) {
|
|
895
|
+
// if we created a new node then handle inserting it to the DOM
|
|
715
896
|
{
|
|
716
897
|
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
717
898
|
}
|
|
@@ -719,21 +900,43 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
719
900
|
}
|
|
720
901
|
}
|
|
721
902
|
if (oldStartIdx > oldEndIdx) {
|
|
903
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
722
904
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
723
905
|
}
|
|
724
906
|
else if (newStartIdx > newEndIdx) {
|
|
907
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
908
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
909
|
+
// relevant DOM nodes)
|
|
725
910
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
726
911
|
}
|
|
727
912
|
};
|
|
728
|
-
|
|
913
|
+
/**
|
|
914
|
+
* Compare two VNodes to determine if they are the same
|
|
915
|
+
*
|
|
916
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
917
|
+
* information set on the two VNodes and can be misleading under certain
|
|
918
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
919
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
920
|
+
* checking that they have the same tag.
|
|
921
|
+
*
|
|
922
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
923
|
+
* changing order within a `children` array or something along those lines then
|
|
924
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
925
|
+
*
|
|
926
|
+
* @param leftVNode the first VNode to check
|
|
927
|
+
* @param rightVNode the second VNode to check
|
|
928
|
+
* @returns whether they're equal or not
|
|
929
|
+
*/
|
|
930
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
729
931
|
// compare if two vnode to see if they're "technically" the same
|
|
730
932
|
// need to have the same element tag, and same key to be the same
|
|
731
|
-
if (
|
|
732
|
-
if (
|
|
733
|
-
return
|
|
933
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
934
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
935
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
734
936
|
}
|
|
937
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
735
938
|
{
|
|
736
|
-
return
|
|
939
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
737
940
|
}
|
|
738
941
|
}
|
|
739
942
|
return false;
|
|
@@ -746,6 +949,14 @@ const referenceNode = (node) => {
|
|
|
746
949
|
return (node && node['s-ol']) || node;
|
|
747
950
|
};
|
|
748
951
|
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
952
|
+
/**
|
|
953
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
954
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
955
|
+
* children of the two nodes (if any).
|
|
956
|
+
*
|
|
957
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
958
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
959
|
+
*/
|
|
749
960
|
const patch = (oldVNode, newVNode) => {
|
|
750
961
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
751
962
|
const oldChildren = oldVNode.$children$;
|
|
@@ -759,7 +970,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
759
970
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
760
971
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
761
972
|
}
|
|
762
|
-
// element node
|
|
763
973
|
{
|
|
764
974
|
if (tag === 'slot')
|
|
765
975
|
;
|
|
@@ -772,6 +982,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
772
982
|
}
|
|
773
983
|
if (oldChildren !== null && newChildren !== null) {
|
|
774
984
|
// looks like there's child vnodes for both the old and new vnodes
|
|
985
|
+
// so we need to call `updateChildren` to reconcile them
|
|
775
986
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
776
987
|
}
|
|
777
988
|
else if (newChildren !== null) {
|
|
@@ -812,7 +1023,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
812
1023
|
let nodeType;
|
|
813
1024
|
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
814
1025
|
childNode = childNodes[i];
|
|
815
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1026
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
816
1027
|
if (childNode['s-sr']) {
|
|
817
1028
|
// this is a slot fallback node
|
|
818
1029
|
// get the slot name for this slot reference node
|
|
@@ -824,7 +1035,7 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
824
1035
|
nodeType = childNodes[j].nodeType;
|
|
825
1036
|
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
826
1037
|
// this sibling node is from a different component OR is a named fallback slot node
|
|
827
|
-
if (nodeType === 1 /* ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1038
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
828
1039
|
childNode.hidden = true;
|
|
829
1040
|
break;
|
|
830
1041
|
}
|
|
@@ -833,8 +1044,8 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
833
1044
|
// this is a default fallback slot node
|
|
834
1045
|
// any element or text node (with content)
|
|
835
1046
|
// should hide the default fallback slot node
|
|
836
|
-
if (nodeType === 1 /* ElementNode */ ||
|
|
837
|
-
(nodeType === 3 /* TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1047
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1048
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
838
1049
|
childNode.hidden = true;
|
|
839
1050
|
break;
|
|
840
1051
|
}
|
|
@@ -912,13 +1123,13 @@ const relocateSlotContent = (elm) => {
|
|
|
912
1123
|
}
|
|
913
1124
|
}
|
|
914
1125
|
}
|
|
915
|
-
if (childNode.nodeType === 1 /* ElementNode */) {
|
|
1126
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
916
1127
|
relocateSlotContent(childNode);
|
|
917
1128
|
}
|
|
918
1129
|
}
|
|
919
1130
|
};
|
|
920
1131
|
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
921
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1132
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
922
1133
|
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
923
1134
|
return true;
|
|
924
1135
|
}
|
|
@@ -949,7 +1160,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
949
1160
|
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
950
1161
|
}
|
|
951
1162
|
rootVnode.$tag$ = null;
|
|
952
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1163
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
953
1164
|
hostRef.$vnode$ = rootVnode;
|
|
954
1165
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
955
1166
|
{
|
|
@@ -957,7 +1168,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
957
1168
|
}
|
|
958
1169
|
{
|
|
959
1170
|
contentRef = hostElm['s-cr'];
|
|
960
|
-
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
|
|
1171
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
961
1172
|
// always reset
|
|
962
1173
|
checkSlotFallbackVisibility = false;
|
|
963
1174
|
}
|
|
@@ -966,7 +1177,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
966
1177
|
{
|
|
967
1178
|
// while we're moving nodes around existing nodes, temporarily disable
|
|
968
1179
|
// the disconnectCallback from working
|
|
969
|
-
plt.$flags$ |= 1 /* isTmpDisconnected */;
|
|
1180
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
970
1181
|
if (checkSlotRelocate) {
|
|
971
1182
|
relocateSlotContent(rootVnode.$elm$);
|
|
972
1183
|
let relocateData;
|
|
@@ -1024,7 +1235,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1024
1235
|
}
|
|
1025
1236
|
else {
|
|
1026
1237
|
// this node doesn't have a slot home to go to, so let's hide it
|
|
1027
|
-
if (nodeToRelocate.nodeType === 1 /* ElementNode */) {
|
|
1238
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1028
1239
|
nodeToRelocate.hidden = true;
|
|
1029
1240
|
}
|
|
1030
1241
|
}
|
|
@@ -1035,37 +1246,11 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
1035
1246
|
}
|
|
1036
1247
|
// done moving nodes around
|
|
1037
1248
|
// allow the disconnect callback to work again
|
|
1038
|
-
plt.$flags$ &= ~1 /* isTmpDisconnected */;
|
|
1249
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1039
1250
|
// always reset
|
|
1040
1251
|
relocateNodes.length = 0;
|
|
1041
1252
|
}
|
|
1042
1253
|
};
|
|
1043
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
1044
|
-
const createEvent = (ref, name, flags) => {
|
|
1045
|
-
const elm = getElement(ref);
|
|
1046
|
-
return {
|
|
1047
|
-
emit: (detail) => {
|
|
1048
|
-
return emitEvent(elm, name, {
|
|
1049
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
1050
|
-
composed: !!(flags & 2 /* Composed */),
|
|
1051
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
1052
|
-
detail,
|
|
1053
|
-
});
|
|
1054
|
-
},
|
|
1055
|
-
};
|
|
1056
|
-
};
|
|
1057
|
-
/**
|
|
1058
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
1059
|
-
* @param elm the target of the Event
|
|
1060
|
-
* @param name the name to give the custom Event
|
|
1061
|
-
* @param opts options for configuring a custom Event
|
|
1062
|
-
* @returns the custom Event
|
|
1063
|
-
*/
|
|
1064
|
-
const emitEvent = (elm, name, opts) => {
|
|
1065
|
-
const ev = plt.ce(name, opts);
|
|
1066
|
-
elm.dispatchEvent(ev);
|
|
1067
|
-
return ev;
|
|
1068
|
-
};
|
|
1069
1254
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
1070
1255
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
1071
1256
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -1073,10 +1258,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
1073
1258
|
};
|
|
1074
1259
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
1075
1260
|
{
|
|
1076
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1261
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1077
1262
|
}
|
|
1078
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
1079
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1263
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1264
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
1080
1265
|
return;
|
|
1081
1266
|
}
|
|
1082
1267
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -1092,7 +1277,7 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
1092
1277
|
let promise;
|
|
1093
1278
|
if (isInitialLoad) {
|
|
1094
1279
|
{
|
|
1095
|
-
hostRef.$flags$ |= 256 /* isListenReady */;
|
|
1280
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1096
1281
|
if (hostRef.$queuedListeners$) {
|
|
1097
1282
|
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1098
1283
|
hostRef.$queuedListeners$ = null;
|
|
@@ -1135,7 +1320,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1135
1320
|
}
|
|
1136
1321
|
else {
|
|
1137
1322
|
Promise.all(childrenPromises).then(postUpdate);
|
|
1138
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1323
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
1139
1324
|
childrenPromises.length = 0;
|
|
1140
1325
|
}
|
|
1141
1326
|
}
|
|
@@ -1145,10 +1330,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
1145
1330
|
renderingRef = instance;
|
|
1146
1331
|
instance = instance.render && instance.render();
|
|
1147
1332
|
{
|
|
1148
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1333
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1149
1334
|
}
|
|
1150
1335
|
{
|
|
1151
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1336
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1152
1337
|
}
|
|
1153
1338
|
{
|
|
1154
1339
|
{
|
|
@@ -1177,8 +1362,8 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1177
1362
|
{
|
|
1178
1363
|
safeCall(instance, 'componentDidRender');
|
|
1179
1364
|
}
|
|
1180
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
1181
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
1365
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1366
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1182
1367
|
{
|
|
1183
1368
|
// DOM WRITE!
|
|
1184
1369
|
addHydratedFlag(elm);
|
|
@@ -1207,10 +1392,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
1207
1392
|
hostRef.$onRenderResolve$();
|
|
1208
1393
|
hostRef.$onRenderResolve$ = undefined;
|
|
1209
1394
|
}
|
|
1210
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1395
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1211
1396
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
1212
1397
|
}
|
|
1213
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1398
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
1214
1399
|
}
|
|
1215
1400
|
// ( •_•)
|
|
1216
1401
|
// ( •_•)>⌐■-■
|
|
@@ -1221,7 +1406,7 @@ const forceUpdate = (ref) => {
|
|
|
1221
1406
|
const hostRef = getHostRef(ref);
|
|
1222
1407
|
const isConnected = hostRef.$hostElement$.isConnected;
|
|
1223
1408
|
if (isConnected &&
|
|
1224
|
-
(hostRef.$flags$ & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1409
|
+
(hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1225
1410
|
scheduleUpdate(hostRef, false);
|
|
1226
1411
|
}
|
|
1227
1412
|
// Returns "true" when the forced update was successfully scheduled
|
|
@@ -1252,53 +1437,6 @@ const then = (promise, thenFn) => {
|
|
|
1252
1437
|
};
|
|
1253
1438
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
1254
1439
|
;
|
|
1255
|
-
/**
|
|
1256
|
-
* Parse a new property value for a given property type.
|
|
1257
|
-
*
|
|
1258
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
1259
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
1260
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
1261
|
-
* 2. the type stored from `propType`.
|
|
1262
|
-
*
|
|
1263
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
1264
|
-
*
|
|
1265
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
1266
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
1267
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
1268
|
-
* ```tsx
|
|
1269
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
1270
|
-
* ```
|
|
1271
|
-
*
|
|
1272
|
-
* HTML prop values on the other hand, will always a string
|
|
1273
|
-
*
|
|
1274
|
-
* @param propValue the new value to coerce to some type
|
|
1275
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
1276
|
-
* @returns the parsed/coerced value
|
|
1277
|
-
*/
|
|
1278
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
1279
|
-
// ensure this value is of the correct prop type
|
|
1280
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
1281
|
-
if (propType & 4 /* Boolean */) {
|
|
1282
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
1283
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1284
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1285
|
-
}
|
|
1286
|
-
if (propType & 2 /* Number */) {
|
|
1287
|
-
// force it to be a number
|
|
1288
|
-
return parseFloat(propValue);
|
|
1289
|
-
}
|
|
1290
|
-
if (propType & 1 /* String */) {
|
|
1291
|
-
// could have been passed as a number or boolean
|
|
1292
|
-
// but we still want it as a string
|
|
1293
|
-
return String(propValue);
|
|
1294
|
-
}
|
|
1295
|
-
// redundant return here for better minification
|
|
1296
|
-
return propValue;
|
|
1297
|
-
}
|
|
1298
|
-
// not sure exactly what type we want
|
|
1299
|
-
// so no need to change to a different type
|
|
1300
|
-
return propValue;
|
|
1301
|
-
};
|
|
1302
1440
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1303
1441
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1304
1442
|
// check our new property value against our internal value
|
|
@@ -1311,13 +1449,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1311
1449
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1312
1450
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1313
1451
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1314
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1452
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1315
1453
|
// gadzooks! the property's value has changed!!
|
|
1316
1454
|
// set our new value!
|
|
1317
1455
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1318
1456
|
if (instance) {
|
|
1319
1457
|
// get an array of method names of watch functions to call
|
|
1320
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1458
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
1321
1459
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
1322
1460
|
if (watchMethods) {
|
|
1323
1461
|
// this instance is watching for when this property changed
|
|
@@ -1332,7 +1470,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1332
1470
|
});
|
|
1333
1471
|
}
|
|
1334
1472
|
}
|
|
1335
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1473
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1336
1474
|
// looks like this value actually changed, so we've got work to do!
|
|
1337
1475
|
// but only if we've already rendered, otherwise just chill out
|
|
1338
1476
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1342,6 +1480,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1342
1480
|
}
|
|
1343
1481
|
}
|
|
1344
1482
|
};
|
|
1483
|
+
/**
|
|
1484
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1485
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1486
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1487
|
+
*
|
|
1488
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1489
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1490
|
+
* @param flags a number used to store a series of bit flags
|
|
1491
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1492
|
+
*/
|
|
1345
1493
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1346
1494
|
if (cmpMeta.$members$) {
|
|
1347
1495
|
if (Cstr.watchers) {
|
|
@@ -1351,8 +1499,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1351
1499
|
const members = Object.entries(cmpMeta.$members$);
|
|
1352
1500
|
const prototype = Cstr.prototype;
|
|
1353
1501
|
members.map(([memberName, [memberFlags]]) => {
|
|
1354
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1355
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1502
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1503
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1356
1504
|
// proxyComponent - prop
|
|
1357
1505
|
Object.defineProperty(prototype, memberName, {
|
|
1358
1506
|
get() {
|
|
@@ -1367,8 +1515,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1367
1515
|
enumerable: true,
|
|
1368
1516
|
});
|
|
1369
1517
|
}
|
|
1370
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
1371
|
-
memberFlags & 64 /* Method */) {
|
|
1518
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1519
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1372
1520
|
// proxyComponent - method
|
|
1373
1521
|
Object.defineProperty(prototype, memberName, {
|
|
1374
1522
|
value(...args) {
|
|
@@ -1378,7 +1526,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1378
1526
|
});
|
|
1379
1527
|
}
|
|
1380
1528
|
});
|
|
1381
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1529
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1382
1530
|
const attrNameToPropName = new Map();
|
|
1383
1531
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1384
1532
|
plt.jmp(() => {
|
|
@@ -1434,11 +1582,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1434
1582
|
// create an array of attributes to observe
|
|
1435
1583
|
// and also create a map of html attribute name to js property name
|
|
1436
1584
|
Cstr.observedAttributes = members
|
|
1437
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1585
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1438
1586
|
.map(([propName, m]) => {
|
|
1439
1587
|
const attrName = m[1] || propName;
|
|
1440
1588
|
attrNameToPropName.set(attrName, propName);
|
|
1441
|
-
if (m[0] & 512 /* ReflectAttr */) {
|
|
1589
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1442
1590
|
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1443
1591
|
}
|
|
1444
1592
|
return attrName;
|
|
@@ -1449,10 +1597,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1449
1597
|
};
|
|
1450
1598
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1451
1599
|
// initializeComponent
|
|
1452
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1600
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1453
1601
|
{
|
|
1454
1602
|
// we haven't initialized this element yet
|
|
1455
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1603
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1456
1604
|
// lazy loaded components
|
|
1457
1605
|
// request the component's implementation to be
|
|
1458
1606
|
// wired up with the host element
|
|
@@ -1470,7 +1618,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1470
1618
|
{
|
|
1471
1619
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1472
1620
|
}
|
|
1473
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1621
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1474
1622
|
Cstr.isProxied = true;
|
|
1475
1623
|
}
|
|
1476
1624
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1478,7 +1626,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1478
1626
|
// but let's keep track of when we start and stop
|
|
1479
1627
|
// so that the getters/setters don't incorrectly step on data
|
|
1480
1628
|
{
|
|
1481
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1629
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1482
1630
|
}
|
|
1483
1631
|
// construct the lazy-loaded component implementation
|
|
1484
1632
|
// passing the hostRef is very important during
|
|
@@ -1491,10 +1639,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1491
1639
|
consoleError(e);
|
|
1492
1640
|
}
|
|
1493
1641
|
{
|
|
1494
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1642
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1495
1643
|
}
|
|
1496
1644
|
{
|
|
1497
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1645
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
1498
1646
|
}
|
|
1499
1647
|
endNewInstance();
|
|
1500
1648
|
}
|
|
@@ -1504,7 +1652,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1504
1652
|
const scopeId = getScopeId(cmpMeta);
|
|
1505
1653
|
if (!styles.has(scopeId)) {
|
|
1506
1654
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1507
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1655
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1508
1656
|
endRegisterStyles();
|
|
1509
1657
|
}
|
|
1510
1658
|
}
|
|
@@ -1526,19 +1674,19 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1526
1674
|
}
|
|
1527
1675
|
};
|
|
1528
1676
|
const connectedCallback = (elm) => {
|
|
1529
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1677
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1530
1678
|
const hostRef = getHostRef(elm);
|
|
1531
1679
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1532
1680
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1533
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1681
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1534
1682
|
// first time this component has connected
|
|
1535
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1683
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1536
1684
|
{
|
|
1537
1685
|
// initUpdate
|
|
1538
1686
|
// if the slot polyfill is required we'll need to put some nodes
|
|
1539
1687
|
// in here to act as original content anchors as we move nodes around
|
|
1540
1688
|
// host element has been connected to the DOM
|
|
1541
|
-
if ((cmpMeta.$flags$ & (4 /* hasSlotRelocation */ | 8 /* needsShadowDomShim */))) {
|
|
1689
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1542
1690
|
setContentReference(elm);
|
|
1543
1691
|
}
|
|
1544
1692
|
}
|
|
@@ -1561,7 +1709,7 @@ const connectedCallback = (elm) => {
|
|
|
1561
1709
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1562
1710
|
if (cmpMeta.$members$) {
|
|
1563
1711
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1564
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1712
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1565
1713
|
const value = elm[memberName];
|
|
1566
1714
|
delete elm[memberName];
|
|
1567
1715
|
elm[memberName] = value;
|
|
@@ -1593,7 +1741,7 @@ const setContentReference = (elm) => {
|
|
|
1593
1741
|
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1594
1742
|
};
|
|
1595
1743
|
const disconnectedCallback = (elm) => {
|
|
1596
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1744
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1597
1745
|
const hostRef = getHostRef(elm);
|
|
1598
1746
|
const instance = hostRef.$lazyInstance$ ;
|
|
1599
1747
|
{
|
|
@@ -1648,7 +1796,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1648
1796
|
super(self);
|
|
1649
1797
|
self = this;
|
|
1650
1798
|
registerHost(self, cmpMeta);
|
|
1651
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1799
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1652
1800
|
// this component is using shadow dom
|
|
1653
1801
|
// and this browser supports shadow dom
|
|
1654
1802
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1683,7 +1831,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1683
1831
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1684
1832
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1685
1833
|
cmpTags.push(tagName);
|
|
1686
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1834
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1687
1835
|
}
|
|
1688
1836
|
});
|
|
1689
1837
|
});
|
|
@@ -1705,7 +1853,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1705
1853
|
// Fallback appLoad event
|
|
1706
1854
|
endBootstrap();
|
|
1707
1855
|
};
|
|
1708
|
-
const
|
|
1856
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1857
|
+
if (listeners) {
|
|
1858
|
+
listeners.map(([flags, name, method]) => {
|
|
1859
|
+
const target = elm;
|
|
1860
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1861
|
+
const opts = hostListenerOpts(flags);
|
|
1862
|
+
plt.ael(target, name, handler, opts);
|
|
1863
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
};
|
|
1867
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1868
|
+
try {
|
|
1869
|
+
{
|
|
1870
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1871
|
+
// instance is ready, let's call it's member method for this event
|
|
1872
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1873
|
+
}
|
|
1874
|
+
else {
|
|
1875
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
catch (e) {
|
|
1880
|
+
consoleError(e);
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
// prettier-ignore
|
|
1884
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1885
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1709
1886
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1710
1887
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1711
1888
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1750,14 +1927,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1750
1927
|
return importedModule[exportName];
|
|
1751
1928
|
}, consoleError);
|
|
1752
1929
|
};
|
|
1753
|
-
const styles = new Map();
|
|
1930
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1931
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1932
|
+
const doc = win.document || { head: {} };
|
|
1933
|
+
const plt = {
|
|
1934
|
+
$flags$: 0,
|
|
1935
|
+
$resourcesUrl$: '',
|
|
1936
|
+
jmp: (h) => h(),
|
|
1937
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1938
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1939
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1940
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1941
|
+
};
|
|
1942
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1943
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1944
|
+
try {
|
|
1945
|
+
new CSSStyleSheet();
|
|
1946
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1947
|
+
}
|
|
1948
|
+
catch (e) { }
|
|
1949
|
+
return false;
|
|
1950
|
+
})()
|
|
1951
|
+
;
|
|
1754
1952
|
const queueDomReads = [];
|
|
1755
1953
|
const queueDomWrites = [];
|
|
1756
1954
|
const queueTask = (queue, write) => (cb) => {
|
|
1757
1955
|
queue.push(cb);
|
|
1758
1956
|
if (!queuePending) {
|
|
1759
1957
|
queuePending = true;
|
|
1760
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1958
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1761
1959
|
nextTick(flush);
|
|
1762
1960
|
}
|
|
1763
1961
|
else {
|