@dso-toolkit/core 62.21.0 → 62.23.0

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