Skip to content

Commit

Permalink
test: add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusBorg committed Jun 20, 2024
1 parent 2ba78f6 commit 1bb87cd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/runtime-dom/__tests__/patchAttrs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,23 @@ describe('runtime-dom: attrs patching', () => {
patchProp(el, 'value', null, symbol)
expect(el.value).toBe(symbol.toString())
})

// #11177
test('should allow setting value to object, leaving stringification to the element/browser', () => {
// normal behavior
const el = document.createElement('div')
const obj = { toString: () => 'foo' }
patchProp(el, 'data-test', null, obj)
expect(el.dataset.test).toBe('foo')

const el2 = document.createElement('div')
let testvalue: null | typeof obj = null
// simulating a web component that implements its own setAttribute handler
el2.setAttribute = (name, value) => {
testvalue = value
}
patchProp(el2, 'data-test', null, obj)
expect(el2.dataset.test).toBe(undefined)
expect(testvalue).toBe(obj)
})
})

0 comments on commit 1bb87cd

Please sign in to comment.