@@ -777,4 +777,118 @@ test("object classnames object to string transition", () => {
777777 Assert . not . ok ( element . classList . contains ( "another-class" ) ) ;
778778} ) ;
779779
780+ test ( "relative src should not cause unnecessary updates" , ( ) => {
781+ // Track how many times src property is set
782+ let srcSetCount = 0 ;
783+ const originalDescriptor = Object . getOwnPropertyDescriptor (
784+ HTMLIFrameElement . prototype ,
785+ "src" ,
786+ ) ! ;
787+ Object . defineProperty ( HTMLIFrameElement . prototype , "src" , {
788+ get : originalDescriptor . get ,
789+ set ( value ) {
790+ srcSetCount ++ ;
791+ return originalDescriptor . set ! . call ( this , value ) ;
792+ } ,
793+ configurable : true ,
794+ } ) ;
795+
796+ try {
797+ // Initial render
798+ renderer . render ( < iframe src = "/test-path" /> , document . body ) ;
799+ Assert . is ( srcSetCount , 1 , "src should be set once on initial render" ) ;
800+
801+ // Re-render with same src
802+ renderer . render ( < iframe src = "/test-path" /> , document . body ) ;
803+ Assert . is ( srcSetCount , 1 , "src should not be set again when unchanged" ) ;
804+
805+ // Re-render with different src
806+ renderer . render ( < iframe src = "/different-path" /> , document . body ) ;
807+ Assert . is ( srcSetCount , 2 , "src should be set when changed" ) ;
808+ } finally {
809+ // Restore original property
810+ Object . defineProperty (
811+ HTMLIFrameElement . prototype ,
812+ "src" ,
813+ originalDescriptor ,
814+ ) ;
815+ }
816+ } ) ;
817+
818+ test ( "relative href should not cause unnecessary updates" , ( ) => {
819+ // Track how many times href property is set
820+ let hrefSetCount = 0 ;
821+ const originalDescriptor = Object . getOwnPropertyDescriptor (
822+ HTMLAnchorElement . prototype ,
823+ "href" ,
824+ ) ! ;
825+ Object . defineProperty ( HTMLAnchorElement . prototype , "href" , {
826+ get : originalDescriptor . get ,
827+ set ( value ) {
828+ hrefSetCount ++ ;
829+ return originalDescriptor . set ! . call ( this , value ) ;
830+ } ,
831+ configurable : true ,
832+ } ) ;
833+
834+ try {
835+ // Initial render
836+ renderer . render ( < a href = "/test-link" > Link</ a > , document . body ) ;
837+ Assert . is ( hrefSetCount , 1 , "href should be set once on initial render" ) ;
838+
839+ // Re-render with same href
840+ renderer . render ( < a href = "/test-link" > Link</ a > , document . body ) ;
841+ Assert . is ( hrefSetCount , 1 , "href should not be set again when unchanged" ) ;
842+
843+ // Re-render with different href
844+ renderer . render ( < a href = "/different-link" > Link</ a > , document . body ) ;
845+ Assert . is ( hrefSetCount , 2 , "href should be set when changed" ) ;
846+ } finally {
847+ // Restore original property
848+ Object . defineProperty (
849+ HTMLAnchorElement . prototype ,
850+ "href" ,
851+ originalDescriptor ,
852+ ) ;
853+ }
854+ } ) ;
855+
856+ test ( "absolute URLs should work correctly for src" , ( ) => {
857+ let srcSetCount = 0 ;
858+ const originalDescriptor = Object . getOwnPropertyDescriptor (
859+ HTMLIFrameElement . prototype ,
860+ "src" ,
861+ ) ! ;
862+ Object . defineProperty ( HTMLIFrameElement . prototype , "src" , {
863+ get : originalDescriptor . get ,
864+ set ( value ) {
865+ srcSetCount ++ ;
866+ return originalDescriptor . set ! . call ( this , value ) ;
867+ } ,
868+ configurable : true ,
869+ } ) ;
870+
871+ try {
872+ // Initial render with absolute URL
873+ renderer . render (
874+ < iframe src = "https://example.com/page" /> ,
875+ document . body ,
876+ ) ;
877+ Assert . is ( srcSetCount , 1 ) ;
878+
879+ // Re-render with same absolute URL
880+ renderer . render (
881+ < iframe src = "https://example.com/page" /> ,
882+ document . body ,
883+ ) ;
884+ Assert . is ( srcSetCount , 1 , "absolute src should not be set again when unchanged" ) ;
885+ } finally {
886+ Object . defineProperty (
887+ HTMLIFrameElement . prototype ,
888+ "src" ,
889+ originalDescriptor ,
890+ ) ;
891+ }
892+ } ) ;
893+
780894test . run ( ) ;
0 commit comments