Skip to content

Commit

Permalink
(fix) set property size to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
neeldug committed Sep 10, 2021
1 parent df87659 commit 5906c58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions boa/src/builtins/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,17 @@ impl Map {
// 4. For each Record { [[Key]], [[Value]] } p of entries, do
// a. Set p.[[Key]] to empty.
// b. Set p.[[Value]] to empty.
Self::set_size(this, 0);
if let Some(object) = this.as_object() {
if let Some(map) = object.borrow_mut().as_map_mut() {
map.clear();
Ok(JsValue::undefined())
} else {
context.throw_type_error("'this' is not a Map")
return context.throw_type_error("'this' is not a Map");
}
} else {
context.throw_type_error("'this' is not a Map")
return context.throw_type_error("'this' is not a Map");
}
Ok(JsValue::undefined())
}

/// `Map.prototype.has( key )`
Expand Down
2 changes: 1 addition & 1 deletion boa/src/builtins/map/ordered_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<V> OrderedMap<V> {
}

pub fn clear(&mut self) {
self.map = IndexMap::new();
self.map.truncate(0);
}

/// Return a reference to the value stored for `key`, if it is present,
Expand Down

0 comments on commit 5906c58

Please sign in to comment.