Skip to content
New issue

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

Fix for importers that return null in load #1139

Merged
merged 1 commit into from Nov 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,11 @@
* Fix a bug where `@at-root (without: all)` wouldn't properly remove a
`@keyframes` context when parsing selectors.

### Dart API

* Fix a bug that prevented importers from returning null when loading from a
URL that they had already canonicalized.

## 1.29.0

* Support a broader syntax for `@supports` conditions, based on the latest
Expand Down
1 change: 1 addition & 0 deletions lib/src/import_cache.dart
Expand Up @@ -162,6 +162,7 @@ Relative canonical URLs are deprecated and will eventually be disallowed.
baseImporter: baseImporter, baseUrl: baseUrl, forImport: forImport);
if (tuple == null) return null;
var stylesheet = importCanonical(tuple.item1, tuple.item2, tuple.item3);
if (stylesheet == null) return null;
return Tuple2(tuple.item1, stylesheet);
}

Expand Down
13 changes: 13 additions & 0 deletions test/dart_api/importer_test.dart
Expand Up @@ -168,4 +168,17 @@ void main() {
return true;
})));
});

test("avoids importer when only load() returns null", () {
expect(() {
compileString('@import "orange";', importers: [
TestImporter((url) => Uri.parse("u:$url"), (url) => null)
]);
}, throwsA(predicate((error) {
expect(error, const TypeMatcher<SassException>());
expect(error.toString(),
startsWith("Error: Can't find stylesheet to import"));
return true;
})));
});
}