Skip to content

Commit

Permalink
Merge pull request #163 from ggoodman/fix-clone-intro-outro
Browse files Browse the repository at this point in the history
Clones intro and outro of MagicString
  • Loading branch information
Rich-Harris committed Sep 30, 2019
2 parents a312519 + 93d0e4b commit 68fcedc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/MagicString.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export default class MagicString {
cloned.sourcemapLocations[loc] = true;
});

cloned.intro = this.intro;
cloned.outro = this.outro;

return cloned;
}

Expand Down
11 changes: 11 additions & 0 deletions test/MagicString.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ describe('MagicString', () => {
assert.notStrictEqual(source.sourcemapLocations, clone.sourcemapLocations);
assert.deepEqual(source.sourcemapLocations, clone.sourcemapLocations);
});

it('should clone intro and outro', () => {
const source = new MagicString('defghi');

source.prepend('abc');
source.append('jkl');

const clone = source.clone();

assert.equal(source.toString(), clone.toString());
});
});

describe('generateMap', () => {
Expand Down

0 comments on commit 68fcedc

Please sign in to comment.