lwc 2.32.1 → 2.34.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 +842 -595
- package/dist/engine-dom/iife/es2017/engine-dom.js +842 -595
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +758 -501
- package/dist/engine-dom/iife/es5/engine-dom.js +316 -177
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +329 -173
- package/dist/engine-dom/umd/es2017/engine-dom.js +842 -595
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +758 -501
- package/dist/engine-dom/umd/es5/engine-dom.js +316 -177
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +329 -173
- package/dist/engine-server/commonjs/es2017/engine-server.js +807 -507
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +807 -507
- 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.34.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.34.0 */
|
|
429
350
|
|
|
430
351
|
/**
|
|
431
352
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -447,6 +368,8 @@ 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,
|
|
372
|
+
ENABLE_PROGRAMMATIC_STYLESHEETS: null,
|
|
450
373
|
};
|
|
451
374
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
452
375
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -500,7 +423,83 @@ function setFeatureFlagForTest(name, value) {
|
|
|
500
423
|
setFeatureFlag(name, value);
|
|
501
424
|
}
|
|
502
425
|
}
|
|
503
|
-
/** version: 2.
|
|
426
|
+
/** version: 2.34.0 */
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Copyright (C) 2018 salesforce.com, inc.
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
/*
|
|
433
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
434
|
+
* All rights reserved.
|
|
435
|
+
* SPDX-License-Identifier: MIT
|
|
436
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
437
|
+
*/
|
|
438
|
+
function detect(propName, prototype) {
|
|
439
|
+
return isUndefined$1(getOwnPropertyDescriptor$1(prototype, propName));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/*
|
|
443
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
444
|
+
* All rights reserved.
|
|
445
|
+
* SPDX-License-Identifier: MIT
|
|
446
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
447
|
+
*/
|
|
448
|
+
function createAriaPropertyPropertyDescriptor(attrName) {
|
|
449
|
+
// Note that we need to call this.{get,set,has,remove}Attribute rather than dereferencing
|
|
450
|
+
// from Element.prototype, because these methods are overridden in LightningElement.
|
|
451
|
+
return {
|
|
452
|
+
get() {
|
|
453
|
+
// reflect what's in the attribute
|
|
454
|
+
return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
|
|
455
|
+
},
|
|
456
|
+
set(newValue) {
|
|
457
|
+
// reflect into the corresponding attribute
|
|
458
|
+
if (isNull(newValue)) {
|
|
459
|
+
this.removeAttribute(attrName);
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
this.setAttribute(attrName, newValue);
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
configurable: true,
|
|
466
|
+
enumerable: true,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
function patch$1(propName, prototype) {
|
|
470
|
+
const attrName = AriaPropNameToAttrNameMap[propName];
|
|
471
|
+
const descriptor = createAriaPropertyPropertyDescriptor(attrName);
|
|
472
|
+
defineProperty(prototype, propName, descriptor);
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/*
|
|
476
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
477
|
+
* All rights reserved.
|
|
478
|
+
* SPDX-License-Identifier: MIT
|
|
479
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
480
|
+
*/
|
|
481
|
+
function applyAriaReflection(prototype = Element.prototype) {
|
|
482
|
+
const ElementPrototypeAriaPropertyNames = keys(AriaPropNameToAttrNameMap);
|
|
483
|
+
for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
|
|
484
|
+
const propName = ElementPrototypeAriaPropertyNames[i];
|
|
485
|
+
if (detect(propName, prototype)) {
|
|
486
|
+
patch$1(propName, prototype);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
/** version: 2.34.0 */
|
|
491
|
+
|
|
492
|
+
/*
|
|
493
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
494
|
+
* All rights reserved.
|
|
495
|
+
* SPDX-License-Identifier: MIT
|
|
496
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
497
|
+
*/
|
|
498
|
+
if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
499
|
+
// If DISABLE_ARIA_REFLECTION_POLYFILL is false, then we need to apply the ARIA reflection polyfill globally,
|
|
500
|
+
// i.e. to the global Element.prototype
|
|
501
|
+
applyAriaReflection();
|
|
502
|
+
}
|
|
504
503
|
|
|
505
504
|
/*
|
|
506
505
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -817,6 +816,7 @@ function log(method, message, vm) {
|
|
|
817
816
|
if (!isUndefined$1(vm)) {
|
|
818
817
|
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
819
818
|
}
|
|
819
|
+
// In Jest tests, reduce the warning and error verbosity by not printing the callstack
|
|
820
820
|
if (process.env.NODE_ENV === 'test') {
|
|
821
821
|
/* eslint-disable-next-line no-console */
|
|
822
822
|
console[method](msg);
|
|
@@ -886,6 +886,9 @@ function offsetPropertyErrorMessage(name) {
|
|
|
886
886
|
// Global HTML Attributes & Properties
|
|
887
887
|
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
|
888
888
|
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
|
|
889
|
+
//
|
|
890
|
+
// If you update this list, check for test files that recapitulate the same list. Searching the codebase
|
|
891
|
+
// for e.g. "dropzone" should suffice.
|
|
889
892
|
const globalHTMLProperties = assign(create(null), {
|
|
890
893
|
accessKey: {
|
|
891
894
|
attribute: 'accesskey',
|
|
@@ -1919,46 +1922,51 @@ function markLockerLiveObject(obj) {
|
|
|
1919
1922
|
* for the Base Lightning Element, it also include the reactivity bit, so the standard property is reactive.
|
|
1920
1923
|
*/
|
|
1921
1924
|
function createBridgeToElementDescriptor(propName, descriptor) {
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1925
|
+
const {
|
|
1926
|
+
get,
|
|
1927
|
+
set,
|
|
1928
|
+
enumerable,
|
|
1929
|
+
configurable
|
|
1930
|
+
} = descriptor;
|
|
1931
|
+
if (!isFunction$1(get)) {
|
|
1932
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1933
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard getter.`);
|
|
1928
1934
|
}
|
|
1929
|
-
|
|
1935
|
+
throw new TypeError();
|
|
1936
|
+
}
|
|
1937
|
+
if (!isFunction$1(set)) {
|
|
1938
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1939
|
+
assert.fail(`Detected invalid public property descriptor for HTMLElement.prototype.${propName} definition. Missing the standard setter.`);
|
|
1940
|
+
}
|
|
1941
|
+
throw new TypeError();
|
|
1942
|
+
}
|
|
1943
|
+
return {
|
|
1944
|
+
enumerable,
|
|
1945
|
+
configurable,
|
|
1946
|
+
get() {
|
|
1947
|
+
const vm = getAssociatedVM(this);
|
|
1948
|
+
if (isBeingConstructed(vm)) {
|
|
1930
1949
|
if (process.env.NODE_ENV !== 'production') {
|
|
1931
|
-
|
|
1950
|
+
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
1951
|
}
|
|
1933
|
-
|
|
1952
|
+
return;
|
|
1953
|
+
}
|
|
1954
|
+
componentValueObserved(vm, propName);
|
|
1955
|
+
return get.call(vm.elm);
|
|
1956
|
+
},
|
|
1957
|
+
set(newValue) {
|
|
1958
|
+
const vm = getAssociatedVM(this);
|
|
1959
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1960
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
1961
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${propName}`);
|
|
1962
|
+
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}`);
|
|
1963
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
1964
|
+
assert.invariant(!isObject(newValue) || isNull(newValue), `Invalid value "${newValue}" for "${propName}" of ${vm}. Value cannot be an object, must be a primitive value.`);
|
|
1965
|
+
}
|
|
1966
|
+
updateComponentValue(vm, propName, newValue);
|
|
1967
|
+
return set.call(vm.elm, newValue);
|
|
1934
1968
|
}
|
|
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
|
-
};
|
|
1969
|
+
};
|
|
1962
1970
|
}
|
|
1963
1971
|
const EMPTY_REFS = freeze(create(null));
|
|
1964
1972
|
const refsCache = new WeakMap();
|
|
@@ -1968,345 +1976,442 @@ const refsCache = new WeakMap();
|
|
|
1968
1976
|
**/
|
|
1969
1977
|
// @ts-ignore
|
|
1970
1978
|
const LightningElement = function () {
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1979
|
+
// This should be as performant as possible, while any initialization should be done lazily
|
|
1980
|
+
if (isNull(vmBeingConstructed)) {
|
|
1981
|
+
// Thrown when doing something like `new LightningElement()` or
|
|
1982
|
+
// `class Foo extends LightningElement {}; new Foo()`
|
|
1983
|
+
throw new TypeError('Illegal constructor');
|
|
1984
|
+
}
|
|
1985
|
+
const vm = vmBeingConstructed;
|
|
1986
|
+
const {
|
|
1987
|
+
def,
|
|
1988
|
+
elm
|
|
1989
|
+
} = vm;
|
|
1990
|
+
const {
|
|
1991
|
+
bridge
|
|
1992
|
+
} = def;
|
|
1993
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
1994
|
+
const {
|
|
1995
|
+
assertInstanceOfHTMLElement
|
|
1996
|
+
} = vm.renderer;
|
|
1997
|
+
assertInstanceOfHTMLElement(vm.elm, `Component creation requires a DOM element to be associated to ${vm}.`);
|
|
1998
|
+
}
|
|
1999
|
+
const component = this;
|
|
2000
|
+
setPrototypeOf(elm, bridge.prototype);
|
|
2001
|
+
vm.component = this;
|
|
2002
|
+
// Locker hooks assignment. When the LWC engine run with Locker, Locker intercepts all the new
|
|
2003
|
+
// component creation and passes hooks to instrument all the component interactions with the
|
|
2004
|
+
// engine. We are intentionally hiding this argument from the formal API of LightningElement
|
|
2005
|
+
// because we don't want folks to know about it just yet.
|
|
2006
|
+
if (arguments.length === 1) {
|
|
2007
|
+
const {
|
|
2008
|
+
callHook,
|
|
2009
|
+
setHook,
|
|
2010
|
+
getHook
|
|
2011
|
+
} = arguments[0];
|
|
2012
|
+
vm.callHook = callHook;
|
|
2013
|
+
vm.setHook = setHook;
|
|
2014
|
+
vm.getHook = getHook;
|
|
2015
|
+
}
|
|
2016
|
+
markLockerLiveObject(this);
|
|
2017
|
+
// Linking elm, shadow root and component with the VM.
|
|
2018
|
+
associateVM(component, vm);
|
|
2019
|
+
associateVM(elm, vm);
|
|
2020
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
2021
|
+
vm.renderRoot = doAttachShadow(vm);
|
|
2022
|
+
} else {
|
|
2023
|
+
vm.renderRoot = elm;
|
|
2024
|
+
}
|
|
2025
|
+
// Adding extra guard rails in DEV mode.
|
|
2026
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2027
|
+
patchCustomElementWithRestrictions(elm);
|
|
2028
|
+
patchComponentWithRestrictions(component);
|
|
2029
|
+
}
|
|
2030
|
+
return this;
|
|
2031
|
+
};
|
|
2032
|
+
function doAttachShadow(vm) {
|
|
2033
|
+
const {
|
|
2034
|
+
elm,
|
|
2035
|
+
mode,
|
|
2036
|
+
shadowMode,
|
|
2037
|
+
def: {
|
|
2038
|
+
ctor
|
|
2039
|
+
},
|
|
2040
|
+
renderer: {
|
|
2041
|
+
attachShadow
|
|
2042
|
+
}
|
|
2043
|
+
} = vm;
|
|
2044
|
+
const shadowRoot = attachShadow(elm, {
|
|
2045
|
+
[KEY__SYNTHETIC_MODE]: shadowMode === 1 /* ShadowMode.Synthetic */,
|
|
2046
|
+
delegatesFocus: Boolean(ctor.delegatesFocus),
|
|
2047
|
+
mode
|
|
2048
|
+
});
|
|
2049
|
+
vm.shadowRoot = shadowRoot;
|
|
2050
|
+
associateVM(shadowRoot, vm);
|
|
2051
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2052
|
+
patchShadowRootWithRestrictions(shadowRoot);
|
|
2053
|
+
}
|
|
2054
|
+
return shadowRoot;
|
|
2055
|
+
}
|
|
2056
|
+
function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
|
|
2057
|
+
if (isBeingConstructed(vm)) {
|
|
2058
|
+
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.`);
|
|
2059
|
+
}
|
|
2060
|
+
}
|
|
2061
|
+
// @ts-ignore
|
|
2062
|
+
LightningElement.prototype = {
|
|
2063
|
+
constructor: LightningElement,
|
|
2064
|
+
dispatchEvent(event) {
|
|
2065
|
+
const vm = getAssociatedVM(this);
|
|
2066
|
+
const {
|
|
2067
|
+
elm,
|
|
2068
|
+
renderer: {
|
|
2069
|
+
dispatchEvent
|
|
2070
|
+
}
|
|
2071
|
+
} = vm;
|
|
2072
|
+
return dispatchEvent(elm, event);
|
|
2073
|
+
},
|
|
2074
|
+
addEventListener(type, listener, options) {
|
|
2075
|
+
const vm = getAssociatedVM(this);
|
|
2076
|
+
const {
|
|
2077
|
+
elm,
|
|
2078
|
+
renderer: {
|
|
2079
|
+
addEventListener
|
|
2080
|
+
}
|
|
2081
|
+
} = vm;
|
|
1980
2082
|
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
|
-
|
|
2083
|
+
const vmBeingRendered = getVMBeingRendered();
|
|
2084
|
+
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2085
|
+
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm} by adding an event listener for "${type}".`);
|
|
2086
|
+
assert.invariant(isFunction$1(listener), `Invalid second argument for this.addEventListener() in ${vm} for event "${type}". Expected an EventListener but received ${listener}.`);
|
|
2087
|
+
}
|
|
2088
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2089
|
+
addEventListener(elm, type, wrappedListener, options);
|
|
2090
|
+
},
|
|
2091
|
+
removeEventListener(type, listener, options) {
|
|
2092
|
+
const vm = getAssociatedVM(this);
|
|
2093
|
+
const {
|
|
2094
|
+
elm,
|
|
2095
|
+
renderer: {
|
|
2096
|
+
removeEventListener
|
|
2097
|
+
}
|
|
2098
|
+
} = vm;
|
|
2099
|
+
const wrappedListener = getWrappedComponentsListener(vm, listener);
|
|
2100
|
+
removeEventListener(elm, type, wrappedListener, options);
|
|
2101
|
+
},
|
|
2102
|
+
hasAttribute(name) {
|
|
2103
|
+
const vm = getAssociatedVM(this);
|
|
2104
|
+
const {
|
|
2105
|
+
elm,
|
|
2106
|
+
renderer: {
|
|
2107
|
+
getAttribute
|
|
2108
|
+
}
|
|
2109
|
+
} = vm;
|
|
2110
|
+
return !isNull(getAttribute(elm, name));
|
|
2111
|
+
},
|
|
2112
|
+
hasAttributeNS(namespace, name) {
|
|
2113
|
+
const vm = getAssociatedVM(this);
|
|
2114
|
+
const {
|
|
2115
|
+
elm,
|
|
2116
|
+
renderer: {
|
|
2117
|
+
getAttribute
|
|
2118
|
+
}
|
|
2119
|
+
} = vm;
|
|
2120
|
+
return !isNull(getAttribute(elm, name, namespace));
|
|
2121
|
+
},
|
|
2122
|
+
removeAttribute(name) {
|
|
2123
|
+
const vm = getAssociatedVM(this);
|
|
2124
|
+
const {
|
|
2125
|
+
elm,
|
|
2126
|
+
renderer: {
|
|
2127
|
+
removeAttribute
|
|
2128
|
+
}
|
|
2129
|
+
} = vm;
|
|
2130
|
+
unlockAttribute(elm, name);
|
|
2131
|
+
removeAttribute(elm, name);
|
|
2132
|
+
lockAttribute();
|
|
2133
|
+
},
|
|
2134
|
+
removeAttributeNS(namespace, name) {
|
|
2135
|
+
const {
|
|
2136
|
+
elm,
|
|
2137
|
+
renderer: {
|
|
2138
|
+
removeAttribute
|
|
2139
|
+
}
|
|
2140
|
+
} = getAssociatedVM(this);
|
|
2141
|
+
unlockAttribute(elm, name);
|
|
2142
|
+
removeAttribute(elm, name, namespace);
|
|
2143
|
+
lockAttribute();
|
|
2144
|
+
},
|
|
2145
|
+
getAttribute(name) {
|
|
2146
|
+
const vm = getAssociatedVM(this);
|
|
2147
|
+
const {
|
|
2148
|
+
elm
|
|
2149
|
+
} = vm;
|
|
2150
|
+
const {
|
|
2151
|
+
getAttribute
|
|
2152
|
+
} = vm.renderer;
|
|
2153
|
+
return getAttribute(elm, name);
|
|
2154
|
+
},
|
|
2155
|
+
getAttributeNS(namespace, name) {
|
|
2156
|
+
const vm = getAssociatedVM(this);
|
|
2157
|
+
const {
|
|
2158
|
+
elm
|
|
2159
|
+
} = vm;
|
|
2160
|
+
const {
|
|
2161
|
+
getAttribute
|
|
2162
|
+
} = vm.renderer;
|
|
2163
|
+
return getAttribute(elm, name, namespace);
|
|
2164
|
+
},
|
|
2165
|
+
setAttribute(name, value) {
|
|
2166
|
+
const vm = getAssociatedVM(this);
|
|
2167
|
+
const {
|
|
2168
|
+
elm,
|
|
2169
|
+
renderer: {
|
|
2170
|
+
setAttribute
|
|
2171
|
+
}
|
|
2172
|
+
} = vm;
|
|
2173
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2174
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2175
|
+
}
|
|
2176
|
+
unlockAttribute(elm, name);
|
|
2177
|
+
setAttribute(elm, name, value);
|
|
2178
|
+
lockAttribute();
|
|
2179
|
+
},
|
|
2180
|
+
setAttributeNS(namespace, name, value) {
|
|
2181
|
+
const vm = getAssociatedVM(this);
|
|
2182
|
+
const {
|
|
2183
|
+
elm,
|
|
2184
|
+
renderer: {
|
|
2185
|
+
setAttribute
|
|
2186
|
+
}
|
|
2187
|
+
} = vm;
|
|
2188
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2189
|
+
assert.isFalse(isBeingConstructed(vm), `Failed to construct '${getComponentTag(vm)}': The result must not have attributes.`);
|
|
2190
|
+
}
|
|
2191
|
+
unlockAttribute(elm, name);
|
|
2192
|
+
setAttribute(elm, name, value, namespace);
|
|
2193
|
+
lockAttribute();
|
|
2194
|
+
},
|
|
2195
|
+
getBoundingClientRect() {
|
|
2196
|
+
const vm = getAssociatedVM(this);
|
|
2197
|
+
const {
|
|
2198
|
+
elm,
|
|
2199
|
+
renderer: {
|
|
2200
|
+
getBoundingClientRect
|
|
2201
|
+
}
|
|
2202
|
+
} = vm;
|
|
2203
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2204
|
+
warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
|
|
2003
2205
|
}
|
|
2004
|
-
|
|
2005
|
-
|
|
2206
|
+
return getBoundingClientRect(elm);
|
|
2207
|
+
},
|
|
2208
|
+
get isConnected() {
|
|
2209
|
+
const vm = getAssociatedVM(this);
|
|
2210
|
+
const {
|
|
2211
|
+
elm,
|
|
2212
|
+
renderer: {
|
|
2213
|
+
isConnected
|
|
2214
|
+
}
|
|
2215
|
+
} = vm;
|
|
2216
|
+
return isConnected(elm);
|
|
2217
|
+
},
|
|
2218
|
+
get classList() {
|
|
2219
|
+
const vm = getAssociatedVM(this);
|
|
2220
|
+
const {
|
|
2221
|
+
elm,
|
|
2222
|
+
renderer: {
|
|
2223
|
+
getClassList
|
|
2224
|
+
}
|
|
2225
|
+
} = vm;
|
|
2226
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2227
|
+
// TODO [#1290]: this still fails in dev but works in production, eventually, we should
|
|
2228
|
+
// just throw in all modes
|
|
2229
|
+
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.`);
|
|
2230
|
+
}
|
|
2231
|
+
return getClassList(elm);
|
|
2232
|
+
},
|
|
2233
|
+
get template() {
|
|
2234
|
+
const vm = getAssociatedVM(this);
|
|
2235
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2236
|
+
if (vm.renderMode === 0 /* RenderMode.Light */) {
|
|
2237
|
+
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`.');
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
return vm.shadowRoot;
|
|
2241
|
+
},
|
|
2242
|
+
get refs() {
|
|
2243
|
+
const vm = getAssociatedVM(this);
|
|
2244
|
+
if (isUpdatingTemplate) {
|
|
2245
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2246
|
+
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().`);
|
|
2247
|
+
}
|
|
2248
|
+
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2249
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2250
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2251
|
+
// based on `this.refs.bar`.
|
|
2252
|
+
return;
|
|
2006
2253
|
}
|
|
2007
|
-
// Adding extra guard rails in DEV mode.
|
|
2008
2254
|
if (process.env.NODE_ENV !== 'production') {
|
|
2009
|
-
|
|
2010
|
-
patchComponentWithRestrictions(component);
|
|
2255
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2011
2256
|
}
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2257
|
+
const {
|
|
2258
|
+
refVNodes,
|
|
2259
|
+
hasRefVNodes,
|
|
2260
|
+
cmpTemplate
|
|
2261
|
+
} = vm;
|
|
2262
|
+
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2263
|
+
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2264
|
+
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2265
|
+
// `warnIfInvokedDuringConstruction` above).
|
|
2266
|
+
if (process.env.NODE_ENV !== 'production' && isNull(cmpTemplate) && !isBeingConstructed(vm)) {
|
|
2267
|
+
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().`);
|
|
2268
|
+
}
|
|
2269
|
+
// For backwards compatibility with component written before template refs
|
|
2270
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
2271
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2272
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2273
|
+
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2274
|
+
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2275
|
+
if (!hasRefVNodes) {
|
|
2276
|
+
return;
|
|
2277
|
+
}
|
|
2278
|
+
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2279
|
+
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2280
|
+
if (isNull(refVNodes)) {
|
|
2281
|
+
return EMPTY_REFS;
|
|
2282
|
+
}
|
|
2283
|
+
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2284
|
+
// are recreated from scratch every time the template is rendered.
|
|
2285
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2286
|
+
let refs = refsCache.get(refVNodes);
|
|
2287
|
+
if (isUndefined$1(refs)) {
|
|
2288
|
+
refs = create(null);
|
|
2289
|
+
for (const key of keys(refVNodes)) {
|
|
2290
|
+
refs[key] = refVNodes[key].elm;
|
|
2291
|
+
}
|
|
2292
|
+
freeze(refs);
|
|
2293
|
+
refsCache.set(refVNodes, refs);
|
|
2294
|
+
}
|
|
2295
|
+
return refs;
|
|
2296
|
+
},
|
|
2297
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2298
|
+
set refs(value) {
|
|
2299
|
+
defineProperty(this, 'refs', {
|
|
2300
|
+
configurable: true,
|
|
2301
|
+
enumerable: true,
|
|
2302
|
+
writable: true,
|
|
2303
|
+
value
|
|
2020
2304
|
});
|
|
2021
|
-
|
|
2022
|
-
|
|
2305
|
+
},
|
|
2306
|
+
get shadowRoot() {
|
|
2307
|
+
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2308
|
+
// Authors should rely on this.template instead.
|
|
2309
|
+
return null;
|
|
2310
|
+
},
|
|
2311
|
+
get children() {
|
|
2312
|
+
const vm = getAssociatedVM(this);
|
|
2313
|
+
const renderer = vm.renderer;
|
|
2023
2314
|
if (process.env.NODE_ENV !== 'production') {
|
|
2024
|
-
|
|
2315
|
+
warnIfInvokedDuringConstruction(vm, 'children');
|
|
2025
2316
|
}
|
|
2026
|
-
return
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2317
|
+
return renderer.getChildren(vm.elm);
|
|
2318
|
+
},
|
|
2319
|
+
get childNodes() {
|
|
2320
|
+
const vm = getAssociatedVM(this);
|
|
2321
|
+
const renderer = vm.renderer;
|
|
2322
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2323
|
+
warnIfInvokedDuringConstruction(vm, 'childNodes');
|
|
2031
2324
|
}
|
|
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
|
-
},
|
|
2325
|
+
return renderer.getChildNodes(vm.elm);
|
|
2326
|
+
},
|
|
2327
|
+
get firstChild() {
|
|
2328
|
+
const vm = getAssociatedVM(this);
|
|
2329
|
+
const renderer = vm.renderer;
|
|
2330
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2331
|
+
warnIfInvokedDuringConstruction(vm, 'firstChild');
|
|
2332
|
+
}
|
|
2333
|
+
return renderer.getFirstChild(vm.elm);
|
|
2334
|
+
},
|
|
2335
|
+
get firstElementChild() {
|
|
2336
|
+
const vm = getAssociatedVM(this);
|
|
2337
|
+
const renderer = vm.renderer;
|
|
2338
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2339
|
+
warnIfInvokedDuringConstruction(vm, 'firstElementChild');
|
|
2340
|
+
}
|
|
2341
|
+
return renderer.getFirstElementChild(vm.elm);
|
|
2342
|
+
},
|
|
2343
|
+
get lastChild() {
|
|
2344
|
+
const vm = getAssociatedVM(this);
|
|
2345
|
+
const renderer = vm.renderer;
|
|
2346
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2347
|
+
warnIfInvokedDuringConstruction(vm, 'lastChild');
|
|
2348
|
+
}
|
|
2349
|
+
return renderer.getLastChild(vm.elm);
|
|
2350
|
+
},
|
|
2351
|
+
get lastElementChild() {
|
|
2352
|
+
const vm = getAssociatedVM(this);
|
|
2353
|
+
const renderer = vm.renderer;
|
|
2354
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2355
|
+
warnIfInvokedDuringConstruction(vm, 'lastElementChild');
|
|
2356
|
+
}
|
|
2357
|
+
return renderer.getLastElementChild(vm.elm);
|
|
2358
|
+
},
|
|
2359
|
+
render() {
|
|
2360
|
+
const vm = getAssociatedVM(this);
|
|
2361
|
+
return vm.def.template;
|
|
2362
|
+
},
|
|
2363
|
+
toString() {
|
|
2364
|
+
const vm = getAssociatedVM(this);
|
|
2365
|
+
return `[object ${vm.def.name}]`;
|
|
2366
|
+
}
|
|
2271
2367
|
};
|
|
2272
2368
|
const queryAndChildGetterDescriptors = create(null);
|
|
2273
|
-
const queryMethods = [
|
|
2274
|
-
'getElementsByClassName',
|
|
2275
|
-
'getElementsByTagName',
|
|
2276
|
-
'querySelector',
|
|
2277
|
-
'querySelectorAll',
|
|
2278
|
-
];
|
|
2369
|
+
const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll'];
|
|
2279
2370
|
// Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
|
|
2280
2371
|
for (const queryMethod of queryMethods) {
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2372
|
+
queryAndChildGetterDescriptors[queryMethod] = {
|
|
2373
|
+
value(arg) {
|
|
2374
|
+
const vm = getAssociatedVM(this);
|
|
2375
|
+
const {
|
|
2376
|
+
elm,
|
|
2377
|
+
renderer
|
|
2378
|
+
} = vm;
|
|
2379
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2380
|
+
warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
|
|
2381
|
+
}
|
|
2382
|
+
return renderer[queryMethod](elm, arg);
|
|
2383
|
+
},
|
|
2384
|
+
configurable: true,
|
|
2385
|
+
enumerable: true,
|
|
2386
|
+
writable: true
|
|
2387
|
+
};
|
|
2294
2388
|
}
|
|
2295
2389
|
defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
|
|
2296
2390
|
const lightningBasedDescriptors = create(null);
|
|
2297
2391
|
for (const propName in HTMLElementOriginalDescriptors) {
|
|
2298
|
-
|
|
2392
|
+
lightningBasedDescriptors[propName] = createBridgeToElementDescriptor(propName, HTMLElementOriginalDescriptors[propName]);
|
|
2299
2393
|
}
|
|
2300
2394
|
defineProperties(LightningElement.prototype, lightningBasedDescriptors);
|
|
2395
|
+
function applyAriaReflectionToLightningElement() {
|
|
2396
|
+
// If ARIA reflection is not applied globally to Element.prototype, or if we are running server-side,
|
|
2397
|
+
// apply it to LightningElement.prototype.
|
|
2398
|
+
// This allows `this.aria*` property accessors to work from inside a component, and to reflect `aria-*` attrs.
|
|
2399
|
+
applyAriaReflection(LightningElement.prototype);
|
|
2400
|
+
}
|
|
2401
|
+
// The reason for this odd if/else branching is limitations in @lwc/features:
|
|
2402
|
+
// https://github.com/salesforce/lwc/blob/master/packages/%40lwc/features/README.md#only-works-with-if-statements
|
|
2403
|
+
if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
2404
|
+
applyAriaReflectionToLightningElement();
|
|
2405
|
+
}
|
|
2301
2406
|
defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2407
|
+
get() {
|
|
2408
|
+
// If required, a runtime-specific implementation must be defined.
|
|
2409
|
+
throw new ReferenceError('The current runtime does not support CustomElementConstructor.');
|
|
2410
|
+
},
|
|
2411
|
+
configurable: true
|
|
2307
2412
|
});
|
|
2308
2413
|
if (process.env.NODE_ENV !== 'production') {
|
|
2309
|
-
|
|
2414
|
+
patchLightningElementPrototypeWithRestrictions(LightningElement.prototype);
|
|
2310
2415
|
}
|
|
2311
2416
|
|
|
2312
2417
|
function createObservedFieldPropertyDescriptor(key) {
|
|
@@ -2766,138 +2871,161 @@ function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
|
|
|
2766
2871
|
const cachedGetterByKey = create(null);
|
|
2767
2872
|
const cachedSetterByKey = create(null);
|
|
2768
2873
|
function createGetter(key) {
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2874
|
+
let fn = cachedGetterByKey[key];
|
|
2875
|
+
if (isUndefined$1(fn)) {
|
|
2876
|
+
fn = cachedGetterByKey[key] = function () {
|
|
2877
|
+
const vm = getAssociatedVM(this);
|
|
2878
|
+
const {
|
|
2879
|
+
getHook
|
|
2880
|
+
} = vm;
|
|
2881
|
+
return getHook(vm.component, key);
|
|
2882
|
+
};
|
|
2883
|
+
}
|
|
2884
|
+
return fn;
|
|
2778
2885
|
}
|
|
2779
2886
|
function createSetter(key) {
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2887
|
+
let fn = cachedSetterByKey[key];
|
|
2888
|
+
if (isUndefined$1(fn)) {
|
|
2889
|
+
fn = cachedSetterByKey[key] = function (newValue) {
|
|
2890
|
+
const vm = getAssociatedVM(this);
|
|
2891
|
+
const {
|
|
2892
|
+
setHook
|
|
2893
|
+
} = vm;
|
|
2894
|
+
newValue = getReadOnlyProxy(newValue);
|
|
2895
|
+
setHook(vm.component, key, newValue);
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
return fn;
|
|
2790
2899
|
}
|
|
2791
2900
|
function createMethodCaller(methodName) {
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
};
|
|
2901
|
+
return function () {
|
|
2902
|
+
const vm = getAssociatedVM(this);
|
|
2903
|
+
const {
|
|
2904
|
+
callHook,
|
|
2905
|
+
component
|
|
2906
|
+
} = vm;
|
|
2907
|
+
const fn = component[methodName];
|
|
2908
|
+
return callHook(vm.component, fn, ArraySlice.call(arguments));
|
|
2909
|
+
};
|
|
2798
2910
|
}
|
|
2799
2911
|
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
|
-
});
|
|
2912
|
+
return function attributeChangedCallback(attrName, oldValue, newValue) {
|
|
2913
|
+
if (oldValue === newValue) {
|
|
2914
|
+
// Ignore same values.
|
|
2915
|
+
return;
|
|
2856
2916
|
}
|
|
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
|
-
};
|
|
2917
|
+
const propName = attributeToPropMap[attrName];
|
|
2918
|
+
if (isUndefined$1(propName)) {
|
|
2919
|
+
if (!isUndefined$1(superAttributeChangedCallback)) {
|
|
2920
|
+
// delegate unknown attributes to the super.
|
|
2921
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2922
|
+
// @ts-ignore type-mismatch
|
|
2923
|
+
superAttributeChangedCallback.apply(this, arguments);
|
|
2924
|
+
}
|
|
2925
|
+
return;
|
|
2873
2926
|
}
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
};
|
|
2927
|
+
if (!isAttributeLocked(this, attrName)) {
|
|
2928
|
+
// Ignore changes triggered by the engine itself during:
|
|
2929
|
+
// * diffing when public props are attempting to reflect to the DOM
|
|
2930
|
+
// * component via `this.setAttribute()`, should never update the prop
|
|
2931
|
+
// Both cases, the setAttribute call is always wrapped by the unlocking of the
|
|
2932
|
+
// attribute to be changed
|
|
2933
|
+
return;
|
|
2882
2934
|
}
|
|
2883
|
-
//
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2935
|
+
// Reflect attribute change to the corresponding property when changed from outside.
|
|
2936
|
+
this[propName] = newValue;
|
|
2937
|
+
};
|
|
2938
|
+
}
|
|
2939
|
+
function HTMLBridgeElementFactory(SuperClass, props, methods) {
|
|
2940
|
+
let HTMLBridgeElement;
|
|
2941
|
+
/**
|
|
2942
|
+
* Modern browsers will have all Native Constructors as regular Classes
|
|
2943
|
+
* and must be instantiated with the new keyword. In older browsers,
|
|
2944
|
+
* specifically IE11, those are objects with a prototype property defined,
|
|
2945
|
+
* since they are not supposed to be extended or instantiated with the
|
|
2946
|
+
* new keyword. This forking logic supports both cases, specifically because
|
|
2947
|
+
* wc.ts relies on the construction path of the bridges to create new
|
|
2948
|
+
* fully qualifying web components.
|
|
2949
|
+
*/
|
|
2950
|
+
if (isFunction$1(SuperClass)) {
|
|
2951
|
+
HTMLBridgeElement = class extends SuperClass {};
|
|
2952
|
+
} else {
|
|
2953
|
+
HTMLBridgeElement = function () {
|
|
2954
|
+
// Bridge classes are not supposed to be instantiated directly in
|
|
2955
|
+
// browsers that do not support web components.
|
|
2956
|
+
throw new TypeError('Illegal constructor');
|
|
2889
2957
|
};
|
|
2890
|
-
//
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2958
|
+
// prototype inheritance dance
|
|
2959
|
+
setPrototypeOf(HTMLBridgeElement, SuperClass);
|
|
2960
|
+
setPrototypeOf(HTMLBridgeElement.prototype, SuperClass.prototype);
|
|
2961
|
+
defineProperty(HTMLBridgeElement.prototype, 'constructor', {
|
|
2962
|
+
writable: true,
|
|
2963
|
+
configurable: true,
|
|
2964
|
+
value: HTMLBridgeElement
|
|
2896
2965
|
});
|
|
2897
|
-
|
|
2898
|
-
|
|
2966
|
+
}
|
|
2967
|
+
// generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
|
2968
|
+
// and false positives in case of inheritance.
|
|
2969
|
+
const attributeToPropMap = create(null);
|
|
2970
|
+
const {
|
|
2971
|
+
attributeChangedCallback: superAttributeChangedCallback
|
|
2972
|
+
} = SuperClass.prototype;
|
|
2973
|
+
const {
|
|
2974
|
+
observedAttributes: superObservedAttributes = []
|
|
2975
|
+
} = SuperClass;
|
|
2976
|
+
const descriptors = create(null);
|
|
2977
|
+
// expose getters and setters for each public props on the new Element Bridge
|
|
2978
|
+
for (let i = 0, len = props.length; i < len; i += 1) {
|
|
2979
|
+
const propName = props[i];
|
|
2980
|
+
attributeToPropMap[htmlPropertyToAttribute(propName)] = propName;
|
|
2981
|
+
descriptors[propName] = {
|
|
2982
|
+
get: createGetter(propName),
|
|
2983
|
+
set: createSetter(propName),
|
|
2984
|
+
enumerable: true,
|
|
2985
|
+
configurable: true
|
|
2986
|
+
};
|
|
2987
|
+
}
|
|
2988
|
+
// expose public methods as props on the new Element Bridge
|
|
2989
|
+
for (let i = 0, len = methods.length; i < len; i += 1) {
|
|
2990
|
+
const methodName = methods[i];
|
|
2991
|
+
descriptors[methodName] = {
|
|
2992
|
+
value: createMethodCaller(methodName),
|
|
2993
|
+
writable: true,
|
|
2994
|
+
configurable: true
|
|
2995
|
+
};
|
|
2996
|
+
}
|
|
2997
|
+
// creating a new attributeChangedCallback per bridge because they are bound to the corresponding
|
|
2998
|
+
// map of attributes to props. We do this after all other props and methods to avoid the possibility
|
|
2999
|
+
// of getting overrule by a class declaration in user-land, and we make it non-writable, non-configurable
|
|
3000
|
+
// to preserve this definition.
|
|
3001
|
+
descriptors.attributeChangedCallback = {
|
|
3002
|
+
value: createAttributeChangedCallback(attributeToPropMap, superAttributeChangedCallback)
|
|
3003
|
+
};
|
|
3004
|
+
// Specify attributes for which we want to reflect changes back to their corresponding
|
|
3005
|
+
// properties via attributeChangedCallback.
|
|
3006
|
+
defineProperty(HTMLBridgeElement, 'observedAttributes', {
|
|
3007
|
+
get() {
|
|
3008
|
+
return [...superObservedAttributes, ...keys(attributeToPropMap)];
|
|
3009
|
+
}
|
|
3010
|
+
});
|
|
3011
|
+
defineProperties(HTMLBridgeElement.prototype, descriptors);
|
|
3012
|
+
return HTMLBridgeElement;
|
|
2899
3013
|
}
|
|
2900
3014
|
const BaseBridgeElement = HTMLBridgeElementFactory(HTMLElementConstructor, getOwnPropertyNames$1(HTMLElementOriginalDescriptors), []);
|
|
3015
|
+
{
|
|
3016
|
+
// This ARIA reflection only really makes sense in the browser. On the server, there is no `renderedCallback()`,
|
|
3017
|
+
// so you cannot do e.g. `this.template.querySelector('x-child').ariaBusy = 'true'`. So we don't need to expose
|
|
3018
|
+
// ARIA props outside the LightningElement
|
|
3019
|
+
if (lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
|
|
3020
|
+
// If ARIA reflection is not applied globally to Element.prototype, apply it to HTMLBridgeElement.prototype.
|
|
3021
|
+
// This allows `elm.aria*` property accessors to work from outside a component, and to reflect `aria-*` attrs.
|
|
3022
|
+
// This is especially important because the template compiler compiles aria-* attrs on components to aria* props
|
|
3023
|
+
//
|
|
3024
|
+
// Also note that we apply this to BaseBridgeElement.prototype to avoid excessively redefining property
|
|
3025
|
+
// accessors inside the HTMLBridgeElementFactory.
|
|
3026
|
+
applyAriaReflection(BaseBridgeElement.prototype);
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
2901
3029
|
freeze(BaseBridgeElement);
|
|
2902
3030
|
seal(BaseBridgeElement.prototype);
|
|
2903
3031
|
|
|
@@ -3353,6 +3481,9 @@ function updateStylesheetToken(vm, template) {
|
|
|
3353
3481
|
stylesheets: newStylesheets,
|
|
3354
3482
|
stylesheetToken: newStylesheetToken
|
|
3355
3483
|
} = template;
|
|
3484
|
+
const {
|
|
3485
|
+
stylesheets: newVmStylesheets
|
|
3486
|
+
} = vm;
|
|
3356
3487
|
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3357
3488
|
const {
|
|
3358
3489
|
hasScopedStyles
|
|
@@ -3376,7 +3507,9 @@ function updateStylesheetToken(vm, template) {
|
|
|
3376
3507
|
}
|
|
3377
3508
|
// Apply the new template styling token to the host element, if the new template has any
|
|
3378
3509
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3379
|
-
|
|
3510
|
+
const hasNewStylesheets = hasStyles(newStylesheets);
|
|
3511
|
+
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
|
3512
|
+
if (hasNewStylesheets || hasNewVmStylesheets) {
|
|
3380
3513
|
newToken = newStylesheetToken;
|
|
3381
3514
|
}
|
|
3382
3515
|
// Set the new styling token on the host element
|
|
@@ -3448,10 +3581,17 @@ function getStylesheetsContent(vm, template) {
|
|
|
3448
3581
|
stylesheets,
|
|
3449
3582
|
stylesheetToken
|
|
3450
3583
|
} = template;
|
|
3584
|
+
const {
|
|
3585
|
+
stylesheets: vmStylesheets
|
|
3586
|
+
} = vm;
|
|
3451
3587
|
let content = [];
|
|
3452
|
-
if (
|
|
3588
|
+
if (hasStyles(stylesheets)) {
|
|
3453
3589
|
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3454
3590
|
}
|
|
3591
|
+
// VM (component) stylesheets apply after template stylesheets
|
|
3592
|
+
if (hasStyles(vmStylesheets)) {
|
|
3593
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
|
3594
|
+
}
|
|
3455
3595
|
return content;
|
|
3456
3596
|
}
|
|
3457
3597
|
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
@@ -3489,10 +3629,13 @@ function getStylesheetTokenHost(vnode) {
|
|
|
3489
3629
|
const {
|
|
3490
3630
|
template
|
|
3491
3631
|
} = getComponentInternalDef(vnode.ctor);
|
|
3632
|
+
const {
|
|
3633
|
+
vm
|
|
3634
|
+
} = vnode;
|
|
3492
3635
|
const {
|
|
3493
3636
|
stylesheetToken
|
|
3494
3637
|
} = template;
|
|
3495
|
-
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3638
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
|
|
3496
3639
|
}
|
|
3497
3640
|
function getNearestNativeShadowComponent(vm) {
|
|
3498
3641
|
const owner = getNearestShadowComponent(vm);
|
|
@@ -4105,6 +4248,28 @@ function patchCustomElement(n1, n2, parent, renderer) {
|
|
|
4105
4248
|
// in fallback mode, the allocation will always set children to
|
|
4106
4249
|
// empty and delegate the real allocation to the slot elements
|
|
4107
4250
|
allocateChildren(n2, vm);
|
|
4251
|
+
// Solves an edge case with slotted VFragments in native shadow mode.
|
|
4252
|
+
//
|
|
4253
|
+
// During allocation, in native shadow, slotted VFragment nodes are flattened and their text delimiters are removed
|
|
4254
|
+
// to avoid interfering with native slot behavior. When this happens, if any of the fragments
|
|
4255
|
+
// were not stable, the children must go through the dynamic diffing algo.
|
|
4256
|
+
//
|
|
4257
|
+
// If the new children (n2.children) contain no VFragments, but the previous children (n1.children) were dynamic,
|
|
4258
|
+
// the new nodes must be marked dynamic so that all nodes are properly updated. The only indicator that the new
|
|
4259
|
+
// nodes need to be dynamic comes from the previous children, so we check that to determine whether we need to
|
|
4260
|
+
// mark the new children dynamic.
|
|
4261
|
+
//
|
|
4262
|
+
// Example:
|
|
4263
|
+
// n1.children: [div, VFragment('', div, null, ''), div] => [div, div, null, div]; // marked dynamic
|
|
4264
|
+
// n2.children: [div, null, div] => [div, null, div] // marked ???
|
|
4265
|
+
const {
|
|
4266
|
+
shadowMode,
|
|
4267
|
+
renderMode
|
|
4268
|
+
} = vm;
|
|
4269
|
+
if (shadowMode == 0 /* ShadowMode.Native */ && renderMode !== 0 /* RenderMode.Light */ && hasDynamicChildren(n1.children)) {
|
|
4270
|
+
// No-op if children has already been marked dynamic by 'allocateChildren()'.
|
|
4271
|
+
markAsDynamicChildren(n2.children);
|
|
4272
|
+
}
|
|
4108
4273
|
}
|
|
4109
4274
|
// in fallback mode, the children will be always empty, so, nothing
|
|
4110
4275
|
// will happen, but in native, it does allocate the light dom
|
|
@@ -4297,7 +4462,6 @@ function allocateChildren(vnode, vm) {
|
|
|
4297
4462
|
//
|
|
4298
4463
|
// In case #2, we will always get a fresh VCustomElement.
|
|
4299
4464
|
const children = vnode.aChildren || vnode.children;
|
|
4300
|
-
vm.aChildren = children;
|
|
4301
4465
|
const {
|
|
4302
4466
|
renderMode,
|
|
4303
4467
|
shadowMode
|
|
@@ -4310,15 +4474,61 @@ function allocateChildren(vnode, vm) {
|
|
|
4310
4474
|
logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
|
|
4311
4475
|
}
|
|
4312
4476
|
}
|
|
4477
|
+
// If any of the children being allocated are VFragments, we remove the text delimiters and flatten all immediate
|
|
4478
|
+
// children VFragments to avoid them interfering with default slot behavior.
|
|
4479
|
+
const allocatedChildren = flattenFragmentsInChildren(children);
|
|
4480
|
+
vnode.children = allocatedChildren;
|
|
4481
|
+
vm.aChildren = allocatedChildren;
|
|
4313
4482
|
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4314
4483
|
// slow path
|
|
4315
|
-
allocateInSlot(vm,
|
|
4484
|
+
allocateInSlot(vm, allocatedChildren, vnode.owner);
|
|
4316
4485
|
// save the allocated children in case this vnode is reused.
|
|
4317
|
-
vnode.aChildren =
|
|
4486
|
+
vnode.aChildren = allocatedChildren;
|
|
4318
4487
|
// every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4319
4488
|
vnode.children = EmptyArray;
|
|
4320
4489
|
}
|
|
4321
4490
|
}
|
|
4491
|
+
/**
|
|
4492
|
+
* Flattens the contents of all VFragments in an array of VNodes, removes the text delimiters on those VFragments, and
|
|
4493
|
+
* marks the resulting children array as dynamic. Uses a stack (array) to iteratively traverse the nested VFragments
|
|
4494
|
+
* and avoid the perf overhead of creating/destroying throwaway arrays/objects in a recursive approach.
|
|
4495
|
+
*
|
|
4496
|
+
* With the delimiters removed, the contents are marked dynamic so they are diffed correctly.
|
|
4497
|
+
*
|
|
4498
|
+
* This function is used for slotted VFragments to avoid the text delimiters interfering with slotting functionality.
|
|
4499
|
+
*/
|
|
4500
|
+
function flattenFragmentsInChildren(children) {
|
|
4501
|
+
const flattenedChildren = [];
|
|
4502
|
+
// Initialize our stack with the direct children of the custom component and check whether we have a VFragment.
|
|
4503
|
+
// If no VFragment is found in children, we don't need to traverse anything or mark the children dynamic and can return early.
|
|
4504
|
+
const nodeStack = [];
|
|
4505
|
+
let fragmentFound = false;
|
|
4506
|
+
for (let i = children.length - 1; i > -1; i -= 1) {
|
|
4507
|
+
const child = children[i];
|
|
4508
|
+
ArrayPush$1.call(nodeStack, child);
|
|
4509
|
+
fragmentFound = fragmentFound || !!(child && isVFragment(child));
|
|
4510
|
+
}
|
|
4511
|
+
if (!fragmentFound) {
|
|
4512
|
+
return children;
|
|
4513
|
+
}
|
|
4514
|
+
let currentNode;
|
|
4515
|
+
while (!isUndefined$1(currentNode = ArrayPop.call(nodeStack))) {
|
|
4516
|
+
if (!isNull(currentNode) && isVFragment(currentNode)) {
|
|
4517
|
+
const fChildren = currentNode.children;
|
|
4518
|
+
// Ignore the start and end text node delimiters
|
|
4519
|
+
for (let i = fChildren.length - 2; i > 0; i -= 1) {
|
|
4520
|
+
ArrayPush$1.call(nodeStack, fChildren[i]);
|
|
4521
|
+
}
|
|
4522
|
+
} else {
|
|
4523
|
+
ArrayPush$1.call(flattenedChildren, currentNode);
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
// We always mark the children as dynamic because nothing generates stable VFragments yet.
|
|
4527
|
+
// If/when stable VFragments are generated by the compiler, this code should be updated to
|
|
4528
|
+
// not mark dynamic if all flattened VFragments were stable.
|
|
4529
|
+
markAsDynamicChildren(flattenedChildren);
|
|
4530
|
+
return flattenedChildren;
|
|
4531
|
+
}
|
|
4322
4532
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4323
4533
|
let vm = getAssociatedVMIfPresent(elm);
|
|
4324
4534
|
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
@@ -4343,22 +4553,20 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4343
4553
|
}
|
|
4344
4554
|
return vm;
|
|
4345
4555
|
}
|
|
4346
|
-
|
|
4347
|
-
* Collects all slots into a SlotSet, traversing through VFragment Nodes
|
|
4348
|
-
*/
|
|
4349
|
-
function collectSlots(vm, children, cmpSlotsMapping) {
|
|
4556
|
+
function allocateInSlot(vm, children, owner) {
|
|
4350
4557
|
var _a, _b;
|
|
4558
|
+
const {
|
|
4559
|
+
cmpSlots: {
|
|
4560
|
+
slotAssignments: oldSlotsMapping
|
|
4561
|
+
}
|
|
4562
|
+
} = vm;
|
|
4563
|
+
const cmpSlotsMapping = create(null);
|
|
4564
|
+
// Collect all slots into cmpSlotsMapping
|
|
4351
4565
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4352
4566
|
const vnode = children[i];
|
|
4353
4567
|
if (isNull(vnode)) {
|
|
4354
4568
|
continue;
|
|
4355
4569
|
}
|
|
4356
|
-
// Dive further iff the content is wrapped in a VFragment
|
|
4357
|
-
if (isVFragment(vnode)) {
|
|
4358
|
-
// Remove the text delimiter nodes to avoid overriding default slot content
|
|
4359
|
-
collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
|
|
4360
|
-
continue;
|
|
4361
|
-
}
|
|
4362
4570
|
let slotName = '';
|
|
4363
4571
|
if (isVBaseElement(vnode)) {
|
|
4364
4572
|
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
@@ -4368,15 +4576,6 @@ function collectSlots(vm, children, cmpSlotsMapping) {
|
|
|
4368
4576
|
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4369
4577
|
ArrayPush$1.call(vnodes, vnode);
|
|
4370
4578
|
}
|
|
4371
|
-
}
|
|
4372
|
-
function allocateInSlot(vm, children, owner) {
|
|
4373
|
-
const {
|
|
4374
|
-
cmpSlots: {
|
|
4375
|
-
slotAssignments: oldSlotsMapping
|
|
4376
|
-
}
|
|
4377
|
-
} = vm;
|
|
4378
|
-
const cmpSlotsMapping = create(null);
|
|
4379
|
-
collectSlots(vm, children, cmpSlotsMapping);
|
|
4380
4579
|
vm.cmpSlots = {
|
|
4381
4580
|
owner,
|
|
4382
4581
|
slotAssignments: cmpSlotsMapping
|
|
@@ -4407,14 +4606,14 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4407
4606
|
}
|
|
4408
4607
|
}
|
|
4409
4608
|
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4410
|
-
const
|
|
4411
|
-
// dynamic children means it was generated by an iteration
|
|
4412
|
-
//
|
|
4609
|
+
const DynamicChildren = new WeakMap();
|
|
4610
|
+
// dynamic children means it was either generated by an iteration in a template
|
|
4611
|
+
// or part of an unstable fragment, and will require a more complex diffing algo.
|
|
4413
4612
|
function markAsDynamicChildren(children) {
|
|
4414
|
-
|
|
4613
|
+
DynamicChildren.set(children, 1);
|
|
4415
4614
|
}
|
|
4416
4615
|
function hasDynamicChildren(children) {
|
|
4417
|
-
return
|
|
4616
|
+
return DynamicChildren.has(children);
|
|
4418
4617
|
}
|
|
4419
4618
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4420
4619
|
const map = {};
|
|
@@ -5280,7 +5479,7 @@ function evaluateTemplate(vm, html) {
|
|
|
5280
5479
|
// Create a brand new template cache for the swapped templated.
|
|
5281
5480
|
context.tplCache = create(null);
|
|
5282
5481
|
// Set the computeHasScopedStyles property in the context, to avoid recomputing it repeatedly.
|
|
5283
|
-
context.hasScopedStyles = computeHasScopedStyles(html);
|
|
5482
|
+
context.hasScopedStyles = computeHasScopedStyles(html, vm);
|
|
5284
5483
|
// Update the scoping token on the host element.
|
|
5285
5484
|
updateStylesheetToken(vm, html);
|
|
5286
5485
|
// Evaluate, create stylesheet and cache the produced VNode for future
|
|
@@ -5323,9 +5522,8 @@ function evaluateTemplate(vm, html) {
|
|
|
5323
5522
|
}
|
|
5324
5523
|
return vnodes;
|
|
5325
5524
|
}
|
|
5326
|
-
function
|
|
5327
|
-
|
|
5328
|
-
if (!isUndefined$1(stylesheets)) {
|
|
5525
|
+
function computeHasScopedStylesInStylesheets(stylesheets) {
|
|
5526
|
+
if (hasStyles(stylesheets)) {
|
|
5329
5527
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5330
5528
|
if (isTrue(stylesheets[i][KEY__SCOPED_CSS])) {
|
|
5331
5529
|
return true;
|
|
@@ -5334,6 +5532,15 @@ function computeHasScopedStyles(template) {
|
|
|
5334
5532
|
}
|
|
5335
5533
|
return false;
|
|
5336
5534
|
}
|
|
5535
|
+
function computeHasScopedStyles(template, vm) {
|
|
5536
|
+
const { stylesheets } = template;
|
|
5537
|
+
const vmStylesheets = !isUndefined$1(vm) ? vm.stylesheets : null;
|
|
5538
|
+
return (computeHasScopedStylesInStylesheets(stylesheets) ||
|
|
5539
|
+
computeHasScopedStylesInStylesheets(vmStylesheets));
|
|
5540
|
+
}
|
|
5541
|
+
function hasStyles(stylesheets) {
|
|
5542
|
+
return !isUndefined$1(stylesheets) && !isNull(stylesheets) && stylesheets.length > 0;
|
|
5543
|
+
}
|
|
5337
5544
|
|
|
5338
5545
|
/*
|
|
5339
5546
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5649,6 +5856,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5649
5856
|
// Properties set right after VM creation.
|
|
5650
5857
|
tro: null,
|
|
5651
5858
|
shadowMode: null,
|
|
5859
|
+
stylesheets: null,
|
|
5652
5860
|
// Properties set by the LightningElement constructor.
|
|
5653
5861
|
component: null,
|
|
5654
5862
|
shadowRoot: null,
|
|
@@ -5661,6 +5869,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5661
5869
|
if (process.env.NODE_ENV !== 'production') {
|
|
5662
5870
|
vm.debugInfo = create(null);
|
|
5663
5871
|
}
|
|
5872
|
+
vm.stylesheets = computeStylesheets(vm, def.ctor);
|
|
5664
5873
|
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5665
5874
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5666
5875
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5679,6 +5888,42 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5679
5888
|
}
|
|
5680
5889
|
return vm;
|
|
5681
5890
|
}
|
|
5891
|
+
function validateComponentStylesheets(vm, stylesheets) {
|
|
5892
|
+
let valid = true;
|
|
5893
|
+
const validate = arrayOrStylesheet => {
|
|
5894
|
+
if (isArray$1(arrayOrStylesheet)) {
|
|
5895
|
+
for (let i = 0; i < arrayOrStylesheet.length; i++) {
|
|
5896
|
+
validate(arrayOrStylesheet[i]);
|
|
5897
|
+
}
|
|
5898
|
+
} else if (!isFunction$1(arrayOrStylesheet)) {
|
|
5899
|
+
// function assumed to be a stylesheet factory
|
|
5900
|
+
valid = false;
|
|
5901
|
+
}
|
|
5902
|
+
};
|
|
5903
|
+
if (!isArray$1(stylesheets)) {
|
|
5904
|
+
valid = false;
|
|
5905
|
+
} else {
|
|
5906
|
+
validate(stylesheets);
|
|
5907
|
+
}
|
|
5908
|
+
return valid;
|
|
5909
|
+
}
|
|
5910
|
+
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
5911
|
+
function computeStylesheets(vm, ctor) {
|
|
5912
|
+
if (lwcRuntimeFlags.ENABLE_PROGRAMMATIC_STYLESHEETS) {
|
|
5913
|
+
const {
|
|
5914
|
+
stylesheets
|
|
5915
|
+
} = ctor;
|
|
5916
|
+
if (!isUndefined$1(stylesheets)) {
|
|
5917
|
+
const valid = validateComponentStylesheets(vm, stylesheets);
|
|
5918
|
+
if (valid) {
|
|
5919
|
+
return flattenStylesheets(stylesheets);
|
|
5920
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
5921
|
+
logError(`static stylesheets must be an array of CSS stylesheets. Found invalid stylesheets on <${vm.tagName}>`, vm);
|
|
5922
|
+
}
|
|
5923
|
+
}
|
|
5924
|
+
}
|
|
5925
|
+
return null;
|
|
5926
|
+
}
|
|
5682
5927
|
function computeShadowMode(vm, renderer) {
|
|
5683
5928
|
const {
|
|
5684
5929
|
def
|
|
@@ -6997,7 +7242,7 @@ function getComponentConstructor(elm) {
|
|
|
6997
7242
|
}
|
|
6998
7243
|
return ctor;
|
|
6999
7244
|
}
|
|
7000
|
-
/* version: 2.
|
|
7245
|
+
/* version: 2.34.0 */
|
|
7001
7246
|
|
|
7002
7247
|
/*
|
|
7003
7248
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7104,7 +7349,9 @@ const stylesheetCache = new Map();
|
|
|
7104
7349
|
//
|
|
7105
7350
|
// Test utilities
|
|
7106
7351
|
//
|
|
7107
|
-
|
|
7352
|
+
// Only used in LWC's Karma tests
|
|
7353
|
+
// @ts-ignore
|
|
7354
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
7108
7355
|
// @ts-ignore
|
|
7109
7356
|
window.__lwcResetGlobalStylesheets = () => {
|
|
7110
7357
|
stylesheetCache.clear();
|
|
@@ -7970,7 +8217,7 @@ function rendererFactory(baseRenderer) {
|
|
|
7970
8217
|
function isNull(obj) {
|
|
7971
8218
|
return obj === null;
|
|
7972
8219
|
}
|
|
7973
|
-
/** version: 2.
|
|
8220
|
+
/** version: 2.34.0 */
|
|
7974
8221
|
|
|
7975
8222
|
/*
|
|
7976
8223
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8531,6 +8778,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8531
8778
|
});
|
|
8532
8779
|
freeze(LightningElement);
|
|
8533
8780
|
seal(LightningElement.prototype);
|
|
8534
|
-
/* version: 2.
|
|
8781
|
+
/* version: 2.34.0 */
|
|
8535
8782
|
|
|
8536
8783
|
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 };
|