fix: remove bad usages of for-in and guard against it (#22616)
* fix: remove bad usages of for-in and guard against it * Apply suggestions from code review Co-Authored-By: Samuel Maddock <samuel.maddock@gmail.com> * Apply suggestions from code review Co-Authored-By: Jeremy Apthorp <jeremya@chromium.org> * Update remote.js Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> Co-authored-by: Jeremy Apthorp <jeremya@chromium.org>
This commit is contained in:
parent
f4868c9a28
commit
5e4e50c5eb
7 changed files with 11 additions and 11 deletions
|
@ -74,7 +74,7 @@ const createGuest = function (embedder, params) {
|
|||
|
||||
// Clear the guest from map when it is destroyed.
|
||||
guest.once('destroyed', () => {
|
||||
if (guestInstanceId in guestInstances) {
|
||||
if (Object.prototype.hasOwnProperty.call(guestInstances, guestInstanceId)) {
|
||||
detachGuest(embedder, guestInstanceId)
|
||||
}
|
||||
})
|
||||
|
@ -288,7 +288,7 @@ const watchEmbedder = function (embedder) {
|
|||
|
||||
// Forward embedder window visiblity change events to guest
|
||||
const onVisibilityChange = function (visibilityState) {
|
||||
for (const guestInstanceId in guestInstances) {
|
||||
for (const guestInstanceId of Object.keys(guestInstances)) {
|
||||
const guestInstance = guestInstances[guestInstanceId]
|
||||
guestInstance.visibilityState = visibilityState
|
||||
if (guestInstance.embedder === embedder) {
|
||||
|
@ -302,7 +302,7 @@ const watchEmbedder = function (embedder) {
|
|||
// Usually the guestInstances is cleared when guest is destroyed, but it
|
||||
// may happen that the embedder gets manually destroyed earlier than guest,
|
||||
// and the embedder will be invalid in the usual code path.
|
||||
for (const guestInstanceId in guestInstances) {
|
||||
for (const guestInstanceId of Object.keys(guestInstances)) {
|
||||
const guestInstance = guestInstances[guestInstanceId]
|
||||
if (guestInstance.embedder === embedder) {
|
||||
detachGuest(embedder, parseInt(guestInstanceId))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue