FIX: more efficient matching
This commit is contained in:
parent
49b501ca20
commit
1e8edaddfa
|
@ -101,9 +101,11 @@
|
|||
function processPlaceholders(placeholders, $cooked, mappings) {
|
||||
mappings.length = 0;
|
||||
|
||||
Object.keys(placeholders).map(placeholderKey => {
|
||||
const placeholder = placeholders[placeholderKey];
|
||||
const pattern = `(${placeholder.delimiter}(?:${placeholderKey})${placeholder.delimiter})`;
|
||||
const keys = Object.keys(placeholders);
|
||||
const pattern = keys.map(key => {
|
||||
const placeholder = placeholders[key];
|
||||
return `(${placeholder.delimiter}${key}${placeholder.delimiter})`;
|
||||
}).join("|");
|
||||
const regex = new RegExp(pattern, "g");
|
||||
|
||||
$cooked.find(VALID_TAGS).each((index, elem) => {
|
||||
|
@ -114,13 +116,12 @@
|
|||
|
||||
while ((match = regex.exec(innerHTML)) != null) {
|
||||
mappings[index].push({
|
||||
pattern: match[1],
|
||||
pattern: match[0],
|
||||
position: match.index,
|
||||
length: match[1].length
|
||||
length: match[0].length
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$cooked.find(".d-wrap[data-wrap=placeholder]:not(.placeholdered)").each((index, elem) => {
|
||||
|
|
Loading…
Reference in New Issue