@lwc/engine-core 8.17.0 → 8.18.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.
@@ -1,4 +1,4 @@
1
- import type { LightningElement } from './base-lightning-element';
1
+ import { LightningElement } from './base-lightning-element';
2
2
  import type { VM } from './vm';
3
3
  import type { LightningElementConstructor } from './base-lightning-element';
4
4
  import type { VNodes } from './vnodes';
package/dist/index.cjs.js CHANGED
@@ -896,8 +896,11 @@ function logMissingPortalWarn(name, type) {
896
896
  function patchElementWithRestrictions(elm, options) {
897
897
  assertNotProd(); // this method should never leak to prod
898
898
  const originalOuterHTMLDescriptor = shared.getPropertyDescriptor(elm, 'outerHTML');
899
- const descriptors = {
900
- outerHTML: generateAccessorDescriptor({
899
+ const descriptors = {};
900
+ // For consistency between dev/prod modes, only patch `outerHTML` if it exists
901
+ // (i.e. patch it in engine-dom, not in engine-server)
902
+ if (originalOuterHTMLDescriptor) {
903
+ descriptors.outerHTML = generateAccessorDescriptor({
901
904
  get() {
902
905
  return originalOuterHTMLDescriptor.get.call(this);
903
906
  },
@@ -905,8 +908,8 @@ function patchElementWithRestrictions(elm, options) {
905
908
  logError(`Invalid attempt to set outerHTML on Element.`);
906
909
  return originalOuterHTMLDescriptor.set.call(this, value);
907
910
  },
908
- }),
909
- };
911
+ });
912
+ }
910
913
  // Apply extra restriction related to DOM manipulation if the element is not a portal.
911
914
  if (!options.isLight && options.isSynthetic && !options.isPortal) {
912
915
  const { appendChild, insertBefore, removeChild, replaceChild } = elm;
@@ -2736,7 +2739,7 @@ function registerDecorators(Ctor, meta) {
2736
2739
  validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
2737
2740
  }
2738
2741
  if (shared.isUndefined(descriptor)) {
2739
- throw new Error();
2742
+ throw new Error(`Missing descriptor for wired method "${fieldOrMethodName}".`);
2740
2743
  }
2741
2744
  wiredMethods[fieldOrMethodName] = descriptor;
2742
2745
  storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
@@ -6508,15 +6511,16 @@ function invokeComponentConstructor(vm, Ctor) {
6508
6511
  try {
6509
6512
  // job
6510
6513
  const result = new Ctor();
6511
- // Check indirectly if the constructor result is an instance of LightningElement. Using
6512
- // the "instanceof" operator would not work here since Locker Service provides its own
6513
- // implementation of LightningElement, so we indirectly check if the base constructor is
6514
- // invoked by accessing the component on the vm.
6515
- // TODO [W-17769475]: Restore this fix when we can reliably detect Locker enabled
6516
- // const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
6517
- // ? vmBeingConstructed.component !== result
6518
- // : !(result instanceof LightningElement);
6519
- const isInvalidConstructor = vmBeingConstructed.component !== result;
6514
+ // Check indirectly if the constructor result is an instance of LightningElement.
6515
+ // When Locker is enabled, the "instanceof" operator would not work since Locker Service
6516
+ // provides its own implementation of LightningElement, so we indirectly check
6517
+ // if the base constructor is invoked by accessing the component on the vm.
6518
+ // When the ENABLE_LOCKER_VALIDATION gate is true and LEGACY_LOCKER_ENABLED is false,
6519
+ // then the instanceof LightningElement can be used.
6520
+ const useLegacyConstructorCheck = lwcRuntimeFlags.ENABLE_LEGACY_VALIDATION || lwcRuntimeFlags.LEGACY_LOCKER_ENABLED;
6521
+ const isInvalidConstructor = useLegacyConstructorCheck
6522
+ ? vmBeingConstructed.component !== result
6523
+ : !(result instanceof LightningElement);
6520
6524
  if (isInvalidConstructor) {
6521
6525
  throw new TypeError('Invalid component constructor, the class should extend LightningElement.');
6522
6526
  }
@@ -8525,5 +8529,5 @@ exports.swapTemplate = swapTemplate;
8525
8529
  exports.track = track;
8526
8530
  exports.unwrap = unwrap;
8527
8531
  exports.wire = wire;
8528
- /** version: 8.17.0 */
8532
+ /** version: 8.18.0 */
8529
8533
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.js CHANGED
@@ -893,8 +893,11 @@ function logMissingPortalWarn(name, type) {
893
893
  function patchElementWithRestrictions(elm, options) {
894
894
  assertNotProd(); // this method should never leak to prod
895
895
  const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
896
- const descriptors = {
897
- outerHTML: generateAccessorDescriptor({
896
+ const descriptors = {};
897
+ // For consistency between dev/prod modes, only patch `outerHTML` if it exists
898
+ // (i.e. patch it in engine-dom, not in engine-server)
899
+ if (originalOuterHTMLDescriptor) {
900
+ descriptors.outerHTML = generateAccessorDescriptor({
898
901
  get() {
899
902
  return originalOuterHTMLDescriptor.get.call(this);
900
903
  },
@@ -902,8 +905,8 @@ function patchElementWithRestrictions(elm, options) {
902
905
  logError(`Invalid attempt to set outerHTML on Element.`);
903
906
  return originalOuterHTMLDescriptor.set.call(this, value);
904
907
  },
905
- }),
906
- };
908
+ });
909
+ }
907
910
  // Apply extra restriction related to DOM manipulation if the element is not a portal.
908
911
  if (!options.isLight && options.isSynthetic && !options.isPortal) {
909
912
  const { appendChild, insertBefore, removeChild, replaceChild } = elm;
@@ -2733,7 +2736,7 @@ function registerDecorators(Ctor, meta) {
2733
2736
  validateMethodDecoratedWithWire(Ctor, fieldOrMethodName, descriptor);
2734
2737
  }
2735
2738
  if (isUndefined$1(descriptor)) {
2736
- throw new Error();
2739
+ throw new Error(`Missing descriptor for wired method "${fieldOrMethodName}".`);
2737
2740
  }
2738
2741
  wiredMethods[fieldOrMethodName] = descriptor;
2739
2742
  storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic);
@@ -6505,15 +6508,16 @@ function invokeComponentConstructor(vm, Ctor) {
6505
6508
  try {
6506
6509
  // job
6507
6510
  const result = new Ctor();
6508
- // Check indirectly if the constructor result is an instance of LightningElement. Using
6509
- // the "instanceof" operator would not work here since Locker Service provides its own
6510
- // implementation of LightningElement, so we indirectly check if the base constructor is
6511
- // invoked by accessing the component on the vm.
6512
- // TODO [W-17769475]: Restore this fix when we can reliably detect Locker enabled
6513
- // const isInvalidConstructor = lwcRuntimeFlags.LEGACY_LOCKER_ENABLED
6514
- // ? vmBeingConstructed.component !== result
6515
- // : !(result instanceof LightningElement);
6516
- const isInvalidConstructor = vmBeingConstructed.component !== result;
6511
+ // Check indirectly if the constructor result is an instance of LightningElement.
6512
+ // When Locker is enabled, the "instanceof" operator would not work since Locker Service
6513
+ // provides its own implementation of LightningElement, so we indirectly check
6514
+ // if the base constructor is invoked by accessing the component on the vm.
6515
+ // When the ENABLE_LOCKER_VALIDATION gate is true and LEGACY_LOCKER_ENABLED is false,
6516
+ // then the instanceof LightningElement can be used.
6517
+ const useLegacyConstructorCheck = lwcRuntimeFlags.ENABLE_LEGACY_VALIDATION || lwcRuntimeFlags.LEGACY_LOCKER_ENABLED;
6518
+ const isInvalidConstructor = useLegacyConstructorCheck
6519
+ ? vmBeingConstructed.component !== result
6520
+ : !(result instanceof LightningElement);
6517
6521
  if (isInvalidConstructor) {
6518
6522
  throw new TypeError('Invalid component constructor, the class should extend LightningElement.');
6519
6523
  }
@@ -8471,5 +8475,5 @@ function readonly(obj) {
8471
8475
  }
8472
8476
 
8473
8477
  export { BaseBridgeElement, LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, computeShadowAndRenderMode, connectRootElement, createContextProviderWithRegister, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentAPIVersion, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, registerComponent, registerDecorators, registerTemplate, runFormAssociatedCallback, runFormDisabledCallback, runFormResetCallback, runFormStateRestoreCallback, sanitizeAttribute, shouldBeFormAssociated, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
8474
- /** version: 8.17.0 */
8478
+ /** version: 8.18.0 */
8475
8479
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
5
5
  ],
6
6
  "name": "@lwc/engine-core",
7
- "version": "8.17.0",
7
+ "version": "8.18.0",
8
8
  "description": "Core LWC engine APIs.",
9
9
  "keywords": [
10
10
  "lwc"
@@ -46,9 +46,9 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@lwc/features": "8.17.0",
50
- "@lwc/shared": "8.17.0",
51
- "@lwc/signals": "8.17.0"
49
+ "@lwc/features": "8.18.0",
50
+ "@lwc/shared": "8.18.0",
51
+ "@lwc/signals": "8.18.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "observable-membrane": "2.0.0"