[Pkg-javascript-commits] [less.js] 91/285: move creation of env to invoker

Jonas Smedegaard dr at jones.dk
Mon Oct 26 23:23:42 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 4f5a449b0b654fb75c3fedd5de7e0bac65f4b5e8
Author: Luke Page <luke.a.page at gmail.com>
Date:   Thu Sep 4 18:24:24 2014 +0100

    move creation of env to invoker
---
 lib/less/parser/parser.js | 7 -------
 lib/less/render.js        | 7 +++++--
 test/less-test.js         | 2 +-
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js
index 70027d0..5c323ab 100644
--- a/lib/less/parser/parser.js
+++ b/lib/less/parser/parser.js
@@ -1,7 +1,6 @@
 var LessError = require('../less-error.js'),
     tree = require("../tree/index.js"),
     visitor = require("../visitor/index.js"),
-    contexts = require("../contexts.js"),
     getImportManager = require("./imports.js"),
     getParserInput = require("./parser-input.js"),
     utils = require("../utils.js");
@@ -45,12 +44,6 @@ var Parser = function Parser(env) {
     var parsers,
         parserInput = getParserInput();
 
-    // Top parser on an import tree must be sure there is one "env"
-    // which will then be passed around by reference.
-    if (!(env instanceof contexts.parseEnv)) {
-        env = new contexts.parseEnv(env);
-    }
-
     var imports = getImportManager(environment, env, Parser);
 
     function expect(arg, msg, index) {
diff --git a/lib/less/render.js b/lib/less/render.js
index 4893f94..df31b37 100644
--- a/lib/less/render.js
+++ b/lib/less/render.js
@@ -1,4 +1,5 @@
-var PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise;
+var PromiseConstructor = typeof Promise === 'undefined' ? require('promise') : Promise,
+    contexts = require("./contexts.js");
 
 var render = function(Parser) {
     return function (input, options, callback) {
@@ -18,7 +19,9 @@ var render = function(Parser) {
                     callback(error);
                 });
         } else {
-            var parser = new(Parser)(options);
+            var env = new contexts.parseEnv(options);
+
+            var parser = new(Parser)(env);
 
             return new PromiseConstructor(function (resolve, reject) {
                 parser.parse(input, function (e, root) {
diff --git a/test/less-test.js b/test/less-test.js
index de13db7..9d2a0db 100644
--- a/test/less-test.js
+++ b/test/less-test.js
@@ -231,7 +231,7 @@ module.exports = function() {
         totalTests++;
         try {
             process.stdout.write("- Integration - creating parser without options: ");
-            new(less.Parser)();
+            less.render("");
         } catch(e) {
             fail(stylize("FAIL\n", "red"));
             return;

-- 
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