@jumpgroup/jump-design-system 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/cjs/{index-46644e39.js → index-91a3ed32.js} +42 -448
  2. package/dist/cjs/index-91a3ed32.js.map +1 -0
  3. package/dist/cjs/jump-button.cjs.entry.js +3 -2
  4. package/dist/cjs/jump-button.cjs.entry.js.map +1 -1
  5. package/dist/cjs/jump-design-system.cjs.js +2 -2
  6. package/dist/cjs/jump-icon.cjs.entry.js +1 -1
  7. package/dist/cjs/jump-pagination.cjs.entry.js +1 -1
  8. package/dist/cjs/loader.cjs.js +2 -2
  9. package/dist/collection/components/jump-button/jump-button.js +21 -1
  10. package/dist/collection/components/jump-button/jump-button.js.map +1 -1
  11. package/dist/collection/components/jump-button/jump-button.stories.js +11 -4
  12. package/dist/collection/components/jump-button/jump-button.stories.js.map +1 -1
  13. package/dist/components/jump-button.js +6 -3
  14. package/dist/components/jump-button.js.map +1 -1
  15. package/dist/esm/{index-b0176170.js → index-3cf3394c.js} +42 -448
  16. package/dist/esm/index-3cf3394c.js.map +1 -0
  17. package/dist/esm/jump-button.entry.js +3 -2
  18. package/dist/esm/jump-button.entry.js.map +1 -1
  19. package/dist/esm/jump-design-system.js +3 -3
  20. package/dist/esm/jump-icon.entry.js +1 -1
  21. package/dist/esm/jump-pagination.entry.js +1 -1
  22. package/dist/esm/loader.js +3 -3
  23. package/dist/jump-design-system/jump-design-system.esm.js +1 -1
  24. package/dist/jump-design-system/jump-design-system.esm.js.map +1 -1
  25. package/dist/jump-design-system/p-7216d46f.js +3 -0
  26. package/dist/jump-design-system/p-7216d46f.js.map +1 -0
  27. package/dist/jump-design-system/{p-0d2b55a8.entry.js → p-85fbbf60.entry.js} +2 -2
  28. package/dist/jump-design-system/{p-411220f1.entry.js → p-e2af0fd9.entry.js} +2 -2
  29. package/dist/jump-design-system/p-e2af0fd9.entry.js.map +1 -0
  30. package/dist/jump-design-system/{p-3cbc3a68.entry.js → p-f4cfa17d.entry.js} +2 -2
  31. package/dist/jump-design-system-elements.json +4 -0
  32. package/dist/types/components/jump-button/jump-button.d.ts +4 -0
  33. package/dist/types/components/jump-button/jump-button.stories.d.ts +5 -0
  34. package/dist/types/components.d.ts +8 -0
  35. package/package.json +1 -1
  36. package/dist/cjs/index-46644e39.js.map +0 -1
  37. package/dist/esm/index-b0176170.js.map +0 -1
  38. package/dist/jump-design-system/p-411220f1.entry.js.map +0 -1
  39. package/dist/jump-design-system/p-68bce598.js +0 -3
  40. package/dist/jump-design-system/p-68bce598.js.map +0 -1
  41. /package/dist/jump-design-system/{p-0d2b55a8.entry.js.map → p-85fbbf60.entry.js.map} +0 -0
  42. /package/dist/jump-design-system/{p-3cbc3a68.entry.js.map → p-f4cfa17d.entry.js.map} +0 -0
@@ -1,5 +1,4 @@
1
1
  const NAMESPACE = 'jump-design-system';
2
- const BUILD = /* jump-design-system */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: false, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, 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: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: false, propNumber: true, propString: true, reflect: true, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: false, slot: true, slotChildNodesFix: false, slotRelocation: true, state: false, style: true, svg: false, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: false, vdomKey: true, vdomListener: false, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: false };
3
2
 
4
3
  /**
5
4
  * Virtual DOM patching algorithm based on Snabbdom by
@@ -9,11 +8,9 @@ const BUILD = /* jump-design-system */ { allRenderFn: true, appendChildSlotFix:
9
8
  *
10
9
  * Modified for Stencil's renderer and slot projection
11
10
  */
12
- let contentRef;
11
+ let scopeId;
13
12
  let hostTagName;
14
13
  let useNativeShadowDom = false;
15
- let checkSlotFallbackVisibility = false;
16
- let checkSlotRelocate = false;
17
14
  let isSvgMode = false;
18
15
  let queuePending = false;
19
16
  const createTime = (fnName, tagName = '') => {
@@ -46,6 +43,7 @@ const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
46
43
  * Don't add values to these!!
47
44
  */
48
45
  const EMPTY_OBJ = {};
46
+ const isDef = (v) => v != null;
49
47
  /**
50
48
  * Check whether a value is a 'complex type', defined here as an object or a
51
49
  * function.
@@ -83,7 +81,6 @@ function queryNonceMetaTagContent(doc) {
83
81
  const h = (nodeName, vnodeData, ...children) => {
84
82
  let child = null;
85
83
  let key = null;
86
- let slotName = null;
87
84
  let simple = false;
88
85
  let lastSimple = false;
89
86
  const vNodeChildren = [];
@@ -114,9 +111,6 @@ const h = (nodeName, vnodeData, ...children) => {
114
111
  if (vnodeData.key) {
115
112
  key = vnodeData.key;
116
113
  }
117
- if (vnodeData.name) {
118
- slotName = vnodeData.name;
119
- }
120
114
  // normalize class / className attributes
121
115
  {
122
116
  const classData = vnodeData.className || vnodeData.class;
@@ -138,9 +132,6 @@ const h = (nodeName, vnodeData, ...children) => {
138
132
  {
139
133
  vnode.$key$ = key;
140
134
  }
141
- {
142
- vnode.$name$ = slotName;
143
- }
144
135
  return vnode;
145
136
  };
146
137
  /**
@@ -165,9 +156,6 @@ const newVNode = (tag, text) => {
165
156
  {
166
157
  vnode.$key$ = null;
167
158
  }
168
- {
169
- vnode.$name$ = null;
170
- }
171
159
  return vnode;
172
160
  };
173
161
  const Host = {};
@@ -298,8 +286,20 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
298
286
  const attachStyles = (hostRef) => {
299
287
  const cmpMeta = hostRef.$cmpMeta$;
300
288
  const elm = hostRef.$hostElement$;
289
+ const flags = cmpMeta.$flags$;
301
290
  const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
302
- addStyle(elm.getRootNode(), cmpMeta);
291
+ const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
292
+ if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
293
+ // only required when we're NOT using native shadow dom (slot)
294
+ // or this browser doesn't support native shadow dom
295
+ // and this host element was NOT created with SSR
296
+ // let's pick out the inner content for slot projection
297
+ // create a node to represent where the original
298
+ // content was first placed, which is useful later on
299
+ // DOM WRITE!!
300
+ elm['s-sc'] = scopeId;
301
+ elm.classList.add(scopeId + '-h');
302
+ }
303
303
  endAttachStyles();
304
304
  };
305
305
  const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
@@ -425,36 +425,22 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
425
425
  let i = 0;
426
426
  let elm;
427
427
  let childNode;
428
- let oldVNode;
429
- if (!useNativeShadowDom) {
430
- // remember for later we need to check to relocate nodes
431
- checkSlotRelocate = true;
432
- if (newVNode.$tag$ === 'slot') {
433
- newVNode.$flags$ |= newVNode.$children$
434
- ? // slot element has fallback content
435
- 2 /* VNODE_FLAGS.isSlotFallback */
436
- : // slot element does not have fallback content
437
- 1 /* VNODE_FLAGS.isSlotReference */;
438
- }
439
- }
440
428
  if (newVNode.$text$ !== null) {
441
429
  // create text node
442
430
  elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
443
431
  }
444
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
445
- // create a slot reference node
446
- elm = newVNode.$elm$ =
447
- doc.createTextNode('');
448
- }
449
432
  else {
450
433
  // create element
451
- elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
452
- ? 'slot-fb'
453
- : newVNode.$tag$));
434
+ elm = newVNode.$elm$ = (doc.createElement(newVNode.$tag$));
454
435
  // add css classes, attrs, props, listeners, etc.
455
436
  {
456
437
  updateElement(null, newVNode, isSvgMode);
457
438
  }
439
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
440
+ // if there is a scopeId and this is the initial render
441
+ // then let's add the scopeId as a css class
442
+ elm.classList.add((elm['s-si'] = scopeId));
443
+ }
458
444
  if (newVNode.$children$) {
459
445
  for (i = 0; i < newVNode.$children$.length; ++i) {
460
446
  // create the node
@@ -470,50 +456,8 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
470
456
  // This needs to always happen so we can hide nodes that are projected
471
457
  // to another component but don't end up in a slot
472
458
  elm['s-hn'] = hostTagName;
473
- {
474
- if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
475
- // remember the content reference comment
476
- elm['s-sr'] = true;
477
- // remember the content reference comment
478
- elm['s-cr'] = contentRef;
479
- // remember the slot name, or empty string for default slot
480
- elm['s-sn'] = newVNode.$name$ || '';
481
- // check if we've got an old vnode for this slot
482
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
483
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
484
- {
485
- // we've got an old slot vnode and the wrapper is being replaced
486
- // so let's move the old slot content back to its original location
487
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
488
- }
489
- }
490
- }
491
- }
492
459
  return elm;
493
460
  };
494
- const putBackInOriginalLocation = (parentElm, recursive) => {
495
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
496
- const oldSlotChildNodes = parentElm.childNodes;
497
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
498
- const childNode = oldSlotChildNodes[i];
499
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
500
- // and relocate it back to it's original location
501
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
502
- // remove the old original location comment entirely
503
- // later on the patch function will know what to do
504
- // and move this to the correct spot if need be
505
- childNode['s-ol'].remove();
506
- childNode['s-ol'] = undefined;
507
- // Reset so we can correctly move the node around again.
508
- childNode['s-sh'] = undefined;
509
- checkSlotRelocate = true;
510
- }
511
- if (recursive) {
512
- putBackInOriginalLocation(childNode, recursive);
513
- }
514
- }
515
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
516
- };
517
461
  /**
518
462
  * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
519
463
  * add them to the DOM in the appropriate place.
@@ -530,14 +474,17 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
530
474
  * creating DOM nodes (inclusive)
531
475
  */
532
476
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
533
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
477
+ let containerElm = (parentElm);
534
478
  let childNode;
479
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
480
+ containerElm = containerElm.shadowRoot;
481
+ }
535
482
  for (; startIdx <= endIdx; ++startIdx) {
536
483
  if (vnodes[startIdx]) {
537
484
  childNode = createElm(null, parentVNode, startIdx);
538
485
  if (childNode) {
539
486
  vnodes[startIdx].$elm$ = childNode;
540
- containerElm.insertBefore(childNode, referenceNode(before) );
487
+ containerElm.insertBefore(childNode, before);
541
488
  }
542
489
  }
543
490
  }
@@ -559,20 +506,6 @@ const removeVnodes = (vnodes, startIdx, endIdx) => {
559
506
  if (vnode) {
560
507
  const elm = vnode.$elm$;
561
508
  if (elm) {
562
- {
563
- // we're removing this element
564
- // so it's possible we need to show slot fallback content now
565
- checkSlotFallbackVisibility = true;
566
- if (elm['s-ol']) {
567
- // remove the original location comment
568
- elm['s-ol'].remove();
569
- }
570
- else {
571
- // it's possible that child nodes of the node
572
- // that's being removed are slot nodes
573
- putBackInOriginalLocation(elm, true);
574
- }
575
- }
576
509
  // remove the vnode's element from the dom
577
510
  elm.remove();
578
511
  }
@@ -693,23 +626,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
693
626
  newEndVnode = newCh[--newEndIdx];
694
627
  }
695
628
  else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
696
- // case: "Vnode moved right"
697
- //
698
- // We've found that the last node in our window on the new children is
699
- // the same VNode as the _first_ node in our window on the old children
700
- // we're dealing with now. Visually, this is the layout of these two
701
- // nodes:
702
- //
703
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
704
- // ^^^^^^^^^^^
705
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
706
- // ^^^^^^^^^^^^^
707
- //
708
- // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
709
- // and move the DOM element for `oldStartVnode`.
710
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
711
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
712
- }
713
629
  patch(oldStartVnode, newEndVnode, isInitialRender);
714
630
  // We need to move the element for `oldStartVnode` into a position which
715
631
  // will be appropriate for `newEndVnode`. For this we can use
@@ -733,24 +649,6 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
733
649
  newEndVnode = newCh[--newEndIdx];
734
650
  }
735
651
  else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
736
- // case: "Vnode moved left"
737
- //
738
- // We've found that the first node in our window on the new children is
739
- // the same VNode as the _last_ node in our window on the old children.
740
- // Visually, this is the layout of these two nodes:
741
- //
742
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
743
- // ^^^^^^^^^^^^^
744
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
745
- // ^^^^^^^^^^^
746
- //
747
- // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
748
- // (which will handle updating any changed attributes, reconciling their
749
- // children etc) but we also need to move the DOM node to which
750
- // `oldEndVnode` corresponds.
751
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
752
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
753
- }
754
652
  patch(oldEndVnode, newStartVnode, isInitialRender);
755
653
  // We've already checked above if `oldStartVnode` and `newStartVnode` are
756
654
  // the same node, so since we're here we know that they are not. Thus we
@@ -807,7 +705,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
807
705
  if (node) {
808
706
  // if we created a new node then handle inserting it to the DOM
809
707
  {
810
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
708
+ oldStartVnode.$elm$.parentNode.insertBefore(node, oldStartVnode.$elm$);
811
709
  }
812
710
  }
813
711
  }
@@ -846,9 +744,6 @@ const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
846
744
  // compare if two vnode to see if they're "technically" the same
847
745
  // need to have the same element tag, and same key to be the same
848
746
  if (leftVNode.$tag$ === rightVNode.$tag$) {
849
- if (leftVNode.$tag$ === 'slot') {
850
- return leftVNode.$name$ === rightVNode.$name$;
851
- }
852
747
  // this will be set if JSX tags in the build have `key` attrs set on them
853
748
  // we only want to check this if we're not on the first render since on
854
749
  // first render `leftVNode.$key$` will always be `null`, so we can be led
@@ -861,14 +756,6 @@ const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
861
756
  }
862
757
  return false;
863
758
  };
864
- const referenceNode = (node) => {
865
- // this node was relocated to a new location in the dom
866
- // because of some other component's slot
867
- // but we still have an html comment in place of where
868
- // it's original location was according to it's original vdom
869
- return (node && node['s-ol']) || node;
870
- };
871
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
872
759
  /**
873
760
  * Handle reconciling an outdated VNode with a new one which corresponds to
874
761
  * it. This function handles flushing updates to the DOM and reconciling the
@@ -884,7 +771,6 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
884
771
  const newChildren = newVNode.$children$;
885
772
  const tag = newVNode.$tag$;
886
773
  const text = newVNode.$text$;
887
- let defaultHolder;
888
774
  if (text === null) {
889
775
  {
890
776
  if (tag === 'slot' && !useNativeShadowDom) ;
@@ -914,193 +800,12 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
914
800
  removeVnodes(oldChildren, 0, oldChildren.length - 1);
915
801
  }
916
802
  }
917
- else if ((defaultHolder = elm['s-cr'])) {
918
- // this element has slotted content
919
- defaultHolder.parentNode.textContent = text;
920
- }
921
803
  else if (oldVNode.$text$ !== text) {
922
804
  // update the text content for the text only vnode
923
805
  // and also only if the text is different than before
924
806
  elm.data = text;
925
807
  }
926
808
  };
927
- /**
928
- * Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
929
- * are slot fallbacks nodes.
930
- *
931
- * A slot fallback node should be visible by default. Then, it should be
932
- * conditionally hidden if:
933
- *
934
- * - it has a sibling with a `slot` property set to its slot name or if
935
- * - it is a default fallback slot node, in which case we hide if it has any
936
- * content
937
- *
938
- * @param elm the element of interest
939
- */
940
- const updateFallbackSlotVisibility = (elm) => {
941
- const childNodes = elm.childNodes;
942
- for (const childNode of childNodes) {
943
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
944
- if (childNode['s-sr']) {
945
- // this is a slot fallback node
946
- // get the slot name for this slot reference node
947
- const slotName = childNode['s-sn'];
948
- // by default always show a fallback slot node
949
- // then hide it if there are other slots in the light dom
950
- childNode.hidden = false;
951
- // we need to check all of its sibling nodes in order to see if
952
- // `childNode` should be hidden
953
- for (const siblingNode of childNodes) {
954
- // Don't check the node against itself
955
- if (siblingNode !== childNode) {
956
- if (siblingNode['s-hn'] !== childNode['s-hn'] || slotName !== '') {
957
- // this sibling node is from a different component OR is a named
958
- // fallback slot node
959
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
960
- (slotName === siblingNode.getAttribute('slot') || slotName === siblingNode['s-sn'])) {
961
- childNode.hidden = true;
962
- break;
963
- }
964
- }
965
- else {
966
- // this is a default fallback slot node
967
- // any element or text node (with content)
968
- // should hide the default fallback slot node
969
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ ||
970
- (siblingNode.nodeType === 3 /* NODE_TYPE.TextNode */ && siblingNode.textContent.trim() !== '')) {
971
- childNode.hidden = true;
972
- break;
973
- }
974
- }
975
- }
976
- }
977
- }
978
- // keep drilling down
979
- updateFallbackSlotVisibility(childNode);
980
- }
981
- }
982
- };
983
- /**
984
- * Component-global information about nodes which are either currently being
985
- * relocated or will be shortly.
986
- */
987
- const relocateNodes = [];
988
- /**
989
- * Mark the contents of a slot for relocation via adding references to them to
990
- * the {@link relocateNodes} data structure. The actual work of relocating them
991
- * will then be handled in {@link renderVdom}.
992
- *
993
- * @param elm a render node whose child nodes need to be relocated
994
- */
995
- const markSlotContentForRelocation = (elm) => {
996
- // tslint:disable-next-line: prefer-const
997
- let node;
998
- let hostContentNodes;
999
- let j;
1000
- for (const childNode of elm.childNodes) {
1001
- // we need to find child nodes which are slot references so we can then try
1002
- // to match them up with nodes that need to be relocated
1003
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1004
- // first get the content reference comment node ('s-cr'), then we get
1005
- // its parent, which is where all the host content is now
1006
- hostContentNodes = node.parentNode.childNodes;
1007
- const slotName = childNode['s-sn'];
1008
- // iterate through all the nodes under the location where the host was
1009
- // originally rendered
1010
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1011
- node = hostContentNodes[j];
1012
- // check that the node is not a content reference node or a node
1013
- // reference and then check that the host name does not match that of
1014
- // childNode.
1015
- // In addition, check that the slot either has not already been relocated, or
1016
- // that its current location's host is not childNode's host. This is essentially
1017
- // a check so that we don't try to relocate (and then hide) a node that is already
1018
- // where it should be.
1019
- if (!node['s-cn'] &&
1020
- !node['s-nr'] &&
1021
- node['s-hn'] !== childNode['s-hn'] &&
1022
- (!BUILD.experimentalSlotFixes )) {
1023
- // if `node` is located in the slot that `childNode` refers to (via the
1024
- // `'s-sn'` property) then we need to relocate it from it's current spot
1025
- // (under the host element parent) to the right slot location
1026
- if (isNodeLocatedInSlot(node, slotName)) {
1027
- // it's possible we've already decided to relocate this node
1028
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1029
- // made some changes to slots
1030
- // let's make sure we also double check
1031
- // fallbacks are correctly hidden or shown
1032
- checkSlotFallbackVisibility = true;
1033
- // ensure that the slot-name attr is correct
1034
- node['s-sn'] = node['s-sn'] || slotName;
1035
- if (relocateNodeData) {
1036
- relocateNodeData.$nodeToRelocate$['s-sh'] = childNode['s-hn'];
1037
- // we marked this node for relocation previously but didn't find
1038
- // out the slot reference node to which it needs to be relocated
1039
- // so write it down now!
1040
- relocateNodeData.$slotRefNode$ = childNode;
1041
- }
1042
- else {
1043
- node['s-sh'] = childNode['s-hn'];
1044
- // add to our list of nodes to relocate
1045
- relocateNodes.push({
1046
- $slotRefNode$: childNode,
1047
- $nodeToRelocate$: node,
1048
- });
1049
- }
1050
- if (node['s-sr']) {
1051
- relocateNodes.map((relocateNode) => {
1052
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1053
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1054
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1055
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1056
- }
1057
- }
1058
- });
1059
- }
1060
- }
1061
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1062
- // the node is not found within the slot (`childNode`) that we're
1063
- // currently looking at, so we stick it into `relocateNodes` to
1064
- // handle later. If we never find a home for this element then
1065
- // we'll need to hide it
1066
- relocateNodes.push({
1067
- $nodeToRelocate$: node,
1068
- });
1069
- }
1070
- }
1071
- }
1072
- }
1073
- // if we're dealing with any type of element (capable of itself being a
1074
- // slot reference or containing one) then we recur
1075
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1076
- markSlotContentForRelocation(childNode);
1077
- }
1078
- }
1079
- };
1080
- /**
1081
- * Check whether a node is located in a given named slot.
1082
- *
1083
- * @param nodeToRelocate the node of interest
1084
- * @param slotName the slot name to check
1085
- * @returns whether the node is located in the slot or not
1086
- */
1087
- const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1088
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1089
- if (nodeToRelocate.getAttribute('slot') === null && slotName === '') {
1090
- // if the node doesn't have a slot attribute, and the slot we're checking
1091
- // is not a named slot, then we assume the node should be within the slot
1092
- return true;
1093
- }
1094
- if (nodeToRelocate.getAttribute('slot') === slotName) {
1095
- return true;
1096
- }
1097
- return false;
1098
- }
1099
- if (nodeToRelocate['s-sn'] === slotName) {
1100
- return true;
1101
- }
1102
- return slotName === '';
1103
- };
1104
809
  /**
1105
810
  * The main entry point for Stencil's virtual DOM-based rendering engine
1106
811
  *
@@ -1115,7 +820,6 @@ const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1115
820
  * @param isInitialLoad whether or not this is the first call after page load
1116
821
  */
1117
822
  const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1118
- var _a, _b, _c, _d;
1119
823
  const hostElm = hostRef.$hostElement$;
1120
824
  const cmpMeta = hostRef.$cmpMeta$;
1121
825
  const oldVNode = hostRef.$vnode$ || newVNode(null, null);
@@ -1154,113 +858,13 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1154
858
  rootVnode.$tag$ = null;
1155
859
  rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1156
860
  hostRef.$vnode$ = rootVnode;
1157
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
1158
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
861
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1159
862
  {
1160
- contentRef = hostElm['s-cr'];
1161
- // always reset
1162
- checkSlotFallbackVisibility = false;
863
+ scopeId = hostElm['s-sc'];
1163
864
  }
865
+ useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1164
866
  // synchronous patch
1165
867
  patch(oldVNode, rootVnode, isInitialLoad);
1166
- {
1167
- // while we're moving nodes around existing nodes, temporarily disable
1168
- // the disconnectCallback from working
1169
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1170
- if (checkSlotRelocate) {
1171
- markSlotContentForRelocation(rootVnode.$elm$);
1172
- for (const relocateData of relocateNodes) {
1173
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1174
- if (!nodeToRelocate['s-ol']) {
1175
- // add a reference node marking this node's original location
1176
- // keep a reference to this node for later lookups
1177
- const orgLocationNode = doc.createTextNode('');
1178
- orgLocationNode['s-nr'] = nodeToRelocate;
1179
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1180
- }
1181
- }
1182
- for (const relocateData of relocateNodes) {
1183
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1184
- const slotRefNode = relocateData.$slotRefNode$;
1185
- if (slotRefNode) {
1186
- const parentNodeRef = slotRefNode.parentNode;
1187
- // When determining where to insert content, the most simple case would be
1188
- // to relocate the node immediately following the slot reference node. We do this
1189
- // by getting a reference to the node immediately following the slot reference node
1190
- // since we will use `insertBefore` to manipulate the DOM.
1191
- //
1192
- // If there is no node immediately following the slot reference node, then we will just
1193
- // end up appending the node as the last child of the parent.
1194
- let insertBeforeNode = slotRefNode.nextSibling;
1195
- // If the node we're currently planning on inserting the new node before is an element,
1196
- // we need to do some additional checks to make sure we're inserting the node in the correct order.
1197
- // The use case here would be that we have multiple nodes being relocated to the same slot. So, we want
1198
- // to make sure they get inserted into their new how in the same order they were declared in their original location.
1199
- //
1200
- // TODO(STENCIL-914): Remove `experimentalSlotFixes` check
1201
- {
1202
- let orgLocationNode = (_a = nodeToRelocate['s-ol']) === null || _a === void 0 ? void 0 : _a.previousSibling;
1203
- while (orgLocationNode) {
1204
- let refNode = (_b = orgLocationNode['s-nr']) !== null && _b !== void 0 ? _b : null;
1205
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1206
- refNode = refNode.nextSibling;
1207
- if (!refNode || !refNode['s-nr']) {
1208
- insertBeforeNode = refNode;
1209
- break;
1210
- }
1211
- }
1212
- orgLocationNode = orgLocationNode.previousSibling;
1213
- }
1214
- }
1215
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1216
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1217
- // we've checked that it's worth while to relocate
1218
- // since that the node to relocate
1219
- // has a different next sibling or parent relocated
1220
- if (nodeToRelocate !== insertBeforeNode) {
1221
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1222
- // probably a component in the index.html that doesn't have its hostname set
1223
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1224
- }
1225
- // Add it back to the dom but in its new home
1226
- // If we get to this point and `insertBeforeNode` is `null`, that means
1227
- // we're just going to append the node as the last child of the parent. Passing
1228
- // `null` as the second arg here will trigger that behavior.
1229
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1230
- // Reset the `hidden` value back to what it was defined as originally
1231
- // This solves a problem where a `slot` is dynamically rendered and `hidden` may have
1232
- // been set on content originally, but now it has a slot to go to so it should have
1233
- // the value it was defined as having in the DOM, not what we overrode it to.
1234
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1235
- nodeToRelocate.hidden = (_c = nodeToRelocate['s-ih']) !== null && _c !== void 0 ? _c : false;
1236
- }
1237
- }
1238
- }
1239
- }
1240
- else {
1241
- // this node doesn't have a slot home to go to, so let's hide it
1242
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1243
- // Store the initial value of `hidden` so we can reset it later when
1244
- // moving nodes around.
1245
- if (isInitialLoad) {
1246
- nodeToRelocate['s-ih'] = (_d = nodeToRelocate.hidden) !== null && _d !== void 0 ? _d : false;
1247
- }
1248
- nodeToRelocate.hidden = true;
1249
- }
1250
- }
1251
- }
1252
- }
1253
- if (checkSlotFallbackVisibility) {
1254
- updateFallbackSlotVisibility(rootVnode.$elm$);
1255
- }
1256
- // done moving nodes around
1257
- // allow the disconnect callback to work again
1258
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1259
- // always reset
1260
- relocateNodes.length = 0;
1261
- }
1262
- // Clear the content ref so we don't create a memory leak
1263
- contentRef = undefined;
1264
868
  };
1265
869
  const attachToAncestor = (hostRef, ancestorComponent) => {
1266
870
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
@@ -1749,16 +1353,6 @@ const connectedCallback = (elm) => {
1749
1353
  if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
1750
1354
  // first time this component has connected
1751
1355
  hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
1752
- {
1753
- // initUpdate
1754
- // if the slot polyfill is required we'll need to put some nodes
1755
- // in here to act as original content anchors as we move nodes around
1756
- // host element has been connected to the DOM
1757
- if ((// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
1758
- cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
1759
- setContentReference(elm);
1760
- }
1761
- }
1762
1356
  {
1763
1357
  // find the first ancestor component (if there is one) and register
1764
1358
  // this component as one of the actively loading child components for its ancestor
@@ -1799,17 +1393,6 @@ const connectedCallback = (elm) => {
1799
1393
  endConnected();
1800
1394
  }
1801
1395
  };
1802
- const setContentReference = (elm) => {
1803
- // only required when we're NOT using native shadow dom (slot)
1804
- // or this browser doesn't support native shadow dom
1805
- // and this host element was NOT created with SSR
1806
- // let's pick out the inner content for slot projection
1807
- // create a node to represent where the original
1808
- // content was first placed, which is useful later on
1809
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
1810
- contentRefElm['s-cn'] = true;
1811
- elm.insertBefore(contentRefElm, elm.firstChild);
1812
- };
1813
1396
  const disconnectInstance = (instance) => {
1814
1397
  };
1815
1398
  const disconnectedCallback = async (elm) => {
@@ -1863,6 +1446,17 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1863
1446
  super(self);
1864
1447
  self = this;
1865
1448
  registerHost(self, cmpMeta);
1449
+ if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
1450
+ // this component is using shadow dom
1451
+ // and this browser supports shadow dom
1452
+ // add the read-only property "shadowRoot" to the host element
1453
+ // adding the shadow root build conditionals to minimize runtime
1454
+ {
1455
+ {
1456
+ self.attachShadow({ mode: 'open' });
1457
+ }
1458
+ }
1459
+ }
1866
1460
  }
1867
1461
  connectedCallback() {
1868
1462
  if (appLoadFallback) {
@@ -2081,4 +1675,4 @@ const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2081
1675
 
2082
1676
  export { Host as H, bootstrapLazy as b, h, promiseResolve as p, registerInstance as r, setNonce as s };
2083
1677
 
2084
- //# sourceMappingURL=index-b0176170.js.map
1678
+ //# sourceMappingURL=index-3cf3394c.js.map