From 93382670cee56a57ae2bc878b1521040d1727620 Mon Sep 17 00:00:00 2001 From: Sampson Gao Date: Mon, 21 Aug 2017 15:22:12 -0400 Subject: [PATCH] Replace napi_is_construct_call with napi_get_new_target --- src/sass_types/boolean.cpp | 5 +++-- src/sass_types/null.cpp | 5 +++-- src/sass_types/sass_value_wrapper.h | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/sass_types/boolean.cpp b/src/sass_types/boolean.cpp index dc9bc03ec..b4717910a 100644 --- a/src/sass_types/boolean.cpp +++ b/src/sass_types/boolean.cpp @@ -63,9 +63,10 @@ namespace SassTypes } napi_value Boolean::New(napi_env env, napi_callback_info info) { - bool r; - CHECK_NAPI_RESULT(napi_is_construct_call(env, info, &r)); + napi_value new_target; + CHECK_NAPI_RESULT(napi_is_construct_call(env, info, &new_target)); + bool r = (new_target != nullptr); if (r) { if (constructor_locked) { CHECK_NAPI_RESULT(napi_throw_type_error(env, nullptr, "Cannot instantiate SassBoolean")); diff --git a/src/sass_types/null.cpp b/src/sass_types/null.cpp index dcfb88d98..b68e061e6 100644 --- a/src/sass_types/null.cpp +++ b/src/sass_types/null.cpp @@ -55,9 +55,10 @@ namespace SassTypes } napi_value Null::New(napi_env env, napi_callback_info info) { - bool r; - CHECK_NAPI_RESULT(napi_is_construct_call(env, info, &r)); + napi_value new_target; + CHECK_NAPI_RESULT(napi_is_construct_call(env, info, &new_target)); + bool r = (new_target != nullptr); if (r) { if (constructor_locked) { CHECK_NAPI_RESULT(napi_throw_type_error(env, nullptr, "Cannot instantiate SassNull")); diff --git a/src/sass_types/sass_value_wrapper.h b/src/sass_types/sass_value_wrapper.h index 204484c21..6f146d696 100644 --- a/src/sass_types/sass_value_wrapper.h +++ b/src/sass_types/sass_value_wrapper.h @@ -261,9 +261,10 @@ namespace SassTypes std::vector argv(argc); CHECK_NAPI_RESULT(napi_get_cb_info(env, info, &argc, argv.data(), nullptr, nullptr)); - bool r; - CHECK_NAPI_RESULT(napi_is_construct_call(env, info, &r)); + napi_value new_target; + CHECK_NAPI_RESULT(napi_is_construct_call(env, info, &new_target)); + bool r = (new_target != nullptr); if (r) { Sass_Value* value; if (T::construct(env, argv, &value) != NULL) {