@ionic/core 7.8.1-dev.11710452743.1ca99e5e → 7.8.1-dev.11710856611.1a76ae36

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