diff options
author | davidot <david.tuin@gmail.com> | 2021-09-30 13:01:09 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-30 15:37:56 +0100 |
commit | 0f5fe3b70e01dc570eaa61b5228ee452f360d75c (patch) | |
tree | 137486f305d0e4be5c18d554427d958e6a3b0241 /Userland/Applications/Spreadsheet | |
parent | 146aaec129922595a6142435eaa2f8ffe4bef787 (diff) | |
download | serenity-0f5fe3b70e01dc570eaa61b5228ee452f360d75c.zip |
SpreadSheet: Fix that non first sheets could not access global functions
Because we declare the functions in runtime.js we need the correct
global object to be setup otherwise they cannot be accessed when
switching to the SheetGlobalObject.
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r-- | Userland/Applications/Spreadsheet/Spreadsheet.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 079104ddf3..5c4278bd96 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -45,6 +45,9 @@ Sheet::Sheet(Workbook& workbook) global_object().define_direct_property("workbook", m_workbook.workbook_object(), JS::default_attributes); global_object().define_direct_property("thisSheet", &global_object(), JS::default_attributes); // Self-reference is unfortunate, but required. + // Note: We have to set the global object here otherwise the functions in runtime.js are not registered correctly. + interpreter().realm().set_global_object(global_object(), &global_object()); + // Sadly, these have to be evaluated once per sheet. auto file_or_error = Core::File::open("/res/js/Spreadsheet/runtime.js", Core::OpenMode::ReadOnly); if (!file_or_error.is_error()) { |