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;
}| // ==UserScript== | |
| // @name XTB CSS fixes | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-09-23.2 | |
| // @updateURL https://gist.github.com/tomalec/94ec4e3137815087e1377a96a54b0e66/raw/xtb_ui_fix.user.js | |
| // @downloadURL https://gist.github.com/tomalec/94ec4e3137815087e1377a96a54b0e66/raw/xtb_ui_fix.user.js | |
| // @description Remove annoying toasts | |
| // @author tomalec | |
| // @match https://xstation5.xtb.com/ | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=xtb.com |
| 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> |