Skip to content

Commit

Permalink
Fix for importers that return null in load (#1139)
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak committed Nov 10, 2020
1 parent 6986dcf commit 4f1f5c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
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;
})));
});
}

0 comments on commit 4f1f5c9

Please sign in to comment.