@mgdis/mg-components 5.27.1 → 5.27.3

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