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

New change #4221

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 3 additions & 7 deletions packages/less/src/less-browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// index.js
// Should expose the additional browser functions on to the less object
//


import {addDataAttr} from './utils';
import lessRoot from '../less';
import browser from './browser';
Expand Down Expand Up @@ -47,13 +49,7 @@
}

// only really needed for phantom
function bind(func, thisArg) {
const curryArgs = Array.prototype.slice.call(arguments, 2);
return function() {
const args = curryArgs.concat(Array.prototype.slice.call(arguments, 0));
return func.apply(thisArg, args);
};
}
//removed phantom
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just unrelated cleanup?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just cleaned up the phantom js code


function loadStyles(modifyVars) {
const styles = document.getElementsByTagName('style');
Expand All @@ -70,7 +66,7 @@
/* jshint loopfunc:true */
// use closure to store current style
less.render(lessText, instanceOptions,
bind((style, e, result) => {

Check failure on line 69 in packages/less/src/less-browser/index.js

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest with node18

'bind' is not defined

Check failure on line 69 in packages/less/src/less-browser/index.js

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest with node10

'bind' is not defined

Check failure on line 69 in packages/less/src/less-browser/index.js

View workflow job for this annotation

GitHub Actions / Tests on ubuntu-latest with node19

'bind' is not defined
if (e) {
errors.add(e, 'inline');
} else {
Expand Down
27 changes: 17 additions & 10 deletions packages/less/src/less/functions/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,24 @@ const minMax = function (isMin, args) {
return new Anonymous(`${isMin ? 'min' : 'max'}(${args})`);
};

export default {
min: function(...args) {
try {
return minMax.call(this, true, args);
} catch (e) {}
},
max: function(...args) {
function evaluateWithFallback(func, context) {
return function (...args) {
try {
return minMax.call(this, false, args);
} catch (e) {}
},
return func.apply(context, args);
} catch (e) {
// Return the original node as-is if evaluation fails
return args
}
};
}

export default {
min: evaluateWithFallback(function (...args) {
return minMax.call(this, true, args);
}, this),
max: evaluateWithFallback(function (...args) {
return minMax.call(this, false, args);
}, this),
convert: function (val, unit) {
return val.convertTo(unit.value);
},
Expand Down