lwc 2.32.0 → 2.33.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 +898 -802
- package/dist/engine-dom/iife/es2017/engine-dom.js +898 -802
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +683 -608
- package/dist/engine-dom/iife/es5/engine-dom.js +324 -313
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +234 -270
- package/dist/engine-dom/umd/es2017/engine-dom.js +898 -802
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +683 -608
- package/dist/engine-dom/umd/es5/engine-dom.js +324 -313
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +234 -270
- package/dist/engine-server/commonjs/es2017/engine-server.js +871 -696
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +871 -696
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +676 -909
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +676 -909
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +644 -882
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +89 -347
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +89 -347
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +676 -909
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +644 -882
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +89 -347
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +89 -347
- 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 +5 -3
- package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
- package/dist/wire-service/iife/es5/wire-service_debug.js +5 -3
- 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 +5 -3
- package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es5/wire-service_debug.js +5 -3
- package/package.json +7 -7
|
@@ -118,6 +118,9 @@ function getPropertyDescriptor(o, p) {
|
|
|
118
118
|
* The above list of 46 aria attributes is consistent with the following resources:
|
|
119
119
|
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
|
|
120
120
|
* https://wicg.github.io/aom/spec/aria-reflection.html
|
|
121
|
+
*
|
|
122
|
+
* NOTE: If you update this list, please update test files that implicitly reference this list!
|
|
123
|
+
* Searching the codebase for `aria-flowto` and `ariaFlowTo` should be good enough to find all usages.
|
|
121
124
|
*/
|
|
122
125
|
const AriaPropertyNames = [
|
|
123
126
|
'ariaActiveDescendant',
|
|
@@ -341,91 +344,9 @@ function htmlAttributeToProperty(attrName) {
|
|
|
341
344
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
342
345
|
*/
|
|
343
346
|
// Increment whenever the LWC template compiler changes
|
|
344
|
-
const LWC_VERSION = "2.
|
|
347
|
+
const LWC_VERSION = "2.33.0";
|
|
345
348
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
346
|
-
/** version: 2.
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Copyright (C) 2018 salesforce.com, inc.
|
|
350
|
-
*/
|
|
351
|
-
|
|
352
|
-
/*
|
|
353
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
354
|
-
* All rights reserved.
|
|
355
|
-
* SPDX-License-Identifier: MIT
|
|
356
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
357
|
-
*/
|
|
358
|
-
function detect(propName) {
|
|
359
|
-
return getOwnPropertyDescriptor$1(Element.prototype, propName) === undefined;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/*
|
|
363
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
364
|
-
* All rights reserved.
|
|
365
|
-
* SPDX-License-Identifier: MIT
|
|
366
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
367
|
-
*/
|
|
368
|
-
const nodeToAriaPropertyValuesMap = new WeakMap();
|
|
369
|
-
function getAriaPropertyMap(elm) {
|
|
370
|
-
let map = nodeToAriaPropertyValuesMap.get(elm);
|
|
371
|
-
if (map === undefined) {
|
|
372
|
-
map = {};
|
|
373
|
-
nodeToAriaPropertyValuesMap.set(elm, map);
|
|
374
|
-
}
|
|
375
|
-
return map;
|
|
376
|
-
}
|
|
377
|
-
function getNormalizedAriaPropertyValue(value) {
|
|
378
|
-
return value == null ? null : String(value);
|
|
379
|
-
}
|
|
380
|
-
function createAriaPropertyPropertyDescriptor(propName, attrName) {
|
|
381
|
-
return {
|
|
382
|
-
get() {
|
|
383
|
-
const map = getAriaPropertyMap(this);
|
|
384
|
-
if (hasOwnProperty$1.call(map, propName)) {
|
|
385
|
-
return map[propName];
|
|
386
|
-
}
|
|
387
|
-
// otherwise just reflect what's in the attribute
|
|
388
|
-
return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
|
|
389
|
-
},
|
|
390
|
-
set(newValue) {
|
|
391
|
-
const normalizedValue = getNormalizedAriaPropertyValue(newValue);
|
|
392
|
-
const map = getAriaPropertyMap(this);
|
|
393
|
-
map[propName] = normalizedValue;
|
|
394
|
-
// reflect into the corresponding attribute
|
|
395
|
-
if (newValue === null) {
|
|
396
|
-
this.removeAttribute(attrName);
|
|
397
|
-
}
|
|
398
|
-
else {
|
|
399
|
-
this.setAttribute(attrName, newValue);
|
|
400
|
-
}
|
|
401
|
-
},
|
|
402
|
-
configurable: true,
|
|
403
|
-
enumerable: true,
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
function patch$1(propName) {
|
|
407
|
-
// Typescript is inferring the wrong function type for this particular
|
|
408
|
-
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
|
|
409
|
-
// @ts-ignore type-mismatch
|
|
410
|
-
const attrName = AriaPropNameToAttrNameMap[propName];
|
|
411
|
-
const descriptor = createAriaPropertyPropertyDescriptor(propName, attrName);
|
|
412
|
-
Object.defineProperty(Element.prototype, propName, descriptor);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/*
|
|
416
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
417
|
-
* All rights reserved.
|
|
418
|
-
* SPDX-License-Identifier: MIT
|
|
419
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
420
|
-
*/
|
|
421
|
-
const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
|
|
422
|
-
for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
|
|
423
|
-
const propName = ElementPrototypeAriaPropertyNames[i];
|
|
424
|
-
if (detect(propName)) {
|
|
425
|
-
patch$1(propName);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
/** version: 2.32.0 */
|
|
349
|
+
/** version: 2.33.0 */
|
|
429
350
|
|
|
430
351
|
/**
|
|
431
352
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -439,19 +360,15 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
|
|
|
439
360
|
*/
|
|
440
361
|
const features = {
|
|
441
362
|
DUMMY_TEST_FLAG: null,
|
|
442
|
-
ENABLE_ELEMENT_PATCH: null,
|
|
443
363
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
444
|
-
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
445
|
-
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
446
364
|
ENABLE_MIXED_SHADOW_MODE: null,
|
|
447
365
|
ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE: null,
|
|
448
|
-
ENABLE_NODE_LIST_PATCH: null,
|
|
449
|
-
ENABLE_NODE_PATCH: null,
|
|
450
|
-
ENABLE_REACTIVE_SETTER: null,
|
|
451
366
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
452
367
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
453
368
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
454
369
|
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
370
|
+
ENABLE_FROZEN_TEMPLATE: null,
|
|
371
|
+
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
455
372
|
};
|
|
456
373
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
457
374
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -505,7 +422,83 @@ function setFeatureFlagForTest(name, value) {
|
|
|
505
422
|
setFeatureFlag(name, value);
|
|
506
423
|
}
|
|
507
424
|
}
|
|
508
|
-
/** version: 2.
|
|
425
|
+
/** version: 2.33.0 */
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Copyright (C) 2018 salesforce.com, inc.
|
|
429
|
+
*/
|
|
430
|
+
|
|
431
|
+
/*
|
|
432
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
433
|
+
* All rights reserved.
|
|
434
|
+
* SPDX-License-Identifier: MIT
|
|
435
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
436
|
+
*/
|
|
437
|
+
function detect(propName, prototype) {
|
|
438
|
+
return isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName));
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/*
|
|
442
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
443
|
+
* All rights reserved.
|
|
444
|
+
* SPDX-License-Identifier: MIT
|
|
445
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
446
|
+
*/
|
|
447
|
+
function createAriaPropertyPropertyDescriptor(attrName) {
|
|
448
|
+
// Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
|
|
449
|
+
// from Element.prototype, because these methods are overridden in LightningElement.
|
|
450
|
+
return {
|
|
451
|
+
get() {
|
|
452
|
+
// reflect what's in the attribute
|
|
453
|
+
return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
|
|
454
|
+
},
|
|
455
|
+
set(newValue) {
|
|
456
|
+
// reflect into the corresponding attribute
|
|
457
|
+
if (isNull(newValue)) {
|
|
458
|
+
this.removeAttribute(attrName);
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
this.setAttribute(attrName, newValue);
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
configurable: true,
|
|
465
|
+
enumerable: true,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
function patch$1(propName, prototype) {
|
|
469
|
+
const attrName = AriaPropNameToAttrNameMap[propName];
|
|
470
|
+
const descriptor = createAriaPropertyPropertyDescriptor(attrName);
|
|
471
|
+
defineProperty(prototype, propName, descriptor);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/*
|
|
475
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
476
|
+
* All rights reserved.
|
|
477
|
+
* SPDX-License-Identifier: MIT
|
|
478
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
479
|
+
*/
|
|
480
|
+
function applyAriaReflection(prototype = Element.prototype) {
|
|
481
|
+
const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
|
|
482
|
+
for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
|
|
483
|
+
const propName = ElementPrototypeAriaPropertyNames[i];
|
|
484
|
+
if (detect(propName, prototype)) {
|
|
485
|
+
patch$1(propName, prototype);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
/** version: 2.33.0 */
|
|
490
|
+
|
|
491
|
+
/*
|
|
492
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
493
|
+
* All rights reserved.
|
|
494
|
+
* SPDX-License-Identifier: MIT
|
|
495
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
496
|
+
*/
|
|
497
|
+
if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
498
|
+
// If DISABLE_ARIA_REFLECTION_POLYFILL is false, then we need to apply the ARIA reflection polyfill globally,
|
|
499
|
+
// i.e. to the global Element.prototype
|
|
500
|
+
applyAriaReflection();
|
|
501
|
+
}
|
|
509
502
|
|
|
510
503
|
/*
|
|
511
504
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1076,7 +1069,7 @@ function patchElementWithRestrictions(elm, options) {
|
|
|
1076
1069
|
}),
|
|
1077
1070
|
};
|
|
1078
1071
|
// Apply extra restriction related to DOM manipulation if the element is not a portal.
|
|
1079
|
-
if (!options.isLight && !options.isPortal) {
|
|
1072
|
+
if (!options.isLight && options.isSynthetic && !options.isPortal) {
|
|
1080
1073
|
const { appendChild, insertBefore, removeChild, replaceChild } = elm;
|
|
1081
1074
|
const originalNodeValueDescriptor = getPropertyDescriptor(elm, 'nodeValue');
|
|
1082
1075
|
const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
|
|
@@ -1924,46 +1917,51 @@ function markLockerLiveObject(obj) {
|
|
|
1924
1917
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1925
1918
|
*/
|
|
1926
1919
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1920
|
+
const {
|
|
1921
|
+
get,
|
|
1922
|
+
set,
|
|
1923
|
+
enumerable,
|
|
1924
|
+
configurable
|
|
1925
|
+
} = descriptor;
|
|
1926
|
+
if (!isFunction$1(get)) {
|
|
1927
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1928
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1933
1929
|
}
|
|
1934
|
-
|
|
1930
|
+
throw new TypeError();
|
|
1931
|
+
}
|
|
1932
|
+
if (!isFunction$1(set)) {
|
|
1933
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1934
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1935
|
+
}
|
|
1936
|
+
throw new TypeError();
|
|
1937
|
+
}
|
|
1938
|
+
return {
|
|
1939
|
+
enumerable,
|
|
1940
|
+
configurable,
|
|
1941
|
+
get() {
|
|
1942
|
+
const vm = getAssociatedVM(this);
|
|
1943
|
+
if (isBeingConstructed(vm)) {
|
|
1935
1944
|
if (process.env.NODE_ENV !== 'production') {
|
|
1936
|
-
|
|
1945
|
+
logError(`The value of property \`${propName}\` can't be read from the constructor because the owner component hasn't set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
1937
1946
|
}
|
|
1938
|
-
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
componentValueObserved(vm, propName);
|
|
1950
|
+
return get.call(vm.elm);
|
|
1951
|
+
},
|
|
1952
|
+
set(newValue) {
|
|
1953
|
+
const vm = getAssociatedVM(this);
|
|
1954
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1955
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
1956
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1957
|
+
assert.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
|
|
1958
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1959
|
+
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1960
|
+
}
|
|
1961
|
+
updateComponentValue(vm, propName, newValue);
|
|
1962
|
+
return set.call(vm.elm, newValue);
|
|
1939
1963
|
}
|
|
1940
|
-
|
|
1941
|
-
enumerable,
|
|
1942
|
-
configurable,
|
|
1943
|
-
get() {
|
|
1944
|
-
const vm = getAssociatedVM(this);
|
|
1945
|
-
if (isBeingConstructed(vm)) {
|
|
1946
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1947
|
-
logError(`The value of property \`${propName}\` can't be read from the constructor because the owner component hasn't set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
1948
|
-
}
|
|
1949
|
-
return;
|
|
1950
|
-
}
|
|
1951
|
-
componentValueObserved(vm, propName);
|
|
1952
|
-
return get.call(vm.elm);
|
|
1953
|
-
},
|
|
1954
|
-
set(newValue) {
|
|
1955
|
-
const vm = getAssociatedVM(this);
|
|
1956
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1957
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
1958
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1959
|
-
assert.invariant(!isUpdatingTemplate, `When updating the template of ${vmBeingRendered}, one of the accessors used by the template has side effects on the state of ${vm}.${propName}`);
|
|
1960
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1961
|
-
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1962
|
-
}
|
|
1963
|
-
updateComponentValue(vm, propName, newValue);
|
|
1964
|
-
return set.call(vm.elm, newValue);
|
|
1965
|
-
},
|
|
1966
|
-
};
|
|
1964
|
+
};
|
|
1967
1965
|
}
|
|
1968
1966
|
const EMPTY_REFS = freeze(create(null));
|
|
1969
1967
|
const refsCache = new WeakMap();
|
|
@@ -1973,345 +1971,442 @@ const refsCache = new WeakMap();
|
|
|
1973
1971
|
**/
|
|
1974
1972
|
// @ts-ignore
|
|
1975
1973
|
const LightningElement = function () {
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1974
|
+
// This should be as performant as possible, while any initialization should be done lazily
|
|
1975
|
+
if (isNull(vmBeingConstructed)) {
|
|
1976
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1977
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1978
|
+
throw new TypeError('Illegal constructor');
|
|
1979
|
+
}
|
|
1980
|
+
const vm = vmBeingConstructed;
|
|
1981
|
+
const {
|
|
1982
|
+
def,
|
|
1983
|
+
elm
|
|
1984
|
+
} = vm;
|
|
1985
|
+
const {
|
|
1986
|
+
bridge
|
|
1987
|
+
} = def;
|
|
1988
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1989
|
+
const {
|
|
1990
|
+
assertInstanceOfHTMLElement
|
|
1991
|
+
} = vm.renderer;
|
|
1992
|
+
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1993
|
+
}
|
|
1994
|
+
const component = this;
|
|
1995
|
+
setPrototypeOf(elm, bridge.prototype);
|
|
1996
|
+
vm.component = this;
|
|
1997
|
+
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
1998
|
+
// component creation and passes hooks to instrument all the component interactions with the
|
|
1999
|
+
// engine. We are intentionally hiding this argument from the formal API of LightningElement
|
|
2000
|
+
// because we don't want folks to know about it just yet.
|
|
2001
|
+
if (arguments.length === 1) {
|
|
2002
|
+
const {
|
|
2003
|
+
callHook,
|
|
2004
|
+
setHook,
|
|
2005
|
+
getHook
|
|
2006
|
+
} = arguments[0];
|
|
2007
|
+
vm.callHook = callHook;
|
|
2008
|
+
vm.setHook = setHook;
|
|
2009
|
+
vm.getHook = getHook;
|
|
2010
|
+
}
|
|
2011
|
+
markLockerLiveObject(this);
|
|
2012
|
+
// Linking elm, shadow root and component with the VM.
|
|
2013
|
+
associateVM(component, vm);
|
|
2014
|
+
associateVM(elm, vm);
|
|
2015
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
2016
|
+
vm.renderRoot = doAttachShadow(vm);
|
|
2017
|
+
} else {
|
|
2018
|
+
vm.renderRoot = elm;
|
|
2019
|
+
}
|
|
2020
|
+
// Adding extra guard rails in DEV mode.
|
|
2021
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2022
|
+
patchCustomElementWithRestrictions(elm);
|
|
2023
|
+
patchComponentWithRestrictions(component);
|
|
2024
|
+
}
|
|
2025
|
+
return this;
|
|
2026
|
+
};
|
|
2027
|
+
function doAttachShadow(vm) {
|
|
2028
|
+
const {
|
|
2029
|
+
elm,
|
|
2030
|
+
mode,
|
|
2031
|
+
shadowMode,
|
|
2032
|
+
def: {
|
|
2033
|
+
ctor
|
|
2034
|
+
},
|
|
2035
|
+
renderer: {
|
|
2036
|
+
attachShadow
|
|
2037
|
+
}
|
|
2038
|
+
} = vm;
|
|
2039
|
+
const shadowRoot = attachShadow(elm, {
|
|
2040
|
+
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
|
|
2041
|
+
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2042
|
+
mode
|
|
2043
|
+
});
|
|
2044
|
+
vm.shadowRoot = shadowRoot;
|
|
2045
|
+
associateVM(shadowRoot, vm);
|
|
2046
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2047
|
+
patchShadowRootWithRestrictions(shadowRoot);
|
|
2048
|
+
}
|
|
2049
|
+
return shadowRoot;
|
|
2050
|
+
}
|
|
2051
|
+
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
2052
|
+
if (isBeingConstructed(vm)) {
|
|
2053
|
+
logError(`this.${methodOrPropName} should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
// @ts-ignore
|
|
2057
|
+
LightningElement.prototype = {
|
|
2058
|
+
constructor: LightningElement,
|
|
2059
|
+
dispatchEvent(event) {
|
|
2060
|
+
const vm = getAssociatedVM(this);
|
|
2061
|
+
const {
|
|
2062
|
+
elm,
|
|
2063
|
+
renderer: {
|
|
2064
|
+
dispatchEvent
|
|
2065
|
+
}
|
|
2066
|
+
} = vm;
|
|
2067
|
+
return dispatchEvent(elm, event);
|
|
2068
|
+
},
|
|
2069
|
+
addEventListener(type, listener, options) {
|
|
2070
|
+
const vm = getAssociatedVM(this);
|
|
2071
|
+
const {
|
|
2072
|
+
elm,
|
|
2073
|
+
renderer: {
|
|
2074
|
+
addEventListener
|
|
2075
|
+
}
|
|
2076
|
+
} = vm;
|
|
1985
2077
|
if (process.env.NODE_ENV !== 'production') {
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
}
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2078
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2079
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2080
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2081
|
+
assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
2082
|
+
}
|
|
2083
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2084
|
+
addEventListener(elm, type, wrappedListener, options);
|
|
2085
|
+
},
|
|
2086
|
+
removeEventListener(type, listener, options) {
|
|
2087
|
+
const vm = getAssociatedVM(this);
|
|
2088
|
+
const {
|
|
2089
|
+
elm,
|
|
2090
|
+
renderer: {
|
|
2091
|
+
removeEventListener
|
|
2092
|
+
}
|
|
2093
|
+
} = vm;
|
|
2094
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2095
|
+
removeEventListener(elm, type, wrappedListener, options);
|
|
2096
|
+
},
|
|
2097
|
+
hasAttribute(name) {
|
|
2098
|
+
const vm = getAssociatedVM(this);
|
|
2099
|
+
const {
|
|
2100
|
+
elm,
|
|
2101
|
+
renderer: {
|
|
2102
|
+
getAttribute
|
|
2103
|
+
}
|
|
2104
|
+
} = vm;
|
|
2105
|
+
return !isNull(getAttribute(elm, name));
|
|
2106
|
+
},
|
|
2107
|
+
hasAttributeNS(namespace, name) {
|
|
2108
|
+
const vm = getAssociatedVM(this);
|
|
2109
|
+
const {
|
|
2110
|
+
elm,
|
|
2111
|
+
renderer: {
|
|
2112
|
+
getAttribute
|
|
2113
|
+
}
|
|
2114
|
+
} = vm;
|
|
2115
|
+
return !isNull(getAttribute(elm, name, namespace));
|
|
2116
|
+
},
|
|
2117
|
+
removeAttribute(name) {
|
|
2118
|
+
const vm = getAssociatedVM(this);
|
|
2119
|
+
const {
|
|
2120
|
+
elm,
|
|
2121
|
+
renderer: {
|
|
2122
|
+
removeAttribute
|
|
2123
|
+
}
|
|
2124
|
+
} = vm;
|
|
2125
|
+
unlockAttribute(elm, name);
|
|
2126
|
+
removeAttribute(elm, name);
|
|
2127
|
+
lockAttribute();
|
|
2128
|
+
},
|
|
2129
|
+
removeAttributeNS(namespace, name) {
|
|
2130
|
+
const {
|
|
2131
|
+
elm,
|
|
2132
|
+
renderer: {
|
|
2133
|
+
removeAttribute
|
|
2134
|
+
}
|
|
2135
|
+
} = getAssociatedVM(this);
|
|
2136
|
+
unlockAttribute(elm, name);
|
|
2137
|
+
removeAttribute(elm, name, namespace);
|
|
2138
|
+
lockAttribute();
|
|
2139
|
+
},
|
|
2140
|
+
getAttribute(name) {
|
|
2141
|
+
const vm = getAssociatedVM(this);
|
|
2142
|
+
const {
|
|
2143
|
+
elm
|
|
2144
|
+
} = vm;
|
|
2145
|
+
const {
|
|
2146
|
+
getAttribute
|
|
2147
|
+
} = vm.renderer;
|
|
2148
|
+
return getAttribute(elm, name);
|
|
2149
|
+
},
|
|
2150
|
+
getAttributeNS(namespace, name) {
|
|
2151
|
+
const vm = getAssociatedVM(this);
|
|
2152
|
+
const {
|
|
2153
|
+
elm
|
|
2154
|
+
} = vm;
|
|
2155
|
+
const {
|
|
2156
|
+
getAttribute
|
|
2157
|
+
} = vm.renderer;
|
|
2158
|
+
return getAttribute(elm, name, namespace);
|
|
2159
|
+
},
|
|
2160
|
+
setAttribute(name, value) {
|
|
2161
|
+
const vm = getAssociatedVM(this);
|
|
2162
|
+
const {
|
|
2163
|
+
elm,
|
|
2164
|
+
renderer: {
|
|
2165
|
+
setAttribute
|
|
2166
|
+
}
|
|
2167
|
+
} = vm;
|
|
2168
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2169
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2170
|
+
}
|
|
2171
|
+
unlockAttribute(elm, name);
|
|
2172
|
+
setAttribute(elm, name, value);
|
|
2173
|
+
lockAttribute();
|
|
2174
|
+
},
|
|
2175
|
+
setAttributeNS(namespace, name, value) {
|
|
2176
|
+
const vm = getAssociatedVM(this);
|
|
2177
|
+
const {
|
|
2178
|
+
elm,
|
|
2179
|
+
renderer: {
|
|
2180
|
+
setAttribute
|
|
2181
|
+
}
|
|
2182
|
+
} = vm;
|
|
2183
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2184
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2185
|
+
}
|
|
2186
|
+
unlockAttribute(elm, name);
|
|
2187
|
+
setAttribute(elm, name, value, namespace);
|
|
2188
|
+
lockAttribute();
|
|
2189
|
+
},
|
|
2190
|
+
getBoundingClientRect() {
|
|
2191
|
+
const vm = getAssociatedVM(this);
|
|
2192
|
+
const {
|
|
2193
|
+
elm,
|
|
2194
|
+
renderer: {
|
|
2195
|
+
getBoundingClientRect
|
|
2196
|
+
}
|
|
2197
|
+
} = vm;
|
|
2198
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2199
|
+
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2008
2200
|
}
|
|
2009
|
-
|
|
2010
|
-
|
|
2201
|
+
return getBoundingClientRect(elm);
|
|
2202
|
+
},
|
|
2203
|
+
get isConnected() {
|
|
2204
|
+
const vm = getAssociatedVM(this);
|
|
2205
|
+
const {
|
|
2206
|
+
elm,
|
|
2207
|
+
renderer: {
|
|
2208
|
+
isConnected
|
|
2209
|
+
}
|
|
2210
|
+
} = vm;
|
|
2211
|
+
return isConnected(elm);
|
|
2212
|
+
},
|
|
2213
|
+
get classList() {
|
|
2214
|
+
const vm = getAssociatedVM(this);
|
|
2215
|
+
const {
|
|
2216
|
+
elm,
|
|
2217
|
+
renderer: {
|
|
2218
|
+
getClassList
|
|
2219
|
+
}
|
|
2220
|
+
} = vm;
|
|
2221
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2222
|
+
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2223
|
+
// just throw in all modes
|
|
2224
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
|
|
2225
|
+
}
|
|
2226
|
+
return getClassList(elm);
|
|
2227
|
+
},
|
|
2228
|
+
get template() {
|
|
2229
|
+
const vm = getAssociatedVM(this);
|
|
2230
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2231
|
+
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2232
|
+
logError('`this.template` returns null for light DOM components. Since there is no shadow, the rendered content can be accessed via `this` itself. e.g. instead of `this.template.querySelector`, use `this.querySelector`.');
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return vm.shadowRoot;
|
|
2236
|
+
},
|
|
2237
|
+
get refs() {
|
|
2238
|
+
const vm = getAssociatedVM(this);
|
|
2239
|
+
if (isUpdatingTemplate) {
|
|
2240
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2241
|
+
logError(`this.refs should not be called while ${getComponentTag(vm)} is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback().`);
|
|
2242
|
+
}
|
|
2243
|
+
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2244
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2245
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2246
|
+
// based on `this.refs.bar`.
|
|
2247
|
+
return;
|
|
2011
2248
|
}
|
|
2012
|
-
// Adding extra guard rails in DEV mode.
|
|
2013
2249
|
if (process.env.NODE_ENV !== 'production') {
|
|
2014
|
-
|
|
2015
|
-
patchComponentWithRestrictions(component);
|
|
2250
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2016
2251
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2252
|
+
const {
|
|
2253
|
+
refVNodes,
|
|
2254
|
+
hasRefVNodes,
|
|
2255
|
+
cmpTemplate
|
|
2256
|
+
} = vm;
|
|
2257
|
+
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2258
|
+
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2259
|
+
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2260
|
+
// `warnIfInvokedDuringConstruction` above).
|
|
2261
|
+
if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
|
|
2262
|
+
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` + `invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` + `been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2263
|
+
}
|
|
2264
|
+
// For backwards compatibility with component written before template refs
|
|
2265
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
2266
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2267
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2268
|
+
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2269
|
+
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2270
|
+
if (!hasRefVNodes) {
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2274
|
+
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2275
|
+
if (isNull(refVNodes)) {
|
|
2276
|
+
return EMPTY_REFS;
|
|
2277
|
+
}
|
|
2278
|
+
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2279
|
+
// are recreated from scratch every time the template is rendered.
|
|
2280
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2281
|
+
let refs = refsCache.get(refVNodes);
|
|
2282
|
+
if (isUndefined$1(refs)) {
|
|
2283
|
+
refs = create(null);
|
|
2284
|
+
for (const key of keys(refVNodes)) {
|
|
2285
|
+
refs[key] = refVNodes[key].elm;
|
|
2286
|
+
}
|
|
2287
|
+
freeze(refs);
|
|
2288
|
+
refsCache.set(refVNodes, refs);
|
|
2289
|
+
}
|
|
2290
|
+
return refs;
|
|
2291
|
+
},
|
|
2292
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2293
|
+
set refs(value) {
|
|
2294
|
+
defineProperty(this, 'refs', {
|
|
2295
|
+
configurable: true,
|
|
2296
|
+
enumerable: true,
|
|
2297
|
+
writable: true,
|
|
2298
|
+
value
|
|
2025
2299
|
});
|
|
2026
|
-
|
|
2027
|
-
|
|
2300
|
+
},
|
|
2301
|
+
get shadowRoot() {
|
|
2302
|
+
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2303
|
+
// Authors should rely on this.template instead.
|
|
2304
|
+
return null;
|
|
2305
|
+
},
|
|
2306
|
+
get children() {
|
|
2307
|
+
const vm = getAssociatedVM(this);
|
|
2308
|
+
const renderer = vm.renderer;
|
|
2028
2309
|
if (process.env.NODE_ENV !== 'production') {
|
|
2029
|
-
|
|
2310
|
+
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2030
2311
|
}
|
|
2031
|
-
return
|
|
2032
|
-
}
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2312
|
+
return renderer.getChildren(vm.elm);
|
|
2313
|
+
},
|
|
2314
|
+
get childNodes() {
|
|
2315
|
+
const vm = getAssociatedVM(this);
|
|
2316
|
+
const renderer = vm.renderer;
|
|
2317
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2318
|
+
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
2036
2319
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
lockAttribute();
|
|
2080
|
-
},
|
|
2081
|
-
removeAttributeNS(namespace, name) {
|
|
2082
|
-
const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
|
|
2083
|
-
unlockAttribute(elm, name);
|
|
2084
|
-
removeAttribute(elm, name, namespace);
|
|
2085
|
-
lockAttribute();
|
|
2086
|
-
},
|
|
2087
|
-
getAttribute(name) {
|
|
2088
|
-
const vm = getAssociatedVM(this);
|
|
2089
|
-
const { elm } = vm;
|
|
2090
|
-
const { getAttribute } = vm.renderer;
|
|
2091
|
-
return getAttribute(elm, name);
|
|
2092
|
-
},
|
|
2093
|
-
getAttributeNS(namespace, name) {
|
|
2094
|
-
const vm = getAssociatedVM(this);
|
|
2095
|
-
const { elm } = vm;
|
|
2096
|
-
const { getAttribute } = vm.renderer;
|
|
2097
|
-
return getAttribute(elm, name, namespace);
|
|
2098
|
-
},
|
|
2099
|
-
setAttribute(name, value) {
|
|
2100
|
-
const vm = getAssociatedVM(this);
|
|
2101
|
-
const { elm, renderer: { setAttribute }, } = vm;
|
|
2102
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2103
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2104
|
-
}
|
|
2105
|
-
unlockAttribute(elm, name);
|
|
2106
|
-
setAttribute(elm, name, value);
|
|
2107
|
-
lockAttribute();
|
|
2108
|
-
},
|
|
2109
|
-
setAttributeNS(namespace, name, value) {
|
|
2110
|
-
const vm = getAssociatedVM(this);
|
|
2111
|
-
const { elm, renderer: { setAttribute }, } = vm;
|
|
2112
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2113
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2114
|
-
}
|
|
2115
|
-
unlockAttribute(elm, name);
|
|
2116
|
-
setAttribute(elm, name, value, namespace);
|
|
2117
|
-
lockAttribute();
|
|
2118
|
-
},
|
|
2119
|
-
getBoundingClientRect() {
|
|
2120
|
-
const vm = getAssociatedVM(this);
|
|
2121
|
-
const { elm, renderer: { getBoundingClientRect }, } = vm;
|
|
2122
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2123
|
-
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2124
|
-
}
|
|
2125
|
-
return getBoundingClientRect(elm);
|
|
2126
|
-
},
|
|
2127
|
-
get isConnected() {
|
|
2128
|
-
const vm = getAssociatedVM(this);
|
|
2129
|
-
const { elm, renderer: { isConnected }, } = vm;
|
|
2130
|
-
return isConnected(elm);
|
|
2131
|
-
},
|
|
2132
|
-
get classList() {
|
|
2133
|
-
const vm = getAssociatedVM(this);
|
|
2134
|
-
const { elm, renderer: { getClassList }, } = vm;
|
|
2135
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2136
|
-
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2137
|
-
// just throw in all modes
|
|
2138
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct ${vm}: The result must not have attributes. Adding or tampering with classname in constructor is not allowed in a web component, use connectedCallback() instead.`);
|
|
2139
|
-
}
|
|
2140
|
-
return getClassList(elm);
|
|
2141
|
-
},
|
|
2142
|
-
get template() {
|
|
2143
|
-
const vm = getAssociatedVM(this);
|
|
2144
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2145
|
-
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2146
|
-
logError('`this.template` returns null for light DOM components. Since there is no shadow, the rendered content can be accessed via `this` itself. e.g. instead of `this.template.querySelector`, use `this.querySelector`.');
|
|
2147
|
-
}
|
|
2148
|
-
}
|
|
2149
|
-
return vm.shadowRoot;
|
|
2150
|
-
},
|
|
2151
|
-
get refs() {
|
|
2152
|
-
const vm = getAssociatedVM(this);
|
|
2153
|
-
if (isUpdatingTemplate) {
|
|
2154
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2155
|
-
logError(`this.refs should not be called while ${getComponentTag(vm)} is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback().`);
|
|
2156
|
-
}
|
|
2157
|
-
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2158
|
-
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2159
|
-
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2160
|
-
// based on `this.refs.bar`.
|
|
2161
|
-
return;
|
|
2162
|
-
}
|
|
2163
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2164
|
-
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2165
|
-
}
|
|
2166
|
-
const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
|
|
2167
|
-
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2168
|
-
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2169
|
-
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2170
|
-
// `warnIfInvokedDuringConstruction` above).
|
|
2171
|
-
if (process.env.NODE_ENV !== 'production' &&
|
|
2172
|
-
isNull(cmpTemplate) &&
|
|
2173
|
-
!isBeingConstructed(vm)) {
|
|
2174
|
-
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
|
|
2175
|
-
`invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
|
|
2176
|
-
`been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2177
|
-
}
|
|
2178
|
-
// For backwards compatibility with component written before template refs
|
|
2179
|
-
// were introduced, we return undefined if the template has no refs defined
|
|
2180
|
-
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2181
|
-
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2182
|
-
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2183
|
-
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2184
|
-
if (!hasRefVNodes) {
|
|
2185
|
-
return;
|
|
2186
|
-
}
|
|
2187
|
-
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2188
|
-
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2189
|
-
if (isNull(refVNodes)) {
|
|
2190
|
-
return EMPTY_REFS;
|
|
2191
|
-
}
|
|
2192
|
-
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2193
|
-
// are recreated from scratch every time the template is rendered.
|
|
2194
|
-
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2195
|
-
let refs = refsCache.get(refVNodes);
|
|
2196
|
-
if (isUndefined$1(refs)) {
|
|
2197
|
-
refs = create(null);
|
|
2198
|
-
for (const key of keys(refVNodes)) {
|
|
2199
|
-
refs[key] = refVNodes[key].elm;
|
|
2200
|
-
}
|
|
2201
|
-
freeze(refs);
|
|
2202
|
-
refsCache.set(refVNodes, refs);
|
|
2203
|
-
}
|
|
2204
|
-
return refs;
|
|
2205
|
-
},
|
|
2206
|
-
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2207
|
-
set refs(value) {
|
|
2208
|
-
defineProperty(this, 'refs', {
|
|
2209
|
-
configurable: true,
|
|
2210
|
-
enumerable: true,
|
|
2211
|
-
writable: true,
|
|
2212
|
-
value,
|
|
2213
|
-
});
|
|
2214
|
-
},
|
|
2215
|
-
get shadowRoot() {
|
|
2216
|
-
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2217
|
-
// Authors should rely on this.template instead.
|
|
2218
|
-
return null;
|
|
2219
|
-
},
|
|
2220
|
-
get children() {
|
|
2221
|
-
const vm = getAssociatedVM(this);
|
|
2222
|
-
const renderer = vm.renderer;
|
|
2223
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2224
|
-
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2225
|
-
}
|
|
2226
|
-
return renderer.getChildren(vm.elm);
|
|
2227
|
-
},
|
|
2228
|
-
get childNodes() {
|
|
2229
|
-
const vm = getAssociatedVM(this);
|
|
2230
|
-
const renderer = vm.renderer;
|
|
2231
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2232
|
-
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
2233
|
-
}
|
|
2234
|
-
return renderer.getChildNodes(vm.elm);
|
|
2235
|
-
},
|
|
2236
|
-
get firstChild() {
|
|
2237
|
-
const vm = getAssociatedVM(this);
|
|
2238
|
-
const renderer = vm.renderer;
|
|
2239
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2240
|
-
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2241
|
-
}
|
|
2242
|
-
return renderer.getFirstChild(vm.elm);
|
|
2243
|
-
},
|
|
2244
|
-
get firstElementChild() {
|
|
2245
|
-
const vm = getAssociatedVM(this);
|
|
2246
|
-
const renderer = vm.renderer;
|
|
2247
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2248
|
-
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2249
|
-
}
|
|
2250
|
-
return renderer.getFirstElementChild(vm.elm);
|
|
2251
|
-
},
|
|
2252
|
-
get lastChild() {
|
|
2253
|
-
const vm = getAssociatedVM(this);
|
|
2254
|
-
const renderer = vm.renderer;
|
|
2255
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2256
|
-
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2257
|
-
}
|
|
2258
|
-
return renderer.getLastChild(vm.elm);
|
|
2259
|
-
},
|
|
2260
|
-
get lastElementChild() {
|
|
2261
|
-
const vm = getAssociatedVM(this);
|
|
2262
|
-
const renderer = vm.renderer;
|
|
2263
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2264
|
-
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2265
|
-
}
|
|
2266
|
-
return renderer.getLastElementChild(vm.elm);
|
|
2267
|
-
},
|
|
2268
|
-
render() {
|
|
2269
|
-
const vm = getAssociatedVM(this);
|
|
2270
|
-
return vm.def.template;
|
|
2271
|
-
},
|
|
2272
|
-
toString() {
|
|
2273
|
-
const vm = getAssociatedVM(this);
|
|
2274
|
-
return `[object ${vm.def.name}]`;
|
|
2275
|
-
},
|
|
2320
|
+
return renderer.getChildNodes(vm.elm);
|
|
2321
|
+
},
|
|
2322
|
+
get firstChild() {
|
|
2323
|
+
const vm = getAssociatedVM(this);
|
|
2324
|
+
const renderer = vm.renderer;
|
|
2325
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2326
|
+
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2327
|
+
}
|
|
2328
|
+
return renderer.getFirstChild(vm.elm);
|
|
2329
|
+
},
|
|
2330
|
+
get firstElementChild() {
|
|
2331
|
+
const vm = getAssociatedVM(this);
|
|
2332
|
+
const renderer = vm.renderer;
|
|
2333
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2334
|
+
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2335
|
+
}
|
|
2336
|
+
return renderer.getFirstElementChild(vm.elm);
|
|
2337
|
+
},
|
|
2338
|
+
get lastChild() {
|
|
2339
|
+
const vm = getAssociatedVM(this);
|
|
2340
|
+
const renderer = vm.renderer;
|
|
2341
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2342
|
+
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2343
|
+
}
|
|
2344
|
+
return renderer.getLastChild(vm.elm);
|
|
2345
|
+
},
|
|
2346
|
+
get lastElementChild() {
|
|
2347
|
+
const vm = getAssociatedVM(this);
|
|
2348
|
+
const renderer = vm.renderer;
|
|
2349
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2350
|
+
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2351
|
+
}
|
|
2352
|
+
return renderer.getLastElementChild(vm.elm);
|
|
2353
|
+
},
|
|
2354
|
+
render() {
|
|
2355
|
+
const vm = getAssociatedVM(this);
|
|
2356
|
+
return vm.def.template;
|
|
2357
|
+
},
|
|
2358
|
+
toString() {
|
|
2359
|
+
const vm = getAssociatedVM(this);
|
|
2360
|
+
return `[object ${vm.def.name}]`;
|
|
2361
|
+
}
|
|
2276
2362
|
};
|
|
2277
2363
|
const queryAndChildGetterDescriptors = create(null);
|
|
2278
|
-
const queryMethods = [
|
|
2279
|
-
'getElementsByClassName',
|
|
2280
|
-
'getElementsByTagName',
|
|
2281
|
-
'querySelector',
|
|
2282
|
-
'querySelectorAll',
|
|
2283
|
-
];
|
|
2364
|
+
const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
|
|
2284
2365
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2285
2366
|
for (const queryMethod of queryMethods) {
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2367
|
+
queryAndChildGetterDescriptors[queryMethod] = {
|
|
2368
|
+
value(arg) {
|
|
2369
|
+
const vm = getAssociatedVM(this);
|
|
2370
|
+
const {
|
|
2371
|
+
elm,
|
|
2372
|
+
renderer
|
|
2373
|
+
} = vm;
|
|
2374
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2375
|
+
warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
|
|
2376
|
+
}
|
|
2377
|
+
return renderer[queryMethod](elm, arg);
|
|
2378
|
+
},
|
|
2379
|
+
configurable: true,
|
|
2380
|
+
enumerable: true,
|
|
2381
|
+
writable: true
|
|
2382
|
+
};
|
|
2299
2383
|
}
|
|
2300
2384
|
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
2301
2385
|
const lightningBasedDescriptors = create(null);
|
|
2302
2386
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
2303
|
-
|
|
2387
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
2304
2388
|
}
|
|
2305
2389
|
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
2390
|
+
function applyAriaReflectionToLightningElement() {
|
|
2391
|
+
// If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
|
|
2392
|
+
// apply it to LightningElement.prototype.
|
|
2393
|
+
// This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
|
|
2394
|
+
applyAriaReflection(LightningElement.prototype);
|
|
2395
|
+
}
|
|
2396
|
+
// The reason for this odd if/else branching is limitations in @lwc/features:
|
|
2397
|
+
// https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#only-works-with-if-statements
|
|
2398
|
+
if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
2399
|
+
applyAriaReflectionToLightningElement();
|
|
2400
|
+
}
|
|
2306
2401
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2402
|
+
get() {
|
|
2403
|
+
// If required, a runtime-specific implementation must be defined.
|
|
2404
|
+
throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
|
|
2405
|
+
},
|
|
2406
|
+
configurable: true
|
|
2312
2407
|
});
|
|
2313
2408
|
if (process.env.NODE_ENV !== 'production') {
|
|
2314
|
-
|
|
2409
|
+
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
|
|
2315
2410
|
}
|
|
2316
2411
|
|
|
2317
2412
|
function createObservedFieldPropertyDescriptor(key) {
|
|
@@ -2329,45 +2424,6 @@ function createObservedFieldPropertyDescriptor(key) {
|
|
|
2329
2424
|
configurable: true,
|
|
2330
2425
|
};
|
|
2331
2426
|
}
|
|
2332
|
-
class AccessorReactiveObserver extends ReactiveObserver {
|
|
2333
|
-
constructor(vm, set) {
|
|
2334
|
-
super(() => {
|
|
2335
|
-
if (isFalse(this.debouncing)) {
|
|
2336
|
-
this.debouncing = true;
|
|
2337
|
-
addCallbackToNextTick(() => {
|
|
2338
|
-
if (isTrue(this.debouncing)) {
|
|
2339
|
-
const { value } = this;
|
|
2340
|
-
const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
|
|
2341
|
-
set.call(component, value);
|
|
2342
|
-
// de-bouncing after the call to the original setter to prevent
|
|
2343
|
-
// infinity loop if the setter itself is mutating things that
|
|
2344
|
-
// were accessed during the previous invocation.
|
|
2345
|
-
this.debouncing = false;
|
|
2346
|
-
if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
|
|
2347
|
-
// immediate rehydration due to a setter driven mutation, otherwise
|
|
2348
|
-
// the component will get rendered on the second tick, which it is not
|
|
2349
|
-
// desirable.
|
|
2350
|
-
rerenderVM(vm);
|
|
2351
|
-
}
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
}
|
|
2355
|
-
});
|
|
2356
|
-
this.debouncing = false;
|
|
2357
|
-
}
|
|
2358
|
-
reset(value) {
|
|
2359
|
-
super.reset();
|
|
2360
|
-
this.debouncing = false;
|
|
2361
|
-
if (arguments.length > 0) {
|
|
2362
|
-
this.value = value;
|
|
2363
|
-
}
|
|
2364
|
-
}
|
|
2365
|
-
}
|
|
2366
|
-
function createAccessorReactiveObserver(vm, set) {
|
|
2367
|
-
// On the server side, we don't need mutation tracking. Skipping it improves performance.
|
|
2368
|
-
return new AccessorReactiveObserver(vm, set)
|
|
2369
|
-
;
|
|
2370
|
-
}
|
|
2371
2427
|
|
|
2372
2428
|
/*
|
|
2373
2429
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -2376,90 +2432,71 @@ function createAccessorReactiveObserver(vm, set) {
|
|
|
2376
2432
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2377
2433
|
*/
|
|
2378
2434
|
function api$1() {
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2435
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2436
|
+
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
2437
|
+
}
|
|
2438
|
+
throw new Error();
|
|
2383
2439
|
}
|
|
2384
2440
|
function createPublicPropertyDescriptor(key) {
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2441
|
+
return {
|
|
2442
|
+
get() {
|
|
2443
|
+
const vm = getAssociatedVM(this);
|
|
2444
|
+
if (isBeingConstructed(vm)) {
|
|
2445
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2446
|
+
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
2447
|
+
}
|
|
2448
|
+
return;
|
|
2449
|
+
}
|
|
2450
|
+
componentValueObserved(vm, key);
|
|
2451
|
+
return vm.cmpProps[key];
|
|
2452
|
+
},
|
|
2453
|
+
set(newValue) {
|
|
2454
|
+
const vm = getAssociatedVM(this);
|
|
2455
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2456
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2457
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2458
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2459
|
+
}
|
|
2460
|
+
vm.cmpProps[key] = newValue;
|
|
2461
|
+
componentValueMutated(vm, key);
|
|
2462
|
+
},
|
|
2463
|
+
enumerable: true,
|
|
2464
|
+
configurable: true,
|
|
2465
|
+
};
|
|
2410
2466
|
}
|
|
2411
2467
|
function createPublicAccessorDescriptor(key, descriptor) {
|
|
2412
|
-
|
|
2413
|
-
get
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
configurable
|
|
2417
|
-
} = descriptor;
|
|
2418
|
-
if (!isFunction$1(get)) {
|
|
2419
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2420
|
-
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
2421
|
-
}
|
|
2422
|
-
throw new Error();
|
|
2423
|
-
}
|
|
2424
|
-
return {
|
|
2425
|
-
get() {
|
|
2426
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2427
|
-
// Assert that the this value is an actual Component with an associated VM.
|
|
2428
|
-
getAssociatedVM(this);
|
|
2429
|
-
}
|
|
2430
|
-
return get.call(this);
|
|
2431
|
-
},
|
|
2432
|
-
set(newValue) {
|
|
2433
|
-
const vm = getAssociatedVM(this);
|
|
2434
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2435
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
2436
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2437
|
-
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2438
|
-
}
|
|
2439
|
-
if (set) {
|
|
2440
|
-
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
2441
|
-
let ro = vm.oar[key];
|
|
2442
|
-
if (isUndefined$1(ro)) {
|
|
2443
|
-
ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
|
|
2444
|
-
}
|
|
2445
|
-
// every time we invoke this setter from outside (through this wrapper setter)
|
|
2446
|
-
// we should reset the value and then debounce just in case there is a pending
|
|
2447
|
-
// invocation the next tick that is not longer relevant since the value is changing
|
|
2448
|
-
// from outside.
|
|
2449
|
-
ro.reset(newValue);
|
|
2450
|
-
ro.observe(() => {
|
|
2451
|
-
set.call(this, newValue);
|
|
2452
|
-
});
|
|
2453
|
-
} else {
|
|
2454
|
-
set.call(this, newValue);
|
|
2468
|
+
const { get, set, enumerable, configurable } = descriptor;
|
|
2469
|
+
if (!isFunction$1(get)) {
|
|
2470
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2471
|
+
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
2455
2472
|
}
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2473
|
+
throw new Error();
|
|
2474
|
+
}
|
|
2475
|
+
return {
|
|
2476
|
+
get() {
|
|
2477
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2478
|
+
// Assert that the this value is an actual Component with an associated VM.
|
|
2479
|
+
getAssociatedVM(this);
|
|
2480
|
+
}
|
|
2481
|
+
return get.call(this);
|
|
2482
|
+
},
|
|
2483
|
+
set(newValue) {
|
|
2484
|
+
const vm = getAssociatedVM(this);
|
|
2485
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2486
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2487
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2488
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2489
|
+
}
|
|
2490
|
+
if (set) {
|
|
2491
|
+
set.call(this, newValue);
|
|
2492
|
+
}
|
|
2493
|
+
else if (process.env.NODE_ENV !== 'production') {
|
|
2494
|
+
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
2495
|
+
}
|
|
2496
|
+
},
|
|
2497
|
+
enumerable,
|
|
2498
|
+
configurable,
|
|
2499
|
+
};
|
|
2463
2500
|
}
|
|
2464
2501
|
|
|
2465
2502
|
/*
|
|
@@ -2785,12 +2822,6 @@ function checkVersionMismatch(func, type) {
|
|
|
2785
2822
|
}
|
|
2786
2823
|
}
|
|
2787
2824
|
|
|
2788
|
-
/*
|
|
2789
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
2790
|
-
* All rights reserved.
|
|
2791
|
-
* SPDX-License-Identifier: MIT
|
|
2792
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2793
|
-
*/
|
|
2794
2825
|
const signedTemplateSet = new Set();
|
|
2795
2826
|
function defaultEmptyTemplate() {
|
|
2796
2827
|
return [];
|
|
@@ -2808,32 +2839,6 @@ function registerTemplate(tpl) {
|
|
|
2808
2839
|
checkVersionMismatch(tpl, 'template');
|
|
2809
2840
|
}
|
|
2810
2841
|
signedTemplateSet.add(tpl);
|
|
2811
|
-
// FIXME[@W-10950976]: the template object should be frozen, and it should not be possible to set
|
|
2812
|
-
// the stylesheets or stylesheetToken(s). For backwards compat, though, we shim stylesheetTokens
|
|
2813
|
-
// on top of stylesheetToken for anyone who is accessing the old internal API.
|
|
2814
|
-
// Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
2815
|
-
defineProperty(tpl, 'stylesheetTokens', {
|
|
2816
|
-
enumerable: true,
|
|
2817
|
-
configurable: true,
|
|
2818
|
-
get() {
|
|
2819
|
-
const { stylesheetToken } = this;
|
|
2820
|
-
if (isUndefined$1(stylesheetToken)) {
|
|
2821
|
-
return stylesheetToken;
|
|
2822
|
-
}
|
|
2823
|
-
// Shim for the old `stylesheetTokens` property
|
|
2824
|
-
// See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
|
|
2825
|
-
return {
|
|
2826
|
-
hostAttribute: `${stylesheetToken}-host`,
|
|
2827
|
-
shadowAttribute: stylesheetToken,
|
|
2828
|
-
};
|
|
2829
|
-
},
|
|
2830
|
-
set(value) {
|
|
2831
|
-
// If the value is null or some other exotic object, you would be broken anyway in the past
|
|
2832
|
-
// because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
|
|
2833
|
-
// However it may be undefined in newer versions of LWC, so we need to guard against that case.
|
|
2834
|
-
this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
|
|
2835
|
-
},
|
|
2836
|
-
});
|
|
2837
2842
|
// chaining this method as a way to wrap existing
|
|
2838
2843
|
// assignment of templates easily, without too much transformation
|
|
2839
2844
|
return tpl;
|
|
@@ -2861,138 +2866,161 @@ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
|
2861
2866
|
const cachedGetterByKey = create(null);
|
|
2862
2867
|
const cachedSetterByKey = create(null);
|
|
2863
2868
|
function createGetter(key) {
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2869
|
+
let fn = cachedGetterByKey[key];
|
|
2870
|
+
if (isUndefined$1(fn)) {
|
|
2871
|
+
fn = cachedGetterByKey[key] = function () {
|
|
2872
|
+
const vm = getAssociatedVM(this);
|
|
2873
|
+
const {
|
|
2874
|
+
getHook
|
|
2875
|
+
} = vm;
|
|
2876
|
+
return getHook(vm.component, key);
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2879
|
+
return fn;
|
|
2873
2880
|
}
|
|
2874
2881
|
function createSetter(key) {
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2882
|
+
let fn = cachedSetterByKey[key];
|
|
2883
|
+
if (isUndefined$1(fn)) {
|
|
2884
|
+
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2885
|
+
const vm = getAssociatedVM(this);
|
|
2886
|
+
const {
|
|
2887
|
+
setHook
|
|
2888
|
+
} = vm;
|
|
2889
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2890
|
+
setHook(vm.component, key, newValue);
|
|
2891
|
+
};
|
|
2892
|
+
}
|
|
2893
|
+
return fn;
|
|
2885
2894
|
}
|
|
2886
2895
|
function createMethodCaller(methodName) {
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
};
|
|
2896
|
+
return function () {
|
|
2897
|
+
const vm = getAssociatedVM(this);
|
|
2898
|
+
const {
|
|
2899
|
+
callHook,
|
|
2900
|
+
component
|
|
2901
|
+
} = vm;
|
|
2902
|
+
const fn = component[methodName];
|
|
2903
|
+
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
2904
|
+
};
|
|
2893
2905
|
}
|
|
2894
2906
|
function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
}
|
|
2900
|
-
const propName = attributeToPropMap[attrName];
|
|
2901
|
-
if (isUndefined$1(propName)) {
|
|
2902
|
-
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
2903
|
-
// delegate unknown attributes to the super.
|
|
2904
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2905
|
-
// @ts-ignore type-mismatch
|
|
2906
|
-
superAttributeChangedCallback.apply(this, arguments);
|
|
2907
|
-
}
|
|
2908
|
-
return;
|
|
2909
|
-
}
|
|
2910
|
-
if (!isAttributeLocked(this, attrName)) {
|
|
2911
|
-
// Ignore changes triggered by the engine itself during:
|
|
2912
|
-
// * diffing when public props are attempting to reflect to the DOM
|
|
2913
|
-
// * component via `this.setAttribute()`, should never update the prop
|
|
2914
|
-
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
2915
|
-
// attribute to be changed
|
|
2916
|
-
return;
|
|
2917
|
-
}
|
|
2918
|
-
// Reflect attribute change to the corresponding property when changed from outside.
|
|
2919
|
-
this[propName] = newValue;
|
|
2920
|
-
};
|
|
2921
|
-
}
|
|
2922
|
-
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
2923
|
-
let HTMLBridgeElement;
|
|
2924
|
-
/**
|
|
2925
|
-
* Modern browsers will have all Native Constructors as regular Classes
|
|
2926
|
-
* and must be instantiated with the new keyword. In older browsers,
|
|
2927
|
-
* specifically IE11, those are objects with a prototype property defined,
|
|
2928
|
-
* since they are not supposed to be extended or instantiated with the
|
|
2929
|
-
* new keyword. This forking logic supports both cases, specifically because
|
|
2930
|
-
* wc.ts relies on the construction path of the bridges to create new
|
|
2931
|
-
* fully qualifying web components.
|
|
2932
|
-
*/
|
|
2933
|
-
if (isFunction$1(SuperClass)) {
|
|
2934
|
-
HTMLBridgeElement = class extends SuperClass {
|
|
2935
|
-
};
|
|
2936
|
-
}
|
|
2937
|
-
else {
|
|
2938
|
-
HTMLBridgeElement = function () {
|
|
2939
|
-
// Bridge classes are not supposed to be instantiated directly in
|
|
2940
|
-
// browsers that do not support web components.
|
|
2941
|
-
throw new TypeError('Illegal constructor');
|
|
2942
|
-
};
|
|
2943
|
-
// prototype inheritance dance
|
|
2944
|
-
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
2945
|
-
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
2946
|
-
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
2947
|
-
writable: true,
|
|
2948
|
-
configurable: true,
|
|
2949
|
-
value: HTMLBridgeElement,
|
|
2950
|
-
});
|
|
2907
|
+
return function attributeChangedCallback(attrName, oldValue, newValue) {
|
|
2908
|
+
if (oldValue === newValue) {
|
|
2909
|
+
// Ignore same values.
|
|
2910
|
+
return;
|
|
2951
2911
|
}
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
2962
|
-
descriptors[propName] = {
|
|
2963
|
-
get: createGetter(propName),
|
|
2964
|
-
set: createSetter(propName),
|
|
2965
|
-
enumerable: true,
|
|
2966
|
-
configurable: true,
|
|
2967
|
-
};
|
|
2912
|
+
const propName = attributeToPropMap[attrName];
|
|
2913
|
+
if (isUndefined$1(propName)) {
|
|
2914
|
+
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
2915
|
+
// delegate unknown attributes to the super.
|
|
2916
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2917
|
+
// @ts-ignore type-mismatch
|
|
2918
|
+
superAttributeChangedCallback.apply(this, arguments);
|
|
2919
|
+
}
|
|
2920
|
+
return;
|
|
2968
2921
|
}
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
};
|
|
2922
|
+
if (!isAttributeLocked(this, attrName)) {
|
|
2923
|
+
// Ignore changes triggered by the engine itself during:
|
|
2924
|
+
// * diffing when public props are attempting to reflect to the DOM
|
|
2925
|
+
// * component via `this.setAttribute()`, should never update the prop
|
|
2926
|
+
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
2927
|
+
// attribute to be changed
|
|
2928
|
+
return;
|
|
2977
2929
|
}
|
|
2978
|
-
//
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2930
|
+
// Reflect attribute change to the corresponding property when changed from outside.
|
|
2931
|
+
this[propName] = newValue;
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2934
|
+
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
2935
|
+
let HTMLBridgeElement;
|
|
2936
|
+
/**
|
|
2937
|
+
* Modern browsers will have all Native Constructors as regular Classes
|
|
2938
|
+
* and must be instantiated with the new keyword. In older browsers,
|
|
2939
|
+
* specifically IE11, those are objects with a prototype property defined,
|
|
2940
|
+
* since they are not supposed to be extended or instantiated with the
|
|
2941
|
+
* new keyword. This forking logic supports both cases, specifically because
|
|
2942
|
+
* wc.ts relies on the construction path of the bridges to create new
|
|
2943
|
+
* fully qualifying web components.
|
|
2944
|
+
*/
|
|
2945
|
+
if (isFunction$1(SuperClass)) {
|
|
2946
|
+
HTMLBridgeElement = class extends SuperClass {};
|
|
2947
|
+
} else {
|
|
2948
|
+
HTMLBridgeElement = function () {
|
|
2949
|
+
// Bridge classes are not supposed to be instantiated directly in
|
|
2950
|
+
// browsers that do not support web components.
|
|
2951
|
+
throw new TypeError('Illegal constructor');
|
|
2984
2952
|
};
|
|
2985
|
-
//
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2953
|
+
// prototype inheritance dance
|
|
2954
|
+
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
2955
|
+
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
2956
|
+
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
2957
|
+
writable: true,
|
|
2958
|
+
configurable: true,
|
|
2959
|
+
value: HTMLBridgeElement
|
|
2991
2960
|
});
|
|
2992
|
-
|
|
2993
|
-
|
|
2961
|
+
}
|
|
2962
|
+
// generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
2963
|
+
// and false positives in case of inheritance.
|
|
2964
|
+
const attributeToPropMap = create(null);
|
|
2965
|
+
const {
|
|
2966
|
+
attributeChangedCallback: superAttributeChangedCallback
|
|
2967
|
+
} = SuperClass.prototype;
|
|
2968
|
+
const {
|
|
2969
|
+
observedAttributes: superObservedAttributes = []
|
|
2970
|
+
} = SuperClass;
|
|
2971
|
+
const descriptors = create(null);
|
|
2972
|
+
// expose getters and setters for each public props on the new Element Bridge
|
|
2973
|
+
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
2974
|
+
const propName = props[i];
|
|
2975
|
+
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
2976
|
+
descriptors[propName] = {
|
|
2977
|
+
get: createGetter(propName),
|
|
2978
|
+
set: createSetter(propName),
|
|
2979
|
+
enumerable: true,
|
|
2980
|
+
configurable: true
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
// expose public methods as props on the new Element Bridge
|
|
2984
|
+
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
2985
|
+
const methodName = methods[i];
|
|
2986
|
+
descriptors[methodName] = {
|
|
2987
|
+
value: createMethodCaller(methodName),
|
|
2988
|
+
writable: true,
|
|
2989
|
+
configurable: true
|
|
2990
|
+
};
|
|
2991
|
+
}
|
|
2992
|
+
// creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
2993
|
+
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
2994
|
+
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
2995
|
+
// to preserve this definition.
|
|
2996
|
+
descriptors.attributeChangedCallback = {
|
|
2997
|
+
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
2998
|
+
};
|
|
2999
|
+
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
3000
|
+
// properties via attributeChangedCallback.
|
|
3001
|
+
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
3002
|
+
get() {
|
|
3003
|
+
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
3004
|
+
}
|
|
3005
|
+
});
|
|
3006
|
+
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3007
|
+
return HTMLBridgeElement;
|
|
2994
3008
|
}
|
|
2995
3009
|
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
3010
|
+
{
|
|
3011
|
+
// This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
|
|
3012
|
+
// so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
|
|
3013
|
+
// ARIA props outside the LightningElement
|
|
3014
|
+
if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
3015
|
+
// If ARIA reflection is not applied globally to Element.prototype, apply it to HTMLBridgeElement.prototype.
|
|
3016
|
+
// This allows `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*` attrs.
|
|
3017
|
+
// This is especially important because the template compiler compiles aria-* attrs on components to aria* props
|
|
3018
|
+
//
|
|
3019
|
+
// Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
|
|
3020
|
+
// accessors inside the HTMLBridgeElementFactory.
|
|
3021
|
+
applyAriaReflection(BaseBridgeElement.prototype);
|
|
3022
|
+
}
|
|
3023
|
+
}
|
|
2996
3024
|
freeze(BaseBridgeElement);
|
|
2997
3025
|
seal(BaseBridgeElement.prototype);
|
|
2998
3026
|
|
|
@@ -4370,11 +4398,13 @@ function applyDomManual(elm, vnode) {
|
|
|
4370
4398
|
function applyElementRestrictions(elm, vnode) {
|
|
4371
4399
|
var _a, _b;
|
|
4372
4400
|
if (process.env.NODE_ENV !== 'production') {
|
|
4401
|
+
const isSynthetic = vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4373
4402
|
const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
|
|
4374
4403
|
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
4375
4404
|
patchElementWithRestrictions(elm, {
|
|
4376
4405
|
isPortal,
|
|
4377
|
-
isLight
|
|
4406
|
+
isLight,
|
|
4407
|
+
isSynthetic
|
|
4378
4408
|
});
|
|
4379
4409
|
}
|
|
4380
4410
|
}
|
|
@@ -4790,7 +4820,7 @@ function s(slotName, data, children, slotset) {
|
|
|
4790
4820
|
// undefined is for root components, but root components cannot accept slotted content
|
|
4791
4821
|
setVMBeingRendered(slotset.owner);
|
|
4792
4822
|
try {
|
|
4793
|
-
ArrayPush$1.
|
|
4823
|
+
ArrayPush$1.call(newChildren, vnode.factory(data.slotData, data.key));
|
|
4794
4824
|
}
|
|
4795
4825
|
finally {
|
|
4796
4826
|
setVMBeingRendered(vmBeingRenderedInception);
|
|
@@ -5670,15 +5700,10 @@ function resetComponentStateWhenRemoved(vm) {
|
|
|
5670
5700
|
} = vm;
|
|
5671
5701
|
if (state !== 2 /* VMState.disconnected */) {
|
|
5672
5702
|
const {
|
|
5673
|
-
oar,
|
|
5674
5703
|
tro
|
|
5675
5704
|
} = vm;
|
|
5676
5705
|
// Making sure that any observing record will not trigger the rehydrated on this vm
|
|
5677
5706
|
tro.reset();
|
|
5678
|
-
// Making sure that any observing accessor record will not trigger the setter to be reinvoked
|
|
5679
|
-
for (const key in oar) {
|
|
5680
|
-
oar[key].reset();
|
|
5681
|
-
}
|
|
5682
5707
|
runDisconnectedCallback(vm);
|
|
5683
5708
|
// Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
|
|
5684
5709
|
runChildNodesDisconnectedCallback(vm);
|
|
@@ -5731,7 +5756,6 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5731
5756
|
cmpSlots: {
|
|
5732
5757
|
slotAssignments: create(null)
|
|
5733
5758
|
},
|
|
5734
|
-
oar: create(null),
|
|
5735
5759
|
cmpTemplate: null,
|
|
5736
5760
|
hydrated: Boolean(hydrated),
|
|
5737
5761
|
renderMode: def.renderMode,
|
|
@@ -6912,94 +6936,166 @@ function setHooks(hooks) {
|
|
|
6912
6936
|
// See @lwc/engine-core/src/framework/template.ts
|
|
6913
6937
|
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
|
|
6914
6938
|
// Via https://www.npmjs.com/package/object-observer
|
|
6915
|
-
const ARRAY_MUTATION_METHODS = [
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
|
|
6920
|
-
'reverse',
|
|
6921
|
-
'sort',
|
|
6922
|
-
'fill',
|
|
6923
|
-
'splice',
|
|
6924
|
-
'copyWithin',
|
|
6925
|
-
];
|
|
6939
|
+
const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
|
|
6940
|
+
// Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
|
|
6941
|
+
const STYLESHEET_FUNCTION_EXPANDOS = [
|
|
6942
|
+
// SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
|
|
6943
|
+
'$scoped$'];
|
|
6926
6944
|
function getOriginalArrayMethod(prop) {
|
|
6927
|
-
|
|
6928
|
-
|
|
6929
|
-
|
|
6930
|
-
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6945
|
+
switch (prop) {
|
|
6946
|
+
case 'pop':
|
|
6947
|
+
return ArrayPop;
|
|
6948
|
+
case 'push':
|
|
6949
|
+
return ArrayPush$1;
|
|
6950
|
+
case 'shift':
|
|
6951
|
+
return ArrayShift;
|
|
6952
|
+
case 'unshift':
|
|
6953
|
+
return ArrayUnshift;
|
|
6954
|
+
case 'reverse':
|
|
6955
|
+
return ArrayReverse;
|
|
6956
|
+
case 'sort':
|
|
6957
|
+
return ArraySort;
|
|
6958
|
+
case 'fill':
|
|
6959
|
+
return ArrayFill;
|
|
6960
|
+
case 'splice':
|
|
6961
|
+
return ArraySplice;
|
|
6962
|
+
case 'copyWithin':
|
|
6963
|
+
return ArrayCopyWithin;
|
|
6964
|
+
}
|
|
6947
6965
|
}
|
|
6948
6966
|
let mutationWarningsSilenced = false;
|
|
6949
|
-
// Warn if the user tries to mutate
|
|
6967
|
+
// Warn if the user tries to mutate a stylesheets array, e.g.:
|
|
6950
6968
|
// `tmpl.stylesheets.push(someStylesheetFunction)`
|
|
6951
6969
|
function warnOnArrayMutation(stylesheets) {
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
|
|
6961
|
-
|
|
6970
|
+
// We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
|
|
6971
|
+
// we can at least warn when they use the most common mutation methods.
|
|
6972
|
+
for (const prop of ARRAY_MUTATION_METHODS) {
|
|
6973
|
+
const originalArrayMethod = getOriginalArrayMethod(prop);
|
|
6974
|
+
stylesheets[prop] = function arrayMutationWarningWrapper() {
|
|
6975
|
+
logError(`Mutating the "stylesheets" array on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
|
|
6976
|
+
// @ts-ignore
|
|
6977
|
+
return originalArrayMethod.apply(this, arguments);
|
|
6978
|
+
};
|
|
6979
|
+
}
|
|
6980
|
+
}
|
|
6981
|
+
// Warn if the user tries to mutate a stylesheet factory function, e.g.:
|
|
6982
|
+
// `stylesheet.$scoped$ = true`
|
|
6983
|
+
function warnOnStylesheetFunctionMutation(stylesheet) {
|
|
6984
|
+
// We could warn on other properties, but in practice only certain expandos are meaningful to LWC at runtime
|
|
6985
|
+
for (const prop of STYLESHEET_FUNCTION_EXPANDOS) {
|
|
6986
|
+
let value = stylesheet[prop];
|
|
6987
|
+
defineProperty(stylesheet, prop, {
|
|
6988
|
+
enumerable: true,
|
|
6989
|
+
configurable: true,
|
|
6990
|
+
get() {
|
|
6991
|
+
return value;
|
|
6992
|
+
},
|
|
6993
|
+
set(newValue) {
|
|
6994
|
+
logError(`Dynamically setting the "${prop}" property on a stylesheet function ` + `is deprecated and may be removed in a future version of LWC.`);
|
|
6995
|
+
value = newValue;
|
|
6996
|
+
}
|
|
6997
|
+
});
|
|
6998
|
+
}
|
|
6999
|
+
}
|
|
7000
|
+
// Warn on either array or stylesheet (function) mutation, in a deeply-nested array
|
|
7001
|
+
function warnOnStylesheetsMutation(stylesheets) {
|
|
7002
|
+
traverseStylesheets(stylesheets, subStylesheets => {
|
|
7003
|
+
if (isArray$1(subStylesheets)) {
|
|
7004
|
+
warnOnArrayMutation(subStylesheets);
|
|
7005
|
+
} else {
|
|
7006
|
+
warnOnStylesheetFunctionMutation(subStylesheets);
|
|
7007
|
+
}
|
|
7008
|
+
});
|
|
7009
|
+
}
|
|
7010
|
+
// Deeply freeze the entire array (of arrays) of stylesheet factory functions
|
|
7011
|
+
function deepFreeze(stylesheets) {
|
|
7012
|
+
traverseStylesheets(stylesheets, subStylesheets => {
|
|
7013
|
+
freeze(subStylesheets);
|
|
7014
|
+
});
|
|
7015
|
+
}
|
|
7016
|
+
// Deep-traverse an array (of arrays) of stylesheet factory functions, and call the callback for every array/function
|
|
7017
|
+
function traverseStylesheets(stylesheets, callback) {
|
|
7018
|
+
callback(stylesheets);
|
|
7019
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
7020
|
+
const stylesheet = stylesheets[i];
|
|
7021
|
+
if (isArray$1(stylesheet)) {
|
|
7022
|
+
traverseStylesheets(stylesheet, callback);
|
|
7023
|
+
} else {
|
|
7024
|
+
callback(stylesheet);
|
|
6962
7025
|
}
|
|
7026
|
+
}
|
|
6963
7027
|
}
|
|
6964
|
-
// TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
|
|
6965
|
-
// just warns on mutation.
|
|
6966
7028
|
function freezeTemplate(tmpl) {
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
});
|
|
7029
|
+
if (lwcRuntimeFlags.ENABLE_FROZEN_TEMPLATE) {
|
|
7030
|
+
// Deep freeze the template
|
|
7031
|
+
freeze(tmpl);
|
|
7032
|
+
if (!isUndefined$1(tmpl.stylesheets)) {
|
|
7033
|
+
deepFreeze(tmpl.stylesheets);
|
|
7034
|
+
}
|
|
7035
|
+
} else {
|
|
7036
|
+
// TODO [#2782]: remove this flag and delete the legacy behavior
|
|
7037
|
+
// When ENABLE_FROZEN_TEMPLATE is false, then we shim stylesheetTokens on top of stylesheetToken for anyone who
|
|
7038
|
+
// is accessing the old internal API (backwards compat). Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
7039
|
+
defineProperty(tmpl, 'stylesheetTokens', {
|
|
7040
|
+
enumerable: true,
|
|
7041
|
+
configurable: true,
|
|
7042
|
+
get() {
|
|
7043
|
+
const {
|
|
7044
|
+
stylesheetToken
|
|
7045
|
+
} = this;
|
|
7046
|
+
if (isUndefined$1(stylesheetToken)) {
|
|
7047
|
+
return stylesheetToken;
|
|
6987
7048
|
}
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7049
|
+
// Shim for the old `stylesheetTokens` property
|
|
7050
|
+
// See https://github.com/salesforce/lwc/pull/2332/files#diff-7901555acef29969adaa6583185b3e9bce475cdc6f23e799a54e0018cb18abaa
|
|
7051
|
+
return {
|
|
7052
|
+
hostAttribute: `${stylesheetToken}-host`,
|
|
7053
|
+
shadowAttribute: stylesheetToken
|
|
7054
|
+
};
|
|
7055
|
+
},
|
|
7056
|
+
set(value) {
|
|
7057
|
+
// If the value is null or some other exotic object, you would be broken anyway in the past
|
|
7058
|
+
// because the engine would try to access hostAttribute/shadowAttribute, which would throw an error.
|
|
7059
|
+
// However it may be undefined in newer versions of LWC, so we need to guard against that case.
|
|
7060
|
+
this.stylesheetToken = isUndefined$1(value) ? undefined : value.shadowAttribute;
|
|
7061
|
+
}
|
|
7062
|
+
});
|
|
7063
|
+
// When ENABLE_FROZEN_TEMPLATE is false, warn in dev mode whenever someone is mutating the template
|
|
7064
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7065
|
+
if (!isUndefined$1(tmpl.stylesheets)) {
|
|
7066
|
+
warnOnStylesheetsMutation(tmpl.stylesheets);
|
|
7067
|
+
}
|
|
7068
|
+
for (const prop of TEMPLATE_PROPS) {
|
|
7069
|
+
let value = tmpl[prop];
|
|
7070
|
+
defineProperty(tmpl, prop, {
|
|
7071
|
+
enumerable: true,
|
|
7072
|
+
configurable: true,
|
|
7073
|
+
get() {
|
|
7074
|
+
return value;
|
|
7075
|
+
},
|
|
7076
|
+
set(newValue) {
|
|
7077
|
+
if (!mutationWarningsSilenced) {
|
|
7078
|
+
logError(`Dynamically setting the "${prop}" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
|
|
7079
|
+
}
|
|
7080
|
+
value = newValue;
|
|
7081
|
+
}
|
|
7001
7082
|
});
|
|
7083
|
+
}
|
|
7084
|
+
const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
|
|
7085
|
+
defineProperty(tmpl, 'stylesheetTokens', {
|
|
7086
|
+
enumerable: true,
|
|
7087
|
+
configurable: true,
|
|
7088
|
+
get: originalDescriptor.get,
|
|
7089
|
+
set(value) {
|
|
7090
|
+
logError(`Dynamically setting the "stylesheetTokens" property on a template function ` + `is deprecated and may be removed in a future version of LWC.`);
|
|
7091
|
+
// Avoid logging twice (for both stylesheetToken and stylesheetTokens)
|
|
7092
|
+
mutationWarningsSilenced = true;
|
|
7093
|
+
originalDescriptor.set.call(this, value);
|
|
7094
|
+
mutationWarningsSilenced = false;
|
|
7095
|
+
}
|
|
7096
|
+
});
|
|
7002
7097
|
}
|
|
7098
|
+
}
|
|
7003
7099
|
}
|
|
7004
7100
|
|
|
7005
7101
|
/*
|
|
@@ -7024,7 +7120,7 @@ function getComponentConstructor(elm) {
|
|
|
7024
7120
|
}
|
|
7025
7121
|
return ctor;
|
|
7026
7122
|
}
|
|
7027
|
-
/* version: 2.
|
|
7123
|
+
/* version: 2.33.0 */
|
|
7028
7124
|
|
|
7029
7125
|
/*
|
|
7030
7126
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7997,7 +8093,7 @@ function rendererFactory(baseRenderer) {
|
|
|
7997
8093
|
function isNull(obj) {
|
|
7998
8094
|
return obj === null;
|
|
7999
8095
|
}
|
|
8000
|
-
/** version: 2.
|
|
8096
|
+
/** version: 2.33.0 */
|
|
8001
8097
|
|
|
8002
8098
|
/*
|
|
8003
8099
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8558,6 +8654,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8558
8654
|
});
|
|
8559
8655
|
freeze(LightningElement);
|
|
8560
8656
|
seal(LightningElement.prototype);
|
|
8561
|
-
/* version: 2.
|
|
8657
|
+
/* version: 2.33.0 */
|
|
8562
8658
|
|
|
8563
8659
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|