From 4a4616ec89ac67577d64a5909b295309278362a1 Mon Sep 17 00:00:00 2001 From: Bernie Reiter Date: Thu, 5 May 2022 15:03:40 +0200 Subject: [PATCH] Add Core CSS to styles compat hook for editor iframe --- packages/block-editor/src/components/iframe/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/iframe/index.js b/packages/block-editor/src/components/iframe/index.js index 5596aa00325782..435df3a821cc5f 100644 --- a/packages/block-editor/src/components/iframe/index.js +++ b/packages/block-editor/src/components/iframe/index.js @@ -45,7 +45,6 @@ function useStylesCompatibility() { } catch ( e ) { return; } - const { ownerNode, cssRules } = styleSheet; if ( ! cssRules ) { @@ -65,6 +64,14 @@ function useStylesCompatibility() { return; } + let isFilenameMatch = false; + if ( styleSheet.href ) { + const url = new URL( styleSheet.href ); + if ( url.pathname === '/wp-admin/css/common.css' ) { + isFilenameMatch = true; + } + } + const isMatch = Array.from( cssRules ).find( ( { selectorText } ) => selectorText && @@ -73,7 +80,7 @@ function useStylesCompatibility() { ); if ( - isMatch && + ( isMatch || isFilenameMatch ) && ! node.ownerDocument.getElementById( ownerNode.id ) ) { // Display warning once we have a way to add style dependencies to the editor.