This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -53,4 +53,20 @@ describe('runtime-dom: attrs patching', () => {
5353 patchProp ( el , 'onwards' , 'a' , null )
5454 expect ( el . getAttribute ( 'onwards' ) ) . toBe ( null )
5555 } )
56+
57+ // #10597
58+ test ( 'should allow setting attribute to symbol' , ( ) => {
59+ const el = document . createElement ( 'div' )
60+ const symbol = Symbol ( 'foo' )
61+ patchProp ( el , 'foo' , null , symbol )
62+ expect ( el . getAttribute ( 'foo' ) ) . toBe ( symbol . toString ( ) )
63+ } )
64+
65+ // #10598
66+ test ( 'should allow setting value to symbol' , ( ) => {
67+ const el = document . createElement ( 'input' )
68+ const symbol = Symbol ( 'foo' )
69+ patchProp ( el , 'value' , null , symbol )
70+ expect ( el . value ) . toBe ( symbol . toString ( ) )
71+ } )
5672} )
Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ export function patchAttr(
3636 if ( value == null || ( isBoolean && ! includeBooleanAttr ( value ) ) ) {
3737 el . removeAttribute ( key )
3838 } else {
39- el . setAttribute ( key , isBoolean ? '' : value )
39+ // attribute value is a string https://html.spec.whatwg.org/multipage/dom.html#attributes
40+ el . setAttribute ( key , isBoolean ? '' : String ( value ) )
4041 }
4142 }
4243}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export function patchDOMProp(
3838 // compare against its attribute value instead.
3939 const oldValue =
4040 tag === 'OPTION' ? el . getAttribute ( 'value' ) || '' : el . value
41- const newValue = value == null ? '' : value
41+ const newValue = value == null ? '' : String ( value )
4242 if ( oldValue !== newValue || ! ( '_value' in el ) ) {
4343 el . value = newValue
4444 }
You can’t perform that action at this time.
0 commit comments