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 a buggy interaction between meta.load-css and the legacy JS API #1722

Merged
merged 2 commits into from Jun 17, 2022
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
@@ -1,5 +1,10 @@
## 1.52.4

### JS API

* Fix a bug where `meta.load-css()` would sometimes resolve relative URLs
incorrectly when called from a mixin using the legacy JS API.

### Embedded Sass

* Respect npm's proxy settings when downloading the embedded Sass compiler.
Expand Down
11 changes: 5 additions & 6 deletions lib/src/visitor/async_evaluate.dart
Expand Up @@ -1600,7 +1600,8 @@ class _EvaluateVisitor
}
}
} else {
var result = await _importLikeNode(url, forImport);
var result = await _importLikeNode(
url, baseUrl ?? _stylesheet.span.sourceUrl, forImport);
if (result != null) {
result.stylesheet.span.sourceUrl.andThen(_loadedUrls.add);
return result;
Expand Down Expand Up @@ -1633,16 +1634,14 @@ class _EvaluateVisitor
///
/// Returns the [Stylesheet], or `null` if the import failed.
Future<_LoadedStylesheet?> _importLikeNode(
String originalUrl, bool forImport) async {
var result = _nodeImporter!
.loadRelative(originalUrl, _stylesheet.span.sourceUrl, forImport);
String originalUrl, Uri? previous, bool forImport) async {
var result = _nodeImporter!.loadRelative(originalUrl, previous, forImport);

bool isDependency;
if (result != null) {
isDependency = _inDependency;
} else {
result = await _nodeImporter!
.loadAsync(originalUrl, _stylesheet.span.sourceUrl, forImport);
result = await _nodeImporter!.loadAsync(originalUrl, previous, forImport);
if (result == null) return null;
isDependency = true;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/src/visitor/evaluate.dart
Expand Up @@ -5,7 +5,7 @@
// DO NOT EDIT. This file was generated from async_evaluate.dart.
// See tool/grind/synchronize.dart for details.
//
// Checksum: fdd5d16c0ec34a4e0e4e2d5bdbe3d764e788a43f
// Checksum: 62020db52400fe22132154e72fbb728f6282bf6d
//
// ignore_for_file: unused_import

Expand Down Expand Up @@ -1598,7 +1598,8 @@ class _EvaluateVisitor
}
}
} else {
var result = _importLikeNode(url, forImport);
var result = _importLikeNode(
url, baseUrl ?? _stylesheet.span.sourceUrl, forImport);
if (result != null) {
result.stylesheet.span.sourceUrl.andThen(_loadedUrls.add);
return result;
Expand Down Expand Up @@ -1630,16 +1631,15 @@ class _EvaluateVisitor
/// Imports a stylesheet using [_nodeImporter].
///
/// Returns the [Stylesheet], or `null` if the import failed.
_LoadedStylesheet? _importLikeNode(String originalUrl, bool forImport) {
var result = _nodeImporter!
.loadRelative(originalUrl, _stylesheet.span.sourceUrl, forImport);
_LoadedStylesheet? _importLikeNode(
String originalUrl, Uri? previous, bool forImport) {
var result = _nodeImporter!.loadRelative(originalUrl, previous, forImport);

bool isDependency;
if (result != null) {
isDependency = _inDependency;
} else {
result = _nodeImporter!
.load(originalUrl, _stylesheet.span.sourceUrl, forImport);
result = _nodeImporter!.load(originalUrl, previous, forImport);
if (result == null) return null;
isDependency = true;
}
Expand Down