8000 fix(core): Improved css clip-path parsing (#10753) · NativeScript/NativeScript@32f2dd1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 32f2dd1

Browse files
authored
fix(core): Improved css clip-path parsing (#10753)
1 parent 6a18370 commit 32f2dd1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/core/ui/styling/style-properties.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,19 +201,19 @@ function isNonNegativeFiniteNumber(value: number): boolean {
201201
}
202202

203203
function parseClipPath(value: string): string | ClipPathFunction {
204-
const functionStartIndex = value.indexOf('(');
204+
const funcStartIndex = value.indexOf('(');
205+
const funcEndIndex = value.lastIndexOf(')');
205206

206-
if (functionStartIndex > -1) {
207-
const functionName = value.substring(0, functionStartIndex).trim();
207+
if (funcStartIndex > -1 && funcEndIndex > -1) {
208+
const functionName = value.substring(0, funcStartIndex).trim();
208209

209210
switch (functionName) {
210211
case 'rect':
211212
case 'circle':
212213
case 'ellipse':
213214
case 'polygon':
214215
case 'inset': {
215-
const rule: string = value.replace(`${functionName}(`, '').replace(')', '');
216-
return new ClipPathFunction(functionName, rule);
216+
return new ClipPathFunction(functionName, value.substring(funcStartIndex + 1, funcEndIndex));
217217
}
218218
default:
219219
throw new Error(`Clip-path function ${functionName} is not valid.`);

0 commit comments

Comments
 (0)
0