Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Aug 12, 2021
1 parent 18d055e commit 422c093
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ function EmbeddedAdminContext( props, forwardedRef ) {
const [ hasFocus, setHasFocus ] = useState();
const ref = useRefEffect( ( element ) => {
const root = element.attachShadow( { mode: 'open' } );
const style = document.createElement( 'style' );
Array.from( document.styleSheets ).forEach( ( styleSheet ) => {
if ( styleSheet.ownerNode.getAttribute( 'data-emotion' ) ) {
return;
}

let child = document.createElement( 'style' );

// Try to avoid requests for stylesheets of which we already
// know the CSS rules.
try {
Expand All @@ -28,13 +27,12 @@ function EmbeddedAdminContext( props, forwardedRef ) {
cssText += cssRule.cssText;
}

child.textContent = cssText;
style.textContent = cssText;
} catch ( e ) {
child = styleSheet.ownerNode.cloneNode( true );
root.appendChild( styleSheet.ownerNode.cloneNode( true ) );
}

root.appendChild( child );
} );
root.appendChild( style );
setShadow( root );

function onFocusIn() {
Expand Down

0 comments on commit 422c093

Please sign in to comment.