I am working on an app, which uses the custom element API (with webcomponents.js as polyfill). Inside of my element, I want to encapsulate everything in a shadow root. The HTML template of the polymer element seems to be imported correctly, however, styling is missing - unlike when I place the element outside, where styling seems to work:
class TestWC extends HTMLElement {
createdCallback() {
console.log('created');
var ShadowRoot = this.createShadowRoot();
ShadowRoot.innerHTML = '<paper-input label="Inside shadow root"></paper-input>';
}
}
var MyTestWC = document.registerElement('test-test', TestWC);
var MyTestWCInst = new MyTestWC();
document.querySelector('#placeholder').appendChild(MyTestWCInst);
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/0.7.22/webcomponents.js"></script>
<paper-input label="Outside shadow root"></paper-input>
<p id="placeholder"></p>
<link rel="import" href="https://polygit.org/components/paper-input/paper-input.html" />
Question: Why does the original styling of polymer web components not work inside shadow root?
Edit: here is a Plunker; works in chrome only FTM. http://plnkr.co/edit/rEibVckeUAqqrZljuVEy?p=preview
iron-image
oriron-icon
. – a1626