mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-29 06:43:41 +01:00
[Glitch] Fix nodes order being sometimes mangled when rewriting emoji
backport ccbca50a25
by Claire
This commit is contained in:
parent
ec15e58efa
commit
06faf2f977
2 changed files with 12 additions and 5 deletions
|
@ -19,10 +19,13 @@ const emojiFilename = (filename) => {
|
||||||
return borderedEmoji.includes(filename) ? (filename + '_border') : filename;
|
return borderedEmoji.includes(filename) ? (filename + '_border') : filename;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const domParser = new DOMParser();
|
||||||
|
|
||||||
const emojifyTextNode = (node, customEmojis) => {
|
const emojifyTextNode = (node, customEmojis) => {
|
||||||
const parentElement = node.parentElement;
|
|
||||||
let str = node.textContent;
|
let str = node.textContent;
|
||||||
|
|
||||||
|
const fragment = new DocumentFragment();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
let match, i = 0;
|
let match, i = 0;
|
||||||
|
|
||||||
|
@ -64,12 +67,16 @@ const emojifyTextNode = (node, customEmojis) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node.textContent = str.slice(0, i);
|
fragment.append(document.createTextNode(str.slice(0, i)));
|
||||||
parentElement.insertAdjacentHTML('beforeend', replacement);
|
if (replacement) {
|
||||||
str = str.slice(rend);
|
fragment.append(domParser.parseFromString(replacement, 'text/html').documentElement.getElementsByTagName('img')[0]);
|
||||||
node = document.createTextNode(str);
|
|
||||||
parentElement.append(node);
|
|
||||||
}
|
}
|
||||||
|
node.textContent = str.slice(0, i);
|
||||||
|
str = str.slice(rend);
|
||||||
|
}
|
||||||
|
|
||||||
|
fragment.append(document.createTextNode(str));
|
||||||
|
node.parentElement.replaceChild(fragment, node);
|
||||||
};
|
};
|
||||||
|
|
||||||
const emojifyNode = (node, customEmojis) => {
|
const emojifyNode = (node, customEmojis) => {
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Mastodon
|
||||||
end
|
end
|
||||||
|
|
||||||
def suffix_version
|
def suffix_version
|
||||||
'+1.0.0'
|
'+1.0.1'
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_a
|
def to_a
|
||||||
|
|
Loading…
Reference in a new issue