code-input icon indicating copy to clipboard operation
code-input copied to clipboard

Autodetect in highlight.js with `language-php-template` causes infinite loop

Open WebCoder49 opened this issue 1 year ago • 0 comments

To reproduce this:

  • Open the highlight.js code-input Tester page and answer the confirmation dialogs.
  • Delete all of the code from the code-input element at the bottom of the page and replace it with <abc>
  • Look in DevTools. The code element's classes and its contents update every single frame. Screenshot. The code-input pre code element is flashing black on blue.
  • Add a long string of as to the end of the <abc> so the textarea begins to scroll horizontally; you now can't scroll back to the left without moving the cursor to the left. This is very likely due to the blur/focus to move to the caret lines of code in the update function.

This occurs in both Chrome and Firefox.

My suspicions are that the update function is being called every frame. The code-input library removes the highlighted="yes" attribute on the pre code in order to be able to highlight text live, but this might be causing problems with recursion present in PHP template language. This does not occur with autodetected JavaScript.

WebCoder49 avatar May 27 '24 14:05 WebCoder49