Skip to content

Commit

Permalink
v2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeapage committed Nov 9, 2014
1 parent 06a97bc commit 89b5e04
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 57 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 2.0.0

2014-11-09

- Fixed multiplication in non strict units mode to take the left operand unit, in the case that the unit cannot be resolved
- Some fixes for browser cross-compatibility
- browser tests now pass in IE 8-11 and FF
- added index.js and browser.js in root as shortcuts
- fixed some local variable spellings
- support for @counter-style directive

# 2.0.0-b3

2014-11-01
Expand Down
2 changes: 1 addition & 1 deletion bower.json
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": [
"**/.*",
Expand Down
99 changes: 50 additions & 49 deletions dist/less.js
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 <self@cloudhead.net>
Expand Down Expand Up @@ -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.");
}
Expand Down Expand Up @@ -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('/');
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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")),
Expand Down Expand Up @@ -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){
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand All @@ -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);
}
};
Expand Down Expand Up @@ -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;
}

Expand All @@ -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();
};
Expand Down
10 changes: 5 additions & 5 deletions dist/less.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/less/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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")),
Expand Down
2 changes: 1 addition & 1 deletion package.json
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",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
Expand Down

0 comments on commit 89b5e04

Please sign in to comment.