Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Polyfill service DEVELOPMENT MODE - for live use set NODE_ENV to 'production'
- * For detailed credits and licence information see http://github.com/financial-times/polyfill-service.
- *
- * UA detected: ie/8.0.0
- * Features requested: HTMLPictureElement,default
- *
- * - ~html5-elements, License: MIT (required by "HTMLPictureElement", "default")
- * - HTMLPictureElement, License: MIT
- * - Object.defineProperty, License: CC0 (required by "Array.from", "Array.isArray", "Array.of", "Array.prototype.fill", "CustomEvent", "Element.prototype.classList", "Event", "Event.DOMContentLoaded", "Function.prototype.bind", "Map", "Object.create", "Object.defineProperties", "Object.getOwnPropertyDescriptor", "Promise", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "URL", "XMLHttpRequest", "default", "location.origin")
- * - Array.from, License: CC0 (required by "default")
- * - Array.isArray, License: CC0 (required by "Promise", "default")
- * - Array.of, License: CC0 (required by "default")
- * - Array.prototype.every, License: CC0 (required by "default")
- * - Array.prototype.fill, License: CC0 (required by "default")
- * - Array.prototype.filter, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
- * - Array.prototype.forEach, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "URL", "default")
- * - Array.prototype.indexOf, License: CC0 (required by "Map", "Set", "default")
- * - Array.prototype.lastIndexOf, License: CC0 (required by "default")
- * - Array.prototype.map, License: CC0 (required by "default")
- * - Array.prototype.reduce, License: CC0 (required by "default")
- * - Array.prototype.reduceRight, License: CC0 (required by "default")
- * - Array.prototype.some, License: CC0 (required by "default")
- * - Document, License: CC0 (required by "CustomEvent", "Element", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.closest", "Element.prototype.matches", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Event", "Event.DOMContentLoaded", "Node.prototype.contains", "XMLHttpRequest", "_mutation", "default", "document.querySelector")
- * - Element, License: CC0 (required by "CustomEvent", "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.classList", "Element.prototype.cloneNode", "Element.prototype.closest", "Element.prototype.matches", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "Event", "Event.DOMContentLoaded", "Node.prototype.contains", "XMLHttpRequest", "_mutation", "default", "document.querySelector")
- * - Event, License: CC0 (required by "CustomEvent", "Event.DOMContentLoaded", "XMLHttpRequest", "default")
- * - CustomEvent, License: CC0 (required by "default")
- * - _DOMTokenList, License: CC0 (required by "DOMTokenList", "Element.prototype.classList", "default")
- * - DOMTokenList, License: CC0 (required by "default")
- * - Date.now, License: CC0 (required by "default", "performance.now", "requestAnimationFrame")
- * - Date.prototype.toISOString, License: CC0 (required by "default")
- * - _mutation, License: CC0 (required by "Element.prototype.after", "Element.prototype.append", "Element.prototype.before", "Element.prototype.prepend", "Element.prototype.remove", "Element.prototype.replaceWith", "default")
- * - Element.prototype.after, License: CC0 (required by "default")
- * - Element.prototype.append, License: CC0 (required by "default")
- * - Element.prototype.before, License: CC0 (required by "default")
- * - Element.prototype.classList, License: CC0 (required by "default")
- * - Element.prototype.cloneNode, License: CC0 (required by "default")
- * - document.querySelector, License: CC0 (required by "Element.prototype.closest", "Element.prototype.matches", "default")
- * - Element.prototype.matches, License: CC0 (required by "Element.prototype.closest", "default")
- * - Element.prototype.closest, License: CC0 (required by "default")
- * - Element.prototype.prepend, License: CC0 (required by "default")
- * - Element.prototype.remove, License: CC0 (required by "default")
- * - Element.prototype.replaceWith, License: CC0 (required by "default")
- * - Event.DOMContentLoaded, License: CC0 (required by "default")
- * - Function.prototype.bind, License: MIT (required by "Map", "Object.getOwnPropertyDescriptor", "Set", "Symbol", "default")
- * - Object.defineProperties, License: CC0 (required by "Map", "Object.create", "Set", "Symbol", "URL", "default", "location.origin")
- * - Object.create, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
- * - Object.getOwnPropertyNames, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
- * - Object.getOwnPropertyDescriptor, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
- * - Object.keys, License: CC0 (required by "Map", "Set", "Symbol", "Symbol.iterator", "Symbol.species", "default")
- * - Symbol, License: MIT (required by "Map", "Set", "Symbol.iterator", "Symbol.species", "default")
- * - Symbol.iterator, License: MIT (required by "Map", "Set", "default")
- * - Symbol.species, License: MIT (required by "Map", "Set", "default")
- * - Number.isNaN, License: MIT (required by "Map", "Set", "default")
- * - Map, License: CC0 (required by "default")
- * - Node.prototype.contains, License: CC0 (required by "default")
- * - Object.assign, License: CC0 (required by "default")
- * - Object.getPrototypeOf, License: CC0 (required by "default")
- * - setImmediate, License: CC0 (required by "Promise", "default")
- * - Promise, License: MIT (required by "default")
- * - Set, License: CC0 (required by "default")
- * - String.prototype.endsWith, License: CC0 (required by "default")
- * - String.prototype.includes, License: CC0 (required by "default")
- * - String.prototype.startsWith, License: CC0 (required by "default")
- * - String.prototype.trim, License: CC0 (required by "default")
- * - URL, License: CC0 (required by "default")
- * - XMLHttpRequest, License: CC0 (required by "default")
- * - atob, License: MIT (required by "default")
- * - location.origin, License: CC0 (required by "default")
- * - performance.now, License: CC0 (required by "default", "requestAnimationFrame")
- * - requestAnimationFrame, License: MIT (required by "default") */
- (function(undefined) {
- if (!(// Primitive detect for HTML5 element support - add a <section> element and check that it acquires block display mode by default
- (function() {
- var p = document.createElement('p');
- var result = false;
- p.innerHTML = '<section></section>';
- document.documentElement.appendChild(p);
- if (p.firstChild) {
- if ('getComputedStyle' in window) {
- result = (getComputedStyle(p.firstChild).display === 'block');
- } else if (p.firstChild.currentStyle) {
- result = (p.firstChild.currentStyle.display === 'block');
- }
- }
- document.documentElement.removeChild(p);
- return result;
- })())) {
- // ~html5-elements
- /**
- * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
- */
- ;(function(window, document) {
- /*jshint evil:true */
- /** version */
- var version = '3.7.3';
- /** Preset options */
- var options = window.html5 || {};
- /** Used to skip problem elements */
- var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
- /** Not all elements can be cloned in IE **/
- var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i;
- /** Detect whether the browser supports default html5 styles */
- var supportsHtml5Styles;
- /** Name of the expando, to work with multiple documents or to re-shiv one document */
- var expando = '_html5shiv';
- /** The id for the the documents expando */
- var expanID = 0;
- /** Cached data for each document */
- var expandoData = {};
- /** Detect whether the browser supports unknown elements */
- var supportsUnknownElements;
- (function() {
- try {
- var a = document.createElement('a');
- a.innerHTML = '<xyz></xyz>';
- //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
- supportsHtml5Styles = ('hidden' in a);
- supportsUnknownElements = a.childNodes.length == 1 || (function() {
- // assign a false positive if unable to shiv
- (document.createElement)('a');
- var frag = document.createDocumentFragment();
- return (
- typeof frag.cloneNode == 'undefined' ||
- typeof frag.createDocumentFragment == 'undefined' ||
- typeof frag.createElement == 'undefined'
- );
- }());
- } catch(e) {
- // assign a false positive if detection fails => unable to shiv
- supportsHtml5Styles = true;
- supportsUnknownElements = true;
- }
- }());
- /*--------------------------------------------------------------------------*/
- /**
- * Creates a style sheet with the given CSS text and adds it to the document.
- * @private
- * @param {Document} ownerDocument The document.
- * @param {String} cssText The CSS text.
- * @returns {StyleSheet} The style element.
- */
- function addStyleSheet(ownerDocument, cssText) {
- var p = ownerDocument.createElement('p'),
- parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
- p.innerHTML = 'x<style>' + cssText + '</style>';
- return parent.insertBefore(p.lastChild, parent.firstChild);
- }
- /**
- * Returns the value of `html5.elements` as an array.
- * @private
- * @returns {Array} An array of shived element node names.
- */
- function getElements() {
- var elements = html5.elements;
- return typeof elements == 'string' ? elements.split(' ') : elements;
- }
- /**
- * Extends the built-in list of html5 elements
- * @memberOf html5
- * @param {String|Array} newElements whitespace separated list or array of new element names to shiv
- * @param {Document} ownerDocument The context document.
- */
- function addElements(newElements, ownerDocument) {
- var elements = html5.elements;
- if(typeof elements != 'string'){
- elements = elements.join(' ');
- }
- if(typeof newElements != 'string'){
- newElements = newElements.join(' ');
- }
- html5.elements = elements +' '+ newElements;
- shivDocument(ownerDocument);
- }
- /**
- * Returns the data associated to the given document
- * @private
- * @param {Document} ownerDocument The document.
- * @returns {Object} An object of data.
- */
- function getExpandoData(ownerDocument) {
- var data = expandoData[ownerDocument[expando]];
- if (!data) {
- data = {};
- expanID++;
- ownerDocument[expando] = expanID;
- expandoData[expanID] = data;
- }
- return data;
- }
- /**
- * returns a shived element for the given nodeName and document
- * @memberOf html5
- * @param {String} nodeName name of the element
- * @param {Document|DocumentFragment} ownerDocument The context document.
- * @returns {Object} The shived element.
- */
- function createElement(nodeName, ownerDocument, data){
- if (!ownerDocument) {
- ownerDocument = document;
- }
- if(supportsUnknownElements){
- return ownerDocument.createElement(nodeName);
- }
- if (!data) {
- data = getExpandoData(ownerDocument);
- }
- var node;
- if (data.cache[nodeName]) {
- node = data.cache[nodeName].cloneNode();
- } else if (saveClones.test(nodeName)) {
- node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
- } else {
- node = data.createElem(nodeName);
- }
- // Avoid adding some elements to fragments in IE < 9 because
- // * Attributes like `name` or `type` cannot be set/changed once an element
- // is inserted into a document/fragment
- // * Link elements with `src` attributes that are inaccessible, as with
- // a 403 response, will cause the tab/window to crash
- // * Script elements appended to fragments will execute when their `src`
- // or `text` property is set
- return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
- }
- /**
- * returns a shived DocumentFragment for the given document
- * @memberOf html5
- * @param {Document} ownerDocument The context document.
- * @returns {Object} The shived DocumentFragment.
- */
- function createDocumentFragment(ownerDocument, data){
- if (!ownerDocument) {
- ownerDocument = document;
- }
- if(supportsUnknownElements){
- return ownerDocument.createDocumentFragment();
- }
- data = data || getExpandoData(ownerDocument);
- var clone = data.frag.cloneNode(),
- i = 0,
- elems = getElements(),
- l = elems.length;
- for(;i<l;i++){
- clone.createElement(elems[i]);
- }
- return clone;
- }
- /**
- * Shivs the `createElement` and `createDocumentFragment` methods of the document.
- * @private
- * @param {Document|DocumentFragment} ownerDocument The document.
- * @param {Object} data of the document.
- */
- function shivMethods(ownerDocument, data) {
- if (!data.cache) {
- data.cache = {};
- data.createElem = ownerDocument.createElement;
- data.createFrag = ownerDocument.createDocumentFragment;
- data.frag = data.createFrag();
- }
- ownerDocument.createElement = function(nodeName) {
- //abort shiv
- if (!html5.shivMethods) {
- return data.createElem(nodeName);
- }
- return createElement(nodeName, ownerDocument, data);
- };
- ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
- 'var n=f.cloneNode(),c=n.createElement;' +
- 'h.shivMethods&&(' +
- // unroll the `createElement` calls
- getElements().join().replace(/[\w\-:]+/g, function(nodeName) {
- data.createElem(nodeName);
- data.frag.createElement(nodeName);
- return 'c("' + nodeName + '")';
- }) +
- ');return n}'
- )(html5, data.frag);
- }
- /*--------------------------------------------------------------------------*/
- /**
- * Shivs the given document.
- * @memberOf html5
- * @param {Document} ownerDocument The document to shiv.
- * @returns {Document} The shived document.
- */
- function shivDocument(ownerDocument) {
- if (!ownerDocument) {
- ownerDocument = document;
- }
- var data = getExpandoData(ownerDocument);
- if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
- data.hasCSS = !!addStyleSheet(ownerDocument,
- // corrects block display not defined in IE6/7/8/9
- 'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' +
- // adds styling not present in IE6/7/8/9
- 'mark{background:#FF0;color:#000}' +
- // hides non-rendered elements
- 'template{display:none}'
- );
- }
- if (!supportsUnknownElements) {
- shivMethods(ownerDocument, data);
- }
- return ownerDocument;
- }
- /*--------------------------------------------------------------------------*/
- /**
- * The `html5` object is exposed so that more elements can be shived and
- * existing shiving can be detected on iframes.
- * @type Object
- * @example
- *
- * // options can be changed before the script is included
- * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
- */
- var html5 = {
- /**
- * An array or space separated string of node names of the elements to shiv.
- * @memberOf html5
- * @type Array|String
- */
- 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video',
- /**
- * current version of html5shiv
- */
- 'version': version,
- /**
- * A flag to indicate that the HTML5 style sheet should be inserted.
- * @memberOf html5
- * @type Boolean
- */
- 'shivCSS': (options.shivCSS !== false),
- /**
- * Is equal to true if a browser supports creating unknown/HTML5 elements
- * @memberOf html5
- * @type boolean
- */
- 'supportsUnknownElements': supportsUnknownElements,
- /**
- * A flag to indicate that the document's `createElement` and `createDocumentFragment`
- * methods should be overwritten.
- * @memberOf html5
- * @type Boolean
- */
- 'shivMethods': (options.shivMethods !== false),
- /**
- * A string to describe the type of `html5` object ("default" or "default print").
- * @memberOf html5
- * @type String
- */
- 'type': 'default',
- // shivs the document according to the specified `html5` object options
- 'shivDocument': shivDocument,
- //creates a shived element
- createElement: createElement,
- //creates a shived documentFragment
- createDocumentFragment: createDocumentFragment,
- //extends list of elements
- addElements: addElements
- };
- /*--------------------------------------------------------------------------*/
- // expose html5
- window.html5 = html5;
- // shiv the document
- shivDocument(document);
- if(typeof module == 'object' && module.exports){
- module.exports = html5;
- }
- }(typeof window !== "undefined" ? window : this, document));
- }
- if (!(/* Picturefill does not set the HTMLPictureElement global, and the srcset property of <source> does not appear to be accessible to JS in IE8, so in IE8 the only way to detect that the polyfill has applied is to use a non-standard global exposed by the polyfill */
- 'HTMLPictureElement' in this || 'picturefill' in this)) {
- // HTMLPictureElement
- /*! picturefill - v3.0.2 - 2016-02-12
- * https://scottjehl.github.io/picturefill/
- * Copyright (c) 2016 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT
- */
- !function(a){var b=navigator.userAgent;a.HTMLPictureElement&&/ecko/.test(b)&&b.match(/rv\:(\d+)/)&&RegExp.$1<45&&addEventListener("resize",function(){var b,c=document.createElement("source"),d=function(a){var b,d,e=a.parentNode;"PICTURE"===e.nodeName.toUpperCase()?(b=c.cloneNode(),e.insertBefore(b,e.firstElementChild),setTimeout(function(){e.removeChild(b)})):(!a._pfLastSize||a.offsetWidth>a._pfLastSize)&&(a._pfLastSize=a.offsetWidth,d=a.sizes,a.sizes+=",100vw",setTimeout(function(){a.sizes=d}))},e=function(){var a,b=document.querySelectorAll("picture > img, img[srcset][sizes]");for(a=0;a<b.length;a++)d(b[a])},f=function(){clearTimeout(b),b=setTimeout(e,99)},g=a.matchMedia&&matchMedia("(orientation: landscape)"),h=function(){f(),g&&g.addListener&&g.addListener(f)};return c.srcset="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",/^[c|i]|d$/.test(document.readyState||"")?h():document.addEventListener("DOMContentLoaded",h),f}())}(window),function(a,b,c){"use strict";function d(a){return" "===a||" "===a||"\n"===a||"\f"===a||"\r"===a}function e(b,c){var d=new a.Image;return d.onerror=function(){A[b]=!1,ba()},d.onload=function(){A[b]=1===d.width,ba()},d.src=c,"pending"}function f(){M=!1,P=a.devicePixelRatio,N={},O={},s.DPR=P||1,Q.width=Math.max(a.innerWidth||0,z.clientWidth),Q.height=Math.max(a.innerHeight||0,z.clientHeight),Q.vw=Q.width/100,Q.vh=Q.height/100,r=[Q.height,Q.width,P].join("-"),Q.em=s.getEmValue(),Q.rem=Q.em}function g(a,b,c,d){var e,f,g,h;return"saveData"===B.algorithm?a>2.7?h=c+1:(f=b-c,e=Math.pow(a-.6,1.5),g=f*e,d&&(g+=.1*e),h=a+g):h=c>1?Math.sqrt(a*b):a,h>c}function h(a){var b,c=s.getSet(a),d=!1;"pending"!==c&&(d=r,c&&(b=s.setRes(c),s.applySetCandidate(b,a))),a[s.ns].evaled=d}function i(a,b){return a.res-b.res}function j(a,b,c){var d;return!c&&b&&(c=a[s.ns].sets,c=c&&c[c.length-1]),d=k(b,c),d&&(b=s.makeUrl(b),a[s.ns].curSrc=b,a[s.ns].curCan=d,d.res||aa(d,d.set.sizes)),d}function k(a,b){var c,d,e;if(a&&b)for(e=s.parseSet(b),a=s.makeUrl(a),c=0;c<e.length;c++)if(a===s.makeUrl(e[c].url)){d=e[c];break}return d}function l(a,b){var c,d,e,f,g=a.getElementsByTagName("source");for(c=0,d=g.length;d>c;c++)e=g[c],e[s.ns]=!0,f=e.getAttribute("srcset"),f&&b.push({srcset:f,media:e.getAttribute("media"),type:e.getAttribute("type"),sizes:e.getAttribute("sizes")})}function m(a,b){function c(b){var c,d=b.exec(a.substring(m));return d?(c=d[0],m+=c.length,c):void 0}function e(){var a,c,d,e,f,i,j,k,l,m=!1,o={};for(e=0;e<h.length;e++)f=h[e],i=f[f.length-1],j=f.substring(0,f.length-1),k=parseInt(j,10),l=parseFloat(j),X.test(j)&&"w"===i?((a||c)&&(m=!0),0===k?m=!0:a=k):Y.test(j)&&"x"===i?((a||c||d)&&(m=!0),0>l?m=!0:c=l):X.test(j)&&"h"===i?((d||c)&&(m=!0),0===k?m=!0:d=k):m=!0;m||(o.url=g,a&&(o.w=a),c&&(o.d=c),d&&(o.h=d),d||c||a||(o.d=1),1===o.d&&(b.has1x=!0),o.set=b,n.push(o))}function f(){for(c(T),i="",j="in descriptor";;){if(k=a.charAt(m),"in descriptor"===j)if(d(k))i&&(h.push(i),i="",j="after descriptor");else{if(","===k)return m+=1,i&&h.push(i),void e();if("("===k)i+=k,j="in parens";else{if(""===k)return i&&h.push(i),void e();i+=k}}else if("in parens"===j)if(")"===k)i+=k,j="in descriptor";else{if(""===k)return h.push(i),void e();i+=k}else if("after descriptor"===j)if(d(k));else{if(""===k)return void e();j="in descriptor",m-=1}m+=1}}for(var g,h,i,j,k,l=a.length,m=0,n=[];;){if(c(U),m>=l)return n;g=c(V),h=[],","===g.slice(-1)?(g=g.replace(W,""),e()):f()}}function n(a){function b(a){function b(){f&&(g.push(f),f="")}function c(){g[0]&&(h.push(g),g=[])}for(var e,f="",g=[],h=[],i=0,j=0,k=!1;;){if(e=a.charAt(j),""===e)return b(),c(),h;if(k){if("*"===e&&"/"===a[j+1]){k=!1,j+=2,b();continue}j+=1}else{if(d(e)){if(a.charAt(j-1)&&d(a.charAt(j-1))||!f){j+=1;continue}if(0===i){b(),j+=1;continue}e=" "}else if("("===e)i+=1;else if(")"===e)i-=1;else{if(","===e){b(),c(),j+=1;continue}if("/"===e&&"*"===a.charAt(j+1)){k=!0,j+=2;continue}}f+=e,j+=1}}}function c(a){return k.test(a)&&parseFloat(a)>=0?!0:l.test(a)?!0:"0"===a||"-0"===a||"+0"===a?!0:!1}var e,f,g,h,i,j,k=/^(?:[+-]?[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?(?:ch|cm|em|ex|in|mm|pc|pt|px|rem|vh|vmin|vmax|vw)$/i,l=/^calc\((?:[0-9a-z \.\+\-\*\/\(\)]+)\)$/i;for(f=b(a),g=f.length,e=0;g>e;e++)if(h=f[e],i=h[h.length-1],c(i)){if(j=i,h.pop(),0===h.length)return j;if(h=h.join(" "),s.matchesMedia(h))return j}return"100vw"}b.createElement("picture");var o,p,q,r,s={},t=!1,u=function(){},v=b.createElement("img"),w=v.getAttribute,x=v.setAttribute,y=v.removeAttribute,z=b.documentElement,A={},B={algorithm:""},C="data-pfsrc",D=C+"set",E=navigator.userAgent,F=/rident/.test(E)||/ecko/.test(E)&&E.match(/rv\:(\d+)/)&&RegExp.$1>35,G="currentSrc",H=/\s+\+?\d+(e\d+)?w/,I=/(\([^)]+\))?\s*(.+)/,J=a.picturefillCFG,K="position:absolute;left:0;visibility:hidden;display:block;padding:0;border:none;font-size:1em;width:1em;overflow:hidden;clip:rect(0px, 0px, 0px, 0px)",L="font-size:100%!important;",M=!0,N={},O={},P=a.devicePixelRatio,Q={px:1,"in":96},R=b.createElement("a"),S=!1,T=/^[ \t\n\r\u000c]+/,U=/^[, \t\n\r\u000c]+/,V=/^[^ \t\n\r\u000c]+/,W=/[,]+$/,X=/^\d+$/,Y=/^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,Z=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d||!1):a.attachEvent&&a.attachEvent("on"+b,c)},$=function(a){var b={};return function(c){return c in b||(b[c]=a(c)),b[c]}},_=function(){var a=/^([\d\.]+)(em|vw|px)$/,b=function(){for(var a=arguments,b=0,c=a[0];++b in a;)c=c.replace(a[b],a[++b]);return c},c=$(function(a){return"return "+b((a||"").toLowerCase(),/\band\b/g,"&&",/,/g,"||",/min-([a-z-\s]+):/g,"e.$1>=",/max-([a-z-\s]+):/g,"e.$1<=",/calc([^)]+)/g,"($1)",/(\d+[\.]*[\d]*)([a-z]+)/g,"($1 * e.$2)",/^(?!(e.[a-z]|[0-9\.&=|><\+\-\*\(\)\/])).*/gi,"")+";"});return function(b,d){var e;if(!(b in N))if(N[b]=!1,d&&(e=b.match(a)))N[b]=e[1]*Q[e[2]];else try{N[b]=new Function("e",c(b))(Q)}catch(f){}return N[b]}}(),aa=function(a,b){return a.w?(a.cWidth=s.calcListLength(b||"100vw"),a.res=a.w/a.cWidth):a.res=a.d,a},ba=function(a){if(t){var c,d,e,f=a||{};if(f.elements&&1===f.elements.nodeType&&("IMG"===f.elements.nodeName.toUpperCase()?f.elements=[f.elements]:(f.context=f.elements,f.elements=null)),c=f.elements||s.qsa(f.context||b,f.reevaluate||f.reselect?s.sel:s.selShort),e=c.length){for(s.setupRun(f),S=!0,d=0;e>d;d++)s.fillImg(c[d],f);s.teardownRun(f)}}};o=a.console&&console.warn?function(a){console.warn(a)}:u,G in v||(G="src"),A["image/jpeg"]=!0,A["image/gif"]=!0,A["image/png"]=!0,A["image/svg+xml"]=b.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image","1.1"),s.ns=("pf"+(new Date).getTime()).substr(0,9),s.supSrcset="srcset"in v,s.supSizes="sizes"in v,s.supPicture=!!a.HTMLPictureElement,s.supSrcset&&s.supPicture&&!s.supSizes&&!function(a){v.srcset="data:,a",a.src="data:,a",s.supSrcset=v.complete===a.complete,s.supPicture=s.supSrcset&&s.supPicture}(b.createElement("img")),s.supSrcset&&!s.supSizes?!function(){var a="data:image/gif;base64,R0lGODlhAgABAPAAAP///wAAACH5BAAAAAAALAAAAAACAAEAAAICBAoAOw==",c="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",d=b.createElement("img"),e=function(){var a=d.width;2===a&&(s.supSizes=!0),q=s.supSrcset&&!s.supSizes,t=!0,setTimeout(ba)};d.onload=e,d.onerror=e,d.setAttribute("sizes","9px"),d.srcset=c+" 1w,"+a+" 9w",d.src=c}():t=!0,s.selShort="picture>img,img[srcset]",s.sel=s.selShort,s.cfg=B,s.DPR=P||1,s.u=Q,s.types=A,s.setSize=u,s.makeUrl=$(function(a){return R.href=a,R.href}),s.qsa=function(a,b){return"querySelector"in a?a.querySelectorAll(b):[]},s.matchesMedia=function(){return a.matchMedia&&(matchMedia("(min-width: 0.1em)")||{}).matches?s.matchesMedia=function(a){return!a||matchMedia(a).matches}:s.matchesMedia=s.mMQ,s.matchesMedia.apply(this,arguments)},s.mMQ=function(a){return a?_(a):!0},s.calcLength=function(a){var b=_(a,!0)||!1;return 0>b&&(b=!1),b},s.supportsType=function(a){return a?A[a]:!0},s.parseSize=$(function(a){var b=(a||"").match(I);return{media:b&&b[1],length:b&&b[2]}}),s.parseSet=function(a){return a.cands||(a.cands=m(a.srcset,a)),a.cands},s.getEmValue=function(){var a;if(!p&&(a=b.body)){var c=b.createElement("div"),d=z.style.cssText,e=a.style.cssText;c.style.cssText=K,z.style.cssText=L,a.style.cssText=L,a.appendChild(c),p=c.offsetWidth,a.removeChild(c),p=parseFloat(p,10),z.style.cssText=d,a.style.cssText=e}return p||16},s.calcListLength=function(a){if(!(a in O)||B.uT){var b=s.calcLength(n(a));O[a]=b?b:Q.width}return O[a]},s.setRes=function(a){var b;if(a){b=s.parseSet(a);for(var c=0,d=b.length;d>c;c++)aa(b[c],a.sizes)}return b},s.setRes.res=aa,s.applySetCandidate=function(a,b){if(a.length){var c,d,e,f,h,k,l,m,n,o=b[s.ns],p=s.DPR;if(k=o.curSrc||b[G],l=o.curCan||j(b,k,a[0].set),l&&l.set===a[0].set&&(n=F&&!b.complete&&l.res-.1>p,n||(l.cached=!0,l.res>=p&&(h=l))),!h)for(a.sort(i),f=a.length,h=a[f-1],d=0;f>d;d++)if(c=a[d],c.res>=p){e=d-1,h=a[e]&&(n||k!==s.makeUrl(c.url))&&g(a[e].res,c.res,p,a[e].cached)?a[e]:c;break}h&&(m=s.makeUrl(h.url),o.curSrc=m,o.curCan=h,m!==k&&s.setSrc(b,h),s.setSize(b))}},s.setSrc=function(a,b){var c;a.src=b.url,"image/svg+xml"===b.set.type&&(c=a.style.width,a.style.width=a.offsetWidth+1+"px",a.offsetWidth+1&&(a.style.width=c))},s.getSet=function(a){var b,c,d,e=!1,f=a[s.ns].sets;for(b=0;b<f.length&&!e;b++)if(c=f[b],c.srcset&&s.matchesMedia(c.media)&&(d=s.supportsType(c.type))){"pending"===d&&(c=d),e=c;break}return e},s.parseSets=function(a,b,d){var e,f,g,h,i=b&&"PICTURE"===b.nodeName.toUpperCase(),j=a[s.ns];(j.src===c||d.src)&&(j.src=w.call(a,"src"),j.src?x.call(a,C,j.src):y.call(a,C)),(j.srcset===c||d.srcset||!s.supSrcset||a.srcset)&&(e=w.call(a,"srcset"),j.srcset=e,h=!0),j.sets=[],i&&(j.pic=!0,l(b,j.sets)),j.srcset?(f={srcset:j.srcset,sizes:w.call(a,"sizes")},j.sets.push(f),g=(q||j.src)&&H.test(j.srcset||""),g||!j.src||k(j.src,f)||f.has1x||(f.srcset+=", "+j.src,f.cands.push({url:j.src,d:1,set:f}))):j.src&&j.sets.push({srcset:j.src,sizes:null}),j.curCan=null,j.curSrc=c,j.supported=!(i||f&&!s.supSrcset||g&&!s.supSizes),h&&s.supSrcset&&!j.supported&&(e?(x.call(a,D,e),a.srcset=""):y.call(a,D)),j.supported&&!j.srcset&&(!j.src&&a.src||a.src!==s.makeUrl(j.src))&&(null===j.src?a.removeAttribute("src"):a.src=j.src),j.parsed=!0},s.fillImg=function(a,b){var c,d=b.reselect||b.reevaluate;a[s.ns]||(a[s.ns]={}),c=a[s.ns],(d||c.evaled!==r)&&((!c.parsed||b.reevaluate)&&s.parseSets(a,a.parentNode,b),c.supported?c.evaled=r:h(a))},s.setupRun=function(){(!S||M||P!==a.devicePixelRatio)&&f()},s.supPicture?(ba=u,s.fillImg=u):!function(){var c,d=a.attachEvent?/d$|^c/:/d$|^c|^i/,e=function(){var a=b.readyState||"";f=setTimeout(e,"loading"===a?200:999),b.body&&(s.fillImgs(),c=c||d.test(a),c&&clearTimeout(f))},f=setTimeout(e,b.body?9:99),g=function(a,b){var c,d,e=function(){var f=new Date-d;b>f?c=setTimeout(e,b-f):(c=null,a())};return function(){d=new Date,c||(c=setTimeout(e,b))}},h=z.clientHeight,i=function(){M=Math.max(a.innerWidth||0,z.clientWidth)!==Q.width||z.clientHeight!==h,h=z.clientHeight,M&&s.fillImgs()};Z(a,"resize",g(i,99)),Z(b,"readystatechange",e)}(),s.picturefill=ba,s.fillImgs=ba,s.teardownRun=u,ba._=s,a.picturefillCFG={pf:s,push:function(a){var b=a.shift();"function"==typeof s[b]?s[b].apply(s,a):(B[b]=a[0],S&&s.fillImgs({reselect:!0}))}};for(;J&&J.length;)a.picturefillCFG.push(J.shift());a.picturefill=ba,"object"==typeof module&&"object"==typeof module.exports?module.exports=ba:"function"==typeof define&&define.amd&&define("picturefill",function(){return ba}),s.supPicture||(A["image/webp"]=e("image/webp","data:image/webp;base64,UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAABBxAR/Q9ERP8DAABWUDggGAAAADABAJ0BKgEAAQADADQlpAADcAD++/1QAA=="))}(window,document);/*! picturefill - v3.0.2 - 2016-02-12
- * https://scottjehl.github.io/picturefill/
- * Copyright (c) 2016 https://github.com/scottjehl/picturefill/blob/master/Authors.txt; Licensed MIT
- */
- !function(a){"use strict";var b,c=0,d=function(){window.picturefill&&a(window.picturefill),(window.picturefill||c>9999)&&clearInterval(b),c++};b=setInterval(d,8),d()}(function(a){"use strict";var b=window.document,c=window.Element,d=window.MutationObserver,e=function(){},f={disconnect:e,take:e,observe:e,start:e,stop:e,connected:!1},g=/^loade|^c|^i/.test(b.readyState||""),h=a._;if(h.mutationSupport=!1,h.observer=f,Object.keys&&window.HTMLSourceElement&&b.addEventListener){var i,j,k,l,m={src:1,srcset:1,sizes:1,media:1},n=Object.keys(m),o={attributes:!0,childList:!0,subtree:!0,attributeFilter:n},p=c&&c.prototype,q={},r=function(a,b){q[a]=h[a],h[a]=b};p&&!p.matches&&(p.matches=p.matchesSelector||p.mozMatchesSelector||p.webkitMatchesSelector||p.msMatchesSelector),p&&p.matches&&(i=function(a,b){return a.matches(b)},h.mutationSupport=!(!Object.create||!Object.defineProperties)),h.mutationSupport&&(f.observe=function(){k&&(f.connected=!0,j&&j.observe(b.documentElement,o))},f.disconnect=function(){f.connected=!1,j&&j.disconnect()},f.take=function(){j?h.onMutations(j.takeRecords()):l&&l.take()},f.start=function(){k=!0,f.observe()},f.stop=function(){k=!1,f.disconnect()},r("setupRun",function(){return f.disconnect(),q.setupRun.apply(this,arguments)}),r("teardownRun",function(){var a=q.setupRun.apply(this,arguments);return f.observe(),a}),r("setSrc",function(){var a,b=f.connected;return f.disconnect(),a=q.setSrc.apply(this,arguments),b&&f.observe(),a}),h.onMutations=function(a){var b,c,d=[];for(b=0,c=a.length;c>b;b++)g&&"childList"===a[b].type?h.onSubtreeChange(a[b],d):"attributes"===a[b].type&&h.onAttrChange(a[b],d);d.length&&h.fillImgs({elements:d,reevaluate:!0})},h.onSubtreeChange=function(a,b){h.findAddedMutations(a.addedNodes,b),h.findRemovedMutations(a.removedNodes,a.target,b)},h.findAddedMutations=function(a,b){var c,d,e,f;for(c=0,d=a.length;d>c;c++)e=a[c],1===e.nodeType&&(f=e.nodeName.toUpperCase(),"PICTURE"===f?h.addToElements(e.getElementsByTagName("img")[0],b):"IMG"===f&&i(e,h.selShort)?h.addToElements(e,b):"SOURCE"===f?h.addImgForSource(e,e.parentNode,b):h.addToElements(h.qsa(e,h.selShort),b))},h.findRemovedMutations=function(a,b,c){var d,e,f;for(d=0,e=a.length;e>d;d++)f=a[d],1===f.nodeType&&"SOURCE"===f.nodeName.toUpperCase()&&h.addImgForSource(f,b,c)},h.addImgForSource=function(a,b,c){b&&"PICTURE"!==(b.nodeName||"").toUpperCase()&&(b=b.parentNode,b&&"PICTURE"===(b.nodeName||"").toUpperCase()||(b=null)),b&&h.addToElements(b.getElementsByTagName("img")[0],c)},h.addToElements=function(a,b){var c,d;if(a)if("length"in a&&!a.nodeType)for(c=0,d=a.length;d>c;c++)h.addToElements(a[c],b);else a.parentNode&&-1===b.indexOf(a)&&b.push(a)},h.onAttrChange=function(a,b){var c,d=a.target[h.ns];d||"srcset"!==a.attributeName||"IMG"!==(c=a.target.nodeName.toUpperCase())?d&&(c||(c=a.target.nodeName.toUpperCase()),"IMG"===c?(a.attributeName in d&&(d[a.attributeName]=void 0),h.addToElements(a.target,b)):"SOURCE"===c&&h.addImgForSource(a.target,a.target.parentNode,b)):h.addToElements(a.target,b)},h.supPicture||(d&&!h.testMutationEvents?j=new d(h.onMutations):(l=function(){var a=!1,b=[],c=window.setImmediate||window.setTimeout;return function(d){a||(a=!0,l.take||(l.take=function(){b.length&&(h.onMutations(b),b=[]),a=!1}),c(l.take)),b.push(d)}}(),b.documentElement.addEventListener("DOMNodeInserted",function(a){f.connected&&g&&l({type:"childList",addedNodes:[a.target],removedNodes:[]})},!0),b.documentElement.addEventListener("DOMNodeRemoved",function(a){f.connected&&g&&"SOURCE"===(a.target||{}).nodeName&&l({type:"childList",addedNodes:[],removedNodes:[a.target],target:a.target.parentNode})},!0),b.documentElement.addEventListener("DOMAttrModified",function(a){f.connected&&m[a.attrName]&&l({type:"attributes",target:a.target,attributeName:a.attrName})},!0)),window.HTMLImageElement&&Object.defineProperties&&!function(){var a=b.createElement("img"),c=[],d=a.getAttribute,e=a.setAttribute,f={src:1};h.supSrcset&&!h.supSizes&&(f.srcset=1),Object.defineProperties(HTMLImageElement.prototype,{getAttribute:{value:function(a){var b;return f[a]&&(b=this[h.ns])&&void 0!==b[a]?b[a]:d.apply(this,arguments)},writeable:!0,enumerable:!0,configurable:!0}}),h.supSrcset||c.push("srcset"),h.supSizes||c.push("sizes"),c.forEach(function(a){Object.defineProperty(HTMLImageElement.prototype,a,{set:function(b){e.call(this,a,b)},get:function(){return d.call(this,a)||""},enumerable:!0,configurable:!0})}),"currentSrc"in a||!function(){var a,c=function(a,b){null==b&&(b=a.src||""),Object.defineProperty(a,"pfCurrentSrc",{value:b,writable:!0})},d=c;h.supSrcset&&window.devicePixelRatio&&(a=function(a,b){var c=a.d||a.w||a.res,d=b.d||b.w||b.res;return c-d},c=function(b){var c,e,f,g,i=b[h.ns];if(i&&i.supported&&i.srcset&&i.sets&&(e=h.parseSet(i.sets[0]))&&e.sort){for(e.sort(a),f=e.length,g=e[f-1],c=0;f>c;c++)if(e[c].d>=window.devicePixelRatio){g=e[c];break}g&&(g=h.makeUrl(g.url))}d(b,g)}),b.addEventListener("load",function(a){"IMG"===a.target.nodeName.toUpperCase()&&c(a.target)},!0),Object.defineProperty(HTMLImageElement.prototype,"currentSrc",{set:function(){window.console&&console.warn&&console.warn("currentSrc can't be set on img element")},get:function(){return this.complete&&c(this),this.src||this.srcset?this.pfCurrentSrc||"":""},enumerable:!0,configurable:!0})}(),!window.HTMLSourceElement||"srcset"in b.createElement("source")||["srcset","sizes"].forEach(function(a){Object.defineProperty(window.HTMLSourceElement.prototype,a,{set:function(b){this.setAttribute(a,b)},get:function(){return this.getAttribute(a)||""},enumerable:!0,configurable:!0})})}(),f.start()),g||b.addEventListener("DOMContentLoaded",function(){g=!0}))}});}
- // Object.defineProperty
- (function (nativeDefineProperty) {
- var supportsAccessors = Object.prototype.hasOwnProperty('__defineGetter__');
- var ERR_ACCESSORS_NOT_SUPPORTED = 'Getters & setters cannot be defined on this javascript engine';
- var ERR_VALUE_ACCESSORS = 'A property cannot both have accessors and be writable or have a value';
- Object.defineProperty = function defineProperty(object, property, descriptor) {
- // Where native support exists, assume it
- if (nativeDefineProperty && (object === window || object === document || object === Element.prototype || object instanceof Element)) {
- return nativeDefineProperty(object, property, descriptor);
- }
- var propertyString = String(property);
- var hasValueOrWritable = 'value' in descriptor || 'writable' in descriptor;
- var getterType = 'get' in descriptor && typeof descriptor.get;
- var setterType = 'set' in descriptor && typeof descriptor.set;
- if (object === null || !(object instanceof Object || typeof object === 'object')) {
- throw new TypeError('Object must be an object (Object.defineProperty polyfill)');
- }
- if (!(descriptor instanceof Object)) {
- throw new TypeError('Descriptor must be an object (Object.defineProperty polyfill)');
- }
- // handle descriptor.get
- if (getterType) {
- if (getterType !== 'function') {
- throw new TypeError('Getter expected a function (Object.defineProperty polyfill)');
- }
- if (!supportsAccessors) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
- if (hasValueOrWritable) {
- throw new TypeError(ERR_VALUE_ACCESSORS);
- }
- object.__defineGetter__(propertyString, descriptor.get);
- } else {
- object[propertyString] = descriptor.value;
- }
- // handle descriptor.set
- if (setterType) {
- if (setterType !== 'function') {
- throw new TypeError('Setter expected a function (Object.defineProperty polyfill)');
- }
- if (!supportsAccessors) {
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- }
- if (hasValueOrWritable) {
- throw new TypeError(ERR_VALUE_ACCESSORS);
- }
- object.__defineSetter__(propertyString, descriptor.set);
- }
- // OK to define value unconditionally - if a getter has been specified as well, an error would be thrown above
- if ('value' in descriptor) {
- object[propertyString] = descriptor.value;
- }
- return object;
- };
- }(Object.defineProperty));
- // Array.from
- // Wrapped in IIFE to prevent leaking to global scope.
- (function () {
- function parseIterable (arraylike) {
- var done = false;
- var iterableResponse;
- var tempArray = [];
- // if the iterable doesn't have next;
- // it is an iterable if 'next' is a function but it has not been defined on
- // the object itself.
- if (typeof arraylike.next === 'function' && arraylike.hasOwnProperty('next') === false) {
- while (!done) {
- iterableResponse = arraylike.next();
- if (
- iterableResponse.hasOwnProperty('value') &&
- iterableResponse.hasOwnProperty('done')
- ) {
- if (iterableResponse.done === true) {
- done = true;
- break;
- // handle the case where the done value is not Boolean
- } else if (iterableResponse.done !== false) {
- break;
- }
- tempArray.push(iterableResponse.value);
- } else {
- // it does not conform to the iterable pattern
- break;
- }
- }
- }
- if (done) {
- return tempArray;
- } else {
- // something went wrong return false;
- return false;
- }
- }
- Object.defineProperty(Array, 'from', {
- configurable: true,
- value: function from(source) {
- // handle non-objects
- if (source === undefined || source === null) {
- throw new TypeError(source + ' is not an object');
- }
- // handle maps that are not functions
- if (1 in arguments && !(arguments[1] instanceof Function)) {
- throw new TypeError(arguments[1] + ' is not a function');
- }
- var arraylike = typeof source === 'string' ? source.split('') : Object(source);
- var map = arguments[1];
- var scope = arguments[2];
- var array = [];
- var index = -1;
- var length = Math.min(Math.max(Number(arraylike.length) || 0, 0), 9007199254740991);
- var value;
- // variables for rebuilding array from iterator
- var arrayFromIterable;
- // if it is an iterable treat like one
- arrayFromIterable = parseIterable(arraylike);
- //if it is a Map or a Set then handle them appropriately
- if (
- typeof arraylike.entries === 'function' &&
- typeof arraylike.values === 'function'
- ) {
- if (arraylike.constructor.name === 'Set' && 'values' in Set.prototype) {
- arrayFromIterable = parseIterable(arraylike.values());
- }
- if (arraylike.constructor.name === 'Map' && 'entries' in Map.prototype) {
- arrayFromIterable = parseIterable(arraylike.entries());
- }
- }
- if (arrayFromIterable) {
- arraylike = arrayFromIterable;
- length = arrayFromIterable.length;
- }
- while (++index < length) {
- if (index in arraylike) {
- value = arraylike[index];
- array[index] = map ? map.call(scope, value, index) : value;
- }
- }
- array.length = length;
- return array;
- },
- writable: true
- });
- }());
- // Array.isArray
- (function (toString) {
- Object.defineProperty(Array, 'isArray', {
- configurable: true,
- value: function isArray(object) {
- return toString.call(object) === '[object Array]';
- },
- writable: true
- });
- })(Object.prototype.toString);
- // Array.of
- (function (slice) {
- Object.defineProperty(Array, 'of', {
- configurable: true,
- value: function of() {
- return slice.call(arguments);
- },
- writable: true
- });
- })(Array.prototype.slice);
- // Array.prototype.every
- Array.prototype.every = function every(callback) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- if (!(callback instanceof Function)) {
- throw new TypeError(callback + ' is not a function');
- }
- var
- object = Object(this),
- scope = arguments[1],
- arraylike = object instanceof String ? object.split('') : object,
- length = Number(arraylike.length) || 0,
- index = -1;
- while (++index < length) {
- if (index in arraylike && !callback.call(scope, arraylike[index], index, object)) {
- return false;
- }
- }
- return true;
- };
- // Array.prototype.fill
- Object.defineProperty(Array.prototype, 'fill', {
- configurable: true,
- value: function fill(value) {
- if (this === undefined || this === null) {
- throw new TypeError(this + ' is not an object');
- }
- var arrayLike = Object(this);
- var length = Math.max(Math.min(arrayLike.length, 9007199254740991), 0) || 0;
- var relativeStart = 1 in arguments ? parseInt(Number(arguments[1]), 10) || 0 : 0;
- relativeStart = relativeStart < 0 ? Math.max(length + relativeStart, 0) : Math.min(relativeStart, length);
- var relativeEnd = 2 in arguments && arguments[2] !== undefined ? parseInt(Number(arguments[2]), 10) || 0 : length;
- relativeEnd = relativeEnd < 0 ? Math.max(length + arguments[2], 0) : Math.min(relativeEnd, length);
- while (relativeStart < relativeEnd) {
- arrayLike[relativeStart] = value;
- ++relativeStart;
- }
- return arrayLike;
- },
- writable: true
- });
- // Array.prototype.filter
- Array.prototype.filter = function filter(callback) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- if (!(callback instanceof Function)) {
- throw new TypeError(callback + ' is not a function');
- }
- var
- object = Object(this),
- scope = arguments[1],
- arraylike = object instanceof String ? object.split('') : object,
- length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- index = -1,
- result = [],
- element;
- while (++index < length) {
- element = arraylike[index];
- if (index in arraylike && callback.call(scope, element, index, object)) {
- result.push(element);
- }
- }
- return result;
- };
- // Array.prototype.forEach
- Array.prototype.forEach = function forEach(callback) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- if (!(callback instanceof Function)) {
- throw new TypeError(callback + ' is not a function');
- }
- var
- object = Object(this),
- scope = arguments[1],
- arraylike = object instanceof String ? object.split('') : object,
- length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- index = -1,
- result = [],
- element;
- while (++index < length) {
- if (index in arraylike) {
- callback.call(scope, arraylike[index], index, object);
- }
- }
- };
- // Array.prototype.indexOf
- Array.prototype.indexOf = function indexOf(searchElement) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- var
- arraylike = this instanceof String ? this.split('') : this,
- length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- index = Number(arguments[1]) || 0;
- index = (index < 0 ? Math.max(length + index, 0) : index) - 1;
- while (++index < length) {
- if (index in arraylike && arraylike[index] === searchElement) {
- return index;
- }
- }
- return -1;
- };
- // Array.prototype.lastIndexOf
- Array.prototype.lastIndexOf = function lastIndexOf(searchElement) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- var
- arraylike = this instanceof String ? this.split('') : this,
- length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- index = Number(arguments[1]) || 0;
- index = 1 in arguments ? (index < 0 ? Math.max(length + index, 0) : index) + 1 : length;
- while (--index >= 0) {
- if (index in arraylike && arraylike[index] === searchElement) {
- return index;
- }
- }
- return -1;
- };
- // Array.prototype.map
- Array.prototype.map = function map(callback) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- if (!(callback instanceof Function)) {
- throw new TypeError(callback + ' is not a function');
- }
- var
- object = Object(this),
- scope = arguments[1],
- arraylike = object instanceof String ? object.split('') : object,
- length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- index = -1,
- result = [],
- element;
- while (++index < length) {
- if (index in arraylike) {
- result[index] = callback.call(scope, arraylike[index], index, object);
- }
- }
- return result;
- };
- // Array.prototype.reduce
- Array.prototype.reduce = function reduce(callback) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- if (!(callback instanceof Function)) {
- throw new TypeError(callback + ' is not a function');
- }
- var
- object = Object(this),
- scope = arguments[1],
- arraylike = object instanceof String ? object.split('') : object,
- length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- index = -1,
- previousValue;
- if (1 in arguments) {
- previousValue = arguments[1];
- } else {
- while (++index < length && !(index in arraylike)) {}
- if (index >= length) {
- throw new TypeError('Reduce of empty array with no initial value');
- }
- previousValue = arraylike[index];
- }
- while (++index < length) {
- if (index in arraylike) {
- previousValue = callback(previousValue, arraylike[index], index, object);
- }
- }
- return previousValue;
- };
- // Array.prototype.reduceRight
- Array.prototype.reduceRight = function reduceRight(callback) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- if (!(callback instanceof Function)) {
- throw new TypeError(callback + ' is not a function');
- }
- var
- object = Object(this),
- scope = arguments[1],
- arraylike = object instanceof String ? object.split('') : object,
- length = -1,
- index = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- previousValue;
- if (1 in arguments) {
- previousValue = arguments[1];
- } else {
- while (--index > length && !(index in arraylike)) {}
- if (index <= length) {
- throw new TypeError('Reduce of empty array with no initial value');
- }
- previousValue = arraylike[index];
- }
- while (--index > length) {
- if (index in arraylike) {
- previousValue = callback(previousValue, arraylike[index], index, object);
- }
- }
- return previousValue;
- };
- // Array.prototype.some
- Array.prototype.some = function some(callback) {
- if (this === undefined || this === null) {
- throw new TypeError(this + 'is not an object');
- }
- if (!(callback instanceof Function)) {
- throw new TypeError(callback + ' is not a function');
- }
- var
- object = Object(this),
- scope = arguments[1],
- arraylike = object instanceof String ? object.split('') : object,
- length = Math.max(Math.min(arraylike.length, 9007199254740991), 0) || 0,
- index = -1;
- while (++index < length) {
- if (index in arraylike && callback.call(scope, arraylike[index], index, object)) {
- return true;
- }
- }
- return false;
- };
- // Document
- if (this.HTMLDocument) { // IE8
- // HTMLDocument is an extension of Document. If the browser has HTMLDocument but not Document, the former will suffice as an alias for the latter.
- this.Document = this.HTMLDocument;
- } else {
- // Create an empty function to act as the missing constructor for the document object, attach the document object as its prototype. The function needs to be anonymous else it is hoisted and causes the feature detect to prematurely pass, preventing the assignments below being made.
- this.Document = this.HTMLDocument = document.constructor = (new Function('return function Document() {}')());
- this.Document.prototype = document;
- }
- // Element
- (function () {
- // IE8
- if (window.Element && !window.HTMLElement) {
- window.HTMLElement = window.Element;
- return;
- }
- // create Element constructor
- window.Element = window.HTMLElement = new Function('return function Element() {}')();
- // generate sandboxed iframe
- var vbody = document.appendChild(document.createElement('body'));
- var frame = vbody.appendChild(document.createElement('iframe'));
- // use sandboxed iframe to replicate Element functionality
- var frameDocument = frame.contentWindow.document;
- var prototype = Element.prototype = frameDocument.appendChild(frameDocument.createElement('*'));
- var cache = {};
- // polyfill Element.prototype on an element
- var shiv = function (element, deep) {
- var
- childNodes = element.childNodes || [],
- index = -1,
- key, value, childNode;
- if (element.nodeType === 1 && element.constructor !== Element) {
- element.constructor = Element;
- for (key in cache) {
- value = cache[key];
- element[key] = value;
- }
- }
- while (childNode = deep && childNodes[++index]) {
- shiv(childNode, deep);
- }
- return element;
- };
- var elements = document.getElementsByTagName('*');
- var nativeCreateElement = document.createElement;
- var interval;
- var loopLimit = 100;
- prototype.attachEvent('onpropertychange', function (event) {
- var
- propertyName = event.propertyName,
- nonValue = !cache.hasOwnProperty(propertyName),
- newValue = prototype[propertyName],
- oldValue = cache[propertyName],
- index = -1,
- element;
- while (element = elements[++index]) {
- if (element.nodeType === 1) {
- if (nonValue || element[propertyName] === oldValue) {
- element[propertyName] = newValue;
- }
- }
- }
- cache[propertyName] = newValue;
- });
- prototype.constructor = Element;
- if (!prototype.hasAttribute) {
- // <Element>.hasAttribute
- prototype.hasAttribute = function hasAttribute(name) {
- return this.getAttribute(name) !== null;
- };
- }
- // Apply Element prototype to the pre-existing DOM as soon as the body element appears.
- function bodyCheck(e) {
- if (!(loopLimit--)) clearTimeout(interval);
- if (document.body && !document.body.prototype && /(complete|interactive)/.test(document.readyState)) {
- shiv(document, true);
- if (interval && document.body.prototype) clearTimeout(interval);
- return (!!document.body.prototype);
- }
- return false;
- }
- if (!bodyCheck(true)) {
- document.onreadystatechange = bodyCheck;
- interval = setInterval(bodyCheck, 25);
- }
- // Apply to any new elements created after load
- document.createElement = function createElement(nodeName) {
- var element = nativeCreateElement(String(nodeName).toLowerCase());
- return shiv(element);
- };
- // remove sandboxed iframe
- document.removeChild(vbody);
- })();
- // Event
- (function () {
- var unlistenableWindowEvents = {
- click: 1,
- dblclick: 1,
- keyup: 1,
- keypress: 1,
- keydown: 1,
- mousedown: 1,
- mouseup: 1,
- mousemove: 1,
- mouseover: 1,
- mouseenter: 1,
- mouseleave: 1,
- mouseout: 1,
- storage: 1,
- storagecommit: 1,
- textinput: 1
- };
- function indexOf(array, element) {
- var
- index = -1,
- length = array.length;
- while (++index < length) {
- if (index in array && array[index] === element) {
- return index;
- }
- }
- return -1;
- }
- var existingProto = (window.Event && window.Event.prototype) || null;
- window.Event = Window.prototype.Event = function Event(type, eventInitDict) {
- if (!type) {
- throw new Error('Not enough arguments');
- }
- // Shortcut if browser supports createEvent
- if ('createEvent' in document) {
- var event = document.createEvent('Event');
- var bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
- var cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
- event.initEvent(type, bubbles, cancelable);
- return event;
- }
- var event = document.createEventObject();
- event.type = type;
- event.bubbles = eventInitDict && eventInitDict.bubbles !== undefined ? eventInitDict.bubbles : false;
- event.cancelable = eventInitDict && eventInitDict.cancelable !== undefined ? eventInitDict.cancelable : false;
- return event;
- };
- if (existingProto) {
- Object.defineProperty(window.Event, 'prototype', {
- configurable: false,
- enumerable: false,
- writable: true,
- value: existingProto
- });
- }
- if (!('createEvent' in document)) {
- window.addEventListener = Window.prototype.addEventListener = Document.prototype.addEventListener = Element.prototype.addEventListener = function addEventListener() {
- var
- element = this,
- type = arguments[0],
- listener = arguments[1];
- if (element === window && type in unlistenableWindowEvents) {
- throw new Error('In IE8 the event: ' + type + ' is not available on the window object. Please see https://github.com/Financial-Times/polyfill-service/issues/317 for more information.');
- }
- if (!element._events) {
- element._events = {};
- }
- if (!element._events[type]) {
- element._events[type] = function (event) {
- var
- list = element._events[event.type].list,
- events = list.slice(),
- index = -1,
- length = events.length,
- eventElement;
- event.preventDefault = function preventDefault() {
- if (event.cancelable !== false) {
- event.returnValue = false;
- }
- };
- event.stopPropagation = function stopPropagation() {
- event.cancelBubble = true;
- };
- event.stopImmediatePropagation = function stopImmediatePropagation() {
- event.cancelBubble = true;
- event.cancelImmediate = true;
- };
- event.currentTarget = element;
- event.relatedTarget = event.fromElement || null;
- event.target = event.target || event.srcElement || element;
- event.timeStamp = new Date().getTime();
- if (event.clientX) {
- event.pageX = event.clientX + document.documentElement.scrollLeft;
- event.pageY = event.clientY + document.documentElement.scrollTop;
- }
- while (++index < length && !event.cancelImmediate) {
- if (index in events) {
- eventElement = events[index];
- if (indexOf(list, eventElement) !== -1 && typeof eventElement === 'function') {
- eventElement.call(element, event);
- }
- }
- }
- };
- element._events[type].list = [];
- if (element.attachEvent) {
- element.attachEvent('on' + type, element._events[type]);
- }
- }
- element._events[type].list.push(listener);
- };
- window.removeEventListener = Window.prototype.removeEventListener = Document.prototype.removeEventListener = Element.prototype.removeEventListener = function removeEventListener() {
- var
- element = this,
- type = arguments[0],
- listener = arguments[1],
- index;
- if (element._events && element._events[type] && element._events[type].list) {
- index = indexOf(element._events[type].list, listener);
- if (index !== -1) {
- element._events[type].list.splice(index, 1);
- if (!element._events[type].list.length) {
- if (element.detachEvent) {
- element.detachEvent('on' + type, element._events[type]);
- }
- delete element._events[type];
- }
- }
- }
- };
- window.dispatchEvent = Window.prototype.dispatchEvent = Document.prototype.dispatchEvent = Element.prototype.dispatchEvent = function dispatchEvent(event) {
- if (!arguments.length) {
- throw new Error('Not enough arguments');
- }
- if (!event || typeof event.type !== 'string') {
- throw new Error('DOM Events Exception 0');
- }
- var element = this, type = event.type;
- try {
- if (!event.bubbles) {
- event.cancelBubble = true;
- var cancelBubbleEvent = function (event) {
- event.cancelBubble = true;
- (element || window).detachEvent('on' + type, cancelBubbleEvent);
- };
- this.attachEvent('on' + type, cancelBubbleEvent);
- }
- this.fireEvent('on' + type, event);
- } catch (error) {
- event.target = element;
- do {
- event.currentTarget = element;
- if ('_events' in element && typeof element._events[type] === 'function') {
- element._events[type].call(element, event);
- }
- if (typeof element['on' + type] === 'function') {
- element['on' + type].call(element, event);
- }
- element = element.nodeType === 9 ? element.parentWindow : element.parentNode;
- } while (element && !event.cancelBubble);
- }
- return true;
- };
- }
- })();
- // CustomEvent
- this.CustomEvent = function CustomEvent(type, eventInitDict) {
- if (!type) {
- throw Error('TypeError: Failed to construct "CustomEvent": An event name must be provided.');
- }
- var event;
- eventInitDict = eventInitDict || {bubbles: false, cancelable: false, detail: null};
- if ('createEvent' in document) {
- try {
- event = document.createEvent('CustomEvent');
- event.initCustomEvent(type, eventInitDict.bubbles, eventInitDict.cancelable, eventInitDict.detail);
- } catch (error) {
- // for browsers which don't support CustomEvent at all, we use a regular event instead
- event = document.createEvent('Event');
- event.initEvent(type, eventInitDict.bubbles, eventInitDict.cancelable);
- event.detail = eventInitDict.detail;
- }
- } else {
- // IE8
- event = new Event(type, eventInitDict);
- event.detail = eventInitDict && eventInitDict.detail || null;
- }
- return event;
- };
- CustomEvent.prototype = Event.prototype;
- // _DOMTokenList
- var _DOMTokenList = (function (global) {
- function tokenize(token) {
- if (/^-?[_a-zA-Z]+[_a-zA-Z0-9-]*$/.test(token)) {
- return String(token);
- } else {
- throw new Error('InvalidCharacterError: DOM Exception 5');
- }
- }
- function toObject(self) {
- for (var index = -1, object = {}, element; element = self[++index];) {
- object[element] = true;
- }
- return object;
- }
- function fromObject(self, object) {
- var array = [], token;
- for (token in object) {
- if (object[token]) {
- array.push(token);
- }
- }
- [].splice.apply(self, [0, self.length].concat(array));
- }
- var DTL = function() {};
- DTL.prototype = {
- constructor: DTL,
- item: function item(index) {
- return this[parseFloat(index)] || null;
- },
- length: Array.prototype.length,
- toString: function toString() {
- return [].join.call(this, ' ');
- },
- add: function add() {
- for (var object = toObject(this), index = 0, token; index in arguments; ++index) {
- token = tokenize(arguments[index]);
- object[token] = true;
- }
- fromObject(this, object);
- },
- contains: function contains(token) {
- return token in toObject(this);
- },
- remove: function remove() {
- for (var object = toObject(this), index = 0, token; index in arguments; ++index) {
- token = tokenize(arguments[index]);
- object[token] = false;
- }
- fromObject(this, object);
- },
- toggle: function toggle(token) {
- var
- object = toObject(this),
- contains = 1 in arguments ? !arguments[1] : tokenize(token) in object;
- object[token] = !contains;
- fromObject(this, object);
- return !contains;
- }
- };
- return DTL;
- })(this);
- // DOMTokenList
- (function (global, join, splice) {
- var nativeImpl = "DOMTokenList" in global && global.DOMTokenList;
- if (!nativeImpl) {
- global.DOMTokenList = _DOMTokenList;
- } else {
- var NativeToggle = nativeImpl.prototype.toggle;
- nativeImpl.prototype.toggle = function toggle(token) {
- if (1 in arguments) {
- var contains = this.contains(token);
- var force = !!arguments[1];
- if ((contains && force) || (!contains && !force)) {
- return force;
- }
- }
- return NativeToggle.call(this, token);
- };
- }
- })(this, Array.prototype.join, Array.prototype.splice);
- // Date.now
- Date.now = function now() {
- return new Date().getTime();
- };
- // Date.prototype.toISOString
- Date.prototype.toISOString = function toISOString() {
- var date = this;
- function pad(str, len) {
- var pad = "0000";
- str = '' + str;
- return pad.substr(0, len - str.length) + str
- }
- var y = date.getUTCFullYear(),
- m = pad(date.getUTCMonth() + 1, 2),
- d = pad(date.getUTCDate(), 2),
- h = pad(date.getUTCHours(), 2),
- i = pad(date.getUTCMinutes(), 2),
- s = pad(date.getUTCSeconds(), 2),
- ms = pad(date.getUTCMilliseconds(), 3);
- return y +'-'+ m +'-'+ d + 'T' + h +':'+ i +':'+ s +'.'+ ms +'Z';
- };
- // _mutation
- // http://dom.spec.whatwg.org/#mutation-method-macro
- function _mutation(nodes) {
- if (!nodes.length) {
- throw new Error('DOM Exception 8');
- } else if (nodes.length === 1) {
- return typeof nodes[0] === 'string' ? document.createTextNode(nodes[0]) : nodes[0];
- } else {
- var
- fragment = document.createDocumentFragment(),
- length = nodes.length,
- index = -1,
- node;
- while (++index < length) {
- node = nodes[index];
- fragment.appendChild(typeof node === 'string' ? document.createTextNode(node) : node);
- }
- return fragment;
- }
- }
- // Element.prototype.after
- Document.prototype.after = Element.prototype.after = function after() {
- if (this.parentNode) {
- this.parentNode.insertBefore(_mutation(arguments), this.nextSibling);
- }
- };
- // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
- // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
- if ("Text" in this) {
- Text.prototype.after = Element.prototype.after;
- }
- // Element.prototype.append
- Document.prototype.append = Element.prototype.append = function append() {
- this.appendChild(_mutation(arguments));
- };
- // Element.prototype.before
- Document.prototype.before = Element.prototype.before = function before() {
- if (this.parentNode) {
- this.parentNode.insertBefore(_mutation(arguments), this);
- }
- };
- // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
- // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
- if ("Text" in this) {
- Text.prototype.before = Element.prototype.before;
- }
- // Element.prototype.classList
- Object.defineProperty(Element.prototype, 'classList', {
- configurable: true,
- get: function () {
- function pull() {
- var className = (typeof element.className === "object" ? element.className.baseVal : element.className);
- [].splice.apply(classList, [0, classList.length].concat((className || '').replace(/^\s+|\s+$/g, '').split(/\s+/)));
- }
- function push() {
- if (element.attachEvent) {
- element.detachEvent('onpropertychange', pull);
- }
- if (typeof element.className === "object") {
- element.className.baseVal = original.toString.call(classList);
- } else {
- element.className = original.toString.call(classList);
- }
- if (element.attachEvent) {
- element.attachEvent('onpropertychange', pull);
- }
- }
- var element = this;
- var original = _DOMTokenList.prototype;
- var ClassList = function ClassList() {};
- var classList;
- ClassList.prototype = new _DOMTokenList;
- ClassList.prototype.item = function item(index) {
- return pull(), original.item.apply(classList, arguments);
- };
- ClassList.prototype.toString = function toString() {
- return pull(), original.toString.apply(classList, arguments);
- };
- ClassList.prototype.add = function add() {
- return pull(), original.add.apply(classList, arguments), push();
- };
- ClassList.prototype.contains = function contains(token) {
- return pull(), original.contains.apply(classList, arguments);
- };
- ClassList.prototype.remove = function remove() {
- return pull(), original.remove.apply(classList, arguments), push();
- };
- ClassList.prototype.toggle = function toggle(token) {
- return pull(), token = original.toggle.apply(classList, arguments), push(), token;
- };
- classList = new ClassList;
- if (element.attachEvent) {
- element.attachEvent('onpropertychange', pull);
- }
- return classList;
- }
- });
- // Element.prototype.cloneNode
- Element.prototype.cloneNode = (function(nativeFunc) {
- return function(deep) {
- var clone = nativeFunc.call(this, deep);
- if ('checked' in this) clone.checked = this.checked;
- return clone;
- }
- })(Element.prototype.cloneNode);
- // document.querySelector
- (function (global) {
- var
- head = document.getElementsByTagName('head')[0];
- function getElementsByQuery(node, selector, one) {
- var
- generator = document.createElement(),
- id = 'qsa' + String(Math.random()).slice(3),
- style, elements;
- generator.innerHTML = 'x<style>' + selector + '{qsa:' + id + ';}';
- style = head.appendChild(generator.lastChild);
- elements = getElements(node, selector, one, id);
- head.removeChild(style);
- return one ? elements[0] : elements;
- }
- function getElements(node, selector, one, id) {
- var
- validNode = /1|9/.test(node.nodeType),
- childNodes = node.childNodes,
- elements = [],
- index = -1,
- childNode;
- if (validNode && node.currentStyle && node.currentStyle.qsa === id) {
- if (elements.push(node) && one) {
- return elements;
- }
- }
- while (childNode = childNodes[++index]) {
- elements = elements.concat(getElements(childNode, selector, one, id));
- if (one && elements.length) {
- return elements;
- }
- }
- return elements;
- }
- Document.prototype.querySelector = Element.prototype.querySelector = function querySelectorAll(selector) {
- return getElementsByQuery(this, selector, true);
- };
- Document.prototype.querySelectorAll = Element.prototype.querySelectorAll = function querySelectorAll(selector) {
- return getElementsByQuery(this, selector, false);
- };
- })(this);
- // Element.prototype.matches
- Element.prototype.matches = Element.prototype.webkitMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || function matches(selector) {
- var element = this;
- var elements = (element.document || element.ownerDocument).querySelectorAll(selector);
- var index = 0;
- while (elements[index] && elements[index] !== element) {
- ++index;
- }
- return !!elements[index];
- };
- // Element.prototype.closest
- Element.prototype.closest = function closest(selector) {
- var node = this;
- while (node) {
- if (node.matches(selector)) return node;
- else node = node.parentElement;
- }
- return null;
- };
- // Element.prototype.prepend
- Document.prototype.prepend = Element.prototype.prepend = function prepend() {
- this.insertBefore(_mutation(arguments), this.firstChild);
- };
- // Element.prototype.remove
- Document.prototype.remove = Element.prototype.remove = function remove() {
- if (this.parentNode) {
- this.parentNode.removeChild(this);
- }
- };
- // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
- // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
- if ("Text" in this) {
- Text.prototype.remove = Element.prototype.remove;
- }
- // Element.prototype.replaceWith
- Document.prototype.replaceWith = Element.prototype.replaceWith = function replaceWith() {
- if (this.parentNode) {
- this.parentNode.replaceChild(_mutation(arguments), this);
- }
- };
- // Not all UAs support the Text constructor. Polyfill on the Text constructor only where it exists
- // TODO: Add a polyfill for the Text constructor, and make it a dependency of this polyfill.
- if ('Text' in this) {
- Text.prototype.replaceWith = Element.prototype.replaceWith;
- }
- // Event.DOMContentLoaded
- document.attachEvent('onreadystatechange', function() {
- if (document.readyState === 'complete') {
- document.dispatchEvent(new Event('DOMContentLoaded', {
- bubbles: true
- }));
- }
- });
- // Function.prototype.bind
- // https://github.com/es-shims/es5-shim/blob/d6d7ff1b131c7ba14c798cafc598bb6780d37d3b/es5-shim.js#L182
- Object.defineProperty(Function.prototype, 'bind', {
- value: function bind(that) { // .length is 1
- // add necessary es5-shim utilities
- var $Array = Array;
- var $Object = Object;
- var ObjectPrototype = $Object.prototype;
- var ArrayPrototype = $Array.prototype;
- var Empty = function Empty() {};
- var to_string = ObjectPrototype.toString;
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
- var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
- var array_slice = ArrayPrototype.slice;
- var array_concat = ArrayPrototype.concat;
- var array_push = ArrayPrototype.push;
- var max = Math.max;
- // /add necessary es5-shim utilities
- // 1. Let Target be the this value.
- var target = this;
- // 2. If IsCallable(Target) is false, throw a TypeError exception.
- if (!isCallable(target)) {
- throw new TypeError('Function.prototype.bind called on incompatible ' + target);
- }
- // 3. Let A be a new (possibly empty) internal list of all of the
- // argument values provided after thisArg (arg1, arg2 etc), in order.
- // XXX slicedArgs will stand in for "A" if used
- var args = array_slice.call(arguments, 1); // for normal call
- // 4. Let F be a new native ECMAScript object.
- // 11. Set the [[Prototype]] internal property of F to the standard
- // built-in Function prototype object as specified in 15.3.3.1.
- // 12. Set the [[Call]] internal property of F as described in
- // 15.3.4.5.1.
- // 13. Set the [[Construct]] internal property of F as described in
- // 15.3.4.5.2.
- // 14. Set the [[HasInstance]] internal property of F as described in
- // 15.3.4.5.3.
- var bound;
- var binder = function () {
- if (this instanceof bound) {
- // 15.3.4.5.2 [[Construct]]
- // When the [[Construct]] internal method of a function object,
- // F that was created using the bind function is called with a
- // list of arguments ExtraArgs, the following steps are taken:
- // 1. Let target be the value of F's [[TargetFunction]]
- // internal property.
- // 2. If target has no [[Construct]] internal method, a
- // TypeError exception is thrown.
- // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
- // property.
- // 4. Let args be a new list containing the same values as the
- // list boundArgs in the same order followed by the same
- // values as the list ExtraArgs in the same order.
- // 5. Return the result of calling the [[Construct]] internal
- // method of target providing args as the arguments.
- var result = target.apply(
- this,
- array_concat.call(args, array_slice.call(arguments))
- );
- if ($Object(result) === result) {
- return result;
- }
- return this;
- } else {
- // 15.3.4.5.1 [[Call]]
- // When the [[Call]] internal method of a function object, F,
- // which was created using the bind function is called with a
- // this value and a list of arguments ExtraArgs, the following
- // steps are taken:
- // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
- // property.
- // 2. Let boundThis be the value of F's [[BoundThis]] internal
- // property.
- // 3. Let target be the value of F's [[TargetFunction]] internal
- // property.
- // 4. Let args be a new list containing the same values as the
- // list boundArgs in the same order followed by the same
- // values as the list ExtraArgs in the same order.
- // 5. Return the result of calling the [[Call]] internal method
- // of target providing boundThis as the this value and
- // providing args as the arguments.
- // equiv: target.call(this, ...boundArgs, ...args)
- return target.apply(
- that,
- array_concat.call(args, array_slice.call(arguments))
- );
- }
- };
- // 15. If the [[Class]] internal property of Target is "Function", then
- // a. Let L be the length property of Target minus the length of A.
- // b. Set the length own property of F to either 0 or L, whichever is
- // larger.
- // 16. Else set the length own property of F to 0.
- var boundLength = max(0, target.length - args.length);
- // 17. Set the attributes of the length own property of F to the values
- // specified in 15.3.5.1.
- var boundArgs = [];
- for (var i = 0; i < boundLength; i++) {
- array_push.call(boundArgs, '$' + i);
- }
- // XXX Build a dynamic function with desired amount of arguments is the only
- // way to set the length property of a function.
- // In environments where Content Security Policies enabled (Chrome extensions,
- // for ex.) all use of eval or Function costructor throws an exception.
- // However in all of these environments Function.prototype.bind exists
- // and so this code will never be executed.
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
- if (target.prototype) {
- Empty.prototype = target.prototype;
- bound.prototype = new Empty();
- // Clean up dangling references.
- Empty.prototype = null;
- }
- // TODO
- // 18. Set the [[Extensible]] internal property of F to true.
- // TODO
- // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
- // 20. Call the [[DefineOwnProperty]] internal method of F with
- // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
- // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
- // false.
- // 21. Call the [[DefineOwnProperty]] internal method of F with
- // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
- // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
- // and false.
- // TODO
- // NOTE Function objects created using Function.prototype.bind do not
- // have a prototype property or the [[Code]], [[FormalParameters]], and
- // [[Scope]] internal properties.
- // XXX can't delete prototype in pure-js.
- // 22. Return F.
- return bound;
- }
- });
- // Object.defineProperties
- Object.defineProperties = function defineProperties(object, descriptors) {
- for (var property in descriptors) {
- Object.defineProperty(object, property, descriptors[property]);
- }
- return object;
- };
- // Object.create
- Object.create = function create(prototype, properties) {
- /* jshint evil: true */
- if (typeof prototype !== 'object' && prototype !== null) {
- throw TypeError('Object prototype may only be an Object or null');
- }
- var
- object = new Function('e', 'function Object() {}Object.prototype=e;return new Object')(prototype);
- object.constructor.prototype = prototype;
- if (1 in arguments) {
- Object.defineProperties(object, properties);
- }
- return object;
- };
- // Object.getOwnPropertyNames
- Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
- var buffer = [];
- var key;
- // Non-enumerable properties cannot be discovered but can be checked for by name.
- // Define those used internally by JS to allow an incomplete solution
- var commonProps = ['length', "name", "arguments", "caller", "prototype", "observe", "unobserve"];
- if (typeof object === 'undefined' || object === null) {
- throw new TypeError('Cannot convert undefined or null to object');
- }
- object = Object(object);
- // Enumerable properties only
- for (key in object) {
- if (Object.prototype.hasOwnProperty.call(object, key)) {
- buffer.push(key);
- }
- }
- // Check for and add the common non-enumerable properties
- for (var i=0, s=commonProps.length; i<s; i++) {
- if (commonProps[i] in object) buffer.push(commonProps[i]);
- }
- return buffer;
- };
- // Object.getOwnPropertyDescriptor
- (function() {
- var call = Function.prototype.call;
- var prototypeOfObject = Object.prototype;
- var owns = call.bind(prototypeOfObject.hasOwnProperty);
- var defineGetter;
- var defineSetter;
- var lookupGetter;
- var lookupSetter;
- var supportsAccessors;
- if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
- }
- function doesGetOwnPropertyDescriptorWork(object) {
- try {
- object.sentinel = 0;
- return Object.getOwnPropertyDescriptor(
- object,
- "sentinel"
- ).value === 0;
- } catch (exception) {
- // returns falsy
- }
- }
- // check whether getOwnPropertyDescriptor works if it's given. Otherwise,
- // shim partially.
- if (Object.defineProperty) {
- var getOwnPropertyDescriptorWorksOnObject =
- doesGetOwnPropertyDescriptorWork({});
- var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
- doesGetOwnPropertyDescriptorWork(document.createElement("div"));
- if (!getOwnPropertyDescriptorWorksOnDom ||
- !getOwnPropertyDescriptorWorksOnObject
- ) {
- var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
- }
- }
- if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
- var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
- Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
- if ((typeof object != "object" && typeof object != "function") || object === null) {
- throw new TypeError(ERR_NON_OBJECT + object);
- }
- // make a valiant attempt to use the real getOwnPropertyDescriptor
- // for I8's DOM elements.
- if (getOwnPropertyDescriptorFallback) {
- try {
- return getOwnPropertyDescriptorFallback.call(Object, object, property);
- } catch (exception) {
- // try the shim if the real one doesn't work
- }
- }
- // If object does not owns property return undefined immediately.
- if (!owns(object, property)) {
- return;
- }
- // If object has a property then it's for sure both `enumerable` and
- // `configurable`.
- var descriptor = { enumerable: true, configurable: true };
- // If JS engine supports accessor properties then property may be a
- // getter or setter.
- if (supportsAccessors) {
- // Unfortunately `__lookupGetter__` will return a getter even
- // if object has own non getter property along with a same named
- // inherited getter. To avoid misbehavior we temporary remove
- // `__proto__` so that `__lookupGetter__` will return getter only
- // if it's owned by an object.
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
- var getter = lookupGetter(object, property);
- var setter = lookupSetter(object, property);
- // Once we have getter and setter we can put values back.
- object.__proto__ = prototype;
- if (getter || setter) {
- if (getter) {
- descriptor.get = getter;
- }
- if (setter) {
- descriptor.set = setter;
- }
- // If it was accessor property we're done and return here
- // in order to avoid adding `value` to the descriptor.
- return descriptor;
- }
- }
- // If we got this far we know that object has an own property that is
- // not an accessor so we set it as a value and return descriptor.
- descriptor.value = object[property];
- return descriptor;
- };
- }
- }())
- // Object.keys
- Object.keys = (function() {
- 'use strict';
- var hasOwnProperty = Object.prototype.hasOwnProperty,
- hasDontEnumBug = !({ toString: null }).propertyIsEnumerable('toString'),
- dontEnums = [
- 'toString',
- 'toLocaleString',
- 'valueOf',
- 'hasOwnProperty',
- 'isPrototypeOf',
- 'propertyIsEnumerable',
- 'constructor'
- ],
- dontEnumsLength = dontEnums.length;
- return function(obj) {
- if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
- throw new TypeError('Object.keys called on non-object');
- }
- var result = [], prop, i;
- for (prop in obj) {
- if (hasOwnProperty.call(obj, prop)) {
- result.push(prop);
- }
- }
- if (hasDontEnumBug) {
- for (i = 0; i < dontEnumsLength; i++) {
- if (hasOwnProperty.call(obj, dontEnums[i])) {
- result.push(dontEnums[i]);
- }
- }
- }
- return result;
- };
- }());
- // Symbol
- // A modification of https://github.com/WebReflection/get-own-property-symbols
- // (C) Andrea Giammarchi - MIT Licensed
- (function (Object, GOPS) {
- var setDescriptor;
- var G = typeof global === typeof G ? window : global;
- var id = 0;
- var random = '' + Math.random();
- var prefix = '__\x01symbol:';
- var prefixLength = prefix.length;
- var internalSymbol = '__\x01symbol@@' + random;
- var DP = 'defineProperty';
- var DPies = 'defineProperties';
- var GOPN = 'getOwnPropertyNames';
- var GOPD = 'getOwnPropertyDescriptor';
- var PIE = 'propertyIsEnumerable';
- var ObjectProto = Object.prototype;
- var hOP = ObjectProto.hasOwnProperty;
- var pIE = ObjectProto[PIE];
- var toString = ObjectProto.toString;
- var concat = Array.prototype.concat;
- var cachedWindowNames = typeof window === 'object' ? Object.getOwnPropertyNames(window) : [];
- var nGOPN = Object[GOPN];
- var gOPN = function getOwnPropertyNames (obj) {
- if (toString.call(obj) === '[object Window]') {
- try {
- return nGOPN(obj);
- } catch (e) {
- // IE bug where layout engine calls userland gOPN for cross-domain `window` objects
- return concat.call([], cachedWindowNames);
- }
- }
- return nGOPN(obj);
- }
- var gOPD = Object[GOPD];
- var create = Object.create;
- var keys = Object.keys;
- var freeze = Object.freeze || Object;
- var defineProperty = Object[DP];
- var $defineProperties = Object[DPies];
- var descriptor = gOPD(Object, GOPN);
- var indexOf = Array.prototype.indexOf || function (v) {
- for (var i = this.length; i-- && this[i] !== v;) {}
- return i;
- };
- var addInternalIfNeeded = function (o, uid, enumerable) {
- if (!hOP.call(o, internalSymbol)) {
- try {
- defineProperty(o, internalSymbol, {
- enumerable: false,
- configurable: false,
- writable: false,
- value: {}
- });
- } catch (e) {
- o.internalSymbol = value
- }
- }
- o[internalSymbol]['@@' + uid] = enumerable;
- };
- var createWithSymbols = function (proto, descriptors) {
- var self = create(proto);
- gOPN(descriptors).forEach(function (key) {
- if (propertyIsEnumerable.call(descriptors, key)) {
- $defineProperty(self, key, descriptors[key]);
- }
- });
- return self;
- };
- var copyAsNonEnumerable = function (descriptor) {
- var newDescriptor = create(descriptor);
- newDescriptor.enumerable = false;
- return newDescriptor;
- };
- var get = function get(){};
- var onlyNonSymbols = function (name) {
- return name != internalSymbol &&
- !hOP.call(source, name);
- };
- var onlySymbols = function (name) {
- return name != internalSymbol &&
- hOP.call(source, name);
- };
- var propertyIsEnumerable = function propertyIsEnumerable(key) {
- var uid = '' + key;
- return onlySymbols(uid) ? (
- hOP.call(this, uid) &&
- this[internalSymbol]['@@' + uid]
- ) : pIE.call(this, key);
- }
- var setAndGetSymbol = function (uid) {
- var descriptor = {
- enumerable: false,
- configurable: true,
- get: get,
- set: function (value) {
- setDescriptor(this, uid, {
- enumerable: false,
- configurable: true,
- writable: true,
- value: value
- });
- addInternalIfNeeded(this, uid, true);
- }
- };
- try {
- defineProperty(ObjectProto, uid, descriptor);
- } catch (e) {
- ObjectProto[uid] = descriptor.value;
- }
- return freeze(source[uid] = defineProperty(
- Object(uid),
- 'constructor',
- sourceConstructor
- ));
- };
- var Symbol = function Symbol(description) {
- if (this instanceof Symbol) {
- throw new TypeError('Symbol is not a constructor');
- }
- return setAndGetSymbol(
- prefix.concat(description || '', random, ++id)
- );
- };
- var source = create(null);
- var sourceConstructor = {value: Symbol};
- var sourceMap = function (uid) {
- return source[uid];
- };
- var $defineProperty = function defineProp(o, key, descriptor) {
- var uid = '' + key;
- if (onlySymbols(uid)) {
- setDescriptor(o, uid, descriptor.enumerable ?
- copyAsNonEnumerable(descriptor) : descriptor);
- addInternalIfNeeded(o, uid, !!descriptor.enumerable);
- } else {
- defineProperty(o, key, descriptor);
- }
- return o;
- };
- var $getOwnPropertySymbols = function getOwnPropertySymbols(o) {
- return gOPN(o).filter(onlySymbols).map(sourceMap);
- }
- ;
- descriptor.value = $defineProperty;
- defineProperty(Object, DP, descriptor);
- descriptor.value = $getOwnPropertySymbols;
- defineProperty(Object, GOPS, descriptor);
- descriptor.value = function getOwnPropertyNames(o) {
- return gOPN(o).filter(onlyNonSymbols);
- };
- defineProperty(Object, GOPN, descriptor);
- descriptor.value = function defineProperties(o, descriptors) {
- var symbols = $getOwnPropertySymbols(descriptors);
- if (symbols.length) {
- keys(descriptors).concat(symbols).forEach(function (uid) {
- if (propertyIsEnumerable.call(descriptors, uid)) {
- $defineProperty(o, uid, descriptors[uid]);
- }
- });
- } else {
- $defineProperties(o, descriptors);
- }
- return o;
- };
- defineProperty(Object, DPies, descriptor);
- descriptor.value = propertyIsEnumerable;
- defineProperty(ObjectProto, PIE, descriptor);
- descriptor.value = Symbol;
- defineProperty(G, 'Symbol', descriptor);
- // defining `Symbol.for(key)`
- descriptor.value = function (key) {
- var uid = prefix.concat(prefix, key, random);
- return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid);
- };
- defineProperty(Symbol, 'for', descriptor);
- // defining `Symbol.keyFor(symbol)`
- descriptor.value = function (symbol) {
- if (onlyNonSymbols(symbol))
- throw new TypeError(symbol + ' is not a symbol');
- return hOP.call(source, symbol) ?
- symbol.slice(prefixLength * 2, -random.length) :
- void 0
- ;
- };
- defineProperty(Symbol, 'keyFor', descriptor);
- descriptor.value = function getOwnPropertyDescriptor(o, key) {
- var descriptor = gOPD(o, key);
- if (descriptor && onlySymbols(key)) {
- descriptor.enumerable = propertyIsEnumerable.call(o, key);
- }
- return descriptor;
- };
- defineProperty(Object, GOPD, descriptor);
- descriptor.value = function (proto, descriptors) {
- return arguments.length === 1 || typeof descriptors === "undefined" ?
- create(proto) :
- createWithSymbols(proto, descriptors);
- };
- defineProperty(Object, 'create', descriptor);
- descriptor.value = function () {
- var str = toString.call(this);
- return (str === '[object String]' && onlySymbols(this)) ? '[object Symbol]' : str;
- };
- defineProperty(ObjectProto, 'toString', descriptor);
- setDescriptor = function (o, key, descriptor) {
- var protoDescriptor = gOPD(ObjectProto, key);
- delete ObjectProto[key];
- defineProperty(o, key, descriptor);
- defineProperty(ObjectProto, key, protoDescriptor);
- };
- }(Object, 'getOwnPropertySymbols'));
- // Symbol.iterator
- Object.defineProperty(Symbol, 'iterator', {value: Symbol('iterator')});
- // Symbol.species
- Object.defineProperty(Symbol, 'species', {value: Symbol('species')});
- // Number.isNaN
- Number.isNaN = Number.isNaN || function(value) {
- return typeof value === "number" && isNaN(value);
- };
- // Map
- (function(global) {
- // Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
- var undefMarker = Symbol('undef');
- // NaN cannot be found in an array using indexOf, so we encode NaNs using a private symbol.
- var NaNMarker = Symbol('NaN');
- function encodeKey(key) {
- return Number.isNaN(key) ? NaNMarker : key;
- }
- function decodeKey(encodedKey) {
- return (encodedKey === NaNMarker) ? NaN : encodedKey;
- }
- function makeIterator(mapInst, getter) {
- var nextIdx = 0;
- var done = false;
- return {
- next: function() {
- if (nextIdx === mapInst._keys.length) done = true;
- if (!done) {
- while (mapInst._keys[nextIdx] === undefMarker) nextIdx++;
- return {value: getter.call(mapInst, nextIdx++), done: false};
- } else {
- return {done:true};
- }
- }
- }
- }
- function calcSize(mapInst) {
- var size = 0;
- for (var i=0, s=mapInst._keys.length; i<s; i++) {
- if (mapInst._keys[i] !== undefMarker) size++;
- }
- return size;
- }
- var ACCESSOR_SUPPORT = true;
- var Map = function(data) {
- this._keys = [];
- this._values = [];
- // If `data` is iterable (indicated by presence of a forEach method), pre-populate the map
- data && (typeof data.forEach === 'function') && data.forEach(function (item) {
- this.set.apply(this, item);
- }, this);
- if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
- };
- Map.prototype = {};
- // Some old engines do not support ES5 getters/setters. Since Map only requires these for the size property, we can fall back to setting the size property statically each time the size of the map changes.
- try {
- Object.defineProperty(Map.prototype, 'size', {
- get: function() {
- return calcSize(this);
- }
- });
- } catch(e) {
- ACCESSOR_SUPPORT = false;
- }
- Map.prototype['get'] = function(key) {
- var idx = this._keys.indexOf(encodeKey(key));
- return (idx !== -1) ? this._values[idx] : undefined;
- };
- Map.prototype['set'] = function(key, value) {
- var idx = this._keys.indexOf(encodeKey(key));
- if (idx !== -1) {
- this._values[idx] = value;
- } else {
- this._keys.push(encodeKey(key));
- this._values.push(value);
- if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
- }
- return this;
- };
- Map.prototype['has'] = function(key) {
- return (this._keys.indexOf(encodeKey(key)) !== -1);
- };
- Map.prototype['delete'] = function(key) {
- var idx = this._keys.indexOf(encodeKey(key));
- if (idx === -1) return false;
- this._keys[idx] = undefMarker;
- this._values[idx] = undefMarker;
- if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
- return true;
- };
- Map.prototype['clear'] = function() {
- this._keys = this._values = [];
- if (!ACCESSOR_SUPPORT) this.size = 0;
- };
- Map.prototype['values'] = function() {
- return makeIterator(this, function(i) { return this._values[i]; });
- };
- Map.prototype['keys'] = function() {
- return makeIterator(this, function(i) { return decodeKey(this._keys[i]); });
- };
- Map.prototype['entries'] =
- Map.prototype[Symbol.iterator] = function() {
- return makeIterator(this, function(i) { return [decodeKey(this._keys[i]), this._values[i]]; });
- };
- Map.prototype['forEach'] = function(callbackFn, thisArg) {
- thisArg = thisArg || global;
- var iterator = this.entries();
- result = iterator.next();
- while (result.done === false) {
- callbackFn.call(thisArg, result.value[1], result.value[0], this);
- result = iterator.next();
- }
- };
- Map.prototype['constructor'] =
- Map.prototype[Symbol.species] = Map;
- Map.length = 0;
- // Export the object
- this.Map = Map;
- })(this);
- // Node.prototype.contains
- (function() {
- function contains(node) {
- if (!(0 in arguments)) {
- throw new TypeError('1 argument is required');
- }
- do {
- if (this === node) {
- return true;
- }
- } while (node = node && node.parentNode);
- return false;
- }
- // IE
- if ('HTMLElement' in this && 'contains' in HTMLElement.prototype) {
- try {
- delete HTMLElement.prototype.contains;
- } catch (e) {}
- }
- if ('Node' in this) {
- Node.prototype.contains = contains;
- } else {
- document.contains = Element.prototype.contains = contains;
- }
- }());
- // Object.assign
- Object.assign = function assign(target, source) {
- for (var index = 1, key, src; index < arguments.length; ++index) {
- src = arguments[index];
- for (key in src) {
- if (Object.prototype.hasOwnProperty.call(src, key)) {
- target[key] = src[key];
- }
- }
- }
- return target;
- };
- // Object.getPrototypeOf
- Object.getPrototypeOf = function getPrototypeOf(object) {
- if (object !== Object(object)) {
- throw new TypeError('Object.getPrototypeOf called on non-object');
- }
- return object.constructor ? object.constructor.prototype : null;
- };
- // setImmediate
- (function (global, undefined) {
- "use strict";
- if (global.setImmediate) {
- return;
- }
- var nextHandle = 1; // Spec says greater than zero
- var tasksByHandle = {};
- var currentlyRunningATask = false;
- var doc = global.document;
- var setImmediate;
- function addFromSetImmediateArguments(args) {
- tasksByHandle[nextHandle] = partiallyApplied.apply(undefined, args);
- return nextHandle++;
- }
- // This function accepts the same arguments as setImmediate, but
- // returns a function that requires no arguments.
- function partiallyApplied(handler) {
- var args = [].slice.call(arguments, 1);
- return function() {
- if (typeof handler === "function") {
- handler.apply(undefined, args);
- } else {
- (new Function("" + handler))();
- }
- };
- }
- function runIfPresent(handle) {
- // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
- // So if we're currently running a task, we'll need to delay this invocation.
- if (currentlyRunningATask) {
- // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
- // "too much recursion" error.
- setTimeout(partiallyApplied(runIfPresent, handle), 0);
- } else {
- var task = tasksByHandle[handle];
- if (task) {
- currentlyRunningATask = true;
- try {
- task();
- } finally {
- clearImmediate(handle);
- currentlyRunningATask = false;
- }
- }
- }
- }
- function clearImmediate(handle) {
- delete tasksByHandle[handle];
- }
- function installNextTickImplementation() {
- setImmediate = function() {
- var handle = addFromSetImmediateArguments(arguments);
- process.nextTick(partiallyApplied(runIfPresent, handle));
- return handle;
- };
- }
- function canUsePostMessage() {
- // The test against `importScripts` prevents this implementation from being installed inside a web worker,
- // where `global.postMessage` means something completely different and can't be used for this purpose.
- if (global.postMessage && !global.importScripts) {
- var postMessageIsAsynchronous = true;
- var oldOnMessage = global.onmessage;
- global.onmessage = function() {
- postMessageIsAsynchronous = false;
- };
- global.postMessage("", "*");
- global.onmessage = oldOnMessage;
- return postMessageIsAsynchronous;
- }
- }
- function installPostMessageImplementation() {
- // Installs an event handler on `global` for the `message` event: see
- // * https://developer.mozilla.org/en/DOM/window.postMessage
- // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
- var messagePrefix = "setImmediate$" + Math.random() + "$";
- var onGlobalMessage = function(event) {
- if (event.source === global &&
- typeof event.data === "string" &&
- event.data.indexOf(messagePrefix) === 0) {
- runIfPresent(+event.data.slice(messagePrefix.length));
- }
- };
- if (global.addEventListener) {
- global.addEventListener("message", onGlobalMessage, false);
- } else {
- global.attachEvent("onmessage", onGlobalMessage);
- }
- setImmediate = function() {
- var handle = addFromSetImmediateArguments(arguments);
- global.postMessage(messagePrefix + handle, "*");
- return handle;
- };
- }
- function installMessageChannelImplementation() {
- var channel = new MessageChannel();
- channel.port1.onmessage = function(event) {
- var handle = event.data;
- runIfPresent(handle);
- };
- setImmediate = function() {
- var handle = addFromSetImmediateArguments(arguments);
- channel.port2.postMessage(handle);
- return handle;
- };
- }
- function installReadyStateChangeImplementation() {
- var html = doc.documentElement;
- setImmediate = function() {
- var handle = addFromSetImmediateArguments(arguments);
- // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
- // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
- var script = doc.createElement("script");
- script.onreadystatechange = function () {
- runIfPresent(handle);
- script.onreadystatechange = null;
- html.removeChild(script);
- script = null;
- };
- html.appendChild(script);
- return handle;
- };
- }
- function installSetTimeoutImplementation() {
- setImmediate = function() {
- var handle = addFromSetImmediateArguments(arguments);
- setTimeout(partiallyApplied(runIfPresent, handle), 0);
- return handle;
- };
- }
- // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
- var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
- attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
- // Don't get fooled by e.g. browserify environments.
- if ({}.toString.call(global.process) === "[object process]") {
- // For Node.js before 0.9
- installNextTickImplementation();
- } else if (canUsePostMessage()) {
- // For non-IE10 modern browsers
- installPostMessageImplementation();
- } else if (global.MessageChannel) {
- // For web workers, where supported
- installMessageChannelImplementation();
- } else if (doc && "onreadystatechange" in doc.createElement("script")) {
- // For IE 6–8
- installReadyStateChangeImplementation();
- } else {
- // For older browsers
- installSetTimeoutImplementation();
- }
- attachTo.setImmediate = setImmediate;
- attachTo.clearImmediate = clearImmediate;
- }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
- // Promise
- /**
- * Promise polyfill v1.0.10
- * requires setImmediate
- *
- * © 2014–2015 Dmitry Korobkin
- * Released under the MIT license
- * github.com/Octane/Promise
- */
- (function (global) {'use strict';
- var STATUS = '[[PromiseStatus]]';
- var VALUE = '[[PromiseValue]]';
- var ON_FUlFILLED = '[[OnFulfilled]]';
- var ON_REJECTED = '[[OnRejected]]';
- var ORIGINAL_ERROR = '[[OriginalError]]';
- var PENDING = 'pending';
- var INTERNAL_PENDING = 'internal pending';
- var FULFILLED = 'fulfilled';
- var REJECTED = 'rejected';
- var NOT_ARRAY = 'not an array.';
- var REQUIRES_NEW = 'constructor Promise requires "new".';
- var CHAINING_CYCLE = 'then() cannot return same Promise that it resolves.';
- // Modifed by polyfill service - remove undefined require statement
- var setImmediate = global.setImmediate;
- var isArray = Array.isArray || function (anything) {
- return Object.prototype.toString.call(anything) == '[object Array]';
- };
- function InternalError(originalError) {
- this[ORIGINAL_ERROR] = originalError;
- }
- function isInternalError(anything) {
- return anything instanceof InternalError;
- }
- function isObject(anything) {
- //Object.create(null) instanceof Object → false
- return Object(anything) === anything;
- }
- function isCallable(anything) {
- return typeof anything == 'function';
- }
- function isPromise(anything) {
- return anything instanceof Promise;
- }
- function identity(value) {
- return value;
- }
- function thrower(reason) {
- throw reason;
- }
- function enqueue(promise, onFulfilled, onRejected) {
- if (!promise[ON_FUlFILLED]) {
- promise[ON_FUlFILLED] = [];
- promise[ON_REJECTED] = [];
- }
- promise[ON_FUlFILLED].push(onFulfilled);
- promise[ON_REJECTED].push(onRejected);
- }
- function clearAllQueues(promise) {
- delete promise[ON_FUlFILLED];
- delete promise[ON_REJECTED];
- }
- function callEach(queue) {
- var i;
- var length = queue.length;
- for (i = 0; i < length; i++) {
- queue[i]();
- }
- }
- function call(resolve, reject, value) {
- var anything = toPromise(value);
- if (isPromise(anything)) {
- anything.then(resolve, reject);
- } else if (isInternalError(anything)) {
- reject(anything[ORIGINAL_ERROR]);
- } else {
- resolve(value);
- }
- }
- function toPromise(anything) {
- var then;
- if (isPromise(anything)) {
- return anything;
- }
- if(isObject(anything)) {
- try {
- then = anything.then;
- } catch (error) {
- return new InternalError(error);
- }
- if (isCallable(then)) {
- return new Promise(function (resolve, reject) {
- setImmediate(function () {
- try {
- then.call(anything, resolve, reject);
- } catch (error) {
- reject(error);
- }
- });
- });
- }
- }
- return null;
- }
- function resolvePromise(promise, resolver) {
- function resolve(value) {
- if (promise[STATUS] == PENDING) {
- fulfillPromise(promise, value);
- }
- }
- function reject(reason) {
- if (promise[STATUS] == PENDING) {
- rejectPromise(promise, reason);
- }
- }
- try {
- resolver(resolve, reject);
- } catch(error) {
- reject(error);
- }
- }
- function fulfillPromise(promise, value) {
- var queue;
- var anything = toPromise(value);
- if (isPromise(anything)) {
- promise[STATUS] = INTERNAL_PENDING;
- anything.then(
- function (value) {
- fulfillPromise(promise, value);
- },
- function (reason) {
- rejectPromise(promise, reason);
- }
- );
- } else if (isInternalError(anything)) {
- rejectPromise(promise, anything[ORIGINAL_ERROR]);
- } else {
- promise[STATUS] = FULFILLED;
- promise[VALUE] = value;
- queue = promise[ON_FUlFILLED];
- if (queue && queue.length) {
- clearAllQueues(promise);
- callEach(queue);
- }
- }
- }
- function rejectPromise(promise, reason) {
- var queue = promise[ON_REJECTED];
- promise[STATUS] = REJECTED;
- promise[VALUE] = reason;
- if (queue && queue.length) {
- clearAllQueues(promise);
- callEach(queue);
- }
- }
- function Promise(resolver) {
- var promise = this;
- if (!isPromise(promise)) {
- throw new TypeError(REQUIRES_NEW);
- }
- promise[STATUS] = PENDING;
- promise[VALUE] = undefined;
- resolvePromise(promise, resolver);
- }
- Promise.prototype.then = function (onFulfilled, onRejected) {
- var promise = this;
- var nextPromise;
- onFulfilled = isCallable(onFulfilled) ? onFulfilled : identity;
- onRejected = isCallable(onRejected) ? onRejected : thrower;
- nextPromise = new Promise(function (resolve, reject) {
- function tryCall(func) {
- var value;
- try {
- value = func(promise[VALUE]);
- } catch (error) {
- reject(error);
- return;
- }
- if (value === nextPromise) {
- reject(new TypeError(CHAINING_CYCLE));
- } else {
- call(resolve, reject, value);
- }
- }
- function asyncOnFulfilled() {
- setImmediate(tryCall, onFulfilled);
- }
- function asyncOnRejected() {
- setImmediate(tryCall, onRejected);
- }
- switch (promise[STATUS]) {
- case FULFILLED:
- asyncOnFulfilled();
- break;
- case REJECTED:
- asyncOnRejected();
- break;
- default:
- enqueue(promise, asyncOnFulfilled, asyncOnRejected);
- }
- });
- return nextPromise;
- };
- Promise.prototype['catch'] = function (onRejected) {
- return this.then(identity, onRejected);
- };
- Promise.resolve = function (value) {
- var anything = toPromise(value);
- if (isPromise(anything)) {
- return anything;
- }
- return new Promise(function (resolve, reject) {
- if (isInternalError(anything)) {
- reject(anything[ORIGINAL_ERROR]);
- } else {
- resolve(value);
- }
- });
- };
- Promise.reject = function (reason) {
- return new Promise(function (resolve, reject) {
- reject(reason);
- });
- };
- Promise.race = function (values) {
- return new Promise(function (resolve, reject) {
- var i;
- var length;
- if (isArray(values)) {
- length = values.length;
- for (i = 0; i < length; i++) {
- call(resolve, reject, values[i]);
- }
- } else {
- reject(new TypeError(NOT_ARRAY));
- }
- });
- };
- Promise.all = function (values) {
- return new Promise(function (resolve, reject) {
- var fulfilledCount = 0;
- var promiseCount = 0;
- var anything;
- var length;
- var value;
- var i;
- if (isArray(values)) {
- values = values.slice(0);
- length = values.length;
- for (i = 0; i < length; i++) {
- value = values[i];
- anything = toPromise(value);
- if (isPromise(anything)) {
- promiseCount++;
- anything.then(
- function (index) {
- return function (value) {
- values[index] = value;
- fulfilledCount++;
- if (fulfilledCount == promiseCount) {
- resolve(values);
- }
- };
- }(i),
- reject
- );
- } else if (isInternalError(anything)) {
- reject(anything[ORIGINAL_ERROR]);
- } else {
- //[1, , 3] → [1, undefined, 3]
- values[i] = value;
- }
- }
- if (!promiseCount) {
- resolve(values);
- }
- } else {
- reject(new TypeError(NOT_ARRAY));
- }
- });
- };
- if (typeof module != 'undefined' && module.exports) {
- module.exports = global.Promise || Promise;
- } else if (!global.Promise) {
- global.Promise = Promise;
- }
- }(this));
- // Set
- (function(global) {
- // Deleted map items mess with iterator pointers, so rather than removing them mark them as deleted. Can't use undefined or null since those both valid keys so use a private symbol.
- var undefMarker = Symbol('undef');
- // NaN cannot be found in an array using indexOf, so we encode NaNs using a private symbol.
- var NaNMarker = Symbol('NaN');
- function encodeVal(data) {
- return Number.isNaN(data) ? NaNMarker : data;
- }
- function decodeVal(encodedData) {
- return (encodedData === NaNMarker) ? NaN : encodedData;
- }
- function makeIterator(setInst, getter) {
- var nextIdx = 0;
- var done = false;
- return {
- next: function() {
- if (nextIdx === setInst._values.length) done = true;
- if (!done) {
- while (setInst._values[nextIdx] === undefMarker) nextIdx++;
- return {value: getter.call(setInst, nextIdx++), done: false};
- } else {
- return {done:true};
- }
- }
- }
- }
- function calcSize(setInst) {
- var size = 0;
- for (var i=0, s=setInst._values.length; i<s; i++) {
- if (setInst._values[i] !== undefMarker) size++;
- }
- return size;
- }
- var ACCESSOR_SUPPORT = true;
- var Set = function(data) {
- this._values = [];
- // If `data` is iterable (indicated by presence of a forEach method), pre-populate the set
- data && (typeof data.forEach === 'function') && data.forEach(function (item) {
- this.add.call(this, item);
- }, this);
- if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
- };
- // Some old engines do not support ES5 getters/setters. Since Set only requires these for the size property, we can fall back to setting the size property statically each time the size of the set changes.
- try {
- Object.defineProperty(Set.prototype, 'size', {
- get: function() {
- return calcSize(this);
- }
- });
- } catch(e) {
- ACCESSOR_SUPPORT = false;
- }
- Set.prototype['add'] = function(value) {
- value = encodeVal(value);
- if (this._values.indexOf(value) === -1) {
- this._values.push(value);
- if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
- }
- return this;
- };
- Set.prototype['has'] = function(value) {
- return (this._values.indexOf(encodeVal(value)) !== -1);
- };
- Set.prototype['delete'] = function(value) {
- var idx = this._values.indexOf(encodeVal(value));
- if (idx === -1) return false;
- this._values[idx] = undefMarker;
- if (!ACCESSOR_SUPPORT) this.size = calcSize(this);
- return true;
- };
- Set.prototype['clear'] = function() {
- this._values = [];
- if (!ACCESSOR_SUPPORT) this.size = 0;
- };
- Set.prototype['values'] =
- Set.prototype['keys'] = function() {
- return makeIterator(this, function(i) { return decodeVal(this._values[i]); });
- };
- Set.prototype['entries'] =
- Set.prototype[Symbol.iterator] = function() {
- return makeIterator(this, function(i) { return [decodeVal(this._values[i]), decodeVal(this._values[i])]; });
- };
- Set.prototype['forEach'] = function(callbackFn, thisArg) {
- thisArg = thisArg || global;
- var iterator = this.entries();
- result = iterator.next();
- while (result.done === false) {
- callbackFn.call(thisArg, result.value[1], result.value[0], this);
- result = iterator.next();
- }
- };
- Set.prototype['constructor'] =
- Set.prototype[Symbol.species] = Set;
- Set.length = 0;
- // Export the object
- this.Set = Set;
- })(this);
- // String.prototype.endsWith
- String.prototype.endsWith = function (string) {
- var index = arguments.length < 2 ? this.length : arguments[1];
- var foundIndex = this.lastIndexOf(string);
- return foundIndex !== -1 && foundIndex === index - string.length;
- };
- // String.prototype.includes
- String.prototype.includes = function (string, index) {
- if (typeof string === 'object' && string instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression");
- return this.indexOf(string, index) !== -1;
- };
- // String.prototype.startsWith
- String.prototype.startsWith = function (string) {
- var index = arguments.length < 2 ? 0 : arguments[1];
- return this.slice(index).indexOf(string) === 0;
- };
- // String.prototype.trim
- String.prototype.trim = function trim() {
- return this.replace(/^\s+|\s+$/g, '');
- };
- // URL
- // URL Polyfill
- // Draft specification: http://url.spec.whatwg.org
- // Notes:
- // - Primarily useful for parsing URLs and modifying query parameters
- // - Should work in IE8+ and everything more modern
- (function (global) {
- 'use strict';
- var origURL = global.URL;
- function URLUtils (url) {
- var anchor = document.createElement('a');
- anchor.href = url;
- return anchor;
- }
- global.URL = function URL (url, base) {
- if (!(this instanceof global.URL)) {
- throw new TypeError("Failed to construct 'URL': Please use the 'new' operator.");
- }
- if (base) {
- url = (function () {
- var doc;
- // Use another document/base tag/anchor for relative URL resolution, if possible
- if (document.implementation && document.implementation.createHTMLDocument) {
- doc = document.implementation.createHTMLDocument('');
- }
- else if (document.implementation && document.implementation.createDocument) {
- doc = document.implementation.createElement('http://www.w3.org/1999/xhtml', 'html', null);
- doc.documentElement.appendChild(doc.createElement('head'));
- doc.documentElement.appendChild(doc.createElement('body'));
- }
- else if (window.ActiveXObject) {
- doc = new window.ActiveXObject('htmlfile');
- doc.write('<head></head><body></body>');
- doc.close();
- }
- if (!doc) {
- throw Error('base not supported');
- }
- var baseTag = doc.createElement('base');
- baseTag.href = base;
- doc.getElementsByTagName('head')[0].appendChild(baseTag);
- var anchor = doc.createElement('a');
- anchor.href = url;
- return anchor.href;
- }());
- }
- // An inner object implementing URLUtils (either a native URL
- // object or an HTMLAnchorElement instance) is used to perform the
- // URL algorithms. With full ES5 getter/setter support, return a
- // regular object For IE8's limited getter/setter support, a
- // different HTMLAnchorElement is returned with properties
- // overridden
- var instance = URLUtils(url || '');
- // Detect for ES5 getter/setter support
- var ES5_GET_SET = false;
- try {
- ES5_GET_SET = (Object.defineProperties && (function () {
- var o = {};
- Object.defineProperties(o, {
- p: {
- 'get': function () {
- return true;
- }
- }
- });
- return o.p;
- }()));
- } catch (e) {
- ES5_GET_SET = false;
- };
- var self = ES5_GET_SET ? this : document.createElement('a');
- // NOTE: Doesn't do the encoding/decoding dance
- function parse (input, isindex) {
- var sequences = input.split('&');
- if (isindex && sequences[0].indexOf('=') === -1) {
- sequences[0] = '=' + sequences[0];
- }
- var pairs = [];
- sequences.forEach(function (bytes) {
- if (bytes.length === 0) {
- return;
- }
- var index = bytes.indexOf('=');
- if (index !== -1) {
- var name = bytes.substring(0, index);
- var value = bytes.substring(index + 1);
- }
- else {
- name = bytes;
- value = '';
- }
- name = name.replace(/\+/g, ' ');
- value = value.replace(/\+/g, ' ');
- pairs.push({name: name, value: value});
- });
- var output = [];
- pairs.forEach(function (pair) {
- output.push({
- name : decodeURIComponent(pair.name),
- value: decodeURIComponent(pair.value)
- });
- });
- return output;
- }
- function URLSearchParams (url_object, init) {
- var pairs = [];
- if (init) {
- pairs = parse(init);
- }
- this._setPairs = function (list) {
- pairs = list;
- };
- this._updateSteps = function () {
- updateSteps();
- };
- var updating = false;
- function updateSteps () {
- if (updating) return;
- updating = true;
- // TODO: For all associated url objects
- url_object.search = serialize(pairs);
- updating = false;
- }
- // NOTE: Doesn't do the encoding/decoding dance
- function serialize (pairs) {
- var output = '',
- first = true;
- pairs.forEach(function (pair) {
- var name = encodeURIComponent(pair.name);
- var value = encodeURIComponent(pair.value);
- if (!first) {
- output += '&';
- }
- output += name + '=' + value;
- first = false;
- });
- return output.replace(/%20/g, '+');
- }
- Object.defineProperties(this, {
- append: {
- value: function (name, value) {
- pairs.push({
- name : name,
- value: value
- });
- updateSteps();
- }
- },
- 'delete': {
- value: function (name) {
- for (var i = 0; i < pairs.length;) {
- if (pairs[i].name === name){
- pairs.splice(i, 1);
- }
- else {
- ++i;
- }
- }
- updateSteps();
- }
- },
- get: {
- value: function (name) {
- for (var i = 0; i < pairs.length; ++i) {
- if (pairs[i].name === name) {
- return pairs[i].value;
- }
- }
- return null;
- }
- },
- getAll: {
- value: function (name) {
- var result = [];
- for (var i = 0; i < pairs.length; ++i) {
- if (pairs[i].name === name) {
- result.push(pairs[i].value);
- }
- }
- return result;
- }
- },
- has: {
- value: function (name) {
- for (var i = 0; i < pairs.length; ++i) {
- if (pairs[i].name === name) {
- return true;
- }
- }
- return false;
- }
- },
- set: {
- value: function (name, value) {
- var found = false;
- for (var i = 0; i < pairs.length;) {
- if (pairs[i].name === name) {
- if (!found) {
- pairs[i].value = value;
- found = true;
- ++i;
- }
- else {
- pairs.splice(i, 1);
- }
- }
- else {
- ++i;
- }
- }
- if (!found){
- pairs.push({name: name, value: value});
- }
- updateSteps();
- }
- },
- toString: {
- value: function () {
- return serialize(pairs);
- }
- }
- });
- }
- var queryObject = new URLSearchParams(
- self, instance.search ? instance.search.substring(1) : null);
- Object.defineProperties(self, {
- href: {
- get: function () {
- return instance.href;
- },
- set: function (v) {
- instance.href = v;
- tidy_instance();
- update_steps();
- }
- },
- origin: {
- get: function () {
- if ('origin' in instance) {
- return instance.origin;
- }
- return this.protocol + '//' + this.host;
- }
- },
- protocol: {
- get: function () {
- return instance.protocol;
- },
- set: function (v) {
- instance.protocol = v;
- }
- },
- username: {
- get: function () {
- return instance.username;
- },
- set: function (v) {
- instance.username = v;
- }
- },
- password: {
- get: function () {
- return instance.password;
- },
- set: function (v) {
- instance.password = v;
- }
- },
- host: {
- get: function () {
- // IE returns default port in |host|
- var re = {
- 'http:' : /:80$/,
- 'https:': /:443$/,
- 'ftp:' : /:21$/
- }
- [instance.protocol];
- return re ? instance.host.replace(re, '') : instance.host;
- },
- set: function (v) {
- instance.host = v;
- }
- },
- hostname: {
- get: function () {
- return instance.hostname;
- },
- set: function (v) {
- instance.hostname = v;
- }
- },
- port: {
- get: function () {
- return instance.port;
- },
- set: function (v) {
- instance.port = v;
- }
- },
- pathname: {
- get: function () {
- // IE does not include leading '/' in |pathname|
- if (instance.pathname.charAt(0) !== '/') {
- return '/' + instance.pathname;
- }
- return instance.pathname;
- },
- set: function (v) {
- instance.pathname = v;
- }
- },
- search: {
- get: function () {
- return instance.search;
- },
- set: function (v) {
- if (instance.search !== v) {
- instance.search = v;
- tidy_instance();
- update_steps();
- }
- }
- },
- searchParams: {
- get: function () {
- return queryObject;
- }
- // TODO: implement setter
- },
- hash: {
- get: function () {
- return instance.hash;
- },
- set: function (v) {
- instance.hash = v;
- tidy_instance();
- }
- },
- toString: {
- value: function () {
- return instance.toString();
- }
- },
- valueOf: {
- value: function () {
- return instance.valueOf();
- }
- }
- });
- function tidy_instance () {
- var href = instance.href.replace(/#$|\?$|\?(?=#)/g, '');
- if (instance.href !== href){
- instance.href = href;
- }
- }
- function update_steps () {
- queryObject._setPairs(instance.search ?
- parse(instance.search.substring(1)) : []);
- queryObject._updateSteps();
- }
- return self;
- };
- if (origURL) {
- for (var i in origURL) {
- if (origURL.hasOwnProperty(i)) {
- global.URL[i] = origURL[i];
- }
- }
- }
- }(this));
- // XMLHttpRequest
- (function (global, NativeXMLHttpRequest) {
- // <Global>.XMLHttpRequest
- global.XMLHttpRequest = function XMLHttpRequest() {
- var request = this, nativeRequest = request._request = NativeXMLHttpRequest ? new NativeXMLHttpRequest() : new ActiveXObject('MSXML2.XMLHTTP.3.0');
- nativeRequest.onreadystatechange = function () {
- request.readyState = nativeRequest.readyState;
- var readyState = request.readyState === 4;
- request.response = request.responseText = readyState ? nativeRequest.responseText : null;
- request.status = readyState ? nativeRequest.status : null;
- request.statusText = readyState ? nativeRequest.statusText : null;
- request.dispatchEvent(new Event('readystatechange'));
- if (readyState) {
- request.dispatchEvent(new Event('load'));
- }
- };
- if ('onerror' in nativeRequest) {
- nativeRequest.onerror = function () {
- request.dispatchEvent(new Event('error'));
- };
- }
- };
- var XMLHttpRequestPrototype = global.XMLHttpRequest.prototype;
- XMLHttpRequestPrototype.addEventListener = global.addEventListener;
- XMLHttpRequestPrototype.removeEventListener = global.removeEventListener;
- XMLHttpRequestPrototype.dispatchEvent = global.dispatchEvent;
- XMLHttpRequestPrototype.abort = function abort() {
- return this._request();
- };
- XMLHttpRequestPrototype.getAllResponseHeaders = function getAllResponseHeaders() {
- return this._request.getAllResponseHeaders();
- };
- XMLHttpRequestPrototype.getResponseHeader = function getResponseHeader(header) {
- return this._request.getResponseHeader(header);
- };
- XMLHttpRequestPrototype.open = function open(method, url) {
- // method, url, async, username, password
- this._request.open(method, url, arguments[2], arguments[3], arguments[4]);
- };
- XMLHttpRequestPrototype.overrideMimeType = function overrideMimeType(mimetype) {
- this._request.overrideMimeType(mimetype);
- };
- XMLHttpRequestPrototype.send = function send() {
- this._request.send(0 in arguments ? arguments[0] : null);
- };
- XMLHttpRequestPrototype.setRequestHeader = function setRequestHeader(header, value) {
- this._request.setRequestHeader(header, value);
- };
- })(this, this.XMLHttpRequest);
- // atob
- (function (global) {
- var keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', keysRe = new RegExp('[^' + keys + ']');
- // <Global>.atob
- global.atob = function atob(input) {
- var output = [], buffer, bufferB, chrs, index = 0, indexB, length = input.length;
- if ((keysRe.test(input)) || (/=/.test(input) && (/=[^=]/.test(input) || /={3}/.test(input)))) {
- throw new Error('Invalid base64 data');
- }
- if (length % 4 > 0) {
- input += Array(4 - length % 4 + 1).join("=");
- length = input.length;
- }
- while (index < length) {
- for (bufferB = [], indexB = index; index < indexB + 4;) {
- bufferB.push(keys.indexOf(input.charAt(index++)));
- }
- buffer = (bufferB[0] << 18) + (bufferB[1] << 12) + ((bufferB[2] & 63) << 6) + (bufferB[3] & 63);
- chrs = [(buffer & (255 << 16)) >> 16, bufferB[2] === 64 ? -1 : (buffer & (255 << 8)) >> 8, bufferB[3] === 64 ? -1 : buffer & 255];
- for (indexB = 0; indexB < 3; ++indexB) {
- if (chrs[indexB] >= 0 || indexB === 0) {
- output.push(String.fromCharCode(chrs[indexB]));
- }
- }
- }
- return output.join('');
- };
- // <Global>.btoa
- global.btoa = function btoa(input) {
- var output = [], buffer, chrs, index = 0, length = input.length;
- while (index < length) {
- chrs = [input.charCodeAt(index++), input.charCodeAt(index++), input.charCodeAt(index++)];
- buffer = (chrs[0] << 16) + ((chrs[1] || 0) << 8) + (chrs[2] || 0);
- output.push(
- keys.charAt((buffer & (63 << 18)) >> 18),
- keys.charAt((buffer & (63 << 12)) >> 12),
- keys.charAt(isNaN(chrs[1]) ? 64 : (buffer & (63 << 6)) >> 6),
- keys.charAt(isNaN(chrs[2]) ? 64 : (buffer & 63))
- );
- }
- return output.join('');
- };
- })(this);
- // location.origin
- try {
- Object.defineProperty(window.location, 'origin', {
- enumerable: true,
- writable: false,
- value: window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''),
- configurable: false
- });
- } catch(e) {
- // IE9 is throwing "Object doesn't support this action" when attempting defineProperty on window.location, so provide an alternative
- window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
- }
- // performance.now
- (function (global) {
- var
- startTime = Date.now();
- if (!global.performance) {
- global.performance = {};
- }
- global.performance.now = function () {
- return Date.now() - startTime;
- };
- }(this));
- // requestAnimationFrame
- (function (global) {
- if ('mozRequestAnimationFrame' in global) {
- global.requestAnimationFrame = function (callback) {
- return mozRequestAnimationFrame(function () {
- callback(performance.now());
- });
- };
- global.cancelAnimationFrame = mozCancelAnimationFrame;
- } else if ('webkitRequestAnimationFrame' in global) {
- global.requestAnimationFrame = function (callback) {
- return webkitRequestAnimationFrame(function () {
- callback(performance.now());
- });
- };
- global.cancelAnimationFrame = webkitCancelAnimationFrame;
- } else {
- var lastTime = Date.now();
- global.requestAnimationFrame = function (callback) {
- if (typeof callback !== 'function') {
- throw new TypeError(callback + 'is not a function');
- }
- var
- currentTime = Date.now(),
- delay = 16 + lastTime - currentTime;
- if (delay < 0) {
- delay = 0;
- }
- lastTime = currentTime;
- return setTimeout(function () {
- lastTime = Date.now();
- callback(performance.now());
- }, delay);
- };
- global.cancelAnimationFrame = function (id) {
- clearTimeout(id);
- };
- }
- })(this);
- })
- .call('object' === typeof window && window || 'object' === typeof self && self || 'object' === typeof global && global || {});
- typeof ftNextPolyfillServiceCallback==='function' && ftNextPolyfillServiceCallback();
Add Comment
Please, Sign In to add comment