mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
do not evaluate backticks in strings as inline-js
This commit is contained in:
@@ -10,7 +10,7 @@ var Quoted = function (str, content, escaped, index, currentFileInfo) {
|
||||
this._index = index;
|
||||
this._fileInfo = currentFileInfo;
|
||||
};
|
||||
Quoted.prototype = new JsEvalNode();
|
||||
Quoted.prototype = new Node();
|
||||
Quoted.prototype.type = "Quoted";
|
||||
Quoted.prototype.genCSS = function (context, output) {
|
||||
if (!this.escaped) {
|
||||
@@ -22,13 +22,10 @@ Quoted.prototype.genCSS = function (context, output) {
|
||||
}
|
||||
};
|
||||
Quoted.prototype.containsVariables = function() {
|
||||
return this.value.match(/(`([^`]+)`)|@\{([\w-]+)\}/);
|
||||
return this.value.match(/@\{([\w-]+)\}/);
|
||||
};
|
||||
Quoted.prototype.eval = function (context) {
|
||||
var that = this, value = this.value;
|
||||
var javascriptReplacement = function (_, exp) {
|
||||
return String(that.evaluateJavaScript(exp, context));
|
||||
};
|
||||
var variableReplacement = function (_, name) {
|
||||
var v = new Variable('@' + name, that.getIndex(), that.fileInfo()).eval(context, true);
|
||||
return (v instanceof Quoted) ? v.value : v.toCSS();
|
||||
@@ -45,7 +42,6 @@ Quoted.prototype.eval = function (context) {
|
||||
} while (value !== evaluatedValue);
|
||||
return evaluatedValue;
|
||||
}
|
||||
value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement);
|
||||
value = iterativeReplace(value, /@\{([\w-]+)\}/g, variableReplacement);
|
||||
value = iterativeReplace(value, /\$\{([\w-]+)\}/g, propertyReplacement);
|
||||
return new Quoted(this.quote + value + this.quote, value, this.escaped, this.getIndex(), this.fileInfo());
|
||||
|
||||
Reference in New Issue
Block a user