Refactor mfm component

This commit is contained in:
Aya Morisawa 2018-09-01 22:32:51 +09:00
parent 0962e62b8c
commit acffc3e522
No known key found for this signature in database
GPG Key ID: 3E64865D70D579F2

View File

@ -205,17 +205,8 @@ export default Vue.component('misskey-flavored-markdown', {
} }
})); }));
const _els = []; // el.tag === 'br' のとき i !== 0 が保証されるため、短絡評価により els[i - 1] は配列外参照しない
els.forEach((el, i) => { const _els = els.filter((el, i) => !(el.tag === 'br' && ['div', 'pre'].includes(els[i - 1].tag)));
if (el.tag == 'br') {
if (!['div', 'pre'].includes(els[i - 1].tag)) {
_els.push(el);
}
} else {
_els.push(el);
}
});
return createElement('span', _els); return createElement('span', _els);
} }
}); });