Skip to content

Commit

Permalink
Replace napi_is_construct_call with napi_get_new_target
Browse files Browse the repository at this point in the history
  • Loading branch information
Sampson Gao committed Aug 21, 2017
1 parent a203738 commit 9338267
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/sass_types/boolean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
5 changes: 3 additions & 2 deletions src/sass_types/null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down
5 changes: 3 additions & 2 deletions src/sass_types/sass_value_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,10 @@ namespace SassTypes
std::vector<napi_value> 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) {
Expand Down

0 comments on commit 9338267

Please sign in to comment.