voyager-ionic-core 8.0.0 → 8.0.1

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 (350) hide show
  1. package/components/input-shims.js +5 -5
  2. package/components/ion-input.js +12 -3
  3. package/dist/cjs/{app-globals-5bfa2d7f.js → app-globals-542c4d91.js} +1 -1
  4. package/dist/cjs/{button-active-564be49f.js → button-active-47528f4c.js} +1 -1
  5. package/dist/cjs/{hardware-back-button-44e7c052.js → hardware-back-button-06ae4d9c.js} +2 -2
  6. package/dist/cjs/index-1437d080.js +11980 -0
  7. package/dist/cjs/{index-defd575f.js → index-57b504ac.js} +2 -2
  8. package/dist/cjs/{index-6d6ac424.js → index-c76a1d14.js} +3 -3
  9. package/dist/cjs/index.cjs.js +8 -8
  10. package/dist/cjs/{input-shims-20d639e6.js → input-shims-9e59ef62.js} +5 -5
  11. package/dist/cjs/ion-accordion_2.cjs.entry.js +2 -2
  12. package/dist/cjs/ion-action-sheet.cjs.entry.js +5 -5
  13. package/dist/cjs/ion-alert.cjs.entry.js +5 -5
  14. package/dist/cjs/ion-app_8.cjs.entry.js +7 -7
  15. package/dist/cjs/ion-avatar_3.cjs.entry.js +2 -2
  16. package/dist/cjs/ion-back-button.cjs.entry.js +2 -2
  17. package/dist/cjs/ion-backdrop.cjs.entry.js +2 -2
  18. package/dist/cjs/ion-breadcrumb_2.cjs.entry.js +2 -2
  19. package/dist/cjs/ion-button_2.cjs.entry.js +2 -2
  20. package/dist/cjs/ion-card_5.cjs.entry.js +2 -2
  21. package/dist/cjs/ion-checkbox.cjs.entry.js +2 -2
  22. package/dist/cjs/ion-chip.cjs.entry.js +2 -2
  23. package/dist/cjs/ion-col_3.cjs.entry.js +2 -2
  24. package/dist/cjs/ion-datetime-button.cjs.entry.js +2 -2
  25. package/dist/cjs/ion-datetime_3.cjs.entry.js +4 -4
  26. package/dist/cjs/ion-fab_3.cjs.entry.js +2 -2
  27. package/dist/cjs/ion-img.cjs.entry.js +2 -2
  28. package/dist/cjs/ion-infinite-scroll_2.cjs.entry.js +2 -2
  29. package/dist/cjs/ion-input-password-toggle.cjs.entry.js +2 -2
  30. package/dist/cjs/ion-input.cjs.entry.js +14 -5
  31. package/dist/cjs/ion-item-option_3.cjs.entry.js +2 -2
  32. package/dist/cjs/ion-item_8.cjs.entry.js +2 -2
  33. package/dist/cjs/ion-loading.cjs.entry.js +4 -4
  34. package/dist/cjs/ion-menu_3.cjs.entry.js +5 -5
  35. package/dist/cjs/ion-modal.cjs.entry.js +5 -5
  36. package/dist/cjs/ion-nav_2.cjs.entry.js +3 -3
  37. package/dist/cjs/ion-picker-column-option.cjs.entry.js +2 -2
  38. package/dist/cjs/ion-picker-column.cjs.entry.js +2 -2
  39. package/dist/cjs/ion-picker.cjs.entry.js +1 -1
  40. package/dist/cjs/ion-popover.cjs.entry.js +5 -5
  41. package/dist/cjs/ion-progress-bar.cjs.entry.js +2 -2
  42. package/dist/cjs/ion-radio_2.cjs.entry.js +2 -2
  43. package/dist/cjs/ion-range.cjs.entry.js +2 -2
  44. package/dist/cjs/ion-refresher_2.cjs.entry.js +2 -2
  45. package/dist/cjs/ion-reorder_2.cjs.entry.js +2 -2
  46. package/dist/cjs/ion-ripple-effect.cjs.entry.js +2 -2
  47. package/dist/cjs/ion-route_4.cjs.entry.js +2 -2
  48. package/dist/cjs/ion-searchbar.cjs.entry.js +2 -2
  49. package/dist/cjs/ion-segment_2.cjs.entry.js +2 -2
  50. package/dist/cjs/ion-select_3.cjs.entry.js +4 -4
  51. package/dist/cjs/ion-spinner.cjs.entry.js +2 -2
  52. package/dist/cjs/ion-split-pane.cjs.entry.js +2 -2
  53. package/dist/cjs/ion-tab-bar_2.cjs.entry.js +2 -2
  54. package/dist/cjs/ion-tab_2.cjs.entry.js +1 -1
  55. package/dist/cjs/ion-text.cjs.entry.js +2 -2
  56. package/dist/cjs/ion-textarea.cjs.entry.js +2 -2
  57. package/dist/cjs/ion-toast.cjs.entry.js +4 -4
  58. package/dist/cjs/ion-toggle.cjs.entry.js +2 -2
  59. package/dist/cjs/{ionic-global-62487d02.js → ionic-global-f3622afe.js} +1 -1
  60. package/dist/cjs/ionic.cjs.js +30 -32
  61. package/dist/cjs/{ios.transition-d4f0ca4e.js → ios.transition-288dfa83.js} +2 -2
  62. package/dist/cjs/loader.cjs.js +3 -3
  63. package/dist/cjs/{md.transition-857328f3.js → md.transition-6e5f6a8d.js} +2 -2
  64. package/dist/cjs/{overlays-10c452b2.js → overlays-32cfd236.js} +2 -2
  65. package/dist/cjs/{status-tap-81daddfa.js → status-tap-c47ff5f5.js} +1 -1
  66. package/dist/collection/collection-manifest.json +2 -2
  67. package/dist/collection/components/datetime/test/color/datetime.e2e.js +14 -7
  68. package/dist/collection/components/input/input.js +12 -3
  69. package/dist/collection/components/toggle/test/enable-on-off-labels/toggle.e2e.js +51 -31
  70. package/dist/collection/utils/input-shims/hacks/scroll-assist.js +5 -5
  71. package/dist/collection/utils/test/playwright/page/utils/goto.js +12 -3
  72. package/dist/docs.json +3 -3
  73. package/dist/esm/{app-globals-49873df1.js → app-globals-3cbaf9d9.js} +1 -1
  74. package/dist/esm/{button-active-46df59c1.js → button-active-9e3c1f3b.js} +1 -1
  75. package/dist/esm/{hardware-back-button-ba8f64c2.js → hardware-back-button-804f43bb.js} +2 -2
  76. package/dist/esm/index-5dc2b88e.js +11942 -0
  77. package/dist/esm/{index-56d90da9.js → index-8dbae644.js} +2 -2
  78. package/dist/esm/{index-f0d7371a.js → index-f7fbe1fb.js} +3 -3
  79. package/dist/esm/index.js +8 -8
  80. package/dist/esm/{input-shims-4530285e.js → input-shims-0314bbe5.js} +5 -5
  81. package/dist/esm/ion-accordion_2.entry.js +2 -2
  82. package/dist/esm/ion-action-sheet.entry.js +5 -5
  83. package/dist/esm/ion-alert.entry.js +5 -5
  84. package/dist/esm/ion-app_8.entry.js +7 -7
  85. package/dist/esm/ion-avatar_3.entry.js +2 -2
  86. package/dist/esm/ion-back-button.entry.js +2 -2
  87. package/dist/esm/ion-backdrop.entry.js +2 -2
  88. package/dist/esm/ion-breadcrumb_2.entry.js +2 -2
  89. package/dist/esm/ion-button_2.entry.js +2 -2
  90. package/dist/esm/ion-card_5.entry.js +2 -2
  91. package/dist/esm/ion-checkbox.entry.js +2 -2
  92. package/dist/esm/ion-chip.entry.js +2 -2
  93. package/dist/esm/ion-col_3.entry.js +2 -2
  94. package/dist/esm/ion-datetime-button.entry.js +2 -2
  95. package/dist/esm/ion-datetime_3.entry.js +4 -4
  96. package/dist/esm/ion-fab_3.entry.js +2 -2
  97. package/dist/esm/ion-img.entry.js +2 -2
  98. package/dist/esm/ion-infinite-scroll_2.entry.js +2 -2
  99. package/dist/esm/ion-input-password-toggle.entry.js +2 -2
  100. package/dist/esm/ion-input.entry.js +14 -5
  101. package/dist/esm/ion-item-option_3.entry.js +2 -2
  102. package/dist/esm/ion-item_8.entry.js +2 -2
  103. package/dist/esm/ion-loading.entry.js +4 -4
  104. package/dist/esm/ion-menu_3.entry.js +5 -5
  105. package/dist/esm/ion-modal.entry.js +5 -5
  106. package/dist/esm/ion-nav_2.entry.js +3 -3
  107. package/dist/esm/ion-picker-column-option.entry.js +2 -2
  108. package/dist/esm/ion-picker-column.entry.js +2 -2
  109. package/dist/esm/ion-picker.entry.js +1 -1
  110. package/dist/esm/ion-popover.entry.js +5 -5
  111. package/dist/esm/ion-progress-bar.entry.js +2 -2
  112. package/dist/esm/ion-radio_2.entry.js +2 -2
  113. package/dist/esm/ion-range.entry.js +2 -2
  114. package/dist/esm/ion-refresher_2.entry.js +2 -2
  115. package/dist/esm/ion-reorder_2.entry.js +2 -2
  116. package/dist/esm/ion-ripple-effect.entry.js +2 -2
  117. package/dist/esm/ion-route_4.entry.js +2 -2
  118. package/dist/esm/ion-searchbar.entry.js +2 -2
  119. package/dist/esm/ion-segment_2.entry.js +2 -2
  120. package/dist/esm/ion-select_3.entry.js +4 -4
  121. package/dist/esm/ion-spinner.entry.js +2 -2
  122. package/dist/esm/ion-split-pane.entry.js +2 -2
  123. package/dist/esm/ion-tab-bar_2.entry.js +2 -2
  124. package/dist/esm/ion-tab_2.entry.js +1 -1
  125. package/dist/esm/ion-text.entry.js +2 -2
  126. package/dist/esm/ion-textarea.entry.js +2 -2
  127. package/dist/esm/ion-toast.entry.js +4 -4
  128. package/dist/esm/ion-toggle.entry.js +2 -2
  129. package/dist/esm/{ionic-global-e6c98cd0.js → ionic-global-d2d8f882.js} +1 -1
  130. package/dist/esm/ionic.js +31 -33
  131. package/dist/esm/{ios.transition-71bfa932.js → ios.transition-a0041e41.js} +2 -2
  132. package/dist/esm/loader.js +4 -4
  133. package/dist/esm/{md.transition-86aef3c0.js → md.transition-0c0602d9.js} +2 -2
  134. package/dist/esm/{overlays-6fb4a2f2.js → overlays-696d25f5.js} +2 -2
  135. package/dist/esm/{status-tap-299361cd.js → status-tap-37a74d1c.js} +1 -1
  136. package/dist/esm-es5/app-globals-3cbaf9d9.js +4 -0
  137. package/dist/esm-es5/{button-active-46df59c1.js → button-active-9e3c1f3b.js} +1 -1
  138. package/dist/esm-es5/{hardware-back-button-ba8f64c2.js → hardware-back-button-804f43bb.js} +1 -1
  139. package/dist/esm-es5/index-5dc2b88e.js +18 -0
  140. package/dist/esm-es5/{index-56d90da9.js → index-8dbae644.js} +1 -1
  141. package/dist/esm-es5/{index-f0d7371a.js → index-f7fbe1fb.js} +1 -1
  142. package/dist/esm-es5/index.js +1 -1
  143. package/dist/esm-es5/input-shims-0314bbe5.js +4 -0
  144. package/dist/esm-es5/ion-accordion_2.entry.js +1 -1
  145. package/dist/esm-es5/ion-action-sheet.entry.js +1 -1
  146. package/dist/esm-es5/ion-alert.entry.js +1 -1
  147. package/dist/esm-es5/ion-app_8.entry.js +1 -1
  148. package/dist/esm-es5/ion-avatar_3.entry.js +1 -1
  149. package/dist/esm-es5/ion-back-button.entry.js +1 -1
  150. package/dist/esm-es5/ion-backdrop.entry.js +1 -1
  151. package/dist/esm-es5/ion-breadcrumb_2.entry.js +1 -1
  152. package/dist/esm-es5/ion-button_2.entry.js +1 -1
  153. package/dist/esm-es5/ion-card_5.entry.js +1 -1
  154. package/dist/esm-es5/ion-checkbox.entry.js +1 -1
  155. package/dist/esm-es5/ion-chip.entry.js +1 -1
  156. package/dist/esm-es5/ion-col_3.entry.js +1 -1
  157. package/dist/esm-es5/ion-datetime-button.entry.js +1 -1
  158. package/dist/esm-es5/ion-datetime_3.entry.js +1 -1
  159. package/dist/esm-es5/ion-fab_3.entry.js +1 -1
  160. package/dist/esm-es5/ion-img.entry.js +1 -1
  161. package/dist/esm-es5/ion-infinite-scroll_2.entry.js +1 -1
  162. package/dist/esm-es5/ion-input-password-toggle.entry.js +1 -1
  163. package/dist/esm-es5/ion-input.entry.js +1 -1
  164. package/dist/esm-es5/ion-item-option_3.entry.js +1 -1
  165. package/dist/esm-es5/ion-item_8.entry.js +1 -1
  166. package/dist/esm-es5/ion-loading.entry.js +1 -1
  167. package/dist/esm-es5/ion-menu_3.entry.js +1 -1
  168. package/dist/esm-es5/ion-modal.entry.js +1 -1
  169. package/dist/esm-es5/ion-nav_2.entry.js +1 -1
  170. package/dist/esm-es5/ion-picker-column-option.entry.js +1 -1
  171. package/dist/esm-es5/ion-picker-column.entry.js +1 -1
  172. package/dist/esm-es5/ion-picker.entry.js +1 -1
  173. package/dist/esm-es5/ion-popover.entry.js +1 -1
  174. package/dist/esm-es5/ion-progress-bar.entry.js +1 -1
  175. package/dist/esm-es5/ion-radio_2.entry.js +1 -1
  176. package/dist/esm-es5/ion-range.entry.js +1 -1
  177. package/dist/esm-es5/ion-refresher_2.entry.js +1 -1
  178. package/dist/esm-es5/ion-reorder_2.entry.js +1 -1
  179. package/dist/esm-es5/ion-ripple-effect.entry.js +1 -1
  180. package/dist/esm-es5/ion-route_4.entry.js +1 -1
  181. package/dist/esm-es5/ion-searchbar.entry.js +1 -1
  182. package/dist/esm-es5/ion-segment_2.entry.js +1 -1
  183. package/dist/esm-es5/ion-select_3.entry.js +1 -1
  184. package/dist/esm-es5/ion-spinner.entry.js +1 -1
  185. package/dist/esm-es5/ion-split-pane.entry.js +1 -1
  186. package/dist/esm-es5/ion-tab-bar_2.entry.js +1 -1
  187. package/dist/esm-es5/ion-tab_2.entry.js +1 -1
  188. package/dist/esm-es5/ion-text.entry.js +1 -1
  189. package/dist/esm-es5/ion-textarea.entry.js +1 -1
  190. package/dist/esm-es5/ion-toast.entry.js +1 -1
  191. package/dist/esm-es5/ion-toggle.entry.js +1 -1
  192. package/dist/esm-es5/{ionic-global-e6c98cd0.js → ionic-global-d2d8f882.js} +1 -1
  193. package/dist/esm-es5/ionic.js +1 -1
  194. package/dist/esm-es5/{ios.transition-71bfa932.js → ios.transition-a0041e41.js} +1 -1
  195. package/dist/esm-es5/loader.js +1 -1
  196. package/dist/esm-es5/md.transition-0c0602d9.js +4 -0
  197. package/dist/esm-es5/{overlays-6fb4a2f2.js → overlays-696d25f5.js} +1 -1
  198. package/dist/esm-es5/{status-tap-299361cd.js → status-tap-37a74d1c.js} +1 -1
  199. package/dist/ionic/index.esm.js +1 -1
  200. package/dist/ionic/ionic.esm.js +1 -1
  201. package/dist/ionic/ionic.js +1 -1
  202. package/dist/ionic/p-051d2d23.js +4 -0
  203. package/dist/ionic/{p-5ad55625.entry.js → p-057b5866.entry.js} +1 -1
  204. package/dist/ionic/p-06d5221c.js +4 -0
  205. package/dist/ionic/{p-510cb8e6.system.js → p-06fad524.system.js} +1 -1
  206. package/dist/ionic/p-08c4d048.entry.js +4 -0
  207. package/dist/ionic/{p-530207f9.entry.js → p-0af79ebd.entry.js} +1 -1
  208. package/dist/ionic/{p-6cf780b6.system.entry.js → p-0b12d1ee.system.entry.js} +1 -1
  209. package/dist/ionic/p-0d56dea9.entry.js +4 -0
  210. package/dist/ionic/{p-5c26fed5.system.entry.js → p-0d960144.system.entry.js} +1 -1
  211. package/dist/ionic/{p-dc4406d7.system.entry.js → p-13bfcef4.system.entry.js} +1 -1
  212. package/dist/ionic/{p-91dabef7.system.js → p-16016625.system.js} +1 -1
  213. package/dist/ionic/{p-e93cd31c.entry.js → p-1930d8e7.entry.js} +1 -1
  214. package/dist/ionic/{p-7bbcce53.system.js → p-1980c728.system.js} +1 -1
  215. package/dist/ionic/{p-53d69c70.system.entry.js → p-1a5227b3.system.entry.js} +1 -1
  216. package/dist/ionic/{p-6ac30fc3.system.js → p-1e4d7975.system.js} +1 -1
  217. package/dist/ionic/{p-0e713efe.js → p-20304962.js} +1 -1
  218. package/dist/ionic/p-23e440b6.entry.js +4 -0
  219. package/dist/ionic/{p-46111310.js → p-2690b1de.js} +1 -1
  220. package/dist/ionic/{p-91b568e2.system.entry.js → p-26d33af2.system.entry.js} +1 -1
  221. package/dist/ionic/{p-aea5f293.system.entry.js → p-283fd4e1.system.entry.js} +1 -1
  222. package/dist/ionic/{p-98af538a.system.entry.js → p-2a3e98fb.system.entry.js} +1 -1
  223. package/dist/ionic/{p-814efd87.system.entry.js → p-2ab5db0d.system.entry.js} +1 -1
  224. package/dist/ionic/{p-55bc2a11.system.entry.js → p-2b1e669d.system.entry.js} +1 -1
  225. package/dist/ionic/{p-3d977e09.system.entry.js → p-2c3c7cb9.system.entry.js} +1 -1
  226. package/dist/ionic/{p-9ccc8035.system.entry.js → p-2dfdda15.system.entry.js} +1 -1
  227. package/dist/ionic/{p-aa79cc0e.system.entry.js → p-2f308f7f.system.entry.js} +1 -1
  228. package/dist/ionic/p-2fa34b5c.entry.js +4 -0
  229. package/dist/ionic/p-32048e4c.system.js +18 -0
  230. package/dist/ionic/{p-e099a6f3.entry.js → p-320cfcab.entry.js} +1 -1
  231. package/dist/ionic/{p-4fadf4b0.entry.js → p-33d926c3.entry.js} +1 -1
  232. package/dist/ionic/{p-83b445c3.js → p-34511b1d.js} +1 -1
  233. package/dist/ionic/{p-a39a73e3.entry.js → p-385964e6.entry.js} +1 -1
  234. package/dist/ionic/{p-f956e38a.entry.js → p-3f5b86b4.entry.js} +1 -1
  235. package/dist/ionic/{p-6ef17d86.system.entry.js → p-42f00e72.system.entry.js} +1 -1
  236. package/dist/ionic/{p-eda2459e.entry.js → p-4324e8a4.entry.js} +1 -1
  237. package/dist/ionic/{p-ca5bb110.system.entry.js → p-45034312.system.entry.js} +1 -1
  238. package/dist/ionic/{p-9fa5ff32.system.js → p-45664cb9.system.js} +1 -1
  239. package/dist/ionic/{p-4a01cec0.entry.js → p-470f73c4.entry.js} +1 -1
  240. package/dist/ionic/{p-904df2ee.system.entry.js → p-48888af6.system.entry.js} +1 -1
  241. package/dist/ionic/{p-341b3f37.entry.js → p-49cdc4f2.entry.js} +1 -1
  242. package/dist/ionic/p-4ad48ec9.system.entry.js +4 -0
  243. package/dist/ionic/p-4af0b730.js +8 -0
  244. package/dist/ionic/{p-ad2b9596.entry.js → p-4c153abb.entry.js} +1 -1
  245. package/dist/ionic/{p-ffbc80ae.system.js → p-4e5288de.system.js} +1 -1
  246. package/dist/ionic/{p-aa8a2f40.system.entry.js → p-4e548bd7.system.entry.js} +1 -1
  247. package/dist/ionic/{p-ac045dad.entry.js → p-4fcef939.entry.js} +1 -1
  248. package/dist/ionic/{p-c54b167f.system.entry.js → p-53a3b33c.system.entry.js} +1 -1
  249. package/dist/ionic/{p-a28ea4d8.system.entry.js → p-567a21a2.system.entry.js} +1 -1
  250. package/dist/ionic/{p-cf8101a6.system.entry.js → p-576786c0.system.entry.js} +1 -1
  251. package/dist/ionic/{p-c2762c6a.system.entry.js → p-583f8865.system.entry.js} +1 -1
  252. package/dist/ionic/p-58f89707.js +4 -0
  253. package/dist/ionic/{p-7492572a.entry.js → p-5a3a3373.entry.js} +1 -1
  254. package/dist/ionic/{p-f13dc6bd.system.entry.js → p-5d3a8503.system.entry.js} +1 -1
  255. package/dist/ionic/{p-987e38ef.system.entry.js → p-5d4d89e0.system.entry.js} +1 -1
  256. package/dist/ionic/{p-e1ad8e76.entry.js → p-5d80b741.entry.js} +1 -1
  257. package/dist/ionic/{p-c927dbe2.system.entry.js → p-5fbc2eae.system.entry.js} +1 -1
  258. package/dist/ionic/{p-e6d46b5d.system.entry.js → p-5ff497dc.system.entry.js} +1 -1
  259. package/dist/ionic/{p-df0d39c7.system.entry.js → p-63265e00.system.entry.js} +1 -1
  260. package/dist/ionic/{p-6e4dac1a.entry.js → p-6730a2f1.entry.js} +1 -1
  261. package/dist/ionic/{p-e81c3ca2.system.entry.js → p-6e9bd6ba.system.entry.js} +1 -1
  262. package/dist/ionic/{p-1c42ad90.entry.js → p-70181008.entry.js} +1 -1
  263. package/dist/ionic/{p-332aa81e.entry.js → p-720927ad.entry.js} +1 -1
  264. package/dist/ionic/{p-b4a7f856.system.entry.js → p-748e6b2b.system.entry.js} +1 -1
  265. package/dist/ionic/{p-c4e495a3.system.js → p-7536b4b3.system.js} +1 -1
  266. package/dist/ionic/{p-67f5b57a.js → p-77ce6034.js} +1 -1
  267. package/dist/ionic/{p-1b0f4e6c.entry.js → p-7ef5bb32.entry.js} +1 -1
  268. package/dist/ionic/{p-4f6ebc2b.entry.js → p-7f59064a.entry.js} +1 -1
  269. package/dist/ionic/{p-7a7ff5e3.system.js → p-806aad8f.system.js} +1 -1
  270. package/dist/ionic/{p-275dd0ba.system.entry.js → p-80f85095.system.entry.js} +1 -1
  271. package/dist/ionic/{p-c4eafa12.system.entry.js → p-819e8479.system.entry.js} +1 -1
  272. package/dist/ionic/{p-68afa357.system.entry.js → p-8627f783.system.entry.js} +1 -1
  273. package/dist/ionic/{p-f6fec6a0.entry.js → p-8664c316.entry.js} +1 -1
  274. package/dist/ionic/p-8c4fc85f.system.js +4 -0
  275. package/dist/ionic/{p-7c93f00b.system.entry.js → p-8caca06c.system.entry.js} +1 -1
  276. package/dist/ionic/{p-ba35f07f.entry.js → p-8e031d97.entry.js} +1 -1
  277. package/dist/ionic/{p-7372cf23.system.entry.js → p-8f48c966.system.entry.js} +1 -1
  278. package/dist/ionic/{p-fea11771.entry.js → p-9384565a.entry.js} +1 -1
  279. package/dist/ionic/{p-3de2aab8.system.entry.js → p-93e43f42.system.entry.js} +1 -1
  280. package/dist/ionic/{p-e8a713b5.entry.js → p-94180ecc.entry.js} +1 -1
  281. package/dist/ionic/{p-4f77a080.system.entry.js → p-94731a92.system.entry.js} +1 -1
  282. package/dist/ionic/{p-1ba197b6.entry.js → p-9b31ebfa.entry.js} +1 -1
  283. package/dist/ionic/{p-7f33a6e2.system.entry.js → p-a592f1b8.system.entry.js} +2 -2
  284. package/dist/ionic/{p-e548fedf.system.entry.js → p-a801da4b.system.entry.js} +1 -1
  285. package/dist/ionic/{p-4809ddae.system.entry.js → p-aa0ed22b.system.entry.js} +1 -1
  286. package/dist/ionic/{p-07584ab4.system.js → p-aa0f60b2.system.js} +1 -1
  287. package/dist/ionic/{p-dec86943.entry.js → p-adb896a0.entry.js} +1 -1
  288. package/dist/ionic/{p-e5a3659f.system.js → p-b0093947.system.js} +1 -1
  289. package/dist/ionic/{p-1fe1f512.entry.js → p-b571cab1.entry.js} +1 -1
  290. package/dist/ionic/{p-e292247e.system.entry.js → p-b76bcd9e.system.entry.js} +1 -1
  291. package/dist/ionic/{p-dbc3e90c.entry.js → p-b799a007.entry.js} +1 -1
  292. package/dist/ionic/{p-3008ca4e.system.entry.js → p-bbbe3138.system.entry.js} +1 -1
  293. package/dist/ionic/p-bd6d9610.entry.js +4 -0
  294. package/dist/ionic/{p-bc3d649d.entry.js → p-bdd3053f.entry.js} +1 -1
  295. package/dist/ionic/{p-90f8498c.entry.js → p-c07e7a5d.entry.js} +1 -1
  296. package/dist/ionic/{p-151e8afd.entry.js → p-c23627c3.entry.js} +1 -1
  297. package/dist/ionic/{p-f8f8c5a8.system.entry.js → p-c3ca0292.system.entry.js} +1 -1
  298. package/dist/ionic/p-c4676693.entry.js +4 -0
  299. package/dist/ionic/{p-cbd87df6.entry.js → p-c62571da.entry.js} +1 -1
  300. package/dist/ionic/{p-96a561dd.js → p-c671b28e.js} +1 -1
  301. package/dist/ionic/{p-e781c893.entry.js → p-c7e0b81a.entry.js} +1 -1
  302. package/dist/ionic/{p-405fd996.entry.js → p-c9ba1908.entry.js} +1 -1
  303. package/dist/ionic/{p-2613c305.system.js → p-cb4f96f3.system.js} +1 -1
  304. package/dist/ionic/p-cc856712.entry.js +4 -0
  305. package/dist/ionic/{p-a90201f2.js → p-cd1b9056.js} +1 -1
  306. package/dist/ionic/{p-9fd3ca09.system.entry.js → p-cdee3a44.system.entry.js} +1 -1
  307. package/dist/ionic/{p-8f9e2850.js → p-d11c336d.js} +1 -1
  308. package/dist/ionic/{p-48f60474.entry.js → p-d1a8f599.entry.js} +1 -1
  309. package/dist/ionic/{p-2b86020c.system.entry.js → p-d6229f05.system.entry.js} +1 -1
  310. package/dist/ionic/{p-cf45a5c7.system.entry.js → p-d918e7ef.system.entry.js} +1 -1
  311. package/dist/ionic/{p-4edce583.system.entry.js → p-df062892.system.entry.js} +1 -1
  312. package/dist/ionic/p-dfb78785.system.js +4 -0
  313. package/dist/ionic/{p-005deca1.system.entry.js → p-e3005be4.system.entry.js} +1 -1
  314. package/dist/ionic/p-e49099b0.entry.js +4 -0
  315. package/dist/ionic/{p-ca6decbd.entry.js → p-e885f3c4.entry.js} +1 -1
  316. package/dist/ionic/{p-50205ef9.system.entry.js → p-e9ef13be.system.entry.js} +1 -1
  317. package/dist/ionic/{p-b6519a42.entry.js → p-ebe0aa6d.entry.js} +1 -1
  318. package/dist/ionic/{p-1472c130.entry.js → p-ee3bbaf2.entry.js} +1 -1
  319. package/dist/ionic/{p-6dc81903.entry.js → p-f0be340f.entry.js} +1 -1
  320. package/dist/ionic/p-f5c42f72.entry.js +4 -0
  321. package/dist/ionic/{p-53d37363.entry.js → p-fc94e18f.entry.js} +1 -1
  322. package/dist/ionic/{p-d061515d.system.entry.js → p-fd392e7f.system.entry.js} +1 -1
  323. package/dist/ionic/p-fdf40b09.js +4 -0
  324. package/hydrate/index.d.ts +1 -1
  325. package/hydrate/index.js +13466 -8294
  326. package/package.json +2 -2
  327. package/dist/cjs/index-bbc6c29f.js +0 -3324
  328. package/dist/esm/index-bcd8859b.js +0 -3286
  329. package/dist/esm-es5/app-globals-49873df1.js +0 -4
  330. package/dist/esm-es5/index-bcd8859b.js +0 -5
  331. package/dist/esm-es5/input-shims-4530285e.js +0 -4
  332. package/dist/esm-es5/md.transition-86aef3c0.js +0 -4
  333. package/dist/ionic/p-0bd47555.js +0 -4
  334. package/dist/ionic/p-13cc6ee6.entry.js +0 -4
  335. package/dist/ionic/p-1fa53d02.entry.js +0 -4
  336. package/dist/ionic/p-23fdee0e.entry.js +0 -4
  337. package/dist/ionic/p-46f407f0.system.js +0 -4
  338. package/dist/ionic/p-495ed1c3.entry.js +0 -4
  339. package/dist/ionic/p-4de53118.js +0 -4
  340. package/dist/ionic/p-582db405.system.entry.js +0 -4
  341. package/dist/ionic/p-5f28cb75.js +0 -4
  342. package/dist/ionic/p-6c5c1bb5.system.js +0 -4
  343. package/dist/ionic/p-7596e24d.system.js +0 -5
  344. package/dist/ionic/p-76971b4f.entry.js +0 -4
  345. package/dist/ionic/p-8a5152e5.entry.js +0 -4
  346. package/dist/ionic/p-ae42c907.entry.js +0 -4
  347. package/dist/ionic/p-c1c77386.js +0 -5
  348. package/dist/ionic/p-d73f49d0.entry.js +0 -4
  349. package/dist/ionic/p-ec178f19.entry.js +0 -4
  350. package/dist/ionic/p-f6ca4d02.js +0 -4
@@ -1,3324 +0,0 @@
1
- /*!
2
- * (C) Ionic http://ionicframework.com - MIT License
3
- */
4
- 'use strict';
5
-
6
- function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () {
16
- return e[k];
17
- }
18
- });
19
- }
20
- });
21
- }
22
- n['default'] = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- const NAMESPACE = 'ionic';
27
- const BUILD = /* ionic */ { allRenderFn: false, appendChildSlotFix: true, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: true, 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: true, experimentalSlotFixes: true, 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: true, scriptDataOpts: false, shadowDelegatesFocus: true, shadowDom: true, slot: true, slotChildNodesFix: true, 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 };
28
-
29
- /**
30
- * Virtual DOM patching algorithm based on Snabbdom by
31
- * Simon Friis Vindum (@paldepind)
32
- * Licensed under the MIT License
33
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
34
- *
35
- * Modified for Stencil's renderer and slot projection
36
- */
37
- let scopeId;
38
- let contentRef;
39
- let hostTagName;
40
- let useNativeShadowDom = false;
41
- let checkSlotFallbackVisibility = false;
42
- let checkSlotRelocate = false;
43
- let isSvgMode = false;
44
- let queuePending = false;
45
- const Build = {
46
- isDev: false,
47
- isBrowser: true,
48
- isServer: false,
49
- isTesting: false,
50
- };
51
- const getAssetPath = (path) => {
52
- const assetUrl = new URL(path, plt.$resourcesUrl$);
53
- return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
54
- };
55
- const createTime = (fnName, tagName = '') => {
56
- {
57
- return () => {
58
- return;
59
- };
60
- }
61
- };
62
- const uniqueTime = (key, measureText) => {
63
- {
64
- return () => {
65
- return;
66
- };
67
- }
68
- };
69
- const CONTENT_REF_ID = 'r';
70
- const ORG_LOCATION_ID = 'o';
71
- const SLOT_NODE_ID = 's';
72
- const TEXT_NODE_ID = 't';
73
- const HYDRATE_ID = 's-id';
74
- const HYDRATED_STYLE_ID = 'sty-id';
75
- const HYDRATE_CHILD_ID = 'c-id';
76
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
77
- /**
78
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
79
- *
80
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
81
- * support as of Stencil v4.
82
- */
83
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
84
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
85
- /**
86
- * Default style mode id
87
- */
88
- /**
89
- * Reusable empty obj/array
90
- * Don't add values to these!!
91
- */
92
- const EMPTY_OBJ = {};
93
- /**
94
- * Namespaces
95
- */
96
- const SVG_NS = 'http://www.w3.org/2000/svg';
97
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
98
- const isDef = (v) => v != null;
99
- /**
100
- * Check whether a value is a 'complex type', defined here as an object or a
101
- * function.
102
- *
103
- * @param o the value to check
104
- * @returns whether it's a complex type or not
105
- */
106
- const isComplexType = (o) => {
107
- // https://jsperf.com/typeof-fn-object/5
108
- o = typeof o;
109
- return o === 'object' || o === 'function';
110
- };
111
- /**
112
- * Helper method for querying a `meta` tag that contains a nonce value
113
- * out of a DOM's head.
114
- *
115
- * @param doc The DOM containing the `head` to query against
116
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
117
- * exists or the tag has no content.
118
- */
119
- function queryNonceMetaTagContent(doc) {
120
- var _a, _b, _c;
121
- 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;
122
- }
123
- /**
124
- * Production h() function based on Preact by
125
- * Jason Miller (@developit)
126
- * Licensed under the MIT License
127
- * https://github.com/developit/preact/blob/master/LICENSE
128
- *
129
- * Modified for Stencil's compiler and vdom
130
- */
131
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
132
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
133
- const h = (nodeName, vnodeData, ...children) => {
134
- let child = null;
135
- let key = null;
136
- let slotName = null;
137
- let simple = false;
138
- let lastSimple = false;
139
- const vNodeChildren = [];
140
- const walk = (c) => {
141
- for (let i = 0; i < c.length; i++) {
142
- child = c[i];
143
- if (Array.isArray(child)) {
144
- walk(child);
145
- }
146
- else if (child != null && typeof child !== 'boolean') {
147
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
148
- child = String(child);
149
- }
150
- if (simple && lastSimple) {
151
- // If the previous child was simple (string), we merge both
152
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
153
- }
154
- else {
155
- // Append a new vNode, if it's text, we create a text vNode
156
- vNodeChildren.push(simple ? newVNode(null, child) : child);
157
- }
158
- lastSimple = simple;
159
- }
160
- }
161
- };
162
- walk(children);
163
- if (vnodeData) {
164
- if (vnodeData.key) {
165
- key = vnodeData.key;
166
- }
167
- if (vnodeData.name) {
168
- slotName = vnodeData.name;
169
- }
170
- // normalize class / className attributes
171
- {
172
- const classData = vnodeData.className || vnodeData.class;
173
- if (classData) {
174
- vnodeData.class =
175
- typeof classData !== 'object'
176
- ? classData
177
- : Object.keys(classData)
178
- .filter((k) => classData[k])
179
- .join(' ');
180
- }
181
- }
182
- }
183
- if (typeof nodeName === 'function') {
184
- // nodeName is a functional component
185
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
186
- }
187
- const vnode = newVNode(nodeName, null);
188
- vnode.$attrs$ = vnodeData;
189
- if (vNodeChildren.length > 0) {
190
- vnode.$children$ = vNodeChildren;
191
- }
192
- {
193
- vnode.$key$ = key;
194
- }
195
- {
196
- vnode.$name$ = slotName;
197
- }
198
- return vnode;
199
- };
200
- /**
201
- * A utility function for creating a virtual DOM node from a tag and some
202
- * possible text content.
203
- *
204
- * @param tag the tag for this element
205
- * @param text possible text content for the node
206
- * @returns a newly-minted virtual DOM node
207
- */
208
- const newVNode = (tag, text) => {
209
- const vnode = {
210
- $flags$: 0,
211
- $tag$: tag,
212
- $text$: text,
213
- $elm$: null,
214
- $children$: null,
215
- };
216
- {
217
- vnode.$attrs$ = null;
218
- }
219
- {
220
- vnode.$key$ = null;
221
- }
222
- {
223
- vnode.$name$ = null;
224
- }
225
- return vnode;
226
- };
227
- const Host = {};
228
- /**
229
- * Check whether a given node is a Host node or not
230
- *
231
- * @param node the virtual DOM node to check
232
- * @returns whether it's a Host node or not
233
- */
234
- const isHost = (node) => node && node.$tag$ === Host;
235
- /**
236
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
237
- *
238
- * Note that these functions convert from {@link d.VNode} to
239
- * {@link d.ChildNode} to give functional component developers a friendly
240
- * interface.
241
- */
242
- const vdomFnUtils = {
243
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
244
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
245
- };
246
- /**
247
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
248
- * friendlier public interface (hence, 'convertToPublic').
249
- *
250
- * @param node the virtual DOM node to convert
251
- * @returns a converted child node
252
- */
253
- const convertToPublic = (node) => ({
254
- vattrs: node.$attrs$,
255
- vchildren: node.$children$,
256
- vkey: node.$key$,
257
- vname: node.$name$,
258
- vtag: node.$tag$,
259
- vtext: node.$text$,
260
- });
261
- /**
262
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
263
- * order to use the resulting object in the virtual DOM. The initial object was
264
- * likely created as part of presenting a public API, so converting it back
265
- * involved making it 'private' again (hence, `convertToPrivate`).
266
- *
267
- * @param node the child node to convert
268
- * @returns a converted virtual DOM node
269
- */
270
- const convertToPrivate = (node) => {
271
- if (typeof node.vtag === 'function') {
272
- const vnodeData = Object.assign({}, node.vattrs);
273
- if (node.vkey) {
274
- vnodeData.key = node.vkey;
275
- }
276
- if (node.vname) {
277
- vnodeData.name = node.vname;
278
- }
279
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
280
- }
281
- const vnode = newVNode(node.vtag, node.vtext);
282
- vnode.$attrs$ = node.vattrs;
283
- vnode.$children$ = node.vchildren;
284
- vnode.$key$ = node.vkey;
285
- vnode.$name$ = node.vname;
286
- return vnode;
287
- };
288
- /**
289
- * Entrypoint of the client-side hydration process. Facilitates calls to hydrate the
290
- * document and all its nodes.
291
- *
292
- * This process will also reconstruct the shadow root and slot DOM nodes for components using shadow DOM.
293
- *
294
- * @param hostElm The element to hydrate.
295
- * @param tagName The element's tag name.
296
- * @param hostId The host ID assigned to the element by the server.
297
- * @param hostRef The host reference for the element.
298
- */
299
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
300
- const endHydrate = createTime('hydrateClient', tagName);
301
- const shadowRoot = hostElm.shadowRoot;
302
- const childRenderNodes = [];
303
- const slotNodes = [];
304
- const shadowRootNodes = shadowRoot ? [] : null;
305
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
306
- if (!plt.$orgLocNodes$) {
307
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
308
- }
309
- hostElm[HYDRATE_ID] = hostId;
310
- hostElm.removeAttribute(HYDRATE_ID);
311
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
312
- childRenderNodes.map((c) => {
313
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
314
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
315
- const node = c.$elm$;
316
- // Put the node back in its original location since the native Shadow DOM
317
- // can handle rendering it its correct location now
318
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
319
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
320
- }
321
- if (!shadowRoot) {
322
- node['s-hn'] = tagName;
323
- if (orgLocationNode) {
324
- node['s-ol'] = orgLocationNode;
325
- node['s-ol']['s-nr'] = node;
326
- }
327
- }
328
- plt.$orgLocNodes$.delete(orgLocationId);
329
- });
330
- if (shadowRoot) {
331
- shadowRootNodes.map((shadowRootNode) => {
332
- if (shadowRootNode) {
333
- shadowRoot.appendChild(shadowRootNode);
334
- }
335
- });
336
- }
337
- endHydrate();
338
- };
339
- /**
340
- * Recursively constructs the virtual node tree for a host element and its children.
341
- * The tree is constructed by parsing the annotations set on the nodes by the server.
342
- *
343
- * In addition to constructing the vNode tree, we also track information about the node's
344
- * descendants like which are slots, which should exist in the shadow root, and which
345
- * are nodes that should be rendered as children of the parent node.
346
- *
347
- * @param parentVNode The vNode representing the parent node.
348
- * @param childRenderNodes An array of all child nodes in the parent's node tree.
349
- * @param slotNodes An array of all slot nodes in the parent's node tree.
350
- * @param shadowRootNodes An array all nodes that should be rendered in the shadow root in the parent's node tree.
351
- * @param hostElm The parent element.
352
- * @param node The node to construct the vNode tree for.
353
- * @param hostId The host ID assigned to the element by the server.
354
- */
355
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
356
- let childNodeType;
357
- let childIdSplt;
358
- let childVNode;
359
- let i;
360
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
361
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
362
- if (childNodeType) {
363
- // got the node data from the element's attribute
364
- // `${hostId}.${nodeId}.${depth}.${index}`
365
- childIdSplt = childNodeType.split('.');
366
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
367
- childVNode = {
368
- $flags$: 0,
369
- $hostId$: childIdSplt[0],
370
- $nodeId$: childIdSplt[1],
371
- $depth$: childIdSplt[2],
372
- $index$: childIdSplt[3],
373
- $tag$: node.tagName.toLowerCase(),
374
- $elm$: node,
375
- $attrs$: null,
376
- $children$: null,
377
- $key$: null,
378
- $name$: null,
379
- $text$: null,
380
- };
381
- childRenderNodes.push(childVNode);
382
- node.removeAttribute(HYDRATE_CHILD_ID);
383
- // this is a new child vnode
384
- // so ensure its parent vnode has the vchildren array
385
- if (!parentVNode.$children$) {
386
- parentVNode.$children$ = [];
387
- }
388
- // add our child vnode to a specific index of the vnode's children
389
- parentVNode.$children$[childVNode.$index$] = childVNode;
390
- // this is now the new parent vnode for all the next child checks
391
- parentVNode = childVNode;
392
- if (shadowRootNodes && childVNode.$depth$ === '0') {
393
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
394
- }
395
- }
396
- }
397
- // recursively drill down, end to start so we can remove nodes
398
- for (i = node.childNodes.length - 1; i >= 0; i--) {
399
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
400
- }
401
- if (node.shadowRoot) {
402
- // keep drilling down through the shadow root nodes
403
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
404
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
405
- }
406
- }
407
- }
408
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
409
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
410
- childIdSplt = node.nodeValue.split('.');
411
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
412
- // comment node for either the host id or a 0 host id
413
- childNodeType = childIdSplt[0];
414
- childVNode = {
415
- $flags$: 0,
416
- $hostId$: childIdSplt[1],
417
- $nodeId$: childIdSplt[2],
418
- $depth$: childIdSplt[3],
419
- $index$: childIdSplt[4],
420
- $elm$: node,
421
- $attrs$: null,
422
- $children$: null,
423
- $key$: null,
424
- $name$: null,
425
- $tag$: null,
426
- $text$: null,
427
- };
428
- if (childNodeType === TEXT_NODE_ID) {
429
- childVNode.$elm$ = node.nextSibling;
430
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
431
- childVNode.$text$ = childVNode.$elm$.textContent;
432
- childRenderNodes.push(childVNode);
433
- // remove the text comment since it's no longer needed
434
- node.remove();
435
- if (!parentVNode.$children$) {
436
- parentVNode.$children$ = [];
437
- }
438
- parentVNode.$children$[childVNode.$index$] = childVNode;
439
- if (shadowRootNodes && childVNode.$depth$ === '0') {
440
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
441
- }
442
- }
443
- }
444
- else if (childVNode.$hostId$ === hostId) {
445
- // this comment node is specifically for this host id
446
- if (childNodeType === SLOT_NODE_ID) {
447
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
448
- childVNode.$tag$ = 'slot';
449
- if (childIdSplt[5]) {
450
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
451
- }
452
- else {
453
- node['s-sn'] = '';
454
- }
455
- node['s-sr'] = true;
456
- if (shadowRootNodes) {
457
- // browser support shadowRoot and this is a shadow dom component
458
- // create an actual slot element
459
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
460
- if (childVNode.$name$) {
461
- // add the slot name attribute
462
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
463
- }
464
- // insert the new slot element before the slot comment
465
- node.parentNode.insertBefore(childVNode.$elm$, node);
466
- // remove the slot comment since it's not needed for shadow
467
- node.remove();
468
- if (childVNode.$depth$ === '0') {
469
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
470
- }
471
- }
472
- slotNodes.push(childVNode);
473
- if (!parentVNode.$children$) {
474
- parentVNode.$children$ = [];
475
- }
476
- parentVNode.$children$[childVNode.$index$] = childVNode;
477
- }
478
- else if (childNodeType === CONTENT_REF_ID) {
479
- // `${CONTENT_REF_ID}.${hostId}`;
480
- if (shadowRootNodes) {
481
- // remove the content ref comment since it's not needed for shadow
482
- node.remove();
483
- }
484
- else {
485
- hostElm['s-cr'] = node;
486
- node['s-cn'] = true;
487
- }
488
- }
489
- }
490
- }
491
- }
492
- else if (parentVNode && parentVNode.$tag$ === 'style') {
493
- const vnode = newVNode(null, node.textContent);
494
- vnode.$elm$ = node;
495
- vnode.$index$ = '0';
496
- parentVNode.$children$ = [vnode];
497
- }
498
- };
499
- /**
500
- * Recursively locate any comments representing an original location for a node in a node's
501
- * children or shadowRoot children.
502
- *
503
- * @param node The node to search.
504
- * @param orgLocNodes A map of the original location annotation and the current node being searched.
505
- */
506
- const initializeDocumentHydrate = (node, orgLocNodes) => {
507
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
508
- let i = 0;
509
- for (; i < node.childNodes.length; i++) {
510
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
511
- }
512
- if (node.shadowRoot) {
513
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
514
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
515
- }
516
- }
517
- }
518
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
519
- const childIdSplt = node.nodeValue.split('.');
520
- if (childIdSplt[0] === ORG_LOCATION_ID) {
521
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
522
- node.nodeValue = '';
523
- // useful to know if the original location is
524
- // the root light-dom of a shadow dom component
525
- node['s-en'] = childIdSplt[3];
526
- }
527
- }
528
- };
529
- // Private
530
- const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) => !!m);
531
- // Public
532
- const setMode = (handler) => modeResolutionChain.push(handler);
533
- const getMode = (ref) => getHostRef(ref).$modeName$;
534
- /**
535
- * Parse a new property value for a given property type.
536
- *
537
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
538
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
539
- * 1. `any`, the type given to `propValue` in the function signature
540
- * 2. the type stored from `propType`.
541
- *
542
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
543
- *
544
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
545
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
546
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
547
- * ```tsx
548
- * <my-cmp prop-val={0}></my-cmp>
549
- * ```
550
- *
551
- * HTML prop values on the other hand, will always a string
552
- *
553
- * @param propValue the new value to coerce to some type
554
- * @param propType the type of the prop, expressed as a binary number
555
- * @returns the parsed/coerced value
556
- */
557
- const parsePropertyValue = (propValue, propType) => {
558
- // ensure this value is of the correct prop type
559
- if (propValue != null && !isComplexType(propValue)) {
560
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
561
- // per the HTML spec, any string value means it is a boolean true value
562
- // but we'll cheat here and say that the string "false" is the boolean false
563
- return propValue === 'false' ? false : propValue === '' || !!propValue;
564
- }
565
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
566
- // force it to be a number
567
- return parseFloat(propValue);
568
- }
569
- if (propType & 1 /* MEMBER_FLAGS.String */) {
570
- // could have been passed as a number or boolean
571
- // but we still want it as a string
572
- return String(propValue);
573
- }
574
- // redundant return here for better minification
575
- return propValue;
576
- }
577
- // not sure exactly what type we want
578
- // so no need to change to a different type
579
- return propValue;
580
- };
581
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
582
- const createEvent = (ref, name, flags) => {
583
- const elm = getElement(ref);
584
- return {
585
- emit: (detail) => {
586
- return emitEvent(elm, name, {
587
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
588
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
589
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
590
- detail,
591
- });
592
- },
593
- };
594
- };
595
- /**
596
- * Helper function to create & dispatch a custom Event on a provided target
597
- * @param elm the target of the Event
598
- * @param name the name to give the custom Event
599
- * @param opts options for configuring a custom Event
600
- * @returns the custom Event
601
- */
602
- const emitEvent = (elm, name, opts) => {
603
- const ev = plt.ce(name, opts);
604
- elm.dispatchEvent(ev);
605
- return ev;
606
- };
607
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
608
- const registerStyle = (scopeId, cssText, allowCS) => {
609
- let style = styles.get(scopeId);
610
- if (supportsConstructableStylesheets && allowCS) {
611
- style = (style || new CSSStyleSheet());
612
- if (typeof style === 'string') {
613
- style = cssText;
614
- }
615
- else {
616
- style.replaceSync(cssText);
617
- }
618
- }
619
- else {
620
- style = cssText;
621
- }
622
- styles.set(scopeId, style);
623
- };
624
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
625
- var _a;
626
- const scopeId = getScopeId(cmpMeta, mode);
627
- const style = styles.get(scopeId);
628
- // if an element is NOT connected then getRootNode() will return the wrong root node
629
- // so the fallback is to always use the document for the root node in those cases
630
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
631
- if (style) {
632
- if (typeof style === 'string') {
633
- styleContainerNode = styleContainerNode.head || styleContainerNode;
634
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
635
- let styleElm;
636
- if (!appliedStyles) {
637
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
638
- }
639
- if (!appliedStyles.has(scopeId)) {
640
- if (styleContainerNode.host &&
641
- (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
642
- // This is only happening on native shadow-dom, do not needs CSS var shim
643
- styleElm.innerHTML = style;
644
- }
645
- else {
646
- styleElm = doc.createElement('style');
647
- styleElm.innerHTML = style;
648
- // Apply CSP nonce to the style tag if it exists
649
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
650
- if (nonce != null) {
651
- styleElm.setAttribute('nonce', nonce);
652
- }
653
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
654
- }
655
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
656
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
657
- styleElm.innerHTML += SLOT_FB_CSS;
658
- }
659
- if (appliedStyles) {
660
- appliedStyles.add(scopeId);
661
- }
662
- }
663
- }
664
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
665
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
666
- }
667
- }
668
- return scopeId;
669
- };
670
- const attachStyles = (hostRef) => {
671
- const cmpMeta = hostRef.$cmpMeta$;
672
- const elm = hostRef.$hostElement$;
673
- const flags = cmpMeta.$flags$;
674
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
675
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta, hostRef.$modeName$);
676
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
677
- // only required when we're NOT using native shadow dom (slot)
678
- // or this browser doesn't support native shadow dom
679
- // and this host element was NOT created with SSR
680
- // let's pick out the inner content for slot projection
681
- // create a node to represent where the original
682
- // content was first placed, which is useful later on
683
- // DOM WRITE!!
684
- elm['s-sc'] = scopeId;
685
- elm.classList.add(scopeId + '-h');
686
- if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
687
- elm.classList.add(scopeId + '-s');
688
- }
689
- }
690
- endAttachStyles();
691
- };
692
- const getScopeId = (cmp, mode) => 'sc-' + (mode && cmp.$flags$ & 32 /* CMP_FLAGS.hasMode */ ? cmp.$tagName$ + '-' + mode : cmp.$tagName$);
693
- const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
694
- /**
695
- * Production setAccessor() function based on Preact by
696
- * Jason Miller (@developit)
697
- * Licensed under the MIT License
698
- * https://github.com/developit/preact/blob/master/LICENSE
699
- *
700
- * Modified for Stencil's compiler and vdom
701
- */
702
- /**
703
- * When running a VDom render set properties present on a VDom node onto the
704
- * corresponding HTML element.
705
- *
706
- * Note that this function has special functionality for the `class`,
707
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
708
- * `onClick`, etc). All others are just passed through as-is.
709
- *
710
- * @param elm the HTMLElement onto which attributes should be set
711
- * @param memberName the name of the attribute to set
712
- * @param oldValue the old value for the attribute
713
- * @param newValue the new value for the attribute
714
- * @param isSvg whether we're in an svg context or not
715
- * @param flags bitflags for Vdom variables
716
- */
717
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
718
- if (oldValue !== newValue) {
719
- let isProp = isMemberInElement(elm, memberName);
720
- let ln = memberName.toLowerCase();
721
- if (memberName === 'class') {
722
- const classList = elm.classList;
723
- const oldClasses = parseClassList(oldValue);
724
- const newClasses = parseClassList(newValue);
725
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
726
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
727
- }
728
- else if (memberName === 'style') {
729
- // update style attribute, css properties and values
730
- {
731
- for (const prop in oldValue) {
732
- if (!newValue || newValue[prop] == null) {
733
- if (prop.includes('-')) {
734
- elm.style.removeProperty(prop);
735
- }
736
- else {
737
- elm.style[prop] = '';
738
- }
739
- }
740
- }
741
- }
742
- for (const prop in newValue) {
743
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
744
- if (prop.includes('-')) {
745
- elm.style.setProperty(prop, newValue[prop]);
746
- }
747
- else {
748
- elm.style[prop] = newValue[prop];
749
- }
750
- }
751
- }
752
- }
753
- else if (memberName === 'key')
754
- ;
755
- else if (memberName === 'ref') {
756
- // minifier will clean this up
757
- if (newValue) {
758
- newValue(elm);
759
- }
760
- }
761
- else if ((!isProp ) &&
762
- memberName[0] === 'o' &&
763
- memberName[1] === 'n') {
764
- // Event Handlers
765
- // so if the member name starts with "on" and the 3rd characters is
766
- // a capital letter, and it's not already a member on the element,
767
- // then we're assuming it's an event listener
768
- if (memberName[2] === '-') {
769
- // on- prefixed events
770
- // allows to be explicit about the dom event to listen without any magic
771
- // under the hood:
772
- // <my-cmp on-click> // listens for "click"
773
- // <my-cmp on-Click> // listens for "Click"
774
- // <my-cmp on-ionChange> // listens for "ionChange"
775
- // <my-cmp on-EVENTS> // listens for "EVENTS"
776
- memberName = memberName.slice(3);
777
- }
778
- else if (isMemberInElement(win, ln)) {
779
- // standard event
780
- // the JSX attribute could have been "onMouseOver" and the
781
- // member name "onmouseover" is on the window's prototype
782
- // so let's add the listener "mouseover", which is all lowercased
783
- memberName = ln.slice(2);
784
- }
785
- else {
786
- // custom event
787
- // the JSX attribute could have been "onMyCustomEvent"
788
- // so let's trim off the "on" prefix and lowercase the first character
789
- // and add the listener "myCustomEvent"
790
- // except for the first character, we keep the event name case
791
- memberName = ln[2] + memberName.slice(3);
792
- }
793
- if (oldValue || newValue) {
794
- // Need to account for "capture" events.
795
- // If the event name ends with "Capture", we'll update the name to remove
796
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
797
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
798
- // Make sure we only replace the last instance of "Capture"
799
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
800
- if (oldValue) {
801
- plt.rel(elm, memberName, oldValue, capture);
802
- }
803
- if (newValue) {
804
- plt.ael(elm, memberName, newValue, capture);
805
- }
806
- }
807
- }
808
- else {
809
- // Set property if it exists and it's not a SVG
810
- const isComplex = isComplexType(newValue);
811
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
812
- try {
813
- if (!elm.tagName.includes('-')) {
814
- const n = newValue == null ? '' : newValue;
815
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
816
- if (memberName === 'list') {
817
- isProp = false;
818
- }
819
- else if (oldValue == null || elm[memberName] != n) {
820
- elm[memberName] = n;
821
- }
822
- }
823
- else {
824
- elm[memberName] = newValue;
825
- }
826
- }
827
- catch (e) {
828
- /**
829
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
830
- */
831
- }
832
- }
833
- /**
834
- * Need to manually update attribute if:
835
- * - memberName is not an attribute
836
- * - if we are rendering the host element in order to reflect attribute
837
- * - if it's a SVG, since properties might not work in <svg>
838
- * - if the newValue is null/undefined or 'false'.
839
- */
840
- let xlink = false;
841
- {
842
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
843
- memberName = ln;
844
- xlink = true;
845
- }
846
- }
847
- if (newValue == null || newValue === false) {
848
- if (newValue !== false || elm.getAttribute(memberName) === '') {
849
- if (xlink) {
850
- elm.removeAttributeNS(XLINK_NS, memberName);
851
- }
852
- else {
853
- elm.removeAttribute(memberName);
854
- }
855
- }
856
- }
857
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
858
- newValue = newValue === true ? '' : newValue;
859
- if (xlink) {
860
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
861
- }
862
- else {
863
- elm.setAttribute(memberName, newValue);
864
- }
865
- }
866
- }
867
- }
868
- };
869
- const parseClassListRegex = /\s/;
870
- /**
871
- * Parsed a string of classnames into an array
872
- * @param value className string, e.g. "foo bar baz"
873
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
874
- */
875
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
876
- const CAPTURE_EVENT_SUFFIX = 'Capture';
877
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
878
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
879
- // if the element passed in is a shadow root, which is a document fragment
880
- // then we want to be adding attrs/props to the shadow root's "host" element
881
- // if it's not a shadow root, then we add attrs/props to the same element
882
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
883
- ? newVnode.$elm$.host
884
- : newVnode.$elm$;
885
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
886
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
887
- {
888
- // remove attributes no longer present on the vnode by setting them to undefined
889
- for (memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
890
- if (!(memberName in newVnodeAttrs)) {
891
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
892
- }
893
- }
894
- }
895
- // add new & update changed attributes
896
- for (memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
897
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
898
- }
899
- };
900
- /**
901
- * Sort a list of attribute names to ensure that all the attribute names which
902
- * are _not_ `"ref"` come before `"ref"`. Preserve the order of the non-ref
903
- * attributes.
904
- *
905
- * **Note**: if the supplied attributes do not include `'ref'` then the same
906
- * (by reference) array will be returned without modification.
907
- *
908
- * @param attrNames attribute names to sort
909
- * @returns a list of attribute names, sorted if they include `"ref"`
910
- */
911
- function sortedAttrNames(attrNames) {
912
- return attrNames.includes('ref')
913
- ? // we need to sort these to ensure that `'ref'` is the last attr
914
- [...attrNames.filter((attr) => attr !== 'ref'), 'ref']
915
- : // no need to sort, return the original array
916
- attrNames;
917
- }
918
- /**
919
- * Create a DOM Node corresponding to one of the children of a given VNode.
920
- *
921
- * @param oldParentVNode the parent VNode from the previous render
922
- * @param newParentVNode the parent VNode from the current render
923
- * @param childIndex the index of the VNode, in the _new_ parent node's
924
- * children, for which we will create a new DOM node
925
- * @param parentElm the parent DOM node which our new node will be a child of
926
- * @returns the newly created node
927
- */
928
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
929
- var _a;
930
- // tslint:disable-next-line: prefer-const
931
- const newVNode = newParentVNode.$children$[childIndex];
932
- let i = 0;
933
- let elm;
934
- let childNode;
935
- let oldVNode;
936
- if (!useNativeShadowDom) {
937
- // remember for later we need to check to relocate nodes
938
- checkSlotRelocate = true;
939
- if (newVNode.$tag$ === 'slot') {
940
- if (scopeId) {
941
- // scoped css needs to add its scoped id to the parent element
942
- parentElm.classList.add(scopeId + '-s');
943
- }
944
- newVNode.$flags$ |= newVNode.$children$
945
- ? // slot element has fallback content
946
- 2 /* VNODE_FLAGS.isSlotFallback */
947
- : // slot element does not have fallback content
948
- 1 /* VNODE_FLAGS.isSlotReference */;
949
- }
950
- }
951
- if (newVNode.$text$ !== null) {
952
- // create text node
953
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
954
- }
955
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
956
- // create a slot reference node
957
- elm = newVNode.$elm$ =
958
- doc.createTextNode('');
959
- }
960
- else {
961
- if (!isSvgMode) {
962
- isSvgMode = newVNode.$tag$ === 'svg';
963
- }
964
- // create element
965
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
966
- ? 'slot-fb'
967
- : newVNode.$tag$)
968
- );
969
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
970
- isSvgMode = false;
971
- }
972
- // add css classes, attrs, props, listeners, etc.
973
- {
974
- updateElement(null, newVNode, isSvgMode);
975
- }
976
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
977
- // if there is a scopeId and this is the initial render
978
- // then let's add the scopeId as a css class
979
- elm.classList.add((elm['s-si'] = scopeId));
980
- }
981
- if (newVNode.$children$) {
982
- for (i = 0; i < newVNode.$children$.length; ++i) {
983
- // create the node
984
- childNode = createElm(oldParentVNode, newVNode, i, elm);
985
- // return node could have been null
986
- if (childNode) {
987
- // append our new node
988
- elm.appendChild(childNode);
989
- }
990
- }
991
- }
992
- {
993
- if (newVNode.$tag$ === 'svg') {
994
- // Only reset the SVG context when we're exiting <svg> element
995
- isSvgMode = false;
996
- }
997
- else if (elm.tagName === 'foreignObject') {
998
- // Reenter SVG context when we're exiting <foreignObject> element
999
- isSvgMode = true;
1000
- }
1001
- }
1002
- }
1003
- // This needs to always happen so we can hide nodes that are projected
1004
- // to another component but don't end up in a slot
1005
- elm['s-hn'] = hostTagName;
1006
- {
1007
- if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
1008
- // remember the content reference comment
1009
- elm['s-sr'] = true;
1010
- // remember the content reference comment
1011
- elm['s-cr'] = contentRef;
1012
- // remember the slot name, or empty string for default slot
1013
- elm['s-sn'] = newVNode.$name$ || '';
1014
- // remember the ref callback function
1015
- elm['s-rf'] = (_a = newVNode.$attrs$) === null || _a === void 0 ? void 0 : _a.ref;
1016
- // check if we've got an old vnode for this slot
1017
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
1018
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
1019
- {
1020
- // we've got an old slot vnode and the wrapper is being replaced
1021
- // so let's move the old slot content to the root of the element currently being rendered
1022
- relocateToHostRoot(oldParentVNode.$elm$);
1023
- }
1024
- }
1025
- }
1026
- }
1027
- return elm;
1028
- };
1029
- /**
1030
- * Relocates all child nodes of an element that were a part of a previous slot relocation
1031
- * to the root of the Stencil component currently being rendered. This happens when a parent
1032
- * element of a slot reference node dynamically changes and triggers a re-render. We cannot use
1033
- * `putBackInOriginalLocation()` because that may relocate nodes to elements that will not be re-rendered
1034
- * and so they will not be relocated again.
1035
- *
1036
- * @param parentElm The element potentially containing relocated nodes.
1037
- */
1038
- const relocateToHostRoot = (parentElm) => {
1039
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1040
- const host = parentElm.closest(hostTagName.toLowerCase());
1041
- if (host != null) {
1042
- const contentRefNode = Array.from(host.childNodes).find((ref) => ref['s-cr']);
1043
- const childNodeArray = Array.from(parentElm.childNodes);
1044
- // If we have a content ref, we need to invert the order of the nodes we're relocating
1045
- // to preserve the correct order of elements in the DOM on future relocations
1046
- for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
1047
- // Only relocate nodes that were slotted in
1048
- if (childNode['s-sh'] != null) {
1049
- host.insertBefore(childNode, contentRefNode !== null && contentRefNode !== void 0 ? contentRefNode : null);
1050
- // Reset so we can correctly move the node around again.
1051
- childNode['s-sh'] = undefined;
1052
- // Need to tell the render pipeline to check to relocate slot content again
1053
- checkSlotRelocate = true;
1054
- }
1055
- }
1056
- }
1057
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1058
- };
1059
- const putBackInOriginalLocation = (parentElm, recursive) => {
1060
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1061
- const oldSlotChildNodes = Array.from(parentElm.childNodes);
1062
- if (parentElm['s-sr'] && BUILD.experimentalSlotFixes) {
1063
- let node = parentElm;
1064
- while ((node = node.nextSibling)) {
1065
- if (node && node['s-sn'] === parentElm['s-sn'] && node['s-sh'] === hostTagName) {
1066
- oldSlotChildNodes.push(node);
1067
- }
1068
- }
1069
- }
1070
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
1071
- const childNode = oldSlotChildNodes[i];
1072
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
1073
- // and relocate it back to it's original location
1074
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
1075
- // remove the old original location comment entirely
1076
- // later on the patch function will know what to do
1077
- // and move this to the correct spot if need be
1078
- childNode['s-ol'].remove();
1079
- childNode['s-ol'] = undefined;
1080
- // Reset so we can correctly move the node around again.
1081
- childNode['s-sh'] = undefined;
1082
- checkSlotRelocate = true;
1083
- }
1084
- if (recursive) {
1085
- putBackInOriginalLocation(childNode, recursive);
1086
- }
1087
- }
1088
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1089
- };
1090
- /**
1091
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
1092
- * add them to the DOM in the appropriate place.
1093
- *
1094
- * @param parentElm the DOM node which should be used as a parent for the new
1095
- * DOM nodes
1096
- * @param before a child of the `parentElm` which the new children should be
1097
- * inserted before (optional)
1098
- * @param parentVNode the parent virtual DOM node
1099
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
1100
- * @param startIdx the index in the child virtual DOM nodes at which to start
1101
- * creating DOM nodes (inclusive)
1102
- * @param endIdx the index in the child virtual DOM nodes at which to stop
1103
- * creating DOM nodes (inclusive)
1104
- */
1105
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1106
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1107
- let childNode;
1108
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1109
- containerElm = containerElm.shadowRoot;
1110
- }
1111
- for (; startIdx <= endIdx; ++startIdx) {
1112
- if (vnodes[startIdx]) {
1113
- childNode = createElm(null, parentVNode, startIdx, parentElm);
1114
- if (childNode) {
1115
- vnodes[startIdx].$elm$ = childNode;
1116
- containerElm.insertBefore(childNode, referenceNode(before) );
1117
- }
1118
- }
1119
- }
1120
- };
1121
- /**
1122
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
1123
- * This can be used to, for instance, clean up after a list of children which
1124
- * should no longer be shown.
1125
- *
1126
- * This function also handles some of Stencil's slot relocation logic.
1127
- *
1128
- * @param vnodes a list of virtual DOM nodes to remove
1129
- * @param startIdx the index at which to start removing nodes (inclusive)
1130
- * @param endIdx the index at which to stop removing nodes (inclusive)
1131
- */
1132
- const removeVnodes = (vnodes, startIdx, endIdx) => {
1133
- for (let index = startIdx; index <= endIdx; ++index) {
1134
- const vnode = vnodes[index];
1135
- if (vnode) {
1136
- const elm = vnode.$elm$;
1137
- nullifyVNodeRefs(vnode);
1138
- if (elm) {
1139
- {
1140
- // we're removing this element
1141
- // so it's possible we need to show slot fallback content now
1142
- checkSlotFallbackVisibility = true;
1143
- if (elm['s-ol']) {
1144
- // remove the original location comment
1145
- elm['s-ol'].remove();
1146
- }
1147
- else {
1148
- // it's possible that child nodes of the node
1149
- // that's being removed are slot nodes
1150
- putBackInOriginalLocation(elm, true);
1151
- }
1152
- }
1153
- // remove the vnode's element from the dom
1154
- elm.remove();
1155
- }
1156
- }
1157
- }
1158
- };
1159
- /**
1160
- * Reconcile the children of a new VNode with the children of an old VNode by
1161
- * traversing the two collections of children, identifying nodes that are
1162
- * conserved or changed, calling out to `patch` to make any necessary
1163
- * updates to the DOM, and rearranging DOM nodes as needed.
1164
- *
1165
- * The algorithm for reconciling children works by analyzing two 'windows' onto
1166
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1167
- * 'windows' by storing start and end indices and references to the
1168
- * corresponding array entries. Initially the two 'windows' are basically equal
1169
- * to the entire array, but we progressively narrow the windows until there are
1170
- * no children left to update by doing the following:
1171
- *
1172
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1173
- * that if we have an initial array like the following we'll end up dealing
1174
- * only with a window bounded by the highlighted elements:
1175
- *
1176
- * [null, null, VNode1 , ... , VNode2, null, null]
1177
- * ^^^^^^ ^^^^^^
1178
- *
1179
- * 2. Check to see if the elements at the head and tail positions are equal
1180
- * across the windows. This will basically detect elements which haven't
1181
- * been added, removed, or changed position, i.e. if you had the following
1182
- * VNode elements (represented as HTML):
1183
- *
1184
- * oldVNode: `<div><p><span>HEY</span></p></div>`
1185
- * newVNode: `<div><p><span>THERE</span></p></div>`
1186
- *
1187
- * Then when comparing the children of the `<div>` tag we check the equality
1188
- * of the VNodes corresponding to the `<p>` tags and, since they are the
1189
- * same tag in the same position, we'd be able to avoid completely
1190
- * re-rendering the subtree under them with a new DOM element and would just
1191
- * call out to `patch` to handle reconciling their children and so on.
1192
- *
1193
- * 3. Check, for both windows, to see if the element at the beginning of the
1194
- * window corresponds to the element at the end of the other window. This is
1195
- * a heuristic which will let us identify _some_ situations in which
1196
- * elements have changed position, for instance it _should_ detect that the
1197
- * children nodes themselves have not changed but merely moved in the
1198
- * following example:
1199
- *
1200
- * oldVNode: `<div><element-one /><element-two /></div>`
1201
- * newVNode: `<div><element-two /><element-one /></div>`
1202
- *
1203
- * If we find cases like this then we also need to move the concrete DOM
1204
- * elements corresponding to the moved children to write the re-order to the
1205
- * DOM.
1206
- *
1207
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1208
- * nodes in the old children which have the same key as the first element in
1209
- * our window on the new children. If we find such a node we handle calling
1210
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1211
- * what we find.
1212
- *
1213
- * Finally, once we've narrowed our 'windows' to the point that either of them
1214
- * collapse (i.e. they have length 0) we then handle any remaining VNode
1215
- * insertion or deletion that needs to happen to get a DOM state that correctly
1216
- * reflects the new child VNodes. If, for instance, after our window on the old
1217
- * children has collapsed we still have more nodes on the new children that
1218
- * we haven't dealt with yet then we need to add them, or if the new children
1219
- * collapse but we still have unhandled _old_ children then we need to make
1220
- * sure the corresponding DOM nodes are removed.
1221
- *
1222
- * @param parentElm the node into which the parent VNode is rendered
1223
- * @param oldCh the old children of the parent node
1224
- * @param newVNode the new VNode which will replace the parent
1225
- * @param newCh the new children of the parent node
1226
- * @param isInitialRender whether or not this is the first render of the vdom
1227
- */
1228
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
1229
- let oldStartIdx = 0;
1230
- let newStartIdx = 0;
1231
- let idxInOld = 0;
1232
- let i = 0;
1233
- let oldEndIdx = oldCh.length - 1;
1234
- let oldStartVnode = oldCh[0];
1235
- let oldEndVnode = oldCh[oldEndIdx];
1236
- let newEndIdx = newCh.length - 1;
1237
- let newStartVnode = newCh[0];
1238
- let newEndVnode = newCh[newEndIdx];
1239
- let node;
1240
- let elmToMove;
1241
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1242
- if (oldStartVnode == null) {
1243
- // VNode might have been moved left
1244
- oldStartVnode = oldCh[++oldStartIdx];
1245
- }
1246
- else if (oldEndVnode == null) {
1247
- oldEndVnode = oldCh[--oldEndIdx];
1248
- }
1249
- else if (newStartVnode == null) {
1250
- newStartVnode = newCh[++newStartIdx];
1251
- }
1252
- else if (newEndVnode == null) {
1253
- newEndVnode = newCh[--newEndIdx];
1254
- }
1255
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1256
- // if the start nodes are the same then we should patch the new VNode
1257
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1258
- // indices to reflect that. We don't need to move any DOM Nodes around
1259
- // since things are matched up in order.
1260
- patch(oldStartVnode, newStartVnode, isInitialRender);
1261
- oldStartVnode = oldCh[++oldStartIdx];
1262
- newStartVnode = newCh[++newStartIdx];
1263
- }
1264
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1265
- // likewise, if the end nodes are the same we patch new onto old and
1266
- // decrement our end indices, and also likewise in this case we don't
1267
- // need to move any DOM Nodes.
1268
- patch(oldEndVnode, newEndVnode, isInitialRender);
1269
- oldEndVnode = oldCh[--oldEndIdx];
1270
- newEndVnode = newCh[--newEndIdx];
1271
- }
1272
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1273
- // case: "Vnode moved right"
1274
- //
1275
- // We've found that the last node in our window on the new children is
1276
- // the same VNode as the _first_ node in our window on the old children
1277
- // we're dealing with now. Visually, this is the layout of these two
1278
- // nodes:
1279
- //
1280
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1281
- // ^^^^^^^^^^^
1282
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1283
- // ^^^^^^^^^^^^^
1284
- //
1285
- // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1286
- // and move the DOM element for `oldStartVnode`.
1287
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1288
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1289
- }
1290
- patch(oldStartVnode, newEndVnode, isInitialRender);
1291
- // We need to move the element for `oldStartVnode` into a position which
1292
- // will be appropriate for `newEndVnode`. For this we can use
1293
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1294
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1295
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1296
- //
1297
- // <old-start-node />
1298
- // <some-intervening-node />
1299
- // <old-end-node />
1300
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1301
- // <next-sibling />
1302
- //
1303
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1304
- // the node for `oldStartVnode` at the end of the children of
1305
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1306
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
1307
- // append it to the children of the parent element.
1308
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1309
- oldStartVnode = oldCh[++oldStartIdx];
1310
- newEndVnode = newCh[--newEndIdx];
1311
- }
1312
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1313
- // case: "Vnode moved left"
1314
- //
1315
- // We've found that the first node in our window on the new children is
1316
- // the same VNode as the _last_ node in our window on the old children.
1317
- // Visually, this is the layout of these two nodes:
1318
- //
1319
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1320
- // ^^^^^^^^^^^^^
1321
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1322
- // ^^^^^^^^^^^
1323
- //
1324
- // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1325
- // (which will handle updating any changed attributes, reconciling their
1326
- // children etc) but we also need to move the DOM node to which
1327
- // `oldEndVnode` corresponds.
1328
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1329
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1330
- }
1331
- patch(oldEndVnode, newStartVnode, isInitialRender);
1332
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
1333
- // the same node, so since we're here we know that they are not. Thus we
1334
- // can move the element for `oldEndVnode` _before_ the element for
1335
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1336
- // future.
1337
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1338
- oldEndVnode = oldCh[--oldEndIdx];
1339
- newStartVnode = newCh[++newStartIdx];
1340
- }
1341
- else {
1342
- // Here we do some checks to match up old and new nodes based on the
1343
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1344
- // in the JSX for a DOM element in the implementation of a Stencil
1345
- // component.
1346
- //
1347
- // First we check to see if there are any nodes in the array of old
1348
- // children which have the same key as the first node in the new
1349
- // children.
1350
- idxInOld = -1;
1351
- {
1352
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1353
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1354
- idxInOld = i;
1355
- break;
1356
- }
1357
- }
1358
- }
1359
- if (idxInOld >= 0) {
1360
- // We found a node in the old children which matches up with the first
1361
- // node in the new children! So let's deal with that
1362
- elmToMove = oldCh[idxInOld];
1363
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1364
- // the tag doesn't match so we'll need a new DOM element
1365
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1366
- }
1367
- else {
1368
- patch(elmToMove, newStartVnode, isInitialRender);
1369
- // invalidate the matching old node so that we won't try to update it
1370
- // again later on
1371
- oldCh[idxInOld] = undefined;
1372
- node = elmToMove.$elm$;
1373
- }
1374
- newStartVnode = newCh[++newStartIdx];
1375
- }
1376
- else {
1377
- // We either didn't find an element in the old children that matches
1378
- // the key of the first new child OR the build is not using `key`
1379
- // attributes at all. In either case we need to create a new element
1380
- // for the new node.
1381
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1382
- newStartVnode = newCh[++newStartIdx];
1383
- }
1384
- if (node) {
1385
- // if we created a new node then handle inserting it to the DOM
1386
- {
1387
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1388
- }
1389
- }
1390
- }
1391
- }
1392
- if (oldStartIdx > oldEndIdx) {
1393
- // we have some more new nodes to add which don't match up with old nodes
1394
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1395
- }
1396
- else if (newStartIdx > newEndIdx) {
1397
- // there are nodes in the `oldCh` array which no longer correspond to nodes
1398
- // in the new array, so lets remove them (which entails cleaning up the
1399
- // relevant DOM nodes)
1400
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1401
- }
1402
- };
1403
- /**
1404
- * Compare two VNodes to determine if they are the same
1405
- *
1406
- * **NB**: This function is an equality _heuristic_ based on the available
1407
- * information set on the two VNodes and can be misleading under certain
1408
- * circumstances. In particular, if the two nodes do not have `key` attrs
1409
- * (available under `$key$` on VNodes) then the function falls back on merely
1410
- * checking that they have the same tag.
1411
- *
1412
- * So, in other words, if `key` attrs are not set on VNodes which may be
1413
- * changing order within a `children` array or something along those lines then
1414
- * we could obtain a false negative and then have to do needless re-rendering
1415
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1416
- *
1417
- * @param leftVNode the first VNode to check
1418
- * @param rightVNode the second VNode to check
1419
- * @param isInitialRender whether or not this is the first render of the vdom
1420
- * @returns whether they're equal or not
1421
- */
1422
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1423
- // compare if two vnode to see if they're "technically" the same
1424
- // need to have the same element tag, and same key to be the same
1425
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1426
- if (leftVNode.$tag$ === 'slot') {
1427
- return leftVNode.$name$ === rightVNode.$name$;
1428
- }
1429
- // this will be set if JSX tags in the build have `key` attrs set on them
1430
- // we only want to check this if we're not on the first render since on
1431
- // first render `leftVNode.$key$` will always be `null`, so we can be led
1432
- // astray and, for instance, accidentally delete a DOM node that we want to
1433
- // keep around.
1434
- if (!isInitialRender) {
1435
- return leftVNode.$key$ === rightVNode.$key$;
1436
- }
1437
- return true;
1438
- }
1439
- return false;
1440
- };
1441
- const referenceNode = (node) => {
1442
- // this node was relocated to a new location in the dom
1443
- // because of some other component's slot
1444
- // but we still have an html comment in place of where
1445
- // it's original location was according to it's original vdom
1446
- return (node && node['s-ol']) || node;
1447
- };
1448
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1449
- /**
1450
- * Handle reconciling an outdated VNode with a new one which corresponds to
1451
- * it. This function handles flushing updates to the DOM and reconciling the
1452
- * children of the two nodes (if any).
1453
- *
1454
- * @param oldVNode an old VNode whose DOM element and children we want to update
1455
- * @param newVNode a new VNode representing an updated version of the old one
1456
- * @param isInitialRender whether or not this is the first render of the vdom
1457
- */
1458
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
1459
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
1460
- const oldChildren = oldVNode.$children$;
1461
- const newChildren = newVNode.$children$;
1462
- const tag = newVNode.$tag$;
1463
- const text = newVNode.$text$;
1464
- let defaultHolder;
1465
- if (text === null) {
1466
- {
1467
- // test if we're rendering an svg element, or still rendering nodes inside of one
1468
- // only add this to the when the compiler sees we're using an svg somewhere
1469
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1470
- }
1471
- {
1472
- if (tag === 'slot' && !useNativeShadowDom) {
1473
- if (oldVNode.$name$ !== newVNode.$name$) {
1474
- newVNode.$elm$['s-sn'] = newVNode.$name$ || '';
1475
- relocateToHostRoot(newVNode.$elm$.parentElement);
1476
- }
1477
- }
1478
- else {
1479
- // either this is the first render of an element OR it's an update
1480
- // AND we already know it's possible it could have changed
1481
- // this updates the element's css classes, attrs, props, listeners, etc.
1482
- updateElement(oldVNode, newVNode, isSvgMode);
1483
- }
1484
- }
1485
- if (oldChildren !== null && newChildren !== null) {
1486
- // looks like there's child vnodes for both the old and new vnodes
1487
- // so we need to call `updateChildren` to reconcile them
1488
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
1489
- }
1490
- else if (newChildren !== null) {
1491
- // no old child vnodes, but there are new child vnodes to add
1492
- if (oldVNode.$text$ !== null) {
1493
- // the old vnode was text, so be sure to clear it out
1494
- elm.textContent = '';
1495
- }
1496
- // add the new vnode children
1497
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1498
- }
1499
- else if (oldChildren !== null) {
1500
- // no new child vnodes, but there are old child vnodes to remove
1501
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1502
- }
1503
- if (isSvgMode && tag === 'svg') {
1504
- isSvgMode = false;
1505
- }
1506
- }
1507
- else if ((defaultHolder = elm['s-cr'])) {
1508
- // this element has slotted content
1509
- defaultHolder.parentNode.textContent = text;
1510
- }
1511
- else if (oldVNode.$text$ !== text) {
1512
- // update the text content for the text only vnode
1513
- // and also only if the text is different than before
1514
- elm.data = text;
1515
- }
1516
- };
1517
- /**
1518
- * Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
1519
- * are slot fallbacks nodes.
1520
- *
1521
- * A slot fallback node should be visible by default. Then, it should be
1522
- * conditionally hidden if:
1523
- *
1524
- * - it has a sibling with a `slot` property set to its slot name or if
1525
- * - it is a default fallback slot node, in which case we hide if it has any
1526
- * content
1527
- *
1528
- * @param elm the element of interest
1529
- */
1530
- const updateFallbackSlotVisibility = (elm) => {
1531
- const childNodes = elm.childNodes;
1532
- for (const childNode of childNodes) {
1533
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1534
- if (childNode['s-sr']) {
1535
- // this is a slot fallback node
1536
- // get the slot name for this slot reference node
1537
- const slotName = childNode['s-sn'];
1538
- // by default always show a fallback slot node
1539
- // then hide it if there are other slots in the light dom
1540
- childNode.hidden = false;
1541
- // we need to check all of its sibling nodes in order to see if
1542
- // `childNode` should be hidden
1543
- for (const siblingNode of childNodes) {
1544
- // Don't check the node against itself
1545
- if (siblingNode !== childNode) {
1546
- if (siblingNode['s-hn'] !== childNode['s-hn'] || slotName !== '') {
1547
- // this sibling node is from a different component OR is a named
1548
- // fallback slot node
1549
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1550
- (slotName === siblingNode.getAttribute('slot') || slotName === siblingNode['s-sn'])) {
1551
- childNode.hidden = true;
1552
- break;
1553
- }
1554
- }
1555
- else {
1556
- // this is a default fallback slot node
1557
- // any element or text node (with content)
1558
- // should hide the default fallback slot node
1559
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1560
- (siblingNode.nodeType === 3 /* NODE_TYPE.TextNode */ && siblingNode.textContent.trim() !== '')) {
1561
- childNode.hidden = true;
1562
- break;
1563
- }
1564
- }
1565
- }
1566
- }
1567
- }
1568
- // keep drilling down
1569
- updateFallbackSlotVisibility(childNode);
1570
- }
1571
- }
1572
- };
1573
- /**
1574
- * Component-global information about nodes which are either currently being
1575
- * relocated or will be shortly.
1576
- */
1577
- const relocateNodes = [];
1578
- /**
1579
- * Mark the contents of a slot for relocation via adding references to them to
1580
- * the {@link relocateNodes} data structure. The actual work of relocating them
1581
- * will then be handled in {@link renderVdom}.
1582
- *
1583
- * @param elm a render node whose child nodes need to be relocated
1584
- */
1585
- const markSlotContentForRelocation = (elm) => {
1586
- // tslint:disable-next-line: prefer-const
1587
- let node;
1588
- let hostContentNodes;
1589
- let j;
1590
- for (const childNode of elm.childNodes) {
1591
- // we need to find child nodes which are slot references so we can then try
1592
- // to match them up with nodes that need to be relocated
1593
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1594
- // first get the content reference comment node ('s-cr'), then we get
1595
- // its parent, which is where all the host content is now
1596
- hostContentNodes = node.parentNode.childNodes;
1597
- const slotName = childNode['s-sn'];
1598
- // iterate through all the nodes under the location where the host was
1599
- // originally rendered
1600
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1601
- node = hostContentNodes[j];
1602
- // check that the node is not a content reference node or a node
1603
- // reference and then check that the host name does not match that of
1604
- // childNode.
1605
- // In addition, check that the slot either has not already been relocated, or
1606
- // that its current location's host is not childNode's host. This is essentially
1607
- // a check so that we don't try to relocate (and then hide) a node that is already
1608
- // where it should be.
1609
- if (!node['s-cn'] &&
1610
- !node['s-nr'] &&
1611
- node['s-hn'] !== childNode['s-hn'] &&
1612
- (!node['s-sh'] || node['s-sh'] !== childNode['s-hn'])) {
1613
- // if `node` is located in the slot that `childNode` refers to (via the
1614
- // `'s-sn'` property) then we need to relocate it from it's current spot
1615
- // (under the host element parent) to the right slot location
1616
- if (isNodeLocatedInSlot(node, slotName)) {
1617
- // it's possible we've already decided to relocate this node
1618
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1619
- // made some changes to slots
1620
- // let's make sure we also double check
1621
- // fallbacks are correctly hidden or shown
1622
- checkSlotFallbackVisibility = true;
1623
- // ensure that the slot-name attr is correct
1624
- node['s-sn'] = node['s-sn'] || slotName;
1625
- if (relocateNodeData) {
1626
- relocateNodeData.$nodeToRelocate$['s-sh'] = childNode['s-hn'];
1627
- // we marked this node for relocation previously but didn't find
1628
- // out the slot reference node to which it needs to be relocated
1629
- // so write it down now!
1630
- relocateNodeData.$slotRefNode$ = childNode;
1631
- }
1632
- else {
1633
- node['s-sh'] = childNode['s-hn'];
1634
- // add to our list of nodes to relocate
1635
- relocateNodes.push({
1636
- $slotRefNode$: childNode,
1637
- $nodeToRelocate$: node,
1638
- });
1639
- }
1640
- if (node['s-sr']) {
1641
- relocateNodes.map((relocateNode) => {
1642
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1643
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1644
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1645
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1646
- }
1647
- }
1648
- });
1649
- }
1650
- }
1651
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1652
- // the node is not found within the slot (`childNode`) that we're
1653
- // currently looking at, so we stick it into `relocateNodes` to
1654
- // handle later. If we never find a home for this element then
1655
- // we'll need to hide it
1656
- relocateNodes.push({
1657
- $nodeToRelocate$: node,
1658
- });
1659
- }
1660
- }
1661
- }
1662
- }
1663
- // if we're dealing with any type of element (capable of itself being a
1664
- // slot reference or containing one) then we recur
1665
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1666
- markSlotContentForRelocation(childNode);
1667
- }
1668
- }
1669
- };
1670
- /**
1671
- * Check whether a node is located in a given named slot.
1672
- *
1673
- * @param nodeToRelocate the node of interest
1674
- * @param slotName the slot name to check
1675
- * @returns whether the node is located in the slot or not
1676
- */
1677
- const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1678
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1679
- if (nodeToRelocate.getAttribute('slot') === null && slotName === '') {
1680
- // if the node doesn't have a slot attribute, and the slot we're checking
1681
- // is not a named slot, then we assume the node should be within the slot
1682
- return true;
1683
- }
1684
- if (nodeToRelocate.getAttribute('slot') === slotName) {
1685
- return true;
1686
- }
1687
- return false;
1688
- }
1689
- if (nodeToRelocate['s-sn'] === slotName) {
1690
- return true;
1691
- }
1692
- return slotName === '';
1693
- };
1694
- /**
1695
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
1696
- * them with `null`. This signals that the DOM element corresponding to the VDom
1697
- * node has been removed from the DOM.
1698
- *
1699
- * @param vNode a virtual DOM node
1700
- */
1701
- const nullifyVNodeRefs = (vNode) => {
1702
- {
1703
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1704
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1705
- }
1706
- };
1707
- /**
1708
- * The main entry point for Stencil's virtual DOM-based rendering engine
1709
- *
1710
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1711
- * function will handle creating a virtual DOM tree with a single root, patching
1712
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1713
- * relocation, and reflecting attributes.
1714
- *
1715
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1716
- * the DOM node into which it should be rendered.
1717
- * @param renderFnResults the virtual DOM nodes to be rendered
1718
- * @param isInitialLoad whether or not this is the first call after page load
1719
- */
1720
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1721
- var _a, _b, _c, _d, _e;
1722
- const hostElm = hostRef.$hostElement$;
1723
- const cmpMeta = hostRef.$cmpMeta$;
1724
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1725
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1726
- // we need to call `h` again to wrap the children of our component in a
1727
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1728
- // implicitly that the top-level vdom node is 1) an only child and 2)
1729
- // contains attrs that need to be set on the host element.
1730
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1731
- hostTagName = hostElm.tagName;
1732
- if (cmpMeta.$attrsToReflect$) {
1733
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1734
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1735
- }
1736
- // On the first render and *only* on the first render we want to check for
1737
- // any attributes set on the host element which are also set on the vdom
1738
- // node. If we find them, we override the value on the VDom node attrs with
1739
- // the value from the host element, which allows developers building apps
1740
- // with Stencil components to override e.g. the `role` attribute on a
1741
- // component even if it's already set on the `Host`.
1742
- if (isInitialLoad && rootVnode.$attrs$) {
1743
- for (const key of Object.keys(rootVnode.$attrs$)) {
1744
- // We have a special implementation in `setAccessor` for `style` and
1745
- // `class` which reconciles values coming from the VDom with values
1746
- // already present on the DOM element, so we don't want to override those
1747
- // attributes on the VDom tree with values from the host element if they
1748
- // are present.
1749
- //
1750
- // Likewise, `ref` and `key` are special internal values for the Stencil
1751
- // runtime and we don't want to override those either.
1752
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1753
- rootVnode.$attrs$[key] = hostElm[key];
1754
- }
1755
- }
1756
- }
1757
- rootVnode.$tag$ = null;
1758
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1759
- hostRef.$vnode$ = rootVnode;
1760
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1761
- {
1762
- scopeId = hostElm['s-sc'];
1763
- }
1764
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1765
- {
1766
- contentRef = hostElm['s-cr'];
1767
- // always reset
1768
- checkSlotFallbackVisibility = false;
1769
- }
1770
- // synchronous patch
1771
- patch(oldVNode, rootVnode, isInitialLoad);
1772
- {
1773
- // while we're moving nodes around existing nodes, temporarily disable
1774
- // the disconnectCallback from working
1775
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1776
- if (checkSlotRelocate) {
1777
- markSlotContentForRelocation(rootVnode.$elm$);
1778
- for (const relocateData of relocateNodes) {
1779
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1780
- if (!nodeToRelocate['s-ol']) {
1781
- // add a reference node marking this node's original location
1782
- // keep a reference to this node for later lookups
1783
- const orgLocationNode = doc.createTextNode('');
1784
- orgLocationNode['s-nr'] = nodeToRelocate;
1785
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1786
- }
1787
- }
1788
- for (const relocateData of relocateNodes) {
1789
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1790
- const slotRefNode = relocateData.$slotRefNode$;
1791
- if (slotRefNode) {
1792
- const parentNodeRef = slotRefNode.parentNode;
1793
- // When determining where to insert content, the most simple case would be
1794
- // to relocate the node immediately following the slot reference node. We do this
1795
- // by getting a reference to the node immediately following the slot reference node
1796
- // since we will use `insertBefore` to manipulate the DOM.
1797
- //
1798
- // If there is no node immediately following the slot reference node, then we will just
1799
- // end up appending the node as the last child of the parent.
1800
- let insertBeforeNode = slotRefNode.nextSibling;
1801
- // If the node we're currently planning on inserting the new node before is an element,
1802
- // we need to do some additional checks to make sure we're inserting the node in the correct order.
1803
- // The use case here would be that we have multiple nodes being relocated to the same slot. So, we want
1804
- // to make sure they get inserted into their new home in the same order they were declared in their original location.
1805
- //
1806
- // TODO(STENCIL-914): Remove `experimentalSlotFixes` check
1807
- if ((insertBeforeNode && insertBeforeNode.nodeType === 1 /* NODE_TYPE.ElementNode */)) {
1808
- let orgLocationNode = (_a = nodeToRelocate['s-ol']) === null || _a === void 0 ? void 0 : _a.previousSibling;
1809
- while (orgLocationNode) {
1810
- let refNode = (_b = orgLocationNode['s-nr']) !== null && _b !== void 0 ? _b : null;
1811
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1812
- refNode = refNode.nextSibling;
1813
- // If the refNode is the same node to be relocated or another element's slot reference, keep searching to find the
1814
- // correct relocation target
1815
- while (refNode === nodeToRelocate || (refNode === null || refNode === void 0 ? void 0 : refNode['s-sr'])) {
1816
- refNode = refNode === null || refNode === void 0 ? void 0 : refNode.nextSibling;
1817
- }
1818
- if (!refNode || !refNode['s-nr']) {
1819
- insertBeforeNode = refNode;
1820
- break;
1821
- }
1822
- }
1823
- orgLocationNode = orgLocationNode.previousSibling;
1824
- }
1825
- }
1826
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1827
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1828
- // we've checked that it's worth while to relocate
1829
- // since that the node to relocate
1830
- // has a different next sibling or parent relocated
1831
- if (nodeToRelocate !== insertBeforeNode) {
1832
- // Add it back to the dom but in its new home
1833
- // If we get to this point and `insertBeforeNode` is `null`, that means
1834
- // we're just going to append the node as the last child of the parent. Passing
1835
- // `null` as the second arg here will trigger that behavior.
1836
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1837
- // Reset the `hidden` value back to what it was defined as originally
1838
- // This solves a problem where a `slot` is dynamically rendered and `hidden` may have
1839
- // been set on content originally, but now it has a slot to go to so it should have
1840
- // the value it was defined as having in the DOM, not what we overrode it to.
1841
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1842
- nodeToRelocate.hidden = (_c = nodeToRelocate['s-ih']) !== null && _c !== void 0 ? _c : false;
1843
- }
1844
- }
1845
- }
1846
- nodeToRelocate && typeof slotRefNode['s-rf'] === 'function' && slotRefNode['s-rf'](nodeToRelocate);
1847
- }
1848
- else {
1849
- // this node doesn't have a slot home to go to, so let's hide it
1850
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1851
- // Store the initial value of `hidden` so we can reset it later when
1852
- // moving nodes around.
1853
- if (isInitialLoad) {
1854
- nodeToRelocate['s-ih'] = (_d = nodeToRelocate.hidden) !== null && _d !== void 0 ? _d : false;
1855
- }
1856
- nodeToRelocate.hidden = true;
1857
- }
1858
- }
1859
- }
1860
- }
1861
- if (checkSlotFallbackVisibility) {
1862
- updateFallbackSlotVisibility(rootVnode.$elm$);
1863
- }
1864
- // done moving nodes around
1865
- // allow the disconnect callback to work again
1866
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1867
- // always reset
1868
- relocateNodes.length = 0;
1869
- }
1870
- // Hide any elements that were projected through, but don't have a slot to go to.
1871
- // Only an issue if there were no "slots" rendered. Otherwise, nodes are hidden correctly.
1872
- // This _only_ happens for `scoped` components!
1873
- if (cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
1874
- for (const childNode of rootVnode.$elm$.childNodes) {
1875
- if (childNode['s-hn'] !== hostTagName && !childNode['s-sh']) {
1876
- // Store the initial value of `hidden` so we can reset it later when
1877
- // moving nodes around.
1878
- if (isInitialLoad && childNode['s-ih'] == null) {
1879
- childNode['s-ih'] = (_e = childNode.hidden) !== null && _e !== void 0 ? _e : false;
1880
- }
1881
- childNode.hidden = true;
1882
- }
1883
- }
1884
- }
1885
- // Clear the content ref so we don't create a memory leak
1886
- contentRef = undefined;
1887
- };
1888
- const attachToAncestor = (hostRef, ancestorComponent) => {
1889
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1890
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1891
- }
1892
- };
1893
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1894
- {
1895
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1896
- }
1897
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1898
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1899
- return;
1900
- }
1901
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1902
- // there is no ancestor component or the ancestor component
1903
- // has already fired off its lifecycle update then
1904
- // fire off the initial update
1905
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1906
- return writeTask(dispatch) ;
1907
- };
1908
- /**
1909
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1910
- * component lifecycle methods like `componentWillLoad` as well as
1911
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1912
- *
1913
- * @param hostRef a reference to a host DOM node
1914
- * @param isInitialLoad whether we're on the initial load or not
1915
- * @returns an empty Promise which is used to enqueue a series of operations for
1916
- * the component
1917
- */
1918
- const dispatchHooks = (hostRef, isInitialLoad) => {
1919
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1920
- const instance = hostRef.$lazyInstance$ ;
1921
- // We're going to use this variable together with `enqueue` to implement a
1922
- // little promise-based queue. We start out with it `undefined`. When we add
1923
- // the first function to the queue we'll set this variable to be that
1924
- // function's return value. When we attempt to add subsequent values to the
1925
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1926
- // the new function off of that `Promise` using `.then()`. This will give our
1927
- // queue two nice properties:
1928
- //
1929
- // 1. If all functions added to the queue are synchronous they'll be called
1930
- // synchronously right away.
1931
- // 2. If all functions added to the queue are asynchronous they'll all be
1932
- // called in order after `dispatchHooks` exits.
1933
- let maybePromise;
1934
- if (isInitialLoad) {
1935
- {
1936
- hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
1937
- if (hostRef.$queuedListeners$) {
1938
- hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
1939
- hostRef.$queuedListeners$ = undefined;
1940
- }
1941
- }
1942
- {
1943
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1944
- // whatever's going on in that `Promise` before we launch into
1945
- // rendering the component, doing other lifecycle stuff, etc. So
1946
- // in that case we assign the returned promise to the variable we
1947
- // declared above to hold a possible 'queueing' Promise
1948
- maybePromise = safeCall(instance, 'componentWillLoad');
1949
- }
1950
- }
1951
- {
1952
- maybePromise = enqueue(maybePromise, () => safeCall(instance, 'componentWillRender'));
1953
- }
1954
- endSchedule();
1955
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1956
- };
1957
- /**
1958
- * This function uses a Promise to implement a simple first-in, first-out queue
1959
- * of functions to be called.
1960
- *
1961
- * The queue is ordered on the basis of the first argument. If it's
1962
- * `undefined`, then nothing is on the queue yet, so the provided function can
1963
- * be called synchronously (although note that this function may return a
1964
- * `Promise`). The idea is that then the return value of that enqueueing
1965
- * operation is kept around, so that if it was a `Promise` then subsequent
1966
- * functions can be enqueued by calling this function again with that `Promise`
1967
- * as the first argument.
1968
- *
1969
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1970
- * @param fn a function to enqueue
1971
- * @returns either a `Promise` or the return value of the provided function
1972
- */
1973
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1974
- /**
1975
- * Check that a value is a `Promise`. To check, we first see if the value is an
1976
- * instance of the `Promise` global. In a few circumstances, in particular if
1977
- * the global has been overwritten, this is could be misleading, so we also do
1978
- * a little 'duck typing' check to see if the `.then` property of the value is
1979
- * defined and a function.
1980
- *
1981
- * @param maybePromise it might be a promise!
1982
- * @returns whether it is or not
1983
- */
1984
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1985
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1986
- /**
1987
- * Update a component given reference to its host elements and so on.
1988
- *
1989
- * @param hostRef an object containing references to the element's host node,
1990
- * VDom nodes, and other metadata
1991
- * @param instance a reference to the underlying host element where it will be
1992
- * rendered
1993
- * @param isInitialLoad whether or not this function is being called as part of
1994
- * the first render cycle
1995
- */
1996
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1997
- var _a;
1998
- const elm = hostRef.$hostElement$;
1999
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
2000
- const rc = elm['s-rc'];
2001
- if (isInitialLoad) {
2002
- // DOM WRITE!
2003
- attachStyles(hostRef);
2004
- }
2005
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
2006
- {
2007
- callRender(hostRef, instance, elm, isInitialLoad);
2008
- }
2009
- if (rc) {
2010
- // ok, so turns out there are some child host elements
2011
- // waiting on this parent element to load
2012
- // let's fire off all update callbacks waiting
2013
- rc.map((cb) => cb());
2014
- elm['s-rc'] = undefined;
2015
- }
2016
- endRender();
2017
- endUpdate();
2018
- {
2019
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
2020
- const postUpdate = () => postUpdateComponent(hostRef);
2021
- if (childrenPromises.length === 0) {
2022
- postUpdate();
2023
- }
2024
- else {
2025
- Promise.all(childrenPromises).then(postUpdate);
2026
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
2027
- childrenPromises.length = 0;
2028
- }
2029
- }
2030
- };
2031
- /**
2032
- * Handle making the call to the VDom renderer with the proper context given
2033
- * various build variables
2034
- *
2035
- * @param hostRef an object containing references to the element's host node,
2036
- * VDom nodes, and other metadata
2037
- * @param instance a reference to the underlying host element where it will be
2038
- * rendered
2039
- * @param elm the Host element for the component
2040
- * @param isInitialLoad whether or not this function is being called as part of
2041
- * @returns an empty promise
2042
- */
2043
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
2044
- try {
2045
- /**
2046
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
2047
- * method, so we can call the method immediately. If not, check before calling it.
2048
- */
2049
- instance = instance.render && instance.render();
2050
- {
2051
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
2052
- }
2053
- {
2054
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
2055
- }
2056
- {
2057
- {
2058
- // looks like we've got child nodes to render into this host element
2059
- // or we need to update the css class/attrs on the host element
2060
- // DOM WRITE!
2061
- {
2062
- renderVdom(hostRef, instance, isInitialLoad);
2063
- }
2064
- }
2065
- }
2066
- }
2067
- catch (e) {
2068
- consoleError(e, hostRef.$hostElement$);
2069
- }
2070
- return null;
2071
- };
2072
- const postUpdateComponent = (hostRef) => {
2073
- const tagName = hostRef.$cmpMeta$.$tagName$;
2074
- const elm = hostRef.$hostElement$;
2075
- const endPostUpdate = createTime('postUpdate', tagName);
2076
- const instance = hostRef.$lazyInstance$ ;
2077
- const ancestorComponent = hostRef.$ancestorComponent$;
2078
- {
2079
- safeCall(instance, 'componentDidRender');
2080
- }
2081
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
2082
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
2083
- {
2084
- // DOM WRITE!
2085
- addHydratedFlag(elm);
2086
- }
2087
- {
2088
- safeCall(instance, 'componentDidLoad');
2089
- }
2090
- endPostUpdate();
2091
- {
2092
- hostRef.$onReadyResolve$(elm);
2093
- if (!ancestorComponent) {
2094
- appDidLoad();
2095
- }
2096
- }
2097
- }
2098
- else {
2099
- {
2100
- safeCall(instance, 'componentDidUpdate');
2101
- }
2102
- endPostUpdate();
2103
- }
2104
- {
2105
- hostRef.$onInstanceResolve$(elm);
2106
- }
2107
- // load events fire from bottom to top
2108
- // the deepest elements load first then bubbles up
2109
- {
2110
- if (hostRef.$onRenderResolve$) {
2111
- hostRef.$onRenderResolve$();
2112
- hostRef.$onRenderResolve$ = undefined;
2113
- }
2114
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
2115
- nextTick(() => scheduleUpdate(hostRef, false));
2116
- }
2117
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
2118
- }
2119
- // ( •_•)
2120
- // ( •_•)>⌐■-■
2121
- // (⌐■_■)
2122
- };
2123
- const forceUpdate = (ref) => {
2124
- {
2125
- const hostRef = getHostRef(ref);
2126
- const isConnected = hostRef.$hostElement$.isConnected;
2127
- if (isConnected &&
2128
- (hostRef.$flags$ & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2129
- scheduleUpdate(hostRef, false);
2130
- }
2131
- // Returns "true" when the forced update was successfully scheduled
2132
- return isConnected;
2133
- }
2134
- };
2135
- const appDidLoad = (who) => {
2136
- // on appload
2137
- // we have finish the first big initial render
2138
- {
2139
- addHydratedFlag(doc.documentElement);
2140
- }
2141
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2142
- };
2143
- /**
2144
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
2145
- * e.g. custom element node. If a build figures out that e.g. no component
2146
- * has a `componentDidLoad` method, the instance method gets removed from the
2147
- * output bundle and this function returns `undefined`.
2148
- * @param instance any object that may or may not contain methods
2149
- * @param method method name
2150
- * @param arg single arbitrary argument
2151
- * @returns result of method call if it exists, otherwise `undefined`
2152
- */
2153
- const safeCall = (instance, method, arg) => {
2154
- if (instance && instance[method]) {
2155
- try {
2156
- return instance[method](arg);
2157
- }
2158
- catch (e) {
2159
- consoleError(e);
2160
- }
2161
- }
2162
- return undefined;
2163
- };
2164
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
2165
- ;
2166
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
2167
- const setValue = (ref, propName, newVal, cmpMeta) => {
2168
- // check our new property value against our internal value
2169
- const hostRef = getHostRef(ref);
2170
- const elm = hostRef.$hostElement$ ;
2171
- const oldVal = hostRef.$instanceValues$.get(propName);
2172
- const flags = hostRef.$flags$;
2173
- const instance = hostRef.$lazyInstance$ ;
2174
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2175
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
2176
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
2177
- const didValueChange = newVal !== oldVal && !areBothNaN;
2178
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2179
- // gadzooks! the property's value has changed!!
2180
- // set our new value!
2181
- hostRef.$instanceValues$.set(propName, newVal);
2182
- if (instance) {
2183
- // get an array of method names of watch functions to call
2184
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2185
- const watchMethods = cmpMeta.$watchers$[propName];
2186
- if (watchMethods) {
2187
- // this instance is watching for when this property changed
2188
- watchMethods.map((watchMethodName) => {
2189
- try {
2190
- // fire off each of the watch methods that are watching this property
2191
- instance[watchMethodName](newVal, oldVal, propName);
2192
- }
2193
- catch (e) {
2194
- consoleError(e, elm);
2195
- }
2196
- });
2197
- }
2198
- }
2199
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2200
- // looks like this value actually changed, so we've got work to do!
2201
- // but only if we've already rendered, otherwise just chill out
2202
- // queue that we need to do an update, but don't worry about queuing
2203
- // up millions cuz this function ensures it only runs once
2204
- scheduleUpdate(hostRef, false);
2205
- }
2206
- }
2207
- }
2208
- };
2209
- /**
2210
- * Attach a series of runtime constructs to a compiled Stencil component
2211
- * constructor, including getters and setters for the `@Prop` and `@State`
2212
- * decorators, callbacks for when attributes change, and so on.
2213
- *
2214
- * @param Cstr the constructor for a component that we need to process
2215
- * @param cmpMeta metadata collected previously about the component
2216
- * @param flags a number used to store a series of bit flags
2217
- * @returns a reference to the same constructor passed in (but now mutated)
2218
- */
2219
- const proxyComponent = (Cstr, cmpMeta, flags) => {
2220
- var _a;
2221
- const prototype = Cstr.prototype;
2222
- if (cmpMeta.$members$) {
2223
- if (Cstr.watchers) {
2224
- cmpMeta.$watchers$ = Cstr.watchers;
2225
- }
2226
- // It's better to have a const than two Object.entries()
2227
- const members = Object.entries(cmpMeta.$members$);
2228
- members.map(([memberName, [memberFlags]]) => {
2229
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2230
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2231
- // proxyComponent - prop
2232
- Object.defineProperty(prototype, memberName, {
2233
- get() {
2234
- // proxyComponent, get value
2235
- return getValue(this, memberName);
2236
- },
2237
- set(newValue) {
2238
- // proxyComponent, set value
2239
- setValue(this, memberName, newValue, cmpMeta);
2240
- },
2241
- configurable: true,
2242
- enumerable: true,
2243
- });
2244
- }
2245
- else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
2246
- memberFlags & 64 /* MEMBER_FLAGS.Method */) {
2247
- // proxyComponent - method
2248
- Object.defineProperty(prototype, memberName, {
2249
- value(...args) {
2250
- var _a;
2251
- const ref = getHostRef(this);
2252
- 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); });
2253
- },
2254
- });
2255
- }
2256
- });
2257
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2258
- const attrNameToPropName = new Map();
2259
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
2260
- plt.jmp(() => {
2261
- var _a;
2262
- const propName = attrNameToPropName.get(attrName);
2263
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
2264
- // in the case where an attribute was set inline.
2265
- // ```html
2266
- // <my-component some-attribute="some-value"></my-component>
2267
- // ```
2268
- //
2269
- // There is an edge case where a developer sets the attribute inline on a custom element and then
2270
- // programmatically changes it before it has been upgraded as shown below:
2271
- //
2272
- // ```html
2273
- // <!-- this component has _not_ been upgraded yet -->
2274
- // <my-component id="test" some-attribute="some-value"></my-component>
2275
- // <script>
2276
- // // grab non-upgraded component
2277
- // el = document.querySelector("#test");
2278
- // el.someAttribute = "another-value";
2279
- // // upgrade component
2280
- // customElements.define('my-component', MyComponent);
2281
- // </script>
2282
- // ```
2283
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
2284
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
2285
- // to the value that was set inline i.e. "some-value" from above example. When
2286
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
2287
- //
2288
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
2289
- // by connectedCallback as this attributeChangedCallback will not fire.
2290
- //
2291
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2292
- //
2293
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
2294
- // properties here given that this goes against best practices outlined here
2295
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2296
- if (this.hasOwnProperty(propName)) {
2297
- newValue = this[propName];
2298
- delete this[propName];
2299
- }
2300
- else if (prototype.hasOwnProperty(propName) &&
2301
- typeof this[propName] === 'number' &&
2302
- this[propName] == newValue) {
2303
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
2304
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
2305
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
2306
- return;
2307
- }
2308
- else if (propName == null) {
2309
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
2310
- // on a vanilla web component
2311
- const hostRef = getHostRef(this);
2312
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
2313
- // We only want to trigger the callback(s) if:
2314
- // 1. The instance is ready
2315
- // 2. The watchers are ready
2316
- // 3. The value has changed
2317
- if (flags &&
2318
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
2319
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
2320
- newValue !== oldValue) {
2321
- const instance = hostRef.$lazyInstance$ ;
2322
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
2323
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
2324
- if (instance[callbackName] != null) {
2325
- instance[callbackName].call(instance, newValue, oldValue, attrName);
2326
- }
2327
- });
2328
- }
2329
- return;
2330
- }
2331
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2332
- });
2333
- };
2334
- // Create an array of attributes to observe
2335
- // This list in comprised of all strings used within a `@Watch()` decorator
2336
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
2337
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
2338
- // an invalid attribute.
2339
- Cstr.observedAttributes = Array.from(new Set([
2340
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
2341
- ...members
2342
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
2343
- .map(([propName, m]) => {
2344
- var _a;
2345
- const attrName = m[1] || propName;
2346
- attrNameToPropName.set(attrName, propName);
2347
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2348
- (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
2349
- }
2350
- return attrName;
2351
- }),
2352
- ]));
2353
- }
2354
- }
2355
- return Cstr;
2356
- };
2357
- /**
2358
- * Initialize a Stencil component given a reference to its host element, its
2359
- * runtime bookkeeping data structure, runtime metadata about the component,
2360
- * and (optionally) an HMR version ID.
2361
- *
2362
- * @param elm a host element
2363
- * @param hostRef the element's runtime bookkeeping object
2364
- * @param cmpMeta runtime metadata for the Stencil component
2365
- * @param hmrVersionId an (optional) HMR version ID
2366
- */
2367
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2368
- let Cstr;
2369
- // initializeComponent
2370
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2371
- // Let the runtime know that the component has been initialized
2372
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2373
- const bundleId = cmpMeta.$lazyBundleId$;
2374
- if (bundleId) {
2375
- // lazy loaded components
2376
- // request the component's implementation to be
2377
- // wired up with the host element
2378
- Cstr = loadModule(cmpMeta);
2379
- if (Cstr.then) {
2380
- // Await creates a micro-task avoid if possible
2381
- const endLoad = uniqueTime();
2382
- Cstr = await Cstr;
2383
- endLoad();
2384
- }
2385
- if (!Cstr.isProxied) {
2386
- // we've never proxied this Constructor before
2387
- // let's add the getters/setters to its prototype before
2388
- // the first time we create an instance of the implementation
2389
- {
2390
- cmpMeta.$watchers$ = Cstr.watchers;
2391
- }
2392
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2393
- Cstr.isProxied = true;
2394
- }
2395
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2396
- // ok, time to construct the instance
2397
- // but let's keep track of when we start and stop
2398
- // so that the getters/setters don't incorrectly step on data
2399
- {
2400
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2401
- }
2402
- // construct the lazy-loaded component implementation
2403
- // passing the hostRef is very important during
2404
- // construction in order to directly wire together the
2405
- // host element and the lazy-loaded instance
2406
- try {
2407
- new Cstr(hostRef);
2408
- }
2409
- catch (e) {
2410
- consoleError(e);
2411
- }
2412
- {
2413
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2414
- }
2415
- {
2416
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2417
- }
2418
- endNewInstance();
2419
- fireConnectedCallback(hostRef.$lazyInstance$);
2420
- }
2421
- else {
2422
- // sync constructor component
2423
- Cstr = elm.constructor;
2424
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2425
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2426
- // Stencil has completed instantiating the component.
2427
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2428
- }
2429
- if (Cstr.style) {
2430
- // this component has styles but we haven't registered them yet
2431
- let style = Cstr.style;
2432
- if (typeof style !== 'string') {
2433
- style = style[(hostRef.$modeName$ = computeMode(elm))];
2434
- }
2435
- const scopeId = getScopeId(cmpMeta, hostRef.$modeName$);
2436
- if (!styles.has(scopeId)) {
2437
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2438
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2439
- endRegisterStyles();
2440
- }
2441
- }
2442
- }
2443
- // we've successfully created a lazy instance
2444
- const ancestorComponent = hostRef.$ancestorComponent$;
2445
- const schedule = () => scheduleUpdate(hostRef, true);
2446
- if (ancestorComponent && ancestorComponent['s-rc']) {
2447
- // this is the initial load and this component it has an ancestor component
2448
- // but the ancestor component has NOT fired its will update lifecycle yet
2449
- // so let's just cool our jets and wait for the ancestor to continue first
2450
- // this will get fired off when the ancestor component
2451
- // finally gets around to rendering its lazy self
2452
- // fire off the initial update
2453
- ancestorComponent['s-rc'].push(schedule);
2454
- }
2455
- else {
2456
- schedule();
2457
- }
2458
- };
2459
- const fireConnectedCallback = (instance) => {
2460
- {
2461
- safeCall(instance, 'connectedCallback');
2462
- }
2463
- };
2464
- const connectedCallback = (elm) => {
2465
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2466
- const hostRef = getHostRef(elm);
2467
- const cmpMeta = hostRef.$cmpMeta$;
2468
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2469
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2470
- // first time this component has connected
2471
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2472
- let hostId;
2473
- {
2474
- hostId = elm.getAttribute(HYDRATE_ID);
2475
- if (hostId) {
2476
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2477
- const scopeId = addStyle(elm.shadowRoot, cmpMeta, elm.getAttribute('s-mode'))
2478
- ;
2479
- elm.classList.remove(scopeId + '-h', scopeId + '-s');
2480
- }
2481
- initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2482
- }
2483
- }
2484
- if (!hostId) {
2485
- // initUpdate
2486
- // if the slot polyfill is required we'll need to put some nodes
2487
- // in here to act as original content anchors as we move nodes around
2488
- // host element has been connected to the DOM
2489
- if ((// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2490
- cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2491
- setContentReference(elm);
2492
- }
2493
- }
2494
- {
2495
- // find the first ancestor component (if there is one) and register
2496
- // this component as one of the actively loading child components for its ancestor
2497
- let ancestorComponent = elm;
2498
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2499
- // climb up the ancestors looking for the first
2500
- // component that hasn't finished its lifecycle update yet
2501
- if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2502
- ancestorComponent.hasAttribute('s-id') &&
2503
- ancestorComponent['s-p']) ||
2504
- ancestorComponent['s-p']) {
2505
- // we found this components first ancestor component
2506
- // keep a reference to this component's ancestor component
2507
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2508
- break;
2509
- }
2510
- }
2511
- }
2512
- // Lazy properties
2513
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2514
- if (cmpMeta.$members$) {
2515
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2516
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2517
- const value = elm[memberName];
2518
- delete elm[memberName];
2519
- elm[memberName] = value;
2520
- }
2521
- });
2522
- }
2523
- {
2524
- initializeComponent(elm, hostRef, cmpMeta);
2525
- }
2526
- }
2527
- else {
2528
- // not the first time this has connected
2529
- // reattach any event listeners to the host
2530
- // since they would have been removed when disconnected
2531
- addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
2532
- // fire off connectedCallback() on component instance
2533
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2534
- fireConnectedCallback(hostRef.$lazyInstance$);
2535
- }
2536
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2537
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback(hostRef.$lazyInstance$));
2538
- }
2539
- }
2540
- endConnected();
2541
- }
2542
- };
2543
- const setContentReference = (elm) => {
2544
- // only required when we're NOT using native shadow dom (slot)
2545
- // or this browser doesn't support native shadow dom
2546
- // and this host element was NOT created with SSR
2547
- // let's pick out the inner content for slot projection
2548
- // create a node to represent where the original
2549
- // content was first placed, which is useful later on
2550
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2551
- contentRefElm['s-cn'] = true;
2552
- elm.insertBefore(contentRefElm, elm.firstChild);
2553
- };
2554
- const disconnectInstance = (instance) => {
2555
- {
2556
- safeCall(instance, 'disconnectedCallback');
2557
- }
2558
- };
2559
- const disconnectedCallback = async (elm) => {
2560
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2561
- const hostRef = getHostRef(elm);
2562
- {
2563
- if (hostRef.$rmListeners$) {
2564
- hostRef.$rmListeners$.map((rmListener) => rmListener());
2565
- hostRef.$rmListeners$ = undefined;
2566
- }
2567
- }
2568
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2569
- disconnectInstance(hostRef.$lazyInstance$);
2570
- }
2571
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2572
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
2573
- }
2574
- }
2575
- };
2576
- const patchPseudoShadowDom = (hostElementPrototype, descriptorPrototype) => {
2577
- patchCloneNode(hostElementPrototype);
2578
- patchSlotAppendChild(hostElementPrototype);
2579
- patchSlotAppend(hostElementPrototype);
2580
- patchSlotPrepend(hostElementPrototype);
2581
- patchSlotInsertAdjacentElement(hostElementPrototype);
2582
- patchSlotInsertAdjacentHTML(hostElementPrototype);
2583
- patchSlotInsertAdjacentText(hostElementPrototype);
2584
- patchTextContent(hostElementPrototype);
2585
- patchChildSlotNodes(hostElementPrototype, descriptorPrototype);
2586
- patchSlotRemoveChild(hostElementPrototype);
2587
- };
2588
- const patchCloneNode = (HostElementPrototype) => {
2589
- const orgCloneNode = HostElementPrototype.cloneNode;
2590
- HostElementPrototype.cloneNode = function (deep) {
2591
- const srcNode = this;
2592
- const isShadowDom = srcNode.shadowRoot && supportsShadow ;
2593
- const clonedNode = orgCloneNode.call(srcNode, isShadowDom ? deep : false);
2594
- if (!isShadowDom && deep) {
2595
- let i = 0;
2596
- let slotted, nonStencilNode;
2597
- const stencilPrivates = [
2598
- 's-id',
2599
- 's-cr',
2600
- 's-lr',
2601
- 's-rc',
2602
- 's-sc',
2603
- 's-p',
2604
- 's-cn',
2605
- 's-sr',
2606
- 's-sn',
2607
- 's-hn',
2608
- 's-ol',
2609
- 's-nr',
2610
- 's-si',
2611
- 's-rf',
2612
- ];
2613
- for (; i < srcNode.childNodes.length; i++) {
2614
- slotted = srcNode.childNodes[i]['s-nr'];
2615
- nonStencilNode = stencilPrivates.every((privateField) => !srcNode.childNodes[i][privateField]);
2616
- if (slotted) {
2617
- if (clonedNode.__appendChild) {
2618
- clonedNode.__appendChild(slotted.cloneNode(true));
2619
- }
2620
- else {
2621
- clonedNode.appendChild(slotted.cloneNode(true));
2622
- }
2623
- }
2624
- if (nonStencilNode) {
2625
- clonedNode.appendChild(srcNode.childNodes[i].cloneNode(true));
2626
- }
2627
- }
2628
- }
2629
- return clonedNode;
2630
- };
2631
- };
2632
- /**
2633
- * Patches the `appendChild` method on a `scoped` Stencil component.
2634
- * The patch will attempt to find a slot with the same name as the node being appended
2635
- * and insert it into the slot reference if found. Otherwise, it falls-back to the original
2636
- * `appendChild` method.
2637
- *
2638
- * @param HostElementPrototype The Stencil component to be patched
2639
- */
2640
- const patchSlotAppendChild = (HostElementPrototype) => {
2641
- HostElementPrototype.__appendChild = HostElementPrototype.appendChild;
2642
- HostElementPrototype.appendChild = function (newChild) {
2643
- const slotName = (newChild['s-sn'] = getSlotName(newChild));
2644
- const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
2645
- if (slotNode) {
2646
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2647
- const appendAfter = slotChildNodes[slotChildNodes.length - 1];
2648
- const insertedNode = appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2649
- // Check if there is fallback content that should be hidden
2650
- updateFallbackSlotVisibility(this);
2651
- return insertedNode;
2652
- }
2653
- return this.__appendChild(newChild);
2654
- };
2655
- };
2656
- /**
2657
- * Patches the `removeChild` method on a `scoped` Stencil component.
2658
- * This patch attempts to remove the specified node from a slot reference
2659
- * if the slot exists. Otherwise, it falls-back to the original `removeChild` method.
2660
- *
2661
- * @param ElementPrototype The Stencil component to be patched
2662
- */
2663
- const patchSlotRemoveChild = (ElementPrototype) => {
2664
- ElementPrototype.__removeChild = ElementPrototype.removeChild;
2665
- ElementPrototype.removeChild = function (toRemove) {
2666
- if (toRemove && typeof toRemove['s-sn'] !== 'undefined') {
2667
- const slotNode = getHostSlotNode(this.childNodes, toRemove['s-sn'], this.tagName);
2668
- if (slotNode) {
2669
- // Get all slot content
2670
- const slotChildNodes = getHostSlotChildNodes(slotNode, toRemove['s-sn']);
2671
- // See if any of the slotted content matches the node to remove
2672
- const existingNode = slotChildNodes.find((n) => n === toRemove);
2673
- if (existingNode) {
2674
- existingNode.remove();
2675
- // Check if there is fallback content that should be displayed if that
2676
- // was the last node in the slot
2677
- updateFallbackSlotVisibility(this);
2678
- return;
2679
- }
2680
- }
2681
- }
2682
- return this.__removeChild(toRemove);
2683
- };
2684
- };
2685
- /**
2686
- * Patches the `prepend` method for a slotted node inside a scoped component.
2687
- *
2688
- * @param HostElementPrototype the `Element` to be patched
2689
- */
2690
- const patchSlotPrepend = (HostElementPrototype) => {
2691
- const originalPrepend = HostElementPrototype.prepend;
2692
- HostElementPrototype.prepend = function (...newChildren) {
2693
- newChildren.forEach((newChild) => {
2694
- if (typeof newChild === 'string') {
2695
- newChild = this.ownerDocument.createTextNode(newChild);
2696
- }
2697
- const slotName = (newChild['s-sn'] = getSlotName(newChild));
2698
- const slotNode = getHostSlotNode(this.childNodes, slotName, this.tagName);
2699
- if (slotNode) {
2700
- const slotPlaceholder = document.createTextNode('');
2701
- slotPlaceholder['s-nr'] = newChild;
2702
- slotNode['s-cr'].parentNode.__appendChild(slotPlaceholder);
2703
- newChild['s-ol'] = slotPlaceholder;
2704
- const slotChildNodes = getHostSlotChildNodes(slotNode, slotName);
2705
- const appendAfter = slotChildNodes[0];
2706
- return appendAfter.parentNode.insertBefore(newChild, appendAfter.nextSibling);
2707
- }
2708
- if (newChild.nodeType === 1 && !!newChild.getAttribute('slot')) {
2709
- newChild.hidden = true;
2710
- }
2711
- return originalPrepend.call(this, newChild);
2712
- });
2713
- };
2714
- };
2715
- /**
2716
- * Patches the `append` method for a slotted node inside a scoped component. The patched method uses
2717
- * `appendChild` under-the-hood while creating text nodes for any new children that passed as bare strings.
2718
- *
2719
- * @param HostElementPrototype the `Element` to be patched
2720
- */
2721
- const patchSlotAppend = (HostElementPrototype) => {
2722
- HostElementPrototype.append = function (...newChildren) {
2723
- newChildren.forEach((newChild) => {
2724
- if (typeof newChild === 'string') {
2725
- newChild = this.ownerDocument.createTextNode(newChild);
2726
- }
2727
- this.appendChild(newChild);
2728
- });
2729
- };
2730
- };
2731
- /**
2732
- * Patches the `insertAdjacentHTML` method for a slotted node inside a scoped component. Specifically,
2733
- * we only need to patch the behavior for the specific `beforeend` and `afterbegin` positions so the element
2734
- * gets inserted into the DOM in the correct location.
2735
- *
2736
- * @param HostElementPrototype the `Element` to be patched
2737
- */
2738
- const patchSlotInsertAdjacentHTML = (HostElementPrototype) => {
2739
- const originalInsertAdjacentHtml = HostElementPrototype.insertAdjacentHTML;
2740
- HostElementPrototype.insertAdjacentHTML = function (position, text) {
2741
- if (position !== 'afterbegin' && position !== 'beforeend') {
2742
- return originalInsertAdjacentHtml.call(this, position, text);
2743
- }
2744
- const container = this.ownerDocument.createElement('_');
2745
- let node;
2746
- container.innerHTML = text;
2747
- if (position === 'afterbegin') {
2748
- while ((node = container.firstChild)) {
2749
- this.prepend(node);
2750
- }
2751
- }
2752
- else if (position === 'beforeend') {
2753
- while ((node = container.firstChild)) {
2754
- this.append(node);
2755
- }
2756
- }
2757
- };
2758
- };
2759
- /**
2760
- * Patches the `insertAdjacentText` method for a slotted node inside a scoped component. Specifically,
2761
- * we only need to patch the behavior for the specific `beforeend` and `afterbegin` positions so the text node
2762
- * gets inserted into the DOM in the correct location.
2763
- *
2764
- * @param HostElementPrototype the `Element` to be patched
2765
- */
2766
- const patchSlotInsertAdjacentText = (HostElementPrototype) => {
2767
- HostElementPrototype.insertAdjacentText = function (position, text) {
2768
- this.insertAdjacentHTML(position, text);
2769
- };
2770
- };
2771
- /**
2772
- * Patches the `insertAdjacentElement` method for a slotted node inside a scoped component. Specifically,
2773
- * we only need to patch the behavior for the specific `beforeend` and `afterbegin` positions so the element
2774
- * gets inserted into the DOM in the correct location.
2775
- *
2776
- * @param HostElementPrototype the `Element` to be patched
2777
- */
2778
- const patchSlotInsertAdjacentElement = (HostElementPrototype) => {
2779
- const originalInsertAdjacentElement = HostElementPrototype.insertAdjacentElement;
2780
- HostElementPrototype.insertAdjacentElement = function (position, element) {
2781
- if (position !== 'afterbegin' && position !== 'beforeend') {
2782
- return originalInsertAdjacentElement.call(this, position, element);
2783
- }
2784
- if (position === 'afterbegin') {
2785
- this.prepend(element);
2786
- return element;
2787
- }
2788
- else if (position === 'beforeend') {
2789
- this.append(element);
2790
- return element;
2791
- }
2792
- return element;
2793
- };
2794
- };
2795
- /**
2796
- * Patches the text content of an unnamed slotted node inside a scoped component
2797
- * @param hostElementPrototype the `Element` to be patched
2798
- */
2799
- const patchTextContent = (hostElementPrototype) => {
2800
- const descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'textContent');
2801
- Object.defineProperty(hostElementPrototype, '__textContent', descriptor);
2802
- {
2803
- // Patch `textContent` to mimic shadow root behavior
2804
- Object.defineProperty(hostElementPrototype, 'textContent', {
2805
- // To mimic shadow root behavior, we need to return the text content of all
2806
- // nodes in a slot reference node
2807
- get() {
2808
- const slotRefNodes = getAllChildSlotNodes(this.childNodes);
2809
- const textContent = slotRefNodes
2810
- .map((node) => {
2811
- var _a, _b;
2812
- const text = [];
2813
- // Need to get the text content of all nodes in the slot reference node
2814
- let slotContent = node.nextSibling;
2815
- while (slotContent && slotContent['s-sn'] === node['s-sn']) {
2816
- if (slotContent.nodeType === 3 /* NODE_TYPES.TEXT_NODE */ || slotContent.nodeType === 1 /* NODE_TYPES.ELEMENT_NODE */) {
2817
- text.push((_b = (_a = slotContent.textContent) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '');
2818
- }
2819
- slotContent = slotContent.nextSibling;
2820
- }
2821
- return text.filter((ref) => ref !== '').join(' ');
2822
- })
2823
- .filter((text) => text !== '')
2824
- .join(' ');
2825
- // Pad the string to return
2826
- return ' ' + textContent + ' ';
2827
- },
2828
- // To mimic shadow root behavior, we need to overwrite all nodes in a slot
2829
- // reference node. If a default slot reference node exists, the text content will be
2830
- // placed there. Otherwise, the new text node will be hidden
2831
- set(value) {
2832
- const slotRefNodes = getAllChildSlotNodes(this.childNodes);
2833
- slotRefNodes.forEach((node) => {
2834
- // Remove the existing content of the slot
2835
- let slotContent = node.nextSibling;
2836
- while (slotContent && slotContent['s-sn'] === node['s-sn']) {
2837
- const tmp = slotContent;
2838
- slotContent = slotContent.nextSibling;
2839
- tmp.remove();
2840
- }
2841
- // If this is a default slot, add the text node in the slot location.
2842
- // Otherwise, destroy the slot reference node
2843
- if (node['s-sn'] === '') {
2844
- const textNode = this.ownerDocument.createTextNode(value);
2845
- textNode['s-sn'] = '';
2846
- node.parentElement.insertBefore(textNode, node.nextSibling);
2847
- }
2848
- else {
2849
- node.remove();
2850
- }
2851
- });
2852
- },
2853
- });
2854
- }
2855
- };
2856
- const patchChildSlotNodes = (elm, cmpMeta) => {
2857
- class FakeNodeList extends Array {
2858
- item(n) {
2859
- return this[n];
2860
- }
2861
- }
2862
- // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2863
- if (cmpMeta.$flags$ & 8 /* CMP_FLAGS.needsShadowDomShim */) {
2864
- const childNodesFn = elm.__lookupGetter__('childNodes');
2865
- Object.defineProperty(elm, 'children', {
2866
- get() {
2867
- return this.childNodes.map((n) => n.nodeType === 1);
2868
- },
2869
- });
2870
- Object.defineProperty(elm, 'childElementCount', {
2871
- get() {
2872
- return elm.children.length;
2873
- },
2874
- });
2875
- Object.defineProperty(elm, 'childNodes', {
2876
- get() {
2877
- const childNodes = childNodesFn.call(this);
2878
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0 &&
2879
- getHostRef(this).$flags$ & 2 /* HOST_FLAGS.hasRendered */) {
2880
- const result = new FakeNodeList();
2881
- for (let i = 0; i < childNodes.length; i++) {
2882
- const slot = childNodes[i]['s-nr'];
2883
- if (slot) {
2884
- result.push(slot);
2885
- }
2886
- }
2887
- return result;
2888
- }
2889
- return FakeNodeList.from(childNodes);
2890
- },
2891
- });
2892
- }
2893
- };
2894
- /**
2895
- * Recursively finds all slot reference nodes ('s-sr') in a series of child nodes.
2896
- *
2897
- * @param childNodes The set of child nodes to search for slot reference nodes.
2898
- * @returns An array of slot reference nodes.
2899
- */
2900
- const getAllChildSlotNodes = (childNodes) => {
2901
- const slotRefNodes = [];
2902
- for (const childNode of Array.from(childNodes)) {
2903
- if (childNode['s-sr']) {
2904
- slotRefNodes.push(childNode);
2905
- }
2906
- slotRefNodes.push(...getAllChildSlotNodes(childNode.childNodes));
2907
- }
2908
- return slotRefNodes;
2909
- };
2910
- const getSlotName = (node) => node['s-sn'] || (node.nodeType === 1 && node.getAttribute('slot')) || '';
2911
- /**
2912
- * Recursively searches a series of child nodes for a slot with the provided name.
2913
- * @param childNodes the nodes to search for a slot with a specific name.
2914
- * @param slotName the name of the slot to match on.
2915
- * @param hostName the host name of the slot to match on.
2916
- * @returns a reference to the slot node that matches the provided name, `null` otherwise
2917
- */
2918
- const getHostSlotNode = (childNodes, slotName, hostName) => {
2919
- let i = 0;
2920
- let childNode;
2921
- for (; i < childNodes.length; i++) {
2922
- childNode = childNodes[i];
2923
- if (childNode['s-sr'] && childNode['s-sn'] === slotName && childNode['s-hn'] === hostName) {
2924
- return childNode;
2925
- }
2926
- childNode = getHostSlotNode(childNode.childNodes, slotName, hostName);
2927
- if (childNode) {
2928
- return childNode;
2929
- }
2930
- }
2931
- return null;
2932
- };
2933
- const getHostSlotChildNodes = (n, slotName) => {
2934
- const childNodes = [n];
2935
- while ((n = n.nextSibling) && n['s-sn'] === slotName) {
2936
- childNodes.push(n);
2937
- }
2938
- return childNodes;
2939
- };
2940
- const bootstrapLazy = (lazyBundles, options = {}) => {
2941
- var _a;
2942
- const endBootstrap = createTime();
2943
- const cmpTags = [];
2944
- const exclude = options.exclude || [];
2945
- const customElements = win.customElements;
2946
- const head = doc.head;
2947
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2948
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
2949
- const deferredConnectedCallbacks = [];
2950
- const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2951
- let appLoadFallback;
2952
- let isBootstrapping = true;
2953
- let i = 0;
2954
- Object.assign(plt, options);
2955
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2956
- {
2957
- // If the app is already hydrated there is not point to disable the
2958
- // async queue. This will improve the first input delay
2959
- plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2960
- }
2961
- {
2962
- for (; i < styles.length; i++) {
2963
- registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2964
- }
2965
- }
2966
- let hasSlotRelocation = false;
2967
- lazyBundles.map((lazyBundle) => {
2968
- lazyBundle[1].map((compactMeta) => {
2969
- var _a;
2970
- const cmpMeta = {
2971
- $flags$: compactMeta[0],
2972
- $tagName$: compactMeta[1],
2973
- $members$: compactMeta[2],
2974
- $listeners$: compactMeta[3],
2975
- };
2976
- // Check if we are using slots outside the shadow DOM in this component.
2977
- // We'll use this information later to add styles for `slot-fb` elements
2978
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
2979
- hasSlotRelocation = true;
2980
- }
2981
- {
2982
- cmpMeta.$members$ = compactMeta[2];
2983
- }
2984
- {
2985
- cmpMeta.$listeners$ = compactMeta[3];
2986
- }
2987
- {
2988
- cmpMeta.$attrsToReflect$ = [];
2989
- }
2990
- {
2991
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
2992
- }
2993
- const tagName = cmpMeta.$tagName$;
2994
- const HostElement = class extends HTMLElement {
2995
- // StencilLazyHost
2996
- constructor(self) {
2997
- // @ts-ignore
2998
- super(self);
2999
- self = this;
3000
- registerHost(self, cmpMeta);
3001
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
3002
- // this component is using shadow dom
3003
- // and this browser supports shadow dom
3004
- // add the read-only property "shadowRoot" to the host element
3005
- // adding the shadow root build conditionals to minimize runtime
3006
- {
3007
- {
3008
- self.attachShadow({
3009
- mode: 'open',
3010
- delegatesFocus: !!(cmpMeta.$flags$ & 16 /* CMP_FLAGS.shadowDelegatesFocus */),
3011
- });
3012
- }
3013
- }
3014
- }
3015
- }
3016
- connectedCallback() {
3017
- if (appLoadFallback) {
3018
- clearTimeout(appLoadFallback);
3019
- appLoadFallback = null;
3020
- }
3021
- if (isBootstrapping) {
3022
- // connectedCallback will be processed once all components have been registered
3023
- deferredConnectedCallbacks.push(this);
3024
- }
3025
- else {
3026
- plt.jmp(() => connectedCallback(this));
3027
- }
3028
- }
3029
- disconnectedCallback() {
3030
- plt.jmp(() => disconnectedCallback(this));
3031
- }
3032
- componentOnReady() {
3033
- return getHostRef(this).$onReadyPromise$;
3034
- }
3035
- };
3036
- // TODO(STENCIL-914): this check and `else` block can go away and be replaced by just the `scoped` check
3037
- {
3038
- // This check is intentionally not combined with the surrounding `experimentalSlotFixes` check
3039
- // since, moving forward, we only want to patch the pseudo shadow DOM when the component is scoped
3040
- if (cmpMeta.$flags$ & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
3041
- patchPseudoShadowDom(HostElement.prototype, cmpMeta);
3042
- }
3043
- }
3044
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
3045
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
3046
- cmpTags.push(tagName);
3047
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
3048
- }
3049
- });
3050
- });
3051
- // Only bother generating CSS if we have components
3052
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
3053
- if (cmpTags.length > 0) {
3054
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
3055
- if (hasSlotRelocation) {
3056
- dataStyles.textContent += SLOT_FB_CSS;
3057
- }
3058
- // Add hydration styles
3059
- {
3060
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
3061
- }
3062
- // If we have styles, add them to the DOM
3063
- if (dataStyles.innerHTML.length) {
3064
- dataStyles.setAttribute('data-styles', '');
3065
- // Apply CSP nonce to the style tag if it exists
3066
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
3067
- if (nonce != null) {
3068
- dataStyles.setAttribute('nonce', nonce);
3069
- }
3070
- // Insert the styles into the document head
3071
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
3072
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
3073
- }
3074
- }
3075
- // Process deferred connectedCallbacks now all components have been registered
3076
- isBootstrapping = false;
3077
- if (deferredConnectedCallbacks.length) {
3078
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
3079
- }
3080
- else {
3081
- {
3082
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
3083
- }
3084
- }
3085
- // Fallback appLoad event
3086
- endBootstrap();
3087
- };
3088
- const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
3089
- if (listeners) {
3090
- listeners.map(([flags, name, method]) => {
3091
- const target = getHostListenerTarget(elm, flags) ;
3092
- const handler = hostListenerProxy(hostRef, method);
3093
- const opts = hostListenerOpts(flags);
3094
- plt.ael(target, name, handler, opts);
3095
- (hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
3096
- });
3097
- }
3098
- };
3099
- const hostListenerProxy = (hostRef, methodName) => (ev) => {
3100
- try {
3101
- {
3102
- if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
3103
- // instance is ready, let's call it's member method for this event
3104
- hostRef.$lazyInstance$[methodName](ev);
3105
- }
3106
- else {
3107
- (hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
3108
- }
3109
- }
3110
- }
3111
- catch (e) {
3112
- consoleError(e);
3113
- }
3114
- };
3115
- const getHostListenerTarget = (elm, flags) => {
3116
- if (flags & 4 /* LISTENER_FLAGS.TargetDocument */)
3117
- return doc;
3118
- if (flags & 8 /* LISTENER_FLAGS.TargetWindow */)
3119
- return win;
3120
- if (flags & 16 /* LISTENER_FLAGS.TargetBody */)
3121
- return doc.body;
3122
- return elm;
3123
- };
3124
- // prettier-ignore
3125
- const hostListenerOpts = (flags) => supportsListenerOptions
3126
- ? ({
3127
- passive: (flags & 1 /* LISTENER_FLAGS.Passive */) !== 0,
3128
- capture: (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0,
3129
- })
3130
- : (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
3131
- /**
3132
- * Assigns the given value to the nonce property on the runtime platform object.
3133
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
3134
- * @param nonce The value to be assigned to the platform nonce property.
3135
- * @returns void
3136
- */
3137
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
3138
- /**
3139
- * A WeakMap mapping runtime component references to their corresponding host reference
3140
- * instances.
3141
- *
3142
- * **Note**: If we're in an HMR context we need to store a reference to this
3143
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
3144
- * to {@link d.HostRef} across HMR updates.
3145
- *
3146
- * This is necessary because when HMR updates for a component are processed by
3147
- * the browser-side dev server client the JS bundle for that component is
3148
- * re-fetched. Since the module containing {@link hostRefs} is included in
3149
- * that bundle, if we do not store a reference to it the new iteration of the
3150
- * component will not have access to the previous hostRef map, leading to a
3151
- * bug where the new version of the component cannot properly initialize.
3152
- */
3153
- const hostRefs = new WeakMap();
3154
- /**
3155
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
3156
- *
3157
- * @param ref the runtime ref of interest
3158
- * @returns the Host reference (if found) or undefined
3159
- */
3160
- const getHostRef = (ref) => hostRefs.get(ref);
3161
- /**
3162
- * Register a lazy instance with the {@link hostRefs} object so it's
3163
- * corresponding {@link d.HostRef} can be retrieved later.
3164
- *
3165
- * @param lazyInstance the lazy instance of interest
3166
- * @param hostRef that instances `HostRef` object
3167
- * @returns a reference to the host ref WeakMap
3168
- */
3169
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
3170
- /**
3171
- * Register a host element for a Stencil component, setting up various metadata
3172
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
3173
- * metadata.
3174
- *
3175
- * @param hostElement the host element to register
3176
- * @param cmpMeta runtime metadata for that component
3177
- * @returns a reference to the host ref WeakMap
3178
- */
3179
- const registerHost = (hostElement, cmpMeta) => {
3180
- const hostRef = {
3181
- $flags$: 0,
3182
- $hostElement$: hostElement,
3183
- $cmpMeta$: cmpMeta,
3184
- $instanceValues$: new Map(),
3185
- };
3186
- {
3187
- hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
3188
- }
3189
- {
3190
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
3191
- hostElement['s-p'] = [];
3192
- hostElement['s-rc'] = [];
3193
- }
3194
- addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
3195
- return hostRefs.set(hostElement, hostRef);
3196
- };
3197
- const isMemberInElement = (elm, memberName) => memberName in elm;
3198
- const consoleError = (e, el) => (0, console.error)(e, el);
3199
- const cmpModules = /*@__PURE__*/ new Map();
3200
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
3201
- // loadModuleImport
3202
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
3203
- const bundleId = cmpMeta.$lazyBundleId$;
3204
- const module = cmpModules.get(bundleId) ;
3205
- if (module) {
3206
- return module[exportName];
3207
- }
3208
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
3209
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
3210
- /* @vite-ignore */
3211
- /* webpackInclude: /\.entry\.js$/ */
3212
- /* webpackExclude: /\.system\.entry\.js$/ */
3213
- /* webpackMode: "lazy" */
3214
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
3215
- {
3216
- cmpModules.set(bundleId, importedModule);
3217
- }
3218
- return importedModule[exportName];
3219
- }, consoleError);
3220
- };
3221
- const styles = /*@__PURE__*/ new Map();
3222
- const modeResolutionChain = [];
3223
- const win = typeof window !== 'undefined' ? window : {};
3224
- const doc = win.document || { head: {} };
3225
- const H = (win.HTMLElement || class {
3226
- });
3227
- const plt = {
3228
- $flags$: 0,
3229
- $resourcesUrl$: '',
3230
- jmp: (h) => h(),
3231
- raf: (h) => requestAnimationFrame(h),
3232
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
3233
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
3234
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
3235
- };
3236
- const setPlatformHelpers = (helpers) => {
3237
- Object.assign(plt, helpers);
3238
- };
3239
- const supportsShadow =
3240
- // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
3241
- true;
3242
- const supportsListenerOptions = /*@__PURE__*/ (() => {
3243
- let supportsListenerOptions = false;
3244
- try {
3245
- doc.addEventListener('e', null, Object.defineProperty({}, 'passive', {
3246
- get() {
3247
- supportsListenerOptions = true;
3248
- },
3249
- }));
3250
- }
3251
- catch (e) { }
3252
- return supportsListenerOptions;
3253
- })();
3254
- const promiseResolve = (v) => Promise.resolve(v);
3255
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
3256
- try {
3257
- new CSSStyleSheet();
3258
- return typeof new CSSStyleSheet().replaceSync === 'function';
3259
- }
3260
- catch (e) { }
3261
- return false;
3262
- })()
3263
- ;
3264
- const queueDomReads = [];
3265
- const queueDomWrites = [];
3266
- const queueTask = (queue, write) => (cb) => {
3267
- queue.push(cb);
3268
- if (!queuePending) {
3269
- queuePending = true;
3270
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
3271
- nextTick(flush);
3272
- }
3273
- else {
3274
- plt.raf(flush);
3275
- }
3276
- }
3277
- };
3278
- const consume = (queue) => {
3279
- for (let i = 0; i < queue.length; i++) {
3280
- try {
3281
- queue[i](performance.now());
3282
- }
3283
- catch (e) {
3284
- consoleError(e);
3285
- }
3286
- }
3287
- queue.length = 0;
3288
- };
3289
- const flush = () => {
3290
- // always force a bunch of medium callbacks to run, but still have
3291
- // a throttle on how many can run in a certain time
3292
- // DOM READS!!!
3293
- consume(queueDomReads);
3294
- // DOM WRITES!!!
3295
- {
3296
- consume(queueDomWrites);
3297
- if ((queuePending = queueDomReads.length > 0)) {
3298
- // still more to do yet, but we've run out of time
3299
- // let's let this thing cool off and try again in the next tick
3300
- plt.raf(flush);
3301
- }
3302
- }
3303
- };
3304
- const nextTick = (cb) => promiseResolve().then(cb);
3305
- const readTask = /*@__PURE__*/ queueTask(queueDomReads, false);
3306
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
3307
-
3308
- exports.Build = Build;
3309
- exports.H = H;
3310
- exports.Host = Host;
3311
- exports.bootstrapLazy = bootstrapLazy;
3312
- exports.createEvent = createEvent;
3313
- exports.forceUpdate = forceUpdate;
3314
- exports.getAssetPath = getAssetPath;
3315
- exports.getElement = getElement;
3316
- exports.getMode = getMode;
3317
- exports.h = h;
3318
- exports.promiseResolve = promiseResolve;
3319
- exports.readTask = readTask;
3320
- exports.registerInstance = registerInstance;
3321
- exports.setMode = setMode;
3322
- exports.setNonce = setNonce;
3323
- exports.setPlatformHelpers = setPlatformHelpers;
3324
- exports.writeTask = writeTask;