Skip to content

Commit

Permalink
Duotone: Remove Safari rerender hack (#49232)
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian authored Mar 21, 2023
1 parent 477711a commit 5436753
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,7 @@ private static function get_css_custom_property_declaration( $filter_data ) {
}

/**
* Safari renders elements incorrectly on first paint when the SVG filter comes after the content that it is filtering,
* so we force a repaint with a WebKit hack which solves the issue.
*
* @param string $selector The selector to apply the hack for.
*/
private static function safari_rerender_hack( $selector ) {
/*
* Simply accessing el.offsetHeight flushes layout and style
* changes in WebKit without having to wait for setTimeout.
*/
printf(
'<script>( function() { var el = document.querySelector( %s ); var display = el.style.display; el.style.display = "none"; el.offsetHeight; el.style.display = display; } )();</script>',
wp_json_encode( $selector )
);
}

/**
* Outputs all necessary SVG for duotone filters, CSS for classic themes, and safari rerendering hack
* Outputs all necessary SVG for duotone filters, CSS for classic themes.
*/
public static function output_footer_assets() {
foreach ( self::$output as $filter_data ) {
Expand All @@ -215,11 +198,6 @@ public static function output_footer_assets() {
if ( ! wp_is_block_theme() ) {
wp_add_inline_style( 'core-block-supports', 'body{' . self::get_css_custom_property_declaration( $filter_data ) . '}' );
}

global $is_safari;
if ( $is_safari ) {
self::safari_rerender_hack( $filter_data['selector'] );
}
}
}

Expand Down

1 comment on commit 5436753

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 5436753.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4480573865
📝 Reported issues:

Please sign in to comment.