mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 13:51:31 +01:00
Merge pull request #422 from sass/include-path-cast
Don't crash when passing includePaths with importer
This commit is contained in:
commit
6552666230
@ -1,3 +1,9 @@
|
|||||||
|
## 1.10.1
|
||||||
|
|
||||||
|
### Node JS API
|
||||||
|
|
||||||
|
* Don't crash when passing both `includePaths` and `importer`.
|
||||||
|
|
||||||
## 1.10.0
|
## 1.10.0
|
||||||
|
|
||||||
* When two `@media` rules' queries can't be merged, leave nested rules in place
|
* When two `@media` rules' queries can't be merged, leave nested rules in place
|
||||||
|
@ -259,7 +259,7 @@ NodeImporter _parseImporter(RenderOptions options, DateTime start) {
|
|||||||
importers = [options.importer as JSFunction];
|
importers = [options.importer as JSFunction];
|
||||||
}
|
}
|
||||||
|
|
||||||
var includePaths = options.includePaths ?? [];
|
var includePaths = new List<String>.from(options.includePaths ?? []);
|
||||||
|
|
||||||
RenderContext context;
|
RenderContext context;
|
||||||
if (importers.isNotEmpty) {
|
if (importers.isNotEmpty) {
|
||||||
|
@ -13,7 +13,7 @@ class RenderOptions {
|
|||||||
external String get data;
|
external String get data;
|
||||||
external dynamic get importer;
|
external dynamic get importer;
|
||||||
external dynamic get functions;
|
external dynamic get functions;
|
||||||
external List<String> get includePaths;
|
external List get includePaths; // contains Strings
|
||||||
external bool get indentedSyntax;
|
external bool get indentedSyntax;
|
||||||
external bool get omitSourceMapUrl;
|
external bool get omitSourceMapUrl;
|
||||||
external String get outFile;
|
external String get outFile;
|
||||||
|
@ -24,7 +24,7 @@ class RenderResultStats {
|
|||||||
external int get start;
|
external int get start;
|
||||||
external int get end;
|
external int get end;
|
||||||
external int get duration;
|
external int get duration;
|
||||||
external List<String> get includedFiles;
|
external List get includedFiles; // contains Strings
|
||||||
|
|
||||||
external factory RenderResultStats(
|
external factory RenderResultStats(
|
||||||
{String entry,
|
{String entry,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: sass
|
name: sass
|
||||||
version: 1.10.0
|
version: 1.10.1
|
||||||
description: A Sass implementation in Dart.
|
description: A Sass implementation in Dart.
|
||||||
author: Dart Team <misc@dartlang.org>
|
author: Dart Team <misc@dartlang.org>
|
||||||
homepage: https://github.com/sass/dart-sass
|
homepage: https://github.com/sass/dart-sass
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:js_util';
|
||||||
|
|
||||||
import 'package:js/js.dart';
|
import 'package:js/js.dart';
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
|
|
||||||
import 'package:sass/src/io.dart';
|
import 'package:sass/src/io.dart';
|
||||||
|
import 'package:sass/src/node/function.dart';
|
||||||
|
|
||||||
import '../hybrid.dart';
|
import '../hybrid.dart';
|
||||||
import 'api.dart';
|
import 'api.dart';
|
||||||
@ -60,6 +62,18 @@ Future<RenderError> renderError(RenderOptions options) {
|
|||||||
String renderSync(RenderOptions options) =>
|
String renderSync(RenderOptions options) =>
|
||||||
utf8.decode(sass.renderSync(options).css);
|
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<String, Object> 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
|
/// Asserts that rendering via [options] produces an error, and returns that
|
||||||
/// error.
|
/// error.
|
||||||
RenderError renderSyncError(RenderOptions options) {
|
RenderError renderSyncError(RenderOptions options) {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
@Tags(const ['node'])
|
@Tags(const ['node'])
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'dart:js';
|
||||||
|
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:test/test.dart';
|
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()", () {
|
group("render()", () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user