Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed js height fix #22141

Merged
merged 6 commits into from Dec 15, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 12 additions & 12 deletions public/embed.js
@@ -1,24 +1,24 @@
// @ts-check

(function() {
(function () {
'use strict';

/**
* @param {() => void} loaded
*/
var ready = function(loaded) {
if (['interactive', 'complete'].indexOf(document.readyState) !== -1) {
loaded();
} else {
document.addEventListener('DOMContentLoaded', loaded);
}
var ready = function (loaded) {
document.onreadystatechange = function () {
if (document.readyState === 'complete') {
loaded();
}
};
hodgesmr marked this conversation as resolved.
Show resolved Hide resolved
};

ready(function() {
ready(function () {
/** @type {Map<number, HTMLIFrameElement>} */
var iframes = new Map();

window.addEventListener('message', function(e) {
window.addEventListener('message', function (e) {
var data = e.data || {};

if (typeof data !== 'object' || data.type !== 'setHeight' || !iframes.has(data.id)) {
Expand All @@ -34,7 +34,7 @@
iframe.height = data.height;
});

[].forEach.call(document.querySelectorAll('iframe.mastodon-embed'), function(iframe) {
[].forEach.call(document.querySelectorAll('iframe.mastodon-embed'), function (iframe) {
// select unique id for each iframe
var id = 0, failCount = 0, idBuffer = new Uint32Array(1);
while (id === 0 || iframes.has(id)) {
Expand All @@ -49,10 +49,10 @@

iframes.set(id, iframe);

iframe.scrolling = 'no';
iframe.scrolling = 'no';
iframe.style.overflow = 'hidden';

iframe.onload = function() {
iframe.onload = function () {
iframe.contentWindow.postMessage({
type: 'setHeight',
id: id,
Expand Down