Skip to content

Commit

Permalink
Fix attributes on properties of functions and constructors (#1023)
Browse files Browse the repository at this point in the history
Co-authored-by: tofpie <tofpie@users.noreply.github.com>
  • Loading branch information
tofpie and tofpie authored Jan 1, 2021
1 parent 57d5679 commit e0a135e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions boa/src/builtins/function/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 3 additions & 3 deletions boa/src/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
);

{
Expand Down

0 comments on commit e0a135e

Please sign in to comment.