diff --git a/lib/output.js b/lib/output.js index 2aa3e982..a7b5e21c 100644 --- a/lib/output.js +++ b/lib/output.js @@ -282,6 +282,14 @@ function OutputStream(options) { var remainder = 0; var offset = 0; var tokenName; + var tokenChars; + var escapable = [ + {find:'\n', replace:'\\n'}, + {find:'\r', replace:'\\r'}, + {find:'\t', replace:'\\t'}, + {find:'\u2028', replace:'\\u2028'}, + {find:'\u2029', replace:'\\u2029'} + ]; tokenName = (!name && token.type == "name") ? token.value : name; @@ -289,6 +297,17 @@ function OutputStream(options) { // Cast to a string, it might be a number tokenName = new String(tokenName); + // Fixes offsets for escaped chars in keys of object literals + tokenChars = tokenName.split(''); + for(var i=0, ii=tokenChars.length; i