From 4114a7088a7161a8aebf27d20433c0f47a4f178c Mon Sep 17 00:00:00 2001 From: Matt Hodges Date: Thu, 15 Dec 2022 09:18:59 -0600 Subject: Embed js height fix (#22141) * only begin iframe reheight once document state is complete * format * lint fixes * Update public/embed.js to use readystatechange event listener Co-authored-by: Claire * Call loaded() if ready, otherwise add listenter * lint fix Co-authored-by: Claire --- public/embed.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'public') diff --git a/public/embed.js b/public/embed.js index 5607c24d5..defba403e 100644 --- a/public/embed.js +++ b/public/embed.js @@ -1,24 +1,28 @@ // @ts-check -(function() { +(function () { 'use strict'; /** * @param {() => void} loaded */ - var ready = function(loaded) { - if (['interactive', 'complete'].indexOf(document.readyState) !== -1) { + var ready = function (loaded) { + if (document.readyState === 'complete') { loaded(); } else { - document.addEventListener('DOMContentLoaded', loaded); + document.addEventListener('readystatechange', function () { + if (document.readyState === 'complete') { + loaded(); + } + }); } }; - ready(function() { + ready(function () { /** @type {Map} */ 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)) { @@ -34,7 +38,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)) { @@ -49,10 +53,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, -- cgit From 558ac411c469a19e9b32f78d4e4f7f29d46afa5f Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Thu, 5 Jan 2023 07:42:13 -0500 Subject: Expand Stylelint glob to include CSS files (#22469) --- lib/assets/wordmark.dark.css | 2 +- package.json | 2 +- public/inert.css | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'public') diff --git a/lib/assets/wordmark.dark.css b/lib/assets/wordmark.dark.css index d87069178..db3355f59 100644 --- a/lib/assets/wordmark.dark.css +++ b/lib/assets/wordmark.dark.css @@ -1 +1 @@ -// Not needed +/* Not needed */ diff --git a/package.json b/package.json index 19e9018e8..291bd416c 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "test": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:jest", "test:lint": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:lint:sass", "test:lint:js": "eslint --ext=js . --cache", - "test:lint:sass": "stylelint '**/*.scss'", + "test:lint:sass": "stylelint \"**/*.{css,scss}\"", "test:jest": "cross-env NODE_ENV=test jest", "format": "prettier --write \"**/*.{json,yml}\"", "format-check": "prettier --check \"**/*.{json,yml}\"" diff --git a/public/inert.css b/public/inert.css index 275fad2e6..54e10616d 100644 --- a/public/inert.css +++ b/public/inert.css @@ -3,7 +3,8 @@ cursor: default; } -[inert], [inert] * { +[inert], +[inert] * { user-select: none; -webkit-user-select: none; -moz-user-select: none; -- cgit