@@ -90,27 +90,36 @@ describe('runtime-dom: attrs patching', () => {
90
90
} )
91
91
92
92
// #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
+
97
109
patchProp ( iframe , 'sandbox' , null , 'allow-scripts' )
98
110
expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( 'allow-scripts' )
99
-
100
- // Setting to null should remove the attribute
111
+ expect ( propSetCount ) . toBe ( 0 )
112
+
101
113
patchProp ( iframe , 'sandbox' , 'allow-scripts' , null )
102
114
expect ( iframe . hasAttribute ( 'sandbox' ) ) . toBe ( false )
103
115
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
+
112
118
patchProp ( iframe , 'sandbox' , null , '' )
113
119
expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( '' )
114
120
expect ( iframe . hasAttribute ( 'sandbox' ) ) . toBe ( true )
121
+ expect ( propSetCount ) . toBe ( 0 )
122
+
123
+ delete iframe . sandbox
115
124
} )
116
125
} )
0 commit comments