Skip to content

Instantly share code, notes, and snippets.

@oscarmarina
oscarmarina / isFocusable.js
Last active June 25, 2025 02:34
Checks if an element is focusable - treewalker = walkComposedTree(this, NodeFilter.SHOW_ELEMENT, isFocusable);
/**
* Checks if an element should be ignored.
* @param {Element} element - The DOM element to check.
* @param {Array} [exceptions=['dialog', '[popover]']] - Array of Elements to ignore when checking the element.
* @returns {boolean} True if the element should be ignored by a screen reader, false otherwise.
*/
const isElementInvisible = (element, exceptions = ['dialog', '[popover]']) => {
if (!element || !(element instanceof HTMLElement)) {
return false;
}
@tatsuyasusukida
tatsuyasusukida / !README-javascript-media-video.md
Last active June 28, 2025 17:22
🎥 How to record a video with JavaScript [demo video available]

🎥 How to record a video with JavaScript [demo video available]

Demo video: How to record a video with JavaScript

About this article

This article describes how to shoot a video from JavaScript using the MediaStream Recording API. The related resources are shown below.

@austinhyde
austinhyde / js-observables-binding.md
Last active January 7, 2025 08:27
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);