Skip to content

Commit 273a81b

Browse files
committed
test: add bind test to ensure removing attribute doesnt fire bind
1 parent 27d26b8 commit 273a81b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/bind.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,4 +199,19 @@ describe('bind', () => {
199199
instance.querySelector('button').click()
200200
expect(instance.foo).to.have.been.called.exactly(1)
201201
})
202+
203+
it('will not fire if the binding attribute is removed', () => {
204+
const instance = document.createElement('bind-test-element')
205+
chai.spy.on(instance, 'foo')
206+
const el1 = document.createElement('div')
207+
el1.setAttribute('data-action', 'click:bind-test-element#foo')
208+
instance.appendChild(el1)
209+
bind(instance)
210+
expect(instance.foo).to.have.not.been.called()
211+
el1.click()
212+
expect(instance.foo).to.have.been.called.exactly(1)
213+
el1.setAttribute('data-action', 'click:other-element#foo')
214+
el1.click()
215+
expect(instance.foo).to.have.been.called.exactly(1)
216+
})
202217
})

0 commit comments

Comments
 (0)