Skip to content

Commit

Permalink
Check for existence of defaultView before attempting to get styles
Browse files Browse the repository at this point in the history
  • Loading branch information
glendaviesnz committed Jul 25, 2023
1 parent 6cf6643 commit c660d66
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/editor-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ function useDarkThemeBodyClassName( styles ) {
body.appendChild( tempCanvas );

backgroundColor = defaultView
.getComputedStyle( tempCanvas, null )
?.getComputedStyle( tempCanvas, null )
.getPropertyValue( 'background-color' );

body.removeChild( tempCanvas );
} else {
backgroundColor = defaultView
.getComputedStyle( canvas, null )
?.getComputedStyle( canvas, null )
.getPropertyValue( 'background-color' );
}
const colordBackgroundColor = colord( backgroundColor );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useSelectionChangeCompat() {
return useRefEffect( ( element ) => {
const { ownerDocument } = element;
const { defaultView } = ownerDocument;
const selection = defaultView.getSelection();
const selection = defaultView?.getSelection();

let range;

Expand Down

0 comments on commit c660d66

Please sign in to comment.