Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
xjArea opened this issue Sep 19, 2022 · 3 comments
Open

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

xjArea opened this issue Sep 19, 2022 · 3 comments
Labels

Comments

@xjArea
Copy link

xjArea commented Sep 19, 2022

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.

@ljharb
Copy link

ljharb commented Sep 19, 2022

You'd need lang.source, i believe.

@ljharb
Copy link

ljharb commented Sep 19, 2022

(Also note that if you use the es5-shim/es6-shim, this scenario is handled properly)

@xjArea
Copy link
Author

xjArea commented Sep 22, 2022

RegExp.prototype.source will return the RegExp text part, no include flags, so is :
element.className = element.className.replace(RegExp(lang.source, 'gi'), '');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants