@xplortech/apollo-core 0.0.7 → 0.1.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.
Files changed (119) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +42 -1
  3. package/build/style.css +972 -372
  4. package/dist/apollo-core/apollo-core.css +2127 -9
  5. package/dist/apollo-core/apollo-core.esm.js +125 -1
  6. package/dist/apollo-core/app-globals-0f993ce5.js +3 -0
  7. package/dist/apollo-core/css-shim-bbdf0cc6.js +4 -0
  8. package/dist/apollo-core/dom-1f98a75f.js +73 -0
  9. package/dist/apollo-core/index-912d1a21.js +584 -0
  10. package/dist/apollo-core/index-f313719f.js +2938 -0
  11. package/dist/apollo-core/index.esm.js +1 -0
  12. package/dist/apollo-core/p-00996870.js +1 -0
  13. package/dist/apollo-core/p-21872e0f.entry.js +1 -0
  14. package/dist/apollo-core/{p-1fc2ec24.entry.js → p-6c4f9227.entry.js} +4 -3
  15. package/dist/apollo-core/p-d8ea7d80.entry.js +1 -0
  16. package/dist/apollo-core/shadow-css-67b66845.js +389 -0
  17. package/dist/apollo-core/xpl-avatar.entry.js +19 -0
  18. package/dist/apollo-core/xpl-badge.entry.js +17 -0
  19. package/dist/apollo-core/xpl-breadcrumb-item.entry.js +19 -0
  20. package/dist/apollo-core/xpl-breadcrumbs.entry.js +14 -0
  21. package/dist/{esm/xpl-button_3.entry.js → apollo-core/xpl-button.entry.js} +15 -152
  22. package/dist/apollo-core/xpl-checkbox.entry.js +14 -0
  23. package/dist/apollo-core/xpl-choicelist.entry.js +12 -0
  24. package/dist/apollo-core/xpl-pagination.entry.js +72 -0
  25. package/dist/apollo-core/xpl-radio.entry.js +14 -0
  26. package/dist/apollo-core/xpl-table.entry.js +85 -0
  27. package/dist/apollo-core/xpl-utility-bar.entry.js +12 -0
  28. package/dist/cjs/apollo-core.cjs.js +113 -5
  29. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  30. package/dist/cjs/css-shim-a7379e2b.js +6 -0
  31. package/dist/cjs/dom-3e7d9c3b.js +75 -0
  32. package/dist/cjs/index-318d5fc7.js +586 -0
  33. package/dist/cjs/{index-d0d9877d.js → index-716d8f57.js} +106 -29
  34. package/dist/cjs/index-fca88002.js +2973 -0
  35. package/dist/cjs/index.cjs.js +1 -0
  36. package/dist/cjs/loader.cjs.js +19 -3
  37. package/dist/cjs/shadow-css-09555044.js +391 -0
  38. package/dist/cjs/xpl-avatar.cjs.entry.js +23 -0
  39. package/dist/cjs/xpl-avatar_9.cjs.entry.js +16327 -0
  40. package/dist/cjs/xpl-badge.cjs.entry.js +21 -0
  41. package/dist/cjs/xpl-breadcrumb-item.cjs.entry.js +23 -0
  42. package/dist/cjs/xpl-breadcrumbs.cjs.entry.js +18 -0
  43. package/dist/cjs/{xpl-button_3.cjs.entry.js → xpl-button.cjs.entry.js} +14 -153
  44. package/dist/cjs/xpl-checkbox.cjs.entry.js +18 -0
  45. package/dist/cjs/xpl-choicelist.cjs.entry.js +16 -0
  46. package/dist/cjs/xpl-pagination.cjs.entry.js +76 -0
  47. package/dist/cjs/xpl-radio.cjs.entry.js +18 -0
  48. package/dist/cjs/xpl-table.cjs.entry.js +89 -0
  49. package/dist/cjs/xpl-utility-bar.cjs.entry.js +16 -0
  50. package/dist/collection/collection-manifest.json +10 -2
  51. package/dist/collection/components/xpl-avatar/xpl-avatar.js +158 -0
  52. package/dist/collection/components/xpl-badge/xpl-badge.js +50 -0
  53. package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumb-item/xpl-breadcrumb-item.js +19 -0
  54. package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumbs/xpl-breadcrumbs.js +12 -0
  55. package/dist/collection/components/xpl-button/xpl-button.js +37 -5
  56. package/dist/collection/components/xpl-checkbox/xpl-checkbox.js +139 -0
  57. package/dist/collection/components/xpl-choicelist/xpl-choicelist.js +9 -0
  58. package/dist/collection/components/xpl-radio/xpl-radio.js +122 -0
  59. package/dist/collection/components/xpl-table/xpl-table.js +9 -5
  60. package/dist/collection/components/xpl-utility-bar/xpl-utility-bar.js +10 -0
  61. package/dist/custom-elements/index.d.ts +36 -0
  62. package/dist/custom-elements/index.js +733 -11
  63. package/dist/esm/apollo-core.js +113 -5
  64. package/dist/esm/app-globals-0f993ce5.js +3 -0
  65. package/dist/esm/css-shim-bbdf0cc6.js +4 -0
  66. package/dist/esm/dom-1f98a75f.js +73 -0
  67. package/dist/esm/{index-252a5f91.js → index-4c8962a5.js} +106 -29
  68. package/dist/esm/index-912d1a21.js +584 -0
  69. package/dist/esm/index-f313719f.js +2938 -0
  70. package/dist/esm/index.js +1 -1
  71. package/dist/esm/loader.js +19 -3
  72. package/dist/esm/shadow-css-67b66845.js +389 -0
  73. package/dist/esm/xpl-avatar.entry.js +19 -0
  74. package/dist/esm/xpl-avatar_9.entry.js +16315 -0
  75. package/dist/esm/xpl-badge.entry.js +17 -0
  76. package/dist/esm/xpl-breadcrumb-item.entry.js +19 -0
  77. package/dist/esm/xpl-breadcrumbs.entry.js +14 -0
  78. package/dist/esm/xpl-button.entry.js +16086 -0
  79. package/dist/esm/xpl-checkbox.entry.js +14 -0
  80. package/dist/esm/xpl-choicelist.entry.js +12 -0
  81. package/dist/esm/xpl-pagination.entry.js +72 -0
  82. package/dist/esm/xpl-radio.entry.js +14 -0
  83. package/dist/esm/xpl-table.entry.js +85 -0
  84. package/dist/esm/xpl-utility-bar.entry.js +12 -0
  85. package/dist/stories/avatar.stories.js +173 -0
  86. package/dist/stories/badge.stories.js +48 -0
  87. package/dist/stories/breadcrumbs.stories.js +115 -0
  88. package/dist/stories/button.stories.js +98 -0
  89. package/dist/stories/checkbox.stories.js +66 -0
  90. package/dist/stories/pagination.stories.js +84 -0
  91. package/dist/stories/radio.stories.js +56 -0
  92. package/dist/stories/table.stories.js +107 -0
  93. package/dist/stories/tabs.stories.js +24 -0
  94. package/dist/stories/utility-bar.stories.js +94 -0
  95. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/avatar.stories.d.ts +91 -0
  96. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/badge.stories.d.ts +48 -0
  97. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/breadcrumbs.stories.d.ts +53 -0
  98. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/button.stories.d.ts +74 -0
  99. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/checkbox.stories.d.ts +64 -0
  100. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/pagination.stories.d.ts +0 -0
  101. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/radio.stories.d.ts +56 -0
  102. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/table.stories.d.ts +50 -0
  103. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/tabs.stories.d.ts +0 -0
  104. package/dist/types/Users/fernandogelin/Projects/apollo/.stencil/stories/utility-bar.stories.d.ts +20 -0
  105. package/dist/types/components/xpl-avatar/xpl-avatar.d.ts +11 -0
  106. package/dist/types/components/xpl-badge/xpl-badge.d.ts +5 -0
  107. package/dist/types/components/xpl-breadcrumbs/xpl-breadcrumb-item/xpl-breadcrumb-item.d.ts +4 -0
  108. package/dist/types/components/xpl-breadcrumbs/xpl-breadcrumbs/xpl-breadcrumbs.d.ts +3 -0
  109. package/dist/types/{.stencil → components}/xpl-button/xpl-button.d.ts +3 -1
  110. package/dist/types/components/xpl-checkbox/xpl-checkbox.d.ts +11 -0
  111. package/dist/types/components/xpl-choicelist/xpl-choicelist.d.ts +3 -0
  112. package/dist/types/components/xpl-radio/xpl-radio.d.ts +10 -0
  113. package/dist/types/{.stencil → components}/xpl-table/xpl-table.d.ts +2 -2
  114. package/dist/types/components/xpl-utility-bar/xpl-utility-bar.d.ts +3 -0
  115. package/dist/types/components.d.ts +132 -4
  116. package/dist/types/stencil-public-runtime.d.ts +183 -182
  117. package/package.json +42 -13
  118. package/dist/apollo-core/p-3f7da885.js +0 -1
  119. /package/dist/types/{.stencil → components}/xpl-pagination/xpl-pagination.d.ts +0 -0
@@ -22,6 +22,7 @@ function _interopNamespace(e) {
22
22
 
23
23
  const NAMESPACE = 'apollo-core';
24
24
 
25
+ let scopeId;
25
26
  let contentRef;
26
27
  let hostTagName;
27
28
  let useNativeShadowDom = false;
@@ -34,8 +35,8 @@ const doc = win.document || { head: {} };
34
35
  const plt = {
35
36
  $flags$: 0,
36
37
  $resourcesUrl$: '',
37
- jmp: h => h(),
38
- raf: h => requestAnimationFrame(h),
38
+ jmp: (h) => h(),
39
+ raf: (h) => requestAnimationFrame(h),
39
40
  ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
40
41
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
41
42
  ce: (eventName, opts) => new CustomEvent(eventName, opts),
@@ -69,6 +70,7 @@ const EMPTY_OBJ = {};
69
70
  */
70
71
  const SVG_NS = 'http://www.w3.org/2000/svg';
71
72
  const HTML_NS = 'http://www.w3.org/1999/xhtml';
73
+ const isDef = (v) => v != null;
72
74
  const isComplexType = (o) => {
73
75
  // https://jsperf.com/typeof-fn-object/5
74
76
  o = typeof o;
@@ -125,7 +127,7 @@ const h = (nodeName, vnodeData, ...children) => {
125
127
  typeof classData !== 'object'
126
128
  ? classData
127
129
  : Object.keys(classData)
128
- .filter(k => classData[k])
130
+ .filter((k) => classData[k])
129
131
  .join(' ');
130
132
  }
131
133
  }
@@ -174,8 +176,8 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
174
176
  const classList = elm.classList;
175
177
  const oldClasses = parseClassList(oldValue);
176
178
  const newClasses = parseClassList(newValue);
177
- classList.remove(...oldClasses.filter(c => c && !newClasses.includes(c)));
178
- classList.add(...newClasses.filter(c => c && !oldClasses.includes(c)));
179
+ classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
180
+ classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
179
181
  }
180
182
  else if (memberName === 'ref') {
181
183
  // minifier will clean this up
@@ -183,7 +185,9 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
183
185
  newValue(elm);
184
186
  }
185
187
  }
186
- else if ((!isProp ) && memberName[0] === 'o' && memberName[1] === 'n') {
188
+ else if ((!isProp ) &&
189
+ memberName[0] === 'o' &&
190
+ memberName[1] === 'n') {
187
191
  // Event Handlers
188
192
  // so if the member name starts with "on" and the 3rd characters is
189
193
  // a capital letter, and it's not already a member on the element,
@@ -264,7 +268,9 @@ const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
264
268
  // if the element passed in is a shadow root, which is a document fragment
265
269
  // then we want to be adding attrs/props to the shadow root's "host" element
266
270
  // if it's not a shadow root, then we add attrs/props to the same element
267
- const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
271
+ const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host
272
+ ? newVnode.$elm$.host
273
+ : newVnode.$elm$;
268
274
  const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
269
275
  const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
270
276
  {
@@ -291,6 +297,10 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
291
297
  // remember for later we need to check to relocate nodes
292
298
  checkSlotRelocate = true;
293
299
  if (newVNode.$tag$ === 'slot') {
300
+ if (scopeId) {
301
+ // scoped css needs to add its scoped id to the parent element
302
+ parentElm.classList.add(scopeId + '-s');
303
+ }
294
304
  newVNode.$flags$ |= newVNode.$children$
295
305
  ? // slot element has fallback content
296
306
  2 /* isSlotFallback */
@@ -304,14 +314,17 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
304
314
  }
305
315
  else if (newVNode.$flags$ & 1 /* isSlotReference */) {
306
316
  // create a slot reference node
307
- elm = newVNode.$elm$ = doc.createTextNode('');
317
+ elm = newVNode.$elm$ =
318
+ doc.createTextNode('');
308
319
  }
309
320
  else {
310
321
  if (!isSvgMode) {
311
322
  isSvgMode = newVNode.$tag$ === 'svg';
312
323
  }
313
324
  // create element
314
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */ ? 'slot-fb' : newVNode.$tag$)
325
+ elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* isSlotFallback */
326
+ ? 'slot-fb'
327
+ : newVNode.$tag$)
315
328
  );
316
329
  if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
317
330
  isSvgMode = false;
@@ -320,10 +333,15 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
320
333
  {
321
334
  updateElement(null, newVNode, isSvgMode);
322
335
  }
336
+ if (isDef(scopeId) && elm['s-si'] !== scopeId) {
337
+ // if there is a scopeId and this is the initial render
338
+ // then let's add the scopeId as a css class
339
+ elm.classList.add((elm['s-si'] = scopeId));
340
+ }
323
341
  if (newVNode.$children$) {
324
342
  for (i = 0; i < newVNode.$children$.length; ++i) {
325
343
  // create the node
326
- childNode = createElm(oldParentVNode, newVNode, i);
344
+ childNode = createElm(oldParentVNode, newVNode, i, elm);
327
345
  // return node could have been null
328
346
  if (childNode) {
329
347
  // append our new node
@@ -389,9 +407,12 @@ const putBackInOriginalLocation = (parentElm, recursive) => {
389
407
  const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
390
408
  let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
391
409
  let childNode;
410
+ if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
411
+ containerElm = containerElm.shadowRoot;
412
+ }
392
413
  for (; startIdx <= endIdx; ++startIdx) {
393
414
  if (vnodes[startIdx]) {
394
- childNode = createElm(null, parentVNode, startIdx);
415
+ childNode = createElm(null, parentVNode, startIdx, parentElm);
395
416
  if (childNode) {
396
417
  vnodes[startIdx].$elm$ = childNode;
397
418
  containerElm.insertBefore(childNode, referenceNode(before) );
@@ -480,7 +501,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
480
501
  else {
481
502
  {
482
503
  // new element
483
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
504
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
484
505
  newStartVnode = newCh[++newStartIdx];
485
506
  }
486
507
  if (node) {
@@ -643,7 +664,7 @@ const relocateSlotContent = (elm) => {
643
664
  // that is suppose to always represent the original content location
644
665
  if (isNodeLocatedInSlot(node, slotNameAttr)) {
645
666
  // it's possible we've already decided to relocate this node
646
- relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
667
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
647
668
  // made some changes to slots
648
669
  // let's make sure we also double check
649
670
  // fallbacks are correctly hidden or shown
@@ -662,9 +683,9 @@ const relocateSlotContent = (elm) => {
662
683
  });
663
684
  }
664
685
  if (node['s-sr']) {
665
- relocateNodes.map(relocateNode => {
686
+ relocateNodes.map((relocateNode) => {
666
687
  if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
667
- relocateNodeData = relocateNodes.find(r => r.$nodeToRelocate$ === node);
688
+ relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
668
689
  if (relocateNodeData && !relocateNode.$slotRefNode$) {
669
690
  relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
670
691
  }
@@ -672,7 +693,7 @@ const relocateSlotContent = (elm) => {
672
693
  });
673
694
  }
674
695
  }
675
- else if (!relocateNodes.some(r => r.$nodeToRelocate$ === node)) {
696
+ else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
676
697
  // so far this element does not have a slot home, not setting slotRefNode on purpose
677
698
  // if we never find a home for this element then we'll need to hide it
678
699
  relocateNodes.push({
@@ -717,7 +738,10 @@ const renderVdom = (hostRef, renderFnResults) => {
717
738
  rootVnode.$tag$ = null;
718
739
  rootVnode.$flags$ |= 4 /* isHost */;
719
740
  hostRef.$vnode$ = rootVnode;
720
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm);
741
+ rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
742
+ {
743
+ scopeId = hostElm['s-sc'];
744
+ }
721
745
  {
722
746
  contentRef = hostElm['s-cr'];
723
747
  useNativeShadowDom = (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) !== 0;
@@ -745,7 +769,8 @@ const renderVdom = (hostRef, renderFnResults) => {
745
769
  if (!nodeToRelocate['s-ol']) {
746
770
  // add a reference node marking this node's original location
747
771
  // keep a reference to this node for later lookups
748
- orgLocationNode = doc.createTextNode('');
772
+ orgLocationNode =
773
+ doc.createTextNode('');
749
774
  orgLocationNode['s-nr'] = nodeToRelocate;
750
775
  nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
751
776
  }
@@ -769,7 +794,8 @@ const renderVdom = (hostRef, renderFnResults) => {
769
794
  }
770
795
  }
771
796
  }
772
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) || nodeToRelocate.nextSibling !== insertBeforeNode) {
797
+ if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
798
+ nodeToRelocate.nextSibling !== insertBeforeNode) {
773
799
  // we've checked that it's worth while to relocate
774
800
  // since that the node to relocate
775
801
  // has a different next sibling or parent relocated
@@ -822,7 +848,7 @@ const emitEvent = (elm, name, opts) => {
822
848
  };
823
849
  const attachToAncestor = (hostRef, ancestorComponent) => {
824
850
  if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
825
- ancestorComponent['s-p'].push(new Promise(r => (hostRef.$onRenderResolve$ = r)));
851
+ ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
826
852
  }
827
853
  };
828
854
  const scheduleUpdate = (hostRef, isInitialLoad) => {
@@ -865,7 +891,7 @@ const updateComponent = async (hostRef, instance, isInitialLoad) => {
865
891
  // ok, so turns out there are some child host elements
866
892
  // waiting on this parent element to load
867
893
  // let's fire off all update callbacks waiting
868
- rc.map(cb => cb());
894
+ rc.map((cb) => cb());
869
895
  elm['s-rc'] = undefined;
870
896
  }
871
897
  endRender();
@@ -971,7 +997,8 @@ const safeCall = (instance, method, arg) => {
971
997
  const then = (promise, thenFn) => {
972
998
  return promise && promise.then ? promise.then(thenFn) : thenFn();
973
999
  };
974
- const addHydratedFlag = (elm) => (elm.classList.add('hydrated') );
1000
+ const addHydratedFlag = (elm) => elm.classList.add('hydrated')
1001
+ ;
975
1002
  const parsePropertyValue = (propValue, propType) => {
976
1003
  // ensure this value is of the correct prop type
977
1004
  if (propValue != null && !isComplexType(propValue)) {
@@ -1025,7 +1052,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1025
1052
  const members = Object.entries(cmpMeta.$members$);
1026
1053
  const prototype = Cstr.prototype;
1027
1054
  members.map(([memberName, [memberFlags]]) => {
1028
- if ((memberFlags & 31 /* Prop */ || ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1055
+ if ((memberFlags & 31 /* Prop */ ||
1056
+ ((flags & 2 /* proxyState */) && memberFlags & 32 /* State */))) {
1029
1057
  // proxyComponent - prop
1030
1058
  Object.defineProperty(prototype, memberName, {
1031
1059
  get() {
@@ -1040,7 +1068,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1040
1068
  enumerable: true,
1041
1069
  });
1042
1070
  }
1043
- else if (flags & 1 /* isElementConstructor */ && memberFlags & 64 /* Method */) {
1071
+ else if (flags & 1 /* isElementConstructor */ &&
1072
+ memberFlags & 64 /* Method */) {
1044
1073
  // proxyComponent - method
1045
1074
  Object.defineProperty(prototype, memberName, {
1046
1075
  value(...args) {
@@ -1055,6 +1084,43 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
1055
1084
  prototype.attributeChangedCallback = function (attrName, _oldValue, newValue) {
1056
1085
  plt.jmp(() => {
1057
1086
  const propName = attrNameToPropName.get(attrName);
1087
+ // In a webcomponent lifecyle the attributeChangedCallback runs prior to connectedCallback
1088
+ // in the case where an attribute was set inline.
1089
+ // ```html
1090
+ // <my-component some-attribute="some-value"></my-component>
1091
+ // ```
1092
+ //
1093
+ // There is an edge case where a developer sets the attribute inline on a custom element and then programatically
1094
+ // changes it before it has been upgraded as shown below:
1095
+ //
1096
+ // ```html
1097
+ // <!-- this component has _not_ been upgraded yet -->
1098
+ // <my-component id="test" some-attribute="some-value"></my-component>
1099
+ // <script>
1100
+ // // grab non-upgraded component
1101
+ // el = document.querySelector("#test");
1102
+ // el.someAttribute = "another-value";
1103
+ // // upgrade component
1104
+ // cutsomElements.define('my-component', MyComponent);
1105
+ // </script>
1106
+ // ```
1107
+ // In this case if we do not unshadow here and use the value of the shadowing property, attributeChangedCallback
1108
+ // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
1109
+ // to the value that was set inline i.e. "some-value" from above example. When
1110
+ // the connectedCallback attempts to unshadow it will use "some-value" as the intial value rather than "another-value"
1111
+ //
1112
+ // The case where the attribute was NOT set inline but was not set programmatically shall be handled/unshadowed
1113
+ // by connectedCallback as this attributeChangedCallback will not fire.
1114
+ //
1115
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
1116
+ //
1117
+ // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
1118
+ // properties here given that this goes against best practices outlined here
1119
+ // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
1120
+ if (this.hasOwnProperty(propName)) {
1121
+ newValue = this[propName];
1122
+ delete this[propName];
1123
+ }
1058
1124
  this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
1059
1125
  });
1060
1126
  };
@@ -1209,7 +1275,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1209
1275
  let isBootstrapping = true;
1210
1276
  Object.assign(plt, options);
1211
1277
  plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
1212
- lazyBundles.map(lazyBundle => lazyBundle[1].map(compactMeta => {
1278
+ lazyBundles.map((lazyBundle) => lazyBundle[1].map((compactMeta) => {
1213
1279
  const cmpMeta = {
1214
1280
  $flags$: compactMeta[0],
1215
1281
  $tagName$: compactMeta[1],
@@ -1227,6 +1293,17 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1227
1293
  super(self);
1228
1294
  self = this;
1229
1295
  registerHost(self, cmpMeta);
1296
+ if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
1297
+ // this component is using shadow dom
1298
+ // and this browser supports shadow dom
1299
+ // add the read-only property "shadowRoot" to the host element
1300
+ // adding the shadow root build conditionals to minimize runtime
1301
+ {
1302
+ {
1303
+ self.attachShadow({ mode: 'open' });
1304
+ }
1305
+ }
1306
+ }
1230
1307
  }
1231
1308
  connectedCallback() {
1232
1309
  if (appLoadFallback) {
@@ -1262,7 +1339,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
1262
1339
  // Process deferred connectedCallbacks now all components have been registered
1263
1340
  isBootstrapping = false;
1264
1341
  if (deferredConnectedCallbacks.length) {
1265
- deferredConnectedCallbacks.map(host => host.connectedCallback());
1342
+ deferredConnectedCallbacks.map((host) => host.connectedCallback());
1266
1343
  }
1267
1344
  else {
1268
1345
  {
@@ -1283,10 +1360,10 @@ const registerHost = (elm, cmpMeta) => {
1283
1360
  $instanceValues$: new Map(),
1284
1361
  };
1285
1362
  {
1286
- hostRef.$onInstancePromise$ = new Promise(r => (hostRef.$onInstanceResolve$ = r));
1363
+ hostRef.$onInstancePromise$ = new Promise((r) => (hostRef.$onInstanceResolve$ = r));
1287
1364
  }
1288
1365
  {
1289
- hostRef.$onReadyPromise$ = new Promise(r => (hostRef.$onReadyResolve$ = r));
1366
+ hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
1290
1367
  elm['s-p'] = [];
1291
1368
  elm['s-rc'] = [];
1292
1369
  }
@@ -1307,7 +1384,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
1307
1384
  /* webpackInclude: /\.entry\.js$/ */
1308
1385
  /* webpackExclude: /\.system\.entry\.js$/ */
1309
1386
  /* webpackMode: "lazy" */
1310
- `./${bundleId}.entry.js${''}`)); }).then(importedModule => {
1387
+ `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
1311
1388
  {
1312
1389
  cmpModules.set(bundleId, importedModule);
1313
1390
  }