Fix for importers that return null in load (#1139)

This commit is contained in:
Jennifer Thakar 2020-11-10 09:44:37 -08:00 committed by GitHub
parent 6986dcf718
commit 4f1f5c9de8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -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

View File

@ -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);
}

View File

@ -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;
})));
});
}