Skip to content

Commit

Permalink
Fix embedding source maps with non-ASCII characters (#471)
Browse files Browse the repository at this point in the history
Closes #457
  • Loading branch information
nex3 authored Sep 11, 2018
1 parent ede9c81 commit 1a5eb2a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
* Properly generate source maps for stylesheets that emit `@charset`
declarations.

### Command-Line Interface

* Don't error out when passing `--embed-source-maps` along with
`--embed-sources` for stylesheets that contain non-ASCII characters.

## 1.13.2

* Properly parse `:nth-child()` and `:nth-last-child()` selectors with
Expand Down
3 changes: 2 additions & 1 deletion lib/src/executable/compile_stylesheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ String _writeSourceMap(

Uri url;
if (options.embedSourceMap) {
url = new Uri.dataFromString(sourceMapText, mimeType: 'application/json');
url = new Uri.dataFromString(sourceMapText,
mimeType: 'application/json', encoding: utf8);
} else {
var sourceMapPath = destination + '.map';
ensureDir(p.dirname(sourceMapPath));
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.13.3-dev
version: 1.13.3
description: A Sass implementation in Dart.
author: Dart Team <[email protected]>
homepage: https://github.com/sass/dart-sass
Expand Down
17 changes: 17 additions & 0 deletions test/cli/shared/source_maps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,23 @@ void sharedTests(Future<TestProcess> runSass(Iterable<String> arguments)) {
test("doesn't generate a source map file", () async {
await d.nothing("out.css.map").validate();
});

// Regression test for #457.
test("--embed-sources works with non-ASCII characters", () async {
await d.file("test.scss", "a {b: '▼'}").create();
await (await runSass([
"--embed-source-map",
"--embed-sources",
"test.scss",
"out.css"
]))
.shouldExit(0);
var css = readFile(d.path("out.css"));
map = embeddedSourceMap(css);

expect(map, containsPair("sources", ["test.scss"]));
expect(map, containsPair("sourcesContent", ["a {b: '▼'}"]));
});
});

group("with the target in a different directory", () {
Expand Down

0 comments on commit 1a5eb2a

Please sign in to comment.