diff --git a/native_mate/object_template_builder.cc b/native_mate/object_template_builder.cc index 5bf2cfb193c..ab4079e4eef 100644 --- a/native_mate/object_template_builder.cc +++ b/native_mate/object_template_builder.cc @@ -10,7 +10,6 @@ ObjectTemplateBuilder::ObjectTemplateBuilder( v8::Isolate* isolate, v8::Local templ) : isolate_(isolate), template_(templ) { - template_->SetInternalFieldCount(1); } ObjectTemplateBuilder::~ObjectTemplateBuilder() { diff --git a/native_mate/wrappable.h b/native_mate/wrappable.h index 3e696410467..935028115ce 100644 --- a/native_mate/wrappable.h +++ b/native_mate/wrappable.h @@ -80,6 +80,7 @@ class Wrappable : public WrappableBase { // Fill the object template. if (!templ_) { v8::Local templ = v8::FunctionTemplate::New(isolate); + templ->InstanceTemplate()->SetInternalFieldCount(1); T::BuildPrototype(isolate, templ->PrototypeTemplate()); templ_ = new v8::Global(isolate, templ); } @@ -89,8 +90,8 @@ class Wrappable : public WrappableBase { v8::Local::New(isolate, *templ_); // |wrapper| may be empty in some extreme cases, e.g., when // Object.prototype.constructor is overwritten. - if (!templ->PrototypeTemplate()->NewInstance( - isolate->GetCurrentContext()).ToLocal(&wrapper)) { + if (!templ->InstanceTemplate()->NewInstance( + isolate->GetCurrentContext()).ToLocal(&wrapper)) { // The current wrappable object will be no longer managed by V8. Delete // this now. delete this;