This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author ebidel@ (Eric Bidelman) | |
* License Apache-2.0 | |
*/ | |
/** | |
* Finds all elements on the page, inclusive of those within shadow roots. | |
* @param {string=} selector Simple selector to filter the elements by. e.g. 'a', 'div.main' | |
* @return {!Array<string>} List of anchor hrefs. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- based on https://twitter.com/ebidel/status/933496242272747520 --> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title><responsive-element></title> | |
<link rel="stylesheet" href="styles.css"> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
if (window['StorageEvent'].name === 'StorageEvent') { | |
return; | |
} | |
var _setItem = window.sessionStorage.setItem; | |
Object.getPrototypeOf(window.sessionStorage).setItem = function(key, value) { | |
_setItem.call(this, key, value); | |
document.dispatchEvent(new CustomEvent('storage', { bubbles: true, composed: true, detail: { key: key, value: value } })); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
const _customElementsDefine = window.customElements.define; | |
window.customElements.define = (name, cl, conf) => { | |
if (customElements.get(name)) { | |
console.warn(name + 'has been defined twice'); | |
} else { | |
_customElementsDefine.call(window.customElements, name, cl, conf); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.localStorage.setItem('expirationDate', new Date((new Date()).getTime() + (15 * 24 * 60 * 60 * 1000)).toString()); | |
window.localStorage.setItem('expirationDate', new Date((new Date()).getTime() - (15 * 24 * 60 * 60 * 1000)).toString()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://www.jsdelivr.com/package/npm/@webcomponents/shadycss |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function supportsMedia(query) { | |
// This works because `media` serializes to 'not all' for unsupported queries | |
return matchMedia(query).media === query; | |
} | |
supportsMedia('(prefers-color-sheme: dark)'); | |
supportsMedia('(prefers-reduced-data: reduce'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable complexity */ | |
const stringsCache = new WeakMap(); | |
/** | |
* https://github.com/Polymer/lit-html/pull/274 | |
* | |
* https://github.com/corpusculejs/corpuscule/blob/master/packages/lit-html-renderer/docs/withCustomElement.md | |
* https://github.com/bashmish/carehtml | |
* | |
* A value that's interpolated directly into the template before parsing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns the deepest active element. | |
* | |
* @param {HTMLElement} element - The element to search. | |
* @returns {!HTMLElement} - Active element | |
*/ | |
export function deepActiveElement(element = document.activeElement) { | |
let elementActive = element; | |
// document.activeElement can be null |
OlderNewer