@@ -2265,32 +2265,40 @@ const collectPositionProperties = () => {
22652265} ;
22662266
22672267// A shadow states its offsets as `<length>{MIN,MAX}`; MIN of them are the two
2268- // offsets every shadow needs.
2268+ // offsets every shadow needs, and one past MAX is no shadow .
22692269const SHADOW_LENGTHS_REGEXP = / < l e n g t h > \{ ( \d + ) , ( \d + ) \} / ;
22702270
22712271/**
2272- * Each property whose value is a list of shadows -> how many lengths a shadow
2273- * cannot go below . The grammar states the range itself (`<length>{2,4}` on
2272+ * Each property whose value is a list of shadows -> the fewest and most lengths a
2273+ * shadow takes . The grammar states the range itself (`<length>{2,4}` on
22742274 * `box-shadow`, `{2,3}` on `text-shadow`), so a trailing zero past the minimum
22752275 * is a value the notation already implies.
2276- * @returns {[string, number][] } the entries, sorted by property
2276+ * @returns {[string, [ number, number] ][] } the entries, sorted by property
22772277 */
22782278const collectShadowProperties = ( ) => {
2279- /** @type {[string, number][] } */
2279+ /** @type {[string, [ number, number] ][] } */
22802280 const out = [ ] ;
22812281 for ( const [ name , entry ] of Object . entries ( properties ) ) {
22822282 if ( typeof entry . syntax !== "string" ) continue ;
2283- let minimum = null ;
2283+ /** @type {[number, number] | null } */
2284+ let lengths = null ;
22842285 for ( const raw of references ( entry . syntax ) ) {
22852286 const definition = definitions . get ( raw ) ;
22862287 if ( definition === undefined ) continue ;
22872288 const range = SHADOW_LENGTHS_REGEXP . exec ( definition ) ;
22882289 if ( range === null ) continue ;
2290+ const minimum = Number ( range [ 1 ] ) ;
2291+ const maximum = Number ( range [ 2 ] ) ;
22892292 // Two productions naming different ranges is no single shadow shape.
2290- if ( minimum !== null && minimum !== Number ( range [ 1 ] ) ) return [ ] ;
2291- minimum = Number ( range [ 1 ] ) ;
2293+ if (
2294+ lengths !== null &&
2295+ ( lengths [ 0 ] !== minimum || lengths [ 1 ] !== maximum )
2296+ ) {
2297+ return [ ] ;
2298+ }
2299+ lengths = [ minimum , maximum ] ;
22922300 }
2293- if ( minimum !== null ) out . push ( [ name , minimum ] ) ;
2301+ if ( lengths !== null ) out . push ( [ name , lengths ] ) ;
22942302 }
22952303 return out . sort ( ( [ a ] , [ b ] ) => ( a < b ? - 1 : 1 ) ) ;
22962304} ;
@@ -3768,15 +3776,6 @@ const mapLiteral = (entries) =>
37683776 . map ( ( [ key , value ] ) => `["${ key } ", "${ value } "]` )
37693777 . join ( ", " ) } ])`;
37703778
3771- /**
3772- * @param {[string, number][] } entries string-keyed, number-valued pairs
3773- * @returns {string } the `Map` literal
3774- */
3775- const countMapLiteral = ( entries ) =>
3776- `new Map([${ entries
3777- . map ( ( [ key , value ] ) => `["${ key } ", ${ value } ]` )
3778- . join ( ", " ) } ])`;
3779-
37803779/**
37813780 * A prefix table's `new Map([…])` literal: `name -> [prefix, [browser, from,
37823781 * to][]][]`. `Infinity` prints as a bare identifier the runtime reads back.
@@ -7351,9 +7350,13 @@ ${displayShortForms
73517350 . join ( ",\n" ) }
73527351]);
73537352
7354- // Each property whose value is a list of shadows -> the count of lengths a
7355- // shadow cannot go below, past which a trailing zero is already implied.
7356- const SHADOW_PROPERTIES = ${ countMapLiteral ( shadowProperties ) } ;
7353+ // Each property whose value is a list of shadows -> the fewest and most lengths
7354+ // a shadow takes; a trailing zero past the fewest is already implied.
7355+ const SHADOW_PROPERTIES = new Map([${ shadowProperties
7356+ . map (
7357+ ( [ name , [ minimum , maximum ] ] ) => `["${ name } ", [${ minimum } , ${ maximum } ]]`
7358+ )
7359+ . join ( ", " ) } ]);
73577360
73587361// WHY: Each shorthand -> the keywords one of its values may drop, each with every
73597362// spelling its own slot takes: the slot's keywords, and each function it
0 commit comments