Skip to content

Commit

Permalink
Replace flags property of RegExp with a more compatible alternative
Browse files Browse the repository at this point in the history
  • Loading branch information
Golmote committed Jun 18, 2016
1 parent 912bdfe commit 9893489
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ var _ = _self.Prism = {

if (greedy && !pattern.pattern.global) {
// Without the global flag, lastIndex won't work
pattern.pattern = RegExp(pattern.pattern.source, pattern.pattern.flags + "g");
var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
}

pattern = pattern.pattern || pattern;
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.

3 changes: 2 additions & 1 deletion prism.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ var _ = _self.Prism = {

if (greedy && !pattern.pattern.global) {
// Without the global flag, lastIndex won't work
pattern.pattern = RegExp(pattern.pattern.source, pattern.pattern.flags + "g");
var flags = pattern.pattern.toString().match(/[imuy]*$/)[0];
pattern.pattern = RegExp(pattern.pattern.source, flags + "g");
}

pattern = pattern.pattern || pattern;
Expand Down

0 comments on commit 9893489

Please sign in to comment.