@@ -592,7 +592,7 @@ describe("motion-blur declarative attribute", () => {
592592 const own = document . createElement ( "span" ) ;
593593 const inheriting = document . createElement ( "span" ) ;
594594 target . word . append ( own , inheriting ) ;
595- target . word . style . visibility = "hidden" ;
595+ target . word . style . setProperty ( " visibility" , "hidden" , "important" ) ;
596596 const mocked = globalThis . getComputedStyle ;
597597 const resolved = ( element : Element , value : string ) =>
598598 Object . assign ( Object . create ( mocked ( element ) ) , [ "visibility" ] , {
@@ -617,7 +617,27 @@ describe("motion-blur declarative attribute", () => {
617617 expect ( ( copy . children [ 0 ] as HTMLElement ) . style . visibility ) . toBe ( "hidden" ) ;
618618 expect ( ( copy . children [ 1 ] as HTMLElement ) . style . visibility ) . toBe ( "" ) ;
619619 expect ( target . word . style . visibility ) . toBe ( "hidden" ) ;
620+ expect ( target . word . style . getPropertyPriority ( "visibility" ) ) . toBe ( "important" ) ;
621+ } ) ;
622+
623+ it ( "puts a hidden target's visibility back when copying its styles throws" , async ( ) => {
624+ const warn = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
625+ const target = declare ( "" ) ;
626+ const child = document . createElement ( "span" ) ;
627+ target . word . append ( child ) ;
628+ target . word . style . visibility = "hidden" ;
629+ const mocked = globalThis . getComputedStyle ;
630+ globalThis . getComputedStyle = ( ( element : Element ) => {
631+ if ( element === child ) throw new Error ( "no style" ) ;
632+ return mocked ( element ) ;
633+ } ) as typeof globalThis . getComputedStyle ;
634+
635+ target . register ( ) ;
636+
637+ expect ( target . groups ( ) ) . toHaveLength ( 0 ) ;
638+ expect ( target . word . style . visibility ) . toBe ( "hidden" ) ;
620639 expect ( target . word . style . getPropertyPriority ( "visibility" ) ) . toBe ( "" ) ;
640+ warn . mockRestore ( ) ;
621641 } ) ;
622642
623643 it ( "leaves a target alone when another composition registers" , async ( ) => {
0 commit comments