Skip to content

Commit 09f5ad5

Browse files
committed
test: add bind test asserting attribute changes are accomodated
1 parent 273a81b commit 09f5ad5

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test/bind.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,23 @@ describe('bind', () => {
214214
el1.click()
215215
expect(instance.foo).to.have.been.called.exactly(1)
216216
})
217+
218+
it('will rebind elements if the attribute changes', async function () {
219+
const instance = document.createElement('bind-test-element')
220+
chai.spy.on(instance, 'foo')
221+
root.appendChild(instance)
222+
const button = document.createElement('button')
223+
button.setAttribute('data-action', 'submit:bind-test-element#foo')
224+
instance.appendChild(button)
225+
bind(instance)
226+
listenForBind(root)
227+
await waitForNextAnimationFrame()
228+
button.click()
229+
expect(instance.foo).to.have.been.called.exactly(0)
230+
button.setAttribute('data-action', 'click:bind-test-element#foo')
231+
await waitForNextAnimationFrame()
232+
await waitForNextAnimationFrame()
233+
button.click()
234+
expect(instance.foo).to.have.been.called.exactly(1)
235+
})
217236
})

0 commit comments

Comments
 (0)