-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
69 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "less", | ||
"version": "2.0.0-b3", | ||
"version": "2.0.0", | ||
"main": "./dist/less.js", | ||
"ignore": [ | ||
"**/.*", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*! | ||
* Less - Leaner CSS v2.0.0-b3 | ||
* Less - Leaner CSS v2.0.0 | ||
* http://lesscss.org | ||
* | ||
* Copyright (c) 2009-2014, Alexis Sellier <[email protected]> | ||
|
@@ -91,47 +91,47 @@ module.exports = { | |
var id = 'less:' + (sheet.title || utils.extractId(href)); | ||
|
||
// If this has already been inserted into the DOM, we may need to replace it | ||
var oldCss = document.getElementById(id); | ||
var keepOldCss = false; | ||
var oldStyleNode = document.getElementById(id); | ||
var keepOldStyleNode = false; | ||
|
||
// Create a new stylesheet node for insertion or (if necessary) replacement | ||
var css = document.createElement('style'); | ||
css.setAttribute('type', 'text/css'); | ||
var styleNode = document.createElement('style'); | ||
styleNode.setAttribute('type', 'text/css'); | ||
if (sheet.media) { | ||
css.setAttribute('media', sheet.media); | ||
styleNode.setAttribute('media', sheet.media); | ||
} | ||
css.id = id; | ||
styleNode.id = id; | ||
|
||
if (!css.styleSheet) { | ||
css.appendChild(document.createTextNode(styles)); | ||
if (!styleNode.styleSheet) { | ||
styleNode.appendChild(document.createTextNode(styles)); | ||
|
||
// If new contents match contents of oldCss, don't replace oldCss | ||
keepOldCss = (oldCss !== null && oldCss.childNodes.length > 0 && css.childNodes.length > 0 && | ||
oldCss.firstChild.nodeValue === css.firstChild.nodeValue); | ||
// If new contents match contents of oldStyleNode, don't replace oldStyleNode | ||
keepOldStyleNode = (oldStyleNode !== null && oldStyleNode.childNodes.length > 0 && styleNode.childNodes.length > 0 && | ||
oldStyleNode.firstChild.nodeValue === styleNode.firstChild.nodeValue); | ||
} | ||
|
||
var head = document.getElementsByTagName('head')[0]; | ||
|
||
// If there is no oldCss, just append; otherwise, only append if we need | ||
// to replace oldCss with an updated stylesheet | ||
if (oldCss === null || keepOldCss === false) { | ||
// If there is no oldStyleNode, just append; otherwise, only append if we need | ||
// to replace oldStyleNode with an updated stylesheet | ||
if (oldStyleNode === null || keepOldStyleNode === false) { | ||
var nextEl = sheet && sheet.nextSibling || null; | ||
if (nextEl) { | ||
nextEl.parentNode.insertBefore(css, nextEl); | ||
nextEl.parentNode.insertBefore(styleNode, nextEl); | ||
} else { | ||
head.appendChild(css); | ||
head.appendChild(styleNode); | ||
} | ||
} | ||
if (oldCss && keepOldCss === false) { | ||
oldCss.parentNode.removeChild(oldCss); | ||
if (oldStyleNode && keepOldStyleNode === false) { | ||
oldStyleNode.parentNode.removeChild(oldStyleNode); | ||
} | ||
|
||
// For IE. | ||
// This needs to happen *after* the style element is added to the DOM, otherwise IE 7 and 8 may crash. | ||
// See http://social.msdn.microsoft.com/Forums/en-US/7e081b65-878a-4c22-8e68-c10d39c2ed32/internet-explorer-crashes-appending-style-element-to-head | ||
if (css.styleSheet) { | ||
if (styleNode.styleSheet) { | ||
try { | ||
css.styleSheet.cssText = styles; | ||
styleNode.styleSheet.cssText = styles; | ||
} catch (e) { | ||
throw new Error("Couldn't reassign styleSheet.cssText."); | ||
} | ||
|
@@ -1092,7 +1092,7 @@ var abstractFileManager = function() { | |
|
||
abstractFileManager.prototype.getPath = function (filename) { | ||
var j = filename.lastIndexOf('?'); | ||
if (j < 0) { | ||
if (j > 0) { | ||
filename = filename.slice(0, j); | ||
} | ||
j = filename.lastIndexOf('/'); | ||
|
@@ -1719,16 +1719,16 @@ var functionRegistry = require("./function-registry"); | |
|
||
var functionCaller = function(name, context, index, currentFileInfo) { | ||
this.name = name.toLowerCase(); | ||
this.function = functionRegistry.get(this.name); | ||
this.func = functionRegistry.get(this.name); | ||
this.index = index; | ||
this.context = context; | ||
this.currentFileInfo = currentFileInfo; | ||
}; | ||
functionCaller.prototype.isValid = function() { | ||
return Boolean(this.function); | ||
return Boolean(this.func); | ||
}; | ||
functionCaller.prototype.call = function(args) { | ||
return this.function.apply(this, args); | ||
return this.func.apply(this, args); | ||
}; | ||
|
||
module.exports = functionCaller; | ||
|
@@ -2208,7 +2208,7 @@ module.exports = function(environment, fileManagers) { | |
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment; | ||
|
||
var less = { | ||
version: [2, 0, "0-b2"], | ||
version: [2, 0, "0"], | ||
data: require('./data'), | ||
tree: require('./tree'), | ||
Environment: (Environment = require("./environment/environment")), | ||
|
@@ -2267,7 +2267,14 @@ var LessError = module.exports = function LessError(e, importManager, currentFil | |
this.stack = e.stack; | ||
}; | ||
|
||
LessError.prototype = Object.create(Error.prototype); | ||
if (typeof Object.create === 'undefined') { | ||
var F = function () {}; | ||
F.prototype = Error.prototype; | ||
LessError.prototype = new F(); | ||
} else { | ||
LessError.prototype = Object.create(Error.prototype); | ||
} | ||
|
||
LessError.prototype.constructor = LessError; | ||
|
||
},{"./utils":79}],31:[function(require,module,exports){ | ||
|
@@ -4021,6 +4028,10 @@ var Parser = function Parser(context, imports, fileInfo) { | |
hasBlock = true; | ||
break; | ||
*/ | ||
case "@counter-style": | ||
hasIdentifier = true; | ||
hasBlock = true; | ||
break; | ||
case "@charset": | ||
hasIdentifier = true; | ||
hasBlock = false; | ||
|
@@ -4900,13 +4911,11 @@ Call.prototype.accept = function (visitor) { | |
}; | ||
// | ||
// When evaluating a function call, | ||
// we either find the function in `less.functions` [1], | ||
// we either find the function in the functionRegistry, | ||
// in which case we call it, passing the evaluated arguments, | ||
// if this returns null or we cannot find the function, we | ||
// simply print it out as it appeared originally [2]. | ||
// | ||
// The *functions.js* file contains the built-in functions. | ||
// | ||
// The reason why we evaluate the arguments, is in the case where | ||
// we try to pass a variable to a function, like: `saturate(@color)`. | ||
// The function should receive the value, not the variable. | ||
|
@@ -7565,7 +7574,11 @@ var Node = require("./node"), | |
var Unit = function (numerator, denominator, backupUnit) { | ||
this.numerator = numerator ? numerator.slice(0).sort() : []; | ||
this.denominator = denominator ? denominator.slice(0).sort() : []; | ||
this.backupUnit = backupUnit; | ||
if (backupUnit) { | ||
this.backupUnit = backupUnit; | ||
} else if (numerator && numerator.length) { | ||
this.backupUnit = numerator[0]; | ||
} | ||
}; | ||
|
||
Unit.prototype = new Node(); | ||
|
@@ -7574,13 +7587,11 @@ Unit.prototype.clone = function () { | |
return new Unit(this.numerator.slice(0), this.denominator.slice(0), this.backupUnit); | ||
}; | ||
Unit.prototype.genCSS = function (context, output) { | ||
if (this.numerator.length >= 1) { | ||
output.add(this.numerator[0]); | ||
} else | ||
if (this.denominator.length >= 1) { | ||
output.add(this.denominator[0]); | ||
} else | ||
if ((!context || !context.strictUnits) && this.backupUnit) { | ||
// Dimension checks the unit is singular and throws an error if in strict math mode. | ||
var strictUnits = context && context.strictUnits; | ||
if (this.numerator.length === 1) { | ||
output.add(this.numerator[0]); // the ideal situation | ||
} else if (!strictUnits && this.backupUnit) { | ||
output.add(this.backupUnit); | ||
} | ||
}; | ||
|
@@ -7640,21 +7651,15 @@ Unit.prototype.usedUnits = function() { | |
return result; | ||
}; | ||
Unit.prototype.cancel = function () { | ||
var counter = {}, atomicUnit, i, backup; | ||
var counter = {}, atomicUnit, i; | ||
|
||
for (i = 0; i < this.numerator.length; i++) { | ||
atomicUnit = this.numerator[i]; | ||
if (!backup) { | ||
backup = atomicUnit; | ||
} | ||
counter[atomicUnit] = (counter[atomicUnit] || 0) + 1; | ||
} | ||
|
||
for (i = 0; i < this.denominator.length; i++) { | ||
atomicUnit = this.denominator[i]; | ||
if (!backup) { | ||
backup = atomicUnit; | ||
} | ||
counter[atomicUnit] = (counter[atomicUnit] || 0) - 1; | ||
} | ||
|
||
|
@@ -7677,10 +7682,6 @@ Unit.prototype.cancel = function () { | |
} | ||
} | ||
|
||
if (this.numerator.length === 0 && this.denominator.length === 0 && backup) { | ||
this.backupUnit = backup; | ||
} | ||
|
||
this.numerator.sort(); | ||
this.denominator.sort(); | ||
}; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters