Add current stylesheet to loadedUrls when throwing parsing error (#1991)

Co-authored-by: Natalie Weizenbaum <nweiz@google.com>
This commit is contained in:
なつき 2023-06-09 13:41:25 -07:00 committed by GitHub
parent 645e48fd5d
commit 760fa2ead1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 10 deletions

View File

@ -1,3 +1,10 @@
## 1.63.4
### Embedded Sass
* Properly include the root stylesheet's URL in the set of loaded URLs when it
fails to parse.
## 1.63.3
### JavaScript API

View File

@ -76,6 +76,7 @@ class Stylesheet extends ParentStatement<List<Statement>> {
/// Throws a [SassFormatException] if parsing fails.
factory Stylesheet.parse(String contents, Syntax syntax,
{Object? url, Logger? logger}) {
try {
switch (syntax) {
case Syntax.sass:
return Stylesheet.parseSass(contents, url: url, logger: logger);
@ -86,6 +87,12 @@ class Stylesheet extends ParentStatement<List<Statement>> {
default:
throw ArgumentError("Unknown syntax $syntax.");
}
} on SassException catch (error) {
var url = error.span.sourceUrl;
if (url == null || url.toString() == 'stdin') rethrow;
throw error.withLoadedUrls(Set.unmodifiable({url}));
}
}
/// Parses an indented-syntax stylesheet from [contents].

View File

@ -1,5 +1,5 @@
name: sass
version: 1.63.3
version: 1.63.4-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass