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

Use slots instead of pure shadow DOM #17

Merged
merged 6 commits into from
May 17, 2022

Conversation

danielgamage
Copy link
Member

Moved inner content on the web component to a <slot> element to make cascade behavior more useful. This was good to update, too, because content updates inside the ragger component via JS weren't propagating to the shadow root before this.

It would be good to

  • test the computed style on a slotted element to see if it inherits from global styles for inheriting other styles #16, but jsdom doesn't return anything from getComputedStyle beside visibility (added a failing test for this)
  • test the shadowRoot's text content after running something like mechanicalragger.innerHTML = "b", too, but mechanicalragger.shadowRoot.textContent, which works fine in the browser, also returns nothing in jsdom. (added a failing test for this)

Would be a lot for this project, but maybe we can try headless chrome / Puppeteer / selenium for these tests?

#16

@mikabusante
Copy link
Contributor

mikabusante commented May 11, 2022

I wonder if this package would be useful https://open-wc.org/docs/testing/testing-package/... but if we are trying to test inherited styles, I think we will have to test that in the browser. To do that we would need to:

Then we could def test the text content + styles. Not 100% sure if we can do something like mechanicalragger.innerHTML = "b" directly in the test body (I just haven't seen an example that does that, ig because it doesn't mimic user behavior), but we could have that innerHTML change happen on a button click or something, and then check that the text content has changed?

@danielgamage
Copy link
Member Author

danielgamage commented May 11, 2022

one other Q: Do you think storybook would be a useful test environment for this?

Asking bc our current demo site doesn't really cover all of the features like writing-modes, text alignment, ragging-width, resizing, and style inheritance (now), so I'm wondering if storybook would be an easier way of showcasing all of those things with minimal test cases and getting them in CI at the same time.

@mikabusante
Copy link
Contributor

oooo yes! I think that's a great idea :)

@danielgamage
Copy link
Member Author

since the tests are in #21 and #22, i'm going to remove the tests from here and merge+release this to resolve #16. then we can take some time to figure out a good test + demo setup

@danielgamage danielgamage merged commit c9e5dee into main May 17, 2022
@danielgamage danielgamage deleted the feat/web-component-style-inheritance branch May 17, 2022 21:57
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.

2 participants