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

Allow binding to <details> open attribute #2854

Closed
LostKobrakai opened this issue May 24, 2019 · 6 comments
Closed

Allow binding to <details> open attribute #2854

LostKobrakai opened this issue May 24, 2019 · 6 comments

Comments

@LostKobrakai
Copy link
Contributor

<details bind:open={variable} is not supported right now. It would be nice if it would be.

Toggling can be observed using an event listener for the toggle event:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#Events

@Rich-Harris
Copy link
Member

@JohnRSim
Copy link

JohnRSim commented Jul 23, 2019

Styling doesn't appear to work for the

tag when opened.
When the browser adds the open attribute on click of summary - the css is not generated for details[open] {} only for details {}

details[open] {
   background:red;
}
details {
   background:blue;
}

@LostKobrakai
Copy link
Contributor Author

Seems like svelte doesn't know that details tags might get a open attribute (it's not reactively added), which requires :global(…) to be used.

@JohnRSim
Copy link

thanks that did the trick :)

@Conduitry
Copy link
Member

I think it would make sense for the compiler to be able to see that bind:open might result in an open attribute being present, so it can scope the styles appropriately.

@Conduitry
Copy link
Member

Opened #3281.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants