File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ node_modules
2+ npm-debug.log
3+ dist
4+ README.md
5+ package-lock.json
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " preact-shadow-root" ,
3+ "amdName" : " Shadow" ,
4+ "version" : " 1.0.0" ,
5+ "description" : " Render a Preact subtree into the Shadow DOM." ,
6+ "source" : " preact-shadow-root.js" ,
7+ "main" : " dist/preact-shadow-root.js" ,
8+ "module" : " dist/preact-shadow-root.es.js" ,
9+ "umd:main" : " dist/preact-shadow-root.umd.js" ,
10+ "scripts" : {
11+ "build" : " microbundle" ,
12+ "prepare" : " npm run -s build" ,
13+ "test" : " eslint src && npm run -s build"
14+ },
15+ "eslintConfig" : {
16+ "extends" : " eslint-config-developit"
17+ },
18+ "files" : [
19+ " preact-shadow-root.js" ,
20+ " dist"
21+ ],
22+ "keywords" : [
23+ " preact" ,
24+ " component" ,
25+ " shadow root" ,
26+ " shadow dom"
27+ ],
28+ "author" : " Jason Miller <jason@developit.ca>" ,
29+ "license" : " MIT" ,
30+ "devDependencies" : {
31+ "eslint" : " ^4.6.1" ,
32+ "eslint-config-developit" : " ^1.1.1" ,
33+ "microbundle" : " ^0.3.1"
34+ },
35+ "peerDependencies" : {
36+ "preact" : " *"
37+ }
38+ }
Original file line number Diff line number Diff line change 1+ import { render } from 'preact' ;
2+
3+ /* Shadow Root component */
4+ export default class Shadow {
5+ shouldComponentUpdate ( nextProps ) {
6+ this . update ( nextProps ) ;
7+ return false ;
8+ }
9+ componentDidMount ( ) {
10+ let parent = this . base && this . base . parentNode ;
11+ if ( parent ) {
12+ this . shadow = parent . attachShadow ( { mode : 'open' } ) ;
13+ this . update ( this . props ) ;
14+ }
15+ }
16+ update ( props ) {
17+ render ( props . children [ 0 ] , this . shadow , this . shadow . firstChild ) ;
18+ }
19+ render ( ) { }
20+ }
You can’t perform that action at this time.
0 commit comments