Skip to content

Commit ed40991

Browse files
fix: gate naming
1 parent b078f6a commit ed40991

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

packages/@lwc/engine-core/src/framework/invoker.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ export function invokeComponentConstructor(vm: VM, Ctor: LightningElementConstru
5858
// When Locker is enabled, the "instanceof" operator would not work since Locker Service
5959
// provides its own implementation of LightningElement, so we indirectly check
6060
// if the base constructor is invoked by accessing the component on the vm.
61-
// When the DISABLE_LIGHTNING_CONSTRUCTOR_CHECK gate is true and LEGACY_LOCKER_ENABLED is false,
61+
// When the ENABLE_LOCKER_VALIDATION gate is true and LEGACY_LOCKER_ENABLED is false,
6262
// then the instanceof LightningElement can be used.
6363
const useLegacyConstructorCheck =
64-
lwcRuntimeFlags.DISABLE_LIGHTNING_CONSTRUCTOR_CHECK ||
65-
lwcRuntimeFlags.LEGACY_LOCKER_ENABLED;
64+
lwcRuntimeFlags.ENABLE_LEGACY_VALIDATION || lwcRuntimeFlags.LEGACY_LOCKER_ENABLED;
6665

6766
const isInvalidConstructor = useLegacyConstructorCheck
6867
? vmBeingConstructed.component !== result

packages/@lwc/features/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const features: FeatureFlagMap = {
2222
DISABLE_SYNTHETIC_SHADOW: null,
2323
DISABLE_SCOPE_TOKEN_VALIDATION: null,
2424
LEGACY_LOCKER_ENABLED: null,
25-
DISABLE_LIGHTNING_CONSTRUCTOR_CHECK: null,
25+
ENABLE_LEGACY_VALIDATION: null,
2626
};
2727

2828
if (!(globalThis as any).lwcRuntimeFlags) {

packages/@lwc/features/src/types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ export interface FeatureFlagMap {
8888
LEGACY_LOCKER_ENABLED: FeatureFlagValue;
8989

9090
/**
91-
* If true, then the legacy constructor check is only used if
92-
* LEGACY_LOCKER_ENABLED is true.
91+
* A manual override for `LEGACY_LOCKER_ENABLED`; should not be used if that flag is correctly set.
92+
* If true, behave as if legacy Locker is enabled.
93+
* If false or unset, then the value of the `LEGACY_LOCKER_ENABLED` flag is used.
9394
*/
94-
DISABLE_LIGHTNING_CONSTRUCTOR_CHECK: FeatureFlagValue;
95+
ENABLE_LEGACY_VALIDATION: FeatureFlagValue;
9596
}
9697

9798
export type FeatureFlagName = keyof FeatureFlagMap;

packages/@lwc/integration-karma/test/component/LightningElement/index.spec.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ it("[W-6981076] shouldn't throw when a component with an invalid child in unmoun
8181
expect(() => document.body.removeChild(elm)).not.toThrow();
8282
});
8383

84-
it('should fail when the constructor returns something other than LightningElement when DISABLE_LIGHTNING_CONSTRUCTOR_CHECK is true', () => {
84+
it('should fail when the constructor returns something other than LightningElement when ENABLE_LEGACY_VALIDATION is falsy and LEGACY_LOCKER_ENABLED is falsy', () => {
8585
expect(() => {
8686
createElement('x-returning-bad', { is: ReturningBad });
8787
}).toThrowError(
@@ -90,10 +90,20 @@ it('should fail when the constructor returns something other than LightningEleme
9090
);
9191
});
9292

93-
it('should succeed when the constructor returns something other than LightningElement when DISABLE_LIGHTNING_CONSTRUCTOR_CHECK is falsy', () => {
94-
setFeatureFlagForTest('DISABLE_LIGHTNING_CONSTRUCTOR_CHECK', true);
93+
it('should succeed when the constructor returns something other than LightningElement when ENABLE_LEGACY_VALIDATION is true', () => {
94+
setFeatureFlagForTest('ENABLE_LEGACY_VALIDATION', true);
9595
expect(() => {
9696
createElement('x-returning-bad', { is: ReturningBad });
9797
}).not.toThrow();
98-
setFeatureFlagForTest('DISABLE_LIGHTNING_CONSTRUCTOR_CHECK', false);
98+
setFeatureFlagForTest('ENABLE_LEGACY_VALIDATION', false);
99+
});
100+
101+
it('should succeed when the constructor returns something other than LightningElement when ENABLE_LEGACY_VALIDATION is false and LEGACY_LOCKER_ENABLED is true', () => {
102+
setFeatureFlagForTest('ENABLE_LEGACY_VALIDATION', false);
103+
setFeatureFlagForTest('LEGACY_LOCKER_ENABLED', true);
104+
expect(() => {
105+
createElement('x-returning-bad', { is: ReturningBad });
106+
}).not.toThrow();
107+
setFeatureFlagForTest('ENABLE_LEGACY_VALIDATION', false);
108+
setFeatureFlagForTest('LEGACY_LOCKER_ENABLED', false);
99109
});

0 commit comments

Comments
 (0)