lwc 2.36.0 → 2.37.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 +26 -576
- package/dist/engine-dom/iife/es2017/engine-dom.js +26 -576
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +18 -568
- package/dist/engine-dom/iife/es5/engine-dom.js +38 -654
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +30 -646
- package/dist/engine-dom/umd/es2017/engine-dom.js +26 -576
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +18 -568
- package/dist/engine-dom/umd/es5/engine-dom.js +38 -654
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +30 -646
- package/dist/engine-server/commonjs/es2017/engine-server.js +38 -24
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +38 -25
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -321,7 +321,7 @@ var LWC = (function (exports) {
|
|
|
321
321
|
CACHED_ATTRIBUTE_PROPERTY_MAPPING.set(attrName, propertyName);
|
|
322
322
|
return propertyName;
|
|
323
323
|
}
|
|
324
|
-
/** version: 2.
|
|
324
|
+
/** version: 2.37.0 */
|
|
325
325
|
|
|
326
326
|
/**
|
|
327
327
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -341,10 +341,8 @@ var LWC = (function (exports) {
|
|
|
341
341
|
ENABLE_WIRE_SYNC_EMIT: null,
|
|
342
342
|
ENABLE_LIGHT_GET_ROOT_NODE_PATCH: null,
|
|
343
343
|
DISABLE_LIGHT_DOM_UNSCOPED_CSS: null,
|
|
344
|
-
ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY: null,
|
|
345
344
|
ENABLE_FROZEN_TEMPLATE: null,
|
|
346
345
|
DISABLE_ARIA_REFLECTION_POLYFILL: null,
|
|
347
|
-
ENABLE_PROGRAMMATIC_STYLESHEETS: null,
|
|
348
346
|
};
|
|
349
347
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
350
348
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
@@ -389,7 +387,7 @@ var LWC = (function (exports) {
|
|
|
389
387
|
*/
|
|
390
388
|
function setFeatureFlagForTest(name, value) {
|
|
391
389
|
}
|
|
392
|
-
/** version: 2.
|
|
390
|
+
/** version: 2.37.0 */
|
|
393
391
|
|
|
394
392
|
/**
|
|
395
393
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -453,7 +451,7 @@ var LWC = (function (exports) {
|
|
|
453
451
|
}
|
|
454
452
|
}
|
|
455
453
|
}
|
|
456
|
-
/** version: 2.
|
|
454
|
+
/** version: 2.37.0 */
|
|
457
455
|
|
|
458
456
|
/*
|
|
459
457
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -4836,15 +4834,13 @@ var LWC = (function (exports) {
|
|
|
4836
4834
|
}
|
|
4837
4835
|
// Validate and flatten any stylesheets defined as `static stylesheets`
|
|
4838
4836
|
function computeStylesheets(vm, ctor) {
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
return flattenStylesheets(stylesheets);
|
|
4847
|
-
}
|
|
4837
|
+
const {
|
|
4838
|
+
stylesheets
|
|
4839
|
+
} = ctor;
|
|
4840
|
+
if (!isUndefined$1(stylesheets)) {
|
|
4841
|
+
const valid = validateComponentStylesheets(vm, stylesheets);
|
|
4842
|
+
if (valid) {
|
|
4843
|
+
return flattenStylesheets(stylesheets);
|
|
4848
4844
|
}
|
|
4849
4845
|
}
|
|
4850
4846
|
return null;
|
|
@@ -5185,7 +5181,7 @@ var LWC = (function (exports) {
|
|
|
5185
5181
|
// The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
|
|
5186
5182
|
// These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
|
|
5187
5183
|
// When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
|
|
5188
|
-
// See: https://
|
|
5184
|
+
// See: https://sfdc.co/synthetic-aria
|
|
5189
5185
|
//
|
|
5190
5186
|
// Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
|
|
5191
5187
|
const getElementById = _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
|
|
@@ -6269,545 +6265,6 @@ var LWC = (function (exports) {
|
|
|
6269
6265
|
}
|
|
6270
6266
|
};
|
|
6271
6267
|
|
|
6272
|
-
/*
|
|
6273
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
|
6274
|
-
* All rights reserved.
|
|
6275
|
-
* SPDX-License-Identifier: MIT
|
|
6276
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6277
|
-
*/
|
|
6278
|
-
/**
|
|
6279
|
-
* Create a scoped registry, i.e. a function that can create custom elements whose tag names
|
|
6280
|
-
* do not conflict with third-party custom elements having the same tag name.
|
|
6281
|
-
*/
|
|
6282
|
-
function createScopedRegistry() {
|
|
6283
|
-
if (!hasCustomElements) {
|
|
6284
|
-
// This code should never be reached, because we don't use the pivot registry if
|
|
6285
|
-
// custom elements are unavailable.
|
|
6286
|
-
throw new Error('Custom elements are not supported in this environment.');
|
|
6287
|
-
}
|
|
6288
|
-
const { HTMLElement: NativeHTMLElement } = window;
|
|
6289
|
-
const { hasAttribute: nativeHasAttribute, setAttribute: nativeSetAttribute, removeAttribute: nativeRemoveAttribute, getAttribute: nativeGetAttribute, } = NativeHTMLElement.prototype;
|
|
6290
|
-
const definitionForElement = new WeakMap();
|
|
6291
|
-
const pendingRegistryForElement = new WeakMap();
|
|
6292
|
-
const definitionForConstructor = new WeakMap();
|
|
6293
|
-
const registeredUserCtors = new WeakSet();
|
|
6294
|
-
const registeredPivotCtors = new WeakSet();
|
|
6295
|
-
const pivotCtorByTag = new Map();
|
|
6296
|
-
const globalDefinitionsByTag = new Map();
|
|
6297
|
-
const globalDefinitionsByClass = new Map();
|
|
6298
|
-
const awaitingUpgrade = new Map();
|
|
6299
|
-
const pendingWhenDefinedCallbacks = new Map();
|
|
6300
|
-
const EMPTY_SET = new Set();
|
|
6301
|
-
function createDefinitionRecord(constructor) {
|
|
6302
|
-
var _a;
|
|
6303
|
-
const { connectedCallback, disconnectedCallback, formAssociatedCallback, formDisabledCallback, formResetCallback, formStateRestoreCallback, adoptedCallback, attributeChangedCallback, } = constructor.prototype;
|
|
6304
|
-
const formAssociated = Boolean(constructor.formAssociated);
|
|
6305
|
-
const observedAttributes = new Set((_a = constructor.observedAttributes) !== null && _a !== void 0 ? _a : []);
|
|
6306
|
-
return {
|
|
6307
|
-
UserCtor: constructor,
|
|
6308
|
-
PivotCtor: undefined,
|
|
6309
|
-
connectedCallback,
|
|
6310
|
-
disconnectedCallback,
|
|
6311
|
-
formAssociatedCallback,
|
|
6312
|
-
formDisabledCallback,
|
|
6313
|
-
formResetCallback,
|
|
6314
|
-
formStateRestoreCallback,
|
|
6315
|
-
adoptedCallback,
|
|
6316
|
-
attributeChangedCallback,
|
|
6317
|
-
observedAttributes,
|
|
6318
|
-
formAssociated,
|
|
6319
|
-
};
|
|
6320
|
-
}
|
|
6321
|
-
// Helper to create stand-in element for each tagName registered that delegates out to the registry for the given
|
|
6322
|
-
// element. Note that the `registeredDefinition` represents the constructor that was used to register during
|
|
6323
|
-
// `customElements.define()`. Whereas the `pivotDefinition` represents the constructor that is passed when the pivot
|
|
6324
|
-
// constructor is invoked with another constructor.
|
|
6325
|
-
function createPivotingClass(tagName, registeredDefinition) {
|
|
6326
|
-
class PivotCtor extends NativeHTMLElement {
|
|
6327
|
-
constructor(UserCtor) {
|
|
6328
|
-
// This constructor can only be invoked by:
|
|
6329
|
-
// a) the browser instantiating an element from parsing or via document.createElement.
|
|
6330
|
-
// b) LWC new PivotClass (This constructor is NOT observable/accessible in user-land).
|
|
6331
|
-
// b) new UserClass.
|
|
6332
|
-
// When LWC instantiates it, it will pass the upgrading definition as an argument
|
|
6333
|
-
// If the caller signals via UserCtor that this is in fact a controlled
|
|
6334
|
-
// definition, we use that one, otherwise fallback to the global
|
|
6335
|
-
// internal registry.
|
|
6336
|
-
super();
|
|
6337
|
-
const userCtorIsDefined = !isUndefined$1(UserCtor);
|
|
6338
|
-
if (userCtorIsDefined) {
|
|
6339
|
-
if (!isConstructor(UserCtor)) {
|
|
6340
|
-
throw new TypeError(`Failed to create custom element: the provided constructor is not a constructor.`);
|
|
6341
|
-
}
|
|
6342
|
-
if (!registeredUserCtors.has(UserCtor)) {
|
|
6343
|
-
throw new Error(`Failed to create custom element: the provided constructor is unregistered: ${UserCtor.name}.`);
|
|
6344
|
-
}
|
|
6345
|
-
}
|
|
6346
|
-
const definition = userCtorIsDefined
|
|
6347
|
-
? getOrCreateDefinitionForConstructor(UserCtor)
|
|
6348
|
-
: globalDefinitionsByTag.get(tagName);
|
|
6349
|
-
if (!isUndefined$1(definition)) {
|
|
6350
|
-
internalUpgrade(this, registeredDefinition, definition);
|
|
6351
|
-
}
|
|
6352
|
-
else {
|
|
6353
|
-
// This is the case in which there is no global definition, and
|
|
6354
|
-
// it is not handled by LWC (otherwise it will have a valid UserCtor)
|
|
6355
|
-
// so we need to add it to the pending queue just in case it eventually
|
|
6356
|
-
// gets defined in the global registry.
|
|
6357
|
-
pendingRegistryForElement.set(this, registeredDefinition);
|
|
6358
|
-
}
|
|
6359
|
-
}
|
|
6360
|
-
connectedCallback() {
|
|
6361
|
-
var _a;
|
|
6362
|
-
const definition = definitionForElement.get(this);
|
|
6363
|
-
if (!isUndefined$1(definition)) {
|
|
6364
|
-
// Delegate out to user callback
|
|
6365
|
-
(_a = definition.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6366
|
-
}
|
|
6367
|
-
else {
|
|
6368
|
-
// Register for upgrade when defined (only when connected, so we don't leak)
|
|
6369
|
-
let awaiting = awaitingUpgrade.get(tagName);
|
|
6370
|
-
if (isUndefined$1(awaiting)) {
|
|
6371
|
-
awaitingUpgrade.set(tagName, (awaiting = new Set()));
|
|
6372
|
-
}
|
|
6373
|
-
awaiting.add(this);
|
|
6374
|
-
}
|
|
6375
|
-
}
|
|
6376
|
-
disconnectedCallback() {
|
|
6377
|
-
var _a;
|
|
6378
|
-
const definition = definitionForElement.get(this);
|
|
6379
|
-
if (!isUndefined$1(definition)) {
|
|
6380
|
-
// Delegate out to user callback
|
|
6381
|
-
(_a = definition.disconnectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6382
|
-
}
|
|
6383
|
-
else {
|
|
6384
|
-
// Un-register for upgrade when defined (so we don't leak)
|
|
6385
|
-
const awaiting = awaitingUpgrade.get(tagName);
|
|
6386
|
-
// At this point, awaiting should never be undefined, because connectedCallback
|
|
6387
|
-
// must have been called before disconnectedCallback. But just to be safe, we check
|
|
6388
|
-
if (!isUndefined$1(awaiting)) {
|
|
6389
|
-
awaiting.delete(this);
|
|
6390
|
-
}
|
|
6391
|
-
}
|
|
6392
|
-
}
|
|
6393
|
-
formAssociatedCallback(form) {
|
|
6394
|
-
var _a;
|
|
6395
|
-
const definition = definitionForElement.get(this);
|
|
6396
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formAssociatedCallback) === null || _a === void 0 ? void 0 : _a.call(this, form);
|
|
6397
|
-
}
|
|
6398
|
-
formDisabledCallback(disabled) {
|
|
6399
|
-
var _a;
|
|
6400
|
-
const definition = definitionForElement.get(this);
|
|
6401
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formDisabledCallback) === null || _a === void 0 ? void 0 : _a.call(this, disabled);
|
|
6402
|
-
}
|
|
6403
|
-
formResetCallback() {
|
|
6404
|
-
var _a;
|
|
6405
|
-
const definition = definitionForElement.get(this);
|
|
6406
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formResetCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6407
|
-
}
|
|
6408
|
-
formStateRestoreCallback(state, mode) {
|
|
6409
|
-
var _a;
|
|
6410
|
-
const definition = definitionForElement.get(this);
|
|
6411
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.formStateRestoreCallback) === null || _a === void 0 ? void 0 : _a.call(this, state, mode);
|
|
6412
|
-
}
|
|
6413
|
-
adoptedCallback() {
|
|
6414
|
-
var _a;
|
|
6415
|
-
const definition = definitionForElement.get(this);
|
|
6416
|
-
(_a = definition === null || definition === void 0 ? void 0 : definition.adoptedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
6417
|
-
}
|
|
6418
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
6419
|
-
var _a;
|
|
6420
|
-
const definition = definitionForElement.get(this);
|
|
6421
|
-
// if both definitions are the same, then the observedAttributes is the same,
|
|
6422
|
-
// but if they are different, only if the runtime definition has the attribute
|
|
6423
|
-
// marked as observed, then it should invoke attributeChangedCallback.
|
|
6424
|
-
if (registeredDefinition === definition ||
|
|
6425
|
-
(definition === null || definition === void 0 ? void 0 : definition.observedAttributes.has(name))) {
|
|
6426
|
-
(_a = definition.attributeChangedCallback) === null || _a === void 0 ? void 0 : _a.apply(this, [name, oldValue, newValue]);
|
|
6427
|
-
}
|
|
6428
|
-
}
|
|
6429
|
-
}
|
|
6430
|
-
PivotCtor.observedAttributes = [...registeredDefinition.observedAttributes];
|
|
6431
|
-
// TODO [#3000]: support case where registeredDefinition is not form-associated, but later definition is.
|
|
6432
|
-
PivotCtor.formAssociated = registeredDefinition.formAssociated;
|
|
6433
|
-
registeredPivotCtors.add(PivotCtor);
|
|
6434
|
-
return PivotCtor;
|
|
6435
|
-
}
|
|
6436
|
-
function getNewObservedAttributes(registeredDefinition, pivotDefinition) {
|
|
6437
|
-
const { observedAttributes, attributeChangedCallback } = pivotDefinition;
|
|
6438
|
-
if (observedAttributes.size === 0 || isUndefined$1(attributeChangedCallback)) {
|
|
6439
|
-
// This instance does not need to observe any attributes, no need to patch
|
|
6440
|
-
return EMPTY_SET;
|
|
6441
|
-
}
|
|
6442
|
-
// Natively, the attributes observed by the registered definition are going to be taken
|
|
6443
|
-
// care of by the browser, only the difference between the two sets has to be taken
|
|
6444
|
-
// care by the patched version.
|
|
6445
|
-
return new Set([...pivotDefinition.observedAttributes].filter((x) => !registeredDefinition.observedAttributes.has(x)));
|
|
6446
|
-
}
|
|
6447
|
-
function throwAsyncError(error) {
|
|
6448
|
-
// Per native custom element behavior, errors thrown in attributeChangedCallback
|
|
6449
|
-
// become unhandled async errors. We use setTimeout() instead of Promise.resolve()
|
|
6450
|
-
// to make it an unhandled error rather than an unhandled rejection.
|
|
6451
|
-
setTimeout(() => {
|
|
6452
|
-
throw error;
|
|
6453
|
-
});
|
|
6454
|
-
}
|
|
6455
|
-
// Helper to patch `setAttribute`/`getAttribute` to implement `attributeChangedCallback`.
|
|
6456
|
-
// Why is this necessary? Well basically, you can't change the `observedAttributes` after
|
|
6457
|
-
// a custom element is defined. So with pivots, if two classes share the same tag name,
|
|
6458
|
-
// and the second class observes attributes that aren't observed by the first one,
|
|
6459
|
-
// then those attributes can never be observed by the native `observedAttributes` system.
|
|
6460
|
-
// So we have to simulate it by patching `getAttribute`/`removeAttribute`. Note that
|
|
6461
|
-
// we only do this when absolutely necessary, though; i.e. because we've determined
|
|
6462
|
-
// that we aren't observing the attributes we need to.
|
|
6463
|
-
function patchAttributes(instance, registeredDefinition, pivotDefinition) {
|
|
6464
|
-
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
6465
|
-
if (newObservedAttributes.size === 0) {
|
|
6466
|
-
return;
|
|
6467
|
-
}
|
|
6468
|
-
const { attributeChangedCallback } = pivotDefinition;
|
|
6469
|
-
// Patch the instance.
|
|
6470
|
-
// Note we use the native `getAttribute` rather than the super's `getAttribute` because
|
|
6471
|
-
// we don't actually want it to be observable that we're calling `getAttribute` from
|
|
6472
|
-
// `setAttribute` and `removeAttribute`.
|
|
6473
|
-
// TODO [#2994]: this should handle reflected properties such as `ariaLabel` and `role`.
|
|
6474
|
-
defineProperties(instance, {
|
|
6475
|
-
setAttribute: {
|
|
6476
|
-
value: function setAttribute(name, value) {
|
|
6477
|
-
if (newObservedAttributes.has(name)) {
|
|
6478
|
-
const old = nativeGetAttribute.call(this, name);
|
|
6479
|
-
nativeSetAttribute.call(this, name, value);
|
|
6480
|
-
try {
|
|
6481
|
-
attributeChangedCallback.call(this, name, old, value + '');
|
|
6482
|
-
}
|
|
6483
|
-
catch (error) {
|
|
6484
|
-
throwAsyncError(error);
|
|
6485
|
-
}
|
|
6486
|
-
}
|
|
6487
|
-
else {
|
|
6488
|
-
nativeSetAttribute.call(this, name, value);
|
|
6489
|
-
}
|
|
6490
|
-
},
|
|
6491
|
-
writable: true,
|
|
6492
|
-
enumerable: true,
|
|
6493
|
-
configurable: true,
|
|
6494
|
-
},
|
|
6495
|
-
removeAttribute: {
|
|
6496
|
-
value: function removeAttribute(name) {
|
|
6497
|
-
if (newObservedAttributes.has(name)) {
|
|
6498
|
-
const old = nativeGetAttribute.call(this, name);
|
|
6499
|
-
nativeRemoveAttribute.call(this, name);
|
|
6500
|
-
try {
|
|
6501
|
-
attributeChangedCallback.call(this, name, old, null);
|
|
6502
|
-
}
|
|
6503
|
-
catch (error) {
|
|
6504
|
-
throwAsyncError(error);
|
|
6505
|
-
}
|
|
6506
|
-
}
|
|
6507
|
-
else {
|
|
6508
|
-
nativeRemoveAttribute.call(this, name);
|
|
6509
|
-
}
|
|
6510
|
-
},
|
|
6511
|
-
writable: true,
|
|
6512
|
-
enumerable: true,
|
|
6513
|
-
configurable: true,
|
|
6514
|
-
},
|
|
6515
|
-
});
|
|
6516
|
-
}
|
|
6517
|
-
function patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
6518
|
-
// The below case patches observed attributes for the case where the HTML element is upgraded
|
|
6519
|
-
// from a pre-existing one in the DOM.
|
|
6520
|
-
const newObservedAttributes = getNewObservedAttributes(registeredDefinition, pivotDefinition);
|
|
6521
|
-
if (getNewObservedAttributes(registeredDefinition, pivotDefinition).size === 0) {
|
|
6522
|
-
return;
|
|
6523
|
-
}
|
|
6524
|
-
const { attributeChangedCallback } = pivotDefinition;
|
|
6525
|
-
// Approximate observedAttributes from the user class, but only for the new observed attributes
|
|
6526
|
-
newObservedAttributes.forEach((name) => {
|
|
6527
|
-
if (nativeHasAttribute.call(instance, name)) {
|
|
6528
|
-
const newValue = nativeGetAttribute.call(instance, name);
|
|
6529
|
-
attributeChangedCallback.call(instance, name, null, newValue);
|
|
6530
|
-
}
|
|
6531
|
-
});
|
|
6532
|
-
}
|
|
6533
|
-
// User extends this HTMLElement, which returns the CE being upgraded
|
|
6534
|
-
let upgradingInstance;
|
|
6535
|
-
// Helper to upgrade an instance with a CE definition using "constructor call trick"
|
|
6536
|
-
function internalUpgrade(instance, registeredDefinition, pivotDefinition) {
|
|
6537
|
-
setPrototypeOf(instance, pivotDefinition.UserCtor.prototype);
|
|
6538
|
-
definitionForElement.set(instance, pivotDefinition);
|
|
6539
|
-
// attributes patches when needed
|
|
6540
|
-
if (pivotDefinition !== registeredDefinition) {
|
|
6541
|
-
patchAttributes(instance, registeredDefinition, pivotDefinition);
|
|
6542
|
-
}
|
|
6543
|
-
// Tricking the construction path to believe that a new instance is being created,
|
|
6544
|
-
// that way it will execute the super initialization mechanism but the HTMLElement
|
|
6545
|
-
// constructor will reuse the instance by returning the upgradingInstance.
|
|
6546
|
-
// This is by far the most important piece of the puzzle
|
|
6547
|
-
upgradingInstance = instance;
|
|
6548
|
-
// By `new`ing the UserCtor, we now jump to the constructor for the overridden global HTMLElement
|
|
6549
|
-
// The reason this happens is that the UserCtor extends HTMLElement, so it calls the `super()`.
|
|
6550
|
-
// Note that `upgradingInstance` is explicitly handled in the HTMLElement constructor.
|
|
6551
|
-
new pivotDefinition.UserCtor();
|
|
6552
|
-
patchAttributesDuringUpgrade(instance, registeredDefinition, pivotDefinition);
|
|
6553
|
-
}
|
|
6554
|
-
function isConstructor(constructor) {
|
|
6555
|
-
return isFunction$1(constructor) && isObject(constructor.prototype);
|
|
6556
|
-
}
|
|
6557
|
-
function getOrCreateDefinitionForConstructor(constructor) {
|
|
6558
|
-
if (!isConstructor(constructor)) {
|
|
6559
|
-
throw new TypeError('The referenced constructor is not a constructor.');
|
|
6560
|
-
}
|
|
6561
|
-
const definition = definitionForConstructor.get(constructor);
|
|
6562
|
-
if (!isUndefined$1(definition)) {
|
|
6563
|
-
return definition;
|
|
6564
|
-
}
|
|
6565
|
-
return createDefinitionRecord(constructor);
|
|
6566
|
-
}
|
|
6567
|
-
// Defer a `whenDefined()` callback until an externally-visible custom element is defined
|
|
6568
|
-
function createPendingWhenDefinedCallback(tagName) {
|
|
6569
|
-
return new Promise((resolve) => {
|
|
6570
|
-
let resolvers = pendingWhenDefinedCallbacks.get(tagName);
|
|
6571
|
-
if (isUndefined$1(resolvers)) {
|
|
6572
|
-
resolvers = [];
|
|
6573
|
-
pendingWhenDefinedCallbacks.set(tagName, resolvers);
|
|
6574
|
-
}
|
|
6575
|
-
resolvers.push(resolve);
|
|
6576
|
-
});
|
|
6577
|
-
}
|
|
6578
|
-
// Call any pending `whenDefined()` callbacks
|
|
6579
|
-
function flushPendingWhenDefinedCallbacks(tagName, ctor) {
|
|
6580
|
-
const resolvers = pendingWhenDefinedCallbacks.get(tagName);
|
|
6581
|
-
if (!isUndefined$1(resolvers)) {
|
|
6582
|
-
for (const resolver of resolvers) {
|
|
6583
|
-
resolver(ctor);
|
|
6584
|
-
}
|
|
6585
|
-
}
|
|
6586
|
-
pendingWhenDefinedCallbacks.delete(tagName);
|
|
6587
|
-
}
|
|
6588
|
-
const { customElements: nativeRegistry } = window;
|
|
6589
|
-
const { define: nativeDefine, whenDefined: nativeWhenDefined, get: nativeGet } = nativeRegistry;
|
|
6590
|
-
// patch for the global registry define mechanism
|
|
6591
|
-
CustomElementRegistry.prototype.define = function define(tagName, constructor, options) {
|
|
6592
|
-
if (options && options.extends) {
|
|
6593
|
-
// TODO [#2983]: should we support `extends`?
|
|
6594
|
-
throw new DOMException('NotSupportedError: "extends" key in customElements.define() options is not supported.');
|
|
6595
|
-
}
|
|
6596
|
-
if (globalDefinitionsByTag.has(tagName)) {
|
|
6597
|
-
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`);
|
|
6598
|
-
}
|
|
6599
|
-
if (!isUndefined$1(globalDefinitionsByClass.get(constructor))) {
|
|
6600
|
-
throw new DOMException(`Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`);
|
|
6601
|
-
}
|
|
6602
|
-
const definition = getOrCreateDefinitionForConstructor(constructor);
|
|
6603
|
-
registeredUserCtors.add(constructor);
|
|
6604
|
-
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
6605
|
-
if (isUndefined$1(PivotCtor)) {
|
|
6606
|
-
PivotCtor = createPivotingClass(tagName, definition);
|
|
6607
|
-
// Register a pivoting class which will handle global registry initializations
|
|
6608
|
-
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
6609
|
-
}
|
|
6610
|
-
// Only cache after nativeDefine has been called, because if it throws an error
|
|
6611
|
-
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
6612
|
-
definitionForConstructor.set(constructor, definition);
|
|
6613
|
-
pivotCtorByTag.set(tagName, PivotCtor);
|
|
6614
|
-
globalDefinitionsByTag.set(tagName, definition);
|
|
6615
|
-
globalDefinitionsByClass.set(constructor, definition);
|
|
6616
|
-
// For globally defined custom elements, the definition associated
|
|
6617
|
-
// to the UserCtor has a back-pointer to PivotCtor in case the user
|
|
6618
|
-
// new the UserCtor, so we know how to create the underlying element.
|
|
6619
|
-
definition.PivotCtor = PivotCtor;
|
|
6620
|
-
// Upgrade any elements created in this scope before customElements.define
|
|
6621
|
-
// was called, which should be exhibited by the following steps:
|
|
6622
|
-
// 1) LWC registers a tagName for an LWC component.
|
|
6623
|
-
// 2) Element with same tagName is created with document.createElement()
|
|
6624
|
-
// and inserted into DOM.
|
|
6625
|
-
// 3) customElements.define() is called with tagName and non-LWC constructor.
|
|
6626
|
-
// This requires immediate upgrade when the new global tagName is defined.
|
|
6627
|
-
const awaiting = awaitingUpgrade.get(tagName);
|
|
6628
|
-
if (!isUndefined$1(awaiting)) {
|
|
6629
|
-
awaitingUpgrade.delete(tagName);
|
|
6630
|
-
for (const element of awaiting) {
|
|
6631
|
-
const registeredDefinition = pendingRegistryForElement.get(element);
|
|
6632
|
-
// At this point, registeredDefinition should never be undefined because awaitingUpgrade
|
|
6633
|
-
// is only populated when we haven't run internalUpgrade yet, and we only populate
|
|
6634
|
-
// pendingRegistryForElement when internalUpgrade hasn't run yet.
|
|
6635
|
-
// But just to be safe, we check.
|
|
6636
|
-
if (!isUndefined$1(registeredDefinition)) {
|
|
6637
|
-
pendingRegistryForElement.delete(element);
|
|
6638
|
-
internalUpgrade(element, registeredDefinition, definition);
|
|
6639
|
-
}
|
|
6640
|
-
}
|
|
6641
|
-
}
|
|
6642
|
-
// If anyone called customElements.whenDefined() and is still waiting for a promise resolution, resolve now
|
|
6643
|
-
flushPendingWhenDefinedCallbacks(tagName, constructor);
|
|
6644
|
-
};
|
|
6645
|
-
CustomElementRegistry.prototype.get = function get(tagName) {
|
|
6646
|
-
const NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
6647
|
-
if (!isUndefined$1(NativeCtor)) {
|
|
6648
|
-
const definition = globalDefinitionsByTag.get(tagName);
|
|
6649
|
-
if (!isUndefined$1(definition)) {
|
|
6650
|
-
return definition.UserCtor; // defined by the patched custom elements registry
|
|
6651
|
-
}
|
|
6652
|
-
if (registeredPivotCtors.has(NativeCtor)) {
|
|
6653
|
-
return undefined; // pivot constructors should not be observable, return undefined
|
|
6654
|
-
}
|
|
6655
|
-
return NativeCtor; // constructor that existed before patching
|
|
6656
|
-
}
|
|
6657
|
-
};
|
|
6658
|
-
CustomElementRegistry.prototype.whenDefined = function whenDefined(tagName) {
|
|
6659
|
-
return nativeWhenDefined.call(nativeRegistry, tagName).then((NativeCtor) => {
|
|
6660
|
-
const definition = globalDefinitionsByTag.get(tagName);
|
|
6661
|
-
if (!isUndefined$1(definition)) {
|
|
6662
|
-
return definition.UserCtor;
|
|
6663
|
-
}
|
|
6664
|
-
// In this case, the custom element must have been defined before the registry patches
|
|
6665
|
-
// were applied. So return the non-pivot constructor
|
|
6666
|
-
if (isUndefined$1(NativeCtor)) {
|
|
6667
|
-
// Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1335247
|
|
6668
|
-
// We can patch the correct behavior using customElements.get()
|
|
6669
|
-
NativeCtor = nativeGet.call(nativeRegistry, tagName);
|
|
6670
|
-
}
|
|
6671
|
-
if (registeredPivotCtors.has(NativeCtor)) {
|
|
6672
|
-
// Pivot constructors should not be observable. Wait to resolve the promise
|
|
6673
|
-
// if a constructor is ever defined in userland
|
|
6674
|
-
return createPendingWhenDefinedCallback(tagName);
|
|
6675
|
-
}
|
|
6676
|
-
return NativeCtor;
|
|
6677
|
-
});
|
|
6678
|
-
};
|
|
6679
|
-
// This constructor is invoked when we call `new pivotDefinition.UserCtor()`
|
|
6680
|
-
// @ts-ignore
|
|
6681
|
-
window.HTMLElement = function HTMLElement() {
|
|
6682
|
-
// Upgrading case: the pivoting class constructor was run by the browser's
|
|
6683
|
-
// native custom elements and we're in the process of running the
|
|
6684
|
-
// "constructor-call trick" on the natively constructed instance, so just
|
|
6685
|
-
// return that here.
|
|
6686
|
-
// This code path is also called when LWC `new`s a PivotCtor.
|
|
6687
|
-
const instance = upgradingInstance;
|
|
6688
|
-
if (!isUndefined$1(instance)) {
|
|
6689
|
-
upgradingInstance = undefined;
|
|
6690
|
-
return instance;
|
|
6691
|
-
}
|
|
6692
|
-
// Construction case: we need to construct the pivoting instance and return it.
|
|
6693
|
-
// This is possible when the user register it via global registry and instantiate
|
|
6694
|
-
// it via `new Ctor()`.
|
|
6695
|
-
const { constructor } = this;
|
|
6696
|
-
const definition = globalDefinitionsByClass.get(constructor);
|
|
6697
|
-
if (isUndefined$1(definition) || isUndefined$1(definition.PivotCtor)) {
|
|
6698
|
-
// This code path is hit if someone `new`s a class that extends `HTMLElement` without
|
|
6699
|
-
// doing `customElements.define()` first. This matches native browser behavior:
|
|
6700
|
-
// https://stackoverflow.com/a/61883392
|
|
6701
|
-
throw new TypeError('Illegal constructor');
|
|
6702
|
-
}
|
|
6703
|
-
// This constructor is ONLY invoked when it is the user instantiating
|
|
6704
|
-
// an element via new Ctor while Ctor is a registered global constructor.
|
|
6705
|
-
const { PivotCtor, UserCtor } = definition;
|
|
6706
|
-
return new PivotCtor(UserCtor);
|
|
6707
|
-
};
|
|
6708
|
-
HTMLElement.prototype = NativeHTMLElement.prototype;
|
|
6709
|
-
/**
|
|
6710
|
-
* Create a new PivotConstructor for the given tagName, which is capable of being constructed
|
|
6711
|
-
* with a UserConstructor defining the behavior. Passing in the UserConstructor here
|
|
6712
|
-
* is a hint that can be used when registering a custom element with the global custom elements
|
|
6713
|
-
* registry for the first time, which provides certain optimizations. It also marks the UserConstructor
|
|
6714
|
-
* as "safe" to be used when passed in to a PivotConstructor.
|
|
6715
|
-
*
|
|
6716
|
-
* @param tagName - element tag name
|
|
6717
|
-
* @param UserCtor - userland custom element constructor
|
|
6718
|
-
* @returns a new custom element constructor
|
|
6719
|
-
*/
|
|
6720
|
-
return function createPivotConstructor(tagName, UserCtor) {
|
|
6721
|
-
tagName = StringToLowerCase.call(tagName);
|
|
6722
|
-
let PivotCtor = pivotCtorByTag.get(tagName);
|
|
6723
|
-
if (isUndefined$1(PivotCtor)) {
|
|
6724
|
-
const definition = getOrCreateDefinitionForConstructor(UserCtor);
|
|
6725
|
-
PivotCtor = createPivotingClass(tagName, definition);
|
|
6726
|
-
// Register a pivoting class as a global custom element
|
|
6727
|
-
nativeDefine.call(nativeRegistry, tagName, PivotCtor);
|
|
6728
|
-
definition.PivotCtor = PivotCtor;
|
|
6729
|
-
// Only cache after nativeDefine has been called, because if it throws an error
|
|
6730
|
-
// (e.g. for an invalid tag name), then we don't want to cache anything.
|
|
6731
|
-
definitionForConstructor.set(UserCtor, definition);
|
|
6732
|
-
pivotCtorByTag.set(tagName, PivotCtor);
|
|
6733
|
-
}
|
|
6734
|
-
// Register a UserConstructor as "safe" to be used within a PivotConstructor
|
|
6735
|
-
registeredUserCtors.add(UserCtor);
|
|
6736
|
-
return PivotCtor;
|
|
6737
|
-
};
|
|
6738
|
-
}
|
|
6739
|
-
|
|
6740
|
-
/*
|
|
6741
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
6742
|
-
* All rights reserved.
|
|
6743
|
-
* SPDX-License-Identifier: MIT
|
|
6744
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6745
|
-
*/
|
|
6746
|
-
let createScopedConstructor;
|
|
6747
|
-
let CachedHTMLElement;
|
|
6748
|
-
// We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
6749
|
-
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
6750
|
-
// or we're in a legacy browser.
|
|
6751
|
-
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
6752
|
-
if (hasCustomElements) {
|
|
6753
|
-
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
6754
|
-
// It's assumed that ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is set *before* LWC loads, and never changes.
|
|
6755
|
-
//
|
|
6756
|
-
// Why not lazily patch in `createCustomElement`? Well, this could lead to subtle bugs, e.g.:
|
|
6757
|
-
//
|
|
6758
|
-
// 1. LWC loads
|
|
6759
|
-
// 2. `const Ctor = class extends HTMLElement {}`
|
|
6760
|
-
// 3. `lwc.createElement(...)` // here we lazily patch
|
|
6761
|
-
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
6762
|
-
//
|
|
6763
|
-
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
6764
|
-
createScopedConstructor = createScopedRegistry();
|
|
6765
|
-
// It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
6766
|
-
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
6767
|
-
// because the HTMLElement prototypes are mixed up.
|
|
6768
|
-
//
|
|
6769
|
-
// The reason this happens is that the scoping implementation overwrites window.HTMLElement and expects to work
|
|
6770
|
-
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
6771
|
-
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
6772
|
-
// Caching avoids this problem.
|
|
6773
|
-
CachedHTMLElement = window.HTMLElement;
|
|
6774
|
-
}
|
|
6775
|
-
}
|
|
6776
|
-
// Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
6777
|
-
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
6778
|
-
// multiple times per tag name.
|
|
6779
|
-
const createUserConstructor = (HTMLElementToExtend, upgradeCallback, connectedCallback, disconnectedCallback) => {
|
|
6780
|
-
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
6781
|
-
return class UserConstructor extends HTMLElementToExtend {
|
|
6782
|
-
constructor() {
|
|
6783
|
-
super();
|
|
6784
|
-
upgradeCallback(this);
|
|
6785
|
-
}
|
|
6786
|
-
// Note that there is no need to do the "avoid defining connectedCallback/disconnectedCallback" optimization
|
|
6787
|
-
// here, because in create-scoped-registry.ts, the registered class will always have these callbacks anyway.
|
|
6788
|
-
// See: https://github.com/salesforce/lwc/pull/3162#issuecomment-1311851174
|
|
6789
|
-
connectedCallback() {
|
|
6790
|
-
if (!isUndefined$1(connectedCallback)) {
|
|
6791
|
-
connectedCallback(this);
|
|
6792
|
-
}
|
|
6793
|
-
}
|
|
6794
|
-
disconnectedCallback() {
|
|
6795
|
-
if (!isUndefined$1(disconnectedCallback)) {
|
|
6796
|
-
disconnectedCallback(this);
|
|
6797
|
-
}
|
|
6798
|
-
}
|
|
6799
|
-
};
|
|
6800
|
-
};
|
|
6801
|
-
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
6802
|
-
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
6803
|
-
// This error should be impossible to hit
|
|
6804
|
-
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
6805
|
-
}
|
|
6806
|
-
const UserConstructor = createUserConstructor(CachedHTMLElement, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
6807
|
-
const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
6808
|
-
return new ScopedConstructor(UserConstructor);
|
|
6809
|
-
}
|
|
6810
|
-
|
|
6811
6268
|
/*
|
|
6812
6269
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6813
6270
|
* All rights reserved.
|
|
@@ -6815,29 +6272,22 @@ var LWC = (function (exports) {
|
|
|
6815
6272
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6816
6273
|
*/
|
|
6817
6274
|
/**
|
|
6818
|
-
* We have
|
|
6275
|
+
* We have two modes for creating custom elements:
|
|
6819
6276
|
*
|
|
6820
6277
|
* 1. Compat (legacy) browser support (e.g. IE11). Totally custom, doesn't rely on native browser APIs.
|
|
6821
6278
|
* 2. "Upgradable constructor" custom element. This allows us to have two LWC components with the same tag name,
|
|
6822
6279
|
* via a trick: every custom element constructor we define in the registry is basically the same. It's essentially
|
|
6823
6280
|
* a dummy `class extends HTMLElement` that accepts an `upgradeCallback` in its constructor ("upgradable
|
|
6824
6281
|
* constructor"), which allows us to have completely customized functionality for different components.
|
|
6825
|
-
* 3. "Scoped" (or "pivot") custom elements. This relies on a sophisticated system that emulates the "scoped custom
|
|
6826
|
-
* elements registry" proposal, with support for avoiding conflicts in tag names both between LWC components and
|
|
6827
|
-
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
6828
|
-
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
6829
6282
|
*/
|
|
6830
6283
|
let createCustomElement;
|
|
6831
6284
|
if (hasCustomElements) {
|
|
6832
|
-
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
6833
|
-
createCustomElement = createCustomElementScoped;
|
|
6834
|
-
} else {
|
|
6835
6285
|
// use the global registry, with an upgradable constructor for the defined custom element
|
|
6836
6286
|
createCustomElement = createCustomElementUsingUpgradableConstructor;
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6287
|
+
}
|
|
6288
|
+
else {
|
|
6289
|
+
// no registry available here
|
|
6290
|
+
createCustomElement = createCustomElementCompat;
|
|
6841
6291
|
}
|
|
6842
6292
|
|
|
6843
6293
|
/*
|
|
@@ -6900,7 +6350,7 @@ var LWC = (function (exports) {
|
|
|
6900
6350
|
function isNull(obj) {
|
|
6901
6351
|
return obj === null;
|
|
6902
6352
|
}
|
|
6903
|
-
/** version: 2.
|
|
6353
|
+
/** version: 2.37.0 */
|
|
6904
6354
|
|
|
6905
6355
|
/*
|
|
6906
6356
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7453,7 +6903,7 @@ var LWC = (function (exports) {
|
|
|
7453
6903
|
});
|
|
7454
6904
|
freeze(LightningElement);
|
|
7455
6905
|
seal(LightningElement.prototype);
|
|
7456
|
-
/* version: 2.
|
|
6906
|
+
/* version: 2.37.0 */
|
|
7457
6907
|
|
|
7458
6908
|
exports.LightningElement = LightningElement;
|
|
7459
6909
|
exports.__unstable__ProfilerControl = profilerControl;
|