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