Use for-of instead of forEach (#3583)
Co-authored-by: syuilo <syuilotan@yahoo.co.jp> Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
@ -57,18 +57,18 @@ const emjdb: EmojiDef[] = lib.map((x: any) => ({
|
||||
url: `https://twemoji.maxcdn.com/2/svg/${char2file(x[1].char)}.svg`
|
||||
}));
|
||||
|
||||
lib.forEach((x: any) => {
|
||||
for (const x of lib as any) {
|
||||
if (x[1].keywords) {
|
||||
x[1].keywords.forEach(k => {
|
||||
for (const k of x[1].keywords) {
|
||||
emjdb.push({
|
||||
emoji: x[1].char,
|
||||
name: k,
|
||||
aliasOf: x[0],
|
||||
url: `https://twemoji.maxcdn.com/2/svg/${char2file(x[1].char)}.svg`
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emjdb.sort((a, b) => a.name.length - b.name.length);
|
||||
|
||||
@ -120,7 +120,7 @@ export default Vue.extend({
|
||||
const customEmojis = (this.$root.getMetaSync() || { emojis: [] }).emojis || [];
|
||||
const emojiDefinitions: EmojiDef[] = [];
|
||||
|
||||
customEmojis.forEach(x => {
|
||||
for (const x of customEmojis) {
|
||||
emojiDefinitions.push({
|
||||
name: x.name,
|
||||
emoji: `:${x.name}:`,
|
||||
@ -129,7 +129,7 @@ export default Vue.extend({
|
||||
});
|
||||
|
||||
if (x.aliases) {
|
||||
x.aliases.forEach(alias => {
|
||||
for (const alias of x.aliases) {
|
||||
emojiDefinitions.push({
|
||||
name: alias,
|
||||
aliasOf: x.name,
|
||||
@ -137,9 +137,9 @@ export default Vue.extend({
|
||||
url: x.url,
|
||||
isCustomEmoji: true
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
emojiDefinitions.sort((a, b) => a.name.length - b.name.length);
|
||||
|
||||
@ -148,9 +148,9 @@ export default Vue.extend({
|
||||
|
||||
this.textarea.addEventListener('keydown', this.onKeydown);
|
||||
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.addEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.exec();
|
||||
@ -166,18 +166,18 @@ export default Vue.extend({
|
||||
beforeDestroy() {
|
||||
this.textarea.removeEventListener('keydown', this.onKeydown);
|
||||
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.removeEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
exec() {
|
||||
this.select = -1;
|
||||
if (this.$refs.suggests) {
|
||||
Array.from(this.items).forEach(el => {
|
||||
for (const el of Array.from(this.items)) {
|
||||
el.removeAttribute('data-selected');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (this.type == 'user') {
|
||||
@ -316,9 +316,9 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
applySelect() {
|
||||
Array.from(this.items).forEach(el => {
|
||||
for (const el of Array.from(this.items)) {
|
||||
el.removeAttribute('data-selected');
|
||||
});
|
||||
}
|
||||
|
||||
this.items[this.select].setAttribute('data-selected', 'true');
|
||||
(this.items[this.select] as any).focus();
|
||||
|
Reference in New Issue
Block a user