-
Notifications
You must be signed in to change notification settings - Fork 2
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
Render samples with shadowDOM to prevent style clashes. #39
Conversation
This renders our samples with shadowDOM on a custom element, so we can embed app styles in those elements and not have them leak into Showcase.
This comment was marked as resolved.
This comment was marked as resolved.
Ok, it looks like if I rendered the element like this: <showcase-isolated-context>
<template data-shadowroot>
<%= render "showcase/engine/stylesheets" %>
<%= sample.preview %>
</template>
</showcase-isolated-context> The Since we've already isolated the |
@KonnorRogers thanks for the advice, I went with |
Looks like shadowDOM also prevents us from logging any dispatched JavaScript events in the |
within :element, data: {controller: "welcome"} do | ||
assert_element text: "Somebody", data: {welcome_target: "greeter"} | ||
within :section, "Samples" do |section| | ||
section.find_css "[data-shadowroot]" do |
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.
Capybara will strip out all template element content from the moment it parses the HTML string. We might need to build a Nokogiri tree from response.body
(for Integration Tests) or rendered
(for View Test). From there, we'd traverse until the template and pass it's contents to Capybara.string
so that we could make assertions on it directly.
Gonna call this done for now, since it seems like ShadowDOM is tough for our use case of having user supplied HTML — and I'll have a hard time maintaining. We'll see how it goes with style clashes. |
This renders our samples with shadowDOM on a custom element, so we can embed app styles in those elements and not have them leak into Showcase.