(value: string, start = 0, keyword = parseKeyword(value, start))
| 242 | |
| 243 | const backgroundSizeKeywords = new Set(['auto', 'contain', 'cover']); |
| 244 | export function parseBackgroundSize(value: string, start = 0, keyword = parseKeyword(value, start)): Parsed<BackgroundSize> { |
| 245 | let end = start; |
| 246 | if (keyword && backgroundSizeKeywords.has(keyword.value)) { |
| 247 | end = keyword.end; |
| 248 | const value = <'auto' | 'cover' | 'contain'>keyword.value; |
| 249 | |
| 250 | return { start, end, value }; |
| 251 | } |
| 252 | |
| 253 | // Parse one or two lengths... the other will be "auto" |
| 254 | const firstLength = parsePercentageOrLength(value, end); |
| 255 | if (firstLength) { |
| 256 | end = firstLength.end; |
| 257 | const secondLength = parsePercentageOrLength(value, firstLength.end); |
| 258 | if (secondLength) { |
| 259 | end = secondLength.end; |
| 260 | |
| 261 | return { |
| 262 | start, |
| 263 | end, |
| 264 | value: { x: firstLength.value, y: secondLength.value }, |
| 265 | }; |
| 266 | } else { |
| 267 | return { start, end, value: { x: firstLength.value, y: 'auto' } }; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | return null; |
| 272 | } |
| 273 | |
| 274 | const backgroundPositionKeywords = Object.freeze(new Set(['left', 'right', 'top', 'bottom', 'center'])); |
| 275 | const backgroundPositionKeywordsDirection: { |
no test coverage detected