Commit 3a9c84bc by Adeel

Importer: Moves the setter inside condition.

parent 00057b70
...@@ -60,6 +60,16 @@ struct Sass_Import** sass_importer(const char* file, void* cookie) ...@@ -60,6 +60,16 @@ struct Sass_Import** sass_importer(const char* file, void* cookie)
} }
void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx_w, bool isFile) { void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx_w, bool isFile) {
struct Sass_Context* ctx;
if (isFile) {
ctx = sass_file_context_get_context((struct Sass_File_Context*) cptr);
} else {
ctx = sass_data_context_get_context((struct Sass_Data_Context*) cptr);
}
struct Sass_Options* sass_options = sass_context_get_options(ctx);
if (ctx_w) { if (ctx_w) {
NanAssignPersistent(ctx_w->stats, options->Get(NanNew("stats"))->ToObject()); NanAssignPersistent(ctx_w->stats, options->Get(NanNew("stats"))->ToObject());
...@@ -77,18 +87,11 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx ...@@ -77,18 +87,11 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
ctx_w->callback = new NanCallback(callback); ctx_w->callback = new NanCallback(callback);
ctx_w->error_callback = new NanCallback(error_callback); ctx_w->error_callback = new NanCallback(error_callback);
ctx_w->importer_callback = new NanCallback(importer_callback); ctx_w->importer_callback = new NanCallback(importer_callback);
}
struct Sass_Context* ctx; if(!importer_callback->IsUndefined())
sass_option_set_importer(sass_options, sass_make_importer(sass_importer, ctx_w->importer_callback));
if (isFile) {
ctx = sass_file_context_get_context((struct Sass_File_Context*) cptr);
} else {
ctx = sass_data_context_get_context((struct Sass_Data_Context*) cptr);
} }
struct Sass_Options* sass_options = sass_context_get_options(ctx);
sass_option_set_output_path(sass_options, CreateString(options->Get(NanNew("outFile")))); sass_option_set_output_path(sass_options, CreateString(options->Get(NanNew("outFile"))));
sass_option_set_image_path(sass_options, CreateString(options->Get(NanNew("imagePath")))); sass_option_set_image_path(sass_options, CreateString(options->Get(NanNew("imagePath"))));
sass_option_set_output_style(sass_options, (Sass_Output_Style)options->Get(NanNew("style"))->Int32Value()); sass_option_set_output_style(sass_options, (Sass_Output_Style)options->Get(NanNew("style"))->Int32Value());
...@@ -100,7 +103,6 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx ...@@ -100,7 +103,6 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
sass_option_set_source_map_file(sass_options, CreateString(options->Get(NanNew("sourceMap")))); sass_option_set_source_map_file(sass_options, CreateString(options->Get(NanNew("sourceMap"))));
sass_option_set_include_path(sass_options, CreateString(options->Get(NanNew("paths")))); sass_option_set_include_path(sass_options, CreateString(options->Get(NanNew("paths"))));
sass_option_set_precision(sass_options, options->Get(NanNew("precision"))->Int32Value()); sass_option_set_precision(sass_options, options->Get(NanNew("precision"))->Int32Value());
sass_option_set_importer(sass_options, sass_make_importer(sass_importer, ctx_w->importer_callback));
} }
void FillStatsObj(Handle<Object> stats, Sass_Context* ctx) { void FillStatsObj(Handle<Object> stats, Sass_Context* ctx) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment