diff --git a/package.json b/package.json index c2910c13..f4911715 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "dependencies": { "bindings": "^1.2.1", "mockery": "^1.6.2", - "nan": "^2.2.1", + "nan": "^2.3.3", "node-gyp": "^3.3.1", "rnpm": "1.6.5", "xcode": "0.8.4" diff --git a/src/node/node_class.hpp b/src/node/node_class.hpp index 757e6228..ea95cf98 100644 --- a/src/node/node_class.hpp +++ b/src/node/node_class.hpp @@ -104,7 +104,7 @@ class ObjectWrap { using Internal = void; static v8::Local get_template() { - return v8::Local();; + return v8::Local(); } }; @@ -195,22 +195,21 @@ inline v8::Local ObjectWrap::create_template() template inline void ObjectWrap::setup_method(v8::Local tpl, const std::string &name, Nan::FunctionCallback callback) { v8::Local signature = Nan::New(tpl); - v8::Local t = Nan::New(callback, v8::Local(), signature); - v8::Local fn = Nan::GetFunction(t).ToLocalChecked(); + v8::Local fn_tpl = Nan::New(callback, v8::Local(), signature); v8::Local fn_name = Nan::New(name).ToLocalChecked(); // The reason we use this rather than Nan::SetPrototypeMethod is DontEnum. - tpl->PrototypeTemplate()->Set(fn_name, fn, v8::PropertyAttribute::DontEnum); - fn->SetName(fn_name); + tpl->PrototypeTemplate()->Set(fn_name, fn_tpl, v8::PropertyAttribute::DontEnum); + fn_tpl->SetClassName(fn_name); } template inline void ObjectWrap::setup_static_method(v8::Local tpl, const std::string &name, Nan::FunctionCallback callback) { - v8::Local fn = Nan::GetFunction(Nan::New(callback)).ToLocalChecked(); + v8::Local fn_tpl = Nan::New(callback); v8::Local fn_name = Nan::New(name).ToLocalChecked(); - tpl->Set(fn_name, fn, v8::PropertyAttribute::DontEnum); - fn->SetName(fn_name); + tpl->Set(fn_name, fn_tpl, v8::PropertyAttribute::DontEnum); + fn_tpl->SetClassName(fn_name); } template diff --git a/tests/js/asserts.js b/tests/js/asserts.js index 75ec6c31..7031717b 100644 --- a/tests/js/asserts.js +++ b/tests/js/asserts.js @@ -109,6 +109,14 @@ module.exports = { throw new TestFailureError(errorMessage || 'Condition expected to be true'); } }, + + isNode: function() { + return typeof process == 'object' && Object.prototype.toString.call(process) == '[object process]'; + }, + + isNode6: function() { + return this.isNode() && process.version.indexOf('v6.') == 0; + }, }; function TestFailureError(message) { diff --git a/tests/js/list-tests.js b/tests/js/list-tests.js index cb316b31..4563528d 100644 --- a/tests/js/list-tests.js +++ b/tests/js/list-tests.js @@ -554,7 +554,11 @@ module.exports = BaseTest.extend({ TestCase.assertEqual(list.slice(1, 3).length, 2); TestCase.assertEqual(list.slice(1, 3)[1].age, 12); - TestCase.assertEqual(list.join(' '), 'Ari Tim Bjarne'); + // A Node 6 regression in v8 causes an error when converting our objects to strings: + // TypeError: Cannot convert a Symbol value to a string + if (!TestCase.isNode6()) { + TestCase.assertEqual(list.join(' '), 'Ari Tim Bjarne'); + } var count = 0; list.forEach(function(p, i) {