Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/auto-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const PrismConfig = {
if (typeof document !== 'undefined' && typeof window !== 'undefined') {
// Get current script and highlight
const script = document.currentScript as HTMLScriptElement | null;
if (script && script.hasAttribute('data-manual')) {
if (script && script.tagName === 'SCRIPT' && script.hasAttribute('data-manual')) {
PrismConfig.manual = true;
}

Expand All @@ -48,7 +48,7 @@ if (typeof document !== 'undefined' && typeof window !== 'undefined') {
// See https://github.com/PrismJS/prism/issues/2102
// See https://github.com/PrismJS/prism/issues/3535
const readyState = document.readyState;
if (readyState === 'loading' || readyState === 'interactive' && script && script.defer && !script.async) {
if (readyState === 'loading' || readyState === 'interactive' && script && script.tagName === 'SCRIPT' && script.defer && !script.async) {
document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback);
} else {
window.requestAnimationFrame(highlightAutomaticallyCallback);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/autoloader/prism-autoloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { ComponentProto, PluginProto } from '../../types';
function getDefaultSrcPath() {
if (typeof document !== 'undefined') {
const script = document.currentScript as HTMLScriptElement | null;
if (script) {
if (script?.tagName === 'SCRIPT') {
const autoloaderFile = /\bplugins\/autoloader\/prism-autoloader\.(?:min\.)?js(?:\?[^\r\n/]*)?$/i;
const prismFile = /(^|\/)[\w-]+\.(?:min\.)?m?js(?:\?[^\r\n/]*)?$/i;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default {

if (typeof document !== 'undefined') {
const script = document.currentScript;
if (script) {
if (script?.tagName === 'SCRIPT') {
config.filterKnown = script.hasAttribute('data-filter-known');

let attr;
Expand Down