From a0a9aa78219ad54c1a8be2c478b91bc4ccfa36c1 Mon Sep 17 00:00:00 2001
From: Hakim El Hattab <hakim.elhattab@gmail.com>
Date: Thu, 23 Nov 2017 15:45:15 +0100
Subject: [PATCH] optimize use of getSlideBackground by avoiding index lookup

---
 js/reveal.js | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/js/reveal.js b/js/reveal.js
index f125c555..9a43903e 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -3200,8 +3200,7 @@
 
 
 		// Show the corresponding background element
-		var indices = getIndices( slide );
-		var background = getSlideBackground( indices.h, indices.v );
+		var background = getSlideBackground( slide );
 		if( background ) {
 			background.style.display = 'block';
 
@@ -3288,8 +3287,7 @@
 		slide.style.display = 'none';
 
 		// Hide the corresponding background element
-		var indices = getIndices( slide );
-		var background = getSlideBackground( indices.h, indices.v );
+		var background = getSlideBackground( slide );
 		if( background ) {
 			background.style.display = 'none';
 		}
@@ -3858,13 +3856,14 @@
 	 * defined, have a background element so as long as the
 	 * index is valid an element will be returned.
 	 *
-	 * @param {number} x Horizontal background index
+	 * @param {mixed} x Horizontal background index OR a slide
+	 * HTML element
 	 * @param {number} y Vertical background index
 	 * @return {(HTMLElement[]|*)}
 	 */
 	function getSlideBackground( x, y ) {
 
-		var slide = getSlide( x, y );
+		var slide = typeof x === 'number' ? getSlide( x, y ) : x;
 		if( slide ) {
 			return slide.slideBackgroundElement;
 		}
-- 
GitLab