From 7160b6426dc0ed2232fe361848bd40a133c036e4 Mon Sep 17 00:00:00 2001 From: Jennifer Thakar Date: Fri, 24 Apr 2020 16:11:46 -0700 Subject: [PATCH] Add missing constants to JS API (#990) Fixes #977. --- CHANGELOG.md | 9 ++++++++- lib/src/node.dart | 3 +++ lib/src/node/exports.dart | 4 ++++ pubspec.yaml | 2 +- test/node_api/api.dart | 3 +++ test/node_api/value/boolean_test.dart | 10 ++++++++++ test/node_api/value/null_test.dart | 4 ++++ 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e83fa7af4..d00a28dbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. @@ -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 diff --git a/lib/src/node.dart b/lib/src/node.dart index dd202b993..f52e0d0f9 100644 --- a/lib/src/node.dart +++ b/lib/src/node.dart @@ -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. diff --git a/lib/src/node/exports.dart b/lib/src/node/exports.dart index 5d1ac8443..06a550f78 100644 --- a/lib/src/node/exports.dart +++ b/lib/src/node/exports.dart @@ -4,6 +4,7 @@ import 'package:js/js.dart'; +import '../value.dart'; import 'types.dart'; @JS() @@ -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() diff --git a/pubspec.yaml b/pubspec.yaml index 00a8fef4a..c5940ced4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 diff --git a/test/node_api/api.dart b/test/node_api/api.dart index 3476571c9..68bf4a6aa 100644 --- a/test/node_api/api.dart +++ b/test/node_api/api.dart @@ -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() diff --git a/test/node_api/value/boolean_test.dart b/test/node_api/value/boolean_test.dart index 0e97e858c..de1738de5 100644 --- a/test/node_api/value/boolean_test.dart +++ b/test/node_api/value/boolean_test.dart @@ -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)); + }); + }); } diff --git a/test/node_api/value/null_test.dart b/test/node_api/value/null_test.dart index 92054477e..c0c14b49d 100644 --- a/test/node_api/value/null_test.dart +++ b/test/node_api/value/null_test.dart @@ -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)); + }); }