Skip to content

Commit

Permalink
Add missing constants to JS API (#990)
Browse files Browse the repository at this point in the history
Fixes #977.
  • Loading branch information
jathak authored Apr 24, 2020
1 parent a7b0ad8 commit 7160b64
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.26.6

### JavaScript API

* Add `sass.NULL`, `sass.TRUE`, and `sass.FALSE` constants to match Node Sass's
API.

## 1.26.5

* No user-visible changes.
Expand Down Expand Up @@ -78,7 +85,7 @@

* Highlight contextually-relevant sections of the stylesheet in error messages,
rather than only highlighting the section where the error was detected.

## 1.24.4

### JavaScript API
Expand Down
3 changes: 3 additions & 0 deletions lib/src/node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ void main() {
Number: numberConstructor,
String: stringConstructor,
Error: jsErrorConstructor);
exports.NULL = sassNull;
exports.TRUE = sassTrue;
exports.FALSE = sassFalse;
}

/// Converts Sass to CSS.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/node/exports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:js/js.dart';

import '../value.dart';
import 'types.dart';

@JS()
Expand All @@ -13,6 +14,9 @@ class Exports {
external set renderSync(Function function);
external set info(String info);
external set types(Types types);
external set NULL(SassNull sassNull);
external set TRUE(SassBoolean sassTrue);
external set FALSE(SassBoolean sassFalse);
}

@JS()
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.26.5
version: 1.26.6-dev
description: A Sass implementation in Dart.
author: Sass Team
homepage: https://github.com/sass/dart-sass
Expand Down
3 changes: 3 additions & 0 deletions test/node_api/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class Sass {
external void render(RenderOptions args,
void callback(RenderError error, RenderResult result));
external SassTypes get types;
external Object get NULL;
external NodeSassBoolean get TRUE;
external NodeSassBoolean get FALSE;
}

@JS()
Expand Down
10 changes: 10 additions & 0 deletions test/node_api/value/boolean_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ void main() {
expect(
() => callConstructor(sass.types.Boolean, [true]), throwsA(anything));
});

group("the convenience accessor", () {
test("sass.TRUE exists", () {
expect(sass.TRUE, equals(sass.types.Boolean.TRUE));
});

test("sass.FALSE exists", () {
expect(sass.FALSE, equals(sass.types.Boolean.FALSE));
});
});
}
4 changes: 4 additions & 0 deletions test/node_api/value/null_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ void main() {
test("the constructor throws", () {
expect(() => callConstructor(sass.types.Null, []), throwsA(anything));
});

test("the convenience accessor sass.NULL exists", () {
expect(sass.NULL, equals(sass.types.Null.NULL));
});
}

0 comments on commit 7160b64

Please sign in to comment.