Skip to content

[ShadyCSS] Specificity issue when mixing straight and module-style CSS #23

Open
@TimvdLippe

Description

@TimvdLippe

From @mercmobily on July 1, 2016 2:19

If you have a simple file test.html:

<!DOCTYPE html>
  <html>
    <head>

      <script>
        window.Polymer = { lazyRegister: true, dom: 'shadow'};
      </script>

      <script src="bower_components/webcomponentsjs/webcomponents-lite.js">
      </script>
      <link rel="import" href="extra-styles.html">

      <style is="custom-style" include="extra-styles"></style>

      <style>
        h1 {
          color: blue;
        }
      </style>

      <title>Extra CSS styles</title>
    </head>
    <body>
      <h1>What colour am I?</h1>
    </body>
  </html>

And extra-styles.html is:

<link rel="import" href="bower_components/polymer/polymer.html">

<dom-module id="extra-styles">
  <template>
    <style>
      h1 {
        color: red;
      }
    </style>
  </template>
  <script>
    Polymer({
      is: 'extra-styles'
    });
  </script>
</dom-module>

You will see that:

  1. Using shadow DOM, the writing is blue
  2. Using shady DOM, the writing is red.

This is because the style set in extra-styles is more specific:

h1:not([style-scope]):not(.style-scope)

Copied from original issue: Polymer/polymer#3758

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions