@@ -90,27 +90,36 @@ describe('runtime-dom: attrs patching', () => {
9090 } )
9191
9292 // #13946
93- test ( 'sandbox attribute should always be handled as attribute' , ( ) => {
94- const iframe = document . createElement ( 'iframe' )
95-
96- // Verify sandbox is treated as attribute, not property
93+ test ( 'sandbox should be handled as attribute even if property exists' , ( ) => {
94+ const iframe = document . createElement ( 'iframe' ) as any
95+ let propSetCount = 0
96+ // simulate sandbox property in jsdom environment
97+ Object . defineProperty ( iframe , 'sandbox' , {
98+ configurable : true ,
99+ enumerable : true ,
100+ get ( ) {
101+ return this . _sandbox
102+ } ,
103+ set ( v ) {
104+ propSetCount ++
105+ this . _sandbox = v
106+ } ,
107+ } )
108+
97109 patchProp ( iframe , 'sandbox' , null , 'allow-scripts' )
98110 expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( 'allow-scripts' )
99-
100- // Setting to null should remove the attribute
111+ expect ( propSetCount ) . toBe ( 0 )
112+
101113 patchProp ( iframe , 'sandbox' , 'allow-scripts' , null )
102114 expect ( iframe . hasAttribute ( 'sandbox' ) ) . toBe ( false )
103115 expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( null )
104-
105- // Setting to undefined should also remove the attribute
106- patchProp ( iframe , 'sandbox' , null , 'allow-forms' )
107- expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( 'allow-forms' )
108- patchProp ( iframe , 'sandbox' , 'allow-forms' , undefined )
109- expect ( iframe . hasAttribute ( 'sandbox' ) ) . toBe ( false )
110-
111- // Empty string should set empty attribute (most restrictive sandbox)
116+ expect ( propSetCount ) . toBe ( 0 )
117+
112118 patchProp ( iframe , 'sandbox' , null , '' )
113119 expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( '' )
114120 expect ( iframe . hasAttribute ( 'sandbox' ) ) . toBe ( true )
121+ expect ( propSetCount ) . toBe ( 0 )
122+
123+ delete iframe . sandbox
115124 } )
116125} )
0 commit comments