[READ-ONLY] a fast, modern browser for the npm registry
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: guard undefined values in `uno-preset-rtl` (#696)

Co-authored-by: Daniel Roe <daniel@roe.dev>

authored by

James Garbutt
Daniel Roe
and committed by
GitHub
64666259 abf7d090

+15 -9
+15 -9
uno-preset-rtl.ts
··· 26 26 const matcher = directionSize(propertyPrefix) 27 27 return (args, context) => { 28 28 const [match, direction, size] = args 29 + if (!size) return undefined 29 30 const defaultMap = { l: 'is', r: 'ie' } 30 31 const map = prefixMap || defaultMap 31 32 const replacement = map[direction as 'l' | 'r'] ··· 41 42 [, a = '', s = 'DEFAULT']: string[], 42 43 { theme }: RuleContext<any>, 43 44 ): CSSEntries | undefined { 44 - if (a in cornerMap) { 45 - if (s === 'full') return cornerMap[a].map(i => [`border${i}-radius`, 'calc(infinity * 1px)']) 45 + const corners = cornerMap[a] 46 + if (!corners) return undefined 47 + 48 + if (s === 'full') return corners.map(i => [`border${i}-radius`, 'calc(infinity * 1px)']) 46 49 47 - const _v = theme.radius?.[s] ?? h.bracket.cssvar.global.fraction.rem(s) 48 - if (_v != null) { 49 - return cornerMap[a].map(i => [`border${i}-radius`, _v]) 50 - } 50 + const _v = theme.radius?.[s] ?? h.bracket?.cssvar?.global?.fraction?.rem?.(s) 51 + if (_v != null) { 52 + return corners.map(i => [`border${i}-radius`, _v]) 51 53 } 52 54 } 53 55 54 56 function handlerBorderSize([, a = '', b = '1']: string[]): CSSEntries | undefined { 55 - const v = h.bracket.cssvar.global.px(b) 56 - if (a in directionMap && v != null) return directionMap[a].map(i => [`border${i}-width`, v]) 57 + const v = h.bracket?.cssvar?.global?.px?.(b) 58 + const directions = directionMap[a] 59 + if (directions && v != null) return directions.map(i => [`border${i}-width`, v]) 57 60 } 58 61 59 62 /** ··· 78 81 [ 79 82 /^(?:position-|pos-)?(left|right)-(.+)$/, 80 83 ([, direction, size], context) => { 84 + if (!size) return undefined 81 85 const replacement = direction === 'left' ? 'inset-is' : 'inset-ie' 82 86 // oxlint-disable-next-line no-console -- warn logging 83 87 console.warn( ··· 101 105 /^rounded-([rl])(?:-(.+))?$/, 102 106 (args, context) => { 103 107 const [_, direction, size] = args 108 + if (!direction) return undefined 104 109 const replacementMap: Record<string, string> = { 105 110 l: 'is', 106 111 r: 'ie', 107 112 } 108 113 const replacement = replacementMap[direction] 114 + if (!replacement) return undefined 109 115 // oxlint-disable-next-line no-console -- warn logging 110 116 console.warn( 111 117 `[RTL] Avoid using 'rounded-${direction}'. Use 'rounded-${replacement}' instead.`, 112 118 ) 113 - return handlerRounded(['', replacement, size], context) 119 + return handlerRounded(['', replacement, size ?? 'DEFAULT'], context) 114 120 }, 115 121 ], 116 122 [