(current: HTMLScriptElement, run: () => void)
| 22 | } |
| 23 | |
| 24 | function withCurrentScript(current: HTMLScriptElement, run: () => void): void { |
| 25 | const descriptor = Object.getOwnPropertyDescriptor(Document.prototype, 'currentScript') |
| 26 | |
| 27 | Object.defineProperty(document, 'currentScript', { |
| 28 | configurable: true, |
| 29 | get() { |
| 30 | return current |
| 31 | } |
| 32 | }) |
| 33 | |
| 34 | try { |
| 35 | run() |
| 36 | } finally { |
| 37 | if (descriptor) { |
| 38 | Object.defineProperty(document, 'currentScript', descriptor) |
| 39 | } else { |
| 40 | Reflect.deleteProperty(document, 'currentScript') |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | function patchFigmaDelete(code: string): string { |
| 46 | return code.replaceAll(FIGMA_DELETE_PATCH_TARGET, FIGMA_DELETE_PATCH_VALUE) |
no outgoing calls
no test coverage detected