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:
@@ -29,7 +29,9 @@ import Vue from 'vue';
|
||||
export default Vue.extend({
|
||||
props: ['data'],
|
||||
created() {
|
||||
this.data.forEach(d => d.total = d.notes + d.replies + d.renotes);
|
||||
for (const d of this.data) {
|
||||
d.total = d.notes + d.replies + d.renotes;
|
||||
}
|
||||
const peak = Math.max.apply(null, this.data.map(d => d.total));
|
||||
|
||||
const now = new Date();
|
||||
|
||||
@@ -57,7 +57,10 @@ export default Vue.extend({
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.data.forEach(d => d.total = d.notes + d.replies + d.renotes);
|
||||
for (const d of this.data) {
|
||||
d.total = d.notes + d.replies + d.renotes;
|
||||
}
|
||||
|
||||
this.render();
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -34,9 +34,9 @@ export default Vue.extend({
|
||||
this.$el.style.left = x + 'px';
|
||||
this.$el.style.top = y + 'px';
|
||||
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.addEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
|
||||
this.$el.style.display = 'block';
|
||||
|
||||
@@ -59,9 +59,9 @@ export default Vue.extend({
|
||||
this.close();
|
||||
},
|
||||
close() {
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.removeEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
|
||||
this.$emit('closed');
|
||||
this.destroyDom();
|
||||
|
||||
@@ -120,9 +120,9 @@ export default Vue.extend({
|
||||
|
||||
// ファイルだったら
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
Array.from(e.dataTransfer.files).forEach(file => {
|
||||
for (const file of Array.from(e.dataTransfer.files)) {
|
||||
this.browser.upload(file, this.folder);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ export default Vue.extend({
|
||||
|
||||
// ファイルだったら
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
Array.from(e.dataTransfer.files).forEach(file => {
|
||||
for (const file of Array.from(e.dataTransfer.files)) {
|
||||
this.browser.upload(file, this.folder);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -277,9 +277,9 @@ export default Vue.extend({
|
||||
|
||||
// ドロップされてきたものがファイルだったら
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
Array.from(e.dataTransfer.files).forEach(file => {
|
||||
for (const file of Array.from(e.dataTransfer.files)) {
|
||||
this.upload(file, this.folder);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -368,9 +368,9 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
onChangeFileInput() {
|
||||
Array.from((this.$refs.fileInput as any).files).forEach(file => {
|
||||
for (const file of Array.from((this.$refs.fileInput as any).files)) {
|
||||
this.upload(file, this.folder);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
upload(file, folder) {
|
||||
@@ -549,8 +549,8 @@ export default Vue.extend({
|
||||
let flag = false;
|
||||
const complete = () => {
|
||||
if (flag) {
|
||||
fetchedFolders.forEach(this.appendFolder);
|
||||
fetchedFiles.forEach(this.appendFile);
|
||||
for (const x of fetchedFolders) this.appendFolder(x);
|
||||
for (const x of fetchedFiles) this.appendFile(x);
|
||||
this.fetching = false;
|
||||
} else {
|
||||
flag = true;
|
||||
@@ -575,7 +575,7 @@ export default Vue.extend({
|
||||
} else {
|
||||
this.moreFiles = false;
|
||||
}
|
||||
files.forEach(this.appendFile);
|
||||
for (const x of files) this.appendFile(x);
|
||||
this.fetching = false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ export default Vue.extend({
|
||||
this.$el.style.left = x + 'px';
|
||||
this.$el.style.top = y + 'px';
|
||||
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.addEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -62,9 +62,9 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
close() {
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.removeEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
|
||||
this.$emit('closed');
|
||||
this.destroyDom();
|
||||
|
||||
@@ -102,23 +102,23 @@ const defaultDesktopHomeWidgets = {
|
||||
//#region Construct home data
|
||||
const _defaultDesktopHomeWidgets = [];
|
||||
|
||||
defaultDesktopHomeWidgets.left.forEach(widget => {
|
||||
for (const widget of defaultDesktopHomeWidgets.left) {
|
||||
_defaultDesktopHomeWidgets.push({
|
||||
name: widget,
|
||||
id: uuid(),
|
||||
place: 'left',
|
||||
data: {}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
defaultDesktopHomeWidgets.right.forEach(widget => {
|
||||
for (const widget of defaultDesktopHomeWidgets.right) {
|
||||
_defaultDesktopHomeWidgets.push({
|
||||
name: widget,
|
||||
id: uuid(),
|
||||
place: 'right',
|
||||
data: {}
|
||||
});
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
export default Vue.extend({
|
||||
@@ -220,8 +220,8 @@ export default Vue.extend({
|
||||
const left = this.widgets.left;
|
||||
const right = this.widgets.right;
|
||||
this.$store.commit('settings/setHome', left.concat(right));
|
||||
left.forEach(w => w.place = 'left');
|
||||
right.forEach(w => w.place = 'right');
|
||||
for (const w of left) w.place = 'left';
|
||||
for (const w of right) w.place = 'right';
|
||||
this.$root.api('i/update_home', {
|
||||
home: this.home
|
||||
});
|
||||
|
||||
@@ -156,7 +156,9 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
releaseQueue() {
|
||||
this.queue.forEach(n => this.prepend(n, true));
|
||||
for (const n of this.queue) {
|
||||
this.prepend(n, true);
|
||||
}
|
||||
this.queue = [];
|
||||
},
|
||||
|
||||
|
||||
@@ -184,7 +184,8 @@ export default Vue.extend({
|
||||
if (this.reply && this.reply.text != null) {
|
||||
const ast = parse(this.reply.text);
|
||||
|
||||
ast.filter(t => t.type == 'mention').forEach(x => {
|
||||
// TODO: 新しいMFMパーサに対応
|
||||
for (const x of ast.filter(t => t.type == 'mention')) {
|
||||
const mention = x.host ? `@${x.username}@${toASCII(x.host)}` : `@${x.username}`;
|
||||
|
||||
// 自分は除外
|
||||
@@ -195,7 +196,7 @@ export default Vue.extend({
|
||||
if (this.text.indexOf(`${mention} `) != -1) return;
|
||||
|
||||
this.text += `${mention} `;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// デフォルト公開範囲
|
||||
@@ -261,7 +262,7 @@ export default Vue.extend({
|
||||
this.$chooseDriveFile({
|
||||
multiple: true
|
||||
}).then(files => {
|
||||
files.forEach(this.attachMedia);
|
||||
for (const x of files) this.attachMedia(x);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -276,7 +277,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
onChangeFile() {
|
||||
Array.from((this.$refs.file as any).files).forEach(this.upload);
|
||||
for (const x of Array.from((this.$refs.file as any).files)) this.upload(x);
|
||||
},
|
||||
|
||||
onPollUpdate() {
|
||||
@@ -304,11 +305,11 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
onPaste(e) {
|
||||
Array.from(e.clipboardData.items).forEach((item: any) => {
|
||||
for (const item of Array.from(e.clipboardData.items)) {
|
||||
if (item.kind == 'file') {
|
||||
this.upload(item.getAsFile());
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onDragover(e) {
|
||||
@@ -335,7 +336,7 @@ export default Vue.extend({
|
||||
// ファイルだったら
|
||||
if (e.dataTransfer.files.length > 0) {
|
||||
e.preventDefault();
|
||||
Array.from(e.dataTransfer.files).forEach(this.upload);
|
||||
for (const x of Array.from(e.dataTransfer.files)) this.upload(x);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,9 @@ export default Vue.extend({
|
||||
} else {
|
||||
this.existMore = false;
|
||||
}
|
||||
notes.forEach(n => (this.$refs.timeline as any).append(n));
|
||||
for (const n of notes) {
|
||||
(this.$refs.timeline as any).append(n);
|
||||
}
|
||||
this.moreFetching = false;
|
||||
});
|
||||
|
||||
|
||||
@@ -120,15 +120,15 @@ export default Vue.extend({
|
||||
},
|
||||
open() {
|
||||
this.isOpen = true;
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.addEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.isOpen = false;
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.removeEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
},
|
||||
onMousedown(e) {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -42,16 +42,16 @@ export default Vue.extend({
|
||||
|
||||
open() {
|
||||
this.isOpen = true;
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.addEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
close() {
|
||||
this.isOpen = false;
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.removeEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onMousedown(e) {
|
||||
|
||||
@@ -171,16 +171,16 @@ export default Vue.extend({
|
||||
|
||||
openNotifications() {
|
||||
this.showNotifications = true;
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.addEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
closeNotifications() {
|
||||
this.showNotifications = false;
|
||||
Array.from(document.querySelectorAll('body *')).forEach(el => {
|
||||
for (const el of Array.from(document.querySelectorAll('body *'))) {
|
||||
el.removeEventListener('mousedown', this.onMousedown);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onMousedown(e) {
|
||||
|
||||
@@ -79,7 +79,7 @@ export default Vue.extend({
|
||||
} else {
|
||||
this.existMore = false;
|
||||
}
|
||||
notes.forEach(n => (this.$refs.timeline as any).append(n));
|
||||
for (const n of notes) (this.$refs.timeline as any).append(n);
|
||||
this.moreFetching = false;
|
||||
});
|
||||
|
||||
|
||||
@@ -234,12 +234,12 @@ export default Vue.extend({
|
||||
top() {
|
||||
let z = 0;
|
||||
|
||||
this.$root.os.windows.getAll().forEach(w => {
|
||||
if (w == this) return;
|
||||
const ws = this.$root.os.windows.getAll().filter(w => w != this);
|
||||
for (const w of ws) {
|
||||
const m = w.$refs.main;
|
||||
const mz = Number(document.defaultView.getComputedStyle(m, null).zIndex);
|
||||
if (mz > z) z = mz;
|
||||
});
|
||||
}
|
||||
|
||||
if (z > 0) {
|
||||
(this.$refs.main as any).style.zIndex = z + 1;
|
||||
|
||||
Reference in New Issue
Block a user