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

hidden attribute does not always work for shadow dom #3711

Closed
coreyfarrell opened this issue Jun 14, 2016 · 2 comments
Closed

hidden attribute does not always work for shadow dom #3711

coreyfarrell opened this issue Jun 14, 2016 · 2 comments
Labels

Comments

@coreyfarrell
Copy link
Contributor

Description

The 'hidden' attribute does not work on polymer elements inside other polymer elements when using shadow dom. Works as expected with shady dom, tested on Chrome 51.

The browser inspector shows two important style selectors when using shadow DOM:

:host {
  display: block;
}
paper-input[Attributes Style] {
  display: none;
}

The :host selector is used over paper-input[Attributes Style].

CSS when using shady DOM:

[hidden] {
  display: none!important;
}
.paper-input-0 {
  display: block;
}
paper-input[Attributes Style] {
  display: none;
}

With shady DOM the [hidden] selector applies first, if that is disabled with the inspector then .paper-input-0 applies.

Live Demo

https://jsbin.com/tiyohitoxi/edit?html,output

@coreyfarrell
Copy link
Contributor Author

To anyone who is having this issue, you can work-around by adding the following to a global stylesheet:

body /deep/ [hidden] {
  display: none!important;
}

Note that /deep/ is deprecated, but it works.

@dfreedm dfreedm added the css label Jun 15, 2016
@sorvell
Copy link
Contributor

sorvell commented Jun 16, 2016

The root issue here is how the hidden attribute works in css. It has very low specificity and any other display setting will override it. It's unfortunate that iron-flex-layout addresses this issue in a way that is incompatible with Shadow DOM. There's a tracking issue for this with more information here: PolymerElements/iron-flex-layout#86.

If you want the hidden attribute to enforce that an element is actually display none, you can include a style inside your element that does:

[hidden] {
  display: none !important;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants