-
Notifications
You must be signed in to change notification settings - Fork 82
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 Empty adSlot Object Caused by Ad Blocker #21
Fix Empty adSlot Object Caused by Ad Blocker #21
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
==========================================
- Coverage 93.98% 92.93% -1.05%
==========================================
Files 7 7
Lines 565 566 +1
==========================================
- Hits 531 526 -5
- Misses 34 40 +6
Continue to review full report at Codecov.
|
Issue When using an ad blocker adSlot can become an empty object which causes the call to adSlot.getServices to produce the error: "getServices is not a function". Solution By adding the check adSlot.hasOwnProperty("getServices") we can ensure that the adSlot object has the correct function before attempting to call it.
c69288b
to
81c157b
Compare
I've been trying to think of a way to simulate this AdBlocker issue in a unit test to verify your PR, but not having any luck. A test like this would be nice to add to this PR, any thoughts on how to achieve it?
|
@potench I tried your test and it passed, it also passed when I removed my change. I did some digging, I'm new to this code base, and found that when the tests are run there is never a case where |
Would it be possible to get this PR merged in quickly? I only ask because we are using react-gpt on http://www.thescoreesports.com/lol/scores and when you use an ad blocker it prevents the site from functioning correctly due to the exception that is thrown. You can also see the error in the in the console when running the example http://localhost:8080/single-request/index.html. If there is anything else you need for this let me know and I will update the PR. In an attempt to work around this issue we've looked at using my branch for the dependency but that ran into a couple of issues with |
version 0.2.4 was published with your PR Sorry for delay; your commit caused codecoverage to drop below threshold indicating that we might need some more tests around the Thanks for the PR |
Issue
When using an ad blocker
adSlot
can become an empty object which causes the call toadSlot.getServices
to produce the error: "getServices is not a function".Solution
By adding the check
adSlot.hasOwnProperty("getServices")
we can ensure that theadSlot
object has the correct function before attempting to call it.