Skip to content

Commit

Permalink
Add compat styles in proper order
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jun 2, 2023
1 parent 898f62c commit 5f13723
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ export function useCompatibilityStyles() {
}

if ( matchFromRules( cssRules ) ) {
// Display warning once we have a way to add style dependencies to the editor.
// See: https://github.com/WordPress/gutenberg/pull/37466.
accumulator.push( ownerNode.cloneNode( true ) );

const isInline = ownerNode.tagName === 'STYLE';

// Add inline styles belonging to the stylesheet.
Expand All @@ -83,7 +79,15 @@ export function useCompatibilityStyles() {
);
const otherElement = document.getElementById( inlineCssId );

if ( otherElement ) {
// If the matched stylesheet is inline, add the main
// stylesheet before the inline style element.
if ( otherElement && isInline ) {
accumulator.push( otherElement.cloneNode( true ) );
}

accumulator.push( ownerNode.cloneNode( true ) );

if ( otherElement && ! isInline ) {
accumulator.push( otherElement.cloneNode( true ) );
}
}
Expand Down

0 comments on commit 5f13723

Please sign in to comment.