@mgdis/mg-components 5.27.2 → 5.27.4

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.
Files changed (123) hide show
  1. package/dist/cjs/{index-00072168.js → index-11b35234.js} +76 -36
  2. package/dist/cjs/index-11b35234.js.map +1 -0
  3. package/dist/cjs/index-3198e64e.js +1688 -0
  4. package/dist/cjs/index-3198e64e.js.map +1 -0
  5. package/dist/cjs/loader.cjs.js +2 -2
  6. package/dist/cjs/mg-action-more_36.cjs.entry.js +270 -216
  7. package/dist/cjs/mg-action-more_36.cjs.entry.js.map +1 -1
  8. package/dist/cjs/mg-components.cjs.js +10 -10
  9. package/dist/cjs/mg-components.cjs.js.map +1 -1
  10. package/dist/cjs/mg-loader.cjs.entry.js +3 -3
  11. package/dist/collection/collection-manifest.json +1 -1
  12. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +124 -97
  13. package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js.map +1 -1
  14. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js +1 -0
  15. package/dist/collection/components/molecules/inputs/mg-input/mg-input.conf.js.map +1 -1
  16. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js +1 -1
  17. package/dist/collection/components/molecules/inputs/mg-input-checkbox/MgInputCheckboxList.js.map +1 -1
  18. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js.map +1 -1
  19. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +21 -3
  20. package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js.map +1 -1
  21. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +21 -18
  22. package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js.map +1 -1
  23. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +2 -1
  24. package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js.map +1 -1
  25. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js +4 -4
  26. package/dist/collection/components/molecules/mg-item-more/mg-item-more.js.map +1 -1
  27. package/dist/collection/components/molecules/mg-popover/mg-popover.js +6 -2
  28. package/dist/collection/components/molecules/mg-popover/mg-popover.js.map +1 -1
  29. package/dist/components/index.es.js +65 -25
  30. package/dist/components/index.es.js.map +1 -1
  31. package/dist/components/index2.js +2 -2
  32. package/dist/components/mg-action-more.js +2 -2
  33. package/dist/components/mg-badge2.js +3 -3
  34. package/dist/components/mg-button2.js +4 -4
  35. package/dist/components/mg-card2.js +2 -2
  36. package/dist/components/mg-details.js +2 -2
  37. package/dist/components/mg-form.js +3 -3
  38. package/dist/components/mg-icon2.js +2 -2
  39. package/dist/components/mg-illustrated-message.js +2 -2
  40. package/dist/components/mg-input-checkbox-paginated2.js +1 -1
  41. package/dist/components/mg-input-checkbox-paginated2.js.map +1 -1
  42. package/dist/components/mg-input-checkbox.js +25 -7
  43. package/dist/components/mg-input-checkbox.js.map +1 -1
  44. package/dist/components/mg-input-date.js +11 -11
  45. package/dist/components/mg-input-numeric.js +5 -5
  46. package/dist/components/mg-input-password.js +3 -3
  47. package/dist/components/mg-input-radio.js +4 -4
  48. package/dist/components/mg-input-select2.js +6 -6
  49. package/dist/components/mg-input-text2.js +6 -6
  50. package/dist/components/mg-input-textarea.js +6 -6
  51. package/dist/components/mg-input-title2.js +2 -2
  52. package/dist/components/mg-input-toggle.js +4 -4
  53. package/dist/components/mg-input2.js +4 -3
  54. package/dist/components/mg-input2.js.map +1 -1
  55. package/dist/components/mg-item-more2.js +26 -23
  56. package/dist/components/mg-item-more2.js.map +1 -1
  57. package/dist/components/mg-loader.js +2 -2
  58. package/dist/components/mg-menu-item2.js +8 -7
  59. package/dist/components/mg-menu-item2.js.map +1 -1
  60. package/dist/components/mg-message.js +3 -3
  61. package/dist/components/mg-modal.js +6 -6
  62. package/dist/components/mg-pagination2.js +2 -2
  63. package/dist/components/mg-panel.js +4 -4
  64. package/dist/components/mg-popover-content2.js +3 -3
  65. package/dist/components/mg-popover2.js +9 -5
  66. package/dist/components/mg-popover2.js.map +1 -1
  67. package/dist/components/mg-skip-links.js +2 -2
  68. package/dist/components/mg-tabs.js +6 -6
  69. package/dist/components/mg-tag.js +3 -3
  70. package/dist/components/mg-tooltip2.js +134 -107
  71. package/dist/components/mg-tooltip2.js.map +1 -1
  72. package/dist/esm/{index-8d5d1bfd.js → index-00abd8c1.js} +67 -27
  73. package/dist/esm/index-00abd8c1.js.map +1 -0
  74. package/dist/esm/index-99317ec3.js +1659 -0
  75. package/dist/esm/index-99317ec3.js.map +1 -0
  76. package/dist/esm/loader.js +3 -3
  77. package/dist/esm/mg-action-more_36.entry.js +270 -216
  78. package/dist/esm/mg-action-more_36.entry.js.map +1 -1
  79. package/dist/esm/mg-components.js +11 -11
  80. package/dist/esm/mg-components.js.map +1 -1
  81. package/dist/esm/mg-loader.entry.js +3 -3
  82. package/dist/mg-components/index.esm.js.map +1 -1
  83. package/dist/mg-components/mg-components.esm.js +1 -1
  84. package/dist/mg-components/mg-components.esm.js.map +1 -1
  85. package/dist/mg-components/p-48c0a0bf.entry.js +2 -0
  86. package/dist/mg-components/p-48c0a0bf.entry.js.map +1 -0
  87. package/dist/mg-components/p-4cfcbdc2.js +2 -0
  88. package/dist/mg-components/p-4cfcbdc2.js.map +1 -0
  89. package/dist/mg-components/p-815362e4.js +3 -0
  90. package/dist/mg-components/p-815362e4.js.map +1 -0
  91. package/dist/mg-components/{p-99e2f42a.entry.js → p-d3e15dd7.entry.js} +2 -2
  92. package/dist/mg-components/{p-99e2f42a.entry.js.map → p-d3e15dd7.entry.js.map} +1 -1
  93. package/dist/mg-components/p-e1255160.js.map +1 -1
  94. package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +25 -12
  95. package/dist/types/components/molecules/inputs/mg-input/mg-input.conf.d.ts +2 -1
  96. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -0
  97. package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +8 -0
  98. package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +1 -5
  99. package/dist/types/stencil-public-runtime.d.ts +3 -8
  100. package/ide/intellij/web-types.json +1 -1
  101. package/ide/vscode/html-custom-data.json +1 -1
  102. package/loader/cdn.js +1 -3
  103. package/loader/index.cjs.js +1 -3
  104. package/loader/index.es2017.js +1 -3
  105. package/loader/index.js +1 -3
  106. package/package.json +25 -25
  107. package/dist/cjs/index-00072168.js.map +0 -1
  108. package/dist/cjs/index-7e27c7ae.js +0 -2561
  109. package/dist/cjs/index-7e27c7ae.js.map +0 -1
  110. package/dist/esm/index-8d5d1bfd.js.map +0 -1
  111. package/dist/esm/index-e479d5ae.js +0 -2532
  112. package/dist/esm/index-e479d5ae.js.map +0 -1
  113. package/dist/esm/polyfills/core-js.js +0 -11
  114. package/dist/esm/polyfills/dom.js +0 -79
  115. package/dist/esm/polyfills/es5-html-element.js +0 -1
  116. package/dist/esm/polyfills/index.js +0 -34
  117. package/dist/esm/polyfills/system.js +0 -6
  118. package/dist/mg-components/p-7315d4a6.js +0 -3
  119. package/dist/mg-components/p-7315d4a6.js.map +0 -1
  120. package/dist/mg-components/p-8800813b.js +0 -2
  121. package/dist/mg-components/p-8800813b.js.map +0 -1
  122. package/dist/mg-components/p-f9ac8927.entry.js +0 -2
  123. package/dist/mg-components/p-f9ac8927.entry.js.map +0 -1
@@ -1,2532 +0,0 @@
1
- const NAMESPACE = 'mg-components';
2
- const BUILD = /* mg-components */ { allRenderFn: false, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: true, cmpShouldUpdate: true, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: true, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: true, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
3
-
4
- /**
5
- * Virtual DOM patching algorithm based on Snabbdom by
6
- * Simon Friis Vindum (@paldepind)
7
- * Licensed under the MIT License
8
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
9
- *
10
- * Modified for Stencil's renderer and slot projection
11
- */
12
- let scopeId;
13
- let contentRef;
14
- let hostTagName;
15
- let useNativeShadowDom = false;
16
- let checkSlotFallbackVisibility = false;
17
- let checkSlotRelocate = false;
18
- let isSvgMode = false;
19
- let queuePending = false;
20
- const createTime = (fnName, tagName = '') => {
21
- {
22
- return () => {
23
- return;
24
- };
25
- }
26
- };
27
- const uniqueTime = (key, measureText) => {
28
- {
29
- return () => {
30
- return;
31
- };
32
- }
33
- };
34
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
35
- /**
36
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
37
- *
38
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
39
- * support as of Stencil v4.
40
- */
41
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
42
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
43
- /**
44
- * Default style mode id
45
- */
46
- /**
47
- * Reusable empty obj/array
48
- * Don't add values to these!!
49
- */
50
- const EMPTY_OBJ = {};
51
- const isDef = (v) => v != null;
52
- /**
53
- * Check whether a value is a 'complex type', defined here as an object or a
54
- * function.
55
- *
56
- * @param o the value to check
57
- * @returns whether it's a complex type or not
58
- */
59
- const isComplexType = (o) => {
60
- // https://jsperf.com/typeof-fn-object/5
61
- o = typeof o;
62
- return o === 'object' || o === 'function';
63
- };
64
- /**
65
- * Helper method for querying a `meta` tag that contains a nonce value
66
- * out of a DOM's head.
67
- *
68
- * @param doc The DOM containing the `head` to query against
69
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
70
- * exists or the tag has no content.
71
- */
72
- function queryNonceMetaTagContent(doc) {
73
- var _a, _b, _c;
74
- 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;
75
- }
76
- /**
77
- * Production h() function based on Preact by
78
- * Jason Miller (@developit)
79
- * Licensed under the MIT License
80
- * https://github.com/developit/preact/blob/master/LICENSE
81
- *
82
- * Modified for Stencil's compiler and vdom
83
- */
84
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
85
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
86
- const h = (nodeName, vnodeData, ...children) => {
87
- let child = null;
88
- let key = null;
89
- let slotName = null;
90
- let simple = false;
91
- let lastSimple = false;
92
- const vNodeChildren = [];
93
- const walk = (c) => {
94
- for (let i = 0; i < c.length; i++) {
95
- child = c[i];
96
- if (Array.isArray(child)) {
97
- walk(child);
98
- }
99
- else if (child != null && typeof child !== 'boolean') {
100
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
101
- child = String(child);
102
- }
103
- if (simple && lastSimple) {
104
- // If the previous child was simple (string), we merge both
105
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
106
- }
107
- else {
108
- // Append a new vNode, if it's text, we create a text vNode
109
- vNodeChildren.push(simple ? newVNode(null, child) : child);
110
- }
111
- lastSimple = simple;
112
- }
113
- }
114
- };
115
- walk(children);
116
- if (vnodeData) {
117
- if (vnodeData.key) {
118
- key = vnodeData.key;
119
- }
120
- if (vnodeData.name) {
121
- slotName = vnodeData.name;
122
- }
123
- // normalize class / className attributes
124
- {
125
- const classData = vnodeData.className || vnodeData.class;
126
- if (classData) {
127
- vnodeData.class =
128
- typeof classData !== 'object'
129
- ? classData
130
- : Object.keys(classData)
131
- .filter((k) => classData[k])
132
- .join(' ');
133
- }
134
- }
135
- }
136
- if (typeof nodeName === 'function') {
137
- // nodeName is a functional component
138
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
139
- }
140
- const vnode = newVNode(nodeName, null);
141
- vnode.$attrs$ = vnodeData;
142
- if (vNodeChildren.length > 0) {
143
- vnode.$children$ = vNodeChildren;
144
- }
145
- {
146
- vnode.$key$ = key;
147
- }
148
- {
149
- vnode.$name$ = slotName;
150
- }
151
- return vnode;
152
- };
153
- /**
154
- * A utility function for creating a virtual DOM node from a tag and some
155
- * possible text content.
156
- *
157
- * @param tag the tag for this element
158
- * @param text possible text content for the node
159
- * @returns a newly-minted virtual DOM node
160
- */
161
- const newVNode = (tag, text) => {
162
- const vnode = {
163
- $flags$: 0,
164
- $tag$: tag,
165
- $text$: text,
166
- $elm$: null,
167
- $children$: null,
168
- };
169
- {
170
- vnode.$attrs$ = null;
171
- }
172
- {
173
- vnode.$key$ = null;
174
- }
175
- {
176
- vnode.$name$ = null;
177
- }
178
- return vnode;
179
- };
180
- const Host = {};
181
- /**
182
- * Check whether a given node is a Host node or not
183
- *
184
- * @param node the virtual DOM node to check
185
- * @returns whether it's a Host node or not
186
- */
187
- const isHost = (node) => node && node.$tag$ === Host;
188
- /**
189
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
190
- *
191
- * Note that these functions convert from {@link d.VNode} to
192
- * {@link d.ChildNode} to give functional component developers a friendly
193
- * interface.
194
- */
195
- const vdomFnUtils = {
196
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
197
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
198
- };
199
- /**
200
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
201
- * friendlier public interface (hence, 'convertToPublic').
202
- *
203
- * @param node the virtual DOM node to convert
204
- * @returns a converted child node
205
- */
206
- const convertToPublic = (node) => ({
207
- vattrs: node.$attrs$,
208
- vchildren: node.$children$,
209
- vkey: node.$key$,
210
- vname: node.$name$,
211
- vtag: node.$tag$,
212
- vtext: node.$text$,
213
- });
214
- /**
215
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
216
- * order to use the resulting object in the virtual DOM. The initial object was
217
- * likely created as part of presenting a public API, so converting it back
218
- * involved making it 'private' again (hence, `convertToPrivate`).
219
- *
220
- * @param node the child node to convert
221
- * @returns a converted virtual DOM node
222
- */
223
- const convertToPrivate = (node) => {
224
- if (typeof node.vtag === 'function') {
225
- const vnodeData = Object.assign({}, node.vattrs);
226
- if (node.vkey) {
227
- vnodeData.key = node.vkey;
228
- }
229
- if (node.vname) {
230
- vnodeData.name = node.vname;
231
- }
232
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
233
- }
234
- const vnode = newVNode(node.vtag, node.vtext);
235
- vnode.$attrs$ = node.vattrs;
236
- vnode.$children$ = node.vchildren;
237
- vnode.$key$ = node.vkey;
238
- vnode.$name$ = node.vname;
239
- return vnode;
240
- };
241
- /**
242
- * Parse a new property value for a given property type.
243
- *
244
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
245
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
246
- * 1. `any`, the type given to `propValue` in the function signature
247
- * 2. the type stored from `propType`.
248
- *
249
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
250
- *
251
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
252
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
253
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
254
- * ```tsx
255
- * <my-cmp prop-val={0}></my-cmp>
256
- * ```
257
- *
258
- * HTML prop values on the other hand, will always a string
259
- *
260
- * @param propValue the new value to coerce to some type
261
- * @param propType the type of the prop, expressed as a binary number
262
- * @returns the parsed/coerced value
263
- */
264
- const parsePropertyValue = (propValue, propType) => {
265
- // ensure this value is of the correct prop type
266
- if (propValue != null && !isComplexType(propValue)) {
267
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
268
- // per the HTML spec, any string value means it is a boolean true value
269
- // but we'll cheat here and say that the string "false" is the boolean false
270
- return propValue === 'false' ? false : propValue === '' || !!propValue;
271
- }
272
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
273
- // force it to be a number
274
- return parseFloat(propValue);
275
- }
276
- if (propType & 1 /* MEMBER_FLAGS.String */) {
277
- // could have been passed as a number or boolean
278
- // but we still want it as a string
279
- return String(propValue);
280
- }
281
- // redundant return here for better minification
282
- return propValue;
283
- }
284
- // not sure exactly what type we want
285
- // so no need to change to a different type
286
- return propValue;
287
- };
288
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
289
- const createEvent = (ref, name, flags) => {
290
- const elm = getElement(ref);
291
- return {
292
- emit: (detail) => {
293
- return emitEvent(elm, name, {
294
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
295
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
296
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
297
- detail,
298
- });
299
- },
300
- };
301
- };
302
- /**
303
- * Helper function to create & dispatch a custom Event on a provided target
304
- * @param elm the target of the Event
305
- * @param name the name to give the custom Event
306
- * @param opts options for configuring a custom Event
307
- * @returns the custom Event
308
- */
309
- const emitEvent = (elm, name, opts) => {
310
- const ev = plt.ce(name, opts);
311
- elm.dispatchEvent(ev);
312
- return ev;
313
- };
314
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
315
- const registerStyle = (scopeId, cssText, allowCS) => {
316
- let style = styles.get(scopeId);
317
- if (supportsConstructableStylesheets && allowCS) {
318
- style = (style || new CSSStyleSheet());
319
- if (typeof style === 'string') {
320
- style = cssText;
321
- }
322
- else {
323
- style.replaceSync(cssText);
324
- }
325
- }
326
- else {
327
- style = cssText;
328
- }
329
- styles.set(scopeId, style);
330
- };
331
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
332
- var _a;
333
- const scopeId = getScopeId(cmpMeta);
334
- const style = styles.get(scopeId);
335
- // if an element is NOT connected then getRootNode() will return the wrong root node
336
- // so the fallback is to always use the document for the root node in those cases
337
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
338
- if (style) {
339
- if (typeof style === 'string') {
340
- styleContainerNode = styleContainerNode.head || styleContainerNode;
341
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
342
- let styleElm;
343
- if (!appliedStyles) {
344
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
345
- }
346
- if (!appliedStyles.has(scopeId)) {
347
- {
348
- styleElm = doc.createElement('style');
349
- styleElm.innerHTML = style;
350
- // Apply CSP nonce to the style tag if it exists
351
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
352
- if (nonce != null) {
353
- styleElm.setAttribute('nonce', nonce);
354
- }
355
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
356
- }
357
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
358
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
359
- styleElm.innerHTML += SLOT_FB_CSS;
360
- }
361
- if (appliedStyles) {
362
- appliedStyles.add(scopeId);
363
- }
364
- }
365
- }
366
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
367
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
368
- }
369
- }
370
- return scopeId;
371
- };
372
- const attachStyles = (hostRef) => {
373
- const cmpMeta = hostRef.$cmpMeta$;
374
- const elm = hostRef.$hostElement$;
375
- const flags = cmpMeta.$flags$;
376
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
377
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
378
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
379
- // only required when we're NOT using native shadow dom (slot)
380
- // or this browser doesn't support native shadow dom
381
- // and this host element was NOT created with SSR
382
- // let's pick out the inner content for slot projection
383
- // create a node to represent where the original
384
- // content was first placed, which is useful later on
385
- // DOM WRITE!!
386
- elm['s-sc'] = scopeId;
387
- elm.classList.add(scopeId + '-h');
388
- if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
389
- elm.classList.add(scopeId + '-s');
390
- }
391
- }
392
- endAttachStyles();
393
- };
394
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
395
- /**
396
- * Production setAccessor() function based on Preact by
397
- * Jason Miller (@developit)
398
- * Licensed under the MIT License
399
- * https://github.com/developit/preact/blob/master/LICENSE
400
- *
401
- * Modified for Stencil's compiler and vdom
402
- */
403
- /**
404
- * When running a VDom render set properties present on a VDom node onto the
405
- * corresponding HTML element.
406
- *
407
- * Note that this function has special functionality for the `class`,
408
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
409
- * `onClick`, etc). All others are just passed through as-is.
410
- *
411
- * @param elm the HTMLElement onto which attributes should be set
412
- * @param memberName the name of the attribute to set
413
- * @param oldValue the old value for the attribute
414
- * @param newValue the new value for the attribute
415
- * @param isSvg whether we're in an svg context or not
416
- * @param flags bitflags for Vdom variables
417
- */
418
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
419
- if (oldValue !== newValue) {
420
- let isProp = isMemberInElement(elm, memberName);
421
- let ln = memberName.toLowerCase();
422
- if (memberName === 'class') {
423
- const classList = elm.classList;
424
- const oldClasses = parseClassList(oldValue);
425
- const newClasses = parseClassList(newValue);
426
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
427
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
428
- }
429
- else if (memberName === 'style') {
430
- // update style attribute, css properties and values
431
- {
432
- for (const prop in oldValue) {
433
- if (!newValue || newValue[prop] == null) {
434
- if (prop.includes('-')) {
435
- elm.style.removeProperty(prop);
436
- }
437
- else {
438
- elm.style[prop] = '';
439
- }
440
- }
441
- }
442
- }
443
- for (const prop in newValue) {
444
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
445
- if (prop.includes('-')) {
446
- elm.style.setProperty(prop, newValue[prop]);
447
- }
448
- else {
449
- elm.style[prop] = newValue[prop];
450
- }
451
- }
452
- }
453
- }
454
- else if (memberName === 'key')
455
- ;
456
- else if (memberName === 'ref') {
457
- // minifier will clean this up
458
- if (newValue) {
459
- newValue(elm);
460
- }
461
- }
462
- else if ((!isProp ) &&
463
- memberName[0] === 'o' &&
464
- memberName[1] === 'n') {
465
- // Event Handlers
466
- // so if the member name starts with "on" and the 3rd characters is
467
- // a capital letter, and it's not already a member on the element,
468
- // then we're assuming it's an event listener
469
- if (memberName[2] === '-') {
470
- // on- prefixed events
471
- // allows to be explicit about the dom event to listen without any magic
472
- // under the hood:
473
- // <my-cmp on-click> // listens for "click"
474
- // <my-cmp on-Click> // listens for "Click"
475
- // <my-cmp on-ionChange> // listens for "ionChange"
476
- // <my-cmp on-EVENTS> // listens for "EVENTS"
477
- memberName = memberName.slice(3);
478
- }
479
- else if (isMemberInElement(win, ln)) {
480
- // standard event
481
- // the JSX attribute could have been "onMouseOver" and the
482
- // member name "onmouseover" is on the window's prototype
483
- // so let's add the listener "mouseover", which is all lowercased
484
- memberName = ln.slice(2);
485
- }
486
- else {
487
- // custom event
488
- // the JSX attribute could have been "onMyCustomEvent"
489
- // so let's trim off the "on" prefix and lowercase the first character
490
- // and add the listener "myCustomEvent"
491
- // except for the first character, we keep the event name case
492
- memberName = ln[2] + memberName.slice(3);
493
- }
494
- if (oldValue || newValue) {
495
- // Need to account for "capture" events.
496
- // If the event name ends with "Capture", we'll update the name to remove
497
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
498
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
499
- // Make sure we only replace the last instance of "Capture"
500
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
501
- if (oldValue) {
502
- plt.rel(elm, memberName, oldValue, capture);
503
- }
504
- if (newValue) {
505
- plt.ael(elm, memberName, newValue, capture);
506
- }
507
- }
508
- }
509
- else {
510
- // Set property if it exists and it's not a SVG
511
- const isComplex = isComplexType(newValue);
512
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
513
- try {
514
- if (!elm.tagName.includes('-')) {
515
- const n = newValue == null ? '' : newValue;
516
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
517
- if (memberName === 'list') {
518
- isProp = false;
519
- }
520
- else if (oldValue == null || elm[memberName] != n) {
521
- elm[memberName] = n;
522
- }
523
- }
524
- else {
525
- elm[memberName] = newValue;
526
- }
527
- }
528
- catch (e) {
529
- /**
530
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
531
- */
532
- }
533
- }
534
- /**
535
- * Need to manually update attribute if:
536
- * - memberName is not an attribute
537
- * - if we are rendering the host element in order to reflect attribute
538
- * - if it's a SVG, since properties might not work in <svg>
539
- * - if the newValue is null/undefined or 'false'.
540
- */
541
- let xlink = false;
542
- {
543
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
544
- memberName = ln;
545
- xlink = true;
546
- }
547
- }
548
- if (newValue == null || newValue === false) {
549
- if (newValue !== false || elm.getAttribute(memberName) === '') {
550
- if (xlink) {
551
- elm.removeAttributeNS(XLINK_NS, memberName);
552
- }
553
- else {
554
- elm.removeAttribute(memberName);
555
- }
556
- }
557
- }
558
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
559
- newValue = newValue === true ? '' : newValue;
560
- if (xlink) {
561
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
562
- }
563
- else {
564
- elm.setAttribute(memberName, newValue);
565
- }
566
- }
567
- }
568
- }
569
- };
570
- const parseClassListRegex = /\s/;
571
- /**
572
- * Parsed a string of classnames into an array
573
- * @param value className string, e.g. "foo bar baz"
574
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
575
- */
576
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
577
- const CAPTURE_EVENT_SUFFIX = 'Capture';
578
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
579
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
580
- // if the element passed in is a shadow root, which is a document fragment
581
- // then we want to be adding attrs/props to the shadow root's "host" element
582
- // if it's not a shadow root, then we add attrs/props to the same element
583
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
584
- ? newVnode.$elm$.host
585
- : newVnode.$elm$;
586
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
587
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
588
- {
589
- // remove attributes no longer present on the vnode by setting them to undefined
590
- for (memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
591
- if (!(memberName in newVnodeAttrs)) {
592
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
593
- }
594
- }
595
- }
596
- // add new & update changed attributes
597
- for (memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
598
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
599
- }
600
- };
601
- /**
602
- * Sort a list of attribute names to ensure that all the attribute names which
603
- * are _not_ `"ref"` come before `"ref"`. Preserve the order of the non-ref
604
- * attributes.
605
- *
606
- * **Note**: if the supplied attributes do not include `'ref'` then the same
607
- * (by reference) array will be returned without modification.
608
- *
609
- * @param attrNames attribute names to sort
610
- * @returns a list of attribute names, sorted if they include `"ref"`
611
- */
612
- function sortedAttrNames(attrNames) {
613
- return attrNames.includes('ref')
614
- ? // we need to sort these to ensure that `'ref'` is the last attr
615
- [...attrNames.filter((attr) => attr !== 'ref'), 'ref']
616
- : // no need to sort, return the original array
617
- attrNames;
618
- }
619
- /**
620
- * Create a DOM Node corresponding to one of the children of a given VNode.
621
- *
622
- * @param oldParentVNode the parent VNode from the previous render
623
- * @param newParentVNode the parent VNode from the current render
624
- * @param childIndex the index of the VNode, in the _new_ parent node's
625
- * children, for which we will create a new DOM node
626
- * @param parentElm the parent DOM node which our new node will be a child of
627
- * @returns the newly created node
628
- */
629
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
630
- var _a;
631
- // tslint:disable-next-line: prefer-const
632
- const newVNode = newParentVNode.$children$[childIndex];
633
- let i = 0;
634
- let elm;
635
- let childNode;
636
- let oldVNode;
637
- if (!useNativeShadowDom) {
638
- // remember for later we need to check to relocate nodes
639
- checkSlotRelocate = true;
640
- if (newVNode.$tag$ === 'slot') {
641
- if (scopeId) {
642
- // scoped css needs to add its scoped id to the parent element
643
- parentElm.classList.add(scopeId + '-s');
644
- }
645
- newVNode.$flags$ |= newVNode.$children$
646
- ? // slot element has fallback content
647
- 2 /* VNODE_FLAGS.isSlotFallback */
648
- : // slot element does not have fallback content
649
- 1 /* VNODE_FLAGS.isSlotReference */;
650
- }
651
- }
652
- if (newVNode.$text$ !== null) {
653
- // create text node
654
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
655
- }
656
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
657
- // create a slot reference node
658
- elm = newVNode.$elm$ =
659
- doc.createTextNode('');
660
- }
661
- else {
662
- // create element
663
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
664
- ? 'slot-fb'
665
- : newVNode.$tag$));
666
- // add css classes, attrs, props, listeners, etc.
667
- {
668
- updateElement(null, newVNode, isSvgMode);
669
- }
670
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
671
- // if there is a scopeId and this is the initial render
672
- // then let's add the scopeId as a css class
673
- elm.classList.add((elm['s-si'] = scopeId));
674
- }
675
- if (newVNode.$children$) {
676
- for (i = 0; i < newVNode.$children$.length; ++i) {
677
- // create the node
678
- childNode = createElm(oldParentVNode, newVNode, i, elm);
679
- // return node could have been null
680
- if (childNode) {
681
- // append our new node
682
- elm.appendChild(childNode);
683
- }
684
- }
685
- }
686
- }
687
- // This needs to always happen so we can hide nodes that are projected
688
- // to another component but don't end up in a slot
689
- elm['s-hn'] = hostTagName;
690
- {
691
- if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
692
- // remember the content reference comment
693
- elm['s-sr'] = true;
694
- // remember the content reference comment
695
- elm['s-cr'] = contentRef;
696
- // remember the slot name, or empty string for default slot
697
- elm['s-sn'] = newVNode.$name$ || '';
698
- // remember the ref callback function
699
- elm['s-rf'] = (_a = newVNode.$attrs$) === null || _a === void 0 ? void 0 : _a.ref;
700
- // check if we've got an old vnode for this slot
701
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
702
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
703
- {
704
- // we've got an old slot vnode and the wrapper is being replaced
705
- // so let's move the old slot content back to its original location
706
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
707
- }
708
- }
709
- }
710
- }
711
- return elm;
712
- };
713
- const putBackInOriginalLocation = (parentElm, recursive) => {
714
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
715
- const oldSlotChildNodes = Array.from(parentElm.childNodes);
716
- if (parentElm['s-sr'] && BUILD.experimentalSlotFixes) {
717
- let node = parentElm;
718
- while ((node = node.nextSibling)) {
719
- if (node && node['s-sn'] === parentElm['s-sn'] && node['s-sh'] === hostTagName) {
720
- oldSlotChildNodes.push(node);
721
- }
722
- }
723
- }
724
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
725
- const childNode = oldSlotChildNodes[i];
726
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
727
- // and relocate it back to it's original location
728
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
729
- // remove the old original location comment entirely
730
- // later on the patch function will know what to do
731
- // and move this to the correct spot if need be
732
- childNode['s-ol'].remove();
733
- childNode['s-ol'] = undefined;
734
- // Reset so we can correctly move the node around again.
735
- childNode['s-sh'] = undefined;
736
- checkSlotRelocate = true;
737
- }
738
- if (recursive) {
739
- putBackInOriginalLocation(childNode, recursive);
740
- }
741
- }
742
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
743
- };
744
- /**
745
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
746
- * add them to the DOM in the appropriate place.
747
- *
748
- * @param parentElm the DOM node which should be used as a parent for the new
749
- * DOM nodes
750
- * @param before a child of the `parentElm` which the new children should be
751
- * inserted before (optional)
752
- * @param parentVNode the parent virtual DOM node
753
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
754
- * @param startIdx the index in the child virtual DOM nodes at which to start
755
- * creating DOM nodes (inclusive)
756
- * @param endIdx the index in the child virtual DOM nodes at which to stop
757
- * creating DOM nodes (inclusive)
758
- */
759
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
760
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
761
- let childNode;
762
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
763
- containerElm = containerElm.shadowRoot;
764
- }
765
- for (; startIdx <= endIdx; ++startIdx) {
766
- if (vnodes[startIdx]) {
767
- childNode = createElm(null, parentVNode, startIdx, parentElm);
768
- if (childNode) {
769
- vnodes[startIdx].$elm$ = childNode;
770
- containerElm.insertBefore(childNode, referenceNode(before) );
771
- }
772
- }
773
- }
774
- };
775
- /**
776
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
777
- * This can be used to, for instance, clean up after a list of children which
778
- * should no longer be shown.
779
- *
780
- * This function also handles some of Stencil's slot relocation logic.
781
- *
782
- * @param vnodes a list of virtual DOM nodes to remove
783
- * @param startIdx the index at which to start removing nodes (inclusive)
784
- * @param endIdx the index at which to stop removing nodes (inclusive)
785
- */
786
- const removeVnodes = (vnodes, startIdx, endIdx) => {
787
- for (let index = startIdx; index <= endIdx; ++index) {
788
- const vnode = vnodes[index];
789
- if (vnode) {
790
- const elm = vnode.$elm$;
791
- nullifyVNodeRefs(vnode);
792
- if (elm) {
793
- {
794
- // we're removing this element
795
- // so it's possible we need to show slot fallback content now
796
- checkSlotFallbackVisibility = true;
797
- if (elm['s-ol']) {
798
- // remove the original location comment
799
- elm['s-ol'].remove();
800
- }
801
- else {
802
- // it's possible that child nodes of the node
803
- // that's being removed are slot nodes
804
- putBackInOriginalLocation(elm, true);
805
- }
806
- }
807
- // remove the vnode's element from the dom
808
- elm.remove();
809
- }
810
- }
811
- }
812
- };
813
- /**
814
- * Reconcile the children of a new VNode with the children of an old VNode by
815
- * traversing the two collections of children, identifying nodes that are
816
- * conserved or changed, calling out to `patch` to make any necessary
817
- * updates to the DOM, and rearranging DOM nodes as needed.
818
- *
819
- * The algorithm for reconciling children works by analyzing two 'windows' onto
820
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
821
- * 'windows' by storing start and end indices and references to the
822
- * corresponding array entries. Initially the two 'windows' are basically equal
823
- * to the entire array, but we progressively narrow the windows until there are
824
- * no children left to update by doing the following:
825
- *
826
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
827
- * that if we have an initial array like the following we'll end up dealing
828
- * only with a window bounded by the highlighted elements:
829
- *
830
- * [null, null, VNode1 , ... , VNode2, null, null]
831
- * ^^^^^^ ^^^^^^
832
- *
833
- * 2. Check to see if the elements at the head and tail positions are equal
834
- * across the windows. This will basically detect elements which haven't
835
- * been added, removed, or changed position, i.e. if you had the following
836
- * VNode elements (represented as HTML):
837
- *
838
- * oldVNode: `<div><p><span>HEY</span></p></div>`
839
- * newVNode: `<div><p><span>THERE</span></p></div>`
840
- *
841
- * Then when comparing the children of the `<div>` tag we check the equality
842
- * of the VNodes corresponding to the `<p>` tags and, since they are the
843
- * same tag in the same position, we'd be able to avoid completely
844
- * re-rendering the subtree under them with a new DOM element and would just
845
- * call out to `patch` to handle reconciling their children and so on.
846
- *
847
- * 3. Check, for both windows, to see if the element at the beginning of the
848
- * window corresponds to the element at the end of the other window. This is
849
- * a heuristic which will let us identify _some_ situations in which
850
- * elements have changed position, for instance it _should_ detect that the
851
- * children nodes themselves have not changed but merely moved in the
852
- * following example:
853
- *
854
- * oldVNode: `<div><element-one /><element-two /></div>`
855
- * newVNode: `<div><element-two /><element-one /></div>`
856
- *
857
- * If we find cases like this then we also need to move the concrete DOM
858
- * elements corresponding to the moved children to write the re-order to the
859
- * DOM.
860
- *
861
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
862
- * nodes in the old children which have the same key as the first element in
863
- * our window on the new children. If we find such a node we handle calling
864
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
865
- * what we find.
866
- *
867
- * Finally, once we've narrowed our 'windows' to the point that either of them
868
- * collapse (i.e. they have length 0) we then handle any remaining VNode
869
- * insertion or deletion that needs to happen to get a DOM state that correctly
870
- * reflects the new child VNodes. If, for instance, after our window on the old
871
- * children has collapsed we still have more nodes on the new children that
872
- * we haven't dealt with yet then we need to add them, or if the new children
873
- * collapse but we still have unhandled _old_ children then we need to make
874
- * sure the corresponding DOM nodes are removed.
875
- *
876
- * @param parentElm the node into which the parent VNode is rendered
877
- * @param oldCh the old children of the parent node
878
- * @param newVNode the new VNode which will replace the parent
879
- * @param newCh the new children of the parent node
880
- * @param isInitialRender whether or not this is the first render of the vdom
881
- */
882
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
883
- let oldStartIdx = 0;
884
- let newStartIdx = 0;
885
- let idxInOld = 0;
886
- let i = 0;
887
- let oldEndIdx = oldCh.length - 1;
888
- let oldStartVnode = oldCh[0];
889
- let oldEndVnode = oldCh[oldEndIdx];
890
- let newEndIdx = newCh.length - 1;
891
- let newStartVnode = newCh[0];
892
- let newEndVnode = newCh[newEndIdx];
893
- let node;
894
- let elmToMove;
895
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
896
- if (oldStartVnode == null) {
897
- // VNode might have been moved left
898
- oldStartVnode = oldCh[++oldStartIdx];
899
- }
900
- else if (oldEndVnode == null) {
901
- oldEndVnode = oldCh[--oldEndIdx];
902
- }
903
- else if (newStartVnode == null) {
904
- newStartVnode = newCh[++newStartIdx];
905
- }
906
- else if (newEndVnode == null) {
907
- newEndVnode = newCh[--newEndIdx];
908
- }
909
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
910
- // if the start nodes are the same then we should patch the new VNode
911
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
912
- // indices to reflect that. We don't need to move any DOM Nodes around
913
- // since things are matched up in order.
914
- patch(oldStartVnode, newStartVnode, isInitialRender);
915
- oldStartVnode = oldCh[++oldStartIdx];
916
- newStartVnode = newCh[++newStartIdx];
917
- }
918
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
919
- // likewise, if the end nodes are the same we patch new onto old and
920
- // decrement our end indices, and also likewise in this case we don't
921
- // need to move any DOM Nodes.
922
- patch(oldEndVnode, newEndVnode, isInitialRender);
923
- oldEndVnode = oldCh[--oldEndIdx];
924
- newEndVnode = newCh[--newEndIdx];
925
- }
926
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
927
- // case: "Vnode moved right"
928
- //
929
- // We've found that the last node in our window on the new children is
930
- // the same VNode as the _first_ node in our window on the old children
931
- // we're dealing with now. Visually, this is the layout of these two
932
- // nodes:
933
- //
934
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
935
- // ^^^^^^^^^^^
936
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
937
- // ^^^^^^^^^^^^^
938
- //
939
- // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
940
- // and move the DOM element for `oldStartVnode`.
941
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
942
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
943
- }
944
- patch(oldStartVnode, newEndVnode, isInitialRender);
945
- // We need to move the element for `oldStartVnode` into a position which
946
- // will be appropriate for `newEndVnode`. For this we can use
947
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
948
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
949
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
950
- //
951
- // <old-start-node />
952
- // <some-intervening-node />
953
- // <old-end-node />
954
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
955
- // <next-sibling />
956
- //
957
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
958
- // the node for `oldStartVnode` at the end of the children of
959
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
960
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
961
- // append it to the children of the parent element.
962
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
963
- oldStartVnode = oldCh[++oldStartIdx];
964
- newEndVnode = newCh[--newEndIdx];
965
- }
966
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
967
- // case: "Vnode moved left"
968
- //
969
- // We've found that the first node in our window on the new children is
970
- // the same VNode as the _last_ node in our window on the old children.
971
- // Visually, this is the layout of these two nodes:
972
- //
973
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
974
- // ^^^^^^^^^^^^^
975
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
976
- // ^^^^^^^^^^^
977
- //
978
- // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
979
- // (which will handle updating any changed attributes, reconciling their
980
- // children etc) but we also need to move the DOM node to which
981
- // `oldEndVnode` corresponds.
982
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
983
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
984
- }
985
- patch(oldEndVnode, newStartVnode, isInitialRender);
986
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
987
- // the same node, so since we're here we know that they are not. Thus we
988
- // can move the element for `oldEndVnode` _before_ the element for
989
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
990
- // future.
991
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
992
- oldEndVnode = oldCh[--oldEndIdx];
993
- newStartVnode = newCh[++newStartIdx];
994
- }
995
- else {
996
- // Here we do some checks to match up old and new nodes based on the
997
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
998
- // in the JSX for a DOM element in the implementation of a Stencil
999
- // component.
1000
- //
1001
- // First we check to see if there are any nodes in the array of old
1002
- // children which have the same key as the first node in the new
1003
- // children.
1004
- idxInOld = -1;
1005
- {
1006
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1007
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1008
- idxInOld = i;
1009
- break;
1010
- }
1011
- }
1012
- }
1013
- if (idxInOld >= 0) {
1014
- // We found a node in the old children which matches up with the first
1015
- // node in the new children! So let's deal with that
1016
- elmToMove = oldCh[idxInOld];
1017
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1018
- // the tag doesn't match so we'll need a new DOM element
1019
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1020
- }
1021
- else {
1022
- patch(elmToMove, newStartVnode, isInitialRender);
1023
- // invalidate the matching old node so that we won't try to update it
1024
- // again later on
1025
- oldCh[idxInOld] = undefined;
1026
- node = elmToMove.$elm$;
1027
- }
1028
- newStartVnode = newCh[++newStartIdx];
1029
- }
1030
- else {
1031
- // We either didn't find an element in the old children that matches
1032
- // the key of the first new child OR the build is not using `key`
1033
- // attributes at all. In either case we need to create a new element
1034
- // for the new node.
1035
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1036
- newStartVnode = newCh[++newStartIdx];
1037
- }
1038
- if (node) {
1039
- // if we created a new node then handle inserting it to the DOM
1040
- {
1041
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1042
- }
1043
- }
1044
- }
1045
- }
1046
- if (oldStartIdx > oldEndIdx) {
1047
- // we have some more new nodes to add which don't match up with old nodes
1048
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1049
- }
1050
- else if (newStartIdx > newEndIdx) {
1051
- // there are nodes in the `oldCh` array which no longer correspond to nodes
1052
- // in the new array, so lets remove them (which entails cleaning up the
1053
- // relevant DOM nodes)
1054
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1055
- }
1056
- };
1057
- /**
1058
- * Compare two VNodes to determine if they are the same
1059
- *
1060
- * **NB**: This function is an equality _heuristic_ based on the available
1061
- * information set on the two VNodes and can be misleading under certain
1062
- * circumstances. In particular, if the two nodes do not have `key` attrs
1063
- * (available under `$key$` on VNodes) then the function falls back on merely
1064
- * checking that they have the same tag.
1065
- *
1066
- * So, in other words, if `key` attrs are not set on VNodes which may be
1067
- * changing order within a `children` array or something along those lines then
1068
- * we could obtain a false negative and then have to do needless re-rendering
1069
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1070
- *
1071
- * @param leftVNode the first VNode to check
1072
- * @param rightVNode the second VNode to check
1073
- * @param isInitialRender whether or not this is the first render of the vdom
1074
- * @returns whether they're equal or not
1075
- */
1076
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1077
- // compare if two vnode to see if they're "technically" the same
1078
- // need to have the same element tag, and same key to be the same
1079
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1080
- if (leftVNode.$tag$ === 'slot') {
1081
- return leftVNode.$name$ === rightVNode.$name$;
1082
- }
1083
- // this will be set if JSX tags in the build have `key` attrs set on them
1084
- // we only want to check this if we're not on the first render since on
1085
- // first render `leftVNode.$key$` will always be `null`, so we can be led
1086
- // astray and, for instance, accidentally delete a DOM node that we want to
1087
- // keep around.
1088
- if (!isInitialRender) {
1089
- return leftVNode.$key$ === rightVNode.$key$;
1090
- }
1091
- return true;
1092
- }
1093
- return false;
1094
- };
1095
- const referenceNode = (node) => {
1096
- // this node was relocated to a new location in the dom
1097
- // because of some other component's slot
1098
- // but we still have an html comment in place of where
1099
- // it's original location was according to it's original vdom
1100
- return (node && node['s-ol']) || node;
1101
- };
1102
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1103
- /**
1104
- * Handle reconciling an outdated VNode with a new one which corresponds to
1105
- * it. This function handles flushing updates to the DOM and reconciling the
1106
- * children of the two nodes (if any).
1107
- *
1108
- * @param oldVNode an old VNode whose DOM element and children we want to update
1109
- * @param newVNode a new VNode representing an updated version of the old one
1110
- * @param isInitialRender whether or not this is the first render of the vdom
1111
- */
1112
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
1113
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
1114
- const oldChildren = oldVNode.$children$;
1115
- const newChildren = newVNode.$children$;
1116
- const tag = newVNode.$tag$;
1117
- const text = newVNode.$text$;
1118
- let defaultHolder;
1119
- if (text === null) {
1120
- {
1121
- if (tag === 'slot' && !useNativeShadowDom) ;
1122
- else {
1123
- // either this is the first render of an element OR it's an update
1124
- // AND we already know it's possible it could have changed
1125
- // this updates the element's css classes, attrs, props, listeners, etc.
1126
- updateElement(oldVNode, newVNode, isSvgMode);
1127
- }
1128
- }
1129
- if (oldChildren !== null && newChildren !== null) {
1130
- // looks like there's child vnodes for both the old and new vnodes
1131
- // so we need to call `updateChildren` to reconcile them
1132
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
1133
- }
1134
- else if (newChildren !== null) {
1135
- // no old child vnodes, but there are new child vnodes to add
1136
- if (oldVNode.$text$ !== null) {
1137
- // the old vnode was text, so be sure to clear it out
1138
- elm.textContent = '';
1139
- }
1140
- // add the new vnode children
1141
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1142
- }
1143
- else if (oldChildren !== null) {
1144
- // no new child vnodes, but there are old child vnodes to remove
1145
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1146
- }
1147
- }
1148
- else if ((defaultHolder = elm['s-cr'])) {
1149
- // this element has slotted content
1150
- defaultHolder.parentNode.textContent = text;
1151
- }
1152
- else if (oldVNode.$text$ !== text) {
1153
- // update the text content for the text only vnode
1154
- // and also only if the text is different than before
1155
- elm.data = text;
1156
- }
1157
- };
1158
- /**
1159
- * Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
1160
- * are slot fallbacks nodes.
1161
- *
1162
- * A slot fallback node should be visible by default. Then, it should be
1163
- * conditionally hidden if:
1164
- *
1165
- * - it has a sibling with a `slot` property set to its slot name or if
1166
- * - it is a default fallback slot node, in which case we hide if it has any
1167
- * content
1168
- *
1169
- * @param elm the element of interest
1170
- */
1171
- const updateFallbackSlotVisibility = (elm) => {
1172
- const childNodes = elm.childNodes;
1173
- for (const childNode of childNodes) {
1174
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1175
- if (childNode['s-sr']) {
1176
- // this is a slot fallback node
1177
- // get the slot name for this slot reference node
1178
- const slotName = childNode['s-sn'];
1179
- // by default always show a fallback slot node
1180
- // then hide it if there are other slots in the light dom
1181
- childNode.hidden = false;
1182
- // we need to check all of its sibling nodes in order to see if
1183
- // `childNode` should be hidden
1184
- for (const siblingNode of childNodes) {
1185
- // Don't check the node against itself
1186
- if (siblingNode !== childNode) {
1187
- if (siblingNode['s-hn'] !== childNode['s-hn'] || slotName !== '') {
1188
- // this sibling node is from a different component OR is a named
1189
- // fallback slot node
1190
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1191
- (slotName === siblingNode.getAttribute('slot') || slotName === siblingNode['s-sn'])) {
1192
- childNode.hidden = true;
1193
- break;
1194
- }
1195
- }
1196
- else {
1197
- // this is a default fallback slot node
1198
- // any element or text node (with content)
1199
- // should hide the default fallback slot node
1200
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1201
- (siblingNode.nodeType === 3 /* NODE_TYPE.TextNode */ && siblingNode.textContent.trim() !== '')) {
1202
- childNode.hidden = true;
1203
- break;
1204
- }
1205
- }
1206
- }
1207
- }
1208
- }
1209
- // keep drilling down
1210
- updateFallbackSlotVisibility(childNode);
1211
- }
1212
- }
1213
- };
1214
- /**
1215
- * Component-global information about nodes which are either currently being
1216
- * relocated or will be shortly.
1217
- */
1218
- const relocateNodes = [];
1219
- /**
1220
- * Mark the contents of a slot for relocation via adding references to them to
1221
- * the {@link relocateNodes} data structure. The actual work of relocating them
1222
- * will then be handled in {@link renderVdom}.
1223
- *
1224
- * @param elm a render node whose child nodes need to be relocated
1225
- */
1226
- const markSlotContentForRelocation = (elm) => {
1227
- // tslint:disable-next-line: prefer-const
1228
- let node;
1229
- let hostContentNodes;
1230
- let j;
1231
- for (const childNode of elm.childNodes) {
1232
- // we need to find child nodes which are slot references so we can then try
1233
- // to match them up with nodes that need to be relocated
1234
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1235
- // first get the content reference comment node ('s-cr'), then we get
1236
- // its parent, which is where all the host content is now
1237
- hostContentNodes = node.parentNode.childNodes;
1238
- const slotName = childNode['s-sn'];
1239
- // iterate through all the nodes under the location where the host was
1240
- // originally rendered
1241
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1242
- node = hostContentNodes[j];
1243
- // check that the node is not a content reference node or a node
1244
- // reference and then check that the host name does not match that of
1245
- // childNode.
1246
- // In addition, check that the slot either has not already been relocated, or
1247
- // that its current location's host is not childNode's host. This is essentially
1248
- // a check so that we don't try to relocate (and then hide) a node that is already
1249
- // where it should be.
1250
- if (!node['s-cn'] &&
1251
- !node['s-nr'] &&
1252
- node['s-hn'] !== childNode['s-hn'] &&
1253
- (!BUILD.experimentalSlotFixes )) {
1254
- // if `node` is located in the slot that `childNode` refers to (via the
1255
- // `'s-sn'` property) then we need to relocate it from it's current spot
1256
- // (under the host element parent) to the right slot location
1257
- if (isNodeLocatedInSlot(node, slotName)) {
1258
- // it's possible we've already decided to relocate this node
1259
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1260
- // made some changes to slots
1261
- // let's make sure we also double check
1262
- // fallbacks are correctly hidden or shown
1263
- checkSlotFallbackVisibility = true;
1264
- // ensure that the slot-name attr is correct
1265
- node['s-sn'] = node['s-sn'] || slotName;
1266
- if (relocateNodeData) {
1267
- relocateNodeData.$nodeToRelocate$['s-sh'] = childNode['s-hn'];
1268
- // we marked this node for relocation previously but didn't find
1269
- // out the slot reference node to which it needs to be relocated
1270
- // so write it down now!
1271
- relocateNodeData.$slotRefNode$ = childNode;
1272
- }
1273
- else {
1274
- node['s-sh'] = childNode['s-hn'];
1275
- // add to our list of nodes to relocate
1276
- relocateNodes.push({
1277
- $slotRefNode$: childNode,
1278
- $nodeToRelocate$: node,
1279
- });
1280
- }
1281
- if (node['s-sr']) {
1282
- relocateNodes.map((relocateNode) => {
1283
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1284
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1285
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1286
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1287
- }
1288
- }
1289
- });
1290
- }
1291
- }
1292
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1293
- // the node is not found within the slot (`childNode`) that we're
1294
- // currently looking at, so we stick it into `relocateNodes` to
1295
- // handle later. If we never find a home for this element then
1296
- // we'll need to hide it
1297
- relocateNodes.push({
1298
- $nodeToRelocate$: node,
1299
- });
1300
- }
1301
- }
1302
- }
1303
- }
1304
- // if we're dealing with any type of element (capable of itself being a
1305
- // slot reference or containing one) then we recur
1306
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1307
- markSlotContentForRelocation(childNode);
1308
- }
1309
- }
1310
- };
1311
- /**
1312
- * Check whether a node is located in a given named slot.
1313
- *
1314
- * @param nodeToRelocate the node of interest
1315
- * @param slotName the slot name to check
1316
- * @returns whether the node is located in the slot or not
1317
- */
1318
- const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1319
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1320
- if (nodeToRelocate.getAttribute('slot') === null && slotName === '') {
1321
- // if the node doesn't have a slot attribute, and the slot we're checking
1322
- // is not a named slot, then we assume the node should be within the slot
1323
- return true;
1324
- }
1325
- if (nodeToRelocate.getAttribute('slot') === slotName) {
1326
- return true;
1327
- }
1328
- return false;
1329
- }
1330
- if (nodeToRelocate['s-sn'] === slotName) {
1331
- return true;
1332
- }
1333
- return slotName === '';
1334
- };
1335
- /**
1336
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
1337
- * them with `null`. This signals that the DOM element corresponding to the VDom
1338
- * node has been removed from the DOM.
1339
- *
1340
- * @param vNode a virtual DOM node
1341
- */
1342
- const nullifyVNodeRefs = (vNode) => {
1343
- {
1344
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1345
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1346
- }
1347
- };
1348
- /**
1349
- * The main entry point for Stencil's virtual DOM-based rendering engine
1350
- *
1351
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1352
- * function will handle creating a virtual DOM tree with a single root, patching
1353
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1354
- * relocation, and reflecting attributes.
1355
- *
1356
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1357
- * the DOM node into which it should be rendered.
1358
- * @param renderFnResults the virtual DOM nodes to be rendered
1359
- * @param isInitialLoad whether or not this is the first call after page load
1360
- */
1361
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1362
- var _a, _b, _c, _d;
1363
- const hostElm = hostRef.$hostElement$;
1364
- const cmpMeta = hostRef.$cmpMeta$;
1365
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1366
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1367
- // we need to call `h` again to wrap the children of our component in a
1368
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1369
- // implicitly that the top-level vdom node is 1) an only child and 2)
1370
- // contains attrs that need to be set on the host element.
1371
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1372
- hostTagName = hostElm.tagName;
1373
- if (cmpMeta.$attrsToReflect$) {
1374
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1375
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1376
- }
1377
- // On the first render and *only* on the first render we want to check for
1378
- // any attributes set on the host element which are also set on the vdom
1379
- // node. If we find them, we override the value on the VDom node attrs with
1380
- // the value from the host element, which allows developers building apps
1381
- // with Stencil components to override e.g. the `role` attribute on a
1382
- // component even if it's already set on the `Host`.
1383
- if (isInitialLoad && rootVnode.$attrs$) {
1384
- for (const key of Object.keys(rootVnode.$attrs$)) {
1385
- // We have a special implementation in `setAccessor` for `style` and
1386
- // `class` which reconciles values coming from the VDom with values
1387
- // already present on the DOM element, so we don't want to override those
1388
- // attributes on the VDom tree with values from the host element if they
1389
- // are present.
1390
- //
1391
- // Likewise, `ref` and `key` are special internal values for the Stencil
1392
- // runtime and we don't want to override those either.
1393
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1394
- rootVnode.$attrs$[key] = hostElm[key];
1395
- }
1396
- }
1397
- }
1398
- rootVnode.$tag$ = null;
1399
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1400
- hostRef.$vnode$ = rootVnode;
1401
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1402
- {
1403
- scopeId = hostElm['s-sc'];
1404
- }
1405
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1406
- {
1407
- contentRef = hostElm['s-cr'];
1408
- // always reset
1409
- checkSlotFallbackVisibility = false;
1410
- }
1411
- // synchronous patch
1412
- patch(oldVNode, rootVnode, isInitialLoad);
1413
- {
1414
- // while we're moving nodes around existing nodes, temporarily disable
1415
- // the disconnectCallback from working
1416
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1417
- if (checkSlotRelocate) {
1418
- markSlotContentForRelocation(rootVnode.$elm$);
1419
- for (const relocateData of relocateNodes) {
1420
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1421
- if (!nodeToRelocate['s-ol']) {
1422
- // add a reference node marking this node's original location
1423
- // keep a reference to this node for later lookups
1424
- const orgLocationNode = doc.createTextNode('');
1425
- orgLocationNode['s-nr'] = nodeToRelocate;
1426
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1427
- }
1428
- }
1429
- for (const relocateData of relocateNodes) {
1430
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1431
- const slotRefNode = relocateData.$slotRefNode$;
1432
- if (slotRefNode) {
1433
- const parentNodeRef = slotRefNode.parentNode;
1434
- // When determining where to insert content, the most simple case would be
1435
- // to relocate the node immediately following the slot reference node. We do this
1436
- // by getting a reference to the node immediately following the slot reference node
1437
- // since we will use `insertBefore` to manipulate the DOM.
1438
- //
1439
- // If there is no node immediately following the slot reference node, then we will just
1440
- // end up appending the node as the last child of the parent.
1441
- let insertBeforeNode = slotRefNode.nextSibling;
1442
- // If the node we're currently planning on inserting the new node before is an element,
1443
- // we need to do some additional checks to make sure we're inserting the node in the correct order.
1444
- // The use case here would be that we have multiple nodes being relocated to the same slot. So, we want
1445
- // to make sure they get inserted into their new home in the same order they were declared in their original location.
1446
- //
1447
- // TODO(STENCIL-914): Remove `experimentalSlotFixes` check
1448
- {
1449
- let orgLocationNode = (_a = nodeToRelocate['s-ol']) === null || _a === void 0 ? void 0 : _a.previousSibling;
1450
- while (orgLocationNode) {
1451
- let refNode = (_b = orgLocationNode['s-nr']) !== null && _b !== void 0 ? _b : null;
1452
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1453
- refNode = refNode.nextSibling;
1454
- // If the refNode is the same node to be relocated or another element's slot reference, keep searching to find the
1455
- // correct relocation target
1456
- while (refNode === nodeToRelocate || (refNode === null || refNode === void 0 ? void 0 : refNode['s-sr'])) {
1457
- refNode = refNode === null || refNode === void 0 ? void 0 : refNode.nextSibling;
1458
- }
1459
- if (!refNode || !refNode['s-nr']) {
1460
- insertBeforeNode = refNode;
1461
- break;
1462
- }
1463
- }
1464
- orgLocationNode = orgLocationNode.previousSibling;
1465
- }
1466
- }
1467
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1468
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1469
- // we've checked that it's worth while to relocate
1470
- // since that the node to relocate
1471
- // has a different next sibling or parent relocated
1472
- if (nodeToRelocate !== insertBeforeNode) {
1473
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1474
- // probably a component in the index.html that doesn't have its hostname set
1475
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1476
- }
1477
- // Add it back to the dom but in its new home
1478
- // If we get to this point and `insertBeforeNode` is `null`, that means
1479
- // we're just going to append the node as the last child of the parent. Passing
1480
- // `null` as the second arg here will trigger that behavior.
1481
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1482
- // Reset the `hidden` value back to what it was defined as originally
1483
- // This solves a problem where a `slot` is dynamically rendered and `hidden` may have
1484
- // been set on content originally, but now it has a slot to go to so it should have
1485
- // the value it was defined as having in the DOM, not what we overrode it to.
1486
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1487
- nodeToRelocate.hidden = (_c = nodeToRelocate['s-ih']) !== null && _c !== void 0 ? _c : false;
1488
- }
1489
- }
1490
- }
1491
- nodeToRelocate && typeof slotRefNode['s-rf'] === 'function' && slotRefNode['s-rf'](nodeToRelocate);
1492
- }
1493
- else {
1494
- // this node doesn't have a slot home to go to, so let's hide it
1495
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1496
- // Store the initial value of `hidden` so we can reset it later when
1497
- // moving nodes around.
1498
- if (isInitialLoad) {
1499
- nodeToRelocate['s-ih'] = (_d = nodeToRelocate.hidden) !== null && _d !== void 0 ? _d : false;
1500
- }
1501
- nodeToRelocate.hidden = true;
1502
- }
1503
- }
1504
- }
1505
- }
1506
- if (checkSlotFallbackVisibility) {
1507
- updateFallbackSlotVisibility(rootVnode.$elm$);
1508
- }
1509
- // done moving nodes around
1510
- // allow the disconnect callback to work again
1511
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1512
- // always reset
1513
- relocateNodes.length = 0;
1514
- }
1515
- // Clear the content ref so we don't create a memory leak
1516
- contentRef = undefined;
1517
- };
1518
- const attachToAncestor = (hostRef, ancestorComponent) => {
1519
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1520
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1521
- }
1522
- };
1523
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1524
- {
1525
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1526
- }
1527
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1528
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1529
- return;
1530
- }
1531
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1532
- // there is no ancestor component or the ancestor component
1533
- // has already fired off its lifecycle update then
1534
- // fire off the initial update
1535
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1536
- return writeTask(dispatch) ;
1537
- };
1538
- /**
1539
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1540
- * component lifecycle methods like `componentWillLoad` as well as
1541
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1542
- *
1543
- * @param hostRef a reference to a host DOM node
1544
- * @param isInitialLoad whether we're on the initial load or not
1545
- * @returns an empty Promise which is used to enqueue a series of operations for
1546
- * the component
1547
- */
1548
- const dispatchHooks = (hostRef, isInitialLoad) => {
1549
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1550
- const instance = hostRef.$lazyInstance$ ;
1551
- // We're going to use this variable together with `enqueue` to implement a
1552
- // little promise-based queue. We start out with it `undefined`. When we add
1553
- // the first function to the queue we'll set this variable to be that
1554
- // function's return value. When we attempt to add subsequent values to the
1555
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1556
- // the new function off of that `Promise` using `.then()`. This will give our
1557
- // queue two nice properties:
1558
- //
1559
- // 1. If all functions added to the queue are synchronous they'll be called
1560
- // synchronously right away.
1561
- // 2. If all functions added to the queue are asynchronous they'll all be
1562
- // called in order after `dispatchHooks` exits.
1563
- let maybePromise;
1564
- if (isInitialLoad) {
1565
- {
1566
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1567
- if (hostRef.$queuedListeners$) {
1568
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1569
- hostRef.$queuedListeners$ = undefined;
1570
- }
1571
- }
1572
- {
1573
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1574
- // whatever's going on in that `Promise` before we launch into
1575
- // rendering the component, doing other lifecycle stuff, etc. So
1576
- // in that case we assign the returned promise to the variable we
1577
- // declared above to hold a possible 'queueing' Promise
1578
- maybePromise = safeCall(instance, 'componentWillLoad');
1579
- }
1580
- }
1581
- else {
1582
- {
1583
- // Like `componentWillLoad` above, we allow Stencil component
1584
- // authors to return a `Promise` from this lifecycle callback, and
1585
- // we specify that our runtime will wait for that `Promise` to
1586
- // resolve before the component re-renders. So if the method
1587
- // returns a `Promise` we need to keep it around!
1588
- maybePromise = safeCall(instance, 'componentWillUpdate');
1589
- }
1590
- }
1591
- endSchedule();
1592
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1593
- };
1594
- /**
1595
- * This function uses a Promise to implement a simple first-in, first-out queue
1596
- * of functions to be called.
1597
- *
1598
- * The queue is ordered on the basis of the first argument. If it's
1599
- * `undefined`, then nothing is on the queue yet, so the provided function can
1600
- * be called synchronously (although note that this function may return a
1601
- * `Promise`). The idea is that then the return value of that enqueueing
1602
- * operation is kept around, so that if it was a `Promise` then subsequent
1603
- * functions can be enqueued by calling this function again with that `Promise`
1604
- * as the first argument.
1605
- *
1606
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1607
- * @param fn a function to enqueue
1608
- * @returns either a `Promise` or the return value of the provided function
1609
- */
1610
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1611
- /**
1612
- * Check that a value is a `Promise`. To check, we first see if the value is an
1613
- * instance of the `Promise` global. In a few circumstances, in particular if
1614
- * the global has been overwritten, this is could be misleading, so we also do
1615
- * a little 'duck typing' check to see if the `.then` property of the value is
1616
- * defined and a function.
1617
- *
1618
- * @param maybePromise it might be a promise!
1619
- * @returns whether it is or not
1620
- */
1621
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1622
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1623
- /**
1624
- * Update a component given reference to its host elements and so on.
1625
- *
1626
- * @param hostRef an object containing references to the element's host node,
1627
- * VDom nodes, and other metadata
1628
- * @param instance a reference to the underlying host element where it will be
1629
- * rendered
1630
- * @param isInitialLoad whether or not this function is being called as part of
1631
- * the first render cycle
1632
- */
1633
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1634
- var _a;
1635
- const elm = hostRef.$hostElement$;
1636
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1637
- const rc = elm['s-rc'];
1638
- if (isInitialLoad) {
1639
- // DOM WRITE!
1640
- attachStyles(hostRef);
1641
- }
1642
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1643
- {
1644
- callRender(hostRef, instance, elm, isInitialLoad);
1645
- }
1646
- if (rc) {
1647
- // ok, so turns out there are some child host elements
1648
- // waiting on this parent element to load
1649
- // let's fire off all update callbacks waiting
1650
- rc.map((cb) => cb());
1651
- elm['s-rc'] = undefined;
1652
- }
1653
- endRender();
1654
- endUpdate();
1655
- {
1656
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1657
- const postUpdate = () => postUpdateComponent(hostRef);
1658
- if (childrenPromises.length === 0) {
1659
- postUpdate();
1660
- }
1661
- else {
1662
- Promise.all(childrenPromises).then(postUpdate);
1663
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1664
- childrenPromises.length = 0;
1665
- }
1666
- }
1667
- };
1668
- /**
1669
- * Handle making the call to the VDom renderer with the proper context given
1670
- * various build variables
1671
- *
1672
- * @param hostRef an object containing references to the element's host node,
1673
- * VDom nodes, and other metadata
1674
- * @param instance a reference to the underlying host element where it will be
1675
- * rendered
1676
- * @param elm the Host element for the component
1677
- * @param isInitialLoad whether or not this function is being called as part of
1678
- * @returns an empty promise
1679
- */
1680
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1681
- try {
1682
- /**
1683
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1684
- * method, so we can call the method immediately. If not, check before calling it.
1685
- */
1686
- instance = instance.render && instance.render();
1687
- {
1688
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1689
- }
1690
- {
1691
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1692
- }
1693
- {
1694
- {
1695
- // looks like we've got child nodes to render into this host element
1696
- // or we need to update the css class/attrs on the host element
1697
- // DOM WRITE!
1698
- {
1699
- renderVdom(hostRef, instance, isInitialLoad);
1700
- }
1701
- }
1702
- }
1703
- }
1704
- catch (e) {
1705
- consoleError(e, hostRef.$hostElement$);
1706
- }
1707
- return null;
1708
- };
1709
- const postUpdateComponent = (hostRef) => {
1710
- const tagName = hostRef.$cmpMeta$.$tagName$;
1711
- const elm = hostRef.$hostElement$;
1712
- const endPostUpdate = createTime('postUpdate', tagName);
1713
- const instance = hostRef.$lazyInstance$ ;
1714
- const ancestorComponent = hostRef.$ancestorComponent$;
1715
- {
1716
- safeCall(instance, 'componentDidRender');
1717
- }
1718
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1719
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1720
- {
1721
- // DOM WRITE!
1722
- addHydratedFlag(elm);
1723
- }
1724
- {
1725
- safeCall(instance, 'componentDidLoad');
1726
- }
1727
- endPostUpdate();
1728
- {
1729
- hostRef.$onReadyResolve$(elm);
1730
- if (!ancestorComponent) {
1731
- appDidLoad();
1732
- }
1733
- }
1734
- }
1735
- else {
1736
- {
1737
- safeCall(instance, 'componentDidUpdate');
1738
- }
1739
- endPostUpdate();
1740
- }
1741
- {
1742
- hostRef.$onInstanceResolve$(elm);
1743
- }
1744
- // load events fire from bottom to top
1745
- // the deepest elements load first then bubbles up
1746
- {
1747
- if (hostRef.$onRenderResolve$) {
1748
- hostRef.$onRenderResolve$();
1749
- hostRef.$onRenderResolve$ = undefined;
1750
- }
1751
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
1752
- nextTick(() => scheduleUpdate(hostRef, false));
1753
- }
1754
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
1755
- }
1756
- // ( •_•)
1757
- // ( •_•)>⌐■-■
1758
- // (⌐■_■)
1759
- };
1760
- const appDidLoad = (who) => {
1761
- // on appload
1762
- // we have finish the first big initial render
1763
- {
1764
- addHydratedFlag(doc.documentElement);
1765
- }
1766
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
1767
- };
1768
- /**
1769
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
1770
- * e.g. custom element node. If a build figures out that e.g. no component
1771
- * has a `componentDidLoad` method, the instance method gets removed from the
1772
- * output bundle and this function returns `undefined`.
1773
- * @param instance any object that may or may not contain methods
1774
- * @param method method name
1775
- * @param arg single arbitrary argument
1776
- * @returns result of method call if it exists, otherwise `undefined`
1777
- */
1778
- const safeCall = (instance, method, arg) => {
1779
- if (instance && instance[method]) {
1780
- try {
1781
- return instance[method](arg);
1782
- }
1783
- catch (e) {
1784
- consoleError(e);
1785
- }
1786
- }
1787
- return undefined;
1788
- };
1789
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1790
- ;
1791
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
1792
- const setValue = (ref, propName, newVal, cmpMeta) => {
1793
- // check our new property value against our internal value
1794
- const hostRef = getHostRef(ref);
1795
- const elm = hostRef.$hostElement$ ;
1796
- const oldVal = hostRef.$instanceValues$.get(propName);
1797
- const flags = hostRef.$flags$;
1798
- const instance = hostRef.$lazyInstance$ ;
1799
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
1800
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
1801
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
1802
- const didValueChange = newVal !== oldVal && !areBothNaN;
1803
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
1804
- // gadzooks! the property's value has changed!!
1805
- // set our new value!
1806
- hostRef.$instanceValues$.set(propName, newVal);
1807
- if (instance) {
1808
- // get an array of method names of watch functions to call
1809
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
1810
- const watchMethods = cmpMeta.$watchers$[propName];
1811
- if (watchMethods) {
1812
- // this instance is watching for when this property changed
1813
- watchMethods.map((watchMethodName) => {
1814
- try {
1815
- // fire off each of the watch methods that are watching this property
1816
- instance[watchMethodName](newVal, oldVal, propName);
1817
- }
1818
- catch (e) {
1819
- consoleError(e, elm);
1820
- }
1821
- });
1822
- }
1823
- }
1824
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
1825
- if (instance.componentShouldUpdate) {
1826
- if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
1827
- return;
1828
- }
1829
- }
1830
- // looks like this value actually changed, so we've got work to do!
1831
- // but only if we've already rendered, otherwise just chill out
1832
- // queue that we need to do an update, but don't worry about queuing
1833
- // up millions cuz this function ensures it only runs once
1834
- scheduleUpdate(hostRef, false);
1835
- }
1836
- }
1837
- }
1838
- };
1839
- /**
1840
- * Attach a series of runtime constructs to a compiled Stencil component
1841
- * constructor, including getters and setters for the `@Prop` and `@State`
1842
- * decorators, callbacks for when attributes change, and so on.
1843
- *
1844
- * @param Cstr the constructor for a component that we need to process
1845
- * @param cmpMeta metadata collected previously about the component
1846
- * @param flags a number used to store a series of bit flags
1847
- * @returns a reference to the same constructor passed in (but now mutated)
1848
- */
1849
- const proxyComponent = (Cstr, cmpMeta, flags) => {
1850
- var _a;
1851
- const prototype = Cstr.prototype;
1852
- if (cmpMeta.$members$) {
1853
- if (Cstr.watchers) {
1854
- cmpMeta.$watchers$ = Cstr.watchers;
1855
- }
1856
- // It's better to have a const than two Object.entries()
1857
- const members = Object.entries(cmpMeta.$members$);
1858
- members.map(([memberName, [memberFlags]]) => {
1859
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
1860
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
1861
- // proxyComponent - prop
1862
- Object.defineProperty(prototype, memberName, {
1863
- get() {
1864
- // proxyComponent, get value
1865
- return getValue(this, memberName);
1866
- },
1867
- set(newValue) {
1868
- // proxyComponent, set value
1869
- setValue(this, memberName, newValue, cmpMeta);
1870
- },
1871
- configurable: true,
1872
- enumerable: true,
1873
- });
1874
- }
1875
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
1876
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
1877
- // proxyComponent - method
1878
- Object.defineProperty(prototype, memberName, {
1879
- value(...args) {
1880
- var _a;
1881
- const ref = getHostRef(this);
1882
- return (_a = ref === null || ref === void 0 ? void 0 : ref.$onInstancePromise$) === null || _a === void 0 ? void 0 : _a.then(() => { var _a; return (_a = ref.$lazyInstance$) === null || _a === void 0 ? void 0 : _a[memberName](...args); });
1883
- },
1884
- });
1885
- }
1886
- });
1887
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
1888
- const attrNameToPropName = new Map();
1889
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
1890
- plt.jmp(() => {
1891
- var _a;
1892
- const propName = attrNameToPropName.get(attrName);
1893
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
1894
- // in the case where an attribute was set inline.
1895
- // ```html
1896
- // <my-component some-attribute="some-value"></my-component>
1897
- // ```
1898
- //
1899
- // There is an edge case where a developer sets the attribute inline on a custom element and then
1900
- // programmatically changes it before it has been upgraded as shown below:
1901
- //
1902
- // ```html
1903
- // <!-- this component has _not_ been upgraded yet -->
1904
- // <my-component id="test" some-attribute="some-value"></my-component>
1905
- // <script>
1906
- // // grab non-upgraded component
1907
- // el = document.querySelector("#test");
1908
- // el.someAttribute = "another-value";
1909
- // // upgrade component
1910
- // customElements.define('my-component', MyComponent);
1911
- // </script>
1912
- // ```
1913
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
1914
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1915
- // to the value that was set inline i.e. "some-value" from above example. When
1916
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
1917
- //
1918
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
1919
- // by connectedCallback as this attributeChangedCallback will not fire.
1920
- //
1921
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1922
- //
1923
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1924
- // properties here given that this goes against best practices outlined here
1925
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1926
- if (this.hasOwnProperty(propName)) {
1927
- newValue = this[propName];
1928
- delete this[propName];
1929
- }
1930
- else if (prototype.hasOwnProperty(propName) &&
1931
- typeof this[propName] === 'number' &&
1932
- this[propName] == newValue) {
1933
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
1934
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
1935
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
1936
- return;
1937
- }
1938
- else if (propName == null) {
1939
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
1940
- // on a vanilla web component
1941
- const hostRef = getHostRef(this);
1942
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
1943
- // We only want to trigger the callback(s) if:
1944
- // 1. The instance is ready
1945
- // 2. The watchers are ready
1946
- // 3. The value has changed
1947
- if (flags &&
1948
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
1949
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
1950
- newValue !== oldValue) {
1951
- const instance = hostRef.$lazyInstance$ ;
1952
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
1953
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
1954
- if (instance[callbackName] != null) {
1955
- instance[callbackName].call(instance, newValue, oldValue, attrName);
1956
- }
1957
- });
1958
- }
1959
- return;
1960
- }
1961
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1962
- });
1963
- };
1964
- // Create an array of attributes to observe
1965
- // This list in comprised of all strings used within a `@Watch()` decorator
1966
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
1967
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
1968
- // an invalid attribute.
1969
- Cstr.observedAttributes = Array.from(new Set([
1970
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
1971
- ...members
1972
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
1973
- .map(([propName, m]) => {
1974
- var _a;
1975
- const attrName = m[1] || propName;
1976
- attrNameToPropName.set(attrName, propName);
1977
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
1978
- (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
1979
- }
1980
- return attrName;
1981
- }),
1982
- ]));
1983
- }
1984
- }
1985
- return Cstr;
1986
- };
1987
- /**
1988
- * Initialize a Stencil component given a reference to its host element, its
1989
- * runtime bookkeeping data structure, runtime metadata about the component,
1990
- * and (optionally) an HMR version ID.
1991
- *
1992
- * @param elm a host element
1993
- * @param hostRef the element's runtime bookkeeping object
1994
- * @param cmpMeta runtime metadata for the Stencil component
1995
- * @param hmrVersionId an (optional) HMR version ID
1996
- */
1997
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
1998
- let Cstr;
1999
- // initializeComponent
2000
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2001
- // Let the runtime know that the component has been initialized
2002
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2003
- const bundleId = cmpMeta.$lazyBundleId$;
2004
- if (bundleId) {
2005
- // lazy loaded components
2006
- // request the component's implementation to be
2007
- // wired up with the host element
2008
- Cstr = loadModule(cmpMeta);
2009
- if (Cstr.then) {
2010
- // Await creates a micro-task avoid if possible
2011
- const endLoad = uniqueTime();
2012
- Cstr = await Cstr;
2013
- endLoad();
2014
- }
2015
- if (!Cstr.isProxied) {
2016
- // we've never proxied this Constructor before
2017
- // let's add the getters/setters to its prototype before
2018
- // the first time we create an instance of the implementation
2019
- {
2020
- cmpMeta.$watchers$ = Cstr.watchers;
2021
- }
2022
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2023
- Cstr.isProxied = true;
2024
- }
2025
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2026
- // ok, time to construct the instance
2027
- // but let's keep track of when we start and stop
2028
- // so that the getters/setters don't incorrectly step on data
2029
- {
2030
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2031
- }
2032
- // construct the lazy-loaded component implementation
2033
- // passing the hostRef is very important during
2034
- // construction in order to directly wire together the
2035
- // host element and the lazy-loaded instance
2036
- try {
2037
- new Cstr(hostRef);
2038
- }
2039
- catch (e) {
2040
- consoleError(e);
2041
- }
2042
- {
2043
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2044
- }
2045
- {
2046
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2047
- }
2048
- endNewInstance();
2049
- }
2050
- else {
2051
- // sync constructor component
2052
- Cstr = elm.constructor;
2053
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2054
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2055
- // Stencil has completed instantiating the component.
2056
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2057
- }
2058
- if (Cstr.style) {
2059
- // this component has styles but we haven't registered them yet
2060
- let style = Cstr.style;
2061
- const scopeId = getScopeId(cmpMeta);
2062
- if (!styles.has(scopeId)) {
2063
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2064
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2065
- endRegisterStyles();
2066
- }
2067
- }
2068
- }
2069
- // we've successfully created a lazy instance
2070
- const ancestorComponent = hostRef.$ancestorComponent$;
2071
- const schedule = () => scheduleUpdate(hostRef, true);
2072
- if (ancestorComponent && ancestorComponent['s-rc']) {
2073
- // this is the initial load and this component it has an ancestor component
2074
- // but the ancestor component has NOT fired its will update lifecycle yet
2075
- // so let's just cool our jets and wait for the ancestor to continue first
2076
- // this will get fired off when the ancestor component
2077
- // finally gets around to rendering its lazy self
2078
- // fire off the initial update
2079
- ancestorComponent['s-rc'].push(schedule);
2080
- }
2081
- else {
2082
- schedule();
2083
- }
2084
- };
2085
- const fireConnectedCallback = (instance) => {
2086
- };
2087
- const connectedCallback = (elm) => {
2088
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2089
- const hostRef = getHostRef(elm);
2090
- const cmpMeta = hostRef.$cmpMeta$;
2091
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2092
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2093
- // first time this component has connected
2094
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2095
- {
2096
- // initUpdate
2097
- // if the slot polyfill is required we'll need to put some nodes
2098
- // in here to act as original content anchors as we move nodes around
2099
- // host element has been connected to the DOM
2100
- if ((// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2101
- cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2102
- setContentReference(elm);
2103
- }
2104
- }
2105
- {
2106
- // find the first ancestor component (if there is one) and register
2107
- // this component as one of the actively loading child components for its ancestor
2108
- let ancestorComponent = elm;
2109
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2110
- // climb up the ancestors looking for the first
2111
- // component that hasn't finished its lifecycle update yet
2112
- if (ancestorComponent['s-p']) {
2113
- // we found this components first ancestor component
2114
- // keep a reference to this component's ancestor component
2115
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2116
- break;
2117
- }
2118
- }
2119
- }
2120
- // Lazy properties
2121
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2122
- if (cmpMeta.$members$) {
2123
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2124
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2125
- const value = elm[memberName];
2126
- delete elm[memberName];
2127
- elm[memberName] = value;
2128
- }
2129
- });
2130
- }
2131
- {
2132
- initializeComponent(elm, hostRef, cmpMeta);
2133
- }
2134
- }
2135
- else {
2136
- // not the first time this has connected
2137
- // reattach any event listeners to the host
2138
- // since they would have been removed when disconnected
2139
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2140
- // fire off connectedCallback() on component instance
2141
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
2142
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2143
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
2144
- }
2145
- }
2146
- endConnected();
2147
- }
2148
- };
2149
- const setContentReference = (elm) => {
2150
- // only required when we're NOT using native shadow dom (slot)
2151
- // or this browser doesn't support native shadow dom
2152
- // and this host element was NOT created with SSR
2153
- // let's pick out the inner content for slot projection
2154
- // create a node to represent where the original
2155
- // content was first placed, which is useful later on
2156
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2157
- contentRefElm['s-cn'] = true;
2158
- elm.insertBefore(contentRefElm, elm.firstChild);
2159
- };
2160
- const disconnectInstance = (instance) => {
2161
- {
2162
- safeCall(instance, 'disconnectedCallback');
2163
- }
2164
- };
2165
- const disconnectedCallback = async (elm) => {
2166
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2167
- const hostRef = getHostRef(elm);
2168
- {
2169
- if (hostRef.$rmListeners$) {
2170
- hostRef.$rmListeners$.map((rmListener) => rmListener());
2171
- hostRef.$rmListeners$ = undefined;
2172
- }
2173
- }
2174
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2175
- disconnectInstance(hostRef.$lazyInstance$);
2176
- }
2177
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2178
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
2179
- }
2180
- }
2181
- };
2182
- const bootstrapLazy = (lazyBundles, options = {}) => {
2183
- var _a;
2184
- const endBootstrap = createTime();
2185
- const cmpTags = [];
2186
- const exclude = options.exclude || [];
2187
- const customElements = win.customElements;
2188
- const head = doc.head;
2189
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2190
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
2191
- const deferredConnectedCallbacks = [];
2192
- let appLoadFallback;
2193
- let isBootstrapping = true;
2194
- Object.assign(plt, options);
2195
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2196
- let hasSlotRelocation = false;
2197
- lazyBundles.map((lazyBundle) => {
2198
- lazyBundle[1].map((compactMeta) => {
2199
- var _a;
2200
- const cmpMeta = {
2201
- $flags$: compactMeta[0],
2202
- $tagName$: compactMeta[1],
2203
- $members$: compactMeta[2],
2204
- $listeners$: compactMeta[3],
2205
- };
2206
- // Check if we are using slots outside the shadow DOM in this component.
2207
- // We'll use this information later to add styles for `slot-fb` elements
2208
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
2209
- hasSlotRelocation = true;
2210
- }
2211
- {
2212
- cmpMeta.$members$ = compactMeta[2];
2213
- }
2214
- {
2215
- cmpMeta.$listeners$ = compactMeta[3];
2216
- }
2217
- {
2218
- cmpMeta.$attrsToReflect$ = [];
2219
- }
2220
- {
2221
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
2222
- }
2223
- const tagName = cmpMeta.$tagName$;
2224
- const HostElement = class extends HTMLElement {
2225
- // StencilLazyHost
2226
- constructor(self) {
2227
- // @ts-ignore
2228
- super(self);
2229
- self = this;
2230
- registerHost(self, cmpMeta);
2231
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2232
- // this component is using shadow dom
2233
- // and this browser supports shadow dom
2234
- // add the read-only property "shadowRoot" to the host element
2235
- // adding the shadow root build conditionals to minimize runtime
2236
- {
2237
- {
2238
- self.attachShadow({ mode: 'open' });
2239
- }
2240
- }
2241
- }
2242
- }
2243
- connectedCallback() {
2244
- if (appLoadFallback) {
2245
- clearTimeout(appLoadFallback);
2246
- appLoadFallback = null;
2247
- }
2248
- if (isBootstrapping) {
2249
- // connectedCallback will be processed once all components have been registered
2250
- deferredConnectedCallbacks.push(this);
2251
- }
2252
- else {
2253
- plt.jmp(() => connectedCallback(this));
2254
- }
2255
- }
2256
- disconnectedCallback() {
2257
- plt.jmp(() => disconnectedCallback(this));
2258
- }
2259
- componentOnReady() {
2260
- return getHostRef(this).$onReadyPromise$;
2261
- }
2262
- };
2263
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
2264
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2265
- cmpTags.push(tagName);
2266
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2267
- }
2268
- });
2269
- });
2270
- // Only bother generating CSS if we have components
2271
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
2272
- if (cmpTags.length > 0) {
2273
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
2274
- if (hasSlotRelocation) {
2275
- dataStyles.textContent += SLOT_FB_CSS;
2276
- }
2277
- // Add hydration styles
2278
- {
2279
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
2280
- }
2281
- // If we have styles, add them to the DOM
2282
- if (dataStyles.innerHTML.length) {
2283
- dataStyles.setAttribute('data-styles', '');
2284
- // Apply CSP nonce to the style tag if it exists
2285
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2286
- if (nonce != null) {
2287
- dataStyles.setAttribute('nonce', nonce);
2288
- }
2289
- // Insert the styles into the document head
2290
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
2291
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
2292
- }
2293
- }
2294
- // Process deferred connectedCallbacks now all components have been registered
2295
- isBootstrapping = false;
2296
- if (deferredConnectedCallbacks.length) {
2297
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
2298
- }
2299
- else {
2300
- {
2301
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2302
- }
2303
- }
2304
- // Fallback appLoad event
2305
- endBootstrap();
2306
- };
2307
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
2308
- if (listeners) {
2309
- listeners.map(([flags, name, method]) => {
2310
- const target = getHostListenerTarget(elm, flags) ;
2311
- const handler = hostListenerProxy(hostRef, method);
2312
- const opts = hostListenerOpts(flags);
2313
- plt.ael(target, name, handler, opts);
2314
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
2315
- });
2316
- }
2317
- };
2318
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
2319
- try {
2320
- {
2321
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
2322
- // instance is ready, let's call it's member method for this event
2323
- hostRef.$lazyInstance$[methodName](ev);
2324
- }
2325
- else {
2326
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
2327
- }
2328
- }
2329
- }
2330
- catch (e) {
2331
- consoleError(e);
2332
- }
2333
- };
2334
- const getHostListenerTarget = (elm, flags) => {
2335
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
2336
- return win;
2337
- return elm;
2338
- };
2339
- // prettier-ignore
2340
- const hostListenerOpts = (flags) => supportsListenerOptions
2341
- ? ({
2342
- passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
2343
- capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
2344
- })
2345
- : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
2346
- /**
2347
- * Assigns the given value to the nonce property on the runtime platform object.
2348
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2349
- * @param nonce The value to be assigned to the platform nonce property.
2350
- * @returns void
2351
- */
2352
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
2353
- /**
2354
- * A WeakMap mapping runtime component references to their corresponding host reference
2355
- * instances.
2356
- *
2357
- * **Note**: If we're in an HMR context we need to store a reference to this
2358
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
2359
- * to {@link d.HostRef} across HMR updates.
2360
- *
2361
- * This is necessary because when HMR updates for a component are processed by
2362
- * the browser-side dev server client the JS bundle for that component is
2363
- * re-fetched. Since the module containing {@link hostRefs} is included in
2364
- * that bundle, if we do not store a reference to it the new iteration of the
2365
- * component will not have access to the previous hostRef map, leading to a
2366
- * bug where the new version of the component cannot properly initialize.
2367
- */
2368
- const hostRefs = new WeakMap();
2369
- /**
2370
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
2371
- *
2372
- * @param ref the runtime ref of interest
2373
- * @returns the Host reference (if found) or undefined
2374
- */
2375
- const getHostRef = (ref) => hostRefs.get(ref);
2376
- /**
2377
- * Register a lazy instance with the {@link hostRefs} object so it's
2378
- * corresponding {@link d.HostRef} can be retrieved later.
2379
- *
2380
- * @param lazyInstance the lazy instance of interest
2381
- * @param hostRef that instances `HostRef` object
2382
- * @returns a reference to the host ref WeakMap
2383
- */
2384
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2385
- /**
2386
- * Register a host element for a Stencil component, setting up various metadata
2387
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
2388
- * metadata.
2389
- *
2390
- * @param hostElement the host element to register
2391
- * @param cmpMeta runtime metadata for that component
2392
- * @returns a reference to the host ref WeakMap
2393
- */
2394
- const registerHost = (hostElement, cmpMeta) => {
2395
- const hostRef = {
2396
- $flags$: 0,
2397
- $hostElement$: hostElement,
2398
- $cmpMeta$: cmpMeta,
2399
- $instanceValues$: new Map(),
2400
- };
2401
- {
2402
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
2403
- }
2404
- {
2405
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2406
- hostElement['s-p'] = [];
2407
- hostElement['s-rc'] = [];
2408
- }
2409
- addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
2410
- return hostRefs.set(hostElement, hostRef);
2411
- };
2412
- const isMemberInElement = (elm, memberName) => memberName in elm;
2413
- const consoleError = (e, el) => (0, console.error)(e, el);
2414
- const cmpModules = /*@__PURE__*/ new Map();
2415
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2416
- // loadModuleImport
2417
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2418
- const bundleId = cmpMeta.$lazyBundleId$;
2419
- const module = cmpModules.get(bundleId) ;
2420
- if (module) {
2421
- return module[exportName];
2422
- }
2423
-
2424
- if (!hmrVersionId || !BUILD.hotModuleReplacement) {
2425
- const processMod = importedModule => {
2426
- cmpModules.set(bundleId, importedModule);
2427
- return importedModule[exportName];
2428
- }
2429
- switch(bundleId) {
2430
-
2431
- case 'mg-action-more_36':
2432
- return import(
2433
- /* webpackMode: "lazy" */
2434
- './mg-action-more_36.entry.js').then(processMod, consoleError);
2435
- case 'mg-loader':
2436
- return import(
2437
- /* webpackMode: "lazy" */
2438
- './mg-loader.entry.js').then(processMod, consoleError);
2439
- }
2440
- }
2441
- return import(
2442
- /* @vite-ignore */
2443
- /* webpackInclude: /\.entry\.js$/ */
2444
- /* webpackExclude: /\.system\.entry\.js$/ */
2445
- /* webpackMode: "lazy" */
2446
- `./${bundleId}.entry.js${''}`).then((importedModule) => {
2447
- {
2448
- cmpModules.set(bundleId, importedModule);
2449
- }
2450
- return importedModule[exportName];
2451
- }, consoleError);
2452
- };
2453
- const styles = /*@__PURE__*/ new Map();
2454
- const win = typeof window !== 'undefined' ? window : {};
2455
- const doc = win.document || { head: {} };
2456
- const plt = {
2457
- $flags$: 0,
2458
- $resourcesUrl$: '',
2459
- jmp: (h) => h(),
2460
- raf: (h) => requestAnimationFrame(h),
2461
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
2462
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2463
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
2464
- };
2465
- const supportsListenerOptions = /*@__PURE__*/ (() => {
2466
- let supportsListenerOptions = false;
2467
- try {
2468
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
2469
- get() {
2470
- supportsListenerOptions = true;
2471
- },
2472
- }));
2473
- }
2474
- catch (e) { }
2475
- return supportsListenerOptions;
2476
- })();
2477
- const promiseResolve = (v) => Promise.resolve(v);
2478
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2479
- try {
2480
- new CSSStyleSheet();
2481
- return typeof new CSSStyleSheet().replaceSync === 'function';
2482
- }
2483
- catch (e) { }
2484
- return false;
2485
- })()
2486
- ;
2487
- const queueDomReads = [];
2488
- const queueDomWrites = [];
2489
- const queueTask = (queue, write) => (cb) => {
2490
- queue.push(cb);
2491
- if (!queuePending) {
2492
- queuePending = true;
2493
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2494
- nextTick(flush);
2495
- }
2496
- else {
2497
- plt.raf(flush);
2498
- }
2499
- }
2500
- };
2501
- const consume = (queue) => {
2502
- for (let i = 0; i < queue.length; i++) {
2503
- try {
2504
- queue[i](performance.now());
2505
- }
2506
- catch (e) {
2507
- consoleError(e);
2508
- }
2509
- }
2510
- queue.length = 0;
2511
- };
2512
- const flush = () => {
2513
- // always force a bunch of medium callbacks to run, but still have
2514
- // a throttle on how many can run in a certain time
2515
- // DOM READS!!!
2516
- consume(queueDomReads);
2517
- // DOM WRITES!!!
2518
- {
2519
- consume(queueDomWrites);
2520
- if ((queuePending = queueDomReads.length > 0)) {
2521
- // still more to do yet, but we've run out of time
2522
- // let's let this thing cool off and try again in the next tick
2523
- plt.raf(flush);
2524
- }
2525
- }
2526
- };
2527
- const nextTick = (cb) => promiseResolve().then(cb);
2528
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2529
-
2530
- export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
2531
-
2532
- //# sourceMappingURL=index-e479d5ae.js.map