mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Create objects from InstanceTemplate
This commit is contained in:
@@ -10,7 +10,6 @@ ObjectTemplateBuilder::ObjectTemplateBuilder(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::ObjectTemplate> templ)
|
||||
: isolate_(isolate), template_(templ) {
|
||||
template_->SetInternalFieldCount(1);
|
||||
}
|
||||
|
||||
ObjectTemplateBuilder::~ObjectTemplateBuilder() {
|
||||
|
||||
@@ -80,6 +80,7 @@ class Wrappable : public WrappableBase {
|
||||
// Fill the object template.
|
||||
if (!templ_) {
|
||||
v8::Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(isolate);
|
||||
templ->InstanceTemplate()->SetInternalFieldCount(1);
|
||||
T::BuildPrototype(isolate, templ->PrototypeTemplate());
|
||||
templ_ = new v8::Global<v8::FunctionTemplate>(isolate, templ);
|
||||
}
|
||||
@@ -89,8 +90,8 @@ class Wrappable : public WrappableBase {
|
||||
v8::Local<v8::FunctionTemplate>::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;
|
||||
|
||||
Reference in New Issue
Block a user