Skip to content

Commit db1e126

Browse files
authored
Fix bug in JS MultiSpan (#1801)
Fixes #1790.
1 parent 5466dd7 commit db1e126

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
* Add an optional `argumentName` parameter to `SassScriptException()` to make it
66
easier to throw exceptions associated with particular argument names.
77

8+
### JS API
9+
10+
* Fix a bug in which certain warning spans would not have their properties
11+
accessible by the JS API.
12+
813
## 1.54.9
914

1015
* Fix an incorrect span in certain `@media` query deprecation warnings.

Diff for: lib/src/node/source_span.dart

+11-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:source_span/source_span.dart';
66

7+
import '../util/multi_span.dart';
78
import '../util/nullable.dart';
89
import 'reflection.dart';
910
import 'utils.dart';
@@ -12,14 +13,17 @@ import 'utils.dart';
1213
/// that they match the JS API.
1314
void updateSourceSpanPrototype() {
1415
var span = SourceFile.fromString('').span(0);
16+
var multiSpan = MultiSpan(span, '', {});
1517

16-
getJSClass(span).defineGetters({
17-
'start': (FileSpan span) => span.start,
18-
'end': (FileSpan span) => span.end,
19-
'url': (FileSpan span) => span.sourceUrl.andThen(dartToJSUrl),
20-
'text': (FileSpan span) => span.text,
21-
'context': (FileSpan span) => span.context,
22-
});
18+
for (var item in [span, multiSpan]) {
19+
getJSClass(item).defineGetters({
20+
'start': (FileSpan span) => span.start,
21+
'end': (FileSpan span) => span.end,
22+
'url': (FileSpan span) => span.sourceUrl.andThen(dartToJSUrl),
23+
'text': (FileSpan span) => span.text,
24+
'context': (FileSpan span) => span.context,
25+
});
26+
}
2327

2428
// Offset is already accessible from JS because it's defined as a field rather
2529
// than a getter.

Diff for: pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.55.0
2+
version: 1.55.0-dev
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)