Skip to content

Commit

Permalink
Handle null doc
Browse files Browse the repository at this point in the history
  • Loading branch information
alpadotsh committed Oct 9, 2019
1 parent 946710f commit 61f1d5b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions modules/viBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export function mergeArrays(hashFn, ...args) {
}

export function documentFocus(doc) {
if (!doc) return undefined;
return typeof doc.hasFocus === 'function' ? +doc.hasFocus() : undefined;
}

Expand Down
1 change: 1 addition & 0 deletions test/spec/modules/viBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ describe('documentFocus', () => {
hasFocus: () => false
})
).to.equal(0);
expect(documentFocus()).to.be.undefined;
expect(documentFocus({})).to.be.undefined;
});
});

0 comments on commit 61f1d5b

Please sign in to comment.