From e3d7cf2562b2a58974f4b5d41ebf3f0adb657a51 Mon Sep 17 00:00:00 2001 From: Tom Arild Jakobsen Date: Wed, 23 Aug 2017 15:22:29 +0200 Subject: [PATCH] HFP-1407 Improve robustness of content-id retrival The code made an assumption that the $element.parent() would contain the [data-content-id] which isn't always true. Changed the code, so that it looks up the parent with [data-content-id]. --- js/h5p.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/h5p.js b/js/h5p.js index b2d13b3..b9d70f6 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -501,7 +501,8 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull // We're called from an iframe. $body = H5P.jQuery(body); $classes = $body.add($element.get()); - var iframeSelector = '#h5p-iframe-' + $element.parent().data('content-id'); + var contentId = $element.closest('[data-content-id]').data('content-id'); + var iframeSelector = '#h5p-iframe-' + contentId; $iframe = H5P.jQuery(iframeSelector); $element = $iframe.parent(); // Put iframe wrapper in fullscreen, not container. }