mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat(core): CSS wide keywords (#10709)
This commit is contained in:
committed by
GitHub
parent
5024156f0d
commit
2d71ada46d
@@ -42,31 +42,32 @@ export function parseCSSShorthand(value: string): {
|
||||
|
||||
if (['', 'none', 'unset'].includes(first)) {
|
||||
return null;
|
||||
} else {
|
||||
const invalidColors = ['inset', 'unset'];
|
||||
const inset = parts.includes('inset');
|
||||
const last = parts[parts.length - 1];
|
||||
let color = 'black';
|
||||
if (first && !isLength(first) && !invalidColors.includes(first)) {
|
||||
color = first;
|
||||
} else if (last && !isLength(last) && !invalidColors.includes(last)) {
|
||||
color = last;
|
||||
}
|
||||
|
||||
const values = parts
|
||||
.filter((n) => !invalidColors.includes(n))
|
||||
.filter((n) => n !== color)
|
||||
.map((val) => {
|
||||
try {
|
||||
return Length.parse(val);
|
||||
} catch (err) {
|
||||
return CoreTypes.zeroLength;
|
||||
}
|
||||
});
|
||||
return {
|
||||
inset,
|
||||
color,
|
||||
values,
|
||||
};
|
||||
}
|
||||
|
||||
const invalidColors = ['inset', 'unset'];
|
||||
const inset = parts.includes('inset');
|
||||
const last = parts[parts.length - 1];
|
||||
let color = 'black';
|
||||
if (first && !isLength(first) && !invalidColors.includes(first)) {
|
||||
color = first;
|
||||
} else if (last && !isLength(last) && !invalidColors.includes(last)) {
|
||||
color = last;
|
||||
}
|
||||
|
||||
const values = parts
|
||||
.filter((n) => !invalidColors.includes(n))
|
||||
.filter((n) => n !== color)
|
||||
.map((val) => {
|
||||
try {
|
||||
return Length.parse(val);
|
||||
} catch (err) {
|
||||
return CoreTypes.zeroLength;
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
inset,
|
||||
color,
|
||||
values,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user