mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:17:35 +00:00
LibJS: Add spec comments to SymbolConstructor
This commit is contained in:
parent
066133d97b
commit
0ae511edae
3 changed files with 35 additions and 10 deletions
|
@ -34,4 +34,20 @@ ErrorOr<String> Symbol::descriptive_string() const
|
|||
return String::formatted("Symbol({})", description);
|
||||
}
|
||||
|
||||
// 20.4.5.1 KeyForSymbol ( sym ), https://tc39.es/ecma262/#sec-keyforsymbol
|
||||
Optional<String> Symbol::key() const
|
||||
{
|
||||
// 1. For each element e of the GlobalSymbolRegistry List, do
|
||||
// a. If SameValue(e.[[Symbol]], sym) is true, return e.[[Key]].
|
||||
if (m_is_global) {
|
||||
// NOTE: Global symbols should always have a description string
|
||||
VERIFY(m_description.has_value());
|
||||
return m_description;
|
||||
}
|
||||
|
||||
// 2. Assert: GlobalSymbolRegistry does not currently contain an entry for sym.
|
||||
// 3. Return undefined.
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue