From 4035d8eae7f20a9c68f7d4c9820573b86061d782 Mon Sep 17 00:00:00 2001 From: Sumedha Pramod Date: Thu, 19 Oct 2017 15:35:47 -0700 Subject: [PATCH] Fix: Setting innerHTML in annotatorUtil.generateButton() (#446) --- src/lib/annotations/__tests__/annotatorUtil-test.js | 4 ++-- src/lib/annotations/annotatorUtil.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/annotations/__tests__/annotatorUtil-test.js b/src/lib/annotations/__tests__/annotatorUtil-test.js index 3d3125b03..c331d4729 100644 --- a/src/lib/annotations/__tests__/annotatorUtil-test.js +++ b/src/lib/annotations/__tests__/annotatorUtil-test.js @@ -236,12 +236,12 @@ describe('lib/annotations/annotatorUtil', () => { describe('generateBtn()', () => { it('should return button node from specified details', () => { - const btn = generateBtn('class', 'title', 'content', 'type'); + const btn = generateBtn('class', 'title', document.createElement('div'), 'type'); expect(btn).to.have.class('bp-btn-plain'); expect(btn).to.have.class('class'); expect(btn).to.have.attribute('data-type', 'type'); expect(btn).to.have.attribute('title', 'title'); - expect(btn).to.have.text('content'); + expect(btn).to.contain.html(document.createElement('div')); }); }); diff --git a/src/lib/annotations/annotatorUtil.js b/src/lib/annotations/annotatorUtil.js index beaaddd8d..d0c7996df 100644 --- a/src/lib/annotations/annotatorUtil.js +++ b/src/lib/annotations/annotatorUtil.js @@ -286,7 +286,7 @@ export function generateBtn(className, title, content, dataType = '') { buttonEl.classList.add(CLASS_BUTTON); buttonEl.classList.add(className); buttonEl.title = title; - buttonEl.textContent = content; + buttonEl.innerHTML = content; buttonEl.setAttribute('data-type', dataType); return buttonEl; }