parent
ff72eaa3c3
commit
b39228892d
12
lib/parse.js
12
lib/parse.js
|
|
@ -241,16 +241,16 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
|
||||||
if (signal_eof && !ch)
|
if (signal_eof && !ch)
|
||||||
throw EX_EOF;
|
throw EX_EOF;
|
||||||
if (NEWLINE_CHARS[ch]) {
|
if (NEWLINE_CHARS[ch]) {
|
||||||
S.newline_before = S.newline_before || !in_string;
|
|
||||||
++S.line;
|
|
||||||
S.col = 0;
|
S.col = 0;
|
||||||
if (!in_string && ch == "\r" && peek() == "\n") {
|
S.line++;
|
||||||
// treat a \r\n sequence as a single \n
|
if (!in_string) S.newline_before = true;
|
||||||
++S.pos;
|
if (ch == "\r" && peek() == "\n") {
|
||||||
|
// treat `\r\n` as `\n`
|
||||||
|
S.pos++;
|
||||||
ch = "\n";
|
ch = "\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
++S.col;
|
S.col++;
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,22 @@ describe("sourcemaps", function() {
|
||||||
assert.strictEqual(result.code, code);
|
assert.strictEqual(result.code, code);
|
||||||
assert.strictEqual(result.map, '{"version":3,"sources":["0"],"names":["console","log"],"mappings":"AAAAA,QAAQC,IAAI","sourceRoot":"//foo.bar/"}');
|
assert.strictEqual(result.map, '{"version":3,"sources":["0"],"names":["console","log"],"mappings":"AAAAA,QAAQC,IAAI","sourceRoot":"//foo.bar/"}');
|
||||||
});
|
});
|
||||||
|
it("Should produce same source map with DOS or UNIX line endings", function() {
|
||||||
|
var code = [
|
||||||
|
'console.log("\\',
|
||||||
|
'hello",',
|
||||||
|
'"world");',
|
||||||
|
];
|
||||||
|
var dos = UglifyJS.minify(code.join("\r\n"), {
|
||||||
|
sourceMap: true,
|
||||||
|
});
|
||||||
|
if (dos.error) throw dos.error;
|
||||||
|
var unix = UglifyJS.minify(code.join("\n"), {
|
||||||
|
sourceMap: true,
|
||||||
|
});
|
||||||
|
if (unix.error) throw unix.error;
|
||||||
|
assert.strictEqual(dos.map, unix.map);
|
||||||
|
});
|
||||||
|
|
||||||
describe("inSourceMap", function() {
|
describe("inSourceMap", function() {
|
||||||
it("Should read the given string filename correctly when sourceMapIncludeSources is enabled", function() {
|
it("Should read the given string filename correctly when sourceMapIncludeSources is enabled", function() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user