Skip to content

Commit 641d8e1

Browse files
authored
Be strict about whitespace in custom functions (#1848)
1 parent e87176a commit 641d8e1

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## 1.56.3
2+
3+
### JavaScript API
4+
5+
* **Potentially breaking bug fix**: Custom functions in both the modern and
6+
legacy API now properly reject signatures with whitespace between the function
7+
name and parentheses.
8+
9+
* Custom functions in the legacy API now allow signatures with whitespace before
10+
the function name, to match a bug in Node Sass.
11+
12+
### Dart API
13+
14+
* **Potentially breaking bug fix**: `Callable.fromSignature()` and
15+
`AsyncCallable.fromSignature()` now reject signatures with whitespace between
16+
the function name and parentheses.
17+
118
## 1.56.2
219

320
### Embedded Sass

lib/src/node/legacy.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ List<AsyncCallable> _parseFunctions(RenderOptions options, DateTime start,
210210

211211
var fiber = options.fiber;
212212
if (fiber != null) {
213-
result.add(Callable.fromSignature(signature, (arguments) {
213+
result.add(Callable.fromSignature(signature.trimLeft(), (arguments) {
214214
var currentFiber = fiber.current;
215215
var jsArguments = [
216216
...arguments.map(wrapValue),
@@ -230,12 +230,13 @@ List<AsyncCallable> _parseFunctions(RenderOptions options, DateTime start,
230230
}, requireParens: false));
231231
} else if (!asynch) {
232232
result.add(Callable.fromSignature(
233-
signature,
233+
signature.trimLeft(),
234234
(arguments) => unwrapValue((callback as JSFunction)
235235
.apply(context, arguments.map(wrapValue).toList())),
236236
requireParens: false));
237237
} else {
238-
result.add(AsyncCallable.fromSignature(signature, (arguments) async {
238+
result.add(
239+
AsyncCallable.fromSignature(signature.trimLeft(), (arguments) async {
239240
var completer = Completer<Object?>();
240241
var jsArguments = [
241242
...arguments.map(wrapValue),

lib/src/parse/stylesheet.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ abstract class StylesheetParser extends Parser {
147147
{bool requireParens = true}) {
148148
return wrapSpanFormatException(() {
149149
var name = identifier();
150-
whitespace();
151150
var arguments = requireParens || scanner.peekChar() == $lparen
152151
? _argumentDeclaration()
153152
: ArgumentDeclaration.empty(scanner.emptySpan);

pubspec.yaml

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

0 commit comments

Comments
 (0)