Skip to content

Commit

Permalink
Core: Add tabindex to code blocks to enable keyboard navigation (#2799
Browse files Browse the repository at this point in the history
)
  • Loading branch information
RunDevelopment authored Mar 21, 2021
1 parent 7e5f78f commit dbf7051
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 15 deletions.
6 changes: 6 additions & 0 deletions components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,12 @@ var _ = {

_.hooks.run('before-sanity-check', env);

// plugins may change/add the parent/element
parent = env.element.parentElement;
if (parent && parent.nodeName.toLowerCase() === 'pre' && !parent.hasAttribute('tabindex')) {
parent.setAttribute('tabindex', '0');
}

if (!env.code) {
_.hooks.run('complete', env);
callback && callback.call(env.element);
Expand Down
2 changes: 1 addition & 1 deletion components/prism-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions docs/Prism.hooks.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h2>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line671">line 671</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line677">line 677</a>
</li></ul></dd>


Expand Down Expand Up @@ -152,7 +152,7 @@ <h4 class="name" id=".add"><span class="type-signature">(static) </span>add<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line686">line 686</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line692">line 692</a>
</li></ul></dd>


Expand Down Expand Up @@ -314,7 +314,7 @@ <h4 class="name" id=".run"><span class="type-signature">(static) </span>run<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line703">line 703</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line709">line 709</a>
</li></ul></dd>


Expand Down
4 changes: 2 additions & 2 deletions docs/Prism.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ <h4 class="name" id=".highlight"><span class="type-signature">(static) </span>hi

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line612">line 612</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line618">line 618</a>
</li></ul></dd>


Expand Down Expand Up @@ -1157,7 +1157,7 @@ <h4 class="name" id=".tokenize"><span class="type-signature">(static) </span>tok

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line648">line 648</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line654">line 654</a>
</li></ul></dd>


Expand Down
8 changes: 4 additions & 4 deletions docs/Token.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h4 class="name" id="Token"><span class="type-signature"></span>new Token<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line737">line 737</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line743">line 743</a>
</li></ul></dd>


Expand Down Expand Up @@ -364,7 +364,7 @@ <h4 class="name" id="alias"><span class="type-signature"></span>alias<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line764">line 764</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line770">line 770</a>
</li></ul></dd>


Expand Down Expand Up @@ -447,7 +447,7 @@ <h4 class="name" id="content"><span class="type-signature"></span>content<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line756">line 756</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line762">line 762</a>
</li></ul></dd>


Expand Down Expand Up @@ -524,7 +524,7 @@ <h4 class="name" id="type"><span class="type-signature"></span>type<span class="

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line747">line 747</a>
<a href="prism-core.js.html">prism-core.js</a>, <a href="prism-core.js.html#line753">line 753</a>
</li></ul></dd>


Expand Down
Loading

0 comments on commit dbf7051

Please sign in to comment.