Skip to content

Commit

Permalink
Fix a buggy interaction between meta.load-css and the legacy JS API (#…
Browse files Browse the repository at this point in the history
…1722)

Closes #1627
  • Loading branch information
nex3 committed Jun 17, 2022
1 parent 4d6b762 commit 8705c06
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
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

0 comments on commit 8705c06

Please sign in to comment.