diff --git a/CHANGELOG.md b/CHANGELOG.md index d63e7a7d..77d14c3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.10.1 + +### Node JS API + +* Don't crash when passing both `includePaths` and `importer`. + ## 1.10.0 * When two `@media` rules' queries can't be merged, leave nested rules in place diff --git a/lib/src/node.dart b/lib/src/node.dart index cf31f154..7667786e 100644 --- a/lib/src/node.dart +++ b/lib/src/node.dart @@ -259,7 +259,7 @@ NodeImporter _parseImporter(RenderOptions options, DateTime start) { importers = [options.importer as JSFunction]; } - var includePaths = options.includePaths ?? []; + var includePaths = new List.from(options.includePaths ?? []); RenderContext context; if (importers.isNotEmpty) { diff --git a/lib/src/node/render_options.dart b/lib/src/node/render_options.dart index 23832ebc..e362daa7 100644 --- a/lib/src/node/render_options.dart +++ b/lib/src/node/render_options.dart @@ -13,7 +13,7 @@ class RenderOptions { external String get data; external dynamic get importer; external dynamic get functions; - external List get includePaths; + external List get includePaths; // contains Strings external bool get indentedSyntax; external bool get omitSourceMapUrl; external String get outFile; diff --git a/lib/src/node/render_result.dart b/lib/src/node/render_result.dart index b3764b0f..b26d2d57 100644 --- a/lib/src/node/render_result.dart +++ b/lib/src/node/render_result.dart @@ -24,7 +24,7 @@ class RenderResultStats { external int get start; external int get end; external int get duration; - external List get includedFiles; + external List get includedFiles; // contains Strings external factory RenderResultStats( {String entry, diff --git a/pubspec.yaml b/pubspec.yaml index 82568d56..58d9676d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.10.0 +version: 1.10.1 description: A Sass implementation in Dart. author: Dart Team homepage: https://github.com/sass/dart-sass diff --git a/test/node_api/utils.dart b/test/node_api/utils.dart index cb5ad6dd..7c86821f 100644 --- a/test/node_api/utils.dart +++ b/test/node_api/utils.dart @@ -4,11 +4,13 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:js_util'; import 'package:js/js.dart'; import 'package:test/test.dart'; import 'package:sass/src/io.dart'; +import 'package:sass/src/node/function.dart'; import '../hybrid.dart'; import 'api.dart'; @@ -60,6 +62,18 @@ Future renderError(RenderOptions options) { String renderSync(RenderOptions options) => utf8.decode(sass.renderSync(options).css); +/// Like [renderSync], but goes through the untyped JS API. +/// +/// This lets us test that we properly cast untyped collections without throwing +/// type errors. +String renderSyncJS(Map options) { + var result = _renderSyncJS.call(sass, jsify(options)) as RenderResult; + return utf8.decode(result.css); +} + +final _renderSyncJS = + new JSFunction("sass", "args", "return sass.renderSync(args);"); + /// Asserts that rendering via [options] produces an error, and returns that /// error. RenderError renderSyncError(RenderOptions options) { diff --git a/test/node_api_test.dart b/test/node_api_test.dart index e522ffd6..d424f108 100644 --- a/test/node_api_test.dart +++ b/test/node_api_test.dart @@ -6,6 +6,7 @@ @Tags(const ['node']) import 'dart:convert'; +import 'dart:js'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; @@ -420,6 +421,28 @@ a { }); }); }); + + group("when called with a raw JS collection", () { + test("for includePaths", () { + expect( + renderSyncJS({ + "data": "@import 'test'", + "includePaths": [sandbox] + }), + equalsIgnoringWhitespace('a { b: c; }')); + }); + + // Regression test for #412 + test("for includePaths with an importer", () { + expect( + renderSyncJS({ + "data": "@import 'test'", + "includePaths": [sandbox], + "importer": allowInterop((url, prev) => null) + }), + equalsIgnoringWhitespace('a { b: c; }')); + }); + }); }); group("render()", () {