@content-blocks/js 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/content-accordion.cjs.entry.js +1 -1
- package/dist/cjs/content-blocks.cjs.js +2 -2
- package/dist/cjs/content-blocks.cjs.js.map +1 -1
- package/dist/cjs/content-button_10.cjs.entry.js +1 -1
- package/dist/cjs/content-button_10.cjs.entry.js.map +1 -1
- package/dist/cjs/{content-carousel-c8e0a9a9.js → content-carousel-d866cb77.js} +27 -22
- package/dist/cjs/content-carousel-d866cb77.js.map +1 -0
- package/dist/cjs/content-carousel.cjs.entry.js +2 -2
- package/dist/cjs/content-navigation-block.cjs.entry.js +4 -6
- package/dist/cjs/content-navigation-block.cjs.entry.js.map +1 -1
- package/dist/cjs/content-split-block.cjs.entry.js +1 -1
- package/dist/cjs/content-split-block.cjs.entry.js.map +1 -1
- package/dist/cjs/content-tabs.cjs.entry.js +1 -1
- package/dist/cjs/{index-e93f381a.js → index-239b1c46.js} +232 -102
- package/dist/cjs/index-239b1c46.js.map +1 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{swiper-d0296c76.js → swiper-2fe1b80b.js} +421 -149
- package/dist/cjs/swiper-2fe1b80b.js.map +1 -0
- package/dist/collection/blocks/content-hero-block/content-hero-block.js.map +1 -1
- package/dist/collection/blocks/content-split-block/content-split-block.js.map +1 -1
- package/dist/collection/blocks/content-text-block/content-text-block.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/content-carousel/content-carousel.css +3 -3
- package/dist/collection/components/content-navigation-block/content-navigation-block.js +3 -5
- package/dist/collection/components/content-navigation-block/content-navigation-block.js.map +1 -1
- package/dist/collection/elements/content-button/content-button.js.map +1 -1
- package/dist/collection/elements/content-line/content-line.js.map +1 -1
- package/dist/collection/elements/content-video/content-video.js.map +1 -1
- package/dist/collection/formatters/content-grid-formatter/content-grid-formatter.js.map +1 -1
- package/dist/components/content-button.js.map +1 -1
- package/dist/components/content-carousel.js +24 -20
- package/dist/components/content-carousel.js.map +1 -1
- package/dist/components/content-grid-formatter2.js.map +1 -1
- package/dist/components/content-hero-block.js.map +1 -1
- package/dist/components/content-line.js.map +1 -1
- package/dist/components/content-navigation-block.js +3 -5
- package/dist/components/content-navigation-block.js.map +1 -1
- package/dist/components/content-split-block.js.map +1 -1
- package/dist/components/content-text-block.js.map +1 -1
- package/dist/components/content-video.js.map +1 -1
- package/dist/components/swiper.js +419 -147
- package/dist/components/swiper.js.map +1 -1
- package/dist/content-blocks/content-blocks.esm.js +1 -1
- package/dist/content-blocks/content-blocks.esm.js.map +1 -1
- package/dist/content-blocks/p-08143d3f.js +2 -0
- package/dist/content-blocks/p-08143d3f.js.map +1 -0
- package/dist/content-blocks/{p-057c0e4d.entry.js → p-14dd6549.entry.js} +2 -2
- package/dist/content-blocks/p-14dd6549.entry.js.map +1 -0
- package/dist/content-blocks/{p-b1300b9a.entry.js → p-1947500c.entry.js} +2 -2
- package/dist/content-blocks/p-1947500c.entry.js.map +1 -0
- package/dist/content-blocks/p-26ff44fc.js +6 -6
- package/dist/content-blocks/{p-01952c81.entry.js → p-3732482d.entry.js} +2 -2
- package/dist/content-blocks/p-3732482d.entry.js.map +1 -0
- package/dist/content-blocks/p-3b4be54b.js +2 -0
- package/dist/content-blocks/p-3b4be54b.js.map +1 -0
- package/dist/content-blocks/{p-914e3550.entry.js → p-8d44f285.entry.js} +2 -2
- package/dist/content-blocks/p-a802c984.entry.js +2 -0
- package/dist/content-blocks/{p-2ec7fda2.entry.js → p-b27f84ad.entry.js} +2 -2
- package/dist/content-blocks/p-dc53dda7.js +3 -0
- package/dist/content-blocks/p-dc53dda7.js.map +1 -0
- package/dist/esm/content-accordion.entry.js +1 -1
- package/dist/esm/content-blocks.js +3 -3
- package/dist/esm/content-blocks.js.map +1 -1
- package/dist/esm/content-button_10.entry.js +1 -1
- package/dist/esm/content-button_10.entry.js.map +1 -1
- package/dist/esm/{content-carousel-f971cfcd.js → content-carousel-af580def.js} +27 -23
- package/dist/esm/content-carousel-af580def.js.map +1 -0
- package/dist/esm/content-carousel.entry.js +2 -2
- package/dist/esm/content-navigation-block.entry.js +4 -6
- package/dist/esm/content-navigation-block.entry.js.map +1 -1
- package/dist/esm/content-split-block.entry.js +1 -1
- package/dist/esm/content-split-block.entry.js.map +1 -1
- package/dist/esm/content-tabs.entry.js +1 -1
- package/dist/esm/{index-9501de67.js → index-6e48707b.js} +232 -102
- package/dist/esm/index-6e48707b.js.map +1 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/{swiper-7d87458d.js → swiper-3d1a80cc.js} +421 -149
- package/dist/esm/swiper-3d1a80cc.js.map +1 -0
- package/dist/types/blocks/content-hero-block/content-hero-block.d.ts +0 -2
- package/dist/types/blocks/content-text-block/content-text-block.d.ts +0 -2
- package/dist/types/components/content-navigation-block/content-navigation-block.d.ts +0 -2
- package/dist/types/components.d.ts +11 -0
- package/dist/types/elements/content-button/content-button.d.ts +0 -2
- package/dist/types/elements/content-line/content-line.d.ts +0 -2
- package/dist/types/elements/content-video/content-video.d.ts +0 -2
- package/dist/types/formatters/content-grid-formatter/content-grid-formatter.d.ts +0 -2
- package/dist/types/stencil-public-runtime.d.ts +21 -0
- package/package.json +11 -11
- package/dist/cjs/content-carousel-c8e0a9a9.js.map +0 -1
- package/dist/cjs/index-e93f381a.js.map +0 -1
- package/dist/cjs/swiper-d0296c76.js.map +0 -1
- package/dist/content-blocks/p-01952c81.entry.js.map +0 -1
- package/dist/content-blocks/p-057c0e4d.entry.js.map +0 -1
- package/dist/content-blocks/p-3f3a30b1.entry.js +0 -2
- package/dist/content-blocks/p-8a8f13fb.js +0 -2
- package/dist/content-blocks/p-8a8f13fb.js.map +0 -1
- package/dist/content-blocks/p-b1300b9a.entry.js.map +0 -1
- package/dist/content-blocks/p-cd3c0fce.js +0 -3
- package/dist/content-blocks/p-cd3c0fce.js.map +0 -1
- package/dist/content-blocks/p-d8dc8d1e.js +0 -2
- package/dist/content-blocks/p-d8dc8d1e.js.map +0 -1
- package/dist/esm/content-carousel-f971cfcd.js.map +0 -1
- package/dist/esm/index-9501de67.js.map +0 -1
- package/dist/esm/swiper-7d87458d.js.map +0 -1
- /package/dist/content-blocks/{p-914e3550.entry.js.map → p-8d44f285.entry.js.map} +0 -0
- /package/dist/content-blocks/{p-3f3a30b1.entry.js.map → p-a802c984.entry.js.map} +0 -0
- /package/dist/content-blocks/{p-2ec7fda2.entry.js.map → p-b27f84ad.entry.js.map} +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const NAMESPACE = 'content-blocks';
|
|
2
|
+
const BUILD = /* content-blocks */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: true, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: true, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: true, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: true, hostListenerTarget: true, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: true, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: true, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: false, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: false, watchCallback: true };
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Virtual DOM patching algorithm based on Snabbdom by
|
|
@@ -449,11 +450,19 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
449
450
|
// except for the first character, we keep the event name case
|
|
450
451
|
memberName = ln[2] + memberName.slice(3);
|
|
451
452
|
}
|
|
452
|
-
if (oldValue) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
453
|
+
if (oldValue || newValue) {
|
|
454
|
+
// Need to account for "capture" events.
|
|
455
|
+
// If the event name ends with "Capture", we'll update the name to remove
|
|
456
|
+
// the "Capture" suffix and make sure the event listener is setup to handle the capture event.
|
|
457
|
+
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
|
458
|
+
// Make sure we only replace the last instance of "Capture"
|
|
459
|
+
memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
|
|
460
|
+
if (oldValue) {
|
|
461
|
+
plt.rel(elm, memberName, oldValue, capture);
|
|
462
|
+
}
|
|
463
|
+
if (newValue) {
|
|
464
|
+
plt.ael(elm, memberName, newValue, capture);
|
|
465
|
+
}
|
|
457
466
|
}
|
|
458
467
|
}
|
|
459
468
|
else {
|
|
@@ -495,6 +504,8 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
495
504
|
};
|
|
496
505
|
const parseClassListRegex = /\s/;
|
|
497
506
|
const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
|
|
507
|
+
const CAPTURE_EVENT_SUFFIX = 'Capture';
|
|
508
|
+
const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
|
|
498
509
|
const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
499
510
|
// if the element passed in is a shadow root, which is a document fragment
|
|
500
511
|
// then we want to be adding attrs/props to the shadow root's "host" element
|
|
@@ -528,6 +539,7 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
|
|
|
528
539
|
* @returns the newly created node
|
|
529
540
|
*/
|
|
530
541
|
const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
542
|
+
var _a;
|
|
531
543
|
// tslint:disable-next-line: prefer-const
|
|
532
544
|
const newVNode = newParentVNode.$children$[childIndex];
|
|
533
545
|
let i = 0;
|
|
@@ -580,6 +592,8 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
580
592
|
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
581
593
|
// remember the content reference comment
|
|
582
594
|
elm['s-sr'] = true;
|
|
595
|
+
// Persist the name of the slot that this slot was going to be projected into.
|
|
596
|
+
elm['s-fs'] = (_a = newVNode.$attrs$) === null || _a === void 0 ? void 0 : _a.slot;
|
|
583
597
|
// remember the content reference comment
|
|
584
598
|
elm['s-cr'] = contentRef;
|
|
585
599
|
// remember the slot name, or empty string for default slot
|
|
@@ -596,6 +610,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
596
610
|
return elm;
|
|
597
611
|
};
|
|
598
612
|
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
613
|
+
var _a;
|
|
599
614
|
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
600
615
|
const oldSlotChildNodes = parentElm.childNodes;
|
|
601
616
|
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
@@ -608,9 +623,17 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
|
608
623
|
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
609
624
|
// remove the old original location comment entirely
|
|
610
625
|
// later on the patch function will know what to do
|
|
611
|
-
// and move this to the correct spot
|
|
626
|
+
// and move this to the correct spot if need be
|
|
612
627
|
childNode['s-ol'].remove();
|
|
613
628
|
childNode['s-ol'] = undefined;
|
|
629
|
+
// Reset so we can correctly move the node around again.
|
|
630
|
+
childNode['s-sh'] = undefined;
|
|
631
|
+
// When putting an element node back in its original location,
|
|
632
|
+
// we need to reset the `slot` attribute back to the value it originally had
|
|
633
|
+
// so we can correctly relocate it again in the future
|
|
634
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
635
|
+
childNode.setAttribute('slot', (_a = childNode['s-sn']) !== null && _a !== void 0 ? _a : '');
|
|
636
|
+
}
|
|
614
637
|
checkSlotRelocate = true;
|
|
615
638
|
}
|
|
616
639
|
if (recursive) {
|
|
@@ -983,42 +1006,53 @@ const patch = (oldVNode, newVNode) => {
|
|
|
983
1006
|
elm.data = text;
|
|
984
1007
|
}
|
|
985
1008
|
};
|
|
1009
|
+
/**
|
|
1010
|
+
* Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
|
|
1011
|
+
* are slot fallbacks nodes.
|
|
1012
|
+
*
|
|
1013
|
+
* A slot fallback node should be visible by default. Then, it should be
|
|
1014
|
+
* conditionally hidden if:
|
|
1015
|
+
*
|
|
1016
|
+
* - it has a sibling with a `slot` property set to its slot name or if
|
|
1017
|
+
* - it is a default fallback slot node, in which case we hide if it has any
|
|
1018
|
+
* content
|
|
1019
|
+
*
|
|
1020
|
+
* @param elm the element of interest
|
|
1021
|
+
*/
|
|
986
1022
|
const updateFallbackSlotVisibility = (elm) => {
|
|
987
|
-
// tslint:disable-next-line: prefer-const
|
|
988
1023
|
const childNodes = elm.childNodes;
|
|
989
|
-
|
|
990
|
-
let i;
|
|
991
|
-
let ilen;
|
|
992
|
-
let j;
|
|
993
|
-
let slotNameAttr;
|
|
994
|
-
let nodeType;
|
|
995
|
-
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
996
|
-
childNode = childNodes[i];
|
|
1024
|
+
for (const childNode of childNodes) {
|
|
997
1025
|
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
998
1026
|
if (childNode['s-sr']) {
|
|
999
1027
|
// this is a slot fallback node
|
|
1000
1028
|
// get the slot name for this slot reference node
|
|
1001
|
-
|
|
1029
|
+
const slotName = childNode['s-sn'];
|
|
1002
1030
|
// by default always show a fallback slot node
|
|
1003
1031
|
// then hide it if there are other slots in the light dom
|
|
1004
1032
|
childNode.hidden = false;
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1033
|
+
// we need to check all of its sibling nodes in order to see if
|
|
1034
|
+
// `childNode` should be hidden
|
|
1035
|
+
for (const siblingNode of childNodes) {
|
|
1036
|
+
// Don't check the node against itself
|
|
1037
|
+
if (siblingNode !== childNode) {
|
|
1038
|
+
if (siblingNode['s-hn'] !== childNode['s-hn'] || slotName !== '') {
|
|
1039
|
+
// this sibling node is from a different component OR is a named
|
|
1040
|
+
// fallback slot node
|
|
1041
|
+
if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
|
|
1042
|
+
(slotName === siblingNode.getAttribute('slot') || slotName === siblingNode['s-sn'])) {
|
|
1043
|
+
childNode.hidden = true;
|
|
1044
|
+
break;
|
|
1045
|
+
}
|
|
1012
1046
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1047
|
+
else {
|
|
1048
|
+
// this is a default fallback slot node
|
|
1049
|
+
// any element or text node (with content)
|
|
1050
|
+
// should hide the default fallback slot node
|
|
1051
|
+
if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
1052
|
+
(siblingNode.nodeType === 3 /* NODE_TYPE.TextNode */ && siblingNode.textContent.trim() !== '')) {
|
|
1053
|
+
childNode.hidden = true;
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1022
1056
|
}
|
|
1023
1057
|
}
|
|
1024
1058
|
}
|
|
@@ -1028,45 +1062,67 @@ const updateFallbackSlotVisibility = (elm) => {
|
|
|
1028
1062
|
}
|
|
1029
1063
|
}
|
|
1030
1064
|
};
|
|
1065
|
+
/**
|
|
1066
|
+
* Component-global information about nodes which are either currently being
|
|
1067
|
+
* relocated or will be shortly.
|
|
1068
|
+
*/
|
|
1031
1069
|
const relocateNodes = [];
|
|
1032
|
-
|
|
1070
|
+
/**
|
|
1071
|
+
* Mark the contents of a slot for relocation via adding references to them to
|
|
1072
|
+
* the {@link relocateNodes} data structure. The actual work of relocating them
|
|
1073
|
+
* will then be handled in {@link renderVdom}.
|
|
1074
|
+
*
|
|
1075
|
+
* @param elm a render node whose child nodes need to be relocated
|
|
1076
|
+
*/
|
|
1077
|
+
const markSlotContentForRelocation = (elm) => {
|
|
1033
1078
|
// tslint:disable-next-line: prefer-const
|
|
1034
|
-
let childNode;
|
|
1035
1079
|
let node;
|
|
1036
1080
|
let hostContentNodes;
|
|
1037
|
-
let slotNameAttr;
|
|
1038
|
-
let relocateNodeData;
|
|
1039
1081
|
let j;
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
for (; i < ilen; i++) {
|
|
1044
|
-
childNode = childNodes[i];
|
|
1082
|
+
for (const childNode of elm.childNodes) {
|
|
1083
|
+
// we need to find child nodes which are slot references so we can then try
|
|
1084
|
+
// to match them up with nodes that need to be relocated
|
|
1045
1085
|
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
1046
|
-
// first
|
|
1047
|
-
//
|
|
1086
|
+
// first get the content reference comment node ('s-cr'), then we get
|
|
1087
|
+
// its parent, which is where all the host content is now
|
|
1048
1088
|
hostContentNodes = node.parentNode.childNodes;
|
|
1049
|
-
|
|
1089
|
+
const slotName = childNode['s-sn'];
|
|
1090
|
+
// iterate through all the nodes under the location where the host was
|
|
1091
|
+
// originally rendered
|
|
1050
1092
|
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
1051
1093
|
node = hostContentNodes[j];
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1094
|
+
// check that the node is not a content reference node or a node
|
|
1095
|
+
// reference and then check that the host name does not match that of
|
|
1096
|
+
// childNode.
|
|
1097
|
+
// In addition, check that the slot either has not already been relocated, or
|
|
1098
|
+
// that its current location's host is not childNode's host. This is essentially
|
|
1099
|
+
// a check so that we don't try to relocate (and then hide) a node that is already
|
|
1100
|
+
// where it should be.
|
|
1101
|
+
if (!node['s-cn'] &&
|
|
1102
|
+
!node['s-nr'] &&
|
|
1103
|
+
node['s-hn'] !== childNode['s-hn'] &&
|
|
1104
|
+
(!BUILD.experimentalSlotFixes )) {
|
|
1105
|
+
// if `node` is located in the slot that `childNode` refers to (via the
|
|
1106
|
+
// `'s-sn'` property) then we need to relocate it from it's current spot
|
|
1107
|
+
// (under the host element parent) to the right slot location
|
|
1108
|
+
if (isNodeLocatedInSlot(node, slotName)) {
|
|
1057
1109
|
// it's possible we've already decided to relocate this node
|
|
1058
|
-
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1110
|
+
let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
1059
1111
|
// made some changes to slots
|
|
1060
1112
|
// let's make sure we also double check
|
|
1061
1113
|
// fallbacks are correctly hidden or shown
|
|
1062
1114
|
checkSlotFallbackVisibility = true;
|
|
1063
|
-
|
|
1115
|
+
// ensure that the slot-name attr is correct
|
|
1116
|
+
node['s-sn'] = node['s-sn'] || slotName;
|
|
1064
1117
|
if (relocateNodeData) {
|
|
1065
|
-
|
|
1066
|
-
//
|
|
1118
|
+
relocateNodeData.$nodeToRelocate$['s-sh'] = childNode['s-hn'];
|
|
1119
|
+
// we marked this node for relocation previously but didn't find
|
|
1120
|
+
// out the slot reference node to which it needs to be relocated
|
|
1121
|
+
// so write it down now!
|
|
1067
1122
|
relocateNodeData.$slotRefNode$ = childNode;
|
|
1068
1123
|
}
|
|
1069
1124
|
else {
|
|
1125
|
+
node['s-sh'] = childNode['s-hn'];
|
|
1070
1126
|
// add to our list of nodes to relocate
|
|
1071
1127
|
relocateNodes.push({
|
|
1072
1128
|
$slotRefNode$: childNode,
|
|
@@ -1085,8 +1141,10 @@ const relocateSlotContent = (elm) => {
|
|
|
1085
1141
|
}
|
|
1086
1142
|
}
|
|
1087
1143
|
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
1088
|
-
//
|
|
1089
|
-
//
|
|
1144
|
+
// the node is not found within the slot (`childNode`) that we're
|
|
1145
|
+
// currently looking at, so we stick it into `relocateNodes` to
|
|
1146
|
+
// handle later. If we never find a home for this element then
|
|
1147
|
+
// we'll need to hide it
|
|
1090
1148
|
relocateNodes.push({
|
|
1091
1149
|
$nodeToRelocate$: node,
|
|
1092
1150
|
});
|
|
@@ -1094,30 +1152,41 @@ const relocateSlotContent = (elm) => {
|
|
|
1094
1152
|
}
|
|
1095
1153
|
}
|
|
1096
1154
|
}
|
|
1155
|
+
// if we're dealing with any type of element (capable of itself being a
|
|
1156
|
+
// slot reference or containing one) then we recur
|
|
1097
1157
|
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1098
|
-
|
|
1158
|
+
markSlotContentForRelocation(childNode);
|
|
1099
1159
|
}
|
|
1100
1160
|
}
|
|
1101
1161
|
};
|
|
1102
|
-
|
|
1162
|
+
/**
|
|
1163
|
+
* Check whether a node is located in a given named slot.
|
|
1164
|
+
*
|
|
1165
|
+
* @param nodeToRelocate the node of interest
|
|
1166
|
+
* @param slotName the slot name to check
|
|
1167
|
+
* @returns whether the node is located in the slot or not
|
|
1168
|
+
*/
|
|
1169
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
|
|
1103
1170
|
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1104
|
-
if (nodeToRelocate.getAttribute('slot') === null &&
|
|
1171
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotName === '') {
|
|
1172
|
+
// if the node doesn't have a slot attribute, and the slot we're checking
|
|
1173
|
+
// is not a named slot, then we assume the node should be within the slot
|
|
1105
1174
|
return true;
|
|
1106
1175
|
}
|
|
1107
|
-
if (nodeToRelocate.getAttribute('slot') ===
|
|
1176
|
+
if (nodeToRelocate.getAttribute('slot') === slotName) {
|
|
1108
1177
|
return true;
|
|
1109
1178
|
}
|
|
1110
1179
|
return false;
|
|
1111
1180
|
}
|
|
1112
|
-
if (nodeToRelocate['s-sn'] ===
|
|
1181
|
+
if (nodeToRelocate['s-sn'] === slotName) {
|
|
1113
1182
|
return true;
|
|
1114
1183
|
}
|
|
1115
|
-
return
|
|
1184
|
+
return slotName === '';
|
|
1116
1185
|
};
|
|
1117
1186
|
/**
|
|
1118
|
-
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by
|
|
1119
|
-
*
|
|
1120
|
-
*
|
|
1187
|
+
* 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
|
|
1188
|
+
* them with `null`. This signals that the DOM element corresponding to the VDom
|
|
1189
|
+
* node has been removed from the DOM.
|
|
1121
1190
|
*
|
|
1122
1191
|
* @param vNode a virtual DOM node
|
|
1123
1192
|
*/
|
|
@@ -1141,6 +1210,7 @@ const nullifyVNodeRefs = (vNode) => {
|
|
|
1141
1210
|
* @param isInitialLoad whether or not this is the first call after page load
|
|
1142
1211
|
*/
|
|
1143
1212
|
const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
1213
|
+
var _a, _b;
|
|
1144
1214
|
const hostElm = hostRef.$hostElement$;
|
|
1145
1215
|
const cmpMeta = hostRef.$cmpMeta$;
|
|
1146
1216
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
@@ -1193,43 +1263,48 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
1193
1263
|
// the disconnectCallback from working
|
|
1194
1264
|
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1195
1265
|
if (checkSlotRelocate) {
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
let orgLocationNode;
|
|
1200
|
-
let parentNodeRef;
|
|
1201
|
-
let insertBeforeNode;
|
|
1202
|
-
let refNode;
|
|
1203
|
-
let i = 0;
|
|
1204
|
-
for (; i < relocateNodes.length; i++) {
|
|
1205
|
-
relocateData = relocateNodes[i];
|
|
1206
|
-
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1266
|
+
markSlotContentForRelocation(rootVnode.$elm$);
|
|
1267
|
+
for (const relocateData of relocateNodes) {
|
|
1268
|
+
const nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1207
1269
|
if (!nodeToRelocate['s-ol']) {
|
|
1208
1270
|
// add a reference node marking this node's original location
|
|
1209
1271
|
// keep a reference to this node for later lookups
|
|
1210
|
-
orgLocationNode =
|
|
1211
|
-
doc.createTextNode('');
|
|
1272
|
+
const orgLocationNode = doc.createTextNode('');
|
|
1212
1273
|
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
1213
1274
|
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1214
1275
|
}
|
|
1215
1276
|
}
|
|
1216
|
-
for (
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
if (
|
|
1220
|
-
|
|
1221
|
-
//
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1277
|
+
for (const relocateData of relocateNodes) {
|
|
1278
|
+
const nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1279
|
+
const slotRefNode = relocateData.$slotRefNode$;
|
|
1280
|
+
if (slotRefNode) {
|
|
1281
|
+
const parentNodeRef = slotRefNode.parentNode;
|
|
1282
|
+
// When determining where to insert content, the most simple case would be
|
|
1283
|
+
// to relocate the node immediately following the slot reference node. We do this
|
|
1284
|
+
// by getting a reference to the node immediately following the slot reference node
|
|
1285
|
+
// since we will use `insertBefore` to manipulate the DOM.
|
|
1286
|
+
//
|
|
1287
|
+
// If there is no node immediately following the slot reference node, then we will just
|
|
1288
|
+
// end up appending the node as the last child of the parent.
|
|
1289
|
+
let insertBeforeNode = slotRefNode.nextSibling;
|
|
1290
|
+
// If the node we're currently planning on inserting the new node before is an element,
|
|
1291
|
+
// we need to do some additional checks to make sure we're inserting the node in the correct order.
|
|
1292
|
+
// The use case here would be that we have multiple nodes being relocated to the same slot. So, we want
|
|
1293
|
+
// to make sure they get inserted into their new how in the same order they were declared in their original location.
|
|
1294
|
+
//
|
|
1295
|
+
// TODO(STENCIL-914): Remove `experimentalSlotFixes` check
|
|
1296
|
+
{
|
|
1297
|
+
let orgLocationNode = (_a = nodeToRelocate['s-ol']) === null || _a === void 0 ? void 0 : _a.previousSibling;
|
|
1298
|
+
while (orgLocationNode) {
|
|
1299
|
+
let refNode = (_b = orgLocationNode['s-nr']) !== null && _b !== void 0 ? _b : null;
|
|
1300
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
1301
|
+
refNode = refNode.nextSibling;
|
|
1302
|
+
if (!refNode || !refNode['s-nr']) {
|
|
1303
|
+
insertBeforeNode = refNode;
|
|
1304
|
+
break;
|
|
1305
|
+
}
|
|
1232
1306
|
}
|
|
1307
|
+
orgLocationNode = orgLocationNode.previousSibling;
|
|
1233
1308
|
}
|
|
1234
1309
|
}
|
|
1235
1310
|
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
@@ -1242,7 +1317,10 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
1242
1317
|
// probably a component in the index.html that doesn't have its hostname set
|
|
1243
1318
|
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1244
1319
|
}
|
|
1245
|
-
//
|
|
1320
|
+
// Add it back to the dom but in its new home
|
|
1321
|
+
// If we get to this point and `insertBeforeNode` is `null`, that means
|
|
1322
|
+
// we're just going to append the node as the last child of the parent. Passing
|
|
1323
|
+
// `null` as the second arg here will trigger that behavior.
|
|
1246
1324
|
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1247
1325
|
}
|
|
1248
1326
|
}
|
|
@@ -1422,6 +1500,10 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
|
1422
1500
|
*/
|
|
1423
1501
|
const callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
1424
1502
|
try {
|
|
1503
|
+
/**
|
|
1504
|
+
* minification optimization: `allRenderFn` is `true` if all components have a `render`
|
|
1505
|
+
* method, so we can call the method immediately. If not, check before calling it.
|
|
1506
|
+
*/
|
|
1425
1507
|
instance = instance.render() ;
|
|
1426
1508
|
{
|
|
1427
1509
|
hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
|
|
@@ -1501,6 +1583,16 @@ const appDidLoad = (who) => {
|
|
|
1501
1583
|
}
|
|
1502
1584
|
nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
|
|
1503
1585
|
};
|
|
1586
|
+
/**
|
|
1587
|
+
* Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
|
|
1588
|
+
* e.g. custom element node. If a build figures out that e.g. no component
|
|
1589
|
+
* has a `componentDidLoad` method, the instance method gets removed from the
|
|
1590
|
+
* output bundle and this function returns `undefined`.
|
|
1591
|
+
* @param instance any object that may or may not contain methods
|
|
1592
|
+
* @param method method name
|
|
1593
|
+
* @param arg single arbitrary argument
|
|
1594
|
+
* @returns result of method call if it exists, otherwise `undefined`
|
|
1595
|
+
*/
|
|
1504
1596
|
const safeCall = (instance, method, arg) => {
|
|
1505
1597
|
if (instance && instance[method]) {
|
|
1506
1598
|
try {
|
|
@@ -1701,7 +1793,18 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
1701
1793
|
}
|
|
1702
1794
|
return Cstr;
|
|
1703
1795
|
};
|
|
1704
|
-
|
|
1796
|
+
/**
|
|
1797
|
+
* Initialize a Stencil component given a reference to its host element, its
|
|
1798
|
+
* runtime bookkeeping data structure, runtime metadata about the component,
|
|
1799
|
+
* and (optionally) an HMR version ID.
|
|
1800
|
+
*
|
|
1801
|
+
* @param elm a host element
|
|
1802
|
+
* @param hostRef the element's runtime bookkeeping object
|
|
1803
|
+
* @param cmpMeta runtime metadata for the Stencil component
|
|
1804
|
+
* @param hmrVersionId an (optional) HMR version ID
|
|
1805
|
+
*/
|
|
1806
|
+
const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
1807
|
+
let Cstr;
|
|
1705
1808
|
// initializeComponent
|
|
1706
1809
|
if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
|
|
1707
1810
|
// Let the runtime know that the component has been initialized
|
|
@@ -2006,13 +2109,40 @@ const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !==
|
|
|
2006
2109
|
* @returns void
|
|
2007
2110
|
*/
|
|
2008
2111
|
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
2112
|
+
/**
|
|
2113
|
+
* A WeakMap mapping runtime component references to their corresponding host reference
|
|
2114
|
+
* instances.
|
|
2115
|
+
*/
|
|
2009
2116
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
2117
|
+
/**
|
|
2118
|
+
* Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
|
|
2119
|
+
*
|
|
2120
|
+
* @param ref the runtime ref of interest
|
|
2121
|
+
* @returns the Host reference (if found) or undefined
|
|
2122
|
+
*/
|
|
2010
2123
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
2124
|
+
/**
|
|
2125
|
+
* Register a lazy instance with the {@link hostRefs} object so it's
|
|
2126
|
+
* corresponding {@link d.HostRef} can be retrieved later.
|
|
2127
|
+
*
|
|
2128
|
+
* @param lazyInstance the lazy instance of interest
|
|
2129
|
+
* @param hostRef that instances `HostRef` object
|
|
2130
|
+
* @returns a reference to the host ref WeakMap
|
|
2131
|
+
*/
|
|
2011
2132
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
2012
|
-
|
|
2133
|
+
/**
|
|
2134
|
+
* Register a host element for a Stencil component, setting up various metadata
|
|
2135
|
+
* and callbacks based on {@link BUILD} flags as well as the component's runtime
|
|
2136
|
+
* metadata.
|
|
2137
|
+
*
|
|
2138
|
+
* @param hostElement the host element to register
|
|
2139
|
+
* @param cmpMeta runtime metadata for that component
|
|
2140
|
+
* @returns a reference to the host ref WeakMap
|
|
2141
|
+
*/
|
|
2142
|
+
const registerHost = (hostElement, cmpMeta) => {
|
|
2013
2143
|
const hostRef = {
|
|
2014
2144
|
$flags$: 0,
|
|
2015
|
-
$hostElement$:
|
|
2145
|
+
$hostElement$: hostElement,
|
|
2016
2146
|
$cmpMeta$: cmpMeta,
|
|
2017
2147
|
$instanceValues$: new Map(),
|
|
2018
2148
|
};
|
|
@@ -2021,11 +2151,11 @@ const registerHost = (elm, cmpMeta) => {
|
|
|
2021
2151
|
}
|
|
2022
2152
|
{
|
|
2023
2153
|
hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
|
|
2024
|
-
|
|
2025
|
-
|
|
2154
|
+
hostElement['s-p'] = [];
|
|
2155
|
+
hostElement['s-rc'] = [];
|
|
2026
2156
|
}
|
|
2027
|
-
addHostEventListeners(
|
|
2028
|
-
return hostRefs.set(
|
|
2157
|
+
addHostEventListeners(hostElement, hostRef, cmpMeta.$listeners$);
|
|
2158
|
+
return hostRefs.set(hostElement, hostRef);
|
|
2029
2159
|
};
|
|
2030
2160
|
const isMemberInElement = (elm, memberName) => memberName in elm;
|
|
2031
2161
|
const consoleError = (e, el) => (0, console.error)(e, el);
|
|
@@ -2118,4 +2248,4 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
|
2118
2248
|
|
|
2119
2249
|
export { Host as H, bootstrapLazy as b, createEvent as c, getElement as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
|
|
2120
2250
|
|
|
2121
|
-
//# sourceMappingURL=index-
|
|
2251
|
+
//# sourceMappingURL=index-6e48707b.js.map
|