Skip to content

Commit

Permalink
Merge pull request #2309 from seven-phases-max/more-input-types-for-r…
Browse files Browse the repository at this point in the history
…eplace

Improve keyword and anonymous input for replace function (fixes #2308).
  • Loading branch information
lukeapage committed Nov 25, 2014
2 parents 7d97027 + ccd49bb commit c2dfa6b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/less/tree/quoted.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var Node = require("./node"),
Variable = require("./variable");

var Quoted = function (str, content, escaped, index, currentFileInfo) {
this.escaped = escaped;
this.escaped = (escaped == null) ? true : escaped;
this.value = content || '';
this.quote = str.charAt(0);
this.index = index;
Expand Down
12 changes: 12 additions & 0 deletions test/css/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,15 @@
extract: 3 2 1 C B A;
length: 6;
}
#quoted-functions-in-mixin {
replace-double-quoted: 'foo-2';
replace-single-quoted: 'foo-4';
replace-escaped-string: bar-2;
replace-keyword: baz-2;
replace-anonymous: qux-2;
format-double-quoted: "hello world";
format-single-quoted: 'hello single world';
format-escaped-string: hello escaped world;
format-keyword: hello;
format-anonymous: hello anonymous world;
}
18 changes: 18 additions & 0 deletions test/less/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,21 @@
extract: extract(@anon, 6) extract(@anon, 5) extract(@anon, 4) extract(@anon, 3) extract(@anon, 2) extract(@anon, 1);
length: length(@anon);
}

#quoted-functions-in-mixin {
// Quoted type may have some weird side-effects when used in mixins (#2308)
.mixin();
.mixin() {
replace-double-quoted: replace('foo-1', "1", "2");
replace-single-quoted: replace('foo-3', "3", "4");
replace-escaped-string: replace(~"bar-1", "1", "2");
replace-keyword: replace(baz-1, "1", "2");
replace-anonymous: replace(e("qux-1"), "1", "2");
format-double-quoted: %("hello %s", "world");
format-single-quoted: %('hello %s', "single world");
format-escaped-string: %(~"hello %s", "escaped world");
format-keyword: %(hello);
format-anonymous: %(e("hello %s"), "anonymous world");
}
}

0 comments on commit c2dfa6b

Please sign in to comment.