-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Fix issue#498 Cannot read property 'firstRun' of undefined #499
Conversation
- fix in location identified by stack trace - audit code and protect other instance of deeply dereferenced variables in `settings`
@@ -201,7 +201,7 @@ | |||
} | |||
|
|||
function checkSingle(){ | |||
var remoteHost = settings[iframeId].remoteHost; | |||
var remoteHost = settings[iframeId] && settings[iframeId].remoteHost; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this make remoteHost
a boolean? Wouldn't that break the lines below, e.g.: return origin === remoteHost
You seem to do this in many places. It's fine when the variable is a boolean, but it makes me nervous in other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, in JavaScript the &&
operator returns the last value or the first non-truthy value. Essentially this simply protects from accessing .remoteHost
when settings[iframeId]
is undefined. So, when settings[iframeId]
is undefined, remoteHost
is assigned undefined; and when settings[iframeId]
is an object, remoteHost
is assigned the value settings[iframeId].remoteHost
.
Drat, the code I added decreased coverage by 0.07%! |
Hi
Currently away on holiday, will take a look next week when back
On Tue, 27 Jun 2017 at 19:56, Shaun Johansen ***@***.***> wrote:
Drat, the code I added decreased coverage by -0.07%!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#499 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAkHEvdGlYbigh6OmPo012GiOZ1v67_Sks5sIUJbgaJpZM4OG7iM>
.
--
Sent from my iPhone.
|
No worries at all. FYI we are deploying this updated version in our product. Just thought we'd make it available to you also. Enjoy the vacation! |
settings