UNPKG

karma

Version:

Spectacular Test Runner for JavaScript.

1,694 lines (1,553 loc) 91.7 kB
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ module.exports = { VERSION: '%KARMA_VERSION%', KARMA_URL_ROOT: '%KARMA_URL_ROOT%', CONTEXT_URL: 'context.html' } },{}],2:[function(require,module,exports){ var stringify = require('./stringify') var constant = require('./constants') var util = require('./util') var Karma = function (socket, iframe, opener, navigator, location) { var hasError = false var startEmitted = false var reloadingContext = false var store = {} var self = this var queryParams = util.parseQueryParams(location.search) var browserId = queryParams.id || util.generateId('manual-') var returnUrl = queryParams['return_url' + ''] || null var resultsBufferLimit = 50 var resultsBuffer = [] this.VERSION = constant.VERSION this.config = {} // Expose for testing purposes as there is no global socket.io // registry anymore. this.socket = socket var childWindow = null var navigateContextTo = function (url) { if (self.config.useIframe === false) { if (childWindow === null || childWindow.closed === true) { // If this is the first time we are opening the window, or the window is closed childWindow = opener('about:blank') } childWindow.location = url } else { iframe.src = url } } this.setupContext = function (contextWindow) { if (hasError) { return } var getConsole = function (currentWindow) { return currentWindow.console || { log: function () {}, info: function () {}, warn: function () {}, error: function () {}, debug: function () {} } } contextWindow.__karma__ = this // This causes memory leak in Chrome (17.0.963.66) contextWindow.onerror = function () { return contextWindow.__karma__.error.apply(contextWindow.__karma__, arguments) } contextWindow.onbeforeunload = function (e, b) { if (!reloadingContext) { // TODO(vojta): show what test (with explanation about jasmine.UPDATE_INTERVAL) contextWindow.__karma__.error('Some of your tests did a full page reload!') } } if (self.config.captureConsole) { // patch the console var localConsole = contextWindow.console = getConsole(contextWindow) var logMethods = ['log', 'info', 'warn', 'error', 'debug'] var patchConsoleMethod = function (method) { var orig = localConsole[method] if (!orig) { return } localConsole[method] = function () { self.log(method, arguments) return Function.prototype.apply.call(orig, localConsole, arguments) } } for (var i = 0; i < logMethods.length; i++) { patchConsoleMethod(logMethods[i]) } } contextWindow.dump = function () { self.log('dump', arguments) } contextWindow.alert = function (msg) { self.log('alert', [msg]) } } this.log = function (type, args) { var values = [] for (var i = 0; i < args.length; i++) { values.push(this.stringify(args[i], 3)) } this.info({log: values.join(', '), type: type}) } this.stringify = stringify var clearContext = function () { reloadingContext = true navigateContextTo('about:blank') } // error during js file loading (most likely syntax error) // we are not going to execute at all this.error = function (msg, url, line) { hasError = true var message = msg if (url) { message = msg + '\nat ' + url + (line ? ':' + line : '') } socket.emit('karma_error', message) this.complete() return false } this.result = function (result) { if (!startEmitted) { socket.emit('start', {total: null}) startEmitted = true } if (resultsBufferLimit === 1) { return socket.emit('result', result) } resultsBuffer.push(result) if (resultsBuffer.length === resultsBufferLimit) { socket.emit('result', resultsBuffer) resultsBuffer = [] } } this.complete = function (result) { if (resultsBuffer.length) { socket.emit('result', resultsBuffer) resultsBuffer = [] } // give the browser some time to breath, there could be a page reload, but because a bunch of // tests could run in the same event loop, we wouldn't notice. setTimeout(function () { clearContext() }, 0) socket.emit('complete', result || {}, function () { if (returnUrl) { location.href = returnUrl } }) } this.info = function (info) { // TODO(vojta): introduce special API for this if (!startEmitted && util.isDefined(info.total)) { socket.emit('start', info) startEmitted = true } else { socket.emit('info', info) } } var UNIMPLEMENTED_START = function () { this.error('You need to include some adapter that implements __karma__.start method!') } // all files loaded, let's start the execution this.loaded = function () { // has error -> cancel if (!hasError) { this.start(this.config) } // remove reference to child iframe this.start = UNIMPLEMENTED_START } this.store = function (key, value) { if (util.isUndefined(value)) { return store[key] } if (util.instanceOf(value, 'Array')) { var s = store[key] = [] for (var i = 0; i < value.length; i++) { s.push(value[i]) } } else { // TODO(vojta): clone objects + deep store[key] = value } } // supposed to be overriden by the context // TODO(vojta): support multiple callbacks (queue) this.start = UNIMPLEMENTED_START socket.on('execute', function (cfg) { // reset hasError and reload the iframe hasError = false startEmitted = false reloadingContext = false self.config = cfg navigateContextTo(constant.CONTEXT_URL) // clear the console before run // works only on FF (Safari, Chrome do not allow to clear console from js source) if (window.console && window.console.clear) { window.console.clear() } }) // report browser name, id socket.on('connect', function () { socket.io.engine.on('upgrade', function () { resultsBufferLimit = 1 }) socket.emit('register', { name: navigator.userAgent, id: browserId }) }) } module.exports = Karma },{"./constants":1,"./stringify":4,"./util":6}],3:[function(require,module,exports){ /* global io */ /* eslint-disable no-new */ require('core-js/modules/es5') var Karma = require('./karma') var StatusUpdater = require('./updater') var util = require('./util') var KARMA_URL_ROOT = require('./constants').KARMA_URL_ROOT // Connect to the server using socket.io http://socket.io var socket = io(location.host, { reconnectionDelay: 500, reconnectionDelayMax: Infinity, timeout: 2000, path: '/' + KARMA_URL_ROOT.substr(1) + 'socket.io', 'sync disconnect on unload': true }) // instantiate the updater of the view new StatusUpdater(socket, util.elm('title'), util.elm('banner'), util.elm('browsers')) window.karma = new Karma(socket, util.elm('context'), window.open, window.navigator, window.location) },{"./constants":1,"./karma":2,"./updater":5,"./util":6,"core-js/modules/es5":35}],4:[function(require,module,exports){ var serialize = require('dom-serialize') var instanceOf = require('./util').instanceOf var stringify = function stringify (obj, depth) { if (depth === 0) { return '...' } if (obj === null) { return 'null' } switch (typeof obj) { case 'string': return "'" + obj + "'" case 'undefined': return 'undefined' case 'function': return obj.toString().replace(/\{[\s\S]*\}/, '{ ... }') case 'boolean': return obj ? 'true' : 'false' case 'object': var strs = [] if (instanceOf(obj, 'Array')) { strs.push('[') for (var i = 0, ii = obj.length; i < ii; i++) { if (i) { strs.push(', ') } strs.push(stringify(obj[i], depth - 1)) } strs.push(']') } else if (instanceOf(obj, 'Date')) { return obj.toString() } else if (instanceOf(obj, 'Text')) { return obj.nodeValue } else if (instanceOf(obj, 'Comment')) { return '<!--' + obj.nodeValue + '-->' } else if (obj.outerHTML) { return obj.outerHTML } else if (obj.tagName || obj.nodeName) { return serialize(obj) } else { var constructor = 'Object' if (obj.constructor && typeof obj.constructor === 'function') { constructor = obj.constructor.name } strs.push(constructor) strs.push('{') var first = true for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { if (first) { first = false } else { strs.push(', ') } strs.push(key + ': ' + stringify(obj[key], depth - 1)) } } strs.push('}') } return strs.join('') default: return obj } } module.exports = stringify },{"./util":6,"dom-serialize":36}],5:[function(require,module,exports){ var VERSION = require('./constants').VERSION var StatusUpdater = function (socket, titleElement, bannerElement, browsersElement) { var updateBrowsersInfo = function (browsers) { var items = [] var status for (var i = 0; i < browsers.length; i++) { status = browsers[i].isReady ? 'idle' : 'executing' items.push('<li class="' + status + '">' + browsers[i].name + ' is ' + status + '</li>') } browsersElement.innerHTML = items.join('\n') } var updateBanner = function (status) { return function (param) { var paramStatus = param ? status.replace('$', param) : status titleElement.innerHTML = 'Karma v' + VERSION + ' - ' + paramStatus bannerElement.className = status === 'connected' ? 'online' : 'offline' } } socket.on('connect', updateBanner('connected')) socket.on('disconnect', updateBanner('disconnected')) socket.on('reconnecting', updateBanner('reconnecting in $ ms...')) socket.on('reconnect', updateBanner('connected')) socket.on('reconnect_failed', updateBanner('failed to reconnect')) socket.on('info', updateBrowsersInfo) socket.on('disconnect', function () { updateBrowsersInfo([]) }) } module.exports = StatusUpdater },{"./constants":1}],6:[function(require,module,exports){ exports.instanceOf = function (value, constructorName) { return Object.prototype.toString.apply(value) === '[object ' + constructorName + ']' } exports.elm = function (id) { return document.getElementById(id) } exports.generateId = function (prefix) { return prefix + Math.floor(Math.random() * 10000) } exports.isUndefined = function (value) { return typeof value === 'undefined' } exports.isDefined = function (value) { return !exports.isUndefined(value) } exports.parseQueryParams = function (locationSearch) { var params = {} var pairs = locationSearch.substr(1).split('&') var keyValue for (var i = 0; i < pairs.length; i++) { keyValue = pairs[i].split('=') params[decodeURIComponent(keyValue[0])] = decodeURIComponent(keyValue[1]) } return params } },{}],7:[function(require,module,exports){ module.exports = function(it){ if(typeof it != 'function')throw TypeError(it + ' is not a function!'); return it; }; },{}],8:[function(require,module,exports){ var isObject = require('./$.is-object'); module.exports = function(it){ if(!isObject(it))throw TypeError(it + ' is not an object!'); return it; }; },{"./$.is-object":23}],9:[function(require,module,exports){ // false -> Array#indexOf // true -> Array#includes var toObject = require('./$.to-object') , toLength = require('./$.to-length') , toIndex = require('./$.to-index'); module.exports = function(IS_INCLUDES){ return function($this, el, fromIndex){ var O = toObject($this) , length = toLength(O.length) , index = toIndex(fromIndex, length) , value; if(IS_INCLUDES && el != el)while(length > index){ value = O[index++]; if(value != value)return true; } else for(;length > index; index++)if(IS_INCLUDES || index in O){ if(O[index] === el)return IS_INCLUDES || index; } return !IS_INCLUDES && -1; }; }; },{"./$.to-index":30,"./$.to-length":32,"./$.to-object":33}],10:[function(require,module,exports){ // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter // 3 -> Array#some // 4 -> Array#every // 5 -> Array#find // 6 -> Array#findIndex var toObject = require('./$.to-object') , ES5Object = require('./$.es5-object') , ctx = require('./$.ctx') , toLength = require('./$.to-length'); module.exports = function(TYPE){ var IS_MAP = TYPE == 1 , IS_FILTER = TYPE == 2 , IS_SOME = TYPE == 3 , IS_EVERY = TYPE == 4 , IS_FIND_INDEX = TYPE == 6 , NO_HOLES = TYPE == 5 || IS_FIND_INDEX; return function($this, callbackfn, that){ var O = toObject($this, true) , self = ES5Object(O) , f = ctx(callbackfn, that, 3) , length = toLength(self.length) , index = 0 , result = IS_MAP ? Array(length) : IS_FILTER ? [] : undefined , val, res; for(;length > index; index++)if(NO_HOLES || index in self){ val = self[index]; res = f(val, index, O); if(TYPE){ if(IS_MAP)result[index] = res; // map else if(res)switch(TYPE){ case 3: return true; // some case 5: return val; // find case 6: return index; // findIndex case 2: result.push(val); // filter } else if(IS_EVERY)return false; // every } } return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; }; }; },{"./$.ctx":13,"./$.es5-object":17,"./$.to-length":32,"./$.to-object":33}],11:[function(require,module,exports){ var toString = {}.toString; module.exports = function(it){ return toString.call(it).slice(8, -1); }; },{}],12:[function(require,module,exports){ var core = module.exports = {}; if(typeof __e == 'number')__e = core; // eslint-disable-line no-undef },{}],13:[function(require,module,exports){ // Optional / simple context binding var aFunction = require('./$.a-function'); module.exports = function(fn, that, length){ aFunction(fn); if(~length && that === undefined)return fn; switch(length){ case 1: return function(a){ return fn.call(that, a); }; case 2: return function(a, b){ return fn.call(that, a, b); }; case 3: return function(a, b, c){ return fn.call(that, a, b, c); }; } return function(/* ...args */){ return fn.apply(that, arguments); }; }; },{"./$.a-function":7}],14:[function(require,module,exports){ var global = require('./$.global') , core = require('./$.core') , hide = require('./$.hide') , $redef = require('./$.redef') , PROTOTYPE = 'prototype'; function ctx(fn, that){ return function(){ return fn.apply(that, arguments); }; } global.core = core; // type bitmap $def.F = 1; // forced $def.G = 2; // global $def.S = 4; // static $def.P = 8; // proto $def.B = 16; // bind $def.W = 32; // wrap function $def(type, name, source){ var key, own, out, exp , isGlobal = type & $def.G , isProto = type & $def.P , target = isGlobal ? global : type & $def.S ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE] , exports = isGlobal ? core : core[name] || (core[name] = {}); if(isGlobal)source = name; for(key in source){ // contains in native own = !(type & $def.F) && target && key in target; // export native or passed out = (own ? target : source)[key]; // bind timers to global for call from export context if(type & $def.B && own)exp = ctx(out, global); else exp = isProto && typeof out == 'function' ? ctx(Function.call, out) : out; // extend global if(target && !own)$redef(target, key, out); // export if(exports[key] != out)hide(exports, key, exp); if(isProto)(exports[PROTOTYPE] || (exports[PROTOTYPE] = {}))[key] = out; } } module.exports = $def; },{"./$.core":12,"./$.global":18,"./$.hide":20,"./$.redef":26}],15:[function(require,module,exports){ module.exports = function(it){ if(it == undefined)throw TypeError("Can't call method on " + it); return it; }; },{}],16:[function(require,module,exports){ var isObject = require('./$.is-object') , document = require('./$.global').document // in old IE typeof document.createElement is 'object' , is = isObject(document) && isObject(document.createElement); module.exports = function(it){ return is ? document.createElement(it) : {}; }; },{"./$.global":18,"./$.is-object":23}],17:[function(require,module,exports){ // fallback for not array-like ES3 strings var cof = require('./$.cof') , $Object = Object; module.exports = 0 in $Object('z') ? $Object : function(it){ return cof(it) == 'String' ? it.split('') : $Object(it); }; },{"./$.cof":11}],18:[function(require,module,exports){ var global = typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); module.exports = global; if(typeof __g == 'number')__g = global; // eslint-disable-line no-undef },{}],19:[function(require,module,exports){ var hasOwnProperty = {}.hasOwnProperty; module.exports = function(it, key){ return hasOwnProperty.call(it, key); }; },{}],20:[function(require,module,exports){ var $ = require('./$') , createDesc = require('./$.property-desc'); module.exports = require('./$.support-desc') ? function(object, key, value){ return $.setDesc(object, key, createDesc(1, value)); } : function(object, key, value){ object[key] = value; return object; }; },{"./$":24,"./$.property-desc":25,"./$.support-desc":28}],21:[function(require,module,exports){ module.exports = require('./$.global').document && document.documentElement; },{"./$.global":18}],22:[function(require,module,exports){ // Fast apply // http://jsperf.lnkit.com/fast-apply/5 module.exports = function(fn, args, that){ var un = that === undefined; switch(args.length){ case 0: return un ? fn() : fn.call(that); case 1: return un ? fn(args[0]) : fn.call(that, args[0]); case 2: return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]); case 3: return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]); case 4: return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]); case 5: return un ? fn(args[0], args[1], args[2], args[3], args[4]) : fn.call(that, args[0], args[1], args[2], args[3], args[4]); } return fn.apply(that, args); }; },{}],23:[function(require,module,exports){ // http://jsperf.com/core-js-isobject module.exports = function(it){ return it !== null && (typeof it == 'object' || typeof it == 'function'); }; },{}],24:[function(require,module,exports){ var $Object = Object; module.exports = { create: $Object.create, getProto: $Object.getPrototypeOf, isEnum: {}.propertyIsEnumerable, getDesc: $Object.getOwnPropertyDescriptor, setDesc: $Object.defineProperty, setDescs: $Object.defineProperties, getKeys: $Object.keys, getNames: $Object.getOwnPropertyNames, getSymbols: $Object.getOwnPropertySymbols, each: [].forEach }; },{}],25:[function(require,module,exports){ module.exports = function(bitmap, value){ return { enumerable : !(bitmap & 1), configurable: !(bitmap & 2), writable : !(bitmap & 4), value : value }; }; },{}],26:[function(require,module,exports){ var global = require('./$.global') , has = require('./$.has') , hide = require('./$.hide') , tpl = String({}.hasOwnProperty) , SRC = require('./$.uid')('src') , _toString = Function.toString; function $redef(O, key, val, safe){ if(typeof val == 'function'){ var base = O[key]; hide(val, SRC, base ? String(base) : tpl.replace(/hasOwnProperty/, String(key))); if(!('name' in val))val.name = key; } if(O === global){ O[key] = val; } else { if(!safe)delete O[key]; hide(O, key, val); } } // add fake Function#toString for correct work wrapped methods / constructors // with methods similar to LoDash isNative $redef(Function.prototype, 'toString', function toString(){ return has(this, SRC) ? this[SRC] : _toString.call(this); }); require('./$.core').inspectSource = function(it){ return _toString.call(it); }; module.exports = $redef; },{"./$.core":12,"./$.global":18,"./$.has":19,"./$.hide":20,"./$.uid":34}],27:[function(require,module,exports){ module.exports = function(regExp, replace){ var replacer = replace === Object(replace) ? function(part){ return replace[part]; } : replace; return function(it){ return String(it).replace(regExp, replacer); }; }; },{}],28:[function(require,module,exports){ // Thank's IE8 for his funny defineProperty module.exports = !!function(){ try { return Object.defineProperty({}, 'a', {get: function(){ return 2; }}).a == 2; } catch(e){ /* empty */ } }(); },{}],29:[function(require,module,exports){ module.exports = function(exec){ try { exec(); return false; } catch(e){ return true; } }; },{}],30:[function(require,module,exports){ var toInteger = require('./$.to-integer') , max = Math.max , min = Math.min; module.exports = function(index, length){ index = toInteger(index); return index < 0 ? max(index + length, 0) : min(index, length); }; },{"./$.to-integer":31}],31:[function(require,module,exports){ // 7.1.4 ToInteger var ceil = Math.ceil , floor = Math.floor; module.exports = function(it){ return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; },{}],32:[function(require,module,exports){ // 7.1.15 ToLength var toInteger = require('./$.to-integer') , min = Math.min; module.exports = function(it){ return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; },{"./$.to-integer":31}],33:[function(require,module,exports){ var ES5Object = require('./$.es5-object') , defined = require('./$.defined'); module.exports = function(it, realString){ return (realString ? Object : ES5Object)(defined(it)); }; },{"./$.defined":15,"./$.es5-object":17}],34:[function(require,module,exports){ var id = 0 , px = Math.random(); module.exports = function(key){ return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; },{}],35:[function(require,module,exports){ var $ = require('./$') , SUPPORT_DESC = require('./$.support-desc') , createDesc = require('./$.property-desc') , html = require('./$.html') , cel = require('./$.dom-create') , has = require('./$.has') , cof = require('./$.cof') , $def = require('./$.def') , invoke = require('./$.invoke') , arrayMethod = require('./$.array-methods') , IE_PROTO = require('./$.uid')('__proto__') , isObject = require('./$.is-object') , anObject = require('./$.an-object') , aFunction = require('./$.a-function') , toObject = require('./$.to-object') , toInteger = require('./$.to-integer') , toIndex = require('./$.to-index') , toLength = require('./$.to-length') , ES5Object = require('./$.es5-object') , ObjectProto = Object.prototype , A = [] , _slice = A.slice , _join = A.join , defineProperty = $.setDesc , getOwnDescriptor = $.getDesc , defineProperties = $.setDescs , IE8_DOM_DEFINE = false , $indexOf = require('./$.array-includes')(false) , $forEach = arrayMethod(0) , $map = arrayMethod(1) , $filter = arrayMethod(2) , $some = arrayMethod(3) , $every = arrayMethod(4) , factories = {} , $trim = require('./$.replacer')(/^\s*([\s\S]*\S)?\s*$/, '$1'); if(!SUPPORT_DESC){ try { IE8_DOM_DEFINE = defineProperty(cel('div'), 'x', {get: function(){ return 8; }} ).x == 8; } catch(e){ /* empty */ } $.setDesc = function(O, P, Attributes){ if(IE8_DOM_DEFINE)try { return defineProperty(O, P, Attributes); } catch(e){ /* empty */ } if('get' in Attributes || 'set' in Attributes)throw TypeError('Accessors not supported!'); if('value' in Attributes)anObject(O)[P] = Attributes.value; return O; }; $.getDesc = function(O, P){ if(IE8_DOM_DEFINE)try { return getOwnDescriptor(O, P); } catch(e){ /* empty */ } if(has(O, P))return createDesc(!ObjectProto.propertyIsEnumerable.call(O, P), O[P]); }; $.setDescs = defineProperties = function(O, Properties){ anObject(O); var keys = $.getKeys(Properties) , length = keys.length , i = 0 , P; while(length > i)$.setDesc(O, P = keys[i++], Properties[P]); return O; }; } $def($def.S + $def.F * !SUPPORT_DESC, 'Object', { // 19.1.2.6 / 15.2.3.3 Object.getOwnPropertyDescriptor(O, P) getOwnPropertyDescriptor: $.getDesc, // 19.1.2.4 / 15.2.3.6 Object.defineProperty(O, P, Attributes) defineProperty: $.setDesc, // 19.1.2.3 / 15.2.3.7 Object.defineProperties(O, Properties) defineProperties: defineProperties }); // IE 8- don't enum bug keys var keys1 = ('constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,' + 'toLocaleString,toString,valueOf').split(',') // Additional keys for getOwnPropertyNames , keys2 = keys1.concat('length', 'prototype') , keysLen1 = keys1.length; // Create object with `null` prototype: use iframe Object with cleared prototype var createDict = function(){ // Thrash, waste and sodomy: IE GC bug var iframe = cel('iframe') , i = keysLen1 , gt = '>' , iframeDocument; iframe.style.display = 'none'; html.appendChild(iframe); iframe.src = 'javascript:'; // eslint-disable-line no-script-url // createDict = iframe.contentWindow.Object; // html.removeChild(iframe); iframeDocument = iframe.contentWindow.document; iframeDocument.open(); iframeDocument.write('<script>document.F=Object</script' + gt); iframeDocument.close(); createDict = iframeDocument.F; while(i--)delete createDict.prototype[keys1[i]]; return createDict(); }; function createGetKeys(names, length){ return function(object){ var O = toObject(object) , i = 0 , result = [] , key; for(key in O)if(key != IE_PROTO)has(O, key) && result.push(key); // Don't enum bug & hidden keys while(length > i)if(has(O, key = names[i++])){ ~$indexOf(result, key) || result.push(key); } return result; }; } function Empty(){} $def($def.S, 'Object', { // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) getPrototypeOf: $.getProto = $.getProto || function(O){ O = toObject(O, true); if(has(O, IE_PROTO))return O[IE_PROTO]; if(typeof O.constructor == 'function' && O instanceof O.constructor){ return O.constructor.prototype; } return O instanceof Object ? ObjectProto : null; }, // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O) getOwnPropertyNames: $.getNames = $.getNames || createGetKeys(keys2, keys2.length, true), // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) create: $.create = $.create || function(O, /*?*/Properties){ var result; if(O !== null){ Empty.prototype = anObject(O); result = new Empty(); Empty.prototype = null; // add "__proto__" for Object.getPrototypeOf shim result[IE_PROTO] = O; } else result = createDict(); return Properties === undefined ? result : defineProperties(result, Properties); }, // 19.1.2.14 / 15.2.3.14 Object.keys(O) keys: $.getKeys = $.getKeys || createGetKeys(keys1, keysLen1, false), // 19.1.2.17 / 15.2.3.8 Object.seal(O) seal: function seal(it){ return it; // <- cap }, // 19.1.2.5 / 15.2.3.9 Object.freeze(O) freeze: function freeze(it){ return it; // <- cap }, // 19.1.2.15 / 15.2.3.10 Object.preventExtensions(O) preventExtensions: function preventExtensions(it){ return it; // <- cap }, // 19.1.2.13 / 15.2.3.11 Object.isSealed(O) isSealed: function isSealed(it){ return !isObject(it); // <- cap }, // 19.1.2.12 / 15.2.3.12 Object.isFrozen(O) isFrozen: function isFrozen(it){ return !isObject(it); // <- cap }, // 19.1.2.11 / 15.2.3.13 Object.isExtensible(O) isExtensible: function isExtensible(it){ return isObject(it); // <- cap } }); function construct(F, len, args){ if(!(len in factories)){ for(var n = [], i = 0; i < len; i++)n[i] = 'a[' + i + ']'; factories[len] = Function('F,a', 'return new F(' + n.join(',') + ')'); } return factories[len](F, args); } // 19.2.3.2 / 15.3.4.5 Function.prototype.bind(thisArg, args...) $def($def.P, 'Function', { bind: function(that /*, args... */){ var fn = aFunction(this) , partArgs = _slice.call(arguments, 1); function bound(/* args... */){ var args = partArgs.concat(_slice.call(arguments)); return this instanceof bound ? construct(fn, args.length, args) : invoke(fn, args, that); } if(isObject(fn.prototype))bound.prototype = fn.prototype; return bound; } }); // fallback for not array-like ES3 strings and DOM objects var buggySlice = true; try { if(html)_slice.call(html); buggySlice = false; } catch(e){ /* empty */ } $def($def.P + $def.F * buggySlice, 'Array', { slice: function slice(begin, end){ var len = toLength(this.length) , klass = cof(this); end = end === undefined ? len : end; if(klass == 'Array')return _slice.call(this, begin, end); var start = toIndex(begin, len) , upTo = toIndex(end, len) , size = toLength(upTo - start) , cloned = Array(size) , i = 0; for(; i < size; i++)cloned[i] = klass == 'String' ? this.charAt(start + i) : this[start + i]; return cloned; } }); $def($def.P + $def.F * (ES5Object != Object), 'Array', { join: function join(){ return _join.apply(ES5Object(this), arguments); } }); // 22.1.2.2 / 15.4.3.2 Array.isArray(arg) $def($def.S, 'Array', {isArray: function(arg){ return cof(arg) == 'Array'; }}); function createArrayReduce(isRight){ return function(callbackfn, memo){ aFunction(callbackfn); var O = toObject(this) , length = toLength(O.length) , index = isRight ? length - 1 : 0 , i = isRight ? -1 : 1; if(arguments.length < 2)for(;;){ if(index in O){ memo = O[index]; index += i; break; } index += i; if(isRight ? index < 0 : length <= index){ throw TypeError('Reduce of empty array with no initial value'); } } for(;isRight ? index >= 0 : length > index; index += i)if(index in O){ memo = callbackfn(memo, O[index], index, this); } return memo; }; } $def($def.P, 'Array', { // 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg]) forEach: $.each = $.each || function forEach(callbackfn/*, that = undefined */){ return $forEach(this, callbackfn, arguments[1]); }, // 22.1.3.15 / 15.4.4.19 Array.prototype.map(callbackfn [, thisArg]) map: function map(callbackfn/*, that = undefined */){ return $map(this, callbackfn, arguments[1]); }, // 22.1.3.7 / 15.4.4.20 Array.prototype.filter(callbackfn [, thisArg]) filter: function filter(callbackfn/*, that = undefined */){ return $filter(this, callbackfn, arguments[1]); }, // 22.1.3.23 / 15.4.4.17 Array.prototype.some(callbackfn [, thisArg]) some: function some(callbackfn/*, that = undefined */){ return $some(this, callbackfn, arguments[1]); }, // 22.1.3.5 / 15.4.4.16 Array.prototype.every(callbackfn [, thisArg]) every: function every(callbackfn/*, that = undefined */){ return $every(this, callbackfn, arguments[1]); }, // 22.1.3.18 / 15.4.4.21 Array.prototype.reduce(callbackfn [, initialValue]) reduce: createArrayReduce(false), // 22.1.3.19 / 15.4.4.22 Array.prototype.reduceRight(callbackfn [, initialValue]) reduceRight: createArrayReduce(true), // 22.1.3.11 / 15.4.4.14 Array.prototype.indexOf(searchElement [, fromIndex]) indexOf: function indexOf(el /*, fromIndex = 0 */){ return $indexOf(this, el, arguments[1]); }, // 22.1.3.14 / 15.4.4.15 Array.prototype.lastIndexOf(searchElement [, fromIndex]) lastIndexOf: function lastIndexOf(el, fromIndex /* = @[*-1] */){ var O = toObject(this) , length = toLength(O.length) , index = length - 1; if(arguments.length > 1)index = Math.min(index, toInteger(fromIndex)); if(index < 0)index = toLength(length + index); for(;index >= 0; index--)if(index in O)if(O[index] === el)return index; return -1; } }); // 21.1.3.25 / 15.5.4.20 String.prototype.trim() $def($def.P, 'String', {trim: function trim(){ return $trim(this); }}); // 20.3.3.1 / 15.9.4.4 Date.now() $def($def.S, 'Date', {now: function now(){ return +new Date; }}); function lz(num){ return num > 9 ? num : '0' + num; } // 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString() // PhantomJS and old webkit had a broken Date implementation. var date = new Date(-5e13 - 1) , brokenDate = !(date.toISOString && date.toISOString() == '0385-07-25T07:06:39.999Z' && require('./$.throws')(function(){ new Date(NaN).toISOString(); })); $def($def.P + $def.F * brokenDate, 'Date', { toISOString: function toISOString(){ if(!isFinite(this))throw RangeError('Invalid time value'); var d = this , y = d.getUTCFullYear() , m = d.getUTCMilliseconds() , s = y < 0 ? '-' : y > 9999 ? '+' : ''; return s + ('00000' + Math.abs(y)).slice(s ? -6 : -4) + '-' + lz(d.getUTCMonth() + 1) + '-' + lz(d.getUTCDate()) + 'T' + lz(d.getUTCHours()) + ':' + lz(d.getUTCMinutes()) + ':' + lz(d.getUTCSeconds()) + '.' + (m > 99 ? m : '0' + lz(m)) + 'Z'; } }); },{"./$":24,"./$.a-function":7,"./$.an-object":8,"./$.array-includes":9,"./$.array-methods":10,"./$.cof":11,"./$.def":14,"./$.dom-create":16,"./$.es5-object":17,"./$.has":19,"./$.html":21,"./$.invoke":22,"./$.is-object":23,"./$.property-desc":25,"./$.replacer":27,"./$.support-desc":28,"./$.throws":29,"./$.to-index":30,"./$.to-integer":31,"./$.to-length":32,"./$.to-object":33,"./$.uid":34}],36:[function(require,module,exports){ /** * Module dependencies. */ var extend = require('extend'); var encode = require('ent/encode'); var CustomEvent = require('custom-event'); var voidElements = require('void-elements').reduce(function (obj, name) { obj[name] = true; return obj; }, {}); /** * Module exports. */ exports = module.exports = serialize; exports.serializeElement = serializeElement; exports.serializeAttribute = serializeAttribute; exports.serializeText = serializeText; exports.serializeComment = serializeComment; exports.serializeDocument = serializeDocument; exports.serializeDoctype = serializeDoctype; exports.serializeDocumentFragment = serializeDocumentFragment; exports.serializeNodeList = serializeNodeList; /** * Serializes any DOM node. Returns a string. * * @param {Node} node - DOM Node to serialize * @param {String} [context] - optional arbitrary "context" string to use (useful for event listeners) * @param {Function} [fn] - optional callback function to use in the "serialize" event for this call * @param {EventTarget} [eventTarget] - optional EventTarget instance to emit the "serialize" event on (defaults to `node`) * return {String} * @public */ function serialize (node, context, fn, eventTarget) { if (!node) return ''; if ('function' === typeof context) { fn = context; context = null; } if (!context) context = null; var rtn; var nodeType = node.nodeType; if (!nodeType && 'number' === typeof node.length) { // assume it's a NodeList or Array of Nodes rtn = exports.serializeNodeList(node, context, fn); } else { if ('function' === typeof fn) { // one-time "serialize" event listener node.addEventListener('serialize', fn, false); } // emit a custom "serialize" event on `node`, in case there // are event listeners for custom serialization of this node var e = new CustomEvent('serialize', { bubbles: true, cancelable: true, detail: { serialize: null, context: context } }); e.serializeTarget = node; var target = eventTarget || node; var cancelled = !target.dispatchEvent(e); // `e.detail.serialize` can be set to a: // String - returned directly // Node - goes through serializer logic instead of `node` // Anything else - get Stringified first, and then returned directly var s = e.detail.serialize; if (s != null) { if ('string' === typeof s) { rtn = s; } else if ('number' === typeof s.nodeType) { // make it go through the serialization logic rtn = serialize(s, context, null, target); } else { rtn = String(s); } } else if (!cancelled) { // default serialization logic switch (nodeType) { case 1 /* element */: rtn = exports.serializeElement(node, context, eventTarget); break; case 2 /* attribute */: rtn = exports.serializeAttribute(node); break; case 3 /* text */: rtn = exports.serializeText(node); break; case 8 /* comment */: rtn = exports.serializeComment(node); break; case 9 /* document */: rtn = exports.serializeDocument(node, context, eventTarget); break; case 10 /* doctype */: rtn = exports.serializeDoctype(node); break; case 11 /* document fragment */: rtn = exports.serializeDocumentFragment(node, context, eventTarget); break; } } if ('function' === typeof fn) { node.removeEventListener('serialize', fn, false); } } return rtn || ''; } /** * Serialize an Attribute node. */ function serializeAttribute (node, opts) { return node.name + '="' + encode(node.value, extend({ named: true }, opts)) + '"'; } /** * Serialize a DOM element. */ function serializeElement (node, context, eventTarget) { var c, i, l; var name = node.nodeName.toLowerCase(); // opening tag var r = '<' + name; // attributes for (i = 0, c = node.attributes, l = c.length; i < l; i++) { r += ' ' + exports.serializeAttribute(c[i]); } r += '>'; // child nodes r += exports.serializeNodeList(node.childNodes, context, null, eventTarget); // closing tag, only for non-void elements if (!voidElements[name]) { r += '</' + name + '>'; } return r; } /** * Serialize a text node. */ function serializeText (node, opts) { return encode(node.nodeValue, extend({ named: true, special: { '<': true, '>': true, '&': true } }, opts)); } /** * Serialize a comment node. */ function serializeComment (node) { return '<!--' + node.nodeValue + '-->'; } /** * Serialize a Document node. */ function serializeDocument (node, context, eventTarget) { return exports.serializeNodeList(node.childNodes, context, null, eventTarget); } /** * Serialize a DOCTYPE node. * See: http://stackoverflow.com/a/10162353 */ function serializeDoctype (node) { var r = '<!DOCTYPE ' + node.name; if (node.publicId) { r += ' PUBLIC "' + node.publicId + '"'; } if (!node.publicId && node.systemId) { r += ' SYSTEM'; } if (node.systemId) { r += ' "' + node.systemId + '"'; } r += '>'; return r; } /** * Serialize a DocumentFragment instance. */ function serializeDocumentFragment (node, context, eventTarget) { return exports.serializeNodeList(node.childNodes, context, null, eventTarget); } /** * Serialize a NodeList/Array of nodes. */ function serializeNodeList (list, context, fn, eventTarget) { var r = ''; for (var i = 0, l = list.length; i < l; i++) { r += serialize(list[i], context, fn, eventTarget); } return r; } },{"custom-event":37,"ent/encode":38,"extend":40,"void-elements":41}],37:[function(require,module,exports){ (function (global){ var NativeCustomEvent = global.CustomEvent; function useNative () { try { var p = new NativeCustomEvent('cat', { detail: { foo: 'bar' } }); return 'cat' === p.type && 'bar' === p.detail.foo; } catch (e) { } return false; } /** * Cross-browser `CustomEvent` constructor. * * https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent.CustomEvent * * @public */ module.exports = useNative() ? NativeCustomEvent : // IE >= 9 'function' === typeof document.createEvent ? function CustomEvent (type, params) { var e = document.createEvent('CustomEvent'); if (params) { e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail); } else { e.initCustomEvent(type, false, false, void 0); } return e; } : // IE <= 8 function CustomEvent (type, params) { var e = document.createEventObject(); e.type = type; if (params) { e.bubbles = Boolean(params.bubbles); e.cancelable = Boolean(params.cancelable); e.detail = params.detail; } else { e.bubbles = false; e.cancelable = false; e.detail = void 0; } return e; } }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],38:[function(require,module,exports){ var punycode = require('punycode'); var revEntities = require('./reversed.json'); module.exports = encode; function encode (str, opts) { if (typeof str !== 'string') { throw new TypeError('Expected a String'); } if (!opts) opts = {}; var numeric = true; if (opts.named) numeric = false; if (opts.numeric !== undefined) numeric = opts.numeric; var special = opts.special || { '"': true, "'": true, '<': true, '>': true, '&': true }; var codePoints = punycode.ucs2.decode(str); var chars = []; for (var i = 0; i < codePoints.length; i++) { var cc = codePoints[i]; var c = punycode.ucs2.encode([ cc ]); var e = revEntities[cc]; if (e && (cc >= 127 || special[c]) && !numeric) { chars.push('&' + (/;$/.test(e) ? e : e + ';')); } else if (cc < 32 || cc >= 127 || special[c]) { chars.push('&#' + cc + ';'); } else { chars.push(c); } } return chars.join(''); } },{"./reversed.json":39,"punycode":42}],39:[function(require,module,exports){ module.exports={ "9": "Tab;", "10": "NewLine;", "33": "excl;", "34": "quot;", "35": "num;", "36": "dollar;", "37": "percnt;", "38": "amp;", "39": "apos;", "40": "lpar;", "41": "rpar;", "42": "midast;", "43": "plus;", "44": "comma;", "46": "period;", "47": "sol;", "58": "colon;", "59": "semi;", "60": "lt;", "61": "equals;", "62": "gt;", "63": "quest;", "64": "commat;", "91": "lsqb;", "92": "bsol;", "93": "rsqb;", "94": "Hat;", "95": "UnderBar;", "96": "grave;", "123": "lcub;", "124": "VerticalLine;", "125": "rcub;", "160": "NonBreakingSpace;", "161": "iexcl;", "162": "cent;", "163": "pound;", "164": "curren;", "165": "yen;", "166": "brvbar;", "167": "sect;", "168": "uml;", "169": "copy;", "170": "ordf;", "171": "laquo;", "172": "not;", "173": "shy;", "174": "reg;", "175": "strns;", "176": "deg;", "177": "pm;", "178": "sup2;", "179": "sup3;", "180": "DiacriticalAcute;", "181": "micro;", "182": "para;", "183": "middot;", "184": "Cedilla;", "185": "sup1;", "186": "ordm;", "187": "raquo;", "188": "frac14;", "189": "half;", "190": "frac34;", "191": "iquest;", "192": "Agrave;", "193": "Aacute;", "194": "Acirc;", "195": "Atilde;", "196": "Auml;", "197": "Aring;", "198": "AElig;", "199": "Ccedil;", "200": "Egrave;", "201": "Eacute;", "202": "Ecirc;", "203": "Euml;", "204": "Igrave;", "205": "Iacute;", "206": "Icirc;", "207": "Iuml;", "208": "ETH;", "209": "Ntilde;", "210": "Ograve;", "211": "Oacute;", "212": "Ocirc;", "213": "Otilde;", "214": "Ouml;", "215": "times;", "216": "Oslash;", "217": "Ugrave;", "218": "Uacute;", "219": "Ucirc;", "220": "Uuml;", "221": "Yacute;", "222": "THORN;", "223": "szlig;", "224": "agrave;", "225": "aacute;", "226": "acirc;", "227": "atilde;", "228": "auml;", "229": "aring;", "230": "aelig;", "231": "ccedil;", "232": "egrave;", "233": "eacute;", "234": "ecirc;", "235": "euml;", "236": "igrave;", "237": "iacute;", "238": "icirc;", "239": "iuml;", "240": "eth;", "241": "ntilde;", "242": "ograve;", "243": "oacute;", "244": "ocirc;", "245": "otilde;", "246": "ouml;", "247": "divide;", "248": "oslash;", "249": "ugrave;", "250": "uacute;", "251": "ucirc;", "252": "uuml;", "253": "yacute;", "254": "thorn;", "255": "yuml;", "256": "Amacr;", "257": "amacr;", "258": "Abreve;", "259": "abreve;", "260": "Aogon;", "261": "aogon;", "262": "Cacute;", "263": "cacute;", "264": "Ccirc;", "265": "ccirc;", "266": "Cdot;", "267": "cdot;", "268": "Ccaron;", "269": "ccaron;", "270": "Dcaron;", "271": "dcaron;", "272": "Dstrok;", "273": "dstrok;", "274": "Emacr;", "275": "emacr;", "278": "Edot;", "279": "edot;", "280": "Eogon;", "281": "eogon;", "282": "Ecaron;", "283": "ecaron;", "284": "Gcirc;", "285": "gcirc;", "286": "Gbreve;", "287": "gbreve;", "288": "Gdot;", "289": "gdot;", "290": "Gcedil;", "292": "Hcirc;", "293": "hcirc;", "294": "Hstrok;", "295": "hstrok;", "296": "Itilde;", "297": "itilde;", "298": "Imacr;", "299": "imacr;", "302": "Iogon;", "303": "iogon;", "304": "Idot;", "305": "inodot;", "306": "IJlig;", "307": "ijlig;", "308": "Jcirc;", "309": "jcirc;", "310": "Kcedil;", "311": "kcedil;", "312": "kgreen;", "313": "Lacute;", "314": "lacute;", "315": "Lcedil;", "316": "lcedil;", "317": "Lcaron;", "318": "lcaron;", "319": "Lmidot;", "320": "lmidot;", "321": "Lstrok;", "322": "lstrok;", "323": "Nacute;", "324": "nacute;", "325": "Ncedil;", "326": "ncedil;", "327": "Ncaron;", "328": "ncaron;", "329": "napos;", "330": "ENG;", "331": "eng;", "332": "Omacr;", "333": "omacr;", "336": "Odblac;", "337": "odblac;", "338": "OElig;", "339": "oelig;", "340": "Racute;", "341": "racute;", "342": "Rcedil;", "343": "rcedil;", "344": "Rcaron;", "345": "rcaron;", "346": "Sacute;", "347": "sacute;", "348": "Scirc;", "349": "scirc;", "350": "Scedil;", "351": "scedil;", "352": "Scaron;", "353": "scaron;", "354": "Tcedil;", "355": "tcedil;", "356": "Tcaron;", "357": "tcaron;", "358": "Tstrok;", "359": "tstrok;", "360": "Utilde;", "361": "utilde;", "362": "Umacr;", "363": "umacr;", "364": "Ubreve;", "365": "ubreve;", "366": "Uring;", "367": "uring;", "368": "Udblac;", "369": "udblac;", "370": "Uogon;", "371": "uogon;", "372": "Wcirc;", "373": "wcirc;", "374": "Ycirc;", "375": "ycirc;", "376": "Yuml;", "377": "Zacute;", "378": "zacute;", "379": "Zdot;", "380": "zdot;", "381": "Zcaron;", "382": "zcaron;", "402": "fnof;", "437": "imped;", "501": "gacute;", "567": "jmath;", "710": "circ;", "711": "Hacek;", "728": "breve;", "729": "dot;", "730": "ring;", "731": "ogon;", "732": "tilde;", "733": "DiacriticalDoubleAcute;", "785": "DownBreve;", "913": "Alpha;", "914": "Beta;", "915": "Gamma;", "916": "Delta;", "917": "Epsilon;", "918": "Zeta;", "919": "Eta;", "920": "Theta;", "921": "Iota;", "922": "Kappa;", "923": "Lambda;", "924": "Mu;", "925": "Nu;", "926": "Xi;", "927": "Omicron;", "928": "Pi;", "929": "Rho;", "931": "Sigma;", "932": "Tau;", "933": "Upsilon;", "934": "Phi;", "935": "Chi;", "936": "Psi;", "937": "Omega;", "945": "alpha;", "946": "beta;", "947": "gamma;", "948": "delta;", "949": "epsilon;", "950": "zeta;", "951": "eta;", "952": "theta;", "953": "iota;", "954": "kappa;", "955": "lambda;", "956": "mu;", "957": "nu;", "958": "xi;", "959": "omicron;", "960": "pi;", "961": "rho;", "962": "varsigma;", "963": "sigma;", "964": "tau;", "965": "upsilon;", "966": "phi;",