From fbed2909091b98f614ae51c5d6503cdd40a74eb5 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" <lbennett@gitlab.com> Date: Tue, 11 Apr 2017 11:42:47 +0100 Subject: [PATCH] Removed prepend in favour of clean and appendChild --- app/assets/javascripts/spinner.js | 3 ++- spec/javascripts/spinner_spec.js | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/spinner.js b/app/assets/javascripts/spinner.js index b7bfe1a2572..6b5ac89a576 100644 --- a/app/assets/javascripts/spinner.js +++ b/app/assets/javascripts/spinner.js @@ -6,7 +6,8 @@ class Spinner { } start() { - this.renderable.prepend(this.container); + this.renderable.innerHTML = ''; + this.renderable.appendChild(this.container); } stop() { diff --git a/spec/javascripts/spinner_spec.js b/spec/javascripts/spinner_spec.js index ec62503659c..f550285e0f7 100644 --- a/spec/javascripts/spinner_spec.js +++ b/spec/javascripts/spinner_spec.js @@ -31,7 +31,7 @@ describe('Spinner', () => { describe('start', () => { beforeEach(() => { - renderable = jasmine.createSpyObj('renderable', ['prepend']); + renderable = jasmine.createSpyObj('renderable', ['appendChild']); container = {}; spinner = { @@ -42,8 +42,12 @@ describe('Spinner', () => { Spinner.prototype.start.call(spinner); }); - it('should call .prepend', () => { - expect(renderable.prepend).toHaveBeenCalledWith(container); + it('should set .innerHTML to an empty string', () => { + expect(renderable.innerHTML).toEqual(''); + }); + + it('should call .appendChild', () => { + expect(renderable.appendChild).toHaveBeenCalledWith(container); }); }); -- GitLab