Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #31344
What is the current behavior?
Currently,
attachPropsassigns every prop onto the element without checking whether it has a value. Assigning a nullish value to a reflected property stringifies it, so an unset optional prop lands asid="undefined"and every element rendered that way shares an id. Setting the prop back toundefinedoverwrites the attribute rather than removing it. The same goes fortitle,slot,lang, anddir.What is the new behavior?
We now remove the attribute after assigning, when the value was nullish and the name is a native property. That is what
@lit/reactalready does in itssetProperty, so the hand-rolled wrappers and the generated components behave the same way.Does this introduce a breaking change?
In fact, this version of this fix was made explicitly to avoid introducing more breaking changes at this time.
Other information
This replaces #31349, which fixed the same issue by skipping the property assignment for nullish values rather than removing the attribute afterwards. That changes what
undefinedmeans for a prop with a declared default. Today<IonModal backdropDismiss={maybeUndefined} />writesundefinedover the@Prop()default oftrueso the backdrop doesn't dismiss, but with the assignment skipped the default survives and it starts dismissing. Same foranimated,showBackdrop, andkeyboardClose. It would also leave the package inconsistent, because the generated components go through@lit/react, which does assign, soIonInputandIonButtonwould disagree about whatundefinedmeans. Mirroring@lit/reactavoids both, and this PR needs no BREAKING.md entry because of it.Note that the repro in #31344 uses
IonToggle, which is generated on v9 and already passes there. This covers the hand-rolled wrappers@lit/reactdoesn't touch: the overlays, the routing proxies, andIonApp/IonIcon/IonNav/IonRouterOutlet/the tabs components.A prop removed from the JSX entirely, rather than set to
undefined, still isn't cleared, sinceattachPropsonly iterates the new props. That's pre-existing and I left it alone, because three call sites pass a filterednewPropsagainst the fullprevPropsso the fix isn't as simple as it would appear.Co-authored-by: Patrick Kenny github@ptmkenny.com
Current dev build: