11/*!
2- * Less - Leaner CSS v2.0.0-b3
2+ * Less - Leaner CSS v2.0.0
33 * http://lesscss.org
44 *
55 * Copyright (c) 2009-2014, Alexis Sellier <[email protected] > @@ -91,47 +91,47 @@ module.exports = {
9191 var id = 'less:' + ( sheet . title || utils . extractId ( href ) ) ;
9292
9393 // If this has already been inserted into the DOM, we may need to replace it
94- var oldCss = document . getElementById ( id ) ;
95- var keepOldCss = false ;
94+ var oldStyleNode = document . getElementById ( id ) ;
95+ var keepOldStyleNode = false ;
9696
9797 // Create a new stylesheet node for insertion or (if necessary) replacement
98- var css = document . createElement ( 'style' ) ;
99- css . setAttribute ( 'type' , 'text/css' ) ;
98+ var styleNode = document . createElement ( 'style' ) ;
99+ styleNode . setAttribute ( 'type' , 'text/css' ) ;
100100 if ( sheet . media ) {
101- css . setAttribute ( 'media' , sheet . media ) ;
101+ styleNode . setAttribute ( 'media' , sheet . media ) ;
102102 }
103- css . id = id ;
103+ styleNode . id = id ;
104104
105- if ( ! css . styleSheet ) {
106- css . appendChild ( document . createTextNode ( styles ) ) ;
105+ if ( ! styleNode . styleSheet ) {
106+ styleNode . appendChild ( document . createTextNode ( styles ) ) ;
107107
108- // If new contents match contents of oldCss , don't replace oldCss
109- keepOldCss = ( oldCss !== null && oldCss . childNodes . length > 0 && css . childNodes . length > 0 &&
110- oldCss . firstChild . nodeValue === css . firstChild . nodeValue ) ;
108+ // If new contents match contents of oldStyleNode , don't replace oldStyleNode
109+ keepOldStyleNode = ( oldStyleNode !== null && oldStyleNode . childNodes . length > 0 && styleNode . childNodes . length > 0 &&
110+ oldStyleNode . firstChild . nodeValue === styleNode . firstChild . nodeValue ) ;
111111 }
112112
113113 var head = document . getElementsByTagName ( 'head' ) [ 0 ] ;
114114
115- // If there is no oldCss , just append; otherwise, only append if we need
116- // to replace oldCss with an updated stylesheet
117- if ( oldCss === null || keepOldCss === false ) {
115+ // If there is no oldStyleNode , just append; otherwise, only append if we need
116+ // to replace oldStyleNode with an updated stylesheet
117+ if ( oldStyleNode === null || keepOldStyleNode === false ) {
118118 var nextEl = sheet && sheet . nextSibling || null ;
119119 if ( nextEl ) {
120- nextEl . parentNode . insertBefore ( css , nextEl ) ;
120+ nextEl . parentNode . insertBefore ( styleNode , nextEl ) ;
121121 } else {
122- head . appendChild ( css ) ;
122+ head . appendChild ( styleNode ) ;
123123 }
124124 }
125- if ( oldCss && keepOldCss === false ) {
126- oldCss . parentNode . removeChild ( oldCss ) ;
125+ if ( oldStyleNode && keepOldStyleNode === false ) {
126+ oldStyleNode . parentNode . removeChild ( oldStyleNode ) ;
127127 }
128128
129129 // For IE.
130130 // This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash.
131131 // See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head
132- if ( css . styleSheet ) {
132+ if ( styleNode . styleSheet ) {
133133 try {
134- css . styleSheet . cssText = styles ;
134+ styleNode . styleSheet . cssText = styles ;
135135 } catch ( e ) {
136136 throw new Error ( "Couldn't reassign styleSheet.cssText." ) ;
137137 }
@@ -1092,7 +1092,7 @@ var abstractFileManager = function() {
10921092
10931093abstractFileManager . prototype . getPath = function ( filename ) {
10941094 var j = filename . lastIndexOf ( '?' ) ;
1095- if ( j < 0 ) {
1095+ if ( j > 0 ) {
10961096 filename = filename . slice ( 0 , j ) ;
10971097 }
10981098 j = filename . lastIndexOf ( '/' ) ;
@@ -1719,16 +1719,16 @@ var functionRegistry = require("./function-registry");
17191719
17201720var functionCaller = function ( name , context , index , currentFileInfo ) {
17211721 this . name = name . toLowerCase ( ) ;
1722- this . function = functionRegistry . get ( this . name ) ;
1722+ this . func = functionRegistry . get ( this . name ) ;
17231723 this . index = index ;
17241724 this . context = context ;
17251725 this . currentFileInfo = currentFileInfo ;
17261726} ;
17271727functionCaller . prototype . isValid = function ( ) {
1728- return Boolean ( this . function ) ;
1728+ return Boolean ( this . func ) ;
17291729} ;
17301730functionCaller . prototype . call = function ( args ) {
1731- return this . function . apply ( this , args ) ;
1731+ return this . func . apply ( this , args ) ;
17321732} ;
17331733
17341734module . exports = functionCaller ;
@@ -2208,7 +2208,7 @@ module.exports = function(environment, fileManagers) {
22082208 var SourceMapOutput , SourceMapBuilder , ParseTree , ImportManager , Environment ;
22092209
22102210 var less = {
2211- version : [ 2 , 0 , "0-b2 " ] ,
2211+ version : [ 2 , 0 , "0" ] ,
22122212 data : require ( './data' ) ,
22132213 tree : require ( './tree' ) ,
22142214 Environment : ( Environment = require ( "./environment/environment" ) ) ,
@@ -2267,7 +2267,14 @@ var LessError = module.exports = function LessError(e, importManager, currentFil
22672267 this . stack = e . stack ;
22682268} ;
22692269
2270- LessError . prototype = Object . create ( Error . prototype ) ;
2270+ if ( typeof Object . create === 'undefined' ) {
2271+ var F = function ( ) { } ;
2272+ F . prototype = Error . prototype ;
2273+ LessError . prototype = new F ( ) ;
2274+ } else {
2275+ LessError . prototype = Object . create ( Error . prototype ) ;
2276+ }
2277+
22712278LessError . prototype . constructor = LessError ;
22722279
22732280} , { "./utils" :79 } ] , 31 :[ function ( require , module , exports ) {
@@ -4021,6 +4028,10 @@ var Parser = function Parser(context, imports, fileInfo) {
40214028 hasBlock = true;
40224029 break;
40234030 */
4031+ case "@counter-style" :
4032+ hasIdentifier = true ;
4033+ hasBlock = true ;
4034+ break ;
40244035 case "@charset" :
40254036 hasIdentifier = true ;
40264037 hasBlock = false ;
@@ -4900,13 +4911,11 @@ Call.prototype.accept = function (visitor) {
49004911} ;
49014912//
49024913// When evaluating a function call,
4903- // we either find the function in `less.functions` [1] ,
4914+ // we either find the function in the functionRegistry ,
49044915// in which case we call it, passing the evaluated arguments,
49054916// if this returns null or we cannot find the function, we
49064917// simply print it out as it appeared originally [2].
49074918//
4908- // The *functions.js* file contains the built-in functions.
4909- //
49104919// The reason why we evaluate the arguments, is in the case where
49114920// we try to pass a variable to a function, like: `saturate(@color)`.
49124921// The function should receive the value, not the variable.
@@ -7565,7 +7574,11 @@ var Node = require("./node"),
75657574var Unit = function ( numerator , denominator , backupUnit ) {
75667575 this . numerator = numerator ? numerator . slice ( 0 ) . sort ( ) : [ ] ;
75677576 this . denominator = denominator ? denominator . slice ( 0 ) . sort ( ) : [ ] ;
7568- this . backupUnit = backupUnit ;
7577+ if ( backupUnit ) {
7578+ this . backupUnit = backupUnit ;
7579+ } else if ( numerator && numerator . length ) {
7580+ this . backupUnit = numerator [ 0 ] ;
7581+ }
75697582} ;
75707583
75717584Unit . prototype = new Node ( ) ;
@@ -7574,13 +7587,11 @@ Unit.prototype.clone = function () {
75747587 return new Unit ( this . numerator . slice ( 0 ) , this . denominator . slice ( 0 ) , this . backupUnit ) ;
75757588} ;
75767589Unit . prototype . genCSS = function ( context , output ) {
7577- if ( this . numerator . length >= 1 ) {
7578- output . add ( this . numerator [ 0 ] ) ;
7579- } else
7580- if ( this . denominator . length >= 1 ) {
7581- output . add ( this . denominator [ 0 ] ) ;
7582- } else
7583- if ( ( ! context || ! context . strictUnits ) && this . backupUnit ) {
7590+ // Dimension checks the unit is singular and throws an error if in strict math mode.
7591+ var strictUnits = context && context . strictUnits ;
7592+ if ( this . numerator . length === 1 ) {
7593+ output . add ( this . numerator [ 0 ] ) ; // the ideal situation
7594+ } else if ( ! strictUnits && this . backupUnit ) {
75847595 output . add ( this . backupUnit ) ;
75857596 }
75867597} ;
@@ -7640,21 +7651,15 @@ Unit.prototype.usedUnits = function() {
76407651 return result ;
76417652} ;
76427653Unit . prototype . cancel = function ( ) {
7643- var counter = { } , atomicUnit , i , backup ;
7654+ var counter = { } , atomicUnit , i ;
76447655
76457656 for ( i = 0 ; i < this . numerator . length ; i ++ ) {
76467657 atomicUnit = this . numerator [ i ] ;
7647- if ( ! backup ) {
7648- backup = atomicUnit ;
7649- }
76507658 counter [ atomicUnit ] = ( counter [ atomicUnit ] || 0 ) + 1 ;
76517659 }
76527660
76537661 for ( i = 0 ; i < this . denominator . length ; i ++ ) {
76547662 atomicUnit = this . denominator [ i ] ;
7655- if ( ! backup ) {
7656- backup = atomicUnit ;
7657- }
76587663 counter [ atomicUnit ] = ( counter [ atomicUnit ] || 0 ) - 1 ;
76597664 }
76607665
@@ -7677,10 +7682,6 @@ Unit.prototype.cancel = function () {
76777682 }
76787683 }
76797684
7680- if ( this . numerator . length === 0 && this . denominator . length === 0 && backup ) {
7681- this . backupUnit = backup ;
7682- }
7683-
76847685 this . numerator . sort ( ) ;
76857686 this . denominator . sort ( ) ;
76867687} ;
0 commit comments