Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: disable form association entirely on older API versions #4041

Merged
merged 10 commits into from
Mar 11, 2024

Conversation

nolanlawson
Copy link
Contributor

@nolanlawson nolanlawson commented Mar 8, 2024

Details

Fixes #3929

Logs a warning when using synthetic custom element lifecycle and attempting to use static formAssociated = true. Also, ensures formAssociated is always false when the API version is <61.

Does this pull request introduce a breaking change?

  • ✅ No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • ⚠️ Yes, it does include an observable change.

Technically someone could have been trying to use an older API version and setting formAssociated to true, but the FACE callbacks wouldn't have worked and older API versions are not used in OSS so I really doubt anyone took a dependency on this.

@nolanlawson nolanlawson requested a review from a team as a code owner March 8, 2024 18:22
@nolanlawson nolanlawson changed the title Nolan/form assoc fix: log friendly error for form associated Mar 8, 2024
`The attachInternals API is only supported in API version 61 and above. To use this API please update the LWC component API version.`
`The attachInternals API is only supported in API version 61 and above. ` +
`The current version is ${apiVersion}. ` +
`To use this API, update the LWC component API version. https://lwc.dev/guide/versioning`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guidelines for user messages say "don't say 'please'".

@@ -38,12 +38,12 @@ function createPreprocessor(config, emitter, logger) {

// Wrap all the tests into a describe block with the file structure name
// This avoids needing to manually write `describe()` for every file.
// Also add a dummy test because otherwise Jasmine complains about empty describe()s:
// Also add an empty test because otherwise Jasmine complains about empty describe()s:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot we were trying to remove this term since it can be misconstrued.

@nolanlawson nolanlawson changed the title fix: log friendly error for form associated fix: disable form association entirely on older API versions Mar 8, 2024
Copy link
Member

@jmsjtu jmsjtu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a few comments but otherwise LGTM!

elm = createElement(tagName, { is: ctor });
};
if (ENABLE_ELEMENT_INTERNALS_AND_FACE) {
doCreate();
Copy link
Member

@jmsjtu jmsjtu Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use process.env.SYNTHETIC_SHADOW_ENABLED here instead of !process.env.NATIVE_SHADOW?

Unless it's possible for process.env.FORCE_NATIVE_SHADOW_MODE_FOR_TEST and process.env.SYNTHETIC_SHADOW_ENABLED to be enabled at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of consider process.env.NATIVE_SHADOW to be the "default" choice for tests, and that SYNTHETIC_SHADOW_ENABLED is only needed for odd cases where you need to do something differently in FORCE_NATIVE_SHADOW_MODE_FOR_TEST mode.

Admittedly FORCE_NATIVE_SHADOW_MODE_FOR_TEST is kind of weird, so it's confusing. Maybe we should have better names here.

toThrowCallbackReactionErrorEvenInSyntheticLifecycleMode: errorMatcherFactory(
windowErrorListener,
true
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jmsjtu This is kind of weird but I couldn't think of a better name for this 😂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😆 how about toThrowCallbackReactionErrorInAllDomModes, what you have works for me too.

We can always change it later if we come up with a better name!

@nolanlawson nolanlawson merged commit 754d9bb into master Mar 11, 2024
9 checks passed
@nolanlawson nolanlawson deleted the nolan/form-assoc branch March 11, 2024 16:02
ravijayaramappa added a commit that referenced this pull request Mar 12, 2024
* refactor: organize API versioning tests (#4040)

* fix: disable form association entirely on older API versions (#4041)

Fixes #3929

* Revert "fix(synthetic-shadow): retargeting does not correctly account for nat…" (#4047)

This reverts commit 13cd45f.

* chore: routine dependencies update (#4046)

* chore: routine dependencies update

* fix: revert prettier updates

* chore: update husky

* chore: update husky

* fix: disable ts rule

* chore: v6.3.2 (#4048)

---------

Co-authored-by: Nolan Lawson <[email protected]>
Co-authored-by: Eugene Kashida <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Post LWC v6] Add friendly error message when ElementInternals is not available due to lower API version
2 participants