1
- /*
2
- * LESS - Leaner CSS v1.5.0-b2
1
+ /*!
2
+ * LESS - Leaner CSS v1.5.0-b3
3
3
* http://lesscss.org
4
4
*
5
5
* Copyright (c) 2009-2013, Alexis Sellier <self@cloudhead.net>
@@ -496,7 +496,8 @@ less.Parser = function Parser(env) {
496
496
outputFilename : options . sourceMapOutputFilename ,
497
497
sourceMapBasepath : options . sourceMapBasepath ,
498
498
sourceMapRootpath : options . sourceMapRootpath ,
499
- outputSourceFiles : options . outputSourceFiles
499
+ outputSourceFiles : options . outputSourceFiles ,
500
+ sourceMapGenerator : options . sourceMapGenerator
500
501
} ) ;
501
502
}
502
503
@@ -555,18 +556,18 @@ less.Parser = function Parser(env) {
555
556
e = new ( LessError ) ( e , env ) ;
556
557
}
557
558
558
- callback ( e ) ;
559
+ return callback ( e ) ;
559
560
}
560
561
else {
561
- callback ( null , root ) ;
562
+ return callback ( null , root ) ;
562
563
}
563
564
} ;
564
565
565
566
if ( env . processImports !== false ) {
566
567
new tree . importVisitor ( this . imports , finish )
567
568
. run ( root ) ;
568
569
} else {
569
- finish ( ) ;
570
+ return finish ( ) ;
570
571
}
571
572
} ,
572
573
@@ -682,12 +683,11 @@ less.Parser = function Parser(env) {
682
683
var k ;
683
684
684
685
if ( k = $ ( / ^ [ _ A - Z a - z - ] [ _ A - Z a - z 0 - 9 - ] * / ) ) {
685
- if ( tree . colors . hasOwnProperty ( k ) ) {
686
- // detect named color
687
-
F438
return new ( tree . Color ) ( tree . colors [ k ] . slice ( 1 ) ) ;
688
- } else {
689
- return new ( tree . Keyword ) ( k ) ;
686
+ var color = tree . Color . fromKeyword ( k ) ;
687
+ if ( color ) {
688
+ return color ;
690
689
}
690
+ return new ( tree . Keyword ) ( k ) ;
691
691
}
692
692
} ,
693
693
@@ -1491,7 +1491,7 @@ less.Parser = function Parser(env) {
1491
1491
//
1492
1492
directive : function ( ) {
1493
1493
var name , value , rules , nonVendorSpecificName ,
1494
- hasBlock , hasIdentifier , hasExpression ;
1494
+ hasBlock , hasIdentifier , hasExpression , identifier ;
1495
1495
1496
1496
if ( input . charAt ( i ) !== '@' ) { return ; }
1497
1497
@@ -1546,7 +1546,10 @@ less.Parser = function Parser(env) {
1546
1546
}
1547
1547
1548
1548
if ( hasIdentifier ) {
1549
- name += " " + ( $ ( / ^ [ ^ { ] + / ) || '' ) . trim ( ) ;
1549
+ identifier = ( $ ( / ^ [ ^ { ] + / ) || '' ) . trim ( ) ;
1550
+ if ( identifier ) {
1551
+ name += " " + identifier ;
1552
+ }
1550
1553
}
1551
1554
1552
1555
if ( hasBlock )
@@ -2047,7 +2050,16 @@ tree.functions = {
2047
2050
} ,
2048
2051
color : function ( n ) {
2049
2052
if ( n instanceof tree . Quoted ) {
2050
- return new ( tree . Color ) ( n . value . slice ( 1 ) ) ;
2053
+ var colorCandidate = n . value ,
2054
+ returnColor ;
2055
+ returnColor = tree . Color . fromKeyword ( colorCandidate ) ;
2056
+ if ( returnColor ) {
2057
+ return returnColor ;
2058
+ }
2059
+ if ( / ^ # ( [ A - F a - f 0 - 9 ] { 6 } | [ A - F a - f 0 - 9 ] { 3 } ) / . test ( colorCandidate ) ) {
2060
+ return new ( tree . Color ) ( colorCandidate . slice ( 1 ) ) ;
2061
+ }
2062
+ throw { type : "Argument" , message : "argument must be a color keyword or 3/6 digit hex e.g. #FFF" } ;
2051
2063
} else {
2052
2064
throw { type : "Argument" , message : "argument must be a string" } ;
2053
2065
}
@@ -2528,7 +2540,6 @@ tree.functionCall.prototype = tree.functions;
2528
2540
'teal' :'#008080' ,
2529
2541
'thistle' :'#d8bfd8' ,
2530
2542
'tomato' :'#ff6347' ,
2531
- // 'transparent':'rgba(0,0,0,0)',
2532
2543
'turquoise' :'#40e0d0' ,
2533
2544
'violet' :'#ee82ee' ,
2534
2545
'wheat' :'#f5deb3' ,
@@ -2803,6 +2814,9 @@ tree.Color = function (rgb, a) {
2803
2814
}
2804
2815
this . alpha = typeof ( a ) === 'number' ? a : 1 ;
2805
2816
} ;
2817
+
2818
+ var transparentKeyword = "transparent" ;
2819
+
2806
2820
tree . Color . prototype = {
2807
2821
type : "Color" ,
2808
2822
eval : function ( ) { return this ; } ,
@@ -2819,6 +2833,9 @@ tree.Color.prototype = {
2819
2833
// which has better compatibility with older browsers.
2820
2834
// Values are capped between `0` and `255`, rounded and zero-padded.
2821
2835
if ( this . alpha < 1.0 ) {
2836
+ if ( this . alpha === 0 && this . isTransparentKeyword ) {
2837
+ return transparentKeyword ;
2838
+ }
2822
2839
return "rgba(" + this . rgb . map ( function ( c ) {
2823
2840
return Math . round ( c ) ;
2824
2841
} ) . concat ( this . alpha ) . join ( ',' + ( compress ? '' : ' ' ) ) + ")" ;
@@ -2937,6 +2954,18 @@ tree.Color.prototype = {
2937
2954
}
2938
2955
} ;
2939
2956
2957
+ tree . Color . fromKeyword = function ( keyword ) {
2958
+ if ( tree . colors . hasOwnProperty ( keyword ) ) {
2959
+ // detect named color
2960
+ return new ( tree . Color ) ( tree . colors [ keyword ] . slice ( 1 ) ) ;
2961
+ }
2962
+ if ( keyword === transparentKeyword ) {
2963
+ var transparent = new ( tree . Color ) ( [ 0 , 0 , 0 ] , 0 ) ;
2964
+ transparent . isTransparentKeyword = true ;
2965
+ return transparent ;
2966
+ }
2967
+ } ;
2968
+
2940
2969
2941
2970
} ) ( require ( '../tree' ) ) ;
2942
2971
@@ -4150,11 +4179,11 @@ tree.mixin.Definition.prototype = {
4150
4179
return ruleset ;
4151
4180
} ,
4152
4181
matchCondition : function ( args , env ) {
4153
-
4154
4182
if ( this . condition && ! this . condition . eval (
4155
4183
new ( tree . evalEnv ) ( env ,
4156
- [ this . evalParams ( env , new ( tree . evalEnv ) ( env , this . frames . concat ( env . frames ) ) , args , [ ] ) ]
4157
- . concat ( env . frames ) ) ) ) {
4184
+ [ this . evalParams ( env , new ( tree . evalEnv ) ( env , this . frames . concat ( env . frames ) ) , args , [ ] ) ] // the parameter variables
4185
+ . concat ( this . frames ) // the parent namespace/mixin frames
4186
+ . concat ( env . frames ) ) ) ) { // the current environment frames
4158
4187
return false ;
4159
4188
}
4160
4189
return true ;
@@ -4644,7 +4673,9 @@ tree.Ruleset.prototype = {
4644
4673
for ( i = 0 ; i < ruleNodes . length ; i ++ ) {
4645
4674
rule = ruleNodes [ i ] ;
4646
4675
4647
- if ( i + 1 === ruleNodes . length ) {
4676
+ // @page { directive ends up with root elements inside it, a mix of rules and rulesets
4677
+ // In this instance we do not know whether it is the last property
4678
+ if ( i + 1 === ruleNodes . length && ( ! this . root || rulesetNodes . length === 0 || this . firstRoot ) ) {
4648
4679
env . lastRule = true ;
4649
4680
}
4650
4681
@@ -4668,10 +4699,10 @@ tree.Ruleset.prototype = {
4668
4699
4669
4700
for ( i = 0 ; i < rulesetNodes . length ; i ++ ) {
4670
4701
if ( ruleNodes . length && firstRuleset ) {
4671
- output . add ( " \n" + ( this . root ? tabRuleStr : tabSetStr ) ) ;
4702
+ output . add ( ( env . compress ? "" : " \n") + ( this . root ? tabRuleStr : tabSetStr ) ) ;
4672
4703
}
4673
4704
if ( ! firstRuleset ) {
4674
- output . add ( '\n' + ( this . root ? tabRuleStr : tabSetStr ) ) ;
4705
+ output . add ( ( env . compress ? "" : "\n" ) + ( this . root ? tabRuleStr : tabSetStr ) ) ;
4675
4706
}
4676
4707
firstRuleset = false ;
4677
4708
rulesetNodes [ i ] . genCSS ( env , output ) ;
@@ -5087,6 +5118,7 @@ tree.Variable.prototype = {
5087
5118
'relativeUrls' , // option - whether to adjust URL's to be relative
5088
5119
'rootpath' , // option - rootpath to append to URL's
5089
5120
'strictImports' , // option -
5121
+ 'insecure' , // option - whether to allow imports from insecure ssl hosts
5090
5122
'dumpLineNumbers' , // option - whether to dump line numbers
5091
5123
'compress' , // option - whether to compress
5092
5124
'processImports' , // option - whether to process imports. if false then imports will not be imported
@@ -6034,7 +6066,6 @@ tree.Variable.prototype = {
6034
6066
} ) ( require ( './tree' ) ) ;
6035
6067
6036
6068
( function ( tree ) {
6037
- var sourceMap = require ( "source-map" ) ;
6038
6069
6039
6070
tree . sourceMapOutput = function ( options ) {
6040
6071
this . _css = [ ] ;
@@ -6046,6 +6077,7 @@ tree.Variable.prototype = {
6046
6077
this . _sourceMapBasepath = options . sourceMapBasepath ;
6047
6078
this . _sourceMapRootpath = options . sourceMapRootpath ;
6048
6079
this . _outputSourceFiles = options . outputSourceFiles ;
6080
+ this . _sourceMapGeneratorConstructor = options . sourceMapGenerator || require ( "source-map" ) . SourceMapGenerator ;
6049
6081
6050
6082
if ( this . _sourceMapRootpath && this . _sourceMapRootpath . charAt ( this . _sourceMapRootpath . length - 1 ) !== '/' ) {
6051
6083
this . _sourceMapRootpath += '/' ;
@@ -6062,7 +6094,7 @@ tree.Variable.prototype = {
6062
6094
filename = filename . substring ( 1 ) ;
6063
6095
}
6064
6096
}
6065
- return this . _sourceMapRootpath + filename . replace ( / \\ / g, '/' ) ;
6097
+ return ( this . _sourceMapRootpath || "" ) + filename . replace ( / \\ / g, '/' ) ;
6066
6098
} ;
6067
6099
6068
6100
tree . sourceMapOutput . prototype . add = function ( chunk , fileInfo , index ) {
@@ -6101,7 +6133,7 @@ tree.Variable.prototype = {
6101
6133
} ;
6102
6134
6103
6135
tree . sourceMapOutput . prototype . toCSS = function ( env ) {
6104
- this . _sourceMapGenerator = new sourceMap . SourceMapGenerator ( { file : this . _outputFilename , sourceRoot : null } ) ;
6136
+ this . _sourceMapGenerator = new this . _sourceMapGeneratorConstructor ( { file : this . _outputFilename , sourceRoot : null } ) ;
6105
6137
6106
6138
if ( this . _outputSourceFiles ) {
6107
6139
for ( var filename in this . _contentsMap ) {
@@ -6112,17 +6144,29 @@ tree.Variable.prototype = {
6112
6144
this . _rootNode . genCSS ( env , this ) ;
6113
6145
6114
6146
if ( this . _css . length > 0 ) {
6115
- this . _writeSourceMap ( JSON . stringify ( this . _sourceMapGenerator . toJSON ( ) ) ) ;
6147
+ var sourceMapFilename ,
6148
+ sourceMapContent = JSON . stringify ( this . _sourceMapGenerator . toJSON ( ) ) ;
6116
6149
6117
6150
if ( this . _sourceMapFilename ) {
6118
- this . _css . push ( "/*# sourceMappingURL=" + this . _sourceMapRootpath + this . _sourceMapFilename + " */" ) ;
6151
+ sourceMapFilename = this . normalizeFilename ( this . _sourceMapFilename ) ;
6152
+ }
6153
+
6154
+ if ( this . _writeSourceMap ) {
6155
+ this . _writeSourceMap ( sourceMapContent ) ;
6156
+ } else {
6157
+ sourceMapFilename = "data:application/json," + encodeURIComponent ( sourceMapContent ) ;
6158
+ }
6159
+
6160
+ if ( sourceMapFilename ) {
6161
+ this . _css . push ( "/*# sourceMappingURL=" + sourceMapFilename + " */" ) ;
6119
6162
}
6120
6163
}
6121
6164
6122
6165
return this . _css . join ( '' ) ;
6123
6166
} ;
6124
6167
6125
6168
} ) ( require ( './tree' ) ) ;
6169
+
6126
6170
//
6127
6171
// browser.js - client-side engine
6128
6172
//
0 commit comments