mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 15:19:42 +00:00
LibJS: Allow null or undefined as a bound |this| value in strict mode
This commit is contained in:
parent
870bcaeef6
commit
b0932b0aec
Notes:
sideshowbarker
2024-07-19 05:52:28 +09:00
Author: https://github.com/jack-karamanian
Commit: b0932b0aec
Pull-request: https://github.com/SerenityOS/serenity/pull/2487
2 changed files with 12 additions and 9 deletions
|
@ -103,15 +103,17 @@ try {
|
|||
assert(Make5() === 5);
|
||||
assert(new Make5().valueOf() === 5);
|
||||
|
||||
// FIXME: Uncomment me when strict mode is implemented
|
||||
// function strictIdentity() {
|
||||
// return this;
|
||||
// }
|
||||
// Null or undefined should be passed through as a |this| value in strict mode.
|
||||
(() => {
|
||||
"use strict";
|
||||
function strictIdentity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
// assert(strictIdentity.bind()() === undefined);
|
||||
// assert(strictIdentity.bind(null)() === null);
|
||||
// assert(strictIdentity.bind(undefined)() === undefined);
|
||||
// })();
|
||||
assert(strictIdentity.bind()() === undefined);
|
||||
assert(strictIdentity.bind(null)() === null);
|
||||
assert(strictIdentity.bind(undefined)() === undefined);
|
||||
})();
|
||||
|
||||
// Arrow functions can not have their |this| value set.
|
||||
assert((() => this).bind("foo")() === globalThis)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue