Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(397)

Unified Diff: sky/engine/bindings/core/v8/CustomElementConstructorBuilder.cpp

Issue 814683002: Custom elements should have class side inheritance. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: better test name. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/bindings/core/v8/CustomElementConstructorBuilder.cpp
diff --git a/sky/engine/bindings/core/v8/CustomElementConstructorBuilder.cpp b/sky/engine/bindings/core/v8/CustomElementConstructorBuilder.cpp
index 89d769e4ab3188a37e24816062cb8bfecbf4fe31..618d570ab1ecfca46e5be9edc26834c5ff4fa6a4 100644
--- a/sky/engine/bindings/core/v8/CustomElementConstructorBuilder.cpp
+++ b/sky/engine/bindings/core/v8/CustomElementConstructorBuilder.cpp
@@ -198,6 +198,8 @@ bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust
V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementType(isolate), v8Type);
v8::Handle<v8::String> prototypeKey = v8String(isolate, "prototype");
+ v8::Handle<v8::String> constructorKey = v8String(isolate, "constructor");
+
ASSERT(m_constructor->HasOwnProperty(prototypeKey));
// This sets the property *value*; calling Set is safe because
// "prototype" is a non-configurable data property so there can be
@@ -207,9 +209,11 @@ bool CustomElementConstructorBuilder::createConstructor(Document* document, Cust
// "prototype" does not affect the value, but can reconfigure the
// property.
m_constructor->ForceSet(prototypeKey, m_prototype, v8::PropertyAttribute(v8::ReadOnly | v8::DontEnum | v8::DontDelete));
+ // The generated constructor should inherit from your constructor.
+ m_constructor->SetPrototype(m_prototype->Get(constructorKey));
V8HiddenValue::setHiddenValue(isolate, m_prototype, V8HiddenValue::customElementIsInterfacePrototypeObject(isolate), v8::True(isolate));
- m_prototype->ForceSet(v8String(isolate, "constructor"), m_constructor, v8::DontEnum);
+ m_prototype->ForceSet(constructorKey, m_constructor, v8::DontEnum);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698