Browse Source

Emit load event before ElementDocument update. Fixes LuaInvader sample crash.

Michael Ragazzon 6 years ago
parent
commit
aa18b0428a
1 changed files with 6 additions and 1 deletions
  1. 6 1
      Source/Core/Context.cpp

+ 6 - 1
Source/Core/Context.cpp

@@ -268,11 +268,16 @@ ElementDocument* Context::LoadDocument(Stream* stream)
 	root->AppendChild(document);
 
 	ElementUtilities::BindEventAttributes(document);
-	document->UpdateDocument();
 
+	// The 'load' event is fired before updating the document, because the user might
+	// need to initalize things before running an update. The drawback is that computed
+	// values and layouting are not performed yet, resulting in default values when
+	// querying such information in the event handler.
 	PluginRegistry::NotifyDocumentLoad(document);
 	document->DispatchEvent(LOAD, Dictionary(), false);
 
+	document->UpdateDocument();
+
 	return document;
 }