Skip to content

Commit 18bed3d

Browse files
committed
Fix Prism crashing Svelte v3.46.2
1 parent 46530dd commit 18bed3d

File tree

2 files changed

+15
-91
lines changed

2 files changed

+15
-91
lines changed

docs/App.svelte

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
/*eslint no-useless-escape: "off"*/
33
import { tick } from 'svelte'
44
import { SvelteToast, toast } from '../src'
5-
import Prism from './Prism.svelte'
5+
//import Prism from './Prism.svelte'
66
import DummyComponent from './Dummy.svelte'
77
import camelCase from 'camelcase'
8+
import Prism from 'prismjs'
89
910
// Hoist to `window` for debug
1011
window.toast = toast
@@ -63,7 +64,9 @@ const buttons = [
6364
code: `toast.push(\`<strong>You won the jackpot!</strong><br>
6465
Click <a href="#" target="_blank">here</a> for details! 😛\`)`,
6566
run: () => {
66-
toast.push('<strong>You won the jackpot!</strong><br>Click <a href="#" target="_blank">here</a> for details! 😛')
67+
toast.push(
68+
'<strong>You won the jackpot!</strong><br>Click <a href="#" target="_blank">here</a> for details! 😛'
69+
)
6770
}
6871
},
6972
{
@@ -296,7 +299,9 @@ toast.pop(0)`,
296299
run: () => {
297300
toast.push('Wait for it...', {
298301
onpop: () => {
299-
toast.push(`<strong><tt>onpop()</tt></strong> callback has been executed.`, { target: 'new' })
302+
toast.push(`<strong><tt>onpop()</tt></strong> callback has been executed.`, {
303+
target: 'new'
304+
})
300305
}
301306
})
302307
}
@@ -328,6 +333,9 @@ toast.pop(0)`,
328333
}
329334
}
330335
]
336+
337+
let formatted
338+
$: formatted = Prism.highlight(code, Prism.languages.javascript, 'javascript')
331339
</script>
332340

333341
<style>
@@ -367,9 +375,10 @@ toast.pop(0)`,
367375

368376
<div class="container">
369377
<div class="w-full h-64 px-2 mt-4 mb-8">
370-
<Prism classes="w-full h-full bg-gray-700 text-gray-200 font-mono shadow rounded-sm overflow-scroll p-4">
371-
{code}
372-
</Prism>
378+
<pre
379+
class="w-full h-full bg-gray-700 text-gray-200 font-mono shadow rounded-sm overflow-scroll p-4"><code
380+
class="language-javascript">{@html formatted}</code
381+
></pre>
373382
</div>
374383
<div class="flex flex-row flex-wrap items-center justify-center">
375384
{#each buttons as btn}

docs/Prism.svelte

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)