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

Custom pseudo-elements cannot be targeted outside shadow dom #475

Closed
peterhorne opened this issue Apr 18, 2014 · 2 comments
Closed

Custom pseudo-elements cannot be targeted outside shadow dom #475

peterhorne opened this issue Apr 18, 2014 · 2 comments

Comments

@peterhorne
Copy link

The following test case creates a custom element which renders Hello, <span pseduo="x-name">Polymer</span>. I'm trying to target the custom pseudo-element x-name using the CSS selector span::x-name in the parent document but it doesn't result in a match.

I've tested the following in Chrome 34 & 36.

<!doctype html>
<html>
    <head>
        <script src="bower_components/platform/platform.js"></script>

        <style type="text/css">
            span::x-name {
                color: green;
            }
        </style>
    </head>

    <body>
        <link rel="import" href="/bower_components/polymer/polymer.html">
        <polymer-element name="my-example">
            <template>
                Hello, <span pseudo="x-name">Polymer</span>
            </template>

            <script>
                Polymer('my-example', {
                    ready: function() {}
                })
            </script>
        </polymer-element>

        <my-example></my-example>
    </body>
</html>
@robdodson
Copy link
Contributor

pseudo is no longer supported in Shadow DOM. You want something that looks like this:

<style shim-shadowdom>
  my-example::shadow .my-name {
    color: red;
  }
</style>
<polymer-element name="my-example">
  <template>
    Hello, <span class="my-name">Polymer</span>
  </template>
  <script>
    Polymer('my-example', {
      ready: function() {}
    })
  </script>
</polymer-element>
<my-example></my-example>

http://jsbin.com/sobov/2/edit

Note the use of shim-shadowdom for legacy browsers and ::shadow to pierce the shadow boundary.

@peterhorne
Copy link
Author

Oh right, thanks!

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

No branches or pull requests

2 participants