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

Option to disable shadow dom #3036

Closed
ghost opened this issue Jan 20, 2023 · 3 comments · Fixed by #3059
Closed

Option to disable shadow dom #3036

ghost opened this issue Jan 20, 2023 · 3 comments · Fixed by #3059
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Jan 20, 2023

  • [ ✔] I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.
Feels like many developers are just struggling to add custom features to gradio components because the shadow dom prevent javascript from reaching the components easily. I've searched a lot in the issues but none of them allows accessing shadow dom. It took me a whole day trying to figure out how to add a click event to the gallery with external javascript (added to the closing of body) but ended up deciding to switch to another framework...

Describe the solution you'd like
Just simply add an option to disable the shadow dom and make all html elements visible to external javascript will be much helpful.

Additional context
If it's not possible to disable shadow dom, I would also appreciate that if we can have an interface to load js into the whole app (instead of for individual components) or allow directly editing the html of the coponents.

@abidlabs abidlabs added the enhancement New feature or request label Jan 20, 2023
@abidlabs
Copy link
Member

Hi @ruochongChen my sense is that we do not want to disable the shadow DOM because it would break the ability for users to embed Gradio apps in other places. But I do think we should allow users to load JS into the whole app. This has been requested several times, e.g. #2137

@apolinario
Copy link
Contributor

Related: #2763

@pngwn
Copy link
Member

pngwn commented Jan 26, 2023

We have recently changed our CSS approach on main and most of our CSS is scoped by default. So we basically don't need the shadow DOM anymore. There is a PR that removes it. This doesn't make gradio very slightly less 'safe': although gradio will never touch anything outside of itself, it is possible for the embedding page to impact the gradio styles. So in short our styles are encapsulated (after a fashion) but the gradio DOM is not, and consumers will need to take note of that.

#3059

@pngwn pngwn mentioned this issue Jan 26, 2023
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants