Skip to content

Instantly share code, notes, and snippets.

@jpnelson
Created July 26, 2016 04:40
Show Gist options
  • Save jpnelson/03c6a70b30817f403e79999aac3fc879 to your computer and use it in GitHub Desktop.
Save jpnelson/03c6a70b30817f403e79999aac3fc879 to your computer and use it in GitHub Desktop.
For sandboxes like codepen. {"es6-map": "^0.1.4", "skatejs-named-slots": "^0.2.10", "webcomponents.js": "webcomponents/webcomponentsjs#b77ca74"}
!function(root, factory) {
"object" == typeof exports && "object" == typeof module ? module.exports = factory(require("d"), require("event-emitter"), require("es6-symbol"), require("es6-iterator")) : "function" == typeof define && define.amd ? define([ "d", "event-emitter", "es6-symbol", "es6-iterator" ], factory) : "object" == typeof exports ? exports.akutilPolyfills = factory(require("d"), require("event-emitter"), require("es6-symbol"), require("es6-iterator")) : root.akutilPolyfills = factory(root.d, root["event-emitter"], root["es6-symbol"], root["es6-iterator"]);
}(this, function(__WEBPACK_EXTERNAL_MODULE_19__, __WEBPACK_EXTERNAL_MODULE_20__, __WEBPACK_EXTERNAL_MODULE_21__, __WEBPACK_EXTERNAL_MODULE_46__) {
/******/
return function(modules) {
/******/
/******/
// The require function
/******/
function __webpack_require__(moduleId) {
/******/
/******/
// Check if module is in cache
/******/
if (installedModules[moduleId]) /******/
return installedModules[moduleId].exports;
/******/
/******/
// Create a new module (and put it into the cache)
/******/
var module = installedModules[moduleId] = {
/******/
exports: {},
/******/
id: moduleId,
/******/
loaded: !1
};
/******/
/******/
// Return the exports of the module
/******/
/******/
/******/
// Execute the module function
/******/
/******/
/******/
// Flag the module as loaded
/******/
return modules[moduleId].call(module.exports, module, module.exports, __webpack_require__),
module.loaded = !0, module.exports;
}
// webpackBootstrap
/******/
// The module cache
/******/
var installedModules = {};
/******/
/******/
// Load entry module and return exports
/******/
/******/
/******/
/******/
// expose the modules object (__webpack_modules__)
/******/
/******/
/******/
// expose the module cache
/******/
/******/
/******/
// __webpack_public_path__
/******/
return __webpack_require__.m = modules, __webpack_require__.c = installedModules,
__webpack_require__.p = "", __webpack_require__(0);
}([ /* 0 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
__webpack_require__(1), __webpack_require__(50), __webpack_require__(51), __webpack_require__(52),
__webpack_require__(53);
}, /* 1 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
__webpack_require__(2)() || Object.defineProperty(__webpack_require__(3), "Map", {
value: __webpack_require__(4),
configurable: !0,
enumerable: !1,
writable: !0
});
}, /* 2 */
/***/
function(module, exports) {
"use strict";
module.exports = function() {
var map, iterator, result;
if ("function" != typeof Map) return !1;
try {
// WebKit doesn't support arguments and crashes
map = new Map([ [ "raz", "one" ], [ "dwa", "two" ], [ "trzy", "three" ] ]);
} catch (e) {
return !1;
}
return "[object Map]" === String(map) && (3 === map.size && ("function" == typeof map.clear && ("function" == typeof map["delete"] && ("function" == typeof map.entries && ("function" == typeof map.forEach && ("function" == typeof map.get && ("function" == typeof map.has && ("function" == typeof map.keys && ("function" == typeof map.set && ("function" == typeof map.values && (iterator = map.entries(),
result = iterator.next(), result.done === !1 && (!!result.value && ("raz" === result.value[0] && "one" === result.value[1])))))))))))));
};
}, /* 3 */
/***/
function(module, exports) {
"use strict";
module.exports = new Function("return this")();
}, /* 4 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var MapPoly, clear = __webpack_require__(5), eIndexOf = __webpack_require__(7), setPrototypeOf = __webpack_require__(13), callable = __webpack_require__(18), validValue = __webpack_require__(6), d = __webpack_require__(19), ee = __webpack_require__(20), Symbol = __webpack_require__(21), iterator = __webpack_require__(22), forOf = __webpack_require__(26), Iterator = __webpack_require__(45), isNative = __webpack_require__(49), call = Function.prototype.call, defineProperties = Object.defineProperties, getPrototypeOf = Object.getPrototypeOf;
module.exports = MapPoly = function() {
var keys, values, self, iterable = arguments[0];
if (!(this instanceof MapPoly)) throw new TypeError("Constructor requires 'new'");
return self = isNative && setPrototypeOf && Map !== MapPoly ? setPrototypeOf(new Map(), getPrototypeOf(this)) : this,
null != iterable && iterator(iterable), defineProperties(self, {
__mapKeysData__: d("c", keys = []),
__mapValuesData__: d("c", values = [])
}), iterable ? (forOf(iterable, function(value) {
var key = validValue(value)[0];
value = value[1], eIndexOf.call(keys, key) === -1 && (keys.push(key), values.push(value));
}, self), self) : self;
}, isNative && (setPrototypeOf && setPrototypeOf(MapPoly, Map), MapPoly.prototype = Object.create(Map.prototype, {
constructor: d(MapPoly)
})), ee(defineProperties(MapPoly.prototype, {
clear: d(function() {
this.__mapKeysData__.length && (clear.call(this.__mapKeysData__), clear.call(this.__mapValuesData__),
this.emit("_clear"));
}),
"delete": d(function(key) {
var index = eIndexOf.call(this.__mapKeysData__, key);
return index !== -1 && (this.__mapKeysData__.splice(index, 1), this.__mapValuesData__.splice(index, 1),
this.emit("_delete", index, key), !0);
}),
entries: d(function() {
return new Iterator(this, "key+value");
}),
forEach: d(function(cb) {
var iterator, result, thisArg = arguments[1];
for (callable(cb), iterator = this.entries(), result = iterator._next(); void 0 !== result; ) call.call(cb, thisArg, this.__mapValuesData__[result], this.__mapKeysData__[result], this),
result = iterator._next();
}),
get: d(function(key) {
var index = eIndexOf.call(this.__mapKeysData__, key);
if (index !== -1) return this.__mapValuesData__[index];
}),
has: d(function(key) {
return eIndexOf.call(this.__mapKeysData__, key) !== -1;
}),
keys: d(function() {
return new Iterator(this, "key");
}),
set: d(function(key, value) {
var emit, index = eIndexOf.call(this.__mapKeysData__, key);
return index === -1 && (index = this.__mapKeysData__.push(key) - 1, emit = !0),
this.__mapValuesData__[index] = value, emit && this.emit("_add", index, key), this;
}),
size: d.gs(function() {
return this.__mapKeysData__.length;
}),
values: d(function() {
return new Iterator(this, "value");
}),
toString: d(function() {
return "[object Map]";
})
})), Object.defineProperty(MapPoly.prototype, Symbol.iterator, d(function() {
return this.entries();
})), Object.defineProperty(MapPoly.prototype, Symbol.toStringTag, d("c", "Map"));
}, /* 5 */
/***/
function(module, exports, __webpack_require__) {
// Inspired by Google Closure:
// http://closure-library.googlecode.com/svn/docs/
// closure_goog_array_array.js.html#goog.array.clear
"use strict";
var value = __webpack_require__(6);
module.exports = function() {
return value(this).length = 0, this;
};
}, /* 6 */
/***/
function(module, exports) {
"use strict";
module.exports = function(value) {
if (null == value) throw new TypeError("Cannot use null or undefined");
return value;
};
}, /* 7 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var toPosInt = __webpack_require__(8), value = __webpack_require__(6), indexOf = Array.prototype.indexOf, hasOwnProperty = Object.prototype.hasOwnProperty, abs = Math.abs, floor = Math.floor;
module.exports = function(searchElement) {
var i, l, fromIndex, val;
if (searchElement === searchElement) //jslint: ignore
return indexOf.apply(this, arguments);
for (l = toPosInt(value(this).length), fromIndex = arguments[1], fromIndex = isNaN(fromIndex) ? 0 : fromIndex >= 0 ? floor(fromIndex) : toPosInt(this.length) - floor(abs(fromIndex)),
i = fromIndex; i < l; ++i) if (hasOwnProperty.call(this, i) && (val = this[i], val !== val)) return i;
return -1;
};
}, /* 8 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var toInteger = __webpack_require__(9), max = Math.max;
module.exports = function(value) {
return max(0, toInteger(value));
};
}, /* 9 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var sign = __webpack_require__(10), abs = Math.abs, floor = Math.floor;
module.exports = function(value) {
return isNaN(value) ? 0 : (value = Number(value), 0 !== value && isFinite(value) ? sign(value) * floor(abs(value)) : value);
};
}, /* 10 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(11)() ? Math.sign : __webpack_require__(12);
}, /* 11 */
/***/
function(module, exports) {
"use strict";
module.exports = function() {
var sign = Math.sign;
return "function" == typeof sign && (1 === sign(10) && sign(-20) === -1);
};
}, /* 12 */
/***/
function(module, exports) {
"use strict";
module.exports = function(value) {
return value = Number(value), isNaN(value) || 0 === value ? value : value > 0 ? 1 : -1;
};
}, /* 13 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(14)() ? Object.setPrototypeOf : __webpack_require__(15);
}, /* 14 */
/***/
function(module, exports) {
"use strict";
var create = Object.create, getPrototypeOf = Object.getPrototypeOf, x = {};
module.exports = function() {
var setPrototypeOf = Object.setPrototypeOf, customCreate = arguments[0] || create;
return "function" == typeof setPrototypeOf && getPrototypeOf(setPrototypeOf(customCreate(null), x)) === x;
};
}, /* 15 */
/***/
function(module, exports, __webpack_require__) {
// Big thanks to @WebReflection for sorting this out
// https://gist.github.com/WebReflection/5593554
"use strict";
var validate, isObject = __webpack_require__(16), value = __webpack_require__(6), isPrototypeOf = Object.prototype.isPrototypeOf, defineProperty = Object.defineProperty, nullDesc = {
configurable: !0,
enumerable: !1,
writable: !0,
value: void 0
};
validate = function(obj, prototype) {
if (value(obj), null === prototype || isObject(prototype)) return obj;
throw new TypeError("Prototype must be null or an object");
}, module.exports = function(status) {
var fn, set;
return status ? (2 === status.level ? status.set ? (set = status.set, fn = function(obj, prototype) {
return set.call(validate(obj, prototype), prototype), obj;
}) : fn = function(obj, prototype) {
return validate(obj, prototype).__proto__ = prototype, obj;
} : fn = function self(obj, prototype) {
var isNullBase;
return validate(obj, prototype), isNullBase = isPrototypeOf.call(self.nullPolyfill, obj),
isNullBase && delete self.nullPolyfill.__proto__, null === prototype && (prototype = self.nullPolyfill),
obj.__proto__ = prototype, isNullBase && defineProperty(self.nullPolyfill, "__proto__", nullDesc),
obj;
}, Object.defineProperty(fn, "level", {
configurable: !1,
enumerable: !1,
writable: !1,
value: status.level
})) : null;
}(function() {
var set, x = Object.create(null), y = {}, desc = Object.getOwnPropertyDescriptor(Object.prototype, "__proto__");
if (desc) {
try {
set = desc.set, // Opera crashes at this point
set.call(x, y);
} catch (ignore) {}
if (Object.getPrototypeOf(x) === y) return {
set: set,
level: 2
};
}
return x.__proto__ = y, Object.getPrototypeOf(x) === y ? {
level: 2
} : (x = {}, x.__proto__ = y, Object.getPrototypeOf(x) === y && {
level: 1
});
}()), __webpack_require__(17);
}, /* 16 */
/***/
function(module, exports) {
"use strict";
var map = {
"function": !0,
object: !0
};
module.exports = function(x) {
return null != x && map[typeof x] || !1;
};
}, /* 17 */
/***/
function(module, exports, __webpack_require__) {
// Workaround for http://code.google.com/p/v8/issues/detail?id=2804
"use strict";
var shim, create = Object.create;
__webpack_require__(14)() || (shim = __webpack_require__(15)), module.exports = function() {
var nullObject, props, desc;
return shim ? 1 !== shim.level ? create : (nullObject = {}, props = {}, desc = {
configurable: !1,
enumerable: !1,
writable: !0,
value: void 0
}, Object.getOwnPropertyNames(Object.prototype).forEach(function(name) {
return "__proto__" === name ? void (props[name] = {
configurable: !0,
enumerable: !1,
writable: !0,
value: void 0
}) : void (props[name] = desc);
}), Object.defineProperties(nullObject, props), Object.defineProperty(shim, "nullPolyfill", {
configurable: !1,
enumerable: !1,
writable: !1,
value: nullObject
}), function(prototype, props) {
return create(null === prototype ? nullObject : prototype, props);
}) : create;
}();
}, /* 18 */
/***/
function(module, exports) {
"use strict";
module.exports = function(fn) {
if ("function" != typeof fn) throw new TypeError(fn + " is not a function");
return fn;
};
}, /* 19 */
/***/
function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_19__;
}, /* 20 */
/***/
function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_20__;
}, /* 21 */
/***/
function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_21__;
}, /* 22 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var isIterable = __webpack_require__(23);
module.exports = function(value) {
if (!isIterable(value)) throw new TypeError(value + " is not iterable");
return value;
};
}, /* 23 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var isArguments = __webpack_require__(24), isString = __webpack_require__(25), iteratorSymbol = __webpack_require__(21).iterator, isArray = Array.isArray;
module.exports = function(value) {
return null != value && (!!isArray(value) || (!!isString(value) || (!!isArguments(value) || "function" == typeof value[iteratorSymbol])));
};
}, /* 24 */
/***/
function(module, exports) {
"use strict";
var toString = Object.prototype.toString, id = toString.call(function() {
return arguments;
}());
module.exports = function(x) {
return toString.call(x) === id;
};
}, /* 25 */
/***/
function(module, exports) {
"use strict";
var toString = Object.prototype.toString, id = toString.call("");
module.exports = function(x) {
return "string" == typeof x || x && "object" == typeof x && (x instanceof String || toString.call(x) === id) || !1;
};
}, /* 26 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var isArguments = __webpack_require__(24), callable = __webpack_require__(18), isString = __webpack_require__(25), get = __webpack_require__(27), isArray = Array.isArray, call = Function.prototype.call, some = Array.prototype.some;
module.exports = function(iterable, cb) {
var mode, result, doBreak, broken, i, l, char, code, thisArg = arguments[2];
if (isArray(iterable) || isArguments(iterable) ? mode = "array" : isString(iterable) ? mode = "string" : iterable = get(iterable),
callable(cb), doBreak = function() {
broken = !0;
}, "array" === mode) return void some.call(iterable, function(value) {
if (call.call(cb, thisArg, value, doBreak), broken) return !0;
});
if ("string" !== mode) for (result = iterable.next(); !result.done; ) {
if (call.call(cb, thisArg, result.value, doBreak), broken) return;
result = iterable.next();
} else for (l = iterable.length, i = 0; i < l && (char = iterable[i], i + 1 < l && (code = char.charCodeAt(0),
code >= 55296 && code <= 56319 && (char += iterable[++i])), call.call(cb, thisArg, char, doBreak),
!broken); ++i) ;
};
}, /* 27 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var isArguments = __webpack_require__(24), isString = __webpack_require__(25), ArrayIterator = __webpack_require__(28), StringIterator = __webpack_require__(44), iterable = __webpack_require__(22), iteratorSymbol = __webpack_require__(21).iterator;
module.exports = function(obj) {
return "function" == typeof iterable(obj)[iteratorSymbol] ? obj[iteratorSymbol]() : isArguments(obj) ? new ArrayIterator(obj) : isString(obj) ? new StringIterator(obj) : new ArrayIterator(obj);
};
}, /* 28 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var ArrayIterator, setPrototypeOf = __webpack_require__(13), contains = __webpack_require__(29), d = __webpack_require__(19), Iterator = __webpack_require__(32), defineProperty = Object.defineProperty;
ArrayIterator = module.exports = function(arr, kind) {
return this instanceof ArrayIterator ? (Iterator.call(this, arr), kind = kind ? contains.call(kind, "key+value") ? "key+value" : contains.call(kind, "key") ? "key" : "value" : "value",
void defineProperty(this, "__kind__", d("", kind))) : new ArrayIterator(arr, kind);
}, setPrototypeOf && setPrototypeOf(ArrayIterator, Iterator), ArrayIterator.prototype = Object.create(Iterator.prototype, {
constructor: d(ArrayIterator),
_resolve: d(function(i) {
return "value" === this.__kind__ ? this.__list__[i] : "key+value" === this.__kind__ ? [ i, this.__list__[i] ] : i;
}),
toString: d(function() {
return "[object Array Iterator]";
})
});
}, /* 29 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(30)() ? String.prototype.contains : __webpack_require__(31);
}, /* 30 */
/***/
function(module, exports) {
"use strict";
var str = "razdwatrzy";
module.exports = function() {
return "function" == typeof str.contains && (str.contains("dwa") === !0 && str.contains("foo") === !1);
};
}, /* 31 */
/***/
function(module, exports) {
"use strict";
var indexOf = String.prototype.indexOf;
module.exports = function(searchString) {
return indexOf.call(this, searchString, arguments[1]) > -1;
};
}, /* 32 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var Iterator, clear = __webpack_require__(5), assign = __webpack_require__(33), callable = __webpack_require__(18), value = __webpack_require__(6), d = __webpack_require__(19), autoBind = __webpack_require__(39), Symbol = __webpack_require__(21), defineProperty = Object.defineProperty, defineProperties = Object.defineProperties;
module.exports = Iterator = function(list, context) {
return this instanceof Iterator ? (defineProperties(this, {
__list__: d("w", value(list)),
__context__: d("w", context),
__nextIndex__: d("w", 0)
}), void (context && (callable(context.on), context.on("_add", this._onAdd), context.on("_delete", this._onDelete),
context.on("_clear", this._onClear)))) : new Iterator(list, context);
}, defineProperties(Iterator.prototype, assign({
constructor: d(Iterator),
_next: d(function() {
var i;
if (this.__list__) return this.__redo__ && (i = this.__redo__.shift(), void 0 !== i) ? i : this.__nextIndex__ < this.__list__.length ? this.__nextIndex__++ : void this._unBind();
}),
next: d(function() {
return this._createResult(this._next());
}),
_createResult: d(function(i) {
return void 0 === i ? {
done: !0,
value: void 0
} : {
done: !1,
value: this._resolve(i)
};
}),
_resolve: d(function(i) {
return this.__list__[i];
}),
_unBind: d(function() {
this.__list__ = null, delete this.__redo__, this.__context__ && (this.__context__.off("_add", this._onAdd),
this.__context__.off("_delete", this._onDelete), this.__context__.off("_clear", this._onClear),
this.__context__ = null);
}),
toString: d(function() {
return "[object Iterator]";
})
}, autoBind({
_onAdd: d(function(index) {
if (!(index >= this.__nextIndex__)) {
if (++this.__nextIndex__, !this.__redo__) return void defineProperty(this, "__redo__", d("c", [ index ]));
this.__redo__.forEach(function(redo, i) {
redo >= index && (this.__redo__[i] = ++redo);
}, this), this.__redo__.push(index);
}
}),
_onDelete: d(function(index) {
var i;
index >= this.__nextIndex__ || (--this.__nextIndex__, this.__redo__ && (i = this.__redo__.indexOf(index),
i !== -1 && this.__redo__.splice(i, 1), this.__redo__.forEach(function(redo, i) {
redo > index && (this.__redo__[i] = --redo);
}, this)));
}),
_onClear: d(function() {
this.__redo__ && clear.call(this.__redo__), this.__nextIndex__ = 0;
})
}))), defineProperty(Iterator.prototype, Symbol.iterator, d(function() {
return this;
})), defineProperty(Iterator.prototype, Symbol.toStringTag, d("", "Iterator"));
}, /* 33 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(34)() ? Object.assign : __webpack_require__(35);
}, /* 34 */
/***/
function(module, exports) {
"use strict";
module.exports = function() {
var obj, assign = Object.assign;
return "function" == typeof assign && (obj = {
foo: "raz"
}, assign(obj, {
bar: "dwa"
}, {
trzy: "trzy"
}), obj.foo + obj.bar + obj.trzy === "razdwatrzy");
};
}, /* 35 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var keys = __webpack_require__(36), value = __webpack_require__(6), max = Math.max;
module.exports = function(dest, src) {
var error, i, assign, l = max(arguments.length, 2);
for (dest = Object(value(dest)), assign = function(key) {
try {
dest[key] = src[key];
} catch (e) {
error || (error = e);
}
}, i = 1; i < l; ++i) src = arguments[i], keys(src).forEach(assign);
if (void 0 !== error) throw error;
return dest;
};
}, /* 36 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(37)() ? Object.keys : __webpack_require__(38);
}, /* 37 */
/***/
function(module, exports) {
"use strict";
module.exports = function() {
try {
return Object.keys("primitive"), !0;
} catch (e) {
return !1;
}
};
}, /* 38 */
/***/
function(module, exports) {
"use strict";
var keys = Object.keys;
module.exports = function(object) {
return keys(null == object ? object : Object(object));
};
}, /* 39 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var define, copy = __webpack_require__(40), map = __webpack_require__(41), callable = __webpack_require__(18), validValue = __webpack_require__(6), bind = Function.prototype.bind, defineProperty = Object.defineProperty, hasOwnProperty = Object.prototype.hasOwnProperty;
define = function(name, desc, bindTo) {
var dgs, value = validValue(desc) && callable(desc.value);
return dgs = copy(desc), delete dgs.writable, delete dgs.value, dgs.get = function() {
return hasOwnProperty.call(this, name) ? value : (desc.value = bind.call(value, null == bindTo ? this : this[bindTo]),
defineProperty(this, name, desc), this[name]);
}, dgs;
}, module.exports = function(props) {
var bindTo = arguments[1];
return map(props, function(desc, name) {
return define(name, desc, bindTo);
});
};
}, /* 40 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var assign = __webpack_require__(33), value = __webpack_require__(6);
module.exports = function(obj) {
var copy = Object(value(obj));
return copy !== obj ? copy : assign({}, obj);
};
}, /* 41 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var callable = __webpack_require__(18), forEach = __webpack_require__(42), call = Function.prototype.call;
module.exports = function(obj, cb) {
var o = {}, thisArg = arguments[2];
return callable(cb), forEach(obj, function(value, key, obj, index) {
o[key] = call.call(cb, thisArg, value, key, obj, index);
}), o;
};
}, /* 42 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(43)("forEach");
}, /* 43 */
/***/
function(module, exports, __webpack_require__) {
// Internal method, used by iteration functions.
// Calls a function for each key-value pair found in object
// Optionally takes compareFn to iterate object in specific order
"use strict";
var callable = __webpack_require__(18), value = __webpack_require__(6), bind = Function.prototype.bind, call = Function.prototype.call, keys = Object.keys, propertyIsEnumerable = Object.prototype.propertyIsEnumerable;
module.exports = function(method, defVal) {
return function(obj, cb) {
var list, thisArg = arguments[2], compareFn = arguments[3];
return obj = Object(value(obj)), callable(cb), list = keys(obj), compareFn && list.sort("function" == typeof compareFn ? bind.call(compareFn, obj) : void 0),
"function" != typeof method && (method = list[method]), call.call(method, list, function(key, index) {
return propertyIsEnumerable.call(obj, key) ? call.call(cb, thisArg, obj[key], key, obj, index) : defVal;
});
};
};
}, /* 44 */
/***/
function(module, exports, __webpack_require__) {
// Thanks @mathiasbynens
// http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols
"use strict";
var StringIterator, setPrototypeOf = __webpack_require__(13), d = __webpack_require__(19), Iterator = __webpack_require__(32), defineProperty = Object.defineProperty;
StringIterator = module.exports = function(str) {
return this instanceof StringIterator ? (str = String(str), Iterator.call(this, str),
void defineProperty(this, "__length__", d("", str.length))) : new StringIterator(str);
}, setPrototypeOf && setPrototypeOf(StringIterator, Iterator), StringIterator.prototype = Object.create(Iterator.prototype, {
constructor: d(StringIterator),
_next: d(function() {
if (this.__list__) return this.__nextIndex__ < this.__length__ ? this.__nextIndex__++ : void this._unBind();
}),
_resolve: d(function(i) {
var code, char = this.__list__[i];
return this.__nextIndex__ === this.__length__ ? char : (code = char.charCodeAt(0),
code >= 55296 && code <= 56319 ? char + this.__list__[this.__nextIndex__++] : char);
}),
toString: d(function() {
return "[object String Iterator]";
})
});
}, /* 45 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
var MapIterator, setPrototypeOf = __webpack_require__(13), d = __webpack_require__(19), Iterator = __webpack_require__(46), toStringTagSymbol = __webpack_require__(21).toStringTag, kinds = __webpack_require__(47), defineProperties = Object.defineProperties, unBind = Iterator.prototype._unBind;
MapIterator = module.exports = function(map, kind) {
return this instanceof MapIterator ? (Iterator.call(this, map.__mapKeysData__, map),
kind && kinds[kind] || (kind = "key+value"), void defineProperties(this, {
__kind__: d("", kind),
__values__: d("w", map.__mapValuesData__)
})) : new MapIterator(map, kind);
}, setPrototypeOf && setPrototypeOf(MapIterator, Iterator), MapIterator.prototype = Object.create(Iterator.prototype, {
constructor: d(MapIterator),
_resolve: d(function(i) {
return "value" === this.__kind__ ? this.__values__[i] : "key" === this.__kind__ ? this.__list__[i] : [ this.__list__[i], this.__values__[i] ];
}),
_unBind: d(function() {
this.__values__ = null, unBind.call(this);
}),
toString: d(function() {
return "[object Map Iterator]";
})
}), Object.defineProperty(MapIterator.prototype, toStringTagSymbol, d("c", "Map Iterator"));
}, /* 46 */
/***/
function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_46__;
}, /* 47 */
/***/
function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(48)("key", "value", "key+value");
}, /* 48 */
/***/
function(module, exports) {
"use strict";
var forEach = Array.prototype.forEach, create = Object.create;
module.exports = function(arg) {
var set = create(null);
return forEach.call(arguments, function(name) {
set[name] = !0;
}), set;
};
}, /* 49 */
/***/
function(module, exports) {
// Exports true if environment provides native `Map` implementation,
// whatever that is.
"use strict";
module.exports = function() {
return "undefined" != typeof Map && "[object Map]" === Object.prototype.toString.call(new Map());
}();
}, /* 50 */
/***/
function(module, exports) {
"use strict";
/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
"undefined" == typeof WeakMap && !function() {
var defineProperty = Object.defineProperty, counter = Date.now() % 1e9, WeakMap = function() {
this.name = "__st" + (1e9 * Math.random() >>> 0) + (counter++ + "__");
};
WeakMap.prototype = {
set: function(key, value) {
var entry = key[this.name];
return entry && entry[0] === key ? entry[1] = value : defineProperty(key, this.name, {
value: [ key, value ],
writable: !0
}), this;
},
get: function(key) {
var entry;
return (entry = key[this.name]) && entry[0] === key ? entry[1] : void 0;
},
"delete": function(key) {
var entry = key[this.name];
return !(!entry || entry[0] !== key) && (entry[0] = entry[1] = void 0, !0);
},
has: function(key) {
var entry = key[this.name];
return !!entry && entry[0] === key;
}
}, window.WeakMap = WeakMap;
}();
}, /* 51 */
/***/
function(module, exports) {
"use strict";
/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
!function(global) {
/**
* Schedules |dispatchCallback| to be called in the future.
* @param {MutationObserver} observer
*/
function scheduleCallback(observer) {
scheduledObservers.push(observer), isScheduled || (isScheduled = !0, setImmediate(dispatchCallbacks));
}
function wrapIfNeeded(node) {
return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
}
function dispatchCallbacks() {
// http://dom.spec.whatwg.org/#mutation-observers
isScheduled = !1;
// Used to allow a new setImmediate call above.
var observers = scheduledObservers;
scheduledObservers = [], // Sort observers based on their creation UID (incremental).
observers.sort(function(o1, o2) {
return o1.uid_ - o2.uid_;
});
var anyNonEmpty = !1;
observers.forEach(function(observer) {
// 2.1, 2.2
var queue = observer.takeRecords();
// 2.3. Remove all transient registered observers whose observer is mo.
removeTransientObserversFor(observer), // 2.4
queue.length && (observer.callback_(queue, observer), anyNonEmpty = !0);
}), // 3.
anyNonEmpty && dispatchCallbacks();
}
function removeTransientObserversFor(observer) {
observer.nodes_.forEach(function(node) {
var registrations = registrationsTable.get(node);
registrations && registrations.forEach(function(registration) {
registration.observer === observer && registration.removeTransientObservers();
});
});
}
/**
* This function is used for the "For each registered observer observer (with
* observer's options as options) in target's list of registered observers,
* run these substeps:" and the "For each ancestor ancestor of target, and for
* each registered observer observer (with options options) in ancestor's list
* of registered observers, run these substeps:" part of the algorithms. The
* |options.subtree| is checked to ensure that the callback is called
* correctly.
*
* @param {Node} target
* @param {function(MutationObserverInit):MutationRecord} callback
*/
function forEachAncestorAndObserverEnqueueRecord(target, callback) {
for (var node = target; node; node = node.parentNode) {
var registrations = registrationsTable.get(node);
if (registrations) for (var j = 0; j < registrations.length; j++) {
var registration = registrations[j], options = registration.options;
// Only target ignores subtree.
if (node === target || options.subtree) {
var record = callback(options);
record && registration.enqueue(record);
}
}
}
}
/**
* The class that maps to the DOM MutationObserver interface.
* @param {Function} callback.
* @constructor
*/
function JsMutationObserver(callback) {
this.callback_ = callback, this.nodes_ = [], this.records_ = [], this.uid_ = ++uidCounter;
}
/**
* @param {string} type
* @param {Node} target
* @constructor
*/
function MutationRecord(type, target) {
this.type = type, this.target = target, this.addedNodes = [], this.removedNodes = [],
this.previousSibling = null, this.nextSibling = null, this.attributeName = null,
this.attributeNamespace = null, this.oldValue = null;
}
function copyMutationRecord(original) {
var record = new MutationRecord(original.type, original.target);
return record.addedNodes = original.addedNodes.slice(), record.removedNodes = original.removedNodes.slice(),
record.previousSibling = original.previousSibling, record.nextSibling = original.nextSibling,
record.attributeName = original.attributeName, record.attributeNamespace = original.attributeNamespace,
record.oldValue = original.oldValue, record;
}
/**
* Creates a record without |oldValue| and caches it as |currentRecord| for
* later use.
* @param {string} oldValue
* @return {MutationRecord}
*/
function getRecord(type, target) {
return currentRecord = new MutationRecord(type, target);
}
/**
* Gets or creates a record with |oldValue| based in the |currentRecord|
* @param {string} oldValue
* @return {MutationRecord}
*/
function getRecordWithOldValue(oldValue) {
return recordWithOldValue ? recordWithOldValue : (recordWithOldValue = copyMutationRecord(currentRecord),
recordWithOldValue.oldValue = oldValue, recordWithOldValue);
}
function clearRecords() {
currentRecord = recordWithOldValue = void 0;
}
/**
* @param {MutationRecord} record
* @return {boolean} Whether the record represents a record from the current
* mutation event.
*/
function recordRepresentsCurrentMutation(record) {
return record === recordWithOldValue || record === currentRecord;
}
/**
* Selects which record, if any, to replace the last record in the queue.
* This returns |null| if no record should be replaced.
*
* @param {MutationRecord} lastRecord
* @param {MutationRecord} newRecord
* @param {MutationRecord}
*/
function selectRecord(lastRecord, newRecord) {
// Check if the the record we are adding represents the same record. If
// so, we keep the one with the oldValue in it.
return lastRecord === newRecord ? lastRecord : recordWithOldValue && recordRepresentsCurrentMutation(lastRecord) ? recordWithOldValue : null;
}
/**
* Class used to represent a registered observer.
* @param {MutationObserver} observer
* @param {Node} target
* @param {MutationObserverInit} options
* @constructor
*/
function Registration(observer, target, options) {
this.observer = observer, this.target = target, this.options = options, this.transientObservedNodes = [];
}
// Don't allow this object to be redefined.
if (!global.JsMutationObserver) {
var setImmediate, registrationsTable = new WeakMap();
// As much as we would like to use the native implementation, IE
// (all versions) suffers a rather annoying bug where it will drop or defer
// callbacks when heavy DOM operations are being performed concurrently.
//
// For a thorough discussion on this, see:
// http://codeforhire.com/2013/09/21/setimmediate-and-messagechannel-broken-on-internet-explorer-10/
if (/Trident|Edge/.test(navigator.userAgent)) // Sadly, this bug also affects postMessage and MessageQueues.
//
// We would like to use the onreadystatechange hack for IE <= 10, but it is
// dangerous in the polyfilled environment due to requiring that the
// observed script element be in the document.
setImmediate = setTimeout; else if (window.setImmediate) setImmediate = window.setImmediate; else {
var setImmediateQueue = [], sentinel = String(Math.random());
window.addEventListener("message", function(e) {
if (e.data === sentinel) {
var queue = setImmediateQueue;
setImmediateQueue = [], queue.forEach(function(func) {
func();
});
}
}), setImmediate = function(func) {
setImmediateQueue.push(func), window.postMessage(sentinel, "*");
};
}
// This is used to ensure that we never schedule 2 callas to setImmediate
var isScheduled = !1, scheduledObservers = [], uidCounter = 0;
JsMutationObserver.prototype = {
observe: function(target, options) {
// 1.1
if (target = wrapIfNeeded(target), !options.childList && !options.attributes && !options.characterData || // 1.2
options.attributeOldValue && !options.attributes || // 1.3
options.attributeFilter && options.attributeFilter.length && !options.attributes || // 1.4
options.characterDataOldValue && !options.characterData) throw new SyntaxError();
var registrations = registrationsTable.get(target);
registrations || registrationsTable.set(target, registrations = []);
for (var registration, i = 0; i < registrations.length; i++) if (registrations[i].observer === this) {
registration = registrations[i], registration.removeListeners(), registration.options = options;
break;
}
// 3.
// Otherwise, add a new registered observer to target's list of registered
// observers with the context object as the observer and options as the
// options, and add target to context object's list of nodes on which it
// is registered.
registration || (registration = new Registration(this, target, options), registrations.push(registration),
this.nodes_.push(target)), registration.addListeners();
},
disconnect: function() {
this.nodes_.forEach(function(node) {
for (var registrations = registrationsTable.get(node), i = 0; i < registrations.length; i++) {
var registration = registrations[i];
if (registration.observer === this) {
registration.removeListeners(), registrations.splice(i, 1);
// Each node can only have one registered observer associated with
// this observer.
break;
}
}
}, this), this.records_ = [];
},
takeRecords: function() {
var copyOfRecords = this.records_;
return this.records_ = [], copyOfRecords;
}
};
// We keep track of the two (possibly one) records used in a single mutation.
var currentRecord, recordWithOldValue;
Registration.prototype = {
enqueue: function(record) {
var records = this.observer.records_, length = records.length;
// There are cases where we replace the last record with the new record.
// For example if the record represents the same mutation we need to use
// the one with the oldValue. If we get same record (this can happen as we
// walk up the tree) we ignore the new record.
if (records.length > 0) {
var lastRecord = records[length - 1], recordToReplaceLast = selectRecord(lastRecord, record);
if (recordToReplaceLast) return void (records[length - 1] = recordToReplaceLast);
} else scheduleCallback(this.observer);
records[length] = record;
},
addListeners: function() {
this.addListeners_(this.target);
},
addListeners_: function(node) {
var options = this.options;
options.attributes && node.addEventListener("DOMAttrModified", this, !0), options.characterData && node.addEventListener("DOMCharacterDataModified", this, !0),
options.childList && node.addEventListener("DOMNodeInserted", this, !0), (options.childList || options.subtree) && node.addEventListener("DOMNodeRemoved", this, !0);
},
removeListeners: function() {
this.removeListeners_(this.target);
},
removeListeners_: function(node) {
var options = this.options;
options.attributes && node.removeEventListener("DOMAttrModified", this, !0), options.characterData && node.removeEventListener("DOMCharacterDataModified", this, !0),
options.childList && node.removeEventListener("DOMNodeInserted", this, !0), (options.childList || options.subtree) && node.removeEventListener("DOMNodeRemoved", this, !0);
},
/**
* Adds a transient observer on node. The transient observer gets removed
* next time we deliver the change records.
* @param {Node} node
*/
addTransientObserver: function(node) {
// Don't add transient observers on the target itself. We already have all
// the required listeners set up on the target.
if (node !== this.target) {
this.addListeners_(node), this.transientObservedNodes.push(node);
var registrations = registrationsTable.get(node);
registrations || registrationsTable.set(node, registrations = []), // We know that registrations does not contain this because we already
// checked if node === this.target.
registrations.push(this);
}
},
removeTransientObservers: function() {
var transientObservedNodes = this.transientObservedNodes;
this.transientObservedNodes = [], transientObservedNodes.forEach(function(node) {
// Transient observers are never added to the target.
this.removeListeners_(node);
for (var registrations = registrationsTable.get(node), i = 0; i < registrations.length; i++) if (registrations[i] === this) {
registrations.splice(i, 1);
// Each node can only have one registered observer associated with
// this observer.
break;
}
}, this);
},
handleEvent: function(e) {
switch (// Stop propagation since we are managing the propagation manually.
// This means that other mutation events on the page will not work
// correctly but that is by design.
e.stopImmediatePropagation(), e.type) {
case "DOMAttrModified":
// http://dom.spec.whatwg.org/#concept-mo-queue-attributes
var name = e.attrName, namespace = e.relatedNode.namespaceURI, target = e.target, record = new getRecord("attributes", target);
record.attributeName = name, record.attributeNamespace = namespace;
// 2.
var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
// 3.1, 4.2
if (options.attributes && (!options.attributeFilter || !options.attributeFilter.length || options.attributeFilter.indexOf(name) !== -1 || options.attributeFilter.indexOf(namespace) !== -1)) // 3.3, 4.4
// 3.3, 4.4
return options.attributeOldValue ? getRecordWithOldValue(oldValue) : record;
});
break;
case "DOMCharacterDataModified":
// http://dom.spec.whatwg.org/#concept-mo-queue-characterdata
var target = e.target, record = getRecord("characterData", target), oldValue = e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
// 3.1, 4.2
if (options.characterData) // 3.2, 4.3
// 3.2, 4.3
return options.characterDataOldValue ? getRecordWithOldValue(oldValue) : record;
});
break;
case "DOMNodeRemoved":
this.addTransientObserver(e.target);
// Fall through.
case "DOMNodeInserted":
// http://dom.spec.whatwg.org/#concept-mo-queue-childlist
var addedNodes, removedNodes, changedNode = e.target;
"DOMNodeInserted" === e.type ? (addedNodes = [ changedNode ], removedNodes = []) : (addedNodes = [],
removedNodes = [ changedNode ]);
var previousSibling = changedNode.previousSibling, nextSibling = changedNode.nextSibling, record = getRecord("childList", e.target.parentNode);
record.addedNodes = addedNodes, record.removedNodes = removedNodes, record.previousSibling = previousSibling,
record.nextSibling = nextSibling, forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
// 2.1, 3.2
if (options.childList) // 2.2, 3.3
return record;
});
}
clearRecords();
}
}, global.JsMutationObserver = JsMutationObserver, global.MutationObserver || (global.MutationObserver = JsMutationObserver,
// Explicltly mark MO as polyfilled for user reference.
JsMutationObserver._isPolyfilled = !0);
}
}(self);
}, /* 52 */
/***/
function(module, exports, __webpack_require__) {
!function(global, factory) {
factory(exports);
}(this, function(exports) {
function eachChildNode(node, func) {
if (node) for (var chs = node.childNodes, chsLen = chs.length, a = 0; a < chsLen; a++) {
var ret = func(chs[a], a, chs);
if ("undefined" != typeof ret) return ret;
}
}
function eachNodeOrFragmentNodes(node, func) {
if (node instanceof DocumentFragment) for (var chs = node.childNodes, chsLen = chs.length, a = 0; a < chsLen; a++) func(chs[a], a); else func(node, 0);
}
function getPrototype(obj, key) {
for (var descriptor = void 0; obj && !(descriptor = Object.getOwnPropertyDescriptor(obj, key)); ) // eslint-disable-line no-cond-assign
obj = Object.getPrototypeOf(obj);
return descriptor;
}
function getPropertyDescriptor(obj, key) {
obj instanceof Node && (obj = div);
var proto = getPrototype(obj, key);
if (proto) {
var getter = proto.get, setter = proto.set, _descriptor = {
configurable: !0,
enumerable: !0
};
if (getter) return _descriptor.get = getter, _descriptor.set = setter, _descriptor;
if ("function" == typeof obj[key]) return _descriptor.value = obj[key], _descriptor;
}
var descriptor = Object.getOwnPropertyDescriptor(obj, key);
if (descriptor && descriptor.get) return descriptor;
}
function createCommonjsModule(fn, module) {
return module = {
exports: {}
}, fn(module, module.exports), module.exports;
}
/**
* See https://w3c.github.io/DOM-Parsing/#serializing
* @param {TextNode}
* @returns {string}
*/
function getEscapedTextContent(textNode) {
return textNode.textContent.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
/**
* @returns {string}
* @param {commentNode}
*/
function getCommentNodeOuterHtml(commentNode) {
return commentNode.text || "<!--" + commentNode.textContent + "-->";
}
function isSlotNode(node) {
return "SLOT" === node.tagName;
}
function findSlots(root) {
var slots = arguments.length <= 1 || void 0 === arguments[1] ? [] : arguments[1], childNodes = root.childNodes;
if (!childNodes || root.nodeType !== Node.ELEMENT_NODE) return slots;
for (var length = childNodes.length, a = 0; a < length; a++) {
var childNode = childNodes[a];
isSlotNode(childNode) && slots.push(childNode), findSlots(childNode, slots);
}
return slots;
}
function isRootNode(node) {
return "_SHADOW_ROOT_" === node.tagName;
}
function parse(html) {
var tree = document.createElement("div");
// Everything not WebKit can do this easily.
if (canPatchNativeAccessors) return tree.__innerHTML = html, tree;
for (var parsed = parser.parseFromString("<div>" + html + "</div>", "text/html").body.firstChild; parsed.hasChildNodes(); ) {
var firstChild = parsed.firstChild;
parsed.removeChild(firstChild), tree.appendChild(firstChild);
}
// Need to import the node to initialise the custom elements from the parser.
return document.importNode(tree, !0);
}
function staticProp(obj, name, value) {
Object.defineProperty(obj, name, {
configurable: !0,
get: function() {
return value;
}
});
}
// Slotting helpers.
function arrayItem(idx) {
return this[idx];
}
function makeLikeNodeList(arr) {
return arr.item = arrayItem, arr;
}
function isHostNode(node) {
return !!hostToRootMap.get(node);
}
function getNodeType(node) {
return isHostNode(node) ? "host" : isSlotNode(node) ? "slot" : isRootNode(node) ? "root" : "node";
}
function findClosest(node, func) {
for (;node && node !== document; ) {
if (func(node)) return node;
node = node.parentNode;
}
}
function getSlotNameFromSlot(node) {
return node.getAttribute && node.getAttribute("name") || "default";
}
function getSlotNameFromNode(node) {
debugger;
if (!node) {
console.trace();
}
return node.getAttribute && node.getAttribute("slot") || "default";
}
function slotNodeIntoSlot(slot, node, insertBefore) {
// Don't slot nodes that have content but are only whitespace. This is an
// anomaly that I don't think the spec deals with.
//
// The problem is:
//
// - If you insert HTML with indentation into the page, there will be
// whitespace and if that's inserted it messes with fallback content
// calculation where there is formatting, but no meaningful content, so in
// theory it should fallback. Since you can attach a shadow root after we
// mean to insert an empty text node and have it "count", we can't really
// discard nodes that are considered formatting at the time of attachment.
// - You can insert a text node and modify its text content later.
// Incremental DOM seems to do this. Every way I look at it, it seems
// problematic that we should have to screen for content, but I don't seems
// much of a way around it at the moment.
if ((3 !== node.nodeType || !node.textContent || 0 !== node.textContent.trim().length) && slottedNodeTypes.indexOf(node.nodeType) !== -1) // only Text and Element nodes should be slotted
{
var assignedNodes = slot.assignedNodes(), shouldGoIntoContentMode = 0 === assignedNodes.length, slotInsertBeforeIndex = assignedNodes.indexOf(insertBefore);
// Assign the slot to the node internally.
nodeToSlotMap.set(node, slot), // Remove the fallback content and state if we're going into content mode.
shouldGoIntoContentMode && forEach.call(slot.childNodes, function(child) {
return slot.__removeChild(child);
}), slotInsertBeforeIndex > -1 ? (slot.__insertBefore(node, void 0 !== insertBefore ? insertBefore : null),
assignedNodes.splice(slotInsertBeforeIndex, 0, node)) : (slot.__appendChild(node),
assignedNodes.push(node)), slot.____triggerSlotChangeEvent();
}
}
function slotNodeFromSlot(node) {
var slot = node.assignedSlot;
if (slot) {
var assignedNodes = slot.assignedNodes(), index = assignedNodes.indexOf(node);
if (index > -1) {
var shouldGoIntoDefaultMode = 1 === assignedNodes.length;
assignedNodes.splice(index, 1), nodeToSlotMap.set(node, null), // Actually remove the child.
slot.__removeChild(node), // If this was the last slotted node, then insert fallback content.
shouldGoIntoDefaultMode && forEach.call(slot.childNodes, function(child) {
return slot.__appendChild(child);
}), slot.____triggerSlotChangeEvent();
}
}
}
// Returns the index of the node in the host's childNodes.
function indexOfNode(host, node) {
for (var chs = host.childNodes, chsLen = chs.length, a = 0; a < chsLen; a++) if (chs[a] === node) return a;
return -1;
}
// Adds the node to the list of childNodes on the host and fakes any necessary
// information such as parentNode.
function registerNode(host, node, insertBefore, func) {
var index = indexOfNode(host, insertBefore);
eachNodeOrFragmentNodes(node, function(eachNode, eachIndex) {
func(eachNode, eachIndex), canPatchNativeAccessors ? nodeToParentNodeMap.set(eachNode, host) : staticProp(eachNode, "parentNode", host),
index > -1 ? arrProto.splice.call(host.childNodes, index + eachIndex, 0, eachNode) : arrProto.push.call(host.childNodes, eachNode);
});
}
// Cleans up registerNode().
function unregisterNode(host, node, func) {
var index = indexOfNode(host, node);
index > -1 && (func(node, 0), canPatchNativeAccessors ? nodeToParentNodeMap.set(node, null) : staticProp(node, "parentNode", null),
arrProto.splice.call(host.childNodes, index, 1));
}
function addNodeToNode(host, node, insertBefore) {
registerNode(host, node, insertBefore, function(eachNode) {
host.__insertBefore(eachNode, void 0 !== insertBefore ? insertBefore : null);
});
}
function addNodeToHost(host, node, insertBefore) {
registerNode(host, node, insertBefore, function(eachNode) {
var rootNode = hostToRootMap.get(host), slotNodes = rootToSlotMap.get(rootNode), slotNode = slotNodes[getSlotNameFromNode(eachNode)];
slotNode && slotNodeIntoSlot(slotNode, eachNode, insertBefore);
});
}
function addSlotToRoot(root, slot) {
var slotName = getSlotNameFromSlot(slot);
// Ensure a slot node's childNodes are overridden at the earliest point
// possible for WebKit.
canPatchNativeAccessors || Array.isArray(slot.childNodes) || staticProp(slot, "childNodes", pseudoArrayToArray(slot.childNodes)),
rootToSlotMap.get(root)[slotName] = slot, slotToRootMap.has(slot) || slotToRootMap.set(slot, root),
eachChildNode(rootToHostMap.get(root), function(eachNode) {
eachNode.assignedSlot || slotName !== getSlotNameFromNode(eachNode) || slotNodeIntoSlot(slot, eachNode);
});
}
function addNodeToRoot(root, node, insertBefore) {
eachNodeOrFragmentNodes(node, function(child) {
if (isSlotNode(child)) addSlotToRoot(root, child); else {
var slotNodes = findSlots(child);
if (slotNodes) for (var slotNodesLen = slotNodes.length, a = 0; a < slotNodesLen; a++) addSlotToRoot(root, slotNodes[a]);
}
}), addNodeToNode(root, node, insertBefore);
}
// Adds a node to a slot. In other words, adds default content to a slot. It
// ensures that if the slot doesn't have any assigned nodes yet, that the node
// is actually displayed, otherwise it's just registered as child content.
function addNodeToSlot(slot, node, insertBefore) {
var isInDefaultMode = 0 === slot.assignedNodes().length;
registerNode(slot, node, insertBefore, function(eachNode) {
isInDefaultMode && slot.__insertBefore(eachNode, void 0 !== insertBefore ? insertBefore : null);
});
}
// Removes a node from a slot (default content). It ensures that if the slot
// doesn't have any assigned nodes yet, that the node is actually removed,
// otherwise it's just unregistered.
function removeNodeFromSlot(slot, node) {
var isInDefaultMode = 0 === slot.assignedNodes().length;
unregisterNode(slot, node, function() {
isInDefaultMode && slot.__removeChild(node);
});
}
function removeNodeFromNode(host, node) {
unregisterNode(host, node, function() {
host.__removeChild(node);
});
}
function removeNodeFromHost(host, node) {
unregisterNode(host, node, function() {
slotNodeFromSlot(node);
});
}
function removeSlotFromRoot(root, node) {
node.assignedNodes().forEach(slotNodeFromSlot), delete rootToSlotMap.get(root)[getSlotNameFromSlot(node)],
slotToRootMap["delete"](node);
}
function removeNodeFromRoot(root, node) {
unregisterNode(root, node, function() {
if (isSlotNode(node)) removeSlotFromRoot(root, node); else {
var nodes = findSlots(node);
if (nodes) for (var a = 0; a < nodes.length; a++) removeSlotFromRoot(root, nodes[a]);
}
root.__removeChild(node);
});
}
// TODO terribly inefficient
function getRootNode(host) {
if (isRootNode(host)) return host;
if (host.parentNode) return getRootNode(host.parentNode);
}
function appendChildOrInsertBefore(host, newNode, refNode) {
var nodeType = getNodeType(host), parentNode = newNode.parentNode, rootNode = getRootNode(host);
// Ensure childNodes is patched so we can manually update it for WebKit.
// If we append a child to a host, the host tells the shadow root to distribute
// it. If the root decides it doesn't need to be distributed, it is never
// removed from the old parent because in polyfill land we store a reference
// to the node but we don't move it. Due to that, we must explicitly remove the
// node from its old parent.
return canPatchNativeAccessors || Array.isArray(host.childNodes) || staticProp(host, "childNodes", pseudoArrayToArray(host.childNodes)),
rootNode && "slot" === getNodeType(newNode) && addSlotToRoot(rootNode, newNode),
parentNode && "host" === getNodeType(parentNode) && (canPatchNativeAccessors ? nodeToParentNodeMap.set(newNode, null) : staticProp(newNode, "parentNode", null)),
"node" === nodeType ? canPatchNativeAccessors ? (nodeToParentNodeMap.set(newNode, host),
host.__insertBefore(newNode, void 0 !== refNode ? refNode : null)) : addNodeToNode(host, newNode, refNode) : "slot" === nodeType ? addNodeToSlot(host, newNode, refNode) : "host" === nodeType ? addNodeToHost(host, newNode, refNode) : "root" === nodeType ? addNodeToRoot(host, newNode, refNode) : void 0;
}
function syncSlotChildNodes(node) {
if (canPatchNativeAccessors && "slot" === getNodeType(node) && node.__childNodes.length !== node.childNodes.length) {
for (;node.hasChildNodes(); ) node.removeChild(node.firstChild);
forEach.call(node.__childNodes, function(child) {
return node.appendChild(child);
});
}
}
var div = document.createElement("div"), nativeParentNode = getPropertyDescriptor(Element.prototype, "innerHTML"), canPatchNativeAccessors = !!nativeParentNode, index$1 = createCommonjsModule(function(module) {
function now() {
return new Date().getTime();
}
module.exports = Date.now || now;
}), require$$0 = index$1 && "object" == typeof index$1 && "default" in index$1 ? index$1["default"] : index$1, index = createCommonjsModule(function(module) {
/**
* Module dependencies.
*/
var now = require$$0;
/**
* Returns a function, that, as long as it continues to be invoked, will not
* be triggered. The function will be called after it stops being called for
* N milliseconds. If `immediate` is passed, trigger the function on the
* leading edge, instead of the trailing.
*
* @source underscore.js
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
* @param {Function} function to wrap
* @param {Number} timeout in ms (`100`)
* @param {Boolean} whether to execute at the beginning (`false`)
* @api public
*/
module.exports = function(func, wait, immediate) {
function later() {
var last = now() - timestamp;
last < wait && last > 0 ? timeout = setTimeout(later, wait - last) : (timeout = null,
immediate || (result = func.apply(context, args), timeout || (context = args = null)));
}
var timeout, args, context, timestamp, result;
return null == wait && (wait = 100), function() {
context = this, args = arguments, timestamp = now();
var callNow = immediate && !timeout;
return timeout || (timeout = setTimeout(later, wait)), callNow && (result = func.apply(context, args),
context = args = null), result;
};
};
}), debounce = index && "object" == typeof index && "default" in index ? index["default"] : index, pseudoArrayToArray = function(pseudoArray) {
return Array.prototype.slice.call(pseudoArray);
}, version = "0.0.1";
/**
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
"undefined" == typeof WeakMap && !function() {
var defineProperty = Object.defineProperty, counter = Date.now() % 1e9, WeakMap = function() {
this.name = "__st" + (1e9 * Math.random() >>> 0) + (counter++ + "__");
};
WeakMap.prototype = {
set: function(key, value) {
var entry = key[this.name];
return entry && entry[0] === key ? entry[1] = value : defineProperty(key, this.name, {
value: [ key, value ],
writable: !0
}), this;
},
get: function(key) {
var entry;
return (entry = key[this.name]) && entry[0] === key ? entry[1] : void 0;
},
"delete": function(key) {
var entry = key[this.name];
return !(!entry || entry[0] !== key) && (entry[0] = entry[1] = void 0, !0);
},
has: function(key) {
var entry = key[this.name];
return !!entry && entry[0] === key;
}
}, window.WeakMap = WeakMap;
}();
// Polyfill for creating CustomEvents on IE9/10/11
// code pulled from:
// https://github.com/d4tocchini/customevent-polyfill
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill
try {
var ce = new window.CustomEvent("test", {
bubbles: !1,
cancelable: !0,
detail: {
x: "y"
}
});
if (ce.preventDefault(), ce.defaultPrevented !== !0) // IE has problems with .preventDefault() on custom events
// http://stackoverflow.com/questions/23349191
throw new Error("Could not prevent default");
} catch (e) {
var CustomEvent$1 = function(event, params) {
var evt;
params = params || {
bubbles: !1,
cancelable: !1,
detail: void 0
}, evt = document.createEvent("CustomEvent"), evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
var origPrevent = evt.preventDefault;
return evt.preventDefault = function() {
origPrevent.call(this);
try {
Object.defineProperty(this, "defaultPrevented", {
get: function() {
return !0;
}
});
} catch (e) {
this.defaultPrevented = !0;
}
}, evt;
};
CustomEvent$1.prototype = window.Event.prototype, window.CustomEvent = CustomEvent$1;
}
var arrProto = Array.prototype, forEach = arrProto.forEach, defaultShadowRootTagName = "_shadow_root_", polyfillAtRuntime = [ "childNodes", "parentNode" ], doNotOverridePropertiesInTextNodes = [ "textContent" ], defineInTextNodes = [ "assignedSlot" ], doNotOverridePropertiesInCommNodes = [ "textContent" ], defineInCommNodes = [], slottedNodeTypes = [ Node.ELEMENT_NODE, Node.TEXT_NODE ], assignedToSlotMap = new WeakMap(), hostToModeMap = new WeakMap(), hostToRootMap = new WeakMap(), nodeToChildNodesMap = new WeakMap(), nodeToParentNodeMap = new WeakMap(), nodeToSlotMap = new WeakMap(), rootToHostMap = new WeakMap(), rootToSlotMap = new WeakMap(), slotToRootMap = new WeakMap(), parser = new DOMParser(), members = {
// For testing purposes.
____assignedNodes: {
get: function() {
return this.______assignedNodes || (this.______assignedNodes = []);
}
},
// For testing purposes.
____isInFallbackMode: {
get: function() {
return 0 === this.assignedNodes().length;
}
},
____slotChangeListeners: {
get: function() {
return "undefined" == typeof this.______slotChangeListeners && (this.______slotChangeListeners = 0),
this.______slotChangeListeners;
},
set: function(value) {
this.______slotChangeListeners = value;
}
},
____triggerSlotChangeEvent: {
value: debounce(function() {
this.____slotChangeListeners && this.dispatchEvent(new CustomEvent("slotchange", {
bubbles: !1,
cancelable: !1
}));
})
},
addEventListener: {
value: function(name, func, opts) {
return "slotchange" === name && isSlotNode(this) && this.____slotChangeListeners++,
this.__addEventListener(name, func, opts);
}
},
appendChild: {
value: function(newNode) {
return appendChildOrInsertBefore(this, newNode), newNode;
}
},
assignedSlot: {
get: function() {
var slot = nodeToSlotMap.get(this);
if (!slot) return null;
var root = slotToRootMap.get(slot), host = rootToHostMap.get(root), mode = hostToModeMap.get(host);
return "open" === mode ? slot : null;
}
},
attachShadow: {
value: function(opts) {
var _this = this, mode = opts && opts.mode;
if ("closed" !== mode && "open" !== mode) throw new Error('You must specify { mode } as "open" or "closed" to attachShadow().');
// Return the existing shadow root if it exists.
var existingShadowRoot = hostToRootMap.get(this);
if (existingShadowRoot) return existingShadowRoot;
var lightNodes = makeLikeNodeList([].slice.call(this.childNodes)), shadowRoot = document.createElement(opts.polyfillShadowRootTagName || defaultShadowRootTagName);
// The shadow root is actually the only child of the host.
// Host and shadow root data.
// Process light DOM.
return hostToModeMap.set(this, mode), hostToRootMap.set(this, shadowRoot), rootToHostMap.set(shadowRoot, this),
rootToSlotMap.set(shadowRoot, {}), canPatchNativeAccessors ? nodeToChildNodesMap.set(this, lightNodes) : staticProp(this, "childNodes", lightNodes),
lightNodes.forEach(function(node) {
// Existing children should be removed from being displayed, but still
// appear to be child nodes. This is how light DOM works; they're still
// child nodes but not in the composed DOM yet as there won't be any
// slots for them to go into.
_this.__removeChild(node), // We must register the parentNode here as this has the potential to
// become out of sync if the node is moved before being slotted.
canPatchNativeAccessors ? nodeToParentNodeMap.set(node, _this) : staticProp(node, "parentNode", _this);
}), this.__appendChild(shadowRoot);
}
},
childElementCount: {
get: function() {
return this.children.length;
}
},
childNodes: {
get: function() {
if (canPatchNativeAccessors && "node" === getNodeType(this)) return this.__childNodes;
var childNodes = nodeToChildNodesMap.get(this);
return childNodes || nodeToChildNodesMap.set(this, childNodes = makeLikeNodeList([])),
childNodes;
}
},
children: {
get: function() {
var chs = [];
return eachChildNode(this, function(node) {
1 === node.nodeType && chs.push(node);
}), makeLikeNodeList(chs);
}
},
firstChild: {
get: function() {
return this.childNodes[0] || null;
}
},
firstElementChild: {
get: function() {
return this.children[0] || null;
}
},
assignedNodes: {
value: function() {
if (isSlotNode(this)) {
var assigned = assignedToSlotMap.get(this);
return assigned || assignedToSlotMap.set(this, assigned = []), assigned;
}
}
},
hasChildNodes: {
value: function() {
return this.childNodes.length > 0;
}
},
innerHTML: {
get: function() {
var innerHTML = "", getHtmlNodeOuterHtml = function(node) {
return node.outerHTML;
}, getOuterHtmlByNodeType = {
1: getHtmlNodeOuterHtml,
3: getEscapedTextContent,
8: getCommentNodeOuterHtml
};
return eachChildNode(this, function(node) {
var getOuterHtml = getOuterHtmlByNodeType[node.nodeType] || getHtmlNodeOuterHtml;
innerHTML += getOuterHtml(node);
}), innerHTML;
},
set: function(innerHTML) {
for (var parsed = parse(innerHTML); this.hasChildNodes(); ) this.removeChild(this.firstChild);
// when we are doing this: root.innerHTML = "<slot><div></div></slot>";
// slot.__childNodes is out of sync with slot.childNodes.
// to fix it we have to manually remove and insert them
var slots = findSlots(parsed);
for (forEach.call(slots, function(slot) {
return syncSlotChildNodes(slot);
}); parsed.hasChildNodes(); ) {
var firstChild = parsed.firstChild;
// When we polyfill everything on HTMLElement.prototype, we overwrite
// properties. This makes it so that parentNode reports null even though
// it's actually a parent of the HTML parser. For this reason,
// cleanNode() won't work and we must manually remove it from the
// parser before it is moved to the host just in case it's added as a
// light node but not assigned to a slot.
parsed.removeChild(firstChild), this.appendChild(firstChild);
}
}
},
insertBefore: {
value: function(newNode, refNode) {
return appendChildOrInsertBefore(this, newNode, refNode), newNode;
}
},
lastChild: {
get: function() {
var ch = this.childNodes;
return ch[ch.length - 1] || null;
}
},
lastElementChild: {
get: function() {
var ch = this.children;
return ch[ch.length - 1] || null;
}
},
name: {
get: function() {
return this.getAttribute("name");
},
set: function(name) {
return this.setAttribute("name", name);
}
},
nextSibling: {
get: function() {
var host = this;
return eachChildNode(this.parentNode, function(child, index, nodes) {
if (host === child) return nodes[index + 1] || null;
});
}
},
nextElementSibling: {
get: function() {
var host = this, found = void 0;
return eachChildNode(this.parentNode, function(child) {
return found && 1 === child.nodeType ? child : void (host === child && (found = !0));
});
}
},
outerHTML: {
get: function() {
var name = this.tagName.toLowerCase(), attributes = Array.prototype.slice.call(this.attributes).map(function(attr) {
return " " + attr.name + (attr.value ? '="' + attr.value + '"' : "");
}).join("");
return "<" + name + attributes + ">" + this.innerHTML + "</" + name + ">";
},
set: function(outerHTML) {
if (this.parentNode) {
var parsed = parse(outerHTML);
this.parentNode.replaceChild(parsed.firstChild, this);
} else {
if (!canPatchNativeAccessors) throw new Error("Failed to set the 'outerHTML' property on 'Element': This element has no parent node.");
this.__outerHTML = outerHTML;
}
}
},
parentElement: {
get: function() {
return findClosest(this.parentNode, function(node) {
return 1 === node.nodeType;
});
}
},
parentNode: {
get: function() {
return nodeToParentNodeMap.get(this) || this.__parentNode || null;
}
},
previousSibling: {
get: function() {
var host = this;
return eachChildNode(this.parentNode, function(child, index, nodes) {
if (host === child) return nodes[index - 1] || null;
});
}
},
previousElementSibling: {
get: function() {
var host = this, found = void 0;
return eachChildNode(this.parentNode, function(child) {
return found && host === child ? found : void (1 === child.nodeType && (found = child));
});
}
},
removeChild: {
value: function(refNode) {
var nodeType = getNodeType(this);
switch (nodeType) {
case "node":
if (canPatchNativeAccessors) return nodeToParentNodeMap.set(refNode, null), this.__removeChild(refNode);
removeNodeFromNode(this, refNode);
break;
case "slot":
removeNodeFromSlot(this, refNode);
break;
case "host":
removeNodeFromHost(this, refNode);
break;
case "root":
removeNodeFromRoot(this, refNode);
}
return refNode;
}
},
removeEventListener: {
value: function(name, func, opts) {
return "slotchange" === name && this.____slotChangeListeners && isSlotNode(this) && this.____slotChangeListeners--,
this.__removeEventListener(name, func, opts);
}
},
replaceChild: {
value: function(newNode, refNode) {
return this.insertBefore(newNode, refNode), this.removeChild(refNode);
}
},
shadowRoot: {
get: function() {
return "open" === hostToModeMap.get(this) ? hostToRootMap.get(this) : null;
}
},
textContent: {
get: function() {
var textContent = "";
return eachChildNode(this, function(node) {
node.nodeType !== Node.COMMENT_NODE && (textContent += node.textContent);
}), textContent;
},
set: function(textContent) {
for (;this.hasChildNodes(); ) this.removeChild(this.firstChild);
textContent && this.appendChild(document.createTextNode(textContent));
}
}
};
"attachShadow" in document.createElement("div") || !function() {
var commProto = Comment.prototype, elementProto = HTMLElement.prototype, svgProto = SVGElement.prototype, textProto = Text.prototype, textNode = document.createTextNode(""), commNode = document.createComment("");
Object.keys(members).forEach(function(memberName) {
var memberProperty = members[memberName];
// Polyfill as much as we can and work around WebKit in other areas.
if (// All properties should be configurable.
memberProperty.configurable = !0, // Applying to the data properties only since we can't have writable accessor properties.
memberProperty.hasOwnProperty("value") && (memberProperty.writable = !0), canPatchNativeAccessors || polyfillAtRuntime.indexOf(memberName) === -1) {
var nativeDescriptor = getPropertyDescriptor(elementProto, memberName), nativeTextDescriptor = getPropertyDescriptor(textProto, memberName), nativeCommDescriptor = getPropertyDescriptor(commProto, memberName), shouldOverrideInTextNode = memberName in textNode && doNotOverridePropertiesInTextNodes.indexOf(memberName) === -1 || ~defineInTextNodes.indexOf(memberName), shouldOverrideInCommentNode = memberName in commNode && doNotOverridePropertiesInCommNodes.indexOf(memberName) === -1 || ~defineInCommNodes.indexOf(memberName), nativeMemberName = "__" + memberName;
Object.defineProperty(elementProto, memberName, memberProperty), Object.defineProperty(svgProto, memberName, memberProperty),
nativeDescriptor && (Object.defineProperty(elementProto, nativeMemberName, nativeDescriptor),
Object.defineProperty(svgProto, nativeMemberName, nativeDescriptor)), shouldOverrideInTextNode && Object.defineProperty(textProto, memberName, memberProperty),
shouldOverrideInTextNode && nativeTextDescriptor && Object.defineProperty(textProto, nativeMemberName, nativeTextDescriptor),
shouldOverrideInCommentNode && Object.defineProperty(commProto, memberName, memberProperty),
shouldOverrideInCommentNode && nativeCommDescriptor && Object.defineProperty(commProto, nativeMemberName, nativeCommDescriptor);
}
});
}(), exports["default"] = version, Object.defineProperty(exports, "__esModule", {
value: !0
});
});
}, /* 53 */
/***/
function(module, exports) {
"use strict";
var _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
return typeof obj;
} : function(obj) {
return obj && "function" == typeof Symbol && obj.constructor === Symbol ? "symbol" : typeof obj;
};
!function() {
function isValidCustomElementName(name) {
return customNameValidation.test(name) && reservedTagList.indexOf(name) === -1;
}
function createTreeWalker(root) {
// IE 11 requires the third and fourth arguments be present. If the third
// arg is null, it applies the default behaviour. However IE also requires
// the fourth argument be present even though the other browsers ignore it.
return doc.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null, !1);
}
function isElement(node) {
return node.nodeType === Node.ELEMENT_NODE;
}
/**
* A registry of custom element definitions.
*
* See https://html.spec.whatwg.org/multipage/scripting.html#customelementsregistry
*
* @constructor
* @property {boolean} polyfilled Whether this registry is polyfilled
* @property {boolean} enableFlush Set to true to enable the flush() method
* to work. This should only be done for tests, as it causes a memory leak.
*/
function CustomElementsRegistry() {
/** @private {Map<string, CustomElementDefinition>} **/
this._definitions = new Map(), /** @private {Map<Function, CustomElementDefinition>} **/
this._constructors = new Map(), this._whenDefinedMap = new Map(), /** @private {Set<MutationObserver>} **/
this._observers = new Set(), /** @private {MutationObserver} **/
this._attributeObserver = new MutationObserver(this._handleAttributeChange.bind(this)),
/** @private {HTMLElement} **/
this._newInstance = null, this.polyfilled = !0, this.enableFlush = !1, this._observeRoot(document);
}
var doc = document, win = window, reservedTagList = [ "annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph" ], customNameValidation = /^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/;
CustomElementsRegistry.prototype = {
// HTML spec part 4.13.4
// https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsregistry-define
define: function(name, constructor, options) {
function getCallback(calllbackName) {
var callback = prototype[calllbackName];
if (void 0 !== callback && "function" != typeof callback) throw new Error(localName + " '" + calllbackName + "' is not a Function");
return callback;
}
// 1:
if (name = name.toString().toLowerCase(), "function" != typeof constructor) throw new TypeError("constructor must be a Constructor");
// 2. If constructor is an interface object whose corresponding interface
// either is HTMLElement or has HTMLElement in its set of inherited
// interfaces, throw a TypeError and abort these steps.
//
// It doesn't appear possible to check this condition from script
// 3:
if (!isValidCustomElementName(name)) throw new SyntaxError("The element name '" + name + "' is not valid.");
// 4, 5:
// Note: we don't track being-defined names and constructors because
// define() isn't normally reentrant. The only time user code can run
// during define() is when getting callbacks off the prototype, which
// would be highly-unusual. We can make define() reentrant-safe if needed.
if (this._definitions.has(name)) throw new Error("An element with name '" + name + "' is already defined");
// 6, 7:
if (this._constructors.has(constructor)) throw new Error("Definition failed for '" + name + "': The constructor is already used.");
// 8:
var localName = name, prototype = constructor.prototype;
// 14.2:
if ("object" !== ("undefined" == typeof prototype ? "undefined" : _typeof(prototype))) throw new TypeError("Definition failed for '" + name + "': constructor.prototype must be an object");
// 3, 4:
var connectedCallback = getCallback("connectedCallback"), disconnectedCallback = getCallback("disconnectedCallback"), attributeChangedCallback = getCallback("attributeChangedCallback"), observedAttributes = constructor.observedAttributes || [], definition = {
name: name,
localName: localName,
constructor: constructor,
connectedCallback: connectedCallback,
disconnectedCallback: disconnectedCallback,
attributeChangedCallback: attributeChangedCallback,
observedAttributes: observedAttributes
};
// 16:
this._definitions.set(localName, definition), this._constructors.set(constructor, localName),
// 17, 18, 19:
this._addNodes(doc.childNodes);
// 20:
var deferred = this._whenDefinedMap.get(localName);
deferred && (deferred.resolve(void 0), this._whenDefinedMap["delete"](localName));
},
/**
* Returns the constructor defined for `name`, or `null`.
*
* @param {string} name
* @return {Function|undefined}
*/
get: function(name) {
// https://html.spec.whatwg.org/multipage/scripting.html#custom-elements-api
var def = this._definitions.get(name);
return def ? def.constructor : void 0;
},
/**
* Returns a `Promise` that resolves when a custom element for `name` has
* been defined.
*
* @param {string} name
* @return {Promise}
*/
whenDefined: function(name) {
// https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementsregistry-whendefined
if (!customNameValidation.test(name)) return Promise.reject(new SyntaxError("The element name '" + name + "' is not valid."));
if (this._definitions.has(name)) return Promise.resolve();
var deferred = {
promise: null
};
return deferred.promise = new Promise(function(resolve, _) {
deferred.resolve = resolve;
}), this._whenDefinedMap.set(name, deferred), deferred.promise;
},
/**
* Causes all pending mutation records to be processed, and thus all
* customization, upgrades and custom element reactions to be called.
* `enableFlush` must be true for this to work. Only use during tests!
*/
flush: function() {
this.enableFlush && (console.warn("flush!!!"), this._observers.forEach(function(observer) {
this._handleMutations(observer.takeRecords());
}, this));
},
_setNewInstance: function(instance) {
this._newInstance = instance;
},
/**
* Observes a DOM root for mutations that trigger upgrades and reactions.
* @private
*/
_observeRoot: function(root) {
root.__observer = new MutationObserver(this._handleMutations.bind(this)), root.__observer.observe(root, {
childList: !0,
subtree: !0
}), this.enableFlush && // this is memory leak, only use in tests
this._observers.add(root.__observer);
},
/**
* @private
*/
_unobserveRoot: function(root) {
root.__observer && (root.__observer.disconnect(), root.__observer = null, this.enableFlush && this._observers["delete"](root.__observer));
},
/**
* @private
*/
_handleMutations: function(mutations) {
for (var i = 0; i < mutations.length; i++) {
var mutation = mutations[i];
"childList" === mutation.type && (// Note: we can't get an ordering between additions and removals, and
// so might diverge from spec reaction ordering
this._addNodes(mutation.addedNodes), this._removeNodes(mutation.removedNodes));
}
},
/**
* @param {NodeList} nodeList
* @private
*/
_addNodes: function(nodeList) {
for (var i = 0; i < nodeList.length; i++) {
var root = nodeList[i];
if (isElement(root)) {
// Since we're adding this node to an observed tree, we can unobserve
this._unobserveRoot(root);
var walker = createTreeWalker(root);
do {
var node = /** @type {HTMLElement} */ walker.currentNode, definition = this._definitions.get(node.localName);
if (definition && (node.__upgraded || this._upgradeElement(node, definition, !0),
node.__upgraded && !node.__attached && (node.__attached = !0, definition && definition.connectedCallback && definition.connectedCallback.call(node))),
node.shadowRoot && // TODO(justinfagnani): do we need to check that the shadowRoot
// is observed?
this._addNodes(node.shadowRoot.childNodes), "LINK" === node.tagName) {
var onLoad = function() {
var link = node;
return function() {
link.removeEventListener("load", onLoad), this._observeRoot(link["import"]), this._addNodes(link["import"].childNodes);
}.bind(this);
}.bind(this)();
node["import"] ? onLoad() : node.addEventListener("load", onLoad);
}
} while (walker.nextNode());
}
}
},
/**
* @param {NodeList} nodeList
* @private
*/
_removeNodes: function(nodeList) {
for (var i = 0; i < nodeList.length; i++) {
var root = nodeList[i];
if (isElement(root)) {
// Since we're detatching this element from an observed root, we need to
// reobserve it.
// TODO(justinfagnani): can we do this in a microtask so we don't thrash
// on creating and destroying MutationObservers on batch DOM mutations?
this._observeRoot(root);
var walker = createTreeWalker(root);
do {
var node = walker.currentNode;
if (node.__upgraded && node.__attached) {
node.__attached = !1;
var definition = this._definitions.get(node.localName);
definition && definition.disconnectedCallback && definition.disconnectedCallback.call(node);
}
} while (walker.nextNode());
}
}
},
/**
* Upgrades or customizes a custom element.
*
* @param {HTMLElement} element
* @param {CustomElementDefinition} definition
* @param {boolean} callConstructor
* @private
*/
_upgradeElement: function(element, definition, callConstructor) {
var prototype = definition.constructor.prototype;
element.__proto__ = prototype, callConstructor && (this._setNewInstance(element),
element.__upgraded = !0, new definition.constructor(), console.assert(null == this._newInstance));
var observedAttributes = definition.observedAttributes;
if (definition.attributeChangedCallback && observedAttributes.length > 0) {
this._attributeObserver.observe(element, {
attributes: !0,
attributeOldValue: !0,
attributeFilter: observedAttributes
});
// Trigger attributeChangedCallback for existing attributes.
// https://html.spec.whatwg.org/multipage/scripting.html#upgrades
for (var i = 0; i < observedAttributes.length; i++) {
var name = observedAttributes[i];
if (element.hasAttribute(name)) {
var value = element.getAttribute(name);
element.attributeChangedCallback(name, null, value);
}
}
}
},
/**
* @private
*/
_handleAttributeChange: function(mutations) {
for (var i = 0; i < mutations.length; i++) {
var mutation = mutations[i];
if ("attributes" === mutation.type) {
var name = mutation.attributeName, oldValue = mutation.oldValue, target = mutation.target, newValue = target.getAttribute(name), namespace = mutation.attributeNamespace;
target.attributeChangedCallback(name, oldValue, newValue, namespace);
}
}
}
}, // Closure Compiler Exports
window.CustomElementsRegistry = CustomElementsRegistry, CustomElementsRegistry.prototype.define = CustomElementsRegistry.prototype.define,
CustomElementsRegistry.prototype.get = CustomElementsRegistry.prototype.get, CustomElementsRegistry.prototype.whenDefined = CustomElementsRegistry.prototype.whenDefined,
CustomElementsRegistry.prototype.flush = CustomElementsRegistry.prototype.flush,
CustomElementsRegistry.prototype.polyfilled = CustomElementsRegistry.prototype.polyfilled,
CustomElementsRegistry.prototype.enableFlush = CustomElementsRegistry.prototype.enableFlush;
// patch window.HTMLElement
var origHTMLElement = win.HTMLElement;
win.HTMLElement = function() {
var customElements = win.customElements;
if (customElements._newInstance) {
var i = customElements._newInstance;
return customElements._newInstance = null, i;
}
if (this.constructor) {
var tagName = customElements._constructors.get(this.constructor);
return doc._createElement(tagName, !1);
}
throw new Error("unknown constructor. Did you call customElements.define()?");
}, win.HTMLElement.prototype = Object.create(origHTMLElement.prototype), Object.defineProperty(win.HTMLElement.prototype, "constructor", {
value: win.HTMLElement
});
for (var htmlElementSubclasses = [ "Button", "Canvas", "Data", "Head", "Mod", "TableCell", "TableCol", "Anchor", "Area", "Base", "Body", "BR", "DataList", "Details", "Dialog", "Div", "DList", "Embed", "FieldSet", "Form", "Heading", "HR", "Html", "IFrame", "Image", "Input", "Keygen", "Label", "Legend", "LI", "Link", "Map", "Media", "Menu", "MenuItem", "Meta", "Meter", "Object", "OList", "OptGroup", "Option", "Output", "Paragraph", "Param", "Picture", "Pre", "Progress", "Quote", "Script", "Select", "Slot", "Source", "Span", "Style", "TableCaption", "Table", "TableRow", "TableSection", "Template", "TextArea", "Time", "Title", "Track", "UList", "Unknown" ], i = 0; i < htmlElementSubclasses.length; i++) {
var ctor = window["HTML" + htmlElementSubclasses[i] + "Element"];
ctor && (ctor.prototype.__proto__ = win.HTMLElement.prototype);
}
// patch doc.createElement
var rawCreateElement = doc.createElement;
doc._createElement = function(tagName, callConstructor) {
var customElements = win.customElements, element = rawCreateElement.call(doc, tagName), definition = customElements._definitions.get(tagName.toLowerCase());
return definition && customElements._upgradeElement(element, definition, callConstructor),
customElements._observeRoot(element), element;
}, doc.createElement = function(tagName) {
return doc._createElement(tagName, !0);
};
// patch doc.createElementNS
var _origCreateElementNS = doc.createElementNS;
doc.createElementNS = function(namespaceURI, qualifiedName) {
return "http://www.w3.org/1999/xhtml" === namespaceURI ? doc.createElement(qualifiedName) : _origCreateElementNS.call(document, namespaceURI, qualifiedName);
};
// patch Element.attachShadow
var _origAttachShadow = Element.prototype.attachShadow;
_origAttachShadow && Object.defineProperty(Element.prototype, "attachShadow", {
value: function(options) {
var root = _origAttachShadow.call(this, options), customElements = win.customElements;
return customElements._observeRoot(root), root;
}
}), /** @type {CustomElementsRegistry} */
window.customElements = new CustomElementsRegistry();
}();
} ]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment