From 2808bc2c902d7ea6414841d50561ddd7ac313128 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 26 Jan 2015 01:32:37 +1100 Subject: [PATCH] add in custom acorn node constructor --- lib/6to5/patch.js | 2 ++ lib/6to5/types/index.js | 5 ++++- lib/6to5/types/node.js | 11 +++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 lib/6to5/types/node.js diff --git a/lib/6to5/patch.js b/lib/6to5/patch.js index 4bc79909c5..b20d9d1d38 100644 --- a/lib/6to5/patch.js +++ b/lib/6to5/patch.js @@ -3,6 +3,8 @@ var t = require("./types"); var _ = require("lodash"); +require("./types/node"); + // estraverse var estraverse = require("estraverse"); diff --git a/lib/6to5/types/index.js b/lib/6to5/types/index.js index 1f33acb85a..8886e2da0b 100644 --- a/lib/6to5/types/index.js +++ b/lib/6to5/types/index.js @@ -2,6 +2,7 @@ var toFastProperties = require("../helpers/to-fast-properties"); var esutils = require("esutils"); +var Node = require("./node"); var _ = require("lodash"); var t = exports; @@ -100,7 +101,9 @@ t.BUILDER_KEYS = _.defaults(require("./builder-keys"), t.VISITOR_KEYS); _.each(t.BUILDER_KEYS, function (keys, type) { t[type[0].toLowerCase() + type.slice(1)] = function () { var args = arguments; - var node = { type: type }; + var node = new Node; + node.start = null; + node.type = type; _.each(keys, function (key, i) { node[key] = args[i]; }); diff --git a/lib/6to5/types/node.js b/lib/6to5/types/node.js new file mode 100644 index 0000000000..411fe40b26 --- /dev/null +++ b/lib/6to5/types/node.js @@ -0,0 +1,11 @@ +module.exports = Node; + +var object = require("../helpers/object"); +var acorn = require("acorn-6to5"); + +var oldNode = acorn.Node; +acorn.Node = Node; + +function Node() { + oldNode.apply(this); +}