浏览代码

Merge pull request #86 from gabomdq/fix-namespace-document

Set the document global variable when the ElementDocumentWrapper is created
Lloyd Weehuizen 13 年之前
父节点
当前提交
c066f09528
共有 2 个文件被更改,包括 3 次插入1 次删除
  1. 3 0
      Source/Core/Python/ElementDocumentWrapper.cpp
  2. 0 1
      Source/Core/Python/EventListener.cpp

+ 3 - 0
Source/Core/Python/ElementDocumentWrapper.cpp

@@ -46,6 +46,9 @@ ElementDocumentWrapper::ElementDocumentWrapper(PyObject* self, const char* tag)
 	PyObject* builtins = PyImport_AddModule("__main__");
 	PyObject* builtins = PyImport_AddModule("__main__");
 	PyObject* builtins_dict = PyModule_GetDict( builtins);
 	PyObject* builtins_dict = PyModule_GetDict( builtins);
 	PyDict_Merge(module_namespace, builtins_dict, 0);
 	PyDict_Merge(module_namespace, builtins_dict, 0);
+
+	// Insert the document global
+	PyDict_SetItemString(module_namespace, "document", self);
 }
 }
 
 
 ElementDocumentWrapper::~ElementDocumentWrapper()
 ElementDocumentWrapper::~ElementDocumentWrapper()

+ 0 - 1
Source/Core/Python/EventListener.cpp

@@ -138,7 +138,6 @@ void EventListener::ProcessEvent(Event& event)
 	// Set up the new expected globals
 	// Set up the new expected globals
 	PyDict_SetItemString(py_namespace, "event", Rocket::Core::Python::Utilities::MakeObject(&event).ptr());
 	PyDict_SetItemString(py_namespace, "event", Rocket::Core::Python::Utilities::MakeObject(&event).ptr());
 	PyDict_SetItemString(py_namespace, "self", Rocket::Core::Python::Utilities::MakeObject(element).ptr());
 	PyDict_SetItemString(py_namespace, "self", Rocket::Core::Python::Utilities::MakeObject(element).ptr());
-	PyDict_SetItemString(py_namespace, "document", Rocket::Core::Python::Utilities::MakeObject(element->GetOwnerDocument()).ptr());
 
 
 	// Call the bound function
 	// Call the bound function
 	PyObject* result = NULL;
 	PyObject* result = NULL;