From 2582c50783709c6c6c57e80bb8f38191108ab420 Mon Sep 17 00:00:00 2001 From: Alex Kennberg Date: Thu, 18 Nov 2021 20:25:34 -0800 Subject: [PATCH] Fix Chrome fullscreen error When embedding h5p and using the fullscreen enter/exit feature, Chrome can produce the following error: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at HTMLDocument. This happens because arguments.callee is not accessible. To fix this, it is sufficient to name the anonymous callback function and reference it by name. --- js/h5p.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/h5p.js b/js/h5p.js index ac232d4..92490cc 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -662,7 +662,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull before('h5p-fullscreen'); var first, eventName = (H5P.fullScreenBrowserPrefix === 'ms' ? 'MSFullscreenChange' : H5P.fullScreenBrowserPrefix + 'fullscreenchange'); - document.addEventListener(eventName, function () { + document.addEventListener(eventName, function fullscreenCallback() { if (first === undefined) { // We are entering fullscreen mode first = false; @@ -672,7 +672,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull // We are exiting fullscreen done('h5p-fullscreen'); - document.removeEventListener(eventName, arguments.callee, false); + document.removeEventListener(eventName, fullscreenCallback, false); }); if (H5P.fullScreenBrowserPrefix === '') {