Index: Source/core/dom/Node.cpp |
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp |
index c1a6aae93108c806125dc9b2725e7b48ed6e6b92..2b4c35fdb3ccd87f6eaeee36acc75a313bec8941 100644 |
--- a/Source/core/dom/Node.cpp |
+++ b/Source/core/dom/Node.cpp |
@@ -2425,6 +2425,12 @@ v8::Local<v8::Object> Node::wrap(v8::Isolate* isolate, v8::Local<v8::Object> cre |
const WrapperTypeInfo* wrapperType = wrapperTypeInfo(); |
v8::Local<v8::Object> wrapper = V8DOMWrapper::createWrapper(isolate, creationContext, wrapperType, this); |
+ // V8DOMWrapper::createWrapper may run an arbitrary script and it may result |
+ // in creating a new wrapper and associating it with |this|. If so, the |
+ // wrapper already created and associated must be used. |
+ v8::Local<v8::Object> associatedWrapper = DOMDataStore::getWrapper(this, isolate); |
+ if (UNLIKELY(!associatedWrapper.IsEmpty())) |
+ return associatedWrapper; |
if (UNLIKELY(wrapper.IsEmpty())) |
return wrapper; |