From 9d0c3cbe4c6c9eec13c4e82afa0ce36bc40b8add Mon Sep 17 00:00:00 2001 From: Timothy Lindvall Date: Thu, 1 May 2014 15:56:13 -0700 Subject: [PATCH] Fix blank z-index for value 0. Added unit tests to verify. --- src/js/hopscotch.js | 2 +- test/js/test.hopscotch.js | 41 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 37fafec4..08914e3f 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -766,7 +766,7 @@ } // Set z-index and arrow placement - el.style.zIndex = step.zindex || ''; + el.style.zIndex = (typeof step.zindex === 'number') ? step.zindex : 'auto'; this._setArrow(step.placement); // Set bubble positioning diff --git a/test/js/test.hopscotch.js b/test/js/test.hopscotch.js index bcbdd8e3..ba399eb8 100644 --- a/test/js/test.hopscotch.js +++ b/test/js/test.hopscotch.js @@ -856,6 +856,47 @@ describe('HopscotchBubble', function() { }); }); + describe('z-index', function(){ + var bubble; + it('should set z-index if provided', function(){ + hopscotch.startTour({ + id: 'hopscotch-test-tour', + steps: [ { + target: 'shopping-list', + orientation: 'left', + title: 'Shopping List', + content: 'It\'s a shopping list', + zindex: 100 + }, + { + target: 'shopping-list', + orientation: 'left', + title: 'Shopping List', + content: 'It\'s a shopping list', + zindex: 0 + }, + { + target: 'shopping-list', + orientation: 'left', + title: 'Shopping List', + content: 'It\'s a shopping list' + }] + }); + bubble = document.querySelector('.hopscotch-bubble'); + expect(bubble.style.zIndex).to.be('100'); + + hopscotch.nextStep(); + bubble = document.querySelector('.hopscotch-bubble'); + expect(bubble.style.zIndex).to.be('0'); + + hopscotch.nextStep(); + bubble = document.querySelector('.hopscotch-bubble'); + expect(bubble.style.zIndex).to.be('auto'); + + hopscotch.endTour(); + }); + }); + describe('Buttons', function() { it('should show Skip button when specified', function() { var $nextBtnEl;