Skip to content

Instantly share code, notes, and snippets.

Avatar

Sonishi Izuka sounisi5011

View GitHub Profile
@sounisi5011
sounisi5011 / dialog-focus-restore.js
Last active Apr 25, 2018 — forked from samthor/dialog-focus-restore.js
Restore focus after a HTML dialog is shown modally
View dialog-focus-restore.js
/**
* 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 Feb 12, 2018 — forked from jonathantneal/matchesSelector.polyfill.js
Element.matches & Element.closest Polyfill
View matches-closest.polyfill.js
/**
* @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;