lwc 2.32.1 → 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 +683 -560
- package/dist/engine-dom/iife/es2017/engine-dom.js +683 -560
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +593 -467
- package/dist/engine-dom/iife/es5/engine-dom.js +121 -95
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +119 -92
- package/dist/engine-dom/umd/es2017/engine-dom.js +683 -560
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +593 -467
- package/dist/engine-dom/umd/es5/engine-dom.js +121 -95
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +119 -92
- package/dist/engine-server/commonjs/es2017/engine-server.js +655 -474
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +655 -474
- 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.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +7 -5
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +7 -5
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +7 -5
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +7 -5
- 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.1 */
|
|
349
|
+
/** version: 2.33.0 */
|
|
429
350
|
|
|
430
351
|
/**
|
|
431
352
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -447,6 +368,7 @@ const features = {
|
|
|
447
368
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
448
369
|
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
449
370
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
371
|
+
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
450
372
|
};
|
|
451
373
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
452
374
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -500,7 +422,83 @@ function setFeatureFlagForTest(name, value) {
|
|
|
500
422
|
setFeatureFlag(name, value);
|
|
501
423
|
}
|
|
502
424
|
}
|
|
503
|
-
/** 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
|
+
}
|
|
504
502
|
|
|
505
503
|
/*
|
|
506
504
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1919,46 +1917,51 @@ function markLockerLiveObject(obj) {
|
|
|
1919
1917
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1920
1918
|
*/
|
|
1921
1919
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
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.`);
|
|
1929
|
+
}
|
|
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.`);
|
|
1928
1935
|
}
|
|
1929
|
-
|
|
1936
|
+
throw new TypeError();
|
|
1937
|
+
}
|
|
1938
|
+
return {
|
|
1939
|
+
enumerable,
|
|
1940
|
+
configurable,
|
|
1941
|
+
get() {
|
|
1942
|
+
const vm = getAssociatedVM(this);
|
|
1943
|
+
if (isBeingConstructed(vm)) {
|
|
1930
1944
|
if (process.env.NODE_ENV !== 'production') {
|
|
1931
|
-
|
|
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);
|
|
1932
1946
|
}
|
|
1933
|
-
|
|
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);
|
|
1934
1963
|
}
|
|
1935
|
-
|
|
1936
|
-
enumerable,
|
|
1937
|
-
configurable,
|
|
1938
|
-
get() {
|
|
1939
|
-
const vm = getAssociatedVM(this);
|
|
1940
|
-
if (isBeingConstructed(vm)) {
|
|
1941
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1942
|
-
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);
|
|
1943
|
-
}
|
|
1944
|
-
return;
|
|
1945
|
-
}
|
|
1946
|
-
componentValueObserved(vm, propName);
|
|
1947
|
-
return get.call(vm.elm);
|
|
1948
|
-
},
|
|
1949
|
-
set(newValue) {
|
|
1950
|
-
const vm = getAssociatedVM(this);
|
|
1951
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
1952
|
-
const vmBeingRendered = getVMBeingRendered();
|
|
1953
|
-
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1954
|
-
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}`);
|
|
1955
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1956
|
-
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1957
|
-
}
|
|
1958
|
-
updateComponentValue(vm, propName, newValue);
|
|
1959
|
-
return set.call(vm.elm, newValue);
|
|
1960
|
-
},
|
|
1961
|
-
};
|
|
1964
|
+
};
|
|
1962
1965
|
}
|
|
1963
1966
|
const EMPTY_REFS = freeze(create(null));
|
|
1964
1967
|
const refsCache = new WeakMap();
|
|
@@ -1968,345 +1971,442 @@ const refsCache = new WeakMap();
|
|
|
1968
1971
|
**/
|
|
1969
1972
|
// @ts-ignore
|
|
1970
1973
|
const LightningElement = function () {
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
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;
|
|
1980
2077
|
if (process.env.NODE_ENV !== 'production') {
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
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()');
|
|
2003
2200
|
}
|
|
2004
|
-
|
|
2005
|
-
|
|
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;
|
|
2006
2248
|
}
|
|
2007
|
-
// Adding extra guard rails in DEV mode.
|
|
2008
2249
|
if (process.env.NODE_ENV !== 'production') {
|
|
2009
|
-
|
|
2010
|
-
patchComponentWithRestrictions(component);
|
|
2250
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2011
2251
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
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
|
|
2020
2299
|
});
|
|
2021
|
-
|
|
2022
|
-
|
|
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;
|
|
2023
2309
|
if (process.env.NODE_ENV !== 'production') {
|
|
2024
|
-
|
|
2310
|
+
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2025
2311
|
}
|
|
2026
|
-
return
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
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');
|
|
2031
2319
|
}
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
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
|
-
lockAttribute();
|
|
2075
|
-
},
|
|
2076
|
-
removeAttributeNS(namespace, name) {
|
|
2077
|
-
const { elm, renderer: { removeAttribute }, } = getAssociatedVM(this);
|
|
2078
|
-
unlockAttribute(elm, name);
|
|
2079
|
-
removeAttribute(elm, name, namespace);
|
|
2080
|
-
lockAttribute();
|
|
2081
|
-
},
|
|
2082
|
-
getAttribute(name) {
|
|
2083
|
-
const vm = getAssociatedVM(this);
|
|
2084
|
-
const { elm } = vm;
|
|
2085
|
-
const { getAttribute } = vm.renderer;
|
|
2086
|
-
return getAttribute(elm, name);
|
|
2087
|
-
},
|
|
2088
|
-
getAttributeNS(namespace, name) {
|
|
2089
|
-
const vm = getAssociatedVM(this);
|
|
2090
|
-
const { elm } = vm;
|
|
2091
|
-
const { getAttribute } = vm.renderer;
|
|
2092
|
-
return getAttribute(elm, name, namespace);
|
|
2093
|
-
},
|
|
2094
|
-
setAttribute(name, value) {
|
|
2095
|
-
const vm = getAssociatedVM(this);
|
|
2096
|
-
const { elm, renderer: { setAttribute }, } = vm;
|
|
2097
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2098
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2099
|
-
}
|
|
2100
|
-
unlockAttribute(elm, name);
|
|
2101
|
-
setAttribute(elm, name, value);
|
|
2102
|
-
lockAttribute();
|
|
2103
|
-
},
|
|
2104
|
-
setAttributeNS(namespace, name, value) {
|
|
2105
|
-
const vm = getAssociatedVM(this);
|
|
2106
|
-
const { elm, renderer: { setAttribute }, } = vm;
|
|
2107
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2108
|
-
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2109
|
-
}
|
|
2110
|
-
unlockAttribute(elm, name);
|
|
2111
|
-
setAttribute(elm, name, value, namespace);
|
|
2112
|
-
lockAttribute();
|
|
2113
|
-
},
|
|
2114
|
-
getBoundingClientRect() {
|
|
2115
|
-
const vm = getAssociatedVM(this);
|
|
2116
|
-
const { elm, renderer: { getBoundingClientRect }, } = vm;
|
|
2117
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2118
|
-
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2119
|
-
}
|
|
2120
|
-
return getBoundingClientRect(elm);
|
|
2121
|
-
},
|
|
2122
|
-
get isConnected() {
|
|
2123
|
-
const vm = getAssociatedVM(this);
|
|
2124
|
-
const { elm, renderer: { isConnected }, } = vm;
|
|
2125
|
-
return isConnected(elm);
|
|
2126
|
-
},
|
|
2127
|
-
get classList() {
|
|
2128
|
-
const vm = getAssociatedVM(this);
|
|
2129
|
-
const { elm, renderer: { getClassList }, } = vm;
|
|
2130
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2131
|
-
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2132
|
-
// just throw in all modes
|
|
2133
|
-
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.`);
|
|
2134
|
-
}
|
|
2135
|
-
return getClassList(elm);
|
|
2136
|
-
},
|
|
2137
|
-
get template() {
|
|
2138
|
-
const vm = getAssociatedVM(this);
|
|
2139
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2140
|
-
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2141
|
-
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`.');
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
return vm.shadowRoot;
|
|
2145
|
-
},
|
|
2146
|
-
get refs() {
|
|
2147
|
-
const vm = getAssociatedVM(this);
|
|
2148
|
-
if (isUpdatingTemplate) {
|
|
2149
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2150
|
-
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().`);
|
|
2151
|
-
}
|
|
2152
|
-
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2153
|
-
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2154
|
-
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2155
|
-
// based on `this.refs.bar`.
|
|
2156
|
-
return;
|
|
2157
|
-
}
|
|
2158
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2159
|
-
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2160
|
-
}
|
|
2161
|
-
const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
|
|
2162
|
-
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2163
|
-
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2164
|
-
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2165
|
-
// `warnIfInvokedDuringConstruction` above).
|
|
2166
|
-
if (process.env.NODE_ENV !== 'production' &&
|
|
2167
|
-
isNull(cmpTemplate) &&
|
|
2168
|
-
!isBeingConstructed(vm)) {
|
|
2169
|
-
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
|
|
2170
|
-
`invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
|
|
2171
|
-
`been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2172
|
-
}
|
|
2173
|
-
// For backwards compatibility with component written before template refs
|
|
2174
|
-
// were introduced, we return undefined if the template has no refs defined
|
|
2175
|
-
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2176
|
-
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2177
|
-
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2178
|
-
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2179
|
-
if (!hasRefVNodes) {
|
|
2180
|
-
return;
|
|
2181
|
-
}
|
|
2182
|
-
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2183
|
-
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2184
|
-
if (isNull(refVNodes)) {
|
|
2185
|
-
return EMPTY_REFS;
|
|
2186
|
-
}
|
|
2187
|
-
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2188
|
-
// are recreated from scratch every time the template is rendered.
|
|
2189
|
-
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2190
|
-
let refs = refsCache.get(refVNodes);
|
|
2191
|
-
if (isUndefined$1(refs)) {
|
|
2192
|
-
refs = create(null);
|
|
2193
|
-
for (const key of keys(refVNodes)) {
|
|
2194
|
-
refs[key] = refVNodes[key].elm;
|
|
2195
|
-
}
|
|
2196
|
-
freeze(refs);
|
|
2197
|
-
refsCache.set(refVNodes, refs);
|
|
2198
|
-
}
|
|
2199
|
-
return refs;
|
|
2200
|
-
},
|
|
2201
|
-
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2202
|
-
set refs(value) {
|
|
2203
|
-
defineProperty(this, 'refs', {
|
|
2204
|
-
configurable: true,
|
|
2205
|
-
enumerable: true,
|
|
2206
|
-
writable: true,
|
|
2207
|
-
value,
|
|
2208
|
-
});
|
|
2209
|
-
},
|
|
2210
|
-
get shadowRoot() {
|
|
2211
|
-
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2212
|
-
// Authors should rely on this.template instead.
|
|
2213
|
-
return null;
|
|
2214
|
-
},
|
|
2215
|
-
get children() {
|
|
2216
|
-
const vm = getAssociatedVM(this);
|
|
2217
|
-
const renderer = vm.renderer;
|
|
2218
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2219
|
-
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2220
|
-
}
|
|
2221
|
-
return renderer.getChildren(vm.elm);
|
|
2222
|
-
},
|
|
2223
|
-
get childNodes() {
|
|
2224
|
-
const vm = getAssociatedVM(this);
|
|
2225
|
-
const renderer = vm.renderer;
|
|
2226
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2227
|
-
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
2228
|
-
}
|
|
2229
|
-
return renderer.getChildNodes(vm.elm);
|
|
2230
|
-
},
|
|
2231
|
-
get firstChild() {
|
|
2232
|
-
const vm = getAssociatedVM(this);
|
|
2233
|
-
const renderer = vm.renderer;
|
|
2234
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2235
|
-
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2236
|
-
}
|
|
2237
|
-
return renderer.getFirstChild(vm.elm);
|
|
2238
|
-
},
|
|
2239
|
-
get firstElementChild() {
|
|
2240
|
-
const vm = getAssociatedVM(this);
|
|
2241
|
-
const renderer = vm.renderer;
|
|
2242
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2243
|
-
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2244
|
-
}
|
|
2245
|
-
return renderer.getFirstElementChild(vm.elm);
|
|
2246
|
-
},
|
|
2247
|
-
get lastChild() {
|
|
2248
|
-
const vm = getAssociatedVM(this);
|
|
2249
|
-
const renderer = vm.renderer;
|
|
2250
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2251
|
-
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2252
|
-
}
|
|
2253
|
-
return renderer.getLastChild(vm.elm);
|
|
2254
|
-
},
|
|
2255
|
-
get lastElementChild() {
|
|
2256
|
-
const vm = getAssociatedVM(this);
|
|
2257
|
-
const renderer = vm.renderer;
|
|
2258
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
2259
|
-
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2260
|
-
}
|
|
2261
|
-
return renderer.getLastElementChild(vm.elm);
|
|
2262
|
-
},
|
|
2263
|
-
render() {
|
|
2264
|
-
const vm = getAssociatedVM(this);
|
|
2265
|
-
return vm.def.template;
|
|
2266
|
-
},
|
|
2267
|
-
toString() {
|
|
2268
|
-
const vm = getAssociatedVM(this);
|
|
2269
|
-
return `[object ${vm.def.name}]`;
|
|
2270
|
-
},
|
|
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
|
+
}
|
|
2271
2362
|
};
|
|
2272
2363
|
const queryAndChildGetterDescriptors = create(null);
|
|
2273
|
-
const queryMethods = [
|
|
2274
|
-
'getElementsByClassName',
|
|
2275
|
-
'getElementsByTagName',
|
|
2276
|
-
'querySelector',
|
|
2277
|
-
'querySelectorAll',
|
|
2278
|
-
];
|
|
2364
|
+
const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
|
|
2279
2365
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2280
2366
|
for (const queryMethod of queryMethods) {
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
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
|
+
};
|
|
2294
2383
|
}
|
|
2295
2384
|
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
2296
2385
|
const lightningBasedDescriptors = create(null);
|
|
2297
2386
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
2298
|
-
|
|
2387
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
2299
2388
|
}
|
|
2300
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
|
+
}
|
|
2301
2401
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
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
|
|
2307
2407
|
});
|
|
2308
2408
|
if (process.env.NODE_ENV !== 'production') {
|
|
2309
|
-
|
|
2409
|
+
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
|
|
2310
2410
|
}
|
|
2311
2411
|
|
|
2312
2412
|
function createObservedFieldPropertyDescriptor(key) {
|
|
@@ -2766,138 +2866,161 @@ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
|
2766
2866
|
const cachedGetterByKey = create(null);
|
|
2767
2867
|
const cachedSetterByKey = create(null);
|
|
2768
2868
|
function createGetter(key) {
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
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;
|
|
2778
2880
|
}
|
|
2779
2881
|
function createSetter(key) {
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
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;
|
|
2790
2894
|
}
|
|
2791
2895
|
function createMethodCaller(methodName) {
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
};
|
|
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
|
+
};
|
|
2798
2905
|
}
|
|
2799
2906
|
function createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback) {
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
}
|
|
2805
|
-
const propName = attributeToPropMap[attrName];
|
|
2806
|
-
if (isUndefined$1(propName)) {
|
|
2807
|
-
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
2808
|
-
// delegate unknown attributes to the super.
|
|
2809
|
-
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2810
|
-
// @ts-ignore type-mismatch
|
|
2811
|
-
superAttributeChangedCallback.apply(this, arguments);
|
|
2812
|
-
}
|
|
2813
|
-
return;
|
|
2814
|
-
}
|
|
2815
|
-
if (!isAttributeLocked(this, attrName)) {
|
|
2816
|
-
// Ignore changes triggered by the engine itself during:
|
|
2817
|
-
// * diffing when public props are attempting to reflect to the DOM
|
|
2818
|
-
// * component via `this.setAttribute()`, should never update the prop
|
|
2819
|
-
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
2820
|
-
// attribute to be changed
|
|
2821
|
-
return;
|
|
2822
|
-
}
|
|
2823
|
-
// Reflect attribute change to the corresponding property when changed from outside.
|
|
2824
|
-
this[propName] = newValue;
|
|
2825
|
-
};
|
|
2826
|
-
}
|
|
2827
|
-
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
2828
|
-
let HTMLBridgeElement;
|
|
2829
|
-
/**
|
|
2830
|
-
* Modern browsers will have all Native Constructors as regular Classes
|
|
2831
|
-
* and must be instantiated with the new keyword. In older browsers,
|
|
2832
|
-
* specifically IE11, those are objects with a prototype property defined,
|
|
2833
|
-
* since they are not supposed to be extended or instantiated with the
|
|
2834
|
-
* new keyword. This forking logic supports both cases, specifically because
|
|
2835
|
-
* wc.ts relies on the construction path of the bridges to create new
|
|
2836
|
-
* fully qualifying web components.
|
|
2837
|
-
*/
|
|
2838
|
-
if (isFunction$1(SuperClass)) {
|
|
2839
|
-
HTMLBridgeElement = class extends SuperClass {
|
|
2840
|
-
};
|
|
2841
|
-
}
|
|
2842
|
-
else {
|
|
2843
|
-
HTMLBridgeElement = function () {
|
|
2844
|
-
// Bridge classes are not supposed to be instantiated directly in
|
|
2845
|
-
// browsers that do not support web components.
|
|
2846
|
-
throw new TypeError('Illegal constructor');
|
|
2847
|
-
};
|
|
2848
|
-
// prototype inheritance dance
|
|
2849
|
-
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
2850
|
-
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
2851
|
-
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
2852
|
-
writable: true,
|
|
2853
|
-
configurable: true,
|
|
2854
|
-
value: HTMLBridgeElement,
|
|
2855
|
-
});
|
|
2907
|
+
return function attributeChangedCallback(attrName, oldValue, newValue) {
|
|
2908
|
+
if (oldValue === newValue) {
|
|
2909
|
+
// Ignore same values.
|
|
2910
|
+
return;
|
|
2856
2911
|
}
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
2867
|
-
descriptors[propName] = {
|
|
2868
|
-
get: createGetter(propName),
|
|
2869
|
-
set: createSetter(propName),
|
|
2870
|
-
enumerable: true,
|
|
2871
|
-
configurable: true,
|
|
2872
|
-
};
|
|
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;
|
|
2873
2921
|
}
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
};
|
|
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;
|
|
2882
2929
|
}
|
|
2883
|
-
//
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
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');
|
|
2889
2952
|
};
|
|
2890
|
-
//
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
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
|
|
2896
2960
|
});
|
|
2897
|
-
|
|
2898
|
-
|
|
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;
|
|
2899
3008
|
}
|
|
2900
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
|
+
}
|
|
2901
3024
|
freeze(BaseBridgeElement);
|
|
2902
3025
|
seal(BaseBridgeElement.prototype);
|
|
2903
3026
|
|
|
@@ -6997,7 +7120,7 @@ function getComponentConstructor(elm) {
|
|
|
6997
7120
|
}
|
|
6998
7121
|
return ctor;
|
|
6999
7122
|
}
|
|
7000
|
-
/* version: 2.
|
|
7123
|
+
/* version: 2.33.0 */
|
|
7001
7124
|
|
|
7002
7125
|
/*
|
|
7003
7126
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7970,7 +8093,7 @@ function rendererFactory(baseRenderer) {
|
|
|
7970
8093
|
function isNull(obj) {
|
|
7971
8094
|
return obj === null;
|
|
7972
8095
|
}
|
|
7973
|
-
/** version: 2.
|
|
8096
|
+
/** version: 2.33.0 */
|
|
7974
8097
|
|
|
7975
8098
|
/*
|
|
7976
8099
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8531,6 +8654,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8531
8654
|
});
|
|
8532
8655
|
freeze(LightningElement);
|
|
8533
8656
|
seal(LightningElement.prototype);
|
|
8534
|
-
/* version: 2.
|
|
8657
|
+
/* version: 2.33.0 */
|
|
8535
8658
|
|
|
8536
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 };
|