Skip to content

Commit

Permalink
fix(runtime-dom): patch textContent on svg properly
Browse files Browse the repository at this point in the history
test: improve case

chore: improve code

chore: improve code

chore: improve
  • Loading branch information
edison1105 committed Aug 11, 2021
1 parent 1c7f5d3 commit 4bd1be0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions packages/runtime-dom/__tests__/patchAttrs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ describe('runtime-dom: attrs patching', () => {
expect(el.getAttributeNS(xlinkNS, 'href')).toBe(null)
})

test('textContent attributes /w svg', () => {
const el = document.createElementNS('http://www.w3.org/2000/svg', 'use')
patchProp(el, 'textContent', null, 'foo', true)
expect(el.attributes.length).toBe(0)
expect(el.innerHTML).toBe('foo')
})

test('boolean attributes', () => {
const el = document.createElement('input')
patchProp(el, 'readonly', null, true)
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function shouldSetAsProp(
if (isSVG) {
// most keys must be set as attribute on svg elements to work
// ...except innerHTML
if (key === 'innerHTML') {
if (key === 'innerHTML' || key === 'textContent') {
return true
}
// or native onclick with function values
Expand Down

0 comments on commit 4bd1be0

Please sign in to comment.