-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace instanceof Object
with typeof
checks
#13657
Replace instanceof Object
with typeof
checks
#13657
Conversation
Using `instanceof Object` is generally problematic, since it's not guaranteed to always do the right thing for all Objects. (I stumbled upon this while working on another patch, when I noticed that the `outlineView` was broken with workers disabled.)
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://3.101.106.178:8877/246445bae803c28/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/1903cc3620eb60f/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.67.70.0:8877/1903cc3620eb60f/output.txt Total script time: 30.38 mins
Image differences available at: http://54.67.70.0:8877/1903cc3620eb60f/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://3.101.106.178:8877/246445bae803c28/output.txt Total script time: 34.81 mins
Image differences available at: http://3.101.106.178:8877/246445bae803c28/reftest-analyzer.html#web=eq.log |
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/915f52a0e39bc28/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/915f52a0e39bc28/output.txt Total script time: 5.05 mins Published |
I couldn't immediately figure out from the given description in which cases this would fail, but some Googling showed me that this happens for objects without prototypes, which we use. From the console: > const foo = Object.create(null);
undefined
> foo instanceof Object
false
> typeof foo === "object" && foo !== null
true I'm adding this for future reference. |
Thanks! |
My apologies; I should have included more details in the commit message! |
Using
instanceof Object
is generally problematic, since it's not guaranteed to always do the right thing for all Objects.(I stumbled upon this while working on another patch, when I noticed that the
outlineView
was broken with workers disabled.)