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
batchunag authored and matthew-dean committed Sep 23, 2019
1 parent 3f8a6ae commit ea71dde
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 10 deletions.
9 changes: 2 additions & 7 deletions lib/less/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,6 @@ const Parser = function Parser(context, imports, fileInfo) {
//
variableCall: function (parsedName) {
let lookups;
let important;
const i = parserInput.i;
const inValue = !!parsedName;
let name = parsedName;
Expand All @@ -787,18 +786,14 @@ const Parser = function Parser(context, imports, fileInfo) {
name = name[1];
}

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

const 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 @@ -927,7 +922,7 @@ const Parser = function Parser(context, imports, fileInfo) {
parserInput.forget();
const 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 @@ -4,12 +4,11 @@ import Ruleset from './ruleset';
import Selector from './selector';

class NamespaceValue extends Node {
constructor(ruleCall, lookups, important, index, fileInfo) {
constructor(ruleCall, lookups, index, fileInfo) {
super();

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 ea71dde

Please sign in to comment.