@@ -74,6 +74,9 @@ class lessc {
74
74
static protected $ dtypes = array ('expression ' , 'variable ' ,
75
75
'function ' , 'negative ' , 'list ' , 'lookup ' );
76
76
77
+ // these properties will supress division unless it's inside parenthases
78
+ static protected $ supressDivisionProps = array ('/border-radius$/i ' , '/^font$/i ' );
79
+
77
80
/**
78
81
* @link http://www.w3.org/TR/css3-values/
79
82
*/
@@ -148,7 +151,7 @@ function parseChunk() {
148
151
149
152
// setting a property
150
153
if ($ this ->keyword ($ key ) && $ this ->assign () &&
151
- $ this ->propertyValue ($ value ) && $ this ->end ())
154
+ $ this ->propertyValue ($ value, $ key ) && $ this ->end ())
152
155
{
153
156
$ this ->append (array ('assign ' , $ key , $ value ), $ s );
154
157
return true ;
@@ -382,6 +385,15 @@ function expHelper($lhs, $minP) {
382
385
383
386
// try to find a valid operator
384
387
while ($ this ->match (self ::$ operatorString .($ needWhite ? '\s ' : '' ), $ m ) && self ::$ precedence [$ m [1 ]] >= $ minP ) {
388
+ if (!$ this ->inParens && isset ($ this ->env ->currentProperty ) && $ m [1 ] == "/ " ) {
389
+ foreach (self ::$ supressDivisionProps as $ pattern ) {
390
+ if (preg_match ($ pattern , $ this ->env ->currentProperty )) {
391
+ $ this ->env ->supressedDivision = true ;
392
+ break 2 ;
393
+ }
394
+ }
395
+ }
396
+
385
397
// get rhs
386
398
$ s = $ this ->seek ();
387
399
$ p = $ this ->inParens ;
@@ -421,8 +433,10 @@ function expHelper($lhs, $minP) {
421
433
}
422
434
423
435
// consume a list of values for a property
424
- function propertyValue (&$ value ) {
436
+ function propertyValue (&$ value, $ keyName = null ) {
425
437
$ values = array ();
438
+
439
+ if (!is_null ($ keyName )) $ this ->env ->currentProperty = $ keyName ;
426
440
427
441
$ s = null ;
428
442
while ($ this ->expressionList ($ v )) {
@@ -433,6 +447,8 @@ function propertyValue(&$value) {
433
447
434
448
if ($ s ) $ this ->seek ($ s );
435
449
450
+ if (!is_null ($ keyName )) unset ($ this ->env ->currentProperty );
451
+
436
452
if (count ($ values ) == 0 ) return false ;
437
453
438
454
$ value = $ this ->compressList ($ values , ', ' );
@@ -503,6 +519,15 @@ function value(&$value) {
503
519
$ this ->seek ($ s );
504
520
}
505
521
522
+ // the spare / when supressing division
523
+ if (!empty ($ this ->env ->supressedDivision )) {
524
+ unset($ this ->env ->supressedDivision );
525
+ if ($ this ->literal("/")) {
526
+ $ value = array('keyword', '/');
527
+ return true;
528
+ }
529
+ }
530
+
506
531
return false;
507
532
}
508
533
@@ -601,25 +626,12 @@ function string(&$string, &$d = null) {
601
626
* $allowed restricts the types that are matched.
602
627
*/
603
628
function unit (&$ unit , $ allowed = null ) {
604
- $ simpleCase = $ allowed == null ;
605
629
if (!$ allowed ) $ allowed = self ::$ units ;
606
630
607
- if ($ this ->match ('(-?[0-9]*(\.)?[0-9]+)( ' .implode ('| ' , $ allowed ).')? ' , $ m, ! $ simpleCase )) {
631
+ if ($ this ->match ('(-?[0-9]*(\.)?[0-9]+)( ' .implode ('| ' , $ allowed ).')? ' , $ m )) {
608
632
if (!isset ($ m [3 ])) $ m [3 ] = 'number ' ;
609
633
$ unit = array ($ m [3 ], $ m [1 ]);
610
634
611
- // check for size/height font unit.. should this even be here?
612
- if ($ simpleCase ) {
613
- $ s = $ this ->seek ();
614
- if (!$ this ->inExp && $ this ->literal ('/ ' , false ) && $ this ->unit ($ right , self ::$ units )) {
615
- $ unit = array ('keyword ' , $ this ->compileValue ($ unit ).'/ ' .$ this ->compileValue ($ right ));
616
- } else {
617
- // get rid of whitespace
618
- $ this ->seek ($ s );
619
- $ this ->match ('' , $ _ );
620
- }
621
- }
622
-
623
635
return true ;
624
636
}
625
637
0 commit comments