Skip to content

Commit

Permalink
Fixes #3430: Removed unnecessary 'important' from NamespaceValue. (#3431
Browse files Browse the repository at this point in the history
)
  • Loading branch information
matthew-dean committed May 5, 2020
1 parent 971eb20 commit 9217936
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
10 changes: 3 additions & 7 deletions lib/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ var Parser = function Parser(context, imports, fileInfo) {
// color: @fink[@color];
//
variableCall: function (parsedName) {
var lookups, important, i = parserInput.i,
var lookups, i = parserInput.i,
inValue = !!parsedName, name = parsedName;

parserInput.save();
Expand All @@ -763,18 +763,14 @@ var Parser = function Parser(context, imports, fileInfo) {
name = name[1];
}

if (lookups && parsers.important()) {
important = true;
}

var call = new tree.VariableCall(name, i, fileInfo);
if (!inValue && parsers.end()) {
parserInput.forget();
return call;
}
else {
parserInput.forget();
return new tree.NamespaceValue(call, lookups, important, i, fileInfo);
return new tree.NamespaceValue(call, lookups, i, fileInfo);
}
}

Expand Down Expand Up @@ -893,7 +889,7 @@ var Parser = function Parser(context, imports, fileInfo) {
parserInput.forget();
var mixin = new(tree.mixin.Call)(elements, args, index, fileInfo, !lookups && important);
if (lookups) {
return new tree.NamespaceValue(mixin, lookups, important);
return new tree.NamespaceValue(mixin, lookups);
}
else {
return mixin;
Expand Down
3 changes: 1 addition & 2 deletions lib/less/tree/namespace-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ var Node = require('./node'),
Ruleset = require('./ruleset'),
Selector = require('./selector');

var NamespaceValue = function (ruleCall, lookups, important, index, fileInfo) {
var NamespaceValue = function (ruleCall, lookups, index, fileInfo) {
this.value = ruleCall;
this.lookups = lookups;
this.important = important;
this._index = index;
this._fileInfo = fileInfo;
};
Expand Down
15 changes: 15 additions & 0 deletions test/css/namespacing/namespacing-3.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,18 @@
color: white;
}
}
.cell {
margin: 0 5px !important;
}
.class1 {
color: #33acfe !important;
margin: 20px !important;
padding: 20px !important;
width: 0 !important;
}
.class2 {
color: #efca44;
margin: 10px;
padding: 40px 10px;
width: 0 !important;
}
25 changes: 24 additions & 1 deletion test/less/namespacing/namespacing-3.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,27 @@
background: @map[@colors][toolbar-background];
color: @map[@colors][toolbar-foreground];
}
}
}

// !important after map usage
// https://github.com/less/less.js/issues/3430
@margins: {
zero: 0;
ten: 10px;
}
.cell {
margin: @margins[zero] @margins[ten]/2 !important;
}

.mixin(@color: black; @margin: 10px; @padding: 20px) {
color: @color;
margin: @margin;
padding: @padding;
width: @margins[zero] !important
}
.class1 {
.mixin(@margin: 20px; @color: #33acfe) !important;
}
.class2 {
.mixin(#efca44; @padding: 40px 10px);
}

0 comments on commit 9217936

Please sign in to comment.