Skip to content

Instantly share code, notes, and snippets.

View jasondmoss's full-sized avatar
😗

Jason D. Moss jasondmoss

😗
View GitHub Profile
/**
* @file
*
* Module: Toggle.
*
* @author Jason D. Moss <jason@jdmlabs.com>
* @copyright 2024 Jason D. Moss. All rights reserved.
*/
import { Exists } from "./exists.js";
@jasondmoss
jasondmoss / accordian.js
Last active March 17, 2024 15:03
Custom Web Component to 'progressively enhance' the <details> element.
/**
* Custom Web Component to 'progressively enhance' the <details> element used
* with our form filters.
*
* @author Jason D. Moss <jason@jdmlabs.com>
* @copyright 2024 Jason D. Moss. All rights reserved.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Web_components
*
* <details>
@jasondmoss
jasondmoss / starts-with.js
Created December 10, 2019 03:52
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `String.prototype.startsWith()`
*
* @return {Boolean}
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
*/
if (!String.prototype.startsWith) {
Object.defineProperty(String.prototype, "startsWith", {
value: function (search, pos) {
@jasondmoss
jasondmoss / replace-with.js
Last active December 10, 2019 03:51
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `ChildNode.replaceWith()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/replaceWith
*/
function replaceWith()
{
"use-strict";
var parent = this.parentNode;
@jasondmoss
jasondmoss / matches.js
Created December 10, 2019 03:48
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `Element.prototype.matches()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
*/
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
}
/* <> */
@jasondmoss
jasondmoss / intersection-observer.js
Created December 10, 2019 03:47
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `IntersectionObserver` + `IntersectionObserverEntry`
*
* @copyright 2016 Google Inc. All Rights Reserved.
* @license https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document [W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE].
* @link https://github.com/w3c/IntersectionObserver/
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver
*/
(function () {
@jasondmoss
jasondmoss / includes.js
Last active December 10, 2019 03:52
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `String.prototype.includes()`
*
* @param {String} String to search for.
* @param {Integer} Start search at 'this' position.
*
* @return {Boolean}
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
*/
@jasondmoss
jasondmoss / foreach.js
Created December 10, 2019 03:44
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polofill for `Array​.prototype​.for​Each()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
*/
if (!Array.prototype.forEach) {
Array.prototype.forEach = function (callback/*, thisArg*/) {
"use strict";
var T, k;
@jasondmoss
jasondmoss / closest.js
Last active December 10, 2019 03:52
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `Element.prototype.closest()`
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
*/
if (!Element.prototype.closest) {
Element.prototype.closest = function (s) {
"use strict";
var el = this;
@jasondmoss
jasondmoss / assign.js
Last active December 10, 2019 03:42
Polyfill Methods for Internet Explorer 11 and below.
/**
* Polyfill for `Object.assign()`
*
* @return {String} Object target.
*
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
*/
if (typeof Object.assign !== "function") {
/**
* Must be writable: true, enumerable: false, configurable: true.