voyager-ionic-core 8.0.0 → 8.1.0

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