3 span::selection { background-color: rgba(
63,
128,
33,
0.95); color: yellow; }
5 <body onload=
"SelectText()">
8 <div id=
"shadowDiv" style=
"display:inline"></div>
12 Above Textual Selection should have Green background and yellow color on
"DOM" <br>
13 and Red background, Green color on
"Shadow DOM".
17 var host
= document
.getElementById('shadowDiv');
18 var root
= host
.createShadowRoot();
19 root
.innerHTML
= '<style> span::selection { background-color: rgba(255, 0, 0, 0.95); color: green; } </style>' +
20 '<span>Shadow DOM </span>';
22 function SelectText() {
23 var ele
= document
.getElementById('container');
24 var selection
= window
.getSelection();
25 selection
.selectAllChildren(ele
);