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

Function parseBackground

packages/core/css/parser.ts:561–615  ·  view source on GitHub ↗
(text: string, start = 0)

Source from the content-addressed store, hash-verified

559}
560
561export function parseBackground(text: string, start = 0): Parsed<Background> {
562 const value: any = {};
563 let end = start;
564 while (end < text.length) {
565 const keyword = parseKeyword(text, end);
566 const color = parseColor(text, end, keyword);
567 if (color) {
568 value.color = color.value;
569 end = color.end;
570 continue;
571 }
572 const repeat = parseRepeat(text, end, keyword);
573 if (repeat) {
574 value.repeat = repeat.value;
575 end = repeat.end;
576 continue;
577 }
578 const position = parseBackgroundPosition(text, end, keyword);
579 if (position) {
580 position.value.text = text.substring(position.start, position.end);
581 value.position = position.value;
582 end = position.end;
583
584 const slash = parseSlash(text, end);
585 if (slash) {
586 end = slash.end;
587 const size = parseBackgroundSize(text, end);
588 if (!size) {
589 // Found / but no proper size following
590 return null;
591 }
592 value.size = size.value;
593 end = size.end;
594 }
595 continue;
596 }
597
598 const url = parseURL(text, end);
599 if (url) {
600 value.image = url.value;
601 end = url.end;
602 continue;
603 }
604 const gradient = parseLinearGradient(text, end);
605 if (gradient) {
606 value.image = gradient.value;
607 end = gradient.end;
608 continue;
609 }
610
611 return null;
612 }
613
614 return { start, end, value };
615}

Callers 2

convertToBackgroundsFunction · 0.90

Calls 8

parseKeywordFunction · 0.85
parseColorFunction · 0.85
parseRepeatFunction · 0.85
parseBackgroundPositionFunction · 0.85
parseSlashFunction · 0.85
parseBackgroundSizeFunction · 0.85
parseURLFunction · 0.85
parseLinearGradientFunction · 0.85

Tested by

no test coverage detected