Skip to content

Commit c82fc26

Browse files
authored
Merge pull request ben-ng#12 from loganfsmyth/cleared-source-fix
Allow mappings with no source.
2 parents a1ddd16 + 61a687b commit c82fc26

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ validateMapping = function (mapping) {
3131
assert.ok(mapping.generatedColumn >= 0, 'generated column must be greater or equal to zero, mapping: ' + prettyMapping);
3232
assert.ok(mapping.generatedLine >= 0, 'generated line must be greater or equal to zero: ' + prettyMapping);
3333

34-
assert.ok(mapping.originalColumn!=null, 'missing original column, mapping: ' + prettyMapping);
35-
assert.ok(mapping.originalLine!=null, 'missing original line, mapping: ' + prettyMapping);
36-
assert.ok(mapping.originalColumn >= 0, 'original column must be greater or equal to zero, mapping: ' + prettyMapping);
37-
assert.ok(mapping.originalLine >= 0, 'original line must be greater or equal to zero, mapping: ' + prettyMapping);
38-
39-
assert.notEqual(mapping.source, null, 'source is missing');
34+
// If the source is null, the original location data has been explicitly
35+
// omitted from the map to clear the mapped state of a line.
36+
if (typeof mapping.source === "string") {
37+
assert.ok(mapping.originalColumn!=null, 'missing original column, mapping: ' + prettyMapping);
38+
assert.ok(mapping.originalLine!=null, 'missing original line, mapping: ' + prettyMapping);
39+
assert.ok(mapping.originalColumn >= 0, 'original column must be greater or equal to zero, mapping: ' + prettyMapping);
40+
assert.ok(mapping.originalLine >= 0, 'original line must be greater or equal to zero, mapping: ' + prettyMapping);
41+
}
4042
};
4143

4244
// Validates an entire sourcemap

tests/fixtures/valid/Babel/router.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/unit.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,13 @@ tests['Valid Minifyified bundle with inline sourcemap should not throw'] = funct
9292
}, 'Valid Minifyified inline sourcemap and inline sourceContent should not throw');
9393
};
9494

95+
tests['Valid Babel map should not throw'] = function () {
96+
var babelDir = path.join(validDir, 'Babel')
97+
, map = fs.readFileSync(path.join(babelDir, 'router.js.map')).toString();
98+
99+
assert.doesNotThrow(function () {
100+
validate(null, map);
101+
}, 'Valid Minifyified inline sourcemap and inline sourceContent should not throw');
102+
};
103+
95104
module.exports = tests;

0 commit comments

Comments
 (0)