0
0
Fork 0

Use modern ES syntax rather than .call (#29368)

This commit is contained in:
Renaud Chaput 2024-02-27 16:42:05 +01:00 committed by GitHub
parent 6f7615ba86
commit 899eac1a92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 34 additions and 28 deletions

View file

@ -73,11 +73,11 @@ function loaded() {
return messageFormat.format(values);
};
[].forEach.call(document.querySelectorAll('.emojify'), (content) => {
document.querySelectorAll('.emojify').forEach((content) => {
content.innerHTML = emojify(content.innerHTML);
});
[].forEach.call(document.querySelectorAll('time.formatted'), (content) => {
document.querySelectorAll('time.formatted').forEach((content) => {
const datetime = new Date(content.getAttribute('datetime'));
const formattedDate = dateTimeFormat.format(datetime);
@ -94,7 +94,7 @@ function loaded() {
};
const todayFormat = new IntlMessageFormat(localeData['relative_format.today'] || 'Today at {time}', locale);
[].forEach.call(document.querySelectorAll('time.relative-formatted'), (content) => {
document.querySelectorAll('time.relative-formatted').forEach((content) => {
const datetime = new Date(content.getAttribute('datetime'));
let formattedContent;
@ -111,7 +111,7 @@ function loaded() {
content.textContent = formattedContent;
});
[].forEach.call(document.querySelectorAll('time.time-ago'), (content) => {
document.querySelectorAll('time.time-ago').forEach((content) => {
const datetime = new Date(content.getAttribute('datetime'));
const now = new Date();
@ -128,8 +128,8 @@ function loaded() {
if (reactComponents.length > 0) {
import(/* webpackChunkName: "containers/media_container" */ '../mastodon/containers/media_container')
.then(({ default: MediaContainer }) => {
[].forEach.call(reactComponents, (component) => {
[].forEach.call(component.children, (child) => {
reactComponents.forEach((component) => {
Array.from(component.children).forEach((child) => {
component.removeChild(child);
});
});
@ -185,7 +185,7 @@ function loaded() {
return false;
});
[].forEach.call(document.querySelectorAll('.status__content__spoiler-link'), (spoilerLink) => {
document.querySelectorAll('.status__content__spoiler-link').forEach((spoilerLink) => {
const statusEl = spoilerLink.parentNode.parentNode;
const message = (statusEl.dataset.spoiler === 'expanded') ? (localeData['status.show_less'] || 'Show less') : (localeData['status.show_more'] || 'Show more');
spoilerLink.textContent = (new IntlMessageFormat(message, locale)).format();