FIX: infinite loop when mentioning in IE11

This commit is contained in:
Régis Hanol 2019-08-22 14:47:25 +02:00
parent 74931eedfd
commit 1e4f0ac216

View File

@ -81,13 +81,16 @@ function allowedBoundary(content, index, utils) {
}
function textPostProcess(content, state, ruler) {
let result = null,
match,
pos = 0;
let result = null;
let match;
let pos = 0;
const matcher = ruler.getMatcher();
while ((match = matcher.exec(content))) {
while (match = matcher.exec(content)) {
// something is wrong
if (match.index < pos) break;
// check boundary
if (match.index > 0) {
if (!allowedBoundary(content, match.index - 1, state.md.utils)) {
@ -104,15 +107,14 @@ function textPostProcess(content, state, ruler) {
}
}
result = result || [];
if (match.index > pos) {
result = result || [];
let token = new state.Token("text", "", 0);
token.content = content.slice(pos, match.index);
result.push(token);
}
result = result || [];
ruler.applyRule(result, match, state);
pos = match.index + match[0].length;