We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s.insertRight(s.original.length, str)
Observed when researching #109:
version: magic-string@0.16.0
$ cat test_insertRight.js
var magic = require('magic-string'); var s = new magic('0123456789'); var index = 0; s.insertRight(index, 'a'); s.insertRight(index, 'b'); s.insertRight(index, 'c'); index = 5; s.insertRight(index, 'd'); s.insertRight(index, 'e'); s.insertRight(index, 'f'); index = 10; s.insertRight(index, 'g'); s.insertRight(index, 'h'); s.insertRight(index, 'i'); console.log(s.toString());
Produces incorrect result:
$ node ./test_insertRight.js
cba01234fed56789ghi
Should be:
cba01234fed56789ihg
Fix:
--- a/src/MagicString.js +++ b/src/MagicString.js @@ -234,7 +234,7 @@ MagicString.prototype = { if ( chunk ) { chunk.prepend( content ); } else { - this.outro += content; + this.outro = content + this.outro; } if ( DEBUG ) this.stats.timeEnd( 'insertRight' );
This would make the behavior consistent with chunk.prepend( content );.
chunk.prepend( content );
The fix probably should result in a major version change as code in the wild may rely on this inconsistent behavior.
The text was updated successfully, but these errors were encountered:
implement (ap|pre)pend(Left|Right) – closes #109, #110
a2c0569
Thanks – fixed in 0.17
Sorry, something went wrong.
No branches or pull requests
Observed when researching #109:
version: magic-string@0.16.0
$ cat test_insertRight.js
Produces incorrect result:
$ node ./test_insertRight.js
Should be:
Fix:
This would make the behavior consistent with
chunk.prepend( content );
.The fix probably should result in a major version change as code in the wild may rely on this inconsistent behavior.
The text was updated successfully, but these errors were encountered: