feat: add support for ElementInternals in synthetic shadow#5519
feat: add support for ElementInternals in synthetic shadow#5519wjhsf merged 16 commits intosalesforce:masterfrom
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
Co-authored-by: Will Harney <62956339+wjhsf@users.noreply.github.com>
| // Ensure the DOM is in a clean state | ||
| document.body.replaceChildren(); | ||
| document.head.replaceChildren(); | ||
| window.__lwcResetGlobalStylesheets(); |
There was a problem hiding this comment.
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
wjhsf
left a comment
There was a problem hiding this comment.
- 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 <62956339+wjhsf@users.noreply.github.com>
…ement.attachInternals/elementInternals/formAssociated/index.spec.js Co-authored-by: Will Harney <62956339+wjhsf@users.noreply.github.com>
|
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 |
6455c37 to
aafc70f
Compare
packages/@lwc/engine-core/src/framework/base-lightning-element.ts
Outdated
Show resolved
Hide resolved
| const COMPONENT_NAME_KEY = 'sel'; | ||
| const API_VERSION_KEY = 'apiVersion'; | ||
| const COMPONENT_CLASS_ID = '__lwc_component_class_internal'; | ||
| const SYNTHETIC_ELEMENT_INTERNALS_KEY = 'enableSyntheticElementInternals'; |
There was a problem hiding this comment.
🤔 if this were written 8 years ago, we'd probably call it sei or something silly. I don't think we still care about that, though...
|
/nucleus test |
Co-authored-by: Will Harney <62956339+wjhsf@users.noreply.github.com>
|
/nucleus test |
Details
Removes the existing error when attempting to use
attachInternalsin 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
ElementInternalsproperties 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