Skip to content

Instantly share code, notes, and snippets.

Shirtless Kirk ShirtlessKirk

View GitHub Profile
@ShirtlessKirk
ShirtlessKirk / object.js
Created Oct 30, 2015
Object methods polyfill (partial)
View object.js
/*global define: false, module: false */
/*jslint forin: true, nomen: true, unparam: true */
(function objectModule(definition) { // non-exporting module magic dance
'use strict';
var
amd = 'amd',
exports = 'exports'; // keeps the method names for CommonJS / AMD from being compiled to single character variable
if (typeof define === 'function' && define[amd]) {
@ShirtlessKirk
ShirtlessKirk / string.js
Created Oct 30, 2015
String.endsWith / String.includes / String.startsWith / String.trim polyfill for IE, Opera, Safari
View string.js
/**
* String.endsWith / String.startsWith polyfills for IE, Opera and Safari
*/
/*global define: false, module: false */
(function stringModule(definition) { // non-exporting module magic dance
'use strict';
var
amd = 'amd',
exports = 'exports'; // keeps the method names for CommonJS / AMD from being compiled to single character variable
@ShirtlessKirk
ShirtlessKirk / settimeout.js
Created Oct 30, 2015
setInterval / setTimeout / setImmediate / requestAnimationFrame polyfill for IE < 10
View settimeout.js
/*jslint regexp: true */
/**
* window.setInterval and window.setTimeout polyfill to allow extra parameters (passed to called function) for IE < 10
*/
(function setTimeoutModule(global, partial, setInterval, setTimeout, slice) {
'use strict';
function dogfooder() {
if (arguments.length) { // no need to polyfill
return;
@ShirtlessKirk
ShirtlessKirk / function.js
Created Oct 30, 2015
Function.bind polyfill for IE8
View function.js
/**
* @preserve Function.bind polyfill for IE8
*/
/*global define: false, module: false */
(function functionModule(definition) { // non-exporting module magic dance
'use strict';
var
amd = 'amd',
exports = 'exports'; // keeps the method names for CommonJS / AMD from being compiled to single character variable
@ShirtlessKirk
ShirtlessKirk / document.js
Created Oct 30, 2015
DOM4 methods polyfill
View document.js
/**
* Polyfill of DOM4 methods
*/
/*global define: false, module: false, console: false */
/*jslint bitwise: true, forin: true */
(function documentModule(global, definition) { // non-exporting module magic dance
'use strict';
var
amd = 'amd',
@ShirtlessKirk
ShirtlessKirk / event.js
Created Oct 30, 2015
Event polyfill for IE < 9 plus DOMContentLoaded, Custom Events (with fix for IE9 - 11)
View event.js
/**
* Polyfill of .addEventListener, .removeEventListener, DOMContentLoaded for IE < 9
* CustomEvent for IE < 9
* Monkey patch custom event for IE9 - 11
*/
/*global define: false, module: false */
/*jslint bitwise: true, forin: true, sloppy: true */
(function eventModule(global, definition) { // non-exporting module magic dance
'use strict';
@ShirtlessKirk
ShirtlessKirk / domtokenlist.js
Last active Dec 10, 2018
DOMTokenList polyfill for IE < 9; implements element.classList
View domtokenlist.js
/**
* Polyfill of DOMTokenList for IE < 9
* Monkey patch of .add, .remove for IE 10 / 11, Firefox < 26 to support multiple arguments
* Monkey patch of .toggle for IE 10 / 11, Firefox < 24 to support second argument
*/
/*global define: false, module: false */
/*jslint nomen: true */
(function domTokenListModule(global, definition) { // non-exporting module magic dance
'use strict';
@ShirtlessKirk
ShirtlessKirk / array.js
Last active Oct 30, 2015
EcmaScript 5 Array methods polyfill for IE < 9
View array.js
/**
* Polyfill of ES5 Array methods for IE < 9
*/
/*global define: false, module: false */
/*jslint bitwise: true, forin: true */
(function arrayModule(definition) { // non-exporting module magic dance
'use strict';
var
amd = 'amd',
@ShirtlessKirk
ShirtlessKirk / dataset.js
Last active Sep 25, 2019
Dataset polyfill for IE < 11
View dataset.js
/*
* @preserve dataset polyfill for IE < 11. See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset and http://caniuse.com/#search=dataset
*
* @author ShirtlessKirk copyright 2015
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
/*global define: false, module: false */
/*jslint nomen: true, regexp: true, unparam: true */
(function datasetModule(global, definition) { // non-exporting module magic dance
'use strict';
@ShirtlessKirk
ShirtlessKirk / FormData.js
Last active Dec 2, 2019
FormData partial polyfill for IE < 10 (<input type="file"> not supported)
View FormData.js
/*
* @preserve FormData polyfill for IE < 10. See https://developer.mozilla.org/en/docs/Web/API/FormData and http://caniuse.com/#search=formdata
*
* @author ShirtlessKirk copyright 2015
* @license WTFPL (http://www.wtfpl.net/txt/copying)
*/
/*global define: false, module: false */
/*jslint bitwise: true, continue: true, nomen: true */
(function formDataModule(global, definition) { // non-exporting module magic dance
'use strict';
You can’t perform that action at this time.