Skip to content

Commit

Permalink
Be strict about whitespace in custom functions (#1848)
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Dec 15, 2022
1 parent e87176a commit 641d8e1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,20 @@
## 1.56.3

### JavaScript API

* **Potentially breaking bug fix**: Custom functions in both the modern and
legacy API now properly reject signatures with whitespace between the function
name and parentheses.

* Custom functions in the legacy API now allow signatures with whitespace before
the function name, to match a bug in Node Sass.

### Dart API

* **Potentially breaking bug fix**: `Callable.fromSignature()` and
`AsyncCallable.fromSignature()` now reject signatures with whitespace between
the function name and parentheses.

## 1.56.2

### Embedded Sass
Expand Down
7 changes: 4 additions & 3 deletions lib/src/node/legacy.dart
Expand Up @@ -210,7 +210,7 @@ List<AsyncCallable> _parseFunctions(RenderOptions options, DateTime start,

var fiber = options.fiber;
if (fiber != null) {
result.add(Callable.fromSignature(signature, (arguments) {
result.add(Callable.fromSignature(signature.trimLeft(), (arguments) {
var currentFiber = fiber.current;
var jsArguments = [
...arguments.map(wrapValue),
Expand All @@ -230,12 +230,13 @@ List<AsyncCallable> _parseFunctions(RenderOptions options, DateTime start,
}, requireParens: false));
} else if (!asynch) {
result.add(Callable.fromSignature(
signature,
signature.trimLeft(),
(arguments) => unwrapValue((callback as JSFunction)
.apply(context, arguments.map(wrapValue).toList())),
requireParens: false));
} else {
result.add(AsyncCallable.fromSignature(signature, (arguments) async {
result.add(
AsyncCallable.fromSignature(signature.trimLeft(), (arguments) async {
var completer = Completer<Object?>();
var jsArguments = [
...arguments.map(wrapValue),
Expand Down
1 change: 0 additions & 1 deletion lib/src/parse/stylesheet.dart
Expand Up @@ -147,7 +147,6 @@ abstract class StylesheetParser extends Parser {
{bool requireParens = true}) {
return wrapSpanFormatException(() {
var name = identifier();
whitespace();
var arguments = requireParens || scanner.peekChar() == $lparen
? _argumentDeclaration()
: ArgumentDeclaration.empty(scanner.emptySpan);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: sass
version: 1.56.2
version: 1.56.3-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit 641d8e1

Please sign in to comment.