Skip to content

Commit

Permalink
strip whitespace from the script tag before output
Browse files Browse the repository at this point in the history
  • Loading branch information
scruffian committed Mar 21, 2023
1 parent 642112d commit 5b81ec9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/class-wp-duotone-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ private static function safari_rerender_hack( $selectors ) {
* Accessing el.offsetHeight flushes layout and style
* changes in WebKit without having to wait for setTimeout.
*/
printf(
$script_tag = sprintf(
'<script>
(
function() {
%s.forEach( selector => {
%s.forEach( selector => {
document.querySelectorAll( selector ).forEach( function( el ) {
if( ! el ) {
return;
Expand All @@ -214,6 +214,9 @@ function() {
</script>',
wp_json_encode( $selectors )
);

// Strip whitespace.
echo preg_replace( '/\s+/', '', $script_tag );
}

/**
Expand Down

0 comments on commit 5b81ec9

Please sign in to comment.