mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-30 12:49:19 +00:00
LibJS: Add spec comments to SymbolConstructor
This commit is contained in:
parent
066133d97b
commit
0ae511edae
Notes:
sideshowbarker
2024-07-17 02:29:45 +09:00
Author: https://github.com/linusg
Commit: 0ae511edae
Pull-request: https://github.com/SerenityOS/serenity/pull/18336
Reviewed-by: https://github.com/trflynn89 ✅
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