Skip to content

Commit

Permalink
fix(Abcjs): Set a unique id for the internal div container, to avoid …
Browse files Browse the repository at this point in the history
…problems if there's more than o
  • Loading branch information
rigobauer committed Jan 24, 2018
1 parent fb4d771 commit 8391e3d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"react": "^16.2.0",
"react-dom": "^16.2.0",
"semantic-release": "^12.2.2",
"sinon": "^4.1.6",
"sinon": "^4.2.1",
"travis-deploy-once": "^4.3.2"
},
"author": "Alberto Iglesias",
Expand Down
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import abcjsObj from 'abcjs'

class Abcjs extends PureComponent {

uniqueNumber = Date.now() + Math.random()

renderAbcNotation(abcNotation, parserParams, engraverParams, renderParams) {
const res = abcjsObj.renderAbc(
'abcjs-result',
'abcjs-result-' + this.uniqueNumber,
abcNotation,
parserParams,
engraverParams,
Expand All @@ -28,7 +30,7 @@ class Abcjs extends PureComponent {
render() {
return (
<div style={{ width: '100%' }} >
<div id="abcjs-result" style={{ width: '100%' }} />
<div id={'abcjs-result-' + this.uniqueNumber} style={{ width: '100%' }} />
</div>
)
}
Expand Down
3 changes: 2 additions & 1 deletion tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ describe('Abcjs', () => {

it('shallow renders <Abcjs /> with default parameters', () => {
const wrapper = shallow(<Abcjs />)
const id = wrapper.find('div').at(1).prop('id')
expect(wrapper.html())
.to.equal('<div style="width:100%"><div id="abcjs-result" style="width:100%"></div></div>')
.to.equal(`<div style="width:100%"><div id="${id}" style="width:100%"></div></div>`)
})

it('mounts <Abcjs /> with a simple abcNotation', () => {
Expand Down

0 comments on commit 8391e3d

Please sign in to comment.