diff --git a/Libraries/LibJS/Runtime/Object.cpp b/Libraries/LibJS/Runtime/Object.cpp index fa54720367..fc71268089 100644 --- a/Libraries/LibJS/Runtime/Object.cpp +++ b/Libraries/LibJS/Runtime/Object.cpp @@ -415,6 +415,12 @@ bool Object::define_property(const StringOrSymbol& property_name, const Object& return define_property(property_name, value, attributes, throw_exceptions); } +bool Object::define_property_without_transition(const PropertyName& property_name, Value value, PropertyAttributes attributes, bool throw_exceptions) +{ + TemporaryChange change(m_transitions_enabled, false); + return define_property(property_name, value, attributes, throw_exceptions); +} + bool Object::define_property(const PropertyName& property_name, Value value, PropertyAttributes attributes, bool throw_exceptions) { if (property_name.is_number()) @@ -753,10 +759,10 @@ bool Object::define_native_function(const StringOrSymbol& property_name, AK::Fun function_name = String::formatted("[{}]", property_name.as_symbol()->description()); } auto* function = NativeFunction::create(global_object(), function_name, move(native_function)); - function->define_property("length", Value(length), Attribute::Configurable); + function->define_property_without_transition("length", Value(length), Attribute::Configurable); if (vm().exception()) return {}; - function->define_property("name", js_string(heap(), function_name), Attribute::Configurable); + function->define_property_without_transition("name", js_string(heap(), function_name), Attribute::Configurable); if (vm().exception()) return {}; return define_property(property_name, function, attribute); diff --git a/Libraries/LibJS/Runtime/Object.h b/Libraries/LibJS/Runtime/Object.h index 0885914195..001255db42 100644 --- a/Libraries/LibJS/Runtime/Object.h +++ b/Libraries/LibJS/Runtime/Object.h @@ -103,6 +103,7 @@ public: virtual bool define_property(const StringOrSymbol& property_name, const Object& descriptor, bool throw_exceptions = true); bool define_property(const PropertyName&, Value value, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true); + bool define_property_without_transition(const PropertyName&, Value value, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true); bool define_accessor(const PropertyName&, Function& getter_or_setter, bool is_getter, PropertyAttributes attributes = default_attributes, bool throw_exceptions = true); bool define_native_function(const StringOrSymbol& property_name, AK::Function, i32 length = 0, PropertyAttributes attributes = default_attributes); diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index 7104f646e3..668f747e00 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -69,7 +69,7 @@ void ScriptFunction::initialize(GlobalObject& global_object) Function::initialize(global_object); if (!m_is_arrow_function) { Object* prototype = Object::create_empty(global_object); - prototype->define_property("constructor", this, Attribute::Writable | Attribute::Configurable); + prototype->define_property_without_transition("constructor", this, Attribute::Writable | Attribute::Configurable); define_property("prototype", prototype, 0); } define_native_property("length", length_getter, nullptr, Attribute::Configurable);