Skip to content

Instantly share code, notes, and snippets.

View villesau's full-sized avatar

Ville Saukkonen villesau

View GitHub Profile
@villesau
villesau / find-elem-with-breakout-width-2.js
Created July 27, 2022 14:20 — forked from joshwcomeau/find-elem-with-breakout-width.js
Paste this in your browser console to search for HTML elements which extend past the window's width and create a horizontal scrollbar.
let widestElement = document.body;
let widestElementDepth = 0;
function checkElemWidth(elem, depth) {
const currentWidest = widestElement.getBoundingClientRect();
const boundingRect = elem.getBoundingClientRect();
const currentRight = currentWidest.right;
const right = boundingRect.right;
if (right >= currentRight && depth > widestElementDepth) {
widestElement = elem;
/*
A collection of tests where Flow and TypeScript might have different behavior
Some tests are borrowed from https://github.com/vkurchatkin/typescript-vs-flow
Some tests now have the same behavior as the new versions of Flow/TS have fixed the bugs and improved type safety
*/
/* 1. Accessing unknown properties on objects */