mirror of
https://github.com/mastodon/mastodon
synced 2024-12-03 01:08:23 +09:00
Add new eventListener to force rendering of embedded toots
This commit is contained in:
parent
986a3676d3
commit
0d5441bcdc
@ -72,7 +72,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Legacy embeds
|
// Legacy embeds
|
||||||
document.querySelectorAll('iframe.mastodon-embed').forEach(iframe => {
|
var renderLegacyEmbed = function (iframe) {
|
||||||
var id = generateId(embeds);
|
var id = generateId(embeds);
|
||||||
|
|
||||||
embeds.set(id, iframe);
|
embeds.set(id, iframe);
|
||||||
@ -91,10 +91,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
iframe.onload(); // In case the script is executing after the iframe has already loaded
|
iframe.onload(); // In case the script is executing after the iframe has already loaded
|
||||||
});
|
};
|
||||||
|
document.querySelectorAll('iframe.mastodon-embed').forEach(renderLegacyEmbed);
|
||||||
|
|
||||||
// New generation of embeds
|
// New generation of embeds
|
||||||
document.querySelectorAll('blockquote.mastodon-embed').forEach(container => {
|
var renderEmbed = function (container) {
|
||||||
var id = generateId(embeds);
|
var id = generateId(embeds);
|
||||||
|
|
||||||
embeds.set(id, container);
|
embeds.set(id, container);
|
||||||
@ -122,6 +123,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
container.appendChild(iframe);
|
container.appendChild(iframe);
|
||||||
|
};
|
||||||
|
document.querySelectorAll('blockquote.mastodon-embed').forEach(renderEmbed);
|
||||||
|
|
||||||
|
// Listen to "mastodon.render" to force rendering of embedded posts
|
||||||
|
document.addEventListener('mastodon.render', function (e) {
|
||||||
|
if (e.target.matches('blockquote.mastodon-embed')) {
|
||||||
|
renderEmbed(e.target);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
})((document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.dataset.allowedPrefixes) ? document.currentScript.dataset.allowedPrefixes.split(' ') : []);
|
})((document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.dataset.allowedPrefixes) ? document.currentScript.dataset.allowedPrefixes.split(' ') : []);
|
||||||
|
Loading…
Reference in New Issue
Block a user