From c84af909f7b15ea40ec147790ed5efae7990fe02 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 4 Feb 2015 23:10:54 +1100 Subject: [PATCH] track end of node positions for sourcemaps - fixes douglasduteil/isparta#8 --- lib/6to5/generation/index.js | 3 ++- lib/6to5/generation/source-map.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/6to5/generation/index.js b/lib/6to5/generation/index.js index 77cfaaf683..3c284bf009 100644 --- a/lib/6to5/generation/index.js +++ b/lib/6to5/generation/index.js @@ -190,7 +190,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) { newline(true); if (opts.before) opts.before(); - this.map.mark(node); + this.map.mark(node, "start"); this[node.type](node, this.buildPrint(node), parent); @@ -200,6 +200,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) { } if (needsParens) this.push(")"); + this.map.mark(node, "end"); if (opts.after) opts.after(); newline(false); diff --git a/lib/6to5/generation/source-map.js b/lib/6to5/generation/source-map.js index 0300519d8c..74372c1ba4 100644 --- a/lib/6to5/generation/source-map.js +++ b/lib/6to5/generation/source-map.js @@ -30,7 +30,7 @@ SourceMap.prototype.get = function () { } }; -SourceMap.prototype.mark = function (node) { +SourceMap.prototype.mark = function (node, type) { var loc = node.loc; if (!loc) return; // no location info @@ -46,7 +46,7 @@ SourceMap.prototype.mark = function (node) { column: position.column }; - var original = loc.start; + var original = loc[type]; map.addMapping({ source: this.opts.sourceFileName,