Skip to content

Commit

Permalink
fix: update with empty string throws exception
Browse files Browse the repository at this point in the history
  • Loading branch information
indr committed Jan 25, 2019
1 parent c3c7714 commit 04f1664
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/Adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const Adapter = class {
}

data (data) {
if (!data || typeof data !== 'object') return
this._updateInstances(data)
}

Expand Down
8 changes: 7 additions & 1 deletion test/Adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ describe('Adapter', () => {
expect(movieClip.visible).to.equal(true)
})

it('data without argument or null must not throw exception', () => {
const adapter = new Adapter(webcg, movieClip, createjs)
adapter.data()
adapter.data(null)
})

it('data with string data should update createjs Text instances', () => {
movieClip.f0 = new createjs.Text('f0')
movieClip.f0.parent = movieClip
Expand All @@ -123,7 +129,7 @@ describe('Adapter', () => {
expect(movieClip.instance.f1.text).to.equal(1)
})

it('data should update createjs MovieClip instances', () => {
it('data with object data should update createjs MovieClip instances', () => {
movieClip.f0 = new createjs.Text('f0')
movieClip.f0.parent = movieClip
movieClip.instance = new createjs.MovieClip()
Expand Down

0 comments on commit 04f1664

Please sign in to comment.