@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
|
@@ -22,32 +22,22 @@ function _interopNamespace(e) {
|
|
|
22
22
|
|
|
23
23
|
const NAMESPACE = 'sankhyablocks';
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
27
|
+
* Simon Friis Vindum (@paldepind)
|
|
28
|
+
* Licensed under the MIT License
|
|
29
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
30
|
+
*
|
|
31
|
+
* Modified for Stencil's renderer and slot projection
|
|
32
|
+
*/
|
|
25
33
|
let scopeId;
|
|
34
|
+
let contentRef;
|
|
26
35
|
let hostTagName;
|
|
36
|
+
let useNativeShadowDom = false;
|
|
37
|
+
let checkSlotFallbackVisibility = false;
|
|
38
|
+
let checkSlotRelocate = false;
|
|
27
39
|
let isSvgMode = false;
|
|
28
40
|
let queuePending = false;
|
|
29
|
-
const win = typeof window !== 'undefined' ? window : {};
|
|
30
|
-
const doc = win.document || { head: {} };
|
|
31
|
-
const plt = {
|
|
32
|
-
$flags$: 0,
|
|
33
|
-
$resourcesUrl$: '',
|
|
34
|
-
jmp: (h) => h(),
|
|
35
|
-
raf: (h) => requestAnimationFrame(h),
|
|
36
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
37
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
38
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
39
|
-
};
|
|
40
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
41
|
-
const supportsConstructibleStylesheets = /*@__PURE__*/ (() => {
|
|
42
|
-
try {
|
|
43
|
-
new CSSStyleSheet();
|
|
44
|
-
return typeof new CSSStyleSheet().replace === 'function';
|
|
45
|
-
}
|
|
46
|
-
catch (e) { }
|
|
47
|
-
return false;
|
|
48
|
-
})()
|
|
49
|
-
;
|
|
50
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
51
41
|
const createTime = (fnName, tagName = '') => {
|
|
52
42
|
{
|
|
53
43
|
return () => {
|
|
@@ -62,74 +52,8 @@ const uniqueTime = (key, measureText) => {
|
|
|
62
52
|
};
|
|
63
53
|
}
|
|
64
54
|
};
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
let style = styles.get(scopeId);
|
|
68
|
-
if (supportsConstructibleStylesheets && allowCS) {
|
|
69
|
-
style = (style || new CSSStyleSheet());
|
|
70
|
-
style.replace(cssText);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
style = cssText;
|
|
74
|
-
}
|
|
75
|
-
styles.set(scopeId, style);
|
|
76
|
-
};
|
|
77
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
78
|
-
let scopeId = getScopeId(cmpMeta);
|
|
79
|
-
const style = styles.get(scopeId);
|
|
80
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
81
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
82
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
83
|
-
if (style) {
|
|
84
|
-
if (typeof style === 'string') {
|
|
85
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
86
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
87
|
-
let styleElm;
|
|
88
|
-
if (!appliedStyles) {
|
|
89
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
90
|
-
}
|
|
91
|
-
if (!appliedStyles.has(scopeId)) {
|
|
92
|
-
{
|
|
93
|
-
{
|
|
94
|
-
styleElm = doc.createElement('style');
|
|
95
|
-
styleElm.innerHTML = style;
|
|
96
|
-
}
|
|
97
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
98
|
-
}
|
|
99
|
-
if (appliedStyles) {
|
|
100
|
-
appliedStyles.add(scopeId);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
105
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return scopeId;
|
|
109
|
-
};
|
|
110
|
-
const attachStyles = (hostRef) => {
|
|
111
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
112
|
-
const elm = hostRef.$hostElement$;
|
|
113
|
-
const flags = cmpMeta.$flags$;
|
|
114
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
115
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
116
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
117
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
118
|
-
// or this browser doesn't support native shadow dom
|
|
119
|
-
// and this host element was NOT created with SSR
|
|
120
|
-
// let's pick out the inner content for slot projection
|
|
121
|
-
// create a node to represent where the original
|
|
122
|
-
// content was first placed, which is useful later on
|
|
123
|
-
// DOM WRITE!!
|
|
124
|
-
elm['s-sc'] = scopeId;
|
|
125
|
-
elm.classList.add(scopeId + '-h');
|
|
126
|
-
if (flags & 2 /* scopedCssEncapsulation */) {
|
|
127
|
-
elm.classList.add(scopeId + '-s');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
endAttachStyles();
|
|
131
|
-
};
|
|
132
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
55
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
56
|
+
const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
|
133
57
|
/**
|
|
134
58
|
* Default style mode id
|
|
135
59
|
*/
|
|
@@ -157,6 +81,8 @@ const isComplexType = (o) => {
|
|
|
157
81
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
158
82
|
const h = (nodeName, vnodeData, ...children) => {
|
|
159
83
|
let child = null;
|
|
84
|
+
let key = null;
|
|
85
|
+
let slotName = null;
|
|
160
86
|
let simple = false;
|
|
161
87
|
let lastSimple = false;
|
|
162
88
|
const vNodeChildren = [];
|
|
@@ -184,6 +110,13 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
184
110
|
};
|
|
185
111
|
walk(children);
|
|
186
112
|
if (vnodeData) {
|
|
113
|
+
// normalize class / classname attributes
|
|
114
|
+
if (vnodeData.key) {
|
|
115
|
+
key = vnodeData.key;
|
|
116
|
+
}
|
|
117
|
+
if (vnodeData.name) {
|
|
118
|
+
slotName = vnodeData.name;
|
|
119
|
+
}
|
|
187
120
|
{
|
|
188
121
|
const classData = vnodeData.className || vnodeData.class;
|
|
189
122
|
if (classData) {
|
|
@@ -196,11 +129,21 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
196
129
|
}
|
|
197
130
|
}
|
|
198
131
|
}
|
|
132
|
+
if (typeof nodeName === 'function') {
|
|
133
|
+
// nodeName is a functional component
|
|
134
|
+
return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
135
|
+
}
|
|
199
136
|
const vnode = newVNode(nodeName, null);
|
|
200
137
|
vnode.$attrs$ = vnodeData;
|
|
201
138
|
if (vNodeChildren.length > 0) {
|
|
202
139
|
vnode.$children$ = vNodeChildren;
|
|
203
140
|
}
|
|
141
|
+
{
|
|
142
|
+
vnode.$key$ = key;
|
|
143
|
+
}
|
|
144
|
+
{
|
|
145
|
+
vnode.$name$ = slotName;
|
|
146
|
+
}
|
|
204
147
|
return vnode;
|
|
205
148
|
};
|
|
206
149
|
const newVNode = (tag, text) => {
|
|
@@ -214,10 +157,192 @@ const newVNode = (tag, text) => {
|
|
|
214
157
|
{
|
|
215
158
|
vnode.$attrs$ = null;
|
|
216
159
|
}
|
|
160
|
+
{
|
|
161
|
+
vnode.$key$ = null;
|
|
162
|
+
}
|
|
163
|
+
{
|
|
164
|
+
vnode.$name$ = null;
|
|
165
|
+
}
|
|
217
166
|
return vnode;
|
|
218
167
|
};
|
|
219
168
|
const Host = {};
|
|
220
169
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
170
|
+
const vdomFnUtils = {
|
|
171
|
+
forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
|
|
172
|
+
map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
|
|
173
|
+
};
|
|
174
|
+
const convertToPublic = (node) => ({
|
|
175
|
+
vattrs: node.$attrs$,
|
|
176
|
+
vchildren: node.$children$,
|
|
177
|
+
vkey: node.$key$,
|
|
178
|
+
vname: node.$name$,
|
|
179
|
+
vtag: node.$tag$,
|
|
180
|
+
vtext: node.$text$,
|
|
181
|
+
});
|
|
182
|
+
const convertToPrivate = (node) => {
|
|
183
|
+
if (typeof node.vtag === 'function') {
|
|
184
|
+
const vnodeData = Object.assign({}, node.vattrs);
|
|
185
|
+
if (node.vkey) {
|
|
186
|
+
vnodeData.key = node.vkey;
|
|
187
|
+
}
|
|
188
|
+
if (node.vname) {
|
|
189
|
+
vnodeData.name = node.vname;
|
|
190
|
+
}
|
|
191
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
192
|
+
}
|
|
193
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
194
|
+
vnode.$attrs$ = node.vattrs;
|
|
195
|
+
vnode.$children$ = node.vchildren;
|
|
196
|
+
vnode.$key$ = node.vkey;
|
|
197
|
+
vnode.$name$ = node.vname;
|
|
198
|
+
return vnode;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Parse a new property value for a given property type.
|
|
202
|
+
*
|
|
203
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
204
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
205
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
206
|
+
* 2. the type stored from `propType`.
|
|
207
|
+
*
|
|
208
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
209
|
+
*
|
|
210
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
211
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
212
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
213
|
+
* ```tsx
|
|
214
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
215
|
+
* ```
|
|
216
|
+
*
|
|
217
|
+
* HTML prop values on the other hand, will always a string
|
|
218
|
+
*
|
|
219
|
+
* @param propValue the new value to coerce to some type
|
|
220
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
221
|
+
* @returns the parsed/coerced value
|
|
222
|
+
*/
|
|
223
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
224
|
+
// ensure this value is of the correct prop type
|
|
225
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
226
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
227
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
228
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
229
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
230
|
+
}
|
|
231
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
232
|
+
// force it to be a number
|
|
233
|
+
return parseFloat(propValue);
|
|
234
|
+
}
|
|
235
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
236
|
+
// could have been passed as a number or boolean
|
|
237
|
+
// but we still want it as a string
|
|
238
|
+
return String(propValue);
|
|
239
|
+
}
|
|
240
|
+
// redundant return here for better minification
|
|
241
|
+
return propValue;
|
|
242
|
+
}
|
|
243
|
+
// not sure exactly what type we want
|
|
244
|
+
// so no need to change to a different type
|
|
245
|
+
return propValue;
|
|
246
|
+
};
|
|
247
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
248
|
+
const createEvent = (ref, name, flags) => {
|
|
249
|
+
const elm = getElement(ref);
|
|
250
|
+
return {
|
|
251
|
+
emit: (detail) => {
|
|
252
|
+
return emitEvent(elm, name, {
|
|
253
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
254
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
255
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
256
|
+
detail,
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
263
|
+
* @param elm the target of the Event
|
|
264
|
+
* @param name the name to give the custom Event
|
|
265
|
+
* @param opts options for configuring a custom Event
|
|
266
|
+
* @returns the custom Event
|
|
267
|
+
*/
|
|
268
|
+
const emitEvent = (elm, name, opts) => {
|
|
269
|
+
const ev = plt.ce(name, opts);
|
|
270
|
+
elm.dispatchEvent(ev);
|
|
271
|
+
return ev;
|
|
272
|
+
};
|
|
273
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
274
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
275
|
+
let style = styles.get(scopeId);
|
|
276
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
277
|
+
style = (style || new CSSStyleSheet());
|
|
278
|
+
if (typeof style === 'string') {
|
|
279
|
+
style = cssText;
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
style.replaceSync(cssText);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
style = cssText;
|
|
287
|
+
}
|
|
288
|
+
styles.set(scopeId, style);
|
|
289
|
+
};
|
|
290
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
291
|
+
let scopeId = getScopeId(cmpMeta);
|
|
292
|
+
const style = styles.get(scopeId);
|
|
293
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
294
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
295
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
296
|
+
if (style) {
|
|
297
|
+
if (typeof style === 'string') {
|
|
298
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
299
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
300
|
+
let styleElm;
|
|
301
|
+
if (!appliedStyles) {
|
|
302
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
303
|
+
}
|
|
304
|
+
if (!appliedStyles.has(scopeId)) {
|
|
305
|
+
{
|
|
306
|
+
{
|
|
307
|
+
styleElm = doc.createElement('style');
|
|
308
|
+
styleElm.innerHTML = style;
|
|
309
|
+
}
|
|
310
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
311
|
+
}
|
|
312
|
+
if (appliedStyles) {
|
|
313
|
+
appliedStyles.add(scopeId);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
318
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return scopeId;
|
|
322
|
+
};
|
|
323
|
+
const attachStyles = (hostRef) => {
|
|
324
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
325
|
+
const elm = hostRef.$hostElement$;
|
|
326
|
+
const flags = cmpMeta.$flags$;
|
|
327
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
328
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
329
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
330
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
331
|
+
// or this browser doesn't support native shadow dom
|
|
332
|
+
// and this host element was NOT created with SSR
|
|
333
|
+
// let's pick out the inner content for slot projection
|
|
334
|
+
// create a node to represent where the original
|
|
335
|
+
// content was first placed, which is useful later on
|
|
336
|
+
// DOM WRITE!!
|
|
337
|
+
elm['s-sc'] = scopeId;
|
|
338
|
+
elm.classList.add(scopeId + '-h');
|
|
339
|
+
if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
|
|
340
|
+
elm.classList.add(scopeId + '-s');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
endAttachStyles();
|
|
344
|
+
};
|
|
345
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
221
346
|
/**
|
|
222
347
|
* Production setAccessor() function based on Preact by
|
|
223
348
|
* Jason Miller (@developit)
|
|
@@ -237,6 +362,33 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
237
362
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
238
363
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
239
364
|
}
|
|
365
|
+
else if (memberName === 'style') {
|
|
366
|
+
// update style attribute, css properties and values
|
|
367
|
+
{
|
|
368
|
+
for (const prop in oldValue) {
|
|
369
|
+
if (!newValue || newValue[prop] == null) {
|
|
370
|
+
if (prop.includes('-')) {
|
|
371
|
+
elm.style.removeProperty(prop);
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
elm.style[prop] = '';
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
for (const prop in newValue) {
|
|
380
|
+
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
381
|
+
if (prop.includes('-')) {
|
|
382
|
+
elm.style.setProperty(prop, newValue[prop]);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
elm.style[prop] = newValue[prop];
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else if (memberName === 'key')
|
|
391
|
+
;
|
|
240
392
|
else if (memberName === 'ref') {
|
|
241
393
|
// minifier will clean this up
|
|
242
394
|
if (newValue) {
|
|
@@ -303,16 +455,36 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
303
455
|
}
|
|
304
456
|
catch (e) { }
|
|
305
457
|
}
|
|
458
|
+
/**
|
|
459
|
+
* Need to manually update attribute if:
|
|
460
|
+
* - memberName is not an attribute
|
|
461
|
+
* - if we are rendering the host element in order to reflect attribute
|
|
462
|
+
* - if it's a SVG, since properties might not work in <svg>
|
|
463
|
+
* - if the newValue is null/undefined or 'false'.
|
|
464
|
+
*/
|
|
465
|
+
let xlink = false;
|
|
466
|
+
{
|
|
467
|
+
if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
|
|
468
|
+
memberName = ln;
|
|
469
|
+
xlink = true;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
306
472
|
if (newValue == null || newValue === false) {
|
|
307
473
|
if (newValue !== false || elm.getAttribute(memberName) === '') {
|
|
308
|
-
{
|
|
474
|
+
if (xlink) {
|
|
475
|
+
elm.removeAttributeNS(XLINK_NS, memberName);
|
|
476
|
+
}
|
|
477
|
+
else {
|
|
309
478
|
elm.removeAttribute(memberName);
|
|
310
479
|
}
|
|
311
480
|
}
|
|
312
481
|
}
|
|
313
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
482
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
314
483
|
newValue = newValue === true ? '' : newValue;
|
|
315
|
-
{
|
|
484
|
+
if (xlink) {
|
|
485
|
+
elm.setAttributeNS(XLINK_NS, memberName, newValue);
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
316
488
|
elm.setAttribute(memberName, newValue);
|
|
317
489
|
}
|
|
318
490
|
}
|
|
@@ -325,7 +497,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
325
497
|
// if the element passed in is a shadow root, which is a document fragment
|
|
326
498
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
327
499
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
328
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
500
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
329
501
|
? newVnode.$elm$.host
|
|
330
502
|
: newVnode.$elm$;
|
|
331
503
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -343,19 +515,52 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
343
515
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
344
516
|
}
|
|
345
517
|
};
|
|
518
|
+
/**
|
|
519
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
520
|
+
*
|
|
521
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
522
|
+
* @param newParentVNode the parent VNode from the current render
|
|
523
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
524
|
+
* children, for which we will create a new DOM node
|
|
525
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
526
|
+
* @returns the newly created node
|
|
527
|
+
*/
|
|
346
528
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
347
529
|
// tslint:disable-next-line: prefer-const
|
|
348
530
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
349
531
|
let i = 0;
|
|
350
532
|
let elm;
|
|
351
533
|
let childNode;
|
|
534
|
+
let oldVNode;
|
|
535
|
+
if (!useNativeShadowDom) {
|
|
536
|
+
// remember for later we need to check to relocate nodes
|
|
537
|
+
checkSlotRelocate = true;
|
|
538
|
+
if (newVNode.$tag$ === 'slot') {
|
|
539
|
+
if (scopeId) {
|
|
540
|
+
// scoped css needs to add its scoped id to the parent element
|
|
541
|
+
parentElm.classList.add(scopeId + '-s');
|
|
542
|
+
}
|
|
543
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
544
|
+
? // slot element has fallback content
|
|
545
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
546
|
+
: // slot element does not have fallback content
|
|
547
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
352
550
|
if (newVNode.$text$ !== null) {
|
|
353
551
|
// create text node
|
|
354
552
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
355
553
|
}
|
|
554
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
555
|
+
// create a slot reference node
|
|
556
|
+
elm = newVNode.$elm$ =
|
|
557
|
+
doc.createTextNode('');
|
|
558
|
+
}
|
|
356
559
|
else {
|
|
357
560
|
// create element
|
|
358
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
561
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
562
|
+
? 'slot-fb'
|
|
563
|
+
: newVNode.$tag$));
|
|
359
564
|
// add css classes, attrs, props, listeners, etc.
|
|
360
565
|
{
|
|
361
566
|
updateElement(null, newVNode, isSvgMode);
|
|
@@ -368,7 +573,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
368
573
|
if (newVNode.$children$) {
|
|
369
574
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
370
575
|
// create the node
|
|
371
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
576
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
372
577
|
// return node could have been null
|
|
373
578
|
if (childNode) {
|
|
374
579
|
// append our new node
|
|
@@ -377,20 +582,62 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
377
582
|
}
|
|
378
583
|
}
|
|
379
584
|
}
|
|
585
|
+
{
|
|
586
|
+
elm['s-hn'] = hostTagName;
|
|
587
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
588
|
+
// remember the content reference comment
|
|
589
|
+
elm['s-sr'] = true;
|
|
590
|
+
// remember the content reference comment
|
|
591
|
+
elm['s-cr'] = contentRef;
|
|
592
|
+
// remember the slot name, or empty string for default slot
|
|
593
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
594
|
+
// check if we've got an old vnode for this slot
|
|
595
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
596
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
597
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
598
|
+
// so let's move the old slot content back to it's original location
|
|
599
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
380
603
|
return elm;
|
|
381
604
|
};
|
|
605
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
606
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
607
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
608
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
609
|
+
const childNode = oldSlotChildNodes[i];
|
|
610
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
611
|
+
// // this child node in the old element is from another component
|
|
612
|
+
// // remove this node from the old slot's parent
|
|
613
|
+
// childNode.remove();
|
|
614
|
+
// and relocate it back to it's original location
|
|
615
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
616
|
+
// remove the old original location comment entirely
|
|
617
|
+
// later on the patch function will know what to do
|
|
618
|
+
// and move this to the correct spot in need be
|
|
619
|
+
childNode['s-ol'].remove();
|
|
620
|
+
childNode['s-ol'] = undefined;
|
|
621
|
+
checkSlotRelocate = true;
|
|
622
|
+
}
|
|
623
|
+
if (recursive) {
|
|
624
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
628
|
+
};
|
|
382
629
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
383
|
-
let containerElm = (parentElm);
|
|
630
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
384
631
|
let childNode;
|
|
385
632
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
386
633
|
containerElm = containerElm.shadowRoot;
|
|
387
634
|
}
|
|
388
635
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
389
636
|
if (vnodes[startIdx]) {
|
|
390
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
637
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
391
638
|
if (childNode) {
|
|
392
639
|
vnodes[startIdx].$elm$ = childNode;
|
|
393
|
-
containerElm.insertBefore(childNode, before);
|
|
640
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
394
641
|
}
|
|
395
642
|
}
|
|
396
643
|
}
|
|
@@ -400,14 +647,98 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
400
647
|
if ((vnode = vnodes[startIdx])) {
|
|
401
648
|
elm = vnode.$elm$;
|
|
402
649
|
callNodeRefs(vnode);
|
|
650
|
+
{
|
|
651
|
+
// we're removing this element
|
|
652
|
+
// so it's possible we need to show slot fallback content now
|
|
653
|
+
checkSlotFallbackVisibility = true;
|
|
654
|
+
if (elm['s-ol']) {
|
|
655
|
+
// remove the original location comment
|
|
656
|
+
elm['s-ol'].remove();
|
|
657
|
+
}
|
|
658
|
+
else {
|
|
659
|
+
// it's possible that child nodes of the node
|
|
660
|
+
// that's being removed are slot nodes
|
|
661
|
+
putBackInOriginalLocation(elm, true);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
403
664
|
// remove the vnode's element from the dom
|
|
404
665
|
elm.remove();
|
|
405
666
|
}
|
|
406
667
|
}
|
|
407
668
|
};
|
|
669
|
+
/**
|
|
670
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
671
|
+
* traversing the two collections of children, identifying nodes that are
|
|
672
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
673
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
674
|
+
*
|
|
675
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
676
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
677
|
+
* 'windows' by storing start and end indices and references to the
|
|
678
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
679
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
680
|
+
* no children left to update by doing the following:
|
|
681
|
+
*
|
|
682
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
683
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
684
|
+
* only with a window bounded by the highlighted elements:
|
|
685
|
+
*
|
|
686
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
687
|
+
* ^^^^^^ ^^^^^^
|
|
688
|
+
*
|
|
689
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
690
|
+
* across the windows. This will basically detect elements which haven't
|
|
691
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
692
|
+
* VNode elements (represented as HTML):
|
|
693
|
+
*
|
|
694
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
695
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
696
|
+
*
|
|
697
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
698
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
699
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
700
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
701
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
702
|
+
*
|
|
703
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
704
|
+
* window corresponds to the element at the end of the other window. This is
|
|
705
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
706
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
707
|
+
* children nodes themselves have not changed but merely moved in the
|
|
708
|
+
* following example:
|
|
709
|
+
*
|
|
710
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
711
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
712
|
+
*
|
|
713
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
714
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
715
|
+
* DOM.
|
|
716
|
+
*
|
|
717
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
718
|
+
* nodes in the old children which have the same key as the first element in
|
|
719
|
+
* our window on the new children. If we find such a node we handle calling
|
|
720
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
721
|
+
* what we find.
|
|
722
|
+
*
|
|
723
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
724
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
725
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
726
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
727
|
+
* children has collapsed we still have more nodes on the new children that
|
|
728
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
729
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
730
|
+
* sure the corresponding DOM nodes are removed.
|
|
731
|
+
*
|
|
732
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
733
|
+
* @param oldCh the old children of the parent node
|
|
734
|
+
* @param newVNode the new VNode which will replace the parent
|
|
735
|
+
* @param newCh the new children of the parent node
|
|
736
|
+
*/
|
|
408
737
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
409
738
|
let oldStartIdx = 0;
|
|
410
739
|
let newStartIdx = 0;
|
|
740
|
+
let idxInOld = 0;
|
|
741
|
+
let i = 0;
|
|
411
742
|
let oldEndIdx = oldCh.length - 1;
|
|
412
743
|
let oldStartVnode = oldCh[0];
|
|
413
744
|
let oldEndVnode = oldCh[oldEndIdx];
|
|
@@ -415,9 +746,10 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
415
746
|
let newStartVnode = newCh[0];
|
|
416
747
|
let newEndVnode = newCh[newEndIdx];
|
|
417
748
|
let node;
|
|
749
|
+
let elmToMove;
|
|
418
750
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
419
751
|
if (oldStartVnode == null) {
|
|
420
|
-
//
|
|
752
|
+
// VNode might have been moved left
|
|
421
753
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
422
754
|
}
|
|
423
755
|
else if (oldEndVnode == null) {
|
|
@@ -430,64 +762,212 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
430
762
|
newEndVnode = newCh[--newEndIdx];
|
|
431
763
|
}
|
|
432
764
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
765
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
766
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
767
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
768
|
+
// since things are matched up in order.
|
|
433
769
|
patch(oldStartVnode, newStartVnode);
|
|
434
770
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
435
771
|
newStartVnode = newCh[++newStartIdx];
|
|
436
772
|
}
|
|
437
773
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
774
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
775
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
776
|
+
// need to move any DOM Nodes.
|
|
438
777
|
patch(oldEndVnode, newEndVnode);
|
|
439
778
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
440
779
|
newEndVnode = newCh[--newEndIdx];
|
|
441
780
|
}
|
|
442
781
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
782
|
+
// case: "Vnode moved right"
|
|
783
|
+
//
|
|
784
|
+
// We've found that the last node in our window on the new children is
|
|
785
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
786
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
787
|
+
// nodes:
|
|
788
|
+
//
|
|
789
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
790
|
+
// ^^^^^^^^^^^
|
|
791
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
792
|
+
// ^^^^^^^^^^^^^
|
|
793
|
+
//
|
|
794
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
795
|
+
// and move the DOM element for `oldStartVnode`.
|
|
796
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
797
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
798
|
+
}
|
|
443
799
|
patch(oldStartVnode, newEndVnode);
|
|
800
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
801
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
802
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
803
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
804
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
805
|
+
//
|
|
806
|
+
// <old-start-node />
|
|
807
|
+
// <some-intervening-node />
|
|
808
|
+
// <old-end-node />
|
|
809
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
810
|
+
// <next-sibling />
|
|
811
|
+
//
|
|
812
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
813
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
814
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
815
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
816
|
+
// append it to the children of the parent element.
|
|
444
817
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
445
818
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
446
819
|
newEndVnode = newCh[--newEndIdx];
|
|
447
820
|
}
|
|
448
821
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
822
|
+
// case: "Vnode moved left"
|
|
823
|
+
//
|
|
824
|
+
// We've found that the first node in our window on the new children is
|
|
825
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
826
|
+
// Visually, this is the layout of these two nodes:
|
|
827
|
+
//
|
|
828
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
829
|
+
// ^^^^^^^^^^^^^
|
|
830
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
831
|
+
// ^^^^^^^^^^^
|
|
832
|
+
//
|
|
833
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
834
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
835
|
+
// children etc) but we also need to move the DOM node to which
|
|
836
|
+
// `oldEndVnode` corresponds.
|
|
837
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
838
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
839
|
+
}
|
|
449
840
|
patch(oldEndVnode, newStartVnode);
|
|
841
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
842
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
843
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
844
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
845
|
+
// future.
|
|
450
846
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
451
847
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
452
848
|
newStartVnode = newCh[++newStartIdx];
|
|
453
849
|
}
|
|
454
850
|
else {
|
|
851
|
+
// Here we do some checks to match up old and new nodes based on the
|
|
852
|
+
// `$key$` attribute, which is set by putting a `key="my-key"` attribute
|
|
853
|
+
// in the JSX for a DOM element in the implementation of a Stencil
|
|
854
|
+
// component.
|
|
855
|
+
//
|
|
856
|
+
// First we check to see if there are any nodes in the array of old
|
|
857
|
+
// children which have the same key as the first node in the new
|
|
858
|
+
// children.
|
|
859
|
+
idxInOld = -1;
|
|
455
860
|
{
|
|
456
|
-
|
|
457
|
-
|
|
861
|
+
for (i = oldStartIdx; i <= oldEndIdx; ++i) {
|
|
862
|
+
if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
|
|
863
|
+
idxInOld = i;
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
if (idxInOld >= 0) {
|
|
869
|
+
// We found a node in the old children which matches up with the first
|
|
870
|
+
// node in the new children! So let's deal with that
|
|
871
|
+
elmToMove = oldCh[idxInOld];
|
|
872
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
873
|
+
// the tag doesn't match so we'll need a new DOM element
|
|
874
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
|
|
875
|
+
}
|
|
876
|
+
else {
|
|
877
|
+
patch(elmToMove, newStartVnode);
|
|
878
|
+
// invalidate the matching old node so that we won't try to update it
|
|
879
|
+
// again later on
|
|
880
|
+
oldCh[idxInOld] = undefined;
|
|
881
|
+
node = elmToMove.$elm$;
|
|
882
|
+
}
|
|
883
|
+
newStartVnode = newCh[++newStartIdx];
|
|
884
|
+
}
|
|
885
|
+
else {
|
|
886
|
+
// We either didn't find an element in the old children that matches
|
|
887
|
+
// the key of the first new child OR the build is not using `key`
|
|
888
|
+
// attributes at all. In either case we need to create a new element
|
|
889
|
+
// for the new node.
|
|
890
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
458
891
|
newStartVnode = newCh[++newStartIdx];
|
|
459
892
|
}
|
|
460
893
|
if (node) {
|
|
894
|
+
// if we created a new node then handle inserting it to the DOM
|
|
461
895
|
{
|
|
462
|
-
oldStartVnode.$elm
|
|
896
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
463
897
|
}
|
|
464
898
|
}
|
|
465
899
|
}
|
|
466
900
|
}
|
|
467
901
|
if (oldStartIdx > oldEndIdx) {
|
|
902
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
468
903
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
469
904
|
}
|
|
470
905
|
else if (newStartIdx > newEndIdx) {
|
|
906
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
907
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
908
|
+
// relevant DOM nodes)
|
|
471
909
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
472
910
|
}
|
|
473
911
|
};
|
|
474
|
-
|
|
912
|
+
/**
|
|
913
|
+
* Compare two VNodes to determine if they are the same
|
|
914
|
+
*
|
|
915
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
916
|
+
* information set on the two VNodes and can be misleading under certain
|
|
917
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
918
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
919
|
+
* checking that they have the same tag.
|
|
920
|
+
*
|
|
921
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
922
|
+
* changing order within a `children` array or something along those lines then
|
|
923
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
924
|
+
*
|
|
925
|
+
* @param leftVNode the first VNode to check
|
|
926
|
+
* @param rightVNode the second VNode to check
|
|
927
|
+
* @returns whether they're equal or not
|
|
928
|
+
*/
|
|
929
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
475
930
|
// compare if two vnode to see if they're "technically" the same
|
|
476
931
|
// need to have the same element tag, and same key to be the same
|
|
477
|
-
if (
|
|
478
|
-
|
|
932
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
933
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
934
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
935
|
+
}
|
|
936
|
+
// this will be set if components in the build have `key` attrs set on them
|
|
937
|
+
{
|
|
938
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
939
|
+
}
|
|
479
940
|
}
|
|
480
941
|
return false;
|
|
481
942
|
};
|
|
943
|
+
const referenceNode = (node) => {
|
|
944
|
+
// this node was relocated to a new location in the dom
|
|
945
|
+
// because of some other component's slot
|
|
946
|
+
// but we still have an html comment in place of where
|
|
947
|
+
// it's original location was according to it's original vdom
|
|
948
|
+
return (node && node['s-ol']) || node;
|
|
949
|
+
};
|
|
950
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
951
|
+
/**
|
|
952
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
953
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
954
|
+
* children of the two nodes (if any).
|
|
955
|
+
*
|
|
956
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
957
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
958
|
+
*/
|
|
482
959
|
const patch = (oldVNode, newVNode) => {
|
|
483
960
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
484
961
|
const oldChildren = oldVNode.$children$;
|
|
485
962
|
const newChildren = newVNode.$children$;
|
|
963
|
+
const tag = newVNode.$tag$;
|
|
486
964
|
const text = newVNode.$text$;
|
|
965
|
+
let defaultHolder;
|
|
487
966
|
if (text === null) {
|
|
488
|
-
// element node
|
|
489
967
|
{
|
|
490
|
-
|
|
968
|
+
if (tag === 'slot')
|
|
969
|
+
;
|
|
970
|
+
else {
|
|
491
971
|
// either this is the first render of an element OR it's an update
|
|
492
972
|
// AND we already know it's possible it could have changed
|
|
493
973
|
// this updates the element's css classes, attrs, props, listeners, etc.
|
|
@@ -496,6 +976,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
496
976
|
}
|
|
497
977
|
if (oldChildren !== null && newChildren !== null) {
|
|
498
978
|
// looks like there's child vnodes for both the old and new vnodes
|
|
979
|
+
// so we need to call `updateChildren` to reconcile them
|
|
499
980
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
500
981
|
}
|
|
501
982
|
else if (newChildren !== null) {
|
|
@@ -512,12 +993,147 @@ const patch = (oldVNode, newVNode) => {
|
|
|
512
993
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
513
994
|
}
|
|
514
995
|
}
|
|
996
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
997
|
+
// this element has slotted content
|
|
998
|
+
defaultHolder.parentNode.textContent = text;
|
|
999
|
+
}
|
|
515
1000
|
else if (oldVNode.$text$ !== text) {
|
|
516
1001
|
// update the text content for the text only vnode
|
|
517
1002
|
// and also only if the text is different than before
|
|
518
1003
|
elm.data = text;
|
|
519
1004
|
}
|
|
520
1005
|
};
|
|
1006
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
1007
|
+
// tslint:disable-next-line: prefer-const
|
|
1008
|
+
const childNodes = elm.childNodes;
|
|
1009
|
+
let childNode;
|
|
1010
|
+
let i;
|
|
1011
|
+
let ilen;
|
|
1012
|
+
let j;
|
|
1013
|
+
let slotNameAttr;
|
|
1014
|
+
let nodeType;
|
|
1015
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
1016
|
+
childNode = childNodes[i];
|
|
1017
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1018
|
+
if (childNode['s-sr']) {
|
|
1019
|
+
// this is a slot fallback node
|
|
1020
|
+
// get the slot name for this slot reference node
|
|
1021
|
+
slotNameAttr = childNode['s-sn'];
|
|
1022
|
+
// by default always show a fallback slot node
|
|
1023
|
+
// then hide it if there are other slots in the light dom
|
|
1024
|
+
childNode.hidden = false;
|
|
1025
|
+
for (j = 0; j < ilen; j++) {
|
|
1026
|
+
nodeType = childNodes[j].nodeType;
|
|
1027
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
1028
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
1029
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
1030
|
+
childNode.hidden = true;
|
|
1031
|
+
break;
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
else {
|
|
1035
|
+
// this is a default fallback slot node
|
|
1036
|
+
// any element or text node (with content)
|
|
1037
|
+
// should hide the default fallback slot node
|
|
1038
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1039
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
1040
|
+
childNode.hidden = true;
|
|
1041
|
+
break;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
// keep drilling down
|
|
1047
|
+
updateFallbackSlotVisibility(childNode);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
const relocateNodes = [];
|
|
1052
|
+
const relocateSlotContent = (elm) => {
|
|
1053
|
+
// tslint:disable-next-line: prefer-const
|
|
1054
|
+
let childNode;
|
|
1055
|
+
let node;
|
|
1056
|
+
let hostContentNodes;
|
|
1057
|
+
let slotNameAttr;
|
|
1058
|
+
let relocateNodeData;
|
|
1059
|
+
let j;
|
|
1060
|
+
let i = 0;
|
|
1061
|
+
const childNodes = elm.childNodes;
|
|
1062
|
+
const ilen = childNodes.length;
|
|
1063
|
+
for (; i < ilen; i++) {
|
|
1064
|
+
childNode = childNodes[i];
|
|
1065
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
1066
|
+
// first got the content reference comment node
|
|
1067
|
+
// then we got it's parent, which is where all the host content is in now
|
|
1068
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
1069
|
+
slotNameAttr = childNode['s-sn'];
|
|
1070
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
1071
|
+
node = hostContentNodes[j];
|
|
1072
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
1073
|
+
// let's do some relocating to its new home
|
|
1074
|
+
// but never relocate a content reference node
|
|
1075
|
+
// that is suppose to always represent the original content location
|
|
1076
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
1077
|
+
// it's possible we've already decided to relocate this node
|
|
1078
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1079
|
+
// made some changes to slots
|
|
1080
|
+
// let's make sure we also double check
|
|
1081
|
+
// fallbacks are correctly hidden or shown
|
|
1082
|
+
checkSlotFallbackVisibility = true;
|
|
1083
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
1084
|
+
if (relocateNodeData) {
|
|
1085
|
+
// previously we never found a slot home for this node
|
|
1086
|
+
// but turns out we did, so let's remember it now
|
|
1087
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
1088
|
+
}
|
|
1089
|
+
else {
|
|
1090
|
+
// add to our list of nodes to relocate
|
|
1091
|
+
relocateNodes.push({
|
|
1092
|
+
$slotRefNode$: childNode,
|
|
1093
|
+
$nodeToRelocate$: node,
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
if (node['s-sr']) {
|
|
1097
|
+
relocateNodes.map((relocateNode) => {
|
|
1098
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
1099
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1100
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
1101
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
1108
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
1109
|
+
// if we never find a home for this element then we'll need to hide it
|
|
1110
|
+
relocateNodes.push({
|
|
1111
|
+
$nodeToRelocate$: node,
|
|
1112
|
+
});
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1118
|
+
relocateSlotContent(childNode);
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
};
|
|
1122
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
1123
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1124
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
1125
|
+
return true;
|
|
1126
|
+
}
|
|
1127
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
1128
|
+
return true;
|
|
1129
|
+
}
|
|
1130
|
+
return false;
|
|
1131
|
+
}
|
|
1132
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
1133
|
+
return true;
|
|
1134
|
+
}
|
|
1135
|
+
return slotNameAttr === '';
|
|
1136
|
+
};
|
|
521
1137
|
const callNodeRefs = (vNode) => {
|
|
522
1138
|
{
|
|
523
1139
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
@@ -526,44 +1142,105 @@ const callNodeRefs = (vNode) => {
|
|
|
526
1142
|
};
|
|
527
1143
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
528
1144
|
const hostElm = hostRef.$hostElement$;
|
|
1145
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
529
1146
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
530
1147
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
531
1148
|
hostTagName = hostElm.tagName;
|
|
1149
|
+
if (cmpMeta.$attrsToReflect$) {
|
|
1150
|
+
rootVnode.$attrs$ = rootVnode.$attrs$ || {};
|
|
1151
|
+
cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
|
|
1152
|
+
}
|
|
532
1153
|
rootVnode.$tag$ = null;
|
|
533
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1154
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
534
1155
|
hostRef.$vnode$ = rootVnode;
|
|
535
1156
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
536
1157
|
{
|
|
537
1158
|
scopeId = hostElm['s-sc'];
|
|
538
1159
|
}
|
|
1160
|
+
{
|
|
1161
|
+
contentRef = hostElm['s-cr'];
|
|
1162
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
1163
|
+
// always reset
|
|
1164
|
+
checkSlotFallbackVisibility = false;
|
|
1165
|
+
}
|
|
539
1166
|
// synchronous patch
|
|
540
1167
|
patch(oldVNode, rootVnode);
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
1168
|
+
{
|
|
1169
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
1170
|
+
// the disconnectCallback from working
|
|
1171
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1172
|
+
if (checkSlotRelocate) {
|
|
1173
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
1174
|
+
let relocateData;
|
|
1175
|
+
let nodeToRelocate;
|
|
1176
|
+
let orgLocationNode;
|
|
1177
|
+
let parentNodeRef;
|
|
1178
|
+
let insertBeforeNode;
|
|
1179
|
+
let refNode;
|
|
1180
|
+
let i = 0;
|
|
1181
|
+
for (; i < relocateNodes.length; i++) {
|
|
1182
|
+
relocateData = relocateNodes[i];
|
|
1183
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1184
|
+
if (!nodeToRelocate['s-ol']) {
|
|
1185
|
+
// add a reference node marking this node's original location
|
|
1186
|
+
// keep a reference to this node for later lookups
|
|
1187
|
+
orgLocationNode =
|
|
1188
|
+
doc.createTextNode('');
|
|
1189
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
1190
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
1194
|
+
relocateData = relocateNodes[i];
|
|
1195
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1196
|
+
if (relocateData.$slotRefNode$) {
|
|
1197
|
+
// by default we're just going to insert it directly
|
|
1198
|
+
// after the slot reference node
|
|
1199
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
1200
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
1201
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
1202
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
1203
|
+
refNode = orgLocationNode['s-nr'];
|
|
1204
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
1205
|
+
refNode = refNode.nextSibling;
|
|
1206
|
+
if (!refNode || !refNode['s-nr']) {
|
|
1207
|
+
insertBeforeNode = refNode;
|
|
1208
|
+
break;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
1213
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
1214
|
+
// we've checked that it's worth while to relocate
|
|
1215
|
+
// since that the node to relocate
|
|
1216
|
+
// has a different next sibling or parent relocated
|
|
1217
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
1218
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1219
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
1220
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1221
|
+
}
|
|
1222
|
+
// add it back to the dom but in its new home
|
|
1223
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
1229
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1230
|
+
nodeToRelocate.hidden = true;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
if (checkSlotFallbackVisibility) {
|
|
1236
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1237
|
+
}
|
|
1238
|
+
// done moving nodes around
|
|
1239
|
+
// allow the disconnect callback to work again
|
|
1240
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1241
|
+
// always reset
|
|
1242
|
+
relocateNodes.length = 0;
|
|
1243
|
+
}
|
|
567
1244
|
};
|
|
568
1245
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
569
1246
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -572,10 +1249,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
572
1249
|
};
|
|
573
1250
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
574
1251
|
{
|
|
575
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1252
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
576
1253
|
}
|
|
577
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
578
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1254
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1255
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
579
1256
|
return;
|
|
580
1257
|
}
|
|
581
1258
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -590,10 +1267,20 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
590
1267
|
const instance = hostRef.$lazyInstance$ ;
|
|
591
1268
|
let promise;
|
|
592
1269
|
if (isInitialLoad) {
|
|
1270
|
+
{
|
|
1271
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1272
|
+
if (hostRef.$queuedListeners$) {
|
|
1273
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1274
|
+
hostRef.$queuedListeners$ = null;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
593
1277
|
{
|
|
594
1278
|
promise = safeCall(instance, 'componentWillLoad');
|
|
595
1279
|
}
|
|
596
1280
|
}
|
|
1281
|
+
{
|
|
1282
|
+
promise = then(promise, () => safeCall(instance, 'componentWillRender'));
|
|
1283
|
+
}
|
|
597
1284
|
endSchedule();
|
|
598
1285
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
599
1286
|
};
|
|
@@ -627,7 +1314,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
627
1314
|
}
|
|
628
1315
|
else {
|
|
629
1316
|
Promise.all(childrenPromises).then(postUpdate);
|
|
630
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
1317
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
631
1318
|
childrenPromises.length = 0;
|
|
632
1319
|
}
|
|
633
1320
|
}
|
|
@@ -636,10 +1323,10 @@ const callRender = (hostRef, instance, elm) => {
|
|
|
636
1323
|
try {
|
|
637
1324
|
instance = instance.render() ;
|
|
638
1325
|
{
|
|
639
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
1326
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
640
1327
|
}
|
|
641
1328
|
{
|
|
642
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
1329
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
643
1330
|
}
|
|
644
1331
|
{
|
|
645
1332
|
{
|
|
@@ -663,8 +1350,11 @@ const postUpdateComponent = (hostRef) => {
|
|
|
663
1350
|
const endPostUpdate = createTime('postUpdate', tagName);
|
|
664
1351
|
const instance = hostRef.$lazyInstance$ ;
|
|
665
1352
|
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
666
|
-
|
|
667
|
-
|
|
1353
|
+
{
|
|
1354
|
+
safeCall(instance, 'componentDidRender');
|
|
1355
|
+
}
|
|
1356
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1357
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
668
1358
|
{
|
|
669
1359
|
// DOM WRITE!
|
|
670
1360
|
addHydratedFlag(elm);
|
|
@@ -693,10 +1383,10 @@ const postUpdateComponent = (hostRef) => {
|
|
|
693
1383
|
hostRef.$onRenderResolve$();
|
|
694
1384
|
hostRef.$onRenderResolve$ = undefined;
|
|
695
1385
|
}
|
|
696
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
1386
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
697
1387
|
nextTick(() => scheduleUpdate(hostRef, false));
|
|
698
1388
|
}
|
|
699
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
1389
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
700
1390
|
}
|
|
701
1391
|
// ( •_•)
|
|
702
1392
|
// ( •_•)>⌐■-■
|
|
@@ -726,44 +1416,6 @@ const then = (promise, thenFn) => {
|
|
|
726
1416
|
};
|
|
727
1417
|
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
728
1418
|
;
|
|
729
|
-
/**
|
|
730
|
-
* Parse a new property value for a given property type.
|
|
731
|
-
*
|
|
732
|
-
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
733
|
-
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
734
|
-
* 1. `any`, the type given to `propValue` in the function signature
|
|
735
|
-
* 2. the type stored from `propType`.
|
|
736
|
-
*
|
|
737
|
-
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
738
|
-
*
|
|
739
|
-
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
740
|
-
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
741
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
742
|
-
* ```tsx
|
|
743
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
744
|
-
* ```
|
|
745
|
-
*
|
|
746
|
-
* HTML prop values on the other hand, will always a string
|
|
747
|
-
*
|
|
748
|
-
* @param propValue the new value to coerce to some type
|
|
749
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
750
|
-
* @returns the parsed/coerced value
|
|
751
|
-
*/
|
|
752
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
753
|
-
// ensure this value is of the correct prop type
|
|
754
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
755
|
-
if (propType & 1 /* String */) {
|
|
756
|
-
// could have been passed as a number or boolean
|
|
757
|
-
// but we still want it as a string
|
|
758
|
-
return String(propValue);
|
|
759
|
-
}
|
|
760
|
-
// redundant return here for better minification
|
|
761
|
-
return propValue;
|
|
762
|
-
}
|
|
763
|
-
// not sure exactly what type we want
|
|
764
|
-
// so no need to change to a different type
|
|
765
|
-
return propValue;
|
|
766
|
-
};
|
|
767
1419
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
768
1420
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
769
1421
|
// check our new property value against our internal value
|
|
@@ -776,13 +1428,13 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
776
1428
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
777
1429
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
778
1430
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
779
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1431
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
780
1432
|
// gadzooks! the property's value has changed!!
|
|
781
1433
|
// set our new value!
|
|
782
1434
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
783
1435
|
if (instance) {
|
|
784
1436
|
// get an array of method names of watch functions to call
|
|
785
|
-
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
1437
|
+
if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
|
|
786
1438
|
const watchMethods = cmpMeta.$watchers$[propName];
|
|
787
1439
|
if (watchMethods) {
|
|
788
1440
|
// this instance is watching for when this property changed
|
|
@@ -797,7 +1449,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
797
1449
|
});
|
|
798
1450
|
}
|
|
799
1451
|
}
|
|
800
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1452
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
801
1453
|
// looks like this value actually changed, so we've got work to do!
|
|
802
1454
|
// but only if we've already rendered, otherwise just chill out
|
|
803
1455
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -807,6 +1459,16 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
807
1459
|
}
|
|
808
1460
|
}
|
|
809
1461
|
};
|
|
1462
|
+
/**
|
|
1463
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1464
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1465
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1466
|
+
*
|
|
1467
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1468
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1469
|
+
* @param flags a number used to store a series of bit flags
|
|
1470
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1471
|
+
*/
|
|
810
1472
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
811
1473
|
if (cmpMeta.$members$) {
|
|
812
1474
|
if (Cstr.watchers) {
|
|
@@ -816,8 +1478,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
816
1478
|
const members = Object.entries(cmpMeta.$members$);
|
|
817
1479
|
const prototype = Cstr.prototype;
|
|
818
1480
|
members.map(([memberName, [memberFlags]]) => {
|
|
819
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
820
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1481
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1482
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
821
1483
|
// proxyComponent - prop
|
|
822
1484
|
Object.defineProperty(prototype, memberName, {
|
|
823
1485
|
get() {
|
|
@@ -832,8 +1494,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
832
1494
|
enumerable: true,
|
|
833
1495
|
});
|
|
834
1496
|
}
|
|
835
|
-
else if (flags & 1 /* isElementConstructor */ &&
|
|
836
|
-
memberFlags & 64 /* Method */) {
|
|
1497
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1498
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
837
1499
|
// proxyComponent - method
|
|
838
1500
|
Object.defineProperty(prototype, memberName, {
|
|
839
1501
|
value(...args) {
|
|
@@ -843,7 +1505,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
843
1505
|
});
|
|
844
1506
|
}
|
|
845
1507
|
});
|
|
846
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1508
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
847
1509
|
const attrNameToPropName = new Map();
|
|
848
1510
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
849
1511
|
plt.jmp(() => {
|
|
@@ -899,10 +1561,13 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
899
1561
|
// create an array of attributes to observe
|
|
900
1562
|
// and also create a map of html attribute name to js property name
|
|
901
1563
|
Cstr.observedAttributes = members
|
|
902
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1564
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
903
1565
|
.map(([propName, m]) => {
|
|
904
1566
|
const attrName = m[1] || propName;
|
|
905
1567
|
attrNameToPropName.set(attrName, propName);
|
|
1568
|
+
if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
|
|
1569
|
+
cmpMeta.$attrsToReflect$.push([propName, attrName]);
|
|
1570
|
+
}
|
|
906
1571
|
return attrName;
|
|
907
1572
|
});
|
|
908
1573
|
}
|
|
@@ -911,10 +1576,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
911
1576
|
};
|
|
912
1577
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
913
1578
|
// initializeComponent
|
|
914
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1579
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
915
1580
|
{
|
|
916
1581
|
// we haven't initialized this element yet
|
|
917
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1582
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
918
1583
|
// lazy loaded components
|
|
919
1584
|
// request the component's implementation to be
|
|
920
1585
|
// wired up with the host element
|
|
@@ -932,7 +1597,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
932
1597
|
{
|
|
933
1598
|
cmpMeta.$watchers$ = Cstr.watchers;
|
|
934
1599
|
}
|
|
935
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1600
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
936
1601
|
Cstr.isProxied = true;
|
|
937
1602
|
}
|
|
938
1603
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -940,7 +1605,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
940
1605
|
// but let's keep track of when we start and stop
|
|
941
1606
|
// so that the getters/setters don't incorrectly step on data
|
|
942
1607
|
{
|
|
943
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1608
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
944
1609
|
}
|
|
945
1610
|
// construct the lazy-loaded component implementation
|
|
946
1611
|
// passing the hostRef is very important during
|
|
@@ -953,10 +1618,10 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
953
1618
|
consoleError(e);
|
|
954
1619
|
}
|
|
955
1620
|
{
|
|
956
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1621
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
957
1622
|
}
|
|
958
1623
|
{
|
|
959
|
-
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1624
|
+
hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
|
|
960
1625
|
}
|
|
961
1626
|
endNewInstance();
|
|
962
1627
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
@@ -967,7 +1632,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
967
1632
|
const scopeId = getScopeId(cmpMeta);
|
|
968
1633
|
if (!styles.has(scopeId)) {
|
|
969
1634
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
970
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1635
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
971
1636
|
endRegisterStyles();
|
|
972
1637
|
}
|
|
973
1638
|
}
|
|
@@ -994,13 +1659,22 @@ const fireConnectedCallback = (instance) => {
|
|
|
994
1659
|
}
|
|
995
1660
|
};
|
|
996
1661
|
const connectedCallback = (elm) => {
|
|
997
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1662
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
998
1663
|
const hostRef = getHostRef(elm);
|
|
999
1664
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1000
1665
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1001
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1666
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1002
1667
|
// first time this component has connected
|
|
1003
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1668
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1669
|
+
{
|
|
1670
|
+
// initUpdate
|
|
1671
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1672
|
+
// in here to act as original content anchors as we move nodes around
|
|
1673
|
+
// host element has been connected to the DOM
|
|
1674
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1675
|
+
setContentReference(elm);
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1004
1678
|
{
|
|
1005
1679
|
// find the first ancestor component (if there is one) and register
|
|
1006
1680
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1020,7 +1694,7 @@ const connectedCallback = (elm) => {
|
|
|
1020
1694
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1021
1695
|
if (cmpMeta.$members$) {
|
|
1022
1696
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1023
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1697
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1024
1698
|
const value = elm[memberName];
|
|
1025
1699
|
delete elm[memberName];
|
|
1026
1700
|
elm[memberName] = value;
|
|
@@ -1032,16 +1706,37 @@ const connectedCallback = (elm) => {
|
|
|
1032
1706
|
}
|
|
1033
1707
|
}
|
|
1034
1708
|
else {
|
|
1709
|
+
// not the first time this has connected
|
|
1710
|
+
// reattach any event listeners to the host
|
|
1711
|
+
// since they would have been removed when disconnected
|
|
1712
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1035
1713
|
// fire off connectedCallback() on component instance
|
|
1036
1714
|
fireConnectedCallback(hostRef.$lazyInstance$);
|
|
1037
1715
|
}
|
|
1038
1716
|
endConnected();
|
|
1039
1717
|
}
|
|
1040
1718
|
};
|
|
1719
|
+
const setContentReference = (elm) => {
|
|
1720
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1721
|
+
// or this browser doesn't support native shadow dom
|
|
1722
|
+
// and this host element was NOT created with SSR
|
|
1723
|
+
// let's pick out the inner content for slot projection
|
|
1724
|
+
// create a node to represent where the original
|
|
1725
|
+
// content was first placed, which is useful later on
|
|
1726
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1727
|
+
contentRefElm['s-cn'] = true;
|
|
1728
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1729
|
+
};
|
|
1041
1730
|
const disconnectedCallback = (elm) => {
|
|
1042
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1731
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1043
1732
|
const hostRef = getHostRef(elm);
|
|
1044
1733
|
const instance = hostRef.$lazyInstance$ ;
|
|
1734
|
+
{
|
|
1735
|
+
if (hostRef.$rmListeners$) {
|
|
1736
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1737
|
+
hostRef.$rmListeners$ = undefined;
|
|
1738
|
+
}
|
|
1739
|
+
}
|
|
1045
1740
|
{
|
|
1046
1741
|
safeCall(instance, 'disconnectedCallback');
|
|
1047
1742
|
}
|
|
@@ -1071,6 +1766,12 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1071
1766
|
{
|
|
1072
1767
|
cmpMeta.$members$ = compactMeta[2];
|
|
1073
1768
|
}
|
|
1769
|
+
{
|
|
1770
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1771
|
+
}
|
|
1772
|
+
{
|
|
1773
|
+
cmpMeta.$attrsToReflect$ = [];
|
|
1774
|
+
}
|
|
1074
1775
|
{
|
|
1075
1776
|
cmpMeta.$watchers$ = {};
|
|
1076
1777
|
}
|
|
@@ -1082,7 +1783,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1082
1783
|
super(self);
|
|
1083
1784
|
self = this;
|
|
1084
1785
|
registerHost(self, cmpMeta);
|
|
1085
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1786
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1086
1787
|
// this component is using shadow dom
|
|
1087
1788
|
// and this browser supports shadow dom
|
|
1088
1789
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1117,7 +1818,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1117
1818
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1118
1819
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1119
1820
|
cmpTags.push(tagName);
|
|
1120
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1821
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1121
1822
|
}
|
|
1122
1823
|
});
|
|
1123
1824
|
});
|
|
@@ -1139,7 +1840,37 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1139
1840
|
// Fallback appLoad event
|
|
1140
1841
|
endBootstrap();
|
|
1141
1842
|
};
|
|
1142
|
-
const
|
|
1843
|
+
const Fragment = (_, children) => children;
|
|
1844
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1845
|
+
if (listeners) {
|
|
1846
|
+
listeners.map(([flags, name, method]) => {
|
|
1847
|
+
const target = elm;
|
|
1848
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1849
|
+
const opts = hostListenerOpts(flags);
|
|
1850
|
+
plt.ael(target, name, handler, opts);
|
|
1851
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1855
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1856
|
+
try {
|
|
1857
|
+
{
|
|
1858
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1859
|
+
// instance is ready, let's call it's member method for this event
|
|
1860
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1861
|
+
}
|
|
1862
|
+
else {
|
|
1863
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
catch (e) {
|
|
1868
|
+
consoleError(e);
|
|
1869
|
+
}
|
|
1870
|
+
};
|
|
1871
|
+
// prettier-ignore
|
|
1872
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1873
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1143
1874
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1144
1875
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1145
1876
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1157,6 +1888,7 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1157
1888
|
elm['s-p'] = [];
|
|
1158
1889
|
elm['s-rc'] = [];
|
|
1159
1890
|
}
|
|
1891
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1160
1892
|
return hostRefs.set(elm, hostRef);
|
|
1161
1893
|
};
|
|
1162
1894
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
@@ -1183,14 +1915,35 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1183
1915
|
return importedModule[exportName];
|
|
1184
1916
|
}, consoleError);
|
|
1185
1917
|
};
|
|
1186
|
-
const styles = new Map();
|
|
1918
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1919
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1920
|
+
const doc = win.document || { head: {} };
|
|
1921
|
+
const plt = {
|
|
1922
|
+
$flags$: 0,
|
|
1923
|
+
$resourcesUrl$: '',
|
|
1924
|
+
jmp: (h) => h(),
|
|
1925
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1926
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1927
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1928
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1929
|
+
};
|
|
1930
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1931
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1932
|
+
try {
|
|
1933
|
+
new CSSStyleSheet();
|
|
1934
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1935
|
+
}
|
|
1936
|
+
catch (e) { }
|
|
1937
|
+
return false;
|
|
1938
|
+
})()
|
|
1939
|
+
;
|
|
1187
1940
|
const queueDomReads = [];
|
|
1188
1941
|
const queueDomWrites = [];
|
|
1189
1942
|
const queueTask = (queue, write) => (cb) => {
|
|
1190
1943
|
queue.push(cb);
|
|
1191
1944
|
if (!queuePending) {
|
|
1192
1945
|
queuePending = true;
|
|
1193
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1946
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1194
1947
|
nextTick(flush);
|
|
1195
1948
|
}
|
|
1196
1949
|
else {
|
|
@@ -1227,9 +1980,11 @@ const flush = () => {
|
|
|
1227
1980
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1228
1981
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1229
1982
|
|
|
1983
|
+
exports.Fragment = Fragment;
|
|
1230
1984
|
exports.Host = Host;
|
|
1231
1985
|
exports.bootstrapLazy = bootstrapLazy;
|
|
1232
1986
|
exports.createEvent = createEvent;
|
|
1987
|
+
exports.getElement = getElement;
|
|
1233
1988
|
exports.h = h;
|
|
1234
1989
|
exports.promiseResolve = promiseResolve;
|
|
1235
1990
|
exports.registerInstance = registerInstance;
|