mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 18:12:09 +08:00
fix(core): Improved css clip-path parsing (#10753)
This commit is contained in:

committed by
GitHub

parent
6a183709ae
commit
32f2dd14e1
@ -201,10 +201,11 @@ function isNonNegativeFiniteNumber(value: number): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function parseClipPath(value: string): string | ClipPathFunction {
|
function parseClipPath(value: string): string | ClipPathFunction {
|
||||||
const functionStartIndex = value.indexOf('(');
|
const funcStartIndex = value.indexOf('(');
|
||||||
|
const funcEndIndex = value.lastIndexOf(')');
|
||||||
|
|
||||||
if (functionStartIndex > -1) {
|
if (funcStartIndex > -1 && funcEndIndex > -1) {
|
||||||
const functionName = value.substring(0, functionStartIndex).trim();
|
const functionName = value.substring(0, funcStartIndex).trim();
|
||||||
|
|
||||||
switch (functionName) {
|
switch (functionName) {
|
||||||
case 'rect':
|
case 'rect':
|
||||||
@ -212,8 +213,7 @@ function parseClipPath(value: string): string | ClipPathFunction {
|
|||||||
case 'ellipse':
|
case 'ellipse':
|
||||||
case 'polygon':
|
case 'polygon':
|
||||||
case 'inset': {
|
case 'inset': {
|
||||||
const rule: string = value.replace(`${functionName}(`, '').replace(')', '');
|
return new ClipPathFunction(functionName, value.substring(funcStartIndex + 1, funcEndIndex));
|
||||||
return new ClipPathFunction(functionName, rule);
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
throw new Error(`Clip-path function ${functionName} is not valid.`);
|
throw new Error(`Clip-path function ${functionName} is not valid.`);
|
||||||
|
Reference in New Issue
Block a user