-
Notifications
You must be signed in to change notification settings - Fork 393
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
feat: enable face lifecycle methods and wrap ElementInternals
in a proxy
#3695
Conversation
packages/@lwc/integration-karma/test/component/face-callbacks/index.spec.js
Outdated
Show resolved
Hide resolved
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.
Overall LGTM, just a few small nitpicks!
packages/@lwc/integration-karma/test/component/face-callbacks/index.spec.js
Outdated
Show resolved
Hide resolved
@nolanlawson The PR is ready for another round of reviews! Also, moving forward with the Since Example: <form>
<x-foo></x-foo>
</form> import { LightningElement, api } from 'lwc';
export default class extends LightningElement {
@api
internals = this.attachInternals();
} In contrast, the browser behavior shows an exception when it's not set: Once we remove the I think we can handle this in a few ways:
Wanted to get your thoughts on how we should handle this moving forward. This might be more straightforward or complicated depending on the Locker/LWS pivot implementation. |
@jmsjtu Great catch. I think if we do nothing, then people might end up taking a dependency on I hate doing this kind of thing, but my preference here is to return a Are there any other properties on |
Discussed with @nolanlawson and we will need to create a proxy for the following instance properties:
Additionally, there's currently a bug in Safari with This is causing a karma test failure. |
This feature is cool. Nice job |
Let's ignore Safari in the test for now. We can also add a comment with a TODO saying to keep an eye on the WebKit bug. |
@@ -80,8 +80,27 @@ describe('LightningElement.focus', () => { | |||
expect(elm.shadowRoot.activeElement).toBeNull(); | |||
}); | |||
|
|||
// TODO [#2566]: Firefox behaves differently from Chrome/Safari in this 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.
Removed this TODO since #2566 has been fixed.
packages/@lwc/integration-karma/test/accessibility/LightningElement.focus/index.spec.js
Outdated
Show resolved
Hide resolved
let formAssociated = superDef.formAssociated; | ||
if (!isUndefined(ctorFormAssociated)) { | ||
formAssociated = ctorFormAssociated; | ||
} |
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.
let formAssociated = superDef.formAssociated; | |
if (!isUndefined(ctorFormAssociated)) { | |
formAssociated = ctorFormAssociated; | |
} | |
const formAssociated = Boolean(superDef.formAssociated); |
I looked into it, and it seems that the browser's treatment of formAssociated
is based on truthiness. It would make our internal code simpler if we set formAssociated
to either true/false in one place in the code, so that we could rely on it being a boolean everywhere else.
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.
Or undefined | boolean
is also fine – just that we don't actually know what type superDef.formAssociated
is right? The user could put static formAssociated = 'yolo'
.
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.
I have a nitpick about types, but overall this looks great to me.
ElementInternals
in a proxy
@@ -2,7 +2,7 @@ | |||
"files": [ | |||
{ | |||
"path": "packages/@lwc/engine-dom/dist/index.js", | |||
"maxSize": "21KB" | |||
"maxSize": "21.2KB" |
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.
Details
This PR exposes the face lifecycle methods as described in the Element Internals and Form Association.
Note that exposing
ElementInternals
was already done in #3670.These lifecycle methods are designed to only work with native lifecycle enabled and only for native shadow or light DOM.
Does this pull request introduce a breaking change?
Does this pull request introduce an observable change?
GUS work item
W-13818672