Skip to content

Commit

Permalink
Add tests to check the updated attribute values
Browse files Browse the repository at this point in the history
  • Loading branch information
kachurun committed Oct 21, 2024
1 parent cff3922 commit 00c4986
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/expressions/attribute.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,4 +409,26 @@ describe('attribute specs', () => {

expect(ref).to.have.been.calledWith(null)
})

it('Attributes can check and restore their values upon update (https://github.com/riot/riot/issues/3023)', () => {
const target = document.createElement('div')
const scope = { attr: { class: 'hello world' } }
const el = template('<p expr0></p>', [
{
selector: '[expr0]',
expressions: [
{ type: expressionTypes.ATTRIBUTE, evaluate: (scope) => scope.attr },
],
},
]).mount(target, scope)

const p = target.querySelector('p')

expect(p.getAttribute('class')).to.be.equal('hello world')
p.classList.remove('world')
expect(p.getAttribute('class')).to.be.equal('hello')

el.update(scope)
expect(p.getAttribute('class')).to.be.equal('hello world')
})
})

0 comments on commit 00c4986

Please sign in to comment.