File tree Expand file tree Collapse file tree 5 files changed +28
-7
lines changed
Expand file tree Collapse file tree 5 files changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -485,14 +485,19 @@ private function parseNumericValue($bForColor = false) {
485485
486486 private function parseLineNameValue () {
487487 $ this ->consume ('[ ' );
488- $ this ->consumeWhiteSpace ();
489488 $ sName = '' ;
490- while (!$ this ->comes ('] ' )) {
491- $ sName .= $ this ->parseCharacter (true );
489+ try {
490+ do {
491+ $ this ->consumeWhiteSpace ();
492+ $ sName .= $ this ->parseIdentifier (false , true ) . ' ' ;
493+ } while (!$ this ->comes ('] ' ));
494+ } catch (UnexpectedTokenException $ e ) {
495+ if (!$ this ->oParserSettings ->bLenientParsing && (!$ sName || !$ this ->comes ('] ' ))) {// This handles constructs like this [ linename ] in non lenient mode
496+ throw $ e ;
497+ }
492498 }
493- $ this ->consumeWhiteSpace ();
494499 $ this ->consume ('] ' );
495- return new LineName ($ sName , $ this ->iLineNo );
500+ return new LineName (rtrim ( $ sName) , $ this ->iLineNo );
496501 }
497502
498503 private function parseColorValue () {
Original file line number Diff line number Diff line change @@ -396,10 +396,23 @@ function testCalcInFile() {
396396
397397 function testGridLineNameInFile () {
398398 $ oDoc = $ this ->parsedStructureForFile ('grid-linename ' , Settings::create ()->withMultibyteSupport (true ));
399- $ sExpected = ' .test {grid-template-columns: [linename] 100px;}' ;
399+ $ sExpected = " div {grid-template-columns: [linename] 100px;}\n span {grid-template-columns: [linename1 linename2] 100px;} " ;
400400 $ this ->assertSame ($ sExpected , $ oDoc ->render ());
401401 }
402402
403+ function testEmptyGridLineNameLenientInFile () {
404+ $ oDoc = $ this ->parsedStructureForFile ('empty-grid-linename ' );
405+ $ sExpected = '.test {grid-template-columns: [] 100px;} ' ;
406+ $ this ->assertSame ($ sExpected , $ oDoc ->render ());
407+ }
408+
409+ /**
410+ * @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
411+ */
412+ function testLineNameFailure () {
413+ $ this ->parsedStructureForFile ('-empty-grid-linename ' , Settings::create ()->withLenientParsing (false ));
414+ }
415+
403416 /**
404417 * @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
405418 */
Original file line number Diff line number Diff line change 1+ .test { grid-template-columns : [ ] 100px ; }
Original file line number Diff line number Diff line change 1+ .test { grid-template-columns : [ ] 100px ; }
Original file line number Diff line number Diff line change 1- .test { grid-template-columns : [linename] 100px ; }
1+ div { grid-template-columns : [ linename ] 100px ; }
2+ span { grid-template-columns : [ linename1 linename2 ] 100px ; }
You can’t perform that action at this time.
0 commit comments