fix(css): prevent shorthand parse error on 'unset' and 'inset' (#10424)

This commit is contained in:
Nathan Walker
2023-11-02 13:40:57 -07:00
committed by GitHub
parent 08478556a9
commit d70b48bbe9
3 changed files with 38 additions and 5 deletions

View File

@ -36,24 +36,25 @@ export function parseCSSShorthand(value: string): {
const parts = value.trim().split(PARTS_RE);
const first = parts[0];
if (['', 'none'].includes(first)) {
if (['', 'none', 'unset'].includes(first)) {
return {
inset: false,
color: undefined,
values: [],
};
} else {
const invalidColors = ['inset', 'unset'];
const inset = parts.includes('inset');
const last = parts[parts.length - 1];
let color = 'black';
if (first && !isLength(first) && first !== 'inset') {
if (first && !isLength(first) && !invalidColors.includes(first)) {
color = first;
} else if (last && !isLength(last)) {
} else if (last && !isLength(last) && !invalidColors.includes(last)) {
color = last;
}
const values = parts
.filter((n) => n !== 'inset')
.filter((n) => !invalidColors.includes(n))
.filter((n) => n !== color)
.map((val) => {
try {