Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes: #3300 #3301

Merged
merged 4 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# npm
node_modules
package-lock.json
npm-debug.log

# project-specific
Expand Down
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ module.exports = function (grunt) {
keepRunner: true,
host: 'http://localhost:8081/',
vendor: [
'./node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js',
'test/browser/vendor/promise.js',
'test/browser/jasmine-jsreporter.js',
'test/browser/common.js',
Expand Down
8 changes: 7 additions & 1 deletion lib/less-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ module.exports = function(window, options) {
var typePattern = /^text\/(x-)?less$/;

function clone(obj) {
return JSON.parse(JSON.stringify(obj || {}));
var cloned = {};
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
cloned[prop] = obj[prop];
}
}
return cloned;
}

// only really needed for phantom
Expand Down
4 changes: 2 additions & 2 deletions lib/less/source-map-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ module.exports = function (environment) {
sourceColumns,
i;

if (fileInfo) {
if (fileInfo && fileInfo.filename) {
var inputSource = this._contentsMap[fileInfo.filename];

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

if (fileInfo) {
if (fileInfo && fileInfo.filename) {
if (!mapLines) {
this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},
original: { line: sourceLines.length, column: sourceColumns.length},
Expand Down
6 changes: 3 additions & 3 deletions lib/less/tree/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ Color.prototype.toCSS = function (context, doNotCompress) {
colorFunction = 'rgba';
}
} else if (this.value.indexOf('hsl') === 0) {
if (alpha === 1) {
colorFunction = 'hsl';
} else {
if (alpha < 1) {
colorFunction = 'hsla';
} else {
colorFunction = 'hsl';
}
} else {
return this.value;
Expand Down
31 changes: 12 additions & 19 deletions lib/less/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* jshint proto: true */
var Constants = require('./constants');
var clone = require('clone');

var utils = {
getLocation: function(index, inputStream) {
Expand Down Expand Up @@ -39,6 +40,9 @@ var utils = {
return cloned;
},
copyOptions: function(obj1, obj2) {
if (obj2 && obj2._defaults) {
return obj2;
}
var opts = utils.defaults(obj1, obj2);
if (opts.strictMath) {
opts.math = Constants.Math.STRICT_LEGACY;
Expand Down Expand Up @@ -79,26 +83,15 @@ var utils = {
return opts;
},
defaults: function(obj1, obj2) {
if (!obj2._defaults || obj2._defaults !== obj1) {
for (var prop in obj1) {
if (obj1.hasOwnProperty(prop)) {
if (!obj2.hasOwnProperty(prop)) {
obj2[prop] = obj1[prop];
}
else if (Array.isArray(obj1[prop])
&& Array.isArray(obj2[prop])) {

obj1[prop].forEach(function(p) {
if (obj2[prop].indexOf(p) === -1) {
obj2[prop].push(p);
}
});
}
}
}
var newObj = obj2 || {};
if (!obj2._defaults) {
newObj = {};
var defaults = clone(obj1);
newObj._defaults = defaults;
var cloned = obj2 ? clone(obj2) : {};
Object.assign(newObj, defaults, cloned);
}
obj2._defaults = obj1;
return obj2;
return newObj;
},
merge: function(obj1, obj2) {
for (var prop in obj2) {
Expand Down
Loading