@@ -88,4 +88,29 @@ describe('runtime-dom: attrs patching', () => {
88
88
expect ( el2 . dataset . test ) . toBe ( undefined )
89
89
expect ( testvalue ) . toBe ( obj )
90
90
} )
91
+
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
97
+ patchProp ( iframe , 'sandbox' , null , 'allow-scripts' )
98
+ expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( 'allow-scripts' )
99
+
100
+ // Setting to null should remove the attribute
101
+ patchProp ( iframe , 'sandbox' , 'allow-scripts' , null )
102
+ expect ( iframe . hasAttribute ( 'sandbox' ) ) . toBe ( false )
103
+ 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)
112
+ patchProp ( iframe , 'sandbox' , null , '' )
113
+ expect ( iframe . getAttribute ( 'sandbox' ) ) . toBe ( '' )
114
+ expect ( iframe . hasAttribute ( 'sandbox' ) ) . toBe ( true )
115
+ } )
91
116
} )
0 commit comments