diff --git a/packages/@lwc/engine-core/src/framework/invoker.ts b/packages/@lwc/engine-core/src/framework/invoker.ts index 8ebe2ccd86..fb9ff62f07 100644 --- a/packages/@lwc/engine-core/src/framework/invoker.ts +++ b/packages/@lwc/engine-core/src/framework/invoker.ts @@ -11,7 +11,7 @@ import { addErrorComponentStack } from '../shared/error'; import { evaluateTemplate, setVMBeingRendered, getVMBeingRendered } from './template'; import { runWithBoundaryProtection } from './vm'; import { logOperationStart, logOperationEnd, OperationId } from './profiler'; -import { LightningElement } from './base-lightning-element'; +import type { LightningElement } from './base-lightning-element'; import type { Template } from './template'; import type { VM } from './vm'; import type { LightningElementConstructor } from './base-lightning-element'; @@ -58,9 +58,11 @@ export function invokeComponentConstructor(vm: VM, Ctor: LightningElementConstru // the "instanceof" operator would not work here since Locker Service provides its own // implementation of LightningElement, so we indirectly check if the base constructor is // invoked by accessing the component on the vm. - const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED - ? vmBeingConstructed.component !== result - : !(result instanceof LightningElement); + // TODO [W-17769475]: Restore this fix when we can reliably detect Locker enabled + // const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED + // ? vmBeingConstructed.component !== result + // : !(result instanceof LightningElement); + const isInvalidConstructor = vmBeingConstructed.component !== result; if (isInvalidConstructor) { throw new TypeError( diff --git a/packages/@lwc/integration-karma/test/component/LightningElement/index.spec.js b/packages/@lwc/integration-karma/test/component/LightningElement/index.spec.js index 7f396c86bd..cb70382a38 100644 --- a/packages/@lwc/integration-karma/test/component/LightningElement/index.spec.js +++ b/packages/@lwc/integration-karma/test/component/LightningElement/index.spec.js @@ -81,7 +81,8 @@ it("[W-6981076] shouldn't throw when a component with an invalid child in unmoun expect(() => document.body.removeChild(elm)).not.toThrow(); }); -it('should fail when the constructor returns something other than an instance of itself', () => { +// TODO [W-17769475]: Restore this test when we can reliably detect Locker enabled +xit('should fail when the constructor returns something other than an instance of itself', () => { expect(() => { createElement('x-returning-bad', { is: ReturningBad }); }).toThrowError(