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() .prototype()
.into(), .into(),
); );
function.insert_property("length", length, Attribute::all()); let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE;
function.insert_property("length", length, attribute);
parent function.insert_property("name", name.as_str(), attribute);
.as_object()
.unwrap() parent.as_object().unwrap().insert_property(
.insert_property(name, function, Attribute::all()); name,
function,
Attribute::WRITABLE | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE,
);
} }
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]

6
boa/src/object/mod.rs

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