-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 #1880 - Adds two new math modes and deprecates strictMath #3274
Changes from 3 commits
f9ab84a
d5f669e
76c1034
7f9435f
556ea61
78c38e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,5 @@ module.exports = function(window, options) { | |
options.onReady = true; | ||
} | ||
|
||
// TODO: deprecate and remove 'inlineJavaScript' thing - where it came from at all? | ||
options.javascriptEnabled = (options.javascriptEnabled || options.inlineJavaScript) ? true : false; | ||
|
||
options.javascriptEnabled = options.javascriptEnabled ? true : false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should just remove this line. I was just removing the |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,9 +48,13 @@ var lessc_helper = { | |
console.log(' -rp, --rootpath=URL Sets rootpath for url rewriting in relative imports and urls'); | ||
console.log(' Works with or without the relative-urls option.'); | ||
console.log(' -ru, --relative-urls Re-writes relative urls to the base less file.'); | ||
console.log(' -sm=on|off Turns on or off strict math, where in strict mode, math.'); | ||
console.log(' --strict-math=on|off Requires brackets. This option may default to on and then'); | ||
console.log(' be removed in the future.'); | ||
console.log(''); | ||
console.log(' -m=, --math='); | ||
console.log(' always Less will eagerly perform math operations always.'); | ||
console.log(' parens-division Math performed except for division (/) operator'); | ||
console.log(' parens-all Math only performed inside parentheses'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mentioned in a separate comment, I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do |
||
console.log(' strict-legacy Parens required in very strict terms (legacy --strict-math)'); | ||
console.log(''); | ||
console.log(' -su=on|off Allows mixed units, e.g. 1px+1em or 1px*1px which have units'); | ||
console.log(' --strict-units=on|off that cannot be represented.'); | ||
console.log(' --global-var=\'VAR=VALUE\' Defines a variable that can be referenced by the file.'); | ||
|
@@ -64,6 +68,9 @@ var lessc_helper = { | |
console.log(' or --clean-css="advanced"'); | ||
console.log(''); | ||
console.log('-------------------------- Deprecated ----------------'); | ||
console.log(' -sm=on|off Legacy parens-only math. Use --math'); | ||
console.log(' --strict-math=on|off '); | ||
console.log(''); | ||
console.log(' --line-numbers=TYPE Outputs filename and line numbers.'); | ||
console.log(' TYPE can be either \'comments\', which will output'); | ||
console.log(' the debug info within comments, \'mediaquery\''); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
ALWAYS: 0, | ||
PARENS_DIVISION: 1, | ||
PARENS_ALL: 2, | ||
STRICT_LEGACY: 3 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Speaking of style guides, you have any strong opinion on comma dangle? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comma dangles shouldn't go in, probably, for compatibility reasons. |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1920,7 +1920,7 @@ var Parser = function Parser(context, imports, fileInfo) { | |
|
||
parserInput.save(); | ||
|
||
op = parserInput.$char('/') || parserInput.$char('*'); | ||
op = parserInput.$char('/') || parserInput.$char('*') || parserInput.$str('./'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I love the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
if (!op) { parserInput.forget(); break; } | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/* jshint proto: true */ | ||
var MATH = require('./math-constants'); | ||
|
||
var utils = { | ||
getLocation: function(index, inputStream) { | ||
var n = index + 1, | ||
|
@@ -36,6 +38,28 @@ var utils = { | |
} | ||
return cloned; | ||
}, | ||
copyOptions: function(obj1, obj2) { | ||
var opts = utils.defaults(obj1, obj2); | ||
if (opts.strictMath) { | ||
opts.math = MATH.STRICT_LEGACY; | ||
} | ||
if (opts.hasOwnProperty('math') && typeof opts.math === 'string') { | ||
switch (opts.math.toLowerCase()) { | ||
case 'always': | ||
opts.math = MATH.ALWAYS; | ||
break; | ||
case 'parens-division': | ||
opts.math = MATH.PARENS_DIVISION; | ||
break; | ||
case 'parens-all': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We had talked about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It was, but after sleeping on it, I realized it might make the concept easier for people switching to decide which one to use. |
||
opts.math = MATH.PARENS_ALL; | ||
break; | ||
case 'strict-legacy': | ||
opts.math = MATH.STRICT_LEGACY; | ||
} | ||
} | ||
return opts; | ||
}, | ||
defaults: function(obj1, obj2) { | ||
if (!obj2._defaults || obj2._defaults !== obj1) { | ||
for (var prop in obj1) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
var less = { | ||
strictUnits: true, | ||
strictMath: true, | ||
math: 'strict-legacy', | ||
logLevel: 4, | ||
javascriptEnabled: true | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
var less = { | ||
logLevel: 4, | ||
errorReporting: 'console', | ||
strictMath: false, | ||
math: 'always', | ||
strictUnits: false | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,4 +223,6 @@ html { | |
e: ; | ||
f: 6; | ||
/* results in void */ | ||
color: green; | ||
color: purple; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@media (min-width: 16 + 1) { | ||
.foo { | ||
bar: 1; | ||
} | ||
} | ||
@media (min-width: 16 / 9) { | ||
.foo { | ||
bar: 1; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This warning could specify
--math=parens
, maybe.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, yes. Will change it.