@justifi/webcomponents 0.0.15 → 0.2.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/CHANGELOG.md +45 -0
- package/changelog-template.hbs +41 -0
- package/dist/cjs/{index-e1b45289.js → index-ca2cd154.js} +456 -97
- package/dist/cjs/justifi-bank-account-form.cjs.entry.js +59 -0
- package/dist/cjs/justifi-billing-form.cjs.entry.js +2150 -0
- package/dist/cjs/justifi-card-form.cjs.entry.js +59 -0
- package/dist/cjs/justifi-payment-form.cjs.entry.js +17 -0
- package/dist/cjs/{justifi-bank-account-form_3.cjs.entry.js → justifi-payment-method-form.cjs.entry.js} +86 -110
- package/dist/cjs/justifi-payments-list.cjs.entry.js +1 -1
- package/dist/cjs/loader.cjs.js +3 -4
- package/dist/cjs/select-input_2.cjs.entry.js +59 -0
- package/dist/cjs/webcomponents.cjs.js +3 -7
- package/dist/collection/collection-manifest.json +7 -3
- package/dist/collection/components/bank-account-form/bank-account-form.js +1 -1
- package/dist/collection/components/billing-form/billing-form-schema.js +14 -0
- package/dist/collection/components/billing-form/billing-form.css +11 -0
- package/dist/collection/components/billing-form/billing-form.js +92 -0
- package/dist/collection/components/billing-form/state-options.js +243 -0
- package/dist/collection/components/card-form/card-form.js +1 -1
- package/dist/collection/components/card-form/card-form.stories.js +132 -0
- package/dist/collection/components/payment-form/payment-form.js +31 -0
- package/dist/collection/components/payment-method-form/payment-method-form.js +6 -4
- package/dist/collection/components/select-input/select-input.css +7 -0
- package/dist/collection/components/select-input/select-input.js +144 -0
- package/dist/collection/components/text-input/text-input.css +7 -0
- package/dist/collection/components/text-input/text-input.js +126 -0
- package/dist/components/index.d.ts +4 -9
- package/dist/components/index.js +5 -1
- package/dist/components/justifi-billing-form.d.ts +11 -0
- package/dist/components/justifi-billing-form.js +2180 -0
- package/dist/components/justifi-payment-form.d.ts +11 -0
- package/dist/components/justifi-payment-form.js +32 -0
- package/dist/components/payment-method-form.js +85 -3
- package/dist/components/select-input.d.ts +11 -0
- package/dist/components/select-input.js +6 -0
- package/dist/components/select-input2.js +52 -0
- package/dist/components/text-input.d.ts +11 -0
- package/dist/components/text-input.js +6 -0
- package/dist/components/text-input2.js +48 -0
- package/dist/esm/{index-c1f569bd.js → index-05706eb5.js} +457 -97
- package/dist/esm/justifi-bank-account-form.entry.js +55 -0
- package/dist/esm/justifi-billing-form.entry.js +2146 -0
- package/dist/esm/justifi-card-form.entry.js +55 -0
- package/dist/esm/justifi-payment-form.entry.js +13 -0
- package/dist/esm/justifi-payment-method-form.entry.js +187 -0
- package/dist/esm/justifi-payments-list.entry.js +1 -1
- package/dist/esm/loader.js +3 -4
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/select-input_2.entry.js +54 -0
- package/dist/esm/webcomponents.js +3 -4
- package/dist/types/api/Api.d.ts +1 -1
- package/dist/types/api/Payment.d.ts +1 -1
- package/dist/types/components/billing-form/billing-form-schema.d.ts +15 -0
- package/dist/types/components/billing-form/billing-form.d.ts +17 -0
- package/dist/types/components/billing-form/state-options.d.ts +5 -0
- package/dist/types/components/card-form/card-form.stories.d.ts +14 -0
- package/dist/types/components/payment-form/payment-form.d.ts +4 -0
- package/dist/types/components/payment-method-form/payment-method-form.d.ts +1 -1
- package/dist/types/components/payment-method-form/theme.d.ts +3 -1
- package/dist/types/components/select-input/select-input.d.ts +18 -0
- package/dist/types/components/text-input/text-input.d.ts +14 -0
- package/dist/types/components.d.ts +87 -3
- package/dist/types/stencil-public-runtime.d.ts +3 -59
- package/dist/webcomponents/p-3809130a.entry.js +1 -0
- package/dist/webcomponents/p-67be9585.entry.js +1 -0
- package/dist/webcomponents/p-787671b9.entry.js +1 -0
- package/dist/webcomponents/p-87654bf4.entry.js +1 -0
- package/dist/webcomponents/p-8ee06fd1.js +2 -0
- package/dist/webcomponents/p-94ef2d0e.entry.js +1 -0
- package/dist/webcomponents/p-c07191dc.entry.js +1 -0
- package/dist/webcomponents/p-e5b0f047.entry.js +1 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/loader/index.d.ts +0 -9
- package/package.json +23 -5
- package/LICENSE +0 -21
- package/dist/esm/justifi-bank-account-form_3.entry.js +0 -209
- package/dist/webcomponents/p-1de39730.js +0 -2
- package/dist/webcomponents/p-f0eb5ed0.entry.js +0 -1
- package/dist/webcomponents/p-f91b7b05.entry.js +0 -1
|
@@ -9,7 +9,11 @@ const NAMESPACE = 'webcomponents';
|
|
|
9
9
|
* Modified for Stencil's renderer and slot projection
|
|
10
10
|
*/
|
|
11
11
|
let scopeId;
|
|
12
|
+
let contentRef;
|
|
12
13
|
let hostTagName;
|
|
14
|
+
let useNativeShadowDom = false;
|
|
15
|
+
let checkSlotFallbackVisibility = false;
|
|
16
|
+
let checkSlotRelocate = false;
|
|
13
17
|
let isSvgMode = false;
|
|
14
18
|
let queuePending = false;
|
|
15
19
|
const createTime = (fnName, tagName = '') => {
|
|
@@ -41,18 +45,6 @@ const isComplexType = (o) => {
|
|
|
41
45
|
o = typeof o;
|
|
42
46
|
return o === 'object' || o === 'function';
|
|
43
47
|
};
|
|
44
|
-
/**
|
|
45
|
-
* Helper method for querying a `meta` tag that contains a nonce value
|
|
46
|
-
* out of a DOM's head.
|
|
47
|
-
*
|
|
48
|
-
* @param doc The DOM containing the `head` to query against
|
|
49
|
-
* @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
|
|
50
|
-
* exists or the tag has no content.
|
|
51
|
-
*/
|
|
52
|
-
function queryNonceMetaTagContent(doc) {
|
|
53
|
-
var _a, _b, _c;
|
|
54
|
-
return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
|
|
55
|
-
}
|
|
56
48
|
/**
|
|
57
49
|
* Production h() function based on Preact by
|
|
58
50
|
* Jason Miller (@developit)
|
|
@@ -61,10 +53,12 @@ function queryNonceMetaTagContent(doc) {
|
|
|
61
53
|
*
|
|
62
54
|
* Modified for Stencil's compiler and vdom
|
|
63
55
|
*/
|
|
56
|
+
// const stack: any[] = [];
|
|
64
57
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
|
|
65
58
|
// export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
|
|
66
59
|
const h = (nodeName, vnodeData, ...children) => {
|
|
67
60
|
let child = null;
|
|
61
|
+
let slotName = null;
|
|
68
62
|
let simple = false;
|
|
69
63
|
let lastSimple = false;
|
|
70
64
|
const vNodeChildren = [];
|
|
@@ -92,6 +86,9 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
92
86
|
};
|
|
93
87
|
walk(children);
|
|
94
88
|
if (vnodeData) {
|
|
89
|
+
if (vnodeData.name) {
|
|
90
|
+
slotName = vnodeData.name;
|
|
91
|
+
}
|
|
95
92
|
{
|
|
96
93
|
const classData = vnodeData.className || vnodeData.class;
|
|
97
94
|
if (classData) {
|
|
@@ -109,16 +106,11 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
109
106
|
if (vNodeChildren.length > 0) {
|
|
110
107
|
vnode.$children$ = vNodeChildren;
|
|
111
108
|
}
|
|
109
|
+
{
|
|
110
|
+
vnode.$name$ = slotName;
|
|
111
|
+
}
|
|
112
112
|
return vnode;
|
|
113
113
|
};
|
|
114
|
-
/**
|
|
115
|
-
* A utility function for creating a virtual DOM node from a tag and some
|
|
116
|
-
* possible text content.
|
|
117
|
-
*
|
|
118
|
-
* @param tag the tag for this element
|
|
119
|
-
* @param text possible text content for the node
|
|
120
|
-
* @returns a newly-minted virtual DOM node
|
|
121
|
-
*/
|
|
122
114
|
const newVNode = (tag, text) => {
|
|
123
115
|
const vnode = {
|
|
124
116
|
$flags$: 0,
|
|
@@ -130,15 +122,12 @@ const newVNode = (tag, text) => {
|
|
|
130
122
|
{
|
|
131
123
|
vnode.$attrs$ = null;
|
|
132
124
|
}
|
|
125
|
+
{
|
|
126
|
+
vnode.$name$ = null;
|
|
127
|
+
}
|
|
133
128
|
return vnode;
|
|
134
129
|
};
|
|
135
130
|
const Host = {};
|
|
136
|
-
/**
|
|
137
|
-
* Check whether a given node is a Host node or not
|
|
138
|
-
*
|
|
139
|
-
* @param node the virtual DOM node to check
|
|
140
|
-
* @returns whether it's a Host node or not
|
|
141
|
-
*/
|
|
142
131
|
const isHost = (node) => node && node.$tag$ === Host;
|
|
143
132
|
/**
|
|
144
133
|
* Parse a new property value for a given property type.
|
|
@@ -222,7 +211,6 @@ const registerStyle = (scopeId, cssText, allowCS) => {
|
|
|
222
211
|
styles.set(scopeId, style);
|
|
223
212
|
};
|
|
224
213
|
const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
225
|
-
var _a;
|
|
226
214
|
let scopeId = getScopeId(cmpMeta);
|
|
227
215
|
const style = styles.get(scopeId);
|
|
228
216
|
// if an element is NOT connected then getRootNode() will return the wrong root node
|
|
@@ -242,11 +230,6 @@ const addStyle = (styleContainerNode, cmpMeta, mode, hostElm) => {
|
|
|
242
230
|
styleElm = doc.createElement('style');
|
|
243
231
|
styleElm.innerHTML = style;
|
|
244
232
|
}
|
|
245
|
-
// Apply CSP nonce to the style tag if it exists
|
|
246
|
-
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
247
|
-
if (nonce != null) {
|
|
248
|
-
styleElm.setAttribute('nonce', nonce);
|
|
249
|
-
}
|
|
250
233
|
styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
|
|
251
234
|
}
|
|
252
235
|
if (appliedStyles) {
|
|
@@ -291,7 +274,7 @@ const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
|
|
|
291
274
|
const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
292
275
|
if (oldValue !== newValue) {
|
|
293
276
|
let isProp = isMemberInElement(elm, memberName);
|
|
294
|
-
memberName.toLowerCase();
|
|
277
|
+
let ln = memberName.toLowerCase();
|
|
295
278
|
if (memberName === 'class') {
|
|
296
279
|
const classList = elm.classList;
|
|
297
280
|
const oldClasses = parseClassList(oldValue);
|
|
@@ -299,12 +282,76 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
|
|
|
299
282
|
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
300
283
|
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
301
284
|
}
|
|
285
|
+
else if (memberName === 'style') {
|
|
286
|
+
// update style attribute, css properties and values
|
|
287
|
+
{
|
|
288
|
+
for (const prop in oldValue) {
|
|
289
|
+
if (!newValue || newValue[prop] == null) {
|
|
290
|
+
if (prop.includes('-')) {
|
|
291
|
+
elm.style.removeProperty(prop);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
elm.style[prop] = '';
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
for (const prop in newValue) {
|
|
300
|
+
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
301
|
+
if (prop.includes('-')) {
|
|
302
|
+
elm.style.setProperty(prop, newValue[prop]);
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
elm.style[prop] = newValue[prop];
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
302
310
|
else if (memberName === 'ref') {
|
|
303
311
|
// minifier will clean this up
|
|
304
312
|
if (newValue) {
|
|
305
313
|
newValue(elm);
|
|
306
314
|
}
|
|
307
315
|
}
|
|
316
|
+
else if ((!isProp ) &&
|
|
317
|
+
memberName[0] === 'o' &&
|
|
318
|
+
memberName[1] === 'n') {
|
|
319
|
+
// Event Handlers
|
|
320
|
+
// so if the member name starts with "on" and the 3rd characters is
|
|
321
|
+
// a capital letter, and it's not already a member on the element,
|
|
322
|
+
// then we're assuming it's an event listener
|
|
323
|
+
if (memberName[2] === '-') {
|
|
324
|
+
// on- prefixed events
|
|
325
|
+
// allows to be explicit about the dom event to listen without any magic
|
|
326
|
+
// under the hood:
|
|
327
|
+
// <my-cmp on-click> // listens for "click"
|
|
328
|
+
// <my-cmp on-Click> // listens for "Click"
|
|
329
|
+
// <my-cmp on-ionChange> // listens for "ionChange"
|
|
330
|
+
// <my-cmp on-EVENTS> // listens for "EVENTS"
|
|
331
|
+
memberName = memberName.slice(3);
|
|
332
|
+
}
|
|
333
|
+
else if (isMemberInElement(win, ln)) {
|
|
334
|
+
// standard event
|
|
335
|
+
// the JSX attribute could have been "onMouseOver" and the
|
|
336
|
+
// member name "onmouseover" is on the window's prototype
|
|
337
|
+
// so let's add the listener "mouseover", which is all lowercased
|
|
338
|
+
memberName = ln.slice(2);
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
// custom event
|
|
342
|
+
// the JSX attribute could have been "onMyCustomEvent"
|
|
343
|
+
// so let's trim off the "on" prefix and lowercase the first character
|
|
344
|
+
// and add the listener "myCustomEvent"
|
|
345
|
+
// except for the first character, we keep the event name case
|
|
346
|
+
memberName = ln[2] + memberName.slice(3);
|
|
347
|
+
}
|
|
348
|
+
if (oldValue) {
|
|
349
|
+
plt.rel(elm, memberName, oldValue, false);
|
|
350
|
+
}
|
|
351
|
+
if (newValue) {
|
|
352
|
+
plt.ael(elm, memberName, newValue, false);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
308
355
|
else {
|
|
309
356
|
// Set property if it exists and it's not a SVG
|
|
310
357
|
const isComplex = isComplexType(newValue);
|
|
@@ -382,13 +429,36 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
382
429
|
let i = 0;
|
|
383
430
|
let elm;
|
|
384
431
|
let childNode;
|
|
432
|
+
let oldVNode;
|
|
433
|
+
if (!useNativeShadowDom) {
|
|
434
|
+
// remember for later we need to check to relocate nodes
|
|
435
|
+
checkSlotRelocate = true;
|
|
436
|
+
if (newVNode.$tag$ === 'slot') {
|
|
437
|
+
if (scopeId) {
|
|
438
|
+
// scoped css needs to add its scoped id to the parent element
|
|
439
|
+
parentElm.classList.add(scopeId + '-s');
|
|
440
|
+
}
|
|
441
|
+
newVNode.$flags$ |= newVNode.$children$
|
|
442
|
+
? // slot element has fallback content
|
|
443
|
+
2 /* VNODE_FLAGS.isSlotFallback */
|
|
444
|
+
: // slot element does not have fallback content
|
|
445
|
+
1 /* VNODE_FLAGS.isSlotReference */;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
385
448
|
if (newVNode.$text$ !== null) {
|
|
386
449
|
// create text node
|
|
387
450
|
elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
|
|
388
451
|
}
|
|
452
|
+
else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
|
|
453
|
+
// create a slot reference node
|
|
454
|
+
elm = newVNode.$elm$ =
|
|
455
|
+
doc.createTextNode('');
|
|
456
|
+
}
|
|
389
457
|
else {
|
|
390
458
|
// create element
|
|
391
|
-
elm = newVNode.$elm$ = (doc.createElement(newVNode.$
|
|
459
|
+
elm = newVNode.$elm$ = (doc.createElement(newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
|
|
460
|
+
? 'slot-fb'
|
|
461
|
+
: newVNode.$tag$));
|
|
392
462
|
// add css classes, attrs, props, listeners, etc.
|
|
393
463
|
{
|
|
394
464
|
updateElement(null, newVNode, isSvgMode);
|
|
@@ -401,7 +471,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
401
471
|
if (newVNode.$children$) {
|
|
402
472
|
for (i = 0; i < newVNode.$children$.length; ++i) {
|
|
403
473
|
// create the node
|
|
404
|
-
childNode = createElm(oldParentVNode, newVNode, i);
|
|
474
|
+
childNode = createElm(oldParentVNode, newVNode, i, elm);
|
|
405
475
|
// return node could have been null
|
|
406
476
|
if (childNode) {
|
|
407
477
|
// append our new node
|
|
@@ -410,57 +480,85 @@ const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
|
|
|
410
480
|
}
|
|
411
481
|
}
|
|
412
482
|
}
|
|
483
|
+
{
|
|
484
|
+
elm['s-hn'] = hostTagName;
|
|
485
|
+
if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
|
|
486
|
+
// remember the content reference comment
|
|
487
|
+
elm['s-sr'] = true;
|
|
488
|
+
// remember the content reference comment
|
|
489
|
+
elm['s-cr'] = contentRef;
|
|
490
|
+
// remember the slot name, or empty string for default slot
|
|
491
|
+
elm['s-sn'] = newVNode.$name$ || '';
|
|
492
|
+
// check if we've got an old vnode for this slot
|
|
493
|
+
oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
|
|
494
|
+
if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
|
|
495
|
+
// we've got an old slot vnode and the wrapper is being replaced
|
|
496
|
+
// so let's move the old slot content back to it's original location
|
|
497
|
+
putBackInOriginalLocation(oldParentVNode.$elm$, false);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
413
501
|
return elm;
|
|
414
502
|
};
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
503
|
+
const putBackInOriginalLocation = (parentElm, recursive) => {
|
|
504
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
505
|
+
const oldSlotChildNodes = parentElm.childNodes;
|
|
506
|
+
for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
|
|
507
|
+
const childNode = oldSlotChildNodes[i];
|
|
508
|
+
if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
|
|
509
|
+
// // this child node in the old element is from another component
|
|
510
|
+
// // remove this node from the old slot's parent
|
|
511
|
+
// childNode.remove();
|
|
512
|
+
// and relocate it back to it's original location
|
|
513
|
+
parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
|
|
514
|
+
// remove the old original location comment entirely
|
|
515
|
+
// later on the patch function will know what to do
|
|
516
|
+
// and move this to the correct spot in need be
|
|
517
|
+
childNode['s-ol'].remove();
|
|
518
|
+
childNode['s-ol'] = undefined;
|
|
519
|
+
checkSlotRelocate = true;
|
|
520
|
+
}
|
|
521
|
+
if (recursive) {
|
|
522
|
+
putBackInOriginalLocation(childNode, recursive);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
526
|
+
};
|
|
430
527
|
const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
431
|
-
let containerElm = (parentElm);
|
|
528
|
+
let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
|
|
432
529
|
let childNode;
|
|
433
530
|
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
434
531
|
containerElm = containerElm.shadowRoot;
|
|
435
532
|
}
|
|
436
533
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
437
534
|
if (vnodes[startIdx]) {
|
|
438
|
-
childNode = createElm(null, parentVNode, startIdx);
|
|
535
|
+
childNode = createElm(null, parentVNode, startIdx, parentElm);
|
|
439
536
|
if (childNode) {
|
|
440
537
|
vnodes[startIdx].$elm$ = childNode;
|
|
441
|
-
containerElm.insertBefore(childNode, before);
|
|
538
|
+
containerElm.insertBefore(childNode, referenceNode(before) );
|
|
442
539
|
}
|
|
443
540
|
}
|
|
444
541
|
}
|
|
445
542
|
};
|
|
446
|
-
/**
|
|
447
|
-
* Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
|
|
448
|
-
* This can be used to, for instance, clean up after a list of children which
|
|
449
|
-
* should no longer be shown.
|
|
450
|
-
*
|
|
451
|
-
* This function also handles some of Stencil's slot relocation logic.
|
|
452
|
-
*
|
|
453
|
-
* @param vnodes a list of virtual DOM nodes to remove
|
|
454
|
-
* @param startIdx the index at which to start removing nodes (inclusive)
|
|
455
|
-
* @param endIdx the index at which to stop removing nodes (inclusive)
|
|
456
|
-
* @param vnode a VNode
|
|
457
|
-
* @param elm an element
|
|
458
|
-
*/
|
|
459
543
|
const removeVnodes = (vnodes, startIdx, endIdx, vnode, elm) => {
|
|
460
544
|
for (; startIdx <= endIdx; ++startIdx) {
|
|
461
545
|
if ((vnode = vnodes[startIdx])) {
|
|
462
546
|
elm = vnode.$elm$;
|
|
463
547
|
callNodeRefs(vnode);
|
|
548
|
+
{
|
|
549
|
+
// we're removing this element
|
|
550
|
+
// so it's possible we need to show slot fallback content now
|
|
551
|
+
checkSlotFallbackVisibility = true;
|
|
552
|
+
if (elm['s-ol']) {
|
|
553
|
+
// remove the original location comment
|
|
554
|
+
elm['s-ol'].remove();
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
// it's possible that child nodes of the node
|
|
558
|
+
// that's being removed are slot nodes
|
|
559
|
+
putBackInOriginalLocation(elm, true);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
464
562
|
// remove the vnode's element from the dom
|
|
465
563
|
elm.remove();
|
|
466
564
|
}
|
|
@@ -576,6 +674,23 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
576
674
|
newEndVnode = newCh[--newEndIdx];
|
|
577
675
|
}
|
|
578
676
|
else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
677
|
+
// case: "Vnode moved right"
|
|
678
|
+
//
|
|
679
|
+
// We've found that the last node in our window on the new children is
|
|
680
|
+
// the same VNode as the _first_ node in our window on the old children
|
|
681
|
+
// we're dealing with now. Visually, this is the layout of these two
|
|
682
|
+
// nodes:
|
|
683
|
+
//
|
|
684
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
685
|
+
// ^^^^^^^^^^^
|
|
686
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
687
|
+
// ^^^^^^^^^^^^^
|
|
688
|
+
//
|
|
689
|
+
// In this situation we need to patch `newEndVnode` onto `oldStartVnode`
|
|
690
|
+
// and move the DOM element for `oldStartVnode`.
|
|
691
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
692
|
+
putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
|
|
693
|
+
}
|
|
579
694
|
patch(oldStartVnode, newEndVnode);
|
|
580
695
|
// We need to move the element for `oldStartVnode` into a position which
|
|
581
696
|
// will be appropriate for `newEndVnode`. For this we can use
|
|
@@ -599,6 +714,24 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
599
714
|
newEndVnode = newCh[--newEndIdx];
|
|
600
715
|
}
|
|
601
716
|
else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
717
|
+
// case: "Vnode moved left"
|
|
718
|
+
//
|
|
719
|
+
// We've found that the first node in our window on the new children is
|
|
720
|
+
// the same VNode as the _last_ node in our window on the old children.
|
|
721
|
+
// Visually, this is the layout of these two nodes:
|
|
722
|
+
//
|
|
723
|
+
// newCh: [..., newStartVnode , ... , newEndVnode , ...]
|
|
724
|
+
// ^^^^^^^^^^^^^
|
|
725
|
+
// oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
|
|
726
|
+
// ^^^^^^^^^^^
|
|
727
|
+
//
|
|
728
|
+
// In this situation we need to patch `newStartVnode` onto `oldEndVnode`
|
|
729
|
+
// (which will handle updating any changed attributes, reconciling their
|
|
730
|
+
// children etc) but we also need to move the DOM node to which
|
|
731
|
+
// `oldEndVnode` corresponds.
|
|
732
|
+
if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
|
|
733
|
+
putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
|
|
734
|
+
}
|
|
602
735
|
patch(oldEndVnode, newStartVnode);
|
|
603
736
|
// We've already checked above if `oldStartVnode` and `newStartVnode` are
|
|
604
737
|
// the same node, so since we're here we know that they are not. Thus we
|
|
@@ -615,13 +748,13 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
615
748
|
// the key of the first new child OR the build is not using `key`
|
|
616
749
|
// attributes at all. In either case we need to create a new element
|
|
617
750
|
// for the new node.
|
|
618
|
-
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
751
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
|
|
619
752
|
newStartVnode = newCh[++newStartIdx];
|
|
620
753
|
}
|
|
621
754
|
if (node) {
|
|
622
755
|
// if we created a new node then handle inserting it to the DOM
|
|
623
756
|
{
|
|
624
|
-
oldStartVnode.$elm
|
|
757
|
+
parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
|
|
625
758
|
}
|
|
626
759
|
}
|
|
627
760
|
}
|
|
@@ -648,8 +781,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh) => {
|
|
|
648
781
|
*
|
|
649
782
|
* So, in other words, if `key` attrs are not set on VNodes which may be
|
|
650
783
|
* changing order within a `children` array or something along those lines then
|
|
651
|
-
* we could obtain a false
|
|
652
|
-
* (i.e. we'd say two VNodes aren't equal when in fact they should be).
|
|
784
|
+
* we could obtain a false positive and then have to do needless re-rendering.
|
|
653
785
|
*
|
|
654
786
|
* @param leftVNode the first VNode to check
|
|
655
787
|
* @param rightVNode the second VNode to check
|
|
@@ -659,10 +791,21 @@ const isSameVnode = (leftVNode, rightVNode) => {
|
|
|
659
791
|
// compare if two vnode to see if they're "technically" the same
|
|
660
792
|
// need to have the same element tag, and same key to be the same
|
|
661
793
|
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
794
|
+
if (leftVNode.$tag$ === 'slot') {
|
|
795
|
+
return leftVNode.$name$ === rightVNode.$name$;
|
|
796
|
+
}
|
|
662
797
|
return true;
|
|
663
798
|
}
|
|
664
799
|
return false;
|
|
665
800
|
};
|
|
801
|
+
const referenceNode = (node) => {
|
|
802
|
+
// this node was relocated to a new location in the dom
|
|
803
|
+
// because of some other component's slot
|
|
804
|
+
// but we still have an html comment in place of where
|
|
805
|
+
// it's original location was according to it's original vdom
|
|
806
|
+
return (node && node['s-ol']) || node;
|
|
807
|
+
};
|
|
808
|
+
const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
|
|
666
809
|
/**
|
|
667
810
|
* Handle reconciling an outdated VNode with a new one which corresponds to
|
|
668
811
|
* it. This function handles flushing updates to the DOM and reconciling the
|
|
@@ -675,10 +818,14 @@ const patch = (oldVNode, newVNode) => {
|
|
|
675
818
|
const elm = (newVNode.$elm$ = oldVNode.$elm$);
|
|
676
819
|
const oldChildren = oldVNode.$children$;
|
|
677
820
|
const newChildren = newVNode.$children$;
|
|
821
|
+
const tag = newVNode.$tag$;
|
|
678
822
|
const text = newVNode.$text$;
|
|
823
|
+
let defaultHolder;
|
|
679
824
|
if (text === null) {
|
|
680
825
|
{
|
|
681
|
-
|
|
826
|
+
if (tag === 'slot')
|
|
827
|
+
;
|
|
828
|
+
else {
|
|
682
829
|
// either this is the first render of an element OR it's an update
|
|
683
830
|
// AND we already know it's possible it could have changed
|
|
684
831
|
// this updates the element's css classes, attrs, props, listeners, etc.
|
|
@@ -704,32 +851,156 @@ const patch = (oldVNode, newVNode) => {
|
|
|
704
851
|
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
705
852
|
}
|
|
706
853
|
}
|
|
854
|
+
else if ((defaultHolder = elm['s-cr'])) {
|
|
855
|
+
// this element has slotted content
|
|
856
|
+
defaultHolder.parentNode.textContent = text;
|
|
857
|
+
}
|
|
707
858
|
else if (oldVNode.$text$ !== text) {
|
|
708
859
|
// update the text content for the text only vnode
|
|
709
860
|
// and also only if the text is different than before
|
|
710
861
|
elm.data = text;
|
|
711
862
|
}
|
|
712
863
|
};
|
|
864
|
+
const updateFallbackSlotVisibility = (elm) => {
|
|
865
|
+
// tslint:disable-next-line: prefer-const
|
|
866
|
+
const childNodes = elm.childNodes;
|
|
867
|
+
let childNode;
|
|
868
|
+
let i;
|
|
869
|
+
let ilen;
|
|
870
|
+
let j;
|
|
871
|
+
let slotNameAttr;
|
|
872
|
+
let nodeType;
|
|
873
|
+
for (i = 0, ilen = childNodes.length; i < ilen; i++) {
|
|
874
|
+
childNode = childNodes[i];
|
|
875
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
876
|
+
if (childNode['s-sr']) {
|
|
877
|
+
// this is a slot fallback node
|
|
878
|
+
// get the slot name for this slot reference node
|
|
879
|
+
slotNameAttr = childNode['s-sn'];
|
|
880
|
+
// by default always show a fallback slot node
|
|
881
|
+
// then hide it if there are other slots in the light dom
|
|
882
|
+
childNode.hidden = false;
|
|
883
|
+
for (j = 0; j < ilen; j++) {
|
|
884
|
+
nodeType = childNodes[j].nodeType;
|
|
885
|
+
if (childNodes[j]['s-hn'] !== childNode['s-hn'] || slotNameAttr !== '') {
|
|
886
|
+
// this sibling node is from a different component OR is a named fallback slot node
|
|
887
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ && slotNameAttr === childNodes[j].getAttribute('slot')) {
|
|
888
|
+
childNode.hidden = true;
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
else {
|
|
893
|
+
// this is a default fallback slot node
|
|
894
|
+
// any element or text node (with content)
|
|
895
|
+
// should hide the default fallback slot node
|
|
896
|
+
if (nodeType === 1 /* NODE_TYPE.ElementNode */ ||
|
|
897
|
+
(nodeType === 3 /* NODE_TYPE.TextNode */ && childNodes[j].textContent.trim() !== '')) {
|
|
898
|
+
childNode.hidden = true;
|
|
899
|
+
break;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
// keep drilling down
|
|
905
|
+
updateFallbackSlotVisibility(childNode);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
const relocateNodes = [];
|
|
910
|
+
const relocateSlotContent = (elm) => {
|
|
911
|
+
// tslint:disable-next-line: prefer-const
|
|
912
|
+
let childNode;
|
|
913
|
+
let node;
|
|
914
|
+
let hostContentNodes;
|
|
915
|
+
let slotNameAttr;
|
|
916
|
+
let relocateNodeData;
|
|
917
|
+
let j;
|
|
918
|
+
let i = 0;
|
|
919
|
+
const childNodes = elm.childNodes;
|
|
920
|
+
const ilen = childNodes.length;
|
|
921
|
+
for (; i < ilen; i++) {
|
|
922
|
+
childNode = childNodes[i];
|
|
923
|
+
if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
|
|
924
|
+
// first got the content reference comment node
|
|
925
|
+
// then we got it's parent, which is where all the host content is in now
|
|
926
|
+
hostContentNodes = node.parentNode.childNodes;
|
|
927
|
+
slotNameAttr = childNode['s-sn'];
|
|
928
|
+
for (j = hostContentNodes.length - 1; j >= 0; j--) {
|
|
929
|
+
node = hostContentNodes[j];
|
|
930
|
+
if (!node['s-cn'] && !node['s-nr'] && node['s-hn'] !== childNode['s-hn']) {
|
|
931
|
+
// let's do some relocating to its new home
|
|
932
|
+
// but never relocate a content reference node
|
|
933
|
+
// that is suppose to always represent the original content location
|
|
934
|
+
if (isNodeLocatedInSlot(node, slotNameAttr)) {
|
|
935
|
+
// it's possible we've already decided to relocate this node
|
|
936
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
937
|
+
// made some changes to slots
|
|
938
|
+
// let's make sure we also double check
|
|
939
|
+
// fallbacks are correctly hidden or shown
|
|
940
|
+
checkSlotFallbackVisibility = true;
|
|
941
|
+
node['s-sn'] = node['s-sn'] || slotNameAttr;
|
|
942
|
+
if (relocateNodeData) {
|
|
943
|
+
// previously we never found a slot home for this node
|
|
944
|
+
// but turns out we did, so let's remember it now
|
|
945
|
+
relocateNodeData.$slotRefNode$ = childNode;
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
// add to our list of nodes to relocate
|
|
949
|
+
relocateNodes.push({
|
|
950
|
+
$slotRefNode$: childNode,
|
|
951
|
+
$nodeToRelocate$: node,
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
if (node['s-sr']) {
|
|
955
|
+
relocateNodes.map((relocateNode) => {
|
|
956
|
+
if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
|
|
957
|
+
relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
|
|
958
|
+
if (relocateNodeData && !relocateNode.$slotRefNode$) {
|
|
959
|
+
relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
|
|
966
|
+
// so far this element does not have a slot home, not setting slotRefNode on purpose
|
|
967
|
+
// if we never find a home for this element then we'll need to hide it
|
|
968
|
+
relocateNodes.push({
|
|
969
|
+
$nodeToRelocate$: node,
|
|
970
|
+
});
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
976
|
+
relocateSlotContent(childNode);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
const isNodeLocatedInSlot = (nodeToRelocate, slotNameAttr) => {
|
|
981
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
982
|
+
if (nodeToRelocate.getAttribute('slot') === null && slotNameAttr === '') {
|
|
983
|
+
return true;
|
|
984
|
+
}
|
|
985
|
+
if (nodeToRelocate.getAttribute('slot') === slotNameAttr) {
|
|
986
|
+
return true;
|
|
987
|
+
}
|
|
988
|
+
return false;
|
|
989
|
+
}
|
|
990
|
+
if (nodeToRelocate['s-sn'] === slotNameAttr) {
|
|
991
|
+
return true;
|
|
992
|
+
}
|
|
993
|
+
return slotNameAttr === '';
|
|
994
|
+
};
|
|
713
995
|
const callNodeRefs = (vNode) => {
|
|
714
996
|
{
|
|
715
997
|
vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
|
|
716
998
|
vNode.$children$ && vNode.$children$.map(callNodeRefs);
|
|
717
999
|
}
|
|
718
1000
|
};
|
|
719
|
-
/**
|
|
720
|
-
* The main entry point for Stencil's virtual DOM-based rendering engine
|
|
721
|
-
*
|
|
722
|
-
* Given a {@link d.HostRef} container and some virtual DOM nodes, this
|
|
723
|
-
* function will handle creating a virtual DOM tree with a single root, patching
|
|
724
|
-
* the current virtual DOM tree onto an old one (if any), dealing with slot
|
|
725
|
-
* relocation, and reflecting attributes.
|
|
726
|
-
*
|
|
727
|
-
* @param hostRef data needed to root and render the virtual DOM tree, such as
|
|
728
|
-
* the DOM node into which it should be rendered.
|
|
729
|
-
* @param renderFnResults the virtual DOM nodes to be rendered
|
|
730
|
-
*/
|
|
731
1001
|
const renderVdom = (hostRef, renderFnResults) => {
|
|
732
1002
|
const hostElm = hostRef.$hostElement$;
|
|
1003
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
733
1004
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
734
1005
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
735
1006
|
hostTagName = hostElm.tagName;
|
|
@@ -740,8 +1011,90 @@ const renderVdom = (hostRef, renderFnResults) => {
|
|
|
740
1011
|
{
|
|
741
1012
|
scopeId = hostElm['s-sc'];
|
|
742
1013
|
}
|
|
1014
|
+
{
|
|
1015
|
+
contentRef = hostElm['s-cr'];
|
|
1016
|
+
useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
|
|
1017
|
+
// always reset
|
|
1018
|
+
checkSlotFallbackVisibility = false;
|
|
1019
|
+
}
|
|
743
1020
|
// synchronous patch
|
|
744
1021
|
patch(oldVNode, rootVnode);
|
|
1022
|
+
{
|
|
1023
|
+
// while we're moving nodes around existing nodes, temporarily disable
|
|
1024
|
+
// the disconnectCallback from working
|
|
1025
|
+
plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1026
|
+
if (checkSlotRelocate) {
|
|
1027
|
+
relocateSlotContent(rootVnode.$elm$);
|
|
1028
|
+
let relocateData;
|
|
1029
|
+
let nodeToRelocate;
|
|
1030
|
+
let orgLocationNode;
|
|
1031
|
+
let parentNodeRef;
|
|
1032
|
+
let insertBeforeNode;
|
|
1033
|
+
let refNode;
|
|
1034
|
+
let i = 0;
|
|
1035
|
+
for (; i < relocateNodes.length; i++) {
|
|
1036
|
+
relocateData = relocateNodes[i];
|
|
1037
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1038
|
+
if (!nodeToRelocate['s-ol']) {
|
|
1039
|
+
// add a reference node marking this node's original location
|
|
1040
|
+
// keep a reference to this node for later lookups
|
|
1041
|
+
orgLocationNode =
|
|
1042
|
+
doc.createTextNode('');
|
|
1043
|
+
orgLocationNode['s-nr'] = nodeToRelocate;
|
|
1044
|
+
nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
for (i = 0; i < relocateNodes.length; i++) {
|
|
1048
|
+
relocateData = relocateNodes[i];
|
|
1049
|
+
nodeToRelocate = relocateData.$nodeToRelocate$;
|
|
1050
|
+
if (relocateData.$slotRefNode$) {
|
|
1051
|
+
// by default we're just going to insert it directly
|
|
1052
|
+
// after the slot reference node
|
|
1053
|
+
parentNodeRef = relocateData.$slotRefNode$.parentNode;
|
|
1054
|
+
insertBeforeNode = relocateData.$slotRefNode$.nextSibling;
|
|
1055
|
+
orgLocationNode = nodeToRelocate['s-ol'];
|
|
1056
|
+
while ((orgLocationNode = orgLocationNode.previousSibling)) {
|
|
1057
|
+
refNode = orgLocationNode['s-nr'];
|
|
1058
|
+
if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
|
|
1059
|
+
refNode = refNode.nextSibling;
|
|
1060
|
+
if (!refNode || !refNode['s-nr']) {
|
|
1061
|
+
insertBeforeNode = refNode;
|
|
1062
|
+
break;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
|
|
1067
|
+
nodeToRelocate.nextSibling !== insertBeforeNode) {
|
|
1068
|
+
// we've checked that it's worth while to relocate
|
|
1069
|
+
// since that the node to relocate
|
|
1070
|
+
// has a different next sibling or parent relocated
|
|
1071
|
+
if (nodeToRelocate !== insertBeforeNode) {
|
|
1072
|
+
if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
|
|
1073
|
+
// probably a component in the index.html that doesn't have it's hostname set
|
|
1074
|
+
nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
|
|
1075
|
+
}
|
|
1076
|
+
// add it back to the dom but in its new home
|
|
1077
|
+
parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
else {
|
|
1082
|
+
// this node doesn't have a slot home to go to, so let's hide it
|
|
1083
|
+
if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
|
|
1084
|
+
nodeToRelocate.hidden = true;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
if (checkSlotFallbackVisibility) {
|
|
1090
|
+
updateFallbackSlotVisibility(rootVnode.$elm$);
|
|
1091
|
+
}
|
|
1092
|
+
// done moving nodes around
|
|
1093
|
+
// allow the disconnect callback to work again
|
|
1094
|
+
plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
|
|
1095
|
+
// always reset
|
|
1096
|
+
relocateNodes.length = 0;
|
|
1097
|
+
}
|
|
745
1098
|
};
|
|
746
1099
|
const attachToAncestor = (hostRef, ancestorComponent) => {
|
|
747
1100
|
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
|
|
@@ -1159,6 +1512,15 @@ const connectedCallback = (elm) => {
|
|
|
1159
1512
|
if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
|
|
1160
1513
|
// first time this component has connected
|
|
1161
1514
|
hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
|
|
1515
|
+
{
|
|
1516
|
+
// initUpdate
|
|
1517
|
+
// if the slot polyfill is required we'll need to put some nodes
|
|
1518
|
+
// in here to act as original content anchors as we move nodes around
|
|
1519
|
+
// host element has been connected to the DOM
|
|
1520
|
+
if ((cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
|
|
1521
|
+
setContentReference(elm);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1162
1524
|
{
|
|
1163
1525
|
// find the first ancestor component (if there is one) and register
|
|
1164
1526
|
// this component as one of the actively loading child components for its ancestor
|
|
@@ -1200,6 +1562,17 @@ const connectedCallback = (elm) => {
|
|
|
1200
1562
|
endConnected();
|
|
1201
1563
|
}
|
|
1202
1564
|
};
|
|
1565
|
+
const setContentReference = (elm) => {
|
|
1566
|
+
// only required when we're NOT using native shadow dom (slot)
|
|
1567
|
+
// or this browser doesn't support native shadow dom
|
|
1568
|
+
// and this host element was NOT created with SSR
|
|
1569
|
+
// let's pick out the inner content for slot projection
|
|
1570
|
+
// create a node to represent where the original
|
|
1571
|
+
// content was first placed, which is useful later on
|
|
1572
|
+
const contentRefElm = (elm['s-cr'] = doc.createComment(''));
|
|
1573
|
+
contentRefElm['s-cn'] = true;
|
|
1574
|
+
elm.insertBefore(contentRefElm, elm.firstChild);
|
|
1575
|
+
};
|
|
1203
1576
|
const disconnectedCallback = (elm) => {
|
|
1204
1577
|
if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
|
|
1205
1578
|
const hostRef = getHostRef(elm);
|
|
@@ -1216,7 +1589,6 @@ const disconnectedCallback = (elm) => {
|
|
|
1216
1589
|
}
|
|
1217
1590
|
};
|
|
1218
1591
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
1219
|
-
var _a;
|
|
1220
1592
|
const endBootstrap = createTime();
|
|
1221
1593
|
const cmpTags = [];
|
|
1222
1594
|
const exclude = options.exclude || [];
|
|
@@ -1296,11 +1668,6 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1296
1668
|
{
|
|
1297
1669
|
visibilityStyle.innerHTML = cmpTags + HYDRATED_CSS;
|
|
1298
1670
|
visibilityStyle.setAttribute('data-styles', '');
|
|
1299
|
-
// Apply CSP nonce to the style tag if it exists
|
|
1300
|
-
const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
|
|
1301
|
-
if (nonce != null) {
|
|
1302
|
-
visibilityStyle.setAttribute('nonce', nonce);
|
|
1303
|
-
}
|
|
1304
1671
|
head.insertBefore(visibilityStyle, metaCharset ? metaCharset.nextSibling : head.firstChild);
|
|
1305
1672
|
}
|
|
1306
1673
|
// Process deferred connectedCallbacks now all components have been registered
|
|
@@ -1345,13 +1712,6 @@ const hostListenerProxy = (hostRef, methodName) => (ev) => {
|
|
|
1345
1712
|
};
|
|
1346
1713
|
// prettier-ignore
|
|
1347
1714
|
const hostListenerOpts = (flags) => (flags & 2 /* LISTENER_FLAGS.Capture */) !== 0;
|
|
1348
|
-
/**
|
|
1349
|
-
* Assigns the given value to the nonce property on the runtime platform object.
|
|
1350
|
-
* During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
|
|
1351
|
-
* @param nonce The value to be assigned to the platform nonce property.
|
|
1352
|
-
* @returns void
|
|
1353
|
-
*/
|
|
1354
|
-
const setNonce = (nonce) => (plt.$nonce$ = nonce);
|
|
1355
1715
|
const hostRefs = /*@__PURE__*/ new WeakMap();
|
|
1356
1716
|
const getHostRef = (ref) => hostRefs.get(ref);
|
|
1357
1717
|
const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
|
|
@@ -1462,4 +1822,4 @@ const flush = () => {
|
|
|
1462
1822
|
const nextTick = /*@__PURE__*/ (cb) => promiseResolve().then(cb);
|
|
1463
1823
|
const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
|
|
1464
1824
|
|
|
1465
|
-
export { Host as H, bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r
|
|
1825
|
+
export { Host as H, bootstrapLazy as b, createEvent as c, h, promiseResolve as p, registerInstance as r };
|