From 917a01df1ea4215b68f7d19580ba0c044627ecf4 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Tue, 2 Jun 2020 07:52:28 +0200 Subject: [PATCH] Only use 'all and...' in conjunction with 'not' --- lib/optimizer/src/Transformer/ServerSideRendering.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/optimizer/src/Transformer/ServerSideRendering.php b/lib/optimizer/src/Transformer/ServerSideRendering.php index 99c17cad9d3..8e9482889b2 100644 --- a/lib/optimizer/src/Transformer/ServerSideRendering.php +++ b/lib/optimizer/src/Transformer/ServerSideRendering.php @@ -1023,7 +1023,9 @@ private function extractMediaAttributeCss(Document $document, DOMElement $elemen $attributeValue = preg_replace('/^not\s+/i', '', $attributeValue, 1, $notFound); $not = $notFound ? '' : 'not '; - if ($attributeValue[0] === '(') { + if ($attributeValue[0] === '(' && ! $notFound) { + // 'not' can only be used with a media type, so we use 'all' as media type if it is missing. + // See quirksmode.org/blog/archives/2012/11/what_the_hells.html#c15586 $attributeValue = 'all and ' . $attributeValue; }