PrismJS / PrismJS/prism

Since V1.26.0, there is a RegExp BUG in IE10/11

Open
#3,558 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Information:

  • Prism version: V1.26.0+
  • Environment: IE10/11 in Windows7/10

Description
V1.25.0 In IE is fine, but Since V1.26.0, IE can't work, the problem is this line :
element.className = element.className.replace(RegExp(lang, 'gi'), '');

Example
Because the type of lang is RexExp, but in IE, RegExp() function, the first parame only can be a String, so it cant't run.
Maybe We can do this to solve it : element.className = element.className.replace(RegExp(String(lang), 'gi'), '');

In addition, the modifier of lang is 'i' : var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;,
but here it is changed to 'gi', I am really worried about whether it will cause an error in some case.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the element.className.replace(RegExp(lang, 'gi'), '') line identified in the issue and inspect how lang is defined and passed in the Prism source. Verify the change against the reported IE10/11 behavior and confirm that language-class removal still works without altering the intended case-insensitive matching.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.