File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
packages/components/src/components/hds/code-block Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,7 @@ export default class HdsCodeBlock extends Component<HdsCodeBlockSignature> {
8181
8282 // If a code block is hidden from view, and made visible after load, the Prism code needs to be re-run
8383 private _setUpObserver = modifier ( ( element : HTMLElement ) => {
84+ this . _preCodeElement = element . querySelector ( 'pre' ) as HTMLPreElement ;
8485 const codeBlock = element . querySelector ( 'code' ) as HTMLElement ;
8586 this . _observer = new IntersectionObserver ( ( entries ) => {
8687 entries . forEach ( ( entry ) => {
@@ -97,7 +98,6 @@ export default class HdsCodeBlock extends Component<HdsCodeBlockSignature> {
9798 } ) ;
9899
99100 private _setUpCodeBlockCode = modifier ( ( element : HTMLElement ) => {
100- this . _preCodeElement = element . querySelector ( 'pre' ) as HTMLPreElement ;
101101 this . setPrismCode ( element ) ;
102102 return ( ) => { } ;
103103 } ) ;
@@ -187,7 +187,7 @@ export default class HdsCodeBlock extends Component<HdsCodeBlockSignature> {
187187 // we need to re-trigger the line numbers generation as late as possible to account for any line wrapping styles that are applied
188188 if ( this . args . hasLineWrapping && Prism ?. plugins ?. [ 'lineNumbers' ] ) {
189189 // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
190- Prism . plugins [ 'lineNumbers' ] . highlight ( this . _preCodeElement ) ;
190+ Prism . plugins [ 'lineNumbers' ] . resize ( this . _preCodeElement ) ;
191191 }
192192
193193 // Force prism-line-highlight plugin initialization
You can’t perform that action at this time.
0 commit comments