Browse Source

Fix attributes on properties of functions and constructors (#1023)

Co-authored-by: tofpie <tofpie@users.noreply.github.com>
pull/1024/head
tofpie 4 years ago committed by GitHub
parent
commit
e0a135e46a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      boa/src/builtins/function/mod.rs
  2. 6
      boa/src/object/mod.rs

15
boa/src/builtins/function/mod.rs

@ -237,12 +237,15 @@ pub fn make_builtin_fn<N>(
.prototype()
.into(),
);
function.insert_property("length", length, Attribute::all());
parent
.as_object()
.unwrap()
.insert_property(name, function, Attribute::all());
let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE;
function.insert_property("length", length, attribute);
function.insert_property("name", name.as_str(), attribute);
parent.as_object().unwrap().insert_property(
name,
function,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
}
#[derive(Debug, Clone, Copy)]

6
boa/src/object/mod.rs

@ -701,7 +701,7 @@ impl<'context> FunctionBuilder<'context> {
.prototype()
.into(),
);
let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT;
let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE;
if let Some(name) = self.name.take() {
function.insert_property("name", name, attribute);
} else {
@ -1014,11 +1014,11 @@ impl<'context> ConstructorBuilder<'context> {
let length = DataDescriptor::new(
self.length,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
let name = DataDescriptor::new(
self.name.take().unwrap_or_else(|| String::from("[object]")),
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::PERMANENT,
Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
{

Loading…
Cancel
Save