@sankhyalabs/sankhyablocks 1.3.34 → 1.4.0-beta.10
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.
- package/dist/cjs/SnkMessageBuilder-6c2f7bcd.js +302 -0
- package/dist/cjs/_commonjsHelpers-537d719a.js +20 -0
- package/dist/cjs/configurableElementsStorage-93459c72.js +20 -0
- package/dist/cjs/constants-9056ca9e.js +84 -0
- package/dist/cjs/draggable.bundle-82a25c06.js +6886 -0
- package/dist/cjs/filter-item-type.enum-3daf58d3.js +16 -0
- package/dist/cjs/form-config-fetcher-2de7c16a.js +6895 -0
- package/dist/cjs/{index-1133bc2a.js → index-20e8b68a.js} +964 -209
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/sankhyablocks.cjs.js +3 -3
- package/dist/cjs/snk-application.cjs.entry.js +680 -6994
- package/dist/cjs/snk-config-modal.cjs.entry.js +62 -0
- package/dist/cjs/snk-config-options.cjs.entry.js +230 -0
- package/dist/cjs/snk-configurator_6.cjs.entry.js +1156 -0
- package/dist/cjs/snk-crud.cjs.entry.js +78 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +272 -0
- package/dist/cjs/snk-field-config_2.cjs.entry.js +135 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +50 -0
- package/dist/cjs/snk-filter-detail.cjs.entry.js +106 -0
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +26 -0
- package/dist/cjs/snk-filter-number.cjs.entry.js +27 -0
- package/dist/cjs/snk-filter-period.cjs.entry.js +40 -0
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +89 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +38 -0
- package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
- package/dist/cjs/snk-form-config.cjs.entry.js +957 -0
- package/dist/cjs/snk-form.cjs.entry.js +146 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-tab-config.cjs.entry.js +321 -0
- package/dist/cjs/taskbar-elements-9a4b1e19.js +97 -0
- package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +45 -2
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +9 -2
- package/dist/collection/components/snk-application/snk-application.js +1346 -642
- package/dist/collection/components/snk-configurator/snk-configurator.js +261 -0
- package/dist/collection/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.js +16 -0
- package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.css +122 -0
- package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.js +137 -0
- package/dist/collection/components/snk-crud/snk-crud.css +6 -0
- package/dist/collection/components/snk-crud/snk-crud.js +232 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +517 -0
- package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +100 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +111 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +87 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +88 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +101 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +180 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +102 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +12 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +178 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +289 -0
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +299 -0
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +222 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +149 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +462 -0
- package/dist/collection/components/snk-form/snk-form.css +38 -0
- package/dist/collection/components/snk-form/snk-form.js +336 -0
- package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.css +9 -0
- package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.js +315 -0
- package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.css +164 -0
- package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.js +140 -0
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.css +185 -0
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +1062 -0
- package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.css +272 -0
- package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.js +476 -0
- package/dist/collection/components/snk-grid/snk-grid.css +18 -0
- package/dist/collection/components/snk-grid/snk-grid.js +273 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +90 -0
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +339 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +39 -14
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +87 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +62 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +106 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +15 -15
- package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +9 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
- package/dist/collection/lib/index.js +2 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +130 -0
- package/dist/collection/lib/message/resources/crud-utils.msg.js +4 -0
- package/dist/collection/lib/message/resources/snk-configurator.msg.js +11 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +23 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +30 -0
- package/dist/collection/lib/message/resources/snk-form.msg.js +67 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +17 -0
- package/dist/collection/lib/utils/CrudUtils.js +73 -0
- package/dist/collection/lib/utils/constants.js +72 -0
- package/dist/components/SnkMessageBuilder.js +280 -0
- package/dist/components/_commonjsHelpers.js +17 -0
- package/dist/components/constants.js +74 -0
- package/dist/components/filter-item-type.enum.js +14 -0
- package/dist/components/form-config-fetcher.js +6889 -0
- package/dist/components/index.d.ts +26 -5
- package/dist/components/index.js +26 -0
- package/dist/components/snk-application2.js +681 -6980
- package/dist/components/snk-config-modal.d.ts +11 -0
- package/dist/components/snk-config-modal.js +6 -0
- package/dist/components/snk-config-modal2.js +91 -0
- package/dist/components/snk-config-options.d.ts +11 -0
- package/dist/components/snk-config-options.js +6 -0
- package/dist/components/snk-config-options2.js +245 -0
- package/dist/components/snk-configurator.d.ts +11 -0
- package/dist/components/snk-configurator.js +6 -0
- package/dist/components/snk-configurator2.js +212 -0
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +183 -0
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +294 -0
- package/dist/components/snk-field-config.d.ts +11 -0
- package/dist/components/snk-field-config.js +6 -0
- package/dist/components/snk-field-config2.js +70 -0
- package/dist/components/snk-filter-bar.d.ts +11 -0
- package/dist/components/snk-filter-bar.js +6 -0
- package/dist/components/snk-filter-bar2.js +516 -0
- package/dist/components/snk-filter-binary-select.d.ts +11 -0
- package/dist/components/snk-filter-binary-select.js +67 -0
- package/dist/components/snk-filter-detail.d.ts +11 -0
- package/dist/components/snk-filter-detail.js +6 -0
- package/dist/components/snk-filter-detail2.js +120 -0
- package/dist/components/snk-filter-item.d.ts +11 -0
- package/dist/components/snk-filter-item.js +6 -0
- package/dist/components/snk-filter-item2.js +194 -0
- package/dist/components/snk-filter-list.d.ts +11 -0
- package/dist/components/snk-filter-list.js +6 -0
- package/dist/components/snk-filter-list2.js +149 -0
- package/dist/components/snk-filter-modal.d.ts +11 -0
- package/dist/components/snk-filter-modal.js +6 -0
- package/dist/components/snk-filter-modal2.js +84 -0
- package/dist/components/snk-filter-multi-select.d.ts +11 -0
- package/dist/components/snk-filter-multi-select.js +43 -0
- package/dist/components/snk-filter-number.d.ts +11 -0
- package/dist/components/snk-filter-number.js +44 -0
- package/dist/components/snk-filter-period.d.ts +11 -0
- package/dist/components/snk-filter-period.js +57 -0
- package/dist/components/snk-filter-personalized.d.ts +11 -0
- package/dist/components/snk-filter-personalized.js +108 -0
- package/dist/components/snk-filter-search.d.ts +11 -0
- package/dist/components/snk-filter-search.js +55 -0
- package/dist/components/snk-filter-text.d.ts +11 -0
- package/dist/components/snk-filter-text.js +38 -0
- package/dist/components/snk-form-config.d.ts +11 -0
- package/dist/components/snk-form-config.js +6 -0
- package/dist/components/snk-form-config2.js +996 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +6 -0
- package/dist/components/snk-form2.js +209 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +6 -0
- package/dist/components/snk-grid2.js +152 -0
- package/dist/components/snk-tab-config.d.ts +11 -0
- package/dist/components/snk-tab-config.js +6 -0
- package/dist/components/snk-tab-config2.js +7220 -0
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +282 -0
- package/dist/components/taskbar-processor.js +45 -0
- package/dist/esm/SnkMessageBuilder-5792c260.js +280 -0
- package/dist/esm/_commonjsHelpers-9943807e.js +17 -0
- package/dist/esm/configurableElementsStorage-cdc144b5.js +18 -0
- package/dist/esm/constants-c6039d3d.js +74 -0
- package/dist/esm/draggable.bundle-41d56f06.js +6884 -0
- package/dist/esm/filter-item-type.enum-a79b2fa8.js +14 -0
- package/dist/esm/form-config-fetcher-96c6c2dc.js +6889 -0
- package/dist/esm/{index-ffda6382.js → index-e4121713.js} +963 -210
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/sankhyablocks.js +3 -3
- package/dist/esm/snk-application.entry.js +667 -6981
- package/dist/esm/snk-config-modal.entry.js +58 -0
- package/dist/esm/snk-config-options.entry.js +226 -0
- package/dist/esm/snk-configurator_6.entry.js +1147 -0
- package/dist/esm/snk-crud.entry.js +74 -0
- package/dist/esm/snk-data-unit.entry.js +268 -0
- package/dist/esm/snk-field-config_2.entry.js +130 -0
- package/dist/esm/snk-filter-binary-select.entry.js +46 -0
- package/dist/esm/snk-filter-detail.entry.js +102 -0
- package/dist/esm/snk-filter-multi-select.entry.js +22 -0
- package/dist/esm/snk-filter-number.entry.js +23 -0
- package/dist/esm/snk-filter-period.entry.js +36 -0
- package/dist/esm/snk-filter-personalized.entry.js +85 -0
- package/dist/esm/snk-filter-search.entry.js +34 -0
- package/dist/esm/snk-filter-text.entry.js +18 -0
- package/dist/esm/snk-form-config.entry.js +953 -0
- package/dist/esm/snk-form.entry.js +142 -0
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-tab-config.entry.js +317 -0
- package/dist/esm/taskbar-elements-e2ed0536.js +94 -0
- package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-029ae4e4.entry.js +1 -0
- package/dist/sankhyablocks/p-03f9c407.js +1 -0
- package/dist/sankhyablocks/p-112455b1.js +1 -0
- package/dist/sankhyablocks/p-12ad2a19.entry.js +1 -0
- package/dist/sankhyablocks/p-1feabfc7.entry.js +1 -0
- package/dist/sankhyablocks/p-21c8929b.js +1 -0
- package/dist/sankhyablocks/p-2284c850.entry.js +1 -0
- package/dist/sankhyablocks/p-2b891c4a.entry.js +1 -0
- package/dist/sankhyablocks/p-2dc76d79.entry.js +1 -0
- package/dist/sankhyablocks/p-361299e8.js +26 -0
- package/dist/sankhyablocks/p-3a276f3d.entry.js +1 -0
- package/dist/sankhyablocks/p-400cc777.entry.js +1 -0
- package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-44ce5b90.entry.js} +1 -1
- package/dist/sankhyablocks/p-521c96f0.entry.js +1 -0
- package/dist/sankhyablocks/{p-9520d78a.entry.js → p-6988f4a6.entry.js} +1 -1
- package/dist/sankhyablocks/p-776ff4d1.entry.js +1 -0
- package/dist/sankhyablocks/p-7b4a4a50.entry.js +1 -0
- package/dist/sankhyablocks/p-9ba3df4c.js +2 -0
- package/dist/sankhyablocks/p-9dc4426d.entry.js +1 -0
- package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
- package/dist/sankhyablocks/p-a17a4fca.entry.js +1 -0
- package/dist/sankhyablocks/p-a5b26df2.js +1 -0
- package/dist/sankhyablocks/p-b6d6b172.js +1 -0
- package/dist/sankhyablocks/p-cc4bef9f.entry.js +1 -0
- package/dist/sankhyablocks/p-d50651a3.js +1 -0
- package/dist/sankhyablocks/p-d690b6b5.entry.js +75 -0
- package/dist/sankhyablocks/p-d9fbb26f.js +1 -0
- package/dist/sankhyablocks/p-deb1f523.entry.js +1 -0
- package/dist/sankhyablocks/p-e871aa92.entry.js +1 -0
- package/dist/sankhyablocks/p-e9beab79.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +178 -26
- package/dist/types/components/snk-configurator/snk-configurator.d.ts +46 -0
- package/dist/types/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.d.ts +8 -0
- package/dist/types/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.d.ts +38 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +50 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +92 -0
- package/dist/types/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +13 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +15 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +24 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +11 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +8 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +11 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +20 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +40 -0
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +45 -0
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +26 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +65 -0
- package/dist/types/components/snk-form/snk-form.d.ts +71 -0
- package/dist/types/components/snk-form/subcomponents/snk-config-options/snk-config-options.d.ts +51 -0
- package/dist/types/components/snk-form/subcomponents/snk-field-config/snk-field-config.d.ts +32 -0
- package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +139 -0
- package/dist/types/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.d.ts +97 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +59 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +30 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +92 -0
- package/dist/types/components.d.ts +1100 -12
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +7 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +21 -3
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +7 -7
- package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
- package/dist/types/lib/message/resources/crud-utils.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-configurator.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-form.msg.d.ts +5 -0
- package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
- package/dist/types/lib/utils/CrudUtils.d.ts +6 -0
- package/dist/types/lib/utils/constants.d.ts +76 -0
- package/dist/types/lib/utils/pesquisa.d.ts +2 -1
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +6 -5
- package/react/components.d.ts +23 -0
- package/react/components.js +23 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-98e8490d.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
const NAMESPACE = 'sankhyablocks';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
5
|
+
* Simon Friis Vindum (@paldepind)
|
|
6
|
+
* Licensed under the MIT License
|
|
7
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
8
|
+
*
|
|
9
|
+
* Modified for Stencil's renderer and slot projection
|
|
10
|
+
*/
|
|
3
11
|
let scopeId;
|
|
12
|
+
let contentRef;
|
|
4
13
|
let hostTagName;
|
|
14
|
+
let useNativeShadowDom = false;
|
|
15
|
+
let checkSlotFallbackVisibility = false;
|
|
16
|
+
let checkSlotRelocate = false;
|
|
5
17
|
let isSvgMode = false;
|
|
6
18
|
let queuePending = false;
|
|
7
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
8
|
-
const doc = win.document || { head: {} };
|
|
9
|
-
const plt = {
|
|
10
|
-
$flags$: 0,
|
|
11
|
-
$resourcesUrl$: '',
|
|
12
|
-
jmp: (h) => h(),
|
|
13
|
-
raf: (h) => requestAnimationFrame(h),
|
|
14
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
15
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
16
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
17
|
-
};
|
|
18
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
19
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
20
|
-
try {
|
|
21
|
-
new CSSStyleSheet();
|
|
22
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
23
|
-
}
|
|
24
|
-
catch (e) { }
|
|
25
|
-
return false;
|
|
26
|
-
})()
|
|
27
|
-
;
|
|
28
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
29
19
|
const createTime = (fnName, tagName = '') => {
|
|
30
20
|
{
|
|
31
21
|
return () => {
|
|
@@ -40,74 +30,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
40
30
|
};
|
|
41
31
|
}
|
|
42
32
|
};
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
let style = styles.get(scopeId);
|
|
46
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
47
|
-
style = (style || new CSSStyleSheet());
|
|
48
|
-
style.replace(cssText);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
style = cssText;
|
|
52
|
-
}
|
|
53
|
-
styles.set(scopeId, style);
|
|
54
|
-
};
|
|
55
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
56
|
-
let scopeId = getScopeId(cmpMeta);
|
|
57
|
-
const style = styles.get(scopeId);
|
|
58
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
59
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
60
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
61
|
-
if (style) {
|
|
62
|
-
if (typeof style === 'string') {
|
|
63
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
64
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
65
|
-
let styleElm;
|
|
66
|
-
if (!appliedStyles) {
|
|
67
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
68
|
-
}
|
|
69
|
-
if (!appliedStyles.has(scopeId)) {
|
|
70
|
-
{
|
|
71
|
-
{
|
|
72
|
-
styleElm = doc.createElement('style');
|
|
73
|
-
styleElm.innerHTML = style;
|
|
74
|
-
}
|
|
75
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
76
|
-
}
|
|
77
|
-
if (appliedStyles) {
|
|
78
|
-
appliedStyles.add(scopeId);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
83
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return scopeId;
|
|
87
|
-
};
|
|
88
|
-
const attachStyles = (hostRef) => {
|
|
89
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
90
|
-
const elm = hostRef.$hostElement$;
|
|
91
|
-
const flags = cmpMeta.$flags$;
|
|
92
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
93
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
94
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
95
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
96
|
-
// or this browser doesn't support native shadow dom
|
|
97
|
-
// and this host element was NOT created with SSR
|
|
98
|
-
// let's pick out the inner content for slot projection
|
|
99
|
-
// create a node to represent where the original
|
|
100
|
-
// content was first placed, which is useful later on
|
|
101
|
-
// DOM WRITE!!
|
|
102
|
-
elm['s-sc'] = scopeId;
|
|
103
|
-
elm.classList.add(scopeId + '-h');
|
|
104
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
105
|
-
elm.classList.add(scopeId + '-s');
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
endAttachStyles();
|
|
109
|
-
};
|
|
110
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
33
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
34
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
111
35
|
/**
|
|
112
36
|
* Default style mode id
|
|
113
37
|
*/
|
|
@@ -135,6 +59,8 @@ const isComplexType = (o) => {
|
|
|
135
59
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
136
60
|
const h = (nodeName, vnodeData, ...children) => {
|
|
137
61
|
let child = null;
|
|
62
|
+
let key = null;
|
|
63
|
+
let slotName = null;
|
|
138
64
|
let simple = false;
|
|
139
65
|
let lastSimple = false;
|
|
140
66
|
const vNodeChildren = [];
|
|
@@ -162,6 +88,13 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
162
88
|
};
|
|
163
89
|
walk(children);
|
|
164
90
|
if (vnodeData) {
|
|
91
|
+
// normalize class / classname attributes
|
|
92
|
+
if (vnodeData.key) {
|
|
93
|
+
key = vnodeData.key;
|
|
94
|
+
}
|
|
95
|
+
if (vnodeData.name) {
|
|
96
|
+
slotName = vnodeData.name;
|
|
97
|
+
}
|
|
165
98
|
{
|
|
166
99
|
const classData = vnodeData.className || vnodeData.class;
|
|
167
100
|
if (classData) {
|
|
@@ -174,11 +107,21 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
174
107
|
}
|
|
175
108
|
}
|
|
176
109
|
}
|
|
110
|
+
if (typeof nodeName === 'function') {
|
|
111
|
+
// nodeName is a functional component
|
|
112
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
113
|
+
}
|
|
177
114
|
const vnode = newVNode(nodeName, null);
|
|
178
115
|
vnode.$attrs$ = vnodeData;
|
|
179
116
|
if (vNodeChildren.length > 0) {
|
|
180
117
|
vnode.$children$ = vNodeChildren;
|
|
181
118
|
}
|
|
119
|
+
{
|
|
120
|
+
vnode.$key$ = key;
|
|
121
|
+
}
|
|
122
|
+
{
|
|
123
|
+
vnode.$name$ = slotName;
|
|
124
|
+
}
|
|
182
125
|
return vnode;
|
|
183
126
|
};
|
|
184
127
|
const newVNode = (tag, text) => {
|
|
@@ -192,10 +135,192 @@ const newVNode = (tag, text) => {
|
|
|
192
135
|
{
|
|
193
136
|
vnode.$attrs$ = null;
|
|
194
137
|
}
|
|
138
|
+
{
|
|
139
|
+
vnode.$key$ = null;
|
|
140
|
+
}
|
|
141
|
+
{
|
|
142
|
+
vnode.$name$ = null;
|
|
143
|
+
}
|
|
195
144
|
return vnode;
|
|
196
145
|
};
|
|
197
146
|
const Host = {};
|
|
198
147
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
148
|
+
const vdomFnUtils = {
|
|
149
|
+
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
150
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
151
|
+
};
|
|
152
|
+
const convertToPublic = (node) => ({
|
|
153
|
+
vattrs: node.$attrs$,
|
|
154
|
+
vchildren: node.$children$,
|
|
155
|
+
vkey: node.$key$,
|
|
156
|
+
vname: node.$name$,
|
|
157
|
+
vtag: node.$tag$,
|
|
158
|
+
vtext: node.$text$,
|
|
159
|
+
});
|
|
160
|
+
const convertToPrivate = (node) => {
|
|
161
|
+
if (typeof node.vtag === 'function') {
|
|
162
|
+
const vnodeData = Object.assign({}, node.vattrs);
|
|
163
|
+
if (node.vkey) {
|
|
164
|
+
vnodeData.key = node.vkey;
|
|
165
|
+
}
|
|
166
|
+
if (node.vname) {
|
|
167
|
+
vnodeData.name = node.vname;
|
|
168
|
+
}
|
|
169
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
170
|
+
}
|
|
171
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
172
|
+
vnode.$attrs$ = node.vattrs;
|
|
173
|
+
vnode.$children$ = node.vchildren;
|
|
174
|
+
vnode.$key$ = node.vkey;
|
|
175
|
+
vnode.$name$ = node.vname;
|
|
176
|
+
return vnode;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Parse a new property value for a given property type.
|
|
180
|
+
*
|
|
181
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
182
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
183
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
184
|
+
* 2. the type stored from `propType`.
|
|
185
|
+
*
|
|
186
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
187
|
+
*
|
|
188
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
189
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
190
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
191
|
+
* ```tsx
|
|
192
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* HTML prop values on the other hand, will always a string
|
|
196
|
+
*
|
|
197
|
+
* @param propValue the new value to coerce to some type
|
|
198
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
199
|
+
* @returns the parsed/coerced value
|
|
200
|
+
*/
|
|
201
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
202
|
+
// ensure this value is of the correct prop type
|
|
203
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
204
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
205
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
206
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
207
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
208
|
+
}
|
|
209
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
210
|
+
// force it to be a number
|
|
211
|
+
return parseFloat(propValue);
|
|
212
|
+
}
|
|
213
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
214
|
+
// could have been passed as a number or boolean
|
|
215
|
+
// but we still want it as a string
|
|
216
|
+
return String(propValue);
|
|
217
|
+
}
|
|
218
|
+
// redundant return here for better minification
|
|
219
|
+
return propValue;
|
|
220
|
+
}
|
|
221
|
+
// not sure exactly what type we want
|
|
222
|
+
// so no need to change to a different type
|
|
223
|
+
return propValue;
|
|
224
|
+
};
|
|
225
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
226
|
+
const createEvent = (ref, name, flags) => {
|
|
227
|
+
const elm = getElement(ref);
|
|
228
|
+
return {
|
|
229
|
+
emit: (detail) => {
|
|
230
|
+
return emitEvent(elm, name, {
|
|
231
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
232
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
233
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
234
|
+
detail,
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
241
|
+
* @param elm the target of the Event
|
|
242
|
+
* @param name the name to give the custom Event
|
|
243
|
+
* @param opts options for configuring a custom Event
|
|
244
|
+
* @returns the custom Event
|
|
245
|
+
*/
|
|
246
|
+
const emitEvent = (elm, name, opts) => {
|
|
247
|
+
const ev = plt.ce(name, opts);
|
|
248
|
+
elm.dispatchEvent(ev);
|
|
249
|
+
return ev;
|
|
250
|
+
};
|
|
251
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
252
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
253
|
+
let style = styles.get(scopeId);
|
|
254
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
255
|
+
style = (style || new CSSStyleSheet());
|
|
256
|
+
if (typeof style === 'string') {
|
|
257
|
+
style = cssText;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
style.replaceSync(cssText);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
style = cssText;
|
|
265
|
+
}
|
|
266
|
+
styles.set(scopeId, style);
|
|
267
|
+
};
|
|
268
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
269
|
+
let scopeId = getScopeId(cmpMeta);
|
|
270
|
+
const style = styles.get(scopeId);
|
|
271
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
272
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
273
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
274
|
+
if (style) {
|
|
275
|
+
if (typeof style === 'string') {
|
|
276
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
277
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
278
|
+
let styleElm;
|
|
279
|
+
if (!appliedStyles) {
|
|
280
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
281
|
+
}
|
|
282
|
+
if (!appliedStyles.has(scopeId)) {
|
|
283
|
+
{
|
|
284
|
+
{
|
|
285
|
+
styleElm = doc.createElement('style');
|
|
286
|
+
styleElm.innerHTML = style;
|
|
287
|
+
}
|
|
288
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
289
|
+
}
|
|
290
|
+
if (appliedStyles) {
|
|
291
|
+
appliedStyles.add(scopeId);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
296
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return scopeId;
|
|
300
|
+
};
|
|
301
|
+
const attachStyles = (hostRef) => {
|
|
302
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
303
|
+
const elm = hostRef.$hostElement$;
|
|
304
|
+
const flags = cmpMeta.$flags$;
|
|
305
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
306
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
307
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
308
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
309
|
+
// or this browser doesn't support native shadow dom
|
|
310
|
+
// and this host element was NOT created with SSR
|
|
311
|
+
// let's pick out the inner content for slot projection
|
|
312
|
+
// create a node to represent where the original
|
|
313
|
+
// content was first placed, which is useful later on
|
|
314
|
+
// DOM WRITE!!
|
|
315
|
+
elm['s-sc'] = scopeId;
|
|
316
|
+
elm.classList.add(scopeId + '-h');
|
|
317
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
318
|
+
elm.classList.add(scopeId + '-s');
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
endAttachStyles();
|
|
322
|
+
};
|
|
323
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
199
324
|
/**
|
|
200
325
|
* Production setAccessor() function based on Preact by
|
|
201
326
|
* Jason Miller (@developit)
|
|
@@ -215,6 +340,33 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
215
340
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
216
341
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
217
342
|
}
|
|
343
|
+
else if (memberName === 'style') {
|
|
344
|
+
// update style attribute, css properties and values
|
|
345
|
+
{
|
|
346
|
+
for (const prop in oldValue) {
|
|
347
|
+
if (!newValue || newValue[prop] == null) {
|
|
348
|
+
if (prop.includes('-')) {
|
|
349
|
+
elm.style.removeProperty(prop);
|
|
350
|
+
}
|
|
351
|
+
else {
|
|
352
|
+
elm.style[prop] = '';
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
for (const prop in newValue) {
|
|
358
|
+
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
359
|
+
if (prop.includes('-')) {
|
|
360
|
+
elm.style.setProperty(prop, newValue[prop]);
|
|
361
|
+
}
|
|
362
|
+
else {
|
|
363
|
+
elm.style[prop] = newValue[prop];
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
else if (memberName === 'key')
|
|
369
|
+
;
|
|
218
370
|
else if (memberName === 'ref') {
|
|
219
371
|
// minifier will clean this up
|
|
220
372
|
if (newValue) {
|
|
@@ -281,16 +433,36 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
281
433
|
}
|
|
282
434
|
catch (e) { }
|
|
283
435
|
}
|
|
436
|
+
/**
|
|
437
|
+
* Need to manually update attribute if:
|
|
438
|
+
* - memberName is not an attribute
|
|
439
|
+
* - if we are rendering the host element in order to reflect attribute
|
|
440
|
+
* - if it's a SVG, since properties might not work in <svg>
|
|
441
|
+
* - if the newValue is null/undefined or 'false'.
|
|
442
|
+
*/
|
|
443
|
+
let xlink = false;
|
|
444
|
+
{
|
|
445
|
+
if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
|
|
446
|
+
memberName = ln;
|
|
447
|
+
xlink = true;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
284
450
|
if (newValue == null || newValue === false) {
|
|
285
451
|
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
286
|
-
{
|
|
452
|
+
if (xlink) {
|
|
453
|
+
elm.removeAttributeNS(XLINK_NS, memberName);
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
287
456
|
elm.removeAttribute(memberName);
|
|
288
457
|
}
|
|
289
458
|
}
|
|
290
459
|
}
|
|
291
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
460
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
292
461
|
newValue = newValue === true ? '' : newValue;
|
|
293
|
-
{
|
|
462
|
+
if (xlink) {
|
|
463
|
+
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
464
|
+
}
|
|
465
|
+
else {
|
|
294
466
|
elm.setAttribute(memberName, newValue);
|
|
295
467
|
}
|
|
296
468
|
}
|
|
@@ -303,7 +475,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
303
475
|
// if the element passed in is a shadow root, which is a document fragment
|
|
304
476
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
305
477
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
306
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
478
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
307
479
|
? newVnode.$elm$.host
|
|
308
480
|
: newVnode.$elm$;
|
|
309
481
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -321,19 +493,52 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
321
493
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
322
494
|
}
|
|
323
495
|
};
|
|
496
|
+
/**
|
|
497
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
498
|
+
*
|
|
499
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
500
|
+
* @param newParentVNode the parent VNode from the current render
|
|
501
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
502
|
+
* children, for which we will create a new DOM node
|
|
503
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
504
|
+
* @returns the newly created node
|
|
505
|
+
*/
|
|
324
506
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
325
507
|
// tslint:disable-next-line: prefer-const
|
|
326
508
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
327
509
|
let i = 0;
|
|
328
510
|
let elm;
|
|
329
511
|
let childNode;
|
|
512
|
+
let oldVNode;
|
|
513
|
+
if (!useNativeShadowDom) {
|
|
514
|
+
// remember for later we need to check to relocate nodes
|
|
515
|
+
checkSlotRelocate = true;
|
|
516
|
+
if (newVNode.$tag$ === 'slot') {
|
|
517
|
+
if (scopeId) {
|
|
518
|
+
// scoped css needs to add its scoped id to the parent element
|
|
519
|
+
parentElm.classList.add(scopeId + '-s');
|
|
520
|
+
}
|
|
521
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
522
|
+
? // slot element has fallback content
|
|
523
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
524
|
+
: // slot element does not have fallback content
|
|
525
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
330
528
|
if (newVNode.$text$ !== null) {
|
|
331
529
|
// create text node
|
|
332
530
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
333
531
|
}
|
|
532
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
533
|
+
// create a slot reference node
|
|
534
|
+
elm = newVNode.$elm$ =
|
|
535
|
+
doc.createTextNode('');
|
|
536
|
+
}
|
|
334
537
|
else {
|
|
335
538
|
// create element
|
|
336
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
539
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
540
|
+
? 'slot-fb'
|
|
541
|
+
: newVNode.$tag$));
|
|
337
542
|
// add css classes, attrs, props, listeners, etc.
|
|
338
543
|
{
|
|
339
544
|
updateElement(null, newVNode, isSvgMode);
|
|
@@ -346,7 +551,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
346
551
|
if (newVNode.$children$) {
|
|
347
552
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
348
553
|
// create the node
|
|
349
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
554
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
350
555
|
// return node could have been null
|
|
351
556
|
if (childNode) {
|
|
352
557
|
// append our new node
|
|
@@ -355,20 +560,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
355
560
|
}
|
|
356
561
|
}
|
|
357
562
|
}
|
|
563
|
+
{
|
|
564
|
+
elm['s-hn'] = hostTagName;
|
|
565
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
566
|
+
// remember the content reference comment
|
|
567
|
+
elm['s-sr'] = true;
|
|
568
|
+
// remember the content reference comment
|
|
569
|
+
elm['s-cr'] = contentRef;
|
|
570
|
+
// remember the slot name, or empty string for default slot
|
|
571
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
572
|
+
// check if we've got an old vnode for this slot
|
|
573
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
574
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
575
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
576
|
+
// so let's move the old slot content back to it's original location
|
|
577
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
358
581
|
return elm;
|
|
359
582
|
};
|
|
583
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
584
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
585
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
586
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
587
|
+
const childNode = oldSlotChildNodes[i];
|
|
588
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
589
|
+
// // this child node in the old element is from another component
|
|
590
|
+
// // remove this node from the old slot's parent
|
|
591
|
+
// childNode.remove();
|
|
592
|
+
// and relocate it back to it's original location
|
|
593
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
594
|
+
// remove the old original location comment entirely
|
|
595
|
+
// later on the patch function will know what to do
|
|
596
|
+
// and move this to the correct spot in need be
|
|
597
|
+
childNode['s-ol'].remove();
|
|
598
|
+
childNode['s-ol'] = undefined;
|
|
599
|
+
checkSlotRelocate = true;
|
|
600
|
+
}
|
|
601
|
+
if (recursive) {
|
|
602
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
606
|
+
};
|
|
360
607
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
361
|
-
let containerElm = (parentElm);
|
|
608
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
362
609
|
let childNode;
|
|
363
610
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
364
611
|
containerElm = containerElm.shadowRoot;
|
|
365
612
|
}
|
|
366
613
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
367
614
|
if (vnodes[startIdx]) {
|
|
368
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
615
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
369
616
|
if (childNode) {
|
|
370
617
|
vnodes[startIdx].$elm$ = childNode;
|
|
371
|
-
containerElm.insertBefore(childNode, before);
|
|
618
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
372
619
|
}
|
|
373
620
|
}
|
|
374
621
|
}
|
|
@@ -378,14 +625,98 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
378
625
|
if ((vnode = vnodes[startIdx])) {
|
|
379
626
|
elm = vnode.$elm$;
|
|
380
627
|
callNodeRefs(vnode);
|
|
628
|
+
{
|
|
629
|
+
// we're removing this element
|
|
630
|
+
// so it's possible we need to show slot fallback content now
|
|
631
|
+
checkSlotFallbackVisibility = true;
|
|
632
|
+
if (elm['s-ol']) {
|
|
633
|
+
// remove the original location comment
|
|
634
|
+
elm['s-ol'].remove();
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
// it's possible that child nodes of the node
|
|
638
|
+
// that's being removed are slot nodes
|
|
639
|
+
putBackInOriginalLocation(elm, true);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
381
642
|
// remove the vnode's element from the dom
|
|
382
643
|
elm.remove();
|
|
383
644
|
}
|
|
384
645
|
}
|
|
385
646
|
};
|
|
647
|
+
/**
|
|
648
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
649
|
+
* traversing the two collections of children, identifying nodes that are
|
|
650
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
651
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
652
|
+
*
|
|
653
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
654
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
655
|
+
* 'windows' by storing start and end indices and references to the
|
|
656
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
657
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
658
|
+
* no children left to update by doing the following:
|
|
659
|
+
*
|
|
660
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
661
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
662
|
+
* only with a window bounded by the highlighted elements:
|
|
663
|
+
*
|
|
664
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
665
|
+
* ^^^^^^ ^^^^^^
|
|
666
|
+
*
|
|
667
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
668
|
+
* across the windows. This will basically detect elements which haven't
|
|
669
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
670
|
+
* VNode elements (represented as HTML):
|
|
671
|
+
*
|
|
672
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
673
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
674
|
+
*
|
|
675
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
676
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
677
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
678
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
679
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
680
|
+
*
|
|
681
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
682
|
+
* window corresponds to the element at the end of the other window. This is
|
|
683
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
684
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
685
|
+
* children nodes themselves have not changed but merely moved in the
|
|
686
|
+
* following example:
|
|
687
|
+
*
|
|
688
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
689
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
690
|
+
*
|
|
691
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
692
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
693
|
+
* DOM.
|
|
694
|
+
*
|
|
695
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
696
|
+
* nodes in the old children which have the same key as the first element in
|
|
697
|
+
* our window on the new children. If we find such a node we handle calling
|
|
698
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
699
|
+
* what we find.
|
|
700
|
+
*
|
|
701
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
702
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
703
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
704
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
705
|
+
* children has collapsed we still have more nodes on the new children that
|
|
706
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
707
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
708
|
+
* sure the corresponding DOM nodes are removed.
|
|
709
|
+
*
|
|
710
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
711
|
+
* @param oldCh the old children of the parent node
|
|
712
|
+
* @param newVNode the new VNode which will replace the parent
|
|
713
|
+
* @param newCh the new children of the parent node
|
|
714
|
+
*/
|
|
386
715
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
387
716
|
let oldStartIdx = 0;
|
|
388
717
|
let newStartIdx = 0;
|
|
718
|
+
let idxInOld = 0;
|
|
719
|
+
let i = 0;
|
|
389
720
|
let oldEndIdx = oldCh.length - 1;
|
|
390
721
|
let oldStartVnode = oldCh[0];
|
|
391
722
|
let oldEndVnode = oldCh[oldEndIdx];
|
|
@@ -393,9 +724,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
393
724
|
let newStartVnode = newCh[0];
|
|
394
725
|
let newEndVnode = newCh[newEndIdx];
|
|
395
726
|
let node;
|
|
727
|
+
let elmToMove;
|
|
396
728
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
397
729
|
if (oldStartVnode == null) {
|
|
398
|
-
//
|
|
730
|
+
// VNode might have been moved left
|
|
399
731
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
400
732
|
}
|
|
401
733
|
else if (oldEndVnode == null) {
|
|
@@ -408,64 +740,212 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
408
740
|
newEndVnode = newCh[--newEndIdx];
|
|
409
741
|
}
|
|
410
742
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
743
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
744
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
745
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
746
|
+
// since things are matched up in order.
|
|
411
747
|
patch(oldStartVnode, newStartVnode);
|
|
412
748
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
413
749
|
newStartVnode = newCh[++newStartIdx];
|
|
414
750
|
}
|
|
415
751
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
752
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
753
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
754
|
+
// need to move any DOM Nodes.
|
|
416
755
|
patch(oldEndVnode, newEndVnode);
|
|
417
756
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
418
757
|
newEndVnode = newCh[--newEndIdx];
|
|
419
758
|
}
|
|
420
759
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
760
|
+
// case: "Vnode moved right"
|
|
761
|
+
//
|
|
762
|
+
// We've found that the last node in our window on the new children is
|
|
763
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
764
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
765
|
+
// nodes:
|
|
766
|
+
//
|
|
767
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
768
|
+
// ^^^^^^^^^^^
|
|
769
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
770
|
+
// ^^^^^^^^^^^^^
|
|
771
|
+
//
|
|
772
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
773
|
+
// and move the DOM element for `oldStartVnode`.
|
|
774
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
775
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
776
|
+
}
|
|
421
777
|
patch(oldStartVnode, newEndVnode);
|
|
778
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
779
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
780
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
781
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
782
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
783
|
+
//
|
|
784
|
+
// <old-start-node />
|
|
785
|
+
// <some-intervening-node />
|
|
786
|
+
// <old-end-node />
|
|
787
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
788
|
+
// <next-sibling />
|
|
789
|
+
//
|
|
790
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
791
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
792
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
793
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
794
|
+
// append it to the children of the parent element.
|
|
422
795
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
423
796
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
424
797
|
newEndVnode = newCh[--newEndIdx];
|
|
425
798
|
}
|
|
426
799
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
800
|
+
// case: "Vnode moved left"
|
|
801
|
+
//
|
|
802
|
+
// We've found that the first node in our window on the new children is
|
|
803
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
804
|
+
// Visually, this is the layout of these two nodes:
|
|
805
|
+
//
|
|
806
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
807
|
+
// ^^^^^^^^^^^^^
|
|
808
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
809
|
+
// ^^^^^^^^^^^
|
|
810
|
+
//
|
|
811
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
812
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
813
|
+
// children etc) but we also need to move the DOM node to which
|
|
814
|
+
// `oldEndVnode` corresponds.
|
|
815
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
816
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
817
|
+
}
|
|
427
818
|
patch(oldEndVnode, newStartVnode);
|
|
819
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
820
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
821
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
822
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
823
|
+
// future.
|
|
428
824
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
429
825
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
430
826
|
newStartVnode = newCh[++newStartIdx];
|
|
431
827
|
}
|
|
432
828
|
else {
|
|
829
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
830
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
831
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
832
|
+
// component.
|
|
833
|
+
//
|
|
834
|
+
// First we check to see if there are any nodes in the array of old
|
|
835
|
+
// children which have the same key as the first node in the new
|
|
836
|
+
// children.
|
|
837
|
+
idxInOld = -1;
|
|
433
838
|
{
|
|
434
|
-
|
|
435
|
-
|
|
839
|
+
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
840
|
+
if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
|
841
|
+
idxInOld = i;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (idxInOld >= 0) {
|
|
847
|
+
// We found a node in the old children which matches up with the first
|
|
848
|
+
// node in the new children! So let's deal with that
|
|
849
|
+
elmToMove = oldCh[idxInOld];
|
|
850
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
851
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
852
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
patch(elmToMove, newStartVnode);
|
|
856
|
+
// invalidate the matching old node so that we won't try to update it
|
|
857
|
+
// again later on
|
|
858
|
+
oldCh[idxInOld] = undefined;
|
|
859
|
+
node = elmToMove.$elm$;
|
|
860
|
+
}
|
|
861
|
+
newStartVnode = newCh[++newStartIdx];
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
// We either didn't find an element in the old children that matches
|
|
865
|
+
// the key of the first new child OR the build is not using `key`
|
|
866
|
+
// attributes at all. In either case we need to create a new element
|
|
867
|
+
// for the new node.
|
|
868
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
436
869
|
newStartVnode = newCh[++newStartIdx];
|
|
437
870
|
}
|
|
438
871
|
if (node) {
|
|
872
|
+
// if we created a new node then handle inserting it to the DOM
|
|
439
873
|
{
|
|
440
|
-
oldStartVnode.$elm
|
|
874
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
441
875
|
}
|
|
442
876
|
}
|
|
443
877
|
}
|
|
444
878
|
}
|
|
445
879
|
if (oldStartIdx > oldEndIdx) {
|
|
880
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
446
881
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
447
882
|
}
|
|
448
883
|
else if (newStartIdx > newEndIdx) {
|
|
884
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
885
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
886
|
+
// relevant DOM nodes)
|
|
449
887
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
450
888
|
}
|
|
451
889
|
};
|
|
452
|
-
|
|
890
|
+
/**
|
|
891
|
+
* Compare two VNodes to determine if they are the same
|
|
892
|
+
*
|
|
893
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
894
|
+
* information set on the two VNodes and can be misleading under certain
|
|
895
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
896
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
897
|
+
* checking that they have the same tag.
|
|
898
|
+
*
|
|
899
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
900
|
+
* changing order within a `children` array or something along those lines then
|
|
901
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
902
|
+
*
|
|
903
|
+
* @param leftVNode the first VNode to check
|
|
904
|
+
* @param rightVNode the second VNode to check
|
|
905
|
+
* @returns whether they're equal or not
|
|
906
|
+
*/
|
|
907
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
453
908
|
// compare if two vnode to see if they're "technically" the same
|
|
454
909
|
// need to have the same element tag, and same key to be the same
|
|
455
|
-
if (
|
|
456
|
-
|
|
910
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
911
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
912
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
913
|
+
}
|
|
914
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
915
|
+
{
|
|
916
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
917
|
+
}
|
|
457
918
|
}
|
|
458
919
|
return false;
|
|
459
920
|
};
|
|
921
|
+
const referenceNode = (node) => {
|
|
922
|
+
// this node was relocated to a new location in the dom
|
|
923
|
+
// because of some other component's slot
|
|
924
|
+
// but we still have an html comment in place of where
|
|
925
|
+
// it's original location was according to it's original vdom
|
|
926
|
+
return (node && node['s-ol']) || node;
|
|
927
|
+
};
|
|
928
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
929
|
+
/**
|
|
930
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
931
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
932
|
+
* children of the two nodes (if any).
|
|
933
|
+
*
|
|
934
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
935
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
936
|
+
*/
|
|
460
937
|
const patch = (oldVNode, newVNode) => {
|
|
461
938
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
462
939
|
const oldChildren = oldVNode.$children$;
|
|
463
940
|
const newChildren = newVNode.$children$;
|
|
941
|
+
const tag = newVNode.$tag$;
|
|
464
942
|
const text = newVNode.$text$;
|
|
943
|
+
let defaultHolder;
|
|
465
944
|
if (text === null) {
|
|
466
|
-
// element node
|
|
467
945
|
{
|
|
468
|
-
|
|
946
|
+
if (tag === 'slot')
|
|
947
|
+
;
|
|
948
|
+
else {
|
|
469
949
|
// either this is the first render of an element OR it's an update
|
|
470
950
|
// AND we already know it's possible it could have changed
|
|
471
951
|
// this updates the element's css classes, attrs, props, listeners, etc.
|
|
@@ -474,6 +954,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
474
954
|
}
|
|
475
955
|
if (oldChildren !== null && newChildren !== null) {
|
|
476
956
|
// looks like there's child vnodes for both the old and new vnodes
|
|
957
|
+
// so we need to call `updateChildren` to reconcile them
|
|
477
958
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
478
959
|
}
|
|
479
960
|
else if (newChildren !== null) {
|
|
@@ -490,12 +971,147 @@ const patch = (oldVNode, newVNode) => {
|
|
|
490
971
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
491
972
|
}
|
|
492
973
|
}
|
|
974
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
975
|
+
// this element has slotted content
|
|
976
|
+
defaultHolder.parentNode.textContent = text;
|
|
977
|
+
}
|
|
493
978
|
else if (oldVNode.$text$ !== text) {
|
|
494
979
|
// update the text content for the text only vnode
|
|
495
980
|
// and also only if the text is different than before
|
|
496
981
|
elm.data = text;
|
|
497
982
|
}
|
|
498
983
|
};
|
|
984
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
985
|
+
// tslint:disable-next-line: prefer-const
|
|
986
|
+
const childNodes = elm.childNodes;
|
|
987
|
+
let childNode;
|
|
988
|
+
let i;
|
|
989
|
+
let ilen;
|
|
990
|
+
let j;
|
|
991
|
+
let slotNameAttr;
|
|
992
|
+
let nodeType;
|
|
993
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
994
|
+
childNode = childNodes[i];
|
|
995
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
996
|
+
if (childNode['s-sr']) {
|
|
997
|
+
// this is a slot fallback node
|
|
998
|
+
// get the slot name for this slot reference node
|
|
999
|
+
slotNameAttr = childNode['s-sn'];
|
|
1000
|
+
// by default always show a fallback slot node
|
|
1001
|
+
// then hide it if there are other slots in the light dom
|
|
1002
|
+
childNode.hidden = false;
|
|
1003
|
+
for (j = 0; j < ilen; j++) {
|
|
1004
|
+
nodeType = childNodes[j].nodeType;
|
|
1005
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
1006
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
1007
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1008
|
+
childNode.hidden = true;
|
|
1009
|
+
break;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
else {
|
|
1013
|
+
// this is a default fallback slot node
|
|
1014
|
+
// any element or text node (with content)
|
|
1015
|
+
// should hide the default fallback slot node
|
|
1016
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1017
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1018
|
+
childNode.hidden = true;
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
// keep drilling down
|
|
1025
|
+
updateFallbackSlotVisibility(childNode);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
};
|
|
1029
|
+
const relocateNodes = [];
|
|
1030
|
+
const relocateSlotContent = (elm) => {
|
|
1031
|
+
// tslint:disable-next-line: prefer-const
|
|
1032
|
+
let childNode;
|
|
1033
|
+
let node;
|
|
1034
|
+
let hostContentNodes;
|
|
1035
|
+
let slotNameAttr;
|
|
1036
|
+
let relocateNodeData;
|
|
1037
|
+
let j;
|
|
1038
|
+
let i = 0;
|
|
1039
|
+
const childNodes = elm.childNodes;
|
|
1040
|
+
const ilen = childNodes.length;
|
|
1041
|
+
for (; i < ilen; i++) {
|
|
1042
|
+
childNode = childNodes[i];
|
|
1043
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
1044
|
+
// first got the content reference comment node
|
|
1045
|
+
// then we got it's parent, which is where all the host content is in now
|
|
1046
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
1047
|
+
slotNameAttr = childNode['s-sn'];
|
|
1048
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
1049
|
+
node = hostContentNodes[j];
|
|
1050
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
1051
|
+
// let's do some relocating to its new home
|
|
1052
|
+
// but never relocate a content reference node
|
|
1053
|
+
// that is suppose to always represent the original content location
|
|
1054
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
1055
|
+
// it's possible we've already decided to relocate this node
|
|
1056
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1057
|
+
// made some changes to slots
|
|
1058
|
+
// let's make sure we also double check
|
|
1059
|
+
// fallbacks are correctly hidden or shown
|
|
1060
|
+
checkSlotFallbackVisibility = true;
|
|
1061
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
1062
|
+
if (relocateNodeData) {
|
|
1063
|
+
// previously we never found a slot home for this node
|
|
1064
|
+
// but turns out we did, so let's remember it now
|
|
1065
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
1066
|
+
}
|
|
1067
|
+
else {
|
|
1068
|
+
// add to our list of nodes to relocate
|
|
1069
|
+
relocateNodes.push({
|
|
1070
|
+
$slotRefNode$: childNode,
|
|
1071
|
+
$nodeToRelocate$: node,
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
if (node['s-sr']) {
|
|
1075
|
+
relocateNodes.map((relocateNode) => {
|
|
1076
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
1077
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1078
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
1079
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
1086
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
1087
|
+
// if we never find a home for this element then we'll need to hide it
|
|
1088
|
+
relocateNodes.push({
|
|
1089
|
+
$nodeToRelocate$: node,
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1096
|
+
relocateSlotContent(childNode);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
1101
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1102
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
1103
|
+
return true;
|
|
1104
|
+
}
|
|
1105
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
1106
|
+
return true;
|
|
1107
|
+
}
|
|
1108
|
+
return false;
|
|
1109
|
+
}
|
|
1110
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
1111
|
+
return true;
|
|
1112
|
+
}
|
|
1113
|
+
return slotNameAttr === '';
|
|
1114
|
+
};
|
|
499
1115
|
const callNodeRefs = (vNode) => {
|
|
500
1116
|
{
|
|
501
1117
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
@@ -504,44 +1120,105 @@ const callNodeRefs = (vNode) => {
|
|
|
504
1120
|
};
|
|
505
1121
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
506
1122
|
const hostElm = hostRef.$hostElement$;
|
|
1123
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
507
1124
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
508
1125
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
509
1126
|
hostTagName = hostElm.tagName;
|
|
1127
|
+
if (cmpMeta.$attrsToReflect$) {
|
|
1128
|
+
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
1129
|
+
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
1130
|
+
}
|
|
510
1131
|
rootVnode.$tag$ = null;
|
|
511
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1132
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
512
1133
|
hostRef.$vnode$ = rootVnode;
|
|
513
1134
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
514
1135
|
{
|
|
515
1136
|
scopeId = hostElm['s-sc'];
|
|
516
1137
|
}
|
|
1138
|
+
{
|
|
1139
|
+
contentRef = hostElm['s-cr'];
|
|
1140
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
1141
|
+
// always reset
|
|
1142
|
+
checkSlotFallbackVisibility = false;
|
|
1143
|
+
}
|
|
517
1144
|
// synchronous patch
|
|
518
1145
|
patch(oldVNode, rootVnode);
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
1146
|
+
{
|
|
1147
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
1148
|
+
// the disconnectCallback from working
|
|
1149
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1150
|
+
if (checkSlotRelocate) {
|
|
1151
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
1152
|
+
let relocateData;
|
|
1153
|
+
let nodeToRelocate;
|
|
1154
|
+
let orgLocationNode;
|
|
1155
|
+
let parentNodeRef;
|
|
1156
|
+
let insertBeforeNode;
|
|
1157
|
+
let refNode;
|
|
1158
|
+
let i = 0;
|
|
1159
|
+
for (; i < relocateNodes.length; i++) {
|
|
1160
|
+
relocateData = relocateNodes[i];
|
|
1161
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1162
|
+
if (!nodeToRelocate['s-ol']) {
|
|
1163
|
+
// add a reference node marking this node's original location
|
|
1164
|
+
// keep a reference to this node for later lookups
|
|
1165
|
+
orgLocationNode =
|
|
1166
|
+
doc.createTextNode('');
|
|
1167
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
1168
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1169
|
+
}
|
|
1170
|
+
}
|
|
1171
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
1172
|
+
relocateData = relocateNodes[i];
|
|
1173
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1174
|
+
if (relocateData.$slotRefNode$) {
|
|
1175
|
+
// by default we're just going to insert it directly
|
|
1176
|
+
// after the slot reference node
|
|
1177
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
1178
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
1179
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
1180
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
1181
|
+
refNode = orgLocationNode['s-nr'];
|
|
1182
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
1183
|
+
refNode = refNode.nextSibling;
|
|
1184
|
+
if (!refNode || !refNode['s-nr']) {
|
|
1185
|
+
insertBeforeNode = refNode;
|
|
1186
|
+
break;
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
1191
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
1192
|
+
// we've checked that it's worth while to relocate
|
|
1193
|
+
// since that the node to relocate
|
|
1194
|
+
// has a different next sibling or parent relocated
|
|
1195
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
1196
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1197
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
1198
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1199
|
+
}
|
|
1200
|
+
// add it back to the dom but in its new home
|
|
1201
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
else {
|
|
1206
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
1207
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1208
|
+
nodeToRelocate.hidden = true;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
if (checkSlotFallbackVisibility) {
|
|
1214
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1215
|
+
}
|
|
1216
|
+
// done moving nodes around
|
|
1217
|
+
// allow the disconnect callback to work again
|
|
1218
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1219
|
+
// always reset
|
|
1220
|
+
relocateNodes.length = 0;
|
|
1221
|
+
}
|
|
545
1222
|
};
|
|
546
1223
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
547
1224
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -550,10 +1227,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
550
1227
|
};
|
|
551
1228
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
552
1229
|
{
|
|
553
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1230
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
554
1231
|
}
|
|
555
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
556
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1232
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1233
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
557
1234
|
return;
|
|
558
1235
|
}
|
|
559
1236
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -568,10 +1245,20 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
568
1245
|
const instance = hostRef.$lazyInstance$ ;
|
|
569
1246
|
let promise;
|
|
570
1247
|
if (isInitialLoad) {
|
|
1248
|
+
{
|
|
1249
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1250
|
+
if (hostRef.$queuedListeners$) {
|
|
1251
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1252
|
+
hostRef.$queuedListeners$ = null;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
571
1255
|
{
|
|
572
1256
|
promise = safeCall(instance, 'componentWillLoad');
|
|
573
1257
|
}
|
|
574
1258
|
}
|
|
1259
|
+
{
|
|
1260
|
+
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
1261
|
+
}
|
|
575
1262
|
endSchedule();
|
|
576
1263
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
577
1264
|
};
|
|
@@ -605,7 +1292,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
605
1292
|
}
|
|
606
1293
|
else {
|
|
607
1294
|
Promise.all(childrenPromises).then(postUpdate);
|
|
608
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1295
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
609
1296
|
childrenPromises.length = 0;
|
|
610
1297
|
}
|
|
611
1298
|
}
|
|
@@ -614,10 +1301,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
614
1301
|
try {
|
|
615
1302
|
instance = instance.render() ;
|
|
616
1303
|
{
|
|
617
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1304
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
618
1305
|
}
|
|
619
1306
|
{
|
|
620
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1307
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
621
1308
|
}
|
|
622
1309
|
{
|
|
623
1310
|
{
|
|
@@ -641,8 +1328,11 @@ const postUpdateComponent = (hostRef) => {
|
|
|
641
1328
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
642
1329
|
const instance = hostRef.$lazyInstance$ ;
|
|
643
1330
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
644
|
-
|
|
645
|
-
|
|
1331
|
+
{
|
|
1332
|
+
safeCall(instance, 'componentDidRender');
|
|
1333
|
+
}
|
|
1334
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1335
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
646
1336
|
{
|
|
647
1337
|
// DOM WRITE!
|
|
648
1338
|
addHydratedFlag(elm);
|
|
@@ -671,10 +1361,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
671
1361
|
hostRef.$onRenderResolve$();
|
|
672
1362
|
hostRef.$onRenderResolve$ = undefined;
|
|
673
1363
|
}
|
|
674
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1364
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
675
1365
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
676
1366
|
}
|
|
677
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1367
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
678
1368
|
}
|
|
679
1369
|
// ( •_•)
|
|
680
1370
|
// ( •_•)>⌐■-■
|
|
@@ -704,44 +1394,6 @@ const then = (promise, thenFn) => {
|
|
|
704
1394
|
};
|
|
705
1395
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
706
1396
|
;
|
|
707
|
-
/**
|
|
708
|
-
* Parse a new property value for a given property type.
|
|
709
|
-
*
|
|
710
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
711
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
712
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
713
|
-
* 2. the type stored from `propType`.
|
|
714
|
-
*
|
|
715
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
716
|
-
*
|
|
717
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
718
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
719
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
720
|
-
* ```tsx
|
|
721
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
722
|
-
* ```
|
|
723
|
-
*
|
|
724
|
-
* HTML prop values on the other hand, will always a string
|
|
725
|
-
*
|
|
726
|
-
* @param propValue the new value to coerce to some type
|
|
727
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
728
|
-
* @returns the parsed/coerced value
|
|
729
|
-
*/
|
|
730
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
731
|
-
// ensure this value is of the correct prop type
|
|
732
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
733
|
-
if (propType & 1 /* String */) {
|
|
734
|
-
// could have been passed as a number or boolean
|
|
735
|
-
// but we still want it as a string
|
|
736
|
-
return String(propValue);
|
|
737
|
-
}
|
|
738
|
-
// redundant return here for better minification
|
|
739
|
-
return propValue;
|
|
740
|
-
}
|
|
741
|
-
// not sure exactly what type we want
|
|
742
|
-
// so no need to change to a different type
|
|
743
|
-
return propValue;
|
|
744
|
-
};
|
|
745
1397
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
746
1398
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
747
1399
|
// check our new property value against our internal value
|
|
@@ -754,13 +1406,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
754
1406
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
755
1407
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
756
1408
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
757
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1409
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
758
1410
|
// gadzooks! the property's value has changed!!
|
|
759
1411
|
// set our new value!
|
|
760
1412
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
761
1413
|
if (instance) {
|
|
762
1414
|
// get an array of method names of watch functions to call
|
|
763
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1415
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
764
1416
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
765
1417
|
if (watchMethods) {
|
|
766
1418
|
// this instance is watching for when this property changed
|
|
@@ -775,7 +1427,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
775
1427
|
});
|
|
776
1428
|
}
|
|
777
1429
|
}
|
|
778
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1430
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
779
1431
|
// looks like this value actually changed, so we've got work to do!
|
|
780
1432
|
// but only if we've already rendered, otherwise just chill out
|
|
781
1433
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -785,6 +1437,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
785
1437
|
}
|
|
786
1438
|
}
|
|
787
1439
|
};
|
|
1440
|
+
/**
|
|
1441
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1442
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1443
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1444
|
+
*
|
|
1445
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1446
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1447
|
+
* @param flags a number used to store a series of bit flags
|
|
1448
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1449
|
+
*/
|
|
788
1450
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
789
1451
|
if (cmpMeta.$members$) {
|
|
790
1452
|
if (Cstr.watchers) {
|
|
@@ -794,8 +1456,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
794
1456
|
const members = Object.entries(cmpMeta.$members$);
|
|
795
1457
|
const prototype = Cstr.prototype;
|
|
796
1458
|
members.map(([memberName, [memberFlags]]) => {
|
|
797
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
798
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1459
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1460
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
799
1461
|
// proxyComponent - prop
|
|
800
1462
|
Object.defineProperty(prototype, memberName, {
|
|
801
1463
|
get() {
|
|
@@ -810,8 +1472,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
810
1472
|
enumerable: true,
|
|
811
1473
|
});
|
|
812
1474
|
}
|
|
813
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
814
|
-
memberFlags & 64 /* Method */) {
|
|
1475
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1476
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
815
1477
|
// proxyComponent - method
|
|
816
1478
|
Object.defineProperty(prototype, memberName, {
|
|
817
1479
|
value(...args) {
|
|
@@ -821,7 +1483,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
821
1483
|
});
|
|
822
1484
|
}
|
|
823
1485
|
});
|
|
824
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1486
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
825
1487
|
const attrNameToPropName = new Map();
|
|
826
1488
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
827
1489
|
plt.jmp(() => {
|
|
@@ -877,10 +1539,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
877
1539
|
// create an array of attributes to observe
|
|
878
1540
|
// and also create a map of html attribute name to js property name
|
|
879
1541
|
Cstr.observedAttributes = members
|
|
880
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1542
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
881
1543
|
.map(([propName, m]) => {
|
|
882
1544
|
const attrName = m[1] || propName;
|
|
883
1545
|
attrNameToPropName.set(attrName, propName);
|
|
1546
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1547
|
+
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1548
|
+
}
|
|
884
1549
|
return attrName;
|
|
885
1550
|
});
|
|
886
1551
|
}
|
|
@@ -889,10 +1554,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
889
1554
|
};
|
|
890
1555
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
891
1556
|
// initializeComponent
|
|
892
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1557
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
893
1558
|
{
|
|
894
1559
|
// we haven't initialized this element yet
|
|
895
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1560
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
896
1561
|
// lazy loaded components
|
|
897
1562
|
// request the component's implementation to be
|
|
898
1563
|
// wired up with the host element
|
|
@@ -910,7 +1575,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
910
1575
|
{
|
|
911
1576
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
912
1577
|
}
|
|
913
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1578
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
914
1579
|
Cstr.isProxied = true;
|
|
915
1580
|
}
|
|
916
1581
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -918,7 +1583,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
918
1583
|
// but let's keep track of when we start and stop
|
|
919
1584
|
// so that the getters/setters don't incorrectly step on data
|
|
920
1585
|
{
|
|
921
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1586
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
922
1587
|
}
|
|
923
1588
|
// construct the lazy-loaded component implementation
|
|
924
1589
|
// passing the hostRef is very important during
|
|
@@ -931,10 +1596,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
931
1596
|
consoleError(e);
|
|
932
1597
|
}
|
|
933
1598
|
{
|
|
934
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1599
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
935
1600
|
}
|
|
936
1601
|
{
|
|
937
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1602
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
938
1603
|
}
|
|
939
1604
|
endNewInstance();
|
|
940
1605
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -945,7 +1610,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
945
1610
|
const scopeId = getScopeId(cmpMeta);
|
|
946
1611
|
if (!styles.has(scopeId)) {
|
|
947
1612
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
948
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1613
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
949
1614
|
endRegisterStyles();
|
|
950
1615
|
}
|
|
951
1616
|
}
|
|
@@ -972,13 +1637,22 @@ const fireConnectedCallback = (instance) => {
|
|
|
972
1637
|
}
|
|
973
1638
|
};
|
|
974
1639
|
const connectedCallback = (elm) => {
|
|
975
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1640
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
976
1641
|
const hostRef = getHostRef(elm);
|
|
977
1642
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
978
1643
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
979
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1644
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
980
1645
|
// first time this component has connected
|
|
981
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1646
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1647
|
+
{
|
|
1648
|
+
// initUpdate
|
|
1649
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1650
|
+
// in here to act as original content anchors as we move nodes around
|
|
1651
|
+
// host element has been connected to the DOM
|
|
1652
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1653
|
+
setContentReference(elm);
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
982
1656
|
{
|
|
983
1657
|
// find the first ancestor component (if there is one) and register
|
|
984
1658
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -998,7 +1672,7 @@ const connectedCallback = (elm) => {
|
|
|
998
1672
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
999
1673
|
if (cmpMeta.$members$) {
|
|
1000
1674
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1001
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1675
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1002
1676
|
const value = elm[memberName];
|
|
1003
1677
|
delete elm[memberName];
|
|
1004
1678
|
elm[memberName] = value;
|
|
@@ -1010,16 +1684,37 @@ const connectedCallback = (elm) => {
|
|
|
1010
1684
|
}
|
|
1011
1685
|
}
|
|
1012
1686
|
else {
|
|
1687
|
+
// not the first time this has connected
|
|
1688
|
+
// reattach any event listeners to the host
|
|
1689
|
+
// since they would have been removed when disconnected
|
|
1690
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1013
1691
|
// fire off connectedCallback() on component instance
|
|
1014
1692
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
1015
1693
|
}
|
|
1016
1694
|
endConnected();
|
|
1017
1695
|
}
|
|
1018
1696
|
};
|
|
1697
|
+
const setContentReference = (elm) => {
|
|
1698
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1699
|
+
// or this browser doesn't support native shadow dom
|
|
1700
|
+
// and this host element was NOT created with SSR
|
|
1701
|
+
// let's pick out the inner content for slot projection
|
|
1702
|
+
// create a node to represent where the original
|
|
1703
|
+
// content was first placed, which is useful later on
|
|
1704
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1705
|
+
contentRefElm['s-cn'] = true;
|
|
1706
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1707
|
+
};
|
|
1019
1708
|
const disconnectedCallback = (elm) => {
|
|
1020
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1709
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1021
1710
|
const hostRef = getHostRef(elm);
|
|
1022
1711
|
const instance = hostRef.$lazyInstance$ ;
|
|
1712
|
+
{
|
|
1713
|
+
if (hostRef.$rmListeners$) {
|
|
1714
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1715
|
+
hostRef.$rmListeners$ = undefined;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1023
1718
|
{
|
|
1024
1719
|
safeCall(instance, 'disconnectedCallback');
|
|
1025
1720
|
}
|
|
@@ -1049,6 +1744,12 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1049
1744
|
{
|
|
1050
1745
|
cmpMeta.$members$ = compactMeta[2];
|
|
1051
1746
|
}
|
|
1747
|
+
{
|
|
1748
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1749
|
+
}
|
|
1750
|
+
{
|
|
1751
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
1752
|
+
}
|
|
1052
1753
|
{
|
|
1053
1754
|
cmpMeta.$watchers$ = {};
|
|
1054
1755
|
}
|
|
@@ -1060,7 +1761,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1060
1761
|
super(self);
|
|
1061
1762
|
self = this;
|
|
1062
1763
|
registerHost(self, cmpMeta);
|
|
1063
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1764
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1064
1765
|
// this component is using shadow dom
|
|
1065
1766
|
// and this browser supports shadow dom
|
|
1066
1767
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1095,7 +1796,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1095
1796
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1096
1797
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1097
1798
|
cmpTags.push(tagName);
|
|
1098
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1799
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1099
1800
|
}
|
|
1100
1801
|
});
|
|
1101
1802
|
});
|
|
@@ -1117,7 +1818,37 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1117
1818
|
// Fallback appLoad event
|
|
1118
1819
|
endBootstrap();
|
|
1119
1820
|
};
|
|
1120
|
-
const
|
|
1821
|
+
const Fragment = (_, children) => children;
|
|
1822
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1823
|
+
if (listeners) {
|
|
1824
|
+
listeners.map(([flags, name, method]) => {
|
|
1825
|
+
const target = elm;
|
|
1826
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1827
|
+
const opts = hostListenerOpts(flags);
|
|
1828
|
+
plt.ael(target, name, handler, opts);
|
|
1829
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
};
|
|
1833
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1834
|
+
try {
|
|
1835
|
+
{
|
|
1836
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1837
|
+
// instance is ready, let's call it's member method for this event
|
|
1838
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1839
|
+
}
|
|
1840
|
+
else {
|
|
1841
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
catch (e) {
|
|
1846
|
+
consoleError(e);
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
// prettier-ignore
|
|
1850
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1851
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1121
1852
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1122
1853
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1123
1854
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1135,6 +1866,7 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1135
1866
|
elm['s-p'] = [];
|
|
1136
1867
|
elm['s-rc'] = [];
|
|
1137
1868
|
}
|
|
1869
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1138
1870
|
return hostRefs.set(elm, hostRef);
|
|
1139
1871
|
};
|
|
1140
1872
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
@@ -1161,14 +1893,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1161
1893
|
return importedModule[exportName];
|
|
1162
1894
|
}, consoleError);
|
|
1163
1895
|
};
|
|
1164
|
-
const styles = new Map();
|
|
1896
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1897
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1898
|
+
const doc = win.document || { head: {} };
|
|
1899
|
+
const plt = {
|
|
1900
|
+
$flags$: 0,
|
|
1901
|
+
$resourcesUrl$: '',
|
|
1902
|
+
jmp: (h) => h(),
|
|
1903
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1904
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1905
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1906
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1907
|
+
};
|
|
1908
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1909
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1910
|
+
try {
|
|
1911
|
+
new CSSStyleSheet();
|
|
1912
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1913
|
+
}
|
|
1914
|
+
catch (e) { }
|
|
1915
|
+
return false;
|
|
1916
|
+
})()
|
|
1917
|
+
;
|
|
1165
1918
|
const queueDomReads = [];
|
|
1166
1919
|
const queueDomWrites = [];
|
|
1167
1920
|
const queueTask = (queue, write) => (cb) => {
|
|
1168
1921
|
queue.push(cb);
|
|
1169
1922
|
if (!queuePending) {
|
|
1170
1923
|
queuePending = true;
|
|
1171
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1924
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1172
1925
|
nextTick(flush);
|
|
1173
1926
|
}
|
|
1174
1927
|
else {
|
|
@@ -1205,4 +1958,4 @@ const flush = () => {
|
|
|
1205
1958
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1206
1959
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1207
1960
|
|
|
1208
|
-
export { Host as H, bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };
|
|
1961
|
+
export { Fragment as F, Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r };
|