lwc 2.7.4 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-dom/esm/es2017/engine-dom.js +663 -470
- package/dist/engine-dom/iife/es2017/engine-dom.js +663 -470
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +544 -426
- package/dist/engine-dom/iife/es5/engine-dom.js +816 -594
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +624 -497
- package/dist/engine-dom/umd/es2017/engine-dom.js +663 -470
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +544 -426
- package/dist/engine-dom/umd/es5/engine-dom.js +816 -594
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +624 -497
- package/dist/engine-server/commonjs/es2017/engine-server.js +427 -299
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +427 -299
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +8 -8
- package/LICENSE +0 -10
|
@@ -303,7 +303,17 @@ function htmlPropertyToAttribute(propName) {
|
|
|
303
303
|
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
304
304
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
305
305
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
306
|
-
|
|
306
|
+
/*
|
|
307
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
308
|
+
* All rights reserved.
|
|
309
|
+
* SPDX-License-Identifier: MIT
|
|
310
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
311
|
+
*/
|
|
312
|
+
// Increment whenever the LWC template compiler changes
|
|
313
|
+
|
|
314
|
+
const LWC_VERSION = "2.10.0";
|
|
315
|
+
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
316
|
+
/** version: 2.10.0 */
|
|
307
317
|
|
|
308
318
|
/*
|
|
309
319
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -370,7 +380,7 @@ function createAriaPropertyPropertyDescriptor(propName, attrName) {
|
|
|
370
380
|
};
|
|
371
381
|
}
|
|
372
382
|
|
|
373
|
-
function patch(propName) {
|
|
383
|
+
function patch$1(propName) {
|
|
374
384
|
// Typescript is inferring the wrong function type for this particular
|
|
375
385
|
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
|
|
376
386
|
// @ts-ignore type-mismatch
|
|
@@ -392,7 +402,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
|
|
|
392
402
|
const propName = ElementPrototypeAriaPropertyNames[i];
|
|
393
403
|
|
|
394
404
|
if (detect(propName)) {
|
|
395
|
-
patch(propName);
|
|
405
|
+
patch$1(propName);
|
|
396
406
|
}
|
|
397
407
|
}
|
|
398
408
|
/**
|
|
@@ -408,14 +418,15 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
|
|
|
408
418
|
|
|
409
419
|
|
|
410
420
|
const features = {
|
|
411
|
-
|
|
412
|
-
ENABLE_HMR: null,
|
|
413
|
-
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
421
|
+
DISABLE_MIXED_SHADOW_MODE: null,
|
|
414
422
|
ENABLE_ELEMENT_PATCH: null,
|
|
415
423
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
416
|
-
|
|
424
|
+
ENABLE_HMR: null,
|
|
417
425
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
426
|
+
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
427
|
+
ENABLE_NODE_LIST_PATCH: null,
|
|
418
428
|
ENABLE_NODE_PATCH: null,
|
|
429
|
+
ENABLE_REACTIVE_SETTER: null,
|
|
419
430
|
ENABLE_WIRE_SYNC_EMIT: null
|
|
420
431
|
};
|
|
421
432
|
|
|
@@ -480,7 +491,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
480
491
|
setFeatureFlag(name, value);
|
|
481
492
|
}
|
|
482
493
|
}
|
|
483
|
-
/** version: 2.
|
|
494
|
+
/** version: 2.10.0 */
|
|
484
495
|
|
|
485
496
|
/* proxy-compat-disable */
|
|
486
497
|
|
|
@@ -554,6 +565,33 @@ function parseStyleText(cssText) {
|
|
|
554
565
|
}
|
|
555
566
|
|
|
556
567
|
return styleMap;
|
|
568
|
+
} // Make a shallow copy of an object but omit the given key
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
|
572
|
+
const result = {};
|
|
573
|
+
|
|
574
|
+
for (const key of Object.keys(object)) {
|
|
575
|
+
if (key !== keyToOmit) {
|
|
576
|
+
result[key] = object[key];
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return result;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function flattenStylesheets(stylesheets) {
|
|
584
|
+
const list = [];
|
|
585
|
+
|
|
586
|
+
for (const stylesheet of stylesheets) {
|
|
587
|
+
if (!Array.isArray(stylesheet)) {
|
|
588
|
+
list.push(stylesheet);
|
|
589
|
+
} else {
|
|
590
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return list;
|
|
557
595
|
} //
|
|
558
596
|
// Primitives
|
|
559
597
|
//
|
|
@@ -3359,6 +3397,47 @@ function getDecoratorsMeta(Ctor) {
|
|
|
3359
3397
|
const meta = signedDecoratorToMetaMap.get(Ctor);
|
|
3360
3398
|
return isUndefined$1(meta) ? defaultMeta : meta;
|
|
3361
3399
|
}
|
|
3400
|
+
/*
|
|
3401
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3402
|
+
* All rights reserved.
|
|
3403
|
+
* SPDX-License-Identifier: MIT
|
|
3404
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3405
|
+
*/
|
|
3406
|
+
|
|
3407
|
+
|
|
3408
|
+
let warned = false;
|
|
3409
|
+
|
|
3410
|
+
if (process.env.NODE_ENV === 'development') {
|
|
3411
|
+
// @ts-ignore
|
|
3412
|
+
window.__lwcResetWarnedOnVersionMismatch = () => {
|
|
3413
|
+
warned = false;
|
|
3414
|
+
};
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
function checkVersionMismatch(func, type) {
|
|
3418
|
+
const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
|
|
3419
|
+
|
|
3420
|
+
if (!isNull(versionMatcher) && !warned) {
|
|
3421
|
+
const version = versionMatcher[1];
|
|
3422
|
+
const [major, minor] = version.split('.');
|
|
3423
|
+
const [expectedMajor, expectedMinor] = LWC_VERSION.split('.');
|
|
3424
|
+
|
|
3425
|
+
if (major !== expectedMajor || minor !== expectedMinor) {
|
|
3426
|
+
warned = true; // only warn once to avoid flooding the console
|
|
3427
|
+
// stylesheets and templates do not have user-meaningful names, but components do
|
|
3428
|
+
|
|
3429
|
+
const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
|
|
3430
|
+
logError(`LWC WARNING: current engine is v${LWC_VERSION}, but ${friendlyName} was compiled with v${version}.\nPlease update your compiled code or LWC engine so that the versions match.\nNo further warnings will appear.`);
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
/*
|
|
3435
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3436
|
+
* All rights reserved.
|
|
3437
|
+
* SPDX-License-Identifier: MIT
|
|
3438
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3439
|
+
*/
|
|
3440
|
+
|
|
3362
3441
|
|
|
3363
3442
|
const signedTemplateSet = new Set();
|
|
3364
3443
|
|
|
@@ -3371,6 +3450,16 @@ signedTemplateSet.add(defaultEmptyTemplate);
|
|
|
3371
3450
|
function isTemplateRegistered(tpl) {
|
|
3372
3451
|
return signedTemplateSet.has(tpl);
|
|
3373
3452
|
}
|
|
3453
|
+
|
|
3454
|
+
function checkTemplateVersionMismatch(template) {
|
|
3455
|
+
checkVersionMismatch(template, 'template');
|
|
3456
|
+
|
|
3457
|
+
if (!isUndefined$1(template.stylesheets)) {
|
|
3458
|
+
for (const stylesheet of flattenStylesheets(template.stylesheets)) {
|
|
3459
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3460
|
+
}
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3374
3463
|
/**
|
|
3375
3464
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
3376
3465
|
* will prevent this function from being imported by userland code.
|
|
@@ -3378,6 +3467,10 @@ function isTemplateRegistered(tpl) {
|
|
|
3378
3467
|
|
|
3379
3468
|
|
|
3380
3469
|
function registerTemplate(tpl) {
|
|
3470
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3471
|
+
checkTemplateVersionMismatch(tpl);
|
|
3472
|
+
}
|
|
3473
|
+
|
|
3381
3474
|
signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
|
|
3382
3475
|
// assignment of templates easily, without too much transformation
|
|
3383
3476
|
|
|
@@ -3673,20 +3766,6 @@ function rehydrateHotComponent(Ctor) {
|
|
|
3673
3766
|
return canRefreshAllInstances;
|
|
3674
3767
|
}
|
|
3675
3768
|
|
|
3676
|
-
function flattenStylesheets(stylesheets) {
|
|
3677
|
-
const list = [];
|
|
3678
|
-
|
|
3679
|
-
for (const stylesheet of stylesheets) {
|
|
3680
|
-
if (!Array.isArray(stylesheet)) {
|
|
3681
|
-
list.push(stylesheet);
|
|
3682
|
-
} else {
|
|
3683
|
-
list.push(...flattenStylesheets(stylesheet));
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
|
-
|
|
3687
|
-
return list;
|
|
3688
|
-
}
|
|
3689
|
-
|
|
3690
3769
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
3691
3770
|
if (process.env.NODE_ENV === 'production') {
|
|
3692
3771
|
// this method should never leak to prod
|
|
@@ -4517,156 +4596,268 @@ function applyStaticStyleAttribute(vnode) {
|
|
|
4517
4596
|
*/
|
|
4518
4597
|
|
|
4519
4598
|
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
const elm = createText$1(vnode.text);
|
|
4526
|
-
linkNodeToShadow(elm, owner);
|
|
4527
|
-
vnode.elm = elm;
|
|
4528
|
-
},
|
|
4529
|
-
update: updateNodeHook,
|
|
4530
|
-
insert: insertNode,
|
|
4531
|
-
move: insertNode,
|
|
4532
|
-
remove: removeNode
|
|
4533
|
-
};
|
|
4534
|
-
const CommentHook = {
|
|
4535
|
-
create: vnode => {
|
|
4536
|
-
const {
|
|
4537
|
-
owner,
|
|
4538
|
-
text
|
|
4539
|
-
} = vnode;
|
|
4540
|
-
const elm = createComment$1(text);
|
|
4541
|
-
linkNodeToShadow(elm, owner);
|
|
4542
|
-
vnode.elm = elm;
|
|
4543
|
-
},
|
|
4544
|
-
update: updateNodeHook,
|
|
4545
|
-
insert: insertNode,
|
|
4546
|
-
move: insertNode,
|
|
4547
|
-
remove: removeNode
|
|
4548
|
-
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4549
|
-
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4550
|
-
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
4551
|
-
// which breaks some invariants. For that reason, we have the following for any
|
|
4552
|
-
// Custom Element that is inserted via a template.
|
|
4553
|
-
|
|
4554
|
-
const ElementHook = {
|
|
4555
|
-
create: vnode => {
|
|
4556
|
-
const {
|
|
4557
|
-
sel,
|
|
4558
|
-
owner,
|
|
4559
|
-
data: {
|
|
4560
|
-
svg
|
|
4561
|
-
}
|
|
4562
|
-
} = vnode;
|
|
4563
|
-
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4564
|
-
const elm = createElement$2(sel, namespace);
|
|
4565
|
-
linkNodeToShadow(elm, owner);
|
|
4566
|
-
fallbackElmHook(elm, vnode);
|
|
4567
|
-
vnode.elm = elm;
|
|
4568
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
4569
|
-
},
|
|
4570
|
-
update: (oldVnode, vnode) => {
|
|
4571
|
-
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
4572
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4573
|
-
},
|
|
4574
|
-
insert: (vnode, parentNode, referenceNode) => {
|
|
4575
|
-
insertNode(vnode, parentNode, referenceNode);
|
|
4576
|
-
createChildrenHook(vnode);
|
|
4577
|
-
},
|
|
4578
|
-
move: insertNode,
|
|
4579
|
-
remove: (vnode, parentNode) => {
|
|
4580
|
-
removeNode(vnode, parentNode);
|
|
4581
|
-
removeChildren(vnode);
|
|
4599
|
+
function patchChildren(c1, c2, parent) {
|
|
4600
|
+
if (hasDynamicChildren(c2)) {
|
|
4601
|
+
updateDynamicChildren(c1, c2, parent);
|
|
4602
|
+
} else {
|
|
4603
|
+
updateStaticChildren(c1, c2, parent);
|
|
4582
4604
|
}
|
|
4583
|
-
}
|
|
4584
|
-
const CustomElementHook = {
|
|
4585
|
-
create: vnode => {
|
|
4586
|
-
const {
|
|
4587
|
-
sel,
|
|
4588
|
-
owner
|
|
4589
|
-
} = vnode;
|
|
4590
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
4591
|
-
/**
|
|
4592
|
-
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4593
|
-
* with a callback as the first argument, we could implement a more advanced
|
|
4594
|
-
* mechanism that only passes that argument if the constructor is known to be
|
|
4595
|
-
* an upgradable custom element.
|
|
4596
|
-
*/
|
|
4597
|
-
|
|
4598
|
-
let vm;
|
|
4599
|
-
const elm = new UpgradableConstructor(elm => {
|
|
4600
|
-
// the custom element from the registry is expecting an upgrade callback
|
|
4601
|
-
vm = createViewModelHook(elm, vnode);
|
|
4602
|
-
});
|
|
4603
|
-
linkNodeToShadow(elm, owner);
|
|
4604
|
-
vnode.elm = elm;
|
|
4605
|
+
}
|
|
4605
4606
|
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4607
|
+
function patch(n1, n2) {
|
|
4608
|
+
if (n1 === n2) {
|
|
4609
|
+
return;
|
|
4610
|
+
}
|
|
4611
|
+
|
|
4612
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4613
|
+
if (!isSameVnode(n1, n2)) {
|
|
4614
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
4615
|
+
sel: n1.sel,
|
|
4616
|
+
key: n1.key
|
|
4617
|
+
}) + ', ' + JSON.stringify({
|
|
4618
|
+
sel: n2.sel,
|
|
4619
|
+
key: n2.key
|
|
4620
|
+
}));
|
|
4610
4621
|
}
|
|
4622
|
+
}
|
|
4611
4623
|
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4624
|
+
switch (n2.type) {
|
|
4625
|
+
case 0
|
|
4626
|
+
/* Text */
|
|
4627
|
+
:
|
|
4628
|
+
patchText(n1, n2);
|
|
4629
|
+
break;
|
|
4630
|
+
|
|
4631
|
+
case 1
|
|
4632
|
+
/* Comment */
|
|
4633
|
+
:
|
|
4634
|
+
patchComment(n1, n2);
|
|
4635
|
+
break;
|
|
4636
|
+
|
|
4637
|
+
case 2
|
|
4638
|
+
/* Element */
|
|
4639
|
+
:
|
|
4640
|
+
patchElement(n1, n2);
|
|
4641
|
+
break;
|
|
4642
|
+
|
|
4643
|
+
case 3
|
|
4644
|
+
/* CustomElement */
|
|
4645
|
+
:
|
|
4646
|
+
patchCustomElement(n1, n2);
|
|
4647
|
+
break;
|
|
4648
|
+
}
|
|
4649
|
+
}
|
|
4617
4650
|
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4651
|
+
function mount(node, parent, anchor) {
|
|
4652
|
+
switch (node.type) {
|
|
4653
|
+
case 0
|
|
4654
|
+
/* Text */
|
|
4655
|
+
:
|
|
4656
|
+
mountText(node, parent, anchor);
|
|
4657
|
+
break;
|
|
4624
4658
|
|
|
4659
|
+
case 1
|
|
4660
|
+
/* Comment */
|
|
4661
|
+
:
|
|
4662
|
+
mountComment(node, parent, anchor);
|
|
4663
|
+
break;
|
|
4625
4664
|
|
|
4626
|
-
|
|
4665
|
+
case 2
|
|
4666
|
+
/* Element */
|
|
4667
|
+
:
|
|
4668
|
+
mountElement(node, parent, anchor);
|
|
4669
|
+
break;
|
|
4627
4670
|
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4671
|
+
case 3
|
|
4672
|
+
/* CustomElement */
|
|
4673
|
+
:
|
|
4674
|
+
mountCustomElement(node, parent, anchor);
|
|
4675
|
+
break;
|
|
4676
|
+
}
|
|
4677
|
+
}
|
|
4678
|
+
|
|
4679
|
+
function patchText(n1, n2) {
|
|
4680
|
+
n2.elm = n1.elm;
|
|
4681
|
+
|
|
4682
|
+
if (n2.text !== n1.text) {
|
|
4683
|
+
updateTextContent(n2);
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
|
|
4687
|
+
function mountText(node, parent, anchor) {
|
|
4688
|
+
const {
|
|
4689
|
+
owner
|
|
4690
|
+
} = node;
|
|
4691
|
+
const textNode = node.elm = createText$1(node.text);
|
|
4692
|
+
linkNodeToShadow(textNode, owner);
|
|
4693
|
+
insertNode(textNode, parent, anchor);
|
|
4694
|
+
}
|
|
4695
|
+
|
|
4696
|
+
function patchComment(n1, n2) {
|
|
4697
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
4698
|
+
// it is the case today.
|
|
4699
|
+
|
|
4700
|
+
if (n2.text !== n1.text) {
|
|
4701
|
+
updateTextContent(n2);
|
|
4702
|
+
}
|
|
4703
|
+
}
|
|
4633
4704
|
|
|
4705
|
+
function mountComment(node, parent, anchor) {
|
|
4706
|
+
const {
|
|
4707
|
+
owner
|
|
4708
|
+
} = node;
|
|
4709
|
+
const commentNode = node.elm = createComment$1(node.text);
|
|
4710
|
+
linkNodeToShadow(commentNode, owner);
|
|
4711
|
+
insertNode(commentNode, parent, anchor);
|
|
4712
|
+
}
|
|
4634
4713
|
|
|
4635
|
-
|
|
4714
|
+
function mountElement(vnode, parent, anchor) {
|
|
4715
|
+
const {
|
|
4716
|
+
sel,
|
|
4717
|
+
owner,
|
|
4718
|
+
data: {
|
|
4719
|
+
svg
|
|
4636
4720
|
}
|
|
4637
|
-
}
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4721
|
+
} = vnode;
|
|
4722
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4723
|
+
const elm = createElement$2(sel, namespace);
|
|
4724
|
+
linkNodeToShadow(elm, owner);
|
|
4725
|
+
fallbackElmHook(elm, vnode);
|
|
4726
|
+
vnode.elm = elm;
|
|
4727
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4728
|
+
insertNode(elm, parent, anchor);
|
|
4729
|
+
mountVNodes(vnode.children, elm, null);
|
|
4730
|
+
}
|
|
4641
4731
|
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4732
|
+
function patchElement(n1, n2) {
|
|
4733
|
+
const elm = n2.elm = n1.elm;
|
|
4734
|
+
patchElementPropsAndAttrs$1(n1, n2);
|
|
4735
|
+
patchChildren(n1.children, n2.children, elm);
|
|
4736
|
+
}
|
|
4737
|
+
|
|
4738
|
+
function mountCustomElement(vnode, parent, anchor) {
|
|
4739
|
+
const {
|
|
4740
|
+
sel,
|
|
4741
|
+
owner
|
|
4742
|
+
} = vnode;
|
|
4743
|
+
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
4744
|
+
/**
|
|
4745
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4746
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4747
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4748
|
+
* an upgradable custom element.
|
|
4749
|
+
*/
|
|
4750
|
+
|
|
4751
|
+
let vm;
|
|
4752
|
+
const elm = new UpgradableConstructor(elm => {
|
|
4753
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4754
|
+
vm = createViewModelHook(elm, vnode);
|
|
4755
|
+
});
|
|
4756
|
+
linkNodeToShadow(elm, owner);
|
|
4757
|
+
vnode.elm = elm;
|
|
4758
|
+
vnode.vm = vm;
|
|
4759
|
+
|
|
4760
|
+
if (vm) {
|
|
4761
|
+
allocateChildren(vnode, vm);
|
|
4762
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4763
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
4764
|
+
}
|
|
4765
|
+
|
|
4766
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4767
|
+
insertNode(elm, parent, anchor);
|
|
4648
4768
|
|
|
4649
|
-
|
|
4769
|
+
if (vm) {
|
|
4770
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4771
|
+
assert.isTrue(vm.state === 0
|
|
4772
|
+
/* created */
|
|
4773
|
+
, `${vm} cannot be recycled.`);
|
|
4650
4774
|
}
|
|
4651
4775
|
|
|
4652
|
-
|
|
4776
|
+
runConnectedCallback(vm);
|
|
4777
|
+
}
|
|
4778
|
+
|
|
4779
|
+
mountVNodes(vnode.children, elm, null);
|
|
4780
|
+
|
|
4781
|
+
if (vm) {
|
|
4782
|
+
appendVM(vm);
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
|
|
4786
|
+
function patchCustomElement(n1, n2) {
|
|
4787
|
+
const elm = n2.elm = n1.elm;
|
|
4788
|
+
const vm = n2.vm = n1.vm;
|
|
4789
|
+
patchElementPropsAndAttrs$1(n1, n2);
|
|
4790
|
+
|
|
4791
|
+
if (!isUndefined$1(vm)) {
|
|
4792
|
+
// in fallback mode, the allocation will always set children to
|
|
4793
|
+
// empty and delegate the real allocation to the slot elements
|
|
4794
|
+
allocateChildren(n2, vm);
|
|
4795
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
4796
|
+
// will happen, but in native, it does allocate the light dom
|
|
4797
|
+
|
|
4798
|
+
|
|
4799
|
+
patchChildren(n1.children, n2.children, elm);
|
|
4800
|
+
|
|
4801
|
+
if (!isUndefined$1(vm)) {
|
|
4802
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4803
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4804
|
+
rerenderVM(vm);
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
|
|
4808
|
+
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
4809
|
+
for (; start < end; ++start) {
|
|
4810
|
+
const vnode = vnodes[start];
|
|
4653
4811
|
|
|
4654
|
-
if (
|
|
4655
|
-
|
|
4812
|
+
if (isVNode(vnode)) {
|
|
4813
|
+
mount(vnode, parent, anchor);
|
|
4656
4814
|
}
|
|
4657
|
-
}
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
|
|
4818
|
+
function unmount(vnode, parent, doRemove = false) {
|
|
4819
|
+
const {
|
|
4820
|
+
type,
|
|
4821
|
+
elm
|
|
4822
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4823
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
4824
|
+
|
|
4825
|
+
if (doRemove) {
|
|
4826
|
+
removeNode(elm, parent);
|
|
4827
|
+
}
|
|
4828
|
+
|
|
4829
|
+
switch (type) {
|
|
4830
|
+
case 2
|
|
4831
|
+
/* Element */
|
|
4832
|
+
:
|
|
4833
|
+
unmountVNodes(vnode.children, elm);
|
|
4834
|
+
break;
|
|
4835
|
+
|
|
4836
|
+
case 3
|
|
4837
|
+
/* CustomElement */
|
|
4838
|
+
:
|
|
4839
|
+
{
|
|
4840
|
+
const {
|
|
4841
|
+
vm
|
|
4842
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
4843
|
+
// children.
|
|
4844
|
+
|
|
4845
|
+
if (!isUndefined$1(vm)) {
|
|
4846
|
+
removeVM(vm);
|
|
4847
|
+
}
|
|
4848
|
+
}
|
|
4849
|
+
}
|
|
4850
|
+
}
|
|
4851
|
+
|
|
4852
|
+
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
4853
|
+
for (; start < end; ++start) {
|
|
4854
|
+
const ch = vnodes[start];
|
|
4662
4855
|
|
|
4663
|
-
if (
|
|
4664
|
-
|
|
4665
|
-
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
4666
|
-
removeVM(vm);
|
|
4856
|
+
if (isVNode(ch)) {
|
|
4857
|
+
unmount(ch, parent, doRemove);
|
|
4667
4858
|
}
|
|
4668
4859
|
}
|
|
4669
|
-
}
|
|
4860
|
+
}
|
|
4670
4861
|
|
|
4671
4862
|
function isVNode(vnode) {
|
|
4672
4863
|
return vnode != null;
|
|
@@ -4711,43 +4902,41 @@ function linkNodeToShadow(elm, owner) {
|
|
|
4711
4902
|
}
|
|
4712
4903
|
}
|
|
4713
4904
|
|
|
4714
|
-
function
|
|
4905
|
+
function updateTextContent(vnode) {
|
|
4715
4906
|
const {
|
|
4716
4907
|
elm,
|
|
4717
4908
|
text
|
|
4718
4909
|
} = vnode;
|
|
4719
4910
|
|
|
4720
|
-
if (
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
}
|
|
4911
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4912
|
+
unlockDomMutation();
|
|
4913
|
+
}
|
|
4724
4914
|
|
|
4725
|
-
|
|
4915
|
+
setText$1(elm, text);
|
|
4726
4916
|
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
}
|
|
4917
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4918
|
+
lockDomMutation();
|
|
4730
4919
|
}
|
|
4731
4920
|
}
|
|
4732
4921
|
|
|
4733
|
-
function insertNode(
|
|
4922
|
+
function insertNode(node, parent, anchor) {
|
|
4734
4923
|
if (process.env.NODE_ENV !== 'production') {
|
|
4735
4924
|
unlockDomMutation();
|
|
4736
4925
|
}
|
|
4737
4926
|
|
|
4738
|
-
insert$1(
|
|
4927
|
+
insert$1(node, parent, anchor);
|
|
4739
4928
|
|
|
4740
4929
|
if (process.env.NODE_ENV !== 'production') {
|
|
4741
4930
|
lockDomMutation();
|
|
4742
4931
|
}
|
|
4743
4932
|
}
|
|
4744
4933
|
|
|
4745
|
-
function removeNode(
|
|
4934
|
+
function removeNode(node, parent) {
|
|
4746
4935
|
if (process.env.NODE_ENV !== 'production') {
|
|
4747
4936
|
unlockDomMutation();
|
|
4748
4937
|
}
|
|
4749
4938
|
|
|
4750
|
-
remove$1(
|
|
4939
|
+
remove$1(node, parent);
|
|
4751
4940
|
|
|
4752
4941
|
if (process.env.NODE_ENV !== 'production') {
|
|
4753
4942
|
lockDomMutation();
|
|
@@ -4792,11 +4981,13 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4792
4981
|
) {
|
|
4793
4982
|
// this element will now accept any manual content inserted into it
|
|
4794
4983
|
observeElementChildNodes(elm);
|
|
4795
|
-
}
|
|
4796
|
-
// into each element from the template, so they can be styled accordingly.
|
|
4797
|
-
|
|
4984
|
+
}
|
|
4798
4985
|
|
|
4799
|
-
|
|
4986
|
+
if (!isUndefined$1(stylesheetToken)) {
|
|
4987
|
+
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
4988
|
+
// into each element from the template, so they can be styled accordingly.
|
|
4989
|
+
setElementShadowToken(elm, stylesheetToken);
|
|
4990
|
+
}
|
|
4800
4991
|
}
|
|
4801
4992
|
|
|
4802
4993
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -4818,14 +5009,6 @@ function fallbackElmHook(elm, vnode) {
|
|
|
4818
5009
|
}
|
|
4819
5010
|
}
|
|
4820
5011
|
|
|
4821
|
-
function patchChildren(parent, oldCh, newCh) {
|
|
4822
|
-
if (hasDynamicChildren(newCh)) {
|
|
4823
|
-
updateDynamicChildren(parent, oldCh, newCh);
|
|
4824
|
-
} else {
|
|
4825
|
-
updateStaticChildren(parent, oldCh, newCh);
|
|
4826
|
-
}
|
|
4827
|
-
}
|
|
4828
|
-
|
|
4829
5012
|
function allocateChildren(vnode, vm) {
|
|
4830
5013
|
// A component with slots will re-render because:
|
|
4831
5014
|
// 1- There is a change of the internal state.
|
|
@@ -4883,7 +5066,9 @@ function createViewModelHook(elm, vnode) {
|
|
|
4883
5066
|
} = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
|
|
4884
5067
|
// into each element from the template, so they can be styled accordingly.
|
|
4885
5068
|
|
|
4886
|
-
|
|
5069
|
+
if (!isUndefined$1(stylesheetToken)) {
|
|
5070
|
+
setElementShadowToken(elm, stylesheetToken);
|
|
5071
|
+
}
|
|
4887
5072
|
}
|
|
4888
5073
|
|
|
4889
5074
|
vm = createVM(elm, ctor, {
|
|
@@ -4899,40 +5084,6 @@ function createViewModelHook(elm, vnode) {
|
|
|
4899
5084
|
return vm;
|
|
4900
5085
|
}
|
|
4901
5086
|
|
|
4902
|
-
function createChildrenHook(vnode) {
|
|
4903
|
-
const {
|
|
4904
|
-
elm,
|
|
4905
|
-
children
|
|
4906
|
-
} = vnode;
|
|
4907
|
-
|
|
4908
|
-
for (let j = 0; j < children.length; ++j) {
|
|
4909
|
-
const ch = children[j];
|
|
4910
|
-
|
|
4911
|
-
if (ch != null) {
|
|
4912
|
-
ch.hook.create(ch);
|
|
4913
|
-
ch.hook.insert(ch, elm, null);
|
|
4914
|
-
}
|
|
4915
|
-
}
|
|
4916
|
-
}
|
|
4917
|
-
|
|
4918
|
-
function removeChildren(vnode) {
|
|
4919
|
-
// this method only needs to search on child vnodes from template
|
|
4920
|
-
// to trigger the remove hook just in case some of those children
|
|
4921
|
-
// are custom elements.
|
|
4922
|
-
const {
|
|
4923
|
-
children,
|
|
4924
|
-
elm
|
|
4925
|
-
} = vnode;
|
|
4926
|
-
|
|
4927
|
-
for (let j = 0, len = children.length; j < len; ++j) {
|
|
4928
|
-
const ch = children[j];
|
|
4929
|
-
|
|
4930
|
-
if (!isNull(ch)) {
|
|
4931
|
-
ch.hook.remove(ch, elm);
|
|
4932
|
-
}
|
|
4933
|
-
}
|
|
4934
|
-
}
|
|
4935
|
-
|
|
4936
5087
|
function allocateInSlot(vm, children) {
|
|
4937
5088
|
var _a;
|
|
4938
5089
|
|
|
@@ -5029,28 +5180,7 @@ function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
|
5029
5180
|
return map;
|
|
5030
5181
|
}
|
|
5031
5182
|
|
|
5032
|
-
function
|
|
5033
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
5034
|
-
const ch = vnodes[startIdx];
|
|
5035
|
-
|
|
5036
|
-
if (isVNode(ch)) {
|
|
5037
|
-
ch.hook.create(ch);
|
|
5038
|
-
ch.hook.insert(ch, parentElm, before);
|
|
5039
|
-
}
|
|
5040
|
-
}
|
|
5041
|
-
}
|
|
5042
|
-
|
|
5043
|
-
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
5044
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
5045
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
5046
|
-
|
|
5047
|
-
if (isVNode(ch)) {
|
|
5048
|
-
ch.hook.remove(ch, parentElm);
|
|
5049
|
-
}
|
|
5050
|
-
}
|
|
5051
|
-
}
|
|
5052
|
-
|
|
5053
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
5183
|
+
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
5054
5184
|
let oldStartIdx = 0;
|
|
5055
5185
|
let newStartIdx = 0;
|
|
5056
5186
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -5064,6 +5194,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
5064
5194
|
let idxInOld;
|
|
5065
5195
|
let elmToMove;
|
|
5066
5196
|
let before;
|
|
5197
|
+
let clonedOldCh = false;
|
|
5067
5198
|
|
|
5068
5199
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
5069
5200
|
if (!isVNode(oldStartVnode)) {
|
|
@@ -5075,23 +5206,23 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
5075
5206
|
} else if (!isVNode(newEndVnode)) {
|
|
5076
5207
|
newEndVnode = newCh[--newEndIdx];
|
|
5077
5208
|
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
5078
|
-
|
|
5209
|
+
patch(oldStartVnode, newStartVnode);
|
|
5079
5210
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
5080
5211
|
newStartVnode = newCh[++newStartIdx];
|
|
5081
5212
|
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
5082
|
-
|
|
5213
|
+
patch(oldEndVnode, newEndVnode);
|
|
5083
5214
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
5084
5215
|
newEndVnode = newCh[--newEndIdx];
|
|
5085
5216
|
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
5086
5217
|
// Vnode moved right
|
|
5087
|
-
|
|
5088
|
-
|
|
5218
|
+
patch(oldStartVnode, newEndVnode);
|
|
5219
|
+
insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
|
|
5089
5220
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
5090
5221
|
newEndVnode = newCh[--newEndIdx];
|
|
5091
5222
|
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
5092
5223
|
// Vnode moved left
|
|
5093
|
-
|
|
5094
|
-
newStartVnode.
|
|
5224
|
+
patch(oldEndVnode, newStartVnode);
|
|
5225
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
5095
5226
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
5096
5227
|
newStartVnode = newCh[++newStartIdx];
|
|
5097
5228
|
} else {
|
|
@@ -5103,8 +5234,7 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
5103
5234
|
|
|
5104
5235
|
if (isUndefined$1(idxInOld)) {
|
|
5105
5236
|
// New element
|
|
5106
|
-
newStartVnode.
|
|
5107
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5237
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
5108
5238
|
newStartVnode = newCh[++newStartIdx];
|
|
5109
5239
|
} else {
|
|
5110
5240
|
elmToMove = oldCh[idxInOld];
|
|
@@ -5112,12 +5242,22 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
5112
5242
|
if (isVNode(elmToMove)) {
|
|
5113
5243
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
5114
5244
|
// New element
|
|
5115
|
-
newStartVnode.
|
|
5116
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5245
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
5117
5246
|
} else {
|
|
5118
|
-
|
|
5247
|
+
patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
|
|
5248
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
5249
|
+
// so we only care about the `oldCh` object inside this function.
|
|
5250
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
5251
|
+
// and only clone once.
|
|
5252
|
+
|
|
5253
|
+
if (!clonedOldCh) {
|
|
5254
|
+
clonedOldCh = true;
|
|
5255
|
+
oldCh = [...oldCh];
|
|
5256
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
5257
|
+
|
|
5258
|
+
|
|
5119
5259
|
oldCh[idxInOld] = undefined;
|
|
5120
|
-
|
|
5260
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
5121
5261
|
}
|
|
5122
5262
|
}
|
|
5123
5263
|
|
|
@@ -5138,65 +5278,55 @@ function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
|
5138
5278
|
} while (!isVNode(n) && i < newChEnd);
|
|
5139
5279
|
|
|
5140
5280
|
before = isVNode(n) ? n.elm : null;
|
|
5141
|
-
|
|
5281
|
+
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
5142
5282
|
} else {
|
|
5143
|
-
|
|
5283
|
+
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
5144
5284
|
}
|
|
5145
5285
|
}
|
|
5146
5286
|
}
|
|
5147
5287
|
|
|
5148
|
-
function updateStaticChildren(
|
|
5149
|
-
const
|
|
5150
|
-
const
|
|
5288
|
+
function updateStaticChildren(c1, c2, parent) {
|
|
5289
|
+
const c1Length = c1.length;
|
|
5290
|
+
const c2Length = c2.length;
|
|
5151
5291
|
|
|
5152
|
-
if (
|
|
5292
|
+
if (c1Length === 0) {
|
|
5153
5293
|
// the old list is empty, we can directly insert anything new
|
|
5154
|
-
|
|
5294
|
+
mountVNodes(c2, parent, null);
|
|
5155
5295
|
return;
|
|
5156
5296
|
}
|
|
5157
5297
|
|
|
5158
|
-
if (
|
|
5298
|
+
if (c2Length === 0) {
|
|
5159
5299
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
5160
5300
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
5161
|
-
|
|
5301
|
+
unmountVNodes(c1, parent, true);
|
|
5162
5302
|
return;
|
|
5163
5303
|
} // if the old list is not empty, the new list MUST have the same
|
|
5164
5304
|
// amount of nodes, that's why we call this static children
|
|
5165
5305
|
|
|
5166
5306
|
|
|
5167
|
-
let
|
|
5307
|
+
let anchor = null;
|
|
5168
5308
|
|
|
5169
|
-
for (let i =
|
|
5170
|
-
const
|
|
5171
|
-
const
|
|
5309
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
5310
|
+
const n1 = c1[i];
|
|
5311
|
+
const n2 = c2[i];
|
|
5172
5312
|
|
|
5173
|
-
if (
|
|
5174
|
-
if (isVNode(
|
|
5175
|
-
if (isVNode(
|
|
5176
|
-
// both vnodes
|
|
5177
|
-
|
|
5178
|
-
|
|
5313
|
+
if (n2 !== n1) {
|
|
5314
|
+
if (isVNode(n1)) {
|
|
5315
|
+
if (isVNode(n2)) {
|
|
5316
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
5317
|
+
patch(n1, n2);
|
|
5318
|
+
anchor = n2.elm;
|
|
5179
5319
|
} else {
|
|
5180
5320
|
// removing the old vnode since the new one is null
|
|
5181
|
-
|
|
5321
|
+
unmount(n1, parent, true);
|
|
5182
5322
|
}
|
|
5183
|
-
} else if (isVNode(
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
5188
|
-
referenceElm = vnode.elm;
|
|
5323
|
+
} else if (isVNode(n2)) {
|
|
5324
|
+
mount(n2, parent, anchor);
|
|
5325
|
+
anchor = n2.elm;
|
|
5189
5326
|
}
|
|
5190
5327
|
}
|
|
5191
5328
|
}
|
|
5192
5329
|
}
|
|
5193
|
-
|
|
5194
|
-
function patchVnode(oldVnode, vnode) {
|
|
5195
|
-
if (oldVnode !== vnode) {
|
|
5196
|
-
vnode.elm = oldVnode.elm;
|
|
5197
|
-
vnode.hook.update(oldVnode, vnode);
|
|
5198
|
-
}
|
|
5199
|
-
}
|
|
5200
5330
|
/*
|
|
5201
5331
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5202
5332
|
* All rights reserved.
|
|
@@ -5212,7 +5342,7 @@ function addVNodeToChildLWC(vnode) {
|
|
|
5212
5342
|
} // [h]tml node
|
|
5213
5343
|
|
|
5214
5344
|
|
|
5215
|
-
function h(sel, data, children) {
|
|
5345
|
+
function h(sel, data, children = EmptyArray) {
|
|
5216
5346
|
const vmBeingRendered = getVMBeingRendered();
|
|
5217
5347
|
|
|
5218
5348
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5248,7 +5378,6 @@ function h(sel, data, children) {
|
|
|
5248
5378
|
children,
|
|
5249
5379
|
elm,
|
|
5250
5380
|
key,
|
|
5251
|
-
hook: ElementHook,
|
|
5252
5381
|
owner: vmBeingRendered
|
|
5253
5382
|
};
|
|
5254
5383
|
} // [t]ab[i]ndex function
|
|
@@ -5335,7 +5464,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
5335
5464
|
const {
|
|
5336
5465
|
key
|
|
5337
5466
|
} = data;
|
|
5338
|
-
let elm;
|
|
5467
|
+
let elm, aChildren, vm;
|
|
5339
5468
|
const vnode = {
|
|
5340
5469
|
type: 3
|
|
5341
5470
|
/* CustomElement */
|
|
@@ -5345,11 +5474,11 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
5345
5474
|
children,
|
|
5346
5475
|
elm,
|
|
5347
5476
|
key,
|
|
5348
|
-
hook: CustomElementHook,
|
|
5349
5477
|
ctor: Ctor,
|
|
5350
5478
|
owner: vmBeingRendered,
|
|
5351
|
-
mode: 'open'
|
|
5352
|
-
|
|
5479
|
+
mode: 'open',
|
|
5480
|
+
aChildren,
|
|
5481
|
+
vm
|
|
5353
5482
|
};
|
|
5354
5483
|
addVNodeToChildLWC(vnode);
|
|
5355
5484
|
return vnode;
|
|
@@ -5479,7 +5608,6 @@ function t(text) {
|
|
|
5479
5608
|
text,
|
|
5480
5609
|
elm,
|
|
5481
5610
|
key,
|
|
5482
|
-
hook: TextHook,
|
|
5483
5611
|
owner: getVMBeingRendered()
|
|
5484
5612
|
};
|
|
5485
5613
|
} // [co]mment node
|
|
@@ -5495,7 +5623,6 @@ function co(text) {
|
|
|
5495
5623
|
text,
|
|
5496
5624
|
elm,
|
|
5497
5625
|
key,
|
|
5498
|
-
hook: CommentHook,
|
|
5499
5626
|
owner: getVMBeingRendered()
|
|
5500
5627
|
};
|
|
5501
5628
|
} // [d]ynamic text
|
|
@@ -5610,7 +5737,7 @@ let dynamicImportedComponentCounter = 0;
|
|
|
5610
5737
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
5611
5738
|
*/
|
|
5612
5739
|
|
|
5613
|
-
function dc(sel, Ctor, data, children) {
|
|
5740
|
+
function dc(sel, Ctor, data, children = EmptyArray) {
|
|
5614
5741
|
if (process.env.NODE_ENV !== 'production') {
|
|
5615
5742
|
assert.isTrue(isString(sel), `dc() 1st argument sel must be a string.`);
|
|
5616
5743
|
assert.isTrue(isObject(data), `dc() 3nd argument data must be an object.`);
|
|
@@ -5634,10 +5761,14 @@ function dc(sel, Ctor, data, children) {
|
|
|
5634
5761
|
} // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
5635
5762
|
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
5636
5763
|
// element used for previous constructors.
|
|
5764
|
+
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
5765
|
+
// hoisting optimization.
|
|
5637
5766
|
|
|
5638
5767
|
|
|
5639
|
-
|
|
5640
|
-
|
|
5768
|
+
const newData = Object.assign(Object.assign({}, data), {
|
|
5769
|
+
key: `dc:${idx}:${data.key}`
|
|
5770
|
+
});
|
|
5771
|
+
return c(sel, Ctor, newData, children);
|
|
5641
5772
|
}
|
|
5642
5773
|
/**
|
|
5643
5774
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -5757,12 +5888,14 @@ function updateStylesheetToken(vm, template) {
|
|
|
5757
5888
|
hasTokenInAttribute: oldHasTokenInAttribute
|
|
5758
5889
|
} = context;
|
|
5759
5890
|
|
|
5760
|
-
if (
|
|
5761
|
-
|
|
5762
|
-
|
|
5891
|
+
if (!isUndefined$1(oldToken)) {
|
|
5892
|
+
if (oldHasTokenInClass) {
|
|
5893
|
+
getClassList$1(elm).remove(makeHostToken(oldToken));
|
|
5894
|
+
}
|
|
5763
5895
|
|
|
5764
|
-
|
|
5765
|
-
|
|
5896
|
+
if (oldHasTokenInAttribute) {
|
|
5897
|
+
removeAttribute$1(elm, makeHostToken(oldToken));
|
|
5898
|
+
}
|
|
5766
5899
|
} // Apply the new template styling token to the host element, if the new template has any
|
|
5767
5900
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
5768
5901
|
|
|
@@ -6356,6 +6489,10 @@ const signedTemplateMap = new Map();
|
|
|
6356
6489
|
function registerComponent(Ctor, {
|
|
6357
6490
|
tmpl
|
|
6358
6491
|
}) {
|
|
6492
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6493
|
+
checkVersionMismatch(Ctor, 'component');
|
|
6494
|
+
}
|
|
6495
|
+
|
|
6359
6496
|
signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
|
|
6360
6497
|
// without too much transformation
|
|
6361
6498
|
|
|
@@ -6480,7 +6617,7 @@ function invokeServiceHook(vm, cbs) {
|
|
|
6480
6617
|
*/
|
|
6481
6618
|
|
|
6482
6619
|
|
|
6483
|
-
function hydrate
|
|
6620
|
+
function hydrate(vnode, node) {
|
|
6484
6621
|
switch (vnode.type) {
|
|
6485
6622
|
case 0
|
|
6486
6623
|
/* Text */
|
|
@@ -6512,16 +6649,18 @@ function hydrateText(vnode, node) {
|
|
|
6512
6649
|
var _a;
|
|
6513
6650
|
|
|
6514
6651
|
if (process.env.NODE_ENV !== 'production') {
|
|
6515
|
-
|
|
6516
|
-
|
|
6652
|
+
validateNodeType(vnode, node, 3
|
|
6653
|
+
/* TEXT */
|
|
6654
|
+
);
|
|
6655
|
+
const nodeValue = getProperty$1(node, 'nodeValue');
|
|
6517
6656
|
|
|
6518
|
-
if (
|
|
6657
|
+
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
6519
6658
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
6520
6659
|
}
|
|
6521
6660
|
} // always set the text value to the one from the vnode.
|
|
6522
6661
|
|
|
6523
6662
|
|
|
6524
|
-
node
|
|
6663
|
+
setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6525
6664
|
vnode.elm = node;
|
|
6526
6665
|
}
|
|
6527
6666
|
|
|
@@ -6529,23 +6668,25 @@ function hydrateComment(vnode, node) {
|
|
|
6529
6668
|
var _a;
|
|
6530
6669
|
|
|
6531
6670
|
if (process.env.NODE_ENV !== 'production') {
|
|
6532
|
-
|
|
6533
|
-
|
|
6671
|
+
validateNodeType(vnode, node, 8
|
|
6672
|
+
/* COMMENT */
|
|
6673
|
+
);
|
|
6534
6674
|
|
|
6535
|
-
if (node
|
|
6675
|
+
if (getProperty$1(node, 'nodeValue') !== vnode.text) {
|
|
6536
6676
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
6537
6677
|
}
|
|
6538
6678
|
} // always set the text value to the one from the vnode.
|
|
6539
6679
|
|
|
6540
6680
|
|
|
6541
|
-
node
|
|
6681
|
+
setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6542
6682
|
vnode.elm = node;
|
|
6543
6683
|
}
|
|
6544
6684
|
|
|
6545
6685
|
function hydrateElement(vnode, node) {
|
|
6546
6686
|
if (process.env.NODE_ENV !== 'production') {
|
|
6547
|
-
|
|
6548
|
-
|
|
6687
|
+
validateNodeType(vnode, node, 1
|
|
6688
|
+
/* ELEMENT */
|
|
6689
|
+
);
|
|
6549
6690
|
validateElement(vnode, node);
|
|
6550
6691
|
}
|
|
6551
6692
|
|
|
@@ -6566,10 +6707,13 @@ function hydrateElement(vnode, node) {
|
|
|
6566
6707
|
} = vnode.data;
|
|
6567
6708
|
|
|
6568
6709
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
6569
|
-
if (elm
|
|
6570
|
-
|
|
6710
|
+
if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
|
|
6711
|
+
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
6712
|
+
vnode.data = Object.assign(Object.assign({}, vnode.data), {
|
|
6713
|
+
props: cloneAndOmitKey(props, 'innerHTML')
|
|
6714
|
+
});
|
|
6571
6715
|
} else {
|
|
6572
|
-
logWarn(`Mismatch hydrating element <${elm
|
|
6716
|
+
logWarn(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
6573
6717
|
}
|
|
6574
6718
|
}
|
|
6575
6719
|
}
|
|
@@ -6577,19 +6721,19 @@ function hydrateElement(vnode, node) {
|
|
|
6577
6721
|
patchElementPropsAndAttrs(vnode);
|
|
6578
6722
|
|
|
6579
6723
|
if (!isDomManual) {
|
|
6580
|
-
hydrateChildren(vnode.elm
|
|
6724
|
+
hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
|
|
6581
6725
|
}
|
|
6582
6726
|
}
|
|
6583
6727
|
|
|
6584
6728
|
function hydrateCustomElement(vnode, node) {
|
|
6585
6729
|
if (process.env.NODE_ENV !== 'production') {
|
|
6586
|
-
|
|
6587
|
-
|
|
6730
|
+
validateNodeType(vnode, node, 1
|
|
6731
|
+
/* ELEMENT */
|
|
6732
|
+
);
|
|
6588
6733
|
validateElement(vnode, node);
|
|
6589
6734
|
}
|
|
6590
6735
|
|
|
6591
6736
|
const elm = node;
|
|
6592
|
-
vnode.elm = elm;
|
|
6593
6737
|
const {
|
|
6594
6738
|
sel,
|
|
6595
6739
|
mode,
|
|
@@ -6601,6 +6745,8 @@ function hydrateCustomElement(vnode, node) {
|
|
|
6601
6745
|
owner,
|
|
6602
6746
|
tagName: sel
|
|
6603
6747
|
});
|
|
6748
|
+
vnode.elm = elm;
|
|
6749
|
+
vnode.vm = vm;
|
|
6604
6750
|
allocateChildren(vnode, vm);
|
|
6605
6751
|
patchElementPropsAndAttrs(vnode); // Insert hook section:
|
|
6606
6752
|
|
|
@@ -6617,7 +6763,7 @@ function hydrateCustomElement(vnode, node) {
|
|
|
6617
6763
|
) {
|
|
6618
6764
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
6619
6765
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
6620
|
-
hydrateChildren(vnode.elm
|
|
6766
|
+
hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
|
|
6621
6767
|
}
|
|
6622
6768
|
|
|
6623
6769
|
hydrateVM(vm);
|
|
@@ -6640,7 +6786,7 @@ function hydrateChildren(elmChildren, children, vm) {
|
|
|
6640
6786
|
|
|
6641
6787
|
if (!isNull(childVnode)) {
|
|
6642
6788
|
const childNode = elmChildren[childNodeIndex];
|
|
6643
|
-
hydrate
|
|
6789
|
+
hydrate(childVnode, childNode);
|
|
6644
6790
|
childNodeIndex++;
|
|
6645
6791
|
}
|
|
6646
6792
|
}
|
|
@@ -6656,15 +6802,15 @@ function throwHydrationError() {
|
|
|
6656
6802
|
}
|
|
6657
6803
|
|
|
6658
6804
|
function validateNodeType(vnode, node, nodeType) {
|
|
6659
|
-
if (node
|
|
6805
|
+
if (getProperty$1(node, 'nodeType') !== nodeType) {
|
|
6660
6806
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6661
6807
|
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
6662
6808
|
}
|
|
6663
6809
|
}
|
|
6664
6810
|
|
|
6665
6811
|
function validateElement(vnode, elm) {
|
|
6666
|
-
if (vnode.sel.toLowerCase() !== elm
|
|
6667
|
-
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${elm
|
|
6812
|
+
if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
|
|
6813
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty$1(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6668
6814
|
throwHydrationError();
|
|
6669
6815
|
}
|
|
6670
6816
|
|
|
@@ -6691,7 +6837,7 @@ function validateAttrs(vnode, elm) {
|
|
|
6691
6837
|
const elmAttrValue = getAttribute$1(elm, attrName);
|
|
6692
6838
|
|
|
6693
6839
|
if (String(attrValue) !== elmAttrValue) {
|
|
6694
|
-
logError(`Mismatch hydrating element <${elm
|
|
6840
|
+
logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
6695
6841
|
nodesAreCompatible = false;
|
|
6696
6842
|
}
|
|
6697
6843
|
}
|
|
@@ -6709,7 +6855,7 @@ function validateClassAttr(vnode, elm) {
|
|
|
6709
6855
|
let nodesAreCompatible = true;
|
|
6710
6856
|
let vnodeClassName;
|
|
6711
6857
|
|
|
6712
|
-
if (!isUndefined$1(className) && String(className) !== elm
|
|
6858
|
+
if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
|
|
6713
6859
|
// className is used when class is bound to an expr.
|
|
6714
6860
|
nodesAreCompatible = false;
|
|
6715
6861
|
vnodeClassName = className;
|
|
@@ -6734,7 +6880,7 @@ function validateClassAttr(vnode, elm) {
|
|
|
6734
6880
|
}
|
|
6735
6881
|
|
|
6736
6882
|
if (!nodesAreCompatible) {
|
|
6737
|
-
logError(`Mismatch hydrating element <${elm
|
|
6883
|
+
logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty$1(elm, 'className')}"`, vnode.owner);
|
|
6738
6884
|
}
|
|
6739
6885
|
|
|
6740
6886
|
return nodesAreCompatible;
|
|
@@ -6781,7 +6927,7 @@ function validateStyleAttr(vnode, elm) {
|
|
|
6781
6927
|
|
|
6782
6928
|
if (!nodesAreCompatible) {
|
|
6783
6929
|
// style is used when class is bound to an expr.
|
|
6784
|
-
logError(`Mismatch hydrating element <${elm
|
|
6930
|
+
logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6785
6931
|
}
|
|
6786
6932
|
|
|
6787
6933
|
return nodesAreCompatible;
|
|
@@ -6851,7 +6997,19 @@ function appendVM(vm) {
|
|
|
6851
6997
|
}
|
|
6852
6998
|
|
|
6853
6999
|
function hydrateVM(vm) {
|
|
6854
|
-
|
|
7000
|
+
if (isTrue(vm.isDirty)) {
|
|
7001
|
+
// manually diffing/patching here.
|
|
7002
|
+
// This routine is:
|
|
7003
|
+
// patchShadowRoot(vm, children);
|
|
7004
|
+
// -> addVnodes.
|
|
7005
|
+
const children = renderComponent(vm);
|
|
7006
|
+
vm.children = children;
|
|
7007
|
+
const vmChildren = vm.renderMode === 0
|
|
7008
|
+
/* Light */
|
|
7009
|
+
? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
|
|
7010
|
+
hydrateChildren(vmChildren, children, vm);
|
|
7011
|
+
runRenderedCallback(vm);
|
|
7012
|
+
}
|
|
6855
7013
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
6856
7014
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
6857
7015
|
|
|
@@ -7002,7 +7160,11 @@ function computeShadowMode(vm) {
|
|
|
7002
7160
|
/* Native */
|
|
7003
7161
|
;
|
|
7004
7162
|
} else if (isNativeShadowDefined$1) {
|
|
7005
|
-
if (
|
|
7163
|
+
if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
|
|
7164
|
+
shadowMode = 1
|
|
7165
|
+
/* Synthetic */
|
|
7166
|
+
;
|
|
7167
|
+
} else if (def.shadowSupportMode === "any"
|
|
7006
7168
|
/* Any */
|
|
7007
7169
|
) {
|
|
7008
7170
|
shadowMode = 0
|
|
@@ -7082,22 +7244,6 @@ function rehydrate(vm) {
|
|
|
7082
7244
|
}
|
|
7083
7245
|
}
|
|
7084
7246
|
|
|
7085
|
-
function hydrate(vm) {
|
|
7086
|
-
if (isTrue(vm.isDirty)) {
|
|
7087
|
-
// manually diffing/patching here.
|
|
7088
|
-
// This routine is:
|
|
7089
|
-
// patchShadowRoot(vm, children);
|
|
7090
|
-
// -> addVnodes.
|
|
7091
|
-
const children = renderComponent(vm);
|
|
7092
|
-
vm.children = children;
|
|
7093
|
-
const vmChildren = vm.renderMode === 0
|
|
7094
|
-
/* Light */
|
|
7095
|
-
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
7096
|
-
hydrateChildren(vmChildren, children, vm);
|
|
7097
|
-
runRenderedCallback(vm);
|
|
7098
|
-
}
|
|
7099
|
-
}
|
|
7100
|
-
|
|
7101
7247
|
function patchShadowRoot(vm, newCh) {
|
|
7102
7248
|
const {
|
|
7103
7249
|
renderRoot,
|
|
@@ -7117,7 +7263,7 @@ function patchShadowRoot(vm, newCh) {
|
|
|
7117
7263
|
, vm);
|
|
7118
7264
|
}, () => {
|
|
7119
7265
|
// job
|
|
7120
|
-
patchChildren(
|
|
7266
|
+
patchChildren(oldCh, newCh, renderRoot);
|
|
7121
7267
|
}, () => {
|
|
7122
7268
|
// post
|
|
7123
7269
|
logOperationEnd(2
|
|
@@ -7864,7 +8010,7 @@ function setHooks(hooks) {
|
|
|
7864
8010
|
hooksAreSet = true;
|
|
7865
8011
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7866
8012
|
}
|
|
7867
|
-
/* version: 2.
|
|
8013
|
+
/* version: 2.10.0 */
|
|
7868
8014
|
|
|
7869
8015
|
/*
|
|
7870
8016
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7890,6 +8036,7 @@ const globalStylesheetsParentElement = document.head || document.body || documen
|
|
|
7890
8036
|
// See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
|
|
7891
8037
|
|
|
7892
8038
|
const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
|
|
8039
|
+
const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
|
|
7893
8040
|
const styleElements = create(null);
|
|
7894
8041
|
const styleSheets = create(null);
|
|
7895
8042
|
const nodesToStyleSheets = new WeakMap();
|
|
@@ -7933,7 +8080,13 @@ function insertConstructableStyleSheet(content, target) {
|
|
|
7933
8080
|
}
|
|
7934
8081
|
|
|
7935
8082
|
if (!target.adoptedStyleSheets.includes(styleSheet)) {
|
|
7936
|
-
|
|
8083
|
+
if (supportsMutableAdoptedStyleSheets) {
|
|
8084
|
+
// This is only supported in later versions of Chromium:
|
|
8085
|
+
// https://chromestatus.com/feature/5638996492288000
|
|
8086
|
+
target.adoptedStyleSheets.push(styleSheet);
|
|
8087
|
+
} else {
|
|
8088
|
+
target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
|
|
8089
|
+
}
|
|
7937
8090
|
}
|
|
7938
8091
|
}
|
|
7939
8092
|
|
|
@@ -8235,6 +8388,156 @@ setSetProperty(setProperty);
|
|
|
8235
8388
|
setSetText(setText);
|
|
8236
8389
|
setSsr(ssr);
|
|
8237
8390
|
setAddEventListener(addEventListener);
|
|
8391
|
+
/*
|
|
8392
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8393
|
+
* All rights reserved.
|
|
8394
|
+
* SPDX-License-Identifier: MIT
|
|
8395
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8396
|
+
*/
|
|
8397
|
+
|
|
8398
|
+
function resetShadowRootAndLightDom(element, Ctor) {
|
|
8399
|
+
if (element.shadowRoot) {
|
|
8400
|
+
const shadowRoot = element.shadowRoot;
|
|
8401
|
+
|
|
8402
|
+
while (!isNull(shadowRoot.firstChild)) {
|
|
8403
|
+
shadowRoot.removeChild(shadowRoot.firstChild);
|
|
8404
|
+
}
|
|
8405
|
+
}
|
|
8406
|
+
|
|
8407
|
+
if (Ctor.renderMode === 'light') {
|
|
8408
|
+
while (!isNull(element.firstChild)) {
|
|
8409
|
+
element.removeChild(element.firstChild);
|
|
8410
|
+
}
|
|
8411
|
+
}
|
|
8412
|
+
}
|
|
8413
|
+
|
|
8414
|
+
function createVMWithProps(element, Ctor, props) {
|
|
8415
|
+
createVM(element, Ctor, {
|
|
8416
|
+
mode: 'open',
|
|
8417
|
+
owner: null,
|
|
8418
|
+
tagName: element.tagName.toLowerCase()
|
|
8419
|
+
});
|
|
8420
|
+
|
|
8421
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8422
|
+
element[key] = value;
|
|
8423
|
+
}
|
|
8424
|
+
}
|
|
8425
|
+
|
|
8426
|
+
function hydrateComponent(element, Ctor, props = {}) {
|
|
8427
|
+
if (!(element instanceof Element)) {
|
|
8428
|
+
throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
|
|
8429
|
+
}
|
|
8430
|
+
|
|
8431
|
+
if (!isFunction$1(Ctor)) {
|
|
8432
|
+
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
8433
|
+
}
|
|
8434
|
+
|
|
8435
|
+
if (!isObject(props) || isNull(props)) {
|
|
8436
|
+
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8437
|
+
}
|
|
8438
|
+
|
|
8439
|
+
if (getAssociatedVMIfPresent(element)) {
|
|
8440
|
+
/* eslint-disable-next-line no-console */
|
|
8441
|
+
console.warn(`"hydrateComponent" expects an element that is not hydrated.`, element);
|
|
8442
|
+
return;
|
|
8443
|
+
}
|
|
8444
|
+
|
|
8445
|
+
try {
|
|
8446
|
+
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8447
|
+
// and uses the same algo to create the stylesheets as in SSR.
|
|
8448
|
+
setIsHydrating(true);
|
|
8449
|
+
createVMWithProps(element, Ctor, props);
|
|
8450
|
+
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
8451
|
+
|
|
8452
|
+
setIsHydrating(false);
|
|
8453
|
+
} catch (e) {
|
|
8454
|
+
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
|
|
8455
|
+
// with the client generated DOM.
|
|
8456
|
+
|
|
8457
|
+
/* eslint-disable-next-line no-console */
|
|
8458
|
+
console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
|
|
8459
|
+
|
|
8460
|
+
resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
|
|
8461
|
+
|
|
8462
|
+
createVMWithProps(element, Ctor, props);
|
|
8463
|
+
setIsHydrating(false);
|
|
8464
|
+
connectRootElement(element);
|
|
8465
|
+
} finally {
|
|
8466
|
+
// in case there's an error during recovery
|
|
8467
|
+
setIsHydrating(false);
|
|
8468
|
+
}
|
|
8469
|
+
}
|
|
8470
|
+
/*
|
|
8471
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8472
|
+
* All rights reserved.
|
|
8473
|
+
* SPDX-License-Identifier: MIT
|
|
8474
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8475
|
+
*/
|
|
8476
|
+
|
|
8477
|
+
/**
|
|
8478
|
+
* This function builds a Web Component class from a LWC constructor so it can be
|
|
8479
|
+
* registered as a new element via customElements.define() at any given time.
|
|
8480
|
+
*
|
|
8481
|
+
* @deprecated since version 1.3.11
|
|
8482
|
+
*
|
|
8483
|
+
* @example
|
|
8484
|
+
* ```
|
|
8485
|
+
* import { buildCustomElementConstructor } from 'lwc';
|
|
8486
|
+
* import Foo from 'ns/foo';
|
|
8487
|
+
* const WC = buildCustomElementConstructor(Foo);
|
|
8488
|
+
* customElements.define('x-foo', WC);
|
|
8489
|
+
* const elm = document.createElement('x-foo');
|
|
8490
|
+
* ```
|
|
8491
|
+
*/
|
|
8492
|
+
|
|
8493
|
+
|
|
8494
|
+
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
8495
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8496
|
+
/* eslint-disable-next-line no-console */
|
|
8497
|
+
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
8498
|
+
}
|
|
8499
|
+
|
|
8500
|
+
return Ctor.CustomElementConstructor;
|
|
8501
|
+
} // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
|
|
8502
|
+
// This WeakSet usage is valid because this functionality is not meant to run in IE11.
|
|
8503
|
+
|
|
8504
|
+
|
|
8505
|
+
const hydratedCustomElements = new WeakSet();
|
|
8506
|
+
|
|
8507
|
+
function buildCustomElementConstructor(Ctor) {
|
|
8508
|
+
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
8509
|
+
return class extends HtmlPrototype {
|
|
8510
|
+
constructor() {
|
|
8511
|
+
super();
|
|
8512
|
+
|
|
8513
|
+
if (this.isConnected) {
|
|
8514
|
+
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
8515
|
+
hydrateComponent(this, Ctor, {});
|
|
8516
|
+
hydratedCustomElements.add(this);
|
|
8517
|
+
} else {
|
|
8518
|
+
createVM(this, Ctor, {
|
|
8519
|
+
mode: 'open',
|
|
8520
|
+
owner: null,
|
|
8521
|
+
tagName: this.tagName
|
|
8522
|
+
});
|
|
8523
|
+
}
|
|
8524
|
+
}
|
|
8525
|
+
|
|
8526
|
+
connectedCallback() {
|
|
8527
|
+
if (hydratedCustomElements.has(this)) {
|
|
8528
|
+
// This is an un-upgraded element that was hydrated in the constructor.
|
|
8529
|
+
hydratedCustomElements.delete(this);
|
|
8530
|
+
} else {
|
|
8531
|
+
connectRootElement(this);
|
|
8532
|
+
}
|
|
8533
|
+
}
|
|
8534
|
+
|
|
8535
|
+
disconnectedCallback() {
|
|
8536
|
+
disconnectRootElement(this);
|
|
8537
|
+
}
|
|
8538
|
+
|
|
8539
|
+
};
|
|
8540
|
+
}
|
|
8238
8541
|
/*
|
|
8239
8542
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
8240
8543
|
* All rights reserved.
|
|
@@ -8244,6 +8547,7 @@ setAddEventListener(addEventListener);
|
|
|
8244
8547
|
// TODO [#2472]: Remove this workaround when appropriate.
|
|
8245
8548
|
// eslint-disable-next-line lwc-internal/no-global-node
|
|
8246
8549
|
|
|
8550
|
+
|
|
8247
8551
|
const _Node$1 = Node;
|
|
8248
8552
|
const ConnectingSlot = new WeakMap();
|
|
8249
8553
|
const DisconnectingSlot = new WeakMap();
|
|
@@ -8352,118 +8656,6 @@ function createElement(sel, options) {
|
|
|
8352
8656
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8353
8657
|
*/
|
|
8354
8658
|
|
|
8355
|
-
|
|
8356
|
-
function hydrateComponent(element, Ctor, props = {}) {
|
|
8357
|
-
if (!(element instanceof Element)) {
|
|
8358
|
-
throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
|
|
8359
|
-
}
|
|
8360
|
-
|
|
8361
|
-
if (!isFunction$1(Ctor)) {
|
|
8362
|
-
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
8363
|
-
}
|
|
8364
|
-
|
|
8365
|
-
if (!isObject(props) || isNull(props)) {
|
|
8366
|
-
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8367
|
-
}
|
|
8368
|
-
|
|
8369
|
-
try {
|
|
8370
|
-
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8371
|
-
// and uses the same algo to create the stylesheets as in SSR.
|
|
8372
|
-
setIsHydrating(true);
|
|
8373
|
-
createVM(element, Ctor, {
|
|
8374
|
-
mode: 'open',
|
|
8375
|
-
owner: null,
|
|
8376
|
-
tagName: element.tagName.toLowerCase()
|
|
8377
|
-
});
|
|
8378
|
-
|
|
8379
|
-
for (const [key, value] of Object.entries(props)) {
|
|
8380
|
-
element[key] = value;
|
|
8381
|
-
}
|
|
8382
|
-
|
|
8383
|
-
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
8384
|
-
|
|
8385
|
-
setIsHydrating(false);
|
|
8386
|
-
} catch (e) {
|
|
8387
|
-
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
|
|
8388
|
-
// the client generated DOM.
|
|
8389
|
-
|
|
8390
|
-
/* eslint-disable-next-line no-console */
|
|
8391
|
-
console.error('Recovering from error while hydrating: ', e);
|
|
8392
|
-
setIsHydrating(false);
|
|
8393
|
-
const newElem = createElement(element.tagName, {
|
|
8394
|
-
is: Ctor,
|
|
8395
|
-
mode: 'open'
|
|
8396
|
-
});
|
|
8397
|
-
|
|
8398
|
-
for (const [key, value] of Object.entries(props)) {
|
|
8399
|
-
newElem[key] = value;
|
|
8400
|
-
}
|
|
8401
|
-
|
|
8402
|
-
element.parentNode.replaceChild(newElem, element);
|
|
8403
|
-
}
|
|
8404
|
-
}
|
|
8405
|
-
/*
|
|
8406
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
8407
|
-
* All rights reserved.
|
|
8408
|
-
* SPDX-License-Identifier: MIT
|
|
8409
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8410
|
-
*/
|
|
8411
|
-
|
|
8412
|
-
/**
|
|
8413
|
-
* This function builds a Web Component class from a LWC constructor so it can be
|
|
8414
|
-
* registered as a new element via customElements.define() at any given time.
|
|
8415
|
-
*
|
|
8416
|
-
* @deprecated since version 1.3.11
|
|
8417
|
-
*
|
|
8418
|
-
* @example
|
|
8419
|
-
* ```
|
|
8420
|
-
* import { buildCustomElementConstructor } from 'lwc';
|
|
8421
|
-
* import Foo from 'ns/foo';
|
|
8422
|
-
* const WC = buildCustomElementConstructor(Foo);
|
|
8423
|
-
* customElements.define('x-foo', WC);
|
|
8424
|
-
* const elm = document.createElement('x-foo');
|
|
8425
|
-
* ```
|
|
8426
|
-
*/
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
8430
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
8431
|
-
/* eslint-disable-next-line no-console */
|
|
8432
|
-
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
8433
|
-
}
|
|
8434
|
-
|
|
8435
|
-
return Ctor.CustomElementConstructor;
|
|
8436
|
-
}
|
|
8437
|
-
|
|
8438
|
-
function buildCustomElementConstructor(Ctor) {
|
|
8439
|
-
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
8440
|
-
return class extends HtmlPrototype {
|
|
8441
|
-
constructor() {
|
|
8442
|
-
super();
|
|
8443
|
-
createVM(this, Ctor, {
|
|
8444
|
-
mode: 'open',
|
|
8445
|
-
owner: null,
|
|
8446
|
-
tagName: this.tagName
|
|
8447
|
-
});
|
|
8448
|
-
}
|
|
8449
|
-
|
|
8450
|
-
connectedCallback() {
|
|
8451
|
-
connectRootElement(this);
|
|
8452
|
-
}
|
|
8453
|
-
|
|
8454
|
-
disconnectedCallback() {
|
|
8455
|
-
disconnectRootElement(this);
|
|
8456
|
-
}
|
|
8457
|
-
|
|
8458
|
-
};
|
|
8459
|
-
}
|
|
8460
|
-
/*
|
|
8461
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
8462
|
-
* All rights reserved.
|
|
8463
|
-
* SPDX-License-Identifier: MIT
|
|
8464
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8465
|
-
*/
|
|
8466
|
-
|
|
8467
8659
|
/**
|
|
8468
8660
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
8469
8661
|
* This API is subject to change or being removed.
|
|
@@ -8495,30 +8687,31 @@ function getComponentConstructor(elm) {
|
|
|
8495
8687
|
|
|
8496
8688
|
const _Node = Node;
|
|
8497
8689
|
/**
|
|
8498
|
-
* EXPERIMENTAL:
|
|
8499
|
-
*
|
|
8690
|
+
* EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
|
|
8691
|
+
* ONCE LOCKER V1 IS NO LONGER SUPPORTED.
|
|
8500
8692
|
*/
|
|
8501
8693
|
|
|
8502
|
-
function
|
|
8694
|
+
function isNodeShadowed(node) {
|
|
8503
8695
|
if (isFalse(node instanceof _Node)) {
|
|
8504
8696
|
return false;
|
|
8505
|
-
} //
|
|
8506
|
-
// this
|
|
8697
|
+
} // It's debatable whether shadow root instances should be considered as shadowed, but we keep
|
|
8698
|
+
// this unchanged for legacy reasons (#1250).
|
|
8507
8699
|
|
|
8508
8700
|
|
|
8509
8701
|
if (node instanceof ShadowRoot) {
|
|
8510
8702
|
return false;
|
|
8511
8703
|
}
|
|
8512
8704
|
|
|
8513
|
-
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
return
|
|
8518
|
-
}
|
|
8705
|
+
const rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
|
|
8706
|
+
// synthetic roots cannot be descendants of native roots.
|
|
8707
|
+
|
|
8708
|
+
if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
|
|
8709
|
+
return true;
|
|
8710
|
+
} // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
|
|
8711
|
+
// inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
|
|
8712
|
+
|
|
8519
8713
|
|
|
8520
|
-
|
|
8521
|
-
return root instanceof ShadowRoot;
|
|
8714
|
+
return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
8522
8715
|
}
|
|
8523
8716
|
/*
|
|
8524
8717
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8563,6 +8756,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8563
8756
|
});
|
|
8564
8757
|
freeze(LightningElement);
|
|
8565
8758
|
seal(LightningElement.prototype);
|
|
8566
|
-
/* version: 2.
|
|
8759
|
+
/* version: 2.10.0 */
|
|
8567
8760
|
|
|
8568
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
8761
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|