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) {
485
485
486
486
private function parseLineNameValue () {
487
487
$ this ->consume ('[ ' );
488
- $ this ->consumeWhiteSpace ();
489
488
$ 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
+ }
492
498
}
493
- $ this ->consumeWhiteSpace ();
494
499
$ this ->consume ('] ' );
495
- return new LineName ($ sName , $ this ->iLineNo );
500
+ return new LineName (rtrim ( $ sName) , $ this ->iLineNo );
496
501
}
497
502
498
503
private function parseColorValue () {
Original file line number Diff line number Diff line change @@ -396,10 +396,23 @@ function testCalcInFile() {
396
396
397
397
function testGridLineNameInFile () {
398
398
$ 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;} " ;
400
400
$ this ->assertSame ($ sExpected , $ oDoc ->render ());
401
401
}
402
402
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
+
403
416
/**
404
417
* @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
405
418
*/
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