Closed rinart73 closed 1 year ago
Input CSS:
.wp-block-gallery.has-nested-images.columns-default figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2), .wp-block-gallery.has-nested-images.columns-default figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2)~figure.wp-block-image:not(#individual-image) { width: calc(50% - var(--wp--style--unstable-gallery-gap, 16px)*0.5) }
Code:
$input = file_get_contents('test.css'); $parser = new Parser(); $parser->setContent($input); $stylesheet = $parser->parse(); echo $stylesheet;
Output:
.wp-block-gallery.has-nested-images.columns-default figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2), .wp-block-gallery.has-nested-images.columns-default figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2)~gure.wp-block-image:not(#individual-image) { width: calc(50% - var(--wp--style--unstable-gallery-gap, 16px)*0.5) }
As you can see, during the parsing the "fi" in "figure" after tilde ~ disappeared.
~
I tracked it to an increment in the following line. Removing increment solves the issue. https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1202
From what I can see that part of the switch-case handles the following situations:
= in the attribute context. This is handled by the following line https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1196
=
~= ^= $= in the attribute context. You're using $string[$i++] to move past the = sign to not consume it again https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1199
~=
^=
$=
$string[$i++]
~ in no context which becomes part of selector. From what I can see, there is no need for increment, since you're handling only one character. https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1202
Input CSS:
Code:
Output:
As you can see, during the parsing the "fi" in "figure" after tilde
~
disappeared.I tracked it to an increment in the following line. Removing increment solves the issue. https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1202
From what I can see that part of the switch-case handles the following situations:
=
in the attribute context. This is handled by the following line https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1196~=
^=
$=
in the attribute context. You're using$string[$i++]
to move past the=
sign to not consume it again https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1199~
in no context which becomes part of selector. From what I can see, there is no need for increment, since you're handling only one character. https://github.com/tbela99/css/blob/16810e7d15e312dbea157dc807249e7f21b5cf8b/src/TBela/CSS/Value.php#L1202