From db1e1261bd183ec74ee4352083724c597670b658 Mon Sep 17 00:00:00 2001 From: Jennifer Thakar Date: Wed, 14 Sep 2022 17:08:57 -0700 Subject: [PATCH] Fix bug in JS MultiSpan (#1801) Fixes #1790. --- CHANGELOG.md | 5 +++++ lib/src/node/source_span.dart | 18 +++++++++++------- pubspec.yaml | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d59652f7..3ebee22e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ * Add an optional `argumentName` parameter to `SassScriptException()` to make it easier to throw exceptions associated with particular argument names. +### JS API + +* Fix a bug in which certain warning spans would not have their properties + accessible by the JS API. + ## 1.54.9 * Fix an incorrect span in certain `@media` query deprecation warnings. diff --git a/lib/src/node/source_span.dart b/lib/src/node/source_span.dart index 7b756681..998db03a 100644 --- a/lib/src/node/source_span.dart +++ b/lib/src/node/source_span.dart @@ -4,6 +4,7 @@ import 'package:source_span/source_span.dart'; +import '../util/multi_span.dart'; import '../util/nullable.dart'; import 'reflection.dart'; import 'utils.dart'; @@ -12,14 +13,17 @@ import 'utils.dart'; /// that they match the JS API. void updateSourceSpanPrototype() { var span = SourceFile.fromString('').span(0); + var multiSpan = MultiSpan(span, '', {}); - getJSClass(span).defineGetters({ - 'start': (FileSpan span) => span.start, - 'end': (FileSpan span) => span.end, - 'url': (FileSpan span) => span.sourceUrl.andThen(dartToJSUrl), - 'text': (FileSpan span) => span.text, - 'context': (FileSpan span) => span.context, - }); + for (var item in [span, multiSpan]) { + getJSClass(item).defineGetters({ + 'start': (FileSpan span) => span.start, + 'end': (FileSpan span) => span.end, + 'url': (FileSpan span) => span.sourceUrl.andThen(dartToJSUrl), + 'text': (FileSpan span) => span.text, + 'context': (FileSpan span) => span.context, + }); + } // Offset is already accessible from JS because it's defined as a field rather // than a getter. diff --git a/pubspec.yaml b/pubspec.yaml index 92542939..e35e1190 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.55.0 +version: 1.55.0-dev description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass