Skip to content

max = Math.min(..) not needed, we know len < olen #1746

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

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 9 additions & 9 deletions lib/less/tree/selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ tree.Selector.prototype = {
match: function (other) {
var elements = this.elements,
len = elements.length,
oelements, olen, max, i;
oelements, olen, i;

oelements = other.elements.slice(
(other.elements.length && other.elements[0].value === "&") ? 1 : 0);
olen = oelements.length;
max = Math.min(len, olen);


if (olen === 0 || len < olen) {
return 0;
} else {
for (i = 0; i < max; i++) {
if (elements[i].value !== oelements[i].value) {
return 0;
}
}

for (i = 0; i < olen; i++) {
if (elements[i].value !== oelements[i].value) {
return 0;
}
}
return max; // return number of matched selectors

return olen; // return number of matched selectors
},
eval: function (env) {
var evaldCondition = this.condition && this.condition.eval(env),
Expand Down