Skip to content

Instantly share code, notes, and snippets.

@sounisi5011
sounisi5011 / dialog-focus-restore.js
Last active April 25, 2018 20:42 — forked from samthor/dialog-focus-restore.js
Restore focus after a HTML dialog is shown modally
/**
* Updates the passed dialog to retain focus and restore it when the dialog is closed. Won't
* upgrade a dialog more than once. Supports IE11+ and is a no-op otherwise.
* @param {!HTMLDialogElement} dialog to upgrade
*/
window.registerFocusRestoreDialog = (function() {
var WeakMap = window.WeakMap;
var registered =
typeof WeakMap === 'function'
? new WeakMap()
@sounisi5011
sounisi5011 / matches-closest.polyfill.js
Last active February 12, 2018 16:02 — forked from jonathantneal/matchesSelector.polyfill.js
Element.matches & Element.closest Polyfill
/**
* @see https://dom.spec.whatwg.org/#interface-element
* @see https://developer.mozilla.org/docs/Web/API/Element/matches#Polyfill
* @see https://gist.github.com/jonathantneal/3062955
* @see https://github.com/jonathantneal/closest
*/
(function(global){
var Element;
var ElementPrototype;