MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / parseBackgroundSize

Function parseBackgroundSize

packages/core/css/parser.ts:244–272  ·  view source on GitHub ↗
(value: string, start = 0, keyword = parseKeyword(value, start))

Source from the content-addressed store, hash-verified

242
243const backgroundSizeKeywords = new Set(['auto', 'contain', 'cover']);
244export 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
274const backgroundPositionKeywords = Object.freeze(new Set(['left', 'right', 'top', 'bottom', 'center']));
275const backgroundPositionKeywordsDirection: {

Callers 1

parseBackgroundFunction · 0.85

Calls 2

parseKeywordFunction · 0.85
parsePercentageOrLengthFunction · 0.85

Tested by

no test coverage detected