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 form selection when element is detached (#1806) #1881

Merged

Conversation

cyantree
Copy link
Contributor

In #1806 the problem is that getElementById() only exists on document level but getRootNode() returns a <div> because the button isn't attached to any document anymore.

I don't know whether this fix is sufficient as it doesn't contain any escaping for the selector and also no adjusted tests.

Copy link

vercel bot commented Feb 20, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
shoelace ✅ Ready (Inspect) Visit Preview Feb 20, 2024 11:46pm

@KonnorRogers
Copy link
Collaborator

KonnorRogers commented Feb 21, 2024

Should be fine. I would largely consider it an edge case tbh. Nothing should need to be adjusted for this. The type fix alone should catch us trying to do getElementById() in the future. Thank you!

EDIT: As im diving into this more, a detached element with a form attribute actually never registers to the form.

https://codepen.io/paramagicdev/pen/ZEPNpdp?editors=1111

Perhaps a check if the element is connected prior to checking the rootNode may be inline with regular HTML Elements.

@KonnorRogers KonnorRogers self-requested a review February 21, 2024 20:29
src/internal/form.ts Show resolved Hide resolved
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.

None yet

3 participants