Skip to content

Instantly share code, notes, and snippets.

@TakayoshiKochi
Created January 11, 2017 08:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakayoshiKochi/119ce0a174c6d0fef7fc0f1705349bc1 to your computer and use it in GitHub Desktop.
Save TakayoshiKochi/119ce0a174c6d0fef7fc0f1705349bc1 to your computer and use it in GitHub Desktop.
Style Sharing for Shadow DOM v1
<!doctype html>
<html>
<body>
</body>
<script>
'use strict';
let host = document.createElement('div');
const numChildren = 10000;
for (var i = 0; i < numChildren; ++i) {
let div = document.createElement('div');
div.textContent = 'Hello';
host.appendChild(div);
}
document.body.appendChild(host);
let root = host.attachShadow({mode: 'open'});
root.innerHTML = `
<style>
slot::slotted(div) { color: green; }
</style>
<slot></slot>
`;
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment