Skip to content

Commit

Permalink
Added ordinary_has_property
Browse files Browse the repository at this point in the history
  • Loading branch information
HalidOdat committed Aug 2, 2020
1 parent 2383211 commit a39c471
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions boa/src/builtins/object/internal_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ impl Object {
self.ordinary_prevent_extensions()
}

/// Check if object has property.
/// Return a bool value indicating whether this ordinay object already has either an own
/// or inherited property with the specified key.
///
/// More information:
/// - [ECMAScript reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p
pub fn has_property(&self, key: &PropertyKey) -> bool {
/// [spec]: https://tc39.es/ecma262/#table-5
fn ordinary_has_property(&self, key: &PropertyKey) -> bool {
if self.get_own_property(key).is_some() {
return true;
}
Expand All @@ -79,6 +80,17 @@ impl Object {
}
}

/// Return a bool value indicating whether this ordinay object already has either an own
/// or inherited property with the specified key.
///
/// More information:
/// - [ECMAScript reference][spec]
///
/// [spec]: https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-hasproperty-p
pub fn has_property(&self, key: &PropertyKey) -> bool {
self.ordinary_has_property(key)
}

/// Delete property.
pub fn delete(&mut self, key: &PropertyKey) -> bool {
let desc = if let Some(desc) = self.get_own_property(key) {
Expand Down

0 comments on commit a39c471

Please sign in to comment.