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

create intermediate shadowRoot to scope styles #6

Open
wants to merge 33 commits into
base: master
Choose a base branch
from

Conversation

valdrinkoshi
Copy link
Collaborator

@valdrinkoshi valdrinkoshi commented Apr 14, 2017

Fixes #2
If we find a <style> in the content template, we scope it by creating an intermediate element and host content in its shadowRoot.
Added new property contentHost to allow querySelectors & adding event listeners on the right host.

  • update README.md
  • update demo
  • add tests

Tests failing because of webcomponents/shadydom#130

@valdrinkoshi
Copy link
Collaborator Author

webcomponents/shadydom#130 got fixed in webcomponents v1.0.0-rc.10, so tests are 💚 again 🎉

@valdrinkoshi
Copy link
Collaborator Author

After discussing about this offline with @frankiefu, I opted for always creating the intermediate shadowRoot and scope styles. There is no strong case for having the content stamped on the light dom, so better not to implement that feature until there is one.

@valdrinkoshi valdrinkoshi requested a review from frankiefu July 21, 2017 23:43
@frankiefu
Copy link

_getHostRoot() {
: Is this the same as getRootNode?

: I don't think we need prefix for flexbox anymore. Both IE 11 and Safari 9 support unprefix flexbox.

this.$.backdrop && this.$.backdrop.classList.toggle('opened', this.opened);
: classList.toggle's second argument is not supported in IE 11.

@valdrinkoshi
Copy link
Collaborator Author

@frankiefu thanks for the review, fixed!

@cdata
Copy link

cdata commented Mar 21, 2018

Heya, going through old PRs thanks to Project Health. What is the status of this PR? Do I still need to be assigned?

@valdrinkoshi
Copy link
Collaborator Author

valdrinkoshi commented Mar 21, 2018

@cdata yeah I'd like to know WDYT of this approach for scoping styles.

The user will declare the overlay like this:

<iron-overlay id="myOverlay">
  <template>
    <style> div { background: orange } </style>
    <div>hello world</div>
  </template>
</iron-overlay>

Which will result in a stamped renderer with content scoped into a new shadowRoot:

<iron-overlay-renderer data-overlay="myOverlay">
  <iron-overlay-content-host>
    #shadowRoot
      <style> div { background: orange } </style>
      <div>hello world</div>
    #/shadowRoot
  </iron-overlay-content-host>
</iron-overlay-renderer>

Pros: styles are scoped
Cons: user now has to access to its content via myOverlay.contentHost instead of myOverlay.renderer

@cdata
Copy link

cdata commented Mar 21, 2018

Speaking abstractly, I like it. I don't consider the con you mentioned to be a big deal.

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.

3 participants