/* onsenui v2.10.10 - 2019-07-29 */ import ons from './ons/index.js'; import './ons/platform'; import './ons/microevent.js'; function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; } var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; var classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; var createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var fastclick = createCommonjsModule(function (module) { (function () { function FastClick(layer, options) { var oldOnClick; options = options || {}; /** * Whether a click is currently being tracked. * * @type boolean */ this.trackingClick = false; /** * Timestamp for when click tracking started. * * @type number */ this.trackingClickStart = 0; /** * The element being tracked for a click. * * @type EventTarget */ this.targetElement = null; /** * X-coordinate of touch start event. * * @type number */ this.touchStartX = 0; /** * Y-coordinate of touch start event. * * @type number */ this.touchStartY = 0; /** * ID of the last touch, retrieved from Touch.identifier. * * @type number */ this.lastTouchIdentifier = 0; /** * Touchmove boundary, beyond which a click will be cancelled. * * @type number */ this.touchBoundary = options.touchBoundary || 10; /** * The FastClick layer. * * @type Element */ this.layer = layer; /** * The minimum time between tap(touchstart and touchend) events * * @type number */ this.tapDelay = options.tapDelay || 200; /** * The maximum time for a tap * * @type number */ this.tapTimeout = options.tapTimeout || 700; if (FastClick.notNeeded(layer)) { return; } // Some old versions of Android don't have Function.prototype.bind function bind(method, context) { return function () { return method.apply(context, arguments); }; } var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel']; var context = this; for (var i = 0, l = methods.length; i < l; i++) { context[methods[i]] = bind(context[methods[i]], context); } // Set up event handlers as required if (deviceIsAndroid) { layer.addEventListener('mouseover', this.onMouse, true); layer.addEventListener('mousedown', this.onMouse, true); layer.addEventListener('mouseup', this.onMouse, true); } layer.addEventListener('click', this.onClick, true); layer.addEventListener('touchstart', this.onTouchStart, false); layer.addEventListener('touchmove', this.onTouchMove, false); layer.addEventListener('touchend', this.onTouchEnd, false); layer.addEventListener('touchcancel', this.onTouchCancel, false); // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick // layer when they are cancelled. if (!Event.prototype.stopImmediatePropagation) { layer.removeEventListener = function (type, callback, capture) { var rmv = Node.prototype.removeEventListener; if (type === 'click') { rmv.call(layer, type, callback.hijacked || callback, capture); } else { rmv.call(layer, type, callback, capture); } }; layer.addEventListener = function (type, callback, capture) { var adv = Node.prototype.addEventListener; if (type === 'click') { adv.call(layer, type, callback.hijacked || (callback.hijacked = function (event) { if (!event.propagationStopped) { callback(event); } }), capture); } else { adv.call(layer, type, callback, capture); } }; } // If a handler is already declared in the element's onclick attribute, it will be fired before // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and // adding it as listener. if (typeof layer.onclick === 'function') { // Android browser on at least 3.2 requires a new reference to the function in layer.onclick // - the old one won't work if passed to addEventListener directly. oldOnClick = layer.onclick; layer.addEventListener('click', function (event) { oldOnClick(event); }, false); layer.onclick = null; } } /** * Windows Phone 8.1 fakes user agent string to look like Android and iPhone. * * @type boolean */ var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0; /** * Android requires exceptions. * * @type boolean */ var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone; /** * iOS requires exceptions. * * @type boolean */ var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone; /** * iOS 4 requires an exception for select elements. * * @type boolean */ var deviceIsIOS4 = deviceIsIOS && /OS 4_\d(_\d)?/.test(navigator.userAgent); /** * iOS 6.0-7.* requires the target element to be manually derived * * @type boolean */ var deviceIsIOSWithBadTarget = deviceIsIOS && /OS [6-7]_\d/.test(navigator.userAgent); /** * BlackBerry requires exceptions. * * @type boolean */ var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0; /** * Valid types for text inputs * * @type array */ var textFields = ['email', 'number', 'password', 'search', 'tel', 'text', 'url']; /** * Determine whether a given element requires a native click. * * @param {EventTarget|Element} target Target DOM element * @returns {boolean} Returns true if the element needs a native click */ FastClick.prototype.needsClick = function (target) { switch (target.nodeName.toLowerCase()) { // Don't send a synthetic click to disabled inputs (issue #62) case 'button': case 'select': case 'textarea': if (target.disabled) { return true; } break; case 'input': // File inputs need real clicks on iOS 6 due to a browser bug (issue #68) if (deviceIsIOS && target.type === 'file' || target.disabled) { return true; } break; case 'label': case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames case 'video': return true; } return (/\bneedsclick\b/.test(target.className) ); }; /** * Determine whether a given element requires a call to focus to simulate click into element. * * @param {EventTarget|Element} target Target DOM element * @returns {boolean} Returns true if the element requires a call to focus to simulate native click. */ FastClick.prototype.needsFocus = function (target) { switch (target.nodeName.toLowerCase()) { case 'textarea': return true; case 'select': return !deviceIsAndroid; case 'input': switch (target.type) { case 'button': case 'checkbox': case 'file': case 'image': case 'radio': case 'submit': return false; } // No point in attempting to focus disabled inputs return !target.disabled && !target.readOnly; default: return (/\bneedsfocus\b/.test(target.className) ); } }; /** * Send a click event to the specified element. * * @param {EventTarget|Element} targetElement * @param {Event} event */ FastClick.prototype.sendClick = function (targetElement, event) { var clickEvent, touch; // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24) if (document.activeElement && document.activeElement !== targetElement) { document.activeElement.blur(); } touch = event.changedTouches[0]; // Synthesise a click event, with an extra attribute so it can be tracked clickEvent = document.createEvent('MouseEvents'); clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null); clickEvent.forwardedTouchEvent = true; targetElement.dispatchEvent(clickEvent); }; FastClick.prototype.determineEventType = function (targetElement) { //Issue #159: Android Chrome Select Box does not open with a synthetic click event if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') { return 'mousedown'; } return 'click'; }; /** * @param {EventTarget|Element} targetElement */ FastClick.prototype.focus = function (targetElement) { var length; // Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724. if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email' && targetElement.type !== 'number') { length = targetElement.value.length; targetElement.setSelectionRange(length, length); } else { targetElement.focus(); } }; /** * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it. * * @param {EventTarget|Element} targetElement */ FastClick.prototype.updateScrollParent = function (targetElement) { var scrollParent, parentElement; scrollParent = targetElement.fastClickScrollParent; // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the // target element was moved to another parent. if (!scrollParent || !scrollParent.contains(targetElement)) { parentElement = targetElement; do { if (parentElement.scrollHeight > parentElement.offsetHeight) { scrollParent = parentElement; targetElement.fastClickScrollParent = parentElement; break; } parentElement = parentElement.parentElement; } while (parentElement); } // Always update the scroll top tracker if possible. if (scrollParent) { scrollParent.fastClickLastScrollTop = scrollParent.scrollTop; } }; /** * @param {EventTarget} targetElement * @returns {Element|EventTarget} */ FastClick.prototype.getTargetElementFromEventTarget = function (eventTarget) { // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node. if (eventTarget.nodeType === Node.TEXT_NODE) { return eventTarget.parentNode; } return eventTarget; }; /** * @param {EventTarget} targetElement * @returns {boolean} */ FastClick.prototype.isTextField = function (targetElement) { return targetElement.tagName.toLowerCase() === 'textarea' || textFields.indexOf(targetElement.type) !== -1; }; /** * On touch start, record the position and scroll offset. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onTouchStart = function (event) { var targetElement, touch; // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111). if (event.targetTouches.length > 1) { return true; } targetElement = this.getTargetElementFromEventTarget(event.target); touch = event.targetTouches[0]; // Ignore touches on contenteditable elements to prevent conflict with text selection. // (For details: https://github.com/ftlabs/fastclick/pull/211 ) if (targetElement.isContentEditable) { return true; } if (deviceIsIOS) { // Ignore touchstart in focused text field // Allows normal text selection and commands (select/paste/cut) when a field has focus, while still allowing fast tap-to-focus. // Without this fix, user needs to tap-and-hold a text field for context menu, and double-tap to select text doesn't work at all. if (targetElement === document.activeElement && this.isTextField(targetElement)) { return true; } if (!deviceIsIOS4) { // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23): // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched // with the same identifier as the touch event that previously triggered the click that triggered the alert. // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform. // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string, // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long, // random integers, it's safe to to continue if the identifier is 0 here. if (touch.identifier && touch.identifier === this.lastTouchIdentifier) { event.preventDefault(); return false; } this.lastTouchIdentifier = touch.identifier; // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and: // 1) the user does a fling scroll on the scrollable layer // 2) the user stops the fling scroll with another tap // then the event.target of the last 'touchend' event will be the element that was under the user's finger // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42). this.updateScrollParent(targetElement); } } this.trackingClick = true; this.trackingClickStart = event.timeStamp; this.targetElement = targetElement; this.touchStartX = touch.pageX; this.touchStartY = touch.pageY; // Prevent phantom clicks on fast double-tap (issue #36) if (event.timeStamp - this.lastClickTime < this.tapDelay && event.timeStamp - this.lastClickTime > -1) { event.preventDefault(); } return true; }; /** * Based on a touchmove event object, check whether the touch has moved past a boundary since it started. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.touchHasMoved = function (event) { var touch = event.changedTouches[0], boundary = this.touchBoundary; if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) { return true; } return false; }; /** * Update the last position. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onTouchMove = function (event) { if (!this.trackingClick) { return true; } // If the touch has moved, cancel the click tracking if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) { this.trackingClick = false; this.targetElement = null; } return true; }; /** * Attempt to find the labelled control for the given label element. * * @param {EventTarget|HTMLLabelElement} labelElement * @returns {Element|null} */ FastClick.prototype.findControl = function (labelElement) { // Fast path for newer browsers supporting the HTML5 control attribute if (labelElement.control !== undefined) { return labelElement.control; } // All browsers under test that support touch events also support the HTML5 htmlFor attribute if (labelElement.htmlFor) { return document.getElementById(labelElement.htmlFor); } // If no for attribute exists, attempt to retrieve the first labellable descendant element // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea'); }; /** * On touch end, determine whether to send a click event at once. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onTouchEnd = function (event) { var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement; if (!this.trackingClick) { return true; } // Prevent phantom clicks on fast double-tap (issue #36) if (event.timeStamp - this.lastClickTime < this.tapDelay && event.timeStamp - this.lastClickTime > -1) { this.cancelNextClick = true; return true; } if (event.timeStamp - this.trackingClickStart > this.tapTimeout) { return true; } // Reset to prevent wrong click cancel on input (issue #156). this.cancelNextClick = false; this.lastClickTime = event.timeStamp; trackingClickStart = this.trackingClickStart; this.trackingClick = false; this.trackingClickStart = 0; // On some iOS devices, the targetElement supplied with the event is invalid if the layer // is performing a transition or scroll, and has to be re-detected manually. Note that // for this to function correctly, it must be called *after* the event target is checked! // See issue #57; also filed as rdar://13048589 . if (deviceIsIOSWithBadTarget) { touch = event.changedTouches[0]; // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement; targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent; } targetTagName = targetElement.tagName.toLowerCase(); if (targetTagName === 'label') { forElement = this.findControl(targetElement); if (forElement) { this.focus(targetElement); if (deviceIsAndroid) { return false; } targetElement = forElement; } } else if (this.needsFocus(targetElement)) { // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through. // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37). if (event.timeStamp - trackingClickStart > 100 || deviceIsIOS && window.top !== window && targetTagName === 'input') { this.targetElement = null; return false; } this.focus(targetElement); this.sendClick(targetElement, event); // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open. // Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others) if (!deviceIsIOS4 || targetTagName !== 'select') { this.targetElement = null; event.preventDefault(); } return false; } if (deviceIsIOS && !deviceIsIOS4) { // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42). scrollParent = targetElement.fastClickScrollParent; if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) { return true; } } // Prevent the actual click from going though - unless the target node is marked as requiring // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted. if (!this.needsClick(targetElement)) { event.preventDefault(); this.sendClick(targetElement, event); } return false; }; /** * On touch cancel, stop tracking the click. * * @returns {void} */ FastClick.prototype.onTouchCancel = function () { this.trackingClick = false; this.targetElement = null; }; /** * Determine mouse events which should be permitted. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onMouse = function (event) { // If a target element was never set (because a touch event was never fired) allow the event if (!this.targetElement) { return true; } if (event.forwardedTouchEvent) { return true; } // Programmatically generated events targeting a specific element should be permitted if (!event.cancelable) { return true; } // Derive and check the target element to see whether the mouse event needs to be permitted; // unless explicitly enabled, prevent non-touch click events from triggering actions, // to prevent ghost/doubleclicks. if (!this.needsClick(this.targetElement) || this.cancelNextClick) { // Prevent any user-added listeners declared on FastClick element from being fired. if (event.stopImmediatePropagation) { event.stopImmediatePropagation(); } else { // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2) event.propagationStopped = true; } // Cancel the event event.stopPropagation(); event.preventDefault(); return false; } // If the mouse event is permitted, return true for the action to go through. return true; }; /** * On actual clicks, determine whether this is a touch-generated click, a click action occurring * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or * an actual click which should be permitted. * * @param {Event} event * @returns {boolean} */ FastClick.prototype.onClick = function (event) { var permitted; // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early. if (this.trackingClick) { this.targetElement = null; this.trackingClick = false; return true; } // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target. if (event.target.type === 'submit' && event.detail === 0) { return true; } permitted = this.onMouse(event); // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through. if (!permitted) { this.targetElement = null; } // If clicks are permitted, return true for the action to go through. return permitted; }; /** * Remove all FastClick's event listeners. * * @returns {void} */ FastClick.prototype.destroy = function () { var layer = this.layer; if (deviceIsAndroid) { layer.removeEventListener('mouseover', this.onMouse, true); layer.removeEventListener('mousedown', this.onMouse, true); layer.removeEventListener('mouseup', this.onMouse, true); } layer.removeEventListener('click', this.onClick, true); layer.removeEventListener('touchstart', this.onTouchStart, false); layer.removeEventListener('touchmove', this.onTouchMove, false); layer.removeEventListener('touchend', this.onTouchEnd, false); layer.removeEventListener('touchcancel', this.onTouchCancel, false); }; /** * Check whether FastClick is needed. * * @param {Element} layer The layer to listen on */ FastClick.notNeeded = function (layer) { var metaViewport; var chromeVersion; var blackberryVersion; var firefoxVersion; // Devices that don't support touch don't need FastClick if (typeof window.ontouchstart === 'undefined') { return true; } // Chrome version - zero for other browsers chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [, 0])[1]; if (chromeVersion) { if (deviceIsAndroid) { metaViewport = document.querySelector('meta[name=viewport]'); if (metaViewport) { // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89) if (metaViewport.content.indexOf('user-scalable=no') !== -1) { return true; } // Chrome 32 and above with width=device-width or less don't need FastClick if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) { return true; } } // Chrome desktop doesn't need FastClick (issue #15) } else { return true; } } if (deviceIsBlackBerry10) { blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/); // BlackBerry 10.3+ does not require Fastclick library. // https://github.com/ftlabs/fastclick/issues/251 if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) { metaViewport = document.querySelector('meta[name=viewport]'); if (metaViewport) { // user-scalable=no eliminates click delay. if (metaViewport.content.indexOf('user-scalable=no') !== -1) { return true; } // width=device-width (or less than device-width) eliminates click delay. if (document.documentElement.scrollWidth <= window.outerWidth) { return true; } } } } // IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97) if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') { return true; } // Firefox version - zero for other browsers firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [, 0])[1]; if (firefoxVersion >= 27) { // Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896 metaViewport = document.querySelector('meta[name=viewport]'); if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) { return true; } } // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') { return true; } return false; }; /** * Factory method for creating a FastClick object * * @param {Element} layer The layer to listen on * @param {Object} [options={}] The options to override the defaults */ FastClick.attach = function (layer, options) { return new FastClick(layer, options); }; if (typeof undefined === 'function' && _typeof(undefined.amd) === 'object' && undefined.amd) { // AMD. Register as an anonymous module. undefined(function () { return FastClick; }); } else if ('object' !== 'undefined' && module.exports) { module.exports = FastClick.attach; module.exports.FastClick = FastClick; } else { window.FastClick = FastClick; } })(); }); var fastclick_1 = fastclick.FastClick; // For @onsenui/custom-elements if (window.customElements) { // even if native CE1 impl exists, use polyfill window.customElements.forcePolyfill = true; } var _global = createCommonjsModule(function (module) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef }); var _core = createCommonjsModule(function (module) { var core = module.exports = { version: '2.5.1' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef }); var _core_1 = _core.version; var _isObject = function _isObject(it) { return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function'; }; var _anObject = function _anObject(it) { if (!_isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; var _fails = function _fails(exec) { try { return !!exec(); } catch (e) { return true; } }; // Thank's IE8 for his funny defineProperty var _descriptors = !_fails(function () { return Object.defineProperty({}, 'a', { get: function get() { return 7; } }).a != 7; }); var document$1 = _global.document; // typeof document.createElement is 'object' in old IE var is = _isObject(document$1) && _isObject(document$1.createElement); var _domCreate = function _domCreate(it) { return is ? document$1.createElement(it) : {}; }; var _ie8DomDefine = !_descriptors && !_fails(function () { return Object.defineProperty(_domCreate('div'), 'a', { get: function get() { return 7; } }).a != 7; }); // 7.1.1 ToPrimitive(input [, PreferredType]) // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string var _toPrimitive = function _toPrimitive(it, S) { if (!_isObject(it)) return it; var fn, val; if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) return val; if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) return val; throw TypeError("Can't convert object to primitive value"); }; var dP = Object.defineProperty; var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) { _anObject(O); P = _toPrimitive(P, true); _anObject(Attributes); if (_ie8DomDefine) try { return dP(O, P, Attributes); } catch (e) {/* empty */} if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); if ('value' in Attributes) O[P] = Attributes.value; return O; }; var _objectDp = { f: f }; var _propertyDesc = function _propertyDesc(bitmap, value) { return { enumerable: !(bitmap & 1), configurable: !(bitmap & 2), writable: !(bitmap & 4), value: value }; }; var _hide = _descriptors ? function (object, key, value) { return _objectDp.f(object, key, _propertyDesc(1, value)); } : function (object, key, value) { object[key] = value; return object; }; var hasOwnProperty = {}.hasOwnProperty; var _has = function _has(it, key) { return hasOwnProperty.call(it, key); }; var id = 0; var px = Math.random(); var _uid = function _uid(key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; var _redefine = createCommonjsModule(function (module) { var SRC = _uid('src'); var TO_STRING = 'toString'; var $toString = Function[TO_STRING]; var TPL = ('' + $toString).split(TO_STRING); _core.inspectSource = function (it) { return $toString.call(it); }; (module.exports = function (O, key, val, safe) { var isFunction = typeof val == 'function'; if (isFunction) _has(val, 'name') || _hide(val, 'name', key); if (O[key] === val) return; if (isFunction) _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); if (O === _global) { O[key] = val; } else if (!safe) { delete O[key]; _hide(O, key, val); } else if (O[key]) { O[key] = val; } else { _hide(O, key, val); } // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative })(Function.prototype, TO_STRING, function toString() { return typeof this == 'function' && this[SRC] || $toString.call(this); }); }); var _aFunction = function _aFunction(it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; // optional / simple context binding var _ctx = function _ctx(fn, that, length) { _aFunction(fn); if (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); }; }; var PROTOTYPE = 'prototype'; var $export = function $export(type, name, source) { var IS_FORCED = type & $export.F; var IS_GLOBAL = type & $export.G; var IS_STATIC = type & $export.S; var IS_PROTO = type & $export.P; var IS_BIND = type & $export.B; var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE]; var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {}); var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); var key, own, out, exp; if (IS_GLOBAL) source = name; for (key in source) { // contains in native own = !IS_FORCED && target && target[key] !== undefined; // export native or passed out = (own ? target : source)[key]; // bind timers to global for call from export context exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out; // extend global if (target) _redefine(target, key, out, type & $export.U); // export if (exports[key] != out) _hide(exports, key, exp); if (IS_PROTO && expProto[key] != out) expProto[key] = out; } }; _global.core = _core; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` var _export = $export; var f$2 = {}.propertyIsEnumerable; var _objectPie = { f: f$2 }; var toString = {}.toString; var _cof = function _cof(it) { return toString.call(it).slice(8, -1); }; // fallback for non-array-like ES3 and non-enumerable old V8 strings // eslint-disable-next-line no-prototype-builtins var _iobject = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return _cof(it) == 'String' ? it.split('') : Object(it); }; // 7.2.1 RequireObjectCoercible(argument) var _defined = function _defined(it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; // to indexed object, toObject with fallback for non-array-like ES3 strings var _toIobject = function _toIobject(it) { return _iobject(_defined(it)); }; var gOPD = Object.getOwnPropertyDescriptor; var f$1 = _descriptors ? gOPD : function getOwnPropertyDescriptor(O, P) { O = _toIobject(O); P = _toPrimitive(P, true); if (_ie8DomDefine) try { return gOPD(O, P); } catch (e) {/* empty */} if (_has(O, P)) return _propertyDesc(!_objectPie.f.call(O, P), O[P]); }; var _objectGopd = { f: f$1 }; // Works with __proto__ only. Old v8 can't work with null proto objects. /* eslint-disable no-proto */ var check = function check(O, proto) { _anObject(O); if (!_isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); }; var _setProto = { set: Object.setPrototypeOf || ('__proto__' in {} ? // eslint-disable-line function (test, buggy, set) { try { set = _ctx(Function.call, _objectGopd.f(Object.prototype, '__proto__').set, 2); set(test, []); buggy = !(test instanceof Array); } catch (e) { buggy = true; } return function setPrototypeOf(O, proto) { check(O, proto); if (buggy) O.__proto__ = proto;else set(O, proto); return O; }; }({}, false) : undefined), check: check }; // 19.1.3.19 Object.setPrototypeOf(O, proto) _export(_export.S, 'Object', { setPrototypeOf: _setProto.set }); var setPrototypeOf = _core.Object.setPrototypeOf; var SHARED = '__core-js_shared__'; var store = _global[SHARED] || (_global[SHARED] = {}); var _shared = function _shared(key) { return store[key] || (store[key] = {}); }; var _wks = createCommonjsModule(function (module) { var store = _shared('wks'); var _Symbol = _global.Symbol; var USE_SYMBOL = typeof _Symbol == 'function'; var $exports = module.exports = function (name) { return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : _uid)('Symbol.' + name)); }; $exports.store = store; }); // getting tag from 19.1.3.6 Object.prototype.toString() var TAG = _wks('toStringTag'); // ES3 wrong here var ARG = _cof(function () { return arguments; }()) == 'Arguments'; // fallback for IE11 Script Access Denied error var tryGet = function tryGet(it, key) { try { return it[key]; } catch (e) {/* empty */} }; var _classof = function _classof(it) { var O, T, B; return it === undefined ? 'Undefined' : it === null ? 'Null' // @@toStringTag case : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T // builtinTag case : ARG ? _cof(O) // ES3 arguments fallback : (B = _cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; }; // 19.1.3.6 Object.prototype.toString() var test = {}; test[_wks('toStringTag')] = 'z'; if (test + '' != '[object z]') { _redefine(Object.prototype, 'toString', function toString() { return '[object ' + _classof(this) + ']'; }, true); } // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; var _toInteger = function _toInteger(it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; // true -> String#at // false -> String#codePointAt var _stringAt = function _stringAt(TO_STRING) { return function (that, pos) { var s = String(_defined(that)); var i = _toInteger(pos); var l = s.length; var a, b; if (i < 0 || i >= l) return TO_STRING ? '' : undefined; a = s.charCodeAt(i); return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; }; }; var _library = false; var _iterators = {}; // 7.1.15 ToLength var min = Math.min; var _toLength = function _toLength(it) { return it > 0 ? min(_toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; var max = Math.max; var min$1 = Math.min; var _toAbsoluteIndex = function _toAbsoluteIndex(index, length) { index = _toInteger(index); return index < 0 ? max(index + length, 0) : min$1(index, length); }; // false -> Array#indexOf // true -> Array#includes var _arrayIncludes = function _arrayIncludes(IS_INCLUDES) { return function ($this, el, fromIndex) { var O = _toIobject($this); var length = _toLength(O.length); var index = _toAbsoluteIndex(fromIndex, length); var value; // Array#includes uses SameValueZero equality algorithm // eslint-disable-next-line no-self-compare if (IS_INCLUDES && el != el) while (length > index) { value = O[index++]; // eslint-disable-next-line no-self-compare if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not } else for (; length > index; index++) { if (IS_INCLUDES || index in O) { if (O[index] === el) return IS_INCLUDES || index || 0; } }return !IS_INCLUDES && -1; }; }; var shared = _shared('keys'); var _sharedKey = function _sharedKey(key) { return shared[key] || (shared[key] = _uid(key)); }; var arrayIndexOf = _arrayIncludes(false); var IE_PROTO$1 = _sharedKey('IE_PROTO'); var _objectKeysInternal = function _objectKeysInternal(object, names) { var O = _toIobject(object); var i = 0; var result = []; var key; for (key in O) { if (key != IE_PROTO$1) _has(O, key) && result.push(key); } // Don't enum bug & hidden keys while (names.length > i) { if (_has(O, key = names[i++])) { ~arrayIndexOf(result, key) || result.push(key); } }return result; }; // IE 8- don't enum bug keys var _enumBugKeys = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(','); // 19.1.2.14 / 15.2.3.14 Object.keys(O) var _objectKeys = Object.keys || function keys(O) { return _objectKeysInternal(O, _enumBugKeys); }; var _objectDps = _descriptors ? Object.defineProperties : function defineProperties(O, Properties) { _anObject(O); var keys = _objectKeys(Properties); var length = keys.length; var i = 0; var P; while (length > i) { _objectDp.f(O, P = keys[i++], Properties[P]); }return O; }; var document$2 = _global.document; var _html = document$2 && document$2.documentElement; // 19.1.2.2 / 15.2.3.5 Object.create(O [, Properties]) var IE_PROTO = _sharedKey('IE_PROTO'); var Empty = function Empty() {/* empty */}; var PROTOTYPE$1 = 'prototype'; // Create object with fake `null` prototype: use iframe Object with cleared prototype var _createDict = function createDict() { // Thrash, waste and sodomy: IE GC bug var iframe = _domCreate('iframe'); var i = _enumBugKeys.length; var lt = '<'; var gt = '>'; var 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(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); iframeDocument.close(); _createDict = iframeDocument.F; while (i--) { delete _createDict[PROTOTYPE$1][_enumBugKeys[i]]; }return _createDict(); }; var _objectCreate = Object.create || function create(O, Properties) { var result; if (O !== null) { Empty[PROTOTYPE$1] = _anObject(O); result = new Empty(); Empty[PROTOTYPE$1] = null; // add "__proto__" for Object.getPrototypeOf polyfill result[IE_PROTO] = O; } else result = _createDict(); return Properties === undefined ? result : _objectDps(result, Properties); }; var def = _objectDp.f; var TAG$1 = _wks('toStringTag'); var _setToStringTag = function _setToStringTag(it, tag, stat) { if (it && !_has(it = stat ? it : it.prototype, TAG$1)) def(it, TAG$1, { configurable: true, value: tag }); }; var IteratorPrototype = {}; // 25.1.2.1.1 %IteratorPrototype%[@@iterator]() _hide(IteratorPrototype, _wks('iterator'), function () { return this; }); var _iterCreate = function _iterCreate(Constructor, NAME, next) { Constructor.prototype = _objectCreate(IteratorPrototype, { next: _propertyDesc(1, next) }); _setToStringTag(Constructor, NAME + ' Iterator'); }; // 7.1.13 ToObject(argument) var _toObject = function _toObject(it) { return Object(_defined(it)); }; // 19.1.2.9 / 15.2.3.2 Object.getPrototypeOf(O) var IE_PROTO$2 = _sharedKey('IE_PROTO'); var ObjectProto = Object.prototype; var _objectGpo = Object.getPrototypeOf || function (O) { O = _toObject(O); if (_has(O, IE_PROTO$2)) return O[IE_PROTO$2]; if (typeof O.constructor == 'function' && O instanceof O.constructor) { return O.constructor.prototype; }return O instanceof Object ? ObjectProto : null; }; var ITERATOR = _wks('iterator'); var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next` var FF_ITERATOR = '@@iterator'; var KEYS = 'keys'; var VALUES = 'values'; var returnThis = function returnThis() { return this; }; var _iterDefine = function _iterDefine(Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { _iterCreate(Constructor, NAME, next); var getMethod = function getMethod(kind) { if (!BUGGY && kind in proto) return proto[kind]; switch (kind) { case KEYS: return function keys() { return new Constructor(this, kind); }; case VALUES: return function values() { return new Constructor(this, kind); }; }return function entries() { return new Constructor(this, kind); }; }; var TAG = NAME + ' Iterator'; var DEF_VALUES = DEFAULT == VALUES; var VALUES_BUG = false; var proto = Base.prototype; var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; var $default = $native || getMethod(DEFAULT); var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; var methods, key, IteratorPrototype; // Fix native if ($anyNative) { IteratorPrototype = _objectGpo($anyNative.call(new Base())); if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { // Set @@toStringTag to native iterators _setToStringTag(IteratorPrototype, TAG, true); // fix for some old engines if (!_library && !_has(IteratorPrototype, ITERATOR)) _hide(IteratorPrototype, ITERATOR, returnThis); } } // fix Array#{values, @@iterator}.name in V8 / FF if (DEF_VALUES && $native && $native.name !== VALUES) { VALUES_BUG = true; $default = function values() { return $native.call(this); }; } // Define iterator if ((!_library || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { _hide(proto, ITERATOR, $default); } // Plug for library _iterators[NAME] = $default; _iterators[TAG] = returnThis; if (DEFAULT) { methods = { values: DEF_VALUES ? $default : getMethod(VALUES), keys: IS_SET ? $default : getMethod(KEYS), entries: $entries }; if (FORCED) for (key in methods) { if (!(key in proto)) _redefine(proto, key, methods[key]); } else _export(_export.P + _export.F * (BUGGY || VALUES_BUG), NAME, methods); } return methods; }; var $at = _stringAt(true); // 21.1.3.27 String.prototype[@@iterator]() _iterDefine(String, 'String', function (iterated) { this._t = String(iterated); // target this._i = 0; // next index // 21.1.5.2.1 %StringIteratorPrototype%.next() }, function () { var O = this._t; var index = this._i; var point; if (index >= O.length) return { value: undefined, done: true }; point = $at(O, index); this._i += point.length; return { value: point, done: false }; }); // 22.1.3.31 Array.prototype[@@unscopables] var UNSCOPABLES = _wks('unscopables'); var ArrayProto = Array.prototype; if (ArrayProto[UNSCOPABLES] == undefined) _hide(ArrayProto, UNSCOPABLES, {}); var _addToUnscopables = function _addToUnscopables(key) { ArrayProto[UNSCOPABLES][key] = true; }; var _iterStep = function _iterStep(done, value) { return { value: value, done: !!done }; }; // 22.1.3.4 Array.prototype.entries() // 22.1.3.13 Array.prototype.keys() // 22.1.3.29 Array.prototype.values() // 22.1.3.30 Array.prototype[@@iterator]() var es6_array_iterator = _iterDefine(Array, 'Array', function (iterated, kind) { this._t = _toIobject(iterated); // target this._i = 0; // next index this._k = kind; // kind // 22.1.5.2.1 %ArrayIteratorPrototype%.next() }, function () { var O = this._t; var kind = this._k; var index = this._i++; if (!O || index >= O.length) { this._t = undefined; return _iterStep(1); } if (kind == 'keys') return _iterStep(0, index); if (kind == 'values') return _iterStep(0, O[index]); return _iterStep(0, [index, O[index]]); }, 'values'); // argumentsList[@@iterator] is %ArrayProto_values% (9.4.4.6, 9.4.4.7) _iterators.Arguments = _iterators.Array; _addToUnscopables('keys'); _addToUnscopables('values'); _addToUnscopables('entries'); var ITERATOR$1 = _wks('iterator'); var TO_STRING_TAG = _wks('toStringTag'); var ArrayValues = _iterators.Array; var DOMIterables = { CSSRuleList: true, // TODO: Not spec compliant, should be false. CSSStyleDeclaration: false, CSSValueList: false, ClientRectList: false, DOMRectList: false, DOMStringList: false, DOMTokenList: true, DataTransferItemList: false, FileList: false, HTMLAllCollection: false, HTMLCollection: false, HTMLFormElement: false, HTMLSelectElement: false, MediaList: true, // TODO: Not spec compliant, should be false. MimeTypeArray: false, NamedNodeMap: false, NodeList: true, PaintRequestList: false, Plugin: false, PluginArray: false, SVGLengthList: false, SVGNumberList: false, SVGPathSegList: false, SVGPointList: false, SVGStringList: false, SVGTransformList: false, SourceBufferList: false, StyleSheetList: true, // TODO: Not spec compliant, should be false. TextTrackCueList: false, TextTrackList: false, TouchList: false }; for (var collections = _objectKeys(DOMIterables), i = 0; i < collections.length; i++) { var NAME = collections[i]; var explicit = DOMIterables[NAME]; var Collection = _global[NAME]; var proto = Collection && Collection.prototype; var key; if (proto) { if (!proto[ITERATOR$1]) _hide(proto, ITERATOR$1, ArrayValues); if (!proto[TO_STRING_TAG]) _hide(proto, TO_STRING_TAG, NAME); _iterators[NAME] = ArrayValues; if (explicit) for (key in es6_array_iterator) { if (!proto[key]) _redefine(proto, key, es6_array_iterator[key], true); } } } var _redefineAll = function _redefineAll(target, src, safe) { for (var key in src) { _redefine(target, key, src[key], safe); }return target; }; var _anInstance = function _anInstance(it, Constructor, name, forbiddenField) { if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) { throw TypeError(name + ': incorrect invocation!'); }return it; }; // call something on iterator step with safe closing on error var _iterCall = function _iterCall(iterator, fn, value, entries) { try { return entries ? fn(_anObject(value)[0], value[1]) : fn(value); // 7.4.6 IteratorClose(iterator, completion) } catch (e) { var ret = iterator['return']; if (ret !== undefined) _anObject(ret.call(iterator)); throw e; } }; // check on default Array iterator var ITERATOR$2 = _wks('iterator'); var ArrayProto$1 = Array.prototype; var _isArrayIter = function _isArrayIter(it) { return it !== undefined && (_iterators.Array === it || ArrayProto$1[ITERATOR$2] === it); }; var ITERATOR$3 = _wks('iterator'); var core_getIteratorMethod = _core.getIteratorMethod = function (it) { if (it != undefined) return it[ITERATOR$3] || it['@@iterator'] || _iterators[_classof(it)]; }; var _forOf = createCommonjsModule(function (module) { var BREAK = {}; var RETURN = {}; var exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable); var f = _ctx(fn, that, entries ? 2 : 1); var index = 0; var length, step, iterator, result; if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); // fast case for arrays with default iterator if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) { result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); if (result === BREAK || result === RETURN) return result; } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { result = _iterCall(iterator, f, step.value, entries); if (result === BREAK || result === RETURN) return result; } }; exports.BREAK = BREAK; exports.RETURN = RETURN; }); var SPECIES = _wks('species'); var _setSpecies = function _setSpecies(KEY) { var C = _global[KEY]; if (_descriptors && C && !C[SPECIES]) _objectDp.f(C, SPECIES, { configurable: true, get: function get() { return this; } }); }; var _meta = createCommonjsModule(function (module) { var META = _uid('meta'); var setDesc = _objectDp.f; var id = 0; var isExtensible = Object.isExtensible || function () { return true; }; var FREEZE = !_fails(function () { return isExtensible(Object.preventExtensions({})); }); var setMeta = function setMeta(it) { setDesc(it, META, { value: { i: 'O' + ++id, // object ID w: {} // weak collections IDs } }); }; var fastKey = function fastKey(it, create) { // return primitive with prefix if (!_isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; if (!_has(it, META)) { // can't set metadata to uncaught frozen object if (!isExtensible(it)) return 'F'; // not necessary to add metadata if (!create) return 'E'; // add missing metadata setMeta(it); // return object ID }return it[META].i; }; var getWeak = function getWeak(it, create) { if (!_has(it, META)) { // can't set metadata to uncaught frozen object if (!isExtensible(it)) return true; // not necessary to add metadata if (!create) return false; // add missing metadata setMeta(it); // return hash weak collections IDs }return it[META].w; }; // add metadata on freeze-family methods calling var onFreeze = function onFreeze(it) { if (FREEZE && meta.NEED && isExtensible(it) && !_has(it, META)) setMeta(it); return it; }; var meta = module.exports = { KEY: META, NEED: false, fastKey: fastKey, getWeak: getWeak, onFreeze: onFreeze }; }); var _meta_1 = _meta.KEY; var _meta_2 = _meta.NEED; var _meta_3 = _meta.fastKey; var _meta_4 = _meta.getWeak; var _meta_5 = _meta.onFreeze; var _validateCollection = function _validateCollection(it, TYPE) { if (!_isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); return it; }; var dP$1 = _objectDp.f; var fastKey = _meta.fastKey; var SIZE = _descriptors ? '_s' : 'size'; var getEntry = function getEntry(that, key) { // fast case var index = fastKey(key); var entry; if (index !== 'F') return that._i[index]; // frozen object case for (entry = that._f; entry; entry = entry.n) { if (entry.k == key) return entry; } }; var _collectionStrong = { getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) { var C = wrapper(function (that, iterable) { _anInstance(that, C, NAME, '_i'); that._t = NAME; // collection type that._i = _objectCreate(null); // index that._f = undefined; // first entry that._l = undefined; // last entry that[SIZE] = 0; // size if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); }); _redefineAll(C.prototype, { // 23.1.3.1 Map.prototype.clear() // 23.2.3.2 Set.prototype.clear() clear: function clear() { for (var that = _validateCollection(this, NAME), data = that._i, entry = that._f; entry; entry = entry.n) { entry.r = true; if (entry.p) entry.p = entry.p.n = undefined; delete data[entry.i]; } that._f = that._l = undefined; that[SIZE] = 0; }, // 23.1.3.3 Map.prototype.delete(key) // 23.2.3.4 Set.prototype.delete(value) 'delete': function _delete(key) { var that = _validateCollection(this, NAME); var entry = getEntry(that, key); if (entry) { var next = entry.n; var prev = entry.p; delete that._i[entry.i]; entry.r = true; if (prev) prev.n = next; if (next) next.p = prev; if (that._f == entry) that._f = next; if (that._l == entry) that._l = prev; that[SIZE]--; }return !!entry; }, // 23.2.3.6 Set.prototype.forEach(callbackfn, thisArg = undefined) // 23.1.3.5 Map.prototype.forEach(callbackfn, thisArg = undefined) forEach: function forEach(callbackfn /* , that = undefined */) { _validateCollection(this, NAME); var f = _ctx(callbackfn, arguments.length > 1 ? arguments[1] : undefined, 3); var entry; while (entry = entry ? entry.n : this._f) { f(entry.v, entry.k, this); // revert to the last existing entry while (entry && entry.r) { entry = entry.p; } } }, // 23.1.3.7 Map.prototype.has(key) // 23.2.3.7 Set.prototype.has(value) has: function has(key) { return !!getEntry(_validateCollection(this, NAME), key); } }); if (_descriptors) dP$1(C.prototype, 'size', { get: function get() { return _validateCollection(this, NAME)[SIZE]; } }); return C; }, def: function def(that, key, value) { var entry = getEntry(that, key); var prev, index; // change existing entry if (entry) { entry.v = value; // create new entry } else { that._l = entry = { i: index = fastKey(key, true), // <- index k: key, // <- key v: value, // <- value p: prev = that._l, // <- previous entry n: undefined, // <- next entry r: false // <- removed }; if (!that._f) that._f = entry; if (prev) prev.n = entry; that[SIZE]++; // add to index if (index !== 'F') that._i[index] = entry; }return that; }, getEntry: getEntry, setStrong: function setStrong(C, NAME, IS_MAP) { // add .keys, .values, .entries, [@@iterator] // 23.1.3.4, 23.1.3.8, 23.1.3.11, 23.1.3.12, 23.2.3.5, 23.2.3.8, 23.2.3.10, 23.2.3.11 _iterDefine(C, NAME, function (iterated, kind) { this._t = _validateCollection(iterated, NAME); // target this._k = kind; // kind this._l = undefined; // previous }, function () { var that = this; var kind = that._k; var entry = that._l; // revert to the last existing entry while (entry && entry.r) { entry = entry.p; } // get next entry if (!that._t || !(that._l = entry = entry ? entry.n : that._t._f)) { // or finish the iteration that._t = undefined; return _iterStep(1); } // return step by kind if (kind == 'keys') return _iterStep(0, entry.k); if (kind == 'values') return _iterStep(0, entry.v); return _iterStep(0, [entry.k, entry.v]); }, IS_MAP ? 'entries' : 'values', !IS_MAP, true); // add [@@species], 23.1.2.2, 23.2.2.2 _setSpecies(NAME); } }; var ITERATOR$4 = _wks('iterator'); var SAFE_CLOSING = false; try { var riter = [7][ITERATOR$4](); riter['return'] = function () { SAFE_CLOSING = true; }; // eslint-disable-next-line no-throw-literal } catch (e) {/* empty */} var _iterDetect = function _iterDetect(exec, skipClosing) { if (!skipClosing && !SAFE_CLOSING) return false; var safe = false; try { var arr = [7]; var iter = arr[ITERATOR$4](); iter.next = function () { return { done: safe = true }; }; arr[ITERATOR$4] = function () { return iter; }; exec(arr); } catch (e) {/* empty */} return safe; }; var setPrototypeOf$2 = _setProto.set; var _inheritIfRequired = function _inheritIfRequired(that, target, C) { var S = target.constructor; var P; if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && _isObject(P) && setPrototypeOf$2) { setPrototypeOf$2(that, P); }return that; }; var _collection = function _collection(NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { var Base = _global[NAME]; var C = Base; var ADDER = IS_MAP ? 'set' : 'add'; var proto = C && C.prototype; var O = {}; var fixMethod = function fixMethod(KEY) { var fn = proto[KEY]; _redefine(proto, KEY, KEY == 'delete' ? function (a) { return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); } : KEY == 'has' ? function has(a) { return IS_WEAK && !_isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); } : KEY == 'get' ? function get(a) { return IS_WEAK && !_isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); } : KEY == 'add' ? function add(a) { fn.call(this, a === 0 ? 0 : a);return this; } : function set(a, b) { fn.call(this, a === 0 ? 0 : a, b);return this; }); }; if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !_fails(function () { new C().entries().next(); }))) { // create collection constructor C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); _redefineAll(C.prototype, methods); _meta.NEED = true; } else { var instance = new C(); // early implementations not supports chaining var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; // V8 ~ Chromium 40- weak-collections throws on primitives, but should return false var THROWS_ON_PRIMITIVES = _fails(function () { instance.has(1); }); // most early implementations doesn't supports iterables, most modern - not close it correctly var ACCEPT_ITERABLES = _iterDetect(function (iter) { new C(iter); }); // eslint-disable-line no-new // for early implementations -0 and +0 not the same var BUGGY_ZERO = !IS_WEAK && _fails(function () { // V8 ~ Chromium 42- fails only with 5+ elements var $instance = new C(); var index = 5; while (index--) { $instance[ADDER](index, index); }return !$instance.has(-0); }); if (!ACCEPT_ITERABLES) { C = wrapper(function (target, iterable) { _anInstance(target, C, NAME); var that = _inheritIfRequired(new Base(), target, C); if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); return that; }); C.prototype = proto; proto.constructor = C; } if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { fixMethod('delete'); fixMethod('has'); IS_MAP && fixMethod('get'); } if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); // weak collections should not contains .clear method if (IS_WEAK && proto.clear) delete proto.clear; } _setToStringTag(C, NAME); O[NAME] = C; _export(_export.G + _export.W + _export.F * (C != Base), O); if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); return C; }; var SET = 'Set'; // 23.2 Set Objects var es6_set = _collection(SET, function (get) { return function Set() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; }, { // 23.2.3.1 Set.prototype.add(value) add: function add(value) { return _collectionStrong.def(_validateCollection(this, SET), value = value === 0 ? 0 : value, value); } }, _collectionStrong); var _arrayFromIterable = function _arrayFromIterable(iter, ITERATOR) { var result = []; _forOf(iter, false, result.push, result, ITERATOR); return result; }; // https://github.com/DavidBruant/Map-Set.prototype.toJSON var _collectionToJson = function _collectionToJson(NAME) { return function toJSON() { if (_classof(this) != NAME) throw TypeError(NAME + "#toJSON isn't generic"); return _arrayFromIterable(this); }; }; // https://github.com/DavidBruant/Map-Set.prototype.toJSON _export(_export.P + _export.R, 'Set', { toJSON: _collectionToJson('Set') }); // https://tc39.github.io/proposal-setmap-offrom/ var _setCollectionOf = function _setCollectionOf(COLLECTION) { _export(_export.S, COLLECTION, { of: function of() { var length = arguments.length; var A = Array(length); while (length--) { A[length] = arguments[length]; }return new this(A); } }); }; // https://tc39.github.io/proposal-setmap-offrom/#sec-set.of _setCollectionOf('Set'); // https://tc39.github.io/proposal-setmap-offrom/ var _setCollectionFrom = function _setCollectionFrom(COLLECTION) { _export(_export.S, COLLECTION, { from: function from(source /* , mapFn, thisArg */) { var mapFn = arguments[1]; var mapping, A, n, cb; _aFunction(this); mapping = mapFn !== undefined; if (mapping) _aFunction(mapFn); if (source == undefined) return new this(); A = []; if (mapping) { n = 0; cb = _ctx(mapFn, arguments[2], 2); _forOf(source, false, function (nextItem) { A.push(cb(nextItem, n++)); }); } else { _forOf(source, false, A.push, A); } return new this(A); } }); }; // https://tc39.github.io/proposal-setmap-offrom/#sec-set.from _setCollectionFrom('Set'); var set$1 = _core.Set; var MAP = 'Map'; // 23.1 Map Objects var es6_map = _collection(MAP, function (get) { return function Map() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; }, { // 23.1.3.6 Map.prototype.get(key) get: function get(key) { var entry = _collectionStrong.getEntry(_validateCollection(this, MAP), key); return entry && entry.v; }, // 23.1.3.9 Map.prototype.set(key, value) set: function set(key, value) { return _collectionStrong.def(_validateCollection(this, MAP), key === 0 ? 0 : key, value); } }, _collectionStrong, true); // https://github.com/DavidBruant/Map-Set.prototype.toJSON _export(_export.P + _export.R, 'Map', { toJSON: _collectionToJson('Map') }); // https://tc39.github.io/proposal-setmap-offrom/#sec-map.of _setCollectionOf('Map'); // https://tc39.github.io/proposal-setmap-offrom/#sec-map.from _setCollectionFrom('Map'); var map = _core.Map; // 7.2.2 IsArray(argument) var _isArray = Array.isArray || function isArray(arg) { return _cof(arg) == 'Array'; }; var SPECIES$1 = _wks('species'); var _arraySpeciesConstructor = function _arraySpeciesConstructor(original) { var C; if (_isArray(original)) { C = original.constructor; // cross-realm fallback if (typeof C == 'function' && (C === Array || _isArray(C.prototype))) C = undefined; if (_isObject(C)) { C = C[SPECIES$1]; if (C === null) C = undefined; } }return C === undefined ? Array : C; }; // 9.4.2.3 ArraySpeciesCreate(originalArray, length) var _arraySpeciesCreate = function _arraySpeciesCreate(original, length) { return new (_arraySpeciesConstructor(original))(length); }; // 0 -> Array#forEach // 1 -> Array#map // 2 -> Array#filter // 3 -> Array#some // 4 -> Array#every // 5 -> Array#find // 6 -> Array#findIndex var _arrayMethods = function _arrayMethods(TYPE, $create) { var IS_MAP = TYPE == 1; var IS_FILTER = TYPE == 2; var IS_SOME = TYPE == 3; var IS_EVERY = TYPE == 4; var IS_FIND_INDEX = TYPE == 6; var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; var create = $create || _arraySpeciesCreate; return function ($this, callbackfn, that) { var O = _toObject($this); var self = _iobject(O); var f = _ctx(callbackfn, that, 3); var length = _toLength(self.length); var index = 0; var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; var 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; }; }; var f$3 = Object.getOwnPropertySymbols; var _objectGops = { f: f$3 }; // 19.1.2.1 Object.assign(target, source, ...) var $assign = Object.assign; // should work with symbols and should have deterministic property order (V8 bug) var _objectAssign = !$assign || _fails(function () { var A = {}; var B = {}; // eslint-disable-next-line no-undef var S = Symbol(); var K = 'abcdefghijklmnopqrst'; A[S] = 7; K.split('').forEach(function (k) { B[k] = k; }); return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; }) ? function assign(target, source) { // eslint-disable-line no-unused-vars var T = _toObject(target); var aLen = arguments.length; var index = 1; var getSymbols = _objectGops.f; var isEnum = _objectPie.f; while (aLen > index) { var S = _iobject(arguments[index++]); var keys = getSymbols ? _objectKeys(S).concat(getSymbols(S)) : _objectKeys(S); var length = keys.length; var j = 0; var key; while (length > j) { if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; } }return T; } : $assign; var getWeak = _meta.getWeak; var arrayFind = _arrayMethods(5); var arrayFindIndex = _arrayMethods(6); var id$1 = 0; // fallback for uncaught frozen keys var uncaughtFrozenStore = function uncaughtFrozenStore(that) { return that._l || (that._l = new UncaughtFrozenStore()); }; var UncaughtFrozenStore = function UncaughtFrozenStore() { this.a = []; }; var findUncaughtFrozen = function findUncaughtFrozen(store, key) { return arrayFind(store.a, function (it) { return it[0] === key; }); }; UncaughtFrozenStore.prototype = { get: function get(key) { var entry = findUncaughtFrozen(this, key); if (entry) return entry[1]; }, has: function has(key) { return !!findUncaughtFrozen(this, key); }, set: function set(key, value) { var entry = findUncaughtFrozen(this, key); if (entry) entry[1] = value;else this.a.push([key, value]); }, 'delete': function _delete(key) { var index = arrayFindIndex(this.a, function (it) { return it[0] === key; }); if (~index) this.a.splice(index, 1); return !!~index; } }; var _collectionWeak = { getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) { var C = wrapper(function (that, iterable) { _anInstance(that, C, NAME, '_i'); that._t = NAME; // collection type that._i = id$1++; // collection id that._l = undefined; // leak store for uncaught frozen objects if (iterable != undefined) _forOf(iterable, IS_MAP, that[ADDER], that); }); _redefineAll(C.prototype, { // 23.3.3.2 WeakMap.prototype.delete(key) // 23.4.3.3 WeakSet.prototype.delete(value) 'delete': function _delete(key) { if (!_isObject(key)) return false; var data = getWeak(key); if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME))['delete'](key); return data && _has(data, this._i) && delete data[this._i]; }, // 23.3.3.4 WeakMap.prototype.has(key) // 23.4.3.4 WeakSet.prototype.has(value) has: function has(key) { if (!_isObject(key)) return false; var data = getWeak(key); if (data === true) return uncaughtFrozenStore(_validateCollection(this, NAME)).has(key); return data && _has(data, this._i); } }); return C; }, def: function def(that, key, value) { var data = getWeak(_anObject(key), true); if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value; return that; }, ufstore: uncaughtFrozenStore }; var es6_weakMap = createCommonjsModule(function (module) { var each = _arrayMethods(0); var WEAK_MAP = 'WeakMap'; var getWeak = _meta.getWeak; var isExtensible = Object.isExtensible; var uncaughtFrozenStore = _collectionWeak.ufstore; var tmp = {}; var InternalMap; var wrapper = function wrapper(get) { return function WeakMap() { return get(this, arguments.length > 0 ? arguments[0] : undefined); }; }; var methods = { // 23.3.3.3 WeakMap.prototype.get(key) get: function get(key) { if (_isObject(key)) { var data = getWeak(key); if (data === true) return uncaughtFrozenStore(_validateCollection(this, WEAK_MAP)).get(key); return data ? data[this._i] : undefined; } }, // 23.3.3.5 WeakMap.prototype.set(key, value) set: function set(key, value) { return _collectionWeak.def(_validateCollection(this, WEAK_MAP), key, value); } }; // 23.3 WeakMap Objects var $WeakMap = module.exports = _collection(WEAK_MAP, wrapper, methods, _collectionWeak, true, true); // IE11 WeakMap frozen keys fix if (_fails(function () { return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; })) { InternalMap = _collectionWeak.getConstructor(wrapper, WEAK_MAP); _objectAssign(InternalMap.prototype, methods); _meta.NEED = true; each(['delete', 'has', 'get', 'set'], function (key) { var proto = $WeakMap.prototype; var method = proto[key]; _redefine(proto, key, function (a, b) { // store frozen objects on internal weakmap shim if (_isObject(a) && !isExtensible(a)) { if (!this._f) this._f = new InternalMap(); var result = this._f[key](a, b); return key == 'set' ? this : result; // store all the rest on native weakmap }return method.call(this, a, b); }); }); } }); // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.of _setCollectionOf('WeakMap'); // https://tc39.github.io/proposal-setmap-offrom/#sec-weakmap.from _setCollectionFrom('WeakMap'); var weakMap = _core.WeakMap; var _createProperty = function _createProperty(object, index, value) { if (index in object) _objectDp.f(object, index, _propertyDesc(0, value));else object[index] = value; }; _export(_export.S + _export.F * !_iterDetect(function (iter) { }), 'Array', { // 22.1.2.1 Array.from(arrayLike, mapfn = undefined, thisArg = undefined) from: function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) { var O = _toObject(arrayLike); var C = typeof this == 'function' ? this : Array; var aLen = arguments.length; var mapfn = aLen > 1 ? arguments[1] : undefined; var mapping = mapfn !== undefined; var index = 0; var iterFn = core_getIteratorMethod(O); var length, result, step, iterator; if (mapping) mapfn = _ctx(mapfn, aLen > 2 ? arguments[2] : undefined, 2); // if object isn't iterable or it's array with default iterator - use simple case if (iterFn != undefined && !(C == Array && _isArrayIter(iterFn))) { for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { _createProperty(result, index, mapping ? _iterCall(iterator, mapfn, [step.value, index], true) : step.value); } } else { length = _toLength(O.length); for (result = new C(length); length > index; index++) { _createProperty(result, index, mapping ? mapfn(O[index], index) : O[index]); } } result.length = index; return result; } }); var from$1 = _core.Array.from; var reservedTagList = new Set(['annotation-xml', 'color-profile', 'font-face', 'font-face-src', 'font-face-uri', 'font-face-format', 'font-face-name', 'missing-glyph']); /** * @param {string} localName * @returns {boolean} */ function isValidCustomElementName(localName) { var reserved = reservedTagList.has(localName); var validForm = /^[a-z][.0-9_a-z]*-[\-.0-9_a-z]*$/.test(localName); return !reserved && validForm; } /** * @private * @param {!Node} node * @return {boolean} */ function isConnected(node) { // Use `Node#isConnected`, if defined. var nativeValue = node.isConnected; if (nativeValue !== undefined) { return nativeValue; } /** @type {?Node|undefined} */ var current = node; while (current && !(current.__CE_isImportDocument || current instanceof Document)) { current = current.parentNode || (window.ShadowRoot && current instanceof ShadowRoot ? current.host : undefined); } return !!(current && (current.__CE_isImportDocument || current instanceof Document)); } /** * @param {!Node} root * @param {!Node} start * @return {?Node} */ function nextSiblingOrAncestorSibling(root, start) { var node = start; while (node && node !== root && !node.nextSibling) { node = node.parentNode; } return !node || node === root ? null : node.nextSibling; } /** * @param {!Node} root * @param {!Node} start * @return {?Node} */ function nextNode(root, start) { return start.firstChild ? start.firstChild : nextSiblingOrAncestorSibling(root, start); } /** * @param {!Node} root * @param {!function(!Element)} callback * @param {!Set=} visitedImports */ function walkDeepDescendantElements(root, callback) { var visitedImports = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set(); var node = root; while (node) { if (node.nodeType === Node.ELEMENT_NODE) { var element = /** @type {!Element} */node; callback(element); var localName = element.localName; if (localName === 'link' && element.getAttribute('rel') === 'import') { // If this import (polyfilled or not) has it's root node available, // walk it. var importNode = /** @type {!Node} */element.import; if (importNode instanceof Node && !visitedImports.has(importNode)) { // Prevent multiple walks of the same import root. visitedImports.add(importNode); for (var child = importNode.firstChild; child; child = child.nextSibling) { walkDeepDescendantElements(child, callback, visitedImports); } } // Ignore descendants of import links to prevent attempting to walk the // elements created by the HTML Imports polyfill that we just walked // above. node = nextSiblingOrAncestorSibling(root, element); continue; } else if (localName === 'template') { // Ignore descendants of templates. There shouldn't be any descendants // because they will be moved into `.content` during construction in // browsers that support template but, in case they exist and are still // waiting to be moved by a polyfill, they will be ignored. node = nextSiblingOrAncestorSibling(root, element); continue; } // Walk shadow roots. var shadowRoot = element.__CE_shadowRoot; if (shadowRoot) { for (var _child = shadowRoot.firstChild; _child; _child = _child.nextSibling) { walkDeepDescendantElements(_child, callback, visitedImports); } } } node = nextNode(root, node); } } /** * Used to suppress Closure's "Modifying the prototype is only allowed if the * constructor is in the same scope" warning without using * `@suppress {newCheckTypes, duplicate}` because `newCheckTypes` is too broad. * * @param {!Object} destination * @param {string} name * @param {*} value */ function setPropertyUnchecked(destination, name, value) { destination[name] = value; } /** * @enum {number} */ var CustomElementState = { custom: 1, failed: 2 }; var CustomElementInternals = function () { function CustomElementInternals() { classCallCheck(this, CustomElementInternals); /** @type {!Map} */ this._localNameToDefinition = new Map(); /** @type {!Map} */ this._constructorToDefinition = new Map(); /** @type {!Array} */ this._patches = []; /** @type {boolean} */ this._hasPatches = false; } /** * @param {string} localName * @param {!CustomElementDefinition} definition */ createClass(CustomElementInternals, [{ key: 'setDefinition', value: function setDefinition(localName, definition) { this._localNameToDefinition.set(localName, definition); this._constructorToDefinition.set(definition.constructor, definition); } /** * @param {string} localName * @return {!CustomElementDefinition|undefined} */ }, { key: 'localNameToDefinition', value: function localNameToDefinition(localName) { return this._localNameToDefinition.get(localName); } /** * @param {!Function} constructor * @return {!CustomElementDefinition|undefined} */ }, { key: 'constructorToDefinition', value: function constructorToDefinition(constructor) { return this._constructorToDefinition.get(constructor); } /** * @param {!function(!Node)} listener */ }, { key: 'addPatch', value: function addPatch(listener) { this._hasPatches = true; this._patches.push(listener); } /** * @param {!Node} node */ }, { key: 'patchTree', value: function patchTree(node) { var _this = this; if (!this._hasPatches) return; walkDeepDescendantElements(node, function (element) { return _this.patch(element); }); } /** * @param {!Node} node */ }, { key: 'patch', value: function patch(node) { if (!this._hasPatches) return; if (node.__CE_patched) return; node.__CE_patched = true; for (var i = 0; i < this._patches.length; i++) { this._patches[i](node); } } /** * @param {!Node} root */ }, { key: 'connectTree', value: function connectTree(root) { var elements = []; walkDeepDescendantElements(root, function (element) { return elements.push(element); }); for (var i = 0; i < elements.length; i++) { var element = elements[i]; if (element.__CE_state === CustomElementState.custom) { if (isConnected(element)) { this.connectedCallback(element); } } else { this.upgradeElement(element); } } } /** * @param {!Node} root */ }, { key: 'disconnectTree', value: function disconnectTree(root) { var elements = []; walkDeepDescendantElements(root, function (element) { return elements.push(element); }); for (var i = 0; i < elements.length; i++) { var element = elements[i]; if (element.__CE_state === CustomElementState.custom) { this.disconnectedCallback(element); } } } /** * Upgrades all uncustomized custom elements at and below a root node for * which there is a definition. When custom element reaction callbacks are * assumed to be called synchronously (which, by the current DOM / HTML spec * definitions, they are *not*), callbacks for both elements customized * synchronously by the parser and elements being upgraded occur in the same * relative order. * * NOTE: This function, when used to simulate the construction of a tree that * is already created but not customized (i.e. by the parser), does *not* * prevent the element from reading the 'final' (true) state of the tree. For * example, the element, during truly synchronous parsing / construction would * see that it contains no children as they have not yet been inserted. * However, this function does not modify the tree, the element will * (incorrectly) have children. Additionally, self-modification restrictions * for custom element constructors imposed by the DOM spec are *not* enforced. * * * The following nested list shows the steps extending down from the HTML * spec's parsing section that cause elements to be synchronously created and * upgraded: * * The "in body" insertion mode: * https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody * - Switch on token: * .. other cases .. * -> Any other start tag * - [Insert an HTML element](below) for the token. * * Insert an HTML element: * https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element * - Insert a foreign element for the token in the HTML namespace: * https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element * - Create an element for a token: * https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token * - Will execute script flag is true? * - (Element queue pushed to the custom element reactions stack.) * - Create an element: * https://dom.spec.whatwg.org/#concept-create-element * - Sync CE flag is true? * - Constructor called. * - Self-modification restrictions enforced. * - Sync CE flag is false? * - (Upgrade reaction enqueued.) * - Attributes appended to element. * (`attributeChangedCallback` reactions enqueued.) * - Will execute script flag is true? * - (Element queue popped from the custom element reactions stack. * Reactions in the popped stack are invoked.) * - (Element queue pushed to the custom element reactions stack.) * - Insert the element: * https://dom.spec.whatwg.org/#concept-node-insert * - Shadow-including descendants are connected. During parsing * construction, there are no shadow-*excluding* descendants. * However, the constructor may have validly attached a shadow * tree to itself and added descendants to that shadow tree. * (`connectedCallback` reactions enqueued.) * - (Element queue popped from the custom element reactions stack. * Reactions in the popped stack are invoked.) * * @param {!Node} root * @param {!Set=} visitedImports */ }, { key: 'patchAndUpgradeTree', value: function patchAndUpgradeTree(root) { var _this2 = this; var visitedImports = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set(); var elements = []; var gatherElements = function gatherElements(element) { if (element.localName === 'link' && element.getAttribute('rel') === 'import') { // The HTML Imports polyfill sets a descendant element of the link to // the `import` property, specifically this is *not* a Document. var importNode = /** @type {?Node} */element.import; if (importNode instanceof Node && importNode.readyState === 'complete') { importNode.__CE_isImportDocument = true; // Connected links are associated with the registry. importNode.__CE_hasRegistry = true; } else { // If this link's import root is not available, its contents can't be // walked. Wait for 'load' and walk it when it's ready. element.addEventListener('load', function () { var importNode = /** @type {!Node} */element.import; if (importNode.__CE_documentLoadHandled) return; importNode.__CE_documentLoadHandled = true; importNode.__CE_isImportDocument = true; // Connected links are associated with the registry. importNode.__CE_hasRegistry = true; // Clone the `visitedImports` set that was populated sync during // the `patchAndUpgradeTree` call that caused this 'load' handler to // be added. Then, remove *this* link's import node so that we can // walk that import again, even if it was partially walked later // during the same `patchAndUpgradeTree` call. visitedImports.delete(importNode); _this2.patchAndUpgradeTree(importNode, visitedImports); }); } } else { elements.push(element); } }; // `walkDeepDescendantElements` populates (and internally checks against) // `visitedImports` when traversing a loaded import. walkDeepDescendantElements(root, gatherElements, visitedImports); if (this._hasPatches) { for (var i = 0; i < elements.length; i++) { this.patch(elements[i]); } } for (var _i = 0; _i < elements.length; _i++) { this.upgradeElement(elements[_i]); } } /** * @param {!Element} element */ }, { key: 'upgradeElement', value: function upgradeElement(element) { var currentState = element.__CE_state; if (currentState !== undefined) return; var definition = this.localNameToDefinition(element.localName); if (!definition) return; definition.constructionStack.push(element); var constructor = definition.constructor; try { try { var result = new constructor(); if (result !== element) { throw new Error('The custom element constructor did not produce the element being upgraded.'); } } finally { definition.constructionStack.pop(); } } catch (e) { element.__CE_state = CustomElementState.failed; throw e; } element.__CE_state = CustomElementState.custom; element.__CE_definition = definition; if (definition.attributeChangedCallback) { var observedAttributes = definition.observedAttributes; for (var i = 0; i < observedAttributes.length; i++) { var name = observedAttributes[i]; var value = element.getAttribute(name); if (value !== null) { this.attributeChangedCallback(element, name, null, value, null); } } } if (isConnected(element)) { this.connectedCallback(element); } } /** * @param {!Element} element */ }, { key: 'connectedCallback', value: function connectedCallback(element) { var definition = element.__CE_definition; if (definition.connectedCallback) { definition.connectedCallback.call(element); } element.__CE_isConnectedCallbackCalled = true; } /** * @param {!Element} element */ }, { key: 'disconnectedCallback', value: function disconnectedCallback(element) { if (!element.__CE_isConnectedCallbackCalled) { this.connectedCallback(element); } var definition = element.__CE_definition; if (definition.disconnectedCallback) { definition.disconnectedCallback.call(element); } element.__CE_isConnectedCallbackCalled = undefined; } /** * @param {!Element} element * @param {string} name * @param {?string} oldValue * @param {?string} newValue * @param {?string} namespace */ }, { key: 'attributeChangedCallback', value: function attributeChangedCallback(element, name, oldValue, newValue, namespace) { var definition = element.__CE_definition; if (definition.attributeChangedCallback && definition.observedAttributes.indexOf(name) > -1) { definition.attributeChangedCallback.call(element, name, oldValue, newValue, namespace); } } }]); return CustomElementInternals; }(); var DocumentConstructionObserver = function () { function DocumentConstructionObserver(internals, doc) { classCallCheck(this, DocumentConstructionObserver); /** * @type {!CustomElementInternals} */ this._internals = internals; /** * @type {!Document} */ this._document = doc; /** * @type {MutationObserver|undefined} */ this._observer = undefined; // Simulate tree construction for all currently accessible nodes in the // document. this._internals.patchAndUpgradeTree(this._document); if (this._document.readyState === 'loading') { this._observer = new MutationObserver(this._handleMutations.bind(this)); // Nodes created by the parser are given to the observer *before* the next // task runs. Inline scripts are run in a new task. This means that the // observer will be able to handle the newly parsed nodes before the inline // script is run. this._observer.observe(this._document, { childList: true, subtree: true }); } } createClass(DocumentConstructionObserver, [{ key: 'disconnect', value: function disconnect() { if (this._observer) { this._observer.disconnect(); } } /** * @param {!Array} mutations */ }, { key: '_handleMutations', value: function _handleMutations(mutations) { // Once the document's `readyState` is 'interactive' or 'complete', all new // nodes created within that document will be the result of script and // should be handled by patching. var readyState = this._document.readyState; if (readyState === 'interactive' || readyState === 'complete') { this.disconnect(); } for (var i = 0; i < mutations.length; i++) { var addedNodes = mutations[i].addedNodes; for (var j = 0; j < addedNodes.length; j++) { var node = addedNodes[j]; this._internals.patchAndUpgradeTree(node); } } } }]); return DocumentConstructionObserver; }(); /** * @template T */ var Deferred = function () { function Deferred() { var _this = this; classCallCheck(this, Deferred); /** * @private * @type {T|undefined} */ this._value = undefined; /** * @private * @type {Function|undefined} */ this._resolve = undefined; /** * @private * @type {!Promise} */ this._promise = new Promise(function (resolve) { _this._resolve = resolve; if (_this._value) { resolve(_this._value); } }); } /** * @param {T} value */ createClass(Deferred, [{ key: 'resolve', value: function resolve(value) { if (this._value) { throw new Error('Already resolved.'); } this._value = value; if (this._resolve) { this._resolve(value); } } /** * @return {!Promise} */ }, { key: 'toPromise', value: function toPromise() { return this._promise; } }]); return Deferred; }(); /** * @unrestricted */ var CustomElementRegistry = function () { /** * @param {!CustomElementInternals} internals */ function CustomElementRegistry(internals) { classCallCheck(this, CustomElementRegistry); /** * @private * @type {boolean} */ this._elementDefinitionIsRunning = false; /** * @private * @type {!CustomElementInternals} */ this._internals = internals; /** * @private * @type {!Map>} */ this._whenDefinedDeferred = new Map(); /** * The default flush callback triggers the document walk synchronously. * @private * @type {!Function} */ this._flushCallback = function (fn) { return fn(); }; /** * @private * @type {boolean} */ this._flushPending = false; /** * @private * @type {!Array} */ this._unflushedLocalNames = []; /** * @private * @type {!DocumentConstructionObserver} */ this._documentConstructionObserver = new DocumentConstructionObserver(internals, document); } /** * @param {string} localName * @param {!Function} constructor */ createClass(CustomElementRegistry, [{ key: 'define', value: function define(localName, constructor) { var _this = this; if (!(constructor instanceof Function)) { throw new TypeError('Custom element constructors must be functions.'); } if (!isValidCustomElementName(localName)) { throw new SyntaxError('The element name \'' + localName + '\' is not valid.'); } if (this._internals.localNameToDefinition(localName)) { throw new Error('A custom element with name \'' + localName + '\' has already been defined.'); } if (this._elementDefinitionIsRunning) { throw new Error('A custom element is already being defined.'); } this._elementDefinitionIsRunning = true; var connectedCallback = void 0; var disconnectedCallback = void 0; var adoptedCallback = void 0; var attributeChangedCallback = void 0; var observedAttributes = void 0; try { var getCallback = function getCallback(name) { var callbackValue = prototype[name]; if (callbackValue !== undefined && !(callbackValue instanceof Function)) { throw new Error('The \'' + name + '\' callback must be a function.'); } return callbackValue; }; /** @type {!Object} */ var prototype = constructor.prototype; if (!(prototype instanceof Object)) { throw new TypeError('The custom element constructor\'s prototype is not an object.'); } connectedCallback = getCallback('connectedCallback'); disconnectedCallback = getCallback('disconnectedCallback'); adoptedCallback = getCallback('adoptedCallback'); attributeChangedCallback = getCallback('attributeChangedCallback'); observedAttributes = constructor['observedAttributes'] || []; } catch (e) { return; } finally { this._elementDefinitionIsRunning = false; } var definition = { localName: localName, constructor: constructor, connectedCallback: connectedCallback, disconnectedCallback: disconnectedCallback, adoptedCallback: adoptedCallback, attributeChangedCallback: attributeChangedCallback, observedAttributes: observedAttributes, constructionStack: [] }; this._internals.setDefinition(localName, definition); this._unflushedLocalNames.push(localName); // If we've already called the flush callback and it hasn't called back yet, // don't call it again. if (!this._flushPending) { this._flushPending = true; this._flushCallback(function () { return _this._flush(); }); } } }, { key: '_flush', value: function _flush() { // If no new definitions were defined, don't attempt to flush. This could // happen if a flush callback keeps the function it is given and calls it // multiple times. if (this._flushPending === false) return; this._flushPending = false; this._internals.patchAndUpgradeTree(document); while (this._unflushedLocalNames.length > 0) { var localName = this._unflushedLocalNames.shift(); var deferred = this._whenDefinedDeferred.get(localName); if (deferred) { deferred.resolve(undefined); } } } /** * @param {string} localName * @return {Function|undefined} */ }, { key: 'get', value: function get$$1(localName) { var definition = this._internals.localNameToDefinition(localName); if (definition) { return definition.constructor; } return undefined; } /** * @param {string} localName * @return {!Promise} */ }, { key: 'whenDefined', value: function whenDefined(localName) { if (!isValidCustomElementName(localName)) { return Promise.reject(new SyntaxError('\'' + localName + '\' is not a valid custom element name.')); } var prior = this._whenDefinedDeferred.get(localName); if (prior) { return prior.toPromise(); } var deferred = new Deferred(); this._whenDefinedDeferred.set(localName, deferred); var definition = this._internals.localNameToDefinition(localName); // Resolve immediately only if the given local name has a definition *and* // the full document walk to upgrade elements with that local name has // already happened. if (definition && this._unflushedLocalNames.indexOf(localName) === -1) { deferred.resolve(undefined); } return deferred.toPromise(); } }, { key: 'polyfillWrapFlushCallback', value: function polyfillWrapFlushCallback(outer) { this._documentConstructionObserver.disconnect(); var inner = this._flushCallback; this._flushCallback = function (flush) { return outer(function () { return inner(flush); }); }; } }]); return CustomElementRegistry; }(); window['CustomElementRegistry'] = CustomElementRegistry; CustomElementRegistry.prototype['define'] = CustomElementRegistry.prototype.define; CustomElementRegistry.prototype['get'] = CustomElementRegistry.prototype.get; CustomElementRegistry.prototype['whenDefined'] = CustomElementRegistry.prototype.whenDefined; CustomElementRegistry.prototype['polyfillWrapFlushCallback'] = CustomElementRegistry.prototype.polyfillWrapFlushCallback; var Native = { Document_createElement: window.Document.prototype.createElement, Document_createElementNS: window.Document.prototype.createElementNS, Document_importNode: window.Document.prototype.importNode, Document_prepend: window.Document.prototype['prepend'], Document_append: window.Document.prototype['append'], Node_cloneNode: window.Node.prototype.cloneNode, Node_appendChild: window.Node.prototype.appendChild, Node_insertBefore: window.Node.prototype.insertBefore, Node_removeChild: window.Node.prototype.removeChild, Node_replaceChild: window.Node.prototype.replaceChild, Node_textContent: Object.getOwnPropertyDescriptor(window.Node.prototype, 'textContent'), Element_attachShadow: window.Element.prototype['attachShadow'], Element_innerHTML: Object.getOwnPropertyDescriptor(window.Element.prototype, 'innerHTML'), Element_getAttribute: window.Element.prototype.getAttribute, Element_setAttribute: window.Element.prototype.setAttribute, Element_removeAttribute: window.Element.prototype.removeAttribute, Element_getAttributeNS: window.Element.prototype.getAttributeNS, Element_setAttributeNS: window.Element.prototype.setAttributeNS, Element_removeAttributeNS: window.Element.prototype.removeAttributeNS, Element_insertAdjacentElement: window.Element.prototype['insertAdjacentElement'], Element_prepend: window.Element.prototype['prepend'], Element_append: window.Element.prototype['append'], Element_before: window.Element.prototype['before'], Element_after: window.Element.prototype['after'], Element_replaceWith: window.Element.prototype['replaceWith'], Element_remove: window.Element.prototype['remove'], HTMLElement: window.HTMLElement, HTMLElement_innerHTML: Object.getOwnPropertyDescriptor(window.HTMLElement.prototype, 'innerHTML'), HTMLElement_insertAdjacentElement: window.HTMLElement.prototype['insertAdjacentElement'] }; /** * This class exists only to work around Closure's lack of a way to describe * singletons. It represents the 'already constructed marker' used in custom * element construction stacks. * * https://html.spec.whatwg.org/#concept-already-constructed-marker */ var AlreadyConstructedMarker = function AlreadyConstructedMarker() { classCallCheck(this, AlreadyConstructedMarker); }; var AlreadyConstructedMarker$1 = new AlreadyConstructedMarker(); /** * @param {!CustomElementInternals} internals */ var PatchHTMLElement = function (internals) { window['HTMLElement'] = function () { /** * @type {function(new: HTMLElement): !HTMLElement} */ function HTMLElement() { // This should really be `new.target` but `new.target` can't be emulated // in ES5. Assuming the user keeps the default value of the constructor's // prototype's `constructor` property, this is equivalent. /** @type {!Function} */ var constructor = this.constructor; var definition = internals.constructorToDefinition(constructor); if (!definition) { throw new Error('The custom element being constructed was not registered with `customElements`.'); } var constructionStack = definition.constructionStack; if (constructionStack.length === 0) { var _element = Native.Document_createElement.call(document, definition.localName); Object.setPrototypeOf(_element, constructor.prototype); _element.__CE_state = CustomElementState.custom; _element.__CE_definition = definition; internals.patch(_element); return _element; } var lastIndex = constructionStack.length - 1; var element = constructionStack[lastIndex]; if (element === AlreadyConstructedMarker$1) { throw new Error('The HTMLElement constructor was either called reentrantly for this constructor or called multiple times.'); } constructionStack[lastIndex] = AlreadyConstructedMarker$1; Object.setPrototypeOf(element, constructor.prototype); internals.patch( /** @type {!HTMLElement} */element); return element; } HTMLElement.prototype = Native.HTMLElement.prototype; return HTMLElement; }(); }; /** * @param {!CustomElementInternals} internals * @param {!Object} destination * @param {!ParentNodeNativeMethods} builtIn */ var PatchParentNode = function (internals, destination, builtIn) { /** * @param {...(!Node|string)} nodes */ destination['prepend'] = function () { for (var _len = arguments.length, nodes = Array(_len), _key = 0; _key < _len; _key++) { nodes[_key] = arguments[_key]; } // TODO: Fix this for when one of `nodes` is a DocumentFragment! var connectedBefore = /** @type {!Array} */nodes.filter(function (node) { // DocumentFragments are not connected and will not be added to the list. return node instanceof Node && isConnected(node); }); builtIn.prepend.apply(this, nodes); for (var i = 0; i < connectedBefore.length; i++) { internals.disconnectTree(connectedBefore[i]); } if (isConnected(this)) { for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; if (node instanceof Element) { internals.connectTree(node); } } } }; /** * @param {...(!Node|string)} nodes */ destination['append'] = function () { for (var _len2 = arguments.length, nodes = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { nodes[_key2] = arguments[_key2]; } // TODO: Fix this for when one of `nodes` is a DocumentFragment! var connectedBefore = /** @type {!Array} */nodes.filter(function (node) { // DocumentFragments are not connected and will not be added to the list. return node instanceof Node && isConnected(node); }); builtIn.append.apply(this, nodes); for (var i = 0; i < connectedBefore.length; i++) { internals.disconnectTree(connectedBefore[i]); } if (isConnected(this)) { for (var _i2 = 0; _i2 < nodes.length; _i2++) { var node = nodes[_i2]; if (node instanceof Element) { internals.connectTree(node); } } } }; }; /** * @param {!CustomElementInternals} internals */ var PatchDocument = function (internals) { setPropertyUnchecked(Document.prototype, 'createElement', /** * @this {Document} * @param {string} localName * @return {!Element} */ function (localName) { // Only create custom elements if this document is associated with the registry. if (this.__CE_hasRegistry) { var definition = internals.localNameToDefinition(localName); if (definition) { return new definition.constructor(); } } var result = /** @type {!Element} */ Native.Document_createElement.call(this, localName); internals.patch(result); return result; }); setPropertyUnchecked(Document.prototype, 'importNode', /** * @this {Document} * @param {!Node} node * @param {boolean=} deep * @return {!Node} */ function (node, deep) { var clone = Native.Document_importNode.call(this, node, deep); // Only create custom elements if this document is associated with the registry. if (!this.__CE_hasRegistry) { internals.patchTree(clone); } else { internals.patchAndUpgradeTree(clone); } return clone; }); var NS_HTML = "http://www.w3.org/1999/xhtml"; setPropertyUnchecked(Document.prototype, 'createElementNS', /** * @this {Document} * @param {?string} namespace * @param {string} localName * @return {!Element} */ function (namespace, localName) { // Only create custom elements if this document is associated with the registry. if (this.__CE_hasRegistry && (namespace === null || namespace === NS_HTML)) { var definition = internals.localNameToDefinition(localName); if (definition) { return new definition.constructor(); } } var result = /** @type {!Element} */ Native.Document_createElementNS.call(this, namespace, localName); internals.patch(result); return result; }); PatchParentNode(internals, Document.prototype, { prepend: Native.Document_prepend, append: Native.Document_append }); }; /** * @param {!CustomElementInternals} internals */ var PatchNode = function (internals) { // `Node#nodeValue` is implemented on `Attr`. // `Node#textContent` is implemented on `Attr`, `Element`. setPropertyUnchecked(Node.prototype, 'insertBefore', /** * @this {Node} * @param {!Node} node * @param {?Node} refNode * @return {!Node} */ function (node, refNode) { if (node instanceof DocumentFragment) { var insertedNodes = Array.prototype.slice.apply(node.childNodes); var _nativeResult = Native.Node_insertBefore.call(this, node, refNode); // DocumentFragments can't be connected, so `disconnectTree` will never // need to be called on a DocumentFragment's children after inserting it. if (isConnected(this)) { for (var i = 0; i < insertedNodes.length; i++) { internals.connectTree(insertedNodes[i]); } } return _nativeResult; } var nodeWasConnected = isConnected(node); var nativeResult = Native.Node_insertBefore.call(this, node, refNode); if (nodeWasConnected) { internals.disconnectTree(node); } if (isConnected(this)) { internals.connectTree(node); } return nativeResult; }); setPropertyUnchecked(Node.prototype, 'appendChild', /** * @this {Node} * @param {!Node} node * @return {!Node} */ function (node) { if (node instanceof DocumentFragment) { var insertedNodes = Array.prototype.slice.apply(node.childNodes); var _nativeResult2 = Native.Node_appendChild.call(this, node); // DocumentFragments can't be connected, so `disconnectTree` will never // need to be called on a DocumentFragment's children after inserting it. if (isConnected(this)) { for (var i = 0; i < insertedNodes.length; i++) { internals.connectTree(insertedNodes[i]); } } return _nativeResult2; } var nodeWasConnected = isConnected(node); var nativeResult = Native.Node_appendChild.call(this, node); if (nodeWasConnected) { internals.disconnectTree(node); } if (isConnected(this)) { internals.connectTree(node); } return nativeResult; }); setPropertyUnchecked(Node.prototype, 'cloneNode', /** * @this {Node} * @param {boolean=} deep * @return {!Node} */ function (deep) { var clone = Native.Node_cloneNode.call(this, deep); // Only create custom elements if this element's owner document is // associated with the registry. if (!this.ownerDocument.__CE_hasRegistry) { internals.patchTree(clone); } else { internals.patchAndUpgradeTree(clone); } return clone; }); setPropertyUnchecked(Node.prototype, 'removeChild', /** * @this {Node} * @param {!Node} node * @return {!Node} */ function (node) { var nodeWasConnected = isConnected(node); var nativeResult = Native.Node_removeChild.call(this, node); if (nodeWasConnected) { internals.disconnectTree(node); } return nativeResult; }); setPropertyUnchecked(Node.prototype, 'replaceChild', /** * @this {Node} * @param {!Node} nodeToInsert * @param {!Node} nodeToRemove * @return {!Node} */ function (nodeToInsert, nodeToRemove) { if (nodeToInsert instanceof DocumentFragment) { var insertedNodes = Array.prototype.slice.apply(nodeToInsert.childNodes); var _nativeResult3 = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove); // DocumentFragments can't be connected, so `disconnectTree` will never // need to be called on a DocumentFragment's children after inserting it. if (isConnected(this)) { internals.disconnectTree(nodeToRemove); for (var i = 0; i < insertedNodes.length; i++) { internals.connectTree(insertedNodes[i]); } } return _nativeResult3; } var nodeToInsertWasConnected = isConnected(nodeToInsert); var nativeResult = Native.Node_replaceChild.call(this, nodeToInsert, nodeToRemove); var thisIsConnected = isConnected(this); if (thisIsConnected) { internals.disconnectTree(nodeToRemove); } if (nodeToInsertWasConnected) { internals.disconnectTree(nodeToInsert); } if (thisIsConnected) { internals.connectTree(nodeToInsert); } return nativeResult; }); function patch_textContent(destination, baseDescriptor) { Object.defineProperty(destination, 'textContent', { enumerable: baseDescriptor.enumerable, configurable: true, get: baseDescriptor.get, set: /** @this {Node} */function set(assignedValue) { // If this is a text node then there are no nodes to disconnect. if (this.nodeType === Node.TEXT_NODE) { baseDescriptor.set.call(this, assignedValue); return; } var removedNodes = undefined; // Checking for `firstChild` is faster than reading `childNodes.length` // to compare with 0. if (this.firstChild) { // Using `childNodes` is faster than `children`, even though we only // care about elements. var childNodes = this.childNodes; var childNodesLength = childNodes.length; if (childNodesLength > 0 && isConnected(this)) { // Copying an array by iterating is faster than using slice. removedNodes = new Array(childNodesLength); for (var i = 0; i < childNodesLength; i++) { removedNodes[i] = childNodes[i]; } } } baseDescriptor.set.call(this, assignedValue); if (removedNodes) { for (var _i = 0; _i < removedNodes.length; _i++) { internals.disconnectTree(removedNodes[_i]); } } } }); } if (Native.Node_textContent && Native.Node_textContent.get) { patch_textContent(Node.prototype, Native.Node_textContent); } else { internals.addPatch(function (element) { patch_textContent(element, { enumerable: true, configurable: true, // NOTE: This implementation of the `textContent` getter assumes that // text nodes' `textContent` getter will not be patched. get: /** @this {Node} */function get() { /** @type {!Array} */ var parts = []; for (var i = 0; i < this.childNodes.length; i++) { parts.push(this.childNodes[i].textContent); } return parts.join(''); }, set: /** @this {Node} */function set(assignedValue) { while (this.firstChild) { Native.Node_removeChild.call(this, this.firstChild); } Native.Node_appendChild.call(this, document.createTextNode(assignedValue)); } }); }); } }; /** * @param {!CustomElementInternals} internals * @param {!Object} destination * @param {!ChildNodeNativeMethods} builtIn */ var PatchChildNode = function (internals, destination, builtIn) { /** * @param {...(!Node|string)} nodes */ destination['before'] = function () { for (var _len = arguments.length, nodes = Array(_len), _key = 0; _key < _len; _key++) { nodes[_key] = arguments[_key]; } // TODO: Fix this for when one of `nodes` is a DocumentFragment! var connectedBefore = /** @type {!Array} */nodes.filter(function (node) { // DocumentFragments are not connected and will not be added to the list. return node instanceof Node && isConnected(node); }); builtIn.before.apply(this, nodes); for (var i = 0; i < connectedBefore.length; i++) { internals.disconnectTree(connectedBefore[i]); } if (isConnected(this)) { for (var _i = 0; _i < nodes.length; _i++) { var node = nodes[_i]; if (node instanceof Element) { internals.connectTree(node); } } } }; /** * @param {...(!Node|string)} nodes */ destination['after'] = function () { for (var _len2 = arguments.length, nodes = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { nodes[_key2] = arguments[_key2]; } // TODO: Fix this for when one of `nodes` is a DocumentFragment! var connectedBefore = /** @type {!Array} */nodes.filter(function (node) { // DocumentFragments are not connected and will not be added to the list. return node instanceof Node && isConnected(node); }); builtIn.after.apply(this, nodes); for (var i = 0; i < connectedBefore.length; i++) { internals.disconnectTree(connectedBefore[i]); } if (isConnected(this)) { for (var _i2 = 0; _i2 < nodes.length; _i2++) { var node = nodes[_i2]; if (node instanceof Element) { internals.connectTree(node); } } } }; /** * @param {...(!Node|string)} nodes */ destination['replaceWith'] = function () { for (var _len3 = arguments.length, nodes = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { nodes[_key3] = arguments[_key3]; } // TODO: Fix this for when one of `nodes` is a DocumentFragment! var connectedBefore = /** @type {!Array} */nodes.filter(function (node) { // DocumentFragments are not connected and will not be added to the list. return node instanceof Node && isConnected(node); }); var wasConnected = isConnected(this); builtIn.replaceWith.apply(this, nodes); for (var i = 0; i < connectedBefore.length; i++) { internals.disconnectTree(connectedBefore[i]); } if (wasConnected) { internals.disconnectTree(this); for (var _i3 = 0; _i3 < nodes.length; _i3++) { var node = nodes[_i3]; if (node instanceof Element) { internals.connectTree(node); } } } }; destination['remove'] = function () { var wasConnected = isConnected(this); builtIn.remove.call(this); if (wasConnected) { internals.disconnectTree(this); } }; }; /** * @param {!CustomElementInternals} internals */ var PatchElement = function (internals) { if (Native.Element_attachShadow) { setPropertyUnchecked(Element.prototype, 'attachShadow', /** * @this {Element} * @param {!{mode: string}} init * @return {ShadowRoot} */ function (init) { var shadowRoot = Native.Element_attachShadow.call(this, init); this.__CE_shadowRoot = shadowRoot; return shadowRoot; }); } else { console.warn('Custom Elements: `Element#attachShadow` was not patched.'); } function patch_innerHTML(destination, baseDescriptor) { Object.defineProperty(destination, 'innerHTML', { enumerable: baseDescriptor.enumerable, configurable: true, get: baseDescriptor.get, set: /** @this {Element} */function set(htmlString) { var _this = this; var isConnected$$1 = isConnected(this); // NOTE: In IE11, when using the native `innerHTML` setter, all nodes // that were previously descendants of the context element have all of // their children removed as part of the set - the entire subtree is // 'disassembled'. This work around walks the subtree *before* using the // native setter. /** @type {!Array|undefined} */ var removedElements = undefined; if (isConnected$$1) { removedElements = []; walkDeepDescendantElements(this, function (element) { if (element !== _this) { removedElements.push(element); } }); } baseDescriptor.set.call(this, htmlString); if (removedElements) { for (var i = 0; i < removedElements.length; i++) { var element = removedElements[i]; if (element.__CE_state === CustomElementState.custom) { internals.disconnectedCallback(element); } } } // Only create custom elements if this element's owner document is // associated with the registry. if (!this.ownerDocument.__CE_hasRegistry) { internals.patchTree(this); } else { internals.patchAndUpgradeTree(this); } return htmlString; } }); } if (Native.Element_innerHTML && Native.Element_innerHTML.get) { patch_innerHTML(Element.prototype, Native.Element_innerHTML); } else if (Native.HTMLElement_innerHTML && Native.HTMLElement_innerHTML.get) { patch_innerHTML(HTMLElement.prototype, Native.HTMLElement_innerHTML); } else { /** @type {HTMLDivElement} */ var rawDiv = Native.Document_createElement.call(document, 'div'); internals.addPatch(function (element) { patch_innerHTML(element, { enumerable: true, configurable: true, // Implements getting `innerHTML` by performing an unpatched `cloneNode` // of the element and returning the resulting element's `innerHTML`. // TODO: Is this too expensive? get: /** @this {Element} */function get() { return Native.Node_cloneNode.call(this, true).innerHTML; }, // Implements setting `innerHTML` by creating an unpatched element, // setting `innerHTML` of that element and replacing the target // element's children with those of the unpatched element. set: /** @this {Element} */function set(assignedValue) { // NOTE: re-route to `content` for `template` elements. // We need to do this because `template.appendChild` does not // route into `template.content`. /** @type {!Node} */ var content = this.localName === 'template' ? /** @type {!HTMLTemplateElement} */this.content : this; rawDiv.innerHTML = assignedValue; while (content.childNodes.length > 0) { Native.Node_removeChild.call(content, content.childNodes[0]); } while (rawDiv.childNodes.length > 0) { Native.Node_appendChild.call(content, rawDiv.childNodes[0]); } } }); }); } setPropertyUnchecked(Element.prototype, 'setAttribute', /** * @this {Element} * @param {string} name * @param {string} newValue */ function (name, newValue) { // Fast path for non-custom elements. if (this.__CE_state !== CustomElementState.custom) { return Native.Element_setAttribute.call(this, name, newValue); } var oldValue = Native.Element_getAttribute.call(this, name); Native.Element_setAttribute.call(this, name, newValue); newValue = Native.Element_getAttribute.call(this, name); internals.attributeChangedCallback(this, name, oldValue, newValue, null); }); setPropertyUnchecked(Element.prototype, 'setAttributeNS', /** * @this {Element} * @param {?string} namespace * @param {string} name * @param {string} newValue */ function (namespace, name, newValue) { // Fast path for non-custom elements. if (this.__CE_state !== CustomElementState.custom) { return Native.Element_setAttributeNS.call(this, namespace, name, newValue); } var oldValue = Native.Element_getAttributeNS.call(this, namespace, name); Native.Element_setAttributeNS.call(this, namespace, name, newValue); newValue = Native.Element_getAttributeNS.call(this, namespace, name); internals.attributeChangedCallback(this, name, oldValue, newValue, namespace); }); setPropertyUnchecked(Element.prototype, 'removeAttribute', /** * @this {Element} * @param {string} name */ function (name) { // Fast path for non-custom elements. if (this.__CE_state !== CustomElementState.custom) { return Native.Element_removeAttribute.call(this, name); } var oldValue = Native.Element_getAttribute.call(this, name); Native.Element_removeAttribute.call(this, name); if (oldValue !== null) { internals.attributeChangedCallback(this, name, oldValue, null, null); } }); setPropertyUnchecked(Element.prototype, 'removeAttributeNS', /** * @this {Element} * @param {?string} namespace * @param {string} name */ function (namespace, name) { // Fast path for non-custom elements. if (this.__CE_state !== CustomElementState.custom) { return Native.Element_removeAttributeNS.call(this, namespace, name); } var oldValue = Native.Element_getAttributeNS.call(this, namespace, name); Native.Element_removeAttributeNS.call(this, namespace, name); // In older browsers, `Element#getAttributeNS` may return the empty string // instead of null if the attribute does not exist. For details, see; // https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNS#Notes var newValue = Native.Element_getAttributeNS.call(this, namespace, name); if (oldValue !== newValue) { internals.attributeChangedCallback(this, name, oldValue, newValue, namespace); } }); function patch_insertAdjacentElement(destination, baseMethod) { setPropertyUnchecked(destination, 'insertAdjacentElement', /** * @this {Element} * @param {string} where * @param {!Element} element * @return {?Element} */ function (where, element) { var wasConnected = isConnected(element); var insertedElement = /** @type {!Element} */ baseMethod.call(this, where, element); if (wasConnected) { internals.disconnectTree(element); } if (isConnected(insertedElement)) { internals.connectTree(element); } return insertedElement; }); } if (Native.HTMLElement_insertAdjacentElement) { patch_insertAdjacentElement(HTMLElement.prototype, Native.HTMLElement_insertAdjacentElement); } else if (Native.Element_insertAdjacentElement) { patch_insertAdjacentElement(Element.prototype, Native.Element_insertAdjacentElement); } else { console.warn('Custom Elements: `Element#insertAdjacentElement` was not patched.'); } PatchParentNode(internals, Element.prototype, { prepend: Native.Element_prepend, append: Native.Element_append }); PatchChildNode(internals, Element.prototype, { before: Native.Element_before, after: Native.Element_after, replaceWith: Native.Element_replaceWith, remove: Native.Element_remove }); }; /** * @license * Copyright (c) 2016 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 */ var priorCustomElements = window['customElements']; if (!priorCustomElements || priorCustomElements['forcePolyfill'] || typeof priorCustomElements['define'] != 'function' || typeof priorCustomElements['get'] != 'function') { /** @type {!CustomElementInternals} */ var internals = new CustomElementInternals(); PatchHTMLElement(internals); PatchDocument(internals); PatchNode(internals); PatchElement(internals); // The main document is always associated with the registry. document.__CE_hasRegistry = true; /** @type {!CustomElementRegistry} */ var customElements = new CustomElementRegistry(internals); Object.defineProperty(window, 'customElements', { configurable: true, enumerable: true, value: customElements }); } /** * @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 */ // @version 0.7.22 (function (global) { if (global.JsMutationObserver) { return; } var registrationsTable = new WeakMap(); var setImmediate; if (/Trident|Edge/.test(navigator.userAgent)) { setImmediate = setTimeout; } else if (window.setImmediate) { setImmediate = window.setImmediate; } else { var setImmediateQueue = []; var sentinel = String(Math.random()); window.addEventListener("message", function (e) { if (e.data === sentinel) { var queue = setImmediateQueue; setImmediateQueue = []; queue.forEach(function (func) { func(); }); } }); setImmediate = function setImmediate(func) { setImmediateQueue.push(func); window.postMessage(sentinel, "*"); }; } var isScheduled = false; var scheduledObservers = []; function scheduleCallback(observer) { scheduledObservers.push(observer); if (!isScheduled) { isScheduled = true; setImmediate(dispatchCallbacks); } } function wrapIfNeeded(node) { return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node; } function dispatchCallbacks() { isScheduled = false; var observers = scheduledObservers; scheduledObservers = []; observers.sort(function (o1, o2) { return o1.uid_ - o2.uid_; }); var anyNonEmpty = false; observers.forEach(function (observer) { var queue = observer.takeRecords(); removeTransientObserversFor(observer); if (queue.length) { observer.callback_(queue, observer); anyNonEmpty = true; } }); if (anyNonEmpty) dispatchCallbacks(); } function removeTransientObserversFor(observer) { observer.nodes_.forEach(function (node) { var registrations = registrationsTable.get(node); if (!registrations) return; registrations.forEach(function (registration) { if (registration.observer === observer) registration.removeTransientObservers(); }); }); } 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]; var options = registration.options; if (node !== target && !options.subtree) continue; var record = callback(options); if (record) registration.enqueue(record); } } } } var uidCounter = 0; function JsMutationObserver(callback) { this.callback_ = callback; this.nodes_ = []; this.records_ = []; this.uid_ = ++uidCounter; } JsMutationObserver.prototype = { observe: function observe(target, options) { target = wrapIfNeeded(target); if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) { throw new SyntaxError(); } var registrations = registrationsTable.get(target); if (!registrations) registrationsTable.set(target, registrations = []); var registration; for (var i = 0; i < registrations.length; i++) { if (registrations[i].observer === this) { registration = registrations[i]; registration.removeListeners(); registration.options = options; break; } } if (!registration) { registration = new Registration(this, target, options); registrations.push(registration); this.nodes_.push(target); } registration.addListeners(); }, disconnect: function disconnect() { this.nodes_.forEach(function (node) { var registrations = registrationsTable.get(node); for (var i = 0; i < registrations.length; i++) { var registration = registrations[i]; if (registration.observer === this) { registration.removeListeners(); registrations.splice(i, 1); break; } } }, this); this.records_ = []; }, takeRecords: function takeRecords() { var copyOfRecords = this.records_; this.records_ = []; return copyOfRecords; } }; 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); 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; return record; } var currentRecord, recordWithOldValue; function getRecord(type, target) { return currentRecord = new MutationRecord(type, target); } function getRecordWithOldValue(oldValue) { if (recordWithOldValue) return recordWithOldValue; recordWithOldValue = copyMutationRecord(currentRecord); recordWithOldValue.oldValue = oldValue; return recordWithOldValue; } function clearRecords() { currentRecord = recordWithOldValue = undefined; } function recordRepresentsCurrentMutation(record) { return record === recordWithOldValue || record === currentRecord; } function selectRecord(lastRecord, newRecord) { if (lastRecord === newRecord) return lastRecord; if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue; return null; } function Registration(observer, target, options) { this.observer = observer; this.target = target; this.options = options; this.transientObservedNodes = []; } Registration.prototype = { enqueue: function enqueue(record) { var records = this.observer.records_; var length = records.length; if (records.length > 0) { var lastRecord = records[length - 1]; var recordToReplaceLast = selectRecord(lastRecord, record); if (recordToReplaceLast) { records[length - 1] = recordToReplaceLast; return; } } else { scheduleCallback(this.observer); } records[length] = record; }, addListeners: function addListeners() { this.addListeners_(this.target); }, addListeners_: function addListeners_(node) { var options = this.options; if (options.attributes) node.addEventListener("DOMAttrModified", this, true); if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true); if (options.childList) node.addEventListener("DOMNodeInserted", this, true); if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true); }, removeListeners: function removeListeners() { this.removeListeners_(this.target); }, removeListeners_: function removeListeners_(node) { var options = this.options; if (options.attributes) node.removeEventListener("DOMAttrModified", this, true); if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true); if (options.childList) node.removeEventListener("DOMNodeInserted", this, true); if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true); }, addTransientObserver: function addTransientObserver(node) { if (node === this.target) return; this.addListeners_(node); this.transientObservedNodes.push(node); var registrations = registrationsTable.get(node); if (!registrations) registrationsTable.set(node, registrations = []); registrations.push(this); }, removeTransientObservers: function removeTransientObservers() { var transientObservedNodes = this.transientObservedNodes; this.transientObservedNodes = []; transientObservedNodes.forEach(function (node) { this.removeListeners_(node); var registrations = registrationsTable.get(node); for (var i = 0; i < registrations.length; i++) { if (registrations[i] === this) { registrations.splice(i, 1); break; } } }, this); }, handleEvent: function handleEvent(e) { e.stopImmediatePropagation(); switch (e.type) { case "DOMAttrModified": var name = e.attrName; var namespace = e.relatedNode.namespaceURI; var target = e.target; var record = new getRecord("attributes", target); record.attributeName = name; record.attributeNamespace = namespace; var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue; forEachAncestorAndObserverEnqueueRecord(target, function (options) { if (!options.attributes) return; if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) { return; } if (options.attributeOldValue) return getRecordWithOldValue(oldValue); return record; }); break; case "DOMCharacterDataModified": var target = e.target; var record = getRecord("characterData", target); var oldValue = e.prevValue; forEachAncestorAndObserverEnqueueRecord(target, function (options) { if (!options.characterData) return; if (options.characterDataOldValue) return getRecordWithOldValue(oldValue); return record; }); break; case "DOMNodeRemoved": this.addTransientObserver(e.target); case "DOMNodeInserted": var changedNode = e.target; var addedNodes, removedNodes; if (e.type === "DOMNodeInserted") { addedNodes = [changedNode]; removedNodes = []; } else { addedNodes = []; removedNodes = [changedNode]; } var previousSibling = changedNode.previousSibling; var nextSibling = changedNode.nextSibling; var record = getRecord("childList", e.target.parentNode); record.addedNodes = addedNodes; record.removedNodes = removedNodes; record.previousSibling = previousSibling; record.nextSibling = nextSibling; forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function (options) { if (!options.childList) return; return record; }); } clearRecords(); } }; global.JsMutationObserver = JsMutationObserver; if (!global.MutationObserver) { global.MutationObserver = JsMutationObserver; JsMutationObserver._isPolyfilled = true; } })(self); /* Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ (function (global, undefined) { if (global.setImmediate) { return; } var nextHandle = 1; // Spec says greater than zero var tasksByHandle = {}; var currentlyRunningATask = false; var doc = global.document; var setImmediate; function addFromSetImmediateArguments(args) { tasksByHandle[nextHandle] = partiallyApplied.apply(undefined, args); return nextHandle++; } // This function accepts the same arguments as setImmediate, but // returns a function that requires no arguments. function partiallyApplied(handler) { var args = [].slice.call(arguments, 1); return function () { if (typeof handler === "function") { handler.apply(undefined, args); } else { new Function("" + handler)(); } }; } function runIfPresent(handle) { // From the spec: "Wait until any invocations of this algorithm started before this one have completed." // So if we're currently running a task, we'll need to delay this invocation. if (currentlyRunningATask) { // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a // "too much recursion" error. setTimeout(partiallyApplied(runIfPresent, handle), 0); } else { var task = tasksByHandle[handle]; if (task) { currentlyRunningATask = true; try { task(); } finally { clearImmediate(handle); currentlyRunningATask = false; } } } } function clearImmediate(handle) { delete tasksByHandle[handle]; } function installNextTickImplementation() { setImmediate = function setImmediate() { var handle = addFromSetImmediateArguments(arguments); process.nextTick(partiallyApplied(runIfPresent, handle)); return handle; }; } function canUsePostMessage() { // The test against `importScripts` prevents this implementation from being installed inside a web worker, // where `global.postMessage` means something completely different and can't be used for this purpose. if (global.postMessage && !global.importScripts) { var postMessageIsAsynchronous = true; var oldOnMessage = global.onmessage; global.onmessage = function () { postMessageIsAsynchronous = false; }; global.postMessage("", "*"); global.onmessage = oldOnMessage; return postMessageIsAsynchronous; } } function installPostMessageImplementation() { // Installs an event handler on `global` for the `message` event: see // * https://developer.mozilla.org/en/DOM/window.postMessage // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages var messagePrefix = "setImmediate$" + Math.random() + "$"; var onGlobalMessage = function onGlobalMessage(event) { if (event.source === global && typeof event.data === "string" && event.data.indexOf(messagePrefix) === 0) { runIfPresent(+event.data.slice(messagePrefix.length)); } }; if (global.addEventListener) { global.addEventListener("message", onGlobalMessage, false); } else { global.attachEvent("onmessage", onGlobalMessage); } setImmediate = function setImmediate() { var handle = addFromSetImmediateArguments(arguments); global.postMessage(messagePrefix + handle, "*"); return handle; }; } function installMessageChannelImplementation() { var channel = new MessageChannel(); channel.port1.onmessage = function (event) { var handle = event.data; runIfPresent(handle); }; setImmediate = function setImmediate() { var handle = addFromSetImmediateArguments(arguments); channel.port2.postMessage(handle); return handle; }; } function installReadyStateChangeImplementation() { var html = doc.documentElement; setImmediate = function setImmediate() { var handle = addFromSetImmediateArguments(arguments); // Create a