@lwc/engine-core 4.0.0 → 4.0.1

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.
@@ -3,7 +3,8 @@ export declare const enum ReportingEventId {
3
3
  CompilerRuntimeVersionMismatch = "CompilerRuntimeVersionMismatch",
4
4
  NonStandardAriaReflection = "NonStandardAriaReflection",
5
5
  TemplateMutation = "TemplateMutation",
6
- StylesheetMutation = "StylesheetMutation"
6
+ StylesheetMutation = "StylesheetMutation",
7
+ ConnectedCallbackWhileDisconnected = "ConnectedCallbackWhileDisconnected"
7
8
  }
8
9
  export interface BasePayload {
9
10
  tagName?: string;
@@ -26,12 +27,15 @@ export interface TemplateMutationPayload extends BasePayload {
26
27
  export interface StylesheetMutationPayload extends BasePayload {
27
28
  propertyName: string;
28
29
  }
30
+ export interface ConnectedCallbackWhileDisconnectedPayload extends BasePayload {
31
+ }
29
32
  export type ReportingPayloadMapping = {
30
33
  [ReportingEventId.CrossRootAriaInSyntheticShadow]: CrossRootAriaInSyntheticShadowPayload;
31
34
  [ReportingEventId.CompilerRuntimeVersionMismatch]: CompilerRuntimeVersionMismatchPayload;
32
35
  [ReportingEventId.NonStandardAriaReflection]: NonStandardAriaReflectionPayload;
33
36
  [ReportingEventId.TemplateMutation]: TemplateMutationPayload;
34
37
  [ReportingEventId.StylesheetMutation]: StylesheetMutationPayload;
38
+ [ReportingEventId.ConnectedCallbackWhileDisconnected]: ConnectedCallbackWhileDisconnectedPayload;
35
39
  };
36
40
  export type ReportingDispatcher<T extends ReportingEventId = ReportingEventId> = (reportingEventId: T, payload: ReportingPayloadMapping[T]) => void;
37
41
  /** Callbacks to invoke when reporting is enabled **/
@@ -60,4 +64,8 @@ export declare function onReportingEnabled(callback: OnReportingEnabledCallback)
60
64
  * @param payload - data to report
61
65
  */
62
66
  export declare function report<T extends ReportingEventId>(reportingEventId: T, payload: ReportingPayloadMapping[T]): void;
67
+ /**
68
+ * Return true if reporting is enabled
69
+ */
70
+ export declare function isReportingEnabled(): boolean;
63
71
  export {};
package/dist/index.cjs.js CHANGED
@@ -78,6 +78,12 @@ function report(reportingEventId, payload) {
78
78
  currentDispatcher$1(reportingEventId, payload);
79
79
  }
80
80
  }
81
+ /**
82
+ * Return true if reporting is enabled
83
+ */
84
+ function isReportingEnabled() {
85
+ return enabled$1;
86
+ }
81
87
 
82
88
  /*
83
89
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6038,6 +6044,24 @@ function runConnectedCallback(vm) {
6038
6044
  invokeComponentCallback(vm, connectedCallback);
6039
6045
  logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
6040
6046
  }
6047
+ // This test only makes sense in the browser, with synthetic lifecycle, and when reporting is enabled or
6048
+ // we're in dev mode. This is to detect a particular issue with synthetic lifecycle.
6049
+ if (process.env.IS_BROWSER &&
6050
+ !lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE &&
6051
+ (process.env.NODE_ENV !== 'production' || isReportingEnabled())) {
6052
+ if (!vm.renderer.isConnected(vm.elm)) {
6053
+ if (process.env.NODE_ENV !== 'production') {
6054
+ logWarnOnce(`Element <${vm.tagName}> ` +
6055
+ `fired a \`connectedCallback\` and rendered, but was not connected to the DOM. ` +
6056
+ `Please ensure all components are actually connected to the DOM, e.g. using ` +
6057
+ `\`document.body.appendChild(element)\`. This will not be supported in future versions of ` +
6058
+ `LWC and could cause component errors. For details, see: https://sfdc.co/synthetic-lifecycle`);
6059
+ }
6060
+ report("ConnectedCallbackWhileDisconnected" /* ReportingEventId.ConnectedCallbackWhileDisconnected */, {
6061
+ tagName: vm.tagName,
6062
+ });
6063
+ }
6064
+ }
6041
6065
  }
6042
6066
  function hasWireAdapters(vm) {
6043
6067
  return shared.getOwnPropertyNames(vm.def.wire).length > 0;
@@ -7313,5 +7337,5 @@ exports.swapTemplate = swapTemplate;
7313
7337
  exports.track = track;
7314
7338
  exports.unwrap = unwrap;
7315
7339
  exports.wire = wire;
7316
- /** version: 4.0.0 */
7340
+ /** version: 4.0.1 */
7317
7341
  //# sourceMappingURL=index.cjs.js.map