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

Context without shadow root #384

Open
megheaiulian opened this issue May 3, 2022 · 2 comments · May be fixed by #453
Open

Context without shadow root #384

megheaiulian opened this issue May 3, 2022 · 2 comments · May be fixed by #453

Comments

@megheaiulian
Copy link

megheaiulian commented May 3, 2022

When creating a Context it is useful to opt out of using shadow DOM for the Consumer and Provider components.
To allow that createContext could pass thru the second argument of component.
Note: Shadow DOM is kind of useless for the Provider component. It makes more sense for the Consumer.

@bennypowers
Copy link
Collaborator

Note: Shadow DOM is kind of useless for the Provider component. It makes more sense for the Consumer.

A card component could provide a 'color-theme' context to it's children, but also have it's own shadow DOM

@megheaiulian
Copy link
Author

@bennypowers The Provider doesn't seem to be using component and does not currently have a shadow DOM.
When doing

import { createContext, component, html } from 'haunted';
const ThemeContext = createContext();
customElements.defined('theme-context-consumer', ThemeContext.Consumer);

// ...
const tmpl = html`
       <theme-context-consumer .render=${v => html`
          <span class="somespan">${v}</span>
            `}></theme-context-consumer>
`

then .somespan is by default in the shadow DOM of theme-context-consumer and you can't style it.
That is not intuitive but it would be good if it could be overwritten with createContext(defaultValue, {useShadowDOM: false}).

megheaiulian added a commit to Neovici/haunted that referenced this issue Nov 4, 2022
The Context's Consumer component does not need to have a ShadowRoot
because it would be very hard to style elements inside it. (part)

fixes matthewp#384
@megheaiulian megheaiulian linked a pull request Nov 4, 2022 that will close this issue
cristinecula pushed a commit to Neovici/haunted that referenced this issue May 15, 2023
The Context's Consumer component does not need to have a ShadowRoot
because it would be very hard to style elements inside it. (part)

fixes matthewp#384
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 a pull request may close this issue.

2 participants