-
Notifications
You must be signed in to change notification settings - Fork 421
feat: add support for ElementInternals in synthetic shadow #5519
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
base: master
Are you sure you want to change the base?
feat: add support for ElementInternals in synthetic shadow #5519
Conversation
Thanks for the contribution! Unfortunately we can't verify the commit author(s): roxanne.baker <r***@s***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, refresh the status of this Pull Request. |
33a6d1e
to
e579965
Compare
e579965
to
31414f3
Compare
packages/@lwc/engine-core/src/framework/base-lightning-element.ts
Outdated
Show resolved
Hide resolved
...-karma/test/component/LightningElement.attachInternals/elementInternals/sanity/index.spec.js
Show resolved
Hide resolved
...est/component/LightningElement.attachInternals/elementInternals/formAssociated/index.spec.js
Outdated
Show resolved
Hide resolved
...est/component/LightningElement.attachInternals/elementInternals/formAssociated/index.spec.js
Outdated
Show resolved
Hide resolved
// Ensure the DOM is in a clean state | ||
document.body.replaceChildren(); | ||
document.head.replaceChildren(); | ||
window.__lwcResetGlobalStylesheets(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without this the stylesheet was removed after the first test, but since it was cached it wouldn't get re-added - meaning that the styles were only actually present for the first test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In synthetic shadow, can a user do
HTMLElement.prototype.attachInternals.call(someComponent)
and get access to the real shadow root (not synthetic)? Or do we already guard that? - IIRC we wanted this to be an internal-only feature because synthetic shadow is deprecated, right? I think we'll need a compiler flag. Lemme double check.
...est/component/LightningElement.attachInternals/elementInternals/formAssociated/index.spec.js
Outdated
Show resolved
Hide resolved
...est/component/LightningElement.attachInternals/elementInternals/formAssociated/index.spec.js
Outdated
Show resolved
Hide resolved
…ement.attachInternals/elementInternals/formAssociated/index.spec.js Co-authored-by: Will Harney <[email protected]>
…ement.attachInternals/elementInternals/formAssociated/index.spec.js Co-authored-by: Will Harney <[email protected]>
|
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
}); This is the current result of compiling an LWC component. In order to have a compile-time switch for synthetic element internals, we should add an additional property to the object, which should just reflect a boolean set in the compiler options. Because 99% of components will never set the flag, we can avoid unnecessarily increasing file sizes by only setting the property when the compiler flag is lwc/packages/@lwc/babel-plugin-component/src/component.ts Lines 86 to 92 in b6e43be
The flag should be an optional boolean set via lwc/packages/@lwc/engine-core/src/framework/component.ts Lines 23 to 27 in b6e43be
lwc/packages/@lwc/engine-core/src/framework/component.ts Lines 62 to 64 in b6e43be
|
Details
Removes the existing error when attempting to use
attachInternals
in synthetic shadow and instead uses a Proxy in synthetic shadow to ensure that the shadow root returns as expected. Error message was also removed for FACE-related callback methods in synthetic shadow.Existing tests were updated to run in synthetic shadow and new tests added to cover functionality related to other
ElementInternals
properties not covered by existing tests.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.
ElementInternals/attachInternals and FACE callbacks should now be fully supported in synthetic shadow instead of throwing errors.
GUS work item
W-19275967