[Pkg-javascript-commits] [less.js] 111/285: Merge branch 'iterated-interpolation-2094' of github.com:SomMeri/less-rhino.js into 2_0_0
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:44 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.0.0
in repository less.js.
commit 6bd327b3f48eaa627af088e1714f6553249c1334
Merge: 723b410 a038121
Author: Luke Page <luke.a.page at gmail.com>
Date: Sat Sep 6 14:39:32 2014 +0100
Merge branch 'iterated-interpolation-2094' of github.com:SomMeri/less-rhino.js into 2_0_0
Conflicts:
lib/less/tree/quoted.js
lib/less/tree/quoted.js | 19 +++++++++++++++----
test/css/strings.css | 12 ++++++++++++
test/less/strings.less | 16 ++++++++++++++++
3 files changed, 43 insertions(+), 4 deletions(-)
diff --cc lib/less/tree/quoted.js
index 3c599a9,6288d80..79c37f7
--- a/lib/less/tree/quoted.js
+++ b/lib/less/tree/quoted.js
@@@ -9,33 -7,61 +9,44 @@@ var Quoted = function (str, content, es
this.index = index;
this.currentFileInfo = currentFileInfo;
};
-tree.Quoted.prototype = {
- type: "Quoted",
- genCSS: function (env, output) {
- if (!this.escaped) {
- output.add(this.quote, this.currentFileInfo, this.index);
- }
- output.add(this.value);
- if (!this.escaped) {
- output.add(this.quote);
- }
- },
- toCSS: tree.toCSS,
- eval: function (env) {
- var that = this, value = this.value;
- var javascriptReplacement = function (_, exp) {
- return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
- };
- var interpolationReplacement = function (_, name) {
- var v = new(tree.Variable)('@' + name, that.index, that.currentFileInfo).eval(env, true);
- return (v instanceof tree.Quoted) ? v.value : v.toCSS();
- };
- function iterativeReplace(value, regexp, replacementFnc) {
+Quoted.prototype = new JsEvalNode();
+Quoted.prototype.type = "Quoted";
+Quoted.prototype.genCSS = function (env, output) {
+ if (!this.escaped) {
+ output.add(this.quote, this.currentFileInfo, this.index);
+ }
+ output.add(this.value);
+ if (!this.escaped) {
+ output.add(this.quote);
+ }
+};
+Quoted.prototype.eval = function (env) {
- var that = this;
- var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
++ var that = this, value = this.value;
++ var javascriptReplacement = function (_, exp) {
+ return String(that.evaluateJavaScript(exp, env));
- }).replace(/@\{([\w-]+)\}/g, function (_, name) {
++ };
++ var interpolationReplacement = function (_, name) {
+ var v = new(Variable)('@' + name, that.index, that.currentFileInfo).eval(env, true);
+ return (v instanceof Quoted) ? v.value : v.toCSS();
- });
++ };
++ function iterativeReplace(value, regexp, replacementFnc) {
+ var evaluatedValue = value;
+ do {
+ value = evaluatedValue;
+ evaluatedValue = value.replace(regexp, replacementFnc);
+ } while (value!==evaluatedValue);
+ return evaluatedValue;
- }
- value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement);
- value = iterativeReplace(value, /@\{([\w-]+)\}/g, interpolationReplacement);
- return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo);
- },
- compare: function (x) {
- if (!x.toCSS) {
- return -1;
- }
-
- var left, right;
-
- // when comparing quoted strings allow the quote to differ
- if (x.type === "Quoted" && !this.escaped && !x.escaped) {
- left = x.value;
- right = this.value;
- } else {
- left = this.toCSS();
- right = x.toCSS();
- }
-
- if (left === right) {
- return 0;
- }
-
- return left < right ? -1 : 1;
+ }
++ value = iterativeReplace(value, /`([^`]+)`/g, javascriptReplacement);
++ value = iterativeReplace(value, /@\{([\w-]+)\}/g, interpolationReplacement);
+ return new(Quoted)(this.quote + value + this.quote, value, this.escaped, this.index, this.currentFileInfo);
};
-
-})(require('../tree'));
+Quoted.prototype.compare = function (other) {
+ // when comparing quoted strings allow the quote to differ
+ if (other.type === "Quoted" && !this.escaped && !other.escaped) {
+ return Node.numericCompare(this.value, other.value);
+ } else {
+ return other.toCSS && this.toCSS() === other.toCSS() ? 0 : undefined;
+ }
+};
+module.exports = Quoted;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list