(attrs: string)
| 100 | * `importmap`, a `text/template`), which no script grammar reads. |
| 101 | */ |
| 102 | export function isJavaScriptBlock(attrs: string): boolean { |
| 103 | // `type`, not `data-type`; and the type itself, not its `; charset=…`. |
| 104 | const type = /(?:^|\s)type\s*=\s*["']([^"']*)["']/i.exec(attrs)?.[1]?.split(';')[0]!.trim().toLowerCase(); |
| 105 | if (type === undefined || type === '') return true; |
| 106 | // A browser's (`module`, `text/javascript`), a build step's (`text/babel`, |
| 107 | // svelte-preprocess's bare `ts`), and Partytown's, which runs it in a worker. |
| 108 | return /^(?:module|(?:(?:text|application)\/)?(?:x-)?(?:javascript|ecmascript|typescript|babel|jsx|tsx|js|ts)|text\/partytown)$/.test(type); |
| 109 | } |
| 110 | |
| 111 | /** The hosts whose markup {@link sfcMarkupElements} reads. */ |
| 112 | export type SfcMarkupHost = 'svelte' | 'astro'; |
no test coverage detected