Skip to content

Commit 33a3830

Browse files
authored
Fixes: #3300 (#3301)
* Fixes: #3300 * Small fixes for color functions * Remove package-lock file * Add package-lock to gitignore
1 parent 4e903e8 commit 33a3830

File tree

13 files changed

+69
-6204
lines changed

13 files changed

+69
-6204
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
# npm
1111
node_modules
12+
package-lock.json
1213
npm-debug.log
1314

1415
# project-specific

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ module.exports = function (grunt) {
292292
keepRunner: true,
293293
host: 'http://localhost:8081/',
294294
vendor: [
295+
'./node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js',
295296
'test/browser/vendor/promise.js',
296297
'test/browser/jasmine-jsreporter.js',
297298
'test/browser/common.js',

lib/less-browser/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ module.exports = function(window, options) {
3030
var typePattern = /^text\/(x-)?less$/;
3131

3232
function clone(obj) {
33-
return JSON.parse(JSON.stringify(obj || {}));
33+
var cloned = {};
34+
for (var prop in obj) {
35+
if (obj.hasOwnProperty(prop)) {
36+
cloned[prop] = obj[prop];
37+
}
38+
}
39+
return cloned;
3440
}
3541

3642
// only really needed for phantom

lib/less/source-map-output.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = function (environment) {
5858
sourceColumns,
5959
i;
6060

61-
if (fileInfo) {
61+
if (fileInfo && fileInfo.filename) {
6262
var inputSource = this._contentsMap[fileInfo.filename];
6363

6464
// remove vars/banner added to the top of the file
@@ -77,7 +77,7 @@ module.exports = function (environment) {
7777
lines = chunk.split('\n');
7878
columns = lines[lines.length - 1];
7979

80-
if (fileInfo) {
80+
if (fileInfo && fileInfo.filename) {
8181
if (!mapLines) {
8282
this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},
8383
original: { line: sourceLines.length, column: sourceColumns.length},

lib/less/tree/color.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ Color.prototype.toCSS = function (context, doNotCompress) {
8282
colorFunction = 'rgba';
8383
}
8484
} else if (this.value.indexOf('hsl') === 0) {
85-
if (alpha === 1) {
86-
colorFunction = 'hsl';
87-
} else {
85+
if (alpha < 1) {
8886
colorFunction = 'hsla';
87+
} else {
88+
colorFunction = 'hsl';
8989
}
9090
} else {
9191
return this.value;

lib/less/utils.js

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* jshint proto: true */
22
var Constants = require('./constants');
3+
var clone = require('clone');
34

45
var utils = {
56
getLocation: function(index, inputStream) {
@@ -39,6 +40,9 @@ var utils = {
3940
return cloned;
4041
},
4142
copyOptions: function(obj1, obj2) {
43+
if (obj2 && obj2._defaults) {
44+
return obj2;
45+
}
4246
var opts = utils.defaults(obj1, obj2);
4347
if (opts.strictMath) {
4448
opts.math = Constants.Math.STRICT_LEGACY;
@@ -79,26 +83,15 @@ var utils = {
7983
return opts;
8084
},
8185
defaults: function(obj1, obj2) {
82-
if (!obj2._defaults || obj2._defaults !== obj1) {
83-
for (var prop in obj1) {
84-
if (obj1.hasOwnProperty(prop)) {
85-
if (!obj2.hasOwnProperty(prop)) {
86-
obj2[prop] = obj1[prop];
87-
}
88-
else if (Array.isArray(obj1[prop])
89-
&& Array.isArray(obj2[prop])) {
90-
91-
obj1[prop].forEach(function(p) {
92-
if (obj2[prop].indexOf(p) === -1) {
93-
obj2[prop].push(p);
94-
}
95-
});
96-
}
97-
}
98-
}
86+
var newObj = obj2 || {};
87+
if (!obj2._defaults) {
88+
newObj = {};
89+
var defaults = clone(obj1);
90+
newObj._defaults = defaults;
91+
var cloned = obj2 ? clone(obj2) : {};
92+
Object.assign(newObj, defaults, cloned);
9993
}
100-
obj2._defaults = obj1;
101-
return obj2;
94+
return newObj;
10295
},
10396
merge: function(obj1, obj2) {
10497
for (var prop in obj2) {

0 commit comments

Comments
 (0)