Skip to content

Commit

Permalink
Fix #34 (slash handling of font property values) caused by regression
Browse files Browse the repository at this point in the history
from #32
  • Loading branch information
Horcrux7 committed Feb 25, 2017
1 parent 29652e8 commit 9c396ee
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 29 deletions.
11 changes: 3 additions & 8 deletions src/com/inet/lib/less/LessParser.java
Expand Up @@ -790,14 +790,6 @@ private Expression parseExpression( char leftOperator ) {
}
switch( ch ) {
case '/':
if( strictMath && nesting == 0 ) {
if( wasWhite ) {
builder.append( ' ' );
wasWhite = false;
}
builder.append( ch );
continue LOOP;
}
if( comment( null ) ) {
continue LOOP;
}
Expand Down Expand Up @@ -846,6 +838,9 @@ private Expression parseExpression( char leftOperator ) {
}
}
left = concat( left, ch, parseExpression( ch ) );
if( strictMath && nesting == 0 && ch == '/' ) {
((Operation)left).setDataType( Expression.STRING );
}
break;
case ':': // Key value parameter like @color:#abc
if( left == null ) {
Expand Down
10 changes: 9 additions & 1 deletion src/com/inet/lib/less/Operation.java
Expand Up @@ -174,6 +174,14 @@ public int getDataType( CssFormatter formatter ) {
return type;
}

/**
* Inject a data type from parser
* @param type the type
*/
void setDataType( int type ) {
this.type = type;
}

/**
* Get the highest data type of different operands
* @param formatter current formatter
Expand Down Expand Up @@ -232,7 +240,7 @@ public void appendTo( CssFormatter formatter ) {
case '/':
for( int i = 0; i < operands.size(); i++ ) {
if( i > 0 ) {
formatter.append( ' ' ).append( operator ).append( ' ' );
formatter.append( operator );
}
operands.get( i ).appendTo( formatter );
}
Expand Down
11 changes: 6 additions & 5 deletions test/com/inet/lib/less/samples/general/import.css
Expand Up @@ -3,15 +3,16 @@
b: "b";
}
.values .slash {
font: 1.5/2;
a: 1.5;
b: 1.5;
e: a / b;
f: a / b;
g: a / b;
h: a / b;
e: a/b;
f: a/b;
g: a/b;
h: a/b;
font: 3/2;
}
.values .slash2 {
background: url("img.jpg") center / 100px;
background: url("img.jpg") center/100px;
background: url(abc/img.jpg);
}
11 changes: 6 additions & 5 deletions test/com/inet/lib/less/samples/general/importOptional.css
@@ -1,13 +1,14 @@
.slash {
font: 1.5/2;
a: 1.5;
b: 1.5;
e: a / b;
f: a / b;
g: a / b;
h: a / b;
e: a/b;
f: a/b;
g: a/b;
h: a/b;
font: 3/2;
}
.slash2 {
background: url("img.jpg") center / 100px;
background: url("img.jpg") center/100px;
background: url(abc/img.jpg);
}
11 changes: 6 additions & 5 deletions test/com/inet/lib/less/samples/general/slash.css
@@ -1,13 +1,14 @@
.slash {
font: 1.5/2;
a: 1.5;
b: 1.5;
e: a / b;
f: a / b;
g: a / b;
h: a / b;
e: a/b;
f: a/b;
g: a/b;
h: a/b;
font: 3/2;
}
.slash2 {
background: url("img.jpg") center / 100px;
background: url("img.jpg") center/100px;
background: url(abc/img.jpg);
}
1 change: 1 addition & 0 deletions test/com/inet/lib/less/samples/general/slash.less
@@ -1,6 +1,7 @@
// comment
.slash {
@a: 3 / 2;
font:@a/2;
a: @a;
b: 3 / 2;
e: a / b;
Expand Down
Expand Up @@ -127,5 +127,5 @@ body ^^ .shadow {
display: done;
}
#issue2066 {
background: url('/images/icon-team.svg') 0 0 / contain;
background: url('/images/icon-team.svg') 0 0/contain;
}
Expand Up @@ -4,8 +4,8 @@
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
background: url("img.jpg") center / 100px;
background: #fff url(image.png) center / 1px 100px repeat-x scroll content-box padding-box;
background: url("img.jpg") center/100px;
background: #fff url(image.png) center/1px 100px repeat-x scroll content-box padding-box;
}
#misc {
background-image: url(images/image.jpg);
Expand Down
4 changes: 2 additions & 2 deletions test/com/inet/lib/less/samples/less_org_tests/less/urls.css
Expand Up @@ -7,8 +7,8 @@
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
background: url("img.jpg") center / 100px;
background: #fff url(image.png) center / 1px 100px repeat-x scroll content-box padding-box;
background: url("img.jpg") center/100px;
background: #fff url(image.png) center/1px 100px repeat-x scroll content-box padding-box;
}
#misc {
background-image: url(images/image.jpg);
Expand Down

0 comments on commit 9c396ee

Please sign in to comment.