(value: string)
| 102 | } |
| 103 | |
| 104 | function parseClipPath(value: string): string | ClipPathFunction { |
| 105 | const funcStartIndex = value.indexOf('('); |
| 106 | const funcEndIndex = value.lastIndexOf(')'); |
| 107 | |
| 108 | if (funcStartIndex > -1 && funcEndIndex > -1) { |
| 109 | const functionName = value.substring(0, funcStartIndex).trim(); |
| 110 | |
| 111 | switch (functionName) { |
| 112 | case 'rect': |
| 113 | case 'circle': |
| 114 | case 'ellipse': |
| 115 | case 'polygon': |
| 116 | case 'inset': { |
| 117 | return new ClipPathFunction(functionName, value.substring(funcStartIndex + 1, funcEndIndex)); |
| 118 | } |
| 119 | default: |
| 120 | throw new Error(`Clip-path function ${functionName} is not valid.`); |
| 121 | } |
| 122 | } else { |
| 123 | if (value === 'none') { |
| 124 | return null; |
| 125 | } |
| 126 | |
| 127 | // Only shape functions and none are supported for now |
| 128 | throw new Error(`Clip-path value ${value} is not valid.`); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | function parseShorthandPositioning(value: string): ShorthandPositioning { |
| 133 | const arr = value.split(/[ ,]+/); |
no test coverage detected