@biggive/components 1.0.96 → 1.0.97
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/biggive/assets/images/biggive-triangle-green.svg +21 -0
- package/dist/biggive/assets/images/cross.svg +11 -0
- package/dist/biggive/assets/images/menu.svg +11 -0
- package/dist/biggive/biggive.esm.js +1 -1
- package/dist/biggive/p-063c44ce.entry.js +1 -0
- package/dist/biggive/p-0892aade.entry.js +1 -0
- package/dist/biggive/{p-e39db89c.entry.js → p-38b36bc6.entry.js} +1 -1
- package/dist/biggive/p-41c6f1f3.entry.js +1 -0
- package/dist/biggive/p-60872399.entry.js +1 -0
- package/dist/biggive/p-6d144f96.js +2 -0
- package/dist/biggive/p-8742102b.entry.js +1 -0
- package/dist/biggive/p-88faca11.js +1 -0
- package/dist/biggive/p-9916d987.entry.js +1 -0
- package/dist/biggive/p-99f15121.entry.js +1 -0
- package/dist/biggive/p-9fa2a9b2.entry.js +1 -0
- package/dist/biggive/p-a13e0f3e.entry.js +1 -0
- package/dist/biggive/p-aa4e1a2a.js +1 -0
- package/dist/biggive/p-bfaf1239.entry.js +1 -0
- package/dist/biggive/p-c1570c9f.entry.js +1 -0
- package/dist/biggive/p-d1c2b64d.entry.js +1 -0
- package/dist/biggive/p-da0a4725.entry.js +1 -0
- package/dist/biggive/p-de0f70ee.entry.js +1 -0
- package/dist/biggive/p-e3b0c4ae.entry.js +1 -0
- package/dist/biggive/p-e546fe69.entry.js +1 -0
- package/dist/cjs/biggive-article-card.cjs.entry.js +2 -35
- package/dist/cjs/biggive-back-to-top_23.cjs.entry.js +625 -0
- package/dist/cjs/biggive-basic-card.cjs.entry.js +2 -35
- package/dist/cjs/biggive-beneficiary-icon.cjs.entry.js +4 -19
- package/dist/cjs/biggive-boxed-content.cjs.entry.js +2 -17
- package/dist/cjs/biggive-branded-image.cjs.entry.js +2 -14
- package/dist/cjs/biggive-category-icon.cjs.entry.js +4 -19
- package/dist/cjs/biggive-form.cjs.entry.js +1 -1
- package/dist/cjs/biggive-formatted-text.cjs.entry.js +2 -8
- package/dist/cjs/biggive-icon-group.cjs.entry.js +2 -8
- package/dist/cjs/biggive-image.cjs.entry.js +2 -20
- package/dist/cjs/biggive-quote.cjs.entry.js +2 -14
- package/dist/cjs/biggive-search.cjs.entry.js +7 -5
- package/dist/cjs/biggive-tab.cjs.entry.js +2 -5
- package/dist/cjs/biggive-tabbed-content.cjs.entry.js +2 -8
- package/dist/cjs/biggive-text-input.cjs.entry.js +1 -1
- package/dist/cjs/biggive-video.cjs.entry.js +2 -11
- package/dist/cjs/biggive.cjs.js +3 -3
- package/dist/cjs/{fontawesome-icons-110f532d.js → fontawesome-icons-f33263c4.js} +45 -55
- package/dist/cjs/index-1fa2bbc6.js +196 -0
- package/dist/cjs/{index-87518c3f.js → index-ecfc2713.js} +734 -495
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/collection/assets/images/biggive-triangle-green.svg +21 -0
- package/dist/collection/assets/images/cross.svg +11 -0
- package/dist/collection/assets/images/menu.svg +11 -0
- package/dist/collection/collection-manifest.json +4 -2
- package/dist/collection/components/biggive-article-card/biggive-article-card.css +20 -0
- package/dist/collection/components/biggive-article-card/biggive-article-card.js +214 -253
- package/dist/collection/components/biggive-back-to-top/biggive-back-to-top.css +20 -0
- package/dist/collection/components/biggive-back-to-top/biggive-back-to-top.js +12 -11
- package/dist/collection/components/biggive-basic-card/biggive-basic-card.css +20 -0
- package/dist/collection/components/biggive-basic-card/biggive-basic-card.js +214 -251
- package/dist/collection/components/biggive-beneficiary-icon/biggive-beneficiary-icon.css +20 -0
- package/dist/collection/components/biggive-beneficiary-icon/biggive-beneficiary-icon.js +102 -116
- package/dist/collection/components/biggive-boxed-content/biggive-boxed-content.css +20 -0
- package/dist/collection/components/biggive-boxed-content/biggive-boxed-content.js +102 -112
- package/dist/collection/components/biggive-branded-image/biggive-branded-image.css +20 -0
- package/dist/collection/components/biggive-branded-image/biggive-branded-image.js +85 -96
- package/dist/collection/components/biggive-button/biggive-button.css +20 -0
- package/dist/collection/components/biggive-button/biggive-button.js +137 -153
- package/dist/collection/components/biggive-call-to-action/biggive-call-to-action.css +20 -0
- package/dist/collection/components/biggive-call-to-action/biggive-call-to-action.js +376 -440
- package/dist/collection/components/biggive-campaign-card/biggive-campaign-card.css +22 -0
- package/dist/collection/components/biggive-campaign-card/biggive-campaign-card.js +322 -385
- package/dist/collection/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.css +57 -0
- package/dist/collection/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.js +123 -124
- package/dist/collection/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.stories.js +6 -0
- package/dist/collection/components/biggive-campaign-highlights/biggive-campaign-highlights.css +20 -0
- package/dist/collection/components/biggive-campaign-highlights/biggive-campaign-highlights.js +238 -292
- package/dist/collection/components/biggive-category-icon/biggive-category-icon.css +20 -0
- package/dist/collection/components/biggive-category-icon/biggive-category-icon.js +102 -116
- package/dist/collection/components/biggive-footer/biggive-footer.css +54 -1
- package/dist/collection/components/biggive-footer/biggive-footer.js +15 -39
- package/dist/collection/components/biggive-footer/biggive-footer.stories.js +8 -1
- package/dist/collection/components/biggive-form/biggive-form.js +12 -9
- package/dist/collection/components/biggive-form-field-select/biggive-form-field-select.css +557 -0
- package/dist/collection/components/biggive-form-field-select/biggive-form-field-select.js +95 -9
- package/dist/collection/components/biggive-form-field-select/biggive-form-field-select.stories.js +9 -0
- package/dist/collection/components/biggive-form-field-select-option/biggive-form-field-select-option.css +520 -0
- package/dist/collection/components/biggive-form-field-select-option/biggive-form-field-select-option.js +94 -0
- package/dist/collection/components/biggive-form-field-select-option/biggive-form-field-select-option.stories.js +23 -0
- package/dist/collection/components/biggive-form-field-text-input/biggive-text-input.js +12 -9
- package/dist/collection/components/biggive-formatted-text/biggive-formatted-text.css +20 -0
- package/dist/collection/components/biggive-formatted-text/biggive-formatted-text.js +51 -52
- package/dist/collection/components/biggive-grid/biggive-grid.css +35 -0
- package/dist/collection/components/biggive-grid/biggive-grid.js +68 -72
- package/dist/collection/components/biggive-header/biggive-header.css +90 -2
- package/dist/collection/components/biggive-header/biggive-header.js +64 -69
- package/dist/collection/components/biggive-header/biggive-header.stories.js +2 -1
- package/dist/collection/components/biggive-heading/biggive-heading.css +20 -0
- package/dist/collection/components/biggive-heading/biggive-heading.js +136 -152
- package/dist/collection/components/biggive-hero-image/biggive-hero-image.css +44 -11
- package/dist/collection/components/biggive-hero-image/biggive-hero-image.js +240 -283
- package/dist/collection/components/biggive-icon-group/biggive-icon-group.css +20 -0
- package/dist/collection/components/biggive-icon-group/biggive-icon-group.js +51 -54
- package/dist/collection/components/biggive-image/biggive-image.css +20 -0
- package/dist/collection/components/biggive-image/biggive-image.js +119 -133
- package/dist/collection/components/biggive-image-feature/biggive-image-feature.css +39 -5
- package/dist/collection/components/biggive-image-feature/biggive-image-feature.js +232 -270
- package/dist/collection/components/biggive-misc-icon/biggive-misc-icon.css +20 -0
- package/dist/collection/components/biggive-misc-icon/biggive-misc-icon.js +85 -94
- package/dist/collection/components/biggive-page-column/biggive-page-column.css +506 -1
- package/dist/collection/components/biggive-page-column/biggive-page-column.js +11 -7
- package/dist/collection/components/biggive-page-columns/biggive-page-columns.css +30 -1
- package/dist/collection/components/biggive-page-columns/biggive-page-columns.js +34 -36
- package/dist/collection/components/biggive-page-section/biggive-page-section.css +20 -0
- package/dist/collection/components/biggive-page-section/biggive-page-section.js +85 -93
- package/dist/collection/components/biggive-popup/biggive-popup.css +547 -0
- package/dist/collection/components/biggive-popup/biggive-popup.js +47 -0
- package/dist/collection/components/biggive-popup/biggive-popup.stories.js +8 -0
- package/dist/collection/components/biggive-progress-bar/biggive-progress-bar.css +20 -0
- package/dist/collection/components/biggive-progress-bar/biggive-progress-bar.js +68 -76
- package/dist/collection/components/biggive-quote/biggive-quote.css +20 -0
- package/dist/collection/components/biggive-quote/biggive-quote.js +85 -93
- package/dist/collection/components/biggive-search/biggive-search.css +20 -0
- package/dist/collection/components/biggive-search/biggive-search.js +74 -74
- package/dist/collection/components/biggive-social-icon/biggive-social-icon.css +20 -0
- package/dist/collection/components/biggive-social-icon/biggive-social-icon.js +85 -94
- package/dist/collection/components/biggive-tab/biggive-tab.css +20 -0
- package/dist/collection/components/biggive-tab/biggive-tab.js +34 -34
- package/dist/collection/components/biggive-tabbed-content/biggive-tabbed-content.css +20 -0
- package/dist/collection/components/biggive-tabbed-content/biggive-tabbed-content.js +51 -52
- package/dist/collection/components/biggive-totalizer/biggive-totalizer.css +29 -1
- package/dist/collection/components/biggive-totalizer/biggive-totalizer.js +178 -208
- package/dist/collection/components/biggive-video/biggive-video.css +20 -0
- package/dist/collection/components/biggive-video/biggive-video.js +68 -72
- package/dist/collection/components/biggive-video-feature/biggive-video-feature.css +39 -5
- package/dist/collection/components/biggive-video-feature/biggive-video-feature.js +238 -278
- package/dist/components/biggive-article-card.js +1 -34
- package/dist/components/biggive-back-to-top.js +1 -1
- package/dist/components/biggive-basic-card.js +1 -34
- package/dist/components/biggive-beneficiary-icon.js +1 -16
- package/dist/components/biggive-boxed-content.js +1 -16
- package/dist/components/biggive-branded-image.js +1 -13
- package/dist/components/biggive-button2.js +2 -23
- package/dist/components/biggive-call-to-action.js +1 -61
- package/dist/components/biggive-campaign-card-filter-grid.js +55 -22
- package/dist/components/biggive-campaign-card.js +2 -49
- package/dist/components/biggive-campaign-highlights.js +1 -40
- package/dist/components/biggive-category-icon.js +1 -16
- package/dist/components/biggive-footer.js +4 -10
- package/dist/components/biggive-form-field-select-option.d.ts +11 -0
- package/dist/components/biggive-form-field-select-option.js +6 -0
- package/dist/components/biggive-form-field-select-option2.js +46 -0
- package/dist/components/biggive-form-field-select.js +1 -28
- package/dist/components/biggive-form-field-select2.js +44 -0
- package/dist/components/biggive-formatted-text.js +1 -7
- package/dist/components/biggive-grid.js +1 -10
- package/dist/components/biggive-header.js +13 -8
- package/dist/components/biggive-heading.js +1 -22
- package/dist/components/biggive-hero-image.js +1 -40
- package/dist/components/biggive-icon-group.js +1 -7
- package/dist/components/biggive-image-feature.js +1 -37
- package/dist/components/biggive-image.js +1 -19
- package/dist/components/biggive-misc-icon2.js +1 -13
- package/dist/components/biggive-page-column.js +1 -1
- package/dist/components/biggive-page-columns.js +1 -4
- package/dist/components/biggive-page-section.js +1 -13
- package/dist/components/biggive-popup.d.ts +11 -0
- package/dist/components/biggive-popup.js +6 -0
- package/dist/components/biggive-popup2.js +41 -0
- package/dist/components/biggive-progress-bar2.js +1 -10
- package/dist/components/biggive-quote.js +1 -13
- package/dist/components/biggive-search.js +5 -3
- package/dist/components/biggive-social-icon.js +41 -1
- package/dist/components/biggive-tab.js +1 -4
- package/dist/components/biggive-tabbed-content.js +1 -7
- package/dist/components/biggive-totalizer.js +1 -28
- package/dist/components/biggive-video-feature.js +1 -40
- package/dist/components/biggive-video.js +1 -10
- package/dist/components/fontawesome-icons.js +11 -21
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index2.js +164 -0
- package/dist/esm/biggive-article-card.entry.js +2 -35
- package/dist/esm/biggive-back-to-top_23.entry.js +599 -0
- package/dist/esm/biggive-basic-card.entry.js +2 -35
- package/dist/esm/biggive-beneficiary-icon.entry.js +4 -19
- package/dist/esm/biggive-boxed-content.entry.js +2 -17
- package/dist/esm/biggive-branded-image.entry.js +2 -14
- package/dist/esm/biggive-category-icon.entry.js +4 -19
- package/dist/esm/biggive-form.entry.js +1 -1
- package/dist/esm/biggive-formatted-text.entry.js +2 -8
- package/dist/esm/biggive-icon-group.entry.js +2 -8
- package/dist/esm/biggive-image.entry.js +2 -20
- package/dist/esm/biggive-quote.entry.js +2 -14
- package/dist/esm/biggive-search.entry.js +6 -4
- package/dist/esm/biggive-tab.entry.js +2 -5
- package/dist/esm/biggive-tabbed-content.entry.js +2 -8
- package/dist/esm/biggive-text-input.entry.js +1 -1
- package/dist/esm/biggive-video.entry.js +2 -11
- package/dist/esm/biggive.js +3 -3
- package/dist/esm/{fontawesome-icons-562459be.js → fontawesome-icons-ff9155ca.js} +11 -21
- package/dist/esm/index-7cfe62c2.js +164 -0
- package/dist/esm/{index-4395d470.js → index-b3c47751.js} +734 -495
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/types/components/biggive-campaign-card-filter-grid/biggive-campaign-card-filter-grid.d.ts +2 -6
- package/dist/types/components/biggive-form-field-select/biggive-form-field-select.d.ts +17 -0
- package/dist/types/components/biggive-form-field-select/biggive-form-field-select.stories.d.ts +5 -0
- package/dist/types/components/biggive-form-field-select-option/biggive-form-field-select-option.d.ts +20 -0
- package/dist/types/components/biggive-form-field-select-option/biggive-form-field-select-option.stories.d.ts +13 -0
- package/dist/types/components/biggive-header/biggive-header.d.ts +1 -0
- package/dist/types/components/biggive-popup/biggive-popup.d.ts +6 -0
- package/dist/types/components/biggive-popup/biggive-popup.stories.d.ts +5 -0
- package/dist/types/components.d.ts +73 -6
- package/dist/types/stencil-public-runtime.d.ts +20 -4
- package/hydrate/index.d.ts +1 -1
- package/hydrate/index.js +1133 -1561
- package/loader/package.json +1 -0
- package/package.json +4 -2
- package/dist/biggive/p-10ba977a.entry.js +0 -1
- package/dist/biggive/p-114fac7c.entry.js +0 -1
- package/dist/biggive/p-1788f27c.entry.js +0 -1
- package/dist/biggive/p-1805f9ab.js +0 -2
- package/dist/biggive/p-1bf2e39d.entry.js +0 -1
- package/dist/biggive/p-26de9586.entry.js +0 -1
- package/dist/biggive/p-3116f3df.entry.js +0 -1
- package/dist/biggive/p-4368caaa.entry.js +0 -1
- package/dist/biggive/p-512c15ed.entry.js +0 -1
- package/dist/biggive/p-78406754.entry.js +0 -1
- package/dist/biggive/p-871707f4.js +0 -6
- package/dist/biggive/p-9125d753.entry.js +0 -1
- package/dist/biggive/p-96ddb8d1.entry.js +0 -1
- package/dist/biggive/p-a423663d.entry.js +0 -1
- package/dist/biggive/p-afde0b4b.entry.js +0 -1
- package/dist/biggive/p-b15292fe.entry.js +0 -1
- package/dist/biggive/p-ec9b42b3.js +0 -6
- package/dist/biggive/p-faa619ad.entry.js +0 -1
- package/dist/biggive/p-faa6817c.entry.js +0 -1
- package/dist/biggive/p-fb8447d1.entry.js +0 -1
- package/dist/cjs/biggive-back-to-top_20.cjs.entry.js +0 -923
- package/dist/cjs/biggive-form-field-select.cjs.entry.js +0 -19
- package/dist/cjs/index.es-d3570170.js +0 -201
- package/dist/components/biggive-social-icon2.js +0 -55
- package/dist/components/index.es.js +0 -169
- package/dist/esm/biggive-back-to-top_20.entry.js +0 -900
- package/dist/esm/biggive-form-field-select.entry.js +0 -15
- package/dist/esm/index.es-5777380a.js +0 -169
|
@@ -1,39 +1,21 @@
|
|
|
1
1
|
const NAMESPACE = 'biggive';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Virtual DOM patching algorithm based on Snabbdom by
|
|
5
|
+
* Simon Friis Vindum (@paldepind)
|
|
6
|
+
* Licensed under the MIT License
|
|
7
|
+
* https://github.com/snabbdom/snabbdom/blob/master/LICENSE
|
|
8
|
+
*
|
|
9
|
+
* Modified for Stencil's renderer and slot projection
|
|
10
|
+
*/
|
|
3
11
|
let scopeId;
|
|
4
12
|
let hostTagName;
|
|
5
13
|
let isSvgMode = false;
|
|
6
14
|
let queuePending = false;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
$flags$: 0,
|
|
11
|
-
$resourcesUrl$: '',
|
|
12
|
-
jmp: (h) => h(),
|
|
13
|
-
raf: (h) => requestAnimationFrame(h),
|
|
14
|
-
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
15
|
-
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
16
|
-
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
15
|
+
const getAssetPath = (path) => {
|
|
16
|
+
const assetUrl = new URL(path, plt.$resourcesUrl$);
|
|
17
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
17
18
|
};
|
|
18
|
-
const supportsShadow = true;
|
|
19
|
-
const promiseResolve = (v) => Promise.resolve(v);
|
|
20
|
-
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
21
|
-
try {
|
|
22
|
-
new CSSStyleSheet();
|
|
23
|
-
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
24
|
-
}
|
|
25
|
-
catch (e) { }
|
|
26
|
-
return false;
|
|
27
|
-
})()
|
|
28
|
-
;
|
|
29
|
-
const CONTENT_REF_ID = 'r';
|
|
30
|
-
const ORG_LOCATION_ID = 'o';
|
|
31
|
-
const SLOT_NODE_ID = 's';
|
|
32
|
-
const TEXT_NODE_ID = 't';
|
|
33
|
-
const HYDRATE_ID = 's-id';
|
|
34
|
-
const HYDRATED_STYLE_ID = 'sty-id';
|
|
35
|
-
const HYDRATE_CHILD_ID = 'c-id';
|
|
36
|
-
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
37
19
|
const createTime = (fnName, tagName = '') => {
|
|
38
20
|
{
|
|
39
21
|
return () => {
|
|
@@ -48,82 +30,14 @@ const uniqueTime = (key, measureText) => {
|
|
|
48
30
|
};
|
|
49
31
|
}
|
|
50
32
|
};
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else {
|
|
60
|
-
style.replaceSync(cssText);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
style = cssText;
|
|
65
|
-
}
|
|
66
|
-
styles.set(scopeId, style);
|
|
67
|
-
};
|
|
68
|
-
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
69
|
-
let scopeId = getScopeId(cmpMeta);
|
|
70
|
-
const style = styles.get(scopeId);
|
|
71
|
-
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
72
|
-
// so the fallback is to always use the document for the root node in those cases
|
|
73
|
-
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : doc;
|
|
74
|
-
if (style) {
|
|
75
|
-
if (typeof style === 'string') {
|
|
76
|
-
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
77
|
-
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
78
|
-
let styleElm;
|
|
79
|
-
if (!appliedStyles) {
|
|
80
|
-
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
81
|
-
}
|
|
82
|
-
if (!appliedStyles.has(scopeId)) {
|
|
83
|
-
if (styleContainerNode.host &&
|
|
84
|
-
(styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
|
85
|
-
// This is only happening on native shadow-dom, do not needs CSS var shim
|
|
86
|
-
styleElm.innerHTML = style;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
{
|
|
90
|
-
styleElm = doc.createElement('style');
|
|
91
|
-
styleElm.innerHTML = style;
|
|
92
|
-
}
|
|
93
|
-
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
94
|
-
}
|
|
95
|
-
if (appliedStyles) {
|
|
96
|
-
appliedStyles.add(scopeId);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
101
|
-
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return scopeId;
|
|
105
|
-
};
|
|
106
|
-
const attachStyles = (hostRef) => {
|
|
107
|
-
const cmpMeta = hostRef.$cmpMeta$;
|
|
108
|
-
const elm = hostRef.$hostElement$;
|
|
109
|
-
const flags = cmpMeta.$flags$;
|
|
110
|
-
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
111
|
-
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
112
|
-
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
113
|
-
// only required when we're NOT using native shadow dom (slot)
|
|
114
|
-
// or this browser doesn't support native shadow dom
|
|
115
|
-
// and this host element was NOT created with SSR
|
|
116
|
-
// let's pick out the inner content for slot projection
|
|
117
|
-
// create a node to represent where the original
|
|
118
|
-
// content was first placed, which is useful later on
|
|
119
|
-
// DOM WRITE!!
|
|
120
|
-
elm['s-sc'] = scopeId;
|
|
121
|
-
elm.classList.add(scopeId + '-h');
|
|
122
|
-
}
|
|
123
|
-
endAttachStyles();
|
|
124
|
-
};
|
|
125
|
-
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
126
|
-
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
|
33
|
+
const CONTENT_REF_ID = 'r';
|
|
34
|
+
const ORG_LOCATION_ID = 'o';
|
|
35
|
+
const SLOT_NODE_ID = 's';
|
|
36
|
+
const TEXT_NODE_ID = 't';
|
|
37
|
+
const HYDRATE_ID = 's-id';
|
|
38
|
+
const HYDRATED_STYLE_ID = 'sty-id';
|
|
39
|
+
const HYDRATE_CHILD_ID = 'c-id';
|
|
40
|
+
const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
|
|
127
41
|
/**
|
|
128
42
|
* Default style mode id
|
|
129
43
|
*/
|
|
@@ -239,18 +153,368 @@ const convertToPrivate = (node) => {
|
|
|
239
153
|
if (node.vkey) {
|
|
240
154
|
vnodeData.key = node.vkey;
|
|
241
155
|
}
|
|
242
|
-
if (node.vname) {
|
|
243
|
-
vnodeData.name = node.vname;
|
|
156
|
+
if (node.vname) {
|
|
157
|
+
vnodeData.name = node.vname;
|
|
158
|
+
}
|
|
159
|
+
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
160
|
+
}
|
|
161
|
+
const vnode = newVNode(node.vtag, node.vtext);
|
|
162
|
+
vnode.$attrs$ = node.vattrs;
|
|
163
|
+
vnode.$children$ = node.vchildren;
|
|
164
|
+
vnode.$key$ = node.vkey;
|
|
165
|
+
vnode.$name$ = node.vname;
|
|
166
|
+
return vnode;
|
|
167
|
+
};
|
|
168
|
+
const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
169
|
+
const endHydrate = createTime('hydrateClient', tagName);
|
|
170
|
+
const shadowRoot = hostElm.shadowRoot;
|
|
171
|
+
const childRenderNodes = [];
|
|
172
|
+
const slotNodes = [];
|
|
173
|
+
const shadowRootNodes = shadowRoot ? [] : null;
|
|
174
|
+
const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
|
175
|
+
if (!plt.$orgLocNodes$) {
|
|
176
|
+
initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
|
177
|
+
}
|
|
178
|
+
hostElm[HYDRATE_ID] = hostId;
|
|
179
|
+
hostElm.removeAttribute(HYDRATE_ID);
|
|
180
|
+
clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
|
181
|
+
childRenderNodes.map((c) => {
|
|
182
|
+
const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
|
183
|
+
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
184
|
+
const node = c.$elm$;
|
|
185
|
+
if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
|
186
|
+
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
|
187
|
+
}
|
|
188
|
+
if (!shadowRoot) {
|
|
189
|
+
node['s-hn'] = tagName;
|
|
190
|
+
if (orgLocationNode) {
|
|
191
|
+
node['s-ol'] = orgLocationNode;
|
|
192
|
+
node['s-ol']['s-nr'] = node;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
plt.$orgLocNodes$.delete(orgLocationId);
|
|
196
|
+
});
|
|
197
|
+
if (shadowRoot) {
|
|
198
|
+
shadowRootNodes.map((shadowRootNode) => {
|
|
199
|
+
if (shadowRootNode) {
|
|
200
|
+
shadowRoot.appendChild(shadowRootNode);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
endHydrate();
|
|
205
|
+
};
|
|
206
|
+
const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
|
207
|
+
let childNodeType;
|
|
208
|
+
let childIdSplt;
|
|
209
|
+
let childVNode;
|
|
210
|
+
let i;
|
|
211
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
212
|
+
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
213
|
+
if (childNodeType) {
|
|
214
|
+
// got the node data from the element's attribute
|
|
215
|
+
// `${hostId}.${nodeId}.${depth}.${index}`
|
|
216
|
+
childIdSplt = childNodeType.split('.');
|
|
217
|
+
if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
|
218
|
+
childVNode = {
|
|
219
|
+
$flags$: 0,
|
|
220
|
+
$hostId$: childIdSplt[0],
|
|
221
|
+
$nodeId$: childIdSplt[1],
|
|
222
|
+
$depth$: childIdSplt[2],
|
|
223
|
+
$index$: childIdSplt[3],
|
|
224
|
+
$tag$: node.tagName.toLowerCase(),
|
|
225
|
+
$elm$: node,
|
|
226
|
+
$attrs$: null,
|
|
227
|
+
$children$: null,
|
|
228
|
+
$key$: null,
|
|
229
|
+
$name$: null,
|
|
230
|
+
$text$: null,
|
|
231
|
+
};
|
|
232
|
+
childRenderNodes.push(childVNode);
|
|
233
|
+
node.removeAttribute(HYDRATE_CHILD_ID);
|
|
234
|
+
// this is a new child vnode
|
|
235
|
+
// so ensure its parent vnode has the vchildren array
|
|
236
|
+
if (!parentVNode.$children$) {
|
|
237
|
+
parentVNode.$children$ = [];
|
|
238
|
+
}
|
|
239
|
+
// add our child vnode to a specific index of the vnode's children
|
|
240
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
241
|
+
// this is now the new parent vnode for all the next child checks
|
|
242
|
+
parentVNode = childVNode;
|
|
243
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
244
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
// recursively drill down, end to start so we can remove nodes
|
|
249
|
+
for (i = node.childNodes.length - 1; i >= 0; i--) {
|
|
250
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
|
251
|
+
}
|
|
252
|
+
if (node.shadowRoot) {
|
|
253
|
+
// keep drilling down through the shadow root nodes
|
|
254
|
+
for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
|
255
|
+
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
260
|
+
// `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
|
|
261
|
+
childIdSplt = node.nodeValue.split('.');
|
|
262
|
+
if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
|
|
263
|
+
// comment node for either the host id or a 0 host id
|
|
264
|
+
childNodeType = childIdSplt[0];
|
|
265
|
+
childVNode = {
|
|
266
|
+
$flags$: 0,
|
|
267
|
+
$hostId$: childIdSplt[1],
|
|
268
|
+
$nodeId$: childIdSplt[2],
|
|
269
|
+
$depth$: childIdSplt[3],
|
|
270
|
+
$index$: childIdSplt[4],
|
|
271
|
+
$elm$: node,
|
|
272
|
+
$attrs$: null,
|
|
273
|
+
$children$: null,
|
|
274
|
+
$key$: null,
|
|
275
|
+
$name$: null,
|
|
276
|
+
$tag$: null,
|
|
277
|
+
$text$: null,
|
|
278
|
+
};
|
|
279
|
+
if (childNodeType === TEXT_NODE_ID) {
|
|
280
|
+
childVNode.$elm$ = node.nextSibling;
|
|
281
|
+
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
|
|
282
|
+
childVNode.$text$ = childVNode.$elm$.textContent;
|
|
283
|
+
childRenderNodes.push(childVNode);
|
|
284
|
+
// remove the text comment since it's no longer needed
|
|
285
|
+
node.remove();
|
|
286
|
+
if (!parentVNode.$children$) {
|
|
287
|
+
parentVNode.$children$ = [];
|
|
288
|
+
}
|
|
289
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
290
|
+
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
291
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
else if (childVNode.$hostId$ === hostId) {
|
|
296
|
+
// this comment node is specifcally for this host id
|
|
297
|
+
if (childNodeType === SLOT_NODE_ID) {
|
|
298
|
+
// `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
|
|
299
|
+
childVNode.$tag$ = 'slot';
|
|
300
|
+
if (childIdSplt[5]) {
|
|
301
|
+
node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
node['s-sn'] = '';
|
|
305
|
+
}
|
|
306
|
+
node['s-sr'] = true;
|
|
307
|
+
if (shadowRootNodes) {
|
|
308
|
+
// browser support shadowRoot and this is a shadow dom component
|
|
309
|
+
// create an actual slot element
|
|
310
|
+
childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
|
311
|
+
if (childVNode.$name$) {
|
|
312
|
+
// add the slot name attribute
|
|
313
|
+
childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
|
314
|
+
}
|
|
315
|
+
// insert the new slot element before the slot comment
|
|
316
|
+
node.parentNode.insertBefore(childVNode.$elm$, node);
|
|
317
|
+
// remove the slot comment since it's not needed for shadow
|
|
318
|
+
node.remove();
|
|
319
|
+
if (childVNode.$depth$ === '0') {
|
|
320
|
+
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
slotNodes.push(childVNode);
|
|
324
|
+
if (!parentVNode.$children$) {
|
|
325
|
+
parentVNode.$children$ = [];
|
|
326
|
+
}
|
|
327
|
+
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
328
|
+
}
|
|
329
|
+
else if (childNodeType === CONTENT_REF_ID) {
|
|
330
|
+
// `${CONTENT_REF_ID}.${hostId}`;
|
|
331
|
+
if (shadowRootNodes) {
|
|
332
|
+
// remove the content ref comment since it's not needed for shadow
|
|
333
|
+
node.remove();
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else if (parentVNode && parentVNode.$tag$ === 'style') {
|
|
340
|
+
const vnode = newVNode(null, node.textContent);
|
|
341
|
+
vnode.$elm$ = node;
|
|
342
|
+
vnode.$index$ = '0';
|
|
343
|
+
parentVNode.$children$ = [vnode];
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
347
|
+
if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
348
|
+
let i = 0;
|
|
349
|
+
for (; i < node.childNodes.length; i++) {
|
|
350
|
+
initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
|
|
351
|
+
}
|
|
352
|
+
if (node.shadowRoot) {
|
|
353
|
+
for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
|
|
354
|
+
initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
|
|
359
|
+
const childIdSplt = node.nodeValue.split('.');
|
|
360
|
+
if (childIdSplt[0] === ORG_LOCATION_ID) {
|
|
361
|
+
orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
|
|
362
|
+
node.nodeValue = '';
|
|
363
|
+
// useful to know if the original location is
|
|
364
|
+
// the root light-dom of a shadow dom component
|
|
365
|
+
node['s-en'] = childIdSplt[3];
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Parse a new property value for a given property type.
|
|
371
|
+
*
|
|
372
|
+
* While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
|
|
373
|
+
* it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
|
|
374
|
+
* 1. `any`, the type given to `propValue` in the function signature
|
|
375
|
+
* 2. the type stored from `propType`.
|
|
376
|
+
*
|
|
377
|
+
* This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
|
|
378
|
+
*
|
|
379
|
+
* Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
|
|
380
|
+
* a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
|
|
381
|
+
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
382
|
+
* ```tsx
|
|
383
|
+
* <my-cmp prop-val={0}></my-cmp>
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* HTML prop values on the other hand, will always a string
|
|
387
|
+
*
|
|
388
|
+
* @param propValue the new value to coerce to some type
|
|
389
|
+
* @param propType the type of the prop, expressed as a binary number
|
|
390
|
+
* @returns the parsed/coerced value
|
|
391
|
+
*/
|
|
392
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
393
|
+
// ensure this value is of the correct prop type
|
|
394
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
395
|
+
if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
|
|
396
|
+
// per the HTML spec, any string value means it is a boolean true value
|
|
397
|
+
// but we'll cheat here and say that the string "false" is the boolean false
|
|
398
|
+
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
399
|
+
}
|
|
400
|
+
if (propType & 2 /* MEMBER_FLAGS.Number */) {
|
|
401
|
+
// force it to be a number
|
|
402
|
+
return parseFloat(propValue);
|
|
403
|
+
}
|
|
404
|
+
if (propType & 1 /* MEMBER_FLAGS.String */) {
|
|
405
|
+
// could have been passed as a number or boolean
|
|
406
|
+
// but we still want it as a string
|
|
407
|
+
return String(propValue);
|
|
408
|
+
}
|
|
409
|
+
// redundant return here for better minification
|
|
410
|
+
return propValue;
|
|
411
|
+
}
|
|
412
|
+
// not sure exactly what type we want
|
|
413
|
+
// so no need to change to a different type
|
|
414
|
+
return propValue;
|
|
415
|
+
};
|
|
416
|
+
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
417
|
+
const createEvent = (ref, name, flags) => {
|
|
418
|
+
const elm = getElement(ref);
|
|
419
|
+
return {
|
|
420
|
+
emit: (detail) => {
|
|
421
|
+
return emitEvent(elm, name, {
|
|
422
|
+
bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
|
|
423
|
+
composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
|
|
424
|
+
cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
|
|
425
|
+
detail,
|
|
426
|
+
});
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Helper function to create & dispatch a custom Event on a provided target
|
|
432
|
+
* @param elm the target of the Event
|
|
433
|
+
* @param name the name to give the custom Event
|
|
434
|
+
* @param opts options for configuring a custom Event
|
|
435
|
+
* @returns the custom Event
|
|
436
|
+
*/
|
|
437
|
+
const emitEvent = (elm, name, opts) => {
|
|
438
|
+
const ev = plt.ce(name, opts);
|
|
439
|
+
elm.dispatchEvent(ev);
|
|
440
|
+
return ev;
|
|
441
|
+
};
|
|
442
|
+
const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
|
|
443
|
+
const registerStyle = (scopeId, cssText, allowCS) => {
|
|
444
|
+
let style = styles.get(scopeId);
|
|
445
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
446
|
+
style = (style || new CSSStyleSheet());
|
|
447
|
+
if (typeof style === 'string') {
|
|
448
|
+
style = cssText;
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
style.replaceSync(cssText);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
else {
|
|
455
|
+
style = cssText;
|
|
456
|
+
}
|
|
457
|
+
styles.set(scopeId, style);
|
|
458
|
+
};
|
|
459
|
+
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
460
|
+
let scopeId = getScopeId(cmpMeta);
|
|
461
|
+
const style = styles.get(scopeId);
|
|
462
|
+
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
463
|
+
// so the fallback is to always use the document for the root node in those cases
|
|
464
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
|
|
465
|
+
if (style) {
|
|
466
|
+
if (typeof style === 'string') {
|
|
467
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
468
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
469
|
+
let styleElm;
|
|
470
|
+
if (!appliedStyles) {
|
|
471
|
+
rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
|
|
472
|
+
}
|
|
473
|
+
if (!appliedStyles.has(scopeId)) {
|
|
474
|
+
if (styleContainerNode.host &&
|
|
475
|
+
(styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
|
|
476
|
+
// This is only happening on native shadow-dom, do not needs CSS var shim
|
|
477
|
+
styleElm.innerHTML = style;
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
{
|
|
481
|
+
styleElm = doc.createElement('style');
|
|
482
|
+
styleElm.innerHTML = style;
|
|
483
|
+
}
|
|
484
|
+
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
485
|
+
}
|
|
486
|
+
if (appliedStyles) {
|
|
487
|
+
appliedStyles.add(scopeId);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
492
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
244
493
|
}
|
|
245
|
-
return h(node.vtag, vnodeData, ...(node.vchildren || []));
|
|
246
494
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
495
|
+
return scopeId;
|
|
496
|
+
};
|
|
497
|
+
const attachStyles = (hostRef) => {
|
|
498
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
499
|
+
const elm = hostRef.$hostElement$;
|
|
500
|
+
const flags = cmpMeta.$flags$;
|
|
501
|
+
const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
|
|
502
|
+
const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
|
|
503
|
+
if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
|
|
504
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
505
|
+
// or this browser doesn't support native shadow dom
|
|
506
|
+
// and this host element was NOT created with SSR
|
|
507
|
+
// let's pick out the inner content for slot projection
|
|
508
|
+
// create a node to represent where the original
|
|
509
|
+
// content was first placed, which is useful later on
|
|
510
|
+
// DOM WRITE!!
|
|
511
|
+
elm['s-sc'] = scopeId;
|
|
512
|
+
elm.classList.add(scopeId + '-h');
|
|
513
|
+
}
|
|
514
|
+
endAttachStyles();
|
|
253
515
|
};
|
|
516
|
+
const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
517
|
+
const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
|
|
254
518
|
/**
|
|
255
519
|
* Production setAccessor() function based on Preact by
|
|
256
520
|
* Jason Miller (@developit)
|
|
@@ -362,7 +626,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
362
626
|
}
|
|
363
627
|
}
|
|
364
628
|
}
|
|
365
|
-
else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex) {
|
|
629
|
+
else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
|
|
366
630
|
newValue = newValue === true ? '' : newValue;
|
|
367
631
|
{
|
|
368
632
|
elm.setAttribute(memberName, newValue);
|
|
@@ -377,7 +641,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
377
641
|
// if the element passed in is a shadow root, which is a document fragment
|
|
378
642
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
379
643
|
// if it's not a shadow root, then we add attrs/props to the same element
|
|
380
|
-
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
|
|
644
|
+
const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
|
|
381
645
|
? newVnode.$elm$.host
|
|
382
646
|
: newVnode.$elm$;
|
|
383
647
|
const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
|
|
@@ -395,6 +659,16 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
395
659
|
setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
|
|
396
660
|
}
|
|
397
661
|
};
|
|
662
|
+
/**
|
|
663
|
+
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
664
|
+
*
|
|
665
|
+
* @param oldParentVNode the parent VNode from the previous render
|
|
666
|
+
* @param newParentVNode the parent VNode from the current render
|
|
667
|
+
* @param childIndex the index of the VNode, in the _new_ parent node's
|
|
668
|
+
* children, for which we will create a new DOM node
|
|
669
|
+
* @param parentElm the parent DOM node which our new node will be a child of
|
|
670
|
+
* @returns the newly created node
|
|
671
|
+
*/
|
|
398
672
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
399
673
|
// tslint:disable-next-line: prefer-const
|
|
400
674
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
@@ -473,6 +747,74 @@ const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
|
473
747
|
}
|
|
474
748
|
}
|
|
475
749
|
};
|
|
750
|
+
/**
|
|
751
|
+
* Reconcile the children of a new VNode with the children of an old VNode by
|
|
752
|
+
* traversing the two collections of children, identifying nodes that are
|
|
753
|
+
* conserved or changed, calling out to `patch` to make any necessary
|
|
754
|
+
* updates to the DOM, and rearranging DOM nodes as needed.
|
|
755
|
+
*
|
|
756
|
+
* The algorithm for reconciling children works by analyzing two 'windows' onto
|
|
757
|
+
* the two arrays of children (`oldCh` and `newCh`). We keep track of the
|
|
758
|
+
* 'windows' by storing start and end indices and references to the
|
|
759
|
+
* corresponding array entries. Initially the two 'windows' are basically equal
|
|
760
|
+
* to the entire array, but we progressively narrow the windows until there are
|
|
761
|
+
* no children left to update by doing the following:
|
|
762
|
+
*
|
|
763
|
+
* 1. Skip any `null` entries at the beginning or end of the two arrays, so
|
|
764
|
+
* that if we have an initial array like the following we'll end up dealing
|
|
765
|
+
* only with a window bounded by the highlighted elements:
|
|
766
|
+
*
|
|
767
|
+
* [null, null, VNode1 , ... , VNode2, null, null]
|
|
768
|
+
* ^^^^^^ ^^^^^^
|
|
769
|
+
*
|
|
770
|
+
* 2. Check to see if the elements at the head and tail positions are equal
|
|
771
|
+
* across the windows. This will basically detect elements which haven't
|
|
772
|
+
* been added, removed, or changed position, i.e. if you had the following
|
|
773
|
+
* VNode elements (represented as HTML):
|
|
774
|
+
*
|
|
775
|
+
* oldVNode: `<div><p><span>HEY</span></p></div>`
|
|
776
|
+
* newVNode: `<div><p><span>THERE</span></p></div>`
|
|
777
|
+
*
|
|
778
|
+
* Then when comparing the children of the `<div>` tag we check the equality
|
|
779
|
+
* of the VNodes corresponding to the `<p>` tags and, since they are the
|
|
780
|
+
* same tag in the same position, we'd be able to avoid completely
|
|
781
|
+
* re-rendering the subtree under them with a new DOM element and would just
|
|
782
|
+
* call out to `patch` to handle reconciling their children and so on.
|
|
783
|
+
*
|
|
784
|
+
* 3. Check, for both windows, to see if the element at the beginning of the
|
|
785
|
+
* window corresponds to the element at the end of the other window. This is
|
|
786
|
+
* a heuristic which will let us identify _some_ situations in which
|
|
787
|
+
* elements have changed position, for instance it _should_ detect that the
|
|
788
|
+
* children nodes themselves have not changed but merely moved in the
|
|
789
|
+
* following example:
|
|
790
|
+
*
|
|
791
|
+
* oldVNode: `<div><element-one /><element-two /></div>`
|
|
792
|
+
* newVNode: `<div><element-two /><element-one /></div>`
|
|
793
|
+
*
|
|
794
|
+
* If we find cases like this then we also need to move the concrete DOM
|
|
795
|
+
* elements corresponding to the moved children to write the re-order to the
|
|
796
|
+
* DOM.
|
|
797
|
+
*
|
|
798
|
+
* 4. Finally, if VNodes have the `key` attribute set on them we check for any
|
|
799
|
+
* nodes in the old children which have the same key as the first element in
|
|
800
|
+
* our window on the new children. If we find such a node we handle calling
|
|
801
|
+
* out to `patch`, moving relevant DOM nodes, and so on, in accordance with
|
|
802
|
+
* what we find.
|
|
803
|
+
*
|
|
804
|
+
* Finally, once we've narrowed our 'windows' to the point that either of them
|
|
805
|
+
* collapse (i.e. they have length 0) we then handle any remaining VNode
|
|
806
|
+
* insertion or deletion that needs to happen to get a DOM state that correctly
|
|
807
|
+
* reflects the new child VNodes. If, for instance, after our window on the old
|
|
808
|
+
* children has collapsed we still have more nodes on the new children that
|
|
809
|
+
* we haven't dealt with yet then we need to add them, or if the new children
|
|
810
|
+
* collapse but we still have unhandled _old_ children then we need to make
|
|
811
|
+
* sure the corresponding DOM nodes are removed.
|
|
812
|
+
*
|
|
813
|
+
* @param parentElm the node into which the parent VNode is rendered
|
|
814
|
+
* @param oldCh the old children of the parent node
|
|
815
|
+
* @param newVNode the new VNode which will replace the parent
|
|
816
|
+
* @param newCh the new children of the parent node
|
|
817
|
+
*/
|
|
476
818
|
const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
477
819
|
let oldStartIdx = 0;
|
|
478
820
|
let newStartIdx = 0;
|
|
@@ -485,7 +827,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
485
827
|
let node;
|
|
486
828
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
487
829
|
if (oldStartVnode == null) {
|
|
488
|
-
//
|
|
830
|
+
// VNode might have been moved left
|
|
489
831
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
490
832
|
}
|
|
491
833
|
else if (oldEndVnode == null) {
|
|
@@ -498,34 +840,67 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
498
840
|
newEndVnode = newCh[--newEndIdx];
|
|
499
841
|
}
|
|
500
842
|
else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
843
|
+
// if the start nodes are the same then we should patch the new VNode
|
|
844
|
+
// onto the old one, and increment our `newStartIdx` and `oldStartIdx`
|
|
845
|
+
// indices to reflect that. We don't need to move any DOM Nodes around
|
|
846
|
+
// since things are matched up in order.
|
|
501
847
|
patch(oldStartVnode, newStartVnode);
|
|
502
848
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
503
849
|
newStartVnode = newCh[++newStartIdx];
|
|
504
850
|
}
|
|
505
851
|
else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
852
|
+
// likewise, if the end nodes are the same we patch new onto old and
|
|
853
|
+
// decrement our end indices, and also likewise in this case we don't
|
|
854
|
+
// need to move any DOM Nodes.
|
|
506
855
|
patch(oldEndVnode, newEndVnode);
|
|
507
856
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
508
857
|
newEndVnode = newCh[--newEndIdx];
|
|
509
858
|
}
|
|
510
859
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
511
860
|
patch(oldStartVnode, newEndVnode);
|
|
861
|
+
// We need to move the element for `oldStartVnode` into a position which
|
|
862
|
+
// will be appropriate for `newEndVnode`. For this we can use
|
|
863
|
+
// `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
|
|
864
|
+
// sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
|
|
865
|
+
// `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
|
|
866
|
+
//
|
|
867
|
+
// <old-start-node />
|
|
868
|
+
// <some-intervening-node />
|
|
869
|
+
// <old-end-node />
|
|
870
|
+
// <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
|
|
871
|
+
// <next-sibling />
|
|
872
|
+
//
|
|
873
|
+
// If instead `oldEndVnode.$elm$` has no sibling then we just want to put
|
|
874
|
+
// the node for `oldStartVnode` at the end of the children of
|
|
875
|
+
// `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
|
|
876
|
+
// aren't any siblings, and passing `null` to `Node.insertBefore` will
|
|
877
|
+
// append it to the children of the parent element.
|
|
512
878
|
parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
513
879
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
514
880
|
newEndVnode = newCh[--newEndIdx];
|
|
515
881
|
}
|
|
516
882
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
517
883
|
patch(oldEndVnode, newStartVnode);
|
|
884
|
+
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
885
|
+
// the same node, so since we're here we know that they are not. Thus we
|
|
886
|
+
// can move the element for `oldEndVnode` _before_ the element for
|
|
887
|
+
// `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
|
|
888
|
+
// future.
|
|
518
889
|
parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
519
890
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
520
891
|
newStartVnode = newCh[++newStartIdx];
|
|
521
892
|
}
|
|
522
893
|
else {
|
|
523
894
|
{
|
|
524
|
-
//
|
|
895
|
+
// We either didn't find an element in the old children that matches
|
|
896
|
+
// the key of the first new child OR the build is not using `key`
|
|
897
|
+
// attributes at all. In either case we need to create a new element
|
|
898
|
+
// for the new node.
|
|
525
899
|
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
526
900
|
newStartVnode = newCh[++newStartIdx];
|
|
527
901
|
}
|
|
528
902
|
if (node) {
|
|
903
|
+
// if we created a new node then handle inserting it to the DOM
|
|
529
904
|
{
|
|
530
905
|
oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
|
|
531
906
|
}
|
|
@@ -533,20 +908,49 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
533
908
|
}
|
|
534
909
|
}
|
|
535
910
|
if (oldStartIdx > oldEndIdx) {
|
|
911
|
+
// we have some more new nodes to add which don't match up with old nodes
|
|
536
912
|
addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
|
|
537
913
|
}
|
|
538
914
|
else if (newStartIdx > newEndIdx) {
|
|
915
|
+
// there are nodes in the `oldCh` array which no longer correspond to nodes
|
|
916
|
+
// in the new array, so lets remove them (which entails cleaning up the
|
|
917
|
+
// relevant DOM nodes)
|
|
539
918
|
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
540
919
|
}
|
|
541
920
|
};
|
|
542
|
-
|
|
921
|
+
/**
|
|
922
|
+
* Compare two VNodes to determine if they are the same
|
|
923
|
+
*
|
|
924
|
+
* **NB**: This function is an equality _heuristic_ based on the available
|
|
925
|
+
* information set on the two VNodes and can be misleading under certain
|
|
926
|
+
* circumstances. In particular, if the two nodes do not have `key` attrs
|
|
927
|
+
* (available under `$key$` on VNodes) then the function falls back on merely
|
|
928
|
+
* checking that they have the same tag.
|
|
929
|
+
*
|
|
930
|
+
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
931
|
+
* changing order within a `children` array or something along those lines then
|
|
932
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
933
|
+
*
|
|
934
|
+
* @param leftVNode the first VNode to check
|
|
935
|
+
* @param rightVNode the second VNode to check
|
|
936
|
+
* @returns whether they're equal or not
|
|
937
|
+
*/
|
|
938
|
+
const isSameVnode = (leftVNode, rightVNode) => {
|
|
543
939
|
// compare if two vnode to see if they're "technically" the same
|
|
544
940
|
// need to have the same element tag, and same key to be the same
|
|
545
|
-
if (
|
|
941
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
546
942
|
return true;
|
|
547
943
|
}
|
|
548
944
|
return false;
|
|
549
945
|
};
|
|
946
|
+
/**
|
|
947
|
+
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
948
|
+
* it. This function handles flushing updates to the DOM and reconciling the
|
|
949
|
+
* children of the two nodes (if any).
|
|
950
|
+
*
|
|
951
|
+
* @param oldVNode an old VNode whose DOM element and children we want to update
|
|
952
|
+
* @param newVNode a new VNode representing an updated version of the old one
|
|
953
|
+
*/
|
|
550
954
|
const patch = (oldVNode, newVNode) => {
|
|
551
955
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
552
956
|
const oldChildren = oldVNode.$children$;
|
|
@@ -559,7 +963,6 @@ const patch = (oldVNode, newVNode) => {
|
|
|
559
963
|
// only add this to the when the compiler sees we're using an svg somewhere
|
|
560
964
|
isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
|
|
561
965
|
}
|
|
562
|
-
// element node
|
|
563
966
|
{
|
|
564
967
|
if (tag === 'slot')
|
|
565
968
|
;
|
|
@@ -572,6 +975,7 @@ const patch = (oldVNode, newVNode) => {
|
|
|
572
975
|
}
|
|
573
976
|
if (oldChildren !== null && newChildren !== null) {
|
|
574
977
|
// looks like there's child vnodes for both the old and new vnodes
|
|
978
|
+
// so we need to call `updateChildren` to reconcile them
|
|
575
979
|
updateChildren(elm, oldChildren, newVNode, newChildren);
|
|
576
980
|
}
|
|
577
981
|
else if (newChildren !== null) {
|
|
@@ -603,7 +1007,7 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
603
1007
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
604
1008
|
hostTagName = hostElm.tagName;
|
|
605
1009
|
rootVnode.$tag$ = null;
|
|
606
|
-
rootVnode.$flags$ |= 4 /* isHost */;
|
|
1010
|
+
rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
|
|
607
1011
|
hostRef.$vnode$ = rootVnode;
|
|
608
1012
|
rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
|
|
609
1013
|
{
|
|
@@ -612,32 +1016,6 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
612
1016
|
// synchronous patch
|
|
613
1017
|
patch(oldVNode, rootVnode);
|
|
614
1018
|
};
|
|
615
|
-
const getElement = (ref) => (getHostRef(ref).$hostElement$ );
|
|
616
|
-
const createEvent = (ref, name, flags) => {
|
|
617
|
-
const elm = getElement(ref);
|
|
618
|
-
return {
|
|
619
|
-
emit: (detail) => {
|
|
620
|
-
return emitEvent(elm, name, {
|
|
621
|
-
bubbles: !!(flags & 4 /* Bubbles */),
|
|
622
|
-
composed: !!(flags & 2 /* Composed */),
|
|
623
|
-
cancelable: !!(flags & 1 /* Cancellable */),
|
|
624
|
-
detail,
|
|
625
|
-
});
|
|
626
|
-
},
|
|
627
|
-
};
|
|
628
|
-
};
|
|
629
|
-
/**
|
|
630
|
-
* Helper function to create & dispatch a custom Event on a provided target
|
|
631
|
-
* @param elm the target of the Event
|
|
632
|
-
* @param name the name to give the custom Event
|
|
633
|
-
* @param opts options for configuring a custom Event
|
|
634
|
-
* @returns the custom Event
|
|
635
|
-
*/
|
|
636
|
-
const emitEvent = (elm, name, opts) => {
|
|
637
|
-
const ev = plt.ce(name, opts);
|
|
638
|
-
elm.dispatchEvent(ev);
|
|
639
|
-
return ev;
|
|
640
|
-
};
|
|
641
1019
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
642
1020
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
643
1021
|
ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
|
|
@@ -645,10 +1023,10 @@ const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
|
645
1023
|
};
|
|
646
1024
|
const scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
647
1025
|
{
|
|
648
|
-
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
1026
|
+
hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
649
1027
|
}
|
|
650
|
-
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
651
|
-
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
1028
|
+
if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
|
|
1029
|
+
hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
|
|
652
1030
|
return;
|
|
653
1031
|
}
|
|
654
1032
|
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
@@ -662,6 +1040,15 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
662
1040
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
663
1041
|
const instance = hostRef.$lazyInstance$ ;
|
|
664
1042
|
let promise;
|
|
1043
|
+
if (isInitialLoad) {
|
|
1044
|
+
{
|
|
1045
|
+
hostRef.$flags$ |= 256 /* HOST_FLAGS.isListenReady */;
|
|
1046
|
+
if (hostRef.$queuedListeners$) {
|
|
1047
|
+
hostRef.$queuedListeners$.map(([methodName, event]) => safeCall(instance, methodName, event));
|
|
1048
|
+
hostRef.$queuedListeners$ = null;
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
665
1052
|
endSchedule();
|
|
666
1053
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
667
1054
|
};
|
|
@@ -690,340 +1077,106 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
690
1077
|
{
|
|
691
1078
|
const childrenPromises = elm['s-p'];
|
|
692
1079
|
const postUpdate = () => postUpdateComponent(hostRef);
|
|
693
|
-
if (childrenPromises.length === 0) {
|
|
694
|
-
postUpdate();
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
Promise.all(childrenPromises).then(postUpdate);
|
|
698
|
-
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
699
|
-
childrenPromises.length = 0;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
const callRender = (hostRef, instance, elm) => {
|
|
704
|
-
try {
|
|
705
|
-
instance = instance.render() ;
|
|
706
|
-
{
|
|
707
|
-
hostRef.$flags$ &= ~16 /* isQueuedForUpdate */;
|
|
708
|
-
}
|
|
709
|
-
{
|
|
710
|
-
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
711
|
-
}
|
|
712
|
-
{
|
|
713
|
-
{
|
|
714
|
-
// looks like we've got child nodes to render into this host element
|
|
715
|
-
// or we need to update the css class/attrs on the host element
|
|
716
|
-
// DOM WRITE!
|
|
717
|
-
{
|
|
718
|
-
renderVdom(hostRef, instance);
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
catch (e) {
|
|
724
|
-
consoleError(e, hostRef.$hostElement$);
|
|
725
|
-
}
|
|
726
|
-
return null;
|
|
727
|
-
};
|
|
728
|
-
const postUpdateComponent = (hostRef) => {
|
|
729
|
-
const tagName = hostRef.$cmpMeta$.$tagName$;
|
|
730
|
-
const elm = hostRef.$hostElement$;
|
|
731
|
-
const endPostUpdate = createTime('postUpdate', tagName);
|
|
732
|
-
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
733
|
-
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
734
|
-
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
735
|
-
{
|
|
736
|
-
// DOM WRITE!
|
|
737
|
-
addHydratedFlag(elm);
|
|
738
|
-
}
|
|
739
|
-
endPostUpdate();
|
|
740
|
-
{
|
|
741
|
-
hostRef.$onReadyResolve$(elm);
|
|
742
|
-
if (!ancestorComponent) {
|
|
743
|
-
appDidLoad();
|
|
744
|
-
}
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
else {
|
|
748
|
-
endPostUpdate();
|
|
749
|
-
}
|
|
750
|
-
// load events fire from bottom to top
|
|
751
|
-
// the deepest elements load first then bubbles up
|
|
752
|
-
{
|
|
753
|
-
if (hostRef.$onRenderResolve$) {
|
|
754
|
-
hostRef.$onRenderResolve$();
|
|
755
|
-
hostRef.$onRenderResolve$ = undefined;
|
|
756
|
-
}
|
|
757
|
-
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
758
|
-
nextTick(() => scheduleUpdate(hostRef, false));
|
|
759
|
-
}
|
|
760
|
-
hostRef.$flags$ &= ~(4 /* isWaitingForChildren */ | 512 /* needsRerender */);
|
|
761
|
-
}
|
|
762
|
-
// ( •_•)
|
|
763
|
-
// ( •_•)>⌐■-■
|
|
764
|
-
// (⌐■_■)
|
|
765
|
-
};
|
|
766
|
-
const appDidLoad = (who) => {
|
|
767
|
-
// on appload
|
|
768
|
-
// we have finish the first big initial render
|
|
769
|
-
{
|
|
770
|
-
addHydratedFlag(doc.documentElement);
|
|
771
|
-
}
|
|
772
|
-
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
773
|
-
};
|
|
774
|
-
const then = (promise, thenFn) => {
|
|
775
|
-
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
776
|
-
};
|
|
777
|
-
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
778
|
-
;
|
|
779
|
-
const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
|
|
780
|
-
const endHydrate = createTime('hydrateClient', tagName);
|
|
781
|
-
const shadowRoot = hostElm.shadowRoot;
|
|
782
|
-
const childRenderNodes = [];
|
|
783
|
-
const slotNodes = [];
|
|
784
|
-
const shadowRootNodes = shadowRoot ? [] : null;
|
|
785
|
-
const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
|
|
786
|
-
if (!plt.$orgLocNodes$) {
|
|
787
|
-
initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
|
|
788
|
-
}
|
|
789
|
-
hostElm[HYDRATE_ID] = hostId;
|
|
790
|
-
hostElm.removeAttribute(HYDRATE_ID);
|
|
791
|
-
clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
|
|
792
|
-
childRenderNodes.map((c) => {
|
|
793
|
-
const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
|
|
794
|
-
const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
|
|
795
|
-
const node = c.$elm$;
|
|
796
|
-
if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
|
|
797
|
-
orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
|
|
798
|
-
}
|
|
799
|
-
if (!shadowRoot) {
|
|
800
|
-
node['s-hn'] = tagName;
|
|
801
|
-
if (orgLocationNode) {
|
|
802
|
-
node['s-ol'] = orgLocationNode;
|
|
803
|
-
node['s-ol']['s-nr'] = node;
|
|
804
|
-
}
|
|
805
|
-
}
|
|
806
|
-
plt.$orgLocNodes$.delete(orgLocationId);
|
|
807
|
-
});
|
|
808
|
-
if (shadowRoot) {
|
|
809
|
-
shadowRootNodes.map((shadowRootNode) => {
|
|
810
|
-
if (shadowRootNode) {
|
|
811
|
-
shadowRoot.appendChild(shadowRootNode);
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
endHydrate();
|
|
816
|
-
};
|
|
817
|
-
const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
|
|
818
|
-
let childNodeType;
|
|
819
|
-
let childIdSplt;
|
|
820
|
-
let childVNode;
|
|
821
|
-
let i;
|
|
822
|
-
if (node.nodeType === 1 /* ElementNode */) {
|
|
823
|
-
childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
|
|
824
|
-
if (childNodeType) {
|
|
825
|
-
// got the node data from the element's attribute
|
|
826
|
-
// `${hostId}.${nodeId}.${depth}.${index}`
|
|
827
|
-
childIdSplt = childNodeType.split('.');
|
|
828
|
-
if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
|
|
829
|
-
childVNode = {
|
|
830
|
-
$flags$: 0,
|
|
831
|
-
$hostId$: childIdSplt[0],
|
|
832
|
-
$nodeId$: childIdSplt[1],
|
|
833
|
-
$depth$: childIdSplt[2],
|
|
834
|
-
$index$: childIdSplt[3],
|
|
835
|
-
$tag$: node.tagName.toLowerCase(),
|
|
836
|
-
$elm$: node,
|
|
837
|
-
$attrs$: null,
|
|
838
|
-
$children$: null,
|
|
839
|
-
$key$: null,
|
|
840
|
-
$name$: null,
|
|
841
|
-
$text$: null,
|
|
842
|
-
};
|
|
843
|
-
childRenderNodes.push(childVNode);
|
|
844
|
-
node.removeAttribute(HYDRATE_CHILD_ID);
|
|
845
|
-
// this is a new child vnode
|
|
846
|
-
// so ensure its parent vnode has the vchildren array
|
|
847
|
-
if (!parentVNode.$children$) {
|
|
848
|
-
parentVNode.$children$ = [];
|
|
849
|
-
}
|
|
850
|
-
// add our child vnode to a specific index of the vnode's children
|
|
851
|
-
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
852
|
-
// this is now the new parent vnode for all the next child checks
|
|
853
|
-
parentVNode = childVNode;
|
|
854
|
-
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
855
|
-
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
// recursively drill down, end to start so we can remove nodes
|
|
860
|
-
for (i = node.childNodes.length - 1; i >= 0; i--) {
|
|
861
|
-
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
|
|
862
|
-
}
|
|
863
|
-
if (node.shadowRoot) {
|
|
864
|
-
// keep drilling down through the shadow root nodes
|
|
865
|
-
for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
|
|
866
|
-
clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
|
|
867
|
-
}
|
|
1080
|
+
if (childrenPromises.length === 0) {
|
|
1081
|
+
postUpdate();
|
|
1082
|
+
}
|
|
1083
|
+
else {
|
|
1084
|
+
Promise.all(childrenPromises).then(postUpdate);
|
|
1085
|
+
hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
|
|
1086
|
+
childrenPromises.length = 0;
|
|
868
1087
|
}
|
|
869
1088
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
$tag$: null,
|
|
888
|
-
$text$: null,
|
|
889
|
-
};
|
|
890
|
-
if (childNodeType === TEXT_NODE_ID) {
|
|
891
|
-
childVNode.$elm$ = node.nextSibling;
|
|
892
|
-
if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* TextNode */) {
|
|
893
|
-
childVNode.$text$ = childVNode.$elm$.textContent;
|
|
894
|
-
childRenderNodes.push(childVNode);
|
|
895
|
-
// remove the text comment since it's no longer needed
|
|
896
|
-
node.remove();
|
|
897
|
-
if (!parentVNode.$children$) {
|
|
898
|
-
parentVNode.$children$ = [];
|
|
899
|
-
}
|
|
900
|
-
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
901
|
-
if (shadowRootNodes && childVNode.$depth$ === '0') {
|
|
902
|
-
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
else if (childVNode.$hostId$ === hostId) {
|
|
907
|
-
// this comment node is specifcally for this host id
|
|
908
|
-
if (childNodeType === SLOT_NODE_ID) {
|
|
909
|
-
// `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
|
|
910
|
-
childVNode.$tag$ = 'slot';
|
|
911
|
-
if (childIdSplt[5]) {
|
|
912
|
-
node['s-sn'] = childVNode.$name$ = childIdSplt[5];
|
|
913
|
-
}
|
|
914
|
-
else {
|
|
915
|
-
node['s-sn'] = '';
|
|
916
|
-
}
|
|
917
|
-
node['s-sr'] = true;
|
|
918
|
-
if (shadowRootNodes) {
|
|
919
|
-
// browser support shadowRoot and this is a shadow dom component
|
|
920
|
-
// create an actual slot element
|
|
921
|
-
childVNode.$elm$ = doc.createElement(childVNode.$tag$);
|
|
922
|
-
if (childVNode.$name$) {
|
|
923
|
-
// add the slot name attribute
|
|
924
|
-
childVNode.$elm$.setAttribute('name', childVNode.$name$);
|
|
925
|
-
}
|
|
926
|
-
// insert the new slot element before the slot comment
|
|
927
|
-
node.parentNode.insertBefore(childVNode.$elm$, node);
|
|
928
|
-
// remove the slot comment since it's not needed for shadow
|
|
929
|
-
node.remove();
|
|
930
|
-
if (childVNode.$depth$ === '0') {
|
|
931
|
-
shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
slotNodes.push(childVNode);
|
|
935
|
-
if (!parentVNode.$children$) {
|
|
936
|
-
parentVNode.$children$ = [];
|
|
937
|
-
}
|
|
938
|
-
parentVNode.$children$[childVNode.$index$] = childVNode;
|
|
939
|
-
}
|
|
940
|
-
else if (childNodeType === CONTENT_REF_ID) {
|
|
941
|
-
// `${CONTENT_REF_ID}.${hostId}`;
|
|
942
|
-
if (shadowRootNodes) {
|
|
943
|
-
// remove the content ref comment since it's not needed for shadow
|
|
944
|
-
node.remove();
|
|
945
|
-
}
|
|
1089
|
+
};
|
|
1090
|
+
const callRender = (hostRef, instance, elm) => {
|
|
1091
|
+
try {
|
|
1092
|
+
instance = instance.render() ;
|
|
1093
|
+
{
|
|
1094
|
+
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
1095
|
+
}
|
|
1096
|
+
{
|
|
1097
|
+
hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
|
|
1098
|
+
}
|
|
1099
|
+
{
|
|
1100
|
+
{
|
|
1101
|
+
// looks like we've got child nodes to render into this host element
|
|
1102
|
+
// or we need to update the css class/attrs on the host element
|
|
1103
|
+
// DOM WRITE!
|
|
1104
|
+
{
|
|
1105
|
+
renderVdom(hostRef, instance);
|
|
946
1106
|
}
|
|
947
1107
|
}
|
|
948
1108
|
}
|
|
949
1109
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
vnode.$elm$ = node;
|
|
953
|
-
vnode.$index$ = '0';
|
|
954
|
-
parentVNode.$children$ = [vnode];
|
|
1110
|
+
catch (e) {
|
|
1111
|
+
consoleError(e, hostRef.$hostElement$);
|
|
955
1112
|
}
|
|
1113
|
+
return null;
|
|
956
1114
|
};
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
1115
|
+
const postUpdateComponent = (hostRef) => {
|
|
1116
|
+
const tagName = hostRef.$cmpMeta$.$tagName$;
|
|
1117
|
+
const elm = hostRef.$hostElement$;
|
|
1118
|
+
const endPostUpdate = createTime('postUpdate', tagName);
|
|
1119
|
+
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1120
|
+
if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
|
|
1121
|
+
hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
|
|
1122
|
+
{
|
|
1123
|
+
// DOM WRITE!
|
|
1124
|
+
addHydratedFlag(elm);
|
|
962
1125
|
}
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
1126
|
+
endPostUpdate();
|
|
1127
|
+
{
|
|
1128
|
+
hostRef.$onReadyResolve$(elm);
|
|
1129
|
+
if (!ancestorComponent) {
|
|
1130
|
+
appDidLoad();
|
|
966
1131
|
}
|
|
967
1132
|
}
|
|
968
1133
|
}
|
|
969
|
-
else
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1134
|
+
else {
|
|
1135
|
+
endPostUpdate();
|
|
1136
|
+
}
|
|
1137
|
+
{
|
|
1138
|
+
hostRef.$onInstanceResolve$(elm);
|
|
1139
|
+
}
|
|
1140
|
+
// load events fire from bottom to top
|
|
1141
|
+
// the deepest elements load first then bubbles up
|
|
1142
|
+
{
|
|
1143
|
+
if (hostRef.$onRenderResolve$) {
|
|
1144
|
+
hostRef.$onRenderResolve$();
|
|
1145
|
+
hostRef.$onRenderResolve$ = undefined;
|
|
1146
|
+
}
|
|
1147
|
+
if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
|
|
1148
|
+
nextTick(() => scheduleUpdate(hostRef, false));
|
|
977
1149
|
}
|
|
1150
|
+
hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
|
|
978
1151
|
}
|
|
1152
|
+
// ( •_•)
|
|
1153
|
+
// ( •_•)>⌐■-■
|
|
1154
|
+
// (⌐■_■)
|
|
979
1155
|
};
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
* based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
|
|
993
|
-
* ```tsx
|
|
994
|
-
* <my-cmp prop-val={0}></my-cmp>
|
|
995
|
-
* ```
|
|
996
|
-
*
|
|
997
|
-
* HTML prop values on the other hand, will always a string
|
|
998
|
-
*
|
|
999
|
-
* @param propValue the new value to coerce to some type
|
|
1000
|
-
* @param propType the type of the prop, expressed as a binary number
|
|
1001
|
-
* @returns the parsed/coerced value
|
|
1002
|
-
*/
|
|
1003
|
-
const parsePropertyValue = (propValue, propType) => {
|
|
1004
|
-
// ensure this value is of the correct prop type
|
|
1005
|
-
if (propValue != null && !isComplexType(propValue)) {
|
|
1006
|
-
if (propType & 4 /* Boolean */) {
|
|
1007
|
-
// per the HTML spec, any string value means it is a boolean true value
|
|
1008
|
-
// but we'll cheat here and say that the string "false" is the boolean false
|
|
1009
|
-
return propValue === 'false' ? false : propValue === '' || !!propValue;
|
|
1010
|
-
}
|
|
1011
|
-
if (propType & 2 /* Number */) {
|
|
1012
|
-
// force it to be a number
|
|
1013
|
-
return parseFloat(propValue);
|
|
1156
|
+
const appDidLoad = (who) => {
|
|
1157
|
+
// on appload
|
|
1158
|
+
// we have finish the first big initial render
|
|
1159
|
+
{
|
|
1160
|
+
addHydratedFlag(doc.documentElement);
|
|
1161
|
+
}
|
|
1162
|
+
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
1163
|
+
};
|
|
1164
|
+
const safeCall = (instance, method, arg) => {
|
|
1165
|
+
if (instance && instance[method]) {
|
|
1166
|
+
try {
|
|
1167
|
+
return instance[method](arg);
|
|
1014
1168
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
// but we still want it as a string
|
|
1018
|
-
return String(propValue);
|
|
1169
|
+
catch (e) {
|
|
1170
|
+
consoleError(e);
|
|
1019
1171
|
}
|
|
1020
|
-
// redundant return here for better minification
|
|
1021
|
-
return propValue;
|
|
1022
1172
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1173
|
+
return undefined;
|
|
1174
|
+
};
|
|
1175
|
+
const then = (promise, thenFn) => {
|
|
1176
|
+
return promise && promise.then ? promise.then(thenFn) : thenFn();
|
|
1026
1177
|
};
|
|
1178
|
+
const addHydratedFlag = (elm) => elm.classList.add('hydrated')
|
|
1179
|
+
;
|
|
1027
1180
|
const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
1028
1181
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
1029
1182
|
// check our new property value against our internal value
|
|
@@ -1035,12 +1188,12 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1035
1188
|
// explicitly check for NaN on both sides, as `NaN === NaN` is always false
|
|
1036
1189
|
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
1037
1190
|
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
1038
|
-
if ((!(flags & 8 /* isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1191
|
+
if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
|
|
1039
1192
|
// gadzooks! the property's value has changed!!
|
|
1040
1193
|
// set our new value!
|
|
1041
1194
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
1042
1195
|
if (instance) {
|
|
1043
|
-
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
1196
|
+
if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
|
|
1044
1197
|
// looks like this value actually changed, so we've got work to do!
|
|
1045
1198
|
// but only if we've already rendered, otherwise just chill out
|
|
1046
1199
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -1050,14 +1203,24 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
1050
1203
|
}
|
|
1051
1204
|
}
|
|
1052
1205
|
};
|
|
1206
|
+
/**
|
|
1207
|
+
* Attach a series of runtime constructs to a compiled Stencil component
|
|
1208
|
+
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
1209
|
+
* decorators, callbacks for when attributes change, and so on.
|
|
1210
|
+
*
|
|
1211
|
+
* @param Cstr the constructor for a component that we need to process
|
|
1212
|
+
* @param cmpMeta metadata collected previously about the component
|
|
1213
|
+
* @param flags a number used to store a series of bit flags
|
|
1214
|
+
* @returns a reference to the same constructor passed in (but now mutated)
|
|
1215
|
+
*/
|
|
1053
1216
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
1054
1217
|
if (cmpMeta.$members$) {
|
|
1055
1218
|
// It's better to have a const than two Object.entries()
|
|
1056
1219
|
const members = Object.entries(cmpMeta.$members$);
|
|
1057
1220
|
const prototype = Cstr.prototype;
|
|
1058
1221
|
members.map(([memberName, [memberFlags]]) => {
|
|
1059
|
-
if ((memberFlags & 31 /* Prop */ ||
|
|
1060
|
-
((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
|
|
1222
|
+
if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
|
|
1223
|
+
((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
|
|
1061
1224
|
// proxyComponent - prop
|
|
1062
1225
|
Object.defineProperty(prototype, memberName, {
|
|
1063
1226
|
get() {
|
|
@@ -1072,8 +1235,18 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1072
1235
|
enumerable: true,
|
|
1073
1236
|
});
|
|
1074
1237
|
}
|
|
1238
|
+
else if (flags & 1 /* PROXY_FLAGS.isElementConstructor */ &&
|
|
1239
|
+
memberFlags & 64 /* MEMBER_FLAGS.Method */) {
|
|
1240
|
+
// proxyComponent - method
|
|
1241
|
+
Object.defineProperty(prototype, memberName, {
|
|
1242
|
+
value(...args) {
|
|
1243
|
+
const ref = getHostRef(this);
|
|
1244
|
+
return ref.$onInstancePromise$.then(() => ref.$lazyInstance$[memberName](...args));
|
|
1245
|
+
},
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1075
1248
|
});
|
|
1076
|
-
if ((flags & 1 /* isElementConstructor */)) {
|
|
1249
|
+
if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
|
|
1077
1250
|
const attrNameToPropName = new Map();
|
|
1078
1251
|
prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
|
|
1079
1252
|
plt.jmp(() => {
|
|
@@ -1129,7 +1302,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1129
1302
|
// create an array of attributes to observe
|
|
1130
1303
|
// and also create a map of html attribute name to js property name
|
|
1131
1304
|
Cstr.observedAttributes = members
|
|
1132
|
-
.filter(([_, m]) => m[0] & 15 /* HasAttribute */) // filter to only keep props that should match attributes
|
|
1305
|
+
.filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */) // filter to only keep props that should match attributes
|
|
1133
1306
|
.map(([propName, m]) => {
|
|
1134
1307
|
const attrName = m[1] || propName;
|
|
1135
1308
|
attrNameToPropName.set(attrName, propName);
|
|
@@ -1141,10 +1314,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1141
1314
|
};
|
|
1142
1315
|
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) => {
|
|
1143
1316
|
// initializeComponent
|
|
1144
|
-
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1317
|
+
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1145
1318
|
{
|
|
1146
1319
|
// we haven't initialized this element yet
|
|
1147
|
-
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1320
|
+
hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
|
|
1148
1321
|
// lazy loaded components
|
|
1149
1322
|
// request the component's implementation to be
|
|
1150
1323
|
// wired up with the host element
|
|
@@ -1156,7 +1329,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1156
1329
|
endLoad();
|
|
1157
1330
|
}
|
|
1158
1331
|
if (!Cstr.isProxied) {
|
|
1159
|
-
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
1332
|
+
proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
|
|
1160
1333
|
Cstr.isProxied = true;
|
|
1161
1334
|
}
|
|
1162
1335
|
const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
|
|
@@ -1164,7 +1337,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1164
1337
|
// but let's keep track of when we start and stop
|
|
1165
1338
|
// so that the getters/setters don't incorrectly step on data
|
|
1166
1339
|
{
|
|
1167
|
-
hostRef.$flags$ |= 8 /* isConstructingInstance */;
|
|
1340
|
+
hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1168
1341
|
}
|
|
1169
1342
|
// construct the lazy-loaded component implementation
|
|
1170
1343
|
// passing the hostRef is very important during
|
|
@@ -1177,7 +1350,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1177
1350
|
consoleError(e);
|
|
1178
1351
|
}
|
|
1179
1352
|
{
|
|
1180
|
-
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1353
|
+
hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
|
|
1181
1354
|
}
|
|
1182
1355
|
endNewInstance();
|
|
1183
1356
|
}
|
|
@@ -1187,7 +1360,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1187
1360
|
const scopeId = getScopeId(cmpMeta);
|
|
1188
1361
|
if (!styles.has(scopeId)) {
|
|
1189
1362
|
const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
|
|
1190
|
-
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1363
|
+
registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
|
|
1191
1364
|
endRegisterStyles();
|
|
1192
1365
|
}
|
|
1193
1366
|
}
|
|
@@ -1209,18 +1382,18 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1209
1382
|
}
|
|
1210
1383
|
};
|
|
1211
1384
|
const connectedCallback = (elm) => {
|
|
1212
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1385
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1213
1386
|
const hostRef = getHostRef(elm);
|
|
1214
1387
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1215
1388
|
const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
|
|
1216
|
-
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1389
|
+
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1217
1390
|
// first time this component has connected
|
|
1218
|
-
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1391
|
+
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1219
1392
|
let hostId;
|
|
1220
1393
|
{
|
|
1221
1394
|
hostId = elm.getAttribute(HYDRATE_ID);
|
|
1222
1395
|
if (hostId) {
|
|
1223
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1396
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1224
1397
|
const scopeId = addStyle(elm.shadowRoot, cmpMeta);
|
|
1225
1398
|
elm.classList.remove(scopeId + '-h', scopeId + '-s');
|
|
1226
1399
|
}
|
|
@@ -1234,7 +1407,7 @@ const connectedCallback = (elm) => {
|
|
|
1234
1407
|
while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
|
|
1235
1408
|
// climb up the ancestors looking for the first
|
|
1236
1409
|
// component that hasn't finished its lifecycle update yet
|
|
1237
|
-
if ((ancestorComponent.nodeType === 1 /* ElementNode */ &&
|
|
1410
|
+
if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
|
|
1238
1411
|
ancestorComponent.hasAttribute('s-id') &&
|
|
1239
1412
|
ancestorComponent['s-p']) ||
|
|
1240
1413
|
ancestorComponent['s-p']) {
|
|
@@ -1249,7 +1422,7 @@ const connectedCallback = (elm) => {
|
|
|
1249
1422
|
// https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
|
|
1250
1423
|
if (cmpMeta.$members$) {
|
|
1251
1424
|
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1252
|
-
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1425
|
+
if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1253
1426
|
const value = elm[memberName];
|
|
1254
1427
|
delete elm[memberName];
|
|
1255
1428
|
elm[memberName] = value;
|
|
@@ -1260,12 +1433,24 @@ const connectedCallback = (elm) => {
|
|
|
1260
1433
|
initializeComponent(elm, hostRef, cmpMeta);
|
|
1261
1434
|
}
|
|
1262
1435
|
}
|
|
1436
|
+
else {
|
|
1437
|
+
// not the first time this has connected
|
|
1438
|
+
// reattach any event listeners to the host
|
|
1439
|
+
// since they would have been removed when disconnected
|
|
1440
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1441
|
+
}
|
|
1263
1442
|
endConnected();
|
|
1264
1443
|
}
|
|
1265
1444
|
};
|
|
1266
1445
|
const disconnectedCallback = (elm) => {
|
|
1267
|
-
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1268
|
-
getHostRef(elm);
|
|
1446
|
+
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1447
|
+
const hostRef = getHostRef(elm);
|
|
1448
|
+
{
|
|
1449
|
+
if (hostRef.$rmListeners$) {
|
|
1450
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
1451
|
+
hostRef.$rmListeners$ = undefined;
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1269
1454
|
}
|
|
1270
1455
|
};
|
|
1271
1456
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
@@ -1286,7 +1471,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1286
1471
|
{
|
|
1287
1472
|
// If the app is already hydrated there is not point to disable the
|
|
1288
1473
|
// async queue. This will improve the first input delay
|
|
1289
|
-
plt.$flags$ |= 2 /* appLoaded */;
|
|
1474
|
+
plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
|
|
1290
1475
|
}
|
|
1291
1476
|
{
|
|
1292
1477
|
for (; i < styles.length; i++) {
|
|
@@ -1304,6 +1489,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1304
1489
|
{
|
|
1305
1490
|
cmpMeta.$members$ = compactMeta[2];
|
|
1306
1491
|
}
|
|
1492
|
+
{
|
|
1493
|
+
cmpMeta.$listeners$ = compactMeta[3];
|
|
1494
|
+
}
|
|
1307
1495
|
const tagName = cmpMeta.$tagName$;
|
|
1308
1496
|
const HostElement = class extends HTMLElement {
|
|
1309
1497
|
// StencilLazyHost
|
|
@@ -1312,7 +1500,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1312
1500
|
super(self);
|
|
1313
1501
|
self = this;
|
|
1314
1502
|
registerHost(self, cmpMeta);
|
|
1315
|
-
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
1503
|
+
if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
|
|
1316
1504
|
// this component is using shadow dom
|
|
1317
1505
|
// and this browser supports shadow dom
|
|
1318
1506
|
// add the read-only property "shadowRoot" to the host element
|
|
@@ -1347,7 +1535,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1347
1535
|
cmpMeta.$lazyBundleId$ = lazyBundle[0];
|
|
1348
1536
|
if (!exclude.includes(tagName) && !customElements.get(tagName)) {
|
|
1349
1537
|
cmpTags.push(tagName);
|
|
1350
|
-
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* isElementConstructor */));
|
|
1538
|
+
customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
|
|
1351
1539
|
}
|
|
1352
1540
|
});
|
|
1353
1541
|
});
|
|
@@ -1369,11 +1557,36 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1369
1557
|
// Fallback appLoad event
|
|
1370
1558
|
endBootstrap();
|
|
1371
1559
|
};
|
|
1372
|
-
const
|
|
1373
|
-
|
|
1374
|
-
|
|
1560
|
+
const addHostEventListeners = (elm, hostRef, listeners, attachParentListeners) => {
|
|
1561
|
+
if (listeners) {
|
|
1562
|
+
listeners.map(([flags, name, method]) => {
|
|
1563
|
+
const target = elm;
|
|
1564
|
+
const handler = hostListenerProxy(hostRef, method);
|
|
1565
|
+
const opts = hostListenerOpts(flags);
|
|
1566
|
+
plt.ael(target, name, handler, opts);
|
|
1567
|
+
(hostRef.$rmListeners$ = hostRef.$rmListeners$ || []).push(() => plt.rel(target, name, handler, opts));
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
1572
|
+
try {
|
|
1573
|
+
{
|
|
1574
|
+
if (hostRef.$flags$ & 256 /* HOST_FLAGS.isListenReady */) {
|
|
1575
|
+
// instance is ready, let's call it's member method for this event
|
|
1576
|
+
hostRef.$lazyInstance$[methodName](ev);
|
|
1577
|
+
}
|
|
1578
|
+
else {
|
|
1579
|
+
(hostRef.$queuedListeners$ = hostRef.$queuedListeners$ || []).push([methodName, ev]);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
catch (e) {
|
|
1584
|
+
consoleError(e);
|
|
1585
|
+
}
|
|
1375
1586
|
};
|
|
1376
|
-
|
|
1587
|
+
// prettier-ignore
|
|
1588
|
+
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1589
|
+
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1377
1590
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1378
1591
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
1379
1592
|
const registerHost = (elm, cmpMeta) => {
|
|
@@ -1383,11 +1596,15 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
1383
1596
|
$cmpMeta$: cmpMeta,
|
|
1384
1597
|
$instanceValues$: new Map(),
|
|
1385
1598
|
};
|
|
1599
|
+
{
|
|
1600
|
+
hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
|
|
1601
|
+
}
|
|
1386
1602
|
{
|
|
1387
1603
|
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
|
1388
1604
|
elm['s-p'] = [];
|
|
1389
1605
|
elm['s-rc'] = [];
|
|
1390
1606
|
}
|
|
1607
|
+
addHostEventListeners(elm, hostRef, cmpMeta.$listeners$);
|
|
1391
1608
|
return hostRefs.set(elm, hostRef);
|
|
1392
1609
|
};
|
|
1393
1610
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
@@ -1414,14 +1631,36 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
|
|
|
1414
1631
|
return importedModule[exportName];
|
|
1415
1632
|
}, consoleError);
|
|
1416
1633
|
};
|
|
1417
|
-
const styles = new Map();
|
|
1634
|
+
const styles = /*@__PURE__*/ new Map();
|
|
1635
|
+
const win = typeof window !== 'undefined' ? window : {};
|
|
1636
|
+
const doc = win.document || { head: {} };
|
|
1637
|
+
const plt = {
|
|
1638
|
+
$flags$: 0,
|
|
1639
|
+
$resourcesUrl$: '',
|
|
1640
|
+
jmp: (h) => h(),
|
|
1641
|
+
raf: (h) => requestAnimationFrame(h),
|
|
1642
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
1643
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
1644
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts),
|
|
1645
|
+
};
|
|
1646
|
+
const supportsShadow = true;
|
|
1647
|
+
const promiseResolve = (v) => Promise.resolve(v);
|
|
1648
|
+
const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
|
|
1649
|
+
try {
|
|
1650
|
+
new CSSStyleSheet();
|
|
1651
|
+
return typeof new CSSStyleSheet().replaceSync === 'function';
|
|
1652
|
+
}
|
|
1653
|
+
catch (e) { }
|
|
1654
|
+
return false;
|
|
1655
|
+
})()
|
|
1656
|
+
;
|
|
1418
1657
|
const queueDomReads = [];
|
|
1419
1658
|
const queueDomWrites = [];
|
|
1420
1659
|
const queueTask = (queue, write) => (cb) => {
|
|
1421
1660
|
queue.push(cb);
|
|
1422
1661
|
if (!queuePending) {
|
|
1423
1662
|
queuePending = true;
|
|
1424
|
-
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
1663
|
+
if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
|
|
1425
1664
|
nextTick(flush);
|
|
1426
1665
|
}
|
|
1427
1666
|
else {
|