inner-host.html (1939B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>CSS Shadow Parts - Inner Host</title> 5 <meta href="mailto:fergal@chromium.org" rel="author" title="Fergal Daly"> 6 <link href="http://www.google.com/" rel="author" title="Google"> 7 <link href="https://drafts.csswg.org/css-shadow-parts/" rel="help"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="support/shadow-helper.js"></script> 11 </head> 12 <body> 13 <style>#c-e-outer::part(partp) { color: green; }</style> 14 <script>installCustomElement("custom-element-inner", "custom-element-inner-template");</script> 15 <template id="custom-element-inner-template"> 16 <style>span { color: blue; }</style> 17 <span id="blue_part" part="partp">This text</span> 18 </template> 19 <script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script> 20 <template id="custom-element-outer-template"> 21 <style>span { color: red; }</style> 22 <span id="green_part" part="partp">This text</span> 23 The following text should be blue: 24 <custom-element-inner id="c-e-inner"></custom-element-inner> 25 </template> 26 The following text should be green: 27 <custom-element-outer id="c-e-outer"></custom-element-outer> 28 <script> 29 "use strict"; 30 const colorBlue = "rgb(0, 0, 255)"; 31 const colorGreen = "rgb(0, 128, 0)"; 32 test(function() { 33 const el = getElementByShadowIds(document, ["c-e-outer", "green_part"]); 34 assert_equals(window.getComputedStyle(el).color, colorGreen); 35 }, "Part in outer host is styled by document style sheet"); 36 test(function() { 37 const el = getElementByShadowIds(document, ["c-e-outer", "c-e-inner", "blue_part"]); 38 assert_equals(window.getComputedStyle(el).color, colorBlue); 39 }, "Part in inner host is not styled by document style sheet"); 40 </script> 41 </body> 42 </html>