Skip to content

Commit fb6a63b

Browse files
committed
fix: add JS syntax highlighting to bolt-code-snippet; remove syntaxStyles from inlined CSS to sync with Sass updates made; clean out the component's innerHTML to fix cross-browser issues in FF and IE 11
1 parent 9a50290 commit fb6a63b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/components/bolt-code-snippet/src/code-snippet.standalone.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import {
1111
} from '@bolt/core';
1212

1313
import styles from './code-snippet.scss';
14-
import syntaxStyles from './code-snippet-syntax.scss';
1514

1615
import Prism from 'prismjs/components/prism-core'
1716
import 'prismjs/components/prism-markup';
1817
import 'prismjs/components/prism-twig';
18+
import 'prismjs/components/prism-clike';
19+
import 'prismjs/components/prism-javascript';
1920
import 'prismjs/components/prism-css';
2021
import 'prismjs/components/prism-css-extras';
2122
import 'prismjs/components/prism-scss';
@@ -51,6 +52,10 @@ export class BoltCodeSnippetClass extends withPreact() {
5152
this.innerHTML = parentElement.innerHTML;
5253
}
5354
this.code = this.innerHTML;
55+
56+
if (!hasNativeShadowDomSupport) {
57+
this.innerHTML = '';
58+
}
5459
}
5560

5661
render() {
@@ -72,11 +77,11 @@ export class BoltCodeSnippetClass extends withPreact() {
7277

7378
if (display === 'inline'){
7479
return (
75-
<code className={codeClasses}>{this.addStyles([styles, syntaxStyles])}{this.html(highlightedCode)}</code>
80+
<code className={codeClasses}>{this.addStyles([styles])}{this.html(highlightedCode)}</code>
7681
)
7782
} else {
7883
return (
79-
<pre className={preClasses}><code className={codeClasses}>{this.addStyles([styles, syntaxStyles])}{this.html(highlightedCode)}</code></pre>
84+
<pre className={preClasses}><code className={codeClasses}>{this.addStyles([styles])}{this.html(highlightedCode)}</code></pre>
8085
)
8186
}
8287
}

0 commit comments

Comments
 (0)