From e2bcea90423ea0d302563bceda5bc77461d3dc23 Mon Sep 17 00:00:00 2001 From: Christopher James Willcock Date: Wed, 27 Jun 2018 00:07:29 -0300 Subject: [PATCH] Preserve combinators that are not surrounded by white space --- src/PhpCss/Scanner/Patterns.php | 6 +++--- tests/PhpCssTest.php | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/PhpCss/Scanner/Patterns.php b/src/PhpCss/Scanner/Patterns.php index 3803154..db295f2 100644 --- a/src/PhpCss/Scanner/Patterns.php +++ b/src/PhpCss/Scanner/Patterns.php @@ -34,9 +34,9 @@ abstract class Patterns { const COMBINATOR = '(\s*[>+~]\s*)S'; - const CLASS_SELECTOR = '(\.[^\r\n\t .,#:()[\\]\\\'"]+)S'; - const ID_SELECTOR = '(#[^\r\n\t .,#:()[\\]\\\'"]+)S'; - const PSEUDO_CLASS = '(:[^\r\n\t .,#:()[\\]\\\'"]+)S'; + const CLASS_SELECTOR = '(\.[^\r\n\t >+~.,#:()[\\]\\\'"]+)S'; + const ID_SELECTOR = '(#[^\r\n\t >+~.,#:()[\\]\\\'"]+)S'; + const PSEUDO_CLASS = '(:[^\r\n\t >+~.,#:()[\\]\\\'"]+)S'; const PSEUDO_ELEMENT = '(::[^\r\n\t .,#:()[\\]\\\'"]+)S'; const ATTRIBUTE_OPERATOR = '([~^$*|]?=)S'; diff --git a/tests/PhpCssTest.php b/tests/PhpCssTest.php index f80d0d7..c4185c3 100644 --- a/tests/PhpCssTest.php +++ b/tests/PhpCssTest.php @@ -101,6 +101,10 @@ public static function provideReformattedCss() { array('element > child', 'element > child'), array('element child', 'element child'), array('html|*:not(:link):not(:visited)', 'html|*:not(:link):not(:visited)'), + array('li + li', 'li+li'), + array('li.class > li', 'li.class>li'), + array('li#id ~ li', 'li#id~li'), + array('li:hover + li', 'li:hover+li'), // pseudo class positions array('tr:nth-child(odd)', 'tr:nth-child(2n+1)'),