Skip to content

Commit

Permalink
check that currentScript is set by a script tag (#3863)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkuechler authored Mar 8, 2025
1 parent f894dc2 commit 8e8b935
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ var Prism = (function (_self) {
if (typeof document === 'undefined') {
return null;
}
if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
return /** @type {any} */ (document.currentScript);
}

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.

2 changes: 1 addition & 1 deletion docs/prism-core.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ <h1 class="page-title">prism-core.js</h1>
if (typeof document === 'undefined') {
return null;
}
if ('currentScript' in document &amp;&amp; 1 &lt; 2 /* hack to trip TS' flow analysis */) {
if (document.currentScript &amp;&amp; document.currentScript.tagName === 'SCRIPT' &amp;&amp; 1 &lt; 2 /* hack to trip TS' flow analysis */) {
return /** @type {any} */ (document.currentScript);
}

Expand Down
2 changes: 1 addition & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ var Prism = (function (_self) {
if (typeof document === 'undefined') {
return null;
}
if ('currentScript' in document && 1 < 2 /* hack to trip TS' flow analysis */) {
if (document.currentScript && document.currentScript.tagName === 'SCRIPT' && 1 < 2 /* hack to trip TS' flow analysis */) {
return /** @type {any} */ (document.currentScript);
}

Expand Down

0 comments on commit 8e8b935

Please sign in to comment.