Skip to content

Prevent TypeError: Document not active - fixes #34 #35

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

Merged
merged 2 commits into from
Apr 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions jquery.fullscreen.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @preserve jquery.fullscreen 1.1.5
* @preserve jquery.fullscreen 1.1.6
* https://github.com/kayahr/jquery-fullscreen-plugin
* Copyright (C) 2012-2013 Klaus Reimer <[email protected]>
* Licensed under the MIT license
Expand Down Expand Up @@ -61,10 +61,7 @@ function fullScreen(state)
}

// Check fullscreen state
state = !!doc["fullscreenElement"]
|| !!doc["msFullscreenElement"]
|| !!doc["webkitIsFullScreen"]
|| !!doc["mozFullScreen"];
state = fullScreenState(doc);
if (!state) return state;

// Return current fullscreen element or "true" if browser doesn't
Expand Down Expand Up @@ -100,11 +97,21 @@ function fullScreen(state)
|| (/** @type {?Function} */ doc["webkitCancelFullScreen"])
|| (/** @type {?Function} */ doc["msExitFullscreen"])
|| (/** @type {?Function} */ doc["mozCancelFullScreen"]);
if (func) func.call(doc);
if (func && fullScreenState(doc)) func.call(doc);
return this;
}
}

/**
* Check fullscreen state
*
* @param {Document} doc The content document
* @return {Boolean}
*/
function fullScreenState(doc) {
return !!(doc["fullscreenElement"] || doc["msFullscreenElement"] || doc["webkitIsFullScreen"] || doc["mozFullScreen"]);
}

/**
* Toggles the fullscreen mode.
*
Expand Down