mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:17:36 +00:00
SpreadSheet: Fix that the js integration abused global objects
Before this commit it only allocated the global object so when it wanted to lookup 'thisSheet' it could not find it in the global environment. We now hotswap the global object everytime a cell evaluated. This also fixes that SheetGlobalObject did not have an internal_has_property meaning 'A0' could not be referenced unless it was via a member lookup (this.A0). This was already broken before the bindings refactoring. The correct behavior of realms in spreadsheet is not completely clear since what is shared between sheets is not very well defined. The reason that just setting the SheetGlobalObject as the global_this_value is not enough is because ECMAScript does not check the global_this_value for members when resolving a reference in the global environment.
This commit is contained in:
parent
e5d48ee238
commit
5611285312
3 changed files with 15 additions and 1 deletions
|
@ -8,7 +8,6 @@
|
|||
#include "Spreadsheet.h"
|
||||
#include "Workbook.h"
|
||||
#include <LibJS/Lexer.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -102,6 +101,17 @@ SheetGlobalObject::~SheetGlobalObject()
|
|||
{
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<bool> SheetGlobalObject::internal_has_property(JS::PropertyName const& name) const
|
||||
{
|
||||
if (name.is_string()) {
|
||||
if (name.as_string() == "value")
|
||||
return true;
|
||||
if (m_sheet.parse_cell_name(name.as_string()).has_value())
|
||||
return true;
|
||||
}
|
||||
return Object::internal_has_property(name);
|
||||
}
|
||||
|
||||
JS::ThrowCompletionOr<JS::Value> SheetGlobalObject::internal_get(const JS::PropertyName& property_name, JS::Value receiver) const
|
||||
{
|
||||
if (property_name.is_string()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue