Skip to content

Conversation

@darylldoyle
Copy link
Contributor

@darylldoyle darylldoyle commented Mar 11, 2021

Description of the Change

There are two bug fixes in this PR.

Another initializeSlotData() error

initializeSlotData() expects an event rather than a Slot. This PR changes out a call that was still passing the slot.

Uncaught TypeError: Cannot read property 'toString' of undefined error

Within isEligible() we were using event.size.toString(). It seems that the size property is only actually available on the googletag.events.slotrenderendedevent event. So when the isEligible() function was being called using googletag.events.slotvisibilitychangedevent or googletag.events.impressionviewableevent, it was erroring with a "Uncaught TypeError: Cannot read property 'toString' of undefined" error.

This PR also fixes this issue by checking if event.size exists before attempting to access it.

Verification Process

Tested on local and preprod environments.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

Applicable Issues

#38

Changelog Entry

@darylldoyle darylldoyle requested a review from davidrgreen March 11, 2021 12:49
@jeffpaul jeffpaul added this to the 1.0.4 milestone Mar 11, 2021
@jeffpaul jeffpaul added the bug label Mar 11, 2021
Copy link
Collaborator

@davidrgreen davidrgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darylldoyle Thanks for catching and fixing this!

@davidrgreen davidrgreen merged commit 3c0c822 into 10up:develop Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing the slot to initializeSlotData rather than the event causes an error

3 participants