diff --git a/src/Chunk.js b/src/Chunk.js index 9798f59..117a917 100644 --- a/src/Chunk.js +++ b/src/Chunk.js @@ -121,12 +121,12 @@ export default class Chunk { if (trimmed.length) { if (trimmed !== this.content) { - this.split(this.start + trimmed.length).edit('', false); + this.split(this.start + trimmed.length).edit('', undefined, true); } return true; } else { - this.edit('', false); + this.edit('', undefined, true); this.intro = this.intro.replace(rx, ''); if (this.intro.length) return true; @@ -142,12 +142,12 @@ export default class Chunk { if (trimmed.length) { if (trimmed !== this.content) { this.split(this.end - trimmed.length); - this.edit('', false); + this.edit('', undefined, true); } return true; } else { - this.edit('', false); + this.edit('', undefined, true); this.outro = this.outro.replace(rx, ''); if (this.outro.length) return true; diff --git a/test/MagicString.js b/test/MagicString.js index c657935..0880bf1 100644 --- a/test/MagicString.js +++ b/test/MagicString.js @@ -1166,7 +1166,7 @@ describe( 'MagicString', () => { it( 'should support trimming chunks with intro and outro', () => { const s = new MagicString( ' \n' ); s.appendRight(4, 'test'); - assert.strictEqual( s.trim(), 'test' ); + assert.strictEqual( s.trim().toString(), 'test' ); }); });