External CSS affecting (bleeding) DOM shadow with Polymer

Something is missing me, but I cannot understand that. I have a simple custom element implemented using polymer:

<polymer-element name="test-elem">

    <template>
        <content></content>
        <div id="container">
            <div class="deepinside">
            TECK ... CHEST
            </div>
        </div>
    </template>

    <script>
        Polymer('test-elem', {
            applyAuthorStyles: false,
        });
    </script>

</polymer-element>

Then I use it on a simple page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />

    <script src="libs/polymer.min.js"></script>

    <link rel="import" href="test-elem.html">

    <style>
    .deepinside { color: red; }
    </style>

</head>
<body>
    <test-elem>Hi</test-elem>
</body>
</html>

The content of item div(s class="deepinside") is displayed in red. If I understand correctly, this should not happen (see this document ). Note that I explicitly declared applyAuthorStyles: falsein the element constructor (this is not necessary because this is the default behavior). I don't understand why external CSS affects an element in the DOM shadow. I even tried to explicitly specify the attribute shadowdomin the element definition, but the result is the same.

What am I missing?

FWIW, I am running Chrome version 31.0.1650.57 on OS X 10.7.5.

+3
1

Shadow DOM polyfill. , , .

. , Chrome 33.0.1717.0 ( Polymer polyfill Shadow DOM), 31.0.1650.57.

+3

Source: https://habr.com/ru/post/1599700/


All Articles