When you load stylesheet with Shadow DOM selectors dynamically, ::content
selector is not polyfilled. It get even worse as it breaks entire definition so for
.foo.bar,
.baz > ::content > .blah{
color: green;
}
Hello | |
<my-element>Custom Elements</my-element> |
customElements.define( 'wc-latest-releases', class extends HTMLElement { | |
constructor() { | |
super(); | |
this.attachShadow({ mode: "open" }); | |
} | |
static get observedAttributes() { return ["limit"]; } | |
get limit() { | |
return Number(this.getAttribute("limit")); | |
} | |
async fetchRealeses() { |
customElsMap = Array.from( document.querySelectorAll( '*' ) ).filter( (e) => e.tagName.includes('-')) | |
.reduce((accu, el)=>{ | |
let set = accu.get( el.tagName ); | |
if( ! set ) { | |
set = new Set(); | |
accu.set( el.tagName, set ); | |
} | |
set.add( el ); | |
return accu; | |
}, new Map()); |
<div id="host-1"><shadowroot mode="open">shadow</shadowroot></div> | |
<script> | |
it('Once parsed should create shadow root in parent element - **host**, and append own content into there.', function() { | |
const host = document.querySelector('#host-1'); | |
assert(host.shadowRoot, "should have shadowRoot property attached"); | |
assert(host.shadowRoot.innerHTML === 'shadow'); | |
}); | |
</script> |
<a href="javascript:(function(){var%20screl=document.createElement('script');screl.setAttribute('type','text/javascript');screl.setAttribute('src','https://gist.githubusercontent.com/tomalec/47f0acd910a729d0b6a2e55061e5c26e/raw/4843f8a32d971f0465871a2d26cf6cc5c88e1229/findStylesheetsInAllHTMLImports.js');document.body.appendChild(screl);})();">Find HTML Imported styles bookmarklet</a> |
When you load stylesheet with Shadow DOM selectors dynamically, ::content
selector is not polyfilled. It get even worse as it breaks entire definition so for
.foo.bar,
.baz > ::content > .blah{
color: green;
}
<!-- dependencies goes here--> | |
<template> | |
<!-- All content/functional/meaningful elements goes here --> | |
<template is="starcounter-composition"> | |
<!-- Shadow DOM layuout goes here --> | |
</template> | |
</template> | |
<!--- VanillaJS example --> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Polymer's dom-bind two-way data binding to native element</title> | |
<script src="https://rawgit.com/webcomponents/webcomponentsjs/master/webcomponents-lite.js"></script> | |
<link rel="import" href="https://rawgit.com/Polymer/polymer/master/polymer.html"> | |
<script> | |
var MyElementPrototype = Object.create(HTMLElement.prototype, { | |
message: { |
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="../../../resources/js-test.js"></script> | |
<script src="resources/shadow-dom.js"></script> | |
</head> | |
<body> | |
<p>This tests that pressing Tab key should traverse into shadow DOM subtrees, and pressing Shift-Tab should reverse the order.</p> | |
<p>This is a specific case with content distribution nodes that changes the order of light DOM nodes in composed tree</p> | |
<pre id="console"></pre> |
<!-- working example: http://jsbin.com/boloxo/1/edit --> | |
<head> | |
<script src="../../../webcomponentsjs/webcomponents.js"></script> | |
<link rel="import" href="../../../polymer/polymer.html"> | |
</head> | |
<body> | |
<div id="stampHere"></div> | |
</body> |