Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix attributes on properties of functions and constructors #1023

Merged
merged 1 commit into from
Jan 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix attributes on properties of functions and constructors
  • Loading branch information
tofpie committed Jan 1, 2021
commit ba87bd45239e7da9e0f8f0e0dddb3124a29be14c
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