Skip to content

Uncaught TypeError: e.querySelectorAll is not a function #3524

Closed
@leonalkalai

Description

"Uncaught TypeError: e.querySelectorAll is not a function" on console on reveal.js slider each time i try to use data-line-numbers attribute.

code1
code2
code3
code

<pre class="codestyle">
<code class="language-html" aria-hidden="true" data-line-numbers="2|4|6|8|10|12">
	<span>&#9193; &#9193; &#9193;    A</span>

	<span>&#9193; &#9193; &#9193;    Shift + Space</span>

	<span>&#9193; &#9193; &#9193;    Control + Alt + U + .</span>

	<span>&#9193; &#9193; &#9193;    Control + Shift + &#39;</span>

	<span>&#9193; &#9193; &#9193;    Alt+Shift+P Control+F</span>
	
	<span>&#9193; &#9193; &#9193;    Meta+C Meta+Shift+C</span>
</code>
</pre>

And i get error

highlight.min.js:1 Uncaught TypeError: e.querySelectorAll is not a function
    at Object.getHighlightedLineBounds (highlight.min.js:1:903503)
    at Object.scrollHighlightedLineIntoView (highlight.min.js:1:902923)
    at Object.Le [as dispatchEvent] (reveal.js:8:83748)
    at reveal.js:8:46814
    at Array.forEach (<anonymous>)
    at x.update (reveal.js:8:46145)
    at x.goto (reveal.js:8:47400)
    at x.prev (reveal.js:8:47874)
    at Object.yt (reveal.js:8:97262)
    at T.onDocumentKeyDown (reveal.js:8:54595)
getHighlightedLineBounds @ highlight.min.js:1
scrollHighlightedLineIntoView @ highlight.min.js:1
Le @ reveal.js:8
(anonymous) @ reveal.js:8
update @ reveal.js:8
goto @ reveal.js:8
prev @ reveal.js:8
yt @ reveal.js:8
onDocumentKeyDown @ reveal.js:8

that points to this line
getHighlightedLineBounds: function(e) {
-> e = e.querySelectorAll(".highlight-line");

This error appears only when you change from the second line to the first and not after the second line when you try to change lines with the keyboard arrow and it happens even with the original template.

https://github.com/hakimel/reveal.js/blob/master/index.html#L351

The only way i found to fix it is using fragments like this and only with many pre elements. If i use one pre element with a code the lines don't get highlighted one by one with the keyboard arrows. The framework just highlights all the code at once.

  <pre class="highlight"><code class="highlight fragment highlight-block featured-code" data-fragment-index="1">&#9193; &#9193; &#9193;    A</code></pre>
  <pre class="highlight"><code class="highlight fragment" data-fragment-index="2">&#9193; &#9193; &#9193;    Shift + Space</code></pre>
  <pre class="highlight"><code class="highlight fragment" data-fragment-index="3">&#9193; &#9193; &#9193;    Control + Alt + U + .</code></pre>
  <pre class="highlight"><code  class="highlight fragment" data-fragment-index="4">&#9193; &#9193; &#9193;    Control + Shift + &#39;</code></pre>
  <pre class="highlight"><code  class="highlight fragment" data-fragment-index="5">&#9193; &#9193; &#9193;    Alt+Shift+P Control+F</code></pre>
  <pre class="highlight"><code class="highlight fragment" data-fragment-index="6">&#9193; &#9193; &#9193;    Meta+C Meta+Shift+C</code></pre>

I have tried everything including all the other ways of the framework documentation and some custom javascript didnt work either as intended. Can you please look into it?

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions