@@ -10672,6 +10672,94 @@ describe("CssSyntax minify — a slot holding its own initial", () => {
1067210672 } ) ;
1067310673} ) ;
1067410674
10675+ describe ( "CssSyntax minify — the declaration a lowered shorthand kills" , ( ) => {
10676+ // Reads `text-decoration` as CSS 2.1's line alone, so the shorthand is
10677+ // written out as the line plus the longhands beside it — and reads those.
10678+ const T = [ "safari 15" ] ;
10679+
10680+ it ( "takes out an earlier declaration the lowered one writes over" , ( ) => {
10681+ expect (
10682+ minifyFor ( "a{text-decoration:underline;text-decoration:underline dotted}" , T )
10683+ ) . toBe ( "a{text-decoration:underline;text-decoration-style:dotted}" ) ;
10684+ } ) ;
10685+
10686+ it ( "takes it out whatever the earlier one said" , ( ) => {
10687+ expect (
10688+ minifyFor ( "a{text-decoration:overline;text-decoration:underline dotted}" , T )
10689+ ) . toBe ( "a{text-decoration:underline;text-decoration-style:dotted}" ) ;
10690+ } ) ;
10691+
10692+ it ( "takes out every earlier one" , ( ) => {
10693+ expect (
10694+ minifyFor (
10695+ "a{text-decoration:overline;text-decoration:blink;text-decoration:underline dotted}" ,
10696+ T
10697+ )
10698+ ) . toBe ( "a{text-decoration:underline;text-decoration-style:dotted}" ) ;
10699+ } ) ;
10700+
10701+ it ( "takes one out past a rule written between them" , ( ) => {
10702+ expect (
10703+ minifyFor (
10704+ "a{text-decoration:overline;& b{top:0}text-decoration:underline dotted}" ,
10705+ T
10706+ )
10707+ ) . toBe ( "a{& b{top:0}text-decoration:underline;text-decoration-style:dotted}" ) ;
10708+ } ) ;
10709+
10710+ it ( "keeps the earlier one where the target reads the later whole" , ( ) => {
10711+ // Nothing is lowered, so the later value is the one a target may not read
10712+ // — and the earlier one is the fallback the author wrote.
10713+ const css = "a{text-decoration:overline;text-decoration:underline dotted}" ;
10714+ expect ( minifyFor ( css , [ "chrome 130" ] ) ) . toBe ( css ) ;
10715+ } ) ;
10716+
10717+ it ( "keeps it where the longhands the lowering writes are unread too" , ( ) => {
10718+ // The lowered form is no more readable than the shorthand was, so the
10719+ // earlier declaration is still the fallback it was written as.
10720+ expect (
10721+ minifyFor (
10722+ "a{text-decoration:overline;text-decoration:underline dotted}" ,
10723+ [ "ie 11" ]
10724+ )
10725+ ) . toBe (
10726+ "a{text-decoration:overline;text-decoration:underline;text-decoration-style:dotted}"
10727+ ) ;
10728+ } ) ;
10729+
10730+ it ( "keeps an `!important` earlier one, which wins the tie" , ( ) => {
10731+ expect (
10732+ minifyFor (
10733+ "a{text-decoration:overline!important;text-decoration:underline dotted}" ,
10734+ T
10735+ )
10736+ ) . toBe (
10737+ "a{text-decoration:overline!important;text-decoration:underline;text-decoration-style:dotted}"
10738+ ) ;
10739+ } ) ;
10740+
10741+ it ( "keeps an earlier longhand, which the shorthand does not repeat" , ( ) => {
10742+ expect (
10743+ minifyFor (
10744+ "a{text-decoration-line:underline;text-decoration:underline dotted}" ,
10745+ T
10746+ )
10747+ ) . toBe (
10748+ "a{text-decoration-line:underline;text-decoration:underline;text-decoration-style:dotted}"
10749+ ) ;
10750+ } ) ;
10751+
10752+ it ( "keeps an earlier one where the later is a substitution" , ( ) => {
10753+ const css = "a{text-decoration:overline;text-decoration:var(--x)}" ;
10754+ expect ( minifyFor ( css , T ) ) . toBe ( css ) ;
10755+ } ) ;
10756+
10757+ it ( "keeps both with the rewrite off" , ( ) => {
10758+ const css = "a{text-decoration:overline;text-decoration:underline dotted}" ;
10759+ expect ( minifyForWith ( css , T , { lowerUnsupported : false } ) ) . toBe ( css ) ;
10760+ } ) ;
10761+ } ) ;
10762+
1067510763describe ( "CssSyntax minify — nesting the target cannot read" , ( ) => {
1067610764 it ( "writes a rule nested in another on its own" , ( ) => {
1067710765 expect ( minifyFor ( "a{color:red;& b{color:blue}}" , [ "chrome 100" ] ) ) . toBe (
0 commit comments