diff --git a/ApiApp/ApiApp.csproj b/ApiApp/ApiApp.csproj index 1473481..109559b 100644 --- a/ApiApp/ApiApp.csproj +++ b/ApiApp/ApiApp.csproj @@ -10,7 +10,7 @@ - + diff --git a/ClientApp/ClientApp.csproj b/ClientApp/ClientApp.csproj index 9763fe1..f854b09 100644 --- a/ClientApp/ClientApp.csproj +++ b/ClientApp/ClientApp.csproj @@ -8,8 +8,8 @@ - - + + diff --git a/ClientApp/ClientApp/app/app.module.shared.ts b/ClientApp/ClientApp/app/app.module.shared.ts index 2c13f1f..f536c71 100644 --- a/ClientApp/ClientApp/app/app.module.shared.ts +++ b/ClientApp/ClientApp/app/app.module.shared.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; -import { HttpModule } from '@angular/http'; +import { HttpClientModule } from '@angular/common/http'; import { RouterModule } from '@angular/router'; import { AppComponent } from './components/app/app.component' @@ -26,7 +26,7 @@ import { AuthService } from './components/services/auth.service'; imports: [ AuthModule.forRoot(), CommonModule, - HttpModule, + HttpClientModule, FormsModule, RouterModule.forRoot([ { path: '', redirectTo: 'home', pathMatch: 'full' }, diff --git a/ClientApp/ClientApp/app/components/fetchdata/fetchdata.component.ts b/ClientApp/ClientApp/app/components/fetchdata/fetchdata.component.ts index 0bf69b6..be562ba 100644 --- a/ClientApp/ClientApp/app/components/fetchdata/fetchdata.component.ts +++ b/ClientApp/ClientApp/app/components/fetchdata/fetchdata.component.ts @@ -10,7 +10,7 @@ export class FetchDataComponent { constructor(authService: AuthService, @Inject('API_URL') apiUrl: string) { authService.get(apiUrl + 'SampleData/WeatherForecasts').subscribe(result => { - this.forecasts = result.json() as WeatherForecast[]; + this.forecasts = result as WeatherForecast[]; }, error => console.error(error)); } } diff --git a/ClientApp/ClientApp/app/components/services/auth.service.ts b/ClientApp/ClientApp/app/components/services/auth.service.ts index 7bde8bb..8474d8e 100644 --- a/ClientApp/ClientApp/app/components/services/auth.service.ts +++ b/ClientApp/ClientApp/app/components/services/auth.service.ts @@ -1,5 +1,5 @@ import { Injectable, Component, OnInit, OnDestroy, Inject } from '@angular/core'; -import { Http, Headers, RequestOptions, Response } from '@angular/http'; +import { HttpClient, HttpHeaders } from '@angular/common/http'; import { Observable } from 'rxjs/Rx'; import { Subscription } from 'rxjs/Subscription'; @@ -11,7 +11,7 @@ export class AuthService implements OnInit, OnDestroy { isAuthorized: boolean; constructor(public oidcSecurityService: OidcSecurityService, - private http: Http, + private http: HttpClient, @Inject('ORIGIN_URL') originUrl: string, @Inject('IDENTITY_URL') identityUrl: string ) { @@ -77,52 +77,36 @@ export class AuthService implements OnInit, OnDestroy { } } - get(url: string, options?: RequestOptions): Observable { - return this.http.get(url, this.setRequestOptions(options)); + get(url: string): Observable { + return this.http.get(url, { headers: this.getHeaders() }); } - put(url: string, data: any, options?: RequestOptions): Observable { + put(url: string, data: any): Observable { const body = JSON.stringify(data); - return this.http.put(url, body, this.setRequestOptions(options)); + return this.http.put(url, body, { headers: this.getHeaders() }); } - delete(url: string, options?: RequestOptions): Observable { - return this.http.delete(url, this.setRequestOptions(options)); + delete(url: string): Observable { + return this.http.delete(url, { headers: this.getHeaders() }); } - post(url: string, data: any, options?: RequestOptions): Observable { + post(url: string, data: any): Observable { const body = JSON.stringify(data); - return this.http.post(url, body, this.setRequestOptions(options)); - } - - private setRequestOptions(options?: RequestOptions | null) { - if (options) { - this.appendAuthHeader(options.headers); - } - else { - options = new RequestOptions({ headers: this.getHeaders(), body: "" }); - } - return options; + return this.http.post(url, body, { headers: this.getHeaders() }); } private getHeaders() { - const headers = new Headers(); - headers.append('Content-Type', 'application/json'); - this.appendAuthHeader(headers); - return headers; + let headers = new HttpHeaders(); + headers = headers.set('Content-Type', 'application/json'); + return this.appendAuthHeader(headers); } - private appendAuthHeader(headers?: Headers | null) { - - if (headers == null) headers = this.getHeaders(); - + private appendAuthHeader(headers: HttpHeaders) { const token = this.oidcSecurityService.getToken(); - if (token == '') return; + if (token === '') return headers; const tokenValue = 'Bearer ' + token; - headers.append('Authorization', tokenValue); + return headers.set('Authorization', tokenValue); } - - } \ No newline at end of file diff --git a/ClientApp/ClientApp/boot.server.ts b/ClientApp/ClientApp/boot.server.ts index 166bcb1..4aa6423 100644 --- a/ClientApp/ClientApp/boot.server.ts +++ b/ClientApp/ClientApp/boot.server.ts @@ -23,7 +23,7 @@ export default createServerRenderer(params => { return platformDynamicServer(providers).bootstrapModule(AppModule).then(moduleRef => { const appRef: ApplicationRef = moduleRef.injector.get(ApplicationRef); const state = moduleRef.injector.get(PlatformState); - const zone = moduleRef.injector.get(NgZone); + const zone: NgZone = moduleRef.injector.get(NgZone); return new Promise((resolve, reject) => { zone.onError.subscribe((errorInfo: any) => reject(errorInfo)); diff --git a/ClientApp/ClientApp/dist/main-server.js b/ClientApp/ClientApp/dist/main-server.js index 40edab8..ae8e270 100644 --- a/ClientApp/ClientApp/dist/main-server.js +++ b/ClientApp/ClientApp/dist/main-server.js @@ -63,6130 +63,14655 @@ /******/ __webpack_require__.p = "dist/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 100); +/******/ return __webpack_require__(__webpack_require__.s = 70); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(0); - -/***/ }), -/* 1 */ /***/ (function(module, exports) { module.exports = require("./vendor"); /***/ }), -/* 2 */ +/* 1 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = (__webpack_require__(1))(2); +"use strict"; + +var DOMException = __webpack_require__(30); +var ERR = DOMException; +var isApiWritable = __webpack_require__(43).isApiWritable; -/***/ }), -/* 3 */ -/***/ (function(module, exports, __webpack_require__) { +exports.NAMESPACE = { + HTML: 'http://www.w3.org/1999/xhtml', + XML: 'http://www.w3.org/XML/1998/namespace', + XMLNS: 'http://www.w3.org/2000/xmlns/', + MATHML: 'http://www.w3.org/1998/Math/MathML', + SVG: 'http://www.w3.org/2000/svg', + XLINK: 'http://www.w3.org/1999/xlink' +}; -module.exports = (__webpack_require__(1))(10); +// +// Shortcut functions for throwing errors of various types. +// +exports.IndexSizeError = function() { throw new DOMException(ERR.INDEX_SIZE_ERR); }; +exports.HierarchyRequestError = function() { throw new DOMException(ERR.HIERARCHY_REQUEST_ERR); }; +exports.WrongDocumentError = function() { throw new DOMException(ERR.WRONG_DOCUMENT_ERR); }; +exports.InvalidCharacterError = function() { throw new DOMException(ERR.INVALID_CHARACTER_ERR); }; +exports.NoModificationAllowedError = function() { throw new DOMException(ERR.NO_MODIFICATION_ALLOWED_ERR); }; +exports.NotFoundError = function() { throw new DOMException(ERR.NOT_FOUND_ERR); }; +exports.NotSupportedError = function() { throw new DOMException(ERR.NOT_SUPPORTED_ERR); }; +exports.InvalidStateError = function() { throw new DOMException(ERR.INVALID_STATE_ERR); }; +exports.SyntaxError = function() { throw new DOMException(ERR.SYNTAX_ERR); }; +exports.InvalidModificationError = function() { throw new DOMException(ERR.INVALID_MODIFICATION_ERR); }; +exports.NamespaceError = function() { throw new DOMException(ERR.NAMESPACE_ERR); }; +exports.InvalidAccessError = function() { throw new DOMException(ERR.INVALID_ACCESS_ERR); }; +exports.TypeMismatchError = function() { throw new DOMException(ERR.TYPE_MISMATCH_ERR); }; +exports.SecurityError = function() { throw new DOMException(ERR.SECURITY_ERR); }; +exports.NetworkError = function() { throw new DOMException(ERR.NETWORK_ERR); }; +exports.AbortError = function() { throw new DOMException(ERR.ABORT_ERR); }; +exports.UrlMismatchError = function() { throw new DOMException(ERR.URL_MISMATCH_ERR); }; +exports.QuotaExceededError = function() { throw new DOMException(ERR.QUOTA_EXCEEDED_ERR); }; +exports.TimeoutError = function() { throw new DOMException(ERR.TIMEOUT_ERR); }; +exports.InvalidNodeTypeError = function() { throw new DOMException(ERR.INVALID_NODE_TYPE_ERR); }; +exports.DataCloneError = function() { throw new DOMException(ERR.DATA_CLONE_ERR); }; -/***/ }), -/* 4 */ -/***/ (function(module, exports, __webpack_require__) { +exports.nyi = function() { + throw new Error("NotYetImplemented"); +}; -module.exports = (__webpack_require__(1))(8); +exports.assert = function(expr, msg) { + if (!expr) { + throw new Error("Assertion failed: " + (msg || "") + "\n" + new Error().stack); + } +}; -/***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { +exports.expose = function(src, c) { + for (var n in src) { + Object.defineProperty(c.prototype, n, { value: src[n], writable: isApiWritable }); + } +}; -module.exports = (__webpack_require__(1))(29); +exports.merge = function(a, b) { + for (var n in b) { + a[n] = b[n]; + } +}; -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { +// Compare two nodes based on their document order. This function is intended +// to be passed to sort(). Assumes that the array being sorted does not +// contain duplicates. And that all nodes are connected and comparable. +// Clever code by ppk via jeresig. +exports.documentOrder = function(n,m) { + /* jshint bitwise: false */ + return 3 - (n.compareDocumentPosition(m) & 6); +}; + +exports.toASCIILowerCase = function(s) { + return s.replace(/[A-Z]+/g, function(t) { return t.toLowerCase(); }); +}; -module.exports = (__webpack_require__(1))(6); /***/ }), -/* 7 */ +/* 2 */ /***/ (function(module, exports, __webpack_require__) { -module.exports = (__webpack_require__(1))(92); +module.exports = (__webpack_require__(0))(0); /***/ }), -/* 8 */ +/* 3 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var AsyncAction_1 = __webpack_require__(20); -var AsyncScheduler_1 = __webpack_require__(21); -/** - * - * Async Scheduler - * - * Schedule task as if you used setTimeout(task, duration) - * - * `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript - * event loop queue. It is best used to delay tasks in time or to schedule tasks repeating - * in intervals. - * - * If you just want to "defer" task, that is to perform it right after currently - * executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`), - * better choice will be the {@link asap} scheduler. - * - * @example Use async scheduler to delay task - * const task = () => console.log('it works!'); - * - * Rx.Scheduler.async.schedule(task, 2000); - * - * // After 2 seconds logs: - * // "it works!" - * - * - * @example Use async scheduler to repeat task in intervals - * function task(state) { - * console.log(state); - * this.schedule(state + 1, 1000); // `this` references currently executing Action, - * // which we reschedule with new state and delay - * } - * - * Rx.Scheduler.async.schedule(task, 3000, 0); - * - * // Logs: - * // 0 after 3s - * // 1 after 4s - * // 2 after 5s - * // 3 after 6s - * - * @static true - * @name async - * @owner Scheduler - */ -exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); -//# sourceMappingURL=async.js.map +module.exports = Node; + +var EventTarget = __webpack_require__(33); +var utils = __webpack_require__(1); +var NAMESPACE = utils.NAMESPACE; + +// All nodes have a nodeType and an ownerDocument. +// Once inserted, they also have a parentNode. +// This is an abstract class; all nodes in a document are instances +// of a subtype, so all the properties are defined by more specific +// constructors. +function Node() { +} + +var ELEMENT_NODE = Node.ELEMENT_NODE = 1; +var ATTRIBUTE_NODE = Node.ATTRIBUTE_NODE = 2; +var TEXT_NODE = Node.TEXT_NODE = 3; +var CDATA_SECTION_NODE = Node.CDATA_SECTION_NODE = 4; +var ENTITY_REFERENCE_NODE = Node.ENTITY_REFERENCE_NODE = 5; +var ENTITY_NODE = Node.ENTITY_NODE = 6; +var PROCESSING_INSTRUCTION_NODE = Node.PROCESSING_INSTRUCTION_NODE = 7; +var COMMENT_NODE = Node.COMMENT_NODE = 8; +var DOCUMENT_NODE = Node.DOCUMENT_NODE = 9; +var DOCUMENT_TYPE_NODE = Node.DOCUMENT_TYPE_NODE = 10; +var DOCUMENT_FRAGMENT_NODE = Node.DOCUMENT_FRAGMENT_NODE = 11; +var NOTATION_NODE = Node.NOTATION_NODE = 12; + +var DOCUMENT_POSITION_DISCONNECTED = Node.DOCUMENT_POSITION_DISCONNECTED = 0x01; +var DOCUMENT_POSITION_PRECEDING = Node.DOCUMENT_POSITION_PRECEDING = 0x02; +var DOCUMENT_POSITION_FOLLOWING = Node.DOCUMENT_POSITION_FOLLOWING = 0x04; +var DOCUMENT_POSITION_CONTAINS = Node.DOCUMENT_POSITION_CONTAINS = 0x08; +var DOCUMENT_POSITION_CONTAINED_BY = Node.DOCUMENT_POSITION_CONTAINED_BY = 0x10; +var DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; + +var hasRawContent = { + STYLE: true, + SCRIPT: true, + XMP: true, + IFRAME: true, + NOEMBED: true, + NOFRAMES: true, + PLAINTEXT: true +}; + +var emptyElements = { + area: true, + base: true, + basefont: true, + bgsound: true, + br: true, + col: true, + embed: true, + frame: true, + hr: true, + img: true, + input: true, + keygen: true, + link: true, + meta: true, + param: true, + source: true, + track: true, + wbr: true +}; + +var extraNewLine = { + /* Removed in https://github.com/whatwg/html/issues/944 + pre: true, + textarea: true, + listing: true + */ +}; + +Node.prototype = Object.create(EventTarget.prototype, { + + // Node that are not inserted into the tree inherit a null parent + parentNode: { value: null, writable: true }, + + // XXX: the baseURI attribute is defined by dom core, but + // a correct implementation of it requires HTML features, so + // we'll come back to this later. + baseURI: { get: utils.nyi }, + + parentElement: { get: function() { + return (this.parentNode && this.parentNode.nodeType===ELEMENT_NODE) ? this.parentNode : null; + }}, + + hasChildNodes: { value: function() { // Overridden in leaf.js + return this.childNodes.length > 0; + }}, + + firstChild: { get: function() { + return this.childNodes.length === 0 ? null : this.childNodes[0]; + }}, + + lastChild: { get: function() { + return this.childNodes.length === 0 ? null : this.childNodes[this.childNodes.length-1]; + }}, + + previousSibling: { get: function() { + if (!this.parentNode) return null; + var sibs = this.parentNode.childNodes, i = this.index; + return i === 0 ? null : sibs[i-1]; + }}, + + nextSibling: { get: function() { + if (!this.parentNode) return null; + var sibs = this.parentNode.childNodes, i = this.index; + return i+1 === sibs.length ? null : sibs[i+1]; + }}, + + + _countChildrenOfType: { value: function(type) { + var sum = 0, nodes = this.childNodes, length = nodes.length, i; + for (i=0; i 0) + utils.HierarchyRequestError(); + switch (node._countChildrenOfType(ELEMENT_NODE)) { + case 0: + break; + case 1: + // 6a2. Otherwise, if node has one element child and either + // parent has an element child, child is a doctype, or child + // is not null and a doctype is following child. [preinsert] + // 6a2. Otherwise, if node has one element child and either + // parent has an element child that is not child or a + // doctype is following child. [replaceWith] + if (child !== null /* always true here for replaceWith */) { + if (isPreinsert && child.nodeType === DOCUMENT_TYPE_NODE) + utils.HierarchyRequestError(); + for (i=parent.childNodes.length-1; i>=0; i--) { + if (parent.childNodes[i] === child) break; + if (parent.childNodes[i].nodeType === DOCUMENT_TYPE_NODE) + utils.HierarchyRequestError(); + } + } + i = parent._countChildrenOfType(ELEMENT_NODE); + if (isPreinsert) { + // "parent has an element child" + if (i > 0) + utils.HierarchyRequestError(); + } else { + // "parent has an element child that is not child" + if (i > 1 || (i === 1 && child.nodeType !== ELEMENT_NODE)) + utils.HierarchyRequestError(); + } + break; + default: // 6a1, continued. (more than one Element child) + utils.HierarchyRequestError(); + } + break; + case ELEMENT_NODE: + // 6b. parent has an element child, child is a doctype, or + // child is not null and a doctype is following child. [preinsert] + // 6b. parent has an element child that is not child or a + // doctype is following child. [replaceWith] + if (child !== null /* always true here for replaceWith */) { + if (isPreinsert && child.nodeType === DOCUMENT_TYPE_NODE) + utils.HierarchyRequestError(); + for (i=parent.childNodes.length-1; i>=0; i--) { + if (parent.childNodes[i] === child) break; + if (parent.childNodes[i].nodeType === DOCUMENT_TYPE_NODE) + utils.HierarchyRequestError(); + } + } + i = parent._countChildrenOfType(ELEMENT_NODE); + if (isPreinsert) { + // "parent has an element child" + if (i > 0) + utils.HierarchyRequestError(); + } else { + // "parent has an element child that is not child" + if (i > 1 || (i === 1 && child.nodeType !== ELEMENT_NODE)) + utils.HierarchyRequestError(); + } + break; + case DOCUMENT_TYPE_NODE: + // 6c. parent has a doctype child, child is non-null and an + // element is preceding child, or child is null and parent has + // an element child. [preinsert] + // 6c. parent has a doctype child that is not child, or an + // element is preceding child. [replaceWith] + if (child === null) { + if (parent._countChildrenOfType(ELEMENT_NODE)) + utils.HierarchyRequestError(); + } else { + // child is always non-null for [replaceWith] case + for (i=0; i 0) + utils.HierarchyRequestError(); + } else { + // "parent has an doctype child that is not child" + if (i > 1 || (i === 1 && child.nodeType !== DOCUMENT_TYPE_NODE)) + utils.HierarchyRequestError(); + } + break; + } + } else { + // 5, continued: (parent is not a document) + if (node.nodeType === DOCUMENT_TYPE_NODE) utils.HierarchyRequestError(); + } + }}, + + insertBefore: { value: function insertBefore(node, child) { + var parent = this; + // 1. Ensure pre-insertion validity + parent._ensureInsertValid(node, child, true); + // 2. Let reference child be child. + var refChild = child; + // 3. If reference child is node, set it to node's next sibling + if (refChild === node) { refChild = node.nextSibling; } + // 4. Adopt node into parent's node document. + parent.doc.adoptNode(node); + // 5. Insert node into parent before reference child. + if (refChild === null) { + parent._appendChild(node); + } else { + node.insert(parent, refChild.index); + } + // 6. Return node + return node; + }}, + + + appendChild: { value: function(child) { + // This invokes _appendChild after doing validity checks. + return this.insertBefore(child, null); + }}, + + _appendChild: { value: function(child) { + child.insert(this, this.childNodes.length); + return child; + }}, + + removeChild: { value: function removeChild(child) { + var parent = this; + if (!child.nodeType) throw new TypeError('not a node'); + if (child.parentNode !== parent) utils.NotFoundError(); + child.remove(); + return child; + }}, + + // To replace a `child` with `node` within a `parent` (this) + replaceChild: { value: function replaceChild(node, child) { + var parent = this; + // Ensure validity (slight differences from pre-insertion check) + parent._ensureInsertValid(node, child, false); + // Adopt node into parent's node document. + if (node.doc !== parent.doc) { + // XXX adoptNode has side-effect of removing node from its parent + // and generating a mutation event, thus causing the _insertOrReplace + // to generate two deletes and an insert instead of a 'move' + // event. It looks like the new MutationObserver stuff avoids + // this problem, but for now let's only adopt (ie, remove `node` + // from its parent) here if we need to. + parent.doc.adoptNode(node); + } + // Do the replace. + node._insertOrReplace(parent, child.index, true); + return child; + }}, + + // See: http://ejohn.org/blog/comparing-document-position/ + contains: { value: function contains(node) { + if (node === null) { return false; } + if (this === node) { return true; /* inclusive descendant */ } + /* jshint bitwise: false */ + return (this.compareDocumentPosition(node) & + DOCUMENT_POSITION_CONTAINED_BY) !== 0; + }}, + + compareDocumentPosition: { value: function compareDocumentPosition(that){ + // Basic algorithm for finding the relative position of two nodes. + // Make a list the ancestors of each node, starting with the + // document element and proceeding down to the nodes themselves. + // Then, loop through the lists, looking for the first element + // that differs. The order of those two elements give the + // order of their descendant nodes. Or, if one list is a prefix + // of the other one, then that node contains the other. + + if (this === that) return 0; + + // If they're not owned by the same document or if one is rooted + // and one is not, then they're disconnected. + if (this.doc !== that.doc || + this.rooted !== that.rooted) + return (DOCUMENT_POSITION_DISCONNECTED + + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + + // Get arrays of ancestors for this and that + var these = [], those = []; + for(var n = this; n !== null; n = n.parentNode) these.push(n); + for(n = that; n !== null; n = n.parentNode) those.push(n); + these.reverse(); // So we start with the outermost + those.reverse(); + + if (these[0] !== those[0]) // No common ancestor + return (DOCUMENT_POSITION_DISCONNECTED + + DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC); + + n = Math.min(these.length, those.length); + for(var i = 1; i < n; i++) { + if (these[i] !== those[i]) { + // We found two different ancestors, so compare + // their positions + if (these[i].index < those[i].index) + return DOCUMENT_POSITION_FOLLOWING; + else + return DOCUMENT_POSITION_PRECEDING; + } + } -/***/ }), -/* 9 */ -/***/ (function(module, exports, __webpack_require__) { + // If we get to here, then one of the nodes (the one with the + // shorter list of ancestors) contains the other one. + if (these.length < those.length) + return (DOCUMENT_POSITION_FOLLOWING + + DOCUMENT_POSITION_CONTAINED_BY); + else + return (DOCUMENT_POSITION_PRECEDING + + DOCUMENT_POSITION_CONTAINS); + }}, + + isSameNode: {value : function isSameNode(node) { + return this === node; + }}, + + + // This method implements the generic parts of node equality testing + // and defers to the (non-recursive) type-specific isEqual() method + // defined by subclasses + isEqualNode: { value: function isEqualNode(node) { + if (!node) return false; + if (node.nodeType !== this.nodeType) return false; + + // Check for same number of children + // Check for children this way because it is more efficient + // for childless leaf nodes. + var n; // number of child nodes + if (!this.firstChild) { + n = 0; + if (node.firstChild) return false; + } + else { + n = this.childNodes.length; + if (node.childNodes.length !== n) return false; + } -module.exports = (__webpack_require__(1))(9); + // Check type-specific properties for equality + if (!this.isEqual(node)) return false; -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { + // Now check children for equality + for(var i = 0; i < n; i++) { + var c1 = this.childNodes[i], c2 = node.childNodes[i]; + if (!c1.isEqualNode(c2)) return false; + } -module.exports = (__webpack_require__(1))(3); + return true; + }}, + + // This method delegates shallow cloning to a clone() method + // that each concrete subclass must implement + cloneNode: { value: function(deep) { + // Clone this node + var clone = this.clone(); + + // Handle the recursive case if necessary + if (deep && this.firstChild) { + for(var i = 0, n = this.childNodes.length; i < n; i++) { + clone._appendChild(this.childNodes[i].cloneNode(true)); + } + } -/***/ }), -/* 11 */ -/***/ (function(module, exports, __webpack_require__) { + return clone; + }}, + + lookupPrefix: { value: function lookupPrefix(ns) { + var e; + if (ns === '') return null; + switch(this.nodeType) { + case ELEMENT_NODE: + return this.locateNamespacePrefix(ns); + case DOCUMENT_NODE: + e = this.documentElement; + return e ? e.locateNamespacePrefix(ns) : null; + case DOCUMENT_TYPE_NODE: + case DOCUMENT_FRAGMENT_NODE: + return null; + default: + e = this.parentElement; + return e ? e.locateNamespacePrefix(ns) : null; + } + }}, + + + lookupNamespaceURI: {value: function lookupNamespaceURI(prefix) { + var e; + switch(this.nodeType) { + case ELEMENT_NODE: + return this.locateNamespace(prefix); + case DOCUMENT_NODE: + e = this.documentElement; + return e ? e.locateNamespace(prefix) : null; + case DOCUMENT_TYPE_NODE: + case DOCUMENT_FRAGMENT_NODE: + return null; + default: + e = this.parentElement; + return e ? e.locateNamespace(prefix) : null; + } + }}, + + isDefaultNamespace: { value: function isDefaultNamespace(ns) { + var defaultns = this.lookupNamespaceURI(null); + if (defaultns === null) defaultns = ''; + return ns === defaultns; + }}, + + // Utility methods for nodes. Not part of the DOM + + // Return the index of this node in its parent. + // Throw if no parent, or if this node is not a child of its parent + index: { get: function() { + utils.assert(this.parentNode); + var kids = this.parentNode.childNodes; + if (this._index === undefined || kids[this._index] !== this) { + // Ensure that we don't have an O(N^2) blowup if none of the + // kids have defined indices yet and we're traversing via + // nextSibling or prevSibling + for (var i=0; i'; + } + break; + case 3: //TEXT_NODE + case 4: //CDATA_SECTION_NODE + var parenttag; + if (this.nodeType === ELEMENT_NODE && + this.namespaceURI === NAMESPACE.HTML) + parenttag = this.tagName; + else + parenttag = ''; -module.exports = (__webpack_require__(1))(11); + if (hasRawContent[parenttag] || + (parenttag==='NOSCRIPT' && this.ownerDocument._scripting_enabled)) { + s += kid.data; + } else { + s += escape(kid.data); + } + break; + case 8: //COMMENT_NODE + s += ''; + break; + case 7: //PROCESSING_INSTRUCTION_NODE + s += ''; + break; + case 10: //DOCUMENT_TYPE_NODE + s += ''; + break; + default: + utils.InvalidState(); + } + } -/***/ }), -/* 16 */ -/***/ (function(module, exports, __webpack_require__) { + return s; + }}, + + // mirror node type properties in the prototype, so they are present + // in instances of Node (and subclasses) + ELEMENT_NODE: { value: ELEMENT_NODE }, + ATTRIBUTE_NODE: { value: ATTRIBUTE_NODE }, + TEXT_NODE: { value: TEXT_NODE }, + CDATA_SECTION_NODE: { value: CDATA_SECTION_NODE }, + ENTITY_REFERENCE_NODE: { value: ENTITY_REFERENCE_NODE }, + ENTITY_NODE: { value: ENTITY_NODE }, + PROCESSING_INSTRUCTION_NODE: { value: PROCESSING_INSTRUCTION_NODE }, + COMMENT_NODE: { value: COMMENT_NODE }, + DOCUMENT_NODE: { value: DOCUMENT_NODE }, + DOCUMENT_TYPE_NODE: { value: DOCUMENT_TYPE_NODE }, + DOCUMENT_FRAGMENT_NODE: { value: DOCUMENT_FRAGMENT_NODE }, + NOTATION_NODE: { value: NOTATION_NODE } +}); -module.exports = (__webpack_require__(1))(86); +function escape(s) { + return s.replace(/[&<>\u00A0]/g, function(c) { + switch(c) { + case '&': return '&'; + case '<': return '<'; + case '>': return '>'; + case '\u00A0': return ' '; + } + }); +} + +function escapeAttr(s) { + var toEscape = /[&"\u00A0]/g; + if (!toEscape.test(s)) { + // nothing to do, fast path + return s; + } else { + return s.replace(toEscape, function(c) { + switch(c) { + case '&': return '&'; + case '"': return '"'; + case '\u00A0': return ' '; + } + }); + } +} -/***/ }), -/* 17 */ -/***/ (function(module, exports, __webpack_require__) { +function attrname(a) { + var ns = a.namespaceURI; + if (!ns) + return a.localName; + if (ns === NAMESPACE.XML) + return 'xml:' + a.localName; + if (ns === NAMESPACE.XLINK) + return 'xlink:' + a.localName; + + if (ns === NAMESPACE.XMLNS) { + if (a.localName === 'xmlns') return 'xmlns'; + else return 'xmlns:' + a.localName; + } + return a.name; +} -module.exports = (__webpack_require__(1))(7); /***/ }), -/* 18 */ +/* 4 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; - +module.exports = (__webpack_require__(0))(3); -exports.REPLACEMENT_CHARACTER = '\uFFFD'; - -exports.CODE_POINTS = { - EOF: -1, - NULL: 0x00, - TABULATION: 0x09, - CARRIAGE_RETURN: 0x0D, - LINE_FEED: 0x0A, - FORM_FEED: 0x0C, - SPACE: 0x20, - EXCLAMATION_MARK: 0x21, - QUOTATION_MARK: 0x22, - NUMBER_SIGN: 0x23, - AMPERSAND: 0x26, - APOSTROPHE: 0x27, - HYPHEN_MINUS: 0x2D, - SOLIDUS: 0x2F, - DIGIT_0: 0x30, - DIGIT_9: 0x39, - SEMICOLON: 0x3B, - LESS_THAN_SIGN: 0x3C, - EQUALS_SIGN: 0x3D, - GREATER_THAN_SIGN: 0x3E, - QUESTION_MARK: 0x3F, - LATIN_CAPITAL_A: 0x41, - LATIN_CAPITAL_F: 0x46, - LATIN_CAPITAL_X: 0x58, - LATIN_CAPITAL_Z: 0x5A, - GRAVE_ACCENT: 0x60, - LATIN_SMALL_A: 0x61, - LATIN_SMALL_F: 0x66, - LATIN_SMALL_X: 0x78, - LATIN_SMALL_Z: 0x7A, - REPLACEMENT_CHARACTER: 0xFFFD -}; - -exports.CODE_POINT_SEQUENCES = { - DASH_DASH_STRING: [0x2D, 0x2D], //-- - DOCTYPE_STRING: [0x44, 0x4F, 0x43, 0x54, 0x59, 0x50, 0x45], //DOCTYPE - CDATA_START_STRING: [0x5B, 0x43, 0x44, 0x41, 0x54, 0x41, 0x5B], //[CDATA[ - CDATA_END_STRING: [0x5D, 0x5D, 0x3E], //]]> - SCRIPT_STRING: [0x73, 0x63, 0x72, 0x69, 0x70, 0x74], //script - PUBLIC_STRING: [0x50, 0x55, 0x42, 0x4C, 0x49, 0x43], //PUBLIC - SYSTEM_STRING: [0x53, 0x59, 0x53, 0x54, 0x45, 0x4D] //SYSTEM -}; +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { +module.exports = (__webpack_require__(0))(5); /***/ }), -/* 19 */ +/* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; +module.exports = Element; -var Preprocessor = __webpack_require__(119), - locationInfoMixin = __webpack_require__(111), - UNICODE = __webpack_require__(18), - neTree = __webpack_require__(118); +var xml = __webpack_require__(24); +var utils = __webpack_require__(1); +var NAMESPACE = utils.NAMESPACE; +var attributes = __webpack_require__(42); +var Node = __webpack_require__(3); +var NodeList = __webpack_require__(11); +var FilteredElementList = __webpack_require__(74); +var DOMTokenList = __webpack_require__(31); +var select = __webpack_require__(23); +var ChildNode = __webpack_require__(16); +var NonDocumentTypeChildNode = __webpack_require__(37); -//Aliases -var $ = UNICODE.CODE_POINTS, - $$ = UNICODE.CODE_POINT_SEQUENCES; - -//Replacement code points for numeric entities -var NUMERIC_ENTITY_REPLACEMENTS = { - 0x00: 0xFFFD, 0x0D: 0x000D, 0x80: 0x20AC, 0x81: 0x0081, 0x82: 0x201A, 0x83: 0x0192, 0x84: 0x201E, - 0x85: 0x2026, 0x86: 0x2020, 0x87: 0x2021, 0x88: 0x02C6, 0x89: 0x2030, 0x8A: 0x0160, 0x8B: 0x2039, - 0x8C: 0x0152, 0x8D: 0x008D, 0x8E: 0x017D, 0x8F: 0x008F, 0x90: 0x0090, 0x91: 0x2018, 0x92: 0x2019, - 0x93: 0x201C, 0x94: 0x201D, 0x95: 0x2022, 0x96: 0x2013, 0x97: 0x2014, 0x98: 0x02DC, 0x99: 0x2122, - 0x9A: 0x0161, 0x9B: 0x203A, 0x9C: 0x0153, 0x9D: 0x009D, 0x9E: 0x017E, 0x9F: 0x0178 -}; - -// Named entity tree flags -var HAS_DATA_FLAG = 1 << 0; -var DATA_DUPLET_FLAG = 1 << 1; -var HAS_BRANCHES_FLAG = 1 << 2; -var MAX_BRANCH_MARKER_VALUE = HAS_DATA_FLAG | DATA_DUPLET_FLAG | HAS_BRANCHES_FLAG; - - -//States -var DATA_STATE = 'DATA_STATE', - CHARACTER_REFERENCE_IN_DATA_STATE = 'CHARACTER_REFERENCE_IN_DATA_STATE', - RCDATA_STATE = 'RCDATA_STATE', - CHARACTER_REFERENCE_IN_RCDATA_STATE = 'CHARACTER_REFERENCE_IN_RCDATA_STATE', - RAWTEXT_STATE = 'RAWTEXT_STATE', - SCRIPT_DATA_STATE = 'SCRIPT_DATA_STATE', - PLAINTEXT_STATE = 'PLAINTEXT_STATE', - TAG_OPEN_STATE = 'TAG_OPEN_STATE', - END_TAG_OPEN_STATE = 'END_TAG_OPEN_STATE', - TAG_NAME_STATE = 'TAG_NAME_STATE', - RCDATA_LESS_THAN_SIGN_STATE = 'RCDATA_LESS_THAN_SIGN_STATE', - RCDATA_END_TAG_OPEN_STATE = 'RCDATA_END_TAG_OPEN_STATE', - RCDATA_END_TAG_NAME_STATE = 'RCDATA_END_TAG_NAME_STATE', - RAWTEXT_LESS_THAN_SIGN_STATE = 'RAWTEXT_LESS_THAN_SIGN_STATE', - RAWTEXT_END_TAG_OPEN_STATE = 'RAWTEXT_END_TAG_OPEN_STATE', - RAWTEXT_END_TAG_NAME_STATE = 'RAWTEXT_END_TAG_NAME_STATE', - SCRIPT_DATA_LESS_THAN_SIGN_STATE = 'SCRIPT_DATA_LESS_THAN_SIGN_STATE', - SCRIPT_DATA_END_TAG_OPEN_STATE = 'SCRIPT_DATA_END_TAG_OPEN_STATE', - SCRIPT_DATA_END_TAG_NAME_STATE = 'SCRIPT_DATA_END_TAG_NAME_STATE', - SCRIPT_DATA_ESCAPE_START_STATE = 'SCRIPT_DATA_ESCAPE_START_STATE', - SCRIPT_DATA_ESCAPE_START_DASH_STATE = 'SCRIPT_DATA_ESCAPE_START_DASH_STATE', - SCRIPT_DATA_ESCAPED_STATE = 'SCRIPT_DATA_ESCAPED_STATE', - SCRIPT_DATA_ESCAPED_DASH_STATE = 'SCRIPT_DATA_ESCAPED_DASH_STATE', - SCRIPT_DATA_ESCAPED_DASH_DASH_STATE = 'SCRIPT_DATA_ESCAPED_DASH_DASH_STATE', - SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE = 'SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE', - SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE = 'SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE', - SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE = 'SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE', - SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE = 'SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE', - SCRIPT_DATA_DOUBLE_ESCAPED_STATE = 'SCRIPT_DATA_DOUBLE_ESCAPED_STATE', - SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE = 'SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE', - SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE = 'SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE', - SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE = 'SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE', - SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE = 'SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE', - BEFORE_ATTRIBUTE_NAME_STATE = 'BEFORE_ATTRIBUTE_NAME_STATE', - ATTRIBUTE_NAME_STATE = 'ATTRIBUTE_NAME_STATE', - AFTER_ATTRIBUTE_NAME_STATE = 'AFTER_ATTRIBUTE_NAME_STATE', - BEFORE_ATTRIBUTE_VALUE_STATE = 'BEFORE_ATTRIBUTE_VALUE_STATE', - ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE = 'ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE', - ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE = 'ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE', - ATTRIBUTE_VALUE_UNQUOTED_STATE = 'ATTRIBUTE_VALUE_UNQUOTED_STATE', - CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE_STATE = 'CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE_STATE', - AFTER_ATTRIBUTE_VALUE_QUOTED_STATE = 'AFTER_ATTRIBUTE_VALUE_QUOTED_STATE', - SELF_CLOSING_START_TAG_STATE = 'SELF_CLOSING_START_TAG_STATE', - BOGUS_COMMENT_STATE = 'BOGUS_COMMENT_STATE', - BOGUS_COMMENT_STATE_CONTINUATION = 'BOGUS_COMMENT_STATE_CONTINUATION', - MARKUP_DECLARATION_OPEN_STATE = 'MARKUP_DECLARATION_OPEN_STATE', - COMMENT_START_STATE = 'COMMENT_START_STATE', - COMMENT_START_DASH_STATE = 'COMMENT_START_DASH_STATE', - COMMENT_STATE = 'COMMENT_STATE', - COMMENT_END_DASH_STATE = 'COMMENT_END_DASH_STATE', - COMMENT_END_STATE = 'COMMENT_END_STATE', - COMMENT_END_BANG_STATE = 'COMMENT_END_BANG_STATE', - DOCTYPE_STATE = 'DOCTYPE_STATE', - DOCTYPE_NAME_STATE = 'DOCTYPE_NAME_STATE', - AFTER_DOCTYPE_NAME_STATE = 'AFTER_DOCTYPE_NAME_STATE', - BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE = 'BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE', - DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE = 'DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE', - DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE = 'DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE', - BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE = 'BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE', - BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE = 'BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE', - DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE = 'DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE', - DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE = 'DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE', - AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE = 'AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE', - BOGUS_DOCTYPE_STATE = 'BOGUS_DOCTYPE_STATE', - CDATA_SECTION_STATE = 'CDATA_SECTION_STATE'; - -//Utils - -//OPTIMIZATION: these utility functions should not be moved out of this module. V8 Crankshaft will not inline -//this functions if they will be situated in another module due to context switch. -//Always perform inlining check before modifying this functions ('node --trace-inlining'). -function isWhitespace(cp) { - return cp === $.SPACE || cp === $.LINE_FEED || cp === $.TABULATION || cp === $.FORM_FEED; -} +function Element(doc, localName, namespaceURI, prefix) { + this.nodeType = Node.ELEMENT_NODE; + this.ownerDocument = doc; + this.localName = localName; + this.namespaceURI = namespaceURI; + this.prefix = prefix; -function isAsciiDigit(cp) { - return cp >= $.DIGIT_0 && cp <= $.DIGIT_9; -} + this.tagName = (prefix !== null) ? prefix + ':' + localName : localName; -function isAsciiUpper(cp) { - return cp >= $.LATIN_CAPITAL_A && cp <= $.LATIN_CAPITAL_Z; -} + if (namespaceURI !== NAMESPACE.HTML || (!namespaceURI && !doc.isHTML)) this.isHTML = false; -function isAsciiLower(cp) { - return cp >= $.LATIN_SMALL_A && cp <= $.LATIN_SMALL_Z; -} + if (this.isHTML) this.tagName = this.tagName.toUpperCase(); -function isAsciiLetter(cp) { - return isAsciiLower(cp) || isAsciiUpper(cp); -} + this.childNodes = new NodeList(); -function isAsciiAlphaNumeric(cp) { - return isAsciiLetter(cp) || isAsciiDigit(cp); -} + // These properties maintain the set of attributes + this._attrsByQName = Object.create(null); // The qname->Attr map + this._attrsByLName = Object.create(null); // The ns|lname->Attr map + this._attrKeys = []; // attr index -> ns|lname -function isDigit(cp, isHex) { - return isAsciiDigit(cp) || isHex && (cp >= $.LATIN_CAPITAL_A && cp <= $.LATIN_CAPITAL_F || - cp >= $.LATIN_SMALL_A && cp <= $.LATIN_SMALL_F); + this._index = undefined; } -function isReservedCodePoint(cp) { - return cp >= 0xD800 && cp <= 0xDFFF || cp > 0x10FFFF; +function recursiveGetText(node, a) { + if (node.nodeType === Node.TEXT_NODE) { + a.push(node._data); + } + else { + for(var i = 0, n = node.childNodes.length; i < n; i++) + recursiveGetText(node.childNodes[i], a); + } } -function toAsciiLowerCodePoint(cp) { - return cp + 0x0020; -} +Element.prototype = Object.create(Node.prototype, { + nodeName: { get: function() { return this.tagName; }}, + nodeValue: { + get: function() { + return null; + }, + set: function() {} + }, + textContent: { + get: function() { + var strings = []; + recursiveGetText(this, strings); + return strings.join(''); + }, + set: function(newtext) { + this.removeChildren(); + if (newtext !== null && newtext !== '') { + this._appendChild(this.ownerDocument.createTextNode(newtext)); + } + } + }, + innerHTML: { + get: function() { + return this.serialize(); + }, + set: utils.nyi + }, + outerHTML: { + get: function() { + // "the attribute must return the result of running the HTML fragment + // serialization algorithm on a fictional node whose only child is + // the context object" + var fictional = { + childNodes: [ this ], + nodeType: 0 + }; + return Node.prototype.serialize.call(fictional); + }, + set: utils.nyi + }, -//NOTE: String.fromCharCode() function can handle only characters from BMP subset. -//So, we need to workaround this manually. -//(see: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/fromCharCode#Getting_it_to_work_with_higher_values) -function toChar(cp) { - if (cp <= 0xFFFF) - return String.fromCharCode(cp); + children: { get: function() { + if (!this._children) { + this._children = new ChildrenCollection(this); + } + return this._children; + }}, - cp -= 0x10000; - return String.fromCharCode(cp >>> 10 & 0x3FF | 0xD800) + String.fromCharCode(0xDC00 | cp & 0x3FF); -} + attributes: { get: function() { + if (!this._attributes) { + this._attributes = new AttributesArray(this); + } + return this._attributes; + }}, -function toAsciiLowerChar(cp) { - return String.fromCharCode(toAsciiLowerCodePoint(cp)); -} -function findNamedEntityTreeBranch(nodeIx, cp) { - var branchCount = neTree[++nodeIx], - lo = ++nodeIx, - hi = lo + branchCount - 1; + firstElementChild: { get: function() { + var kids = this.childNodes; + for(var i = 0, n = kids.length; i < n; i++) { + if (kids[i].nodeType === Node.ELEMENT_NODE) return kids[i]; + } + return null; + }}, - while (lo <= hi) { - var mid = lo + hi >>> 1, - midCp = neTree[mid]; + lastElementChild: { get: function() { + var kids = this.childNodes; + for(var i = kids.length-1; i >= 0; i--) { + if (kids[i].nodeType === Node.ELEMENT_NODE) return kids[i]; + } + return null; + }}, + + childElementCount: { get: function() { + return this.children.length; + }}, + + + // Return the next element, in source order, after this one or + // null if there are no more. If root element is specified, + // then don't traverse beyond its subtree. + // + // This is not a DOM method, but is convenient for + // lazy traversals of the tree. + nextElement: { value: function(root) { + if (!root) root = this.ownerDocument.documentElement; + var next = this.firstElementChild; + if (!next) { + // don't use sibling if we're at root + if (this===root) return null; + next = this.nextElementSibling; + } + if (next) return next; + + // If we can't go down or across, then we have to go up + // and across to the parent sibling or another ancestor's + // sibling. Be careful, though: if we reach the root + // element, or if we reach the documentElement, then + // the traversal ends. + for(var parent = this.parentElement; + parent && parent !== root; + parent = parent.parentElement) { + + next = parent.nextElementSibling; + if (next) return next; + } - if (midCp < cp) - lo = mid + 1; + return null; + }}, + + // XXX: + // Tests are currently failing for this function. + // Awaiting resolution of: + // http://lists.w3.org/Archives/Public/www-dom/2011JulSep/0016.html + getElementsByTagName: { value: function getElementsByTagName(lname) { + var filter; + if (!lname) return new NodeList(); + if (lname === '*') + filter = function() { return true; }; + else if (this.isHTML) + filter = htmlLocalNameElementFilter(lname); + else + filter = localNameElementFilter(lname); + + return new FilteredElementList(this, filter); + }}, + + getElementsByTagNameNS: { value: function getElementsByTagNameNS(ns, lname){ + var filter; + if (ns === '*' && lname === '*') + filter = function() { return true; }; + else if (ns === '*') + filter = localNameElementFilter(lname); + else if (lname === '*') + filter = namespaceElementFilter(ns); + else + filter = namespaceLocalNameElementFilter(ns, lname); + + return new FilteredElementList(this, filter); + }}, + + getElementsByClassName: { value: function getElementsByClassName(names){ + names = String(names).trim(); + if (names === '') { + var result = new NodeList(); // Empty node list + return result; + } + names = names.split(/\s+/); // Split on spaces + return new FilteredElementList(this, classNamesElementFilter(names)); + }}, + + getElementsByName: { value: function getElementsByName(name) { + return new FilteredElementList(this, elementNameFilter(String(name))); + }}, + + // Overwritten in the constructor if not in the HTML namespace + isHTML: { value: true, writable: true }, + + // Utility methods used by the public API methods above + clone: { value: function clone() { + var e; + + // XXX: + // Modify this to use the constructor directly or + // avoid error checking in some other way. In case we try + // to clone an invalid node that the parser inserted. + // + if (this.namespaceURI !== NAMESPACE.HTML || this.prefix) + e = this.ownerDocument.createElementNS(this.namespaceURI, + this.tagName); + else + e = this.ownerDocument.createElement(this.localName); + + for(var i = 0, n = this._attrKeys.length; i < n; i++) { + var lname = this._attrKeys[i]; + var a = this._attrsByLName[lname]; + var b = new Attr(e, a.localName, a.prefix, a.namespaceURI); + b.data = a.data; + e._attrsByLName[lname] = b; + e._addQName(b); + } + e._attrKeys = this._attrKeys.concat(); + + return e; + }}, + + isEqual: { value: function isEqual(that) { + if (this.localName !== that.localName || + this.namespaceURI !== that.namespaceURI || + this.prefix !== that.prefix || + this._numattrs !== that._numattrs) + return false; + + // Compare the sets of attributes, ignoring order + // and ignoring attribute prefixes. + for(var i = 0, n = this._numattrs; i < n; i++) { + var a = this._attr(i); + if (!that.hasAttributeNS(a.namespaceURI, a.localName)) + return false; + if (that.getAttributeNS(a.namespaceURI,a.localName) !== a.value) + return false; + } - else if (midCp > cp) - hi = mid - 1; + return true; + }}, + + // This is the 'locate a namespace prefix' algorithm from the + // DOMCore specification. It is used by Node.lookupPrefix() + locateNamespacePrefix: { value: function locateNamespacePrefix(ns) { + if (this.namespaceURI === ns && this.prefix !== null) + return this.prefix; + + for(var i = 0, n = this._numattrs; i < n; i++) { + var a = this._attr(i); + if (a.prefix === 'xmlns' && a.value === ns) + return a.localName; + } + + var parent = this.parentElement; + return parent ? parent.locateNamespacePrefix(ns) : null; + }}, + + // This is the 'locate a namespace' algorithm for Element nodes + // from the DOM Core spec. It is used by Node.lookupNamespaceURI + locateNamespace: { value: function locateNamespace(prefix) { + if (this.prefix === prefix && this.namespaceURI !== null) + return this.namespaceURI; + + for(var i = 0, n = this._numattrs; i < n; i++) { + var a = this._attr(i); + if ((a.prefix === 'xmlns' && a.localName === prefix) || + (a.prefix === null && a.localName === 'xmlns')) { + return a.value || null; + } + } - else - return neTree[mid + branchCount]; + var parent = this.parentElement; + return parent ? parent.locateNamespace(prefix) : null; + }}, + + // + // Attribute handling methods and utilities + // + + /* + * Attributes in the DOM are tricky: + * + * - there are the 8 basic get/set/has/removeAttribute{NS} methods + * + * - but many HTML attributes are also 'reflected' through IDL + * attributes which means that they can be queried and set through + * regular properties of the element. There is just one attribute + * value, but two ways to get and set it. + * + * - Different HTML element types have different sets of reflected + attributes. + * + * - attributes can also be queried and set through the .attributes + * property of an element. This property behaves like an array of + * Attr objects. The value property of each Attr is writeable, so + * this is a third way to read and write attributes. + * + * - for efficiency, we really want to store attributes in some kind + * of name->attr map. But the attributes[] array is an array, not a + * map, which is kind of unnatural. + * + * - When using namespaces and prefixes, and mixing the NS methods + * with the non-NS methods, it is apparently actually possible for + * an attributes[] array to have more than one attribute with the + * same qualified name. And certain methods must operate on only + * the first attribute with such a name. So for these methods, an + * inefficient array-like data structure would be easier to + * implement. + * + * - The attributes[] array is live, not a snapshot, so changes to the + * attributes must be immediately visible through existing arrays. + * + * - When attributes are queried and set through IDL properties + * (instead of the get/setAttributes() method or the attributes[] + * array) they may be subject to type conversions, URL + * normalization, etc., so some extra processing is required in that + * case. + * + * - But access through IDL properties is probably the most common + * case, so we'd like that to be as fast as possible. + * + * - We can't just store attribute values in their parsed idl form, + * because setAttribute() has to return whatever string is passed to + * getAttribute even if it is not a legal, parseable value. So + * attribute values must be stored in unparsed string form. + * + * - We need to be able to send change notifications or mutation + * events of some sort to the renderer whenever an attribute value + * changes, regardless of the way in which it changes. + * + * - Some attributes, such as id and class affect other parts of the + * DOM API, like getElementById and getElementsByClassName and so + * for efficiency, we need to specially track changes to these + * special attributes. + * + * - Some attributes like class have different names (className) when + * reflected. + * + * - Attributes whose names begin with the string 'data-' are treated + specially. + * + * - Reflected attributes that have a boolean type in IDL have special + * behavior: setting them to false (in IDL) is the same as removing + * them with removeAttribute() + * + * - numeric attributes (like HTMLElement.tabIndex) can have default + * values that must be returned by the idl getter even if the + * content attribute does not exist. (The default tabIndex value + * actually varies based on the type of the element, so that is a + * tricky one). + * + * See + * http://www.whatwg.org/specs/web-apps/current-work/multipage/urls.html#reflect + * for rules on how attributes are reflected. + * + */ + + getAttribute: { value: function getAttribute(qname) { + if (this.isHTML) qname = utils.toASCIILowerCase(qname); + var attr = this._attrsByQName[qname]; + if (!attr) return null; + + if (Array.isArray(attr)) // If there is more than one + attr = attr[0]; // use the first + + return attr.value; + }}, + + getAttributeNS: { value: function getAttributeNS(ns, lname) { + var attr = this._attrsByLName[(ns === null ? '' : ns) + '|' + lname]; + return attr ? attr.value : null; + }}, + + hasAttribute: { value: function hasAttribute(qname) { + if (this.isHTML) qname = utils.toASCIILowerCase(qname); + return this._attrsByQName[qname] !== undefined; + }}, + + hasAttributeNS: { value: function hasAttributeNS(ns, lname) { + var key = (ns === null ? '' : ns) + '|' + lname; + return this._attrsByLName[key] !== undefined; + }}, + + // Set the attribute without error checking. The parser uses this. + _setAttribute: { value: function _setAttribute(qname, value) { + // XXX: the spec says that this next search should be done + // on the local name, but I think that is an error. + // email pending on www-dom about it. + var attr = this._attrsByQName[qname]; + var isnew; + if (!attr) { + attr = this._newattr(qname); + isnew = true; + } + else { + if (Array.isArray(attr)) attr = attr[0]; } - return -1; -} + // Now set the attribute value on the new or existing Attr object. + // The Attr.value setter method handles mutation events, etc. + attr.value = value; + if (this._attributes) this._attributes[qname] = attr; + if (isnew && this._newattrhook) this._newattrhook(qname, value); + }}, + // Check for errors, and then set the attribute + setAttribute: { value: function setAttribute(qname, value) { + if (!xml.isValidName(qname)) utils.InvalidCharacterError(); + if (this.isHTML) qname = utils.toASCIILowerCase(qname); + if (qname.substring(0, 5) === 'xmlns') utils.NamespaceError(); + this._setAttribute(qname, String(value)); + }}, -//Tokenizer -var Tokenizer = module.exports = function (options) { - this.preprocessor = new Preprocessor(); - this.tokenQueue = []; + // The version with no error checking used by the parser + _setAttributeNS: { value: function _setAttributeNS(ns, qname, value) { + var pos = qname.indexOf(':'), prefix, lname; + if (pos === -1) { + prefix = null; + lname = qname; + } + else { + prefix = qname.substring(0, pos); + lname = qname.substring(pos+1); + } - this.allowCDATA = false; + var key = (ns === null ? '' : ns) + '|' + lname; + if (ns === '') ns = null; - this.state = DATA_STATE; - this.returnState = ''; + var attr = this._attrsByLName[key]; + var isnew; + if (!attr) { + attr = new Attr(this, lname, prefix, ns); + isnew = true; + this._attrsByLName[key] = attr; + this._attrKeys.push(key); - this.tempBuff = []; - this.additionalAllowedCp = void 0; - this.lastStartTagName = ''; + // We also have to make the attr searchable by qname. + // But we have to be careful because there may already + // be an attr with this qname. + this._addQName(attr); + } + else { + // Calling setAttributeNS() can change the prefix of an + // existing attribute! + if (attr.prefix !== prefix) { + // Unbind the old qname + this._removeQName(attr); + // Update the prefix + attr.prefix = prefix; + // Bind the new qname + this._addQName(attr); - this.consumedAfterSnapshot = -1; - this.active = false; + } - this.currentCharacterToken = null; - this.currentToken = null; - this.currentAttr = null; + } + attr.value = value; // Automatically sends mutation event + if (isnew && this._newattrhook) this._newattrhook(qname, value); + }}, - if (options && options.locationInfo) - locationInfoMixin.assign(this); -}; + // Do error checking then call _setAttributeNS + setAttributeNS: { value: function setAttributeNS(ns, qname, value) { + if (!xml.isValidName(qname)) utils.InvalidCharacterError(); + if (!xml.isValidQName(qname)) utils.NamespaceError(); -//Token types -Tokenizer.CHARACTER_TOKEN = 'CHARACTER_TOKEN'; -Tokenizer.NULL_CHARACTER_TOKEN = 'NULL_CHARACTER_TOKEN'; -Tokenizer.WHITESPACE_CHARACTER_TOKEN = 'WHITESPACE_CHARACTER_TOKEN'; -Tokenizer.START_TAG_TOKEN = 'START_TAG_TOKEN'; -Tokenizer.END_TAG_TOKEN = 'END_TAG_TOKEN'; -Tokenizer.COMMENT_TOKEN = 'COMMENT_TOKEN'; -Tokenizer.DOCTYPE_TOKEN = 'DOCTYPE_TOKEN'; -Tokenizer.EOF_TOKEN = 'EOF_TOKEN'; -Tokenizer.HIBERNATION_TOKEN = 'HIBERNATION_TOKEN'; - -//Tokenizer initial states for different modes -Tokenizer.MODE = Tokenizer.prototype.MODE = { - DATA: DATA_STATE, - RCDATA: RCDATA_STATE, - RAWTEXT: RAWTEXT_STATE, - SCRIPT_DATA: SCRIPT_DATA_STATE, - PLAINTEXT: PLAINTEXT_STATE -}; + var pos = qname.indexOf(':'); + var prefix = (pos === -1) ? null : qname.substring(0, pos); + if (ns === '') ns = null; -//Static -Tokenizer.getTokenAttr = function (token, attrName) { - for (var i = token.attrs.length - 1; i >= 0; i--) { - if (token.attrs[i].name === attrName) - return token.attrs[i].value; - } + if ((prefix !== null && ns === null) || + (prefix === 'xml' && ns !== NAMESPACE.XML) || + ((qname === 'xmlns' || prefix === 'xmlns') && + (ns !== NAMESPACE.XMLNS)) || + (ns === NAMESPACE.XMLNS && + !(qname === 'xmlns' || prefix === 'xmlns'))) + utils.NamespaceError(); - return null; -}; + this._setAttributeNS(ns, qname, String(value)); + }}, -//API -Tokenizer.prototype.getNextToken = function () { - while (!this.tokenQueue.length && this.active) { - this._hibernationSnapshot(); + removeAttribute: { value: function removeAttribute(qname) { + if (this.isHTML) qname = utils.toASCIILowerCase(qname); - var cp = this._consume(); + var attr = this._attrsByQName[qname]; + if (!attr) return; - if (!this._ensureHibernation()) - this[this.state](cp); + // If there is more than one match for this qname + // so don't delete the qname mapping, just remove the first + // element from it. + if (Array.isArray(attr)) { + if (attr.length > 2) { + attr = attr.shift(); // remove it from the array + } + else { + this._attrsByQName[qname] = attr[1]; + attr = attr[0]; + } + } + else { + // only a single match, so remove the qname mapping + this._attrsByQName[qname] = undefined; + } + + var ns = attr.namespaceURI; + // Now attr is the removed attribute. Figure out its + // ns+lname key and remove it from the other mapping as well. + var key = (ns === null ? '' : ns) + '|' + attr.localName; + this._attrsByLName[key] = undefined; + + var i = this._attrKeys.indexOf(key); + this._attrKeys.splice(i, 1); + + if (this._attributes) + this._attributes[qname] = undefined; + + // Onchange handler for the attribute + if (attr.onchange) + attr.onchange(this, attr.localName, attr.value, null); + + // Mutation event + if (this.rooted) this.ownerDocument.mutateRemoveAttr(attr); + }}, + + removeAttributeNS: { value: function removeAttributeNS(ns, lname) { + var key = (ns === null ? '' : ns) + '|' + lname; + var attr = this._attrsByLName[key]; + if (!attr) return; + + this._attrsByLName[key] = undefined; + + var i = this._attrKeys.indexOf(key); + this._attrKeys.splice(i, 1); + + // Now find the same Attr object in the qname mapping and remove it + // But be careful because there may be more than one match. + this._removeQName(attr); + + // Onchange handler for the attribute + if (attr.onchange) + attr.onchange(this, attr.localName, attr.value, null); + // Mutation event + if (this.rooted) this.ownerDocument.mutateRemoveAttr(attr); + }}, + + // This 'raw' version of getAttribute is used by the getter functions + // of reflected attributes. It skips some error checking and + // namespace steps + _getattr: { value: function _getattr(qname) { + // Assume that qname is already lowercased, so don't do it here. + // Also don't check whether attr is an array: a qname with no + // prefix will never have two matching Attr objects (because + // setAttributeNS doesn't allow a non-null namespace with a + // null prefix. + var attr = this._attrsByQName[qname]; + return attr ? attr.value : null; + }}, + + // The raw version of setAttribute for reflected idl attributes. + _setattr: { value: function _setattr(qname, value) { + var attr = this._attrsByQName[qname]; + var isnew; + if (!attr) { + attr = this._newattr(qname); + isnew = true; + } + attr.value = String(value); + if (this._attributes) this._attributes[qname] = attr; + if (isnew && this._newattrhook) this._newattrhook(qname, value); + }}, + + // Create a new Attr object, insert it, and return it. + // Used by setAttribute() and by set() + _newattr: { value: function _newattr(qname) { + var attr = new Attr(this, qname, null, null); + var key = '|' + qname; + this._attrsByQName[qname] = attr; + this._attrsByLName[key] = attr; + this._attrKeys.push(key); + return attr; + }}, + + // Add a qname->Attr mapping to the _attrsByQName object, taking into + // account that there may be more than one attr object with the + // same qname + _addQName: { value: function(attr) { + var qname = attr.name; + var existing = this._attrsByQName[qname]; + if (!existing) { + this._attrsByQName[qname] = attr; + } + else if (Array.isArray(existing)) { + existing.push(attr); + } + else { + this._attrsByQName[qname] = [existing, attr]; + } + if (this._attributes) this._attributes[qname] = attr; + }}, + + // Remove a qname->Attr mapping to the _attrsByQName object, taking into + // account that there may be more than one attr object with the + // same qname + _removeQName: { value: function(attr) { + var qname = attr.name; + var target = this._attrsByQName[qname]; + + if (Array.isArray(target)) { + var idx = target.indexOf(attr); + utils.assert(idx !== -1); // It must be here somewhere + if (target.length === 2) { + this._attrsByQName[qname] = target[1-idx]; + } + else { + target.splice(idx, 1); + } } + else { + utils.assert(target === attr); // If only one, it must match + this._attrsByQName[qname] = undefined; + } + }}, - return this.tokenQueue.shift(); -}; + // Return the number of attributes + _numattrs: { get: function() { return this._attrKeys.length; }}, + // Return the nth Attr object + _attr: { value: function(n) { + return this._attrsByLName[this._attrKeys[n]]; + }}, -Tokenizer.prototype.write = function (chunk, isLastChunk) { - this.active = true; - this.preprocessor.write(chunk, isLastChunk); -}; + // Define getters and setters for an 'id' property that reflects + // the content attribute 'id'. + id: attributes.property({name: 'id'}), -Tokenizer.prototype.insertHtmlAtCurrentPos = function (chunk) { - this.active = true; - this.preprocessor.insertHtmlAtCurrentPos(chunk); -}; + // Define getters and setters for a 'className' property that reflects + // the content attribute 'class'. + className: attributes.property({name: 'class'}), -//Hibernation -Tokenizer.prototype._hibernationSnapshot = function () { - this.consumedAfterSnapshot = 0; -}; + classList: { get: function() { + var self = this; + if (this._classList) { + return this._classList; + } + var dtlist = new DOMTokenList( + function() { + return self.className || ""; + }, + function(v) { + self.className = v; + } + ); + this._classList = dtlist; + return dtlist; + }}, + + matches: { value: function(selector) { + return select.matches(this, selector); + }}, + + closest: { value: function(selector) { + var el = this; + while (el.matches && !el.matches(selector)) el = el.parentNode; + return el.matches ? el : null; + }}, + + querySelector: { value: function(selector) { + return select(selector, this)[0]; + }}, + + querySelectorAll: { value: function(selector) { + var nodes = select(selector, this); + return nodes.item ? nodes : new NodeList(nodes); + }} -Tokenizer.prototype._ensureHibernation = function () { - if (this.preprocessor.endOfChunkHit) { - for (; this.consumedAfterSnapshot > 0; this.consumedAfterSnapshot--) - this.preprocessor.retreat(); - - this.active = false; - this.tokenQueue.push({type: Tokenizer.HIBERNATION_TOKEN}); - - return true; - } - - return false; -}; - - -//Consumption -Tokenizer.prototype._consume = function () { - this.consumedAfterSnapshot++; - return this.preprocessor.advance(); -}; - -Tokenizer.prototype._unconsume = function () { - this.consumedAfterSnapshot--; - this.preprocessor.retreat(); -}; - -Tokenizer.prototype._unconsumeSeveral = function (count) { - while (count--) - this._unconsume(); -}; - -Tokenizer.prototype._reconsumeInState = function (state) { - this.state = state; - this._unconsume(); -}; - -Tokenizer.prototype._consumeSubsequentIfMatch = function (pattern, startCp, caseSensitive) { - var consumedCount = 0, - isMatch = true, - patternLength = pattern.length, - patternPos = 0, - cp = startCp, - patternCp = void 0; - - for (; patternPos < patternLength; patternPos++) { - if (patternPos > 0) { - cp = this._consume(); - consumedCount++; - } - - if (cp === $.EOF) { - isMatch = false; - break; - } - - patternCp = pattern[patternPos]; - - if (cp !== patternCp && (caseSensitive || cp !== toAsciiLowerCodePoint(patternCp))) { - isMatch = false; - break; - } - } - - if (!isMatch) - this._unconsumeSeveral(consumedCount); - - return isMatch; -}; - -//Lookahead -Tokenizer.prototype._lookahead = function () { - var cp = this._consume(); - - this._unconsume(); - - return cp; -}; - -//Temp buffer -Tokenizer.prototype.isTempBufferEqualToScriptString = function () { - if (this.tempBuff.length !== $$.SCRIPT_STRING.length) - return false; - - for (var i = 0; i < this.tempBuff.length; i++) { - if (this.tempBuff[i] !== $$.SCRIPT_STRING[i]) - return false; - } +}); +Object.defineProperties(Element.prototype, ChildNode); +Object.defineProperties(Element.prototype, NonDocumentTypeChildNode); + +// Register special handling for the id attribute +attributes.registerChangeHandler(Element, 'id', + function(element, lname, oldval, newval) { + if (element.rooted) { + if (oldval) { + element.ownerDocument.delId(oldval, element); + } + if (newval) { + element.ownerDocument.addId(newval, element); + } + } + } +); + + +// The Attr class represents a single attribute. The values in +// _attrsByQName and _attrsByLName are instances of this class. +function Attr(elt, lname, prefix, namespace) { + // Always remember what element we're associated with. + // We need this to property handle mutations + this.ownerElement = elt; + + if (!namespace && !prefix && elt._attributeChangeHandlers[lname]) + this.onchange = elt._attributeChangeHandlers[lname]; + + // localName and namespace are constant for any attr object. + // But value may change. And so can prefix, and so, therefore can name. + this.localName = lname; + this.prefix = (prefix===null || prefix==='') ? null : ('' + prefix); + this.namespaceURI = (namespace===null || namespace==='') ? null : ('' + namespace); +} + +Attr.prototype = { + get name() { + return this.prefix ? this.prefix + ':' + this.localName : this.localName; + }, + + get value() { + return this.data; + }, + + get specified() { + // Deprecated return true; -}; - -//Token creation -Tokenizer.prototype._createStartTagToken = function () { - this.currentToken = { - type: Tokenizer.START_TAG_TOKEN, - tagName: '', - selfClosing: false, - attrs: [] - }; -}; - -Tokenizer.prototype._createEndTagToken = function () { - this.currentToken = { - type: Tokenizer.END_TAG_TOKEN, - tagName: '', - attrs: [] - }; -}; - -Tokenizer.prototype._createCommentToken = function () { - this.currentToken = { - type: Tokenizer.COMMENT_TOKEN, - data: '' - }; -}; - -Tokenizer.prototype._createDoctypeToken = function (initialName) { - this.currentToken = { - type: Tokenizer.DOCTYPE_TOKEN, - name: initialName, - forceQuirks: false, - publicId: null, - systemId: null - }; -}; - -Tokenizer.prototype._createCharacterToken = function (type, ch) { - this.currentCharacterToken = { - type: type, - chars: ch - }; -}; - -//Tag attributes -Tokenizer.prototype._createAttr = function (attrNameFirstCh) { - this.currentAttr = { - name: attrNameFirstCh, - value: '' - }; -}; - -Tokenizer.prototype._isDuplicateAttr = function () { - return Tokenizer.getTokenAttr(this.currentToken, this.currentAttr.name) !== null; -}; - -Tokenizer.prototype._leaveAttrName = function (toState) { - this.state = toState; - - if (!this._isDuplicateAttr()) - this.currentToken.attrs.push(this.currentAttr); -}; + }, + + set value(value) { + var oldval = this.data; + value = (value === undefined) ? '' : value + ''; + if (value === oldval) return; + + this.data = value; + + // Run the onchange hook for the attribute + // if there is one. + if (this.onchange) + this.onchange(this.ownerElement,this.localName, oldval, value); + + // Generate a mutation event if the element is rooted + if (this.ownerElement.rooted) + this.ownerElement.ownerDocument.mutateAttr(this, oldval); + }, + + // Legacy aliases (see gh#70 and https://dom.spec.whatwg.org/#interface-attr) + get nodeName() { return this.name; }, + get nodeValue() { return this.value; }, + get textContent() { return this.value; }, + set nodeValue(v) { this.value = v; }, + set textContent(v) { this.value = v; }, +}; + + +// The attributes property of an Element will be an instance of this class. +// This class is really just a dummy, though. It only defines a length +// property and an item() method. The AttrArrayProxy that +// defines the public API just uses the Element object itself. +function AttributesArray(elt) { + this.element = elt; + for (var name in elt._attrsByQName) { + this[name] = elt._attrsByQName[name]; + } +} +AttributesArray.prototype = { + get length() { + return this.element._attrKeys.length; + }, + item: function(n) { + return this.element._attrsByLName[this.element._attrKeys[n]]; + } +}; + + +// The children property of an Element will be an instance of this class. +// It defines length, item() and namedItem() and will be wrapped by an +// HTMLCollection when exposed through the DOM. +function ChildrenCollection(e) { + this.element = e; + this.updateCache(); +} + +ChildrenCollection.prototype = { + get length() { + this.updateCache(); + return this.childrenByNumber.length; + }, + item: function item(n) { + this.updateCache(); + return this.childrenByNumber[n] || null; + }, + + namedItem: function namedItem(name) { + this.updateCache(); + return this.childrenByName[name] || null; + }, + + // This attribute returns the entire name->element map. + // It is not part of the HTMLCollection API, but we need it in + // src/HTMLCollectionProxy + get namedItems() { + this.updateCache(); + return this.childrenByName; + }, + + updateCache: function updateCache() { + var namedElts = /^(a|applet|area|embed|form|frame|frameset|iframe|img|object)$/; + if (this.lastModTime !== this.element.lastModTime) { + this.lastModTime = this.element.lastModTime; + + var n = this.childrenByNumber && this.childrenByNumber.length || 0; + for(var i = 0; i < n; i++) { + this[i] = undefined; + } -Tokenizer.prototype._leaveAttrValue = function (toState) { - this.state = toState; -}; + this.childrenByNumber = []; + this.childrenByName = Object.create(null); -//Appropriate end tag token -//(see: http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#appropriate-end-tag-token) -Tokenizer.prototype._isAppropriateEndTagToken = function () { - return this.lastStartTagName === this.currentToken.tagName; -}; + for(i = 0, n = this.element.childNodes.length; i < n; i++) { + var c = this.element.childNodes[i]; + if (c.nodeType === Node.ELEMENT_NODE) { -//Token emission -Tokenizer.prototype._emitCurrentToken = function () { - this._emitCurrentCharacterToken(); + this[this.childrenByNumber.length] = c; + this.childrenByNumber.push(c); - //NOTE: store emited start tag's tagName to determine is the following end tag token is appropriate. - if (this.currentToken.type === Tokenizer.START_TAG_TOKEN) - this.lastStartTagName = this.currentToken.tagName; + // XXX Are there any requirements about the namespace + // of the id property? + var id = c.getAttribute('id'); - this.tokenQueue.push(this.currentToken); - this.currentToken = null; -}; + // If there is an id that is not already in use... + if (id && !this.childrenByName[id]) + this.childrenByName[id] = c; -Tokenizer.prototype._emitCurrentCharacterToken = function () { - if (this.currentCharacterToken) { - this.tokenQueue.push(this.currentCharacterToken); - this.currentCharacterToken = null; + // For certain HTML elements we check the name attribute + var name = c.getAttribute('name'); + if (name && + this.element.namespaceURI === NAMESPACE.HTML && + namedElts.test(this.element.localName) && + !this.childrenByName[name]) + this.childrenByName[id] = c; + } + } } + } }; -Tokenizer.prototype._emitEOFToken = function () { - this._emitCurrentCharacterToken(); - this.tokenQueue.push({type: Tokenizer.EOF_TOKEN}); -}; - -//Characters emission - -//OPTIMIZATION: specification uses only one type of character tokens (one token per character). -//This causes a huge memory overhead and a lot of unnecessary parser loops. parse5 uses 3 groups of characters. -//If we have a sequence of characters that belong to the same group, parser can process it -//as a single solid character token. -//So, there are 3 types of character tokens in parse5: -//1)NULL_CHARACTER_TOKEN - \u0000-character sequences (e.g. '\u0000\u0000\u0000') -//2)WHITESPACE_CHARACTER_TOKEN - any whitespace/new-line character sequences (e.g. '\n \r\t \f') -//3)CHARACTER_TOKEN - any character sequence which don't belong to groups 1 and 2 (e.g. 'abcdef1234@@#$%^') -Tokenizer.prototype._appendCharToCurrentCharacterToken = function (type, ch) { - if (this.currentCharacterToken && this.currentCharacterToken.type !== type) - this._emitCurrentCharacterToken(); - - if (this.currentCharacterToken) - this.currentCharacterToken.chars += ch; - - else - this._createCharacterToken(type, ch); -}; - -Tokenizer.prototype._emitCodePoint = function (cp) { - var type = Tokenizer.CHARACTER_TOKEN; - - if (isWhitespace(cp)) - type = Tokenizer.WHITESPACE_CHARACTER_TOKEN; - - else if (cp === $.NULL) - type = Tokenizer.NULL_CHARACTER_TOKEN; - - this._appendCharToCurrentCharacterToken(type, toChar(cp)); -}; - -Tokenizer.prototype._emitSeveralCodePoints = function (codePoints) { - for (var i = 0; i < codePoints.length; i++) - this._emitCodePoint(codePoints[i]); -}; - -//NOTE: used then we emit character explicitly. This is always a non-whitespace and a non-null character. -//So we can avoid additional checks here. -Tokenizer.prototype._emitChar = function (ch) { - this._appendCharToCurrentCharacterToken(Tokenizer.CHARACTER_TOKEN, ch); -}; - -//Character reference tokenization -Tokenizer.prototype._consumeNumericEntity = function (isHex) { - var digits = '', - nextCp = void 0; +// These functions return predicates for filtering elements. +// They're used by the Document and Element classes for methods like +// getElementsByTagName and getElementsByClassName - do { - digits += toChar(this._consume()); - nextCp = this._lookahead(); - } while (nextCp !== $.EOF && isDigit(nextCp, isHex)); - - if (this._lookahead() === $.SEMICOLON) - this._consume(); +function localNameElementFilter(lname) { + return function(e) { return e.localName === lname; }; +} - var referencedCp = parseInt(digits, isHex ? 16 : 10), - replacement = NUMERIC_ENTITY_REPLACEMENTS[referencedCp]; +function htmlLocalNameElementFilter(lname) { + var lclname = utils.toASCIILowerCase(lname); + if (lclname === lname) + return localNameElementFilter(lname); - if (replacement) - return replacement; + return function(e) { + return e.isHTML ? e.localName === lclname : e.localName === lname; + }; +} - if (isReservedCodePoint(referencedCp)) - return $.REPLACEMENT_CHARACTER; +function namespaceElementFilter(ns) { + return function(e) { return e.namespaceURI === ns; }; +} - return referencedCp; -}; +function namespaceLocalNameElementFilter(ns, lname) { + return function(e) { + return e.namespaceURI === ns && e.localName === lname; + }; +} -// NOTE: for the details on this algorithm see -// https://github.com/inikulin/parse5/tree/master/scripts/generate_named_entity_data/README.md -Tokenizer.prototype._consumeNamedEntity = function (inAttr) { - var referencedCodePoints = null, - referenceSize = 0, - cp = null, - consumedCount = 0, - semicolonTerminated = false; - - for (var i = 0; i > -1;) { - var current = neTree[i], - inNode = current < MAX_BRANCH_MARKER_VALUE, - nodeWithData = inNode && current & HAS_DATA_FLAG; - - if (nodeWithData) { - referencedCodePoints = current & DATA_DUPLET_FLAG ? [neTree[++i], neTree[++i]] : [neTree[++i]]; - referenceSize = consumedCount; - - if (cp === $.SEMICOLON) { - semicolonTerminated = true; - break; - } - } +// XXX +// Optimize this when I implement classList. +function classNamesElementFilter(names) { + return function(e) { + var classAttr = e.getAttribute('class'); + if (!classAttr) return false; + var classes = classAttr.trim().split(/\s+/); + return names.every(function(n) { + return classes.indexOf(n) !== -1; + }); + }; +} - cp = this._consume(); - consumedCount++; +function elementNameFilter(name) { + return function(e) { + return e.getAttribute('name') === name; + }; +} - if (cp === $.EOF) - break; - if (inNode) - i = current & HAS_BRANCHES_FLAG ? findNamedEntityTreeBranch(i, cp) : -1; +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { - else - i = cp === current ? ++i : -1; - } +"use strict"; +module.exports = Event; - if (referencedCodePoints) { - if (!semicolonTerminated) { - //NOTE: unconsume excess (e.g. 'it' in '¬it') - this._unconsumeSeveral(consumedCount - referenceSize); +Event.CAPTURING_PHASE = 1; +Event.AT_TARGET = 2; +Event.BUBBLING_PHASE = 3; - //NOTE: If the character reference is being consumed as part of an attribute and the next character - //is either a U+003D EQUALS SIGN character (=) or an alphanumeric ASCII character, then, for historical - //reasons, all the characters that were matched after the U+0026 AMPERSAND character (&) must be - //unconsumed, and nothing is returned. - //However, if this next character is in fact a U+003D EQUALS SIGN character (=), then this is a - //parse error, because some legacy user agents will misinterpret the markup in those cases. - //(see: http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references) - if (inAttr) { - var nextCp = this._lookahead(); +function Event(type, dictionary) { + // Initialize basic event properties + this.type = ''; + this.target = null; + this.currentTarget = null; + this.eventPhase = Event.AT_TARGET; + this.bubbles = false; + this.cancelable = false; + this.isTrusted = false; + this.defaultPrevented = false; + this.timeStamp = Date.now(); - if (nextCp === $.EQUALS_SIGN || isAsciiAlphaNumeric(nextCp)) { - this._unconsumeSeveral(referenceSize); - return null; - } - } - } + // Initialize internal flags + // XXX: Would it be better to inherit these defaults from the prototype? + this._propagationStopped = false; + this._immediatePropagationStopped = false; + this._initialized = true; + this._dispatching = false; - return referencedCodePoints; + // Now initialize based on the constructor arguments (if any) + if (type) this.type = type; + if (dictionary) { + for(var p in dictionary) { + this[p] = dictionary[p]; } + } +} - this._unconsumeSeveral(consumedCount); - - return null; -}; - -Tokenizer.prototype._consumeCharacterReference = function (startCp, inAttr) { - if (isWhitespace(startCp) || startCp === $.GREATER_THAN_SIGN || - startCp === $.AMPERSAND || startCp === this.additionalAllowedCp || startCp === $.EOF) { - //NOTE: not a character reference. No characters are consumed, and nothing is returned. - this._unconsume(); - return null; - } +Event.prototype = Object.create(Object.prototype, { + constructor: { value: Event }, + stopPropagation: { value: function stopPropagation() { + this._propagationStopped = true; + }}, - if (startCp === $.NUMBER_SIGN) { - //NOTE: we have a numeric entity candidate, now we should determine if it's hex or decimal - var isHex = false, - nextCp = this._lookahead(); + stopImmediatePropagation: { value: function stopImmediatePropagation() { + this._propagationStopped = true; + this._immediatePropagationStopped = true; + }}, - if (nextCp === $.LATIN_SMALL_X || nextCp === $.LATIN_CAPITAL_X) { - this._consume(); - isHex = true; - } + preventDefault: { value: function preventDefault() { + if (this.cancelable) this.defaultPrevented = true; + }}, - nextCp = this._lookahead(); + initEvent: { value: function initEvent(type, bubbles, cancelable) { + this._initialized = true; + if (this._dispatching) return; - //NOTE: if we have at least one digit this is a numeric entity for sure, so we consume it - if (nextCp !== $.EOF && isDigit(nextCp, isHex)) - return [this._consumeNumericEntity(isHex)]; + this._propagationStopped = false; + this._immediatePropagationStopped = false; + this.defaultPrevented = false; + this.isTrusted = false; - //NOTE: otherwise this is a bogus number entity and a parse error. Unconsume the number sign - //and the 'x'-character if appropriate. - this._unconsumeSeveral(isHex ? 2 : 1); - return null; - } + this.target = null; + this.type = type; + this.bubbles = bubbles; + this.cancelable = cancelable; + }}, - this._unconsume(); +}); - return this._consumeNamedEntity(inAttr); -}; -//State machine -var _ = Tokenizer.prototype; +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { -//12.2.4.1 Data state -//------------------------------------------------------------------ -_[DATA_STATE] = function dataState(cp) { - this.preprocessor.dropParsedChunk(); +"use strict"; - if (cp === $.AMPERSAND) - this.state = CHARACTER_REFERENCE_IN_DATA_STATE; +module.exports = CharacterData; + +var Leaf = __webpack_require__(34); +var utils = __webpack_require__(1); +var ChildNode = __webpack_require__(16); +var NonDocumentTypeChildNode = __webpack_require__(37); + +function CharacterData() { +} + +CharacterData.prototype = Object.create(Leaf.prototype, { + // DOMString substringData(unsigned long offset, + // unsigned long count); + // The substringData(offset, count) method must run these steps: + // + // If offset is greater than the context object's + // length, throw an INDEX_SIZE_ERR exception and + // terminate these steps. + // + // If offset+count is greater than the context + // object's length, return a DOMString whose value is + // the UTF-16 code units from the offsetth UTF-16 code + // unit to the end of data. + // + // Return a DOMString whose value is the UTF-16 code + // units from the offsetth UTF-16 code unit to the + // offset+countth UTF-16 code unit in data. + substringData: { value: function substringData(offset, count) { + if (offset > this.data.length || offset < 0 || count < 0) + utils.IndexSizeError(); + return this.data.substring(offset, offset+count); + }}, + + // void appendData(DOMString data); + // The appendData(data) method must append data to the context + // object's data. + appendData: { value: function appendData(data) { + this.data = this.data + data; + }}, + + // void insertData(unsigned long offset, DOMString data); + // The insertData(offset, data) method must run these steps: + // + // If offset is greater than the context object's + // length, throw an INDEX_SIZE_ERR exception and + // terminate these steps. + // + // Insert data into the context object's data after + // offset UTF-16 code units. + // + insertData: { value: function insertData(offset, data) { + var curtext = this.data; + if (offset > curtext.length || offset < 0) utils.IndexSizeError(); + var prefix = curtext.substring(0, offset), + suffix = curtext.substring(offset); + this.data = prefix + data + suffix; + }}, + + + // void deleteData(unsigned long offset, unsigned long count); + // The deleteData(offset, count) method must run these steps: + // + // If offset is greater than the context object's + // length, throw an INDEX_SIZE_ERR exception and + // terminate these steps. + // + // If offset+count is greater than the context + // object's length var count be length-offset. + // + // Starting from offset UTF-16 code units remove count + // UTF-16 code units from the context object's data. + deleteData: { value: function deleteData(offset, count) { + var curtext = this.data, len = curtext.length; + + if (offset > len || offset < 0) utils.IndexSizeError(); + + if (offset+count > len) + count = len - offset; + + var prefix = curtext.substring(0, offset), + suffix = curtext.substring(offset+count); + + this.data = prefix + suffix; + }}, + + + // void replaceData(unsigned long offset, unsigned long count, + // DOMString data); + // + // The replaceData(offset, count, data) method must act as + // if the deleteData() method is invoked with offset and + // count as arguments followed by the insertData() method + // with offset and data as arguments and re-throw any + // exceptions these methods might have thrown. + replaceData: { value: function replaceData(offset, count, data) { + var curtext = this.data, len = curtext.length; + + if (offset > len || offset < 0) utils.IndexSizeError(); + + if (offset+count > len) + count = len - offset; + + var prefix = curtext.substring(0, offset), + suffix = curtext.substring(offset+count); + + this.data = prefix + data + suffix; + }}, + + // Utility method that Node.isEqualNode() calls to test Text and + // Comment nodes for equality. It is okay to put it here, since + // Node will have already verified that nodeType is equal + isEqual: { value: function isEqual(n) { + return this._data === n._data; + }}, + + length: { get: function() { return this.data.length; }} - else if (cp === $.LESS_THAN_SIGN) - this.state = TAG_OPEN_STATE; +}); - else if (cp === $.NULL) - this._emitCodePoint(cp); +Object.defineProperties(CharacterData.prototype, ChildNode); +Object.defineProperties(CharacterData.prototype, NonDocumentTypeChildNode); - else if (cp === $.EOF) - this._emitEOFToken(); - else - this._emitCodePoint(cp); -}; +/***/ }), +/* 9 */ +/***/ (function(module, exports, __webpack_require__) { +"use strict"; -//12.2.4.2 Character reference in data state -//------------------------------------------------------------------ -_[CHARACTER_REFERENCE_IN_DATA_STATE] = function characterReferenceInDataState(cp) { - this.additionalAllowedCp = void 0; +module.exports = DOMImplementation; - var referencedCodePoints = this._consumeCharacterReference(cp, false); +var Document = __webpack_require__(17); +var DocumentType = __webpack_require__(18); +var HTMLParser = __webpack_require__(19); +var utils = __webpack_require__(1); +var xml = __webpack_require__(24); - if (!this._ensureHibernation()) { - if (referencedCodePoints) - this._emitSeveralCodePoints(referencedCodePoints); +// Each document must have its own instance of the domimplementation object +// Even though these objects have no state +function DOMImplementation() {} - else - this._emitChar('&'); - this.state = DATA_STATE; - } +// Feature/version pairs that DOMImplementation.hasFeature() returns +// true for. It returns false for anything else. +var supportedFeatures = { + 'xml': { '': true, '1.0': true, '2.0': true }, // DOM Core + 'core': { '': true, '2.0': true }, // DOM Core + 'html': { '': true, '1.0': true, '2.0': true} , // HTML + 'xhtml': { '': true, '1.0': true, '2.0': true} , // HTML }; +DOMImplementation.prototype = { + hasFeature: function hasFeature(feature, version) { + var f = supportedFeatures[(feature || '').toLowerCase()]; + return (f && f[version || '']) || false; + }, -//12.2.4.3 RCDATA state -//------------------------------------------------------------------ -_[RCDATA_STATE] = function rcdataState(cp) { - this.preprocessor.dropParsedChunk(); + createDocumentType: function createDocumentType(qualifiedName, publicId, systemId) { + if (!xml.isValidName(qualifiedName)) utils.InvalidCharacterError(); + if (!xml.isValidQName(qualifiedName)) utils.NamespaceError(); - if (cp === $.AMPERSAND) - this.state = CHARACTER_REFERENCE_IN_RCDATA_STATE; + return new DocumentType(qualifiedName, publicId, systemId); + }, - else if (cp === $.LESS_THAN_SIGN) - this.state = RCDATA_LESS_THAN_SIGN_STATE; - - else if (cp === $.NULL) - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); - - else if (cp === $.EOF) - this._emitEOFToken(); + createDocument: function createDocument(namespace, qualifiedName, doctype) { + // + // Note that the current DOMCore spec makes it impossible to + // create an HTML document with this function, even if the + // namespace and doctype are propertly set. See this thread: + // http://lists.w3.org/Archives/Public/www-dom/2011AprJun/0132.html + // + var d = new Document(false, null); + var e; + if (qualifiedName) + e = d.createElementNS(namespace, qualifiedName); else - this._emitCodePoint(cp); -}; - - -//12.2.4.4 Character reference in RCDATA state -//------------------------------------------------------------------ -_[CHARACTER_REFERENCE_IN_RCDATA_STATE] = function characterReferenceInRcdataState(cp) { - this.additionalAllowedCp = void 0; - - var referencedCodePoints = this._consumeCharacterReference(cp, false); - - if (!this._ensureHibernation()) { - if (referencedCodePoints) - this._emitSeveralCodePoints(referencedCodePoints); - - else - this._emitChar('&'); + e = null; - this.state = RCDATA_STATE; + if (doctype) { + if (doctype.ownerDocument) utils.WrongDocumentError(); + d.appendChild(doctype); } -}; - - -//12.2.4.5 RAWTEXT state -//------------------------------------------------------------------ -_[RAWTEXT_STATE] = function rawtextState(cp) { - this.preprocessor.dropParsedChunk(); - - if (cp === $.LESS_THAN_SIGN) - this.state = RAWTEXT_LESS_THAN_SIGN_STATE; - - else if (cp === $.NULL) - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); - - else if (cp === $.EOF) - this._emitEOFToken(); - - else - this._emitCodePoint(cp); -}; - - -//12.2.4.6 Script data state -//------------------------------------------------------------------ -_[SCRIPT_DATA_STATE] = function scriptDataState(cp) { - this.preprocessor.dropParsedChunk(); - - if (cp === $.LESS_THAN_SIGN) - this.state = SCRIPT_DATA_LESS_THAN_SIGN_STATE; - - else if (cp === $.NULL) - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); - - else if (cp === $.EOF) - this._emitEOFToken(); - - else - this._emitCodePoint(cp); -}; - - -//12.2.4.7 PLAINTEXT state -//------------------------------------------------------------------ -_[PLAINTEXT_STATE] = function plaintextState(cp) { - this.preprocessor.dropParsedChunk(); - - if (cp === $.NULL) - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); - - else if (cp === $.EOF) - this._emitEOFToken(); - - else - this._emitCodePoint(cp); -}; + if (e) d.appendChild(e); -//12.2.4.8 Tag open state -//------------------------------------------------------------------ -_[TAG_OPEN_STATE] = function tagOpenState(cp) { - if (cp === $.EXCLAMATION_MARK) - this.state = MARKUP_DECLARATION_OPEN_STATE; + return d; + }, - else if (cp === $.SOLIDUS) - this.state = END_TAG_OPEN_STATE; + createHTMLDocument: function createHTMLDocument(titleText) { + var d = new Document(true, null); + d.appendChild(new DocumentType('html')); + var html = d.createElement('html'); + d.appendChild(html); + var head = d.createElement('head'); + html.appendChild(head); + var title = d.createElement('title'); + head.appendChild(title); + title.appendChild(d.createTextNode(titleText)); + html.appendChild(d.createElement('body')); + d.modclock = 1; // Start tracking modifications + return d; + }, - else if (isAsciiLetter(cp)) { - this._createStartTagToken(); - this._reconsumeInState(TAG_NAME_STATE); - } + mozSetOutputMutationHandler: function(doc, handler) { + doc.mutationHandler = handler; + }, - else if (cp === $.QUESTION_MARK) - this._reconsumeInState(BOGUS_COMMENT_STATE); + mozGetInputMutationHandler: function(doc) { + utils.nyi(); + }, - else { - this._emitChar('<'); - this._reconsumeInState(DATA_STATE); - } + mozHTMLParser: HTMLParser, }; -//12.2.4.9 End tag open state -//------------------------------------------------------------------ -_[END_TAG_OPEN_STATE] = function endTagOpenState(cp) { - if (isAsciiLetter(cp)) { - this._createEndTagToken(); - this._reconsumeInState(TAG_NAME_STATE); - } +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { - else if (cp === $.GREATER_THAN_SIGN) - this.state = DATA_STATE; +"use strict"; - else if (cp === $.EOF) { - this._reconsumeInState(DATA_STATE); - this._emitChar('<'); - this._emitChar('/'); - } +var NodeFilter = { + // Constants for acceptNode() + FILTER_ACCEPT: 1, + FILTER_REJECT: 2, + FILTER_SKIP: 3, - else - this._reconsumeInState(BOGUS_COMMENT_STATE); + // Constants for whatToShow + SHOW_ALL: 0xFFFFFFFF, + SHOW_ELEMENT: 0x1, + SHOW_ATTRIBUTE: 0x2, // historical + SHOW_TEXT: 0x4, + SHOW_CDATA_SECTION: 0x8, // historical + SHOW_ENTITY_REFERENCE: 0x10, // historical + SHOW_ENTITY: 0x20, // historical + SHOW_PROCESSING_INSTRUCTION: 0x40, + SHOW_COMMENT: 0x80, + SHOW_DOCUMENT: 0x100, + SHOW_DOCUMENT_TYPE: 0x200, + SHOW_DOCUMENT_FRAGMENT: 0x400, + SHOW_NOTATION: 0x800 // historical }; +module.exports = (NodeFilter.constructor = NodeFilter.prototype = NodeFilter); -//12.2.4.10 Tag name state -//------------------------------------------------------------------ -_[TAG_NAME_STATE] = function tagNameState(cp) { - if (isWhitespace(cp)) - this.state = BEFORE_ATTRIBUTE_NAME_STATE; - - else if (cp === $.SOLIDUS) - this.state = SELF_CLOSING_START_TAG_STATE; - else if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); - } - - else if (isAsciiUpper(cp)) - this.currentToken.tagName += toAsciiLowerChar(cp); - - else if (cp === $.NULL) - this.currentToken.tagName += UNICODE.REPLACEMENT_CHARACTER; +/***/ }), +/* 11 */ +/***/ (function(module, exports, __webpack_require__) { - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); +"use strict"; - else - this.currentToken.tagName += toChar(cp); -}; +module.exports = NodeList; +function item(i) { + /* jshint validthis: true */ + return this[i]; +} -//12.2.4.11 RCDATA less-than sign state -//------------------------------------------------------------------ -_[RCDATA_LESS_THAN_SIGN_STATE] = function rcdataLessThanSignState(cp) { - if (cp === $.SOLIDUS) { - this.tempBuff = []; - this.state = RCDATA_END_TAG_OPEN_STATE; - } +function NodeList(a) { + if (!a) a = []; + a.item = item; + return a; +} - else { - this._emitChar('<'); - this._reconsumeInState(RCDATA_STATE); - } -}; +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { -//12.2.4.12 RCDATA end tag open state -//------------------------------------------------------------------ -_[RCDATA_END_TAG_OPEN_STATE] = function rcdataEndTagOpenState(cp) { - if (isAsciiLetter(cp)) { - this._createEndTagToken(); - this._reconsumeInState(RCDATA_END_TAG_NAME_STATE); - } +"use strict"; - else { - this._emitChar('<'); - this._emitChar('/'); - this._reconsumeInState(RCDATA_STATE); - } -}; +var AsyncAction_1 = __webpack_require__(115); +var AsyncScheduler_1 = __webpack_require__(116); +/** + * + * Async Scheduler + * + * Schedule task as if you used setTimeout(task, duration) + * + * `async` scheduler schedules tasks asynchronously, by putting them on the JavaScript + * event loop queue. It is best used to delay tasks in time or to schedule tasks repeating + * in intervals. + * + * If you just want to "defer" task, that is to perform it right after currently + * executing synchronous code ends (commonly achieved by `setTimeout(deferredTask, 0)`), + * better choice will be the {@link asap} scheduler. + * + * @example Use async scheduler to delay task + * const task = () => console.log('it works!'); + * + * Rx.Scheduler.async.schedule(task, 2000); + * + * // After 2 seconds logs: + * // "it works!" + * + * + * @example Use async scheduler to repeat task in intervals + * function task(state) { + * console.log(state); + * this.schedule(state + 1, 1000); // `this` references currently executing Action, + * // which we reschedule with new state and delay + * } + * + * Rx.Scheduler.async.schedule(task, 3000, 0); + * + * // Logs: + * // 0 after 3s + * // 1 after 4s + * // 2 after 5s + * // 3 after 6s + * + * @static true + * @name async + * @owner Scheduler + */ +exports.async = new AsyncScheduler_1.AsyncScheduler(AsyncAction_1.AsyncAction); +//# sourceMappingURL=async.js.map +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { -//12.2.4.13 RCDATA end tag name state -//------------------------------------------------------------------ -_[RCDATA_END_TAG_NAME_STATE] = function rcdataEndTagNameState(cp) { - if (isAsciiUpper(cp)) { - this.currentToken.tagName += toAsciiLowerChar(cp); - this.tempBuff.push(cp); - } +module.exports = (__webpack_require__(0))(43); - else if (isAsciiLower(cp)) { - this.currentToken.tagName += toChar(cp); - this.tempBuff.push(cp); - } +/***/ }), +/* 14 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { - else { - if (this._isAppropriateEndTagToken()) { - if (isWhitespace(cp)) { - this.state = BEFORE_ATTRIBUTE_NAME_STATE; - return; - } +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AuthService; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__angular_core__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_common_http__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_common_http___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__angular_common_http__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; + + + +var AuthService = (function () { + function AuthService(oidcSecurityService, http, originUrl, identityUrl) { + var _this = this; + this.oidcSecurityService = oidcSecurityService; + this.http = http; + var openIdImplicitFlowConfiguration = new __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OpenIDImplicitFlowConfiguration"](); + openIdImplicitFlowConfiguration.stsServer = identityUrl; + openIdImplicitFlowConfiguration.redirect_url = originUrl + 'callback'; + openIdImplicitFlowConfiguration.client_id = 'ng'; + openIdImplicitFlowConfiguration.response_type = 'id_token token'; + openIdImplicitFlowConfiguration.scope = 'openid profile apiApp'; + openIdImplicitFlowConfiguration.post_logout_redirect_uri = originUrl + 'home'; + openIdImplicitFlowConfiguration.forbidden_route = '/forbidden'; + openIdImplicitFlowConfiguration.unauthorized_route = '/unauthorized'; + openIdImplicitFlowConfiguration.auto_userinfo = true; + openIdImplicitFlowConfiguration.log_console_warning_active = true; + openIdImplicitFlowConfiguration.log_console_debug_active = false; + openIdImplicitFlowConfiguration.max_id_token_iat_offset_allowed_in_seconds = 10; + this.oidcSecurityService.setupModule(openIdImplicitFlowConfiguration); + if (this.oidcSecurityService.moduleSetup) { + this.doCallbackLogicIfRequired(); + } + else { + this.oidcSecurityService.onModuleSetup.subscribe(function () { + _this.doCallbackLogicIfRequired(); + }); + } + } + AuthService.prototype.ngOnInit = function () { + var _this = this; + this.isAuthorizedSubscription = this.oidcSecurityService.getIsAuthorized().subscribe(function (isAuthorized) { + _this.isAuthorized = isAuthorized; + }); + }; + AuthService.prototype.ngOnDestroy = function () { + this.isAuthorizedSubscription.unsubscribe(); + this.oidcSecurityService.onModuleSetup.unsubscribe(); + }; + AuthService.prototype.getIsAuthorized = function () { + return this.oidcSecurityService.getIsAuthorized(); + }; + AuthService.prototype.login = function () { + console.log('start login'); + this.oidcSecurityService.authorize(); + }; + AuthService.prototype.refreshSession = function () { + console.log('start refreshSession'); + this.oidcSecurityService.authorize(); + }; + AuthService.prototype.logout = function () { + console.log('start logoff'); + this.oidcSecurityService.logoff(); + }; + AuthService.prototype.doCallbackLogicIfRequired = function () { + if (typeof location !== "undefined" && window.location.hash) { + this.oidcSecurityService.authorizedCallback(); + } + }; + AuthService.prototype.get = function (url) { + return this.http.get(url, { headers: this.getHeaders() }); + }; + AuthService.prototype.put = function (url, data) { + var body = JSON.stringify(data); + return this.http.put(url, body, { headers: this.getHeaders() }); + }; + AuthService.prototype.delete = function (url) { + return this.http.delete(url, { headers: this.getHeaders() }); + }; + AuthService.prototype.post = function (url, data) { + var body = JSON.stringify(data); + return this.http.post(url, body, { headers: this.getHeaders() }); + }; + AuthService.prototype.getHeaders = function () { + var headers = new __WEBPACK_IMPORTED_MODULE_1__angular_common_http__["HttpHeaders"](); + headers = headers.set('Content-Type', 'application/json'); + return this.appendAuthHeader(headers); + }; + AuthService.prototype.appendAuthHeader = function (headers) { + var token = this.oidcSecurityService.getToken(); + if (token === '') + return headers; + var tokenValue = 'Bearer ' + token; + return headers.set('Authorization', tokenValue); + }; + AuthService = __decorate([ + __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Injectable"])(), + __param(2, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Inject"])('ORIGIN_URL')), + __param(3, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Inject"])('IDENTITY_URL')), + __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OidcSecurityService"], + __WEBPACK_IMPORTED_MODULE_1__angular_common_http__["HttpClient"], String, String]) + ], AuthService); + return AuthService; +}()); + - if (cp === $.SOLIDUS) { - this.state = SELF_CLOSING_START_TAG_STATE; - return; - } - if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); - return; - } - } +/***/ }), +/* 15 */ +/***/ (function(module, exports, __webpack_require__) { - this._emitChar('<'); - this._emitChar('/'); - this._emitSeveralCodePoints(this.tempBuff); - this._reconsumeInState(RCDATA_STATE); - } -}; +"use strict"; +var parserlib = __webpack_require__(81); -//12.2.4.14 RAWTEXT less-than sign state -//------------------------------------------------------------------ -_[RAWTEXT_LESS_THAN_SIGN_STATE] = function rawtextLessThanSignState(cp) { - if (cp === $.SOLIDUS) { - this.tempBuff = []; - this.state = RAWTEXT_END_TAG_OPEN_STATE; - } +module.exports = CSSStyleDeclaration; - else { - this._emitChar('<'); - this._reconsumeInState(RAWTEXT_STATE); - } -}; +function CSSStyleDeclaration(elt) { + this._element = elt; +} +// Utility function for parsing style declarations +// Pass in a string like "margin-left: 5px; border-style: solid" +// and this function returns an object like +// {"margin-left":"5px", "border-style":"solid"} +function parseStyles(s) { + var parser = new parserlib.css.Parser(); + var result = { property: Object.create(null), priority: Object.create(null) }; + parser.addListener("property", function(e) { + if (e.invalid) return; // Skip errors + result.property[e.property.text] = e.value.text; + if (e.important) result.priority[e.property.text] = 'important'; + }); + s = (''+s).replace(/^;/, ''); + parser.parseStyleAttribute(s); + return result; +} -//12.2.4.15 RAWTEXT end tag open state -//------------------------------------------------------------------ -_[RAWTEXT_END_TAG_OPEN_STATE] = function rawtextEndTagOpenState(cp) { - if (isAsciiLetter(cp)) { - this._createEndTagToken(); - this._reconsumeInState(RAWTEXT_END_TAG_NAME_STATE); - } +var NO_CHANGE = {}; // Private marker object - else { - this._emitChar('<'); - this._emitChar('/'); - this._reconsumeInState(RAWTEXT_STATE); +CSSStyleDeclaration.prototype = Object.create(Object.prototype, { + + // Return the parsed form of the element's style attribute. + // If the element's style attribute has never been parsed + // or if it has changed since the last parse, then reparse it + // Note that the styles don't get parsed until they're actually needed + _parsed: { get: function() { + if (!this._parsedStyles || this.cssText !== this._lastParsedText) { + var text = this.cssText; + this._parsedStyles = parseStyles(text); + this._lastParsedText = text; + delete this._names; } -}; + return this._parsedStyles; + }}, + // Call this method any time the parsed representation of the + // style changes. It converts the style properties to a string and + // sets cssText and the element's style attribute + _serialize: { value: function() { + var styles = this._parsed; + var s = ""; -//12.2.4.16 RAWTEXT end tag name state -//------------------------------------------------------------------ -_[RAWTEXT_END_TAG_NAME_STATE] = function rawtextEndTagNameState(cp) { - if (isAsciiUpper(cp)) { - this.currentToken.tagName += toAsciiLowerChar(cp); - this.tempBuff.push(cp); + for(var name in styles.property) { + if (s) s += " "; + s += name + ": " + styles.property[name]; + if (styles.priority[name]) { + s += " !" + styles.priority[name]; + } + s += ";"; } - else if (isAsciiLower(cp)) { - this.currentToken.tagName += toChar(cp); - this.tempBuff.push(cp); - } + this.cssText = s; // also sets the style attribute + this._lastParsedText = s; // so we don't reparse + delete this._names; + }}, - else { - if (this._isAppropriateEndTagToken()) { - if (isWhitespace(cp)) { - this.state = BEFORE_ATTRIBUTE_NAME_STATE; - return; - } + cssText: { + get: function() { + // XXX: this is a CSSStyleDeclaration for an element. + // A different impl might be necessary for a set of styles + // associated returned by getComputedStyle(), e.g. + return this._element.getAttribute("style"); + }, + set: function(value) { + // XXX: I should parse and serialize the value to + // normalize it and remove errors. FF and chrome do that. + this._element.setAttribute("style", value); + } + }, - if (cp === $.SOLIDUS) { - this.state = SELF_CLOSING_START_TAG_STATE; - return; - } + length: { get: function() { + if (!this._names) + this._names = Object.getOwnPropertyNames(this._parsed.property); + return this._names.length; + }}, - if (cp === $.GREATER_THAN_SIGN) { - this._emitCurrentToken(); - this.state = DATA_STATE; - return; - } - } + item: { value: function(n) { + if (!this._names) + this._names = Object.getOwnPropertyNames(this._parsed.property); + return this._names[n]; + }}, - this._emitChar('<'); - this._emitChar('/'); - this._emitSeveralCodePoints(this.tempBuff); - this._reconsumeInState(RAWTEXT_STATE); - } -}; + getPropertyValue: { value: function(property) { + property = property.toLowerCase(); + return this._parsed.property[property] || ""; + }}, + getPropertyPriority: { value: function(property) { + property = property.toLowerCase(); + return this._parsed.priority[property] || ""; + }}, -//12.2.4.17 Script data less-than sign state -//------------------------------------------------------------------ -_[SCRIPT_DATA_LESS_THAN_SIGN_STATE] = function scriptDataLessThanSignState(cp) { - if (cp === $.SOLIDUS) { - this.tempBuff = []; - this.state = SCRIPT_DATA_END_TAG_OPEN_STATE; + setProperty: { value: function(property, value, priority) { + property = property.toLowerCase(); + if (value === null || value === undefined) { + value = ""; } - - else if (cp === $.EXCLAMATION_MARK) { - this.state = SCRIPT_DATA_ESCAPE_START_STATE; - this._emitChar('<'); - this._emitChar('!'); + if (priority === null || priority === undefined) { + priority = ""; } - else { - this._emitChar('<'); - this._reconsumeInState(SCRIPT_DATA_STATE); + // String coercion + if (value !== NO_CHANGE) { + value = "" + value; } -}; - -//12.2.4.18 Script data end tag open state -//------------------------------------------------------------------ -_[SCRIPT_DATA_END_TAG_OPEN_STATE] = function scriptDataEndTagOpenState(cp) { - if (isAsciiLetter(cp)) { - this._createEndTagToken(); - this._reconsumeInState(SCRIPT_DATA_END_TAG_NAME_STATE); + if (value === "") { + this.removeProperty(property); + return; } - else { - this._emitChar('<'); - this._emitChar('/'); - this._reconsumeInState(SCRIPT_DATA_STATE); + if (priority !== "" && priority !== NO_CHANGE && + !/^important$/i.test(priority)) { + return; } -}; + var styles = this._parsed; + if (value === NO_CHANGE) { + if (!styles.property[property]) { + return; // Not a valid property name. + } + if (priority !== "") { + styles.priority[property] = "important"; + } else { + delete styles.priority[property]; + } + } else { + // We don't just accept the property value. Instead + // we parse it to ensure that it is something valid. + // If it contains a semicolon it is invalid + if (value.indexOf(";") !== -1) return; + + var newprops = parseStyles(property + ":" + value); + if (Object.getOwnPropertyNames(newprops.property).length === 0) { + return; // no valid property found + } + if (Object.getOwnPropertyNames(newprops.priority).length !== 0) { + return; // if the value included '!important' it wasn't valid. + } -//12.2.4.19 Script data end tag name state -//------------------------------------------------------------------ -_[SCRIPT_DATA_END_TAG_NAME_STATE] = function scriptDataEndTagNameState(cp) { - if (isAsciiUpper(cp)) { - this.currentToken.tagName += toAsciiLowerChar(cp); - this.tempBuff.push(cp); - } + // XXX handle shorthand properties - else if (isAsciiLower(cp)) { - this.currentToken.tagName += toChar(cp); - this.tempBuff.push(cp); + for (var p in newprops.property) { + styles.property[p] = newprops.property[p]; + if (priority === NO_CHANGE) { + continue; + } else if (priority !== "") { + styles.priority[p] = "important"; + } else if (styles.priority[p]) { + delete styles.priority[p]; + } + } } - else { - if (this._isAppropriateEndTagToken()) { - if (isWhitespace(cp)) { - this.state = BEFORE_ATTRIBUTE_NAME_STATE; - return; - } + // Serialize and update cssText and element.style! + this._serialize(); + }}, - else if (cp === $.SOLIDUS) { - this.state = SELF_CLOSING_START_TAG_STATE; - return; - } + setPropertyValue: { value: function(property, value) { + return this.setProperty(property, value, NO_CHANGE); + }}, - else if (cp === $.GREATER_THAN_SIGN) { - this._emitCurrentToken(); - this.state = DATA_STATE; - return; - } - } + setPropertyPriority: { value: function(property, priority) { + return this.setProperty(property, NO_CHANGE, priority); + }}, - this._emitChar('<'); - this._emitChar('/'); - this._emitSeveralCodePoints(this.tempBuff); - this._reconsumeInState(SCRIPT_DATA_STATE); - } -}; + removeProperty: { value: function(property) { + property = property.toLowerCase(); + var styles = this._parsed; + if (property in styles.property) { + delete styles.property[property]; + delete styles.priority[property]; + // Serialize and update cssText and element.style! + this._serialize(); + } + }}, +}); -//12.2.4.20 Script data escape start state -//------------------------------------------------------------------ -_[SCRIPT_DATA_ESCAPE_START_STATE] = function scriptDataEscapeStartState(cp) { - if (cp === $.HYPHEN_MINUS) { - this.state = SCRIPT_DATA_ESCAPE_START_DASH_STATE; - this._emitChar('-'); +var cssProperties = { + background: "background", + backgroundAttachment: "background-attachment", + backgroundColor: "background-color", + backgroundImage: "background-image", + backgroundPosition: "background-position", + backgroundRepeat: "background-repeat", + border: "border", + borderCollapse: "border-collapse", + borderColor: "border-color", + borderSpacing: "border-spacing", + borderStyle: "border-style", + borderTop: "border-top", + borderRight: "border-right", + borderBottom: "border-bottom", + borderLeft: "border-left", + borderTopColor: "border-top-color", + borderRightColor: "border-right-color", + borderBottomColor: "border-bottom-color", + borderLeftColor: "border-left-color", + borderTopStyle: "border-top-style", + borderRightStyle: "border-right-style", + borderBottomStyle: "border-bottom-style", + borderLeftStyle: "border-left-style", + borderTopWidth: "border-top-width", + borderRightWidth: "border-right-width", + borderBottomWidth: "border-bottom-width", + borderLeftWidth: "border-left-width", + borderWidth: "border-width", + bottom: "bottom", + captionSide: "caption-side", + clear: "clear", + clip: "clip", + color: "color", + content: "content", + counterIncrement: "counter-increment", + counterReset: "counter-reset", + cursor: "cursor", + direction: "direction", + display: "display", + emptyCells: "empty-cells", + cssFloat: "float", + font: "font", + fontFamily: "font-family", + fontSize: "font-size", + fontSizeAdjust: "font-size-adjust", + fontStretch: "font-stretch", + fontStyle: "font-style", + fontVariant: "font-variant", + fontWeight: "font-weight", + height: "height", + left: "left", + letterSpacing: "letter-spacing", + lineHeight: "line-height", + listStyle: "list-style", + listStyleImage: "list-style-image", + listStylePosition: "list-style-position", + listStyleType: "list-style-type", + margin: "margin", + marginTop: "margin-top", + marginRight: "margin-right", + marginBottom: "margin-bottom", + marginLeft: "margin-left", + markerOffset: "marker-offset", + marks: "marks", + maxHeight: "max-height", + maxWidth: "max-width", + minHeight: "min-height", + minWidth: "min-width", + opacity: "opacity", + orphans: "orphans", + outline: "outline", + outlineColor: "outline-color", + outlineStyle: "outline-style", + outlineWidth: "outline-width", + overflow: "overflow", + padding: "padding", + paddingTop: "padding-top", + paddingRight: "padding-right", + paddingBottom: "padding-bottom", + paddingLeft: "padding-left", + page: "page", + pageBreakAfter: "page-break-after", + pageBreakBefore: "page-break-before", + pageBreakInside: "page-break-inside", + position: "position", + quotes: "quotes", + right: "right", + size: "size", + tableLayout: "table-layout", + textAlign: "text-align", + textDecoration: "text-decoration", + textIndent: "text-indent", + textShadow: "text-shadow", + textTransform: "text-transform", + top: "top", + unicodeBidi: "unicode-bidi", + verticalAlign: "vertical-align", + visibility: "visibility", + whiteSpace: "white-space", + widows: "widows", + width: "width", + wordSpacing: "word-spacing", + zIndex: "z-index", +}; + +for(var prop in cssProperties) defineStyleProperty(prop); + +function defineStyleProperty(jsname) { + var cssname = cssProperties[jsname]; + Object.defineProperty(CSSStyleDeclaration.prototype, jsname, { + get: function() { + return this.getPropertyValue(cssname); + }, + set: function(value) { + this.setProperty(cssname, value); } + }); +} - else - this._reconsumeInState(SCRIPT_DATA_STATE); -}; +/***/ }), +/* 16 */ +/***/ (function(module, exports, __webpack_require__) { -//12.2.4.21 Script data escape start dash state -//------------------------------------------------------------------ -_[SCRIPT_DATA_ESCAPE_START_DASH_STATE] = function scriptDataEscapeStartDashState(cp) { - if (cp === $.HYPHEN_MINUS) { - this.state = SCRIPT_DATA_ESCAPED_DASH_DASH_STATE; - this._emitChar('-'); - } +"use strict"; - else - this._reconsumeInState(SCRIPT_DATA_STATE); -}; +var Node = __webpack_require__(3); -//12.2.4.22 Script data escaped state -//------------------------------------------------------------------ -_[SCRIPT_DATA_ESCAPED_STATE] = function scriptDataEscapedState(cp) { - if (cp === $.HYPHEN_MINUS) { - this.state = SCRIPT_DATA_ESCAPED_DASH_STATE; - this._emitChar('-'); - } +var createDocumentFragmentFromArguments = function(document, args) { + var docFrag = document.createDocumentFragment(); - else if (cp === $.LESS_THAN_SIGN) - this.state = SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE; + for (var i=0; i'); - } +"use strict"; - else if (cp === $.NULL) { - this.state = SCRIPT_DATA_ESCAPED_STATE; - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); +module.exports = Document; + +var Node = __webpack_require__(3); +var NodeList = __webpack_require__(11); +var Element = __webpack_require__(6); +var Text = __webpack_require__(39); +var Comment = __webpack_require__(29); +var Event = __webpack_require__(7); +var DocumentFragment = __webpack_require__(32); +var ProcessingInstruction = __webpack_require__(38); +var DOMImplementation = __webpack_require__(9); +var TreeWalker = __webpack_require__(79); +var NodeIterator = __webpack_require__(78); +var NodeFilter = __webpack_require__(10); +var URL = __webpack_require__(20); +var select = __webpack_require__(23); +var events = __webpack_require__(45); +var xml = __webpack_require__(24); +var html = __webpack_require__(22); +var svg = __webpack_require__(48); +var utils = __webpack_require__(1); +var MUTATE = __webpack_require__(76); +var NAMESPACE = utils.NAMESPACE; +var isApiWritable = __webpack_require__(43).isApiWritable; + +function Document(isHTML, address) { + this.nodeType = Node.DOCUMENT_NODE; + this.isHTML = isHTML; + this._address = address || 'about:blank'; + this.readyState = 'loading'; + this.implementation = new DOMImplementation(); + + // DOMCore says that documents are always associated with themselves + this.ownerDocument = null; // ... but W3C tests expect null + + // These will be initialized by our custom versions of + // appendChild and insertBefore that override the inherited + // Node methods. + // XXX: override those methods! + this.doctype = null; + this.documentElement = null; + this.childNodes = new NodeList(); + + // "Associated inert template document" + this._templateDocCache = null; + + // Documents are always rooted, by definition + this._nid = 1; + this._nextnid = 2; // For numbering children of the document + this._nodes = [null, this]; // nid to node map + + // This maintains the mapping from element ids to element nodes. + // We may need to update this mapping every time a node is rooted + // or uprooted, and any time an attribute is added, removed or changed + // on a rooted element. + this.byId = Object.create(null); + + // This property holds a monotonically increasing value akin to + // a timestamp used to record the last modification time of nodes + // and their subtrees. See the lastModTime attribute and modify() + // method of the Node class. And see FilteredElementList for an example + // of the use of lastModTime + this.modclock = 0; +} + +// Map from lowercase event category names (used as arguments to +// createEvent()) to the property name in the impl object of the +// event constructor. +var supportedEvents = { + event: 'Event', + customevent: 'CustomEvent', + uievent: 'UIEvent', + mouseevent: 'MouseEvent' +}; + +// Certain arguments to document.createEvent() must be treated specially +var replacementEvent = { + events: 'event', + htmlevents: 'event', + mouseevents: 'mouseevent', + mutationevents: 'mutationevent', + uievents: 'uievent' +}; + +var mirrorAttr = function(f, name, defaultValue) { + return { + get: function() { + var o = f.call(this); + if (o) { return o[name]; } + return defaultValue; + }, + set: function(value) { + var o = f.call(this); + if (o) { o[name] = value; } + }, + }; +}; + +Document.prototype = Object.create(Node.prototype, { + // This method allows dom.js to communicate with a renderer + // that displays the document in some way + // XXX: I should probably move this to the window object + _setMutationHandler: { value: function(handler) { + this.mutationHandler = handler; + }}, + + // This method allows dom.js to receive event notifications + // from the renderer. + // XXX: I should probably move this to the window object + _dispatchRendererEvent: { value: function(targetNid, type, details) { + var target = this._nodes[targetNid]; + if (!target) return; + target._dispatchEvent(new Event(type, details), true); + }}, + + nodeName: { value: '#document'}, + nodeValue: { + get: function() { + return null; + }, + set: function() {} + }, + + // XXX: DOMCore may remove documentURI, so it is NYI for now + documentURI: { get: utils.nyi, set: utils.nyi }, + compatMode: { get: function() { + // The _quirks property is set by the HTML parser + return this._quirks ? 'BackCompat' : 'CSS1Compat'; + }}, + parentNode: { value: null }, + + createTextNode: { value: function(data) { + return new Text(this, '' + data); + }}, + createComment: { value: function(data) { + return new Comment(this, data); + }}, + createDocumentFragment: { value: function() { + return new DocumentFragment(this); + }}, + createProcessingInstruction: { value: function(target, data) { + if (!xml.isValidName(target) || data.indexOf('?>') !== -1) + utils.InvalidCharacterError(); + return new ProcessingInstruction(this, target, data); + }}, + + createElement: { value: function(localName) { + if (!xml.isValidName(localName)) utils.InvalidCharacterError(); + if (this.isHTML) localName = utils.toASCIILowerCase(localName); + return html.createElement(this, localName, null); + }, writable: isApiWritable }, + + createElementNS: { value: function(namespace, qualifiedName) { + if (!xml.isValidName(qualifiedName)) utils.InvalidCharacterError(); + if (!xml.isValidQName(qualifiedName)) utils.NamespaceError(); + + var pos, prefix, localName; + if ((pos = qualifiedName.indexOf(':')) !== -1) { + prefix = qualifiedName.substring(0, pos); + localName = qualifiedName.substring(pos+1); + + if (namespace === '' || + (prefix === 'xml' && namespace !== NAMESPACE.XML)) + utils.NamespaceError(); } - - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); - else { - this.state = SCRIPT_DATA_ESCAPED_STATE; - this._emitCodePoint(cp); + prefix = null; + localName = qualifiedName; } -}; + if (((qualifiedName === 'xmlns' || prefix === 'xmlns') && + namespace !== NAMESPACE.XMLNS) || + (namespace === NAMESPACE.XMLNS && + qualifiedName !== 'xmlns' && + prefix !== 'xmlns')) + utils.NamespaceError(); -//12.2.4.25 Script data escaped less-than sign state -//------------------------------------------------------------------ -_[SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN_STATE] = function scriptDataEscapedLessThanSignState(cp) { - if (cp === $.SOLIDUS) { - this.tempBuff = []; - this.state = SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE; + if (namespace === NAMESPACE.HTML) { + return html.createElement(this, localName, prefix); } - - else if (isAsciiLetter(cp)) { - this.tempBuff = []; - this._emitChar('<'); - this._reconsumeInState(SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE); + else if (namespace === NAMESPACE.SVG) { + return svg.createElement(this, localName, prefix); } - else { - this._emitChar('<'); - this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE); - } -}; + return new Element(this, localName, namespace, prefix); + }, writable: isApiWritable }, + createEvent: { value: function createEvent(interfaceName) { + interfaceName = interfaceName.toLowerCase(); + var name = replacementEvent[interfaceName] || interfaceName; + var constructor = events[supportedEvents[name]]; -//12.2.4.26 Script data escaped end tag open state -//------------------------------------------------------------------ -_[SCRIPT_DATA_ESCAPED_END_TAG_OPEN_STATE] = function scriptDataEscapedEndTagOpenState(cp) { - if (isAsciiLetter(cp)) { - this._createEndTagToken(); - this._reconsumeInState(SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE); + if (constructor) { + var e = new constructor(); + e._initialized = false; + return e; } - else { - this._emitChar('<'); - this._emitChar('/'); - this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE); + utils.NotSupportedError(); + } + }}, + + // See: http://www.w3.org/TR/dom/#dom-document-createtreewalker + createTreeWalker: {value: function (root, whatToShow, filter) { + whatToShow = whatToShow === undefined ? NodeFilter.SHOW_ALL : whatToShow; + + if (filter && typeof filter === 'object' && + typeof filter.acceptNode === 'function') { + filter = filter.acceptNode.bind(filter); + // Support filter being a function + // https://developer.mozilla.org/en-US/docs/DOM/document.createTreeWalker + } + else if (typeof filter !== 'function') { + filter = null; + } + return new TreeWalker(root, whatToShow, filter); + }}, + + // See: http://www.w3.org/TR/dom/#dom-document-createnodeiterator + createNodeIterator: {value: function (root, whatToShow, filter) { + whatToShow = whatToShow === undefined ? NodeFilter.SHOW_ALL : whatToShow; + + if (filter && typeof filter === 'object' && + typeof filter.acceptNode === 'function') { + filter = filter.acceptNode.bind(filter); + // Support filter being a function + // https://developer.mozilla.org/en-US/docs/DOM/document.createNodeIterator + } + else if (typeof filter !== 'function') { + filter = null; + } + return new NodeIterator(root, whatToShow, filter); + }}, + + // Maintain the documentElement and + // doctype properties of the document. Each of the following + // methods chains to the Node implementation of the method + // to do the actual inserting, removal or replacement. + + _updateDocTypeElement: { value: function _updateDocTypeElement() { + var i, n, nodes = this.childNodes, length = nodes.length; + this.doctype = this.documentElement = null; + for (i=0; i child of the document element. + // XXX For now, setting this attribute is not implemented. + body: { + get: function() { + return namedHTMLChild(this.documentElement, 'body'); + }, + set: utils.nyi + }, + // Return the first child of the document element. + head: { get: function() { + return namedHTMLChild(this.documentElement, 'head'); + }}, + images: { get: utils.nyi }, + embeds: { get: utils.nyi }, + plugins: { get: utils.nyi }, + links: { get: utils.nyi }, + forms: { get: utils.nyi }, + scripts: { get: utils.nyi }, + innerHTML: { + get: function() { return this.serialize(); }, + set: utils.nyi + }, + outerHTML: { + get: function() { return this.serialize(); }, + set: utils.nyi + }, + + write: { value: function(args) { + if (!this.isHTML) utils.InvalidStateError(); + + // XXX: still have to implement the ignore part + if (!this._parser /* && this._ignore_destructive_writes > 0 */ ) + return; + + if (!this._parser) { + // XXX call document.open, etc. + } + + var s = arguments.join(''); + + // If the Document object's reload override flag is set, then + // append the string consisting of the concatenation of all the + // arguments to the method to the Document's reload override + // buffer. + // XXX: don't know what this is about. Still have to do it + + // If there is no pending parsing-blocking script, have the + // tokenizer process the characters that were inserted, one at a + // time, processing resulting tokens as they are emitted, and + // stopping when the tokenizer reaches the insertion point or when + // the processing of the tokenizer is aborted by the tree + // construction stage (this can happen if a script end tag token is + // emitted by the tokenizer). + + // XXX: still have to do the above. Sounds as if we don't + // always call parse() here. If we're blocked, then we just + // insert the text into the stream but don't parse it reentrantly... + + // Invoke the parser reentrantly + this._parser.parse(s); + }}, + + writeln: { value: function writeln(args) { + this.write(Array.prototype.join.call(arguments, '') + '\n'); + }}, + + open: { value: function() { + this.documentElement = null; + }}, + + close: { value: function() { + this.readyState = 'complete'; + var ev = new Event('DOMContentLoaded'); + this._dispatchEvent(ev, true); + if (this.defaultView) { + ev = new Event('load'); + this.defaultView._dispatchEvent(ev, true); + } + }}, + + // Utility methods + clone: { value: function clone() { + // Can't clone an entire document + utils.DataCloneError(); + }}, + + isEqual: { value: function isEqual(n) { + // Any two documents are shallowly equal. + // Node.isEqualNode will also test the children + return true; + }}, + + // Implementation-specific function. Called when a text, comment, + // or pi value changes. + mutateValue: { value: function(node) { + if (this.mutationHandler) { + this.mutationHandler({ + type: MUTATE.VALUE, + target: node, + data: node.data + }); } -}; + }}, - -//12.2.4.27 Script data escaped end tag name state -//------------------------------------------------------------------ -_[SCRIPT_DATA_ESCAPED_END_TAG_NAME_STATE] = function scriptDataEscapedEndTagNameState(cp) { - if (isAsciiUpper(cp)) { - this.currentToken.tagName += toAsciiLowerChar(cp); - this.tempBuff.push(cp); + // Invoked when an attribute's value changes. Attr holds the new + // value. oldval is the old value. Attribute mutations can also + // involve changes to the prefix (and therefore the qualified name) + mutateAttr: { value: function(attr, oldval) { + // Manage id->element mapping for getElementsById() + // XXX: this special case id handling should not go here, + // but in the attribute declaration for the id attribute + /* + if (attr.localName === 'id' && attr.namespaceURI === null) { + if (oldval) delId(oldval, attr.ownerElement); + addId(attr.value, attr.ownerElement); + } + */ + if (this.mutationHandler) { + this.mutationHandler({ + type: MUTATE.ATTR, + target: attr.ownerElement, + attr: attr + }); } + }}, - else if (isAsciiLower(cp)) { - this.currentToken.tagName += toChar(cp); - this.tempBuff.push(cp); + // Used by removeAttribute and removeAttributeNS for attributes. + mutateRemoveAttr: { value: function(attr) { +/* +* This is now handled in Attributes.js + // Manage id to element mapping + if (attr.localName === 'id' && attr.namespaceURI === null) { + this.delId(attr.value, attr.ownerElement); + } +*/ + if (this.mutationHandler) { + this.mutationHandler({ + type: MUTATE.REMOVE_ATTR, + target: attr.ownerElement, + attr: attr + }); + } + }}, + + // Called by Node.removeChild, etc. to remove a rooted element from + // the tree. Only needs to generate a single mutation event when a + // node is removed, but must recursively mark all descendants as not + // rooted. + mutateRemove: { value: function(node) { + // Send a single mutation event + if (this.mutationHandler) { + this.mutationHandler({ + type: MUTATE.REMOVE, + target: node.parentNode, + node: node + }); } - else { - if (this._isAppropriateEndTagToken()) { - if (isWhitespace(cp)) { - this.state = BEFORE_ATTRIBUTE_NAME_STATE; - return; - } + // Mark this and all descendants as not rooted + recursivelyUproot(node); + }}, - if (cp === $.SOLIDUS) { - this.state = SELF_CLOSING_START_TAG_STATE; - return; - } + // Called when a new element becomes rooted. It must recursively + // generate mutation events for each of the children, and mark them all + // as rooted. + mutateInsert: { value: function(node) { + // Mark node and its descendants as rooted + recursivelyRoot(node); - if (cp === $.GREATER_THAN_SIGN) { - this._emitCurrentToken(); - this.state = DATA_STATE; - return; - } - } + // Send a single mutation event + if (this.mutationHandler) { + this.mutationHandler({ + type: MUTATE.INSERT, + target: node.parentNode, + node: node + }); + } + }}, - this._emitChar('<'); - this._emitChar('/'); - this._emitSeveralCodePoints(this.tempBuff); - this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE); + // Called when a rooted element is moved within the document + mutateMove: { value: function(node) { + if (this.mutationHandler) { + this.mutationHandler({ + type: MUTATE.MOVE, + target: node + }); } -}; + }}, -//12.2.4.28 Script data double escape start state -//------------------------------------------------------------------ -_[SCRIPT_DATA_DOUBLE_ESCAPE_START_STATE] = function scriptDataDoubleEscapeStartState(cp) { - if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN) { - this.state = this.isTempBufferEqualToScriptString() ? SCRIPT_DATA_DOUBLE_ESCAPED_STATE : SCRIPT_DATA_ESCAPED_STATE; - this._emitCodePoint(cp); + // Add a mapping from id to n for n.ownerDocument + addId: { value: function addId(id, n) { + var val = this.byId[id]; + if (!val) { + this.byId[id] = n; } - - else if (isAsciiUpper(cp)) { - this.tempBuff.push(toAsciiLowerCodePoint(cp)); - this._emitCodePoint(cp); + else { + // TODO: Add a way to opt-out console warnings + //console.warn('Duplicate element id ' + id); + if (!(val instanceof MultiId)) { + val = new MultiId(val); + this.byId[id] = val; + } + val.add(n); } + }}, + + // Delete the mapping from id to n for n.ownerDocument + delId: { value: function delId(id, n) { + var val = this.byId[id]; + utils.assert(val); - else if (isAsciiLower(cp)) { - this.tempBuff.push(cp); - this._emitCodePoint(cp); + if (val instanceof MultiId) { + val.del(n); + if (val.length === 1) { // convert back to a single node + this.byId[id] = val.downgrade(); + } + } + else { + this.byId[id] = undefined; } + }}, - else - this._reconsumeInState(SCRIPT_DATA_ESCAPED_STATE); -}; + _resolve: { value: function(href) { + //XXX: Cache the URL + return new URL(this._documentBaseURL).resolve(href); + }}, + _documentBaseURL: { get: function() { + // XXX: This is not implemented correctly yet + var url = this._address; + if (url === 'about:blank') url = '/'; -//12.2.4.29 Script data double escaped state -//------------------------------------------------------------------ -_[SCRIPT_DATA_DOUBLE_ESCAPED_STATE] = function scriptDataDoubleEscapedState(cp) { - if (cp === $.HYPHEN_MINUS) { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE; - this._emitChar('-'); + var base = this.querySelector('base[href]'); + if (base) { + return new URL(url).resolve(base.getAttribute('href')); } + return url; - else if (cp === $.LESS_THAN_SIGN) { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE; - this._emitChar('<'); - } + // The document base URL of a Document object is the + // absolute URL obtained by running these substeps: - else if (cp === $.NULL) - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); + // Let fallback base url be the document's address. - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); + // If fallback base url is about:blank, and the + // Document's browsing context has a creator browsing + // context, then let fallback base url be the document + // base URL of the creator Document instead. - else - this._emitCodePoint(cp); -}; + // If the Document is an iframe srcdoc document, then + // let fallback base url be the document base URL of + // the Document's browsing context's browsing context + // container's Document instead. + // If there is no base element that has an href + // attribute, then the document base URL is fallback + // base url; abort these steps. Otherwise, let url be + // the value of the href attribute of the first such + // element. -//12.2.4.30 Script data double escaped dash state -//------------------------------------------------------------------ -_[SCRIPT_DATA_DOUBLE_ESCAPED_DASH_STATE] = function scriptDataDoubleEscapedDashState(cp) { - if (cp === $.HYPHEN_MINUS) { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE; - this._emitChar('-'); - } + // Resolve url relative to fallback base url (thus, + // the base href attribute isn't affected by xml:base + // attributes). - else if (cp === $.LESS_THAN_SIGN) { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE; - this._emitChar('<'); - } + // The document base URL is the result of the previous + // step if it was successful; otherwise it is fallback + // base url. + }}, - else if (cp === $.NULL) { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_STATE; - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); + _templateDoc: { get: function() { + if (!this._templateDocCache) { + // "associated inert template document" + var newDoc = new Document(this.isHTML, this._address); + this._templateDocCache = newDoc._templateDocCache = newDoc; } + return this._templateDocCache; + }}, - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); + querySelector: { value: function(selector) { + return select(selector, this)[0]; + }}, - else { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_STATE; - this._emitCodePoint(cp); - } -}; + querySelectorAll: { value: function(selector) { + var nodes = select(selector, this); + return nodes.item ? nodes : new NodeList(nodes); + }} + +}); -//12.2.4.31 Script data double escaped dash dash state -//------------------------------------------------------------------ -_[SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH_STATE] = function scriptDataDoubleEscapedDashDashState(cp) { - if (cp === $.HYPHEN_MINUS) - this._emitChar('-'); +var eventHandlerTypes = [ + 'abort', 'canplay', 'canplaythrough', 'change', 'click', 'contextmenu', + 'cuechange', 'dblclick', 'drag', 'dragend', 'dragenter', 'dragleave', + 'dragover', 'dragstart', 'drop', 'durationchange', 'emptied', 'ended', + 'input', 'invalid', 'keydown', 'keypress', 'keyup', 'loadeddata', + 'loadedmetadata', 'loadstart', 'mousedown', 'mousemove', 'mouseout', + 'mouseover', 'mouseup', 'mousewheel', 'pause', 'play', 'playing', + 'progress', 'ratechange', 'readystatechange', 'reset', 'seeked', + 'seeking', 'select', 'show', 'stalled', 'submit', 'suspend', + 'timeupdate', 'volumechange', 'waiting', - else if (cp === $.LESS_THAN_SIGN) { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE; - this._emitChar('<'); - } + 'blur', 'error', 'focus', 'load', 'scroll' +]; - else if (cp === $.GREATER_THAN_SIGN) { - this.state = SCRIPT_DATA_STATE; - this._emitChar('>'); +// Add event handler idl attribute getters and setters to Document +eventHandlerTypes.forEach(function(type) { + // Define the event handler registration IDL attribute for this type + Object.defineProperty(Document.prototype, 'on' + type, { + get: function() { + return this._getEventHandler(type); + }, + set: function(v) { + this._setEventHandler(type, v); } + }); +}); - else if (cp === $.NULL) { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_STATE; - this._emitChar(UNICODE.REPLACEMENT_CHARACTER); +function namedHTMLChild(parent, name) { + if (parent && parent.isHTML) { + var kids = parent.childNodes; + for(var i = 0, n = kids.length; i < n; i++) { + if (kids[i].nodeType === Node.ELEMENT_NODE && + kids[i].localName === name && + kids[i].namespaceURI === NAMESPACE.HTML) { + return kids[i]; + } } + } + return null; +} + +function root(n) { + n._nid = n.ownerDocument._nextnid++; + n.ownerDocument._nodes[n._nid] = n; + // Manage id to element mapping + if (n.nodeType === Node.ELEMENT_NODE) { + var id = n.getAttribute('id'); + if (id) n.ownerDocument.addId(id, n); + + // Script elements need to know when they're inserted + // into the document + if (n._roothook) n._roothook(); + } +} + +function uproot(n) { + // Manage id to element mapping + if (n.nodeType === Node.ELEMENT_NODE) { + var id = n.getAttribute('id'); + if (id) n.ownerDocument.delId(id, n); + } + n.ownerDocument._nodes[n._nid] = undefined; + n._nid = undefined; +} + +function recursivelyRoot(node) { + root(node); + // XXX: + // accessing childNodes on a leaf node creates a new array the + // first time, so be careful to write this loop so that it + // doesn't do that. node is polymorphic, so maybe this is hard to + // optimize? Try switching on nodeType? +/* + if (node.hasChildNodes()) { + var kids = node.childNodes; + for(var i = 0, n = kids.length; i < n; i++) + recursivelyRoot(kids[i]); + } +*/ + if (node.nodeType === Node.ELEMENT_NODE) { + var kids = node.childNodes; + for(var i = 0, n = kids.length; i < n; i++) + recursivelyRoot(kids[i]); + } +} - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); +function recursivelyUproot(node) { + uproot(node); + for(var i = 0, n = node.childNodes.length; i < n; i++) + recursivelyUproot(node.childNodes[i]); +} - else { - this.state = SCRIPT_DATA_DOUBLE_ESCAPED_STATE; - this._emitCodePoint(cp); - } -}; +function recursivelySetOwner(node, owner) { + node.ownerDocument = owner; + node._lastModTime = undefined; // mod times are document-based + var kids = node.childNodes; + for(var i = 0, n = kids.length; i < n; i++) + recursivelySetOwner(kids[i], owner); +} +// A class for storing multiple nodes with the same ID +function MultiId(node) { + this.nodes = Object.create(null); + this.nodes[node._nid] = node; + this.length = 1; + this.firstNode = undefined; +} -//12.2.4.32 Script data double escaped less-than sign state -//------------------------------------------------------------------ -_[SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN_STATE] = function scriptDataDoubleEscapedLessThanSignState(cp) { - if (cp === $.SOLIDUS) { - this.tempBuff = []; - this.state = SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE; - this._emitChar('/'); +// Add a node to the list, with O(1) time +MultiId.prototype.add = function(node) { + if (!this.nodes[node._nid]) { + this.nodes[node._nid] = node; + this.length++; + this.firstNode = undefined; + } +}; + +// Remove a node from the list, with O(1) time +MultiId.prototype.del = function(node) { + if (this.nodes[node._nid]) { + delete this.nodes[node._nid]; + this.length--; + this.firstNode = undefined; + } +}; + +// Get the first node from the list, in the document order +// Takes O(N) time in the size of the list, with a cache that is invalidated +// when the list is modified. +MultiId.prototype.getFirst = function() { + /* jshint bitwise: false */ + if (!this.firstNode) { + var nid; + for (nid in this.nodes) { + if (this.firstNode === undefined || + this.firstNode.compareDocumentPosition(this.nodes[nid]) & Node.DOCUMENT_POSITION_PRECEDING) { + this.firstNode = this.nodes[nid]; + } } - - else - this._reconsumeInState(SCRIPT_DATA_DOUBLE_ESCAPED_STATE); + } + return this.firstNode; }; - -//12.2.4.33 Script data double escape end state -//------------------------------------------------------------------ -_[SCRIPT_DATA_DOUBLE_ESCAPE_END_STATE] = function scriptDataDoubleEscapeEndState(cp) { - if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN) { - this.state = this.isTempBufferEqualToScriptString() ? SCRIPT_DATA_ESCAPED_STATE : SCRIPT_DATA_DOUBLE_ESCAPED_STATE; - - this._emitCodePoint(cp); - } - - else if (isAsciiUpper(cp)) { - this.tempBuff.push(toAsciiLowerCodePoint(cp)); - this._emitCodePoint(cp); - } - - else if (isAsciiLower(cp)) { - this.tempBuff.push(cp); - this._emitCodePoint(cp); +// If there is only one node left, return it. Otherwise return "this". +MultiId.prototype.downgrade = function() { + if (this.length === 1) { + var nid; + for (nid in this.nodes) { + return this.nodes[nid]; } - - else - this._reconsumeInState(SCRIPT_DATA_DOUBLE_ESCAPED_STATE); + } + return this; }; -//12.2.4.34 Before attribute name state -//------------------------------------------------------------------ -_[BEFORE_ATTRIBUTE_NAME_STATE] = function beforeAttributeNameState(cp) { - if (isWhitespace(cp)) - return; - - if (cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN || cp === $.EOF) - this._reconsumeInState(AFTER_ATTRIBUTE_NAME_STATE); - - else if (cp === $.EQUALS_SIGN) { - this._createAttr('='); - this.state = ATTRIBUTE_NAME_STATE; - } +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { - else { - this._createAttr(''); - this._reconsumeInState(ATTRIBUTE_NAME_STATE); - } -}; +"use strict"; +module.exports = DocumentType; -//12.2.4.35 Attribute name state -//------------------------------------------------------------------ -_[ATTRIBUTE_NAME_STATE] = function attributeNameState(cp) { - if (isWhitespace(cp) || cp === $.SOLIDUS || cp === $.GREATER_THAN_SIGN || cp === $.EOF) { - this._leaveAttrName(AFTER_ATTRIBUTE_NAME_STATE); - this._unconsume(); - } +var Node = __webpack_require__(3); +var Leaf = __webpack_require__(34); +var utils = __webpack_require__(1); +var ChildNode = __webpack_require__(16); - else if (cp === $.EQUALS_SIGN) - this._leaveAttrName(BEFORE_ATTRIBUTE_VALUE_STATE); +function DocumentType(name, publicId, systemId) { + // Unlike other nodes, doctype nodes always start off unowned + // until inserted + this.nodeType = Node.DOCUMENT_TYPE_NODE; + this.ownerDocument = null; + this.name = name; + this.publicId = publicId || ""; + this.systemId = systemId || ""; +} - else if (isAsciiUpper(cp)) - this.currentAttr.name += toAsciiLowerChar(cp); +DocumentType.prototype = Object.create(Leaf.prototype, { + nodeName: { get: function() { return this.name; }}, + nodeValue: { + get: function() { return null; }, + set: function() {} + }, - else if (cp === $.QUOTATION_MARK || cp === $.APOSTROPHE || cp === $.LESS_THAN_SIGN) - this.currentAttr.name += toChar(cp); + // Utility methods + clone: { value: function clone() { + utils.DataCloneError(); + }}, - else if (cp === $.NULL) - this.currentAttr.name += UNICODE.REPLACEMENT_CHARACTER; + isEqual: { value: function isEqual(n) { + return this.name === n.name && + this.publicId === n.publicId && + this.systemId === n.systemId; + }} +}); - else - this.currentAttr.name += toChar(cp); -}; +Object.defineProperties(DocumentType.prototype, ChildNode); -//12.2.4.36 After attribute name state -//------------------------------------------------------------------ -_[AFTER_ATTRIBUTE_NAME_STATE] = function afterAttributeNameState(cp) { - if (isWhitespace(cp)) - return; +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { - if (cp === $.SOLIDUS) - this.state = SELF_CLOSING_START_TAG_STATE; +"use strict"; - else if (cp === $.EQUALS_SIGN) - this.state = BEFORE_ATTRIBUTE_VALUE_STATE; +module.exports = HTMLParser; - else if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); - } +var Document = __webpack_require__(17); +var DocumentType = __webpack_require__(18); +var Node = __webpack_require__(3); +var NAMESPACE = __webpack_require__(1).NAMESPACE; +var html = __webpack_require__(22); +var impl = html.elements; - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); +var pushAll = Function.prototype.apply.bind(Array.prototype.push); - else { - this._createAttr(''); - this._reconsumeInState(ATTRIBUTE_NAME_STATE); - } +/* + * This file contains an implementation of the HTML parsing algorithm. + * The algorithm and the implementation are complex because HTML + * explicitly defines how the parser should behave for all possible + * valid and invalid inputs. + * + * Usage: + * + * The file defines a single HTMLParser() function, which dom.js exposes + * publicly as document.implementation.mozHTMLParser(). This is a + * factory function, not a constructor. + * + * When you call document.implementation.mozHTMLParser(), it returns + * an object that has parse() and document() methods. To parse HTML text, + * pass the text (in one or more chunks) to the parse() method. When + * you've passed all the text (on the last chunk, or afterward) pass + * true as the second argument to parse() to tell the parser that there + * is no more coming. Call document() to get the document object that + * the parser is parsing into. You can call this at any time, before + * or after calling parse(). + * + * The first argument to mozHTMLParser is the absolute URL of the document. + * + * The second argument is optional and is for internal use only. Pass an + * element as the fragmentContext to do innerHTML parsing for the + * element. To do innerHTML parsing on a document, pass null. Otherwise, + * omit the 2nd argument. See HTMLElement.innerHTML for an example. Note + * that if you pass a context element, the end() method will return an + * unwrapped document instead of a wrapped one. + * + * Implementation details: + * + * This is a long file of almost 7000 lines. It is structured as one + * big function nested within another big function. The outer + * function defines a bunch of constant data, utility functions + * that use that data, and a couple of classes used by the parser. + * The outer function also defines and returns the + * inner function. This inner function is the HTMLParser factory + * function that implements the parser and holds all the parser state + * as local variables. The HTMLParser function is quite big because + * it defines many nested functions that use those local variables. + * + * There are three tightly coupled parser stages: a scanner, a + * tokenizer and a tree builder. In a (possibly misguided) attempt at + * efficiency, the stages are not implemented as separate classes: + * everything shares state and is (mostly) implemented in imperative + * (rather than OO) style. + * + * The stages of the parser work like this: When the client code calls + * the parser's parse() method, the specified string is passed to + * scanChars(). The scanner loops through that string and passes characters + * (sometimes one at a time, sometimes in chunks) to the tokenizer stage. + * The tokenizer groups the characters into tokens: tags, endtags, runs + * of text, comments, doctype declarations, and the end-of-file (EOF) + * token. These tokens are then passed to the tree building stage via + * the insertToken() function. The tree building stage builds up the + * document tree. + * + * The tokenizer stage is a finite state machine. Each state is + * implemented as a function with a name that ends in "_state". The + * initial state is data_state(). The current tokenizer state is stored + * in the variable 'tokenizer'. Most state functions expect a single + * integer argument which represents a single UTF-16 codepoint. Some + * states want more characters and set a lookahead property on + * themselves. The scanChars() function in the scanner checks for this + * lookahead property. If it doesn't exist, then scanChars() just passes + * the next input character to the current tokenizer state function. + * Otherwise, scanChars() looks ahead (a given # of characters, or for a + * matching string, or for a matching regexp) and passes a string of + * characters to the current tokenizer state function. + * + * As a shortcut, certain states of the tokenizer use regular expressions + * to look ahead in the scanner's input buffer for runs of text, simple + * tags and attributes. For well-formed input, these shortcuts skip a + * lot of state transitions and speed things up a bit. + * + * When a tokenizer state function has consumed a complete token, it + * emits that token, by calling insertToken(), or by calling a utility + * function that itself calls insertToken(). These tokens are passed to + * the tree building stage, which is also a state machine. Like the + * tokenizer, the tree building states are implemented as functions, and + * these functions have names that end with _mode (because the HTML spec + * refers to them as insertion modes). The current insertion mode is held + * by the 'parser' variable. Each insertion mode function takes up to 4 + * arguments. The first is a token type, represented by the constants + * TAG, ENDTAG, TEXT, COMMENT, DOCTYPE and EOF. The second argument is + * the value of the token: the text or comment data, or tagname or + * doctype. For tags, the 3rd argument is an array of attributes. For + * DOCTYPES it is the optional public id. For tags, the 4th argument is + * true if the tag is self-closing. For doctypes, the 4th argument is the + * optional system id. + * + * Search for "***" to find the major sub-divisions in the code. + */ + + +/*** + * Data prolog. Lots of constants declared here, including some + * very large objects. They're used throughout the code that follows + */ +// Token types for the tree builder. +var EOF = -1; +var TEXT = 1; +var TAG = 2; +var ENDTAG = 3; +var COMMENT = 4; +var DOCTYPE = 5; + +// A re-usable empty array +var NOATTRS = []; + +// These DTD public ids put the browser in quirks mode +var quirkyPublicIds = /^HTML$|^-\/\/W3O\/\/DTD W3 HTML Strict 3\.0\/\/EN\/\/$|^-\/W3C\/DTD HTML 4\.0 Transitional\/EN$|^\+\/\/Silmaril\/\/dtd html Pro v0r11 19970101\/\/|^-\/\/AdvaSoft Ltd\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/AS\/\/DTD HTML 3\.0 asWedit \+ extensions\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML 2\.0 Strict\/\/|^-\/\/IETF\/\/DTD HTML 2\.0\/\/|^-\/\/IETF\/\/DTD HTML 2\.1E\/\/|^-\/\/IETF\/\/DTD HTML 3\.0\/\/|^-\/\/IETF\/\/DTD HTML 3\.2 Final\/\/|^-\/\/IETF\/\/DTD HTML 3\.2\/\/|^-\/\/IETF\/\/DTD HTML 3\/\/|^-\/\/IETF\/\/DTD HTML Level 0\/\/|^-\/\/IETF\/\/DTD HTML Level 1\/\/|^-\/\/IETF\/\/DTD HTML Level 2\/\/|^-\/\/IETF\/\/DTD HTML Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 0\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 1\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 2\/\/|^-\/\/IETF\/\/DTD HTML Strict Level 3\/\/|^-\/\/IETF\/\/DTD HTML Strict\/\/|^-\/\/IETF\/\/DTD HTML\/\/|^-\/\/Metrius\/\/DTD Metrius Presentational\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 2\.0 Tables\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML Strict\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 HTML\/\/|^-\/\/Microsoft\/\/DTD Internet Explorer 3\.0 Tables\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD HTML\/\/|^-\/\/Netscape Comm\. Corp\.\/\/DTD Strict HTML\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML 2\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended 1\.0\/\/|^-\/\/O'Reilly and Associates\/\/DTD HTML Extended Relaxed 1\.0\/\/|^-\/\/SoftQuad Software\/\/DTD HoTMetaL PRO 6\.0::19990601::extensions to HTML 4\.0\/\/|^-\/\/SoftQuad\/\/DTD HoTMetaL PRO 4\.0::19971010::extensions to HTML 4\.0\/\/|^-\/\/Spyglass\/\/DTD HTML 2\.0 Extended\/\/|^-\/\/SQ\/\/DTD HTML 2\.0 HoTMetaL \+ extensions\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava HTML\/\/|^-\/\/Sun Microsystems Corp\.\/\/DTD HotJava Strict HTML\/\/|^-\/\/W3C\/\/DTD HTML 3 1995-03-24\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Draft\/\/|^-\/\/W3C\/\/DTD HTML 3\.2 Final\/\/|^-\/\/W3C\/\/DTD HTML 3\.2\/\/|^-\/\/W3C\/\/DTD HTML 3\.2S Draft\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.0 Transitional\/\/|^-\/\/W3C\/\/DTD HTML Experimental 19960712\/\/|^-\/\/W3C\/\/DTD HTML Experimental 970421\/\/|^-\/\/W3C\/\/DTD W3 HTML\/\/|^-\/\/W3O\/\/DTD W3 HTML 3\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML 2\.0\/\/|^-\/\/WebTechs\/\/DTD Mozilla HTML\/\//i; + +var quirkySystemId = "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"; + +var conditionallyQuirkyPublicIds = /^-\/\/W3C\/\/DTD HTML 4\.01 Frameset\/\/|^-\/\/W3C\/\/DTD HTML 4\.01 Transitional\/\//i; + +// These DTD public ids put the browser in limited quirks mode +var limitedQuirkyPublicIds = /^-\/\/W3C\/\/DTD XHTML 1\.0 Frameset\/\/|^-\/\/W3C\/\/DTD XHTML 1\.0 Transitional\/\//i; + + +// Element sets below. See the isA() function for a way to test +// whether an element is a member of a set +var specialSet = Object.create(null); +specialSet[NAMESPACE.HTML] = { + __proto__: null, + "address":true, "applet":true, "area":true, "article":true, + "aside":true, "base":true, "basefont":true, "bgsound":true, + "blockquote":true, "body":true, "br":true, "button":true, + "caption":true, "center":true, "col":true, "colgroup":true, + "dd":true, "details":true, "dir":true, + "div":true, "dl":true, "dt":true, "embed":true, + "fieldset":true, "figcaption":true, "figure":true, "footer":true, + "form":true, "frame":true, "frameset":true, "h1":true, + "h2":true, "h3":true, "h4":true, "h5":true, + "h6":true, "head":true, "header":true, "hgroup":true, + "hr":true, "html":true, "iframe":true, "img":true, + "input":true, "li":true, "link":true, + "listing":true, "main":true, "marquee":true, "menu":true, "meta":true, + "nav":true, "noembed":true, "noframes":true, "noscript":true, + "object":true, "ol":true, "p":true, "param":true, + "plaintext":true, "pre":true, "script":true, "section":true, + "select":true, "source":true, "style":true, "summary":true, "table":true, + "tbody":true, "td":true, "template":true, "textarea":true, "tfoot":true, + "th":true, "thead":true, "title":true, "tr":true, "track":true, + // Note that "xmp" was removed from the "special" set in the latest + // spec, apparently by accident; see + // https://github.com/whatwg/html/pull/1919 + "ul":true, "wbr":true, "xmp":true +}; +specialSet[NAMESPACE.SVG] = { + __proto__: null, + "foreignObject": true, "desc": true, "title": true +}; +specialSet[NAMESPACE.MATHML] = { + __proto__: null, + "mi":true, "mo":true, "mn":true, "ms":true, + "mtext":true, "annotation-xml":true +}; + +// The set of address, div, and p HTML tags +var addressdivpSet = Object.create(null); +addressdivpSet[NAMESPACE.HTML] = { + __proto__: null, + "address":true, "div":true, "p":true +}; + +var dddtSet = Object.create(null); +dddtSet[NAMESPACE.HTML] = { + __proto__: null, + "dd":true, "dt":true +}; + +var tablesectionrowSet = Object.create(null); +tablesectionrowSet[NAMESPACE.HTML] = { + __proto__: null, + "table":true, "thead":true, "tbody":true, "tfoot":true, "tr":true +}; + +var impliedEndTagsSet = Object.create(null); +impliedEndTagsSet[NAMESPACE.HTML] = { + __proto__: null, + "dd": true, "dt": true, "li": true, "menuitem": true, "optgroup": true, + "option": true, "p": true, "rb": true, "rp": true, "rt": true, "rtc": true +}; + +var thoroughImpliedEndTagsSet = Object.create(null); +thoroughImpliedEndTagsSet[NAMESPACE.HTML] = { + __proto__: null, + "caption": true, "colgroup": true, "dd": true, "dt": true, "li": true, + "optgroup": true, "option": true, "p": true, "rb": true, "rp": true, + "rt": true, "rtc": true, "tbody": true, "td": true, "tfoot": true, + "th": true, "thead": true, "tr": true +}; + +var tableContextSet = Object.create(null); +tableContextSet[NAMESPACE.HTML] = { + __proto__: null, + "table": true, "template": true, "html": true +}; + +var tableBodyContextSet = Object.create(null); +tableBodyContextSet[NAMESPACE.HTML] = { + __proto__: null, + "tbody": true, "tfoot": true, "thead": true, "template": true, "html": true +}; + +var tableRowContextSet = Object.create(null); +tableRowContextSet[NAMESPACE.HTML] = { + __proto__: null, + "tr": true, "template": true, "html": true +}; + +// See http://www.w3.org/TR/html5/forms.html#form-associated-element +var formassociatedSet = Object.create(null); +formassociatedSet[NAMESPACE.HTML] = { + __proto__: null, + "button": true, "fieldset": true, "input": true, "keygen": true, + "object": true, "output": true, "select": true, "textarea": true, + "img": true +}; + +var inScopeSet = Object.create(null); +inScopeSet[NAMESPACE.HTML]= { + __proto__: null, + "applet":true, "caption":true, "html":true, "table":true, + "td":true, "th":true, "marquee":true, "object":true, + "template":true +}; +inScopeSet[NAMESPACE.MATHML] = { + __proto__: null, + "mi":true, "mo":true, "mn":true, "ms":true, + "mtext":true, "annotation-xml":true +}; +inScopeSet[NAMESPACE.SVG] = { + __proto__: null, + "foreignObject":true, "desc":true, "title":true +}; + +var inListItemScopeSet = Object.create(inScopeSet); +inListItemScopeSet[NAMESPACE.HTML] = + Object.create(inScopeSet[NAMESPACE.HTML]); +inListItemScopeSet[NAMESPACE.HTML].ol = true; +inListItemScopeSet[NAMESPACE.HTML].ul = true; + +var inButtonScopeSet = Object.create(inScopeSet); +inButtonScopeSet[NAMESPACE.HTML] = + Object.create(inScopeSet[NAMESPACE.HTML]); +inButtonScopeSet[NAMESPACE.HTML].button = true; + +var inTableScopeSet = Object.create(null); +inTableScopeSet[NAMESPACE.HTML] = { + __proto__: null, + "html":true, "table":true, "template":true +}; + +// The set of elements for select scope is the everything *except* these +var invertedSelectScopeSet = Object.create(null); +invertedSelectScopeSet[NAMESPACE.HTML] = { + __proto__: null, + "optgroup":true, "option":true +}; + +var mathmlTextIntegrationPointSet = Object.create(null); +mathmlTextIntegrationPointSet[NAMESPACE.MATHML] = { + __proto__: null, + mi: true, + mo: true, + mn: true, + ms: true, + mtext: true +}; + +var htmlIntegrationPointSet = Object.create(null); +htmlIntegrationPointSet[NAMESPACE.SVG] = { + __proto__: null, + foreignObject: true, + desc: true, + title: true +}; + +var foreignAttributes = { + __proto__: null, + "xlink:actuate": NAMESPACE.XLINK, "xlink:arcrole": NAMESPACE.XLINK, + "xlink:href": NAMESPACE.XLINK, "xlink:role": NAMESPACE.XLINK, + "xlink:show": NAMESPACE.XLINK, "xlink:title": NAMESPACE.XLINK, + "xlink:type": NAMESPACE.XLINK, "xml:base": NAMESPACE.XML, + "xml:lang": NAMESPACE.XML, "xml:space": NAMESPACE.XML, + "xmlns": NAMESPACE.XMLNS, "xmlns:xlink": NAMESPACE.XMLNS +}; + + +// Lowercase to mixed case mapping for SVG attributes and tagnames +var svgAttrAdjustments = { + __proto__: null, + attributename: "attributeName", attributetype: "attributeType", + basefrequency: "baseFrequency", baseprofile: "baseProfile", + calcmode: "calcMode", clippathunits: "clipPathUnits", + diffuseconstant: "diffuseConstant", + edgemode: "edgeMode", + filterunits: "filterUnits", + glyphref: "glyphRef", gradienttransform: "gradientTransform", + gradientunits: "gradientUnits", kernelmatrix: "kernelMatrix", + kernelunitlength: "kernelUnitLength", keypoints: "keyPoints", + keysplines: "keySplines", keytimes: "keyTimes", + lengthadjust: "lengthAdjust", limitingconeangle: "limitingConeAngle", + markerheight: "markerHeight", markerunits: "markerUnits", + markerwidth: "markerWidth", maskcontentunits: "maskContentUnits", + maskunits: "maskUnits", numoctaves: "numOctaves", + pathlength: "pathLength", patterncontentunits: "patternContentUnits", + patterntransform: "patternTransform", patternunits: "patternUnits", + pointsatx: "pointsAtX", pointsaty: "pointsAtY", + pointsatz: "pointsAtZ", preservealpha: "preserveAlpha", + preserveaspectratio: "preserveAspectRatio", + primitiveunits: "primitiveUnits", refx: "refX", + refy: "refY", repeatcount: "repeatCount", + repeatdur: "repeatDur", requiredextensions: "requiredExtensions", + requiredfeatures: "requiredFeatures", + specularconstant: "specularConstant", + specularexponent: "specularExponent", spreadmethod: "spreadMethod", + startoffset: "startOffset", stddeviation: "stdDeviation", + stitchtiles: "stitchTiles", surfacescale: "surfaceScale", + systemlanguage: "systemLanguage", tablevalues: "tableValues", + targetx: "targetX", targety: "targetY", + textlength: "textLength", viewbox: "viewBox", + viewtarget: "viewTarget", xchannelselector: "xChannelSelector", + ychannelselector: "yChannelSelector", zoomandpan: "zoomAndPan" +}; + +var svgTagNameAdjustments = { + __proto__: null, + altglyph: "altGlyph", altglyphdef: "altGlyphDef", + altglyphitem: "altGlyphItem", animatecolor: "animateColor", + animatemotion: "animateMotion", animatetransform: "animateTransform", + clippath: "clipPath", feblend: "feBlend", + fecolormatrix: "feColorMatrix", + fecomponenttransfer: "feComponentTransfer", fecomposite: "feComposite", + feconvolvematrix: "feConvolveMatrix", + fediffuselighting: "feDiffuseLighting", + fedisplacementmap: "feDisplacementMap", + fedistantlight: "feDistantLight", feflood: "feFlood", + fefunca: "feFuncA", fefuncb: "feFuncB", + fefuncg: "feFuncG", fefuncr: "feFuncR", + fegaussianblur: "feGaussianBlur", feimage: "feImage", + femerge: "feMerge", femergenode: "feMergeNode", + femorphology: "feMorphology", feoffset: "feOffset", + fepointlight: "fePointLight", fespecularlighting: "feSpecularLighting", + fespotlight: "feSpotLight", fetile: "feTile", + feturbulence: "feTurbulence", foreignobject: "foreignObject", + glyphref: "glyphRef", lineargradient: "linearGradient", + radialgradient: "radialGradient", textpath: "textPath" +}; + + +// Data for parsing numeric and named character references +// These next 3 objects are direct translations of tables +// in the HTML spec into JavaScript object format +var numericCharRefReplacements = { + __proto__: null, + 0x00:0xFFFD, 0x80:0x20AC, 0x82:0x201A, 0x83:0x0192, 0x84:0x201E, + 0x85:0x2026, 0x86:0x2020, 0x87:0x2021, 0x88:0x02C6, 0x89:0x2030, + 0x8A:0x0160, 0x8B:0x2039, 0x8C:0x0152, 0x8E:0x017D, 0x91:0x2018, + 0x92:0x2019, 0x93:0x201C, 0x94:0x201D, 0x95:0x2022, 0x96:0x2013, + 0x97:0x2014, 0x98:0x02DC, 0x99:0x2122, 0x9A:0x0161, 0x9B:0x203A, + 0x9C:0x0153, 0x9E:0x017E, 0x9F:0x0178 }; - -//12.2.4.37 Before attribute value state -//------------------------------------------------------------------ -_[BEFORE_ATTRIBUTE_VALUE_STATE] = function beforeAttributeValueState(cp) { - if (isWhitespace(cp)) - return; - - if (cp === $.QUOTATION_MARK) - this.state = ATTRIBUTE_VALUE_DOUBLE_QUOTED_STATE; - - else if (cp === $.APOSTROPHE) - this.state = ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE; - - else - this._reconsumeInState(ATTRIBUTE_VALUE_UNQUOTED_STATE); +/* + * This table is generated with test/tools/update-entities.js + */ +var namedCharRefs = { + __proto__: null, + "AElig":0xc6, "AElig;":0xc6, + "AMP":0x26, "AMP;":0x26, + "Aacute":0xc1, "Aacute;":0xc1, + "Abreve;":0x102, "Acirc":0xc2, + "Acirc;":0xc2, "Acy;":0x410, + "Afr;":[0xd835,0xdd04], "Agrave":0xc0, + "Agrave;":0xc0, "Alpha;":0x391, + "Amacr;":0x100, "And;":0x2a53, + "Aogon;":0x104, "Aopf;":[0xd835,0xdd38], + "ApplyFunction;":0x2061, "Aring":0xc5, + "Aring;":0xc5, "Ascr;":[0xd835,0xdc9c], + "Assign;":0x2254, "Atilde":0xc3, + "Atilde;":0xc3, "Auml":0xc4, + "Auml;":0xc4, "Backslash;":0x2216, + "Barv;":0x2ae7, "Barwed;":0x2306, + "Bcy;":0x411, "Because;":0x2235, + "Bernoullis;":0x212c, "Beta;":0x392, + "Bfr;":[0xd835,0xdd05], "Bopf;":[0xd835,0xdd39], + "Breve;":0x2d8, "Bscr;":0x212c, + "Bumpeq;":0x224e, "CHcy;":0x427, + "COPY":0xa9, "COPY;":0xa9, + "Cacute;":0x106, "Cap;":0x22d2, + "CapitalDifferentialD;":0x2145, "Cayleys;":0x212d, + "Ccaron;":0x10c, "Ccedil":0xc7, + "Ccedil;":0xc7, "Ccirc;":0x108, + "Cconint;":0x2230, "Cdot;":0x10a, + "Cedilla;":0xb8, "CenterDot;":0xb7, + "Cfr;":0x212d, "Chi;":0x3a7, + "CircleDot;":0x2299, "CircleMinus;":0x2296, + "CirclePlus;":0x2295, "CircleTimes;":0x2297, + "ClockwiseContourIntegral;":0x2232, "CloseCurlyDoubleQuote;":0x201d, + "CloseCurlyQuote;":0x2019, "Colon;":0x2237, + "Colone;":0x2a74, "Congruent;":0x2261, + "Conint;":0x222f, "ContourIntegral;":0x222e, + "Copf;":0x2102, "Coproduct;":0x2210, + "CounterClockwiseContourIntegral;":0x2233, "Cross;":0x2a2f, + "Cscr;":[0xd835,0xdc9e], "Cup;":0x22d3, + "CupCap;":0x224d, "DD;":0x2145, + "DDotrahd;":0x2911, "DJcy;":0x402, + "DScy;":0x405, "DZcy;":0x40f, + "Dagger;":0x2021, "Darr;":0x21a1, + "Dashv;":0x2ae4, "Dcaron;":0x10e, + "Dcy;":0x414, "Del;":0x2207, + "Delta;":0x394, "Dfr;":[0xd835,0xdd07], + "DiacriticalAcute;":0xb4, "DiacriticalDot;":0x2d9, + "DiacriticalDoubleAcute;":0x2dd, "DiacriticalGrave;":0x60, + "DiacriticalTilde;":0x2dc, "Diamond;":0x22c4, + "DifferentialD;":0x2146, "Dopf;":[0xd835,0xdd3b], + "Dot;":0xa8, "DotDot;":0x20dc, + "DotEqual;":0x2250, "DoubleContourIntegral;":0x222f, + "DoubleDot;":0xa8, "DoubleDownArrow;":0x21d3, + "DoubleLeftArrow;":0x21d0, "DoubleLeftRightArrow;":0x21d4, + "DoubleLeftTee;":0x2ae4, "DoubleLongLeftArrow;":0x27f8, + "DoubleLongLeftRightArrow;":0x27fa, "DoubleLongRightArrow;":0x27f9, + "DoubleRightArrow;":0x21d2, "DoubleRightTee;":0x22a8, + "DoubleUpArrow;":0x21d1, "DoubleUpDownArrow;":0x21d5, + "DoubleVerticalBar;":0x2225, "DownArrow;":0x2193, + "DownArrowBar;":0x2913, "DownArrowUpArrow;":0x21f5, + "DownBreve;":0x311, "DownLeftRightVector;":0x2950, + "DownLeftTeeVector;":0x295e, "DownLeftVector;":0x21bd, + "DownLeftVectorBar;":0x2956, "DownRightTeeVector;":0x295f, + "DownRightVector;":0x21c1, "DownRightVectorBar;":0x2957, + "DownTee;":0x22a4, "DownTeeArrow;":0x21a7, + "Downarrow;":0x21d3, "Dscr;":[0xd835,0xdc9f], + "Dstrok;":0x110, "ENG;":0x14a, + "ETH":0xd0, "ETH;":0xd0, + "Eacute":0xc9, "Eacute;":0xc9, + "Ecaron;":0x11a, "Ecirc":0xca, + "Ecirc;":0xca, "Ecy;":0x42d, + "Edot;":0x116, "Efr;":[0xd835,0xdd08], + "Egrave":0xc8, "Egrave;":0xc8, + "Element;":0x2208, "Emacr;":0x112, + "EmptySmallSquare;":0x25fb, "EmptyVerySmallSquare;":0x25ab, + "Eogon;":0x118, "Eopf;":[0xd835,0xdd3c], + "Epsilon;":0x395, "Equal;":0x2a75, + "EqualTilde;":0x2242, "Equilibrium;":0x21cc, + "Escr;":0x2130, "Esim;":0x2a73, + "Eta;":0x397, "Euml":0xcb, + "Euml;":0xcb, "Exists;":0x2203, + "ExponentialE;":0x2147, "Fcy;":0x424, + "Ffr;":[0xd835,0xdd09], "FilledSmallSquare;":0x25fc, + "FilledVerySmallSquare;":0x25aa, "Fopf;":[0xd835,0xdd3d], + "ForAll;":0x2200, "Fouriertrf;":0x2131, + "Fscr;":0x2131, "GJcy;":0x403, + "GT":0x3e, "GT;":0x3e, + "Gamma;":0x393, "Gammad;":0x3dc, + "Gbreve;":0x11e, "Gcedil;":0x122, + "Gcirc;":0x11c, "Gcy;":0x413, + "Gdot;":0x120, "Gfr;":[0xd835,0xdd0a], + "Gg;":0x22d9, "Gopf;":[0xd835,0xdd3e], + "GreaterEqual;":0x2265, "GreaterEqualLess;":0x22db, + "GreaterFullEqual;":0x2267, "GreaterGreater;":0x2aa2, + "GreaterLess;":0x2277, "GreaterSlantEqual;":0x2a7e, + "GreaterTilde;":0x2273, "Gscr;":[0xd835,0xdca2], + "Gt;":0x226b, "HARDcy;":0x42a, + "Hacek;":0x2c7, "Hat;":0x5e, + "Hcirc;":0x124, "Hfr;":0x210c, + "HilbertSpace;":0x210b, "Hopf;":0x210d, + "HorizontalLine;":0x2500, "Hscr;":0x210b, + "Hstrok;":0x126, "HumpDownHump;":0x224e, + "HumpEqual;":0x224f, "IEcy;":0x415, + "IJlig;":0x132, "IOcy;":0x401, + "Iacute":0xcd, "Iacute;":0xcd, + "Icirc":0xce, "Icirc;":0xce, + "Icy;":0x418, "Idot;":0x130, + "Ifr;":0x2111, "Igrave":0xcc, + "Igrave;":0xcc, "Im;":0x2111, + "Imacr;":0x12a, "ImaginaryI;":0x2148, + "Implies;":0x21d2, "Int;":0x222c, + "Integral;":0x222b, "Intersection;":0x22c2, + "InvisibleComma;":0x2063, "InvisibleTimes;":0x2062, + "Iogon;":0x12e, "Iopf;":[0xd835,0xdd40], + "Iota;":0x399, "Iscr;":0x2110, + "Itilde;":0x128, "Iukcy;":0x406, + "Iuml":0xcf, "Iuml;":0xcf, + "Jcirc;":0x134, "Jcy;":0x419, + "Jfr;":[0xd835,0xdd0d], "Jopf;":[0xd835,0xdd41], + "Jscr;":[0xd835,0xdca5], "Jsercy;":0x408, + "Jukcy;":0x404, "KHcy;":0x425, + "KJcy;":0x40c, "Kappa;":0x39a, + "Kcedil;":0x136, "Kcy;":0x41a, + "Kfr;":[0xd835,0xdd0e], "Kopf;":[0xd835,0xdd42], + "Kscr;":[0xd835,0xdca6], "LJcy;":0x409, + "LT":0x3c, "LT;":0x3c, + "Lacute;":0x139, "Lambda;":0x39b, + "Lang;":0x27ea, "Laplacetrf;":0x2112, + "Larr;":0x219e, "Lcaron;":0x13d, + "Lcedil;":0x13b, "Lcy;":0x41b, + "LeftAngleBracket;":0x27e8, "LeftArrow;":0x2190, + "LeftArrowBar;":0x21e4, "LeftArrowRightArrow;":0x21c6, + "LeftCeiling;":0x2308, "LeftDoubleBracket;":0x27e6, + "LeftDownTeeVector;":0x2961, "LeftDownVector;":0x21c3, + "LeftDownVectorBar;":0x2959, "LeftFloor;":0x230a, + "LeftRightArrow;":0x2194, "LeftRightVector;":0x294e, + "LeftTee;":0x22a3, "LeftTeeArrow;":0x21a4, + "LeftTeeVector;":0x295a, "LeftTriangle;":0x22b2, + "LeftTriangleBar;":0x29cf, "LeftTriangleEqual;":0x22b4, + "LeftUpDownVector;":0x2951, "LeftUpTeeVector;":0x2960, + "LeftUpVector;":0x21bf, "LeftUpVectorBar;":0x2958, + "LeftVector;":0x21bc, "LeftVectorBar;":0x2952, + "Leftarrow;":0x21d0, "Leftrightarrow;":0x21d4, + "LessEqualGreater;":0x22da, "LessFullEqual;":0x2266, + "LessGreater;":0x2276, "LessLess;":0x2aa1, + "LessSlantEqual;":0x2a7d, "LessTilde;":0x2272, + "Lfr;":[0xd835,0xdd0f], "Ll;":0x22d8, + "Lleftarrow;":0x21da, "Lmidot;":0x13f, + "LongLeftArrow;":0x27f5, "LongLeftRightArrow;":0x27f7, + "LongRightArrow;":0x27f6, "Longleftarrow;":0x27f8, + "Longleftrightarrow;":0x27fa, "Longrightarrow;":0x27f9, + "Lopf;":[0xd835,0xdd43], "LowerLeftArrow;":0x2199, + "LowerRightArrow;":0x2198, "Lscr;":0x2112, + "Lsh;":0x21b0, "Lstrok;":0x141, + "Lt;":0x226a, "Map;":0x2905, + "Mcy;":0x41c, "MediumSpace;":0x205f, + "Mellintrf;":0x2133, "Mfr;":[0xd835,0xdd10], + "MinusPlus;":0x2213, "Mopf;":[0xd835,0xdd44], + "Mscr;":0x2133, "Mu;":0x39c, + "NJcy;":0x40a, "Nacute;":0x143, + "Ncaron;":0x147, "Ncedil;":0x145, + "Ncy;":0x41d, "NegativeMediumSpace;":0x200b, + "NegativeThickSpace;":0x200b, "NegativeThinSpace;":0x200b, + "NegativeVeryThinSpace;":0x200b, "NestedGreaterGreater;":0x226b, + "NestedLessLess;":0x226a, "NewLine;":0xa, + "Nfr;":[0xd835,0xdd11], "NoBreak;":0x2060, + "NonBreakingSpace;":0xa0, "Nopf;":0x2115, + "Not;":0x2aec, "NotCongruent;":0x2262, + "NotCupCap;":0x226d, "NotDoubleVerticalBar;":0x2226, + "NotElement;":0x2209, "NotEqual;":0x2260, + "NotEqualTilde;":[0x2242,0x338], "NotExists;":0x2204, + "NotGreater;":0x226f, "NotGreaterEqual;":0x2271, + "NotGreaterFullEqual;":[0x2267,0x338], "NotGreaterGreater;":[0x226b,0x338], + "NotGreaterLess;":0x2279, "NotGreaterSlantEqual;":[0x2a7e,0x338], + "NotGreaterTilde;":0x2275, "NotHumpDownHump;":[0x224e,0x338], + "NotHumpEqual;":[0x224f,0x338], "NotLeftTriangle;":0x22ea, + "NotLeftTriangleBar;":[0x29cf,0x338], "NotLeftTriangleEqual;":0x22ec, + "NotLess;":0x226e, "NotLessEqual;":0x2270, + "NotLessGreater;":0x2278, "NotLessLess;":[0x226a,0x338], + "NotLessSlantEqual;":[0x2a7d,0x338], "NotLessTilde;":0x2274, + "NotNestedGreaterGreater;":[0x2aa2,0x338], "NotNestedLessLess;":[0x2aa1,0x338], + "NotPrecedes;":0x2280, "NotPrecedesEqual;":[0x2aaf,0x338], + "NotPrecedesSlantEqual;":0x22e0, "NotReverseElement;":0x220c, + "NotRightTriangle;":0x22eb, "NotRightTriangleBar;":[0x29d0,0x338], + "NotRightTriangleEqual;":0x22ed, "NotSquareSubset;":[0x228f,0x338], + "NotSquareSubsetEqual;":0x22e2, "NotSquareSuperset;":[0x2290,0x338], + "NotSquareSupersetEqual;":0x22e3, "NotSubset;":[0x2282,0x20d2], + "NotSubsetEqual;":0x2288, "NotSucceeds;":0x2281, + "NotSucceedsEqual;":[0x2ab0,0x338], "NotSucceedsSlantEqual;":0x22e1, + "NotSucceedsTilde;":[0x227f,0x338], "NotSuperset;":[0x2283,0x20d2], + "NotSupersetEqual;":0x2289, "NotTilde;":0x2241, + "NotTildeEqual;":0x2244, "NotTildeFullEqual;":0x2247, + "NotTildeTilde;":0x2249, "NotVerticalBar;":0x2224, + "Nscr;":[0xd835,0xdca9], "Ntilde":0xd1, + "Ntilde;":0xd1, "Nu;":0x39d, + "OElig;":0x152, "Oacute":0xd3, + "Oacute;":0xd3, "Ocirc":0xd4, + "Ocirc;":0xd4, "Ocy;":0x41e, + "Odblac;":0x150, "Ofr;":[0xd835,0xdd12], + "Ograve":0xd2, "Ograve;":0xd2, + "Omacr;":0x14c, "Omega;":0x3a9, + "Omicron;":0x39f, "Oopf;":[0xd835,0xdd46], + "OpenCurlyDoubleQuote;":0x201c, "OpenCurlyQuote;":0x2018, + "Or;":0x2a54, "Oscr;":[0xd835,0xdcaa], + "Oslash":0xd8, "Oslash;":0xd8, + "Otilde":0xd5, "Otilde;":0xd5, + "Otimes;":0x2a37, "Ouml":0xd6, + "Ouml;":0xd6, "OverBar;":0x203e, + "OverBrace;":0x23de, "OverBracket;":0x23b4, + "OverParenthesis;":0x23dc, "PartialD;":0x2202, + "Pcy;":0x41f, "Pfr;":[0xd835,0xdd13], + "Phi;":0x3a6, "Pi;":0x3a0, + "PlusMinus;":0xb1, "Poincareplane;":0x210c, + "Popf;":0x2119, "Pr;":0x2abb, + "Precedes;":0x227a, "PrecedesEqual;":0x2aaf, + "PrecedesSlantEqual;":0x227c, "PrecedesTilde;":0x227e, + "Prime;":0x2033, "Product;":0x220f, + "Proportion;":0x2237, "Proportional;":0x221d, + "Pscr;":[0xd835,0xdcab], "Psi;":0x3a8, + "QUOT":0x22, "QUOT;":0x22, + "Qfr;":[0xd835,0xdd14], "Qopf;":0x211a, + "Qscr;":[0xd835,0xdcac], "RBarr;":0x2910, + "REG":0xae, "REG;":0xae, + "Racute;":0x154, "Rang;":0x27eb, + "Rarr;":0x21a0, "Rarrtl;":0x2916, + "Rcaron;":0x158, "Rcedil;":0x156, + "Rcy;":0x420, "Re;":0x211c, + "ReverseElement;":0x220b, "ReverseEquilibrium;":0x21cb, + "ReverseUpEquilibrium;":0x296f, "Rfr;":0x211c, + "Rho;":0x3a1, "RightAngleBracket;":0x27e9, + "RightArrow;":0x2192, "RightArrowBar;":0x21e5, + "RightArrowLeftArrow;":0x21c4, "RightCeiling;":0x2309, + "RightDoubleBracket;":0x27e7, "RightDownTeeVector;":0x295d, + "RightDownVector;":0x21c2, "RightDownVectorBar;":0x2955, + "RightFloor;":0x230b, "RightTee;":0x22a2, + "RightTeeArrow;":0x21a6, "RightTeeVector;":0x295b, + "RightTriangle;":0x22b3, "RightTriangleBar;":0x29d0, + "RightTriangleEqual;":0x22b5, "RightUpDownVector;":0x294f, + "RightUpTeeVector;":0x295c, "RightUpVector;":0x21be, + "RightUpVectorBar;":0x2954, "RightVector;":0x21c0, + "RightVectorBar;":0x2953, "Rightarrow;":0x21d2, + "Ropf;":0x211d, "RoundImplies;":0x2970, + "Rrightarrow;":0x21db, "Rscr;":0x211b, + "Rsh;":0x21b1, "RuleDelayed;":0x29f4, + "SHCHcy;":0x429, "SHcy;":0x428, + "SOFTcy;":0x42c, "Sacute;":0x15a, + "Sc;":0x2abc, "Scaron;":0x160, + "Scedil;":0x15e, "Scirc;":0x15c, + "Scy;":0x421, "Sfr;":[0xd835,0xdd16], + "ShortDownArrow;":0x2193, "ShortLeftArrow;":0x2190, + "ShortRightArrow;":0x2192, "ShortUpArrow;":0x2191, + "Sigma;":0x3a3, "SmallCircle;":0x2218, + "Sopf;":[0xd835,0xdd4a], "Sqrt;":0x221a, + "Square;":0x25a1, "SquareIntersection;":0x2293, + "SquareSubset;":0x228f, "SquareSubsetEqual;":0x2291, + "SquareSuperset;":0x2290, "SquareSupersetEqual;":0x2292, + "SquareUnion;":0x2294, "Sscr;":[0xd835,0xdcae], + "Star;":0x22c6, "Sub;":0x22d0, + "Subset;":0x22d0, "SubsetEqual;":0x2286, + "Succeeds;":0x227b, "SucceedsEqual;":0x2ab0, + "SucceedsSlantEqual;":0x227d, "SucceedsTilde;":0x227f, + "SuchThat;":0x220b, "Sum;":0x2211, + "Sup;":0x22d1, "Superset;":0x2283, + "SupersetEqual;":0x2287, "Supset;":0x22d1, + "THORN":0xde, "THORN;":0xde, + "TRADE;":0x2122, "TSHcy;":0x40b, + "TScy;":0x426, "Tab;":0x9, + "Tau;":0x3a4, "Tcaron;":0x164, + "Tcedil;":0x162, "Tcy;":0x422, + "Tfr;":[0xd835,0xdd17], "Therefore;":0x2234, + "Theta;":0x398, "ThickSpace;":[0x205f,0x200a], + "ThinSpace;":0x2009, "Tilde;":0x223c, + "TildeEqual;":0x2243, "TildeFullEqual;":0x2245, + "TildeTilde;":0x2248, "Topf;":[0xd835,0xdd4b], + "TripleDot;":0x20db, "Tscr;":[0xd835,0xdcaf], + "Tstrok;":0x166, "Uacute":0xda, + "Uacute;":0xda, "Uarr;":0x219f, + "Uarrocir;":0x2949, "Ubrcy;":0x40e, + "Ubreve;":0x16c, "Ucirc":0xdb, + "Ucirc;":0xdb, "Ucy;":0x423, + "Udblac;":0x170, "Ufr;":[0xd835,0xdd18], + "Ugrave":0xd9, "Ugrave;":0xd9, + "Umacr;":0x16a, "UnderBar;":0x5f, + "UnderBrace;":0x23df, "UnderBracket;":0x23b5, + "UnderParenthesis;":0x23dd, "Union;":0x22c3, + "UnionPlus;":0x228e, "Uogon;":0x172, + "Uopf;":[0xd835,0xdd4c], "UpArrow;":0x2191, + "UpArrowBar;":0x2912, "UpArrowDownArrow;":0x21c5, + "UpDownArrow;":0x2195, "UpEquilibrium;":0x296e, + "UpTee;":0x22a5, "UpTeeArrow;":0x21a5, + "Uparrow;":0x21d1, "Updownarrow;":0x21d5, + "UpperLeftArrow;":0x2196, "UpperRightArrow;":0x2197, + "Upsi;":0x3d2, "Upsilon;":0x3a5, + "Uring;":0x16e, "Uscr;":[0xd835,0xdcb0], + "Utilde;":0x168, "Uuml":0xdc, + "Uuml;":0xdc, "VDash;":0x22ab, + "Vbar;":0x2aeb, "Vcy;":0x412, + "Vdash;":0x22a9, "Vdashl;":0x2ae6, + "Vee;":0x22c1, "Verbar;":0x2016, + "Vert;":0x2016, "VerticalBar;":0x2223, + "VerticalLine;":0x7c, "VerticalSeparator;":0x2758, + "VerticalTilde;":0x2240, "VeryThinSpace;":0x200a, + "Vfr;":[0xd835,0xdd19], "Vopf;":[0xd835,0xdd4d], + "Vscr;":[0xd835,0xdcb1], "Vvdash;":0x22aa, + "Wcirc;":0x174, "Wedge;":0x22c0, + "Wfr;":[0xd835,0xdd1a], "Wopf;":[0xd835,0xdd4e], + "Wscr;":[0xd835,0xdcb2], "Xfr;":[0xd835,0xdd1b], + "Xi;":0x39e, "Xopf;":[0xd835,0xdd4f], + "Xscr;":[0xd835,0xdcb3], "YAcy;":0x42f, + "YIcy;":0x407, "YUcy;":0x42e, + "Yacute":0xdd, "Yacute;":0xdd, + "Ycirc;":0x176, "Ycy;":0x42b, + "Yfr;":[0xd835,0xdd1c], "Yopf;":[0xd835,0xdd50], + "Yscr;":[0xd835,0xdcb4], "Yuml;":0x178, + "ZHcy;":0x416, "Zacute;":0x179, + "Zcaron;":0x17d, "Zcy;":0x417, + "Zdot;":0x17b, "ZeroWidthSpace;":0x200b, + "Zeta;":0x396, "Zfr;":0x2128, + "Zopf;":0x2124, "Zscr;":[0xd835,0xdcb5], + "aacute":0xe1, "aacute;":0xe1, + "abreve;":0x103, "ac;":0x223e, + "acE;":[0x223e,0x333], "acd;":0x223f, + "acirc":0xe2, "acirc;":0xe2, + "acute":0xb4, "acute;":0xb4, + "acy;":0x430, "aelig":0xe6, + "aelig;":0xe6, "af;":0x2061, + "afr;":[0xd835,0xdd1e], "agrave":0xe0, + "agrave;":0xe0, "alefsym;":0x2135, + "aleph;":0x2135, "alpha;":0x3b1, + "amacr;":0x101, "amalg;":0x2a3f, + "amp":0x26, "amp;":0x26, + "and;":0x2227, "andand;":0x2a55, + "andd;":0x2a5c, "andslope;":0x2a58, + "andv;":0x2a5a, "ang;":0x2220, + "ange;":0x29a4, "angle;":0x2220, + "angmsd;":0x2221, "angmsdaa;":0x29a8, + "angmsdab;":0x29a9, "angmsdac;":0x29aa, + "angmsdad;":0x29ab, "angmsdae;":0x29ac, + "angmsdaf;":0x29ad, "angmsdag;":0x29ae, + "angmsdah;":0x29af, "angrt;":0x221f, + "angrtvb;":0x22be, "angrtvbd;":0x299d, + "angsph;":0x2222, "angst;":0xc5, + "angzarr;":0x237c, "aogon;":0x105, + "aopf;":[0xd835,0xdd52], "ap;":0x2248, + "apE;":0x2a70, "apacir;":0x2a6f, + "ape;":0x224a, "apid;":0x224b, + "apos;":0x27, "approx;":0x2248, + "approxeq;":0x224a, "aring":0xe5, + "aring;":0xe5, "ascr;":[0xd835,0xdcb6], + "ast;":0x2a, "asymp;":0x2248, + "asympeq;":0x224d, "atilde":0xe3, + "atilde;":0xe3, "auml":0xe4, + "auml;":0xe4, "awconint;":0x2233, + "awint;":0x2a11, "bNot;":0x2aed, + "backcong;":0x224c, "backepsilon;":0x3f6, + "backprime;":0x2035, "backsim;":0x223d, + "backsimeq;":0x22cd, "barvee;":0x22bd, + "barwed;":0x2305, "barwedge;":0x2305, + "bbrk;":0x23b5, "bbrktbrk;":0x23b6, + "bcong;":0x224c, "bcy;":0x431, + "bdquo;":0x201e, "becaus;":0x2235, + "because;":0x2235, "bemptyv;":0x29b0, + "bepsi;":0x3f6, "bernou;":0x212c, + "beta;":0x3b2, "beth;":0x2136, + "between;":0x226c, "bfr;":[0xd835,0xdd1f], + "bigcap;":0x22c2, "bigcirc;":0x25ef, + "bigcup;":0x22c3, "bigodot;":0x2a00, + "bigoplus;":0x2a01, "bigotimes;":0x2a02, + "bigsqcup;":0x2a06, "bigstar;":0x2605, + "bigtriangledown;":0x25bd, "bigtriangleup;":0x25b3, + "biguplus;":0x2a04, "bigvee;":0x22c1, + "bigwedge;":0x22c0, "bkarow;":0x290d, + "blacklozenge;":0x29eb, "blacksquare;":0x25aa, + "blacktriangle;":0x25b4, "blacktriangledown;":0x25be, + "blacktriangleleft;":0x25c2, "blacktriangleright;":0x25b8, + "blank;":0x2423, "blk12;":0x2592, + "blk14;":0x2591, "blk34;":0x2593, + "block;":0x2588, "bne;":[0x3d,0x20e5], + "bnequiv;":[0x2261,0x20e5], "bnot;":0x2310, + "bopf;":[0xd835,0xdd53], "bot;":0x22a5, + "bottom;":0x22a5, "bowtie;":0x22c8, + "boxDL;":0x2557, "boxDR;":0x2554, + "boxDl;":0x2556, "boxDr;":0x2553, + "boxH;":0x2550, "boxHD;":0x2566, + "boxHU;":0x2569, "boxHd;":0x2564, + "boxHu;":0x2567, "boxUL;":0x255d, + "boxUR;":0x255a, "boxUl;":0x255c, + "boxUr;":0x2559, "boxV;":0x2551, + "boxVH;":0x256c, "boxVL;":0x2563, + "boxVR;":0x2560, "boxVh;":0x256b, + "boxVl;":0x2562, "boxVr;":0x255f, + "boxbox;":0x29c9, "boxdL;":0x2555, + "boxdR;":0x2552, "boxdl;":0x2510, + "boxdr;":0x250c, "boxh;":0x2500, + "boxhD;":0x2565, "boxhU;":0x2568, + "boxhd;":0x252c, "boxhu;":0x2534, + "boxminus;":0x229f, "boxplus;":0x229e, + "boxtimes;":0x22a0, "boxuL;":0x255b, + "boxuR;":0x2558, "boxul;":0x2518, + "boxur;":0x2514, "boxv;":0x2502, + "boxvH;":0x256a, "boxvL;":0x2561, + "boxvR;":0x255e, "boxvh;":0x253c, + "boxvl;":0x2524, "boxvr;":0x251c, + "bprime;":0x2035, "breve;":0x2d8, + "brvbar":0xa6, "brvbar;":0xa6, + "bscr;":[0xd835,0xdcb7], "bsemi;":0x204f, + "bsim;":0x223d, "bsime;":0x22cd, + "bsol;":0x5c, "bsolb;":0x29c5, + "bsolhsub;":0x27c8, "bull;":0x2022, + "bullet;":0x2022, "bump;":0x224e, + "bumpE;":0x2aae, "bumpe;":0x224f, + "bumpeq;":0x224f, "cacute;":0x107, + "cap;":0x2229, "capand;":0x2a44, + "capbrcup;":0x2a49, "capcap;":0x2a4b, + "capcup;":0x2a47, "capdot;":0x2a40, + "caps;":[0x2229,0xfe00], "caret;":0x2041, + "caron;":0x2c7, "ccaps;":0x2a4d, + "ccaron;":0x10d, "ccedil":0xe7, + "ccedil;":0xe7, "ccirc;":0x109, + "ccups;":0x2a4c, "ccupssm;":0x2a50, + "cdot;":0x10b, "cedil":0xb8, + "cedil;":0xb8, "cemptyv;":0x29b2, + "cent":0xa2, "cent;":0xa2, + "centerdot;":0xb7, "cfr;":[0xd835,0xdd20], + "chcy;":0x447, "check;":0x2713, + "checkmark;":0x2713, "chi;":0x3c7, + "cir;":0x25cb, "cirE;":0x29c3, + "circ;":0x2c6, "circeq;":0x2257, + "circlearrowleft;":0x21ba, "circlearrowright;":0x21bb, + "circledR;":0xae, "circledS;":0x24c8, + "circledast;":0x229b, "circledcirc;":0x229a, + "circleddash;":0x229d, "cire;":0x2257, + "cirfnint;":0x2a10, "cirmid;":0x2aef, + "cirscir;":0x29c2, "clubs;":0x2663, + "clubsuit;":0x2663, "colon;":0x3a, + "colone;":0x2254, "coloneq;":0x2254, + "comma;":0x2c, "commat;":0x40, + "comp;":0x2201, "compfn;":0x2218, + "complement;":0x2201, "complexes;":0x2102, + "cong;":0x2245, "congdot;":0x2a6d, + "conint;":0x222e, "copf;":[0xd835,0xdd54], + "coprod;":0x2210, "copy":0xa9, + "copy;":0xa9, "copysr;":0x2117, + "crarr;":0x21b5, "cross;":0x2717, + "cscr;":[0xd835,0xdcb8], "csub;":0x2acf, + "csube;":0x2ad1, "csup;":0x2ad0, + "csupe;":0x2ad2, "ctdot;":0x22ef, + "cudarrl;":0x2938, "cudarrr;":0x2935, + "cuepr;":0x22de, "cuesc;":0x22df, + "cularr;":0x21b6, "cularrp;":0x293d, + "cup;":0x222a, "cupbrcap;":0x2a48, + "cupcap;":0x2a46, "cupcup;":0x2a4a, + "cupdot;":0x228d, "cupor;":0x2a45, + "cups;":[0x222a,0xfe00], "curarr;":0x21b7, + "curarrm;":0x293c, "curlyeqprec;":0x22de, + "curlyeqsucc;":0x22df, "curlyvee;":0x22ce, + "curlywedge;":0x22cf, "curren":0xa4, + "curren;":0xa4, "curvearrowleft;":0x21b6, + "curvearrowright;":0x21b7, "cuvee;":0x22ce, + "cuwed;":0x22cf, "cwconint;":0x2232, + "cwint;":0x2231, "cylcty;":0x232d, + "dArr;":0x21d3, "dHar;":0x2965, + "dagger;":0x2020, "daleth;":0x2138, + "darr;":0x2193, "dash;":0x2010, + "dashv;":0x22a3, "dbkarow;":0x290f, + "dblac;":0x2dd, "dcaron;":0x10f, + "dcy;":0x434, "dd;":0x2146, + "ddagger;":0x2021, "ddarr;":0x21ca, + "ddotseq;":0x2a77, "deg":0xb0, + "deg;":0xb0, "delta;":0x3b4, + "demptyv;":0x29b1, "dfisht;":0x297f, + "dfr;":[0xd835,0xdd21], "dharl;":0x21c3, + "dharr;":0x21c2, "diam;":0x22c4, + "diamond;":0x22c4, "diamondsuit;":0x2666, + "diams;":0x2666, "die;":0xa8, + "digamma;":0x3dd, "disin;":0x22f2, + "div;":0xf7, "divide":0xf7, + "divide;":0xf7, "divideontimes;":0x22c7, + "divonx;":0x22c7, "djcy;":0x452, + "dlcorn;":0x231e, "dlcrop;":0x230d, + "dollar;":0x24, "dopf;":[0xd835,0xdd55], + "dot;":0x2d9, "doteq;":0x2250, + "doteqdot;":0x2251, "dotminus;":0x2238, + "dotplus;":0x2214, "dotsquare;":0x22a1, + "doublebarwedge;":0x2306, "downarrow;":0x2193, + "downdownarrows;":0x21ca, "downharpoonleft;":0x21c3, + "downharpoonright;":0x21c2, "drbkarow;":0x2910, + "drcorn;":0x231f, "drcrop;":0x230c, + "dscr;":[0xd835,0xdcb9], "dscy;":0x455, + "dsol;":0x29f6, "dstrok;":0x111, + "dtdot;":0x22f1, "dtri;":0x25bf, + "dtrif;":0x25be, "duarr;":0x21f5, + "duhar;":0x296f, "dwangle;":0x29a6, + "dzcy;":0x45f, "dzigrarr;":0x27ff, + "eDDot;":0x2a77, "eDot;":0x2251, + "eacute":0xe9, "eacute;":0xe9, + "easter;":0x2a6e, "ecaron;":0x11b, + "ecir;":0x2256, "ecirc":0xea, + "ecirc;":0xea, "ecolon;":0x2255, + "ecy;":0x44d, "edot;":0x117, + "ee;":0x2147, "efDot;":0x2252, + "efr;":[0xd835,0xdd22], "eg;":0x2a9a, + "egrave":0xe8, "egrave;":0xe8, + "egs;":0x2a96, "egsdot;":0x2a98, + "el;":0x2a99, "elinters;":0x23e7, + "ell;":0x2113, "els;":0x2a95, + "elsdot;":0x2a97, "emacr;":0x113, + "empty;":0x2205, "emptyset;":0x2205, + "emptyv;":0x2205, "emsp13;":0x2004, + "emsp14;":0x2005, "emsp;":0x2003, + "eng;":0x14b, "ensp;":0x2002, + "eogon;":0x119, "eopf;":[0xd835,0xdd56], + "epar;":0x22d5, "eparsl;":0x29e3, + "eplus;":0x2a71, "epsi;":0x3b5, + "epsilon;":0x3b5, "epsiv;":0x3f5, + "eqcirc;":0x2256, "eqcolon;":0x2255, + "eqsim;":0x2242, "eqslantgtr;":0x2a96, + "eqslantless;":0x2a95, "equals;":0x3d, + "equest;":0x225f, "equiv;":0x2261, + "equivDD;":0x2a78, "eqvparsl;":0x29e5, + "erDot;":0x2253, "erarr;":0x2971, + "escr;":0x212f, "esdot;":0x2250, + "esim;":0x2242, "eta;":0x3b7, + "eth":0xf0, "eth;":0xf0, + "euml":0xeb, "euml;":0xeb, + "euro;":0x20ac, "excl;":0x21, + "exist;":0x2203, "expectation;":0x2130, + "exponentiale;":0x2147, "fallingdotseq;":0x2252, + "fcy;":0x444, "female;":0x2640, + "ffilig;":0xfb03, "fflig;":0xfb00, + "ffllig;":0xfb04, "ffr;":[0xd835,0xdd23], + "filig;":0xfb01, "fjlig;":[0x66,0x6a], + "flat;":0x266d, "fllig;":0xfb02, + "fltns;":0x25b1, "fnof;":0x192, + "fopf;":[0xd835,0xdd57], "forall;":0x2200, + "fork;":0x22d4, "forkv;":0x2ad9, + "fpartint;":0x2a0d, "frac12":0xbd, + "frac12;":0xbd, "frac13;":0x2153, + "frac14":0xbc, "frac14;":0xbc, + "frac15;":0x2155, "frac16;":0x2159, + "frac18;":0x215b, "frac23;":0x2154, + "frac25;":0x2156, "frac34":0xbe, + "frac34;":0xbe, "frac35;":0x2157, + "frac38;":0x215c, "frac45;":0x2158, + "frac56;":0x215a, "frac58;":0x215d, + "frac78;":0x215e, "frasl;":0x2044, + "frown;":0x2322, "fscr;":[0xd835,0xdcbb], + "gE;":0x2267, "gEl;":0x2a8c, + "gacute;":0x1f5, "gamma;":0x3b3, + "gammad;":0x3dd, "gap;":0x2a86, + "gbreve;":0x11f, "gcirc;":0x11d, + "gcy;":0x433, "gdot;":0x121, + "ge;":0x2265, "gel;":0x22db, + "geq;":0x2265, "geqq;":0x2267, + "geqslant;":0x2a7e, "ges;":0x2a7e, + "gescc;":0x2aa9, "gesdot;":0x2a80, + "gesdoto;":0x2a82, "gesdotol;":0x2a84, + "gesl;":[0x22db,0xfe00], "gesles;":0x2a94, + "gfr;":[0xd835,0xdd24], "gg;":0x226b, + "ggg;":0x22d9, "gimel;":0x2137, + "gjcy;":0x453, "gl;":0x2277, + "glE;":0x2a92, "gla;":0x2aa5, + "glj;":0x2aa4, "gnE;":0x2269, + "gnap;":0x2a8a, "gnapprox;":0x2a8a, + "gne;":0x2a88, "gneq;":0x2a88, + "gneqq;":0x2269, "gnsim;":0x22e7, + "gopf;":[0xd835,0xdd58], "grave;":0x60, + "gscr;":0x210a, "gsim;":0x2273, + "gsime;":0x2a8e, "gsiml;":0x2a90, + "gt":0x3e, "gt;":0x3e, + "gtcc;":0x2aa7, "gtcir;":0x2a7a, + "gtdot;":0x22d7, "gtlPar;":0x2995, + "gtquest;":0x2a7c, "gtrapprox;":0x2a86, + "gtrarr;":0x2978, "gtrdot;":0x22d7, + "gtreqless;":0x22db, "gtreqqless;":0x2a8c, + "gtrless;":0x2277, "gtrsim;":0x2273, + "gvertneqq;":[0x2269,0xfe00], "gvnE;":[0x2269,0xfe00], + "hArr;":0x21d4, "hairsp;":0x200a, + "half;":0xbd, "hamilt;":0x210b, + "hardcy;":0x44a, "harr;":0x2194, + "harrcir;":0x2948, "harrw;":0x21ad, + "hbar;":0x210f, "hcirc;":0x125, + "hearts;":0x2665, "heartsuit;":0x2665, + "hellip;":0x2026, "hercon;":0x22b9, + "hfr;":[0xd835,0xdd25], "hksearow;":0x2925, + "hkswarow;":0x2926, "hoarr;":0x21ff, + "homtht;":0x223b, "hookleftarrow;":0x21a9, + "hookrightarrow;":0x21aa, "hopf;":[0xd835,0xdd59], + "horbar;":0x2015, "hscr;":[0xd835,0xdcbd], + "hslash;":0x210f, "hstrok;":0x127, + "hybull;":0x2043, "hyphen;":0x2010, + "iacute":0xed, "iacute;":0xed, + "ic;":0x2063, "icirc":0xee, + "icirc;":0xee, "icy;":0x438, + "iecy;":0x435, "iexcl":0xa1, + "iexcl;":0xa1, "iff;":0x21d4, + "ifr;":[0xd835,0xdd26], "igrave":0xec, + "igrave;":0xec, "ii;":0x2148, + "iiiint;":0x2a0c, "iiint;":0x222d, + "iinfin;":0x29dc, "iiota;":0x2129, + "ijlig;":0x133, "imacr;":0x12b, + "image;":0x2111, "imagline;":0x2110, + "imagpart;":0x2111, "imath;":0x131, + "imof;":0x22b7, "imped;":0x1b5, + "in;":0x2208, "incare;":0x2105, + "infin;":0x221e, "infintie;":0x29dd, + "inodot;":0x131, "int;":0x222b, + "intcal;":0x22ba, "integers;":0x2124, + "intercal;":0x22ba, "intlarhk;":0x2a17, + "intprod;":0x2a3c, "iocy;":0x451, + "iogon;":0x12f, "iopf;":[0xd835,0xdd5a], + "iota;":0x3b9, "iprod;":0x2a3c, + "iquest":0xbf, "iquest;":0xbf, + "iscr;":[0xd835,0xdcbe], "isin;":0x2208, + "isinE;":0x22f9, "isindot;":0x22f5, + "isins;":0x22f4, "isinsv;":0x22f3, + "isinv;":0x2208, "it;":0x2062, + "itilde;":0x129, "iukcy;":0x456, + "iuml":0xef, "iuml;":0xef, + "jcirc;":0x135, "jcy;":0x439, + "jfr;":[0xd835,0xdd27], "jmath;":0x237, + "jopf;":[0xd835,0xdd5b], "jscr;":[0xd835,0xdcbf], + "jsercy;":0x458, "jukcy;":0x454, + "kappa;":0x3ba, "kappav;":0x3f0, + "kcedil;":0x137, "kcy;":0x43a, + "kfr;":[0xd835,0xdd28], "kgreen;":0x138, + "khcy;":0x445, "kjcy;":0x45c, + "kopf;":[0xd835,0xdd5c], "kscr;":[0xd835,0xdcc0], + "lAarr;":0x21da, "lArr;":0x21d0, + "lAtail;":0x291b, "lBarr;":0x290e, + "lE;":0x2266, "lEg;":0x2a8b, + "lHar;":0x2962, "lacute;":0x13a, + "laemptyv;":0x29b4, "lagran;":0x2112, + "lambda;":0x3bb, "lang;":0x27e8, + "langd;":0x2991, "langle;":0x27e8, + "lap;":0x2a85, "laquo":0xab, + "laquo;":0xab, "larr;":0x2190, + "larrb;":0x21e4, "larrbfs;":0x291f, + "larrfs;":0x291d, "larrhk;":0x21a9, + "larrlp;":0x21ab, "larrpl;":0x2939, + "larrsim;":0x2973, "larrtl;":0x21a2, + "lat;":0x2aab, "latail;":0x2919, + "late;":0x2aad, "lates;":[0x2aad,0xfe00], + "lbarr;":0x290c, "lbbrk;":0x2772, + "lbrace;":0x7b, "lbrack;":0x5b, + "lbrke;":0x298b, "lbrksld;":0x298f, + "lbrkslu;":0x298d, "lcaron;":0x13e, + "lcedil;":0x13c, "lceil;":0x2308, + "lcub;":0x7b, "lcy;":0x43b, + "ldca;":0x2936, "ldquo;":0x201c, + "ldquor;":0x201e, "ldrdhar;":0x2967, + "ldrushar;":0x294b, "ldsh;":0x21b2, + "le;":0x2264, "leftarrow;":0x2190, + "leftarrowtail;":0x21a2, "leftharpoondown;":0x21bd, + "leftharpoonup;":0x21bc, "leftleftarrows;":0x21c7, + "leftrightarrow;":0x2194, "leftrightarrows;":0x21c6, + "leftrightharpoons;":0x21cb, "leftrightsquigarrow;":0x21ad, + "leftthreetimes;":0x22cb, "leg;":0x22da, + "leq;":0x2264, "leqq;":0x2266, + "leqslant;":0x2a7d, "les;":0x2a7d, + "lescc;":0x2aa8, "lesdot;":0x2a7f, + "lesdoto;":0x2a81, "lesdotor;":0x2a83, + "lesg;":[0x22da,0xfe00], "lesges;":0x2a93, + "lessapprox;":0x2a85, "lessdot;":0x22d6, + "lesseqgtr;":0x22da, "lesseqqgtr;":0x2a8b, + "lessgtr;":0x2276, "lesssim;":0x2272, + "lfisht;":0x297c, "lfloor;":0x230a, + "lfr;":[0xd835,0xdd29], "lg;":0x2276, + "lgE;":0x2a91, "lhard;":0x21bd, + "lharu;":0x21bc, "lharul;":0x296a, + "lhblk;":0x2584, "ljcy;":0x459, + "ll;":0x226a, "llarr;":0x21c7, + "llcorner;":0x231e, "llhard;":0x296b, + "lltri;":0x25fa, "lmidot;":0x140, + "lmoust;":0x23b0, "lmoustache;":0x23b0, + "lnE;":0x2268, "lnap;":0x2a89, + "lnapprox;":0x2a89, "lne;":0x2a87, + "lneq;":0x2a87, "lneqq;":0x2268, + "lnsim;":0x22e6, "loang;":0x27ec, + "loarr;":0x21fd, "lobrk;":0x27e6, + "longleftarrow;":0x27f5, "longleftrightarrow;":0x27f7, + "longmapsto;":0x27fc, "longrightarrow;":0x27f6, + "looparrowleft;":0x21ab, "looparrowright;":0x21ac, + "lopar;":0x2985, "lopf;":[0xd835,0xdd5d], + "loplus;":0x2a2d, "lotimes;":0x2a34, + "lowast;":0x2217, "lowbar;":0x5f, + "loz;":0x25ca, "lozenge;":0x25ca, + "lozf;":0x29eb, "lpar;":0x28, + "lparlt;":0x2993, "lrarr;":0x21c6, + "lrcorner;":0x231f, "lrhar;":0x21cb, + "lrhard;":0x296d, "lrm;":0x200e, + "lrtri;":0x22bf, "lsaquo;":0x2039, + "lscr;":[0xd835,0xdcc1], "lsh;":0x21b0, + "lsim;":0x2272, "lsime;":0x2a8d, + "lsimg;":0x2a8f, "lsqb;":0x5b, + "lsquo;":0x2018, "lsquor;":0x201a, + "lstrok;":0x142, "lt":0x3c, + "lt;":0x3c, "ltcc;":0x2aa6, + "ltcir;":0x2a79, "ltdot;":0x22d6, + "lthree;":0x22cb, "ltimes;":0x22c9, + "ltlarr;":0x2976, "ltquest;":0x2a7b, + "ltrPar;":0x2996, "ltri;":0x25c3, + "ltrie;":0x22b4, "ltrif;":0x25c2, + "lurdshar;":0x294a, "luruhar;":0x2966, + "lvertneqq;":[0x2268,0xfe00], "lvnE;":[0x2268,0xfe00], + "mDDot;":0x223a, "macr":0xaf, + "macr;":0xaf, "male;":0x2642, + "malt;":0x2720, "maltese;":0x2720, + "map;":0x21a6, "mapsto;":0x21a6, + "mapstodown;":0x21a7, "mapstoleft;":0x21a4, + "mapstoup;":0x21a5, "marker;":0x25ae, + "mcomma;":0x2a29, "mcy;":0x43c, + "mdash;":0x2014, "measuredangle;":0x2221, + "mfr;":[0xd835,0xdd2a], "mho;":0x2127, + "micro":0xb5, "micro;":0xb5, + "mid;":0x2223, "midast;":0x2a, + "midcir;":0x2af0, "middot":0xb7, + "middot;":0xb7, "minus;":0x2212, + "minusb;":0x229f, "minusd;":0x2238, + "minusdu;":0x2a2a, "mlcp;":0x2adb, + "mldr;":0x2026, "mnplus;":0x2213, + "models;":0x22a7, "mopf;":[0xd835,0xdd5e], + "mp;":0x2213, "mscr;":[0xd835,0xdcc2], + "mstpos;":0x223e, "mu;":0x3bc, + "multimap;":0x22b8, "mumap;":0x22b8, + "nGg;":[0x22d9,0x338], "nGt;":[0x226b,0x20d2], + "nGtv;":[0x226b,0x338], "nLeftarrow;":0x21cd, + "nLeftrightarrow;":0x21ce, "nLl;":[0x22d8,0x338], + "nLt;":[0x226a,0x20d2], "nLtv;":[0x226a,0x338], + "nRightarrow;":0x21cf, "nVDash;":0x22af, + "nVdash;":0x22ae, "nabla;":0x2207, + "nacute;":0x144, "nang;":[0x2220,0x20d2], + "nap;":0x2249, "napE;":[0x2a70,0x338], + "napid;":[0x224b,0x338], "napos;":0x149, + "napprox;":0x2249, "natur;":0x266e, + "natural;":0x266e, "naturals;":0x2115, + "nbsp":0xa0, "nbsp;":0xa0, + "nbump;":[0x224e,0x338], "nbumpe;":[0x224f,0x338], + "ncap;":0x2a43, "ncaron;":0x148, + "ncedil;":0x146, "ncong;":0x2247, + "ncongdot;":[0x2a6d,0x338], "ncup;":0x2a42, + "ncy;":0x43d, "ndash;":0x2013, + "ne;":0x2260, "neArr;":0x21d7, + "nearhk;":0x2924, "nearr;":0x2197, + "nearrow;":0x2197, "nedot;":[0x2250,0x338], + "nequiv;":0x2262, "nesear;":0x2928, + "nesim;":[0x2242,0x338], "nexist;":0x2204, + "nexists;":0x2204, "nfr;":[0xd835,0xdd2b], + "ngE;":[0x2267,0x338], "nge;":0x2271, + "ngeq;":0x2271, "ngeqq;":[0x2267,0x338], + "ngeqslant;":[0x2a7e,0x338], "nges;":[0x2a7e,0x338], + "ngsim;":0x2275, "ngt;":0x226f, + "ngtr;":0x226f, "nhArr;":0x21ce, + "nharr;":0x21ae, "nhpar;":0x2af2, + "ni;":0x220b, "nis;":0x22fc, + "nisd;":0x22fa, "niv;":0x220b, + "njcy;":0x45a, "nlArr;":0x21cd, + "nlE;":[0x2266,0x338], "nlarr;":0x219a, + "nldr;":0x2025, "nle;":0x2270, + "nleftarrow;":0x219a, "nleftrightarrow;":0x21ae, + "nleq;":0x2270, "nleqq;":[0x2266,0x338], + "nleqslant;":[0x2a7d,0x338], "nles;":[0x2a7d,0x338], + "nless;":0x226e, "nlsim;":0x2274, + "nlt;":0x226e, "nltri;":0x22ea, + "nltrie;":0x22ec, "nmid;":0x2224, + "nopf;":[0xd835,0xdd5f], "not":0xac, + "not;":0xac, "notin;":0x2209, + "notinE;":[0x22f9,0x338], "notindot;":[0x22f5,0x338], + "notinva;":0x2209, "notinvb;":0x22f7, + "notinvc;":0x22f6, "notni;":0x220c, + "notniva;":0x220c, "notnivb;":0x22fe, + "notnivc;":0x22fd, "npar;":0x2226, + "nparallel;":0x2226, "nparsl;":[0x2afd,0x20e5], + "npart;":[0x2202,0x338], "npolint;":0x2a14, + "npr;":0x2280, "nprcue;":0x22e0, + "npre;":[0x2aaf,0x338], "nprec;":0x2280, + "npreceq;":[0x2aaf,0x338], "nrArr;":0x21cf, + "nrarr;":0x219b, "nrarrc;":[0x2933,0x338], + "nrarrw;":[0x219d,0x338], "nrightarrow;":0x219b, + "nrtri;":0x22eb, "nrtrie;":0x22ed, + "nsc;":0x2281, "nsccue;":0x22e1, + "nsce;":[0x2ab0,0x338], "nscr;":[0xd835,0xdcc3], + "nshortmid;":0x2224, "nshortparallel;":0x2226, + "nsim;":0x2241, "nsime;":0x2244, + "nsimeq;":0x2244, "nsmid;":0x2224, + "nspar;":0x2226, "nsqsube;":0x22e2, + "nsqsupe;":0x22e3, "nsub;":0x2284, + "nsubE;":[0x2ac5,0x338], "nsube;":0x2288, + "nsubset;":[0x2282,0x20d2], "nsubseteq;":0x2288, + "nsubseteqq;":[0x2ac5,0x338], "nsucc;":0x2281, + "nsucceq;":[0x2ab0,0x338], "nsup;":0x2285, + "nsupE;":[0x2ac6,0x338], "nsupe;":0x2289, + "nsupset;":[0x2283,0x20d2], "nsupseteq;":0x2289, + "nsupseteqq;":[0x2ac6,0x338], "ntgl;":0x2279, + "ntilde":0xf1, "ntilde;":0xf1, + "ntlg;":0x2278, "ntriangleleft;":0x22ea, + "ntrianglelefteq;":0x22ec, "ntriangleright;":0x22eb, + "ntrianglerighteq;":0x22ed, "nu;":0x3bd, + "num;":0x23, "numero;":0x2116, + "numsp;":0x2007, "nvDash;":0x22ad, + "nvHarr;":0x2904, "nvap;":[0x224d,0x20d2], + "nvdash;":0x22ac, "nvge;":[0x2265,0x20d2], + "nvgt;":[0x3e,0x20d2], "nvinfin;":0x29de, + "nvlArr;":0x2902, "nvle;":[0x2264,0x20d2], + "nvlt;":[0x3c,0x20d2], "nvltrie;":[0x22b4,0x20d2], + "nvrArr;":0x2903, "nvrtrie;":[0x22b5,0x20d2], + "nvsim;":[0x223c,0x20d2], "nwArr;":0x21d6, + "nwarhk;":0x2923, "nwarr;":0x2196, + "nwarrow;":0x2196, "nwnear;":0x2927, + "oS;":0x24c8, "oacute":0xf3, + "oacute;":0xf3, "oast;":0x229b, + "ocir;":0x229a, "ocirc":0xf4, + "ocirc;":0xf4, "ocy;":0x43e, + "odash;":0x229d, "odblac;":0x151, + "odiv;":0x2a38, "odot;":0x2299, + "odsold;":0x29bc, "oelig;":0x153, + "ofcir;":0x29bf, "ofr;":[0xd835,0xdd2c], + "ogon;":0x2db, "ograve":0xf2, + "ograve;":0xf2, "ogt;":0x29c1, + "ohbar;":0x29b5, "ohm;":0x3a9, + "oint;":0x222e, "olarr;":0x21ba, + "olcir;":0x29be, "olcross;":0x29bb, + "oline;":0x203e, "olt;":0x29c0, + "omacr;":0x14d, "omega;":0x3c9, + "omicron;":0x3bf, "omid;":0x29b6, + "ominus;":0x2296, "oopf;":[0xd835,0xdd60], + "opar;":0x29b7, "operp;":0x29b9, + "oplus;":0x2295, "or;":0x2228, + "orarr;":0x21bb, "ord;":0x2a5d, + "order;":0x2134, "orderof;":0x2134, + "ordf":0xaa, "ordf;":0xaa, + "ordm":0xba, "ordm;":0xba, + "origof;":0x22b6, "oror;":0x2a56, + "orslope;":0x2a57, "orv;":0x2a5b, + "oscr;":0x2134, "oslash":0xf8, + "oslash;":0xf8, "osol;":0x2298, + "otilde":0xf5, "otilde;":0xf5, + "otimes;":0x2297, "otimesas;":0x2a36, + "ouml":0xf6, "ouml;":0xf6, + "ovbar;":0x233d, "par;":0x2225, + "para":0xb6, "para;":0xb6, + "parallel;":0x2225, "parsim;":0x2af3, + "parsl;":0x2afd, "part;":0x2202, + "pcy;":0x43f, "percnt;":0x25, + "period;":0x2e, "permil;":0x2030, + "perp;":0x22a5, "pertenk;":0x2031, + "pfr;":[0xd835,0xdd2d], "phi;":0x3c6, + "phiv;":0x3d5, "phmmat;":0x2133, + "phone;":0x260e, "pi;":0x3c0, + "pitchfork;":0x22d4, "piv;":0x3d6, + "planck;":0x210f, "planckh;":0x210e, + "plankv;":0x210f, "plus;":0x2b, + "plusacir;":0x2a23, "plusb;":0x229e, + "pluscir;":0x2a22, "plusdo;":0x2214, + "plusdu;":0x2a25, "pluse;":0x2a72, + "plusmn":0xb1, "plusmn;":0xb1, + "plussim;":0x2a26, "plustwo;":0x2a27, + "pm;":0xb1, "pointint;":0x2a15, + "popf;":[0xd835,0xdd61], "pound":0xa3, + "pound;":0xa3, "pr;":0x227a, + "prE;":0x2ab3, "prap;":0x2ab7, + "prcue;":0x227c, "pre;":0x2aaf, + "prec;":0x227a, "precapprox;":0x2ab7, + "preccurlyeq;":0x227c, "preceq;":0x2aaf, + "precnapprox;":0x2ab9, "precneqq;":0x2ab5, + "precnsim;":0x22e8, "precsim;":0x227e, + "prime;":0x2032, "primes;":0x2119, + "prnE;":0x2ab5, "prnap;":0x2ab9, + "prnsim;":0x22e8, "prod;":0x220f, + "profalar;":0x232e, "profline;":0x2312, + "profsurf;":0x2313, "prop;":0x221d, + "propto;":0x221d, "prsim;":0x227e, + "prurel;":0x22b0, "pscr;":[0xd835,0xdcc5], + "psi;":0x3c8, "puncsp;":0x2008, + "qfr;":[0xd835,0xdd2e], "qint;":0x2a0c, + "qopf;":[0xd835,0xdd62], "qprime;":0x2057, + "qscr;":[0xd835,0xdcc6], "quaternions;":0x210d, + "quatint;":0x2a16, "quest;":0x3f, + "questeq;":0x225f, "quot":0x22, + "quot;":0x22, "rAarr;":0x21db, + "rArr;":0x21d2, "rAtail;":0x291c, + "rBarr;":0x290f, "rHar;":0x2964, + "race;":[0x223d,0x331], "racute;":0x155, + "radic;":0x221a, "raemptyv;":0x29b3, + "rang;":0x27e9, "rangd;":0x2992, + "range;":0x29a5, "rangle;":0x27e9, + "raquo":0xbb, "raquo;":0xbb, + "rarr;":0x2192, "rarrap;":0x2975, + "rarrb;":0x21e5, "rarrbfs;":0x2920, + "rarrc;":0x2933, "rarrfs;":0x291e, + "rarrhk;":0x21aa, "rarrlp;":0x21ac, + "rarrpl;":0x2945, "rarrsim;":0x2974, + "rarrtl;":0x21a3, "rarrw;":0x219d, + "ratail;":0x291a, "ratio;":0x2236, + "rationals;":0x211a, "rbarr;":0x290d, + "rbbrk;":0x2773, "rbrace;":0x7d, + "rbrack;":0x5d, "rbrke;":0x298c, + "rbrksld;":0x298e, "rbrkslu;":0x2990, + "rcaron;":0x159, "rcedil;":0x157, + "rceil;":0x2309, "rcub;":0x7d, + "rcy;":0x440, "rdca;":0x2937, + "rdldhar;":0x2969, "rdquo;":0x201d, + "rdquor;":0x201d, "rdsh;":0x21b3, + "real;":0x211c, "realine;":0x211b, + "realpart;":0x211c, "reals;":0x211d, + "rect;":0x25ad, "reg":0xae, + "reg;":0xae, "rfisht;":0x297d, + "rfloor;":0x230b, "rfr;":[0xd835,0xdd2f], + "rhard;":0x21c1, "rharu;":0x21c0, + "rharul;":0x296c, "rho;":0x3c1, + "rhov;":0x3f1, "rightarrow;":0x2192, + "rightarrowtail;":0x21a3, "rightharpoondown;":0x21c1, + "rightharpoonup;":0x21c0, "rightleftarrows;":0x21c4, + "rightleftharpoons;":0x21cc, "rightrightarrows;":0x21c9, + "rightsquigarrow;":0x219d, "rightthreetimes;":0x22cc, + "ring;":0x2da, "risingdotseq;":0x2253, + "rlarr;":0x21c4, "rlhar;":0x21cc, + "rlm;":0x200f, "rmoust;":0x23b1, + "rmoustache;":0x23b1, "rnmid;":0x2aee, + "roang;":0x27ed, "roarr;":0x21fe, + "robrk;":0x27e7, "ropar;":0x2986, + "ropf;":[0xd835,0xdd63], "roplus;":0x2a2e, + "rotimes;":0x2a35, "rpar;":0x29, + "rpargt;":0x2994, "rppolint;":0x2a12, + "rrarr;":0x21c9, "rsaquo;":0x203a, + "rscr;":[0xd835,0xdcc7], "rsh;":0x21b1, + "rsqb;":0x5d, "rsquo;":0x2019, + "rsquor;":0x2019, "rthree;":0x22cc, + "rtimes;":0x22ca, "rtri;":0x25b9, + "rtrie;":0x22b5, "rtrif;":0x25b8, + "rtriltri;":0x29ce, "ruluhar;":0x2968, + "rx;":0x211e, "sacute;":0x15b, + "sbquo;":0x201a, "sc;":0x227b, + "scE;":0x2ab4, "scap;":0x2ab8, + "scaron;":0x161, "sccue;":0x227d, + "sce;":0x2ab0, "scedil;":0x15f, + "scirc;":0x15d, "scnE;":0x2ab6, + "scnap;":0x2aba, "scnsim;":0x22e9, + "scpolint;":0x2a13, "scsim;":0x227f, + "scy;":0x441, "sdot;":0x22c5, + "sdotb;":0x22a1, "sdote;":0x2a66, + "seArr;":0x21d8, "searhk;":0x2925, + "searr;":0x2198, "searrow;":0x2198, + "sect":0xa7, "sect;":0xa7, + "semi;":0x3b, "seswar;":0x2929, + "setminus;":0x2216, "setmn;":0x2216, + "sext;":0x2736, "sfr;":[0xd835,0xdd30], + "sfrown;":0x2322, "sharp;":0x266f, + "shchcy;":0x449, "shcy;":0x448, + "shortmid;":0x2223, "shortparallel;":0x2225, + "shy":0xad, "shy;":0xad, + "sigma;":0x3c3, "sigmaf;":0x3c2, + "sigmav;":0x3c2, "sim;":0x223c, + "simdot;":0x2a6a, "sime;":0x2243, + "simeq;":0x2243, "simg;":0x2a9e, + "simgE;":0x2aa0, "siml;":0x2a9d, + "simlE;":0x2a9f, "simne;":0x2246, + "simplus;":0x2a24, "simrarr;":0x2972, + "slarr;":0x2190, "smallsetminus;":0x2216, + "smashp;":0x2a33, "smeparsl;":0x29e4, + "smid;":0x2223, "smile;":0x2323, + "smt;":0x2aaa, "smte;":0x2aac, + "smtes;":[0x2aac,0xfe00], "softcy;":0x44c, + "sol;":0x2f, "solb;":0x29c4, + "solbar;":0x233f, "sopf;":[0xd835,0xdd64], + "spades;":0x2660, "spadesuit;":0x2660, + "spar;":0x2225, "sqcap;":0x2293, + "sqcaps;":[0x2293,0xfe00], "sqcup;":0x2294, + "sqcups;":[0x2294,0xfe00], "sqsub;":0x228f, + "sqsube;":0x2291, "sqsubset;":0x228f, + "sqsubseteq;":0x2291, "sqsup;":0x2290, + "sqsupe;":0x2292, "sqsupset;":0x2290, + "sqsupseteq;":0x2292, "squ;":0x25a1, + "square;":0x25a1, "squarf;":0x25aa, + "squf;":0x25aa, "srarr;":0x2192, + "sscr;":[0xd835,0xdcc8], "ssetmn;":0x2216, + "ssmile;":0x2323, "sstarf;":0x22c6, + "star;":0x2606, "starf;":0x2605, + "straightepsilon;":0x3f5, "straightphi;":0x3d5, + "strns;":0xaf, "sub;":0x2282, + "subE;":0x2ac5, "subdot;":0x2abd, + "sube;":0x2286, "subedot;":0x2ac3, + "submult;":0x2ac1, "subnE;":0x2acb, + "subne;":0x228a, "subplus;":0x2abf, + "subrarr;":0x2979, "subset;":0x2282, + "subseteq;":0x2286, "subseteqq;":0x2ac5, + "subsetneq;":0x228a, "subsetneqq;":0x2acb, + "subsim;":0x2ac7, "subsub;":0x2ad5, + "subsup;":0x2ad3, "succ;":0x227b, + "succapprox;":0x2ab8, "succcurlyeq;":0x227d, + "succeq;":0x2ab0, "succnapprox;":0x2aba, + "succneqq;":0x2ab6, "succnsim;":0x22e9, + "succsim;":0x227f, "sum;":0x2211, + "sung;":0x266a, "sup1":0xb9, + "sup1;":0xb9, "sup2":0xb2, + "sup2;":0xb2, "sup3":0xb3, + "sup3;":0xb3, "sup;":0x2283, + "supE;":0x2ac6, "supdot;":0x2abe, + "supdsub;":0x2ad8, "supe;":0x2287, + "supedot;":0x2ac4, "suphsol;":0x27c9, + "suphsub;":0x2ad7, "suplarr;":0x297b, + "supmult;":0x2ac2, "supnE;":0x2acc, + "supne;":0x228b, "supplus;":0x2ac0, + "supset;":0x2283, "supseteq;":0x2287, + "supseteqq;":0x2ac6, "supsetneq;":0x228b, + "supsetneqq;":0x2acc, "supsim;":0x2ac8, + "supsub;":0x2ad4, "supsup;":0x2ad6, + "swArr;":0x21d9, "swarhk;":0x2926, + "swarr;":0x2199, "swarrow;":0x2199, + "swnwar;":0x292a, "szlig":0xdf, + "szlig;":0xdf, "target;":0x2316, + "tau;":0x3c4, "tbrk;":0x23b4, + "tcaron;":0x165, "tcedil;":0x163, + "tcy;":0x442, "tdot;":0x20db, + "telrec;":0x2315, "tfr;":[0xd835,0xdd31], + "there4;":0x2234, "therefore;":0x2234, + "theta;":0x3b8, "thetasym;":0x3d1, + "thetav;":0x3d1, "thickapprox;":0x2248, + "thicksim;":0x223c, "thinsp;":0x2009, + "thkap;":0x2248, "thksim;":0x223c, + "thorn":0xfe, "thorn;":0xfe, + "tilde;":0x2dc, "times":0xd7, + "times;":0xd7, "timesb;":0x22a0, + "timesbar;":0x2a31, "timesd;":0x2a30, + "tint;":0x222d, "toea;":0x2928, + "top;":0x22a4, "topbot;":0x2336, + "topcir;":0x2af1, "topf;":[0xd835,0xdd65], + "topfork;":0x2ada, "tosa;":0x2929, + "tprime;":0x2034, "trade;":0x2122, + "triangle;":0x25b5, "triangledown;":0x25bf, + "triangleleft;":0x25c3, "trianglelefteq;":0x22b4, + "triangleq;":0x225c, "triangleright;":0x25b9, + "trianglerighteq;":0x22b5, "tridot;":0x25ec, + "trie;":0x225c, "triminus;":0x2a3a, + "triplus;":0x2a39, "trisb;":0x29cd, + "tritime;":0x2a3b, "trpezium;":0x23e2, + "tscr;":[0xd835,0xdcc9], "tscy;":0x446, + "tshcy;":0x45b, "tstrok;":0x167, + "twixt;":0x226c, "twoheadleftarrow;":0x219e, + "twoheadrightarrow;":0x21a0, "uArr;":0x21d1, + "uHar;":0x2963, "uacute":0xfa, + "uacute;":0xfa, "uarr;":0x2191, + "ubrcy;":0x45e, "ubreve;":0x16d, + "ucirc":0xfb, "ucirc;":0xfb, + "ucy;":0x443, "udarr;":0x21c5, + "udblac;":0x171, "udhar;":0x296e, + "ufisht;":0x297e, "ufr;":[0xd835,0xdd32], + "ugrave":0xf9, "ugrave;":0xf9, + "uharl;":0x21bf, "uharr;":0x21be, + "uhblk;":0x2580, "ulcorn;":0x231c, + "ulcorner;":0x231c, "ulcrop;":0x230f, + "ultri;":0x25f8, "umacr;":0x16b, + "uml":0xa8, "uml;":0xa8, + "uogon;":0x173, "uopf;":[0xd835,0xdd66], + "uparrow;":0x2191, "updownarrow;":0x2195, + "upharpoonleft;":0x21bf, "upharpoonright;":0x21be, + "uplus;":0x228e, "upsi;":0x3c5, + "upsih;":0x3d2, "upsilon;":0x3c5, + "upuparrows;":0x21c8, "urcorn;":0x231d, + "urcorner;":0x231d, "urcrop;":0x230e, + "uring;":0x16f, "urtri;":0x25f9, + "uscr;":[0xd835,0xdcca], "utdot;":0x22f0, + "utilde;":0x169, "utri;":0x25b5, + "utrif;":0x25b4, "uuarr;":0x21c8, + "uuml":0xfc, "uuml;":0xfc, + "uwangle;":0x29a7, "vArr;":0x21d5, + "vBar;":0x2ae8, "vBarv;":0x2ae9, + "vDash;":0x22a8, "vangrt;":0x299c, + "varepsilon;":0x3f5, "varkappa;":0x3f0, + "varnothing;":0x2205, "varphi;":0x3d5, + "varpi;":0x3d6, "varpropto;":0x221d, + "varr;":0x2195, "varrho;":0x3f1, + "varsigma;":0x3c2, "varsubsetneq;":[0x228a,0xfe00], + "varsubsetneqq;":[0x2acb,0xfe00], "varsupsetneq;":[0x228b,0xfe00], + "varsupsetneqq;":[0x2acc,0xfe00], "vartheta;":0x3d1, + "vartriangleleft;":0x22b2, "vartriangleright;":0x22b3, + "vcy;":0x432, "vdash;":0x22a2, + "vee;":0x2228, "veebar;":0x22bb, + "veeeq;":0x225a, "vellip;":0x22ee, + "verbar;":0x7c, "vert;":0x7c, + "vfr;":[0xd835,0xdd33], "vltri;":0x22b2, + "vnsub;":[0x2282,0x20d2], "vnsup;":[0x2283,0x20d2], + "vopf;":[0xd835,0xdd67], "vprop;":0x221d, + "vrtri;":0x22b3, "vscr;":[0xd835,0xdccb], + "vsubnE;":[0x2acb,0xfe00], "vsubne;":[0x228a,0xfe00], + "vsupnE;":[0x2acc,0xfe00], "vsupne;":[0x228b,0xfe00], + "vzigzag;":0x299a, "wcirc;":0x175, + "wedbar;":0x2a5f, "wedge;":0x2227, + "wedgeq;":0x2259, "weierp;":0x2118, + "wfr;":[0xd835,0xdd34], "wopf;":[0xd835,0xdd68], + "wp;":0x2118, "wr;":0x2240, + "wreath;":0x2240, "wscr;":[0xd835,0xdccc], + "xcap;":0x22c2, "xcirc;":0x25ef, + "xcup;":0x22c3, "xdtri;":0x25bd, + "xfr;":[0xd835,0xdd35], "xhArr;":0x27fa, + "xharr;":0x27f7, "xi;":0x3be, + "xlArr;":0x27f8, "xlarr;":0x27f5, + "xmap;":0x27fc, "xnis;":0x22fb, + "xodot;":0x2a00, "xopf;":[0xd835,0xdd69], + "xoplus;":0x2a01, "xotime;":0x2a02, + "xrArr;":0x27f9, "xrarr;":0x27f6, + "xscr;":[0xd835,0xdccd], "xsqcup;":0x2a06, + "xuplus;":0x2a04, "xutri;":0x25b3, + "xvee;":0x22c1, "xwedge;":0x22c0, + "yacute":0xfd, "yacute;":0xfd, + "yacy;":0x44f, "ycirc;":0x177, + "ycy;":0x44b, "yen":0xa5, + "yen;":0xa5, "yfr;":[0xd835,0xdd36], + "yicy;":0x457, "yopf;":[0xd835,0xdd6a], + "yscr;":[0xd835,0xdcce], "yucy;":0x44e, + "yuml":0xff, "yuml;":0xff, + "zacute;":0x17a, "zcaron;":0x17e, + "zcy;":0x437, "zdot;":0x17c, + "zeetrf;":0x2128, "zeta;":0x3b6, + "zfr;":[0xd835,0xdd37], "zhcy;":0x436, + "zigrarr;":0x21dd, "zopf;":[0xd835,0xdd6b], + "zscr;":[0xd835,0xdccf], "zwj;":0x200d, + "zwnj;":0x200c, }; +/* + * This regexp is generated with test/tools/update-entities.js + * It will always match at least one character -- but note that there + * are no entities whose names are a single character long. + */ +var NAMEDCHARREF = /(A(?:Elig;?|MP;?|acute;?|breve;|c(?:irc;?|y;)|fr;|grave;?|lpha;|macr;|nd;|o(?:gon;|pf;)|pplyFunction;|ring;?|s(?:cr;|sign;)|tilde;?|uml;?)|B(?:a(?:ckslash;|r(?:v;|wed;))|cy;|e(?:cause;|rnoullis;|ta;)|fr;|opf;|reve;|scr;|umpeq;)|C(?:Hcy;|OPY;?|a(?:cute;|p(?:;|italDifferentialD;)|yleys;)|c(?:aron;|edil;?|irc;|onint;)|dot;|e(?:dilla;|nterDot;)|fr;|hi;|ircle(?:Dot;|Minus;|Plus;|Times;)|lo(?:ckwiseContourIntegral;|seCurly(?:DoubleQuote;|Quote;))|o(?:lon(?:;|e;)|n(?:gruent;|int;|tourIntegral;)|p(?:f;|roduct;)|unterClockwiseContourIntegral;)|ross;|scr;|up(?:;|Cap;))|D(?:D(?:;|otrahd;)|Jcy;|Scy;|Zcy;|a(?:gger;|rr;|shv;)|c(?:aron;|y;)|el(?:;|ta;)|fr;|i(?:a(?:critical(?:Acute;|Do(?:t;|ubleAcute;)|Grave;|Tilde;)|mond;)|fferentialD;)|o(?:pf;|t(?:;|Dot;|Equal;)|uble(?:ContourIntegral;|Do(?:t;|wnArrow;)|L(?:eft(?:Arrow;|RightArrow;|Tee;)|ong(?:Left(?:Arrow;|RightArrow;)|RightArrow;))|Right(?:Arrow;|Tee;)|Up(?:Arrow;|DownArrow;)|VerticalBar;)|wn(?:Arrow(?:;|Bar;|UpArrow;)|Breve;|Left(?:RightVector;|TeeVector;|Vector(?:;|Bar;))|Right(?:TeeVector;|Vector(?:;|Bar;))|Tee(?:;|Arrow;)|arrow;))|s(?:cr;|trok;))|E(?:NG;|TH;?|acute;?|c(?:aron;|irc;?|y;)|dot;|fr;|grave;?|lement;|m(?:acr;|pty(?:SmallSquare;|VerySmallSquare;))|o(?:gon;|pf;)|psilon;|qu(?:al(?:;|Tilde;)|ilibrium;)|s(?:cr;|im;)|ta;|uml;?|x(?:ists;|ponentialE;))|F(?:cy;|fr;|illed(?:SmallSquare;|VerySmallSquare;)|o(?:pf;|rAll;|uriertrf;)|scr;)|G(?:Jcy;|T;?|amma(?:;|d;)|breve;|c(?:edil;|irc;|y;)|dot;|fr;|g;|opf;|reater(?:Equal(?:;|Less;)|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|scr;|t;)|H(?:ARDcy;|a(?:cek;|t;)|circ;|fr;|ilbertSpace;|o(?:pf;|rizontalLine;)|s(?:cr;|trok;)|ump(?:DownHump;|Equal;))|I(?:Ecy;|Jlig;|Ocy;|acute;?|c(?:irc;?|y;)|dot;|fr;|grave;?|m(?:;|a(?:cr;|ginaryI;)|plies;)|n(?:t(?:;|e(?:gral;|rsection;))|visible(?:Comma;|Times;))|o(?:gon;|pf;|ta;)|scr;|tilde;|u(?:kcy;|ml;?))|J(?:c(?:irc;|y;)|fr;|opf;|s(?:cr;|ercy;)|ukcy;)|K(?:Hcy;|Jcy;|appa;|c(?:edil;|y;)|fr;|opf;|scr;)|L(?:Jcy;|T;?|a(?:cute;|mbda;|ng;|placetrf;|rr;)|c(?:aron;|edil;|y;)|e(?:ft(?:A(?:ngleBracket;|rrow(?:;|Bar;|RightArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|Right(?:Arrow;|Vector;)|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Bar;))|Vector(?:;|Bar;)|arrow;|rightarrow;)|ss(?:EqualGreater;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;))|fr;|l(?:;|eftarrow;)|midot;|o(?:ng(?:Left(?:Arrow;|RightArrow;)|RightArrow;|left(?:arrow;|rightarrow;)|rightarrow;)|pf;|wer(?:LeftArrow;|RightArrow;))|s(?:cr;|h;|trok;)|t;)|M(?:ap;|cy;|e(?:diumSpace;|llintrf;)|fr;|inusPlus;|opf;|scr;|u;)|N(?:Jcy;|acute;|c(?:aron;|edil;|y;)|e(?:gative(?:MediumSpace;|Thi(?:ckSpace;|nSpace;)|VeryThinSpace;)|sted(?:GreaterGreater;|LessLess;)|wLine;)|fr;|o(?:Break;|nBreakingSpace;|pf;|t(?:;|C(?:ongruent;|upCap;)|DoubleVerticalBar;|E(?:lement;|qual(?:;|Tilde;)|xists;)|Greater(?:;|Equal;|FullEqual;|Greater;|Less;|SlantEqual;|Tilde;)|Hump(?:DownHump;|Equal;)|Le(?:ftTriangle(?:;|Bar;|Equal;)|ss(?:;|Equal;|Greater;|Less;|SlantEqual;|Tilde;))|Nested(?:GreaterGreater;|LessLess;)|Precedes(?:;|Equal;|SlantEqual;)|R(?:everseElement;|ightTriangle(?:;|Bar;|Equal;))|S(?:quareSu(?:bset(?:;|Equal;)|perset(?:;|Equal;))|u(?:bset(?:;|Equal;)|cceeds(?:;|Equal;|SlantEqual;|Tilde;)|perset(?:;|Equal;)))|Tilde(?:;|Equal;|FullEqual;|Tilde;)|VerticalBar;))|scr;|tilde;?|u;)|O(?:Elig;|acute;?|c(?:irc;?|y;)|dblac;|fr;|grave;?|m(?:acr;|ega;|icron;)|opf;|penCurly(?:DoubleQuote;|Quote;)|r;|s(?:cr;|lash;?)|ti(?:lde;?|mes;)|uml;?|ver(?:B(?:ar;|rac(?:e;|ket;))|Parenthesis;))|P(?:artialD;|cy;|fr;|hi;|i;|lusMinus;|o(?:incareplane;|pf;)|r(?:;|ecedes(?:;|Equal;|SlantEqual;|Tilde;)|ime;|o(?:duct;|portion(?:;|al;)))|s(?:cr;|i;))|Q(?:UOT;?|fr;|opf;|scr;)|R(?:Barr;|EG;?|a(?:cute;|ng;|rr(?:;|tl;))|c(?:aron;|edil;|y;)|e(?:;|verse(?:E(?:lement;|quilibrium;)|UpEquilibrium;))|fr;|ho;|ight(?:A(?:ngleBracket;|rrow(?:;|Bar;|LeftArrow;))|Ceiling;|Do(?:ubleBracket;|wn(?:TeeVector;|Vector(?:;|Bar;)))|Floor;|T(?:ee(?:;|Arrow;|Vector;)|riangle(?:;|Bar;|Equal;))|Up(?:DownVector;|TeeVector;|Vector(?:;|Bar;))|Vector(?:;|Bar;)|arrow;)|o(?:pf;|undImplies;)|rightarrow;|s(?:cr;|h;)|uleDelayed;)|S(?:H(?:CHcy;|cy;)|OFTcy;|acute;|c(?:;|aron;|edil;|irc;|y;)|fr;|hort(?:DownArrow;|LeftArrow;|RightArrow;|UpArrow;)|igma;|mallCircle;|opf;|q(?:rt;|uare(?:;|Intersection;|Su(?:bset(?:;|Equal;)|perset(?:;|Equal;))|Union;))|scr;|tar;|u(?:b(?:;|set(?:;|Equal;))|c(?:ceeds(?:;|Equal;|SlantEqual;|Tilde;)|hThat;)|m;|p(?:;|erset(?:;|Equal;)|set;)))|T(?:HORN;?|RADE;|S(?:Hcy;|cy;)|a(?:b;|u;)|c(?:aron;|edil;|y;)|fr;|h(?:e(?:refore;|ta;)|i(?:ckSpace;|nSpace;))|ilde(?:;|Equal;|FullEqual;|Tilde;)|opf;|ripleDot;|s(?:cr;|trok;))|U(?:a(?:cute;?|rr(?:;|ocir;))|br(?:cy;|eve;)|c(?:irc;?|y;)|dblac;|fr;|grave;?|macr;|n(?:der(?:B(?:ar;|rac(?:e;|ket;))|Parenthesis;)|ion(?:;|Plus;))|o(?:gon;|pf;)|p(?:Arrow(?:;|Bar;|DownArrow;)|DownArrow;|Equilibrium;|Tee(?:;|Arrow;)|arrow;|downarrow;|per(?:LeftArrow;|RightArrow;)|si(?:;|lon;))|ring;|scr;|tilde;|uml;?)|V(?:Dash;|bar;|cy;|dash(?:;|l;)|e(?:e;|r(?:bar;|t(?:;|ical(?:Bar;|Line;|Separator;|Tilde;))|yThinSpace;))|fr;|opf;|scr;|vdash;)|W(?:circ;|edge;|fr;|opf;|scr;)|X(?:fr;|i;|opf;|scr;)|Y(?:Acy;|Icy;|Ucy;|acute;?|c(?:irc;|y;)|fr;|opf;|scr;|uml;)|Z(?:Hcy;|acute;|c(?:aron;|y;)|dot;|e(?:roWidthSpace;|ta;)|fr;|opf;|scr;)|a(?:acute;?|breve;|c(?:;|E;|d;|irc;?|ute;?|y;)|elig;?|f(?:;|r;)|grave;?|l(?:e(?:fsym;|ph;)|pha;)|m(?:a(?:cr;|lg;)|p;?)|n(?:d(?:;|and;|d;|slope;|v;)|g(?:;|e;|le;|msd(?:;|a(?:a;|b;|c;|d;|e;|f;|g;|h;))|rt(?:;|vb(?:;|d;))|s(?:ph;|t;)|zarr;))|o(?:gon;|pf;)|p(?:;|E;|acir;|e;|id;|os;|prox(?:;|eq;))|ring;?|s(?:cr;|t;|ymp(?:;|eq;))|tilde;?|uml;?|w(?:conint;|int;))|b(?:Not;|a(?:ck(?:cong;|epsilon;|prime;|sim(?:;|eq;))|r(?:vee;|wed(?:;|ge;)))|brk(?:;|tbrk;)|c(?:ong;|y;)|dquo;|e(?:caus(?:;|e;)|mptyv;|psi;|rnou;|t(?:a;|h;|ween;))|fr;|ig(?:c(?:ap;|irc;|up;)|o(?:dot;|plus;|times;)|s(?:qcup;|tar;)|triangle(?:down;|up;)|uplus;|vee;|wedge;)|karow;|l(?:a(?:ck(?:lozenge;|square;|triangle(?:;|down;|left;|right;))|nk;)|k(?:1(?:2;|4;)|34;)|ock;)|n(?:e(?:;|quiv;)|ot;)|o(?:pf;|t(?:;|tom;)|wtie;|x(?:D(?:L;|R;|l;|r;)|H(?:;|D;|U;|d;|u;)|U(?:L;|R;|l;|r;)|V(?:;|H;|L;|R;|h;|l;|r;)|box;|d(?:L;|R;|l;|r;)|h(?:;|D;|U;|d;|u;)|minus;|plus;|times;|u(?:L;|R;|l;|r;)|v(?:;|H;|L;|R;|h;|l;|r;)))|prime;|r(?:eve;|vbar;?)|s(?:cr;|emi;|im(?:;|e;)|ol(?:;|b;|hsub;))|u(?:ll(?:;|et;)|mp(?:;|E;|e(?:;|q;))))|c(?:a(?:cute;|p(?:;|and;|brcup;|c(?:ap;|up;)|dot;|s;)|r(?:et;|on;))|c(?:a(?:ps;|ron;)|edil;?|irc;|ups(?:;|sm;))|dot;|e(?:dil;?|mptyv;|nt(?:;|erdot;|))|fr;|h(?:cy;|eck(?:;|mark;)|i;)|ir(?:;|E;|c(?:;|eq;|le(?:arrow(?:left;|right;)|d(?:R;|S;|ast;|circ;|dash;)))|e;|fnint;|mid;|scir;)|lubs(?:;|uit;)|o(?:lon(?:;|e(?:;|q;))|m(?:ma(?:;|t;)|p(?:;|fn;|le(?:ment;|xes;)))|n(?:g(?:;|dot;)|int;)|p(?:f;|rod;|y(?:;|sr;|)))|r(?:arr;|oss;)|s(?:cr;|u(?:b(?:;|e;)|p(?:;|e;)))|tdot;|u(?:darr(?:l;|r;)|e(?:pr;|sc;)|larr(?:;|p;)|p(?:;|brcap;|c(?:ap;|up;)|dot;|or;|s;)|r(?:arr(?:;|m;)|ly(?:eq(?:prec;|succ;)|vee;|wedge;)|ren;?|vearrow(?:left;|right;))|vee;|wed;)|w(?:conint;|int;)|ylcty;)|d(?:Arr;|Har;|a(?:gger;|leth;|rr;|sh(?:;|v;))|b(?:karow;|lac;)|c(?:aron;|y;)|d(?:;|a(?:gger;|rr;)|otseq;)|e(?:g;?|lta;|mptyv;)|f(?:isht;|r;)|har(?:l;|r;)|i(?:am(?:;|ond(?:;|suit;)|s;)|e;|gamma;|sin;|v(?:;|ide(?:;|ontimes;|)|onx;))|jcy;|lc(?:orn;|rop;)|o(?:llar;|pf;|t(?:;|eq(?:;|dot;)|minus;|plus;|square;)|ublebarwedge;|wn(?:arrow;|downarrows;|harpoon(?:left;|right;)))|r(?:bkarow;|c(?:orn;|rop;))|s(?:c(?:r;|y;)|ol;|trok;)|t(?:dot;|ri(?:;|f;))|u(?:arr;|har;)|wangle;|z(?:cy;|igrarr;))|e(?:D(?:Dot;|ot;)|a(?:cute;?|ster;)|c(?:aron;|ir(?:;|c;?)|olon;|y;)|dot;|e;|f(?:Dot;|r;)|g(?:;|rave;?|s(?:;|dot;))|l(?:;|inters;|l;|s(?:;|dot;))|m(?:acr;|pty(?:;|set;|v;)|sp(?:1(?:3;|4;)|;))|n(?:g;|sp;)|o(?:gon;|pf;)|p(?:ar(?:;|sl;)|lus;|si(?:;|lon;|v;))|q(?:c(?:irc;|olon;)|s(?:im;|lant(?:gtr;|less;))|u(?:als;|est;|iv(?:;|DD;))|vparsl;)|r(?:Dot;|arr;)|s(?:cr;|dot;|im;)|t(?:a;|h;?)|u(?:ml;?|ro;)|x(?:cl;|ist;|p(?:ectation;|onentiale;)))|f(?:allingdotseq;|cy;|emale;|f(?:ilig;|l(?:ig;|lig;)|r;)|ilig;|jlig;|l(?:at;|lig;|tns;)|nof;|o(?:pf;|r(?:all;|k(?:;|v;)))|partint;|r(?:a(?:c(?:1(?:2;?|3;|4;?|5;|6;|8;)|2(?:3;|5;)|3(?:4;?|5;|8;)|45;|5(?:6;|8;)|78;)|sl;)|own;)|scr;)|g(?:E(?:;|l;)|a(?:cute;|mma(?:;|d;)|p;)|breve;|c(?:irc;|y;)|dot;|e(?:;|l;|q(?:;|q;|slant;)|s(?:;|cc;|dot(?:;|o(?:;|l;))|l(?:;|es;)))|fr;|g(?:;|g;)|imel;|jcy;|l(?:;|E;|a;|j;)|n(?:E;|ap(?:;|prox;)|e(?:;|q(?:;|q;))|sim;)|opf;|rave;|s(?:cr;|im(?:;|e;|l;))|t(?:;|c(?:c;|ir;)|dot;|lPar;|quest;|r(?:a(?:pprox;|rr;)|dot;|eq(?:less;|qless;)|less;|sim;)|)|v(?:ertneqq;|nE;))|h(?:Arr;|a(?:irsp;|lf;|milt;|r(?:dcy;|r(?:;|cir;|w;)))|bar;|circ;|e(?:arts(?:;|uit;)|llip;|rcon;)|fr;|ks(?:earow;|warow;)|o(?:arr;|mtht;|ok(?:leftarrow;|rightarrow;)|pf;|rbar;)|s(?:cr;|lash;|trok;)|y(?:bull;|phen;))|i(?:acute;?|c(?:;|irc;?|y;)|e(?:cy;|xcl;?)|f(?:f;|r;)|grave;?|i(?:;|i(?:int;|nt;)|nfin;|ota;)|jlig;|m(?:a(?:cr;|g(?:e;|line;|part;)|th;)|of;|ped;)|n(?:;|care;|fin(?:;|tie;)|odot;|t(?:;|cal;|e(?:gers;|rcal;)|larhk;|prod;))|o(?:cy;|gon;|pf;|ta;)|prod;|quest;?|s(?:cr;|in(?:;|E;|dot;|s(?:;|v;)|v;))|t(?:;|ilde;)|u(?:kcy;|ml;?))|j(?:c(?:irc;|y;)|fr;|math;|opf;|s(?:cr;|ercy;)|ukcy;)|k(?:appa(?:;|v;)|c(?:edil;|y;)|fr;|green;|hcy;|jcy;|opf;|scr;)|l(?:A(?:arr;|rr;|tail;)|Barr;|E(?:;|g;)|Har;|a(?:cute;|emptyv;|gran;|mbda;|ng(?:;|d;|le;)|p;|quo;?|rr(?:;|b(?:;|fs;)|fs;|hk;|lp;|pl;|sim;|tl;)|t(?:;|ail;|e(?:;|s;)))|b(?:arr;|brk;|r(?:ac(?:e;|k;)|k(?:e;|sl(?:d;|u;))))|c(?:aron;|e(?:dil;|il;)|ub;|y;)|d(?:ca;|quo(?:;|r;)|r(?:dhar;|ushar;)|sh;)|e(?:;|ft(?:arrow(?:;|tail;)|harpoon(?:down;|up;)|leftarrows;|right(?:arrow(?:;|s;)|harpoons;|squigarrow;)|threetimes;)|g;|q(?:;|q;|slant;)|s(?:;|cc;|dot(?:;|o(?:;|r;))|g(?:;|es;)|s(?:approx;|dot;|eq(?:gtr;|qgtr;)|gtr;|sim;)))|f(?:isht;|loor;|r;)|g(?:;|E;)|h(?:ar(?:d;|u(?:;|l;))|blk;)|jcy;|l(?:;|arr;|corner;|hard;|tri;)|m(?:idot;|oust(?:;|ache;))|n(?:E;|ap(?:;|prox;)|e(?:;|q(?:;|q;))|sim;)|o(?:a(?:ng;|rr;)|brk;|ng(?:left(?:arrow;|rightarrow;)|mapsto;|rightarrow;)|oparrow(?:left;|right;)|p(?:ar;|f;|lus;)|times;|w(?:ast;|bar;)|z(?:;|enge;|f;))|par(?:;|lt;)|r(?:arr;|corner;|har(?:;|d;)|m;|tri;)|s(?:aquo;|cr;|h;|im(?:;|e;|g;)|q(?:b;|uo(?:;|r;))|trok;)|t(?:;|c(?:c;|ir;)|dot;|hree;|imes;|larr;|quest;|r(?:Par;|i(?:;|e;|f;))|)|ur(?:dshar;|uhar;)|v(?:ertneqq;|nE;))|m(?:DDot;|a(?:cr;?|l(?:e;|t(?:;|ese;))|p(?:;|sto(?:;|down;|left;|up;))|rker;)|c(?:omma;|y;)|dash;|easuredangle;|fr;|ho;|i(?:cro;?|d(?:;|ast;|cir;|dot;?)|nus(?:;|b;|d(?:;|u;)))|l(?:cp;|dr;)|nplus;|o(?:dels;|pf;)|p;|s(?:cr;|tpos;)|u(?:;|ltimap;|map;))|n(?:G(?:g;|t(?:;|v;))|L(?:eft(?:arrow;|rightarrow;)|l;|t(?:;|v;))|Rightarrow;|V(?:Dash;|dash;)|a(?:bla;|cute;|ng;|p(?:;|E;|id;|os;|prox;)|tur(?:;|al(?:;|s;)))|b(?:sp;?|ump(?:;|e;))|c(?:a(?:p;|ron;)|edil;|ong(?:;|dot;)|up;|y;)|dash;|e(?:;|Arr;|ar(?:hk;|r(?:;|ow;))|dot;|quiv;|s(?:ear;|im;)|xist(?:;|s;))|fr;|g(?:E;|e(?:;|q(?:;|q;|slant;)|s;)|sim;|t(?:;|r;))|h(?:Arr;|arr;|par;)|i(?:;|s(?:;|d;)|v;)|jcy;|l(?:Arr;|E;|arr;|dr;|e(?:;|ft(?:arrow;|rightarrow;)|q(?:;|q;|slant;)|s(?:;|s;))|sim;|t(?:;|ri(?:;|e;)))|mid;|o(?:pf;|t(?:;|in(?:;|E;|dot;|v(?:a;|b;|c;))|ni(?:;|v(?:a;|b;|c;))|))|p(?:ar(?:;|allel;|sl;|t;)|olint;|r(?:;|cue;|e(?:;|c(?:;|eq;))))|r(?:Arr;|arr(?:;|c;|w;)|ightarrow;|tri(?:;|e;))|s(?:c(?:;|cue;|e;|r;)|hort(?:mid;|parallel;)|im(?:;|e(?:;|q;))|mid;|par;|qsu(?:be;|pe;)|u(?:b(?:;|E;|e;|set(?:;|eq(?:;|q;)))|cc(?:;|eq;)|p(?:;|E;|e;|set(?:;|eq(?:;|q;)))))|t(?:gl;|ilde;?|lg;|riangle(?:left(?:;|eq;)|right(?:;|eq;)))|u(?:;|m(?:;|ero;|sp;))|v(?:Dash;|Harr;|ap;|dash;|g(?:e;|t;)|infin;|l(?:Arr;|e;|t(?:;|rie;))|r(?:Arr;|trie;)|sim;)|w(?:Arr;|ar(?:hk;|r(?:;|ow;))|near;))|o(?:S;|a(?:cute;?|st;)|c(?:ir(?:;|c;?)|y;)|d(?:ash;|blac;|iv;|ot;|sold;)|elig;|f(?:cir;|r;)|g(?:on;|rave;?|t;)|h(?:bar;|m;)|int;|l(?:arr;|c(?:ir;|ross;)|ine;|t;)|m(?:acr;|ega;|i(?:cron;|d;|nus;))|opf;|p(?:ar;|erp;|lus;)|r(?:;|arr;|d(?:;|er(?:;|of;)|f;?|m;?)|igof;|or;|slope;|v;)|s(?:cr;|lash;?|ol;)|ti(?:lde;?|mes(?:;|as;))|uml;?|vbar;)|p(?:ar(?:;|a(?:;|llel;|)|s(?:im;|l;)|t;)|cy;|er(?:cnt;|iod;|mil;|p;|tenk;)|fr;|h(?:i(?:;|v;)|mmat;|one;)|i(?:;|tchfork;|v;)|l(?:an(?:ck(?:;|h;)|kv;)|us(?:;|acir;|b;|cir;|d(?:o;|u;)|e;|mn;?|sim;|two;))|m;|o(?:intint;|pf;|und;?)|r(?:;|E;|ap;|cue;|e(?:;|c(?:;|approx;|curlyeq;|eq;|n(?:approx;|eqq;|sim;)|sim;))|ime(?:;|s;)|n(?:E;|ap;|sim;)|o(?:d;|f(?:alar;|line;|surf;)|p(?:;|to;))|sim;|urel;)|s(?:cr;|i;)|uncsp;)|q(?:fr;|int;|opf;|prime;|scr;|u(?:at(?:ernions;|int;)|est(?:;|eq;)|ot;?))|r(?:A(?:arr;|rr;|tail;)|Barr;|Har;|a(?:c(?:e;|ute;)|dic;|emptyv;|ng(?:;|d;|e;|le;)|quo;?|rr(?:;|ap;|b(?:;|fs;)|c;|fs;|hk;|lp;|pl;|sim;|tl;|w;)|t(?:ail;|io(?:;|nals;)))|b(?:arr;|brk;|r(?:ac(?:e;|k;)|k(?:e;|sl(?:d;|u;))))|c(?:aron;|e(?:dil;|il;)|ub;|y;)|d(?:ca;|ldhar;|quo(?:;|r;)|sh;)|e(?:al(?:;|ine;|part;|s;)|ct;|g;?)|f(?:isht;|loor;|r;)|h(?:ar(?:d;|u(?:;|l;))|o(?:;|v;))|i(?:ght(?:arrow(?:;|tail;)|harpoon(?:down;|up;)|left(?:arrows;|harpoons;)|rightarrows;|squigarrow;|threetimes;)|ng;|singdotseq;)|l(?:arr;|har;|m;)|moust(?:;|ache;)|nmid;|o(?:a(?:ng;|rr;)|brk;|p(?:ar;|f;|lus;)|times;)|p(?:ar(?:;|gt;)|polint;)|rarr;|s(?:aquo;|cr;|h;|q(?:b;|uo(?:;|r;)))|t(?:hree;|imes;|ri(?:;|e;|f;|ltri;))|uluhar;|x;)|s(?:acute;|bquo;|c(?:;|E;|a(?:p;|ron;)|cue;|e(?:;|dil;)|irc;|n(?:E;|ap;|sim;)|polint;|sim;|y;)|dot(?:;|b;|e;)|e(?:Arr;|ar(?:hk;|r(?:;|ow;))|ct;?|mi;|swar;|tm(?:inus;|n;)|xt;)|fr(?:;|own;)|h(?:arp;|c(?:hcy;|y;)|ort(?:mid;|parallel;)|y;?)|i(?:gma(?:;|f;|v;)|m(?:;|dot;|e(?:;|q;)|g(?:;|E;)|l(?:;|E;)|ne;|plus;|rarr;))|larr;|m(?:a(?:llsetminus;|shp;)|eparsl;|i(?:d;|le;)|t(?:;|e(?:;|s;)))|o(?:ftcy;|l(?:;|b(?:;|ar;))|pf;)|pa(?:des(?:;|uit;)|r;)|q(?:c(?:ap(?:;|s;)|up(?:;|s;))|su(?:b(?:;|e;|set(?:;|eq;))|p(?:;|e;|set(?:;|eq;)))|u(?:;|ar(?:e;|f;)|f;))|rarr;|s(?:cr;|etmn;|mile;|tarf;)|t(?:ar(?:;|f;)|r(?:aight(?:epsilon;|phi;)|ns;))|u(?:b(?:;|E;|dot;|e(?:;|dot;)|mult;|n(?:E;|e;)|plus;|rarr;|s(?:et(?:;|eq(?:;|q;)|neq(?:;|q;))|im;|u(?:b;|p;)))|cc(?:;|approx;|curlyeq;|eq;|n(?:approx;|eqq;|sim;)|sim;)|m;|ng;|p(?:1;?|2;?|3;?|;|E;|d(?:ot;|sub;)|e(?:;|dot;)|hs(?:ol;|ub;)|larr;|mult;|n(?:E;|e;)|plus;|s(?:et(?:;|eq(?:;|q;)|neq(?:;|q;))|im;|u(?:b;|p;))))|w(?:Arr;|ar(?:hk;|r(?:;|ow;))|nwar;)|zlig;?)|t(?:a(?:rget;|u;)|brk;|c(?:aron;|edil;|y;)|dot;|elrec;|fr;|h(?:e(?:re(?:4;|fore;)|ta(?:;|sym;|v;))|i(?:ck(?:approx;|sim;)|nsp;)|k(?:ap;|sim;)|orn;?)|i(?:lde;|mes(?:;|b(?:;|ar;)|d;|)|nt;)|o(?:ea;|p(?:;|bot;|cir;|f(?:;|ork;))|sa;)|prime;|r(?:ade;|i(?:angle(?:;|down;|left(?:;|eq;)|q;|right(?:;|eq;))|dot;|e;|minus;|plus;|sb;|time;)|pezium;)|s(?:c(?:r;|y;)|hcy;|trok;)|w(?:ixt;|ohead(?:leftarrow;|rightarrow;)))|u(?:Arr;|Har;|a(?:cute;?|rr;)|br(?:cy;|eve;)|c(?:irc;?|y;)|d(?:arr;|blac;|har;)|f(?:isht;|r;)|grave;?|h(?:ar(?:l;|r;)|blk;)|l(?:c(?:orn(?:;|er;)|rop;)|tri;)|m(?:acr;|l;?)|o(?:gon;|pf;)|p(?:arrow;|downarrow;|harpoon(?:left;|right;)|lus;|si(?:;|h;|lon;)|uparrows;)|r(?:c(?:orn(?:;|er;)|rop;)|ing;|tri;)|scr;|t(?:dot;|ilde;|ri(?:;|f;))|u(?:arr;|ml;?)|wangle;)|v(?:Arr;|Bar(?:;|v;)|Dash;|a(?:ngrt;|r(?:epsilon;|kappa;|nothing;|p(?:hi;|i;|ropto;)|r(?:;|ho;)|s(?:igma;|u(?:bsetneq(?:;|q;)|psetneq(?:;|q;)))|t(?:heta;|riangle(?:left;|right;))))|cy;|dash;|e(?:e(?:;|bar;|eq;)|llip;|r(?:bar;|t;))|fr;|ltri;|nsu(?:b;|p;)|opf;|prop;|rtri;|s(?:cr;|u(?:bn(?:E;|e;)|pn(?:E;|e;)))|zigzag;)|w(?:circ;|e(?:d(?:bar;|ge(?:;|q;))|ierp;)|fr;|opf;|p;|r(?:;|eath;)|scr;)|x(?:c(?:ap;|irc;|up;)|dtri;|fr;|h(?:Arr;|arr;)|i;|l(?:Arr;|arr;)|map;|nis;|o(?:dot;|p(?:f;|lus;)|time;)|r(?:Arr;|arr;)|s(?:cr;|qcup;)|u(?:plus;|tri;)|vee;|wedge;)|y(?:ac(?:ute;?|y;)|c(?:irc;|y;)|en;?|fr;|icy;|opf;|scr;|u(?:cy;|ml;?))|z(?:acute;|c(?:aron;|y;)|dot;|e(?:etrf;|ta;)|fr;|hcy;|igrarr;|opf;|scr;|w(?:j;|nj;)))|[\s\S]/g; + +var NAMEDCHARREF_MAXLEN = 32; + +// Regular expression constants used by the tokenizer and parser + +// Note that \r is included in all of these regexps because it will need +// to be converted to LF by the scanChars() function. +var DBLQUOTEATTRVAL = /[^\r"&\u0000]+/g; +var SINGLEQUOTEATTRVAL = /[^\r'&\u0000]+/g; +var UNQUOTEDATTRVAL = /[^\r\t\n\f &>\u0000]+/g; +var TAGNAME = /[^\r\t\n\f \/>A-Z\u0000]+/g; +var ATTRNAME = /[^\r\t\n\f \/=>A-Z\u0000]+/g; + +var CDATATEXT = /[^\]\r\u0000\uffff]*/g; +var DATATEXT = /[^&<\r\u0000\uffff]*/g; +var RAWTEXT = /[^<\r\u0000\uffff]*/g; +var PLAINTEXT = /[^\r\u0000\uffff]*/g; +// Since we don't have the 'sticky tag', add '|.' to the end of SIMPLETAG +// and SIMPLEATTR so that we are guaranteed to always match. This prevents +// us from scanning past the lastIndex set. (Note that the desired matches +// are always greater than 1 char long, so longest-match will ensure that . +// is not matched unless the desired match fails.) +var SIMPLETAG = /(?:(\/)?([a-z]+)>)|[\s\S]/g; +var SIMPLEATTR = /(?:([-a-z]+)[ \t\n\f]*=[ \t\n\f]*('[^'&\r\u0000]*'|"[^"&\r\u0000]*"|[^\t\n\r\f "&'\u0000>][^&> \t\n\r\f\u0000]*[ \t\n\f]))|[\s\S]/g; + +var NONWS = /[^\x09\x0A\x0C\x0D\x20]/; +var ALLNONWS = /[^\x09\x0A\x0C\x0D\x20]/g; // like above, with g flag +var NONWSNONNUL = /[^\x00\x09\x0A\x0C\x0D\x20]/; // don't allow NUL either +var LEADINGWS = /^[\x09\x0A\x0C\x0D\x20]+/; +var NULCHARS = /\x00/g; + +/*** + * These are utility functions that don't use any of the parser's + * internal state. + */ +function buf2str(buf) { + var CHUNKSIZE=16384; + if (buf.length < CHUNKSIZE) { + return String.fromCharCode.apply(String, buf); + } + // special case for large strings, to avoid busting the stack. + var result = ''; + for (var i = 0; i < buf.length; i += CHUNKSIZE) { + result += String.fromCharCode.apply(String, buf.slice(i, i+CHUNKSIZE)); + } + return result; +} + +function str2buf(s) { + var result = []; + for (var i=0; i 0; i--) { + var e = this.elements[i]; + if (isA(e, tag)) break; + } + this.elements.length = i; + this.top = this.elements[i-1]; +}; -//12.2.4.39 Attribute value (single-quoted) state -//------------------------------------------------------------------ -_[ATTRIBUTE_VALUE_SINGLE_QUOTED_STATE] = function attributeValueSingleQuotedState(cp) { - if (cp === $.APOSTROPHE) - this.state = AFTER_ATTRIBUTE_VALUE_QUOTED_STATE; +// Pop elements off the stack up to and including the first +// element that is an instance of the specified type +HTMLParser.ElementStack.prototype.popElementType = function(type) { + for(var i = this.elements.length-1; i > 0; i--) { + if (this.elements[i] instanceof type) break; + } + this.elements.length = i; + this.top = this.elements[i-1]; +}; - else if (cp === $.AMPERSAND) { - this.additionalAllowedCp = $.APOSTROPHE; - this.returnState = this.state; - this.state = CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE_STATE; - } +// Pop elements off the stack up to and including the element e. +// Note that this is very different from removeElement() +// This requires that e is on the stack. +HTMLParser.ElementStack.prototype.popElement = function(e) { + for(var i = this.elements.length-1; i > 0; i--) { + if (this.elements[i] === e) break; + } + this.elements.length = i; + this.top = this.elements[i-1]; +}; - else if (cp === $.NULL) - this.currentAttr.value += UNICODE.REPLACEMENT_CHARACTER; +// Remove a specific element from the stack. +// Do nothing if the element is not on the stack +HTMLParser.ElementStack.prototype.removeElement = function(e) { + if (this.top === e) this.pop(); + else { + var idx = this.elements.lastIndexOf(e); + if (idx !== -1) + this.elements.splice(idx, 1); + } +}; - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); +HTMLParser.ElementStack.prototype.clearToContext = function(set) { + // Note that we don't loop to 0. Never pop the elt off. + for(var i = this.elements.length-1; i > 0; i--) { + if (isA(this.elements[i], set)) break; + } + this.elements.length = i+1; + this.top = this.elements[i]; +}; - else - this.currentAttr.value += toChar(cp); +HTMLParser.ElementStack.prototype.contains = function(tag) { + return this.inSpecificScope(tag, Object.create(null)); }; +HTMLParser.ElementStack.prototype.inSpecificScope = function(tag, set) { + for(var i = this.elements.length-1; i >= 0; i--) { + var elt = this.elements[i]; + if (isA(elt, tag)) return true; + if (isA(elt, set)) return false; + } + return false; +}; -//12.2.4.40 Attribute value (unquoted) state -//------------------------------------------------------------------ -_[ATTRIBUTE_VALUE_UNQUOTED_STATE] = function attributeValueUnquotedState(cp) { - if (isWhitespace(cp)) - this._leaveAttrValue(BEFORE_ATTRIBUTE_NAME_STATE); +// Like the above, but for a specific element, not a tagname +HTMLParser.ElementStack.prototype.elementInSpecificScope = function(target, set) { + for(var i = this.elements.length-1; i >= 0; i--) { + var elt = this.elements[i]; + if (elt === target) return true; + if (isA(elt, set)) return false; + } + return false; +}; - else if (cp === $.AMPERSAND) { - this.additionalAllowedCp = $.GREATER_THAN_SIGN; - this.returnState = this.state; - this.state = CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE_STATE; - } +// Like the above, but for an element interface, not a tagname +HTMLParser.ElementStack.prototype.elementTypeInSpecificScope = function(target, set) { + for(var i = this.elements.length-1; i >= 0; i--) { + var elt = this.elements[i]; + if (elt instanceof target) return true; + if (isA(elt, set)) return false; + } + return false; +}; - else if (cp === $.GREATER_THAN_SIGN) { - this._leaveAttrValue(DATA_STATE); - this._emitCurrentToken(); - } +HTMLParser.ElementStack.prototype.inScope = function(tag) { + return this.inSpecificScope(tag, inScopeSet); +}; - else if (cp === $.NULL) - this.currentAttr.value += UNICODE.REPLACEMENT_CHARACTER; +HTMLParser.ElementStack.prototype.elementInScope = function(e) { + return this.elementInSpecificScope(e, inScopeSet); +}; - else if (cp === $.QUOTATION_MARK || cp === $.APOSTROPHE || cp === $.LESS_THAN_SIGN || - cp === $.EQUALS_SIGN || cp === $.GRAVE_ACCENT) - this.currentAttr.value += toChar(cp); +HTMLParser.ElementStack.prototype.elementTypeInScope = function(type) { + return this.elementTypeInSpecificScope(type, inScopeSet); +}; - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); +HTMLParser.ElementStack.prototype.inButtonScope = function(tag) { + return this.inSpecificScope(tag, inButtonScopeSet); +}; - else - this.currentAttr.value += toChar(cp); +HTMLParser.ElementStack.prototype.inListItemScope = function(tag) { + return this.inSpecificScope(tag, inListItemScopeSet); }; +HTMLParser.ElementStack.prototype.inTableScope = function(tag) { + return this.inSpecificScope(tag, inTableScopeSet); +}; -//12.2.4.41 Character reference in attribute value state -//------------------------------------------------------------------ -_[CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE_STATE] = function characterReferenceInAttributeValueState(cp) { - var referencedCodePoints = this._consumeCharacterReference(cp, true); +HTMLParser.ElementStack.prototype.inSelectScope = function(tag) { + // Can't implement this one with inSpecificScope, since it involves + // a set defined by inverting another set. So implement manually. + for(var i = this.elements.length-1; i >= 0; i--) { + var elt = this.elements[i]; + if (elt.namespaceURI !== NAMESPACE.HTML) return false; + var localname = elt.localName; + if (localname === tag) return true; + if (localname !== "optgroup" && localname !== "option") + return false; + } + return false; +}; - if (!this._ensureHibernation()) { - if (referencedCodePoints) { - for (var i = 0; i < referencedCodePoints.length; i++) - this.currentAttr.value += toChar(referencedCodePoints[i]); - } - else - this.currentAttr.value += '&'; +HTMLParser.ElementStack.prototype.generateImpliedEndTags = function(butnot, thorough) { + var endTagSet = thorough ? thoroughImpliedEndTagsSet : impliedEndTagsSet; + for(var i = this.elements.length-1; i >= 0; i--) { + var e = this.elements[i]; + if (butnot && isA(e, butnot)) break; + if (!isA(this.elements[i], endTagSet)) break; + } - this.state = this.returnState; - } + this.elements.length = i+1; + this.top = this.elements[i]; }; +/*** + * The ActiveFormattingElements class + */ +HTMLParser.ActiveFormattingElements = function AFE() { + this.list = []; // elements + this.attrs = []; // attribute tokens for cloning +}; -//12.2.4.42 After attribute value (quoted) state -//------------------------------------------------------------------ -_[AFTER_ATTRIBUTE_VALUE_QUOTED_STATE] = function afterAttributeValueQuotedState(cp) { - if (isWhitespace(cp)) - this._leaveAttrValue(BEFORE_ATTRIBUTE_NAME_STATE); +HTMLParser.ActiveFormattingElements.prototype.MARKER = { localName: "|" }; - else if (cp === $.SOLIDUS) - this._leaveAttrValue(SELF_CLOSING_START_TAG_STATE); +/* +// For debugging +HTMLParser.ActiveFormattingElements.prototype.toString = function() { + return "AFE: " + + this.list.map(function(e) { return e.localName; }).join("-"); +} +*/ - else if (cp === $.GREATER_THAN_SIGN) { - this._leaveAttrValue(DATA_STATE); - this._emitCurrentToken(); +HTMLParser.ActiveFormattingElements.prototype.insertMarker = function() { + this.list.push(this.MARKER); + this.attrs.push(this.MARKER); +}; + +HTMLParser.ActiveFormattingElements.prototype.push = function(elt, attrs) { + // Scan backwards: if there are already 3 copies of this element + // before we encounter a marker, then drop the last one + var count = 0; + for(var i = this.list.length-1; i >= 0; i--) { + if (this.list[i] === this.MARKER) break; + // equal() is defined below + if (equal(elt, this.list[i], this.attrs[i])) { + count++; + if (count === 3) { + this.list.splice(i, 1); + this.attrs.splice(i, 1); + break; + } } + } - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); - else - this._reconsumeInState(BEFORE_ATTRIBUTE_NAME_STATE); -}; + // Now push the element onto the list + this.list.push(elt); + + // Copy the attributes and push those on, too + var attrcopy = []; + for(var ii = 0; ii < attrs.length; ii++) { + attrcopy[ii] = attrs[ii]; + } + this.attrs.push(attrcopy); -//12.2.4.43 Self-closing start tag state -//------------------------------------------------------------------ -_[SELF_CLOSING_START_TAG_STATE] = function selfClosingStartTagState(cp) { - if (cp === $.GREATER_THAN_SIGN) { - this.currentToken.selfClosing = true; - this.state = DATA_STATE; - this._emitCurrentToken(); + // This function defines equality of two elements for the purposes + // of the AFE list. Note that it compares the new elements + // attributes to the saved array of attributes associated with + // the old element because a script could have changed the + // old element's set of attributes + function equal(newelt, oldelt, oldattrs) { + if (newelt.localName !== oldelt.localName) return false; + if (newelt._numattrs !== oldattrs.length) return false; + for(var i = 0, n = oldattrs.length; i < n; i++) { + var oldname = oldattrs[i][0]; + var oldval = oldattrs[i][1]; + if (!newelt.hasAttribute(oldname)) return false; + if (newelt.getAttribute(oldname) !== oldval) return false; } + return true; + } +}; + +HTMLParser.ActiveFormattingElements.prototype.clearToMarker = function() { + for(var i = this.list.length-1; i >= 0; i--) { + if (this.list[i] === this.MARKER) break; + } + if (i < 0) i = 0; + this.list.length = i; + this.attrs.length = i; +}; + +// Find and return the last element with the specified tag between the +// end of the list and the last marker on the list. +// Used when parsing in_body_mode() +HTMLParser.ActiveFormattingElements.prototype.findElementByTag = function(tag) { + for(var i = this.list.length-1; i >= 0; i--) { + var elt = this.list[i]; + if (elt === this.MARKER) break; + if (elt.localName === tag) return elt; + } + return null; +}; + +HTMLParser.ActiveFormattingElements.prototype.indexOf = function(e) { + return this.list.lastIndexOf(e); +}; + +// Find the element e in the list and remove it +// Used when parsing in_body() +HTMLParser.ActiveFormattingElements.prototype.remove = function(e) { + var idx = this.list.lastIndexOf(e); + if (idx !== -1) { + this.list.splice(idx, 1); + this.attrs.splice(idx, 1); + } +}; + +// Find element a in the list and replace it with element b +// XXX: Do I need to handle attributes here? +HTMLParser.ActiveFormattingElements.prototype.replace = function(a, b, attrs) { + var idx = this.list.lastIndexOf(a); + if (idx !== -1) { + this.list[idx] = b; + this.attrs[idx] = attrs; + } +}; + +// Find a in the list and insert b after it +// This is only used for insert a bookmark object, so the +// attrs array doesn't really matter +HTMLParser.ActiveFormattingElements.prototype.insertAfter = function(a,b) { + var idx = this.list.lastIndexOf(a); + if (idx !== -1) { + this.list.splice(idx, 0, b); + this.attrs.splice(idx, 0, b); + } +}; + + + + +/*** + * This is the parser factory function. It is the return value of + * the outer closure that it is defined within. Most of the parser + * implementation details are inside this function. + */ +function HTMLParser(address, fragmentContext, options) { + /*** + * These are the parser's state variables + */ + // Scanner state + var chars = null; + var numchars = 0; // Length of chars + var nextchar = 0; // Index of next char + var input_complete = false; // Becomes true when end() called. + var scanner_skip_newline = false; // If previous char was CR + var reentrant_invocations = 0; + var saved_scanner_state = []; + var leftovers = ""; + var first_batch = true; + var paused = 0; // Becomes non-zero while loading scripts + + + // Tokenizer state + var tokenizer = data_state; // Current tokenizer state + var return_state; + var character_reference_code; + var tagnamebuf = ""; + var lasttagname = ""; // holds the target end tag for text states + var tempbuf = []; + var attrnamebuf = ""; + var attrvaluebuf = ""; + var commentbuf = []; + var doctypenamebuf = []; + var doctypepublicbuf = []; + var doctypesystembuf = []; + var attributes = []; + var is_end_tag = false; + + // Tree builder state + var parser = initial_mode; // Current insertion mode + var originalInsertionMode = null; // A saved insertion mode + var templateInsertionModes = []; // Stack of template insertion modes. + var stack = new HTMLParser.ElementStack(); // Stack of open elements + var afe = new HTMLParser.ActiveFormattingElements(); // mis-nested tags + var fragment = (fragmentContext!==undefined); // For innerHTML, etc. + var head_element_pointer = null; + var form_element_pointer = null; + var scripting_enabled = true; + if (fragmentContext) { + scripting_enabled = fragmentContext.ownerDocument._scripting_enabled; + } + if (options && options.scripting_enabled === false) + scripting_enabled = false; + var frameset_ok = true; + var force_quirks = false; + var pending_table_text; + var text_integration_mode; // XXX a spec bug workaround? + + // A single run of characters, buffered up to be sent to + // the parser as a single string. + var textrun = []; + var textIncludesNUL = false; + var ignore_linefeed = false; + + /*** + * This is the parser object that will be the return value of this + * factory function, which is some 5000 lines below. + * Note that the variable "parser" is the current state of the + * parser's state machine. This variable "htmlparser" is the + * return value and defines the public API of the parser + */ + var htmlparser = { + document: function() { + return doc; + }, - else if (cp === $.EOF) - this._reconsumeInState(DATA_STATE); + // Internal function used from HTMLScriptElement to pause the + // parser while a script is being loaded from the network + pause: function() { + // print("pausing parser"); + paused++; + }, - else - this._reconsumeInState(BEFORE_ATTRIBUTE_NAME_STATE); -}; + // Called when a script finishes loading + resume: function() { + // print("resuming parser"); + paused--; + // XXX: added this to force a resumption. + // Is this the right thing to do? + this.parse(""); + }, + // Parse the HTML text s. + // The second argument should be true if there is no more + // text to be parsed, and should be false or omitted otherwise. + // The second argument must not be set for recursive invocations + // from document.write() + parse: function(s, end) { + + // If we're paused, remember the text to parse, but + // don't parse it now. + if (paused > 0) { + leftovers += s; + return; + } -//12.2.4.44 Bogus comment state -//------------------------------------------------------------------ -_[BOGUS_COMMENT_STATE] = function bogusCommentState() { - this._createCommentToken(); - this._reconsumeInState(BOGUS_COMMENT_STATE_CONTINUATION); -}; -//HACK: to support streaming and make BOGUS_COMMENT_STATE reentrant we've -//introduced BOGUS_COMMENT_STATE_CONTINUATION state which will not produce -//comment token on each call. -_[BOGUS_COMMENT_STATE_CONTINUATION] = function bogusCommentStateContinuation(cp) { - while (true) { - if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - break; + if (reentrant_invocations === 0) { + // A normal, top-level invocation + if (leftovers) { + s = leftovers + s; + leftovers = ""; } - else if (cp === $.EOF) { - this._reconsumeInState(DATA_STATE); - break; + // Add a special marker character to the end of + // the buffer. If the scanner is at the end of + // the buffer and input_complete is set, then this + // character will transform into an EOF token. + // Having an actual character that represents EOF + // in the character buffer makes lookahead regexp + // matching work more easily, and this is + // important for character references. + if (end) { + s += "\uFFFF"; + input_complete = true; // Makes scanChars() send EOF } - else { - this.currentToken.data += cp === $.NULL ? UNICODE.REPLACEMENT_CHARACTER : toChar(cp); - - this._hibernationSnapshot(); - cp = this._consume(); + chars = s; + numchars = s.length; + nextchar = 0; - if (this._ensureHibernation()) - return; + if (first_batch) { + // We skip a leading Byte Order Mark (\uFEFF) + // on first batch of text we're given + first_batch = false; + if (chars.charCodeAt(0) === 0xFEFF) nextchar = 1; } - } - this._emitCurrentToken(); -}; - -//12.2.4.45 Markup declaration open state -//------------------------------------------------------------------ -_[MARKUP_DECLARATION_OPEN_STATE] = function markupDeclarationOpenState(cp) { - var dashDashMatch = this._consumeSubsequentIfMatch($$.DASH_DASH_STRING, cp, true), - doctypeMatch = !dashDashMatch && this._consumeSubsequentIfMatch($$.DOCTYPE_STRING, cp, false), - cdataMatch = !dashDashMatch && !doctypeMatch && - this.allowCDATA && - this._consumeSubsequentIfMatch($$.CDATA_START_STRING, cp, true); + reentrant_invocations++; + scanChars(); + leftovers = chars.substring(nextchar, numchars); + reentrant_invocations--; + } + else { + // This is the re-entrant case, which we have to + // handle a little differently. + reentrant_invocations++; - if (!this._ensureHibernation()) { - if (dashDashMatch) { - this._createCommentToken(); - this.state = COMMENT_START_STATE; - } + // Save current scanner state + saved_scanner_state.push(chars, numchars, nextchar); - else if (doctypeMatch) - this.state = DOCTYPE_STATE; + // Set new scanner state + chars = s; + numchars = s.length; + nextchar = 0; - else if (cdataMatch) - this.state = CDATA_SECTION_STATE; + // Now scan as many of these new chars as we can + scanChars(); - else - this._reconsumeInState(BOGUS_COMMENT_STATE); - } -}; + leftovers = chars.substring(nextchar, numchars); + // restore old scanner state + nextchar = saved_scanner_state.pop(); + numchars = saved_scanner_state.pop(); + chars = saved_scanner_state.pop(); -//12.2.4.46 Comment start state -//------------------------------------------------------------------ -_[COMMENT_START_STATE] = function commentStartState(cp) { - if (cp === $.HYPHEN_MINUS) - this.state = COMMENT_START_DASH_STATE; + // If there were leftover chars from this invocation + // insert them into the pending invocation's buffer + // and trim already processed chars at the same time + if (leftovers) { + chars = leftovers + chars.substring(nextchar); + numchars = chars.length; + nextchar = 0; + leftovers = ""; + } - else if (cp === $.NULL) { - this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER; - this.state = COMMENT_STATE; + // Decrement the counter + reentrant_invocations--; + } } - - else if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); + }; + + + // This is the document we'll be building up + var doc = new Document(true, address); + + // The document needs to know about the parser, for document.write(). + // This _parser property will be deleted when we're done parsing. + doc._parser = htmlparser; + + // XXX I think that any document we use this parser on should support + // scripts. But I may need to configure that through a parser parameter + // Only documents with windows ("browsing contexts" to be precise) + // allow scripting. + doc._scripting_enabled = scripting_enabled; + + + /*** + * The actual code of the HTMLParser() factory function begins here. + */ + + if (fragmentContext) { // for innerHTML parsing + if (fragmentContext.ownerDocument._quirks) + doc._quirks = true; + if (fragmentContext.ownerDocument._limitedQuirks) + doc._limitedQuirks = true; + + // Set the initial tokenizer state + if (fragmentContext.namespaceURI === NAMESPACE.HTML) { + switch(fragmentContext.localName) { + case "title": + case "textarea": + tokenizer = rcdata_state; + break; + case "style": + case "xmp": + case "iframe": + case "noembed": + case "noframes": + case "script": + case "plaintext": + tokenizer = plaintext_state; + break; + case "noscript": + if (scripting_enabled) + tokenizer = plaintext_state; + } } - else if (cp === $.EOF) { - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); + var root = doc.createElement("html"); + doc._appendChild(root); + stack.push(root); + if (fragmentContext instanceof impl.HTMLTemplateElement) { + templateInsertionModes.push(in_template_mode); } + resetInsertionMode(); - else { - this.currentToken.data += toChar(cp); - this.state = COMMENT_STATE; + for(var e = fragmentContext; e !== null; e = e.parentElement) { + if (e instanceof impl.HTMLFormElement) { + form_element_pointer = e; + break; + } } -}; + } + + /*** + * Scanner functions + */ + // Loop through the characters in chars, and pass them one at a time + // to the tokenizer FSM. Return when no more characters can be processed + // (This may leave 1 or more characters in the buffer: like a CR + // waiting to see if the next char is LF, or for states that require + // lookahead...) + function scanChars() { + var codepoint, s, pattern, eof; + + while(nextchar < numchars) { + + // If we just tokenized a tag, then the paused flag + // may have been set to tell us to stop tokenizing while + // the script is loading + if (paused > 0) { + return; + } -//12.2.4.47 Comment start dash state -//------------------------------------------------------------------ -_[COMMENT_START_DASH_STATE] = function commentStartDashState(cp) { - if (cp === $.HYPHEN_MINUS) - this.state = COMMENT_END_STATE; + switch(typeof tokenizer.lookahead) { + case 'undefined': + codepoint = chars.charCodeAt(nextchar++); + if (scanner_skip_newline) { + scanner_skip_newline = false; + if (codepoint === 0x000A) { + nextchar++; + continue; + } + } + switch(codepoint) { + case 0x000D: + // CR always turns into LF, but if the next character + // is LF, then that second LF is skipped. + if (nextchar < numchars) { + if (chars.charCodeAt(nextchar) === 0x000A) + nextchar++; + } + else { + // We don't know the next char right now, so we + // can't check if it is a LF. So set a flag + scanner_skip_newline = true; + } - else if (cp === $.NULL) { - this.currentToken.data += '-'; - this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER; - this.state = COMMENT_STATE; - } + // In either case, emit a LF + tokenizer(0x000A); - else if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); - } + break; + case 0xFFFF: + if (input_complete && nextchar === numchars) { + tokenizer(EOF); // codepoint will be 0xFFFF here + break; + } + /* falls through */ + default: + tokenizer(codepoint); + break; + } + break; - else if (cp === $.EOF) { - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } + case 'number': + codepoint = chars.charCodeAt(nextchar); - else { - this.currentToken.data += '-'; - this.currentToken.data += toChar(cp); - this.state = COMMENT_STATE; - } -}; + // The only tokenizer states that require fixed lookahead + // only consume alphanum characters, so we don't have + // to worry about CR and LF in this case + // tokenizer wants n chars of lookahead + var n = tokenizer.lookahead; + var needsString = true; + if (n < 0) { + needsString = false; + n = -n; + } -//12.2.4.48 Comment state -//------------------------------------------------------------------ -_[COMMENT_STATE] = function commentState(cp) { - if (cp === $.HYPHEN_MINUS) - this.state = COMMENT_END_DASH_STATE; + if (n < numchars - nextchar) { + // If we can look ahead that far + s = needsString ? chars.substring(nextchar, nextchar+n) : null; + eof = false; + } + else { // if we don't have that many characters + if (input_complete) { // If no more are coming + // Just return what we have + s = needsString ? chars.substring(nextchar, numchars) : null; + eof = true; + if (codepoint === 0xFFFF && nextchar === numchars-1) + codepoint = EOF; + } + else { + // Return now and wait for more chars later + return; + } + } + tokenizer(codepoint, s, eof); + break; + case 'string': + codepoint = chars.charCodeAt(nextchar); + + // tokenizer wants characters up to a matching string + pattern = tokenizer.lookahead; + var pos = chars.indexOf(pattern, nextchar); + if (pos !== -1) { + s = chars.substring(nextchar, pos + pattern.length); + eof = false; + } + else { // No match + // If more characters coming, wait for them + if (!input_complete) return; + + // Otherwise, we've got to return what we've got + s = chars.substring(nextchar, numchars); + if (codepoint === 0xFFFF && nextchar === numchars-1) + codepoint = EOF; + eof = true; + } + + // The tokenizer states that require this kind of + // lookahead have to be careful to handle CR characters + // correctly + tokenizer(codepoint, s, eof); + break; + } + } + } - else if (cp === $.NULL) - this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER; - else if (cp === $.EOF) { - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); + /*** + * Tokenizer utility functions + */ + function addAttribute(name,value) { + // Make sure there isn't already an attribute with this name + // If there is, ignore this one. + for(var i = 0; i < attributes.length; i++) { + if (attributes[i][0] === name) return; } - else - this.currentToken.data += toChar(cp); -}; + if (value !== undefined) { + attributes.push([name, value]); + } + else { + attributes.push([name]); + } + } + + // Shortcut for simple attributes + function handleSimpleAttribute() { + SIMPLEATTR.lastIndex = nextchar-1; + var matched = SIMPLEATTR.exec(chars); + if (!matched) throw new Error("should never happen"); + var name = matched[1]; + if (!name) return false; + var value = matched[2]; + var len = value.length; + switch(value[0]) { + case '"': + case "'": + value = value.substring(1, len-1); + nextchar += (matched[0].length-1); + tokenizer = after_attribute_value_quoted_state; + break; + default: + tokenizer = before_attribute_name_state; + nextchar += (matched[0].length-1); + value = value.substring(0, len-1); + break; + } + + // Make sure there isn't already an attribute with this name + // If there is, ignore this one. + for(var i = 0; i < attributes.length; i++) { + if (attributes[i][0] === name) return true; + } + + attributes.push([name, value]); + return true; + } + + function beginTagName() { + is_end_tag = false; + tagnamebuf = ""; + attributes.length = 0; + } + function beginEndTagName() { + is_end_tag = true; + tagnamebuf = ""; + attributes.length = 0; + } + + function beginTempBuf() { tempbuf.length = 0; } + function beginAttrName() { attrnamebuf = ""; } + function beginAttrValue() { attrvaluebuf = ""; } + function beginComment() { commentbuf.length = 0; } + function beginDoctype() { + doctypenamebuf.length = 0; + doctypepublicbuf = null; + doctypesystembuf = null; + } + function beginDoctypePublicId() { doctypepublicbuf = []; } + function beginDoctypeSystemId() { doctypesystembuf = []; } + function forcequirks() { force_quirks = true; } + function cdataAllowed() { + return stack.top && + stack.top.namespaceURI !== "http://www.w3.org/1999/xhtml"; + } + + // Return true if the codepoints in the specified buffer match the + // characters of lasttagname + function appropriateEndTag(buf) { + return lasttagname === buf; + } + + function flushText() { + if (textrun.length > 0) { + var s = buf2str(textrun); + textrun.length = 0; + + if (ignore_linefeed) { + ignore_linefeed = false; + if (s[0] === "\n") s = s.substring(1); + if (s.length === 0) return; + } + insertToken(TEXT, s); + textIncludesNUL = false; + } + ignore_linefeed = false; + } + + // Consume chars matched by the pattern and return them as a string. Starts + // matching at the current position, so users should drop the current char + // otherwise. + function getMatchingChars(pattern) { + pattern.lastIndex = nextchar - 1; + var match = pattern.exec(chars); + if (match && match.index === nextchar - 1) { + match = match[0]; + nextchar += match.length - 1; + /* Careful! Make sure we haven't matched the EOF character! */ + if (input_complete && nextchar === numchars) { + // Oops, backup one. + match = match.slice(0, -1); + nextchar--; + } + return match; + } else { + throw new Error("should never happen"); + } + } + + // emit a string of chars that match a regexp + // Returns false if no chars matched. + function emitCharsWhile(pattern) { + pattern.lastIndex = nextchar-1; + var match = pattern.exec(chars)[0]; + if (!match) return false; + emitCharString(match); + nextchar += match.length - 1; + return true; + } -//12.2.4.49 Comment end dash state -//------------------------------------------------------------------ -_[COMMENT_END_DASH_STATE] = function commentEndDashState(cp) { - if (cp === $.HYPHEN_MINUS) - this.state = COMMENT_END_STATE; + // This is used by CDATA sections + function emitCharString(s) { + if (textrun.length > 0) flushText(); - else if (cp === $.NULL) { - this.currentToken.data += '-'; - this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER; - this.state = COMMENT_STATE; + if (ignore_linefeed) { + ignore_linefeed = false; + if (s[0] === "\n") s = s.substring(1); + if (s.length === 0) return; } - else if (cp === $.EOF) { - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } + insertToken(TEXT, s); + } + function emitTag() { + if (is_end_tag) insertToken(ENDTAG, tagnamebuf); else { - this.currentToken.data += '-'; - this.currentToken.data += toChar(cp); - this.state = COMMENT_STATE; + // Remember the last open tag we emitted + var tagname = tagnamebuf; + tagnamebuf = ""; + lasttagname = tagname; + insertToken(TAG, tagname, attributes); + } + } + + + // A shortcut: look ahead and if this is a open or close tag + // in lowercase with no spaces and no attributes, just emit it now. + function emitSimpleTag() { + SIMPLETAG.lastIndex = nextchar; + var matched = SIMPLETAG.exec(chars); + if (!matched) throw new Error("should never happen"); + var tagname = matched[2]; + if (!tagname) return false; + var endtag = matched[1]; + if (endtag) { + nextchar += (tagname.length+2); + insertToken(ENDTAG, tagname); } -}; - + else { + nextchar += (tagname.length+1); + lasttagname = tagname; + insertToken(TAG, tagname, NOATTRS); + } + return true; + } -//12.2.4.50 Comment end state -//------------------------------------------------------------------ -_[COMMENT_END_STATE] = function commentEndState(cp) { - if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); + function emitSelfClosingTag() { + if (is_end_tag) insertToken(ENDTAG, tagnamebuf, null, true); + else { + insertToken(TAG, tagnamebuf, attributes, true); } + } - else if (cp === $.EXCLAMATION_MARK) - this.state = COMMENT_END_BANG_STATE; + function emitDoctype() { + insertToken(DOCTYPE, + buf2str(doctypenamebuf), + doctypepublicbuf ? buf2str(doctypepublicbuf) : undefined, + doctypesystembuf ? buf2str(doctypesystembuf) : undefined); + } - else if (cp === $.HYPHEN_MINUS) - this.currentToken.data += '-'; + function emitEOF() { + flushText(); + parser(EOF); // EOF never goes to insertForeignContent() + doc.modclock = 1; // Start tracking modifications + } - else if (cp === $.NULL) { - this.currentToken.data += '--'; - this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER; - this.state = COMMENT_STATE; - } + // Insert a token, either using the current parser insertion mode + // (for HTML stuff) or using the insertForeignToken() method. + var insertToken = htmlparser.insertToken = function insertToken(t, value, arg3, arg4) { + flushText(); + var current = stack.top; - else if (cp === $.EOF) { - this._reconsumeInState(DATA_STATE); - this._emitCurrentToken(); + if (!current || current.namespaceURI === NAMESPACE.HTML) { + // This is the common case + parser(t, value, arg3, arg4); } - else { - this.currentToken.data += '--'; - this.currentToken.data += toChar(cp); - this.state = COMMENT_STATE; + // Otherwise we may need to insert this token as foreign content + if (t !== TAG && t !== TEXT) { + insertForeignToken(t, value, arg3, arg4); + } + else { + // But in some cases we treat it as regular content + if ((isMathmlTextIntegrationPoint(current) && + (t === TEXT || + (t === TAG && + value !== "mglyph" && value !== "malignmark"))) || + (t === TAG && + value === "svg" && + current.namespaceURI === NAMESPACE.MATHML && + current.localName === "annotation-xml") || + isHTMLIntegrationPoint(current)) { + + // XXX: the text_integration_mode stuff is an + // attempted bug workaround of mine + text_integration_mode = true; + parser(t, value, arg3, arg4); + text_integration_mode = false; + } + // Otherwise it is foreign content + else { + insertForeignToken(t, value, arg3, arg4); + } + } } -}; + }; + + + /*** + * Tree building utility functions + */ + function insertComment(data) { + var parent = stack.top; + if (foster_parent_mode && isA(parent, tablesectionrowSet)) { + fosterParent(function(doc) { return doc.createComment(data); }); + } else { + // "If the adjusted insertion location is inside a template element, + // let it instead be inside the template element's template contents" + if (parent instanceof impl.HTMLTemplateElement) { + parent = parent.content; + } + parent._appendChild(parent.ownerDocument.createComment(data)); + } + } + + function insertText(s) { + var parent = stack.top; + if (foster_parent_mode && isA(parent, tablesectionrowSet)) { + fosterParent(function(doc) { return doc.createTextNode(s); }); + } else { + // "If the adjusted insertion location is inside a template element, + // let it instead be inside the template element's template contents" + if (parent instanceof impl.HTMLTemplateElement) { + parent = parent.content; + } + // "If there is a Text node immediately before the adjusted insertion + // location, then append data to that Text node's data." + var lastChild = parent.lastChild; + if (lastChild && lastChild.nodeType === Node.TEXT_NODE) { + lastChild.appendData(s); + } else { + parent._appendChild(parent.ownerDocument.createTextNode(s)); + } + } + } + function createHTMLElt(doc, name, attrs) { + // Create the element this way, rather than with + // doc.createElement because createElement() does error + // checking on the element name that we need to avoid here. + var elt = html.createElement(doc, name, null); -//12.2.4.51 Comment end bang state -//------------------------------------------------------------------ -_[COMMENT_END_BANG_STATE] = function commentEndBangState(cp) { - if (cp === $.HYPHEN_MINUS) { - this.currentToken.data += '--!'; - this.state = COMMENT_END_DASH_STATE; + if (attrs) { + for(var i = 0, n = attrs.length; i < n; i++) { + // Use the _ version to avoid testing the validity + // of the attribute name + elt._setAttribute(attrs[i][0], attrs[i][1]); + } } + // XXX + // If the element is a resettable form element, + // run its reset algorithm now + // XXX + // handle case where form-element-pointer is not null + return elt; + } + + // The in_table insertion mode turns on this flag, and that makes + // insertHTMLElement use the foster parenting algorithm for elements + // tags inside a table + var foster_parent_mode = false; + + function insertHTMLElement(name, attrs) { + var elt = insertElement(function(doc) { + return createHTMLElt(doc, name, attrs); + }); + + // XXX + // If this is a form element, set its form attribute property here + if (isA(elt, formassociatedSet)) { + elt._form = form_element_pointer; + } + + return elt; + } + + // Insert the element into the open element or foster parent it + function insertElement(eltFunc) { + var elt; + if (foster_parent_mode && isA(stack.top, tablesectionrowSet)) { + elt = fosterParent(eltFunc); + } + else if (stack.top instanceof impl.HTMLTemplateElement) { + // "If the adjusted insertion location is inside a template element, + // let it instead be inside the template element's template contents" + elt = eltFunc(stack.top.content.ownerDocument); + stack.top.content._appendChild(elt); + } else { + elt = eltFunc(stack.top.ownerDocument); + stack.top._appendChild(elt); + } + + stack.push(elt); + return elt; + } + + function insertForeignElement(name, attrs, ns) { + return insertElement(function(doc) { + var elt = doc.createElementNS(ns, name); + if (attrs) { + for(var i = 0, n = attrs.length; i < n; i++) { + var attr = attrs[i]; + if (attr.length === 2) + elt._setAttribute(attr[0], attr[1]); + else { + elt._setAttributeNS(attr[2], attr[0], attr[1]); + } + } + } + return elt; + }); + } - else if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); + function lastElementOfType(type) { + for(var i = stack.elements.length-1; i >= 0; i--) { + if (stack.elements[i] instanceof type) { + return i; + } } + return -1; + } + + function fosterParent(eltFunc) { + var parent, before, lastTable = -1, lastTemplate = -1, elt; - else if (cp === $.NULL) { - this.currentToken.data += '--!'; - this.currentToken.data += UNICODE.REPLACEMENT_CHARACTER; - this.state = COMMENT_STATE; + lastTable = lastElementOfType(impl.HTMLTableElement); + lastTemplate = lastElementOfType(impl.HTMLTemplateElement); + + if (lastTemplate >= 0 && (lastTable < 0 || lastTemplate > lastTable)) { + parent = stack.elements[lastTemplate]; + } else if (lastTable >= 0) { + parent = stack.elements[lastTable].parentNode; + if (parent) { + before = stack.elements[lastTable]; + } else { + parent = stack.elements[lastTable - 1]; + } } + if (!parent) parent = stack.elements[0]; // the `html` element. - else if (cp === $.EOF) { - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); + // "If the adjusted insertion location is inside a template element, + // let it instead be inside the template element's template contents" + if (parent instanceof impl.HTMLTemplateElement) { + parent = parent.content; } + // Create element in the appropriate document. + elt = eltFunc(parent.ownerDocument); - else { - this.currentToken.data += '--!'; - this.currentToken.data += toChar(cp); - this.state = COMMENT_STATE; + if (elt.nodeType === Node.TEXT_NODE) { + var prev; + if (before) prev = before.previousSibling; + else prev = parent.lastChild; + if (prev && prev.nodeType === Node.TEXT_NODE) { + prev.appendData(elt.data); + return elt; + } } -}; + if (before) + parent.insertBefore(elt, before); + else + parent._appendChild(elt); + return elt; + } -//12.2.4.52 DOCTYPE state -//------------------------------------------------------------------ -_[DOCTYPE_STATE] = function doctypeState(cp) { - if (isWhitespace(cp)) + function resetInsertionMode() { + var last = false; + for(var i = stack.elements.length-1; i >= 0; i--) { + var node = stack.elements[i]; + if (i === 0) { + last = true; + if (fragment) { + node = fragmentContext; + } + } + if (node.namespaceURI === NAMESPACE.HTML) { + var tag = node.localName; + switch(tag) { + case "select": + for(var j = i; j > 0; ) { + var ancestor = stack.elements[--j]; + if (ancestor instanceof impl.HTMLTemplateElement) { + break; + } else if (ancestor instanceof impl.HTMLTableElement) { + parser = in_select_in_table_mode; + return; + } + } + parser = in_select_mode; + return; + case "tr": + parser = in_row_mode; + return; + case "tbody": + case "tfoot": + case "thead": + parser = in_table_body_mode; + return; + case "caption": + parser = in_caption_mode; + return; + case "colgroup": + parser = in_column_group_mode; + return; + case "table": + parser = in_table_mode; + return; + case "template": + parser = templateInsertionModes[templateInsertionModes.length-1]; + return; + case "body": + parser = in_body_mode; + return; + case "frameset": + parser = in_frameset_mode; + return; + case "html": + if (head_element_pointer === null) { + parser = before_head_mode; + } else { + parser = after_head_mode; + } + return; + default: + if (!last) { + if (tag === "head") { + parser = in_head_mode; + return; + } + if (tag === "td" || tag === "th") { + parser = in_cell_mode; + return; + } + } + } + } + if (last) { + parser = in_body_mode; return; - - else if (cp === $.GREATER_THAN_SIGN) { - this._createDoctypeToken(null); - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this.state = DATA_STATE; + } } + } - else if (cp === $.EOF) { - this._createDoctypeToken(null); - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } - else { - this._createDoctypeToken(''); - this._reconsumeInState(DOCTYPE_NAME_STATE); - } -}; + function parseRawText(name, attrs) { + insertHTMLElement(name, attrs); + tokenizer = rawtext_state; + originalInsertionMode = parser; + parser = text_mode; + } -//12.2.4.54 DOCTYPE name state -//------------------------------------------------------------------ -_[DOCTYPE_NAME_STATE] = function doctypeNameState(cp) { - if (isWhitespace(cp) || cp === $.GREATER_THAN_SIGN || cp === $.EOF) - this._reconsumeInState(AFTER_DOCTYPE_NAME_STATE); + function parseRCDATA(name, attrs) { + insertHTMLElement(name, attrs); + tokenizer = rcdata_state; + originalInsertionMode = parser; + parser = text_mode; + } - else if (isAsciiUpper(cp)) - this.currentToken.name += toAsciiLowerChar(cp); + // Make a copy of element i on the list of active formatting + // elements, using its original attributes, not current + // attributes (which may have been modified by a script) + function afeclone(doc, i) { + return { + elt: createHTMLElt(doc, afe.list[i].localName, afe.attrs[i]), + attrs: afe.attrs[i], + }; + } + + + function afereconstruct() { + if (afe.list.length === 0) return; + var entry = afe.list[afe.list.length-1]; + // If the last is a marker , do nothing + if (entry === afe.MARKER) return; + // Or if it is an open element, do nothing + if (stack.elements.lastIndexOf(entry) !== -1) return; + + // Loop backward through the list until we find a marker or an + // open element, and then move forward one from there. + for(var i = afe.list.length-2; i >= 0; i--) { + entry = afe.list[i]; + if (entry === afe.MARKER) break; + if (stack.elements.lastIndexOf(entry) !== -1) break; + } + + // Now loop forward, starting from the element after the current + // one, recreating formatting elements and pushing them back onto + // the list of open elements + for(i = i+1; i < afe.list.length; i++) { + var newelt = insertElement(function(doc) { return afeclone(doc, i).elt; }); + afe.list[i] = newelt; + } + } + + // Used by the adoptionAgency() function + var BOOKMARK = {localName:"BM"}; + + function adoptionAgency(tag) { + // If the current node is an HTML element whose tag name is subject, + // and the current node is not in the list of active formatting + // elements, then pop the current node off the stack of open + // elements and abort these steps. + if (isA(stack.top, tag) && afe.indexOf(stack.top) === -1) { + stack.pop(); + return true; // no more handling required + } + + // Let outer loop counter be zero. + var outer = 0; + + // Outer loop: If outer loop counter is greater than or + // equal to eight, then abort these steps. + while(outer < 8) { + // Increment outer loop counter by one. + outer++; + + // Let the formatting element be the last element in the list + // of active formatting elements that: is between the end of + // the list and the last scope marker in the list, if any, or + // the start of the list otherwise, and has the same tag name + // as the token. + var fmtelt = afe.findElementByTag(tag); + + // If there is no such node, then abort these steps and instead + // act as described in the "any other end tag" entry below. + if (!fmtelt) { + return false; // false means handle by the default case + } - else if (cp === $.NULL) - this.currentToken.name += UNICODE.REPLACEMENT_CHARACTER; + // Otherwise, if there is such a node, but that node is not in + // the stack of open elements, then this is a parse error; + // remove the element from the list, and abort these steps. + var index = stack.elements.lastIndexOf(fmtelt); + if (index === -1) { + afe.remove(fmtelt); + return true; // true means no more handling required + } - else - this.currentToken.name += toChar(cp); -}; + // Otherwise, if there is such a node, and that node is also in + // the stack of open elements, but the element is not in scope, + // then this is a parse error; ignore the token, and abort + // these steps. + if (!stack.elementInScope(fmtelt)) { + return true; + } + // Let the furthest block be the topmost node in the stack of + // open elements that is lower in the stack than the formatting + // element, and is an element in the special category. There + // might not be one. + var furthestblock = null, furthestblockindex; + for(var i = index+1; i < stack.elements.length; i++) { + if (isA(stack.elements[i], specialSet)) { + furthestblock = stack.elements[i]; + furthestblockindex = i; + break; + } + } -//12.2.4.55 After DOCTYPE name state -//------------------------------------------------------------------ -_[AFTER_DOCTYPE_NAME_STATE] = function afterDoctypeNameState(cp) { - if (isWhitespace(cp)) - return; + // If there is no furthest block, then the UA must skip the + // subsequent steps and instead just pop all the nodes from the + // bottom of the stack of open elements, from the current node + // up to and including the formatting element, and remove the + // formatting element from the list of active formatting + // elements. + if (!furthestblock) { + stack.popElement(fmtelt); + afe.remove(fmtelt); + return true; + } + else { + // Let the common ancestor be the element immediately above + // the formatting element in the stack of open elements. + var ancestor = stack.elements[index-1]; + + // Let a bookmark note the position of the formatting + // element in the list of active formatting elements + // relative to the elements on either side of it in the + // list. + afe.insertAfter(fmtelt, BOOKMARK); + + // Let node and last node be the furthest block. + var node = furthestblock; + var lastnode = furthestblock; + var nodeindex = furthestblockindex; + var nodeafeindex; + + // Let inner loop counter be zero. + var inner = 0; + + while (true) { + + // Increment inner loop counter by one. + inner++; + + // Let node be the element immediately above node in + // the stack of open elements, or if node is no longer + // in the stack of open elements (e.g. because it got + // removed by this algorithm), the element that was + // immediately above node in the stack of open elements + // before node was removed. + node = stack.elements[--nodeindex]; + + // If node is the formatting element, then go + // to the next step in the overall algorithm. + if (node === fmtelt) break; + + // If the inner loop counter is greater than three and node + // is in the list of active formatting elements, then remove + // node from the list of active formatting elements. + nodeafeindex = afe.indexOf(node); + if (inner > 3 && nodeafeindex !== -1) { + afe.remove(node); + nodeafeindex = -1; + } - if (cp === $.GREATER_THAN_SIGN) { - this.state = DATA_STATE; - this._emitCurrentToken(); - } + // If node is not in the list of active formatting + // elements, then remove node from the stack of open + // elements and then go back to the step labeled inner + // loop. + if (nodeafeindex === -1) { + stack.removeElement(node); + continue; + } - else { - var publicMatch = this._consumeSubsequentIfMatch($$.PUBLIC_STRING, cp, false), - systemMatch = !publicMatch && this._consumeSubsequentIfMatch($$.SYSTEM_STRING, cp, false); + // Create an element for the token for which the + // element node was created with common ancestor as + // the intended parent, replace the entry for node + // in the list of active formatting elements with an + // entry for the new element, replace the entry for + // node in the stack of open elements with an entry for + // the new element, and let node be the new element. + var newelt = afeclone(ancestor.ownerDocument, nodeafeindex); + afe.replace(node, newelt.elt, newelt.attrs); + stack.elements[nodeindex] = newelt.elt; + node = newelt.elt; + + // If last node is the furthest block, then move the + // aforementioned bookmark to be immediately after the + // new node in the list of active formatting elements. + if (lastnode === furthestblock) { + afe.remove(BOOKMARK); + afe.insertAfter(newelt.elt, BOOKMARK); + } - if (!this._ensureHibernation()) { - if (publicMatch) - this.state = BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE; + // Insert last node into node, first removing it from + // its previous parent node if any. + node._appendChild(lastnode); - else if (systemMatch) - this.state = BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE; + // Let last node be node. + lastnode = node; + } - else { - this.currentToken.forceQuirks = true; - this.state = BOGUS_DOCTYPE_STATE; - } + // If the common ancestor node is a table, tbody, tfoot, + // thead, or tr element, then, foster parent whatever last + // node ended up being in the previous step, first removing + // it from its previous parent node if any. + if (foster_parent_mode && isA(ancestor, tablesectionrowSet)) { + fosterParent(function() { return lastnode; }); + } + // Otherwise, append whatever last node ended up being in + // the previous step to the common ancestor node, first + // removing it from its previous parent node if any. + else if (ancestor instanceof impl.HTMLTemplateElement) { + ancestor.content._appendChild(lastnode); + } else { + ancestor._appendChild(lastnode); } - } -}; + // Create an element for the token for which the + // formatting element was created, with furthest block + // as the intended parent. + var newelt2 = afeclone(furthestblock.ownerDocument, afe.indexOf(fmtelt)); -//12.2.4.57 Before DOCTYPE public identifier state -//------------------------------------------------------------------ -_[BEFORE_DOCTYPE_PUBLIC_IDENTIFIER_STATE] = function beforeDoctypePublicIdentifierState(cp) { - if (isWhitespace(cp)) - return; + // Take all of the child nodes of the furthest block and + // append them to the element created in the last step. + while(furthestblock.hasChildNodes()) { + newelt2.elt._appendChild(furthestblock.firstChild); + } - if (cp === $.QUOTATION_MARK) { - this.currentToken.publicId = ''; - this.state = DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE; - } + // Append that new element to the furthest block. + furthestblock._appendChild(newelt2.elt); - else if (cp === $.APOSTROPHE) { - this.currentToken.publicId = ''; - this.state = DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE; - } + // Remove the formatting element from the list of active + // formatting elements, and insert the new element into the + // list of active formatting elements at the position of + // the aforementioned bookmark. + afe.remove(fmtelt); + afe.replace(BOOKMARK, newelt2.elt, newelt2.attrs); - else { - this.currentToken.forceQuirks = true; - this._reconsumeInState(BOGUS_DOCTYPE_STATE); + // Remove the formatting element from the stack of open + // elements, and insert the new element into the stack of + // open elements immediately below the position of the + // furthest block in that stack. + stack.removeElement(fmtelt); + var pos = stack.elements.lastIndexOf(furthestblock); + stack.elements.splice(pos+1, 0, newelt2.elt); + } } -}; + return true; + } -//12.2.4.58 DOCTYPE public identifier (double-quoted) state -//------------------------------------------------------------------ -_[DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED_STATE] = function doctypePublicIdentifierDoubleQuotedState(cp) { - if (cp === $.QUOTATION_MARK) - this.state = BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE; + // We do this when we get /script in in_text_mode + function handleScriptEnd() { + // XXX: + // This is just a stub implementation right now and doesn't run scripts. + // Getting this method right involves the event loop, URL resolution + // script fetching etc. For now I just want to be able to parse + // documents and test the parser. - else if (cp === $.NULL) - this.currentToken.publicId += UNICODE.REPLACEMENT_CHARACTER; + //var script = stack.top; + stack.pop(); + parser = originalInsertionMode; + //script._prepare(); + return; - else if (cp === $.GREATER_THAN_SIGN) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this.state = DATA_STATE; - } + // XXX: here is what this method is supposed to do - else if (cp === $.EOF) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } + // Provide a stable state. - else - this.currentToken.publicId += toChar(cp); -}; + // Let script be the current node (which will be a script + // element). + // Pop the current node off the stack of open elements. -//12.2.4.59 DOCTYPE public identifier (single-quoted) state -//------------------------------------------------------------------ -_[DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED_STATE] = function doctypePublicIdentifierSingleQuotedState(cp) { - if (cp === $.APOSTROPHE) - this.state = BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE; + // Switch the insertion mode to the original insertion mode. - else if (cp === $.NULL) - this.currentToken.publicId += UNICODE.REPLACEMENT_CHARACTER; - - else if (cp === $.GREATER_THAN_SIGN) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this.state = DATA_STATE; - } + // Let the old insertion point have the same value as the current + // insertion point. Let the insertion point be just before the + // next input character. - else if (cp === $.EOF) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } + // Increment the parser's script nesting level by one. - else - this.currentToken.publicId += toChar(cp); -}; + // Prepare the script. This might cause some script to execute, + // which might cause new characters to be inserted into the + // tokenizer, and might cause the tokenizer to output more tokens, + // resulting in a reentrant invocation of the parser. + // Decrement the parser's script nesting level by one. If the + // parser's script nesting level is zero, then set the parser + // pause flag to false. -//12.2.4.61 Between DOCTYPE public and system identifiers state -//------------------------------------------------------------------ -_[BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS_STATE] = function betweenDoctypePublicAndSystemIdentifiersState(cp) { - if (isWhitespace(cp)) - return; + // Let the insertion point have the value of the old insertion + // point. (In other words, restore the insertion point to its + // previous value. This value might be the "undefined" value.) - if (cp === $.GREATER_THAN_SIGN) { - this._emitCurrentToken(); - this.state = DATA_STATE; - } + // At this stage, if there is a pending parsing-blocking script, + // then: - else if (cp === $.QUOTATION_MARK) { - this.currentToken.systemId = ''; - this.state = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; - } + // If the script nesting level is not zero: + // Set the parser pause flag to true, and abort the processing + // of any nested invocations of the tokenizer, yielding + // control back to the caller. (Tokenization will resume when + // the caller returns to the "outer" tree construction stage.) - else if (cp === $.APOSTROPHE) { - this.currentToken.systemId = ''; - this.state = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; + // The tree construction stage of this particular parser is + // being called reentrantly, say from a call to + // document.write(). + + // Otherwise: + + // Run these steps: + + // Let the script be the pending parsing-blocking + // script. There is no longer a pending + // parsing-blocking script. + + // Block the tokenizer for this instance of the HTML + // parser, such that the event loop will not run tasks + // that invoke the tokenizer. + + // If the parser's Document has a style sheet that is + // blocking scripts or the script's "ready to be + // parser-executed" flag is not set: spin the event + // loop until the parser's Document has no style sheet + // that is blocking scripts and the script's "ready to + // be parser-executed" flag is set. + + // Unblock the tokenizer for this instance of the HTML + // parser, such that tasks that invoke the tokenizer + // can again be run. + + // Let the insertion point be just before the next + // input character. + + // Increment the parser's script nesting level by one + // (it should be zero before this step, so this sets + // it to one). + + // Execute the script. + + // Decrement the parser's script nesting level by + // one. If the parser's script nesting level is zero + // (which it always should be at this point), then set + // the parser pause flag to false. + + // Let the insertion point be undefined again. + + // If there is once again a pending parsing-blocking + // script, then repeat these steps from step 1. + + + } + + function stopParsing() { + // XXX This is just a temporary implementation to get the parser working. + // A full implementation involves scripts and events and the event loop. + + // Remove the link from document to parser. + // This is instead of "set the insertion point to undefined". + // It means that document.write() can't write into the doc anymore. + delete doc._parser; + + stack.elements.length = 0; // pop everything off + + // If there is a window object associated with the document + // then trigger an load event on it + if (doc.defaultView) { + doc.defaultView.dispatchEvent(new impl.Event("load",{})); + } + + } + + /**** + * Tokenizer states + */ + + /** + * This file was partially mechanically generated from + * http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html + * + * After mechanical conversion, it was further converted from + * prose to JS by hand, but the intent is that it is a very + * faithful rendering of the HTML tokenization spec in + * JavaScript. + * + * It is not a goal of this tokenizer to detect or report + * parse errors. + * + * XXX The tokenizer is supposed to work with straight UTF32 + * codepoints. But I don't think it has any dependencies on + * any character outside of the BMP so I think it is safe to + * pass it UTF16 characters. I don't think it will ever change + * state in the middle of a surrogate pair. + */ + + /* + * Each state is represented by a function. For most states, the + * scanner simply passes the next character (as an integer + * codepoint) to the current state function and automatically + * consumes the character. If the state function can't process + * the character it can call pushback() to push it back to the + * scanner. + * + * Some states require lookahead, though. If a state function has + * a lookahead property, then it is invoked differently. In this + * case, the scanner invokes the function with 3 arguments: 1) the + * next codepoint 2) a string of lookahead text 3) a boolean that + * is true if the lookahead goes all the way to the EOF. (XXX + * actually maybe this third is not necessary... the lookahead + * could just include \uFFFF?) + * + * If the lookahead property of a state function is an integer, it + * specifies the number of characters required. If it is a string, + * then the scanner will scan for that string and return all + * characters up to and including that sequence, or up to EOF. If + * the lookahead property is a regexp, then the scanner will match + * the regexp at the current point and return the matching string. + * + * States that require lookahead are responsible for explicitly + * consuming the characters they process. They do this by + * incrementing nextchar by the number of processed characters. + */ + function reconsume(c, new_state) { + tokenizer = new_state; + nextchar--; // pushback + } + + function data_state(c) { + switch(c) { + case 0x0026: // AMPERSAND + return_state = data_state; + tokenizer = character_reference_state; + break; + case 0x003C: // LESS-THAN SIGN + if (emitSimpleTag()) // Shortcut for

,

, etc. + break; + tokenizer = tag_open_state; + break; + case 0x0000: // NULL + // Usually null characters emitted by the tokenizer will be + // ignored by the tree builder, but sometimes they'll be + // converted to \uFFFD. I don't want to have the search every + // string emitted to replace NULs, so I'll set a flag + // if I've emitted a NUL. + textrun.push(c); + textIncludesNUL = true; + break; + case -1: // EOF + emitEOF(); + break; + default: + // Instead of just pushing a single character and then + // coming back to the very same place, lookahead and + // emit everything we can at once. + /*jshint -W030 */ + emitCharsWhile(DATATEXT) || textrun.push(c); + break; + } + } + + function rcdata_state(c) { + // Save the open tag so we can find a matching close tag + switch(c) { + case 0x0026: // AMPERSAND + return_state = rcdata_state; + tokenizer = character_reference_state; + break; + case 0x003C: // LESS-THAN SIGN + tokenizer = rcdata_less_than_sign_state; + break; + case 0x0000: // NULL + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + textIncludesNUL = true; + break; + case -1: // EOF + emitEOF(); + break; + default: + textrun.push(c); + break; + } + } + + function rawtext_state(c) { + switch(c) { + case 0x003C: // LESS-THAN SIGN + tokenizer = rawtext_less_than_sign_state; + break; + case 0x0000: // NULL + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + /*jshint -W030 */ + emitCharsWhile(RAWTEXT) || textrun.push(c); + break; + } + } + + function script_data_state(c) { + switch(c) { + case 0x003C: // LESS-THAN SIGN + tokenizer = script_data_less_than_sign_state; + break; + case 0x0000: // NULL + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + /*jshint -W030 */ + emitCharsWhile(RAWTEXT) || textrun.push(c); + break; + } + } + + function plaintext_state(c) { + switch(c) { + case 0x0000: // NULL + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + /*jshint -W030 */ + emitCharsWhile(PLAINTEXT) || textrun.push(c); + break; + } + } + + function tag_open_state(c) { + switch(c) { + case 0x0021: // EXCLAMATION MARK + tokenizer = markup_declaration_open_state; + break; + case 0x002F: // SOLIDUS + tokenizer = end_tag_open_state; + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + beginTagName(); + reconsume(c, tag_name_state); + break; + case 0x003F: // QUESTION MARK + reconsume(c, bogus_comment_state); + break; + default: + textrun.push(0x003C); // LESS-THAN SIGN + reconsume(c, data_state); + break; + } + } + + function end_tag_open_state(c) { + switch(c) { + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + beginEndTagName(); + reconsume(c, tag_name_state); + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + break; + case -1: // EOF + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + emitEOF(); + break; + default: + reconsume(c, bogus_comment_state); + break; + } + } + + function tag_name_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + tokenizer = before_attribute_name_state; + break; + case 0x002F: // SOLIDUS + tokenizer = self_closing_start_tag_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitTag(); + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + tagnamebuf += String.fromCharCode(c + 0x0020); + break; + case 0x0000: // NULL + tagnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case -1: // EOF + emitEOF(); + break; + default: + tagnamebuf += getMatchingChars(TAGNAME); + break; + } + } + + function rcdata_less_than_sign_state(c) { + /* identical to the RAWTEXT less-than sign state, except s/RAWTEXT/RCDATA/g */ + if (c === 0x002F) { // SOLIDUS + beginTempBuf(); + tokenizer = rcdata_end_tag_open_state; + } + else { + textrun.push(0x003C); // LESS-THAN SIGN + reconsume(c, rcdata_state); + } + } + + function rcdata_end_tag_open_state(c) { + /* identical to the RAWTEXT (and Script data) end tag open state, except s/RAWTEXT/RCDATA/g */ + switch(c) { + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + beginEndTagName(); + reconsume(c, rcdata_end_tag_name_state); + break; + default: + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + reconsume(c, rcdata_state); + break; + } + } + + function rcdata_end_tag_name_state(c) { + /* identical to the RAWTEXT (and Script data) end tag name state, except s/RAWTEXT/RCDATA/g */ + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + if (appropriateEndTag(tagnamebuf)) { + tokenizer = before_attribute_name_state; + return; + } + break; + case 0x002F: // SOLIDUS + if (appropriateEndTag(tagnamebuf)) { + tokenizer = self_closing_start_tag_state; + return; + } + break; + case 0x003E: // GREATER-THAN SIGN + if (appropriateEndTag(tagnamebuf)) { + tokenizer = data_state; + emitTag(); + return; + } + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + + tagnamebuf += String.fromCharCode(c + 0x0020); + tempbuf.push(c); + return; + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + + tagnamebuf += String.fromCharCode(c); + tempbuf.push(c); + return; + default: + break; + } + + // If we don't return in one of the cases above, then this was not + // an appropriately matching close tag, so back out by emitting all + // the characters as text + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + pushAll(textrun, tempbuf); + reconsume(c, rcdata_state); + } + + function rawtext_less_than_sign_state(c) { + /* identical to the RCDATA less-than sign state, except s/RCDATA/RAWTEXT/g + */ + if (c === 0x002F) { // SOLIDUS + beginTempBuf(); + tokenizer = rawtext_end_tag_open_state; + } + else { + textrun.push(0x003C); // LESS-THAN SIGN + reconsume(c, rawtext_state); + } + } + + function rawtext_end_tag_open_state(c) { + /* identical to the RCDATA (and Script data) end tag open state, except s/RCDATA/RAWTEXT/g */ + switch(c) { + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + beginEndTagName(); + reconsume(c, rawtext_end_tag_name_state); + break; + default: + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + reconsume(c, rawtext_state); + break; + } + } + + function rawtext_end_tag_name_state(c) { + /* identical to the RCDATA (and Script data) end tag name state, except s/RCDATA/RAWTEXT/g */ + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + if (appropriateEndTag(tagnamebuf)) { + tokenizer = before_attribute_name_state; + return; + } + break; + case 0x002F: // SOLIDUS + if (appropriateEndTag(tagnamebuf)) { + tokenizer = self_closing_start_tag_state; + return; + } + break; + case 0x003E: // GREATER-THAN SIGN + if (appropriateEndTag(tagnamebuf)) { + tokenizer = data_state; + emitTag(); + return; + } + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + tagnamebuf += String.fromCharCode(c + 0x0020); + tempbuf.push(c); + return; + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + tagnamebuf += String.fromCharCode(c); + tempbuf.push(c); + return; + default: + break; + } + + // If we don't return in one of the cases above, then this was not + // an appropriately matching close tag, so back out by emitting all + // the characters as text + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + pushAll(textrun,tempbuf); + reconsume(c, rawtext_state); + } + + function script_data_less_than_sign_state(c) { + switch(c) { + case 0x002F: // SOLIDUS + beginTempBuf(); + tokenizer = script_data_end_tag_open_state; + break; + case 0x0021: // EXCLAMATION MARK + tokenizer = script_data_escape_start_state; + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x0021); // EXCLAMATION MARK + break; + default: + textrun.push(0x003C); // LESS-THAN SIGN + reconsume(c, script_data_state); + break; + } + } + + function script_data_end_tag_open_state(c) { + /* identical to the RCDATA (and RAWTEXT) end tag open state, except s/RCDATA/Script data/g */ + switch(c) { + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + beginEndTagName(); + reconsume(c, script_data_end_tag_name_state); + break; + default: + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + reconsume(c, script_data_state); + break; + } + } + + function script_data_end_tag_name_state(c) { + /* identical to the RCDATA (and RAWTEXT) end tag name state, except s/RCDATA/Script data/g */ + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + if (appropriateEndTag(tagnamebuf)) { + tokenizer = before_attribute_name_state; + return; + } + break; + case 0x002F: // SOLIDUS + if (appropriateEndTag(tagnamebuf)) { + tokenizer = self_closing_start_tag_state; + return; + } + break; + case 0x003E: // GREATER-THAN SIGN + if (appropriateEndTag(tagnamebuf)) { + tokenizer = data_state; + emitTag(); + return; + } + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + + tagnamebuf += String.fromCharCode(c + 0x0020); + tempbuf.push(c); + return; + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + + tagnamebuf += String.fromCharCode(c); + tempbuf.push(c); + return; + default: + break; + } + + // If we don't return in one of the cases above, then this was not + // an appropriately matching close tag, so back out by emitting all + // the characters as text + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + pushAll(textrun,tempbuf); + reconsume(c, script_data_state); + } + + function script_data_escape_start_state(c) { + if (c === 0x002D) { // HYPHEN-MINUS + tokenizer = script_data_escape_start_dash_state; + textrun.push(0x002D); // HYPHEN-MINUS } + else { + reconsume(c, script_data_state); + } + } + function script_data_escape_start_dash_state(c) { + if (c === 0x002D) { // HYPHEN-MINUS + tokenizer = script_data_escaped_dash_dash_state; + textrun.push(0x002D); // HYPHEN-MINUS + } + else { + reconsume(c, script_data_state); + } + } + + function script_data_escaped_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = script_data_escaped_dash_state; + textrun.push(0x002D); // HYPHEN-MINUS + break; + case 0x003C: // LESS-THAN SIGN + tokenizer = script_data_escaped_less_than_sign_state; + break; + case 0x0000: // NULL + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + textrun.push(c); + break; + } + } + + function script_data_escaped_dash_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = script_data_escaped_dash_dash_state; + textrun.push(0x002D); // HYPHEN-MINUS + break; + case 0x003C: // LESS-THAN SIGN + tokenizer = script_data_escaped_less_than_sign_state; + break; + case 0x0000: // NULL + tokenizer = script_data_escaped_state; + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + tokenizer = script_data_escaped_state; + textrun.push(c); + break; + } + } + + function script_data_escaped_dash_dash_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + textrun.push(0x002D); // HYPHEN-MINUS + break; + case 0x003C: // LESS-THAN SIGN + tokenizer = script_data_escaped_less_than_sign_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = script_data_state; + textrun.push(0x003E); // GREATER-THAN SIGN + break; + case 0x0000: // NULL + tokenizer = script_data_escaped_state; + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + tokenizer = script_data_escaped_state; + textrun.push(c); + break; + } + } + + function script_data_escaped_less_than_sign_state(c) { + switch(c) { + case 0x002F: // SOLIDUS + beginTempBuf(); + tokenizer = script_data_escaped_end_tag_open_state; + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + beginTempBuf(); + textrun.push(0x003C); // LESS-THAN SIGN + reconsume(c, script_data_double_escape_start_state); + break; + default: + textrun.push(0x003C); // LESS-THAN SIGN + reconsume(c, script_data_escaped_state); + break; + } + } + + function script_data_escaped_end_tag_open_state(c) { + switch(c) { + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + beginEndTagName(); + reconsume(c, script_data_escaped_end_tag_name_state); + break; + default: + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + reconsume(c, script_data_escaped_state); + break; + } + } + + function script_data_escaped_end_tag_name_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + if (appropriateEndTag(tagnamebuf)) { + tokenizer = before_attribute_name_state; + return; + } + break; + case 0x002F: // SOLIDUS + if (appropriateEndTag(tagnamebuf)) { + tokenizer = self_closing_start_tag_state; + return; + } + break; + case 0x003E: // GREATER-THAN SIGN + if (appropriateEndTag(tagnamebuf)) { + tokenizer = data_state; + emitTag(); + return; + } + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + tagnamebuf += String.fromCharCode(c + 0x0020); + tempbuf.push(c); + return; + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + tagnamebuf += String.fromCharCode(c); + tempbuf.push(c); + return; + default: + break; + } + + // We get here in the default case, and if the closing tagname + // is not an appropriate tagname. + textrun.push(0x003C); // LESS-THAN SIGN + textrun.push(0x002F); // SOLIDUS + pushAll(textrun,tempbuf); + reconsume(c, script_data_escaped_state); + } + + function script_data_double_escape_start_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + case 0x002F: // SOLIDUS + case 0x003E: // GREATER-THAN SIGN + if (buf2str(tempbuf) === "script") { + tokenizer = script_data_double_escaped_state; + } + else { + tokenizer = script_data_escaped_state; + } + textrun.push(c); + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + tempbuf.push(c + 0x0020); + textrun.push(c); + break; + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + tempbuf.push(c); + textrun.push(c); + break; + default: + reconsume(c, script_data_escaped_state); + break; + } + } + + function script_data_double_escaped_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = script_data_double_escaped_dash_state; + textrun.push(0x002D); // HYPHEN-MINUS + break; + case 0x003C: // LESS-THAN SIGN + tokenizer = script_data_double_escaped_less_than_sign_state; + textrun.push(0x003C); // LESS-THAN SIGN + break; + case 0x0000: // NULL + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + textrun.push(c); + break; + } + } + + function script_data_double_escaped_dash_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = script_data_double_escaped_dash_dash_state; + textrun.push(0x002D); // HYPHEN-MINUS + break; + case 0x003C: // LESS-THAN SIGN + tokenizer = script_data_double_escaped_less_than_sign_state; + textrun.push(0x003C); // LESS-THAN SIGN + break; + case 0x0000: // NULL + tokenizer = script_data_double_escaped_state; + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + tokenizer = script_data_double_escaped_state; + textrun.push(c); + break; + } + } + + function script_data_double_escaped_dash_dash_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + textrun.push(0x002D); // HYPHEN-MINUS + break; + case 0x003C: // LESS-THAN SIGN + tokenizer = script_data_double_escaped_less_than_sign_state; + textrun.push(0x003C); // LESS-THAN SIGN + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = script_data_state; + textrun.push(0x003E); // GREATER-THAN SIGN + break; + case 0x0000: // NULL + tokenizer = script_data_double_escaped_state; + textrun.push(0xFFFD); // REPLACEMENT CHARACTER + break; + case -1: // EOF + emitEOF(); + break; + default: + tokenizer = script_data_double_escaped_state; + textrun.push(c); + break; + } + } + + function script_data_double_escaped_less_than_sign_state(c) { + if (c === 0x002F) { // SOLIDUS + beginTempBuf(); + tokenizer = script_data_double_escape_end_state; + textrun.push(0x002F); // SOLIDUS + } else { - this.currentToken.forceQuirks = true; - this._reconsumeInState(BOGUS_DOCTYPE_STATE); + reconsume(c, script_data_double_escaped_state); + } + } + + function script_data_double_escape_end_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + case 0x002F: // SOLIDUS + case 0x003E: // GREATER-THAN SIGN + if (buf2str(tempbuf) === "script") { + tokenizer = script_data_escaped_state; + } + else { + tokenizer = script_data_double_escaped_state; + } + textrun.push(c); + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + tempbuf.push(c + 0x0020); + textrun.push(c); + break; + case 0x0061: // [a-z] + case 0x0062:case 0x0063:case 0x0064:case 0x0065:case 0x0066: + case 0x0067:case 0x0068:case 0x0069:case 0x006A:case 0x006B: + case 0x006C:case 0x006D:case 0x006E:case 0x006F:case 0x0070: + case 0x0071:case 0x0072:case 0x0073:case 0x0074:case 0x0075: + case 0x0076:case 0x0077:case 0x0078:case 0x0079:case 0x007A: + tempbuf.push(c); + textrun.push(c); + break; + default: + reconsume(c, script_data_double_escaped_state); + break; + } + } + + function before_attribute_name_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + /* Ignore the character. */ + break; + // For SOLIDUS, GREATER-THAN SIGN, and EOF, spec says "reconsume in + // the after attribute name state", but in our implementation that + // state always has an active attribute in attrnamebuf. Just clone + // the rules here, without the addAttribute business. + case 0x002F: // SOLIDUS + tokenizer = self_closing_start_tag_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitTag(); + break; + case -1: // EOF + emitEOF(); + break; + case 0x003D: // EQUALS SIGN + beginAttrName(); + attrnamebuf += String.fromCharCode(c); + tokenizer = attribute_name_state; + break; + default: + if (handleSimpleAttribute()) break; + beginAttrName(); + reconsume(c, attribute_name_state); + break; + } + } + + // beginAttrName() must have been called before this point + // There is an active attribute in attrnamebuf (but not attrvaluebuf) + function attribute_name_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + case 0x002F: // SOLIDUS + case 0x003E: // GREATER-THAN SIGN + case -1: // EOF + reconsume(c, after_attribute_name_state); + break; + case 0x003D: // EQUALS SIGN + tokenizer = before_attribute_value_state; + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + attrnamebuf += String.fromCharCode(c + 0x0020); + break; + case 0x0000: // NULL + attrnamebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case 0x0022: // QUOTATION MARK + case 0x0027: // APOSTROPHE + case 0x003C: // LESS-THAN SIGN + /* falls through */ + default: + attrnamebuf += getMatchingChars(ATTRNAME); + break; + } + } + + // There is an active attribute in attrnamebuf, but not yet in attrvaluebuf. + function after_attribute_name_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + /* Ignore the character. */ + break; + case 0x002F: // SOLIDUS + // Keep in sync with before_attribute_name_state. + addAttribute(attrnamebuf); + tokenizer = self_closing_start_tag_state; + break; + case 0x003D: // EQUALS SIGN + tokenizer = before_attribute_value_state; + break; + case 0x003E: // GREATER-THAN SIGN + // Keep in sync with before_attribute_name_state. + tokenizer = data_state; + addAttribute(attrnamebuf); + emitTag(); + break; + case -1: // EOF + // Keep in sync with before_attribute_name_state. + addAttribute(attrnamebuf); + emitEOF(); + break; + default: + addAttribute(attrnamebuf); + beginAttrName(); + reconsume(c, attribute_name_state); + break; + } + } + + function before_attribute_value_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + /* Ignore the character. */ + break; + case 0x0022: // QUOTATION MARK + beginAttrValue(); + tokenizer = attribute_value_double_quoted_state; + break; + case 0x0027: // APOSTROPHE + beginAttrValue(); + tokenizer = attribute_value_single_quoted_state; + break; + case 0x003E: // GREATER-THAN SIGN + /* falls through */ + default: + beginAttrValue(); + reconsume(c, attribute_value_unquoted_state); + break; + } + } + + function attribute_value_double_quoted_state(c) { + switch(c) { + case 0x0022: // QUOTATION MARK + addAttribute(attrnamebuf, attrvaluebuf); + tokenizer = after_attribute_value_quoted_state; + break; + case 0x0026: // AMPERSAND + return_state = attribute_value_double_quoted_state; + tokenizer = character_reference_state; + break; + case 0x0000: // NULL + attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case -1: // EOF + emitEOF(); + break; + case 0x000A: // LF + // this could be a converted \r, so don't use getMatchingChars + attrvaluebuf += String.fromCharCode(c); + break; + default: + attrvaluebuf += getMatchingChars(DBLQUOTEATTRVAL); + break; + } + } + + function attribute_value_single_quoted_state(c) { + switch(c) { + case 0x0027: // APOSTROPHE + addAttribute(attrnamebuf, attrvaluebuf); + tokenizer = after_attribute_value_quoted_state; + break; + case 0x0026: // AMPERSAND + return_state = attribute_value_single_quoted_state; + tokenizer = character_reference_state; + break; + case 0x0000: // NULL + attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case -1: // EOF + emitEOF(); + break; + case 0x000A: // LF + // this could be a converted \r, so don't use getMatchingChars + attrvaluebuf += String.fromCharCode(c); + break; + default: + attrvaluebuf += getMatchingChars(SINGLEQUOTEATTRVAL); + break; + } + } + + function attribute_value_unquoted_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + addAttribute(attrnamebuf, attrvaluebuf); + tokenizer = before_attribute_name_state; + break; + case 0x0026: // AMPERSAND + return_state = attribute_value_unquoted_state; + tokenizer = character_reference_state; + break; + case 0x003E: // GREATER-THAN SIGN + addAttribute(attrnamebuf, attrvaluebuf); + tokenizer = data_state; + emitTag(); + break; + case 0x0000: // NULL + attrvaluebuf += String.fromCharCode(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case -1: // EOF + nextchar--; // pushback + tokenizer = data_state; + break; + case 0x0022: // QUOTATION MARK + case 0x0027: // APOSTROPHE + case 0x003C: // LESS-THAN SIGN + case 0x003D: // EQUALS SIGN + case 0x0060: // GRAVE ACCENT + /* falls through */ + default: + attrvaluebuf += getMatchingChars(UNQUOTEDATTRVAL); + break; + } + } + + function after_attribute_value_quoted_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + tokenizer = before_attribute_name_state; + break; + case 0x002F: // SOLIDUS + tokenizer = self_closing_start_tag_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitTag(); + break; + case -1: // EOF + emitEOF(); + break; + default: + reconsume(c, before_attribute_name_state); + break; + } + } + + function self_closing_start_tag_state(c) { + switch(c) { + case 0x003E: // GREATER-THAN SIGN + // Set the self-closing flag of the current tag token. + tokenizer = data_state; + emitSelfClosingTag(true); + break; + case -1: // EOF + emitEOF(); + break; + default: + reconsume(c, before_attribute_name_state); + break; + } + } + + function bogus_comment_state(c, lookahead, eof) { + var len = lookahead.length; + + if (eof) { + nextchar += len-1; // don't consume the eof + } + else { + nextchar += len; } -}; + var comment = lookahead.substring(0, len-1); -//12.2.4.63 Before DOCTYPE system identifier state -//------------------------------------------------------------------ -_[BEFORE_DOCTYPE_SYSTEM_IDENTIFIER_STATE] = function beforeDoctypeSystemIdentifierState(cp) { - if (isWhitespace(cp)) - return; + comment = comment.replace(/\u0000/g,"\uFFFD"); + comment = comment.replace(/\u000D\u000A/g,"\u000A"); + comment = comment.replace(/\u000D/g,"\u000A"); - if (cp === $.QUOTATION_MARK) { - this.currentToken.systemId = ''; - this.state = DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE; - } + insertToken(COMMENT, comment); + tokenizer = data_state; + } + bogus_comment_state.lookahead = ">"; - else if (cp === $.APOSTROPHE) { - this.currentToken.systemId = ''; - this.state = DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE; + function markup_declaration_open_state(c, lookahead, eof) { + if (lookahead[0] === "-" && lookahead[1] === "-") { + nextchar += 2; + beginComment(); + tokenizer = comment_start_state; + return; } + if (lookahead.toUpperCase() === "DOCTYPE") { + nextchar += 7; + tokenizer = doctype_state; + } + else if (lookahead === "[CDATA[" && cdataAllowed()) { + nextchar += 7; + tokenizer = cdata_section_state; + } else { - this.currentToken.forceQuirks = true; - this._reconsumeInState(BOGUS_DOCTYPE_STATE); + tokenizer = bogus_comment_state; + } + } + markup_declaration_open_state.lookahead = 7; + + function comment_start_state(c) { + beginComment(); + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = comment_start_dash_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + insertToken(COMMENT, buf2str(commentbuf)); + break; /* see comment in comment end state */ + default: + reconsume(c, comment_state); + break; + } + } + + function comment_start_dash_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = comment_end_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + insertToken(COMMENT, buf2str(commentbuf)); + break; + case -1: // EOF + insertToken(COMMENT, buf2str(commentbuf)); + emitEOF(); + break; /* see comment in comment end state */ + default: + commentbuf.push(0x002D /* HYPHEN-MINUS */); + reconsume(c, comment_state); + break; + } + } + + function comment_state(c) { + switch(c) { + case 0x003C: // LESS-THAN SIGN + commentbuf.push(c); + tokenizer = comment_less_than_sign_state; + break; + case 0x002D: // HYPHEN-MINUS + tokenizer = comment_end_dash_state; + break; + case 0x0000: // NULL + commentbuf.push(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case -1: // EOF + insertToken(COMMENT, buf2str(commentbuf)); + emitEOF(); + break; /* see comment in comment end state */ + default: + commentbuf.push(c); + break; + } + } + + function comment_less_than_sign_state(c) { + switch(c) { + case 0x0021: // EXCLAMATION MARK + commentbuf.push(c); + tokenizer = comment_less_than_sign_bang_state; + break; + case 0x003C: // LESS-THAN SIGN + commentbuf.push(c); + break; + default: + reconsume(c, comment_state); + break; + } + } + + function comment_less_than_sign_bang_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = comment_less_than_sign_bang_dash_state; + break; + default: + reconsume(c, comment_state); + break; + } + } + + function comment_less_than_sign_bang_dash_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = comment_less_than_sign_bang_dash_dash_state; + break; + default: + reconsume(c, comment_end_dash_state); + break; + } + } + + function comment_less_than_sign_bang_dash_dash_state(c) { + switch(c) { + case 0x003E: // GREATER-THAN SIGN + case -1: // EOF + reconsume(c, comment_end_state); + break; + default: + // parse error + reconsume(c, comment_end_state); + break; + } + } + + function comment_end_dash_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + tokenizer = comment_end_state; + break; + case -1: // EOF + insertToken(COMMENT, buf2str(commentbuf)); + emitEOF(); + break; /* see comment in comment end state */ + default: + commentbuf.push(0x002D /* HYPHEN-MINUS */); + reconsume(c, comment_state); + break; + } + } + + function comment_end_state(c) { + switch(c) { + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + insertToken(COMMENT, buf2str(commentbuf)); + break; + case 0x0021: // EXCLAMATION MARK + tokenizer = comment_end_bang_state; + break; + case 0x002D: // HYPHEN-MINUS + commentbuf.push(0x002D); + break; + case -1: // EOF + insertToken(COMMENT, buf2str(commentbuf)); + emitEOF(); + break; /* For security reasons: otherwise, hostile user could put a script in a comment e.g. in a blog comment and then DOS the server so that the end tag isn't read, and then the commented script tag would be treated as live code */ + default: + commentbuf.push(0x002D); + commentbuf.push(0x002D); + reconsume(c, comment_state); + break; + } + } + + function comment_end_bang_state(c) { + switch(c) { + case 0x002D: // HYPHEN-MINUS + commentbuf.push(0x002D); + commentbuf.push(0x002D); + commentbuf.push(0x0021); + tokenizer = comment_end_dash_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + insertToken(COMMENT, buf2str(commentbuf)); + break; + case -1: // EOF + insertToken(COMMENT, buf2str(commentbuf)); + emitEOF(); + break; /* see comment in comment end state */ + default: + commentbuf.push(0x002D); + commentbuf.push(0x002D); + commentbuf.push(0x0021); + reconsume(c, comment_state); + break; + } + } + + function doctype_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + tokenizer = before_doctype_name_state; + break; + case -1: // EOF + beginDoctype(); + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + reconsume(c, before_doctype_name_state); + break; + } + } + + function before_doctype_name_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + /* Ignore the character. */ + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + beginDoctype(); + doctypenamebuf.push(c + 0x0020); + tokenizer = doctype_name_state; + break; + case 0x0000: // NULL + beginDoctype(); + doctypenamebuf.push(0xFFFD); + tokenizer = doctype_name_state; + break; + case 0x003E: // GREATER-THAN SIGN + beginDoctype(); + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + beginDoctype(); + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + beginDoctype(); + doctypenamebuf.push(c); + tokenizer = doctype_name_state; + break; + } + } + + function doctype_name_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + tokenizer = after_doctype_name_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitDoctype(); + break; + case 0x0041: // [A-Z] + case 0x0042:case 0x0043:case 0x0044:case 0x0045:case 0x0046: + case 0x0047:case 0x0048:case 0x0049:case 0x004A:case 0x004B: + case 0x004C:case 0x004D:case 0x004E:case 0x004F:case 0x0050: + case 0x0051:case 0x0052:case 0x0053:case 0x0054:case 0x0055: + case 0x0056:case 0x0057:case 0x0058:case 0x0059:case 0x005A: + doctypenamebuf.push(c + 0x0020); + break; + case 0x0000: // NULL + doctypenamebuf.push(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + doctypenamebuf.push(c); + break; + } + } + + function after_doctype_name_state(c, lookahead, eof) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + /* Ignore the character. */ + nextchar += 1; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + nextchar += 1; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + lookahead = lookahead.toUpperCase(); + if (lookahead === "PUBLIC") { + nextchar += 6; + tokenizer = after_doctype_public_keyword_state; + } + else if (lookahead === "SYSTEM") { + nextchar += 6; + tokenizer = after_doctype_system_keyword_state; + } + else { + forcequirks(); + tokenizer = bogus_doctype_state; + } + break; + } + } + after_doctype_name_state.lookahead = 6; + + function after_doctype_public_keyword_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + tokenizer = before_doctype_public_identifier_state; + break; + case 0x0022: // QUOTATION MARK + beginDoctypePublicId(); + tokenizer = doctype_public_identifier_double_quoted_state; + break; + case 0x0027: // APOSTROPHE + beginDoctypePublicId(); + tokenizer = doctype_public_identifier_single_quoted_state; + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + forcequirks(); + tokenizer = bogus_doctype_state; + break; + } + } + + function before_doctype_public_identifier_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + /* Ignore the character. */ + break; + case 0x0022: // QUOTATION MARK + beginDoctypePublicId(); + tokenizer = doctype_public_identifier_double_quoted_state; + break; + case 0x0027: // APOSTROPHE + beginDoctypePublicId(); + tokenizer = doctype_public_identifier_single_quoted_state; + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + forcequirks(); + tokenizer = bogus_doctype_state; + break; + } + } + + function doctype_public_identifier_double_quoted_state(c) { + switch(c) { + case 0x0022: // QUOTATION MARK + tokenizer = after_doctype_public_identifier_state; + break; + case 0x0000: // NULL + doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + doctypepublicbuf.push(c); + break; + } + } + + function doctype_public_identifier_single_quoted_state(c) { + switch(c) { + case 0x0027: // APOSTROPHE + tokenizer = after_doctype_public_identifier_state; + break; + case 0x0000: // NULL + doctypepublicbuf.push(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + doctypepublicbuf.push(c); + break; + } + } + + function after_doctype_public_identifier_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + tokenizer = between_doctype_public_and_system_identifiers_state; + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitDoctype(); + break; + case 0x0022: // QUOTATION MARK + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_double_quoted_state; + break; + case 0x0027: // APOSTROPHE + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_single_quoted_state; + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + forcequirks(); + tokenizer = bogus_doctype_state; + break; + } + } + + function between_doctype_public_and_system_identifiers_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE Ignore the character. + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitDoctype(); + break; + case 0x0022: // QUOTATION MARK + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_double_quoted_state; + break; + case 0x0027: // APOSTROPHE + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_single_quoted_state; + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + forcequirks(); + tokenizer = bogus_doctype_state; + break; + } + } + + function after_doctype_system_keyword_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + tokenizer = before_doctype_system_identifier_state; + break; + case 0x0022: // QUOTATION MARK + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_double_quoted_state; + break; + case 0x0027: // APOSTROPHE + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_single_quoted_state; + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + forcequirks(); + tokenizer = bogus_doctype_state; + break; + } + } + + function before_doctype_system_identifier_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE Ignore the character. + break; + case 0x0022: // QUOTATION MARK + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_double_quoted_state; + break; + case 0x0027: // APOSTROPHE + beginDoctypeSystemId(); + tokenizer = doctype_system_identifier_single_quoted_state; + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + forcequirks(); + tokenizer = bogus_doctype_state; + break; + } + } + + function doctype_system_identifier_double_quoted_state(c) { + switch(c) { + case 0x0022: // QUOTATION MARK + tokenizer = after_doctype_system_identifier_state; + break; + case 0x0000: // NULL + doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + doctypesystembuf.push(c); + break; + } + } + + function doctype_system_identifier_single_quoted_state(c) { + switch(c) { + case 0x0027: // APOSTROPHE + tokenizer = after_doctype_system_identifier_state; + break; + case 0x0000: // NULL + doctypesystembuf.push(0xFFFD /* REPLACEMENT CHARACTER */); + break; + case 0x003E: // GREATER-THAN SIGN + forcequirks(); + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + doctypesystembuf.push(c); + break; + } + } + + function after_doctype_system_identifier_state(c) { + switch(c) { + case 0x0009: // CHARACTER TABULATION (tab) + case 0x000A: // LINE FEED (LF) + case 0x000C: // FORM FEED (FF) + case 0x0020: // SPACE + /* Ignore the character. */ + break; + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + forcequirks(); + emitDoctype(); + emitEOF(); + break; + default: + tokenizer = bogus_doctype_state; + /* This does *not* set the DOCTYPE token's force-quirks flag. */ + break; + } + } + + function bogus_doctype_state(c) { + switch(c) { + case 0x003E: // GREATER-THAN SIGN + tokenizer = data_state; + emitDoctype(); + break; + case -1: // EOF + emitDoctype(); + emitEOF(); + break; + default: + /* Ignore the character. */ + break; + } + } + + function cdata_section_state(c) { + switch(c) { + case 0x005D: // RIGHT SQUARE BRACKET + tokenizer = cdata_section_bracket_state; + break; + case -1: // EOF + emitEOF(); + break; + case 0x0000: // NULL + textIncludesNUL = true; + /* fall through */ + default: + // Instead of just pushing a single character and then + // coming back to the very same place, lookahead and + // emit everything we can at once. + /*jshint -W030 */ + emitCharsWhile(CDATATEXT) || textrun.push(c); + break; + } + } + + function cdata_section_bracket_state(c) { + switch(c) { + case 0x005D: // RIGHT SQUARE BRACKET + tokenizer = cdata_section_end_state; + break; + default: + textrun.push(0x005D); + reconsume(c, cdata_section_state); + break; + } + } + + function cdata_section_end_state(c) { + switch(c) { + case 0x005D: // RIGHT SQUARE BRACKET + textrun.push(0x005D); + break; + case 0x003E: // GREATER-THAN SIGN + flushText(); + tokenizer = data_state; + break; + default: + textrun.push(0x005D); + textrun.push(0x005D); + reconsume(c, cdata_section_state); + break; + } + } + + function character_reference_state(c) { + beginTempBuf(); + tempbuf.push(0x0026); + switch(c) { + case 0x0009: // TAB + case 0x000A: // LINE FEED + case 0x000C: // FORM FEED + case 0x0020: // SPACE + case 0x003C: // LESS-THAN SIGN + case 0x0026: // AMPERSAND + case -1: // EOF + reconsume(c, character_reference_end_state); + break; + case 0x0023: // NUMBER SIGN + tempbuf.push(c); + tokenizer = numeric_character_reference_state; + break; + default: + reconsume(c, named_character_reference_state); + break; + } + } + + function named_character_reference_state(c) { + NAMEDCHARREF.lastIndex = nextchar; // w/ lookahead no char has been consumed + var matched = NAMEDCHARREF.exec(chars); + if (!matched) throw new Error("should never happen"); + var name = matched[1]; + if (!name) { + // If no match can be made, switch to the character reference end state + tokenizer = character_reference_end_state; + return; + } + + // Consume the matched characters and append them to temporary buffer + nextchar += name.length; + pushAll(tempbuf, str2buf(name)); + + switch(return_state) { + case attribute_value_double_quoted_state: + case attribute_value_single_quoted_state: + case attribute_value_unquoted_state: + // If the character reference was consumed as part of an attribute... + if (name[name.length-1] !== ';') { // ...and the last char is not ; + if (/[=A-Za-z0-9]/.test(chars[nextchar])) { + tokenizer = character_reference_end_state; + return; + } + } + break; + default: + break; + } + + beginTempBuf(); + var rv = namedCharRefs[name]; + if (typeof rv === 'number') { + tempbuf.push(rv); + } else { + pushAll(tempbuf, rv); + } + tokenizer = character_reference_end_state; + } + // We might need to pause tokenization until we have enough characters + // in the buffer for longest possible character reference. + named_character_reference_state.lookahead = -NAMEDCHARREF_MAXLEN; + + function numeric_character_reference_state(c) { + character_reference_code = 0; + switch(c) { + case 0x0078: // x + case 0x0058: // X + tempbuf.push(c); + tokenizer = hexadecimal_character_reference_start_state; + break; + default: + reconsume(c, decimal_character_reference_start_state); + break; + } + } + + function hexadecimal_character_reference_start_state(c) { + switch(c) { + case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: + case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9] + case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045: + case 0x0046: // [A-F] + case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065: + case 0x0066: // [a-f] + reconsume(c, hexadecimal_character_reference_state); + break; + default: + reconsume(c, character_reference_end_state); + break; + } + } + + function decimal_character_reference_start_state(c) { + switch(c) { + case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: + case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9] + reconsume(c, decimal_character_reference_state); + break; + default: + reconsume(c, character_reference_end_state); + break; + } + } + + function hexadecimal_character_reference_state(c) { + switch(c) { + case 0x0041: case 0x0042: case 0x0043: case 0x0044: case 0x0045: + case 0x0046: // [A-F] + character_reference_code *= 16; + character_reference_code += (c - 0x0037); + break; + case 0x0061: case 0x0062: case 0x0063: case 0x0064: case 0x0065: + case 0x0066: // [a-f] + character_reference_code *= 16; + character_reference_code += (c - 0x0057); + break; + case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: + case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9] + character_reference_code *= 16; + character_reference_code += (c - 0x0030); + break; + case 0x003B: // SEMICOLON + tokenizer = numeric_character_reference_end_state; + break; + default: + reconsume(c, numeric_character_reference_end_state); + break; + } + } + + function decimal_character_reference_state(c) { + switch(c) { + case 0x0030: case 0x0031: case 0x0032: case 0x0033: case 0x0034: + case 0x0035: case 0x0036: case 0x0037: case 0x0038: case 0x0039: // [0-9] + character_reference_code *= 10; + character_reference_code += (c - 0x0030); + break; + case 0x003B: // SEMICOLON + tokenizer = numeric_character_reference_end_state; + break; + default: + reconsume(c, numeric_character_reference_end_state); + break; + } + } + + function numeric_character_reference_end_state(c) { + if (character_reference_code in numericCharRefReplacements) { + character_reference_code = numericCharRefReplacements[character_reference_code]; + } else if (character_reference_code > 0x10FFFF || (character_reference_code >= 0xD800 && character_reference_code < 0xE000)) { + character_reference_code = 0xFFFD; + } + + beginTempBuf(); + if (character_reference_code <= 0xFFFF) { + tempbuf.push(character_reference_code); + } else { + character_reference_code = character_reference_code - 0x10000; + /* jshint bitwise: false */ + tempbuf.push(0xD800 + (character_reference_code >> 10)); + tempbuf.push(0xDC00 + (character_reference_code & 0x03FF)); + } + reconsume(c, character_reference_end_state); + } + + function character_reference_end_state(c) { + switch(return_state) { + case attribute_value_double_quoted_state: + case attribute_value_single_quoted_state: + case attribute_value_unquoted_state: + // append each character to the current attribute's value + attrvaluebuf += buf2str(tempbuf); + break; + default: + pushAll(textrun, tempbuf); + break; + } + reconsume(c, return_state); + } + + /*** + * The tree builder insertion modes + */ + + // 11.2.5.4.1 The "initial" insertion mode + function initial_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + value = value.replace(LEADINGWS, ""); // Ignore spaces + if (value.length === 0) return; // Are we done? + break; // Handle anything non-space text below + case 4: // COMMENT + doc._appendChild(doc.createComment(value)); + return; + case 5: // DOCTYPE + var name = value; + var publicid = arg3; + var systemid = arg4; + // Use the constructor directly instead of + // implementation.createDocumentType because the create + // function throws errors on invalid characters, and + // we don't want the parser to throw them. + doc.appendChild(new DocumentType(name,publicid, systemid)); + + // Note that there is no public API for setting quirks mode We can + // do this here because we have access to implementation details + if (force_quirks || + name.toLowerCase() !== "html" || + quirkyPublicIds.test(publicid) || + (systemid && systemid.toLowerCase() === quirkySystemId) || + (systemid === undefined && + conditionallyQuirkyPublicIds.test(publicid))) + doc._quirks = true; + else if (limitedQuirkyPublicIds.test(publicid) || + (systemid !== undefined && + conditionallyQuirkyPublicIds.test(publicid))) + doc._limitedQuirks = true; + parser = before_html_mode; + return; + } + + // tags or non-whitespace text + doc._quirks = true; + parser = before_html_mode; + parser(t,value,arg3,arg4); + } + + // 11.2.5.4.2 The "before html" insertion mode + function before_html_mode(t,value,arg3,arg4) { + var elt; + switch(t) { + case 1: // TEXT + value = value.replace(LEADINGWS, ""); // Ignore spaces + if (value.length === 0) return; // Are we done? + break; // Handle anything non-space text below + case 5: // DOCTYPE + /* ignore the token */ + return; + case 4: // COMMENT + doc._appendChild(doc.createComment(value)); + return; + case 2: // TAG + if (value === "html") { + elt = createHTMLElt(doc, value, arg3); + stack.push(elt); + doc.appendChild(elt); + // XXX: handle application cache here + parser = before_head_mode; + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "html": + case "head": + case "body": + case "br": + break; // fall through on these + default: + return; // ignore most end tags + } } -}; + // Anything that didn't get handled above is handled like this: + elt = createHTMLElt(doc, "html", null); + stack.push(elt); + doc.appendChild(elt); + // XXX: handle application cache here + parser = before_head_mode; + parser(t,value,arg3,arg4); + } + + // 11.2.5.4.3 The "before head" insertion mode + function before_head_mode(t,value,arg3,arg4) { + switch(t) { + case 1: // TEXT + value = value.replace(LEADINGWS, ""); // Ignore spaces + if (value.length === 0) return; // Are we done? + break; // Handle anything non-space text below + case 5: // DOCTYPE + /* ignore the token */ + return; + case 4: // COMMENT + insertComment(value); + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t,value,arg3,arg4); + return; + case "head": + var elt = insertHTMLElement(value, arg3); + head_element_pointer = elt; + parser = in_head_mode; + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "html": + case "head": + case "body": + case "br": + break; + default: + return; // ignore most end tags + } + } -//12.2.4.64 DOCTYPE system identifier (double-quoted) state -//------------------------------------------------------------------ -_[DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED_STATE] = function doctypeSystemIdentifierDoubleQuotedState(cp) { - if (cp === $.QUOTATION_MARK) - this.state = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; + // If not handled explicitly above + before_head_mode(TAG, "head", null); // create a head tag + parser(t, value, arg3, arg4); // then try again with this token + } - else if (cp === $.GREATER_THAN_SIGN) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this.state = DATA_STATE; + function in_head_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + var ws = value.match(LEADINGWS); + if (ws) { + insertText(ws[0]); + value = value.substring(ws[0].length); + } + if (value.length === 0) return; + break; // Handle non-whitespace below + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "meta": + // XXX: + // May need to change the encoding based on this tag + /* falls through */ + case "base": + case "basefont": + case "bgsound": + case "link": + insertHTMLElement(value, arg3); + stack.pop(); + return; + case "title": + parseRCDATA(value, arg3); + return; + case "noscript": + if (!scripting_enabled) { + insertHTMLElement(value, arg3); + parser = in_head_noscript_mode; + return; + } + // Otherwise, if scripting is enabled... + /* falls through */ + case "noframes": + case "style": + parseRawText(value,arg3); + return; + case "script": + insertElement(function(doc) { + var elt = createHTMLElt(doc, value, arg3); + elt._parser_inserted = true; + elt._force_async = false; + if (fragment) elt._already_started = true; + flushText(); + return elt; + }); + tokenizer = script_data_state; + originalInsertionMode = parser; + parser = text_mode; + return; + case "template": + insertHTMLElement(value, arg3); + afe.insertMarker(); + frameset_ok = false; + parser = in_template_mode; + templateInsertionModes.push(parser); + return; + case "head": + return; // ignore it + } + break; + case 3: // ENDTAG + switch(value) { + case "head": + stack.pop(); + parser = after_head_mode; + return; + case "body": + case "html": + case "br": + break; // handle these at the bottom of the function + case "template": + if (!stack.contains("template")) { + return; + } + stack.generateImpliedEndTags(null, "thorough"); + stack.popTag("template"); + afe.clearToMarker(); + templateInsertionModes.pop(); + resetInsertionMode(); + return; + default: + // ignore any other end tag + return; + } + break; + } + + // If not handled above + in_head_mode(ENDTAG, "head", null); // synthetic + parser(t, value, arg3, arg4); // Then redo this one + } + + // 13.2.5.4.5 The "in head noscript" insertion mode + function in_head_noscript_mode(t, value, arg3, arg4) { + switch(t) { + case 5: // DOCTYPE + return; + case 4: // COMMENT + in_head_mode(t, value); + return; + case 1: // TEXT + var ws = value.match(LEADINGWS); + if (ws) { + in_head_mode(t, ws[0]); + value = value.substring(ws[0].length); + } + if (value.length === 0) return; // no more text + break; // Handle non-whitespace below + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "basefont": + case "bgsound": + case "link": + case "meta": + case "noframes": + case "style": + in_head_mode(t, value, arg3); + return; + case "head": + case "noscript": + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "noscript": + stack.pop(); + parser = in_head_mode; + return; + case "br": + break; // goes to the outer default + default: + return; // ignore other end tags + } + break; } - else if (cp === $.NULL) - this.currentToken.systemId += UNICODE.REPLACEMENT_CHARACTER; + // If not handled above + in_head_noscript_mode(ENDTAG, "noscript", null); + parser(t, value, arg3, arg4); + } - else if (cp === $.EOF) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } + function after_head_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + var ws = value.match(LEADINGWS); + if (ws) { + insertText(ws[0]); + value = value.substring(ws[0].length); + } + if (value.length === 0) return; + break; // Handle non-whitespace below + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "body": + insertHTMLElement(value, arg3); + frameset_ok = false; + parser = in_body_mode; + return; + case "frameset": + insertHTMLElement(value, arg3); + parser = in_frameset_mode; + return; + case "base": + case "basefont": + case "bgsound": + case "link": + case "meta": + case "noframes": + case "script": + case "style": + case "template": + case "title": + stack.push(head_element_pointer); + in_head_mode(TAG, value, arg3); + stack.removeElement(head_element_pointer); + return; + case "head": + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "template": + return in_head_mode(t, value, arg3, arg4); + case "body": + case "html": + case "br": + break; + default: + return; // ignore any other end tag + } + break; + } + + after_head_mode(TAG, "body", null); + frameset_ok = true; + parser(t, value, arg3, arg4); + } + + // 13.2.5.4.7 The "in body" insertion mode + function in_body_mode(t,value,arg3,arg4) { + var body, i, node, elt; + switch(t) { + case 1: // TEXT + if (textIncludesNUL) { + value = value.replace(NULCHARS, ""); + if (value.length === 0) return; + } + // If any non-space characters + if (frameset_ok && NONWS.test(value)) + frameset_ok = false; + afereconstruct(); + insertText(value); + return; + case 5: // DOCTYPE + return; + case 4: // COMMENT + insertComment(value); + return; + case -1: // EOF + if (templateInsertionModes.length) { + return in_template_mode(t); + } + stopParsing(); + return; + case 2: // TAG + switch(value) { + case "html": + if (stack.contains("template")) { + return; + } + transferAttributes(arg3, stack.elements[0]); + return; + case "base": + case "basefont": + case "bgsound": + case "link": + case "meta": + case "noframes": + case "script": + case "style": + case "template": + case "title": + in_head_mode(TAG, value, arg3); + return; + case "body": + body = stack.elements[1]; + if (!body || !(body instanceof impl.HTMLBodyElement) || + stack.contains("template")) + return; + frameset_ok = false; + transferAttributes(arg3, body); + return; + case "frameset": + if (!frameset_ok) return; + body = stack.elements[1]; + if (!body || !(body instanceof impl.HTMLBodyElement)) + return; + if (body.parentNode) body.parentNode.removeChild(body); + while(!(stack.top instanceof impl.HTMLHtmlElement)) + stack.pop(); + insertHTMLElement(value, arg3); + parser = in_frameset_mode; + return; - else - this.currentToken.systemId += toChar(cp); -}; + case "address": + case "article": + case "aside": + case "blockquote": + case "center": + case "details": + case "dialog": + case "dir": + case "div": + case "dl": + case "fieldset": + case "figcaption": + case "figure": + case "footer": + case "header": + case "hgroup": + case "main": + case "nav": + case "ol": + case "p": + case "section": + case "summary": + case "ul": + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + insertHTMLElement(value, arg3); + return; + case "menu": + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + if (isA(stack.top, 'menuitem')) { + stack.pop(); + } + insertHTMLElement(value, arg3); + return; -//12.2.4.65 DOCTYPE system identifier (single-quoted) state -//------------------------------------------------------------------ -_[DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED_STATE] = function doctypeSystemIdentifierSingleQuotedState(cp) { - if (cp === $.APOSTROPHE) - this.state = AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE; + case "h1": + case "h2": + case "h3": + case "h4": + case "h5": + case "h6": + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + if (stack.top instanceof impl.HTMLHeadingElement) + stack.pop(); + insertHTMLElement(value, arg3); + return; - else if (cp === $.GREATER_THAN_SIGN) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this.state = DATA_STATE; - } + case "pre": + case "listing": + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + insertHTMLElement(value, arg3); + ignore_linefeed = true; + frameset_ok = false; + return; - else if (cp === $.NULL) - this.currentToken.systemId += UNICODE.REPLACEMENT_CHARACTER; + case "form": + if (form_element_pointer && !stack.contains("template")) return; + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + elt = insertHTMLElement(value, arg3); + if (!stack.contains("template")) + form_element_pointer = elt; + return; - else if (cp === $.EOF) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } + case "li": + frameset_ok = false; + for(i = stack.elements.length-1; i >= 0; i--) { + node = stack.elements[i]; + if (node instanceof impl.HTMLLIElement) { + in_body_mode(ENDTAG, "li"); + break; + } + if (isA(node, specialSet) && !isA(node, addressdivpSet)) + break; + } + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + insertHTMLElement(value, arg3); + return; - else - this.currentToken.systemId += toChar(cp); -}; + case "dd": + case "dt": + frameset_ok = false; + for(i = stack.elements.length-1; i >= 0; i--) { + node = stack.elements[i]; + if (isA(node, dddtSet)) { + in_body_mode(ENDTAG, node.localName); + break; + } + if (isA(node, specialSet) && !isA(node, addressdivpSet)) + break; + } + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + insertHTMLElement(value, arg3); + return; + case "plaintext": + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + insertHTMLElement(value, arg3); + tokenizer = plaintext_state; + return; -//12.2.4.66 After DOCTYPE system identifier state -//------------------------------------------------------------------ -_[AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE] = function afterDoctypeSystemIdentifierState(cp) { - if (isWhitespace(cp)) + case "button": + if (stack.inScope("button")) { + in_body_mode(ENDTAG, "button"); + parser(t, value, arg3, arg4); + } + else { + afereconstruct(); + insertHTMLElement(value, arg3); + frameset_ok = false; + } return; - if (cp === $.GREATER_THAN_SIGN) { - this._emitCurrentToken(); - this.state = DATA_STATE; - } + case "a": + var activeElement = afe.findElementByTag("a"); + if (activeElement) { + in_body_mode(ENDTAG, value); + afe.remove(activeElement); + stack.removeElement(activeElement); + } + /* falls through */ + case "b": + case "big": + case "code": + case "em": + case "font": + case "i": + case "s": + case "small": + case "strike": + case "strong": + case "tt": + case "u": + afereconstruct(); + afe.push(insertHTMLElement(value,arg3), arg3); + return; - else if (cp === $.EOF) { - this.currentToken.forceQuirks = true; - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } + case "nobr": + afereconstruct(); - else - this.state = BOGUS_DOCTYPE_STATE; -}; + if (stack.inScope(value)) { + in_body_mode(ENDTAG, value); + afereconstruct(); + } + afe.push(insertHTMLElement(value,arg3), arg3); + return; + case "applet": + case "marquee": + case "object": + afereconstruct(); + insertHTMLElement(value,arg3); + afe.insertMarker(); + frameset_ok = false; + return; -//12.2.4.67 Bogus DOCTYPE state -//------------------------------------------------------------------ -_[BOGUS_DOCTYPE_STATE] = function bogusDoctypeState(cp) { - if (cp === $.GREATER_THAN_SIGN) { - this._emitCurrentToken(); - this.state = DATA_STATE; - } + case "table": + if (!doc._quirks && stack.inButtonScope("p")) { + in_body_mode(ENDTAG, "p"); + } + insertHTMLElement(value,arg3); + frameset_ok = false; + parser = in_table_mode; + return; - else if (cp === $.EOF) { - this._emitCurrentToken(); - this._reconsumeInState(DATA_STATE); - } -}; + case "area": + case "br": + case "embed": + case "img": + case "keygen": + case "wbr": + afereconstruct(); + insertHTMLElement(value,arg3); + stack.pop(); + frameset_ok = false; + return; + case "input": + afereconstruct(); + elt = insertHTMLElement(value,arg3); + stack.pop(); + var type = elt.getAttribute("type"); + if (!type || type.toLowerCase() !== "hidden") + frameset_ok = false; + return; -//12.2.4.68 CDATA section state -//------------------------------------------------------------------ -_[CDATA_SECTION_STATE] = function cdataSectionState(cp) { - while (true) { - if (cp === $.EOF) { - this._reconsumeInState(DATA_STATE); - break; + case "param": + case "source": + case "track": + insertHTMLElement(value,arg3); + stack.pop(); + return; + + case "hr": + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + if (isA(stack.top, 'menuitem')) { + stack.pop(); } + insertHTMLElement(value,arg3); + stack.pop(); + frameset_ok = false; + return; - else { - var cdataEndMatch = this._consumeSubsequentIfMatch($$.CDATA_END_STRING, cp, true); + case "image": + in_body_mode(TAG, "img", arg3, arg4); + return; - if (this._ensureHibernation()) - break; + case "textarea": + insertHTMLElement(value,arg3); + ignore_linefeed = true; + frameset_ok = false; + tokenizer = rcdata_state; + originalInsertionMode = parser; + parser = text_mode; + return; - if (cdataEndMatch) { - this.state = DATA_STATE; - break; - } + case "xmp": + if (stack.inButtonScope("p")) in_body_mode(ENDTAG, "p"); + afereconstruct(); + frameset_ok = false; + parseRawText(value, arg3); + return; - this._emitCodePoint(cp); + case "iframe": + frameset_ok = false; + parseRawText(value, arg3); + return; - this._hibernationSnapshot(); - cp = this._consume(); + case "noembed": + parseRawText(value,arg3); + return; - if (this._ensureHibernation()) - break; + case "noscript": + if (scripting_enabled) { + parseRawText(value,arg3); + return; } - } -}; + break; // XXX Otherwise treat it as any other open tag? + + case "select": + afereconstruct(); + insertHTMLElement(value,arg3); + frameset_ok = false; + if (parser === in_table_mode || + parser === in_caption_mode || + parser === in_table_body_mode || + parser === in_row_mode || + parser === in_cell_mode) + parser = in_select_in_table_mode; + else + parser = in_select_mode; + return; + case "optgroup": + case "option": + if (stack.top instanceof impl.HTMLOptionElement) { + in_body_mode(ENDTAG, "option"); + } + afereconstruct(); + insertHTMLElement(value,arg3); + return; -/***/ }), -/* 20 */ -/***/ (function(module, exports, __webpack_require__) { + case "menuitem": + if (isA(stack.top, 'menuitem')) { + stack.pop(); + } + afereconstruct(); + insertHTMLElement(value, arg3); + return; -"use strict"; + case "rb": + case "rtc": + if (stack.inScope("ruby")) { + stack.generateImpliedEndTags(); + } + insertHTMLElement(value,arg3); + return; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var root_1 = __webpack_require__(12); -var Action_1 = __webpack_require__(356); -/** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ -var AsyncAction = (function (_super) { - __extends(AsyncAction, _super); - function AsyncAction(scheduler, work) { - _super.call(this, scheduler, work); - this.scheduler = scheduler; - this.work = work; - this.pending = false; - } - AsyncAction.prototype.schedule = function (state, delay) { - if (delay === void 0) { delay = 0; } - if (this.closed) { - return this; + case "rp": + case "rt": + if (stack.inScope("ruby")) { + stack.generateImpliedEndTags("rtc"); } - // Always replace the current state with the new state. - this.state = state; - // Set the pending flag indicating that this action has been scheduled, or - // has recursively rescheduled itself. - this.pending = true; - var id = this.id; - var scheduler = this.scheduler; - // - // Important implementation note: - // - // Actions only execute once by default, unless rescheduled from within the - // scheduled callback. This allows us to implement single and repeat - // actions via the same code path, without adding API surface area, as well - // as mimic traditional recursion but across asynchronous boundaries. - // - // However, JS runtimes and timers distinguish between intervals achieved by - // serial `setTimeout` calls vs. a single `setInterval` call. An interval of - // serial `setTimeout` calls can be individually delayed, which delays - // scheduling the next `setTimeout`, and so on. `setInterval` attempts to - // guarantee the interval callback will be invoked more precisely to the - // interval period, regardless of load. - // - // Therefore, we use `setInterval` to schedule single and repeat actions. - // If the action reschedules itself with the same delay, the interval is not - // canceled. If the action doesn't reschedule, or reschedules with a - // different delay, the interval will be canceled after scheduled callback - // execution. - // - if (id != null) { - this.id = this.recycleAsyncId(scheduler, id, delay); + insertHTMLElement(value,arg3); + return; + + case "math": + afereconstruct(); + adjustMathMLAttributes(arg3); + adjustForeignAttributes(arg3); + insertForeignElement(value, arg3, NAMESPACE.MATHML); + if (arg4) // self-closing flag + stack.pop(); + return; + + case "svg": + afereconstruct(); + adjustSVGAttributes(arg3); + adjustForeignAttributes(arg3); + insertForeignElement(value, arg3, NAMESPACE.SVG); + if (arg4) // self-closing flag + stack.pop(); + return; + + case "caption": + case "col": + case "colgroup": + case "frame": + case "head": + case "tbody": + case "td": + case "tfoot": + case "th": + case "thead": + case "tr": + // Ignore table tags if we're not in_table mode + return; + } + + // Handle any other start tag here + // (and also noscript tags when scripting is disabled) + afereconstruct(); + insertHTMLElement(value,arg3); + return; + + case 3: // ENDTAG + switch(value) { + case "template": + in_head_mode(ENDTAG, value, arg3); + return; + case "body": + if (!stack.inScope("body")) return; + parser = after_body_mode; + return; + case "html": + if (!stack.inScope("body")) return; + parser = after_body_mode; + parser(t, value, arg3); + return; + + case "address": + case "article": + case "aside": + case "blockquote": + case "button": + case "center": + case "details": + case "dialog": + case "dir": + case "div": + case "dl": + case "fieldset": + case "figcaption": + case "figure": + case "footer": + case "header": + case "hgroup": + case "listing": + case "main": + case "menu": + case "nav": + case "ol": + case "pre": + case "section": + case "summary": + case "ul": + // Ignore if there is not a matching open tag + if (!stack.inScope(value)) return; + stack.generateImpliedEndTags(); + stack.popTag(value); + return; + + case "form": + if (!stack.contains("template")) { + var openform = form_element_pointer; + form_element_pointer = null; + if (!openform || !stack.elementInScope(openform)) return; + stack.generateImpliedEndTags(); + stack.removeElement(openform); + } else { + if (!stack.inScope("form")) return; + stack.generateImpliedEndTags(); + stack.popTag("form"); } - this.delay = delay; - // If this action has already an async Id, don't request a new one. - this.id = this.id || this.requestAsyncId(scheduler, this.id, delay); - return this; - }; - AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) { - if (delay === void 0) { delay = 0; } - return root_1.root.setInterval(scheduler.flush.bind(scheduler, this), delay); - }; - AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) { - if (delay === void 0) { delay = 0; } - // If this action is rescheduled with the same delay time, don't clear the interval id. - if (delay !== null && this.delay === delay && this.pending === false) { - return id; - } - // Otherwise, if the action's delay time is different from the current delay, - // or the action has been rescheduled before it's executed, clear the interval id - return root_1.root.clearInterval(id) && undefined || undefined; - }; - /** - * Immediately executes this action and the `work` it contains. - * @return {any} - */ - AsyncAction.prototype.execute = function (state, delay) { - if (this.closed) { - return new Error('executing a cancelled action'); - } - this.pending = false; - var error = this._execute(state, delay); - if (error) { - return error; - } - else if (this.pending === false && this.id != null) { - // Dequeue if the action didn't reschedule itself. Don't call - // unsubscribe(), because the action could reschedule later. - // For example: - // ``` - // scheduler.schedule(function doWork(counter) { - // /* ... I'm a busy worker bee ... */ - // var originalAction = this; - // /* wait 100ms before rescheduling the action */ - // setTimeout(function () { - // originalAction.schedule(counter + 1); - // }, 100); - // }, 1000); - // ``` - this.id = this.recycleAsyncId(this.scheduler, this.id, null); - } - }; - AsyncAction.prototype._execute = function (state, delay) { - var errored = false; - var errorValue = undefined; - try { - this.work(state); - } - catch (e) { - errored = true; - errorValue = !!e && e || new Error(e); - } - if (errored) { - this.unsubscribe(); - return errorValue; - } - }; - AsyncAction.prototype._unsubscribe = function () { - var id = this.id; - var scheduler = this.scheduler; - var actions = scheduler.actions; - var index = actions.indexOf(this); - this.work = null; - this.state = null; - this.pending = false; - this.scheduler = null; - if (index !== -1) { - actions.splice(index, 1); + return; + + case "p": + if (!stack.inButtonScope(value)) { + in_body_mode(TAG, value, null); + parser(t, value, arg3, arg4); } - if (id != null) { - this.id = this.recycleAsyncId(scheduler, id, null); + else { + stack.generateImpliedEndTags(value); + stack.popTag(value); } - this.delay = null; - }; - return AsyncAction; -}(Action_1.Action)); -exports.AsyncAction = AsyncAction; -//# sourceMappingURL=AsyncAction.js.map + return; -/***/ }), -/* 21 */ -/***/ (function(module, exports, __webpack_require__) { + case "li": + if (!stack.inListItemScope(value)) return; + stack.generateImpliedEndTags(value); + stack.popTag(value); + return; -"use strict"; + case "dd": + case "dt": + if (!stack.inScope(value)) return; + stack.generateImpliedEndTags(value); + stack.popTag(value); + return; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var Scheduler_1 = __webpack_require__(122); -var AsyncScheduler = (function (_super) { - __extends(AsyncScheduler, _super); - function AsyncScheduler() { - _super.apply(this, arguments); - this.actions = []; - /** - * A flag to indicate whether the Scheduler is currently executing a batch of - * queued actions. - * @type {boolean} - */ - this.active = false; - /** - * An internal ID used to track the latest asynchronous task such as those - * coming from `setTimeout`, `setInterval`, `requestAnimationFrame`, and - * others. - * @type {any} - */ - this.scheduled = undefined; - } - AsyncScheduler.prototype.flush = function (action) { - var actions = this.actions; - if (this.active) { - actions.push(action); - return; + case "h1": + case "h2": + case "h3": + case "h4": + case "h5": + case "h6": + if (!stack.elementTypeInScope(impl.HTMLHeadingElement)) return; + stack.generateImpliedEndTags(); + stack.popElementType(impl.HTMLHeadingElement); + return; + + case "sarcasm": + // Take a deep breath, and then: + break; + + case "a": + case "b": + case "big": + case "code": + case "em": + case "font": + case "i": + case "nobr": + case "s": + case "small": + case "strike": + case "strong": + case "tt": + case "u": + var result = adoptionAgency(value); + if (result) return; // If we did something we're done + break; // Go to the "any other end tag" case + + case "applet": + case "marquee": + case "object": + if (!stack.inScope(value)) return; + stack.generateImpliedEndTags(); + stack.popTag(value); + afe.clearToMarker(); + return; + + case "br": + in_body_mode(TAG, value, null); // Turn
into
+ return; + } + + // Any other end tag goes here + for(i = stack.elements.length-1; i >= 0; i--) { + node = stack.elements[i]; + if (isA(node, value)) { + stack.generateImpliedEndTags(value); + stack.popElement(node); + break; } - var error; - this.active = true; - do { - if (error = action.execute(action.state, action.delay)) { - break; - } - } while (action = actions.shift()); // exhaust the scheduler queue - this.active = false; - if (error) { - while (action = actions.shift()) { - action.unsubscribe(); - } - throw error; + else if (isA(node, specialSet)) { + return; } - }; - return AsyncScheduler; -}(Scheduler_1.Scheduler)); -exports.AsyncScheduler = AsyncScheduler; -//# sourceMappingURL=AsyncScheduler.js.map + } -/***/ }), -/* 22 */ -/***/ (function(module, exports, __webpack_require__) { + return; + } + } + + function text_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + insertText(value); + return; + case -1: // EOF + if (stack.top instanceof impl.HTMLScriptElement) + stack.top._already_started = true; + stack.pop(); + parser = originalInsertionMode; + parser(t); + return; + case 3: // ENDTAG + if (value === "script") { + handleScriptEnd(); + } + else { + stack.pop(); + parser = originalInsertionMode; + } + return; + default: + // We should never get any other token types + return; + } + } + + function in_table_mode(t, value, arg3, arg4) { + function getTypeAttr(attrs) { + for(var i = 0, n = attrs.length; i < n; i++) { + if (attrs[i][0] === "type") + return attrs[i][1].toLowerCase(); + } + return null; + } -"use strict"; + switch(t) { + case 1: // TEXT + // XXX the text_integration_mode stuff is + // just a hack I made up + if (text_integration_mode) { + in_body_mode(t, value, arg3, arg4); + return; + } + else if (isA(stack.top, tablesectionrowSet)) { + pending_table_text = []; + originalInsertionMode = parser; + parser = in_table_text_mode; + parser(t, value, arg3, arg4); + return; + } + break; + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + return; + case 2: // TAG + switch(value) { + case "caption": + stack.clearToContext(tableContextSet); + afe.insertMarker(); + insertHTMLElement(value,arg3); + parser = in_caption_mode; + return; + case "colgroup": + stack.clearToContext(tableContextSet); + insertHTMLElement(value,arg3); + parser = in_column_group_mode; + return; + case "col": + in_table_mode(TAG, "colgroup", null); + parser(t, value, arg3, arg4); + return; + case "tbody": + case "tfoot": + case "thead": + stack.clearToContext(tableContextSet); + insertHTMLElement(value,arg3); + parser = in_table_body_mode; + return; + case "td": + case "th": + case "tr": + in_table_mode(TAG, "tbody", null); + parser(t, value, arg3, arg4); + return; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -/** - * An error thrown when an element was queried at a certain index of an - * Observable, but no such index or position exists in that sequence. - * - * @see {@link elementAt} - * @see {@link take} - * @see {@link takeLast} - * - * @class ArgumentOutOfRangeError - */ -var ArgumentOutOfRangeError = (function (_super) { - __extends(ArgumentOutOfRangeError, _super); - function ArgumentOutOfRangeError() { - var err = _super.call(this, 'argument out of range'); - this.name = err.name = 'ArgumentOutOfRangeError'; - this.stack = err.stack; - this.message = err.message; - } - return ArgumentOutOfRangeError; -}(Error)); -exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError; -//# sourceMappingURL=ArgumentOutOfRangeError.js.map + case "table": + if (!stack.inTableScope(value)) { + return; // Ignore the token + } + in_table_mode(ENDTAG, value); + parser(t, value, arg3, arg4); + return; -/***/ }), -/* 23 */ -/***/ (function(module, exports, __webpack_require__) { + case "style": + case "script": + case "template": + in_head_mode(t, value, arg3, arg4); + return; -module.exports = (__webpack_require__(1))(12); + case "input": + var type = getTypeAttr(arg3); + if (type !== "hidden") break; // to the anything else case + insertHTMLElement(value,arg3); + stack.pop(); + return; -/***/ }), -/* 24 */ -/***/ (function(module, exports) { + case "form": + if (form_element_pointer || stack.contains("template")) return; + form_element_pointer = insertHTMLElement(value, arg3); + stack.popElement(form_element_pointer); + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "table": + if (!stack.inTableScope(value)) return; + stack.popTag(value); + resetInsertionMode(); + return; + case "body": + case "caption": + case "col": + case "colgroup": + case "html": + case "tbody": + case "td": + case "tfoot": + case "th": + case "thead": + case "tr": + return; + case "template": + in_head_mode(t, value, arg3, arg4); + return; + } -module.exports = require("util"); + break; + case -1: // EOF + in_body_mode(t, value, arg3, arg4); + return; + } -/***/ }), -/* 25 */ -/***/ (function(module, exports, __webpack_require__) { + // This is the anything else case + foster_parent_mode = true; + in_body_mode(t, value, arg3, arg4); + foster_parent_mode = false; + } -"use strict"; + function in_table_text_mode(t, value, arg3, arg4) { + if (t === TEXT) { + if (textIncludesNUL) { + value = value.replace(NULCHARS, ""); + if (value.length === 0) return; + } + pending_table_text.push(value); + } + else { + var s = pending_table_text.join(""); + pending_table_text.length = 0; + if (NONWS.test(s)) { // If any non-whitespace characters + // This must be the same code as the "anything else" + // case of the in_table mode above. + foster_parent_mode = true; + in_body_mode(TEXT, s); + foster_parent_mode = false; + } + else { + insertText(s); + } + parser = originalInsertionMode; + parser(t, value, arg3, arg4); + } + } + + + function in_caption_mode(t, value, arg3, arg4) { + function end_caption() { + if (!stack.inTableScope("caption")) return false; + stack.generateImpliedEndTags(); + stack.popTag("caption"); + afe.clearToMarker(); + parser = in_table_mode; + return true; + } + + switch(t) { + case 2: // TAG + switch(value) { + case "caption": + case "col": + case "colgroup": + case "tbody": + case "td": + case "tfoot": + case "th": + case "thead": + case "tr": + if (end_caption()) parser(t, value, arg3, arg4); + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "caption": + end_caption(); + return; + case "table": + if (end_caption()) parser(t, value, arg3, arg4); + return; + case "body": + case "col": + case "colgroup": + case "html": + case "tbody": + case "td": + case "tfoot": + case "th": + case "thead": + case "tr": + return; + } + break; + } -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var Subject_1 = __webpack_require__(6); -var Subscription_1 = __webpack_require__(9); -/** - * @class AsyncSubject - */ -var AsyncSubject = (function (_super) { - __extends(AsyncSubject, _super); - function AsyncSubject() { - _super.apply(this, arguments); - this.value = null; - this.hasNext = false; - this.hasCompleted = false; + // The Anything Else case + in_body_mode(t, value, arg3, arg4); + } + + function in_column_group_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + var ws = value.match(LEADINGWS); + if (ws) { + insertText(ws[0]); + value = value.substring(ws[0].length); + } + if (value.length === 0) return; + break; // Handle non-whitespace below + + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "col": + insertHTMLElement(value, arg3); + stack.pop(); + return; + case "template": + in_head_mode(t, value, arg3, arg4); + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "colgroup": + if (!isA(stack.top, 'colgroup')) { + return; // Ignore the token. + } + stack.pop(); + parser = in_table_mode; + return; + case "col": + return; + case "template": + in_head_mode(t, value, arg3, arg4); + return; + } + break; + case -1: // EOF + in_body_mode(t, value, arg3, arg4); + return; } - AsyncSubject.prototype._subscribe = function (subscriber) { - if (this.hasError) { - subscriber.error(this.thrownError); - return Subscription_1.Subscription.EMPTY; - } - else if (this.hasCompleted && this.hasNext) { - subscriber.next(this.value); - subscriber.complete(); - return Subscription_1.Subscription.EMPTY; - } - return _super.prototype._subscribe.call(this, subscriber); - }; - AsyncSubject.prototype.next = function (value) { - if (!this.hasCompleted) { - this.value = value; - this.hasNext = true; + + // Anything else + if (!isA(stack.top, 'colgroup')) { + return; // Ignore the token. + } + in_column_group_mode(ENDTAG, "colgroup"); + parser(t, value, arg3, arg4); + } + + function in_table_body_mode(t, value, arg3, arg4) { + function endsect() { + if (!stack.inTableScope("tbody") && + !stack.inTableScope("thead") && + !stack.inTableScope("tfoot")) + return; + stack.clearToContext(tableBodyContextSet); + in_table_body_mode(ENDTAG, stack.top.localName, null); + parser(t, value, arg3, arg4); + } + + switch(t) { + case 2: // TAG + switch(value) { + case "tr": + stack.clearToContext(tableBodyContextSet); + insertHTMLElement(value, arg3); + parser = in_row_mode; + return; + case "th": + case "td": + in_table_body_mode(TAG, "tr", null); + parser(t, value, arg3, arg4); + return; + case "caption": + case "col": + case "colgroup": + case "tbody": + case "tfoot": + case "thead": + endsect(); + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "table": + endsect(); + return; + case "tbody": + case "tfoot": + case "thead": + if (stack.inTableScope(value)) { + stack.clearToContext(tableBodyContextSet); + stack.pop(); + parser = in_table_mode; } - }; - AsyncSubject.prototype.error = function (error) { - if (!this.hasCompleted) { - _super.prototype.error.call(this, error); + return; + case "body": + case "caption": + case "col": + case "colgroup": + case "html": + case "td": + case "th": + case "tr": + return; + } + break; + } + + // Anything else: + in_table_mode(t, value, arg3, arg4); + } + + function in_row_mode(t, value, arg3, arg4) { + function endrow() { + if (!stack.inTableScope("tr")) return false; + stack.clearToContext(tableRowContextSet); + stack.pop(); + parser = in_table_body_mode; + return true; + } + + switch(t) { + case 2: // TAG + switch(value) { + case "th": + case "td": + stack.clearToContext(tableRowContextSet); + insertHTMLElement(value, arg3); + parser = in_cell_mode; + afe.insertMarker(); + return; + case "caption": + case "col": + case "colgroup": + case "tbody": + case "tfoot": + case "thead": + case "tr": + if (endrow()) parser(t, value, arg3, arg4); + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "tr": + endrow(); + return; + case "table": + if (endrow()) parser(t, value, arg3, arg4); + return; + case "tbody": + case "tfoot": + case "thead": + if (stack.inTableScope(value)) { + if (endrow()) parser(t, value, arg3, arg4); } - }; - AsyncSubject.prototype.complete = function () { - this.hasCompleted = true; - if (this.hasNext) { - _super.prototype.next.call(this, this.value); + return; + case "body": + case "caption": + case "col": + case "colgroup": + case "html": + case "td": + case "th": + return; + } + break; + } + + // anything else + in_table_mode(t, value, arg3, arg4); + } + + function in_cell_mode(t, value, arg3, arg4) { + switch(t) { + case 2: // TAG + switch(value) { + case "caption": + case "col": + case "colgroup": + case "tbody": + case "td": + case "tfoot": + case "th": + case "thead": + case "tr": + if (stack.inTableScope("td")) { + in_cell_mode(ENDTAG, "td"); + parser(t, value, arg3, arg4); + } + else if (stack.inTableScope("th")) { + in_cell_mode(ENDTAG, "th"); + parser(t, value, arg3, arg4); } - _super.prototype.complete.call(this); - }; - return AsyncSubject; -}(Subject_1.Subject)); -exports.AsyncSubject = AsyncSubject; -//# sourceMappingURL=AsyncSubject.js.map + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "td": + case "th": + if (!stack.inTableScope(value)) return; + stack.generateImpliedEndTags(); + stack.popTag(value); + afe.clearToMarker(); + parser = in_row_mode; + return; -/***/ }), -/* 26 */ + case "body": + case "caption": + case "col": + case "colgroup": + case "html": + return; + + case "table": + case "tbody": + case "tfoot": + case "thead": + case "tr": + if (!stack.inTableScope(value)) return; + in_cell_mode(ENDTAG, stack.inTableScope("td") ? "td" : "th"); + parser(t, value, arg3, arg4); + return; + } + break; + } + + // anything else + in_body_mode(t, value, arg3, arg4); + } + + function in_select_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + if (textIncludesNUL) { + value = value.replace(NULCHARS, ""); + if (value.length === 0) return; + } + insertText(value); + return; + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + return; + case -1: // EOF + in_body_mode(t, value, arg3, arg4); + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "option": + if (stack.top instanceof impl.HTMLOptionElement) + in_select_mode(ENDTAG, value); + insertHTMLElement(value, arg3); + return; + case "optgroup": + if (stack.top instanceof impl.HTMLOptionElement) + in_select_mode(ENDTAG, "option"); + if (stack.top instanceof impl.HTMLOptGroupElement) + in_select_mode(ENDTAG, value); + insertHTMLElement(value, arg3); + return; + case "select": + in_select_mode(ENDTAG, value); // treat it as a close tag + return; + + case "input": + case "keygen": + case "textarea": + if (!stack.inSelectScope("select")) return; + in_select_mode(ENDTAG, "select"); + parser(t, value, arg3, arg4); + return; + + case "script": + case "template": + in_head_mode(t, value, arg3, arg4); + return; + } + break; + case 3: // ENDTAG + switch(value) { + case "optgroup": + if (stack.top instanceof impl.HTMLOptionElement && + stack.elements[stack.elements.length-2] instanceof + impl.HTMLOptGroupElement) { + in_select_mode(ENDTAG, "option"); + } + if (stack.top instanceof impl.HTMLOptGroupElement) + stack.pop(); + + return; + + case "option": + if (stack.top instanceof impl.HTMLOptionElement) + stack.pop(); + return; + + case "select": + if (!stack.inSelectScope(value)) return; + stack.popTag(value); + resetInsertionMode(); + return; + + case "template": + in_head_mode(t, value, arg3, arg4); + return; + } + + break; + } + + // anything else: just ignore the token + } + + function in_select_in_table_mode(t, value, arg3, arg4) { + switch(value) { + case "caption": + case "table": + case "tbody": + case "tfoot": + case "thead": + case "tr": + case "td": + case "th": + switch(t) { + case 2: // TAG + in_select_in_table_mode(ENDTAG, "select"); + parser(t, value, arg3, arg4); + return; + case 3: // ENDTAG + if (stack.inTableScope(value)) { + in_select_in_table_mode(ENDTAG, "select"); + parser(t, value, arg3, arg4); + } + return; + } + } + + // anything else + in_select_mode(t, value, arg3, arg4); + } + + function in_template_mode(t, value, arg3, arg4) { + function switchModeAndReprocess(mode) { + parser = mode; + templateInsertionModes[templateInsertionModes.length-1] = parser; + parser(t, value, arg3, arg4); + } + switch(t) { + case 1: // TEXT + case 4: // COMMENT + case 5: // DOCTYPE + in_body_mode(t, value, arg3, arg4); + return; + case -1: // EOF + if (!stack.contains("template")) { + stopParsing(); + } else { + stack.popTag("template"); + afe.clearToMarker(); + templateInsertionModes.pop(); + resetInsertionMode(); + parser(t, value, arg3, arg4); + } + return; + case 2: // TAG + switch(value) { + case "base": + case "basefont": + case "bgsound": + case "link": + case "meta": + case "noframes": + case "script": + case "style": + case "template": + case "title": + in_head_mode(t, value, arg3, arg4); + return; + case "caption": + case "colgroup": + case "tbody": + case "tfoot": + case "thead": + switchModeAndReprocess(in_table_mode); + return; + case "col": + switchModeAndReprocess(in_column_group_mode); + return; + case "tr": + switchModeAndReprocess(in_table_body_mode); + return; + case "td": + case "th": + switchModeAndReprocess(in_row_mode); + return; + } + switchModeAndReprocess(in_body_mode); + return; + case 3: // ENDTAG + switch(value) { + case "template": + in_head_mode(t, value, arg3, arg4); + return; + default: + return; + } + } + } + + function after_body_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + // If any non-space chars, handle below + if (NONWS.test(value)) break; + in_body_mode(t, value); + return; + case 4: // COMMENT + // Append it to the element + stack.elements[0]._appendChild(doc.createComment(value)); + return; + case 5: // DOCTYPE + return; + case -1: // EOF + stopParsing(); + return; + case 2: // TAG + if (value === "html") { + in_body_mode(t, value, arg3, arg4); + return; + } + break; // for any other tags + case 3: // ENDTAG + if (value === "html") { + if (fragment) return; + parser = after_after_body_mode; + return; + } + break; // for any other tags + } + + // anything else + parser = in_body_mode; + parser(t, value, arg3, arg4); + } + + function in_frameset_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + // Ignore any non-space characters + value = value.replace(ALLNONWS, ""); + if (value.length > 0) insertText(value); + return; + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + return; + case -1: // EOF + stopParsing(); + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "frameset": + insertHTMLElement(value, arg3); + return; + case "frame": + insertHTMLElement(value, arg3); + stack.pop(); + return; + case "noframes": + in_head_mode(t, value, arg3, arg4); + return; + } + break; + case 3: // ENDTAG + if (value === "frameset") { + if (fragment && stack.top instanceof impl.HTMLHtmlElement) + return; + stack.pop(); + if (!fragment && + !(stack.top instanceof impl.HTMLFrameSetElement)) + parser = after_frameset_mode; + return; + } + break; + } + + // ignore anything else + } + + function after_frameset_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + // Ignore any non-space characters + value = value.replace(ALLNONWS, ""); + if (value.length > 0) insertText(value); + return; + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + return; + case -1: // EOF + stopParsing(); + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "noframes": + in_head_mode(t, value, arg3, arg4); + return; + } + break; + case 3: // ENDTAG + if (value === "html") { + parser = after_after_frameset_mode; + return; + } + break; + } + + // ignore anything else + } + + function after_after_body_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + // If any non-space chars, handle below + if (NONWS.test(value)) break; + in_body_mode(t, value, arg3, arg4); + return; + case 4: // COMMENT + doc._appendChild(doc.createComment(value)); + return; + case 5: // DOCTYPE + in_body_mode(t, value, arg3, arg4); + return; + case -1: // EOF + stopParsing(); + return; + case 2: // TAG + if (value === "html") { + in_body_mode(t, value, arg3, arg4); + return; + } + break; + } + + // anything else + parser = in_body_mode; + parser(t, value, arg3, arg4); + } + + function after_after_frameset_mode(t, value, arg3, arg4) { + switch(t) { + case 1: // TEXT + // Ignore any non-space characters + value = value.replace(ALLNONWS, ""); + if (value.length > 0) + in_body_mode(t, value, arg3, arg4); + return; + case 4: // COMMENT + doc._appendChild(doc.createComment(value)); + return; + case 5: // DOCTYPE + in_body_mode(t, value, arg3, arg4); + return; + case -1: // EOF + stopParsing(); + return; + case 2: // TAG + switch(value) { + case "html": + in_body_mode(t, value, arg3, arg4); + return; + case "noframes": + in_head_mode(t, value, arg3, arg4); + return; + } + break; + } + + // ignore anything else + } + + + // 13.2.5.5 The rules for parsing tokens in foreign content + // + // This is like one of the insertion modes above, but is + // invoked somewhat differently when the current token is not HTML. + // See the insertToken() function. + function insertForeignToken(t, value, arg3, arg4) { + // A tag is an HTML font tag if it has a color, font, or size + // attribute. Otherwise we assume it is foreign content + function isHTMLFont(attrs) { + for(var i = 0, n = attrs.length; i < n; i++) { + switch(attrs[i][0]) { + case "color": + case "face": + case "size": + return true; + } + } + return false; + } + + var current; + + switch(t) { + case 1: // TEXT + // If any non-space, non-nul characters + if (frameset_ok && NONWSNONNUL.test(value)) + frameset_ok = false; + if (textIncludesNUL) { + value = value.replace(NULCHARS, "\uFFFD"); + } + insertText(value); + return; + case 4: // COMMENT + insertComment(value); + return; + case 5: // DOCTYPE + // ignore it + return; + case 2: // TAG + switch(value) { + case "font": + if (!isHTMLFont(arg3)) break; + /* falls through */ + case "b": + case "big": + case "blockquote": + case "body": + case "br": + case "center": + case "code": + case "dd": + case "div": + case "dl": + case "dt": + case "em": + case "embed": + case "h1": + case "h2": + case "h3": + case "h4": + case "h5": + case "h6": + case "head": + case "hr": + case "i": + case "img": + case "li": + case "listing": + case "menu": + case "meta": + case "nobr": + case "ol": + case "p": + case "pre": + case "ruby": + case "s": + case "small": + case "span": + case "strong": + case "strike": + case "sub": + case "sup": + case "table": + case "tt": + case "u": + case "ul": + case "var": + if (fragment) { + break; + } + do { + stack.pop(); + current = stack.top; + } while(current.namespaceURI !== NAMESPACE.HTML && + !isMathmlTextIntegrationPoint(current) && + !isHTMLIntegrationPoint(current)); + + insertToken(t, value, arg3, arg4); // reprocess + return; + } + + // Any other start tag case goes here + current = (stack.elements.length===1 && fragment) ? fragmentContext : + stack.top; + if (current.namespaceURI === NAMESPACE.MATHML) { + adjustMathMLAttributes(arg3); + } + else if (current.namespaceURI === NAMESPACE.SVG) { + value = adjustSVGTagName(value); + adjustSVGAttributes(arg3); + } + adjustForeignAttributes(arg3); + + insertForeignElement(value, arg3, current.namespaceURI); + if (arg4) { // the self-closing flag + if (value === 'script' && current.namespaceURI === NAMESPACE.SVG) { + // XXX deal with SVG scripts here + } + stack.pop(); + } + return; + + case 3: // ENDTAG + current = stack.top; + if (value === "script" && + current.namespaceURI === NAMESPACE.SVG && + current.localName === "script") { + + stack.pop(); + + // XXX + // Deal with SVG scripts here + } + else { + // The any other end tag case + var i = stack.elements.length-1; + var node = stack.elements[i]; + for(;;) { + if (node.localName.toLowerCase() === value) { + stack.popElement(node); + break; + } + node = stack.elements[--i]; + // If non-html, keep looping + if (node.namespaceURI !== NAMESPACE.HTML) + continue; + // Otherwise process the end tag as html + parser(t, value, arg3, arg4); + break; + } + } + return; + } + } + + /*** + * Finally, this is the end of the HTMLParser() factory function. + * It returns the htmlparser object with the append() and end() methods. + */ + + // Sneak another method into the htmlparser object to allow us to run + // tokenizer tests. This can be commented out in production code. + // This is a hook for testing the tokenizer. It has to be here + // because the tokenizer details are all hidden away within the closure. + // It should return an array of tokens generated while parsing the + // input string. + htmlparser.testTokenizer = function(input, initialState, lastStartTag, charbychar) { + var tokens = []; + + switch(initialState) { + case "PCDATA state": + tokenizer = data_state; + break; + case "RCDATA state": + tokenizer = rcdata_state; + break; + case "RAWTEXT state": + tokenizer = rawtext_state; + break; + case "PLAINTEXT state": + tokenizer = plaintext_state; + break; + } + + if (lastStartTag) { + lasttagname = lastStartTag; + } + + insertToken = function(t, value, arg3, arg4) { + flushText(); + switch(t) { + case 1: // TEXT + if (tokens.length > 0 && + tokens[tokens.length-1][0] === "Character") { + tokens[tokens.length-1][1] += value; + } + else tokens.push(["Character", value]); + break; + case 4: // COMMENT + tokens.push(["Comment", value]); + break; + case 5: // DOCTYPE + tokens.push(["DOCTYPE", value, + arg3 === undefined ? null : arg3, + arg4 === undefined ? null : arg4, + !force_quirks]); + break; + case 2: // TAG + var attrs = Object.create(null); + for(var i = 0; i < arg3.length; i++) { + // XXX: does attribute order matter? + var a = arg3[i]; + if (a.length === 1) { + attrs[a[0]] = ""; + } + else { + attrs[a[0]] = a[1]; + } + } + var token = ["StartTag", value, attrs]; + if (arg4) token.push(true); + tokens.push(token); + break; + case 3: // ENDTAG + tokens.push(["EndTag", value]); + break; + case -1: // EOF + break; + } + }; + + if (!charbychar) { + this.parse(input, true); + } + else { + for(var i = 0; i < input.length; i++) { + this.parse(input[i]); + } + this.parse("", true); + } + return tokens; + }; + + // Return the parser object from the HTMLParser() factory function + return htmlparser; +} + + +/***/ }), +/* 20 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var Subject_1 = __webpack_require__(6); -var queue_1 = __webpack_require__(71); -var Subscription_1 = __webpack_require__(9); -var observeOn_1 = __webpack_require__(87); -var ObjectUnsubscribedError_1 = __webpack_require__(80); -var SubjectSubscription_1 = __webpack_require__(385); -/** - * @class ReplaySubject - */ -var ReplaySubject = (function (_super) { - __extends(ReplaySubject, _super); - function ReplaySubject(bufferSize, windowTime, scheduler) { - if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; } - if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; } - _super.call(this); - this.scheduler = scheduler; - this._events = []; - this._bufferSize = bufferSize < 1 ? 1 : bufferSize; - this._windowTime = windowTime < 1 ? 1 : windowTime; - } - ReplaySubject.prototype.next = function (value) { - var now = this._getNow(); - this._events.push(new ReplayEvent(now, value)); - this._trimBufferThenGetEvents(); - _super.prototype.next.call(this, value); - }; - ReplaySubject.prototype._subscribe = function (subscriber) { - var _events = this._trimBufferThenGetEvents(); - var scheduler = this.scheduler; - var subscription; - if (this.closed) { - throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError(); +module.exports = URL; + +function URL(url) { + if (!url) return Object.create(URL.prototype); + // Can't use String.trim() since it defines whitespace differently than HTML + this.url = url.replace(/^[ \t\n\r\f]+|[ \t\n\r\f]+$/g, ""); + + // See http://tools.ietf.org/html/rfc3986#appendix-B + // and https://url.spec.whatwg.org/#parsing + var match = URL.pattern.exec(this.url); + if (match) { + if (match[2]) this.scheme = match[2]; + if (match[4]) { + // parse username/password + var userinfo = match[4].match(URL.userinfoPattern); + if (userinfo) { + this.username = userinfo[1]; + this.password = userinfo[3]; + match[4] = match[4].substring(userinfo[0].length); + } + if (match[4].match(URL.portPattern)) { + var pos = match[4].lastIndexOf(':'); + this.host = match[4].substring(0, pos); + this.port = match[4].substring(pos+1); + } + else { + this.host = match[4]; + } + } + if (match[5]) this.path = match[5]; + if (match[6]) this.query = match[7]; + if (match[8]) this.fragment = match[9]; + } +} + +URL.pattern = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/; +URL.userinfoPattern = /^([^@:]*)(:([^@]*))?@/; +URL.portPattern = /:\d+$/; +URL.authorityPattern = /^[^:\/?#]+:\/\//; +URL.hierarchyPattern = /^[^:\/?#]+:\//; + +// Return a percentEncoded version of s. +// S should be a single-character string +// XXX: needs to do utf-8 encoding? +URL.percentEncode = function percentEncode(s) { + var c = s.charCodeAt(0); + if (c < 256) return "%" + c.toString(16); + else throw Error("can't percent-encode codepoints > 255 yet"); +}; + +URL.prototype = { + constructor: URL, + + // XXX: not sure if this is the precise definition of absolute + isAbsolute: function() { return !!this.scheme; }, + isAuthorityBased: function() { + return URL.authorityPattern.test(this.url); + }, + isHierarchical: function() { + return URL.hierarchyPattern.test(this.url); + }, + + toString: function() { + var s = ""; + if (this.scheme !== undefined) s += this.scheme + ":"; + if (this.isAbsolute()) { + s += '//'; + if (this.username || this.password) { + s += this.username || ''; + if (this.password) { + s += ':' + this.password; + } + s += '@'; + } + s += this.host; + } + if (this.port !== undefined) s += ":" + this.port; + if (this.path !== undefined) s += this.path; + if (this.query !== undefined) s += "?" + this.query; + if (this.fragment !== undefined) s += "#" + this.fragment; + return s; + }, + + // See: http://tools.ietf.org/html/rfc3986#section-5.2 + // and https://url.spec.whatwg.org/#constructors + resolve: function(relative) { + var base = this; // The base url we're resolving against + var r = new URL(relative); // The relative reference url to resolve + var t = new URL(); // The absolute target url we will return + + if (r.scheme !== undefined) { + t.scheme = r.scheme; + t.username = r.username; + t.password = r.password; + t.host = r.host; + t.port = r.port; + t.path = remove_dot_segments(r.path); + t.query = r.query; + } + else { + t.scheme = base.scheme; + if (r.host !== undefined) { + t.username = r.username; + t.password = r.password; + t.host = r.host; + t.port = r.port; + t.path = remove_dot_segments(r.path); + t.query = r.query; + } + else { + t.username = base.username; + t.password = base.password; + t.host = base.host; + t.port = base.port; + if (!r.path) { // undefined or empty + t.path = base.path; + if (r.query !== undefined) + t.query = r.query; + else + t.query = base.query; + } + else { + if (r.path.charAt(0) === "/") { + t.path = remove_dot_segments(r.path); + } + else { + t.path = merge(base.path, r.path); + t.path = remove_dot_segments(t.path); + } + t.query = r.query; + } + } + } + t.fragment = r.fragment; + + return t.toString(); + + + function merge(basepath, refpath) { + if (base.host !== undefined && !base.path) + return "/" + refpath; + + var lastslash = basepath.lastIndexOf("/"); + if (lastslash === -1) + return refpath; + else + return basepath.substring(0, lastslash+1) + refpath; + } + + function remove_dot_segments(path) { + if (!path) return path; // For "" or undefined + + var output = ""; + while(path.length > 0) { + if (path === "." || path === "..") { + path = ""; + break; } - else if (this.hasError) { - subscription = Subscription_1.Subscription.EMPTY; + + var twochars = path.substring(0,2); + var threechars = path.substring(0,3); + var fourchars = path.substring(0,4); + if (threechars === "../") { + path = path.substring(3); } - else if (this.isStopped) { - subscription = Subscription_1.Subscription.EMPTY; + else if (twochars === "./") { + path = path.substring(2); } - else { - this.observers.push(subscriber); - subscription = new SubjectSubscription_1.SubjectSubscription(this, subscriber); + else if (threechars === "/./") { + path = "/" + path.substring(3); } - if (scheduler) { - subscriber.add(subscriber = new observeOn_1.ObserveOnSubscriber(subscriber, scheduler)); - } - var len = _events.length; - for (var i = 0; i < len && !subscriber.closed; i++) { - subscriber.next(_events[i].value); - } - if (this.hasError) { - subscriber.error(this.thrownError); - } - else if (this.isStopped) { - subscriber.complete(); - } - return subscription; - }; - ReplaySubject.prototype._getNow = function () { - return (this.scheduler || queue_1.queue).now(); - }; - ReplaySubject.prototype._trimBufferThenGetEvents = function () { - var now = this._getNow(); - var _bufferSize = this._bufferSize; - var _windowTime = this._windowTime; - var _events = this._events; - var eventsCount = _events.length; - var spliceCount = 0; - // Trim events that fall out of the time window. - // Start at the front of the list. Break early once - // we encounter an event that falls within the window. - while (spliceCount < eventsCount) { - if ((now - _events[spliceCount].time) < _windowTime) { - break; - } - spliceCount++; + else if (twochars === "/." && path.length === 2) { + path = "/"; } - if (eventsCount > _bufferSize) { - spliceCount = Math.max(spliceCount, eventsCount - _bufferSize); + else if (fourchars === "/../" || + (threechars === "/.." && path.length === 3)) { + path = "/" + path.substring(4); + + output = output.replace(/\/?[^\/]*$/, ""); } - if (spliceCount > 0) { - _events.splice(0, spliceCount); + else { + var segment = path.match(/(\/?([^\/]*))/)[0]; + output += segment; + path = path.substring(segment.length); } - return _events; - }; - return ReplaySubject; -}(Subject_1.Subject)); -exports.ReplaySubject = ReplaySubject; -var ReplayEvent = (function () { - function ReplayEvent(time, value) { - this.time = time; - this.value = value; + } + + return output; } - return ReplayEvent; -}()); -//# sourceMappingURL=ReplaySubject.js.map + }, +}; + /***/ }), -/* 27 */ +/* 21 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -function isDate(value) { - return value instanceof Date && !isNaN(+value); +var DOMImplementation = __webpack_require__(9); +var EventTarget = __webpack_require__(33); +var Location = __webpack_require__(75); +var sloppy = __webpack_require__(47); +var utils = __webpack_require__(1); + +module.exports = Window; + +function Window(document) { + this.document = document || new DOMImplementation().createHTMLDocument(""); + this.document._scripting_enabled = true; + this.document.defaultView = this; + this.location = new Location(this, this.document._address || 'about:blank'); } -exports.isDate = isDate; -//# sourceMappingURL=isDate.js.map + +Window.prototype = Object.create(EventTarget.prototype, { + _run: { value: sloppy.Window_run }, + console: { value: console }, + history: { value: { + back: utils.nyi, + forward: utils.nyi, + go: utils.nyi + }}, + navigator: { value: __webpack_require__(77) }, + + // Self-referential properties + window: { get: function() { return this; }}, + self: { get: function() { return this; }}, + frames: { get: function() { return this; }}, + + // Self-referential properties for a top-level window + parent: { get: function() { return this; }}, + top: { get: function() { return this; }}, + + // We don't support any other windows for now + length: { value: 0 }, // no frames + frameElement: { value: null }, // not part of a frame + opener: { value: null }, // not opened by another window + + // The onload event handler. + // XXX: need to support a bunch of other event types, too, + // and have them interoperate with document.body. + + onload: { + get: function() { + return this._getEventHandler("load"); + }, + set: function(v) { + this._setEventHandler("load", v); + } + }, + + // XXX This is a completely broken implementation + getComputedStyle: { value: function getComputedStyle(elt) { + return elt.style; + }} + +}); + +utils.expose(__webpack_require__(80), Window); +utils.expose(__webpack_require__(46), Window); + /***/ }), -/* 28 */ +/* 22 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var isArray_1 = __webpack_require__(15); -function isNumeric(val) { - // parseFloat NaNs numeric-cast false positives (null|true|false|"") - // ...but misinterprets leading-number strings, particularly hex literals ("0x...") - // subtraction forces infinities to NaN - // adding 1 corrects loss of precision from parseFloat (#15100) - return !isArray_1.isArray(val) && (val - parseFloat(val) + 1) >= 0; +var Node = __webpack_require__(3); +var Element = __webpack_require__(6); +var CSSStyleDeclaration = __webpack_require__(15); +var utils = __webpack_require__(1); +var URLUtils = __webpack_require__(41); +var defineElement = __webpack_require__(44); + +var htmlElements = exports.elements = {}; +var htmlNameToImpl = Object.create(null); + +exports.createElement = function(doc, localName, prefix) { + var impl = htmlNameToImpl[localName] || HTMLUnknownElement; + return new impl(doc, localName, prefix); +}; + +function define(spec) { + return defineElement(spec, HTMLElement, htmlElements, htmlNameToImpl); } -exports.isNumeric = isNumeric; -; -//# sourceMappingURL=isNumeric.js.map -/***/ }), -/* 29 */ -/***/ (function(module, exports, __webpack_require__) { +function URL(attr) { + return { + get: function() { + var v = this._getattr(attr); + if (v === null) { return ''; } + var url = this.doc._resolve(v); + return (url === null) ? v : url; + }, + set: function(value) { + this._setattr(attr, value); + } + }; +} -module.exports = (__webpack_require__(1))(38); +function CORS(attr) { + return { + get: function() { + var v = this._getattr(attr); + if (v === null) { return null; } + if (v.toLowerCase() === 'use-credentials') { return 'use-credentials'; } + return 'anonymous'; + }, + set: function(value) { + if (value===null || value===undefined) { + this.removeAttribute(attr); + } else { + this._setattr(attr, value); + } + } + }; +} -/***/ }), -/* 30 */ -/***/ (function(module, exports, __webpack_require__) { +var REFERRER = { + type: ["", "no-referrer", "no-referrer-when-downgrade", "same-origin", "origin", "strict-origin", "origin-when-cross-origin", "strict-origin-when-cross-origin", "unsafe-url"], + missing: '', +}; -module.exports = (__webpack_require__(1))(67); -/***/ }), -/* 31 */ -/***/ (function(module, exports) { +// XXX: the default value for tabIndex should be 0 if the element is +// focusable and -1 if it is not. But the full definition of focusable +// is actually hard to compute, so for now, I'll follow Firefox and +// just base the default value on the type of the element. +var focusableElements = { + "A":true, "LINK":true, "BUTTON":true, "INPUT":true, + "SELECT":true, "TEXTAREA":true, "COMMAND":true +}; -module.exports = require("stream"); +var HTMLFormElement = function(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + this._form = null; // Prevent later deoptimization +}; -/***/ }), -/* 32 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +var HTMLElement = exports.HTMLElement = define({ + superclass: Element, + ctor: function HTMLElement(doc, localName, prefix) { + Element.call(this, doc, localName, utils.NAMESPACE.HTML, prefix); + }, + props: { + innerHTML: { + get: function() { + return this.serialize(); + }, + set: function(v) { + var parser = this.ownerDocument.implementation.mozHTMLParser( + this.ownerDocument._address, + this); + parser.parse(v, true); + var tmpdoc = parser.document(); + var root = tmpdoc.firstChild; + var target = (this instanceof htmlNameToImpl.template) ? + this.content : this; -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AuthService; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__angular_core__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http__ = __webpack_require__(29); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__angular_http___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__angular_http__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__); -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -var __param = (this && this.__param) || function (paramIndex, decorator) { - return function (target, key) { decorator(target, key, paramIndex); } -}; - - - -var AuthService = (function () { - function AuthService(oidcSecurityService, http, originUrl, identityUrl) { - var _this = this; - this.oidcSecurityService = oidcSecurityService; - this.http = http; - var openIdImplicitFlowConfiguration = new __WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OpenIDImplicitFlowConfiguration"](); - openIdImplicitFlowConfiguration.stsServer = identityUrl; - openIdImplicitFlowConfiguration.redirect_url = originUrl + 'callback'; - openIdImplicitFlowConfiguration.client_id = 'ng'; - openIdImplicitFlowConfiguration.response_type = 'id_token token'; - openIdImplicitFlowConfiguration.scope = 'openid profile apiApp'; - openIdImplicitFlowConfiguration.post_logout_redirect_uri = originUrl + 'home'; - openIdImplicitFlowConfiguration.forbidden_route = '/forbidden'; - openIdImplicitFlowConfiguration.unauthorized_route = '/unauthorized'; - openIdImplicitFlowConfiguration.auto_userinfo = true; - openIdImplicitFlowConfiguration.log_console_warning_active = true; - openIdImplicitFlowConfiguration.log_console_debug_active = false; - openIdImplicitFlowConfiguration.max_id_token_iat_offset_allowed_in_seconds = 10; - this.oidcSecurityService.setupModule(openIdImplicitFlowConfiguration); - if (this.oidcSecurityService.moduleSetup) { - this.doCallbackLogicIfRequired(); - } - else { - this.oidcSecurityService.onModuleSetup.subscribe(function () { - _this.doCallbackLogicIfRequired(); - }); - } - } - AuthService.prototype.ngOnInit = function () { - var _this = this; - this.isAuthorizedSubscription = this.oidcSecurityService.getIsAuthorized().subscribe(function (isAuthorized) { - _this.isAuthorized = isAuthorized; - }); - }; - AuthService.prototype.ngOnDestroy = function () { - this.isAuthorizedSubscription.unsubscribe(); - this.oidcSecurityService.onModuleSetup.unsubscribe(); - }; - AuthService.prototype.getIsAuthorized = function () { - return this.oidcSecurityService.getIsAuthorized(); - }; - AuthService.prototype.login = function () { - console.log('start login'); - this.oidcSecurityService.authorize(); - }; - AuthService.prototype.refreshSession = function () { - console.log('start refreshSession'); - this.oidcSecurityService.authorize(); - }; - AuthService.prototype.logout = function () { - console.log('start logoff'); - this.oidcSecurityService.logoff(); - }; - AuthService.prototype.doCallbackLogicIfRequired = function () { - if (typeof location !== "undefined" && window.location.hash) { - this.oidcSecurityService.authorizedCallback(); - } - }; - AuthService.prototype.get = function (url, options) { - return this.http.get(url, this.setRequestOptions(options)); - }; - AuthService.prototype.put = function (url, data, options) { - var body = JSON.stringify(data); - return this.http.put(url, body, this.setRequestOptions(options)); - }; - AuthService.prototype.delete = function (url, options) { - return this.http.delete(url, this.setRequestOptions(options)); - }; - AuthService.prototype.post = function (url, data, options) { - var body = JSON.stringify(data); - return this.http.post(url, body, this.setRequestOptions(options)); - }; - AuthService.prototype.setRequestOptions = function (options) { - if (options) { - this.appendAuthHeader(options.headers); - } - else { - options = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["RequestOptions"]({ headers: this.getHeaders(), body: "" }); - } - return options; - }; - AuthService.prototype.getHeaders = function () { - var headers = new __WEBPACK_IMPORTED_MODULE_1__angular_http__["Headers"](); - headers.append('Content-Type', 'application/json'); - this.appendAuthHeader(headers); - return headers; - }; - AuthService.prototype.appendAuthHeader = function (headers) { - if (headers == null) - headers = this.getHeaders(); - var token = this.oidcSecurityService.getToken(); - if (token == '') - return; - var tokenValue = 'Bearer ' + token; - headers.append('Authorization', tokenValue); - }; - AuthService = __decorate([ - __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Injectable"])(), - __param(2, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Inject"])('ORIGIN_URL')), - __param(3, __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Inject"])('IDENTITY_URL')), - __metadata("design:paramtypes", [__WEBPACK_IMPORTED_MODULE_2_angular_auth_oidc_client__["OidcSecurityService"], - __WEBPACK_IMPORTED_MODULE_1__angular_http__["Http"], String, String]) - ], AuthService); - return AuthService; -}()); - + // Remove any existing children of this node + while(target.hasChildNodes()) + target.removeChild(target.firstChild); + // Now copy newly parsed children from the root to this node + target.doc.adoptNode(root); + while(root.hasChildNodes()) { + target.appendChild(root.firstChild); + } + } + }, + style: { get: function() { + if (!this._style) + this._style = new CSSStyleDeclaration(this); + return this._style; + }}, + + click: { value: function() { + if (this._click_in_progress) return; + this._click_in_progress = true; + try { + if (this._pre_click_activation_steps) + this._pre_click_activation_steps(); + + var event = this.ownerDocument.createEvent("MouseEvent"); + event.initMouseEvent("click", true, true, + this.ownerDocument.defaultView, 1, + 0, 0, 0, 0, + // These 4 should be initialized with + // the actually current keyboard state + // somehow... + false, false, false, false, + 0, null + ); + + // Dispatch this as an untrusted event since it is synthetic + var success = this.dispatchEvent(event); + + if (success) { + if (this._post_click_activation_steps) + this._post_click_activation_steps(event); + } + else { + if (this._cancelled_activation_steps) + this._cancelled_activation_steps(); + } + } + finally { + this._click_in_progress = false; + } + }} + }, + attributes: { + title: String, + lang: String, + dir: {type: ["ltr", "rtl", "auto"], missing: ''}, + accessKey: String, + hidden: Boolean, + tabIndex: {type: "long", default: function() { + if (this.tagName in focusableElements || + this.contentEditable) + return 0; + else + return -1; + }} + }, + events: [ + "abort", "canplay", "canplaythrough", "change", "click", "contextmenu", + "cuechange", "dblclick", "drag", "dragend", "dragenter", "dragleave", + "dragover", "dragstart", "drop", "durationchange", "emptied", "ended", + "input", "invalid", "keydown", "keypress", "keyup", "loadeddata", + "loadedmetadata", "loadstart", "mousedown", "mousemove", "mouseout", + "mouseover", "mouseup", "mousewheel", "pause", "play", "playing", + "progress", "ratechange", "readystatechange", "reset", "seeked", + "seeking", "select", "show", "stalled", "submit", "suspend", + "timeupdate", "volumechange", "waiting", + + // These last 5 event types will be overriden by HTMLBodyElement + "blur", "error", "focus", "load", "scroll" + ] +}); -/***/ }), -/* 33 */ -/***/ (function(module, exports, __webpack_require__) { -"use strict"; +// XXX: reflect contextmenu as contextMenu, with element type -var DOCUMENT_MODE = __webpack_require__(11).DOCUMENT_MODE; - -//Const -var VALID_DOCTYPE_NAME = 'html', - QUIRKS_MODE_SYSTEM_ID = 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd', - QUIRKS_MODE_PUBLIC_ID_PREFIXES = [ - '+//silmaril//dtd html pro v0r11 19970101//en', - '-//advasoft ltd//dtd html 3.0 aswedit + extensions//en', - '-//as//dtd html 3.0 aswedit + extensions//en', - '-//ietf//dtd html 2.0 level 1//en', - '-//ietf//dtd html 2.0 level 2//en', - '-//ietf//dtd html 2.0 strict level 1//en', - '-//ietf//dtd html 2.0 strict level 2//en', - '-//ietf//dtd html 2.0 strict//en', - '-//ietf//dtd html 2.0//en', - '-//ietf//dtd html 2.1e//en', - '-//ietf//dtd html 3.0//en', - '-//ietf//dtd html 3.0//en//', - '-//ietf//dtd html 3.2 final//en', - '-//ietf//dtd html 3.2//en', - '-//ietf//dtd html 3//en', - '-//ietf//dtd html level 0//en', - '-//ietf//dtd html level 0//en//2.0', - '-//ietf//dtd html level 1//en', - '-//ietf//dtd html level 1//en//2.0', - '-//ietf//dtd html level 2//en', - '-//ietf//dtd html level 2//en//2.0', - '-//ietf//dtd html level 3//en', - '-//ietf//dtd html level 3//en//3.0', - '-//ietf//dtd html strict level 0//en', - '-//ietf//dtd html strict level 0//en//2.0', - '-//ietf//dtd html strict level 1//en', - '-//ietf//dtd html strict level 1//en//2.0', - '-//ietf//dtd html strict level 2//en', - '-//ietf//dtd html strict level 2//en//2.0', - '-//ietf//dtd html strict level 3//en', - '-//ietf//dtd html strict level 3//en//3.0', - '-//ietf//dtd html strict//en', - '-//ietf//dtd html strict//en//2.0', - '-//ietf//dtd html strict//en//3.0', - '-//ietf//dtd html//en', - '-//ietf//dtd html//en//2.0', - '-//ietf//dtd html//en//3.0', - '-//metrius//dtd metrius presentational//en', - '-//microsoft//dtd internet explorer 2.0 html strict//en', - '-//microsoft//dtd internet explorer 2.0 html//en', - '-//microsoft//dtd internet explorer 2.0 tables//en', - '-//microsoft//dtd internet explorer 3.0 html strict//en', - '-//microsoft//dtd internet explorer 3.0 html//en', - '-//microsoft//dtd internet explorer 3.0 tables//en', - '-//netscape comm. corp.//dtd html//en', - '-//netscape comm. corp.//dtd strict html//en', - '-//o\'reilly and associates//dtd html 2.0//en', - '-//o\'reilly and associates//dtd html extended 1.0//en', - '-//spyglass//dtd html 2.0 extended//en', - '-//sq//dtd html 2.0 hotmetal + extensions//en', - '-//sun microsystems corp.//dtd hotjava html//en', - '-//sun microsystems corp.//dtd hotjava strict html//en', - '-//w3c//dtd html 3 1995-03-24//en', - '-//w3c//dtd html 3.2 draft//en', - '-//w3c//dtd html 3.2 final//en', - '-//w3c//dtd html 3.2//en', - '-//w3c//dtd html 3.2s draft//en', - '-//w3c//dtd html 4.0 frameset//en', - '-//w3c//dtd html 4.0 transitional//en', - '-//w3c//dtd html experimental 19960712//en', - '-//w3c//dtd html experimental 970421//en', - '-//w3c//dtd w3 html//en', - '-//w3o//dtd w3 html 3.0//en', - '-//w3o//dtd w3 html 3.0//en//', - '-//webtechs//dtd mozilla html 2.0//en', - '-//webtechs//dtd mozilla html//en' - ], - QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES = QUIRKS_MODE_PUBLIC_ID_PREFIXES.concat([ - '-//w3c//dtd html 4.01 frameset//', - '-//w3c//dtd html 4.01 transitional//' - ]), - QUIRKS_MODE_PUBLIC_IDS = [ - '-//w3o//dtd w3 html strict 3.0//en//', - '-/w3c/dtd html 4.0 transitional/en', - 'html' - ], - LIMITED_QUIRKS_PUBLIC_ID_PREFIXES = [ - '-//W3C//DTD XHTML 1.0 Frameset//', - '-//W3C//DTD XHTML 1.0 Transitional//' - ], - LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES = LIMITED_QUIRKS_PUBLIC_ID_PREFIXES.concat([ - '-//W3C//DTD HTML 4.01 Frameset//', - '-//W3C//DTD HTML 4.01 Transitional//' - ]); +// style: the spec doesn't call this a reflected attribute. +// may want to handle it manually. +// contentEditable: enumerated, not clear if it is actually +// reflected or requires custom getter/setter. Not listed as +// "limited to known values". Raises syntax_err on bad setting, +// so I think this is custom. -//Utils -function enquoteDoctypeId(id) { - var quote = id.indexOf('"') !== -1 ? '\'' : '"'; +// contextmenu: content is element id, idl type is an element +// draggable: boolean, but not a reflected attribute +// dropzone: reflected SettableTokenList, experimental, so don't +// implement it right away. - return quote + id + quote; -} +// data-* attributes: need special handling in setAttribute? +// Or maybe that isn't necessary. Can I just scan the attribute list +// when building the dataset? Liveness and caching issues? -function hasPrefix(publicId, prefixes) { - for (var i = 0; i < prefixes.length; i++) { - if (publicId.indexOf(prefixes[i]) === 0) - return true; - } +// microdata attributes: many are simple reflected attributes, but +// I'm not going to implement this now. - return false; -} +var HTMLUnknownElement = define({ + ctor: function HTMLUnknownElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + } +}); -//API -exports.getDocumentMode = function (name, publicId, systemId) { - if (name !== VALID_DOCTYPE_NAME) - return DOCUMENT_MODE.QUIRKS; - if (systemId && systemId.toLowerCase() === QUIRKS_MODE_SYSTEM_ID) - return DOCUMENT_MODE.QUIRKS; +var formAssociatedProps = { + // See http://www.w3.org/TR/html5/association-of-controls-and-forms.html#form-owner + form: { get: function() { + return this._form; + }} +}; + +define({ + tag: 'a', + ctor: function HTMLAnchorElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + _post_click_activation_steps: { value: function(e) { + if (this.href) { + // Follow the link + // XXX: this is just a quick hack + // XXX: the HTML spec probably requires more than this + this.ownerDocument.defaultView.location = this.href; + } + }}, + blur: { value: function() {}}, + focus: { value: function() {}} + }, + attributes: { + href: URL, + ping: String, + download: String, + target: String, + rel: String, + media: String, + hreflang: String, + type: String, + referrerPolicy: REFERRER, + // Obsolete + coords: String, + charset: String, + name: String, + rev: String, + shape: String, + } +}); +URLUtils._inherit(htmlNameToImpl.a.prototype); + +define({ + tag: 'area', + ctor: function HTMLAreaElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + alt: String, + target: String, + download: String, + rel: String, + media: String, + href: URL, + hreflang: String, + type: String, + shape: String, + coords: String, + ping: String, + // XXX: also reflect relList + referrerPolicy: REFERRER, + // Obsolete + noHref: Boolean, + } +}); - if (publicId !== null) { - publicId = publicId.toLowerCase(); +define({ + tag: 'br', + ctor: function HTMLBRElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + clear: String + }, +}); - if (QUIRKS_MODE_PUBLIC_IDS.indexOf(publicId) > -1) - return DOCUMENT_MODE.QUIRKS; +define({ + tag: 'base', + ctor: function HTMLBaseElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + "target": String + } +}); - var prefixes = systemId === null ? QUIRKS_MODE_NO_SYSTEM_ID_PUBLIC_ID_PREFIXES : QUIRKS_MODE_PUBLIC_ID_PREFIXES; - if (hasPrefix(publicId, prefixes)) - return DOCUMENT_MODE.QUIRKS; +define({ + tag: 'body', + ctor: function HTMLBodyElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + // Certain event handler attributes on a tag actually set + // handlers for the window rather than just that element. Define + // getters and setters for those here. Note that some of these override + // properties on HTMLElement.prototype. + // XXX: If I add support for , these have to go there, too + // XXX + // When the Window object is implemented, these attribute will have + // to work with the same-named attributes on the Window. + events: [ + "afterprint", "beforeprint", "beforeunload", "blur", "error", + "focus","hashchange", "load", "message", "offline", "online", + "pagehide", "pageshow","popstate","resize","scroll","storage","unload", + ], + attributes: { + // Obsolete + text: { type: String, treatNullAsEmptyString: true }, + link: { type: String, treatNullAsEmptyString: true }, + vLink: { type: String, treatNullAsEmptyString: true }, + aLink: { type: String, treatNullAsEmptyString: true }, + bgColor: { type: String, treatNullAsEmptyString: true }, + background: String, + } +}); - prefixes = systemId === null ? LIMITED_QUIRKS_PUBLIC_ID_PREFIXES : LIMITED_QUIRKS_WITH_SYSTEM_ID_PUBLIC_ID_PREFIXES; +define({ + tag: 'button', + ctor: function HTMLButtonElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + name: String, + value: String, + disabled: Boolean, + autofocus: Boolean, + type: { type:["submit", "reset", "button", "menu"], missing: 'submit' }, + formTarget: String, + formNoValidate: Boolean, + formMethod: { type: ["get", "post", "dialog"], invalid: 'get', missing: '' }, + formEnctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: '' }, + } +}); - if (hasPrefix(publicId, prefixes)) - return DOCUMENT_MODE.LIMITED_QUIRKS; - } +define({ + tag: 'dl', + ctor: function HTMLDListElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + compact: Boolean, + } +}); - return DOCUMENT_MODE.NO_QUIRKS; -}; +define({ + tag: 'data', + ctor: function HTMLDataElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + value: String, + } +}); -exports.serializeContent = function (name, publicId, systemId) { - var str = '!DOCTYPE '; +define({ + tag: 'datalist', + ctor: function HTMLDataListElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + } +}); - if (name) - str += name; +define({ + tag: 'details', + ctor: function HTMLDetailsElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + "open": Boolean + } +}); - if (publicId !== null) - str += ' PUBLIC ' + enquoteDoctypeId(publicId); +define({ + tag: 'div', + ctor: function HTMLDivElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + align: String + } +}); - else if (systemId !== null) - str += ' SYSTEM'; +define({ + tag: 'embed', + ctor: function HTMLEmbedElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + src: URL, + type: String, + width: String, + height: String, + // Obsolete + align: String, + name: String, + } +}); - if (systemId !== null) - str += ' ' + enquoteDoctypeId(systemId); +define({ + tag: 'fieldset', + ctor: function HTMLFieldSetElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + disabled: Boolean, + name: String + } +}); - return str; -}; +define({ + tag: 'form', + ctor: function HTMLFormElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + action: String, + autocomplete: {type:['on', 'off'], missing: 'on'}, + name: String, + acceptCharset: {name: "accept-charset"}, + target: String, + noValidate: Boolean, + method: { type: ["get", "post", "dialog"], invalid: 'get', missing: 'get' }, + // Both enctype and encoding reflect the enctype content attribute + enctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: "application/x-www-form-urlencoded" }, + encoding: {name: 'enctype', type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: "application/x-www-form-urlencoded" }, + } +}); +define({ + tag: 'hr', + ctor: function HTMLHRElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + align: String, + color: String, + noShade: Boolean, + size: String, + width: String, + }, +}); -/***/ }), -/* 34 */ -/***/ (function(module, exports, __webpack_require__) { +define({ + tag: 'head', + ctor: function HTMLHeadElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + } +}); -"use strict"; +define({ + tags: ['h1','h2','h3','h4','h5','h6'], + ctor: function HTMLHeadingElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + align: String, + }, +}); +define({ + tag: 'html', + ctor: function HTMLHtmlElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + version: String + } +}); -module.exports = function mergeOptions(defaults, options) { - options = options || Object.create(null); +define({ + tag: 'iframe', + ctor: function HTMLIFrameElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + var Window = __webpack_require__(21); // Avoid circular dependencies. + this._contentWindow = new Window(); + }, + props: { + contentWindow: { get: function() { + return this._contentWindow; + } }, + contentDocument: { get: function() { + return this.contentWindow.document; + } }, + }, + attributes: { + src: URL, + srcdoc: String, + name: String, + width: String, + height: String, + // XXX: sandbox is a reflected settable token list + seamless: Boolean, + allowFullscreen: Boolean, + allowUserMedia: Boolean, + allowPaymentRequest: Boolean, + referrerPolicy: REFERRER, + // Obsolete + align: String, + scrolling: String, + frameBorder: String, + longDesc: URL, + marginHeight: { type: String, treatNullAsEmptyString: true }, + marginWidth: { type: String, treatNullAsEmptyString: true }, + } +}); - return [defaults, options].reduce(function (merged, optObj) { - Object.keys(optObj).forEach(function (key) { - merged[key] = optObj[key]; - }); +define({ + tag: 'img', + ctor: function HTMLImageElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + alt: String, + src: URL, + srcset: String, + crossOrigin: CORS, + useMap: String, + isMap: Boolean, + height: { type: "unsigned long", default: 0 }, + width: { type: "unsigned long", default: 0 }, + referrerPolicy: REFERRER, + // Obsolete: + name: String, + lowsrc: URL, + align: String, + hspace: { type: "unsigned long", default: 0 }, + vspace: { type: "unsigned long", default: 0 }, + longDesc: URL, + border: { type: String, treatNullAsEmptyString: true }, + } +}); - return merged; - }, Object.create(null)); -}; +define({ + tag: 'input', + ctor: function HTMLInputElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: { + form: formAssociatedProps.form, + _post_click_activation_steps: { value: function(e) { + if (this.type === 'checkbox') { + this.checked = !this.checked; + } + else if (this.type === 'radio') { + var group = this.form.getElementsByName(this.name); + for (var i=group.length-1; i >= 0; i--) { + var el = group[i]; + el.checked = (el === this); + } + } + }}, + }, + attributes: { + name: String, + disabled: Boolean, + autofocus: Boolean, + accept: String, + alt: String, + max: String, + min: String, + pattern: String, + placeholder: String, + step: String, + dirName: String, + defaultValue: {name: 'value'}, + multiple: Boolean, + required: Boolean, + readOnly: Boolean, + checked: Boolean, + value: String, + src: URL, + defaultChecked: {name: 'checked', type: Boolean}, + size: {type: 'unsigned long', default: 20, min: 1, setmin: 1}, + maxLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1}, + autocomplete: String, // It's complicated + type: { type: + ["text", "hidden", "search", "tel", "url", "email", "password", + "datetime", "date", "month", "week", "time", "datetime-local", + "number", "range", "color", "checkbox", "radio", "file", "submit", + "image", "reset", "button"], + missing: 'text' }, + formTarget: String, + formNoValidate: Boolean, + formMethod: { type: ["get", "post"], invalid: 'get', missing: '' }, + formEnctype: { type: ["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"], invalid: "application/x-www-form-urlencoded", missing: '' }, + inputMode: { type: [ "verbatim", "latin", "latin-name", "latin-prose", "full-width-latin", "kana", "kana-name", "katakana", "numeric", "tel", "email", "url" ], missing: '' }, + // Obsolete + align: String, + useMap: String, + } +}); +define({ + tag: 'keygen', + ctor: function HTMLKeygenElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + name: String, + disabled: Boolean, + autofocus: Boolean, + challenge: String, + keytype: { type:["rsa"], missing: '' }, + } +}); -/***/ }), -/* 35 */ -/***/ (function(module, exports, __webpack_require__) { +define({ + tag: 'li', + ctor: function HTMLLIElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + value: {type: "long", default: 0}, + // Obsolete + type: String, + } +}); -"use strict"; +define({ + tag: 'label', + ctor: function HTMLLabelElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + htmlFor: {name: 'for', type: String} + } +}); +define({ + tag: 'legend', + ctor: function HTMLLegendElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + align: String + }, +}); -var Parser = __webpack_require__(50), - Serializer = __webpack_require__(53); +define({ + tag: 'link', + ctor: function HTMLLinkElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // XXX Reflect DOMSettableTokenList sizes also DOMTokenList relList + href: URL, + rel: String, + media: String, + hreflang: String, + type: String, + crossOrigin: CORS, + nonce: String, + integrity: String, + referrerPolicy: REFERRER, + // Obsolete + charset: String, + rev: String, + target: String, + } +}); +define({ + tag: 'map', + ctor: function HTMLMapElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + name: String + } +}); -// Shorthands -exports.parse = function parse(html, options) { - var parser = new Parser(options); +define({ + tag: 'menu', + ctor: function HTMLMenuElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // XXX: not quite right, default should be popup if parent element is + // popup. + type: { type: [ 'context', 'popup', 'toolbar' ], missing: 'toolbar' }, + label: String, + // Obsolete + compact: Boolean, + } +}); - return parser.parse(html); -}; +define({ + tag: 'meta', + ctor: function HTMLMetaElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + name: String, + content: String, + httpEquiv: {name: 'http-equiv', type: String}, + // Obsolete + scheme: String, + } +}); -exports.parseFragment = function parseFragment(fragmentContext, html, options) { - if (typeof fragmentContext === 'string') { - options = html; - html = fragmentContext; - fragmentContext = null; - } +define({ + tag: 'meter', + ctor: function HTMLMeterElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps +}); - var parser = new Parser(options); +define({ + tags: ['ins', 'del'], + ctor: function HTMLModElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + cite: URL, + dateTime: String + } +}); - return parser.parseFragment(html, fragmentContext); -}; +define({ + tag: 'ol', + ctor: function HTMLOListElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + // Utility function (see the start attribute default value). Returns + // the number of
  • children of this element + _numitems: { get: function() { + var items = 0; + this.childNodes.forEach(function(n) { + if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "LI") + items++; + }); + return items; + }} + }, + attributes: { + type: String, + reversed: Boolean, + start: { + type: "long", + default: function() { + // The default value of the start attribute is 1 unless the list is + // reversed. Then it is the # of li children + if (this.reversed) + return this._numitems; + else + return 1; + } + }, + // Obsolete + compact: Boolean, + } +}); -exports.serialize = function (node, options) { - var serializer = new Serializer(node, options); +define({ + tag: 'object', + ctor: function HTMLObjectElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + data: URL, + type: String, + name: String, + useMap: String, + typeMustMatch: Boolean, + width: String, + height: String, + // Obsolete + align: String, + archive: String, + code: String, + declare: Boolean, + hspace: { type: "unsigned long", default: 0 }, + standby: String, + vspace: { type: "unsigned long", default: 0 }, + codeBase: URL, + codeType: String, + border: { type: String, treatNullAsEmptyString: true }, + } +}); - return serializer.serialize(); -}; +define({ + tag: 'optgroup', + ctor: function HTMLOptGroupElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + disabled: Boolean, + label: String + } +}); +define({ + tag: 'option', + ctor: function HTMLOptionElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + form: { get: function() { + var p = this.parentNode; + while (p && p.nodeType === Node.ELEMENT_NODE) { + if (p.localName === 'select') return p.form; + p = p.parentNode; + } + }} + }, + attributes: { + disabled: Boolean, + defaultSelected: {name: 'selected', type: Boolean}, + label: String, + value: String, + } +}); -// Tree adapters -exports.treeAdapters = { - default: __webpack_require__(36), - htmlparser2: __webpack_require__(120) -}; +define({ + tag: 'output', + ctor: function HTMLOutputElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + // XXX Reflect for/htmlFor as a settable token list + name: String + } +}); +define({ + tag: 'p', + ctor: function HTMLParagraphElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + align: String + } +}); -// Streaming -exports.ParserStream = __webpack_require__(52); -exports.PlainTextConversionStream = __webpack_require__(113); -exports.SerializerStream = __webpack_require__(117); -exports.SAXParser = __webpack_require__(115); +define({ + tag: 'param', + ctor: function HTMLParamElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + name: String, + value: String, + // Obsolete + type: String, + valueType: String, + } +}); +define({ + tags: ['pre',/*legacy elements:*/'listing','xmp'], + ctor: function HTMLPreElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + width: { type: "long", default: 0 }, + } +}); -/***/ }), -/* 36 */ -/***/ (function(module, exports, __webpack_require__) { +define({ + tag: 'progress', + ctor: function HTMLProgressElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + max: {type: Number, float: true, default: 1.0, min: 0} + } +}); -"use strict"; +define({ + tags: ['q', 'blockquote'], + ctor: function HTMLQuoteElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + cite: URL + } +}); +define({ + tag: 'script', + ctor: function HTMLScriptElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + text: { + get: function() { + var s = ""; + for(var i = 0, n = this.childNodes.length; i < n; i++) { + var child = this.childNodes[i]; + if (child.nodeType === Node.TEXT_NODE) + s += child._data; + } + return s; + }, + set: function(value) { + this.removeChildren(); + if (value !== null && value !== "") { + this.appendChild(this.ownerDocument.createTextNode(value)); + } + } + } + }, + attributes: { + src: URL, + type: String, + charset: String, + defer: Boolean, + async: Boolean, + crossOrigin: CORS, + nonce: String, + integrity: String, + } +}); -var DOCUMENT_MODE = __webpack_require__(11).DOCUMENT_MODE; +define({ + tag: 'select', + ctor: function HTMLSelectElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: { + form: formAssociatedProps.form, + options: { get: function() { + return this.getElementsByTagName('option'); + }} + }, + attributes: { + name: String, + disabled: Boolean, + autofocus: Boolean, + multiple: Boolean, + required: Boolean, + size: {type: "unsigned long", default: 0} + } +}); -//Node construction -exports.createDocument = function () { - return { - nodeName: '#document', - mode: DOCUMENT_MODE.NO_QUIRKS, - childNodes: [] - }; -}; +define({ + tag: 'source', + ctor: function HTMLSourceElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + src: URL, + type: String, + media: String + } +}); -exports.createDocumentFragment = function () { - return { - nodeName: '#document-fragment', - childNodes: [] - }; -}; +define({ + tag: 'span', + ctor: function HTMLSpanElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + } +}); -exports.createElement = function (tagName, namespaceURI, attrs) { - return { - nodeName: tagName, - tagName: tagName, - attrs: attrs, - namespaceURI: namespaceURI, - childNodes: [], - parentNode: null - }; -}; +define({ + tag: 'style', + ctor: function HTMLStyleElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + media: String, + type: String, + scoped: Boolean + } +}); -exports.createCommentNode = function (data) { - return { - nodeName: '#comment', - data: data, - parentNode: null - }; -}; +define({ + tag: 'caption', + ctor: function HTMLTableCaptionElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + // Obsolete + align: String, + } +}); -var createTextNode = function (value) { - return { - nodeName: '#text', - value: value, - parentNode: null - }; -}; +define({ + ctor: function HTMLTableCellElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + colSpan: {type: "unsigned long", default: 1}, + rowSpan: {type: "unsigned long", default: 1}, + //XXX Also reflect settable token list headers + scope: { type: ['row','col','rowgroup','colgroup'], missing: '' }, + abbr: String, + // Obsolete + align: String, + axis: String, + height: String, + width: String, + ch: { name: 'char', type: String }, + chOff: { name: 'charoff', type: String }, + noWrap: Boolean, + vAlign: String, + bgColor: { type: String, treatNullAsEmptyString: true }, + } +}); -//Tree mutation -var appendChild = exports.appendChild = function (parentNode, newNode) { - parentNode.childNodes.push(newNode); - newNode.parentNode = parentNode; -}; +define({ + tags: ['col', 'colgroup'], + ctor: function HTMLTableColElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + span: {type: 'limited unsigned long with fallback', default: 1, min: 1}, + // Obsolete + align: String, + ch: { name: 'char', type: String }, + chOff: { name: 'charoff', type: String }, + vAlign: String, + width: String, + } +}); -var insertBefore = exports.insertBefore = function (parentNode, newNode, referenceNode) { - var insertionIdx = parentNode.childNodes.indexOf(referenceNode); +define({ + tag: 'table', + ctor: function HTMLTableElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + rows: { get: function() { + return this.getElementsByTagName('tr'); + }} + }, + attributes: { + // Obsolete + align: String, + border: String, + frame: String, + rules: String, + summary: String, + width: String, + bgColor: { type: String, treatNullAsEmptyString: true }, + cellPadding: { type: String, treatNullAsEmptyString: true }, + cellSpacing: { type: String, treatNullAsEmptyString: true }, + } +}); - parentNode.childNodes.splice(insertionIdx, 0, newNode); - newNode.parentNode = parentNode; -}; +define({ + tag: 'template', + ctor: function HTMLTemplateElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + this._contentFragment = doc._templateDoc.createDocumentFragment(); + }, + props: { + content: { get: function() { return this._contentFragment; } }, + serialize: { value: function() { return this.content.serialize(); } } + } +}); -exports.setTemplateContent = function (templateElement, contentElement) { - templateElement.content = contentElement; -}; +define({ + tag: 'tr', + ctor: function HTMLTableRowElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + cells: { get: function() { + return this.querySelectorAll('td,th'); + }} + }, + attributes: { + // Obsolete + align: String, + ch: { name: 'char', type: String }, + chOff: { name: 'charoff', type: String }, + vAlign: String, + bgColor: { type: String, treatNullAsEmptyString: true }, + }, +}); -exports.getTemplateContent = function (templateElement) { - return templateElement.content; -}; +define({ + tags: ['thead', 'tfoot', 'tbody'], + ctor: function HTMLTableSectionElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + rows: { get: function() { + return this.getElementsByTagName('tr'); + }} + }, + attributes: { + // Obsolete + align: String, + ch: { name: 'char', type: String }, + chOff: { name: 'charoff', type: String }, + vAlign: String, + } +}); -exports.setDocumentType = function (document, name, publicId, systemId) { - var doctypeNode = null; +define({ + tag: 'textarea', + ctor: function HTMLTextAreaElement(doc, localName, prefix) { + HTMLFormElement.call(this, doc, localName, prefix); + }, + props: formAssociatedProps, + attributes: { + autocomplete: String, // It's complicated + name: String, + disabled: Boolean, + autofocus: Boolean, + placeholder: String, + wrap: String, + dirName: String, + required: Boolean, + readOnly: Boolean, + rows: {type: 'limited unsigned long with fallback', default: 2 }, + cols: {type: 'limited unsigned long with fallback', default: 20 }, + maxLength: {type: 'unsigned long', min: 0, setmin: 0, default: -1}, + inputMode: { type: [ "verbatim", "latin", "latin-name", "latin-prose", "full-width-latin", "kana", "kana-name", "katakana", "numeric", "tel", "email", "url" ], missing: '' }, + } +}); - for (var i = 0; i < document.childNodes.length; i++) { - if (document.childNodes[i].nodeName === '#documentType') { - doctypeNode = document.childNodes[i]; - break; - } - } +define({ + tag: 'time', + ctor: function HTMLTimeElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + dateTime: String, + pubDate: Boolean + } +}); - if (doctypeNode) { - doctypeNode.name = name; - doctypeNode.publicId = publicId; - doctypeNode.systemId = systemId; - } +define({ + tag: 'title', + ctor: function HTMLTitleElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + text: { get: function() { + return this.textContent; + }} + } +}); - else { - appendChild(document, { - nodeName: '#documentType', - name: name, - publicId: publicId, - systemId: systemId - }); - } -}; +define({ + tag: 'ul', + ctor: function HTMLUListElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + type: String, + // Obsolete + compact: Boolean, + } +}); -exports.setDocumentMode = function (document, mode) { - document.mode = mode; -}; +define({ + ctor: function HTMLMediaElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + src: URL, + crossOrigin: CORS, + preload: { type:["metadata", "none", "auto", {value: "", alias: "auto"}], missing: 'auto' }, + loop: Boolean, + autoplay: Boolean, + mediaGroup: String, + controls: Boolean, + defaultMuted: {name: "muted", type: Boolean} + } +}); -exports.getDocumentMode = function (document) { - return document.mode; -}; +define({ + tag: 'audio', + superclass: htmlElements.HTMLMediaElement, + ctor: function HTMLAudioElement(doc, localName, prefix) { + htmlElements.HTMLMediaElement.call(this, doc, localName, prefix); + } +}); -exports.detachNode = function (node) { - if (node.parentNode) { - var idx = node.parentNode.childNodes.indexOf(node); +define({ + tag: 'video', + superclass: htmlElements.HTMLMediaElement, + ctor: function HTMLVideoElement(doc, localName, prefix) { + htmlElements.HTMLMediaElement.call(this, doc, localName, prefix); + }, + attributes: { + poster: URL, + width: {type: "unsigned long", min: 0, default: 0 }, + height: {type: "unsigned long", min: 0, default: 0 } + } +}); - node.parentNode.childNodes.splice(idx, 1); - node.parentNode = null; - } -}; +define({ + tag: 'td', + superclass: htmlElements.HTMLTableCellElement, + ctor: function HTMLTableDataCellElement(doc, localName, prefix) { + htmlElements.HTMLTableCellElement.call(this, doc, localName, prefix); + } +}); -exports.insertText = function (parentNode, text) { - if (parentNode.childNodes.length) { - var prevNode = parentNode.childNodes[parentNode.childNodes.length - 1]; +define({ + tag: 'th', + superclass: htmlElements.HTMLTableCellElement, + ctor: function HTMLTableHeaderCellElement(doc, localName, prefix) { + htmlElements.HTMLTableCellElement.call(this, doc, localName, prefix); + }, +}); - if (prevNode.nodeName === '#text') { - prevNode.value += text; - return; - } - } +define({ + tag: 'frameset', + ctor: function HTMLFrameSetElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + } +}); - appendChild(parentNode, createTextNode(text)); -}; +define({ + tag: 'frame', + ctor: function HTMLFrameElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + } +}); -exports.insertTextBefore = function (parentNode, text, referenceNode) { - var prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1]; +define({ + tag: 'canvas', + ctor: function HTMLCanvasElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + getContext: { value: utils.nyi }, + probablySupportsContext: { value: utils.nyi }, + setContext: { value: utils.nyi }, + transferControlToProxy: { value: utils.nyi }, + toDataURL: { value: utils.nyi }, + toBlob: { value: utils.nyi } + }, + attributes: { + width: { type: "unsigned long", default: 300}, + height: { type: "unsigned long", default: 150} + } +}); - if (prevNode && prevNode.nodeName === '#text') - prevNode.value += text; - else - insertBefore(parentNode, createTextNode(text), referenceNode); -}; +define({ + tag: 'dialog', + ctor: function HTMLDialogElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + show: { value: utils.nyi }, + showModal: { value: utils.nyi }, + close: { value: utils.nyi } + }, + attributes: { + open: Boolean, + returnValue: String + } +}); -exports.adoptAttributes = function (recipient, attrs) { - var recipientAttrsMap = []; +define({ + tag: 'menuitem', + ctor: function HTMLMenuItemElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + props: { + // The menuitem's label + _label: { + get: function() { + var val = this._getattr('label'); + if (val !== null && val !== '') { return val; } + val = this.textContent; + // Strip and collapse whitespace + return val.replace(/[ \t\n\f\r]+/g, ' ').trim(); + } + }, + // The menuitem label IDL attribute + label: { + get: function() { + var val = this._getattr('label'); + if (val !== null) { return val; } + return this._label; + }, + set: function(v) { + this._setattr('label', v); + }, + } + }, + attributes: { + type: { type: ["command","checkbox","radio"], missing: 'command' }, + icon: URL, + disabled: Boolean, + checked: Boolean, + radiogroup: String, + default: Boolean + } +}); - for (var i = 0; i < recipient.attrs.length; i++) - recipientAttrsMap.push(recipient.attrs[i].name); +define({ + tag: 'source', + ctor: function HTMLSourceElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + srcset: String, + sizes: String, + media: String, + src: URL, + type: String + } +}); - for (var j = 0; j < attrs.length; j++) { - if (recipientAttrsMap.indexOf(attrs[j].name) === -1) - recipient.attrs.push(attrs[j]); - } -}; +define({ + tag: 'track', + ctor: function HTMLTrackElement(doc, localName, prefix) { + HTMLElement.call(this, doc, localName, prefix); + }, + attributes: { + src: URL, + srclang: String, + label: String, + default: Boolean, + kind: { type: ["subtitles", "captions", "descriptions", "chapters", "metadata"], missing: 'subtitles', invalid: 'metadata' }, + }, + props: { + NONE: { get: function() { return 0; } }, + LOADING: { get: function() { return 1; } }, + LOADED: { get: function() { return 2; } }, + ERROR: { get: function() { return 3; } }, + readyState: { get: utils.nyi }, + track: { get: utils.nyi } + } +}); +define({ + tags: [ + "abbr", "address", "article", "aside", "b", "bdi", "bdo", + "cite", "code", "dd", "dfn", "dt", "em", "figcaption", "figure", + "footer", "header", "hgroup", "i", "kbd", "main", "mark", "nav", "noscript", + "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "section", "small", "strong", + "sub", "summary", "sup", "u", "var", "wbr", + // Legacy elements + "acronym", "basefont", "big", "center", "nobr", "noembed", "noframes", + "plaintext", "strike", "tt" + ] +}); -//Tree traversing -exports.getFirstChild = function (node) { - return node.childNodes[0]; -}; -exports.getChildNodes = function (node) { - return node.childNodes; -}; +/***/ }), +/* 23 */ +/***/ (function(module, exports, __webpack_require__) { -exports.getParentNode = function (node) { - return node.parentNode; -}; +"use strict"; -exports.getAttrList = function (element) { - return element.attrs; -}; +/* jshint eqnull: true */ +/** + * Zest (https://github.com/chjj/zest) + * A css selector engine. + * Copyright (c) 2011-2012, Christopher Jeffrey. (MIT Licensed) + */ -//Node data -exports.getTagName = function (element) { - return element.tagName; -}; +/** + * Helpers + */ -exports.getNamespaceURI = function (element) { - return element.namespaceURI; -}; +var window = Object.create(null, { + location: { get: function() { + throw new Error('window.location is not supported.'); + } } +}); -exports.getTextNodeContent = function (textNode) { - return textNode.value; +var compareDocumentPosition = function(a, b) { + return a.compareDocumentPosition(b); }; -exports.getCommentNodeContent = function (commentNode) { - return commentNode.data; +var order = function(a, b) { + /* jshint bitwise: false */ + return compareDocumentPosition(a, b) & 2 ? 1 : -1; }; -exports.getDocumentTypeNodeName = function (doctypeNode) { - return doctypeNode.name; +var next = function(el) { + while ((el = el.nextSibling) + && el.nodeType !== 1); + return el; }; -exports.getDocumentTypeNodePublicId = function (doctypeNode) { - return doctypeNode.publicId; +var prev = function(el) { + while ((el = el.previousSibling) + && el.nodeType !== 1); + return el; }; -exports.getDocumentTypeNodeSystemId = function (doctypeNode) { - return doctypeNode.systemId; +var child = function(el) { + /*jshint -W084 */ + if (el = el.firstChild) { + while (el.nodeType !== 1 + && (el = el.nextSibling)); + } + return el; }; -//Node types -exports.isTextNode = function (node) { - return node.nodeName === '#text'; +var lastChild = function(el) { + /*jshint -W084 */ + if (el = el.lastChild) { + while (el.nodeType !== 1 + && (el = el.previousSibling)); + } + return el; }; -exports.isCommentNode = function (node) { - return node.nodeName === '#comment'; +var unquote = function(str) { + if (!str) return str; + var ch = str[0]; + if (ch === '"' || ch === '\'') { + if (str[str.length-1] === ch) { + str = str.slice(1, -1); + } else { + // bad string. + str = str.slice(1); + } + return str.replace(rules.str_escape, function(s) { + var m = /^\\(?:([0-9A-Fa-f]+)|([\r\n\f]+))/.exec(s); + if (!m) { return s.slice(1); } + if (m[2]) { return ''; /* escaped newlines are ignored in strings. */ } + var cp = parseInt(m[1], 16); + return String.fromCodePoint ? String.fromCodePoint(cp) : + // Not all JavaScript implementations have String.fromCodePoint yet. + String.fromCharCode(cp); + }); + } else if (rules.ident.test(str)) { + return decodeid(str); + } else { + // NUMBER, PERCENTAGE, DIMENSION, etc + return str; + } }; -exports.isDocumentTypeNode = function (node) { - return node.nodeName === '#documentType'; +var decodeid = function(str) { + return str.replace(rules.escape, function(s) { + var m = /^\\([0-9A-Fa-f]+)/.exec(s); + if (!m) { return s[1]; } + var cp = parseInt(m[1], 16); + return String.fromCodePoint ? String.fromCodePoint(cp) : + // Not all JavaScript implementations have String.fromCodePoint yet. + String.fromCharCode(cp); + }); }; -exports.isElementNode = function (node) { - return !!node.tagName; -}; +var indexOf = (function() { + if (Array.prototype.indexOf) { + return Array.prototype.indexOf; + } + return function(obj, item) { + var i = this.length; + while (i--) { + if (this[i] === item) return i; + } + return -1; + }; +})(); +var makeInside = function(start, end) { + var regex = rules.inside.source + .replace(//g, end); -/***/ }), -/* 37 */ -/***/ (function(module, exports, __webpack_require__) { + return new RegExp(regex); +}; -"use strict"; +var replace = function(regex, name, val) { + regex = regex.source; + regex = regex.replace(name, val.source || val); + return new RegExp(regex); +}; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +var truncateUrl = function(url, num) { + return url + .replace(/^(?:\w+:\/\/|\/+)/, '') + .replace(/(?:\/+|\/*#.*?)$/, '') + .split('/', num) + .join('/'); }; -var ArrayObservable_1 = __webpack_require__(14); -var isArray_1 = __webpack_require__(15); -var OuterSubscriber_1 = __webpack_require__(4); -var subscribeToResult_1 = __webpack_require__(3); -var none = {}; -/* tslint:enable:max-line-length */ + /** - * Combines multiple Observables to create an Observable whose values are - * calculated from the latest values of each of its input Observables. - * - * Whenever any input Observable emits a value, it - * computes a formula using the latest values from all the inputs, then emits - * the output of that formula. - * - * - * - * `combineLatest` combines the values from this Observable with values from - * Observables passed as arguments. This is done by subscribing to each - * Observable, in order, and collecting an array of each of the most recent - * values any time any of the input Observables emits, then either taking that - * array and passing it as arguments to an optional `project` function and - * emitting the return value of that, or just emitting the array of recent - * values directly if there is no `project` function. - * - * @example Dynamically calculate the Body-Mass Index from an Observable of weight and one for height - * var weight = Rx.Observable.of(70, 72, 76, 79, 75); - * var height = Rx.Observable.of(1.76, 1.77, 1.78); - * var bmi = weight.combineLatest(height, (w, h) => w / (h * h)); - * bmi.subscribe(x => console.log('BMI is ' + x)); - * - * // With output to console: - * // BMI is 24.212293388429753 - * // BMI is 23.93948099205209 - * // BMI is 23.671253629592222 - * - * @see {@link combineAll} - * @see {@link merge} - * @see {@link withLatestFrom} - * - * @param {ObservableInput} other An input Observable to combine with the source - * Observable. More than one input Observables may be given as argument. - * @param {function} [project] An optional function to project the values from - * the combined latest values into a new value on the output Observable. - * @return {Observable} An Observable of projected values from the most recent - * values from each input Observable, or an array of the most recent values from - * each input Observable. - * @method combineLatest - * @owner Observable + * Handle `nth` Selectors */ -function combineLatest() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; + +var parseNth = function(param_, test) { + var param = param_.replace(/\s+/g, '') + , cap; + + if (param === 'even') { + param = '2n+0'; + } else if (param === 'odd') { + param = '2n+1'; + } else if (param.indexOf('n') === -1) { + param = '0n' + param; + } + + cap = /^([+-])?(\d+)?n([+-])?(\d+)?$/.exec(param); + + return { + group: cap[1] === '-' + ? -(cap[2] || 1) + : +(cap[2] || 1), + offset: cap[4] + ? (cap[3] === '-' ? -cap[4] : +cap[4]) + : 0 + }; +}; + +var nth = function(param_, test, last) { + var param = parseNth(param_) + , group = param.group + , offset = param.offset + , find = !last ? child : lastChild + , advance = !last ? next : prev; + + return function(el) { + if (el.parentNode.nodeType !== 1) return; + + var rel = find(el.parentNode) + , pos = 0; + + while (rel) { + if (test(rel, el)) pos++; + if (rel === el) { + pos -= offset; + return group && pos + ? (pos % group) === 0 && (pos < 0 === group < 0) + : !pos; + } + rel = advance(rel); } - var project = null; - if (typeof observables[observables.length - 1] === 'function') { - project = observables.pop(); + }; +}; + +/** + * Simple Selectors + */ + +var selectors = { + '*': (function() { + if (false/*function() { + var el = document.createElement('div'); + el.appendChild(document.createComment('')); + return !!el.getElementsByTagName('*')[0]; + }()*/) { + return function(el) { + if (el.nodeType === 1) return true; + }; } - // if the first and only other argument besides the resultSelector is an array - // assume it's been called with `combineLatest([obs1, obs2, obs3], project)` - if (observables.length === 1 && isArray_1.isArray(observables[0])) { - observables = observables[0].slice(); + return function() { + return true; + }; + })(), + 'type': function(type) { + type = type.toLowerCase(); + return function(el) { + return el.nodeName.toLowerCase() === type; + }; + }, + 'attr': function(key, op, val, i) { + op = operators[op]; + return function(el) { + var attr; + switch (key) { + case 'for': + attr = el.htmlFor; + break; + case 'class': + // className is '' when non-existent + // getAttribute('class') is null + attr = el.className; + if (attr === '' && el.getAttribute('class') == null) { + attr = null; + } + break; + case 'href': + attr = el.getAttribute('href', 2); + break; + case 'title': + // getAttribute('title') can be '' when non-existent sometimes? + attr = el.getAttribute('title') || null; + break; + // careful with attributes with special getter functions + case 'id': + case 'lang': + case 'dir': + case 'accessKey': + case 'hidden': + case 'tabIndex': + case 'style': + if (el.getAttribute) { + attr = el.getAttribute(key); + break; + } + /* falls through */ + default: + if (el.hasAttribute && !el.hasAttribute(key)) { + break; + } + attr = el[key] != null + ? el[key] + : el.getAttribute && el.getAttribute(key); + break; + } + if (attr == null) return; + attr = attr + ''; + if (i) { + attr = attr.toLowerCase(); + val = val.toLowerCase(); + } + return op(attr, val); + }; + }, + ':first-child': function(el) { + return !prev(el) && el.parentNode.nodeType === 1; + }, + ':last-child': function(el) { + return !next(el) && el.parentNode.nodeType === 1; + }, + ':only-child': function(el) { + return !prev(el) && !next(el) + && el.parentNode.nodeType === 1; + }, + ':nth-child': function(param, last) { + return nth(param, function() { + return true; + }, last); + }, + ':nth-last-child': function(param) { + return selectors[':nth-child'](param, true); + }, + ':root': function(el) { + return el.ownerDocument.documentElement === el; + }, + ':empty': function(el) { + return !el.firstChild; + }, + ':not': function(sel) { + var test = compileGroup(sel); + return function(el) { + return !test(el); + }; + }, + ':first-of-type': function(el) { + if (el.parentNode.nodeType !== 1) return; + var type = el.nodeName; + /*jshint -W084 */ + while (el = prev(el)) { + if (el.nodeName === type) return; } - observables.unshift(this); - return this.lift.call(new ArrayObservable_1.ArrayObservable(observables), new CombineLatestOperator(project)); -} -exports.combineLatest = combineLatest; -var CombineLatestOperator = (function () { - function CombineLatestOperator(project) { - this.project = project; + return true; + }, + ':last-of-type': function(el) { + if (el.parentNode.nodeType !== 1) return; + var type = el.nodeName; + /*jshint -W084 */ + while (el = next(el)) { + if (el.nodeName === type) return; } - CombineLatestOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new CombineLatestSubscriber(subscriber, this.project)); + return true; + }, + ':only-of-type': function(el) { + return selectors[':first-of-type'](el) + && selectors[':last-of-type'](el); + }, + ':nth-of-type': function(param, last) { + return nth(param, function(rel, el) { + return rel.nodeName === el.nodeName; + }, last); + }, + ':nth-last-of-type': function(param) { + return selectors[':nth-of-type'](param, true); + }, + ':checked': function(el) { + return !!(el.checked || el.selected); + }, + ':indeterminate': function(el) { + return !selectors[':checked'](el); + }, + ':enabled': function(el) { + return !el.disabled && el.type !== 'hidden'; + }, + ':disabled': function(el) { + return !!el.disabled; + }, + ':target': function(el) { + return el.id === window.location.hash.substring(1); + }, + ':focus': function(el) { + return el === el.ownerDocument.activeElement; + }, + ':matches': function(sel) { + return compileGroup(sel); + }, + ':nth-match': function(param, last) { + var args = param.split(/\s*,\s*/) + , arg = args.shift() + , test = compileGroup(args.join(',')); + + return nth(arg, test, last); + }, + ':nth-last-match': function(param) { + return selectors[':nth-match'](param, true); + }, + ':links-here': function(el) { + return el + '' === window.location + ''; + }, + ':lang': function(param) { + return function(el) { + while (el) { + if (el.lang) return el.lang.indexOf(param) === 0; + el = el.parentNode; + } }; - return CombineLatestOperator; -}()); -exports.CombineLatestOperator = CombineLatestOperator; -/** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ -var CombineLatestSubscriber = (function (_super) { - __extends(CombineLatestSubscriber, _super); - function CombineLatestSubscriber(destination, project) { - _super.call(this, destination); - this.project = project; - this.active = 0; - this.values = []; - this.observables = []; - } - CombineLatestSubscriber.prototype._next = function (observable) { - this.values.push(none); - this.observables.push(observable); + }, + ':dir': function(param) { + return function(el) { + while (el) { + if (el.dir) return el.dir === param; + el = el.parentNode; + } }; - CombineLatestSubscriber.prototype._complete = function () { - var observables = this.observables; - var len = observables.length; - if (len === 0) { - this.destination.complete(); - } - else { - this.active = len; - this.toRespond = len; - for (var i = 0; i < len; i++) { - var observable = observables[i]; - this.add(subscribeToResult_1.subscribeToResult(this, observable, observable, i)); - } - } + }, + ':scope': function(el, con) { + var context = con || el.ownerDocument; + if (context.nodeType === 9) { + return el === context.documentElement; + } + return el === context; + }, + ':any-link': function(el) { + return typeof el.href === 'string'; + }, + ':local-link': function(el) { + if (el.nodeName) { + return el.href && el.host === window.location.host; + } + var param = +el + 1; + return function(el) { + if (!el.href) return; + + var url = window.location + '' + , href = el + ''; + + return truncateUrl(url, param) === truncateUrl(href, param); + }; + }, + ':default': function(el) { + return !!el.defaultSelected; + }, + ':valid': function(el) { + return el.willValidate || (el.validity && el.validity.valid); + }, + ':invalid': function(el) { + return !selectors[':valid'](el); + }, + ':in-range': function(el) { + return el.value > el.min && el.value <= el.max; + }, + ':out-of-range': function(el) { + return !selectors[':in-range'](el); + }, + ':required': function(el) { + return !!el.required; + }, + ':optional': function(el) { + return !el.required; + }, + ':read-only': function(el) { + if (el.readOnly) return true; + + var attr = el.getAttribute('contenteditable') + , prop = el.contentEditable + , name = el.nodeName.toLowerCase(); + + name = name !== 'input' && name !== 'textarea'; + + return (name || el.disabled) && attr == null && prop !== 'true'; + }, + ':read-write': function(el) { + return !selectors[':read-only'](el); + }, + ':hover': function() { + throw new Error(':hover is not supported.'); + }, + ':active': function() { + throw new Error(':active is not supported.'); + }, + ':link': function() { + throw new Error(':link is not supported.'); + }, + ':visited': function() { + throw new Error(':visited is not supported.'); + }, + ':column': function() { + throw new Error(':column is not supported.'); + }, + ':nth-column': function() { + throw new Error(':nth-column is not supported.'); + }, + ':nth-last-column': function() { + throw new Error(':nth-last-column is not supported.'); + }, + ':current': function() { + throw new Error(':current is not supported.'); + }, + ':past': function() { + throw new Error(':past is not supported.'); + }, + ':future': function() { + throw new Error(':future is not supported.'); + }, + // Non-standard, for compatibility purposes. + ':contains': function(param) { + return function(el) { + var text = el.innerText || el.textContent || el.value || ''; + return text.indexOf(param) !== -1; + }; + }, + ':has': function(param) { + return function(el) { + return find(param, el).length > 0; + }; + } + // Potentially add more pseudo selectors for + // compatibility with sizzle and most other + // selector engines (?). +}; + +/** + * Attribute Operators + */ + +var operators = { + '-': function() { + return true; + }, + '=': function(attr, val) { + return attr === val; + }, + '*=': function(attr, val) { + return attr.indexOf(val) !== -1; + }, + '~=': function(attr, val) { + var i = attr.indexOf(val) + , f + , l; + + if (i === -1) return; + f = attr[i - 1]; + l = attr[i + val.length]; + + return (!f || f === ' ') && (!l || l === ' '); + }, + '|=': function(attr, val) { + var i = attr.indexOf(val) + , l; + + if (i !== 0) return; + l = attr[i + val.length]; + + return l === '-' || !l; + }, + '^=': function(attr, val) { + return attr.indexOf(val) === 0; + }, + '$=': function(attr, val) { + return attr.indexOf(val) + val.length === attr.length; + }, + // non-standard + '!=': function(attr, val) { + return attr !== val; + } +}; + +/** + * Combinator Logic + */ + +var combinators = { + ' ': function(test) { + return function(el) { + /*jshint -W084 */ + while (el = el.parentNode) { + if (test(el)) return el; + } }; - CombineLatestSubscriber.prototype.notifyComplete = function (unused) { - if ((this.active -= 1) === 0) { - this.destination.complete(); - } + }, + '>': function(test) { + return function(el) { + /*jshint -W084 */ + if (el = el.parentNode) { + return test(el) && el; + } }; - CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - var values = this.values; - var oldVal = values[outerIndex]; - var toRespond = !this.toRespond - ? 0 - : oldVal === none ? --this.toRespond : this.toRespond; - values[outerIndex] = innerValue; - if (toRespond === 0) { - if (this.project) { - this._tryProject(values); - } - else { - this.destination.next(values.slice()); - } - } + }, + '+': function(test) { + return function(el) { + /*jshint -W084 */ + if (el = prev(el)) { + return test(el) && el; + } }; - CombineLatestSubscriber.prototype._tryProject = function (values) { - var result; - try { - result = this.project.apply(this, values); - } - catch (err) { - this.destination.error(err); - return; + }, + '~': function(test) { + return function(el) { + /*jshint -W084 */ + while (el = prev(el)) { + if (test(el)) return el; + } + }; + }, + 'noop': function(test) { + return function(el) { + return test(el) && el; + }; + }, + 'ref': function(test, name) { + var node; + + function ref(el) { + var doc = el.ownerDocument + , nodes = doc.getElementsByTagName('*') + , i = nodes.length; + + while (i--) { + node = nodes[i]; + if (ref.test(el)) { + node = null; + return true; } - this.destination.next(result); + } + + node = null; + } + + ref.combinator = function(el) { + if (!node || !node.getAttribute) return; + + var attr = node.getAttribute(name) || ''; + if (attr[0] === '#') attr = attr.substring(1); + + if (attr === el.id && test(node)) { + return node; + } }; - return CombineLatestSubscriber; -}(OuterSubscriber_1.OuterSubscriber)); -exports.CombineLatestSubscriber = CombineLatestSubscriber; -//# sourceMappingURL=combineLatest.js.map -/***/ }), -/* 38 */ -/***/ (function(module, exports, __webpack_require__) { + return ref; + } +}; + +/** + * Grammar + */ + +var rules = { + escape: /\\(?:[^0-9A-Fa-f\r\n]|[0-9A-Fa-f]{1,6}[\r\n\t ]?)/g, + str_escape: /(escape)|\\(\n|\r\n?|\f)/g, + nonascii: /[\u00A0-\uFFFF]/, + cssid: /(?:(?!-?[0-9])(?:escape|nonascii|[-_a-zA-Z0-9])+)/, + qname: /^ *(cssid|\*)/, + simple: /^(?:([.#]cssid)|pseudo|attr)/, + ref: /^ *\/(cssid)\/ */, + combinator: /^(?: +([^ \w*.#\\]) +|( )+|([^ \w*.#\\]))(?! *$)/, + attr: /^\[(cssid)(?:([^\w]?=)(inside))?\]/, + pseudo: /^(:cssid)(?:\((inside)\))?/, + inside: /(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|<[^"'>]*>|\\["'>]|[^"'>])*/, + ident: /^(cssid)$/ +}; + +rules.cssid = replace(rules.cssid, 'nonascii', rules.nonascii); +rules.cssid = replace(rules.cssid, 'escape', rules.escape); +rules.qname = replace(rules.qname, 'cssid', rules.cssid); +rules.simple = replace(rules.simple, 'cssid', rules.cssid); +rules.ref = replace(rules.ref, 'cssid', rules.cssid); +rules.attr = replace(rules.attr, 'cssid', rules.cssid); +rules.pseudo = replace(rules.pseudo, 'cssid', rules.cssid); +rules.inside = replace(rules.inside, '[^"\'>]*', rules.inside); +rules.attr = replace(rules.attr, 'inside', makeInside('\\[', '\\]')); +rules.pseudo = replace(rules.pseudo, 'inside', makeInside('\\(', '\\)')); +rules.simple = replace(rules.simple, 'pseudo', rules.pseudo); +rules.simple = replace(rules.simple, 'attr', rules.attr); +rules.ident = replace(rules.ident, 'cssid', rules.cssid); +rules.str_escape = replace(rules.str_escape, 'escape', rules.escape); + +/** + * Compiling + */ + +var compile = function(sel_) { + var sel = sel_.replace(/^\s+|\s+$/g, '') + , test + , filter = [] + , buff = [] + , subject + , qname + , cap + , op + , ref; + + /*jshint -W084 */ + while (sel) { + if (cap = rules.qname.exec(sel)) { + sel = sel.substring(cap[0].length); + qname = cap[1]; + buff.push(tok(qname, true)); + } else if (cap = rules.simple.exec(sel)) { + sel = sel.substring(cap[0].length); + qname = '*'; + buff.push(tok(qname, true)); + buff.push(tok(cap)); + } else { + throw new SyntaxError('Invalid selector.'); + } + + while (cap = rules.simple.exec(sel)) { + sel = sel.substring(cap[0].length); + buff.push(tok(cap)); + } + + if (sel[0] === '!') { + sel = sel.substring(1); + subject = makeSubject(); + subject.qname = qname; + buff.push(subject.simple); + } + + if (cap = rules.ref.exec(sel)) { + sel = sel.substring(cap[0].length); + ref = combinators.ref(makeSimple(buff), decodeid(cap[1])); + filter.push(ref.combinator); + buff = []; + continue; + } + + if (cap = rules.combinator.exec(sel)) { + sel = sel.substring(cap[0].length); + op = cap[1] || cap[2] || cap[3]; + if (op === ',') { + filter.push(combinators.noop(makeSimple(buff))); + break; + } + } else { + op = 'noop'; + } + + if (!combinators[op]) { throw new SyntaxError('Bad combinator.'); } + filter.push(combinators[op](makeSimple(buff))); + buff = []; + } + + test = makeTest(filter); + test.qname = qname; + test.sel = sel; + + if (subject) { + subject.lname = test.qname; + + subject.test = test; + subject.qname = subject.qname; + subject.sel = test.sel; + test = subject; + } + + if (ref) { + ref.test = test; + ref.qname = test.qname; + ref.sel = test.sel; + test = ref; + } + + return test; +}; + +var tok = function(cap, qname) { + // qname + if (qname) { + return cap === '*' + ? selectors['*'] + : selectors.type(decodeid(cap)); + } + + // class/id + if (cap[1]) { + return cap[1][0] === '.' + // XXX unescape here? or in attr? + ? selectors.attr('class', '~=', decodeid(cap[1].substring(1))) + : selectors.attr('id', '=', decodeid(cap[1].substring(1))); + } + + // pseudo-name + // inside-pseudo + if (cap[2]) { + return cap[3] + ? selectors[decodeid(cap[2])](unquote(cap[3])) + : selectors[decodeid(cap[2])]; + } + + // attr name + // attr op + // attr value + if (cap[4]) { + return selectors.attr(decodeid(cap[4]), cap[5] || '-', unquote(cap[6]), false); + } + + throw new SyntaxError('Unknown Selector.'); +}; + +var makeSimple = function(func) { + var l = func.length + , i; + + // Potentially make sure + // `el` is truthy. + if (l < 2) return func[0]; + + return function(el) { + if (!el) return; + for (i = 0; i < l; i++) { + if (!func[i](el)) return; + } + return true; + }; +}; -"use strict"; +var makeTest = function(func) { + if (func.length < 2) { + return function(el) { + return !!func[0](el); + }; + } + return function(el) { + var i = func.length; + while (i--) { + if (!(el = func[i](el))) return; + } + return true; + }; +}; + +var makeSubject = function() { + var target; + + function subject(el) { + var node = el.ownerDocument + , scope = node.getElementsByTagName(subject.lname) + , i = scope.length; + + while (i--) { + if (subject.test(scope[i]) && target === el) { + target = null; + return true; + } + } + + target = null; + } + + subject.simple = function(el) { + target = el; + return true; + }; + + return subject; +}; + +var compileGroup = function(sel) { + var test = compile(sel) + , tests = [ test ]; + + while (test.sel) { + test = compile(test.sel); + tests.push(test); + } + + if (tests.length < 2) return test; + + return function(el) { + var l = tests.length + , i = 0; + + for (; i < l; i++) { + if (tests[i](el)) return true; + } + }; +}; -var Observable_1 = __webpack_require__(0); -var isScheduler_1 = __webpack_require__(13); -var ArrayObservable_1 = __webpack_require__(14); -var mergeAll_1 = __webpack_require__(77); -/* tslint:enable:max-line-length */ /** - * Creates an output Observable which sequentially emits all values from every - * given input Observable after the current Observable. - * - * Concatenates multiple Observables together by - * sequentially emitting their values, one Observable after the other. - * - * - * - * Joins this Observable with multiple other Observables by subscribing to them - * one at a time, starting with the source, and merging their results into the - * output Observable. Will wait for each Observable to complete before moving - * on to the next. - * - * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 - * var timer = Rx.Observable.interval(1000).take(4); - * var sequence = Rx.Observable.range(1, 10); - * var result = timer.concat(sequence); - * result.subscribe(x => console.log(x)); - * - * // results in: - * // 1000ms-> 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 - * - * @example Concatenate 3 Observables - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var result = timer1.concat(timer2, timer3); - * result.subscribe(x => console.log(x)); - * - * // results in the following: - * // (Prints to console sequentially) - * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 - * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 - * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 - * - * @see {@link concatAll} - * @see {@link concatMap} - * @see {@link concatMapTo} - * - * @param {ObservableInput} other An input Observable to concatenate after the source - * Observable. More than one input Observables may be given as argument. - * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each - * Observable subscription on. - * @return {Observable} All values of each passed Observable merged into a - * single Observable, in order, in serial fashion. - * @method concat - * @owner Observable + * Selection */ -function concat() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; + +var find = function(sel, node) { + var results = [] + , test = compile(sel) + , scope = node.getElementsByTagName(test.qname) + , i = 0 + , el; + + /*jshint -W084 */ + while (el = scope[i++]) { + if (test(el)) results.push(el); + } + + if (test.sel) { + while (test.sel) { + test = compile(test.sel); + scope = node.getElementsByTagName(test.qname); + i = 0; + /*jshint -W084 */ + while (el = scope[i++]) { + if (test(el) && indexOf.call(results, el) === -1) { + results.push(el); + } + } } - return this.lift.call(concatStatic.apply(void 0, [this].concat(observables))); -} -exports.concat = concat; -/* tslint:enable:max-line-length */ + results.sort(order); + } + + return results; +}; + /** - * Creates an output Observable which sequentially emits all values from given - * Observable and then moves on to the next. - * - * Concatenates multiple Observables together by - * sequentially emitting their values, one Observable after the other. - * - * - * - * `concat` joins multiple Observables together, by subscribing to them one at a time and - * merging their results into the output Observable. You can pass either an array of - * Observables, or put them directly as arguments. Passing an empty array will result - * in Observable that completes immediately. - * - * `concat` will subscribe to first input Observable and emit all its values, without - * changing or affecting them in any way. When that Observable completes, it will - * subscribe to then next Observable passed and, again, emit its values. This will be - * repeated, until the operator runs out of Observables. When last input Observable completes, - * `concat` will complete as well. At any given moment only one Observable passed to operator - * emits values. If you would like to emit values from passed Observables concurrently, check out - * {@link merge} instead, especially with optional `concurrent` parameter. As a matter of fact, - * `concat` is an equivalent of `merge` operator with `concurrent` parameter set to `1`. - * - * Note that if some input Observable never completes, `concat` will also never complete - * and Observables following the one that did not complete will never be subscribed. On the other - * hand, if some Observable simply completes immediately after it is subscribed, it will be - * invisible for `concat`, which will just move on to the next Observable. - * - * If any Observable in chain errors, instead of passing control to the next Observable, - * `concat` will error immediately as well. Observables that would be subscribed after - * the one that emitted error, never will. - * - * If you pass to `concat` the same Observable many times, its stream of values - * will be "replayed" on every subscription, which means you can repeat given Observable - * as many times as you like. If passing the same Observable to `concat` 1000 times becomes tedious, - * you can always use {@link repeat}. - * - * @example Concatenate a timer counting from 0 to 3 with a synchronous sequence from 1 to 10 - * var timer = Rx.Observable.interval(1000).take(4); - * var sequence = Rx.Observable.range(1, 10); - * var result = Rx.Observable.concat(timer, sequence); - * result.subscribe(x => console.log(x)); - * - * // results in: - * // 0 -1000ms-> 1 -1000ms-> 2 -1000ms-> 3 -immediate-> 1 ... 10 - * - * - * @example Concatenate an array of 3 Observables - * var timer1 = Rx.Observable.interval(1000).take(10); - * var timer2 = Rx.Observable.interval(2000).take(6); - * var timer3 = Rx.Observable.interval(500).take(10); - * var result = Rx.Observable.concat([timer1, timer2, timer3]); // note that array is passed - * result.subscribe(x => console.log(x)); - * - * // results in the following: - * // (Prints to console sequentially) - * // -1000ms-> 0 -1000ms-> 1 -1000ms-> ... 9 - * // -2000ms-> 0 -2000ms-> 1 -2000ms-> ... 5 - * // -500ms-> 0 -500ms-> 1 -500ms-> ... 9 - * - * - * @example Concatenate the same Observable to repeat it - * const timer = Rx.Observable.interval(1000).take(2); - * - * Rx.Observable.concat(timer, timer) // concating the same Observable! - * .subscribe( - * value => console.log(value), - * err => {}, - * () => console.log('...and it is done!') - * ); - * - * // Logs: - * // 0 after 1s - * // 1 after 2s - * // 0 after 3s - * // 1 after 4s - * // "...and it is done!" also after 4s - * - * @see {@link concatAll} - * @see {@link concatMap} - * @see {@link concatMapTo} - * - * @param {ObservableInput} input1 An input Observable to concatenate with others. - * @param {ObservableInput} input2 An input Observable to concatenate with others. - * More than one input Observables may be given as argument. - * @param {Scheduler} [scheduler=null] An optional IScheduler to schedule each - * Observable subscription on. - * @return {Observable} All values of each passed Observable merged into a - * single Observable, in order, in serial fashion. - * @static true - * @name concat - * @owner Observable + * Expose */ -function concatStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; + +module.exports = exports = function(sel, context) { + /* when context isn't a DocumentFragment and the selector is simple: */ + var id, r; + if (context.nodeType !== 11 && sel.indexOf(' ') === -1) { + if (sel[0] === '#' && context.rooted && /^#[A-Z_][-A-Z0-9_]*$/i.test(sel)) { + if (context.doc._hasMultipleElementsWithId) { + id = sel.substring(1); + if (!context.doc._hasMultipleElementsWithId(id)) { + r = context.doc.getElementById(id); + return r ? [r] : []; + } + } } - var scheduler = null; - var args = observables; - if (isScheduler_1.isScheduler(args[observables.length - 1])) { - scheduler = args.pop(); + if (sel[0] === '.' && /^\.\w+$/.test(sel)) { + return context.getElementsByClassName(sel.substring(1)); } - if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) { - return observables[0]; + if (/^\w+$/.test(sel)) { + return context.getElementsByTagName(sel); } - return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(1)); -} -exports.concatStatic = concatStatic; -//# sourceMappingURL=concat.js.map + } + /* do things the hard/slow way */ + return find(sel, context); +}; + +exports.selectors = selectors; +exports.operators = operators; +exports.combinators = combinators; + +exports.matches = function(el, sel) { + var test = { sel: sel }; + do { + test = compile(test.sel); + if (test(el)) { return true; } + } while (test.sel); + return false; +}; + /***/ }), -/* 39 */ +/* 24 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -var ArrayObservable_1 = __webpack_require__(14); -var isArray_1 = __webpack_require__(15); -var Subscriber_1 = __webpack_require__(2); -var OuterSubscriber_1 = __webpack_require__(4); -var subscribeToResult_1 = __webpack_require__(3); -var iterator_1 = __webpack_require__(78); -/* tslint:enable:max-line-length */ +// This grammar is from the XML and XML Namespace specs. It specifies whether +// a string (such as an element or attribute name) is a valid Name or QName. +// +// Name ::= NameStartChar (NameChar)* +// NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | +// [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | +// [#x370-#x37D] | [#x37F-#x1FFF] | +// [#x200C-#x200D] | [#x2070-#x218F] | +// [#x2C00-#x2FEF] | [#x3001-#xD7FF] | +// [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | +// [#x10000-#xEFFFF] +// +// NameChar ::= NameStartChar | "-" | "." | [0-9] | +// #xB7 | [#x0300-#x036F] | [#x203F-#x2040] +// +// QName ::= PrefixedName| UnprefixedName +// PrefixedName ::= Prefix ':' LocalPart +// UnprefixedName ::= LocalPart +// Prefix ::= NCName +// LocalPart ::= NCName +// NCName ::= Name - (Char* ':' Char*) +// # An XML Name, minus the ":" +// + +exports.isValidName = isValidName; +exports.isValidQName = isValidQName; + +// Most names will be ASCII only. Try matching against simple regexps first +var simplename = /^[_:A-Za-z][-.:\w]+$/; +var simpleqname = /^([_A-Za-z][-.\w]+|[_A-Za-z][-.\w]+:[_A-Za-z][-.\w]+)$/; + +// If the regular expressions above fail, try more complex ones that work +// for any identifiers using codepoints from the Unicode BMP +var ncnamestartchars = "_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02ff\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD"; +var ncnamechars = "-._A-Za-z0-9\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02ff\u0300-\u037D\u037F-\u1FFF\u200C\u200D\u203f\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD"; + +var ncname = "[" + ncnamestartchars + "][" + ncnamechars + "]*"; +var namestartchars = ncnamestartchars + ":"; +var namechars = ncnamechars + ":"; +var name = new RegExp("^[" + namestartchars + "]" + "[" + namechars + "]*$"); +var qname = new RegExp("^(" + ncname + "|" + ncname + ":" + ncname + ")$"); + +// XML says that these characters are also legal: +// [#x10000-#xEFFFF]. So if the patterns above fail, and the +// target string includes surrogates, then try the following +// patterns that allow surrogates and then run an extra validation +// step to make sure that the surrogates are in valid pairs and in +// the right range. Note that since the characters \uf0000 to \u1f0000 +// are not allowed, it means that the high surrogate can only go up to +// \uDB7f instead of \uDBFF. +var hassurrogates = /[\uD800-\uDB7F\uDC00-\uDFFF]/; +var surrogatechars = /[\uD800-\uDB7F\uDC00-\uDFFF]/g; +var surrogatepairs = /[\uD800-\uDB7F][\uDC00-\uDFFF]/g; + +// Modify the variables above to allow surrogates +ncnamestartchars += "\uD800-\uDB7F\uDC00-\uDFFF"; +ncnamechars += "\uD800-\uDB7F\uDC00-\uDFFF"; +ncname = "[" + ncnamestartchars + "][" + ncnamechars + "]*"; +namestartchars = ncnamestartchars + ":"; +namechars = ncnamechars + ":"; + +// Build another set of regexps that include surrogates +var surrogatename = new RegExp("^[" + namestartchars + "]" + "[" + namechars + "]*$"); +var surrogateqname = new RegExp("^(" + ncname + "|" + ncname + ":" + ncname + ")$"); + +function isValidName(s) { + if (simplename.test(s)) return true; // Plain ASCII + if (name.test(s)) return true; // Unicode BMP + + // Maybe the tests above failed because s includes surrogate pairs + // Most likely, though, they failed for some more basic syntax problem + if (!hassurrogates.test(s)) return false; + + // Is the string a valid name if we allow surrogates? + if (!surrogatename.test(s)) return false; + + // Finally, are the surrogates all correctly paired up? + var chars = s.match(surrogatechars), pairs = s.match(surrogatepairs); + return pairs !== null && 2*pairs.length === chars.length; +} + +function isValidQName(s) { + if (simpleqname.test(s)) return true; // Plain ASCII + if (qname.test(s)) return true; // Unicode BMP + + if (!hassurrogates.test(s)) return false; + if (!surrogateqname.test(s)) return false; + var chars = s.match(surrogatechars), pairs = s.match(surrogatepairs); + return pairs !== null && 2*pairs.length === chars.length; +} + + +/***/ }), +/* 25 */ +/***/ (function(module, exports, __webpack_require__) { + /** - * @param observables - * @return {Observable} - * @method zip - * @owner Observable + * @license Angular v5.0.1 + * (c) 2010-2017 Google, Inc. https://angular.io/ + * License: MIT */ -function zipProto() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - return this.lift.call(zipStatic.apply(void 0, [this].concat(observables))); +(function (global, factory) { + true ? factory(exports, __webpack_require__(4), __webpack_require__(53), __webpack_require__(26), __webpack_require__(5), __webpack_require__(13), __webpack_require__(130), __webpack_require__(131), __webpack_require__(63), __webpack_require__(2), __webpack_require__(132), __webpack_require__(57), __webpack_require__(125), __webpack_require__(126), __webpack_require__(55), __webpack_require__(110)) : + typeof define === 'function' && define.amd ? define('@angular/platform-server', ['exports', '@angular/core', '@angular/platform-browser', '@angular/animations/browser', '@angular/common', '@angular/common/http', '@angular/http', '@angular/platform-browser-dynamic', '@angular/platform-browser/animations', 'rxjs/Observable', 'rxjs/Subject', 'url', '@angular/compiler', 'rxjs/operator/filter', 'rxjs/operator/first', 'rxjs/operator/toPromise'], factory) : + (factory((global.ng = global.ng || {}, global.ng.platformServer = {}),global.ng.core,global.ng.platformBrowser,global.ng.animations.browser,global.ng.common,global.ng.common.http,global.ng.http,global.ng.platformBrowserDynamic,global.ng.platformBrowser.animations,global.Rx,global.Rx,global.url,global.ng.compiler,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype)); +}(this, (function (exports,_angular_core,_angular_platformBrowser,_angular_animations_browser,_angular_common,_angular_common_http,_angular_http,_angular_platformBrowserDynamic,_angular_platformBrowser_animations,rxjs_Observable,rxjs_Subject,url,_angular_compiler,rxjs_operator_filter,rxjs_operator_first,rxjs_operator_toPromise) { 'use strict'; + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ +/* global Reflect, Promise */ + +var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + +function __extends(d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } -exports.zipProto = zipProto; -/* tslint:enable:max-line-length */ + /** - * Combines multiple Observables to create an Observable whose values are calculated from the values, in order, of each - * of its input Observables. - * - * If the latest parameter is a function, this function is used to compute the created value from the input values. - * Otherwise, an array of the input values is returned. - * - * @example Combine age and name from different sources - * - * let age$ = Observable.of(27, 25, 29); - * let name$ = Observable.of('Foo', 'Bar', 'Beer'); - * let isDev$ = Observable.of(true, true, false); - * - * Observable - * .zip(age$, - * name$, - * isDev$, - * (age: number, name: string, isDev: boolean) => ({ age, name, isDev })) - * .subscribe(x => console.log(x)); - * - * // outputs - * // { age: 27, name: 'Foo', isDev: true } - * // { age: 25, name: 'Bar', isDev: true } - * // { age: 29, name: 'Beer', isDev: false } + * @license Angular v5.0.1 + * (c) 2010-2017 Google, Inc. https://angular.io/ + * License: MIT + */ +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @license + * Copyright Google Inc. All Rights Reserved. * - * @param observables - * @return {Observable} - * @static true - * @name zip - * @owner Observable + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license */ -function zipStatic() { - var observables = []; - for (var _i = 0; _i < arguments.length; _i++) { - observables[_i - 0] = arguments[_i]; - } - var project = observables[observables.length - 1]; - if (typeof project === 'function') { - observables.pop(); - } - return new ArrayObservable_1.ArrayObservable(observables).lift(new ZipOperator(project)); -} -exports.zipStatic = zipStatic; -var ZipOperator = (function () { - function ZipOperator(project) { - this.project = project; - } - ZipOperator.prototype.call = function (subscriber, source) { - return source.subscribe(new ZipSubscriber(subscriber, this.project)); - }; - return ZipOperator; -}()); -exports.ZipOperator = ZipOperator; +var domino = __webpack_require__(82); /** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} + * @param {?} methodName + * @return {?} */ -var ZipSubscriber = (function (_super) { - __extends(ZipSubscriber, _super); - function ZipSubscriber(destination, project, values) { - if (values === void 0) { values = Object.create(null); } - _super.call(this, destination); - this.iterators = []; - this.active = 0; - this.project = (typeof project === 'function') ? project : null; - this.values = values; - } - ZipSubscriber.prototype._next = function (value) { - var iterators = this.iterators; - if (isArray_1.isArray(value)) { - iterators.push(new StaticArrayIterator(value)); - } - else if (typeof value[iterator_1.iterator] === 'function') { - iterators.push(new StaticIterator(value[iterator_1.iterator]())); - } - else { - iterators.push(new ZipBufferIterator(this.destination, this, value)); - } - }; - ZipSubscriber.prototype._complete = function () { - var iterators = this.iterators; - var len = iterators.length; - if (len === 0) { - this.destination.complete(); - return; - } - this.active = len; - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - if (iterator.stillUnsubscribed) { - this.add(iterator.subscribe(iterator, i)); - } - else { - this.active--; // not an observable - } - } - }; - ZipSubscriber.prototype.notifyInactive = function () { - this.active--; - if (this.active === 0) { - this.destination.complete(); - } - }; - ZipSubscriber.prototype.checkIterators = function () { - var iterators = this.iterators; - var len = iterators.length; - var destination = this.destination; - // abort if not all of them have values - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - if (typeof iterator.hasValue === 'function' && !iterator.hasValue()) { - return; - } - } - var shouldComplete = false; - var args = []; - for (var i = 0; i < len; i++) { - var iterator = iterators[i]; - var result = iterator.next(); - // check to see if it's completed now that you've gotten - // the next value. - if (iterator.hasCompleted()) { - shouldComplete = true; - } - if (result.done) { - destination.complete(); - return; - } - args.push(result.value); - } - if (this.project) { - this._tryProject(args); - } - else { - destination.next(args); - } - if (shouldComplete) { - destination.complete(); - } - }; - ZipSubscriber.prototype._tryProject = function (args) { - var result; - try { - result = this.project.apply(this, args); - } - catch (err) { - this.destination.error(err); - return; - } - this.destination.next(result); - }; - return ZipSubscriber; -}(Subscriber_1.Subscriber)); -exports.ZipSubscriber = ZipSubscriber; -var StaticIterator = (function () { - function StaticIterator(iterator) { - this.iterator = iterator; - this.nextResult = iterator.next(); - } - StaticIterator.prototype.hasValue = function () { - return true; - }; - StaticIterator.prototype.next = function () { - var result = this.nextResult; - this.nextResult = this.iterator.next(); - return result; - }; - StaticIterator.prototype.hasCompleted = function () { - var nextResult = this.nextResult; - return nextResult && nextResult.done; - }; - return StaticIterator; -}()); -var StaticArrayIterator = (function () { - function StaticArrayIterator(array) { - this.array = array; - this.index = 0; - this.length = 0; - this.length = array.length; - } - StaticArrayIterator.prototype[iterator_1.iterator] = function () { - return this; - }; - StaticArrayIterator.prototype.next = function (value) { - var i = this.index++; - var array = this.array; - return i < this.length ? { value: array[i], done: false } : { value: null, done: true }; - }; - StaticArrayIterator.prototype.hasValue = function () { - return this.array.length > this.index; - }; - StaticArrayIterator.prototype.hasCompleted = function () { - return this.array.length === this.index; - }; - return StaticArrayIterator; -}()); -/** - * We need this JSDoc comment for affecting ESDoc. - * @ignore - * @extends {Ignored} - */ -var ZipBufferIterator = (function (_super) { - __extends(ZipBufferIterator, _super); - function ZipBufferIterator(destination, parent, observable) { - _super.call(this, destination); - this.parent = parent; - this.observable = observable; - this.stillUnsubscribed = true; - this.buffer = []; - this.isComplete = false; - } - ZipBufferIterator.prototype[iterator_1.iterator] = function () { - return this; - }; - // NOTE: there is actually a name collision here with Subscriber.next and Iterator.next - // this is legit because `next()` will never be called by a subscription in this case. - ZipBufferIterator.prototype.next = function () { - var buffer = this.buffer; - if (buffer.length === 0 && this.isComplete) { - return { value: null, done: true }; - } - else { - return { value: buffer.shift(), done: false }; - } - }; - ZipBufferIterator.prototype.hasValue = function () { - return this.buffer.length > 0; - }; - ZipBufferIterator.prototype.hasCompleted = function () { - return this.buffer.length === 0 && this.isComplete; - }; - ZipBufferIterator.prototype.notifyComplete = function () { - if (this.buffer.length > 0) { - this.isComplete = true; - this.parent.notifyInactive(); - } - else { - this.destination.complete(); - } - }; - ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) { - this.buffer.push(innerValue); - this.parent.checkIterators(); - }; - ZipBufferIterator.prototype.subscribe = function (value, index) { - return subscribeToResult_1.subscribeToResult(this, this.observable, this, index); - }; - return ZipBufferIterator; -}(OuterSubscriber_1.OuterSubscriber)); -//# sourceMappingURL=zip.js.map - -/***/ }), -/* 40 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(26); - -/***/ }), -/* 41 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(65); - -/***/ }), -/* 42 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(82); - -/***/ }), -/* 43 */ -/***/ (function(module, exports, __webpack_require__) { - -module.exports = (__webpack_require__(1))(88); - -/***/ }), -/* 44 */ -/***/ (function(module, exports, __webpack_require__) { - -/** - * @license Angular v4.2.5 - * (c) 2010-2017 Google, Inc. https://angular.io/ - * License: MIT - */ -(function (global, factory) { - true ? factory(exports, __webpack_require__(10), __webpack_require__(84), __webpack_require__(46), __webpack_require__(17), __webpack_require__(380), __webpack_require__(29), __webpack_require__(93), __webpack_require__(0), __webpack_require__(6), __webpack_require__(88), __webpack_require__(42), __webpack_require__(86), __webpack_require__(68)) : - typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/platform-browser', '@angular/animations/browser', '@angular/common', '@angular/compiler', '@angular/http', '@angular/platform-browser/animations', 'rxjs/Observable', 'rxjs/Subject', 'url', 'rxjs/operator/filter', 'rxjs/operator/first', 'rxjs/operator/toPromise'], factory) : - (factory((global.ng = global.ng || {}, global.ng.platformServer = global.ng.platformServer || {}),global.ng.core,global.ng.platformBrowser,global._angular_animations_browser,global.ng.common,global.ng.compiler,global._angular_http,global._angular_platformBrowser_animations,global.Rx,global.Rx,global.url,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype)); -}(this, (function (exports,_angular_core,_angular_platformBrowser,_angular_animations_browser,_angular_common,_angular_compiler,_angular_http,_angular_platformBrowser_animations,rxjs_Observable,rxjs_Subject,url,rxjs_operator_filter,rxjs_operator_first,rxjs_operator_toPromise) { 'use strict'; - -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ -/* global Reflect, Promise */ - -var extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - -function __extends(d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +function _notImplemented(methodName) { + return new Error('This method is not implemented in DominoAdapter: ' + methodName); } - /** - * @license Angular v4.2.5 - * (c) 2010-2017 Google, Inc. https://angular.io/ - * License: MIT + * Parses a document string to a Document object. + * @param {?} html + * @param {?=} url + * @return {?} */ +function parseDocument(html, url$$1) { + if (url$$1 === void 0) { url$$1 = '/'; } + var /** @type {?} */ window = domino.createWindow(html, url$$1); + var /** @type {?} */ doc = window.document; + return doc; +} /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * Serializes a document to string. + * @param {?} doc + * @return {?} */ -var parse5 = __webpack_require__(35); +function serializeDocument(doc) { + return (/** @type {?} */ (doc)).serialize(); +} /** - * Representation of the current platform state. - * - * \@experimental + * DOM Adapter for the server platform based on https://github.com/fgnass/domino. */ -var PlatformState = (function () { +var DominoAdapter = (function (_super) { + __extends(DominoAdapter, _super); + function DominoAdapter() { + return _super !== null && _super.apply(this, arguments) || this; + } /** - * @param {?} _doc + * @return {?} */ - function PlatformState(_doc) { - this._doc = _doc; - } + DominoAdapter.makeCurrent = /** + * @return {?} + */ + function () { _angular_platformBrowser.ɵsetRootDomAdapter(new DominoAdapter()); }; /** - * Renders the current state of the platform to string. + * @param {?} error + * @return {?} + */ + DominoAdapter.prototype.logError = /** + * @param {?} error * @return {?} */ - PlatformState.prototype.renderToString = function () { return _angular_platformBrowser.ɵgetDOM().getInnerHTML(this._doc); }; + function (error) { console.error(error); }; /** - * Returns the current DOM state. + * @param {?} error * @return {?} */ - PlatformState.prototype.getDocument = function () { return this._doc; }; - return PlatformState; -}()); -PlatformState.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -PlatformState.ctorParameters = function () { return [ - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, -]; }; -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -var xhr2 = __webpack_require__(377); -var isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//; -/** - * @param {?} url - * @return {?} - */ -function validateRequestUrl(url$$1) { - if (!isAbsoluteUrl.test(url$$1)) { - throw new Error("URLs requested via Http on the server must be absolute. URL: " + url$$1); - } -} -var ServerXhr = (function () { - function ServerXhr() { - } + DominoAdapter.prototype.log = /** + * @param {?} error + * @return {?} + */ + function (error) { + // tslint:disable-next-line:no-console + console.log(error); + }; /** + * @param {?} error * @return {?} */ - ServerXhr.prototype.build = function () { return new xhr2.XMLHttpRequest(); }; - return ServerXhr; -}()); -ServerXhr.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -ServerXhr.ctorParameters = function () { return []; }; -var ServerXsrfStrategy = (function () { - function ServerXsrfStrategy() { - } + DominoAdapter.prototype.logGroup = /** + * @param {?} error + * @return {?} + */ + function (error) { console.error(error); }; /** - * @param {?} req * @return {?} */ - ServerXsrfStrategy.prototype.configureRequest = function (req) { }; - return ServerXsrfStrategy; -}()); -ServerXsrfStrategy.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -ServerXsrfStrategy.ctorParameters = function () { return []; }; -var ZoneMacroTaskConnection = (function () { + DominoAdapter.prototype.logGroupEnd = /** + * @return {?} + */ + function () { }; /** - * @param {?} request - * @param {?} backend + * @return {?} */ - function ZoneMacroTaskConnection(request, backend) { - var _this = this; - this.request = request; - validateRequestUrl(request.url); - this.response = new rxjs_Observable.Observable(function (observer) { - var task = null; - var scheduled = false; - var sub = null; - var savedResult = null; - var savedError = null; - var scheduleTask = function (_task) { - task = _task; - scheduled = true; - _this.lastConnection = backend.createConnection(request); - sub = _this.lastConnection.response - .subscribe(function (res) { return savedResult = res; }, function (err) { - if (!scheduled) { - throw new Error('invoke twice'); - } - savedError = err; - scheduled = false; - task.invoke(); - }, function () { - if (!scheduled) { - throw new Error('invoke twice'); - } - scheduled = false; - task.invoke(); - }); - }; - var cancelTask = function (_task) { - if (!scheduled) { - return; - } - scheduled = false; - if (sub) { - sub.unsubscribe(); - sub = null; - } - }; - var onComplete = function () { - if (savedError !== null) { - observer.error(savedError); - } - else { - observer.next(savedResult); - observer.complete(); - } - }; - // MockBackend is currently synchronous, which means that if scheduleTask is by - // scheduleMacroTask, the request will hit MockBackend and the response will be - // sent, causing task.invoke() to be called. - var _task = Zone.current.scheduleMacroTask('ZoneMacroTaskConnection.subscribe', onComplete, {}, function () { return null; }, cancelTask); - scheduleTask(_task); - return function () { - if (scheduled && task) { - task.zone.cancelTask(task); - scheduled = false; - } - if (sub) { - sub.unsubscribe(); - sub = null; - } - }; - }); - } - Object.defineProperty(ZoneMacroTaskConnection.prototype, "readyState", { - /** - * @return {?} - */ - get: function () { - return !!this.lastConnection ? this.lastConnection.readyState : _angular_http.ReadyState.Unsent; - }, - enumerable: true, - configurable: true - }); - return ZoneMacroTaskConnection; -}()); -var ZoneMacroTaskBackend = (function () { - /** - * @param {?} backend + DominoAdapter.prototype.supportsDOMEvents = /** + * @return {?} */ - function ZoneMacroTaskBackend(backend) { - this.backend = backend; - } + function () { return false; }; /** - * @param {?} request * @return {?} */ - ZoneMacroTaskBackend.prototype.createConnection = function (request) { - return new ZoneMacroTaskConnection(request, this.backend); - }; - return ZoneMacroTaskBackend; -}()); -/** - * @param {?} xhrBackend - * @param {?} options - * @return {?} - */ -function httpFactory(xhrBackend, options) { - var /** @type {?} */ macroBackend = new ZoneMacroTaskBackend(xhrBackend); - return new _angular_http.Http(macroBackend, options); -} -var SERVER_HTTP_PROVIDERS = [ - { provide: _angular_http.Http, useFactory: httpFactory, deps: [_angular_http.XHRBackend, _angular_http.RequestOptions] }, - { provide: _angular_http.BrowserXhr, useClass: ServerXhr }, - { provide: _angular_http.XSRFStrategy, useClass: ServerXsrfStrategy }, -]; -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -/** - * The DI token for setting the initial config for the platform. - * - * \@experimental - */ -var INITIAL_CONFIG = new _angular_core.InjectionToken('Server.INITIAL_CONFIG'); -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -/** - * @param {?} urlStr - * @return {?} - */ -function parseUrl(urlStr) { - var /** @type {?} */ parsedUrl = url.parse(urlStr); - return { - pathname: parsedUrl.pathname || '', - search: parsedUrl.search || '', - hash: parsedUrl.hash || '', - }; -} -/** - * Server-side implementation of URL state. Implements `pathname`, `search`, and `hash` - * but not the state stack. - */ -var ServerPlatformLocation = (function () { + DominoAdapter.prototype.supportsNativeShadowDOM = /** + * @return {?} + */ + function () { return false; }; /** - * @param {?} _doc - * @param {?} _config + * @param {?} nodeA + * @param {?} nodeB + * @return {?} */ - function ServerPlatformLocation(_doc, _config) { - this._doc = _doc; - this._path = '/'; - this._search = ''; - this._hash = ''; - this._hashUpdate = new rxjs_Subject.Subject(); - var config = _config; - if (!!config && !!config.url) { - var parsedUrl = parseUrl(config.url); - this._path = parsedUrl.pathname; - this._search = parsedUrl.search; - this._hash = parsedUrl.hash; + DominoAdapter.prototype.contains = /** + * @param {?} nodeA + * @param {?} nodeB + * @return {?} + */ + function (nodeA, nodeB) { + var /** @type {?} */ inner = nodeB; + while (inner) { + if (inner === nodeA) + return true; + inner = inner.parent; } - } + return false; + }; /** * @return {?} */ - ServerPlatformLocation.prototype.getBaseHrefFromDOM = function () { return ((_angular_platformBrowser.ɵgetDOM().getBaseHref(this._doc))); }; - /** - * @param {?} fn + DominoAdapter.prototype.createHtmlDocument = /** * @return {?} */ - ServerPlatformLocation.prototype.onPopState = function (fn) { - // No-op: a state stack is not implemented, so - // no events will ever come. + function () { + return parseDocument('fakeTitle'); }; /** - * @param {?} fn * @return {?} */ - ServerPlatformLocation.prototype.onHashChange = function (fn) { this._hashUpdate.subscribe(fn); }; - Object.defineProperty(ServerPlatformLocation.prototype, "pathname", { - /** - * @return {?} - */ - get: function () { return this._path; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ServerPlatformLocation.prototype, "search", { - /** - * @return {?} - */ - get: function () { return this._search; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ServerPlatformLocation.prototype, "hash", { - /** - * @return {?} - */ - get: function () { return this._hash; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ServerPlatformLocation.prototype, "url", { - /** - * @return {?} - */ - get: function () { return "" + this.pathname + this.search + this.hash; }, - enumerable: true, - configurable: true - }); - /** - * @param {?} value - * @param {?} oldUrl + DominoAdapter.prototype.getDefaultDocument = /** * @return {?} */ - ServerPlatformLocation.prototype.setHash = function (value, oldUrl) { - var _this = this; - if (this._hash === value) { - // Don't fire events if the hash has not changed. - return; + function () { + if (!DominoAdapter.defaultDoc) { + DominoAdapter.defaultDoc = domino.createDocument(); } - this._hash = value; - var /** @type {?} */ newUrl = this.url; - scheduleMicroTask(function () { return _this._hashUpdate.next(/** @type {?} */ ({ type: 'hashchange', oldUrl: oldUrl, newUrl: newUrl })); }); + return DominoAdapter.defaultDoc; }; /** - * @param {?} state - * @param {?} title - * @param {?} newUrl + * @param {?} el + * @param {?=} doc * @return {?} */ - ServerPlatformLocation.prototype.replaceState = function (state, title, newUrl) { - var /** @type {?} */ oldUrl = this.url; - var /** @type {?} */ parsedUrl = parseUrl(newUrl); - this._path = parsedUrl.pathname; - this._search = parsedUrl.search; - this.setHash(parsedUrl.hash, oldUrl); - }; - /** - * @param {?} state - * @param {?} title - * @param {?} newUrl + DominoAdapter.prototype.createShadowRoot = /** + * @param {?} el + * @param {?=} doc * @return {?} */ - ServerPlatformLocation.prototype.pushState = function (state, title, newUrl) { - this.replaceState(state, title, newUrl); + function (el, doc) { + if (doc === void 0) { doc = document; } + el.shadowRoot = doc.createDocumentFragment(); + el.shadowRoot.parent = el; + return el.shadowRoot; }; /** + * @param {?} el * @return {?} */ - ServerPlatformLocation.prototype.forward = function () { throw new Error('Not implemented'); }; - /** + DominoAdapter.prototype.getShadowRoot = /** + * @param {?} el * @return {?} */ - ServerPlatformLocation.prototype.back = function () { throw new Error('Not implemented'); }; - return ServerPlatformLocation; -}()); -ServerPlatformLocation.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -ServerPlatformLocation.ctorParameters = function () { return [ - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, - { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [INITIAL_CONFIG,] },] }, -]; }; -/** - * @param {?} fn - * @return {?} - */ -function scheduleMicroTask(fn) { - Zone.current.scheduleMicroTask('scheduleMicrotask', fn); -} -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -var parse5$1 = __webpack_require__(35); -var treeAdapter; -var _attrToPropMap = { - 'class': 'className', - 'innerHtml': 'innerHTML', - 'readonly': 'readOnly', - 'tabindex': 'tabIndex', -}; -var mapProps = ['attribs', 'x-attribsNamespace', 'x-attribsPrefix']; -/** - * @param {?} methodName - * @return {?} - */ -function _notImplemented(methodName) { - return new Error('This method is not implemented in Parse5DomAdapter: ' + methodName); -} -/** - * @param {?} el - * @param {?} name - * @return {?} - */ -function _getElement(el, name) { - for (var /** @type {?} */ i = 0; i < el.childNodes.length; i++) { - var /** @type {?} */ node = el.childNodes[i]; - if (node.name === name) { - return node; - } - } - return null; -} -/** - * Parses a document string to a Document object. - * @param {?} html - * @return {?} - */ -function parseDocument(html) { - var /** @type {?} */ doc = parse5$1.parse(html, { treeAdapter: parse5$1.treeAdapters.htmlparser2 }); - var /** @type {?} */ docElement = _getElement(doc, 'html'); - doc['head'] = _getElement(docElement, 'head'); - doc['body'] = _getElement(docElement, 'body'); - doc['_window'] = {}; - return doc; -} -/** - * A `DomAdapter` powered by the `parse5` NodeJS module. - * - * \@security Tread carefully! Interacting with the DOM directly is dangerous and - * can introduce XSS risks. - */ -var Parse5DomAdapter = (function (_super) { - __extends(Parse5DomAdapter, _super); - function Parse5DomAdapter() { - return _super !== null && _super.apply(this, arguments) || this; - } + function (el) { return el.shadowRoot; }; /** + * @param {?} node * @return {?} */ - Parse5DomAdapter.makeCurrent = function () { - treeAdapter = parse5$1.treeAdapters.htmlparser2; - _angular_platformBrowser.ɵsetRootDomAdapter(new Parse5DomAdapter()); - }; - /** - * @param {?} nodeA - * @param {?} nodeB + DominoAdapter.prototype.isTextNode = /** + * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.contains = function (nodeA, nodeB) { - var /** @type {?} */ inner = nodeB; - while (inner) { - if (inner === nodeA) - return true; - inner = inner.parent; - } - return false; - }; + function (node) { return node.nodeType === DominoAdapter.defaultDoc.TEXT_NODE; }; /** - * @param {?} element - * @param {?} name + * @param {?} node + * @return {?} + */ + DominoAdapter.prototype.isCommentNode = /** + * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.hasProperty = function (element, name) { - return _HTMLElementPropertyList.indexOf(name) > -1; + function (node) { + return node.nodeType === DominoAdapter.defaultDoc.COMMENT_NODE; }; /** - * @param {?} el - * @param {?} name - * @param {?} value + * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.setProperty = function (el, name, value) { - if (name === 'innerHTML') { - this.setInnerHTML(el, value); - } - else if (name === 'innerText') { - this.setText(el, value); - } - else if (name === 'className') { - el.attribs['class'] = el.className = value; - } - else { - el[name] = value; - } + DominoAdapter.prototype.isElementNode = /** + * @param {?} node + * @return {?} + */ + function (node) { + return node ? node.nodeType === DominoAdapter.defaultDoc.ELEMENT_NODE : false; }; /** - * @param {?} el - * @param {?} name + * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.getProperty = function (el, name) { return el[name]; }; - /** - * @param {?} error + DominoAdapter.prototype.hasShadowRoot = /** + * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.logError = function (error) { console.error(error); }; + function (node) { return node.shadowRoot != null; }; /** - * @param {?} error + * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.log = function (error) { console.log(error); }; - /** - * @param {?} error + DominoAdapter.prototype.isShadowRoot = /** + * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.logGroup = function (error) { console.error(error); }; + function (node) { return this.getShadowRoot(node) == node; }; /** + * @param {?} el + * @param {?} name * @return {?} */ - Parse5DomAdapter.prototype.logGroupEnd = function () { }; - Object.defineProperty(Parse5DomAdapter.prototype, "attrToPropMap", { - /** - * @return {?} - */ - get: function () { return _attrToPropMap; }, - enumerable: true, - configurable: true - }); - /** + DominoAdapter.prototype.getProperty = /** * @param {?} el - * @param {?} selector + * @param {?} name * @return {?} */ - Parse5DomAdapter.prototype.querySelector = function (el, selector) { - return this.querySelectorAll(el, selector)[0] || null; + function (el, name) { + if (name === 'href') { + // Domino tries tp resolve href-s which we do not want. Just return the + // atribute value. + return this.getAttribute(el, 'href'); + } + else if (name === 'innerText') { + // Domino does not support innerText. Just map it to textContent. + return el.textContent; + } + return (/** @type {?} */ (el))[name]; }; /** * @param {?} el - * @param {?} selector + * @param {?} name + * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.querySelectorAll = function (el, selector) { - var _this = this; - var /** @type {?} */ res = []; - var /** @type {?} */ _recursive = function (result, node, selector, matcher) { - var /** @type {?} */ cNodes = node.childNodes; - if (cNodes && cNodes.length > 0) { - for (var /** @type {?} */ i = 0; i < cNodes.length; i++) { - var /** @type {?} */ childNode = cNodes[i]; - if (_this.elementMatches(childNode, selector, matcher)) { - result.push(childNode); - } - _recursive(result, childNode, selector, matcher); - } - } - }; - var /** @type {?} */ matcher = new _angular_compiler.SelectorMatcher(); - matcher.addSelectables(_angular_compiler.CssSelector.parse(selector)); - _recursive(res, el, selector, matcher); - return res; + DominoAdapter.prototype.setProperty = /** + * @param {?} el + * @param {?} name + * @param {?} value + * @return {?} + */ + function (el, name, value) { + if (name === 'href') { + // Eventhough the server renderer reflects any properties to attributes + // map 'href' to atribute just to handle when setProperty is directly called. + this.setAttribute(el, 'href', value); + } + else if (name === 'innerText') { + // Domino does not support innerText. Just map it to textContent. + el.textContent = value; + } + (/** @type {?} */ (el))[name] = value; }; /** - * @param {?} node - * @param {?} selector - * @param {?=} matcher + * @param {?} doc + * @param {?} target * @return {?} */ - Parse5DomAdapter.prototype.elementMatches = function (node, selector, matcher) { - if (matcher === void 0) { matcher = null; } - if (this.isElementNode(node) && selector === '*') { - return true; + DominoAdapter.prototype.getGlobalEventTarget = /** + * @param {?} doc + * @param {?} target + * @return {?} + */ + function (doc, target) { + if (target === 'window') { + return doc.defaultView; } - var /** @type {?} */ result = false; - if (selector && selector.charAt(0) == '#') { - result = this.getAttribute(node, 'id') == selector.substring(1); + if (target === 'document') { + return doc; } - else if (selector) { - if (!matcher) { - matcher = new _angular_compiler.SelectorMatcher(); - matcher.addSelectables(_angular_compiler.CssSelector.parse(selector)); - } - var /** @type {?} */ cssSelector = new _angular_compiler.CssSelector(); - cssSelector.setElement(this.tagName(node)); - if (node.attribs) { - for (var /** @type {?} */ attrName in node.attribs) { - cssSelector.addAttribute(attrName, node.attribs[attrName]); - } - } - var /** @type {?} */ classList = this.classList(node); - for (var /** @type {?} */ i = 0; i < classList.length; i++) { - cssSelector.addClassName(classList[i]); - } - matcher.match(cssSelector, function (selector, cb) { result = true; }); + if (target === 'body') { + return doc.body; } - return result; + return null; }; /** - * @param {?} el - * @param {?} evt - * @param {?} listener + * @param {?} doc * @return {?} */ - Parse5DomAdapter.prototype.on = function (el, evt, listener) { - var /** @type {?} */ listenersMap = el._eventListenersMap; - if (!listenersMap) { - listenersMap = {}; - el._eventListenersMap = listenersMap; + DominoAdapter.prototype.getBaseHref = /** + * @param {?} doc + * @return {?} + */ + function (doc) { + var /** @type {?} */ base = this.querySelector(doc.documentElement, 'base'); + var /** @type {?} */ href = ''; + if (base) { + href = this.getHref(base); } - var /** @type {?} */ listeners = listenersMap[evt] || []; - listenersMap[evt] = listeners.concat([listener]); + // TODO(alxhub): Need relative path logic from BrowserDomAdapter here? + return href; }; + /** @internal */ /** - * @param {?} el - * @param {?} evt - * @param {?} listener + * \@internal + * @param {?} element * @return {?} */ - Parse5DomAdapter.prototype.onAndCancel = function (el, evt, listener) { - this.on(el, evt, listener); - return function () { remove(/** @type {?} */ ((el._eventListenersMap[evt])), listener); }; - }; - /** - * @param {?} el - * @param {?} evt + DominoAdapter.prototype._readStyleAttribute = /** + * \@internal + * @param {?} element * @return {?} */ - Parse5DomAdapter.prototype.dispatchEvent = function (el, evt) { - if (!evt.target) { - evt.target = el; - } - if (el._eventListenersMap) { - var /** @type {?} */ listeners = el._eventListenersMap[evt.type]; - if (listeners) { - for (var /** @type {?} */ i = 0; i < listeners.length; i++) { - listeners[i](evt); + function (element) { + var /** @type {?} */ styleMap = {}; + var /** @type {?} */ styleAttribute = element.getAttribute('style'); + if (styleAttribute) { + var /** @type {?} */ styleList = styleAttribute.split(/;+/g); + for (var /** @type {?} */ i = 0; i < styleList.length; i++) { + if (styleList[i].length > 0) { + var /** @type {?} */ style = /** @type {?} */ (styleList[i]); + var /** @type {?} */ colon = style.indexOf(':'); + if (colon === -1) { + throw new Error("Invalid CSS style: " + style); + } + (/** @type {?} */ (styleMap))[style.substr(0, colon).trim()] = style.substr(colon + 1).trim(); } } } - if (el.parent) { - this.dispatchEvent(el.parent, evt); - } - if (el._window) { - this.dispatchEvent(el._window, evt); - } + return styleMap; }; + /** @internal */ /** - * @param {?} eventType + * \@internal + * @param {?} element + * @param {?} styleMap * @return {?} */ - Parse5DomAdapter.prototype.createMouseEvent = function (eventType) { return this.createEvent(eventType); }; - /** - * @param {?} eventType + DominoAdapter.prototype._writeStyleAttribute = /** + * \@internal + * @param {?} element + * @param {?} styleMap * @return {?} */ - Parse5DomAdapter.prototype.createEvent = function (eventType) { - var /** @type {?} */ event = ({ - type: eventType, - defaultPrevented: false, - preventDefault: function () { ((event)).defaultPrevented = true; } - }); - return event; + function (element, styleMap) { + var /** @type {?} */ styleAttrValue = ''; + for (var /** @type {?} */ key in styleMap) { + var /** @type {?} */ newValue = styleMap[key]; + if (newValue) { + styleAttrValue += key + ':' + styleMap[key] + ';'; + } + } + element.setAttribute('style', styleAttrValue); }; /** - * @param {?} event - * @return {?} - */ - Parse5DomAdapter.prototype.preventDefault = function (event) { event.returnValue = false; }; - /** - * @param {?} event + * @param {?} element + * @param {?} styleName + * @param {?=} styleValue * @return {?} */ - Parse5DomAdapter.prototype.isPrevented = function (event) { return event.returnValue != null && !event.returnValue; }; - /** - * @param {?} el + DominoAdapter.prototype.setStyle = /** + * @param {?} element + * @param {?} styleName + * @param {?=} styleValue * @return {?} */ - Parse5DomAdapter.prototype.getInnerHTML = function (el) { - return parse5$1.serialize(this.templateAwareRoot(el), { treeAdapter: treeAdapter }); + function (element, styleName, styleValue) { + var /** @type {?} */ styleMap = this._readStyleAttribute(element); + (/** @type {?} */ (styleMap))[styleName] = styleValue; + this._writeStyleAttribute(element, styleMap); }; /** - * @param {?} el + * @param {?} element + * @param {?} styleName * @return {?} */ - Parse5DomAdapter.prototype.getTemplateContent = function (el) { return null; }; - /** - * @param {?} el + DominoAdapter.prototype.removeStyle = /** + * @param {?} element + * @param {?} styleName * @return {?} */ - Parse5DomAdapter.prototype.getOuterHTML = function (el) { - var /** @type {?} */ fragment = treeAdapter.createDocumentFragment(); - this.appendChild(fragment, el); - return parse5$1.serialize(fragment, { treeAdapter: treeAdapter }); - }; + function (element, styleName) { this.setStyle(element, styleName, null); }; /** - * @param {?} node + * @param {?} element + * @param {?} styleName * @return {?} */ - Parse5DomAdapter.prototype.nodeName = function (node) { return node.tagName; }; - /** - * @param {?} node + DominoAdapter.prototype.getStyle = /** + * @param {?} element + * @param {?} styleName * @return {?} */ - Parse5DomAdapter.prototype.nodeValue = function (node) { return node.nodeValue; }; + function (element, styleName) { + var /** @type {?} */ styleMap = this._readStyleAttribute(element); + return styleMap.hasOwnProperty(styleName) ? (/** @type {?} */ (styleMap))[styleName] : ''; + }; /** - * @param {?} node + * @param {?} element + * @param {?} styleName + * @param {?=} styleValue * @return {?} */ - Parse5DomAdapter.prototype.type = function (node) { throw _notImplemented('type'); }; - /** - * @param {?} node + DominoAdapter.prototype.hasStyle = /** + * @param {?} element + * @param {?} styleName + * @param {?=} styleValue * @return {?} */ - Parse5DomAdapter.prototype.content = function (node) { return node.childNodes[0]; }; + function (element, styleName, styleValue) { + var /** @type {?} */ value = this.getStyle(element, styleName) || ''; + return styleValue ? value == styleValue : value.length > 0; + }; /** * @param {?} el + * @param {?} evt * @return {?} */ - Parse5DomAdapter.prototype.firstChild = function (el) { return el.firstChild; }; - /** + DominoAdapter.prototype.dispatchEvent = /** * @param {?} el + * @param {?} evt * @return {?} */ - Parse5DomAdapter.prototype.nextSibling = function (el) { return el.nextSibling; }; + function (el, evt) { + el.dispatchEvent(evt); + // Dispatch the event to the window also. + var /** @type {?} */ doc = el.ownerDocument || el; + var /** @type {?} */ win = (/** @type {?} */ (doc)).defaultView; + if (win) { + win.dispatchEvent(evt); + } + }; /** - * @param {?} el * @return {?} */ - Parse5DomAdapter.prototype.parentElement = function (el) { return el.parent; }; - /** - * @param {?} el + DominoAdapter.prototype.getHistory = /** * @return {?} */ - Parse5DomAdapter.prototype.childNodes = function (el) { return el.childNodes; }; + function () { throw _notImplemented('getHistory'); }; /** - * @param {?} el * @return {?} */ - Parse5DomAdapter.prototype.childNodesAsList = function (el) { - var /** @type {?} */ childNodes = el.childNodes; - var /** @type {?} */ res = new Array(childNodes.length); - for (var /** @type {?} */ i = 0; i < childNodes.length; i++) { - res[i] = childNodes[i]; - } - return res; - }; - /** - * @param {?} el + DominoAdapter.prototype.getLocation = /** * @return {?} */ - Parse5DomAdapter.prototype.clearNodes = function (el) { - while (el.childNodes.length > 0) { - this.remove(el.childNodes[0]); - } - }; + function () { throw _notImplemented('getLocation'); }; /** - * @param {?} el - * @param {?} node * @return {?} */ - Parse5DomAdapter.prototype.appendChild = function (el, node) { - this.remove(node); - treeAdapter.appendChild(this.templateAwareRoot(el), node); - }; - /** - * @param {?} el - * @param {?} node + DominoAdapter.prototype.getUserAgent = /** * @return {?} */ - Parse5DomAdapter.prototype.removeChild = function (el, node) { - if (el.childNodes.indexOf(node) > -1) { - this.remove(node); - } - }; + function () { return 'Fake user agent'; }; /** - * @param {?} el * @return {?} */ - Parse5DomAdapter.prototype.remove = function (el) { - var /** @type {?} */ parent = el.parent; - if (parent) { - var /** @type {?} */ index = parent.childNodes.indexOf(el); - parent.childNodes.splice(index, 1); - } - var /** @type {?} */ prev = el.previousSibling; - var /** @type {?} */ next = el.nextSibling; - if (prev) { - prev.next = next; - } - if (next) { - next.prev = prev; - } - el.prev = null; - el.next = null; - el.parent = null; - return el; - }; - /** - * @param {?} parent - * @param {?} ref - * @param {?} newNode + DominoAdapter.prototype.supportsWebAnimation = /** * @return {?} */ - Parse5DomAdapter.prototype.insertBefore = function (parent, ref, newNode) { - this.remove(newNode); - if (ref) { - treeAdapter.insertBefore(parent, newNode, ref); - } - else { - this.appendChild(parent, newNode); - } - }; + function () { return false; }; /** - * @param {?} parent - * @param {?} ref - * @param {?} nodes * @return {?} */ - Parse5DomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) { - var _this = this; - nodes.forEach(function (n) { return _this.insertBefore(parent, ref, n); }); - }; - /** - * @param {?} parent - * @param {?} ref - * @param {?} node + DominoAdapter.prototype.performanceNow = /** * @return {?} */ - Parse5DomAdapter.prototype.insertAfter = function (parent, ref, node) { - if (ref.nextSibling) { - this.insertBefore(parent, ref.nextSibling, node); - } - else { - this.appendChild(parent, node); - } - }; + function () { return Date.now(); }; /** - * @param {?} el - * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.setInnerHTML = function (el, value) { - this.clearNodes(el); - var /** @type {?} */ content = parse5$1.parseFragment(value, { treeAdapter: treeAdapter }); - for (var /** @type {?} */ i = 0; i < content.childNodes.length; i++) { - treeAdapter.appendChild(el, content.childNodes[i]); - } - }; - /** - * @param {?} el - * @param {?=} isRecursive + DominoAdapter.prototype.getAnimationPrefix = /** * @return {?} */ - Parse5DomAdapter.prototype.getText = function (el, isRecursive) { - if (this.isTextNode(el)) { - return el.data; - } - if (this.isCommentNode(el)) { - // In the DOM, comments within an element return an empty string for textContent - // However, comment node instances return the comment content for textContent getter - return isRecursive ? '' : el.data; - } - if (!el.childNodes || el.childNodes.length == 0) { - return ''; - } - var /** @type {?} */ textContent = ''; - for (var /** @type {?} */ i = 0; i < el.childNodes.length; i++) { - textContent += this.getText(el.childNodes[i], true); - } - return textContent; - }; + function () { return ''; }; /** - * @param {?} el - * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.setText = function (el, value) { - if (this.isTextNode(el) || this.isCommentNode(el)) { - el.data = value; - } - else { - this.clearNodes(el); - if (value !== '') - treeAdapter.insertText(el, value); - } - }; - /** - * @param {?} el + DominoAdapter.prototype.getTransitionEnd = /** * @return {?} */ - Parse5DomAdapter.prototype.getValue = function (el) { return el.value; }; + function () { return 'transitionend'; }; /** - * @param {?} el - * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.setValue = function (el, value) { el.value = value; }; + DominoAdapter.prototype.supportsAnimation = /** + * @return {?} + */ + function () { return true; }; /** * @param {?} el * @return {?} */ - Parse5DomAdapter.prototype.getChecked = function (el) { return el.checked; }; - /** + DominoAdapter.prototype.getDistributedNodes = /** * @param {?} el - * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.setChecked = function (el, value) { el.checked = value; }; + function (el) { throw _notImplemented('getDistributedNodes'); }; /** - * @param {?} text * @return {?} */ - Parse5DomAdapter.prototype.createComment = function (text) { return treeAdapter.createCommentNode(text); }; - /** - * @param {?} html + DominoAdapter.prototype.supportsCookies = /** * @return {?} */ - Parse5DomAdapter.prototype.createTemplate = function (html) { - var /** @type {?} */ template = treeAdapter.createElement('template', 'http://www.w3.org/1999/xhtml', []); - var /** @type {?} */ content = parse5$1.parseFragment(html, { treeAdapter: treeAdapter }); - treeAdapter.setTemplateContent(template, content); - return template; - }; + function () { return false; }; /** - * @param {?} tagName + * @param {?} name * @return {?} */ - Parse5DomAdapter.prototype.createElement = function (tagName) { - return treeAdapter.createElement(tagName, 'http://www.w3.org/1999/xhtml', []); - }; - /** - * @param {?} ns - * @param {?} tagName + DominoAdapter.prototype.getCookie = /** + * @param {?} name * @return {?} */ - Parse5DomAdapter.prototype.createElementNS = function (ns, tagName) { - return treeAdapter.createElement(tagName, ns, []); - }; + function (name) { throw _notImplemented('getCookie'); }; /** - * @param {?} text + * @param {?} name + * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.createTextNode = function (text) { - var /** @type {?} */ t = (this.createComment(text)); - t.type = 'text'; - return t; - }; - /** - * @param {?} attrName - * @param {?} attrValue + DominoAdapter.prototype.setCookie = /** + * @param {?} name + * @param {?} value * @return {?} */ - Parse5DomAdapter.prototype.createScriptTag = function (attrName, attrValue) { - return treeAdapter.createElement('script', 'http://www.w3.org/1999/xhtml', [{ name: attrName, value: attrValue }]); - }; + function (name, value) { throw _notImplemented('setCookie'); }; + return DominoAdapter; +}(_angular_platformBrowser.ɵBrowserDomAdapter)); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +/** + * Representation of the current platform state. + * + * \@experimental + */ +var PlatformState = (function () { + function PlatformState(_doc) { + this._doc = _doc; + } /** - * @param {?} css - * @return {?} + * Renders the current state of the platform to string. */ - Parse5DomAdapter.prototype.createStyleElement = function (css) { - var /** @type {?} */ style = this.createElement('style'); - this.setText(style, css); - return (style); - }; /** - * @param {?} el + * Renders the current state of the platform to string. * @return {?} */ - Parse5DomAdapter.prototype.createShadowRoot = function (el) { - el.shadowRoot = treeAdapter.createDocumentFragment(); - el.shadowRoot.parent = el; - return el.shadowRoot; - }; - /** - * @param {?} el + PlatformState.prototype.renderToString = /** + * Renders the current state of the platform to string. * @return {?} */ - Parse5DomAdapter.prototype.getShadowRoot = function (el) { return el.shadowRoot; }; + function () { return serializeDocument(this._doc); }; /** - * @param {?} el - * @return {?} + * Returns the current DOM state. */ - Parse5DomAdapter.prototype.getHost = function (el) { return el.host; }; /** - * @param {?} el + * Returns the current DOM state. * @return {?} */ - Parse5DomAdapter.prototype.getDistributedNodes = function (el) { throw _notImplemented('getDistributedNodes'); }; - /** - * @param {?} node + PlatformState.prototype.getDocument = /** + * Returns the current DOM state. * @return {?} */ - Parse5DomAdapter.prototype.clone = function (node) { - var /** @type {?} */ _recursive = function (node) { - var /** @type {?} */ nodeClone = Object.create(Object.getPrototypeOf(node)); - for (var /** @type {?} */ prop in node) { - var /** @type {?} */ desc = Object.getOwnPropertyDescriptor(node, prop); - if (desc && 'value' in desc && typeof desc.value !== 'object') { - nodeClone[prop] = node[prop]; - } - } - nodeClone.parent = null; - nodeClone.prev = null; - nodeClone.next = null; - nodeClone.children = null; - mapProps.forEach(function (mapName) { - if (node[mapName] != null) { - nodeClone[mapName] = {}; - for (var /** @type {?} */ prop in node[mapName]) { - nodeClone[mapName][prop] = node[mapName][prop]; - } - } - }); - var /** @type {?} */ cNodes = node.children; - if (cNodes) { - var /** @type {?} */ cNodesClone = new Array(cNodes.length); - for (var /** @type {?} */ i = 0; i < cNodes.length; i++) { - var /** @type {?} */ childNode = cNodes[i]; - var /** @type {?} */ childNodeClone = _recursive(childNode); - cNodesClone[i] = childNodeClone; - if (i > 0) { - childNodeClone.prev = cNodesClone[i - 1]; - cNodesClone[i - 1].next = childNodeClone; - } - childNodeClone.parent = nodeClone; - } - nodeClone.children = cNodesClone; - } - return nodeClone; - }; - return _recursive(node); - }; - /** - * @param {?} element - * @param {?} name - * @return {?} - */ - Parse5DomAdapter.prototype.getElementsByClassName = function (element, name) { - return this.querySelectorAll(element, '.' + name); - }; - /** - * @param {?} element - * @param {?} name - * @return {?} - */ - Parse5DomAdapter.prototype.getElementsByTagName = function (element, name) { - return this.querySelectorAll(element, name); - }; + function () { return this._doc; }; + PlatformState.decorators = [ + { type: _angular_core.Injectable }, + ]; + /** @nocollapse */ + PlatformState.ctorParameters = function () { return [ + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, + ]; }; + return PlatformState; +}()); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +var xhr2 = __webpack_require__(120); +var isAbsoluteUrl = /^[a-zA-Z\-\+.]+:\/\//; +/** + * @param {?} url + * @return {?} + */ +function validateRequestUrl(url$$1) { + if (!isAbsoluteUrl.test(url$$1)) { + throw new Error("URLs requested via Http on the server must be absolute. URL: " + url$$1); + } +} +var ServerXhr = (function () { + function ServerXhr() { + } /** - * @param {?} element * @return {?} */ - Parse5DomAdapter.prototype.classList = function (element) { - var /** @type {?} */ classAttrValue = null; - var /** @type {?} */ attributes = element.attribs; - if (attributes && attributes['class'] != null) { - classAttrValue = attributes['class']; - } - return classAttrValue ? classAttrValue.trim().split(/\s+/g) : []; - }; - /** - * @param {?} element - * @param {?} className + ServerXhr.prototype.build = /** * @return {?} */ - Parse5DomAdapter.prototype.addClass = function (element, className) { - var /** @type {?} */ classList = this.classList(element); - var /** @type {?} */ index = classList.indexOf(className); - if (index == -1) { - classList.push(className); - element.attribs['class'] = element.className = classList.join(' '); - } - }; + function () { return new xhr2.XMLHttpRequest(); }; + ServerXhr.decorators = [ + { type: _angular_core.Injectable }, + ]; + /** @nocollapse */ + ServerXhr.ctorParameters = function () { return []; }; + return ServerXhr; +}()); +var ServerXsrfStrategy = (function () { + function ServerXsrfStrategy() { + } /** - * @param {?} element - * @param {?} className + * @param {?} req * @return {?} */ - Parse5DomAdapter.prototype.removeClass = function (element, className) { - var /** @type {?} */ classList = this.classList(element); - var /** @type {?} */ index = classList.indexOf(className); - if (index > -1) { - classList.splice(index, 1); - element.attribs['class'] = element.className = classList.join(' '); - } - }; - /** - * @param {?} element - * @param {?} className + ServerXsrfStrategy.prototype.configureRequest = /** + * @param {?} req * @return {?} */ - Parse5DomAdapter.prototype.hasClass = function (element, className) { - return this.classList(element).indexOf(className) > -1; - }; + function (req) { }; + ServerXsrfStrategy.decorators = [ + { type: _angular_core.Injectable }, + ]; + /** @nocollapse */ + ServerXsrfStrategy.ctorParameters = function () { return []; }; + return ServerXsrfStrategy; +}()); +/** + * @abstract + */ +var ZoneMacroTaskWrapper = (function () { + function ZoneMacroTaskWrapper() { + } /** - * @param {?} element - * @param {?} styleName - * @param {?=} styleValue + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.hasStyle = function (element, styleName, styleValue) { - var /** @type {?} */ value = this.getStyle(element, styleName) || ''; - return styleValue ? value == styleValue : value.length > 0; - }; - /** - * \@internal - * @param {?} element + ZoneMacroTaskWrapper.prototype.wrap = /** + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype._readStyleAttribute = function (element) { - var /** @type {?} */ styleMap = {}; - var /** @type {?} */ attributes = element.attribs; - if (attributes && attributes['style'] != null) { - var /** @type {?} */ styleAttrValue = attributes['style']; - var /** @type {?} */ styleList = styleAttrValue.split(/;+/g); - for (var /** @type {?} */ i = 0; i < styleList.length; i++) { - if (styleList[i].length > 0) { - var /** @type {?} */ style = (styleList[i]); - var /** @type {?} */ colon = style.indexOf(':'); - if (colon === -1) { - throw new Error("Invalid CSS style: " + style); + function (request) { + var _this = this; + return new rxjs_Observable.Observable(function (observer) { + var /** @type {?} */ task = /** @type {?} */ ((null)); + var /** @type {?} */ scheduled = false; + var /** @type {?} */ sub = null; + var /** @type {?} */ savedResult = null; + var /** @type {?} */ savedError = null; + var /** @type {?} */ scheduleTask = function (_task) { + task = _task; + scheduled = true; + var /** @type {?} */ delegate = _this.delegate(request); + sub = delegate.subscribe(function (res) { return savedResult = res; }, function (err) { + if (!scheduled) { + throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.'); + } + savedError = err; + scheduled = false; + task.invoke(); + }, function () { + if (!scheduled) { + throw new Error('An http observable was completed twice. This shouldn\'t happen, please file a bug.'); } - ((styleMap))[style.substr(0, colon).trim()] = style.substr(colon + 1).trim(); + scheduled = false; + task.invoke(); + }); + }; + var /** @type {?} */ cancelTask = function (_task) { + if (!scheduled) { + return; } - } - } - return styleMap; + scheduled = false; + if (sub) { + sub.unsubscribe(); + sub = null; + } + }; + var /** @type {?} */ onComplete = function () { + if (savedError !== null) { + observer.error(savedError); + } + else { + observer.next(savedResult); + observer.complete(); + } + }; + // MockBackend for Http is synchronous, which means that if scheduleTask is by + // scheduleMacroTask, the request will hit MockBackend and the response will be + // sent, causing task.invoke() to be called. + var /** @type {?} */ _task = Zone.current.scheduleMacroTask('ZoneMacroTaskWrapper.subscribe', onComplete, {}, function () { return null; }, cancelTask); + scheduleTask(_task); + return function () { + if (scheduled && task) { + task.zone.cancelTask(task); + scheduled = false; + } + if (sub) { + sub.unsubscribe(); + sub = null; + } + }; + }); }; + return ZoneMacroTaskWrapper; +}()); +var ZoneMacroTaskConnection = (function (_super) { + __extends(ZoneMacroTaskConnection, _super); + function ZoneMacroTaskConnection(request, backend) { + var _this = _super.call(this) || this; + _this.request = request; + _this.backend = backend; + validateRequestUrl(request.url); + _this.response = _this.wrap(request); + return _this; + } /** - * \@internal - * @param {?} element - * @param {?} styleMap + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype._writeStyleAttribute = function (element, styleMap) { - var /** @type {?} */ styleAttrValue = ''; - for (var /** @type {?} */ key in styleMap) { - var /** @type {?} */ newValue = styleMap[key]; - if (newValue) { - styleAttrValue += key + ':' + styleMap[key] + ';'; - } - } - element.attribs['style'] = styleAttrValue; - }; - /** - * @param {?} element - * @param {?} styleName - * @param {?=} styleValue + ZoneMacroTaskConnection.prototype.delegate = /** + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.setStyle = function (element, styleName, styleValue) { - var /** @type {?} */ styleMap = this._readStyleAttribute(element); - ((styleMap))[styleName] = styleValue; - this._writeStyleAttribute(element, styleMap); + function (request) { + this.lastConnection = this.backend.createConnection(request); + return /** @type {?} */ (this.lastConnection.response); }; + Object.defineProperty(ZoneMacroTaskConnection.prototype, "readyState", { + get: /** + * @return {?} + */ + function () { + return !!this.lastConnection ? this.lastConnection.readyState : _angular_http.ReadyState.Unsent; + }, + enumerable: true, + configurable: true + }); + return ZoneMacroTaskConnection; +}(ZoneMacroTaskWrapper)); +var ZoneMacroTaskBackend = (function () { + function ZoneMacroTaskBackend(backend) { + this.backend = backend; + } /** - * @param {?} element - * @param {?} styleName + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.removeStyle = function (element, styleName) { this.setStyle(element, styleName, null); }; - /** - * @param {?} element - * @param {?} styleName + ZoneMacroTaskBackend.prototype.createConnection = /** + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.getStyle = function (element, styleName) { - var /** @type {?} */ styleMap = this._readStyleAttribute(element); - return styleMap.hasOwnProperty(styleName) ? ((styleMap))[styleName] : ''; + function (request) { + return new ZoneMacroTaskConnection(request, this.backend); }; + return ZoneMacroTaskBackend; +}()); +var ZoneClientBackend = (function (_super) { + __extends(ZoneClientBackend, _super); + function ZoneClientBackend(backend) { + var _this = _super.call(this) || this; + _this.backend = backend; + return _this; + } /** - * @param {?} element + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.tagName = function (element) { return element.tagName == 'style' ? 'STYLE' : element.tagName; }; - /** - * @param {?} element + ZoneClientBackend.prototype.handle = /** + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.attributeMap = function (element) { - var /** @type {?} */ res = new Map(); - var /** @type {?} */ elAttrs = treeAdapter.getAttrList(element); - for (var /** @type {?} */ i = 0; i < elAttrs.length; i++) { - var /** @type {?} */ attrib = elAttrs[i]; - res.set(attrib.name, attrib.value); - } - return res; - }; + function (request) { return this.wrap(request); }; /** - * @param {?} element - * @param {?} attribute + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.hasAttribute = function (element, attribute) { - return element.attribs && element.attribs[attribute] != null; - }; - /** - * @param {?} element - * @param {?} ns - * @param {?} attribute + ZoneClientBackend.prototype.delegate = /** + * @param {?} request * @return {?} */ - Parse5DomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) { - return this.hasAttribute(element, attribute); + function (request) { + return this.backend.handle(request); }; - /** - * @param {?} element - * @param {?} attribute - * @return {?} - */ - Parse5DomAdapter.prototype.getAttribute = function (element, attribute) { - return this.hasAttribute(element, attribute) ? element.attribs[attribute] : null; + return ZoneClientBackend; +}(ZoneMacroTaskWrapper)); +/** + * @param {?} xhrBackend + * @param {?} options + * @return {?} + */ +function httpFactory(xhrBackend, options) { + var /** @type {?} */ macroBackend = new ZoneMacroTaskBackend(xhrBackend); + return new _angular_http.Http(macroBackend, options); +} +/** + * @param {?} backend + * @param {?} interceptors + * @return {?} + */ +function zoneWrappedInterceptingHandler(backend, interceptors) { + var /** @type {?} */ realBackend = _angular_common_http.ɵinterceptingHandler(backend, interceptors); + return new ZoneClientBackend(realBackend); +} +var SERVER_HTTP_PROVIDERS = [ + { provide: _angular_http.Http, useFactory: httpFactory, deps: [_angular_http.XHRBackend, _angular_http.RequestOptions] }, + { provide: _angular_http.BrowserXhr, useClass: ServerXhr }, { provide: _angular_http.XSRFStrategy, useClass: ServerXsrfStrategy }, + { provide: _angular_common_http.XhrFactory, useClass: ServerXhr }, { + provide: _angular_common_http.HttpHandler, + useFactory: zoneWrappedInterceptingHandler, + deps: [_angular_common_http.HttpBackend, [new _angular_core.Optional(), _angular_common_http.HTTP_INTERCEPTORS]] + } +]; + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +/** + * Config object passed to initialize the platform. + * + * \@experimental + * @record + */ + +/** + * The DI token for setting the initial config for the platform. + * + * \@experimental + */ +var INITIAL_CONFIG = new _angular_core.InjectionToken('Server.INITIAL_CONFIG'); +/** + * A function that will be executed when calling `renderModuleFactory` or `renderModule` just + * before current platform state is rendered to string. + * + * \@experimental + */ +var BEFORE_APP_SERIALIZED = new _angular_core.InjectionToken('Server.RENDER_MODULE_HOOK'); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @param {?} urlStr + * @return {?} + */ +function parseUrl(urlStr) { + var /** @type {?} */ parsedUrl = url.parse(urlStr); + return { + pathname: parsedUrl.pathname || '', + search: parsedUrl.search || '', + hash: parsedUrl.hash || '', }; - /** - * @param {?} element - * @param {?} ns - * @param {?} attribute - * @return {?} - */ - Parse5DomAdapter.prototype.getAttributeNS = function (element, ns, attribute) { - return this.getAttribute(element, attribute); - }; - /** - * @param {?} element - * @param {?} attribute - * @param {?} value - * @return {?} - */ - Parse5DomAdapter.prototype.setAttribute = function (element, attribute, value) { - if (attribute) { - element.attribs[attribute] = value; - if (attribute === 'class') { - element.className = value; - } - } - }; - /** - * @param {?} element - * @param {?} ns - * @param {?} attribute - * @param {?} value - * @return {?} - */ - Parse5DomAdapter.prototype.setAttributeNS = function (element, ns, attribute, value) { - this.setAttribute(element, attribute, value); - }; - /** - * @param {?} element - * @param {?} attribute - * @return {?} - */ - Parse5DomAdapter.prototype.removeAttribute = function (element, attribute) { - if (attribute) { - delete element.attribs[attribute]; +} +/** + * Server-side implementation of URL state. Implements `pathname`, `search`, and `hash` + * but not the state stack. + */ +var ServerPlatformLocation = (function () { + function ServerPlatformLocation(_doc, _config) { + this._doc = _doc; + this.pathname = '/'; + this.search = ''; + this.hash = ''; + this._hashUpdate = new rxjs_Subject.Subject(); + var /** @type {?} */ config = /** @type {?} */ (_config); + if (!!config && !!config.url) { + var /** @type {?} */ parsedUrl = parseUrl(config.url); + this.pathname = parsedUrl.pathname; + this.search = parsedUrl.search; + this.hash = parsedUrl.hash; } - }; - /** - * @param {?} element - * @param {?} ns - * @param {?} name - * @return {?} - */ - Parse5DomAdapter.prototype.removeAttributeNS = function (element, ns, name) { throw 'not implemented'; }; - /** - * @param {?} el - * @return {?} - */ - Parse5DomAdapter.prototype.templateAwareRoot = function (el) { - return this.isTemplateElement(el) ? treeAdapter.getTemplateContent(el) : el; - }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.createHtmlDocument = function () { - var /** @type {?} */ newDoc = treeAdapter.createDocument(); - newDoc.title = 'fakeTitle'; - var /** @type {?} */ head = treeAdapter.createElement('head', null, []); - var /** @type {?} */ body = treeAdapter.createElement('body', 'http://www.w3.org/1999/xhtml', []); - this.appendChild(newDoc, head); - this.appendChild(newDoc, body); - newDoc['head'] = head; - newDoc['body'] = body; - newDoc['_window'] = {}; - return newDoc; - }; + } /** - * @param {?} el * @return {?} */ - Parse5DomAdapter.prototype.getBoundingClientRect = function (el) { return { left: 0, top: 0, width: 0, height: 0 }; }; - /** - * @param {?} doc + ServerPlatformLocation.prototype.getBaseHrefFromDOM = /** * @return {?} */ - Parse5DomAdapter.prototype.getTitle = function (doc) { return this.getText(this.getTitleNode(doc)) || ''; }; + function () { return /** @type {?} */ ((_angular_platformBrowser.ɵgetDOM().getBaseHref(this._doc))); }; /** - * @param {?} doc - * @param {?} newTitle + * @param {?} fn * @return {?} */ - Parse5DomAdapter.prototype.setTitle = function (doc, newTitle) { - this.setText(this.getTitleNode(doc), newTitle || ''); - }; - /** - * @param {?} el + ServerPlatformLocation.prototype.onPopState = /** + * @param {?} fn * @return {?} */ - Parse5DomAdapter.prototype.isTemplateElement = function (el) { - return this.isElementNode(el) && this.tagName(el) === 'template'; + function (fn) { + // No-op: a state stack is not implemented, so + // no events will ever come. }; /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.isTextNode = function (node) { return treeAdapter.isTextNode(node); }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.isCommentNode = function (node) { return treeAdapter.isCommentNode(node); }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.isElementNode = function (node) { return node ? treeAdapter.isElementNode(node) : false; }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.hasShadowRoot = function (node) { return node.shadowRoot != null; }; - /** - * @param {?} node - * @return {?} - */ - Parse5DomAdapter.prototype.isShadowRoot = function (node) { return this.getShadowRoot(node) == node; }; - /** - * @param {?} node + * @param {?} fn * @return {?} */ - Parse5DomAdapter.prototype.importIntoDoc = function (node) { return this.clone(node); }; - /** - * @param {?} node + ServerPlatformLocation.prototype.onHashChange = /** + * @param {?} fn * @return {?} */ - Parse5DomAdapter.prototype.adoptNode = function (node) { return node; }; + function (fn) { this._hashUpdate.subscribe(fn); }; + Object.defineProperty(ServerPlatformLocation.prototype, "url", { + get: /** + * @return {?} + */ + function () { return "" + this.pathname + this.search + this.hash; }, + enumerable: true, + configurable: true + }); /** - * @param {?} el + * @param {?} value + * @param {?} oldUrl * @return {?} */ - Parse5DomAdapter.prototype.getHref = function (el) { return this.getAttribute(el, 'href'); }; - /** - * @param {?} el - * @param {?} baseUrl - * @param {?} href + ServerPlatformLocation.prototype.setHash = /** + * @param {?} value + * @param {?} oldUrl * @return {?} */ - Parse5DomAdapter.prototype.resolveAndSetHref = function (el, baseUrl, href) { - if (href == null) { - el.href = baseUrl; - } - else { - el.href = baseUrl + '/../' + href; - } - }; - /** - * \@internal - * @param {?} parsedRules - * @param {?=} css - * @return {?} - */ - Parse5DomAdapter.prototype._buildRules = function (parsedRules, css) { - var /** @type {?} */ rules = []; - for (var /** @type {?} */ i = 0; i < parsedRules.length; i++) { - var /** @type {?} */ parsedRule = parsedRules[i]; - var /** @type {?} */ rule = {}; - rule['cssText'] = css; - rule['style'] = { content: '', cssText: '' }; - if (parsedRule.type == 'rule') { - rule['type'] = 1; - rule['selectorText'] = - parsedRule.selectors.join(', '.replace(/\s{2,}/g, ' ') - .replace(/\s*~\s*/g, ' ~ ') - .replace(/\s*\+\s*/g, ' + ') - .replace(/\s*>\s*/g, ' > ') - .replace(/\[(\w+)=(\w+)\]/g, '[$1="$2"]')); - if (parsedRule.declarations == null) { - continue; - } - for (var /** @type {?} */ j = 0; j < parsedRule.declarations.length; j++) { - var /** @type {?} */ declaration = parsedRule.declarations[j]; - rule['style'] = declaration.property[declaration.value]; - rule['style'].cssText += declaration.property + ': ' + declaration.value + ';'; - } - } - else if (parsedRule.type == 'media') { - rule['type'] = 4; - rule['media'] = { mediaText: parsedRule.media }; - if (parsedRule.rules) { - rule['cssRules'] = this._buildRules(parsedRule.rules); - } - } - rules.push(rule); + function (value, oldUrl) { + var _this = this; + if (this.hash === value) { + // Don't fire events if the hash has not changed. + return; } - return rules; + (/** @type {?} */ (this)).hash = value; + var /** @type {?} */ newUrl = this.url; + scheduleMicroTask(function () { return _this._hashUpdate.next(/** @type {?} */ ({ type: 'hashchange', oldUrl: oldUrl, newUrl: newUrl })); }); }; /** + * @param {?} state + * @param {?} title + * @param {?} newUrl * @return {?} */ - Parse5DomAdapter.prototype.supportsDOMEvents = function () { return false; }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.supportsNativeShadowDOM = function () { return false; }; - /** - * @param {?} doc - * @param {?} target - * @return {?} - */ - Parse5DomAdapter.prototype.getGlobalEventTarget = function (doc, target) { - if (target == 'window') { - return ((doc))._window; - } - else if (target == 'document') { - return doc; - } - else if (target == 'body') { - return doc.body; - } - }; - /** - * @param {?} doc + ServerPlatformLocation.prototype.replaceState = /** + * @param {?} state + * @param {?} title + * @param {?} newUrl * @return {?} */ - Parse5DomAdapter.prototype.getBaseHref = function (doc) { - var /** @type {?} */ base = this.querySelector(doc, 'base'); - var /** @type {?} */ href = ''; - if (base) { - href = this.getHref(base); - } - // TODO(alxhub): Need relative path logic from BrowserDomAdapter here? - return href == null ? null : href; + function (state, title, newUrl) { + var /** @type {?} */ oldUrl = this.url; + var /** @type {?} */ parsedUrl = parseUrl(newUrl); + (/** @type {?} */ (this)).pathname = parsedUrl.pathname; + (/** @type {?} */ (this)).search = parsedUrl.search; + this.setHash(parsedUrl.hash, oldUrl); }; /** + * @param {?} state + * @param {?} title + * @param {?} newUrl * @return {?} */ - Parse5DomAdapter.prototype.resetBaseElement = function () { throw 'not implemented'; }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.getHistory = function () { throw 'not implemented'; }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.getLocation = function () { throw 'not implemented'; }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.getUserAgent = function () { return 'Fake user agent'; }; - /** - * @param {?} el - * @param {?} name - * @return {?} - */ - Parse5DomAdapter.prototype.getData = function (el, name) { return this.getAttribute(el, 'data-' + name); }; - /** - * @param {?} el - * @return {?} - */ - Parse5DomAdapter.prototype.getComputedStyle = function (el) { throw 'not implemented'; }; - /** - * @param {?} el - * @param {?} name - * @param {?} value - * @return {?} - */ - Parse5DomAdapter.prototype.setData = function (el, name, value) { this.setAttribute(el, 'data-' + name, value); }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.supportsWebAnimation = function () { return false; }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.performanceNow = function () { return Date.now(); }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.getAnimationPrefix = function () { return ''; }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.getTransitionEnd = function () { return 'transitionend'; }; - /** - * @return {?} - */ - Parse5DomAdapter.prototype.supportsAnimation = function () { return true; }; - /** - * @param {?} el - * @param {?} newNode - * @param {?} oldNode - * @return {?} - */ - Parse5DomAdapter.prototype.replaceChild = function (el, newNode, oldNode) { throw new Error('not implemented'); }; - /** - * @param {?} templateHtml - * @return {?} - */ - Parse5DomAdapter.prototype.parse = function (templateHtml) { throw new Error('not implemented'); }; - /** - * @param {?} el - * @param {?} methodName - * @param {?} args - * @return {?} - */ - Parse5DomAdapter.prototype.invoke = function (el, methodName, args) { throw new Error('not implemented'); }; - /** - * @param {?} event - * @return {?} - */ - Parse5DomAdapter.prototype.getEventKey = function (event) { throw new Error('not implemented'); }; - /** + ServerPlatformLocation.prototype.pushState = /** + * @param {?} state + * @param {?} title + * @param {?} newUrl * @return {?} */ - Parse5DomAdapter.prototype.supportsCookies = function () { return false; }; + function (state, title, newUrl) { + this.replaceState(state, title, newUrl); + }; /** - * @param {?} name * @return {?} */ - Parse5DomAdapter.prototype.getCookie = function (name) { throw new Error('not implemented'); }; - /** - * @param {?} name - * @param {?} value + ServerPlatformLocation.prototype.forward = /** * @return {?} */ - Parse5DomAdapter.prototype.setCookie = function (name, value) { throw new Error('not implemented'); }; + function () { throw new Error('Not implemented'); }; /** - * @param {?} element - * @param {?} keyframes - * @param {?} options * @return {?} */ - Parse5DomAdapter.prototype.animate = function (element, keyframes, options) { throw new Error('not implemented'); }; - /** - * @param {?} doc + ServerPlatformLocation.prototype.back = /** * @return {?} */ - Parse5DomAdapter.prototype.getTitleNode = function (doc) { - var /** @type {?} */ title = this.querySelector(doc, 'title'); - if (!title) { - title = (this.createElement('title')); - this.appendChild(this.querySelector(doc, 'head'), title); - } - return title; - }; - return Parse5DomAdapter; -}(_angular_platformBrowser.ɵDomAdapter)); -// TODO: build a proper list, this one is all the keys of a HTMLInputElement -var _HTMLElementPropertyList = [ - 'webkitEntries', - 'incremental', - 'webkitdirectory', - 'selectionDirection', - 'selectionEnd', - 'selectionStart', - 'labels', - 'validationMessage', - 'validity', - 'willValidate', - 'width', - 'valueAsNumber', - 'valueAsDate', - 'value', - 'useMap', - 'defaultValue', - 'type', - 'step', - 'src', - 'size', - 'required', - 'readOnly', - 'placeholder', - 'pattern', - 'name', - 'multiple', - 'min', - 'minLength', - 'maxLength', - 'max', - 'list', - 'indeterminate', - 'height', - 'formTarget', - 'formNoValidate', - 'formMethod', - 'formEnctype', - 'formAction', - 'files', - 'form', - 'disabled', - 'dirName', - 'checked', - 'defaultChecked', - 'autofocus', - 'autocomplete', - 'alt', - 'align', - 'accept', - 'onautocompleteerror', - 'onautocomplete', - 'onwaiting', - 'onvolumechange', - 'ontoggle', - 'ontimeupdate', - 'onsuspend', - 'onsubmit', - 'onstalled', - 'onshow', - 'onselect', - 'onseeking', - 'onseeked', - 'onscroll', - 'onresize', - 'onreset', - 'onratechange', - 'onprogress', - 'onplaying', - 'onplay', - 'onpause', - 'onmousewheel', - 'onmouseup', - 'onmouseover', - 'onmouseout', - 'onmousemove', - 'onmouseleave', - 'onmouseenter', - 'onmousedown', - 'onloadstart', - 'onloadedmetadata', - 'onloadeddata', - 'onload', - 'onkeyup', - 'onkeypress', - 'onkeydown', - 'oninvalid', - 'oninput', - 'onfocus', - 'onerror', - 'onended', - 'onemptied', - 'ondurationchange', - 'ondrop', - 'ondragstart', - 'ondragover', - 'ondragleave', - 'ondragenter', - 'ondragend', - 'ondrag', - 'ondblclick', - 'oncuechange', - 'oncontextmenu', - 'onclose', - 'onclick', - 'onchange', - 'oncanplaythrough', - 'oncanplay', - 'oncancel', - 'onblur', - 'onabort', - 'spellcheck', - 'isContentEditable', - 'contentEditable', - 'outerText', - 'innerText', - 'accessKey', - 'hidden', - 'webkitdropzone', - 'draggable', - 'tabIndex', - 'dir', - 'translate', - 'lang', - 'title', - 'childElementCount', - 'lastElementChild', - 'firstElementChild', - 'children', - 'onwebkitfullscreenerror', - 'onwebkitfullscreenchange', - 'nextElementSibling', - 'previousElementSibling', - 'onwheel', - 'onselectstart', - 'onsearch', - 'onpaste', - 'oncut', - 'oncopy', - 'onbeforepaste', - 'onbeforecut', - 'onbeforecopy', - 'shadowRoot', - 'dataset', - 'classList', - 'className', - 'outerHTML', - 'innerHTML', - 'scrollHeight', - 'scrollWidth', - 'scrollTop', - 'scrollLeft', - 'clientHeight', - 'clientWidth', - 'clientTop', - 'clientLeft', - 'offsetParent', - 'offsetHeight', - 'offsetWidth', - 'offsetTop', - 'offsetLeft', - 'localName', - 'prefix', - 'namespaceURI', - 'id', - 'style', - 'attributes', - 'tagName', - 'parentElement', - 'textContent', - 'baseURI', - 'ownerDocument', - 'nextSibling', - 'previousSibling', - 'lastChild', - 'firstChild', - 'childNodes', - 'parentNode', - 'nodeType', - 'nodeValue', - 'nodeName', - 'closure_lm_714617', - '__jsaction', -]; + function () { throw new Error('Not implemented'); }; + ServerPlatformLocation.decorators = [ + { type: _angular_core.Injectable }, + ]; + /** @nocollapse */ + ServerPlatformLocation.ctorParameters = function () { return [ + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, + { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [INITIAL_CONFIG,] },] }, + ]; }; + return ServerPlatformLocation; +}()); /** - * @template T - * @param {?} list - * @param {?} el + * @param {?} fn * @return {?} */ -function remove(list, el) { - var /** @type {?} */ index = list.indexOf(el); - if (index > -1) { - list.splice(index, 1); - } +function scheduleMicroTask(fn) { + Zone.current.scheduleMicroTask('scheduleMicrotask', fn); } + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6196,11 +14721,6 @@ function remove(list, el) { */ var EMPTY_ARRAY = []; var ServerRendererFactory2 = (function () { - /** - * @param {?} ngZone - * @param {?} document - * @param {?} sharedStylesHost - */ function ServerRendererFactory2(ngZone, document, sharedStylesHost) { this.ngZone = ngZone; this.document = document; @@ -6209,13 +14729,17 @@ var ServerRendererFactory2 = (function () { this.schema = new _angular_compiler.DomElementSchemaRegistry(); this.defaultRenderer = new DefaultServerRenderer2(document, ngZone, this.schema); } - /** * @param {?} element * @param {?} type * @return {?} */ - ServerRendererFactory2.prototype.createRenderer = function (element, type) { + ServerRendererFactory2.prototype.createRenderer = /** + * @param {?} element + * @param {?} type + * @return {?} + */ + function (element, type) { if (!element || !type) { return this.defaultRenderer; } @@ -6227,7 +14751,7 @@ var ServerRendererFactory2 = (function () { renderer = new EmulatedEncapsulationServerRenderer2(this.document, this.ngZone, this.sharedStylesHost, this.schema, type); this.rendererByCompId.set(type.id, renderer); } - ((renderer)).applyToHost(element); + (/** @type {?} */ (renderer)).applyToHost(element); return renderer; } case _angular_core.ViewEncapsulation.Native: @@ -6245,30 +14769,29 @@ var ServerRendererFactory2 = (function () { /** * @return {?} */ - ServerRendererFactory2.prototype.begin = function () { }; + ServerRendererFactory2.prototype.begin = /** + * @return {?} + */ + function () { }; /** * @return {?} */ - ServerRendererFactory2.prototype.end = function () { }; + ServerRendererFactory2.prototype.end = /** + * @return {?} + */ + function () { }; + ServerRendererFactory2.decorators = [ + { type: _angular_core.Injectable }, + ]; + /** @nocollapse */ + ServerRendererFactory2.ctorParameters = function () { return [ + { type: _angular_core.NgZone, }, + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, + { type: _angular_platformBrowser.ɵSharedStylesHost, }, + ]; }; return ServerRendererFactory2; }()); -ServerRendererFactory2.decorators = [ - { type: _angular_core.Injectable }, -]; -/** - * @nocollapse - */ -ServerRendererFactory2.ctorParameters = function () { return [ - { type: _angular_core.NgZone, }, - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, - { type: _angular_platformBrowser.ɵSharedStylesHost, }, -]; }; var DefaultServerRenderer2 = (function () { - /** - * @param {?} document - * @param {?} ngZone - * @param {?} schema - */ function DefaultServerRenderer2(document, ngZone, schema) { this.document = document; this.ngZone = ngZone; @@ -6278,14 +14801,23 @@ var DefaultServerRenderer2 = (function () { /** * @return {?} */ - DefaultServerRenderer2.prototype.destroy = function () { }; + DefaultServerRenderer2.prototype.destroy = /** + * @return {?} + */ + function () { }; /** * @param {?} name * @param {?=} namespace * @param {?=} debugInfo * @return {?} */ - DefaultServerRenderer2.prototype.createElement = function (name, namespace, debugInfo) { + DefaultServerRenderer2.prototype.createElement = /** + * @param {?} name + * @param {?=} namespace + * @param {?=} debugInfo + * @return {?} + */ + function (name, namespace, debugInfo) { if (namespace) { return _angular_platformBrowser.ɵgetDOM().createElementNS(_angular_platformBrowser.ɵNAMESPACE_URIS[namespace], name); } @@ -6296,26 +14828,47 @@ var DefaultServerRenderer2 = (function () { * @param {?=} debugInfo * @return {?} */ - DefaultServerRenderer2.prototype.createComment = function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createComment(value); }; - /** + DefaultServerRenderer2.prototype.createComment = /** * @param {?} value * @param {?=} debugInfo * @return {?} */ - DefaultServerRenderer2.prototype.createText = function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createTextNode(value); }; + function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createComment(value); }; /** - * @param {?} parent - * @param {?} newChild + * @param {?} value + * @param {?=} debugInfo + * @return {?} + */ + DefaultServerRenderer2.prototype.createText = /** + * @param {?} value + * @param {?=} debugInfo + * @return {?} + */ + function (value, debugInfo) { return _angular_platformBrowser.ɵgetDOM().createTextNode(value); }; + /** + * @param {?} parent + * @param {?} newChild + * @return {?} + */ + DefaultServerRenderer2.prototype.appendChild = /** + * @param {?} parent + * @param {?} newChild * @return {?} */ - DefaultServerRenderer2.prototype.appendChild = function (parent, newChild) { _angular_platformBrowser.ɵgetDOM().appendChild(parent, newChild); }; + function (parent, newChild) { _angular_platformBrowser.ɵgetDOM().appendChild(parent, newChild); }; /** * @param {?} parent * @param {?} newChild * @param {?} refChild * @return {?} */ - DefaultServerRenderer2.prototype.insertBefore = function (parent, newChild, refChild) { + DefaultServerRenderer2.prototype.insertBefore = /** + * @param {?} parent + * @param {?} newChild + * @param {?} refChild + * @return {?} + */ + function (parent, newChild, refChild) { if (parent) { _angular_platformBrowser.ɵgetDOM().insertBefore(parent, refChild, newChild); } @@ -6325,7 +14878,12 @@ var DefaultServerRenderer2 = (function () { * @param {?} oldChild * @return {?} */ - DefaultServerRenderer2.prototype.removeChild = function (parent, oldChild) { + DefaultServerRenderer2.prototype.removeChild = /** + * @param {?} parent + * @param {?} oldChild + * @return {?} + */ + function (parent, oldChild) { if (parent) { _angular_platformBrowser.ɵgetDOM().removeChild(parent, oldChild); } @@ -6335,7 +14893,12 @@ var DefaultServerRenderer2 = (function () { * @param {?=} debugInfo * @return {?} */ - DefaultServerRenderer2.prototype.selectRootElement = function (selectorOrNode, debugInfo) { + DefaultServerRenderer2.prototype.selectRootElement = /** + * @param {?} selectorOrNode + * @param {?=} debugInfo + * @return {?} + */ + function (selectorOrNode, debugInfo) { var /** @type {?} */ el; if (typeof selectorOrNode === 'string') { el = _angular_platformBrowser.ɵgetDOM().querySelector(this.document, selectorOrNode); @@ -6353,12 +14916,20 @@ var DefaultServerRenderer2 = (function () { * @param {?} node * @return {?} */ - DefaultServerRenderer2.prototype.parentNode = function (node) { return _angular_platformBrowser.ɵgetDOM().parentElement(node); }; + DefaultServerRenderer2.prototype.parentNode = /** + * @param {?} node + * @return {?} + */ + function (node) { return _angular_platformBrowser.ɵgetDOM().parentElement(node); }; /** * @param {?} node * @return {?} */ - DefaultServerRenderer2.prototype.nextSibling = function (node) { return _angular_platformBrowser.ɵgetDOM().nextSibling(node); }; + DefaultServerRenderer2.prototype.nextSibling = /** + * @param {?} node + * @return {?} + */ + function (node) { return _angular_platformBrowser.ɵgetDOM().nextSibling(node); }; /** * @param {?} el * @param {?} name @@ -6366,7 +14937,14 @@ var DefaultServerRenderer2 = (function () { * @param {?=} namespace * @return {?} */ - DefaultServerRenderer2.prototype.setAttribute = function (el, name, value, namespace) { + DefaultServerRenderer2.prototype.setAttribute = /** + * @param {?} el + * @param {?} name + * @param {?} value + * @param {?=} namespace + * @return {?} + */ + function (el, name, value, namespace) { if (namespace) { _angular_platformBrowser.ɵgetDOM().setAttributeNS(el, _angular_platformBrowser.ɵNAMESPACE_URIS[namespace], namespace + ':' + name, value); } @@ -6380,7 +14958,13 @@ var DefaultServerRenderer2 = (function () { * @param {?=} namespace * @return {?} */ - DefaultServerRenderer2.prototype.removeAttribute = function (el, name, namespace) { + DefaultServerRenderer2.prototype.removeAttribute = /** + * @param {?} el + * @param {?} name + * @param {?=} namespace + * @return {?} + */ + function (el, name, namespace) { if (namespace) { _angular_platformBrowser.ɵgetDOM().removeAttributeNS(el, _angular_platformBrowser.ɵNAMESPACE_URIS[namespace], name); } @@ -6393,13 +14977,23 @@ var DefaultServerRenderer2 = (function () { * @param {?} name * @return {?} */ - DefaultServerRenderer2.prototype.addClass = function (el, name) { _angular_platformBrowser.ɵgetDOM().addClass(el, name); }; + DefaultServerRenderer2.prototype.addClass = /** + * @param {?} el + * @param {?} name + * @return {?} + */ + function (el, name) { _angular_platformBrowser.ɵgetDOM().addClass(el, name); }; /** * @param {?} el * @param {?} name * @return {?} */ - DefaultServerRenderer2.prototype.removeClass = function (el, name) { _angular_platformBrowser.ɵgetDOM().removeClass(el, name); }; + DefaultServerRenderer2.prototype.removeClass = /** + * @param {?} el + * @param {?} name + * @return {?} + */ + function (el, name) { _angular_platformBrowser.ɵgetDOM().removeClass(el, name); }; /** * @param {?} el * @param {?} style @@ -6407,7 +15001,14 @@ var DefaultServerRenderer2 = (function () { * @param {?} flags * @return {?} */ - DefaultServerRenderer2.prototype.setStyle = function (el, style, value, flags) { + DefaultServerRenderer2.prototype.setStyle = /** + * @param {?} el + * @param {?} style + * @param {?} value + * @param {?} flags + * @return {?} + */ + function (el, style, value, flags) { _angular_platformBrowser.ɵgetDOM().setStyle(el, style, value); }; /** @@ -6416,7 +15017,13 @@ var DefaultServerRenderer2 = (function () { * @param {?} flags * @return {?} */ - DefaultServerRenderer2.prototype.removeStyle = function (el, style, flags) { + DefaultServerRenderer2.prototype.removeStyle = /** + * @param {?} el + * @param {?} style + * @param {?} flags + * @return {?} + */ + function (el, style, flags) { _angular_platformBrowser.ɵgetDOM().removeStyle(el, style); }; /** @@ -6424,7 +15031,12 @@ var DefaultServerRenderer2 = (function () { * @param {?} propertyName * @return {?} */ - DefaultServerRenderer2.prototype._isSafeToReflectProperty = function (tagName, propertyName) { + DefaultServerRenderer2.prototype._isSafeToReflectProperty = /** + * @param {?} tagName + * @param {?} propertyName + * @return {?} + */ + function (tagName, propertyName) { return this.schema.securityContext(tagName, propertyName, true) === this.schema.securityContext(tagName, propertyName, false); }; @@ -6434,11 +15046,17 @@ var DefaultServerRenderer2 = (function () { * @param {?} value * @return {?} */ - DefaultServerRenderer2.prototype.setProperty = function (el, name, value) { + DefaultServerRenderer2.prototype.setProperty = /** + * @param {?} el + * @param {?} name + * @param {?} value + * @return {?} + */ + function (el, name, value) { checkNoSyntheticProp(name, 'property'); _angular_platformBrowser.ɵgetDOM().setProperty(el, name, value); // Mirror property values for known HTML element properties in the attributes. - var /** @type {?} */ tagName = ((el.tagName)).toLowerCase(); + var /** @type {?} */ tagName = (/** @type {?} */ (el.tagName)).toLowerCase(); if (value != null && (typeof value === 'number' || typeof value == 'string') && this.schema.hasElement(tagName, EMPTY_ARRAY) && this.schema.hasProperty(tagName, name, EMPTY_ARRAY) && @@ -6451,21 +15069,32 @@ var DefaultServerRenderer2 = (function () { * @param {?} value * @return {?} */ - DefaultServerRenderer2.prototype.setValue = function (node, value) { _angular_platformBrowser.ɵgetDOM().setText(node, value); }; + DefaultServerRenderer2.prototype.setValue = /** + * @param {?} node + * @param {?} value + * @return {?} + */ + function (node, value) { _angular_platformBrowser.ɵgetDOM().setText(node, value); }; /** * @param {?} target * @param {?} eventName * @param {?} callback * @return {?} */ - DefaultServerRenderer2.prototype.listen = function (target, eventName, callback) { + DefaultServerRenderer2.prototype.listen = /** + * @param {?} target + * @param {?} eventName + * @param {?} callback + * @return {?} + */ + function (target, eventName, callback) { var _this = this; // Note: We are not using the EventsPlugin here as this is not needed // to run our tests. checkNoSyntheticProp(eventName, 'listener'); var /** @type {?} */ el = typeof target === 'string' ? _angular_platformBrowser.ɵgetDOM().getGlobalEventTarget(this.document, target) : target; var /** @type {?} */ outsideHandler = function (event) { return _this.ngZone.runGuarded(function () { return callback(event); }); }; - return this.ngZone.runOutsideAngular(function () { return _angular_platformBrowser.ɵgetDOM().onAndCancel(el, eventName, outsideHandler); }); + return this.ngZone.runOutsideAngular(function () { return /** @type {?} */ (_angular_platformBrowser.ɵgetDOM().onAndCancel(el, eventName, outsideHandler)); }); }; return DefaultServerRenderer2; }()); @@ -6482,17 +15111,10 @@ function checkNoSyntheticProp(name, nameKind) { } var EmulatedEncapsulationServerRenderer2 = (function (_super) { __extends(EmulatedEncapsulationServerRenderer2, _super); - /** - * @param {?} document - * @param {?} ngZone - * @param {?} sharedStylesHost - * @param {?} schema - * @param {?} component - */ function EmulatedEncapsulationServerRenderer2(document, ngZone, sharedStylesHost, schema, component) { var _this = _super.call(this, document, ngZone, schema) || this; _this.component = component; - var styles = _angular_platformBrowser.ɵflattenStyles(component.id, component.styles, []); + var /** @type {?} */ styles = _angular_platformBrowser.ɵflattenStyles(component.id, component.styles, []); sharedStylesHost.addStyles(styles); _this.contentAttr = _angular_platformBrowser.ɵshimContentAttribute(component.id); _this.hostAttr = _angular_platformBrowser.ɵshimHostAttribute(component.id); @@ -6502,19 +15124,33 @@ var EmulatedEncapsulationServerRenderer2 = (function (_super) { * @param {?} element * @return {?} */ - EmulatedEncapsulationServerRenderer2.prototype.applyToHost = function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); }; + EmulatedEncapsulationServerRenderer2.prototype.applyToHost = /** + * @param {?} element + * @return {?} + */ + function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); }; /** * @param {?} parent * @param {?} name * @return {?} */ - EmulatedEncapsulationServerRenderer2.prototype.createElement = function (parent, name) { + EmulatedEncapsulationServerRenderer2.prototype.createElement = /** + * @param {?} parent + * @param {?} name + * @return {?} + */ + function (parent, name) { var /** @type {?} */ el = _super.prototype.createElement.call(this, parent, name); _super.prototype.setAttribute.call(this, el, this.contentAttr, ''); return el; }; return EmulatedEncapsulationServerRenderer2; }(DefaultServerRenderer2)); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6524,10 +15160,6 @@ var EmulatedEncapsulationServerRenderer2 = (function (_super) { */ var ServerStylesHost = (function (_super) { __extends(ServerStylesHost, _super); - /** - * @param {?} doc - * @param {?} transitionId - */ function ServerStylesHost(doc, transitionId) { var _this = _super.call(this) || this; _this.doc = doc; @@ -6540,8 +15172,12 @@ var ServerStylesHost = (function (_super) { * @param {?} style * @return {?} */ - ServerStylesHost.prototype._addStyle = function (style) { - var /** @type {?} */ adapter = (_angular_platformBrowser.ɵgetDOM()); + ServerStylesHost.prototype._addStyle = /** + * @param {?} style + * @return {?} + */ + function (style) { + var /** @type {?} */ adapter = _angular_platformBrowser.ɵgetDOM(); var /** @type {?} */ el = adapter.createElement('style'); adapter.setText(el, style); if (!!this.transitionId) { @@ -6553,22 +15189,29 @@ var ServerStylesHost = (function (_super) { * @param {?} additions * @return {?} */ - ServerStylesHost.prototype.onStylesAdded = function (additions) { + ServerStylesHost.prototype.onStylesAdded = /** + * @param {?} additions + * @return {?} + */ + function (additions) { var _this = this; additions.forEach(function (style) { return _this._addStyle(style); }); }; + ServerStylesHost.decorators = [ + { type: _angular_core.Injectable }, + ]; + /** @nocollapse */ + ServerStylesHost.ctorParameters = function () { return [ + { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, + { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [_angular_platformBrowser.ɵTRANSITION_ID,] },] }, + ]; }; return ServerStylesHost; }(_angular_platformBrowser.ɵSharedStylesHost)); -ServerStylesHost.decorators = [ - { type: _angular_core.Injectable }, -]; + /** - * @nocollapse + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ -ServerStylesHost.ctorParameters = function () { return [ - { type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_platformBrowser.DOCUMENT,] },] }, - { type: undefined, decorators: [{ type: _angular_core.Optional }, { type: _angular_core.Inject, args: [_angular_platformBrowser.ɵTRANSITION_ID,] },] }, -]; }; /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6579,8 +15222,12 @@ ServerStylesHost.ctorParameters = function () { return [ var INTERNAL_SERVER_PLATFORM_PROVIDERS = [ { provide: _angular_platformBrowser.DOCUMENT, useFactory: _document, deps: [_angular_core.Injector] }, { provide: _angular_core.PLATFORM_ID, useValue: _angular_common.ɵPLATFORM_SERVER_ID }, - { provide: _angular_core.PLATFORM_INITIALIZER, useFactory: initParse5Adapter, multi: true, deps: [_angular_core.Injector] }, - { provide: _angular_common.PlatformLocation, useClass: ServerPlatformLocation }, PlatformState, + { provide: _angular_core.PLATFORM_INITIALIZER, useFactory: initDominoAdapter, multi: true, deps: [_angular_core.Injector] }, { + provide: _angular_common.PlatformLocation, + useClass: ServerPlatformLocation, + deps: [_angular_platformBrowser.DOCUMENT, [_angular_core.Optional, INITIAL_CONFIG]] + }, + { provide: PlatformState, deps: [_angular_platformBrowser.DOCUMENT] }, // Add special provider that allows multiple instances of platformServer* to be created. { provide: _angular_core.ɵALLOW_MULTIPLE_PLATFORMS, useValue: true } ]; @@ -6588,8 +15235,8 @@ var INTERNAL_SERVER_PLATFORM_PROVIDERS = [ * @param {?} injector * @return {?} */ -function initParse5Adapter(injector) { - return function () { Parse5DomAdapter.makeCurrent(); }; +function initDominoAdapter(injector) { + return function () { DominoAdapter.makeCurrent(); }; } /** * @param {?} renderer @@ -6618,23 +15265,21 @@ var SERVER_RENDER_PROVIDERS = [ var ServerModule = (function () { function ServerModule() { } + ServerModule.decorators = [ + { type: _angular_core.NgModule, args: [{ + exports: [_angular_platformBrowser.BrowserModule], + imports: [_angular_http.HttpModule, _angular_common_http.HttpClientModule, _angular_platformBrowser_animations.NoopAnimationsModule], + providers: [ + SERVER_RENDER_PROVIDERS, + SERVER_HTTP_PROVIDERS, + { provide: _angular_core.Testability, useValue: null }, + ], + },] }, + ]; + /** @nocollapse */ + ServerModule.ctorParameters = function () { return []; }; return ServerModule; }()); -ServerModule.decorators = [ - { type: _angular_core.NgModule, args: [{ - exports: [_angular_platformBrowser.BrowserModule], - imports: [_angular_http.HttpModule, _angular_platformBrowser_animations.NoopAnimationsModule], - providers: [ - SERVER_RENDER_PROVIDERS, - SERVER_HTTP_PROVIDERS, - { provide: _angular_core.Testability, useValue: null }, - ], - },] }, -]; -/** - * @nocollapse - */ -ServerModule.ctorParameters = function () { return []; }; /** * @param {?} injector * @return {?} @@ -6642,7 +15287,7 @@ ServerModule.ctorParameters = function () { return []; }; function _document(injector) { var /** @type {?} */ config = injector.get(INITIAL_CONFIG, null); if (config && config.document) { - return parseDocument(config.document); + return parseDocument(config.document, config.url); } else { return _angular_platformBrowser.ɵgetDOM().createHtmlDocument(); @@ -6657,7 +15302,64 @@ var platformServer = _angular_core.createPlatformFactory(_angular_core.platformC * * \@experimental */ -var platformDynamicServer = _angular_core.createPlatformFactory(_angular_compiler.platformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS); +var platformDynamicServer = _angular_core.createPlatformFactory(_angular_platformBrowserDynamic.ɵplatformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +/** + * @param {?} doc + * @param {?} appId + * @param {?} transferStore + * @return {?} + */ +function serializeTransferStateFactory(doc, appId, transferStore) { + return function () { + var /** @type {?} */ script = doc.createElement('script'); + script.id = appId + '-state'; + script.setAttribute('type', 'application/json'); + script.textContent = _angular_platformBrowser.ɵescapeHtml(transferStore.toJson()); + doc.body.appendChild(script); + }; +} +/** + * NgModule to install on the server side while using the `TransferState` to transfer state from + * server to client. + * + * \@experimental + */ +var ServerTransferStateModule = (function () { + function ServerTransferStateModule() { + } + ServerTransferStateModule.decorators = [ + { type: _angular_core.NgModule, args: [{ + providers: [ + _angular_platformBrowser.TransferState, { + provide: BEFORE_APP_SERIALIZED, + useFactory: serializeTransferStateFactory, + deps: [_angular_platformBrowser.DOCUMENT, _angular_core.APP_ID, _angular_platformBrowser.TransferState], + multi: true, + } + ] + },] }, + ]; + /** @nocollapse */ + ServerTransferStateModule.ctorParameters = function () { return []; }; + return ServerTransferStateModule; +}()); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6665,7 +15367,6 @@ var platformDynamicServer = _angular_core.createPlatformFactory(_angular_compile * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -var parse5$2 = __webpack_require__(35); /** * @param {?} platformFactory * @param {?} options @@ -6694,7 +15395,22 @@ function _render(platform, moduleRefPromise) { return rxjs_operator_toPromise.toPromise .call(rxjs_operator_first.first.call(rxjs_operator_filter.filter.call(applicationRef.isStable, function (isStable) { return isStable; }))) .then(function () { - var /** @type {?} */ output = platform.injector.get(PlatformState).renderToString(); + var /** @type {?} */ platformState = platform.injector.get(PlatformState); + // Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string. + var /** @type {?} */ callbacks = moduleRef.injector.get(BEFORE_APP_SERIALIZED, null); + if (callbacks) { + for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) { + var callback = callbacks_1[_i]; + try { + callback(); + } + catch (/** @type {?} */ e) { + // Ignore exceptions. + console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e); + } + } + } + var /** @type {?} */ output = platformState.renderToString(); platform.destroy(); return output; }); @@ -6703,8 +15419,12 @@ function _render(platform, moduleRefPromise) { /** * Renders a Module to string. * + * `document` is the full document HTML of the page to render, as a string. + * `url` is the URL for the current render request. + * `extraProviders` are the platform level providers for the current render request. + * * Do not use this in a production server environment. Use pre-compiled {\@link NgModuleFactory} with - * {link renderModuleFactory} instead. + * {\@link renderModuleFactory} instead. * * \@experimental * @template T @@ -6719,6 +15439,10 @@ function renderModule(module, options) { /** * Renders a {\@link NgModuleFactory} to string. * + * `document` is the full document HTML of the page to render, as a string. + * `url` is the URL for the current render request. + * `extraProviders` are the platform level providers for the current render request. + * * \@experimental * @template T * @param {?} moduleFactory @@ -6729,6 +15453,11 @@ function renderModuleFactory(moduleFactory, options) { var /** @type {?} */ platform = _getPlatform(platformServer, options); return _render(platform, platform.bootstrapModuleFactory(moduleFactory)); } + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6736,6 +15465,11 @@ function renderModuleFactory(moduleFactory, options) { * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6751,25 +15485,29 @@ function renderModuleFactory(moduleFactory, options) { /** * \@stable */ -var VERSION = new _angular_core.Version('4.2.5'); +var VERSION = new _angular_core.Version('5.0.1'); exports.PlatformState = PlatformState; exports.ServerModule = ServerModule; exports.platformDynamicServer = platformDynamicServer; exports.platformServer = platformServer; +exports.BEFORE_APP_SERIALIZED = BEFORE_APP_SERIALIZED; exports.INITIAL_CONFIG = INITIAL_CONFIG; +exports.ServerTransferStateModule = ServerTransferStateModule; exports.renderModule = renderModule; exports.renderModuleFactory = renderModuleFactory; exports.VERSION = VERSION; exports.ɵINTERNAL_SERVER_PLATFORM_PROVIDERS = INTERNAL_SERVER_PLATFORM_PROVIDERS; exports.ɵSERVER_RENDER_PROVIDERS = SERVER_RENDER_PROVIDERS; exports.ɵServerRendererFactory2 = ServerRendererFactory2; -exports.ɵf = SERVER_HTTP_PROVIDERS; -exports.ɵc = ServerXhr; -exports.ɵd = ServerXsrfStrategy; -exports.ɵe = httpFactory; +exports.ɵh = SERVER_HTTP_PROVIDERS; +exports.ɵd = ServerXhr; +exports.ɵe = ServerXsrfStrategy; +exports.ɵf = httpFactory; +exports.ɵg = zoneWrappedInterceptingHandler; exports.ɵa = instantiateServerRendererFactory; -exports.ɵb = ServerStylesHost; +exports.ɵc = ServerStylesHost; +exports.ɵb = serializeTransferStateFactory; Object.defineProperty(exports, '__esModule', { value: true }); @@ -6778,29 +15516,18 @@ Object.defineProperty(exports, '__esModule', { value: true }); /***/ }), -/* 45 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - -var Observable_1 = __webpack_require__(0); -var first_1 = __webpack_require__(86); -Observable_1.Observable.prototype.first = first_1.first; -//# sourceMappingURL=first.js.map - -/***/ }), -/* 46 */ +/* 26 */ /***/ (function(module, exports, __webpack_require__) { /** - * @license Angular v4.2.5 + * @license Angular v5.0.1 * (c) 2010-2017 Google, Inc. https://angular.io/ * License: MIT */ (function (global, factory) { - true ? factory(exports, __webpack_require__(82)) : - typeof define === 'function' && define.amd ? define(['exports', '@angular/animations'], factory) : - (factory((global.ng = global.ng || {}, global.ng.animations = global.ng.animations || {}, global.ng.animations.browser = global.ng.animations.browser || {}),global.ng.animations)); + true ? factory(exports, __webpack_require__(51)) : + typeof define === 'function' && define.amd ? define('@angular/animations/browser', ['exports', '@angular/animations'], factory) : + (factory((global.ng = global.ng || {}, global.ng.animations = global.ng.animations || {}, global.ng.animations.browser = {}),global.ng.animations)); }(this, (function (exports,_angular_animations) { 'use strict'; /*! ***************************************************************************** @@ -6827,13 +15554,25 @@ function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} +} + +var __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; +}; /** - * @license Angular v4.2.5 + * @license Angular v5.0.1 * (c) 2010-2017 Google, Inc. https://angular.io/ * License: MIT */ +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6841,6 +15580,10 @@ function __extends(d, b) { * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ +/** + * @param {?} players + * @return {?} + */ function optimizeGroupPlayer(players) { switch (players.length) { case 0: @@ -6851,29 +15594,43 @@ function optimizeGroupPlayer(players) { return new _angular_animations.ɵAnimationGroupPlayer(players); } } +/** + * @param {?} driver + * @param {?} normalizer + * @param {?} element + * @param {?} keyframes + * @param {?=} preStyles + * @param {?=} postStyles + * @return {?} + */ function normalizeKeyframes(driver, normalizer, element, keyframes, preStyles, postStyles) { if (preStyles === void 0) { preStyles = {}; } if (postStyles === void 0) { postStyles = {}; } - var errors = []; - var normalizedKeyframes = []; - var previousOffset = -1; - var previousKeyframe = null; + var /** @type {?} */ errors = []; + var /** @type {?} */ normalizedKeyframes = []; + var /** @type {?} */ previousOffset = -1; + var /** @type {?} */ previousKeyframe = null; keyframes.forEach(function (kf) { - var offset = kf['offset']; - var isSameOffset = offset == previousOffset; - var normalizedKeyframe = (isSameOffset && previousKeyframe) || {}; + var /** @type {?} */ offset = /** @type {?} */ (kf['offset']); + var /** @type {?} */ isSameOffset = offset == previousOffset; + var /** @type {?} */ normalizedKeyframe = (isSameOffset && previousKeyframe) || {}; Object.keys(kf).forEach(function (prop) { - var normalizedProp = prop; - var normalizedValue = kf[prop]; - if (normalizedValue == _angular_animations.ɵPRE_STYLE) { - normalizedValue = preStyles[prop]; - } - else if (normalizedValue == _angular_animations.AUTO_STYLE) { - normalizedValue = postStyles[prop]; - } - else if (prop != 'offset') { - normalizedProp = normalizer.normalizePropertyName(prop, errors); - normalizedValue = normalizer.normalizeStyleValue(prop, normalizedProp, kf[prop], errors); + var /** @type {?} */ normalizedProp = prop; + var /** @type {?} */ normalizedValue = kf[prop]; + if (prop !== 'offset') { + normalizedProp = normalizer.normalizePropertyName(normalizedProp, errors); + switch (normalizedValue) { + case _angular_animations.ɵPRE_STYLE: + normalizedValue = preStyles[prop]; + break; + case _angular_animations.AUTO_STYLE: + normalizedValue = postStyles[prop]; + break; + default: + normalizedValue = + normalizer.normalizeStyleValue(prop, normalizedProp, normalizedValue, errors); + break; + } } normalizedKeyframe[normalizedProp] = normalizedValue; }); @@ -6884,11 +15641,18 @@ function normalizeKeyframes(driver, normalizer, element, keyframes, preStyles, p previousOffset = offset; }); if (errors.length) { - var LINE_START = '\n - '; + var /** @type {?} */ LINE_START = '\n - '; throw new Error("Unable to animate due to the following errors:" + LINE_START + errors.join(LINE_START)); } return normalizedKeyframes; } +/** + * @param {?} player + * @param {?} eventName + * @param {?} event + * @param {?} callback + * @return {?} + */ function listenOnPlayer(player, eventName, event, callback) { switch (eventName) { case 'start': @@ -6902,21 +15666,42 @@ function listenOnPlayer(player, eventName, event, callback) { break; } } +/** + * @param {?} e + * @param {?=} phaseName + * @param {?=} totalTime + * @return {?} + */ function copyAnimationEvent(e, phaseName, totalTime) { - var event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == undefined ? e.totalTime : totalTime); - var data = e['_data']; + var /** @type {?} */ event = makeAnimationEvent(e.element, e.triggerName, e.fromState, e.toState, phaseName || e.phaseName, totalTime == undefined ? e.totalTime : totalTime); + var /** @type {?} */ data = (/** @type {?} */ (e))['_data']; if (data != null) { - event['_data'] = data; + (/** @type {?} */ (event))['_data'] = data; } return event; } +/** + * @param {?} element + * @param {?} triggerName + * @param {?} fromState + * @param {?} toState + * @param {?=} phaseName + * @param {?=} totalTime + * @return {?} + */ function makeAnimationEvent(element, triggerName, fromState, toState, phaseName, totalTime) { if (phaseName === void 0) { phaseName = ''; } if (totalTime === void 0) { totalTime = 0; } return { element: element, triggerName: triggerName, fromState: fromState, toState: toState, phaseName: phaseName, totalTime: totalTime }; } +/** + * @param {?} map + * @param {?} key + * @param {?} defaultValue + * @return {?} + */ function getOrSetAsInMap(map, key, defaultValue) { - var value; + var /** @type {?} */ value; if (map instanceof Map) { value = map.get(key); if (!value) { @@ -6931,38 +15716,44 @@ function getOrSetAsInMap(map, key, defaultValue) { } return value; } +/** + * @param {?} command + * @return {?} + */ function parseTimelineCommand(command) { - var separatorPos = command.indexOf(':'); - var id = command.substring(1, separatorPos); - var action = command.substr(separatorPos + 1); + var /** @type {?} */ separatorPos = command.indexOf(':'); + var /** @type {?} */ id = command.substring(1, separatorPos); + var /** @type {?} */ action = command.substr(separatorPos + 1); return [id, action]; } var _contains = function (elm1, elm2) { return false; }; -var _matches = function (element, selector) { return false; }; +var _matches = function (element, selector) { + return false; +}; var _query = function (element, selector, multi) { return []; }; if (typeof Element != 'undefined') { // this is well supported in all browsers - _contains = function (elm1, elm2) { return elm1.contains(elm2); }; + _contains = function (elm1, elm2) { return /** @type {?} */ (elm1.contains(elm2)); }; if (Element.prototype.matches) { _matches = function (element, selector) { return element.matches(selector); }; } else { - var proto = Element.prototype; - var fn_1 = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || + var /** @type {?} */ proto = /** @type {?} */ (Element.prototype); + var /** @type {?} */ fn_1 = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; if (fn_1) { _matches = function (element, selector) { return fn_1.apply(element, [selector]); }; } } _query = function (element, selector, multi) { - var results = []; + var /** @type {?} */ results = []; if (multi) { results.push.apply(results, element.querySelectorAll(selector)); } else { - var elm = element.querySelector(selector); + var /** @type {?} */ elm = element.querySelector(selector); if (elm) { results.push(elm); } @@ -6970,9 +15761,34 @@ if (typeof Element != 'undefined') { return results; }; } +var _CACHED_BODY = null; +/** + * @param {?} prop + * @return {?} + */ +function validateStyleProperty(prop) { + if (!_CACHED_BODY) { + _CACHED_BODY = getBodyNode() || {}; + } + return /** @type {?} */ ((_CACHED_BODY)).style ? prop in /** @type {?} */ ((_CACHED_BODY)).style : true; +} +/** + * @return {?} + */ +function getBodyNode() { + if (typeof document != 'undefined') { + return document.body; + } + return null; +} var matchesElement = _matches; var containsElement = _contains; var invokeQuery = _query; + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -6981,36 +15797,113 @@ var invokeQuery = _query; * found in the LICENSE file at https://angular.io/license */ /** - * @experimental + * \@experimental */ var NoopAnimationDriver = (function () { function NoopAnimationDriver() { } - NoopAnimationDriver.prototype.matchesElement = function (element, selector) { + /** + * @param {?} prop + * @return {?} + */ + NoopAnimationDriver.prototype.validateStyleProperty = /** + * @param {?} prop + * @return {?} + */ + function (prop) { return validateStyleProperty(prop); }; + /** + * @param {?} element + * @param {?} selector + * @return {?} + */ + NoopAnimationDriver.prototype.matchesElement = /** + * @param {?} element + * @param {?} selector + * @return {?} + */ + function (element, selector) { return matchesElement(element, selector); }; - NoopAnimationDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); }; - NoopAnimationDriver.prototype.query = function (element, selector, multi) { - return invokeQuery(element, selector, multi); - }; - NoopAnimationDriver.prototype.computeStyle = function (element, prop, defaultValue) { - return defaultValue || ''; - }; - NoopAnimationDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) { - if (previousPlayers === void 0) { previousPlayers = []; } - return new _angular_animations.NoopAnimationPlayer(); - }; - return NoopAnimationDriver; -}()); -/** - * @experimental - */ -var AnimationDriver = (function () { - function AnimationDriver() { - } + /** + * @param {?} elm1 + * @param {?} elm2 + * @return {?} + */ + NoopAnimationDriver.prototype.containsElement = /** + * @param {?} elm1 + * @param {?} elm2 + * @return {?} + */ + function (elm1, elm2) { return containsElement(elm1, elm2); }; + /** + * @param {?} element + * @param {?} selector + * @param {?} multi + * @return {?} + */ + NoopAnimationDriver.prototype.query = /** + * @param {?} element + * @param {?} selector + * @param {?} multi + * @return {?} + */ + function (element, selector, multi) { + return invokeQuery(element, selector, multi); + }; + /** + * @param {?} element + * @param {?} prop + * @param {?=} defaultValue + * @return {?} + */ + NoopAnimationDriver.prototype.computeStyle = /** + * @param {?} element + * @param {?} prop + * @param {?=} defaultValue + * @return {?} + */ + function (element, prop, defaultValue) { + return defaultValue || ''; + }; + /** + * @param {?} element + * @param {?} keyframes + * @param {?} duration + * @param {?} delay + * @param {?} easing + * @param {?=} previousPlayers + * @return {?} + */ + NoopAnimationDriver.prototype.animate = /** + * @param {?} element + * @param {?} keyframes + * @param {?} duration + * @param {?} delay + * @param {?} easing + * @param {?=} previousPlayers + * @return {?} + */ + function (element, keyframes, duration, delay, easing, previousPlayers) { + if (previousPlayers === void 0) { previousPlayers = []; } + return new _angular_animations.NoopAnimationPlayer(); + }; + return NoopAnimationDriver; +}()); +/** + * \@experimental + * @abstract + */ +var AnimationDriver = (function () { + function AnimationDriver() { + } + AnimationDriver.NOOP = new NoopAnimationDriver(); return AnimationDriver; }()); -AnimationDriver.NOOP = new NoopAnimationDriver(); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -7019,6 +15912,8 @@ AnimationDriver.NOOP = new NoopAnimationDriver(); * found in the LICENSE file at https://angular.io/license */ var ONE_SECOND = 1000; +var SUBSTITUTION_EXPR_START = '{{'; +var SUBSTITUTION_EXPR_END = '}}'; var ENTER_CLASSNAME = 'ng-enter'; var LEAVE_CLASSNAME = 'ng-leave'; var ENTER_SELECTOR = '.ng-enter'; @@ -7034,7 +15929,7 @@ var NG_ANIMATING_SELECTOR = '.ng-animating'; function resolveTimingValue(value) { if (typeof value == 'number') return value; - var /** @type {?} */ matches = ((value)).match(/^(-?[\.\d]+)(m?s)/); + var /** @type {?} */ matches = (/** @type {?} */ (value)).match(/^(-?[\.\d]+)(m?s)/); if (!matches || matches.length < 2) return 0; return _convertTimeValueToMS(parseFloat(matches[1]), matches[2]); @@ -7049,6 +15944,7 @@ function _convertTimeValueToMS(value, unit) { case 's': return value * ONE_SECOND; default: + // ms or something else return value; } } @@ -7059,7 +15955,7 @@ function _convertTimeValueToMS(value, unit) { * @return {?} */ function resolveTiming(timings, errors, allowNegativeValues) { - return timings.hasOwnProperty('duration') ? (timings) : + return timings.hasOwnProperty('duration') ? /** @type {?} */ (timings) : parseTimeExpression(/** @type {?} */ (timings), errors, allowNegativeValues); } /** @@ -7090,7 +15986,7 @@ function parseTimeExpression(exp, errors, allowNegativeValues) { } } else { - duration = (exp); + duration = /** @type {?} */ (exp); } if (!allowNegativeValues) { var /** @type {?} */ containsErrors = false; @@ -7190,7 +16086,7 @@ function normalizeAnimationEntry(steps) { return steps[0]; return _angular_animations.sequence(steps); } - return (steps); + return /** @type {?} */ (steps); } /** * @param {?} value @@ -7200,10 +16096,8 @@ function normalizeAnimationEntry(steps) { */ function validateStyleParams(value, options, errors) { var /** @type {?} */ params = options.params || {}; - if (typeof value !== 'string') - return; - var /** @type {?} */ matches = value.toString().match(PARAM_REGEX); - if (matches) { + var /** @type {?} */ matches = extractStyleParams(value); + if (matches.length) { matches.forEach(function (varName) { if (!params.hasOwnProperty(varName)) { errors.push("Unable to resolve the local animation param " + varName + " in the given list of values"); @@ -7211,7 +16105,23 @@ function validateStyleParams(value, options, errors) { }); } } -var PARAM_REGEX = /\{\{\s*(.+?)\s*\}\}/g; +var PARAM_REGEX = new RegExp(SUBSTITUTION_EXPR_START + "\\s*(.+?)\\s*" + SUBSTITUTION_EXPR_END, 'g'); +/** + * @param {?} value + * @return {?} + */ +function extractStyleParams(value) { + var /** @type {?} */ params = []; + if (typeof value === 'string') { + var /** @type {?} */ val = value.toString(); + var /** @type {?} */ match = void 0; + while (match = PARAM_REGEX.exec(val)) { + params.push(/** @type {?} */ (match[1])); + } + PARAM_REGEX.lastIndex = 0; + } + return params; +} /** * @param {?} value * @param {?} params @@ -7250,21 +16160,7 @@ function iteratorToArray(iterator) { * @param {?} destination * @return {?} */ -function mergeAnimationOptions(source, destination) { - if (source.params) { - var /** @type {?} */ p0_1 = source.params; - if (!destination.params) { - destination.params = {}; - } - var /** @type {?} */ p1_1 = destination.params; - Object.keys(p0_1).forEach(function (param) { - if (!p1_1.hasOwnProperty(param)) { - p1_1[param] = p0_1[param]; - } - }); - } - return destination; -} + var DASH_CASE_REGEXP = /-+([a-z0-9])/g; /** * @param {?} input @@ -7279,6 +16175,57 @@ function dashCaseToCamelCase(input) { return m[1].toUpperCase(); }); } +/** + * @param {?} duration + * @param {?} delay + * @return {?} + */ +function allowPreviousPlayerStylesMerge(duration, delay) { + return duration === 0 || delay === 0; +} +/** + * @param {?} visitor + * @param {?} node + * @param {?} context + * @return {?} + */ +function visitDslNode(visitor, node, context) { + switch (node.type) { + case 7 /* Trigger */: + return visitor.visitTrigger(node, context); + case 0 /* State */: + return visitor.visitState(node, context); + case 1 /* Transition */: + return visitor.visitTransition(node, context); + case 2 /* Sequence */: + return visitor.visitSequence(node, context); + case 3 /* Group */: + return visitor.visitGroup(node, context); + case 4 /* Animate */: + return visitor.visitAnimate(node, context); + case 5 /* Keyframes */: + return visitor.visitKeyframes(node, context); + case 6 /* Style */: + return visitor.visitStyle(node, context); + case 8 /* Reference */: + return visitor.visitReference(node, context); + case 9 /* AnimateChild */: + return visitor.visitAnimateChild(node, context); + case 10 /* AnimateRef */: + return visitor.visitAnimateRef(node, context); + case 11 /* Query */: + return visitor.visitQuery(node, context); + case 12 /* Stagger */: + return visitor.visitStagger(node, context); + default: + throw new Error("Unable to resolve animation metadata node #" + node.type); + } +} + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -7286,844 +16233,647 @@ function dashCaseToCamelCase(input) { * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -var EMPTY_ANIMATION_OPTIONS = {}; +var ANY_STATE = '*'; /** - * @abstract + * @param {?} transitionValue + * @param {?} errors + * @return {?} + */ +function parseTransitionExpr(transitionValue, errors) { + var /** @type {?} */ expressions = []; + if (typeof transitionValue == 'string') { + (/** @type {?} */ (transitionValue)) + .split(/\s*,\s*/) + .forEach(function (str) { return parseInnerTransitionStr(str, expressions, errors); }); + } + else { + expressions.push(/** @type {?} */ (transitionValue)); + } + return expressions; +} +/** + * @param {?} eventStr + * @param {?} expressions + * @param {?} errors + * @return {?} + */ +function parseInnerTransitionStr(eventStr, expressions, errors) { + if (eventStr[0] == ':') { + var /** @type {?} */ result = parseAnimationAlias(eventStr, errors); + if (typeof result == 'function') { + expressions.push(result); + return; + } + eventStr = /** @type {?} */ (result); + } + var /** @type {?} */ match = eventStr.match(/^(\*|[-\w]+)\s*()\s*(\*|[-\w]+)$/); + if (match == null || match.length < 4) { + errors.push("The provided transition expression \"" + eventStr + "\" is not supported"); + return expressions; + } + var /** @type {?} */ fromState = match[1]; + var /** @type {?} */ separator = match[2]; + var /** @type {?} */ toState = match[3]; + expressions.push(makeLambdaFromStates(fromState, toState)); + var /** @type {?} */ isFullAnyStateExpr = fromState == ANY_STATE && toState == ANY_STATE; + if (separator[0] == '<' && !isFullAnyStateExpr) { + expressions.push(makeLambdaFromStates(toState, fromState)); + } +} +/** + * @param {?} alias + * @param {?} errors + * @return {?} + */ +function parseAnimationAlias(alias, errors) { + switch (alias) { + case ':enter': + return 'void => *'; + case ':leave': + return '* => void'; + case ':increment': + return function (fromState, toState) { return parseFloat(toState) > parseFloat(fromState); }; + case ':decrement': + return function (fromState, toState) { return parseFloat(toState) < parseFloat(fromState); }; + default: + errors.push("The transition alias value \"" + alias + "\" is not supported"); + return '* => *'; + } +} +var TRUE_BOOLEAN_VALUES = new Set(); +TRUE_BOOLEAN_VALUES.add('true'); +TRUE_BOOLEAN_VALUES.add('1'); +var FALSE_BOOLEAN_VALUES = new Set(); +FALSE_BOOLEAN_VALUES.add('false'); +FALSE_BOOLEAN_VALUES.add('0'); +/** + * @param {?} lhs + * @param {?} rhs + * @return {?} + */ +function makeLambdaFromStates(lhs, rhs) { + var /** @type {?} */ LHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(lhs) || FALSE_BOOLEAN_VALUES.has(lhs); + var /** @type {?} */ RHS_MATCH_BOOLEAN = TRUE_BOOLEAN_VALUES.has(rhs) || FALSE_BOOLEAN_VALUES.has(rhs); + return function (fromState, toState) { + var /** @type {?} */ lhsMatch = lhs == ANY_STATE || lhs == fromState; + var /** @type {?} */ rhsMatch = rhs == ANY_STATE || rhs == toState; + if (!lhsMatch && LHS_MATCH_BOOLEAN && typeof fromState === 'boolean') { + lhsMatch = fromState ? TRUE_BOOLEAN_VALUES.has(lhs) : FALSE_BOOLEAN_VALUES.has(lhs); + } + if (!rhsMatch && RHS_MATCH_BOOLEAN && typeof toState === 'boolean') { + rhsMatch = toState ? TRUE_BOOLEAN_VALUES.has(rhs) : FALSE_BOOLEAN_VALUES.has(rhs); + } + return lhsMatch && rhsMatch; + }; +} + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ +var SELF_TOKEN = ':self'; +var SELF_TOKEN_REGEX = new RegExp("s*" + SELF_TOKEN + "s*,?", 'g'); +/** + * @param {?} driver + * @param {?} metadata + * @param {?} errors + * @return {?} */ -var Ast = (function () { - function Ast() { - this.options = EMPTY_ANIMATION_OPTIONS; +function buildAnimationAst(driver, metadata, errors) { + return new AnimationAstBuilderVisitor(driver).build(metadata, errors); +} +var LEAVE_TOKEN = ':leave'; +var LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, 'g'); +var ENTER_TOKEN = ':enter'; +var ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, 'g'); +var ROOT_SELECTOR = ''; +var AnimationAstBuilderVisitor = (function () { + function AnimationAstBuilderVisitor(_driver) { + this._driver = _driver; } /** - * @abstract - * @param {?} ast - * @param {?} context + * @param {?} metadata + * @param {?} errors * @return {?} */ - Ast.prototype.visit = function (ast, context) { }; - Object.defineProperty(Ast.prototype, "params", { - /** - * @return {?} - */ - get: function () { return this.options['params'] || null; }, - enumerable: true, - configurable: true - }); - return Ast; -}()); -var TriggerAst = (function (_super) { - __extends(TriggerAst, _super); - /** - * @param {?} name - * @param {?} states - * @param {?} transitions + AnimationAstBuilderVisitor.prototype.build = /** + * @param {?} metadata + * @param {?} errors + * @return {?} */ - function TriggerAst(name, states, transitions) { - var _this = _super.call(this) || this; - _this.name = name; - _this.states = states; - _this.transitions = transitions; - _this.queryCount = 0; - _this.depCount = 0; - return _this; - } + function (metadata, errors) { + var /** @type {?} */ context = new AnimationAstBuilderContext(errors); + this._resetContextStyleTimingState(context); + return /** @type {?} */ (visitDslNode(this, normalizeAnimationEntry(metadata), context)); + }; /** - * @param {?} visitor * @param {?} context * @return {?} */ - TriggerAst.prototype.visit = function (visitor, context) { return visitor.visitTrigger(this, context); }; - return TriggerAst; -}(Ast)); -var StateAst = (function (_super) { - __extends(StateAst, _super); - /** - * @param {?} name - * @param {?} style - */ - function StateAst(name, style$$1) { - var _this = _super.call(this) || this; - _this.name = name; - _this.style = style$$1; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype._resetContextStyleTimingState = /** * @param {?} context * @return {?} */ - StateAst.prototype.visit = function (visitor, context) { return visitor.visitState(this, context); }; - return StateAst; -}(Ast)); -var TransitionAst = (function (_super) { - __extends(TransitionAst, _super); + function (context) { + context.currentQuerySelector = ROOT_SELECTOR; + context.collectedStyles = {}; + context.collectedStyles[ROOT_SELECTOR] = {}; + context.currentTime = 0; + }; /** - * @param {?} matchers - * @param {?} animation + * @param {?} metadata + * @param {?} context + * @return {?} */ - function TransitionAst(matchers, animation) { - var _this = _super.call(this) || this; - _this.matchers = matchers; - _this.animation = animation; - _this.queryCount = 0; - _this.depCount = 0; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype.visitTrigger = /** + * @param {?} metadata * @param {?} context * @return {?} */ - TransitionAst.prototype.visit = function (visitor, context) { return visitor.visitTransition(this, context); }; - return TransitionAst; -}(Ast)); -var SequenceAst = (function (_super) { - __extends(SequenceAst, _super); - /** - * @param {?} steps - */ - function SequenceAst(steps) { - var _this = _super.call(this) || this; - _this.steps = steps; - return _this; - } + function (metadata, context) { + var _this = this; + var /** @type {?} */ queryCount = context.queryCount = 0; + var /** @type {?} */ depCount = context.depCount = 0; + var /** @type {?} */ states = []; + var /** @type {?} */ transitions = []; + metadata.definitions.forEach(function (def) { + _this._resetContextStyleTimingState(context); + if (def.type == 0 /* State */) { + var /** @type {?} */ stateDef_1 = /** @type {?} */ (def); + var /** @type {?} */ name_1 = stateDef_1.name; + name_1.split(/\s*,\s*/).forEach(function (n) { + stateDef_1.name = n; + states.push(_this.visitState(stateDef_1, context)); + }); + stateDef_1.name = name_1; + } + else if (def.type == 1 /* Transition */) { + var /** @type {?} */ transition = _this.visitTransition(/** @type {?} */ (def), context); + queryCount += transition.queryCount; + depCount += transition.depCount; + transitions.push(transition); + } + else { + context.errors.push('only state() and transition() definitions can sit inside of a trigger()'); + } + }); + return { + type: 7 /* Trigger */, + name: metadata.name, states: states, transitions: transitions, queryCount: queryCount, depCount: depCount, + options: null + }; + }; /** - * @param {?} visitor + * @param {?} metadata * @param {?} context * @return {?} */ - SequenceAst.prototype.visit = function (visitor, context) { return visitor.visitSequence(this, context); }; - return SequenceAst; -}(Ast)); -var GroupAst = (function (_super) { - __extends(GroupAst, _super); - /** - * @param {?} steps - */ - function GroupAst(steps) { - var _this = _super.call(this) || this; - _this.steps = steps; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype.visitState = /** + * @param {?} metadata * @param {?} context * @return {?} */ - GroupAst.prototype.visit = function (visitor, context) { return visitor.visitGroup(this, context); }; - return GroupAst; -}(Ast)); -var AnimateAst = (function (_super) { - __extends(AnimateAst, _super); - /** - * @param {?} timings - * @param {?} style - */ - function AnimateAst(timings, style$$1) { - var _this = _super.call(this) || this; - _this.timings = timings; - _this.style = style$$1; - return _this; - } + function (metadata, context) { + var /** @type {?} */ styleAst = this.visitStyle(metadata.styles, context); + var /** @type {?} */ astParams = (metadata.options && metadata.options.params) || null; + if (styleAst.containsDynamicStyles) { + var /** @type {?} */ missingSubs_1 = new Set(); + var /** @type {?} */ params_1 = astParams || {}; + styleAst.styles.forEach(function (value) { + if (isObject(value)) { + var /** @type {?} */ stylesObj_1 = /** @type {?} */ (value); + Object.keys(stylesObj_1).forEach(function (prop) { + extractStyleParams(stylesObj_1[prop]).forEach(function (sub) { + if (!params_1.hasOwnProperty(sub)) { + missingSubs_1.add(sub); + } + }); + }); + } + }); + if (missingSubs_1.size) { + var /** @type {?} */ missingSubsArr = iteratorToArray(missingSubs_1.values()); + context.errors.push("state(\"" + metadata.name + "\", ...) must define default values for all the following style substitutions: " + missingSubsArr.join(', ')); + } + } + return { + type: 0 /* State */, + name: metadata.name, + style: styleAst, + options: astParams ? { params: astParams } : null + }; + }; /** - * @param {?} visitor + * @param {?} metadata * @param {?} context * @return {?} */ - AnimateAst.prototype.visit = function (visitor, context) { return visitor.visitAnimate(this, context); }; - return AnimateAst; -}(Ast)); -var StyleAst = (function (_super) { - __extends(StyleAst, _super); - /** - * @param {?} styles - * @param {?} easing - * @param {?} offset - */ - function StyleAst(styles, easing, offset) { - var _this = _super.call(this) || this; - _this.styles = styles; - _this.easing = easing; - _this.offset = offset; - _this.isEmptyStep = false; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype.visitTransition = /** + * @param {?} metadata * @param {?} context * @return {?} */ - StyleAst.prototype.visit = function (visitor, context) { return visitor.visitStyle(this, context); }; - return StyleAst; -}(Ast)); -var KeyframesAst = (function (_super) { - __extends(KeyframesAst, _super); - /** - * @param {?} styles - */ - function KeyframesAst(styles) { - var _this = _super.call(this) || this; - _this.styles = styles; - return _this; - } + function (metadata, context) { + context.queryCount = 0; + context.depCount = 0; + var /** @type {?} */ animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context); + var /** @type {?} */ matchers = parseTransitionExpr(metadata.expr, context.errors); + return { + type: 1 /* Transition */, + matchers: matchers, + animation: animation, + queryCount: context.queryCount, + depCount: context.depCount, + options: normalizeAnimationOptions(metadata.options) + }; + }; /** - * @param {?} visitor + * @param {?} metadata * @param {?} context * @return {?} */ - KeyframesAst.prototype.visit = function (visitor, context) { return visitor.visitKeyframes(this, context); }; - return KeyframesAst; -}(Ast)); -var ReferenceAst = (function (_super) { - __extends(ReferenceAst, _super); - /** - * @param {?} animation + AnimationAstBuilderVisitor.prototype.visitSequence = /** + * @param {?} metadata + * @param {?} context + * @return {?} */ - function ReferenceAst(animation) { - var _this = _super.call(this) || this; - _this.animation = animation; - return _this; - } + function (metadata, context) { + var _this = this; + return { + type: 2 /* Sequence */, + steps: metadata.steps.map(function (s) { return visitDslNode(_this, s, context); }), + options: normalizeAnimationOptions(metadata.options) + }; + }; /** - * @param {?} visitor + * @param {?} metadata * @param {?} context * @return {?} */ - ReferenceAst.prototype.visit = function (visitor, context) { return visitor.visitReference(this, context); }; - return ReferenceAst; -}(Ast)); -var AnimateChildAst = (function (_super) { - __extends(AnimateChildAst, _super); - function AnimateChildAst() { - return _super.call(this) || this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype.visitGroup = /** + * @param {?} metadata * @param {?} context * @return {?} */ - AnimateChildAst.prototype.visit = function (visitor, context) { return visitor.visitAnimateChild(this, context); }; - return AnimateChildAst; -}(Ast)); -var AnimateRefAst = (function (_super) { - __extends(AnimateRefAst, _super); + function (metadata, context) { + var _this = this; + var /** @type {?} */ currentTime = context.currentTime; + var /** @type {?} */ furthestTime = 0; + var /** @type {?} */ steps = metadata.steps.map(function (step) { + context.currentTime = currentTime; + var /** @type {?} */ innerAst = visitDslNode(_this, step, context); + furthestTime = Math.max(furthestTime, context.currentTime); + return innerAst; + }); + context.currentTime = furthestTime; + return { + type: 3 /* Group */, + steps: steps, + options: normalizeAnimationOptions(metadata.options) + }; + }; /** - * @param {?} animation + * @param {?} metadata + * @param {?} context + * @return {?} */ - function AnimateRefAst(animation) { - var _this = _super.call(this) || this; - _this.animation = animation; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype.visitAnimate = /** + * @param {?} metadata * @param {?} context * @return {?} */ - AnimateRefAst.prototype.visit = function (visitor, context) { return visitor.visitAnimateRef(this, context); }; - return AnimateRefAst; -}(Ast)); -var QueryAst = (function (_super) { - __extends(QueryAst, _super); + function (metadata, context) { + var /** @type {?} */ timingAst = constructTimingAst(metadata.timings, context.errors); + context.currentAnimateTimings = timingAst; + var /** @type {?} */ styleAst; + var /** @type {?} */ styleMetadata = metadata.styles ? metadata.styles : _angular_animations.style({}); + if (styleMetadata.type == 5 /* Keyframes */) { + styleAst = this.visitKeyframes(/** @type {?} */ (styleMetadata), context); + } + else { + var /** @type {?} */ styleMetadata_1 = /** @type {?} */ (metadata.styles); + var /** @type {?} */ isEmpty = false; + if (!styleMetadata_1) { + isEmpty = true; + var /** @type {?} */ newStyleData = {}; + if (timingAst.easing) { + newStyleData['easing'] = timingAst.easing; + } + styleMetadata_1 = _angular_animations.style(newStyleData); + } + context.currentTime += timingAst.duration + timingAst.delay; + var /** @type {?} */ _styleAst = this.visitStyle(styleMetadata_1, context); + _styleAst.isEmptyStep = isEmpty; + styleAst = _styleAst; + } + context.currentAnimateTimings = null; + return { + type: 4 /* Animate */, + timings: timingAst, + style: styleAst, + options: null + }; + }; /** - * @param {?} selector - * @param {?} limit - * @param {?} optional - * @param {?} includeSelf - * @param {?} animation + * @param {?} metadata + * @param {?} context + * @return {?} */ - function QueryAst(selector, limit, optional, includeSelf, animation) { - var _this = _super.call(this) || this; - _this.selector = selector; - _this.limit = limit; - _this.optional = optional; - _this.includeSelf = includeSelf; - _this.animation = animation; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype.visitStyle = /** + * @param {?} metadata * @param {?} context * @return {?} */ - QueryAst.prototype.visit = function (visitor, context) { return visitor.visitQuery(this, context); }; - return QueryAst; -}(Ast)); -var StaggerAst = (function (_super) { - __extends(StaggerAst, _super); + function (metadata, context) { + var /** @type {?} */ ast = this._makeStyleAst(metadata, context); + this._validateStyleAst(ast, context); + return ast; + }; /** - * @param {?} timings - * @param {?} animation + * @param {?} metadata + * @param {?} context + * @return {?} */ - function StaggerAst(timings, animation) { - var _this = _super.call(this) || this; - _this.timings = timings; - _this.animation = animation; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype._makeStyleAst = /** + * @param {?} metadata * @param {?} context * @return {?} */ - StaggerAst.prototype.visit = function (visitor, context) { return visitor.visitStagger(this, context); }; - return StaggerAst; -}(Ast)); -var TimingAst = (function (_super) { - __extends(TimingAst, _super); + function (metadata, context) { + var /** @type {?} */ styles = []; + if (Array.isArray(metadata.styles)) { + (/** @type {?} */ (metadata.styles)).forEach(function (styleTuple) { + if (typeof styleTuple == 'string') { + if (styleTuple == _angular_animations.AUTO_STYLE) { + styles.push(/** @type {?} */ (styleTuple)); + } + else { + context.errors.push("The provided style string value " + styleTuple + " is not allowed."); + } + } + else { + styles.push(/** @type {?} */ (styleTuple)); + } + }); + } + else { + styles.push(metadata.styles); + } + var /** @type {?} */ containsDynamicStyles = false; + var /** @type {?} */ collectedEasing = null; + styles.forEach(function (styleData) { + if (isObject(styleData)) { + var /** @type {?} */ styleMap = /** @type {?} */ (styleData); + var /** @type {?} */ easing = styleMap['easing']; + if (easing) { + collectedEasing = /** @type {?} */ (easing); + delete styleMap['easing']; + } + if (!containsDynamicStyles) { + for (var /** @type {?} */ prop in styleMap) { + var /** @type {?} */ value = styleMap[prop]; + if (value.toString().indexOf(SUBSTITUTION_EXPR_START) >= 0) { + containsDynamicStyles = true; + break; + } + } + } + } + }); + return { + type: 6 /* Style */, + styles: styles, + easing: collectedEasing, + offset: metadata.offset, containsDynamicStyles: containsDynamicStyles, + options: null + }; + }; /** - * @param {?} duration - * @param {?=} delay - * @param {?=} easing + * @param {?} ast + * @param {?} context + * @return {?} */ - function TimingAst(duration, delay, easing) { - if (delay === void 0) { delay = 0; } - if (easing === void 0) { easing = null; } - var _this = _super.call(this) || this; - _this.duration = duration; - _this.delay = delay; - _this.easing = easing; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype._validateStyleAst = /** + * @param {?} ast * @param {?} context * @return {?} */ - TimingAst.prototype.visit = function (visitor, context) { return visitor.visitTiming(this, context); }; - return TimingAst; -}(Ast)); -var DynamicTimingAst = (function (_super) { - __extends(DynamicTimingAst, _super); + function (ast, context) { + var _this = this; + var /** @type {?} */ timings = context.currentAnimateTimings; + var /** @type {?} */ endTime = context.currentTime; + var /** @type {?} */ startTime = context.currentTime; + if (timings && startTime > 0) { + startTime -= timings.duration + timings.delay; + } + ast.styles.forEach(function (tuple) { + if (typeof tuple == 'string') + return; + Object.keys(tuple).forEach(function (prop) { + if (!_this._driver.validateStyleProperty(prop)) { + context.errors.push("The provided animation property \"" + prop + "\" is not a supported CSS property for animations"); + return; + } + var /** @type {?} */ collectedStyles = context.collectedStyles[/** @type {?} */ ((context.currentQuerySelector))]; + var /** @type {?} */ collectedEntry = collectedStyles[prop]; + var /** @type {?} */ updateCollectedStyle = true; + if (collectedEntry) { + if (startTime != endTime && startTime >= collectedEntry.startTime && + endTime <= collectedEntry.endTime) { + context.errors.push("The CSS property \"" + prop + "\" that exists between the times of \"" + collectedEntry.startTime + "ms\" and \"" + collectedEntry.endTime + "ms\" is also being animated in a parallel animation between the times of \"" + startTime + "ms\" and \"" + endTime + "ms\""); + updateCollectedStyle = false; + } + // we always choose the smaller start time value since we + // want to have a record of the entire animation window where + // the style property is being animated in between + startTime = collectedEntry.startTime; + } + if (updateCollectedStyle) { + collectedStyles[prop] = { startTime: startTime, endTime: endTime }; + } + if (context.options) { + validateStyleParams(tuple[prop], context.options, context.errors); + } + }); + }); + }; /** - * @param {?} value + * @param {?} metadata + * @param {?} context + * @return {?} */ - function DynamicTimingAst(value) { - var _this = _super.call(this, 0, 0, '') || this; - _this.value = value; - return _this; - } - /** - * @param {?} visitor + AnimationAstBuilderVisitor.prototype.visitKeyframes = /** + * @param {?} metadata * @param {?} context * @return {?} */ - DynamicTimingAst.prototype.visit = function (visitor, context) { return visitor.visitTiming(this, context); }; - return DynamicTimingAst; -}(TimingAst)); -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -/** - * @param {?} visitor - * @param {?} node - * @param {?} context - * @return {?} - */ -function visitAnimationNode(visitor, node, context) { - switch (node.type) { - case 7 /* Trigger */: - return visitor.visitTrigger(/** @type {?} */ (node), context); - case 0 /* State */: - return visitor.visitState(/** @type {?} */ (node), context); - case 1 /* Transition */: - return visitor.visitTransition(/** @type {?} */ (node), context); - case 2 /* Sequence */: - return visitor.visitSequence(/** @type {?} */ (node), context); - case 3 /* Group */: - return visitor.visitGroup(/** @type {?} */ (node), context); - case 4 /* Animate */: - return visitor.visitAnimate(/** @type {?} */ (node), context); - case 5 /* Keyframes */: - return visitor.visitKeyframes(/** @type {?} */ (node), context); - case 6 /* Style */: - return visitor.visitStyle(/** @type {?} */ (node), context); - case 8 /* Reference */: - return visitor.visitReference(/** @type {?} */ (node), context); - case 9 /* AnimateChild */: - return visitor.visitAnimateChild(/** @type {?} */ (node), context); - case 10 /* AnimateRef */: - return visitor.visitAnimateRef(/** @type {?} */ (node), context); - case 11 /* Query */: - return visitor.visitQuery(/** @type {?} */ (node), context); - case 12 /* Stagger */: - return visitor.visitStagger(/** @type {?} */ (node), context); - default: - throw new Error("Unable to resolve animation metadata node #" + node.type); - } -} -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -var ANY_STATE = '*'; -/** - * @param {?} transitionValue - * @param {?} errors - * @return {?} - */ -function parseTransitionExpr(transitionValue, errors) { - var /** @type {?} */ expressions = []; - if (typeof transitionValue == 'string') { - ((transitionValue)) - .split(/\s*,\s*/) - .forEach(function (str) { return parseInnerTransitionStr(str, expressions, errors); }); - } - else { - expressions.push(/** @type {?} */ (transitionValue)); - } - return expressions; -} -/** - * @param {?} eventStr - * @param {?} expressions - * @param {?} errors - * @return {?} - */ -function parseInnerTransitionStr(eventStr, expressions, errors) { - if (eventStr[0] == ':') { - eventStr = parseAnimationAlias(eventStr, errors); - } - var /** @type {?} */ match = eventStr.match(/^(\*|[-\w]+)\s*()\s*(\*|[-\w]+)$/); - if (match == null || match.length < 4) { - errors.push("The provided transition expression \"" + eventStr + "\" is not supported"); - return expressions; - } - var /** @type {?} */ fromState = match[1]; - var /** @type {?} */ separator = match[2]; - var /** @type {?} */ toState = match[3]; - expressions.push(makeLambdaFromStates(fromState, toState)); - var /** @type {?} */ isFullAnyStateExpr = fromState == ANY_STATE && toState == ANY_STATE; - if (separator[0] == '<' && !isFullAnyStateExpr) { - expressions.push(makeLambdaFromStates(toState, fromState)); - } -} -/** - * @param {?} alias - * @param {?} errors - * @return {?} - */ -function parseAnimationAlias(alias, errors) { - switch (alias) { - case ':enter': - return 'void => *'; - case ':leave': - return '* => void'; - default: - errors.push("The transition alias value \"" + alias + "\" is not supported"); - return '* => *'; - } -} -/** - * @param {?} lhs - * @param {?} rhs - * @return {?} - */ -function makeLambdaFromStates(lhs, rhs) { - return function (fromState, toState) { - var /** @type {?} */ lhsMatch = lhs == ANY_STATE || lhs == fromState; - var /** @type {?} */ rhsMatch = rhs == ANY_STATE || rhs == toState; - if (!lhsMatch && typeof fromState === 'boolean') { - lhsMatch = fromState ? lhs === 'true' : lhs === 'false'; + function (metadata, context) { + var _this = this; + var /** @type {?} */ ast = { type: 5 /* Keyframes */, styles: [], options: null }; + if (!context.currentAnimateTimings) { + context.errors.push("keyframes() must be placed inside of a call to animate()"); + return ast; + } + var /** @type {?} */ MAX_KEYFRAME_OFFSET = 1; + var /** @type {?} */ totalKeyframesWithOffsets = 0; + var /** @type {?} */ offsets = []; + var /** @type {?} */ offsetsOutOfOrder = false; + var /** @type {?} */ keyframesOutOfRange = false; + var /** @type {?} */ previousOffset = 0; + var /** @type {?} */ keyframes = metadata.steps.map(function (styles) { + var /** @type {?} */ style$$1 = _this._makeStyleAst(styles, context); + var /** @type {?} */ offsetVal = style$$1.offset != null ? style$$1.offset : consumeOffset(style$$1.styles); + var /** @type {?} */ offset = 0; + if (offsetVal != null) { + totalKeyframesWithOffsets++; + offset = style$$1.offset = offsetVal; + } + keyframesOutOfRange = keyframesOutOfRange || offset < 0 || offset > 1; + offsetsOutOfOrder = offsetsOutOfOrder || offset < previousOffset; + previousOffset = offset; + offsets.push(offset); + return style$$1; + }); + if (keyframesOutOfRange) { + context.errors.push("Please ensure that all keyframe offsets are between 0 and 1"); } - if (!rhsMatch && typeof toState === 'boolean') { - rhsMatch = toState ? rhs === 'true' : rhs === 'false'; + if (offsetsOutOfOrder) { + context.errors.push("Please ensure that all keyframe offsets are in order"); } - return lhsMatch && rhsMatch; + var /** @type {?} */ length = metadata.steps.length; + var /** @type {?} */ generatedOffset = 0; + if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) { + context.errors.push("Not all style() steps within the declared keyframes() contain offsets"); + } + else if (totalKeyframesWithOffsets == 0) { + generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1); + } + var /** @type {?} */ limit = length - 1; + var /** @type {?} */ currentTime = context.currentTime; + var /** @type {?} */ currentAnimateTimings = /** @type {?} */ ((context.currentAnimateTimings)); + var /** @type {?} */ animateDuration = currentAnimateTimings.duration; + keyframes.forEach(function (kf, i) { + var /** @type {?} */ offset = generatedOffset > 0 ? (i == limit ? 1 : (generatedOffset * i)) : offsets[i]; + var /** @type {?} */ durationUpToThisFrame = offset * animateDuration; + context.currentTime = currentTime + currentAnimateTimings.delay + durationUpToThisFrame; + currentAnimateTimings.duration = durationUpToThisFrame; + _this._validateStyleAst(kf, context); + kf.offset = offset; + ast.styles.push(kf); + }); + return ast; }; -} -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -var SELF_TOKEN = ':self'; -var SELF_TOKEN_REGEX = new RegExp("s*" + SELF_TOKEN + "s*,?", 'g'); -/** - * @param {?} metadata - * @param {?} errors - * @return {?} - */ -function buildAnimationAst(metadata, errors) { - return new AnimationAstBuilderVisitor().build(metadata, errors); -} -var LEAVE_TOKEN = ':leave'; -var LEAVE_TOKEN_REGEX = new RegExp(LEAVE_TOKEN, 'g'); -var ENTER_TOKEN = ':enter'; -var ENTER_TOKEN_REGEX = new RegExp(ENTER_TOKEN, 'g'); -var ROOT_SELECTOR = ''; -var AnimationAstBuilderVisitor = (function () { - function AnimationAstBuilderVisitor() { - } /** * @param {?} metadata - * @param {?} errors + * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.build = function (metadata, errors) { - var /** @type {?} */ context = new AnimationAstBuilderContext(errors); - this._resetContextStyleTimingState(context); - return (visitAnimationNode(this, normalizeAnimationEntry(metadata), context)); - }; - /** + AnimationAstBuilderVisitor.prototype.visitReference = /** + * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype._resetContextStyleTimingState = function (context) { - context.currentQuerySelector = ROOT_SELECTOR; - context.collectedStyles = {}; - context.collectedStyles[ROOT_SELECTOR] = {}; - context.currentTime = 0; + function (metadata, context) { + return { + type: 8 /* Reference */, + animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context), + options: normalizeAnimationOptions(metadata.options) + }; }; /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitTrigger = function (metadata, context) { - var _this = this; - var /** @type {?} */ queryCount = context.queryCount = 0; - var /** @type {?} */ depCount = context.depCount = 0; - var /** @type {?} */ states = []; - var /** @type {?} */ transitions = []; - metadata.definitions.forEach(function (def) { - _this._resetContextStyleTimingState(context); - if (def.type == 0 /* State */) { - var /** @type {?} */ stateDef_1 = (def); - var /** @type {?} */ name = stateDef_1.name; - name.split(/\s*,\s*/).forEach(function (n) { - stateDef_1.name = n; - states.push(_this.visitState(stateDef_1, context)); - }); - stateDef_1.name = name; - } - else if (def.type == 1 /* Transition */) { - var /** @type {?} */ transition = _this.visitTransition(/** @type {?} */ (def), context); - queryCount += transition.queryCount; - depCount += transition.depCount; - transitions.push(transition); - } - else { - context.errors.push('only state() and transition() definitions can sit inside of a trigger()'); - } - }); - var /** @type {?} */ ast = new TriggerAst(metadata.name, states, transitions); - ast.options = normalizeAnimationOptions(metadata.options); - ast.queryCount = queryCount; - ast.depCount = depCount; - return ast; - }; - /** + AnimationAstBuilderVisitor.prototype.visitAnimateChild = /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitState = function (metadata, context) { - return new StateAst(metadata.name, this.visitStyle(metadata.styles, context)); + function (metadata, context) { + context.depCount++; + return { + type: 9 /* AnimateChild */, + options: normalizeAnimationOptions(metadata.options) + }; }; /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitTransition = function (metadata, context) { - context.queryCount = 0; - context.depCount = 0; - var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - var /** @type {?} */ matchers = parseTransitionExpr(metadata.expr, context.errors); - var /** @type {?} */ ast = new TransitionAst(matchers, entry); - ast.options = normalizeAnimationOptions(metadata.options); - ast.queryCount = context.queryCount; - ast.depCount = context.depCount; - return ast; - }; - /** + AnimationAstBuilderVisitor.prototype.visitAnimateRef = /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitSequence = function (metadata, context) { - var _this = this; - var /** @type {?} */ ast = new SequenceAst(metadata.steps.map(function (s) { return visitAnimationNode(_this, s, context); })); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; + function (metadata, context) { + return { + type: 10 /* AnimateRef */, + animation: this.visitReference(metadata.animation, context), + options: normalizeAnimationOptions(metadata.options) + }; }; /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitGroup = function (metadata, context) { - var _this = this; - var /** @type {?} */ currentTime = context.currentTime; - var /** @type {?} */ furthestTime = 0; - var /** @type {?} */ steps = metadata.steps.map(function (step) { - context.currentTime = currentTime; - var /** @type {?} */ innerAst = visitAnimationNode(_this, step, context); - furthestTime = Math.max(furthestTime, context.currentTime); - return innerAst; - }); - context.currentTime = furthestTime; - var /** @type {?} */ ast = new GroupAst(steps); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; - /** + AnimationAstBuilderVisitor.prototype.visitQuery = /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitAnimate = function (metadata, context) { - var /** @type {?} */ timingAst = constructTimingAst(metadata.timings, context.errors); - context.currentAnimateTimings = timingAst; - var /** @type {?} */ styles; - var /** @type {?} */ styleMetadata = metadata.styles ? metadata.styles : _angular_animations.style({}); - if (styleMetadata.type == 5 /* Keyframes */) { - styles = this.visitKeyframes(/** @type {?} */ (styleMetadata), context); - } - else { - var /** @type {?} */ styleMetadata_1 = (metadata.styles); - var /** @type {?} */ isEmpty = false; - if (!styleMetadata_1) { - isEmpty = true; - var /** @type {?} */ newStyleData = {}; - if (timingAst.easing) { - newStyleData['easing'] = timingAst.easing; - } - styleMetadata_1 = _angular_animations.style(newStyleData); - } - context.currentTime += timingAst.duration + timingAst.delay; - var /** @type {?} */ styleAst = this.visitStyle(styleMetadata_1, context); - styleAst.isEmptyStep = isEmpty; - styles = styleAst; - } - context.currentAnimateTimings = null; - return new AnimateAst(timingAst, styles); + function (metadata, context) { + var /** @type {?} */ parentSelector = /** @type {?} */ ((context.currentQuerySelector)); + var /** @type {?} */ options = /** @type {?} */ ((metadata.options || {})); + context.queryCount++; + context.currentQuery = metadata; + var _a = normalizeSelector(metadata.selector), selector = _a[0], includeSelf = _a[1]; + context.currentQuerySelector = + parentSelector.length ? (parentSelector + ' ' + selector) : selector; + getOrSetAsInMap(context.collectedStyles, context.currentQuerySelector, {}); + var /** @type {?} */ animation = visitDslNode(this, normalizeAnimationEntry(metadata.animation), context); + context.currentQuery = null; + context.currentQuerySelector = parentSelector; + return { + type: 11 /* Query */, + selector: selector, + limit: options.limit || 0, + optional: !!options.optional, includeSelf: includeSelf, animation: animation, + originalSelector: metadata.selector, + options: normalizeAnimationOptions(metadata.options) + }; }; /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitStyle = function (metadata, context) { - var /** @type {?} */ ast = this._makeStyleAst(metadata, context); - this._validateStyleAst(ast, context); - return ast; - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype._makeStyleAst = function (metadata, context) { - var /** @type {?} */ styles = []; - if (Array.isArray(metadata.styles)) { - ((metadata.styles)).forEach(function (styleTuple) { - if (typeof styleTuple == 'string') { - if (styleTuple == _angular_animations.AUTO_STYLE) { - styles.push(/** @type {?} */ (styleTuple)); - } - else { - context.errors.push("The provided style string value " + styleTuple + " is not allowed."); - } - } - else { - styles.push(/** @type {?} */ (styleTuple)); - } - }); - } - else { - styles.push(metadata.styles); - } - var /** @type {?} */ collectedEasing = null; - styles.forEach(function (styleData) { - if (isObject(styleData)) { - var /** @type {?} */ styleMap = (styleData); - var /** @type {?} */ easing = styleMap['easing']; - if (easing) { - collectedEasing = (easing); - delete styleMap['easing']; - } - } - }); - return new StyleAst(styles, collectedEasing, metadata.offset); - }; - /** - * @param {?} ast - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype._validateStyleAst = function (ast, context) { - var /** @type {?} */ timings = context.currentAnimateTimings; - var /** @type {?} */ endTime = context.currentTime; - var /** @type {?} */ startTime = context.currentTime; - if (timings && startTime > 0) { - startTime -= timings.duration + timings.delay; - } - ast.styles.forEach(function (tuple) { - if (typeof tuple == 'string') - return; - Object.keys(tuple).forEach(function (prop) { - var /** @type {?} */ collectedStyles = context.collectedStyles[((context.currentQuerySelector))]; - var /** @type {?} */ collectedEntry = collectedStyles[prop]; - var /** @type {?} */ updateCollectedStyle = true; - if (collectedEntry) { - if (startTime != endTime && startTime >= collectedEntry.startTime && - endTime <= collectedEntry.endTime) { - context.errors.push("The CSS property \"" + prop + "\" that exists between the times of \"" + collectedEntry.startTime + "ms\" and \"" + collectedEntry.endTime + "ms\" is also being animated in a parallel animation between the times of \"" + startTime + "ms\" and \"" + endTime + "ms\""); - updateCollectedStyle = false; - } - // we always choose the smaller start time value since we - // want to have a record of the entire animation window where - // the style property is being animated in between - startTime = collectedEntry.startTime; - } - if (updateCollectedStyle) { - collectedStyles[prop] = { startTime: startTime, endTime: endTime }; - } - if (context.options) { - validateStyleParams(tuple[prop], context.options, context.errors); - } - }); - }); - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitKeyframes = function (metadata, context) { - var _this = this; - if (!context.currentAnimateTimings) { - context.errors.push("keyframes() must be placed inside of a call to animate()"); - return new KeyframesAst([]); - } - var /** @type {?} */ MAX_KEYFRAME_OFFSET = 1; - var /** @type {?} */ totalKeyframesWithOffsets = 0; - var /** @type {?} */ offsets = []; - var /** @type {?} */ offsetsOutOfOrder = false; - var /** @type {?} */ keyframesOutOfRange = false; - var /** @type {?} */ previousOffset = 0; - var /** @type {?} */ keyframes = metadata.steps.map(function (styles) { - var /** @type {?} */ style$$1 = _this._makeStyleAst(styles, context); - var /** @type {?} */ offsetVal = style$$1.offset != null ? style$$1.offset : consumeOffset(style$$1.styles); - var /** @type {?} */ offset = 0; - if (offsetVal != null) { - totalKeyframesWithOffsets++; - offset = style$$1.offset = offsetVal; - } - keyframesOutOfRange = keyframesOutOfRange || offset < 0 || offset > 1; - offsetsOutOfOrder = offsetsOutOfOrder || offset < previousOffset; - previousOffset = offset; - offsets.push(offset); - return style$$1; - }); - if (keyframesOutOfRange) { - context.errors.push("Please ensure that all keyframe offsets are between 0 and 1"); - } - if (offsetsOutOfOrder) { - context.errors.push("Please ensure that all keyframe offsets are in order"); - } - var /** @type {?} */ length = metadata.steps.length; - var /** @type {?} */ generatedOffset = 0; - if (totalKeyframesWithOffsets > 0 && totalKeyframesWithOffsets < length) { - context.errors.push("Not all style() steps within the declared keyframes() contain offsets"); - } - else if (totalKeyframesWithOffsets == 0) { - generatedOffset = MAX_KEYFRAME_OFFSET / (length - 1); - } - var /** @type {?} */ limit = length - 1; - var /** @type {?} */ currentTime = context.currentTime; - var /** @type {?} */ currentAnimateTimings = ((context.currentAnimateTimings)); - var /** @type {?} */ animateDuration = currentAnimateTimings.duration; - keyframes.forEach(function (kf, i) { - var /** @type {?} */ offset = generatedOffset > 0 ? (i == limit ? 1 : (generatedOffset * i)) : offsets[i]; - var /** @type {?} */ durationUpToThisFrame = offset * animateDuration; - context.currentTime = currentTime + currentAnimateTimings.delay + durationUpToThisFrame; - currentAnimateTimings.duration = durationUpToThisFrame; - _this._validateStyleAst(kf, context); - kf.offset = offset; - }); - return new KeyframesAst(keyframes); - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitReference = function (metadata, context) { - var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - var /** @type {?} */ ast = new ReferenceAst(entry); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitAnimateChild = function (metadata, context) { - context.depCount++; - var /** @type {?} */ ast = new AnimateChildAst(); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitAnimateRef = function (metadata, context) { - var /** @type {?} */ animation = this.visitReference(metadata.animation, context); - var /** @type {?} */ ast = new AnimateRefAst(animation); - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; - /** - * @param {?} metadata - * @param {?} context - * @return {?} - */ - AnimationAstBuilderVisitor.prototype.visitQuery = function (metadata, context) { - var /** @type {?} */ parentSelector = ((context.currentQuerySelector)); - var /** @type {?} */ options = ((metadata.options || {})); - context.queryCount++; - context.currentQuery = metadata; - var _a = normalizeSelector(metadata.selector), selector = _a[0], includeSelf = _a[1]; - context.currentQuerySelector = - parentSelector.length ? (parentSelector + ' ' + selector) : selector; - getOrSetAsInMap(context.collectedStyles, context.currentQuerySelector, {}); - var /** @type {?} */ entry = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - context.currentQuery = null; - context.currentQuerySelector = parentSelector; - var /** @type {?} */ ast = new QueryAst(selector, options.limit || 0, !!options.optional, includeSelf, entry); - ast.originalSelector = metadata.selector; - ast.options = normalizeAnimationOptions(metadata.options); - return ast; - }; - /** + AnimationAstBuilderVisitor.prototype.visitStagger = /** * @param {?} metadata * @param {?} context * @return {?} */ - AnimationAstBuilderVisitor.prototype.visitStagger = function (metadata, context) { + function (metadata, context) { if (!context.currentQuery) { context.errors.push("stagger() can only be used inside of query()"); } var /** @type {?} */ timings = metadata.timings === 'full' ? { duration: 0, delay: 0, easing: 'full' } : resolveTiming(metadata.timings, context.errors, true); - var /** @type {?} */ animation = visitAnimationNode(this, normalizeAnimationEntry(metadata.animation), context); - return new StaggerAst(timings, animation); + return { + type: 12 /* Stagger */, + animation: visitDslNode(this, normalizeAnimationEntry(metadata.animation), context), timings: timings, + options: null + }; }; return AnimationAstBuilderVisitor; }()); @@ -8151,9 +16901,6 @@ function normalizeParams(obj) { return obj ? copyObj(obj) : null; } var AnimationAstBuilderContext = (function () { - /** - * @param {?} errors - */ function AnimationAstBuilderContext(errors) { this.errors = errors; this.queryCount = 0; @@ -8179,14 +16926,14 @@ function consumeOffset(styles) { if (Array.isArray(styles)) { styles.forEach(function (styleTuple) { if (isObject(styleTuple) && styleTuple.hasOwnProperty('offset')) { - var /** @type {?} */ obj = (styleTuple); + var /** @type {?} */ obj = /** @type {?} */ (styleTuple); offset = parseFloat(/** @type {?} */ (obj['offset'])); delete obj['offset']; } }); } else if (isObject(styles) && styles.hasOwnProperty('offset')) { - var /** @type {?} */ obj = (styles); + var /** @type {?} */ obj = /** @type {?} */ (styles); offset = parseFloat(/** @type {?} */ (obj['offset'])); delete obj['offset']; } @@ -8207,19 +16954,22 @@ function isObject(value) { function constructTimingAst(value, errors) { var /** @type {?} */ timings = null; if (value.hasOwnProperty('duration')) { - timings = (value); + timings = /** @type {?} */ (value); } else if (typeof value == 'number') { var /** @type {?} */ duration = resolveTiming(/** @type {?} */ (value), errors).duration; - return new TimingAst(/** @type {?} */ (value), 0, ''); + return makeTimingAst(/** @type {?} */ (duration), 0, ''); } - var /** @type {?} */ strValue = (value); + var /** @type {?} */ strValue = /** @type {?} */ (value); var /** @type {?} */ isDynamic = strValue.split(/\s+/).some(function (v) { return v.charAt(0) == '{' && v.charAt(1) == '{'; }); if (isDynamic) { - return new DynamicTimingAst(strValue); + var /** @type {?} */ ast = /** @type {?} */ (makeTimingAst(0, 0, '')); + ast.dynamic = true; + ast.strValue = strValue; + return /** @type {?} */ (ast); } timings = timings || resolveTiming(strValue, errors); - return new TimingAst(timings.duration, timings.delay, timings.easing); + return makeTimingAst(timings.duration, timings.delay, timings.easing); } /** * @param {?} options @@ -8229,7 +16979,7 @@ function normalizeAnimationOptions(options) { if (options) { options = copyObj(options); if (options['params']) { - options['params'] = ((normalizeParams(options['params']))); + options['params'] = /** @type {?} */ ((normalizeParams(options['params']))); } } else { @@ -8238,12 +16988,23 @@ function normalizeAnimationOptions(options) { return options; } /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @param {?} duration + * @param {?} delay + * @param {?} easing + * @return {?} + */ +function makeTimingAst(duration, delay, easing) { + return { duration: duration, delay: delay, easing: easing }; +} + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @record */ + /** * @param {?} element * @param {?} keyframes @@ -8269,12 +17030,10 @@ function createTimelineInstruction(element, keyframes, preStyleProps, postStyleP totalTime: duration + delay, easing: easing, subTimeline: subTimeline }; } + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ var ElementInstructionMap = (function () { function ElementInstructionMap() { @@ -8284,7 +17043,11 @@ var ElementInstructionMap = (function () { * @param {?} element * @return {?} */ - ElementInstructionMap.prototype.consume = function (element) { + ElementInstructionMap.prototype.consume = /** + * @param {?} element + * @return {?} + */ + function (element) { var /** @type {?} */ instructions = this._map.get(element); if (instructions) { this._map.delete(element); @@ -8299,7 +17062,12 @@ var ElementInstructionMap = (function () { * @param {?} instructions * @return {?} */ - ElementInstructionMap.prototype.append = function (element, instructions) { + ElementInstructionMap.prototype.append = /** + * @param {?} element + * @param {?} instructions + * @return {?} + */ + function (element, instructions) { var /** @type {?} */ existingInstructions = this._map.get(element); if (!existingInstructions) { this._map.set(element, existingInstructions = []); @@ -8310,13 +17078,25 @@ var ElementInstructionMap = (function () { * @param {?} element * @return {?} */ - ElementInstructionMap.prototype.has = function (element) { return this._map.has(element); }; + ElementInstructionMap.prototype.has = /** + * @param {?} element + * @return {?} + */ + function (element) { return this._map.has(element); }; /** * @return {?} */ - ElementInstructionMap.prototype.clear = function () { this._map.clear(); }; + ElementInstructionMap.prototype.clear = /** + * @return {?} + */ + function () { this._map.clear(); }; return ElementInstructionMap; }()); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -8356,13 +17136,24 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?=} errors * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.buildKeyframes = function (driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors) { + AnimationTimelineBuilderVisitor.prototype.buildKeyframes = /** + * @param {?} driver + * @param {?} rootElement + * @param {?} ast + * @param {?} startingStyles + * @param {?} finalStyles + * @param {?} options + * @param {?=} subInstructions + * @param {?=} errors + * @return {?} + */ + function (driver, rootElement, ast, startingStyles, finalStyles, options, subInstructions, errors) { if (errors === void 0) { errors = []; } subInstructions = subInstructions || new ElementInstructionMap(); var /** @type {?} */ context = new AnimationTimelineContext(driver, rootElement, subInstructions, errors, []); context.options = options; context.currentTimeline.setStyles([startingStyles], null, context.errors, options); - ast.visit(this, context); + visitDslNode(this, ast, context); // this checks to see if an actual animation happened var /** @type {?} */ timelines = context.timelines.filter(function (timeline) { return timeline.containsAnimation(); }); if (timelines.length && Object.keys(finalStyles).length) { @@ -8379,7 +17170,12 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitTrigger = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitTrigger = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { // these values are not visited in this AST }; /** @@ -8387,7 +17183,12 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitState = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitState = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { // these values are not visited in this AST }; /** @@ -8395,7 +17196,12 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitTransition = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitTransition = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { // these values are not visited in this AST }; /** @@ -8403,7 +17209,12 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitAnimateChild = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitAnimateChild = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { var /** @type {?} */ elementInstructions = context.subInstructions.consume(context.element); if (elementInstructions) { var /** @type {?} */ innerContext = context.createSubContext(ast.options); @@ -8422,7 +17233,12 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitAnimateRef = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitAnimateRef = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { var /** @type {?} */ innerContext = context.createSubContext(ast.options); innerContext.transformIntoNewTimeline(); this.visitReference(ast.animation, innerContext); @@ -8435,7 +17251,13 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} options * @return {?} */ - AnimationTimelineBuilderVisitor.prototype._visitSubInstructions = function (instructions, context, options) { + AnimationTimelineBuilderVisitor.prototype._visitSubInstructions = /** + * @param {?} instructions + * @param {?} context + * @param {?} options + * @return {?} + */ + function (instructions, context, options) { var /** @type {?} */ startTime = context.currentTimeline.currentTime; var /** @type {?} */ furthestTime = startTime; // this is a special-case for when a user wants to skip a sub @@ -8456,9 +17278,14 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitReference = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitReference = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { context.updateOptions(ast.options, true); - ast.animation.visit(this, context); + visitDslNode(this, ast.animation, context); context.previousNode = ast; }; /** @@ -8466,7 +17293,12 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitSequence = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitSequence = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { var _this = this; var /** @type {?} */ subContextCount = context.subContextCount; var /** @type {?} */ ctx = context; @@ -8475,7 +17307,7 @@ var AnimationTimelineBuilderVisitor = (function () { ctx = context.createSubContext(options); ctx.transformIntoNewTimeline(); if (options.delay != null) { - if (ctx.previousNode instanceof StyleAst) { + if (ctx.previousNode.type == 6 /* Style */) { ctx.currentTimeline.snapshotCurrentStyles(); ctx.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; } @@ -8484,7 +17316,7 @@ var AnimationTimelineBuilderVisitor = (function () { } } if (ast.steps.length) { - ast.steps.forEach(function (s) { return s.visit(_this, ctx); }); + ast.steps.forEach(function (s) { return visitDslNode(_this, s, ctx); }); // this is here just incase the inner steps only contain or end with a style() call ctx.currentTimeline.applyStylesToKeyframe(); // this means that some animation function within the sequence @@ -8501,7 +17333,12 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitGroup = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitGroup = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { var _this = this; var /** @type {?} */ innerTimelines = []; var /** @type {?} */ furthestTime = context.currentTimeline.currentTime; @@ -8511,7 +17348,7 @@ var AnimationTimelineBuilderVisitor = (function () { if (delay) { innerContext.delayNextStep(delay); } - s.visit(_this, innerContext); + visitDslNode(_this, s, innerContext); furthestTime = Math.max(furthestTime, innerContext.currentTimeline.currentTime); innerTimelines.push(innerContext.currentTimeline); }); @@ -8527,15 +17364,19 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitTiming = function (ast, context) { - if (ast instanceof DynamicTimingAst) { - var /** @type {?} */ strValue = context.params ? - interpolateParams(ast.value, context.params, context.errors) : - ast.value.toString(); - return resolveTiming(strValue, context.errors); - } - else { - return { duration: ast.duration, delay: ast.delay, easing: ast.easing }; + AnimationTimelineBuilderVisitor.prototype._visitTiming = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { + if ((/** @type {?} */ (ast)).dynamic) { + var /** @type {?} */ strValue = (/** @type {?} */ (ast)).strValue; + var /** @type {?} */ timingValue = context.params ? interpolateParams(strValue, context.params, context.errors) : strValue; + return resolveTiming(timingValue, context.errors); + } + else { + return { duration: ast.duration, delay: ast.delay, easing: ast.easing }; } }; /** @@ -8543,15 +17384,20 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitAnimate = function (ast, context) { - var /** @type {?} */ timings = context.currentAnimateTimings = this.visitTiming(ast.timings, context); + AnimationTimelineBuilderVisitor.prototype.visitAnimate = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { + var /** @type {?} */ timings = context.currentAnimateTimings = this._visitTiming(ast.timings, context); var /** @type {?} */ timeline = context.currentTimeline; if (timings.delay) { context.incrementTime(timings.delay); timeline.snapshotCurrentStyles(); } var /** @type {?} */ style$$1 = ast.style; - if (style$$1 instanceof KeyframesAst) { + if (style$$1.type == 5 /* Keyframes */) { this.visitKeyframes(style$$1, context); } else { @@ -8567,9 +17413,14 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitStyle = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitStyle = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { var /** @type {?} */ timeline = context.currentTimeline; - var /** @type {?} */ timings = ((context.currentAnimateTimings)); + var /** @type {?} */ timings = /** @type {?} */ ((context.currentAnimateTimings)); // this is a special case for when a style() call // directly follows an animate() call (but not inside of an animate() call) if (!timings && timeline.getCurrentStyleProperties().length) { @@ -8589,9 +17440,14 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitKeyframes = function (ast, context) { - var /** @type {?} */ currentAnimateTimings = ((context.currentAnimateTimings)); - var /** @type {?} */ startTime = (((context.currentTimeline))).duration; + AnimationTimelineBuilderVisitor.prototype.visitKeyframes = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { + var /** @type {?} */ currentAnimateTimings = /** @type {?} */ ((context.currentAnimateTimings)); + var /** @type {?} */ startTime = (/** @type {?} */ ((context.currentTimeline))).duration; var /** @type {?} */ duration = currentAnimateTimings.duration; var /** @type {?} */ innerContext = context.createSubContext(); var /** @type {?} */ innerTimeline = innerContext.currentTimeline; @@ -8615,14 +17471,19 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitQuery = function (ast, context) { + AnimationTimelineBuilderVisitor.prototype.visitQuery = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { var _this = this; // in the event that the first step before this is a style step we need // to ensure the styles are applied before the children are animated var /** @type {?} */ startTime = context.currentTimeline.currentTime; - var /** @type {?} */ options = ((ast.options || {})); + var /** @type {?} */ options = /** @type {?} */ ((ast.options || {})); var /** @type {?} */ delay = options.delay ? resolveTimingValue(options.delay) : 0; - if (delay && (context.previousNode instanceof StyleAst || + if (delay && (context.previousNode.type === 6 /* Style */ || (startTime == 0 && context.currentTimeline.getCurrentStyleProperties().length))) { context.currentTimeline.snapshotCurrentStyles(); context.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; @@ -8640,7 +17501,7 @@ var AnimationTimelineBuilderVisitor = (function () { if (element === context.element) { sameElementTimeline = innerContext.currentTimeline; } - ast.animation.visit(_this, innerContext); + visitDslNode(_this, ast.animation, innerContext); // this is here just incase the inner steps only contain or end // with a style() call (which is here to signal that this is a preparatory // call to style an element before it is animated again) @@ -8662,8 +17523,13 @@ var AnimationTimelineBuilderVisitor = (function () { * @param {?} context * @return {?} */ - AnimationTimelineBuilderVisitor.prototype.visitStagger = function (ast, context) { - var /** @type {?} */ parentContext = ((context.parentContext)); + AnimationTimelineBuilderVisitor.prototype.visitStagger = /** + * @param {?} ast + * @param {?} context + * @return {?} + */ + function (ast, context) { + var /** @type {?} */ parentContext = /** @type {?} */ ((context.parentContext)); var /** @type {?} */ tl = context.currentTimeline; var /** @type {?} */ timings = ast.timings; var /** @type {?} */ duration = Math.abs(timings.duration); @@ -8683,7 +17549,7 @@ var AnimationTimelineBuilderVisitor = (function () { timeline.delayNextStep(delay); } var /** @type {?} */ startingTime = timeline.currentTime; - ast.animation.visit(this, context); + visitDslNode(this, ast.animation, context); context.previousNode = ast; // time = duration + delay // the reason why this computation is so complex is because @@ -8694,16 +17560,8 @@ var AnimationTimelineBuilderVisitor = (function () { }; return AnimationTimelineBuilderVisitor; }()); -var DEFAULT_NOOP_PREVIOUS_NODE = ({}); +var DEFAULT_NOOP_PREVIOUS_NODE = /** @type {?} */ ({}); var AnimationTimelineContext = (function () { - /** - * @param {?} _driver - * @param {?} element - * @param {?} subInstructions - * @param {?} errors - * @param {?} timelines - * @param {?=} initialTimeline - */ function AnimationTimelineContext(_driver, element, subInstructions, errors, timelines, initialTimeline) { this._driver = _driver; this.element = element; @@ -8718,14 +17576,14 @@ var AnimationTimelineContext = (function () { this.currentQueryIndex = 0; this.currentQueryTotal = 0; this.currentStaggerTime = 0; - this.currentTimeline = initialTimeline || new TimelineBuilder(element, 0); + this.currentTimeline = initialTimeline || new TimelineBuilder(this._driver, element, 0); timelines.push(this.currentTimeline); } Object.defineProperty(AnimationTimelineContext.prototype, "params", { - /** + get: /** * @return {?} */ - get: function () { return this.options.params; }, + function () { return this.options.params; }, enumerable: true, configurable: true }); @@ -8734,22 +17592,27 @@ var AnimationTimelineContext = (function () { * @param {?=} skipIfExists * @return {?} */ - AnimationTimelineContext.prototype.updateOptions = function (options, skipIfExists) { + AnimationTimelineContext.prototype.updateOptions = /** + * @param {?} options + * @param {?=} skipIfExists + * @return {?} + */ + function (options, skipIfExists) { var _this = this; if (!options) return; - var /** @type {?} */ newOptions = (options); + var /** @type {?} */ newOptions = /** @type {?} */ (options); var /** @type {?} */ optionsToUpdate = this.options; // NOTE: this will get patched up when other animation methods support duration overrides if (newOptions.duration != null) { - ((optionsToUpdate)).duration = resolveTimingValue(newOptions.duration); + (/** @type {?} */ (optionsToUpdate)).duration = resolveTimingValue(newOptions.duration); } if (newOptions.delay != null) { optionsToUpdate.delay = resolveTimingValue(newOptions.delay); } var /** @type {?} */ newParams = newOptions.params; if (newParams) { - var /** @type {?} */ paramsToUpdate_1 = ((optionsToUpdate.params)); + var /** @type {?} */ paramsToUpdate_1 = /** @type {?} */ ((optionsToUpdate.params)); if (!paramsToUpdate_1) { paramsToUpdate_1 = this.options.params = {}; } @@ -8763,13 +17626,16 @@ var AnimationTimelineContext = (function () { /** * @return {?} */ - AnimationTimelineContext.prototype._copyOptions = function () { + AnimationTimelineContext.prototype._copyOptions = /** + * @return {?} + */ + function () { var /** @type {?} */ options = {}; if (this.options) { var /** @type {?} */ oldParams_1 = this.options.params; if (oldParams_1) { var /** @type {?} */ params_1 = options['params'] = {}; - Object.keys(this.options.params).forEach(function (name) { params_1[name] = oldParams_1[name]; }); + Object.keys(oldParams_1).forEach(function (name) { params_1[name] = oldParams_1[name]; }); } } return options; @@ -8780,7 +17646,13 @@ var AnimationTimelineContext = (function () { * @param {?=} newTime * @return {?} */ - AnimationTimelineContext.prototype.createSubContext = function (options, element, newTime) { + AnimationTimelineContext.prototype.createSubContext = /** + * @param {?=} options + * @param {?=} element + * @param {?=} newTime + * @return {?} + */ + function (options, element, newTime) { if (options === void 0) { options = null; } var /** @type {?} */ target = element || this.element; var /** @type {?} */ context = new AnimationTimelineContext(this._driver, target, this.subInstructions, this.errors, this.timelines, this.currentTimeline.fork(target, newTime || 0)); @@ -8798,7 +17670,11 @@ var AnimationTimelineContext = (function () { * @param {?=} newTime * @return {?} */ - AnimationTimelineContext.prototype.transformIntoNewTimeline = function (newTime) { + AnimationTimelineContext.prototype.transformIntoNewTimeline = /** + * @param {?=} newTime + * @return {?} + */ + function (newTime) { this.previousNode = DEFAULT_NOOP_PREVIOUS_NODE; this.currentTimeline = this.currentTimeline.fork(this.element, newTime); this.timelines.push(this.currentTimeline); @@ -8810,13 +17686,19 @@ var AnimationTimelineContext = (function () { * @param {?} delay * @return {?} */ - AnimationTimelineContext.prototype.appendInstructionToTimeline = function (instruction, duration, delay) { + AnimationTimelineContext.prototype.appendInstructionToTimeline = /** + * @param {?} instruction + * @param {?} duration + * @param {?} delay + * @return {?} + */ + function (instruction, duration, delay) { var /** @type {?} */ updatedTimings = { duration: duration != null ? duration : instruction.duration, delay: this.currentTimeline.currentTime + (delay != null ? delay : 0) + instruction.delay, easing: '' }; - var /** @type {?} */ builder = new SubTimelineBuilder(instruction.element, instruction.keyframes, instruction.preStyleProps, instruction.postStyleProps, updatedTimings, instruction.stretchStartingKeyframe); + var /** @type {?} */ builder = new SubTimelineBuilder(this._driver, instruction.element, instruction.keyframes, instruction.preStyleProps, instruction.postStyleProps, updatedTimings, instruction.stretchStartingKeyframe); this.timelines.push(builder); return updatedTimings; }; @@ -8824,14 +17706,22 @@ var AnimationTimelineContext = (function () { * @param {?} time * @return {?} */ - AnimationTimelineContext.prototype.incrementTime = function (time) { + AnimationTimelineContext.prototype.incrementTime = /** + * @param {?} time + * @return {?} + */ + function (time) { this.currentTimeline.forwardTime(this.currentTimeline.duration + time); }; /** * @param {?} delay * @return {?} */ - AnimationTimelineContext.prototype.delayNextStep = function (delay) { + AnimationTimelineContext.prototype.delayNextStep = /** + * @param {?} delay + * @return {?} + */ + function (delay) { // negative delays are not yet supported if (delay > 0) { this.currentTimeline.delayNextStep(delay); @@ -8846,14 +17736,29 @@ var AnimationTimelineContext = (function () { * @param {?} errors * @return {?} */ - AnimationTimelineContext.prototype.invokeQuery = function (selector, originalSelector, limit, includeSelf, optional, errors) { + AnimationTimelineContext.prototype.invokeQuery = /** + * @param {?} selector + * @param {?} originalSelector + * @param {?} limit + * @param {?} includeSelf + * @param {?} optional + * @param {?} errors + * @return {?} + */ + function (selector, originalSelector, limit, includeSelf, optional, errors) { var /** @type {?} */ results = []; if (includeSelf) { results.push(this.element); } if (selector.length > 0) { + // if :self is only used then the selector is empty var /** @type {?} */ multi = limit != 1; - results.push.apply(results, this._driver.query(this.element, selector, multi)); + var /** @type {?} */ elements = this._driver.query(this.element, selector, multi); + if (limit !== 0) { + elements = limit < 0 ? elements.slice(elements.length + limit, elements.length) : + elements.slice(0, limit); + } + results.push.apply(results, elements); } if (!optional && results.length == 0) { errors.push("`query(\"" + originalSelector + "\")` returned zero elements. (Use `query(\"" + originalSelector + "\", { optional: true })` if you wish to allow this.)"); @@ -8863,12 +17768,8 @@ var AnimationTimelineContext = (function () { return AnimationTimelineContext; }()); var TimelineBuilder = (function () { - /** - * @param {?} element - * @param {?} startTime - * @param {?=} _elementTimelineStylesLookup - */ - function TimelineBuilder(element, startTime, _elementTimelineStylesLookup) { + function TimelineBuilder(_driver, element, startTime, _elementTimelineStylesLookup) { + this._driver = _driver; this.element = element; this.startTime = startTime; this._elementTimelineStylesLookup = _elementTimelineStylesLookup; @@ -8884,7 +17785,7 @@ var TimelineBuilder = (function () { this._elementTimelineStylesLookup = new Map(); } this._localTimelineStyles = Object.create(this._backFill, {}); - this._globalTimelineStyles = this._elementTimelineStylesLookup.get(element); + this._globalTimelineStyles = /** @type {?} */ ((this._elementTimelineStylesLookup.get(element))); if (!this._globalTimelineStyles) { this._globalTimelineStyles = this._localTimelineStyles; this._elementTimelineStylesLookup.set(element, this._localTimelineStyles); @@ -8894,7 +17795,10 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.containsAnimation = function () { + TimelineBuilder.prototype.containsAnimation = /** + * @return {?} + */ + function () { switch (this._keyframes.size) { case 0: return false; @@ -8907,12 +17811,15 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.getCurrentStyleProperties = function () { return Object.keys(this._currentKeyframe); }; + TimelineBuilder.prototype.getCurrentStyleProperties = /** + * @return {?} + */ + function () { return Object.keys(this._currentKeyframe); }; Object.defineProperty(TimelineBuilder.prototype, "currentTime", { - /** + get: /** * @return {?} */ - get: function () { return this.startTime + this.duration; }, + function () { return this.startTime + this.duration; }, enumerable: true, configurable: true }); @@ -8920,7 +17827,11 @@ var TimelineBuilder = (function () { * @param {?} delay * @return {?} */ - TimelineBuilder.prototype.delayNextStep = function (delay) { + TimelineBuilder.prototype.delayNextStep = /** + * @param {?} delay + * @return {?} + */ + function (delay) { // in the event that a style() step is placed right before a stagger() // and that style() step is the very first style() value in the animation // then we need to make a copy of the keyframe [0, copy, 1] so that the delay @@ -8941,18 +17852,26 @@ var TimelineBuilder = (function () { * @param {?=} currentTime * @return {?} */ - TimelineBuilder.prototype.fork = function (element, currentTime) { + TimelineBuilder.prototype.fork = /** + * @param {?} element + * @param {?=} currentTime + * @return {?} + */ + function (element, currentTime) { this.applyStylesToKeyframe(); - return new TimelineBuilder(element, currentTime || this.currentTime, this._elementTimelineStylesLookup); + return new TimelineBuilder(this._driver, element, currentTime || this.currentTime, this._elementTimelineStylesLookup); }; /** * @return {?} */ - TimelineBuilder.prototype._loadKeyframe = function () { + TimelineBuilder.prototype._loadKeyframe = /** + * @return {?} + */ + function () { if (this._currentKeyframe) { this._previousKeyframe = this._currentKeyframe; } - this._currentKeyframe = ((this._keyframes.get(this.duration))); + this._currentKeyframe = /** @type {?} */ ((this._keyframes.get(this.duration))); if (!this._currentKeyframe) { this._currentKeyframe = Object.create(this._backFill, {}); this._keyframes.set(this.duration, this._currentKeyframe); @@ -8961,7 +17880,10 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.forwardFrame = function () { + TimelineBuilder.prototype.forwardFrame = /** + * @return {?} + */ + function () { this.duration += ONE_FRAME_IN_MILLISECONDS; this._loadKeyframe(); }; @@ -8969,7 +17891,11 @@ var TimelineBuilder = (function () { * @param {?} time * @return {?} */ - TimelineBuilder.prototype.forwardTime = function (time) { + TimelineBuilder.prototype.forwardTime = /** + * @param {?} time + * @return {?} + */ + function (time) { this.applyStylesToKeyframe(); this.duration = time; this._loadKeyframe(); @@ -8979,7 +17905,12 @@ var TimelineBuilder = (function () { * @param {?} value * @return {?} */ - TimelineBuilder.prototype._updateStyle = function (prop, value) { + TimelineBuilder.prototype._updateStyle = /** + * @param {?} prop + * @param {?} value + * @return {?} + */ + function (prop, value) { this._localTimelineStyles[prop] = value; this._globalTimelineStyles[prop] = value; this._styleSummary[prop] = { time: this.currentTime, value: value }; @@ -8987,12 +17918,19 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.allowOnlyTimelineStyles = function () { return this._currentEmptyStepKeyframe !== this._currentKeyframe; }; + TimelineBuilder.prototype.allowOnlyTimelineStyles = /** + * @return {?} + */ + function () { return this._currentEmptyStepKeyframe !== this._currentKeyframe; }; /** * @param {?} easing * @return {?} */ - TimelineBuilder.prototype.applyEmptyStep = function (easing) { + TimelineBuilder.prototype.applyEmptyStep = /** + * @param {?} easing + * @return {?} + */ + function (easing) { var _this = this; if (easing) { this._previousKeyframe['easing'] = easing; @@ -9016,7 +17954,14 @@ var TimelineBuilder = (function () { * @param {?=} options * @return {?} */ - TimelineBuilder.prototype.setStyles = function (input, easing, errors, options) { + TimelineBuilder.prototype.setStyles = /** + * @param {?} input + * @param {?} easing + * @param {?} errors + * @param {?=} options + * @return {?} + */ + function (input, easing, errors, options) { var _this = this; if (easing) { this._previousKeyframe['easing'] = easing; @@ -9037,7 +17982,10 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.applyStylesToKeyframe = function () { + TimelineBuilder.prototype.applyStylesToKeyframe = /** + * @return {?} + */ + function () { var _this = this; var /** @type {?} */ styles = this._pendingStyles; var /** @type {?} */ props = Object.keys(styles); @@ -9057,7 +18005,10 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.snapshotCurrentStyles = function () { + TimelineBuilder.prototype.snapshotCurrentStyles = /** + * @return {?} + */ + function () { var _this = this; Object.keys(this._localTimelineStyles).forEach(function (prop) { var /** @type {?} */ val = _this._localTimelineStyles[prop]; @@ -9068,12 +18019,15 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.getFinalKeyframe = function () { return this._keyframes.get(this.duration); }; + TimelineBuilder.prototype.getFinalKeyframe = /** + * @return {?} + */ + function () { return this._keyframes.get(this.duration); }; Object.defineProperty(TimelineBuilder.prototype, "properties", { - /** + get: /** * @return {?} */ - get: function () { + function () { var /** @type {?} */ properties = []; for (var /** @type {?} */ prop in this._currentKeyframe) { properties.push(prop); @@ -9087,7 +18041,11 @@ var TimelineBuilder = (function () { * @param {?} timeline * @return {?} */ - TimelineBuilder.prototype.mergeTimelineCollectedStyles = function (timeline) { + TimelineBuilder.prototype.mergeTimelineCollectedStyles = /** + * @param {?} timeline + * @return {?} + */ + function (timeline) { var _this = this; Object.keys(timeline._styleSummary).forEach(function (prop) { var /** @type {?} */ details0 = _this._styleSummary[prop]; @@ -9100,7 +18058,10 @@ var TimelineBuilder = (function () { /** * @return {?} */ - TimelineBuilder.prototype.buildKeyframes = function () { + TimelineBuilder.prototype.buildKeyframes = /** + * @return {?} + */ + function () { var _this = this; this.applyStylesToKeyframe(); var /** @type {?} */ preStyleProps = new Set(); @@ -9139,17 +18100,9 @@ var TimelineBuilder = (function () { }()); var SubTimelineBuilder = (function (_super) { __extends(SubTimelineBuilder, _super); - /** - * @param {?} element - * @param {?} keyframes - * @param {?} preStyleProps - * @param {?} postStyleProps - * @param {?} timings - * @param {?=} _stretchStartingKeyframe - */ - function SubTimelineBuilder(element, keyframes, preStyleProps, postStyleProps, timings, _stretchStartingKeyframe) { + function SubTimelineBuilder(driver, element, keyframes, preStyleProps, postStyleProps, timings, _stretchStartingKeyframe) { if (_stretchStartingKeyframe === void 0) { _stretchStartingKeyframe = false; } - var _this = _super.call(this, element, timings.delay) || this; + var _this = _super.call(this, driver, element, timings.delay) || this; _this.element = element; _this.keyframes = keyframes; _this.preStyleProps = preStyleProps; @@ -9161,11 +18114,17 @@ var SubTimelineBuilder = (function (_super) { /** * @return {?} */ - SubTimelineBuilder.prototype.containsAnimation = function () { return this.keyframes.length > 1; }; + SubTimelineBuilder.prototype.containsAnimation = /** + * @return {?} + */ + function () { return this.keyframes.length > 1; }; /** * @return {?} */ - SubTimelineBuilder.prototype.buildKeyframes = function () { + SubTimelineBuilder.prototype.buildKeyframes = /** + * @return {?} + */ + function () { var /** @type {?} */ keyframes = this.keyframes; var _a = this.timings, delay = _a.delay, duration = _a.duration, easing = _a.easing; if (this._stretchStartingKeyframe && delay) { @@ -9180,24 +18139,24 @@ var SubTimelineBuilder = (function (_super) { oldFirstKeyframe['offset'] = roundOffset(startingGap); newKeyframes.push(oldFirstKeyframe); /* - When the keyframe is stretched then it means that the delay before the animation - starts is gone. Instead the first keyframe is placed at the start of the animation - and it is then copied to where it starts when the original delay is over. This basically - means nothing animates during that delay, but the styles are still renderered. For this - to work the original offset values that exist in the original keyframes must be "warped" - so that they can take the new keyframe + delay into account. - - delay=1000, duration=1000, keyframes = 0 .5 1 - - turns into - - delay=0, duration=2000, keyframes = 0 .33 .66 1 - */ + When the keyframe is stretched then it means that the delay before the animation + starts is gone. Instead the first keyframe is placed at the start of the animation + and it is then copied to where it starts when the original delay is over. This basically + means nothing animates during that delay, but the styles are still renderered. For this + to work the original offset values that exist in the original keyframes must be "warped" + so that they can take the new keyframe + delay into account. + + delay=1000, duration=1000, keyframes = 0 .5 1 + + turns into + + delay=0, duration=2000, keyframes = 0 .33 .66 1 + */ // offsets between 1 ... n -1 are all warped by the keyframe stretch var /** @type {?} */ limit = keyframes.length - 1; for (var /** @type {?} */ i = 1; i <= limit; i++) { var /** @type {?} */ kf = copyStyles(keyframes[i], false); - var /** @type {?} */ oldOffset = (kf['offset']); + var /** @type {?} */ oldOffset = /** @type {?} */ (kf['offset']); var /** @type {?} */ timeAtKeyframe = delay + oldOffset * duration; kf['offset'] = roundOffset(timeAtKeyframe / totalTime); newKeyframes.push(kf); @@ -9241,24 +18200,18 @@ function flattenStyles(input, allStyles) { }); return styles; } + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ var Animation = (function () { - /** - * @param {?} _driver - * @param {?} input - */ function Animation(_driver, input) { this._driver = _driver; - var errors = []; - var ast = buildAnimationAst(input, errors); + var /** @type {?} */ errors = []; + var /** @type {?} */ ast = buildAnimationAst(_driver, input, errors); if (errors.length) { - var errorMessage = "animation validation failed:\n" + errors.join("\n"); + var /** @type {?} */ errorMessage = "animation validation failed:\n" + errors.join("\n"); throw new Error(errorMessage); } this._animationAst = ast; @@ -9271,9 +18224,17 @@ var Animation = (function () { * @param {?=} subInstructions * @return {?} */ - Animation.prototype.buildTimelines = function (element, startingStyles, destinationStyles, options, subInstructions) { - var /** @type {?} */ start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) : (startingStyles); - var /** @type {?} */ dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) : (destinationStyles); + Animation.prototype.buildTimelines = /** + * @param {?} element + * @param {?} startingStyles + * @param {?} destinationStyles + * @param {?} options + * @param {?=} subInstructions + * @return {?} + */ + function (element, startingStyles, destinationStyles, options, subInstructions) { + var /** @type {?} */ start = Array.isArray(startingStyles) ? normalizeStyles(startingStyles) : /** @type {?} */ (startingStyles); + var /** @type {?} */ dest = Array.isArray(destinationStyles) ? normalizeStyles(destinationStyles) : /** @type {?} */ (destinationStyles); var /** @type {?} */ errors = []; subInstructions = subInstructions || new ElementInstructionMap(); var /** @type {?} */ result = buildAnimationTimelines(this._driver, element, this._animationAst, start, dest, options, subInstructions, errors); @@ -9285,39 +18246,61 @@ var Animation = (function () { }; return Animation; }()); + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ /** - * @experimental Animation support is experimental. + * \@experimental Animation support is experimental. + * @abstract */ -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ var AnimationStyleNormalizer = (function () { +var AnimationStyleNormalizer = (function () { function AnimationStyleNormalizer() { } return AnimationStyleNormalizer; }()); /** - * @experimental Animation support is experimental. + * \@experimental Animation support is experimental. */ var NoopAnimationStyleNormalizer = (function () { function NoopAnimationStyleNormalizer() { } - NoopAnimationStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) { return propertyName; }; - NoopAnimationStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) { - return value; + /** + * @param {?} propertyName + * @param {?} errors + * @return {?} + */ + NoopAnimationStyleNormalizer.prototype.normalizePropertyName = /** + * @param {?} propertyName + * @param {?} errors + * @return {?} + */ + function (propertyName, errors) { return propertyName; }; + /** + * @param {?} userProvidedProperty + * @param {?} normalizedProperty + * @param {?} value + * @param {?} errors + * @return {?} + */ + NoopAnimationStyleNormalizer.prototype.normalizeStyleValue = /** + * @param {?} userProvidedProperty + * @param {?} normalizedProperty + * @param {?} value + * @param {?} errors + * @return {?} + */ + function (userProvidedProperty, normalizedProperty, value, errors) { + return /** @type {?} */ (value); }; return NoopAnimationStyleNormalizer; }()); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -9335,7 +18318,12 @@ var WebAnimationsStyleNormalizer = (function (_super) { * @param {?} errors * @return {?} */ - WebAnimationsStyleNormalizer.prototype.normalizePropertyName = function (propertyName, errors) { + WebAnimationsStyleNormalizer.prototype.normalizePropertyName = /** + * @param {?} propertyName + * @param {?} errors + * @return {?} + */ + function (propertyName, errors) { return dashCaseToCamelCase(propertyName); }; /** @@ -9345,7 +18333,14 @@ var WebAnimationsStyleNormalizer = (function (_super) { * @param {?} errors * @return {?} */ - WebAnimationsStyleNormalizer.prototype.normalizeStyleValue = function (userProvidedProperty, normalizedProperty, value, errors) { + WebAnimationsStyleNormalizer.prototype.normalizeStyleValue = /** + * @param {?} userProvidedProperty + * @param {?} normalizedProperty + * @param {?} value + * @param {?} errors + * @return {?} + */ + function (userProvidedProperty, normalizedProperty, value, errors) { var /** @type {?} */ unit = ''; var /** @type {?} */ strVal = value.toString().trim(); if (DIMENSIONAL_PROP_MAP[normalizedProperty] && value !== 0 && value !== '0') { @@ -9374,13 +18369,15 @@ function makeBooleanMap(keys) { keys.forEach(function (key) { return map[key] = true; }); return map; } + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * @record */ + /** * @param {?} element * @param {?} triggerName @@ -9393,9 +18390,10 @@ function makeBooleanMap(keys) { * @param {?} queriedElements * @param {?} preStyleProps * @param {?} postStyleProps + * @param {?=} errors * @return {?} */ -function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps) { +function createTransitionInstruction(element, triggerName, fromState, toState, isRemovalTransition, fromStyles, toStyles, timelines, queriedElements, preStyleProps, postStyleProps, errors) { return { type: 0 /* TransitionAnimation */, element: element, @@ -9408,22 +18406,17 @@ function createTransitionInstruction(element, triggerName, fromState, toState, i timelines: timelines, queriedElements: queriedElements, preStyleProps: preStyleProps, - postStyleProps: postStyleProps + postStyleProps: postStyleProps, + errors: errors }; } + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ +var EMPTY_OBJECT = {}; var AnimationTransitionFactory = (function () { - /** - * @param {?} _triggerName - * @param {?} ast - * @param {?} _stateStyles - */ function AnimationTransitionFactory(_triggerName, ast, _stateStyles) { this._triggerName = _triggerName; this.ast = ast; @@ -9434,32 +18427,68 @@ var AnimationTransitionFactory = (function () { * @param {?} nextState * @return {?} */ - AnimationTransitionFactory.prototype.match = function (currentState, nextState) { + AnimationTransitionFactory.prototype.match = /** + * @param {?} currentState + * @param {?} nextState + * @return {?} + */ + function (currentState, nextState) { return oneOrMoreTransitionsMatch(this.ast.matchers, currentState, nextState); }; + /** + * @param {?} stateName + * @param {?} params + * @param {?} errors + * @return {?} + */ + AnimationTransitionFactory.prototype.buildStyles = /** + * @param {?} stateName + * @param {?} params + * @param {?} errors + * @return {?} + */ + function (stateName, params, errors) { + var /** @type {?} */ backupStateStyler = this._stateStyles['*']; + var /** @type {?} */ stateStyler = this._stateStyles[stateName]; + var /** @type {?} */ backupStyles = backupStateStyler ? backupStateStyler.buildStyles(params, errors) : {}; + return stateStyler ? stateStyler.buildStyles(params, errors) : backupStyles; + }; /** * @param {?} driver * @param {?} element * @param {?} currentState * @param {?} nextState - * @param {?=} options + * @param {?=} currentOptions + * @param {?=} nextOptions + * @param {?=} subInstructions + * @return {?} + */ + AnimationTransitionFactory.prototype.build = /** + * @param {?} driver + * @param {?} element + * @param {?} currentState + * @param {?} nextState + * @param {?=} currentOptions + * @param {?=} nextOptions * @param {?=} subInstructions * @return {?} */ - AnimationTransitionFactory.prototype.build = function (driver, element, currentState, nextState, options, subInstructions) { - var /** @type {?} */ animationOptions = mergeAnimationOptions(this.ast.options || {}, options || {}); - var /** @type {?} */ backupStateStyles = this._stateStyles['*'] || {}; - var /** @type {?} */ currentStateStyles = this._stateStyles[currentState] || backupStateStyles; - var /** @type {?} */ nextStateStyles = this._stateStyles[nextState] || backupStateStyles; + function (driver, element, currentState, nextState, currentOptions, nextOptions, subInstructions) { var /** @type {?} */ errors = []; + var /** @type {?} */ transitionAnimationParams = this.ast.options && this.ast.options.params || EMPTY_OBJECT; + var /** @type {?} */ currentAnimationParams = currentOptions && currentOptions.params || EMPTY_OBJECT; + var /** @type {?} */ currentStateStyles = this.buildStyles(currentState, currentAnimationParams, errors); + var /** @type {?} */ nextAnimationParams = nextOptions && nextOptions.params || EMPTY_OBJECT; + var /** @type {?} */ nextStateStyles = this.buildStyles(nextState, nextAnimationParams, errors); + var /** @type {?} */ queriedElements = new Set(); + var /** @type {?} */ preStyleMap = new Map(); + var /** @type {?} */ postStyleMap = new Map(); + var /** @type {?} */ isRemoval = nextState === 'void'; + var /** @type {?} */ animationOptions = { params: __assign({}, transitionAnimationParams, nextAnimationParams) }; var /** @type {?} */ timelines = buildAnimationTimelines(driver, element, this.ast.animation, currentStateStyles, nextStateStyles, animationOptions, subInstructions, errors); if (errors.length) { - var /** @type {?} */ errorMessage = "animation building failed:\n" + errors.join("\n"); - throw new Error(errorMessage); + return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, [], [], preStyleMap, postStyleMap, errors); } - var /** @type {?} */ preStyleMap = new Map(); - var /** @type {?} */ postStyleMap = new Map(); - var /** @type {?} */ queriedElements = new Set(); timelines.forEach(function (tl) { var /** @type {?} */ elm = tl.element; var /** @type {?} */ preProps = getOrSetAsInMap(preStyleMap, elm, {}); @@ -9471,7 +18500,7 @@ var AnimationTransitionFactory = (function () { } }); var /** @type {?} */ queriedElementsList = iteratorToArray(queriedElements.values()); - return createTransitionInstruction(element, this._triggerName, currentState, nextState, nextState === 'void', currentStateStyles, nextStateStyles, timelines, queriedElementsList, preStyleMap, postStyleMap); + return createTransitionInstruction(element, this._triggerName, currentState, nextState, isRemoval, currentStateStyles, nextStateStyles, timelines, queriedElementsList, preStyleMap, postStyleMap); }; return AnimationTransitionFactory; }()); @@ -9484,30 +18513,64 @@ var AnimationTransitionFactory = (function () { function oneOrMoreTransitionsMatch(matchFns, currentState, nextState) { return matchFns.some(function (fn) { return fn(currentState, nextState); }); } -/** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license - */ -/** - * \@experimental Animation support is experimental. - * @param {?} name - * @param {?} ast - * @return {?} - */ -function buildTrigger(name, ast) { - return new AnimationTrigger(name, ast); +var AnimationStateStyles = (function () { + function AnimationStateStyles(styles, defaultParams) { + this.styles = styles; + this.defaultParams = defaultParams; + } + /** + * @param {?} params + * @param {?} errors + * @return {?} + */ + AnimationStateStyles.prototype.buildStyles = /** + * @param {?} params + * @param {?} errors + * @return {?} + */ + function (params, errors) { + var /** @type {?} */ finalStyles = {}; + var /** @type {?} */ combinedParams = copyObj(this.defaultParams); + Object.keys(params).forEach(function (key) { + var /** @type {?} */ value = params[key]; + if (value != null) { + combinedParams[key] = value; + } + }); + this.styles.styles.forEach(function (value) { + if (typeof value !== 'string') { + var /** @type {?} */ styleObj_1 = /** @type {?} */ (value); + Object.keys(styleObj_1).forEach(function (prop) { + var /** @type {?} */ val = styleObj_1[prop]; + if (val.length > 1) { + val = interpolateParams(val, combinedParams, errors); + } + finalStyles[prop] = val; + }); + } + }); + return finalStyles; + }; + return AnimationStateStyles; +}()); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ +/** + * \@experimental Animation support is experimental. + * @param {?} name + * @param {?} ast + * @return {?} + */ +function buildTrigger(name, ast) { + return new AnimationTrigger(name, ast); } /** * \@experimental Animation support is experimental. */ var AnimationTrigger = (function () { - /** - * @param {?} name - * @param {?} ast - */ function AnimationTrigger(name, ast) { var _this = this; this.name = name; @@ -9515,12 +18578,8 @@ var AnimationTrigger = (function () { this.transitionFactories = []; this.states = {}; ast.states.forEach(function (ast) { - var obj = _this.states[ast.name] = {}; - ast.style.styles.forEach(function (styleTuple) { - if (typeof styleTuple == 'object') { - copyStyles(styleTuple, false, obj); - } - }); + var /** @type {?} */ defaultParams = (ast.options && ast.options.params) || {}; + _this.states[ast.name] = new AnimationStateStyles(ast.style, defaultParams); }); balanceProperties(this.states, 'true', '1'); balanceProperties(this.states, 'false', '0'); @@ -9530,10 +18589,10 @@ var AnimationTrigger = (function () { this.fallbackTransition = createFallbackTransition(name, this.states); } Object.defineProperty(AnimationTrigger.prototype, "containsQueries", { - /** + get: /** * @return {?} */ - get: function () { return this.ast.queryCount > 0; }, + function () { return this.ast.queryCount > 0; }, enumerable: true, configurable: true }); @@ -9542,10 +18601,30 @@ var AnimationTrigger = (function () { * @param {?} nextState * @return {?} */ - AnimationTrigger.prototype.matchTransition = function (currentState, nextState) { + AnimationTrigger.prototype.matchTransition = /** + * @param {?} currentState + * @param {?} nextState + * @return {?} + */ + function (currentState, nextState) { var /** @type {?} */ entry = this.transitionFactories.find(function (f) { return f.match(currentState, nextState); }); return entry || null; }; + /** + * @param {?} currentState + * @param {?} params + * @param {?} errors + * @return {?} + */ + AnimationTrigger.prototype.matchStyles = /** + * @param {?} currentState + * @param {?} params + * @param {?} errors + * @return {?} + */ + function (currentState, params, errors) { + return this.fallbackTransition.buildStyles(currentState, params, errors); + }; return AnimationTrigger; }()); /** @@ -9555,8 +18634,15 @@ var AnimationTrigger = (function () { */ function createFallbackTransition(triggerName, states) { var /** @type {?} */ matchers = [function (fromState, toState) { return true; }]; - var /** @type {?} */ animation = new SequenceAst([]); - var /** @type {?} */ transition = new TransitionAst(matchers, animation); + var /** @type {?} */ animation = { type: 2 /* Sequence */, steps: [], options: null }; + var /** @type {?} */ transition = { + type: 1 /* Transition */, + animation: animation, + matchers: matchers, + options: null, + queryCount: 0, + depCount: 0 + }; return new AnimationTransitionFactory(triggerName, transition, states); } /** @@ -9575,6 +18661,11 @@ function balanceProperties(obj, key1, key2) { obj[key1] = obj[key2]; } } + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -9584,10 +18675,6 @@ function balanceProperties(obj, key1, key2) { */ var EMPTY_INSTRUCTION_MAP = new ElementInstructionMap(); var TimelineAnimationEngine = (function () { - /** - * @param {?} _driver - * @param {?} _normalizer - */ function TimelineAnimationEngine(_driver, _normalizer) { this._driver = _driver; this._normalizer = _normalizer; @@ -9600,9 +18687,14 @@ var TimelineAnimationEngine = (function () { * @param {?} metadata * @return {?} */ - TimelineAnimationEngine.prototype.register = function (id, metadata) { + TimelineAnimationEngine.prototype.register = /** + * @param {?} id + * @param {?} metadata + * @return {?} + */ + function (id, metadata) { var /** @type {?} */ errors = []; - var /** @type {?} */ ast = buildAnimationAst(metadata, errors); + var /** @type {?} */ ast = buildAnimationAst(this._driver, metadata, errors); if (errors.length) { throw new Error("Unable to build the animation due to the following errors: " + errors.join("\n")); } @@ -9616,7 +18708,13 @@ var TimelineAnimationEngine = (function () { * @param {?=} postStyles * @return {?} */ - TimelineAnimationEngine.prototype._buildPlayer = function (i, preStyles, postStyles) { + TimelineAnimationEngine.prototype._buildPlayer = /** + * @param {?} i + * @param {?} preStyles + * @param {?=} postStyles + * @return {?} + */ + function (i, preStyles, postStyles) { var /** @type {?} */ element = i.element; var /** @type {?} */ keyframes = normalizeKeyframes(this._driver, this._normalizer, element, i.keyframes, preStyles, postStyles); return this._driver.animate(element, keyframes, i.duration, i.delay, i.easing, []); @@ -9627,7 +18725,13 @@ var TimelineAnimationEngine = (function () { * @param {?=} options * @return {?} */ - TimelineAnimationEngine.prototype.create = function (id, element, options) { + TimelineAnimationEngine.prototype.create = /** + * @param {?} id + * @param {?} element + * @param {?=} options + * @return {?} + */ + function (id, element, options) { var _this = this; if (options === void 0) { options = {}; } var /** @type {?} */ errors = []; @@ -9665,7 +18769,11 @@ var TimelineAnimationEngine = (function () { * @param {?} id * @return {?} */ - TimelineAnimationEngine.prototype.destroy = function (id) { + TimelineAnimationEngine.prototype.destroy = /** + * @param {?} id + * @return {?} + */ + function (id) { var /** @type {?} */ player = this._getPlayer(id); player.destroy(); delete this._playersById[id]; @@ -9678,7 +18786,11 @@ var TimelineAnimationEngine = (function () { * @param {?} id * @return {?} */ - TimelineAnimationEngine.prototype._getPlayer = function (id) { + TimelineAnimationEngine.prototype._getPlayer = /** + * @param {?} id + * @return {?} + */ + function (id) { var /** @type {?} */ player = this._playersById[id]; if (!player) { throw new Error("Unable to find the timeline player referenced by " + id); @@ -9692,7 +18804,14 @@ var TimelineAnimationEngine = (function () { * @param {?} callback * @return {?} */ - TimelineAnimationEngine.prototype.listen = function (id, element, eventName, callback) { + TimelineAnimationEngine.prototype.listen = /** + * @param {?} id + * @param {?} element + * @param {?} eventName + * @param {?} callback + * @return {?} + */ + function (id, element, eventName, callback) { // triggerName, fromState, toState are all ignored for timeline animations var /** @type {?} */ baseEvent = makeAnimationEvent(element, '', '', ''); listenOnPlayer(this._getPlayer(id), eventName, baseEvent, callback); @@ -9705,13 +18824,20 @@ var TimelineAnimationEngine = (function () { * @param {?} args * @return {?} */ - TimelineAnimationEngine.prototype.command = function (id, element, command, args) { + TimelineAnimationEngine.prototype.command = /** + * @param {?} id + * @param {?} element + * @param {?} command + * @param {?} args + * @return {?} + */ + function (id, element, command, args) { if (command == 'register') { this.register(id, /** @type {?} */ (args[0])); return; } if (command == 'create') { - var /** @type {?} */ options = ((args[0] || {})); + var /** @type {?} */ options = /** @type {?} */ ((args[0] || {})); this.create(id, element, options); return; } @@ -9745,6 +18871,11 @@ var TimelineAnimationEngine = (function () { }; return TimelineAnimationEngine; }()); + +/** + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc + */ /** * @license * Copyright Google Inc. All Rights Reserved. @@ -9752,6 +18883,10 @@ var TimelineAnimationEngine = (function () { * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ +var QUEUED_CLASSNAME = 'ng-animate-queued'; +var QUEUED_SELECTOR = '.ng-animate-queued'; +var DISABLED_CLASSNAME = 'ng-animate-disabled'; +var DISABLED_SELECTOR = '.ng-animate-disabled'; var EMPTY_PLAYER_ARRAY = []; var NULL_REMOVAL_STATE = { namespaceId: '', @@ -9765,19 +18900,26 @@ var NULL_REMOVED_QUERIED_STATE = { hasAnimation: false, removedBeforeQueried: true }; +/** + * @record + */ + var REMOVAL_FLAG = '__ng_removed'; +/** + * @record + */ + var StateValue = (function () { - /** - * @param {?} input - */ - function StateValue(input) { - var isObj = input && input.hasOwnProperty('value'); - var value = isObj ? input['value'] : input; + function StateValue(input, namespaceId) { + if (namespaceId === void 0) { namespaceId = ''; } + this.namespaceId = namespaceId; + var /** @type {?} */ isObj = input && input.hasOwnProperty('value'); + var /** @type {?} */ value = isObj ? input['value'] : input; this.value = normalizeTriggerValue(value); if (isObj) { - var options = copyObj(input); + var /** @type {?} */ options = copyObj(/** @type {?} */ (input)); delete options['value']; - this.options = options; + this.options = /** @type {?} */ (options); } else { this.options = {}; @@ -9786,17 +18928,29 @@ var StateValue = (function () { this.options.params = {}; } } + Object.defineProperty(StateValue.prototype, "params", { + get: /** + * @return {?} + */ + function () { return /** @type {?} */ (this.options.params); }, + enumerable: true, + configurable: true + }); /** * @param {?} options * @return {?} */ - StateValue.prototype.absorbOptions = function (options) { + StateValue.prototype.absorbOptions = /** + * @param {?} options + * @return {?} + */ + function (options) { var /** @type {?} */ newParams = options.params; if (newParams) { - var /** @type {?} */ oldParams_2 = ((this.options.params)); + var /** @type {?} */ oldParams_1 = /** @type {?} */ ((this.options.params)); Object.keys(newParams).forEach(function (prop) { - if (oldParams_2[prop] == null) { - oldParams_2[prop] = newParams[prop]; + if (oldParams_1[prop] == null) { + oldParams_1[prop] = newParams[prop]; } }); } @@ -9807,11 +18961,6 @@ var VOID_VALUE = 'void'; var DEFAULT_STATE_VALUE = new StateValue(VOID_VALUE); var DELETED_STATE_VALUE = new StateValue('DELETED'); var AnimationTransitionNamespace = (function () { - /** - * @param {?} id - * @param {?} hostElement - * @param {?} _engine - */ function AnimationTransitionNamespace(id, hostElement, _engine) { this.id = id; this.hostElement = hostElement; @@ -9830,7 +18979,14 @@ var AnimationTransitionNamespace = (function () { * @param {?} callback * @return {?} */ - AnimationTransitionNamespace.prototype.listen = function (element, name, phase, callback) { + AnimationTransitionNamespace.prototype.listen = /** + * @param {?} element + * @param {?} name + * @param {?} phase + * @param {?} callback + * @return {?} + */ + function (element, name, phase, callback) { var _this = this; if (!this._triggers.hasOwnProperty(name)) { throw new Error("Unable to listen on the animation trigger event \"" + phase + "\" because the animation trigger \"" + name + "\" doesn't exist!"); @@ -9848,9 +19004,12 @@ var AnimationTransitionNamespace = (function () { if (!triggersWithStates.hasOwnProperty(name)) { addClass(element, NG_TRIGGER_CLASSNAME); addClass(element, NG_TRIGGER_CLASSNAME + '-' + name); - triggersWithStates[name] = null; + triggersWithStates[name] = DEFAULT_STATE_VALUE; } return function () { + // the event listener is removed AFTER the flush has occurred such + // that leave animations callbacks can fire (otherwise if the node + // is removed in between then the listeners would be deregistered) // the event listener is removed AFTER the flush has occurred such // that leave animations callbacks can fire (otherwise if the node // is removed in between then the listeners would be deregistered) @@ -9870,7 +19029,12 @@ var AnimationTransitionNamespace = (function () { * @param {?} ast * @return {?} */ - AnimationTransitionNamespace.prototype.register = function (name, ast) { + AnimationTransitionNamespace.prototype.register = /** + * @param {?} name + * @param {?} ast + * @return {?} + */ + function (name, ast) { if (this._triggers[name]) { // throw return false; @@ -9884,7 +19048,11 @@ var AnimationTransitionNamespace = (function () { * @param {?} name * @return {?} */ - AnimationTransitionNamespace.prototype._getTrigger = function (name) { + AnimationTransitionNamespace.prototype._getTrigger = /** + * @param {?} name + * @return {?} + */ + function (name) { var /** @type {?} */ trigger = this._triggers[name]; if (!trigger) { throw new Error("The provided animation trigger \"" + name + "\" has not been registered!"); @@ -9898,7 +19066,14 @@ var AnimationTransitionNamespace = (function () { * @param {?=} defaultToFallback * @return {?} */ - AnimationTransitionNamespace.prototype.trigger = function (element, triggerName, value, defaultToFallback) { + AnimationTransitionNamespace.prototype.trigger = /** + * @param {?} element + * @param {?} triggerName + * @param {?} value + * @param {?=} defaultToFallback + * @return {?} + */ + function (element, triggerName, value, defaultToFallback) { var _this = this; if (defaultToFallback === void 0) { defaultToFallback = true; } var /** @type {?} */ trigger = this._getTrigger(triggerName); @@ -9910,7 +19085,7 @@ var AnimationTransitionNamespace = (function () { this._engine.statesByElement.set(element, triggersWithStates = {}); } var /** @type {?} */ fromState = triggersWithStates[triggerName]; - var /** @type {?} */ toState = new StateValue(value); + var /** @type {?} */ toState = new StateValue(value, this.id); var /** @type {?} */ isObj = value && value.hasOwnProperty('value'); if (!isObj && fromState) { toState.absorbOptions(fromState.options); @@ -9922,6 +19097,32 @@ var AnimationTransitionNamespace = (function () { else if (fromState === DELETED_STATE_VALUE) { return player; } + var /** @type {?} */ isRemoval = toState.value === VOID_VALUE; + // normally this isn't reached by here, however, if an object expression + // is passed in then it may be a new object each time. Comparing the value + // is important since that will stay the same despite there being a new object. + // The removal arc here is special cased because the same element is triggered + // twice in the event that it contains animations on the outer/inner portions + // of the host container + if (!isRemoval && fromState.value === toState.value) { + // this means that despite the value not changing, some inner params + // have changed which means that the animation final styles need to be applied + if (!objEquals(fromState.params, toState.params)) { + var /** @type {?} */ errors = []; + var /** @type {?} */ fromStyles_1 = trigger.matchStyles(fromState.value, fromState.params, errors); + var /** @type {?} */ toStyles_1 = trigger.matchStyles(toState.value, toState.params, errors); + if (errors.length) { + this._engine.reportError(errors); + } + else { + this._engine.afterFlush(function () { + eraseStyles(element, fromStyles_1); + setStyles(element, toStyles_1); + }); + } + } + return; + } var /** @type {?} */ playersOnElement = getOrSetAsInMap(this._engine.playersByElement, element, []); playersOnElement.forEach(function (player) { // only remove the player if it is queued on the EXACT same trigger/namespace @@ -9943,10 +19144,10 @@ var AnimationTransitionNamespace = (function () { this._engine.totalQueuedPlayers++; this._queue.push({ element: element, triggerName: triggerName, transition: transition, fromState: fromState, toState: toState, player: player, isFallbackTransition: isFallbackTransition }); if (!isFallbackTransition) { - addClass(element, NG_ANIMATING_CLASSNAME); + addClass(element, QUEUED_CLASSNAME); + player.onStart(function () { removeClass(element, QUEUED_CLASSNAME); }); } player.onDone(function () { - removeClass(element, NG_ANIMATING_CLASSNAME); var /** @type {?} */ index = _this.players.indexOf(player); if (index >= 0) { _this.players.splice(index, 1); @@ -9967,7 +19168,11 @@ var AnimationTransitionNamespace = (function () { * @param {?} name * @return {?} */ - AnimationTransitionNamespace.prototype.deregister = function (name) { + AnimationTransitionNamespace.prototype.deregister = /** + * @param {?} name + * @return {?} + */ + function (name) { var _this = this; delete this._triggers[name]; this._engine.statesByElement.forEach(function (stateMap, element) { delete stateMap[name]; }); @@ -9979,7 +19184,11 @@ var AnimationTransitionNamespace = (function () { * @param {?} element * @return {?} */ - AnimationTransitionNamespace.prototype.clearElementCache = function (element) { + AnimationTransitionNamespace.prototype.clearElementCache = /** + * @param {?} element + * @return {?} + */ + function (element) { this._engine.statesByElement.delete(element); this._elementListeners.delete(element); var /** @type {?} */ elementPlayers = this._engine.playersByElement.get(element); @@ -9994,17 +19203,22 @@ var AnimationTransitionNamespace = (function () { * @param {?=} animate * @return {?} */ - AnimationTransitionNamespace.prototype._destroyInnerNodes = function (rootElement, context, animate) { + AnimationTransitionNamespace.prototype._signalRemovalForInnerTriggers = /** + * @param {?} rootElement + * @param {?} context + * @param {?=} animate + * @return {?} + */ + function (rootElement, context, animate) { var _this = this; if (animate === void 0) { animate = false; } + // emulate a leave animation for all inner nodes within this node. + // If there are no animations found for any of the nodes then clear the cache + // for the element. this._engine.driver.query(rootElement, NG_TRIGGER_SELECTOR, true).forEach(function (elm) { - if (animate && containsClass(elm, _this._hostClassName)) { - var /** @type {?} */ innerNs = _this._engine.namespacesByHostElement.get(elm); - // special case for a host element with animations on the same element - if (innerNs) { - innerNs.removeNode(elm, context, true); - } - _this.removeNode(elm, context, true); + var /** @type {?} */ namespaces = _this._engine.fetchNamespacesByElement(elm); + if (namespaces.size) { + namespaces.forEach(function (ns) { ns.triggerLeaveAnimation(elm, context, false, true); }); } else { _this.clearElementCache(elm); @@ -10014,61 +19228,52 @@ var AnimationTransitionNamespace = (function () { /** * @param {?} element * @param {?} context - * @param {?=} doNotRecurse + * @param {?=} destroyAfterComplete + * @param {?=} defaultToFallback + * @return {?} + */ + AnimationTransitionNamespace.prototype.triggerLeaveAnimation = /** + * @param {?} element + * @param {?} context + * @param {?=} destroyAfterComplete + * @param {?=} defaultToFallback * @return {?} */ - AnimationTransitionNamespace.prototype.removeNode = function (element, context, doNotRecurse) { + function (element, context, destroyAfterComplete, defaultToFallback) { var _this = this; - var /** @type {?} */ engine = this._engine; - if (!doNotRecurse && element.childElementCount) { - this._destroyInnerNodes(element, context, true); - } - var /** @type {?} */ triggerStates = engine.statesByElement.get(element); + var /** @type {?} */ triggerStates = this._engine.statesByElement.get(element); if (triggerStates) { var /** @type {?} */ players_1 = []; Object.keys(triggerStates).forEach(function (triggerName) { // this check is here in the event that an element is removed // twice (both on the host level and the component level) if (_this._triggers[triggerName]) { - var /** @type {?} */ player = _this.trigger(element, triggerName, VOID_VALUE, false); + var /** @type {?} */ player = _this.trigger(element, triggerName, VOID_VALUE, defaultToFallback); if (player) { players_1.push(player); } } }); if (players_1.length) { - engine.markElementAsRemoved(this.id, element, true, context); - optimizeGroupPlayer(players_1).onDone(function () { return engine.processLeaveNode(element); }); - return; - } - } - // find the player that is animating and make sure that the - // removal is delayed until that player has completed - var /** @type {?} */ containsPotentialParentTransition = false; - if (engine.totalAnimations) { - var /** @type {?} */ currentPlayers = engine.players.length ? engine.playersByQueriedElement.get(element) : []; - // when this `if statement` does not continue forward it means that - // a previous animation query has selected the current element and - // is animating it. In this situation want to continue fowards and - // allow the element to be queued up for animation later. - if (currentPlayers && currentPlayers.length) { - containsPotentialParentTransition = true; - } - else { - var /** @type {?} */ parent = element; - while (parent = parent.parentNode) { - var /** @type {?} */ triggers = engine.statesByElement.get(parent); - if (triggers) { - containsPotentialParentTransition = true; - break; - } + this._engine.markElementAsRemoved(this.id, element, true, context); + if (destroyAfterComplete) { + optimizeGroupPlayer(players_1).onDone(function () { return _this._engine.processLeaveNode(element); }); } + return true; } } - // at this stage we know that the element will either get removed - // during flush or will be picked up by a parent query. Either way - // we need to fire the listeners for this element when it DOES get - // removed (once the query parent animation is done or after flush) + return false; + }; + /** + * @param {?} element + * @return {?} + */ + AnimationTransitionNamespace.prototype.prepareLeaveAnimationListeners = /** + * @param {?} element + * @return {?} + */ + function (element) { + var _this = this; var /** @type {?} */ listeners = this._elementListeners.get(element); if (listeners) { var /** @type {?} */ visitedTriggers_1 = new Set(); @@ -10079,7 +19284,7 @@ var AnimationTransitionNamespace = (function () { visitedTriggers_1.add(triggerName); var /** @type {?} */ trigger = _this._triggers[triggerName]; var /** @type {?} */ transition = trigger.fallbackTransition; - var /** @type {?} */ elementStates = ((engine.statesByElement.get(element))); + var /** @type {?} */ elementStates = /** @type {?} */ ((_this._engine.statesByElement.get(element))); var /** @type {?} */ fromState = elementStates[triggerName] || DEFAULT_STATE_VALUE; var /** @type {?} */ toState = new StateValue(VOID_VALUE); var /** @type {?} */ player = new TransitionAnimationPlayer(_this.id, triggerName, element); @@ -10095,6 +19300,54 @@ var AnimationTransitionNamespace = (function () { }); }); } + }; + /** + * @param {?} element + * @param {?} context + * @return {?} + */ + AnimationTransitionNamespace.prototype.removeNode = /** + * @param {?} element + * @param {?} context + * @return {?} + */ + function (element, context) { + var _this = this; + var /** @type {?} */ engine = this._engine; + if (element.childElementCount) { + this._signalRemovalForInnerTriggers(element, context, true); + } + // this means that a * => VOID animation was detected and kicked off + if (this.triggerLeaveAnimation(element, context, true)) + return; + // find the player that is animating and make sure that the + // removal is delayed until that player has completed + var /** @type {?} */ containsPotentialParentTransition = false; + if (engine.totalAnimations) { + var /** @type {?} */ currentPlayers = engine.players.length ? engine.playersByQueriedElement.get(element) : []; + // when this `if statement` does not continue forward it means that + // a previous animation query has selected the current element and + // is animating it. In this situation want to continue fowards and + // allow the element to be queued up for animation later. + if (currentPlayers && currentPlayers.length) { + containsPotentialParentTransition = true; + } + else { + var /** @type {?} */ parent_1 = element; + while (parent_1 = parent_1.parentNode) { + var /** @type {?} */ triggers = engine.statesByElement.get(parent_1); + if (triggers) { + containsPotentialParentTransition = true; + break; + } + } + } + } + // at this stage we know that the element will either get removed + // during flush or will be picked up by a parent query. Either way + // we need to fire the listeners for this element when it DOES get + // removed (once the query parent animation is done or after flush) + this.prepareLeaveAnimationListeners(element); // whether or not a parent has an animation we need to delay the deferral of the leave // operation until we have more information (which we do after flush() has been called) if (containsPotentialParentTransition) { @@ -10113,12 +19366,21 @@ var AnimationTransitionNamespace = (function () { * @param {?} parent * @return {?} */ - AnimationTransitionNamespace.prototype.insertNode = function (element, parent) { addClass(element, this._hostClassName); }; + AnimationTransitionNamespace.prototype.insertNode = /** + * @param {?} element + * @param {?} parent + * @return {?} + */ + function (element, parent) { addClass(element, this._hostClassName); }; /** * @param {?} microtaskId * @return {?} */ - AnimationTransitionNamespace.prototype.drainQueuedTransitions = function (microtaskId) { + AnimationTransitionNamespace.prototype.drainQueuedTransitions = /** + * @param {?} microtaskId + * @return {?} + */ + function (microtaskId) { var _this = this; var /** @type {?} */ instructions = []; this._queue.forEach(function (entry) { @@ -10131,7 +19393,7 @@ var AnimationTransitionNamespace = (function () { listeners.forEach(function (listener) { if (listener.name == entry.triggerName) { var /** @type {?} */ baseEvent = makeAnimationEvent(element, entry.triggerName, entry.fromState.value, entry.toState.value); - ((baseEvent))['_data'] = microtaskId; + (/** @type {?} */ (baseEvent))['_data'] = microtaskId; listenOnPlayer(entry.player, listener.phase, baseEvent, listener.callback); } }); @@ -10163,15 +19425,23 @@ var AnimationTransitionNamespace = (function () { * @param {?} context * @return {?} */ - AnimationTransitionNamespace.prototype.destroy = function (context) { + AnimationTransitionNamespace.prototype.destroy = /** + * @param {?} context + * @return {?} + */ + function (context) { this.players.forEach(function (p) { return p.destroy(); }); - this._destroyInnerNodes(this.hostElement, context); + this._signalRemovalForInnerTriggers(this.hostElement, context); }; /** * @param {?} element * @return {?} */ - AnimationTransitionNamespace.prototype.elementContainsData = function (element) { + AnimationTransitionNamespace.prototype.elementContainsData = /** + * @param {?} element + * @return {?} + */ + function (element) { var /** @type {?} */ containsData = false; if (this._elementListeners.has(element)) containsData = true; @@ -10181,11 +19451,11 @@ var AnimationTransitionNamespace = (function () { }; return AnimationTransitionNamespace; }()); +/** + * @record + */ + var TransitionAnimationEngine = (function () { - /** - * @param {?} driver - * @param {?} _normalizer - */ function TransitionAnimationEngine(driver, _normalizer) { this.driver = driver; this._normalizer = _normalizer; @@ -10194,6 +19464,7 @@ var TransitionAnimationEngine = (function () { this.playersByElement = new Map(); this.playersByQueriedElement = new Map(); this.statesByElement = new Map(); + this.disabledNodes = new Set(); this.totalAnimations = 0; this.totalQueuedPlayers = 0; this._namespaceLookup = {}; @@ -10205,17 +19476,25 @@ var TransitionAnimationEngine = (function () { this.collectedLeaveElements = []; this.onRemovalComplete = function (element, context) { }; } + /** @internal */ /** + * \@internal * @param {?} element * @param {?} context * @return {?} */ - TransitionAnimationEngine.prototype._onRemovalComplete = function (element, context) { this.onRemovalComplete(element, context); }; - Object.defineProperty(TransitionAnimationEngine.prototype, "queuedPlayers", { - /** - * @return {?} + TransitionAnimationEngine.prototype._onRemovalComplete = /** + * \@internal + * @param {?} element + * @param {?} context + * @return {?} + */ + function (element, context) { this.onRemovalComplete(element, context); }; + Object.defineProperty(TransitionAnimationEngine.prototype, "queuedPlayers", { + get: /** + * @return {?} */ - get: function () { + function () { var /** @type {?} */ players = []; this._namespaceList.forEach(function (ns) { ns.players.forEach(function (player) { @@ -10234,7 +19513,12 @@ var TransitionAnimationEngine = (function () { * @param {?} hostElement * @return {?} */ - TransitionAnimationEngine.prototype.createNamespace = function (namespaceId, hostElement) { + TransitionAnimationEngine.prototype.createNamespace = /** + * @param {?} namespaceId + * @param {?} hostElement + * @return {?} + */ + function (namespaceId, hostElement) { var /** @type {?} */ ns = new AnimationTransitionNamespace(namespaceId, hostElement, this); if (hostElement.parentNode) { this._balanceNamespaceList(ns, hostElement); @@ -10258,7 +19542,12 @@ var TransitionAnimationEngine = (function () { * @param {?} hostElement * @return {?} */ - TransitionAnimationEngine.prototype._balanceNamespaceList = function (ns, hostElement) { + TransitionAnimationEngine.prototype._balanceNamespaceList = /** + * @param {?} ns + * @param {?} hostElement + * @return {?} + */ + function (ns, hostElement) { var /** @type {?} */ limit = this._namespaceList.length - 1; if (limit >= 0) { var /** @type {?} */ found = false; @@ -10285,7 +19574,12 @@ var TransitionAnimationEngine = (function () { * @param {?} hostElement * @return {?} */ - TransitionAnimationEngine.prototype.register = function (namespaceId, hostElement) { + TransitionAnimationEngine.prototype.register = /** + * @param {?} namespaceId + * @param {?} hostElement + * @return {?} + */ + function (namespaceId, hostElement) { var /** @type {?} */ ns = this._namespaceLookup[namespaceId]; if (!ns) { ns = this.createNamespace(namespaceId, hostElement); @@ -10298,7 +19592,13 @@ var TransitionAnimationEngine = (function () { * @param {?} trigger * @return {?} */ - TransitionAnimationEngine.prototype.registerTrigger = function (namespaceId, name, trigger) { + TransitionAnimationEngine.prototype.registerTrigger = /** + * @param {?} namespaceId + * @param {?} name + * @param {?} trigger + * @return {?} + */ + function (namespaceId, name, trigger) { var /** @type {?} */ ns = this._namespaceLookup[namespaceId]; if (ns && ns.register(name, trigger)) { this.totalAnimations++; @@ -10309,7 +19609,12 @@ var TransitionAnimationEngine = (function () { * @param {?} context * @return {?} */ - TransitionAnimationEngine.prototype.destroy = function (namespaceId, context) { + TransitionAnimationEngine.prototype.destroy = /** + * @param {?} namespaceId + * @param {?} context + * @return {?} + */ + function (namespaceId, context) { var _this = this; if (!namespaceId) return; @@ -10328,7 +19633,41 @@ var TransitionAnimationEngine = (function () { * @param {?} id * @return {?} */ - TransitionAnimationEngine.prototype._fetchNamespace = function (id) { return this._namespaceLookup[id]; }; + TransitionAnimationEngine.prototype._fetchNamespace = /** + * @param {?} id + * @return {?} + */ + function (id) { return this._namespaceLookup[id]; }; + /** + * @param {?} element + * @return {?} + */ + TransitionAnimationEngine.prototype.fetchNamespacesByElement = /** + * @param {?} element + * @return {?} + */ + function (element) { + // normally there should only be one namespace per element, however + // if @triggers are placed on both the component element and then + // its host element (within the component code) then there will be + // two namespaces returned. We use a set here to simply the dedupe + // of namespaces incase there are multiple triggers both the elm and host + var /** @type {?} */ namespaces = new Set(); + var /** @type {?} */ elementStates = this.statesByElement.get(element); + if (elementStates) { + var /** @type {?} */ keys = Object.keys(elementStates); + for (var /** @type {?} */ i = 0; i < keys.length; i++) { + var /** @type {?} */ nsId = elementStates[keys[i]].namespaceId; + if (nsId) { + var /** @type {?} */ ns = this._fetchNamespace(nsId); + if (ns) { + namespaces.add(ns); + } + } + } + } + return namespaces; + }; /** * @param {?} namespaceId * @param {?} element @@ -10336,7 +19675,14 @@ var TransitionAnimationEngine = (function () { * @param {?} value * @return {?} */ - TransitionAnimationEngine.prototype.trigger = function (namespaceId, element, name, value) { + TransitionAnimationEngine.prototype.trigger = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} name + * @param {?} value + * @return {?} + */ + function (namespaceId, element, name, value) { if (isElementNode(element)) { this._fetchNamespace(namespaceId).trigger(element, name, value); return true; @@ -10350,12 +19696,19 @@ var TransitionAnimationEngine = (function () { * @param {?} insertBefore * @return {?} */ - TransitionAnimationEngine.prototype.insertNode = function (namespaceId, element, parent, insertBefore) { + TransitionAnimationEngine.prototype.insertNode = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} parent + * @param {?} insertBefore + * @return {?} + */ + function (namespaceId, element, parent, insertBefore) { if (!isElementNode(element)) return; // special case for when an element is removed and reinserted (move operation) // when this occurs we do not want to use the element for deletion later - var /** @type {?} */ details = (element[REMOVAL_FLAG]); + var /** @type {?} */ details = /** @type {?} */ (element[REMOVAL_FLAG]); if (details && details.setForRemoval) { details.setForRemoval = false; } @@ -10374,22 +19727,53 @@ var TransitionAnimationEngine = (function () { * @param {?} element * @return {?} */ - TransitionAnimationEngine.prototype.collectEnterElement = function (element) { this.collectedEnterElements.push(element); }; + TransitionAnimationEngine.prototype.collectEnterElement = /** + * @param {?} element + * @return {?} + */ + function (element) { this.collectedEnterElements.push(element); }; + /** + * @param {?} element + * @param {?} value + * @return {?} + */ + TransitionAnimationEngine.prototype.markElementAsDisabled = /** + * @param {?} element + * @param {?} value + * @return {?} + */ + function (element, value) { + if (value) { + if (!this.disabledNodes.has(element)) { + this.disabledNodes.add(element); + addClass(element, DISABLED_CLASSNAME); + } + } + else if (this.disabledNodes.has(element)) { + this.disabledNodes.delete(element); + removeClass(element, DISABLED_CLASSNAME); + } + }; /** * @param {?} namespaceId * @param {?} element * @param {?} context - * @param {?=} doNotRecurse * @return {?} */ - TransitionAnimationEngine.prototype.removeNode = function (namespaceId, element, context, doNotRecurse) { + TransitionAnimationEngine.prototype.removeNode = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} context + * @return {?} + */ + function (namespaceId, element, context) { if (!isElementNode(element)) { this._onRemovalComplete(element, context); return; } var /** @type {?} */ ns = namespaceId ? this._fetchNamespace(namespaceId) : null; if (ns) { - ns.removeNode(element, context, doNotRecurse); + ns.removeNode(element, context); } else { this.markElementAsRemoved(namespaceId, element, false, context); @@ -10402,7 +19786,14 @@ var TransitionAnimationEngine = (function () { * @param {?=} context * @return {?} */ - TransitionAnimationEngine.prototype.markElementAsRemoved = function (namespaceId, element, hasAnimation, context) { + TransitionAnimationEngine.prototype.markElementAsRemoved = /** + * @param {?} namespaceId + * @param {?} element + * @param {?=} hasAnimation + * @param {?=} context + * @return {?} + */ + function (namespaceId, element, hasAnimation, context) { this.collectedLeaveElements.push(element); element[REMOVAL_FLAG] = { namespaceId: namespaceId, @@ -10418,7 +19809,15 @@ var TransitionAnimationEngine = (function () { * @param {?} callback * @return {?} */ - TransitionAnimationEngine.prototype.listen = function (namespaceId, element, name, phase, callback) { + TransitionAnimationEngine.prototype.listen = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} name + * @param {?} phase + * @param {?} callback + * @return {?} + */ + function (namespaceId, element, name, phase, callback) { if (isElementNode(element)) { return this._fetchNamespace(namespaceId).listen(element, name, phase, callback); } @@ -10429,52 +19828,80 @@ var TransitionAnimationEngine = (function () { * @param {?} subTimelines * @return {?} */ - TransitionAnimationEngine.prototype._buildInstruction = function (entry, subTimelines) { - return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, entry.toState.options, subTimelines); + TransitionAnimationEngine.prototype._buildInstruction = /** + * @param {?} entry + * @param {?} subTimelines + * @return {?} + */ + function (entry, subTimelines) { + return entry.transition.build(this.driver, entry.element, entry.fromState.value, entry.toState.value, entry.fromState.options, entry.toState.options, subTimelines); }; /** * @param {?} containerElement * @return {?} */ - TransitionAnimationEngine.prototype.destroyInnerAnimations = function (containerElement) { + TransitionAnimationEngine.prototype.destroyInnerAnimations = /** + * @param {?} containerElement + * @return {?} + */ + function (containerElement) { var _this = this; var /** @type {?} */ elements = this.driver.query(containerElement, NG_TRIGGER_SELECTOR, true); - elements.forEach(function (element) { - var /** @type {?} */ players = _this.playersByElement.get(element); - if (players) { - players.forEach(function (player) { - // special case for when an element is set for destruction, but hasn't started. - // in this situation we want to delay the destruction until the flush occurs - // so that any event listeners attached to the player are triggered. - if (player.queued) { - player.markedForDestroy = true; - } - else { - player.destroy(); - } - }); - } - var /** @type {?} */ stateMap = _this.statesByElement.get(element); - if (stateMap) { - Object.keys(stateMap).forEach(function (triggerName) { return stateMap[triggerName] = DELETED_STATE_VALUE; }); - } - }); + elements.forEach(function (element) { return _this.destroyActiveAnimationsForElement(element); }); if (this.playersByQueriedElement.size == 0) return; elements = this.driver.query(containerElement, NG_ANIMATING_SELECTOR, true); - if (elements.length) { - elements.forEach(function (element) { - var /** @type {?} */ players = _this.playersByQueriedElement.get(element); - if (players) { - players.forEach(function (player) { return player.finish(); }); + elements.forEach(function (element) { return _this.finishActiveQueriedAnimationOnElement(element); }); + }; + /** + * @param {?} element + * @return {?} + */ + TransitionAnimationEngine.prototype.destroyActiveAnimationsForElement = /** + * @param {?} element + * @return {?} + */ + function (element) { + var /** @type {?} */ players = this.playersByElement.get(element); + if (players) { + players.forEach(function (player) { + // special case for when an element is set for destruction, but hasn't started. + // in this situation we want to delay the destruction until the flush occurs + // so that any event listeners attached to the player are triggered. + if (player.queued) { + player.markedForDestroy = true; + } + else { + player.destroy(); } }); } + var /** @type {?} */ stateMap = this.statesByElement.get(element); + if (stateMap) { + Object.keys(stateMap).forEach(function (triggerName) { return stateMap[triggerName] = DELETED_STATE_VALUE; }); + } + }; + /** + * @param {?} element + * @return {?} + */ + TransitionAnimationEngine.prototype.finishActiveQueriedAnimationOnElement = /** + * @param {?} element + * @return {?} + */ + function (element) { + var /** @type {?} */ players = this.playersByQueriedElement.get(element); + if (players) { + players.forEach(function (player) { return player.finish(); }); + } }; /** * @return {?} */ - TransitionAnimationEngine.prototype.whenRenderingDone = function () { + TransitionAnimationEngine.prototype.whenRenderingDone = /** + * @return {?} + */ + function () { var _this = this; return new Promise(function (resolve) { if (_this.players.length) { @@ -10489,8 +19916,13 @@ var TransitionAnimationEngine = (function () { * @param {?} element * @return {?} */ - TransitionAnimationEngine.prototype.processLeaveNode = function (element) { - var /** @type {?} */ details = (element[REMOVAL_FLAG]); + TransitionAnimationEngine.prototype.processLeaveNode = /** + * @param {?} element + * @return {?} + */ + function (element) { + var _this = this; + var /** @type {?} */ details = /** @type {?} */ (element[REMOVAL_FLAG]); if (details && details.setForRemoval) { // this will prevent it from removing it twice element[REMOVAL_FLAG] = NULL_REMOVAL_STATE; @@ -10503,12 +19935,22 @@ var TransitionAnimationEngine = (function () { } this._onRemovalComplete(element, details.setForRemoval); } + if (this.driver.matchesElement(element, DISABLED_SELECTOR)) { + this.markElementAsDisabled(element, false); + } + this.driver.query(element, DISABLED_SELECTOR, true).forEach(function (node) { + _this.markElementAsDisabled(element, false); + }); }; /** * @param {?=} microtaskId * @return {?} */ - TransitionAnimationEngine.prototype.flush = function (microtaskId) { + TransitionAnimationEngine.prototype.flush = /** + * @param {?=} microtaskId + * @return {?} + */ + function (microtaskId) { var _this = this; if (microtaskId === void 0) { microtaskId = -1; } var /** @type {?} */ players = []; @@ -10518,7 +19960,15 @@ var TransitionAnimationEngine = (function () { } if (this._namespaceList.length && (this.totalQueuedPlayers || this.collectedLeaveElements.length)) { - players = this._flushAnimations(microtaskId); + var /** @type {?} */ cleanupFns = []; + try { + players = this._flushAnimations(cleanupFns, microtaskId); + } + finally { + for (var /** @type {?} */ i = 0; i < cleanupFns.length; i++) { + cleanupFns[i](); + } + } } else { for (var /** @type {?} */ i = 0; i < this.collectedLeaveElements.length; i++) { @@ -10546,10 +19996,27 @@ var TransitionAnimationEngine = (function () { } }; /** + * @param {?} errors + * @return {?} + */ + TransitionAnimationEngine.prototype.reportError = /** + * @param {?} errors + * @return {?} + */ + function (errors) { + throw new Error("Unable to process animations due to the following failed trigger transitions\n " + errors.join('\n')); + }; + /** + * @param {?} cleanupFns + * @param {?} microtaskId + * @return {?} + */ + TransitionAnimationEngine.prototype._flushAnimations = /** + * @param {?} cleanupFns * @param {?} microtaskId * @return {?} */ - TransitionAnimationEngine.prototype._flushAnimations = function (microtaskId) { + function (cleanupFns, microtaskId) { var _this = this; var /** @type {?} */ subTimelines = new ElementInstructionMap(); var /** @type {?} */ skippedPlayers = []; @@ -10558,6 +20025,14 @@ var TransitionAnimationEngine = (function () { var /** @type {?} */ queriedElements = new Map(); var /** @type {?} */ allPreStyleElements = new Map(); var /** @type {?} */ allPostStyleElements = new Map(); + var /** @type {?} */ disabledElementsSet = new Set(); + this.disabledNodes.forEach(function (node) { + disabledElementsSet.add(node); + var /** @type {?} */ nodesThatAreDisabled = _this.driver.query(node, QUEUED_SELECTOR, true); + for (var /** @type {?} */ i = 0; i < nodesThatAreDisabled.length; i++) { + disabledElementsSet.add(nodesThatAreDisabled[i]); + } + }); var /** @type {?} */ bodyNode = getBodyNode(); var /** @type {?} */ allEnterNodes = this.collectedEnterElements.length ? this.collectedEnterElements.filter(createIsRootFilterFn(this.collectedEnterElements)) : @@ -10569,30 +20044,42 @@ var TransitionAnimationEngine = (function () { addClass(allEnterNodes[i], ENTER_CLASSNAME); } var /** @type {?} */ allLeaveNodes = []; - var /** @type {?} */ leaveNodesWithoutAnimations = []; + var /** @type {?} */ leaveNodesWithoutAnimations = new Set(); for (var /** @type {?} */ i = 0; i < this.collectedLeaveElements.length; i++) { var /** @type {?} */ element = this.collectedLeaveElements[i]; - var /** @type {?} */ details = (element[REMOVAL_FLAG]); + var /** @type {?} */ details = /** @type {?} */ (element[REMOVAL_FLAG]); if (details && details.setForRemoval) { addClass(element, LEAVE_CLASSNAME); allLeaveNodes.push(element); if (!details.hasAnimation) { - leaveNodesWithoutAnimations.push(element); + leaveNodesWithoutAnimations.add(element); } } } + cleanupFns.push(function () { + allEnterNodes.forEach(function (element) { return removeClass(element, ENTER_CLASSNAME); }); + allLeaveNodes.forEach(function (element) { + removeClass(element, LEAVE_CLASSNAME); + _this.processLeaveNode(element); + }); + }); + var /** @type {?} */ allPlayers = []; + var /** @type {?} */ erroneousTransitions = []; for (var /** @type {?} */ i = this._namespaceList.length - 1; i >= 0; i--) { var /** @type {?} */ ns = this._namespaceList[i]; ns.drainQueuedTransitions(microtaskId).forEach(function (entry) { var /** @type {?} */ player = entry.player; + allPlayers.push(player); var /** @type {?} */ element = entry.element; if (!bodyNode || !_this.driver.containsElement(bodyNode, element)) { player.destroy(); return; } - var /** @type {?} */ instruction = _this._buildInstruction(entry, subTimelines); - if (!instruction) + var /** @type {?} */ instruction = /** @type {?} */ ((_this._buildInstruction(entry, subTimelines))); + if (instruction.errors && instruction.errors.length) { + erroneousTransitions.push(instruction); return; + } // if a unmatched transition is queued to go then it SHOULD NOT render // an animation and cancel the previously running animations. if (entry.isFallbackTransition) { @@ -10614,7 +20101,7 @@ var TransitionAnimationEngine = (function () { instruction.preStyleProps.forEach(function (stringMap, element) { var /** @type {?} */ props = Object.keys(stringMap); if (props.length) { - var /** @type {?} */ setVal_1 = ((allPreStyleElements.get(element))); + var /** @type {?} */ setVal_1 = /** @type {?} */ ((allPreStyleElements.get(element))); if (!setVal_1) { allPreStyleElements.set(element, setVal_1 = new Set()); } @@ -10623,7 +20110,7 @@ var TransitionAnimationEngine = (function () { }); instruction.postStyleProps.forEach(function (stringMap, element) { var /** @type {?} */ props = Object.keys(stringMap); - var /** @type {?} */ setVal = ((allPostStyleElements.get(element))); + var /** @type {?} */ setVal = /** @type {?} */ ((allPostStyleElements.get(element))); if (!setVal) { allPostStyleElements.set(element, setVal = new Set()); } @@ -10631,13 +20118,24 @@ var TransitionAnimationEngine = (function () { }); }); } + if (erroneousTransitions.length) { + var /** @type {?} */ errors_1 = []; + erroneousTransitions.forEach(function (instruction) { + errors_1.push("@" + instruction.triggerName + " has failed due to:\n"); /** @type {?} */ + ((instruction.errors)).forEach(function (error) { return errors_1.push("- " + error + "\n"); }); + }); + allPlayers.forEach(function (player) { return player.destroy(); }); + this.reportError(errors_1); + } // these can only be detected here since we have a map of all the elements - // that have animations attached to them... - var /** @type {?} */ enterNodesWithoutAnimations = []; + // that have animations attached to them... We use a set here in the event + // multiple enter captures on the same element were caught in different + // renderer namespaces (e.g. when a @trigger was on a host binding that had *ngIf) + var /** @type {?} */ enterNodesWithoutAnimations = new Set(); for (var /** @type {?} */ i = 0; i < allEnterNodes.length; i++) { var /** @type {?} */ element = allEnterNodes[i]; if (!subTimelines.has(element)) { - enterNodesWithoutAnimations.push(element); + enterNodesWithoutAnimations.add(element); } } var /** @type {?} */ allPreviousPlayersMap = new Map(); @@ -10652,15 +20150,37 @@ var TransitionAnimationEngine = (function () { skippedPlayers.forEach(function (player) { var /** @type {?} */ element = player.element; var /** @type {?} */ previousPlayers = _this._getPreviousPlayers(element, false, player.namespaceId, player.triggerName, null); - previousPlayers.forEach(function (prevPlayer) { getOrSetAsInMap(allPreviousPlayersMap, element, []).push(prevPlayer); }); + previousPlayers.forEach(function (prevPlayer) { + getOrSetAsInMap(allPreviousPlayersMap, element, []).push(prevPlayer); + prevPlayer.destroy(); + }); + }); + // this is a special case for nodes that will be removed (either by) + // having their own leave animations or by being queried in a container + // that will be removed once a parent animation is complete. The idea + // here is that * styles must be identical to ! styles because of + // backwards compatibility (* is also filled in by default in many places). + // Otherwise * styles will return an empty value or auto since the element + // that is being getComputedStyle'd will not be visible (since * = destination) + var /** @type {?} */ replaceNodes = allLeaveNodes.filter(function (node) { + return replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements); + }); + // POST STAGE: fill the * styles + var _a = cloakAndComputeStyles(this.driver, leaveNodesWithoutAnimations, allPostStyleElements, _angular_animations.AUTO_STYLE), postStylesMap = _a[0], allLeaveQueriedNodes = _a[1]; + allLeaveQueriedNodes.forEach(function (node) { + if (replacePostStylesAsPre(node, allPreStyleElements, allPostStyleElements)) { + replaceNodes.push(node); + } }); - allPreviousPlayersMap.forEach(function (players) { return players.forEach(function (player) { return player.destroy(); }); }); // PRE STAGE: fill the ! styles - var /** @type {?} */ preStylesMap = allPreStyleElements.size ? + var preStylesMap = (allPreStyleElements.size ? cloakAndComputeStyles(this.driver, enterNodesWithoutAnimations, allPreStyleElements, _angular_animations.ɵPRE_STYLE) : - new Map(); - // POST STAGE: fill the * styles - var /** @type {?} */ postStylesMap = cloakAndComputeStyles(this.driver, leaveNodesWithoutAnimations, allPostStyleElements, _angular_animations.AUTO_STYLE); + [new Map()])[0]; + replaceNodes.forEach(function (node) { + var /** @type {?} */ post = postStylesMap.get(node); + var /** @type {?} */ pre = preStylesMap.get(node); + postStylesMap.set(node, /** @type {?} */ (__assign({}, post, pre))); + }); var /** @type {?} */ rootPlayers = []; var /** @type {?} */ subPlayers = []; queuedInstructions.forEach(function (entry) { @@ -10668,15 +20188,19 @@ var TransitionAnimationEngine = (function () { // this means that it was never consumed by a parent animation which // means that it is independent and therefore should be set for animation if (subTimelines.has(element)) { + if (disabledElementsSet.has(element)) { + skippedPlayers.push(player); + return; + } var /** @type {?} */ innerPlayer = _this._buildAnimation(player.namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap); player.setRealPlayer(innerPlayer); var /** @type {?} */ parentHasPriority = null; for (var /** @type {?} */ i = 0; i < sortedParentElements.length; i++) { - var /** @type {?} */ parent = sortedParentElements[i]; - if (parent === element) + var /** @type {?} */ parent_2 = sortedParentElements[i]; + if (parent_2 === element) break; - if (_this.driver.containsElement(parent, element)) { - parentHasPriority = parent; + if (_this.driver.containsElement(parent_2, element)) { + parentHasPriority = parent_2; break; } } @@ -10694,10 +20218,19 @@ var TransitionAnimationEngine = (function () { else { eraseStyles(element, instruction.fromStyles); player.onDestroy(function () { return setStyles(element, instruction.toStyles); }); + // there still might be a ancestor player animating this + // element therefore we will still add it as a sub player + // even if its animation may be disabled subPlayers.push(player); + if (disabledElementsSet.has(element)) { + skippedPlayers.push(player); + } } }); + // find all of the sub players' corresponding inner animation player subPlayers.forEach(function (player) { + // even if any players are not found for a sub animation then it + // will still complete itself after the next tick since it's Noop var /** @type {?} */ playersForElement = skippedPlayersMap.get(player.element); if (playersForElement && playersForElement.length) { var /** @type {?} */ innerPlayer = optimizeGroupPlayer(playersForElement); @@ -10720,7 +20253,8 @@ var TransitionAnimationEngine = (function () { // operation right away unless a parent animation is ongoing. for (var /** @type {?} */ i = 0; i < allLeaveNodes.length; i++) { var /** @type {?} */ element = allLeaveNodes[i]; - var /** @type {?} */ details = (element[REMOVAL_FLAG]); + var /** @type {?} */ details = /** @type {?} */ (element[REMOVAL_FLAG]); + removeClass(element, LEAVE_CLASSNAME); // this means the element has a removal animation that is being // taken care of and therefore the inner elements will hang around // until that animation is over (or the parent queried animation) @@ -10743,13 +20277,16 @@ var TransitionAnimationEngine = (function () { } } } - if (players.length) { - removeNodesAfterAnimationDone(this, element, players); + var /** @type {?} */ activePlayers = players.filter(function (p) { return !p.destroyed; }); + if (activePlayers.length) { + removeNodesAfterAnimationDone(this, element, activePlayers); } else { this.processLeaveNode(element); } } + // this is required so the cleanup method doesn't remove them + allLeaveNodes.length = 0; rootPlayers.forEach(function (player) { _this.players.push(player); player.onDone(function () { @@ -10759,7 +20296,6 @@ var TransitionAnimationEngine = (function () { }); player.play(); }); - allEnterNodes.forEach(function (element) { return removeClass(element, ENTER_CLASSNAME); }); return rootPlayers; }; /** @@ -10767,9 +20303,14 @@ var TransitionAnimationEngine = (function () { * @param {?} element * @return {?} */ - TransitionAnimationEngine.prototype.elementContainsData = function (namespaceId, element) { + TransitionAnimationEngine.prototype.elementContainsData = /** + * @param {?} namespaceId + * @param {?} element + * @return {?} + */ + function (namespaceId, element) { var /** @type {?} */ containsData = false; - var /** @type {?} */ details = (element[REMOVAL_FLAG]); + var /** @type {?} */ details = /** @type {?} */ (element[REMOVAL_FLAG]); if (details && details.setForRemoval) containsData = true; if (this.playersByElement.has(element)) @@ -10784,12 +20325,20 @@ var TransitionAnimationEngine = (function () { * @param {?} callback * @return {?} */ - TransitionAnimationEngine.prototype.afterFlush = function (callback) { this._flushFns.push(callback); }; + TransitionAnimationEngine.prototype.afterFlush = /** + * @param {?} callback + * @return {?} + */ + function (callback) { this._flushFns.push(callback); }; /** * @param {?} callback * @return {?} */ - TransitionAnimationEngine.prototype.afterFlushAnimationsDone = function (callback) { this._whenQuietFns.push(callback); }; + TransitionAnimationEngine.prototype.afterFlushAnimationsDone = /** + * @param {?} callback + * @return {?} + */ + function (callback) { this._whenQuietFns.push(callback); }; /** * @param {?} element * @param {?} isQueriedElement @@ -10798,7 +20347,15 @@ var TransitionAnimationEngine = (function () { * @param {?=} toStateValue * @return {?} */ - TransitionAnimationEngine.prototype._getPreviousPlayers = function (element, isQueriedElement, namespaceId, triggerName, toStateValue) { + TransitionAnimationEngine.prototype._getPreviousPlayers = /** + * @param {?} element + * @param {?} isQueriedElement + * @param {?=} namespaceId + * @param {?=} triggerName + * @param {?=} toStateValue + * @return {?} + */ + function (element, isQueriedElement, namespaceId, triggerName, toStateValue) { var /** @type {?} */ players = []; if (isQueriedElement) { var /** @type {?} */ queriedElementPlayers = this.playersByQueriedElement.get(element); @@ -10836,11 +20393,14 @@ var TransitionAnimationEngine = (function () { * @param {?} allPreviousPlayersMap * @return {?} */ - TransitionAnimationEngine.prototype._beforeAnimationBuild = function (namespaceId, instruction, allPreviousPlayersMap) { + TransitionAnimationEngine.prototype._beforeAnimationBuild = /** + * @param {?} namespaceId + * @param {?} instruction + * @param {?} allPreviousPlayersMap + * @return {?} + */ + function (namespaceId, instruction, allPreviousPlayersMap) { var _this = this; - // it's important to do this step before destroying the players - // so that the onDone callback below won't fire before this - eraseStyles(instruction.element, instruction.fromStyles); var /** @type {?} */ triggerName = instruction.triggerName; var /** @type {?} */ rootElement = instruction.element; // when a removal animation occurs, ALL previous players are collected @@ -10853,13 +20413,17 @@ var TransitionAnimationEngine = (function () { var /** @type {?} */ players = getOrSetAsInMap(allPreviousPlayersMap, element, []); var /** @type {?} */ previousPlayers = _this._getPreviousPlayers(element, isQueriedElement, targetNameSpaceId, targetTriggerName, instruction.toState); previousPlayers.forEach(function (player) { - var /** @type {?} */ realPlayer = (player.getRealPlayer()); + var /** @type {?} */ realPlayer = /** @type {?} */ (player.getRealPlayer()); if (realPlayer.beforeDestroy) { realPlayer.beforeDestroy(); } + player.destroy(); players.push(player); }); }); + // this needs to be done so that the PRE/POST styles can be + // computed properly without interfering with the previous animation + eraseStyles(rootElement, instruction.fromStyles); }; /** * @param {?} namespaceId @@ -10870,7 +20434,16 @@ var TransitionAnimationEngine = (function () { * @param {?} postStylesMap * @return {?} */ - TransitionAnimationEngine.prototype._buildAnimation = function (namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap) { + TransitionAnimationEngine.prototype._buildAnimation = /** + * @param {?} namespaceId + * @param {?} instruction + * @param {?} allPreviousPlayersMap + * @param {?} skippedPlayersMap + * @param {?} preStylesMap + * @param {?} postStylesMap + * @return {?} + */ + function (namespaceId, instruction, allPreviousPlayersMap, skippedPlayersMap, preStylesMap, postStylesMap) { var _this = this; var /** @type {?} */ triggerName = instruction.triggerName; var /** @type {?} */ rootElement = instruction.element; @@ -10881,19 +20454,22 @@ var TransitionAnimationEngine = (function () { var /** @type {?} */ allSubElements = new Set(); var /** @type {?} */ allNewPlayers = instruction.timelines.map(function (timelineInstruction) { var /** @type {?} */ element = timelineInstruction.element; + allConsumedElements.add(element); // FIXME (matsko): make sure to-be-removed animations are removed properly var /** @type {?} */ details = element[REMOVAL_FLAG]; if (details && details.removedBeforeQueried) return new _angular_animations.NoopAnimationPlayer(); var /** @type {?} */ isQueriedElement = element !== rootElement; - var /** @type {?} */ previousPlayers = EMPTY_PLAYER_ARRAY; - if (!allConsumedElements.has(element)) { - allConsumedElements.add(element); - var /** @type {?} */ _previousPlayers = allPreviousPlayersMap.get(element); - if (_previousPlayers) { - previousPlayers = _previousPlayers.map(function (p) { return p.getRealPlayer(); }); - } - } + var /** @type {?} */ previousPlayers = flattenGroupPlayers((allPreviousPlayersMap.get(element) || EMPTY_PLAYER_ARRAY) + .map(function (p) { return p.getRealPlayer(); })) + .filter(function (p) { + // the `element` is not apart of the AnimationPlayer definition, but + // Mock/WebAnimations + // use the element within their implementation. This will be added in Angular5 to + // AnimationPlayer + var /** @type {?} */ pp = /** @type {?} */ (p); + return pp.element ? pp.element === element : false; + }); var /** @type {?} */ preStyles = preStylesMap.get(element); var /** @type {?} */ postStyles = postStylesMap.get(element); var /** @type {?} */ keyframes = normalizeKeyframes(_this.driver, _this._normalizer, element, timelineInstruction.keyframes, preStyles, postStyles); @@ -10931,7 +20507,13 @@ var TransitionAnimationEngine = (function () { * @param {?} previousPlayers * @return {?} */ - TransitionAnimationEngine.prototype._buildPlayer = function (instruction, keyframes, previousPlayers) { + TransitionAnimationEngine.prototype._buildPlayer = /** + * @param {?} instruction + * @param {?} keyframes + * @param {?} previousPlayers + * @return {?} + */ + function (instruction, keyframes, previousPlayers) { if (keyframes.length > 0) { return this.driver.animate(instruction.element, keyframes, instruction.duration, instruction.delay, instruction.easing, previousPlayers); } @@ -10942,11 +20524,6 @@ var TransitionAnimationEngine = (function () { return TransitionAnimationEngine; }()); var TransitionAnimationPlayer = (function () { - /** - * @param {?} namespaceId - * @param {?} triggerName - * @param {?} element - */ function TransitionAnimationPlayer(namespaceId, triggerName, element) { this.namespaceId = namespaceId; this.triggerName = triggerName; @@ -10954,22 +20531,14 @@ var TransitionAnimationPlayer = (function () { this._player = new _angular_animations.NoopAnimationPlayer(); this._containsRealPlayer = false; this._queuedCallbacks = {}; - this._destroyed = false; + this.destroyed = false; this.markedForDestroy = false; } Object.defineProperty(TransitionAnimationPlayer.prototype, "queued", { - /** - * @return {?} - */ - get: function () { return this._containsRealPlayer == false; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(TransitionAnimationPlayer.prototype, "destroyed", { - /** + get: /** * @return {?} */ - get: function () { return this._destroyed; }, + function () { return this._containsRealPlayer == false; }, enumerable: true, configurable: true }); @@ -10977,7 +20546,11 @@ var TransitionAnimationPlayer = (function () { * @param {?} player * @return {?} */ - TransitionAnimationPlayer.prototype.setRealPlayer = function (player) { + TransitionAnimationPlayer.prototype.setRealPlayer = /** + * @param {?} player + * @return {?} + */ + function (player) { var _this = this; if (this._containsRealPlayer) return; @@ -10991,20 +20564,32 @@ var TransitionAnimationPlayer = (function () { /** * @return {?} */ - TransitionAnimationPlayer.prototype.getRealPlayer = function () { return this._player; }; + TransitionAnimationPlayer.prototype.getRealPlayer = /** + * @return {?} + */ + function () { return this._player; }; /** * @param {?} name * @param {?} callback * @return {?} */ - TransitionAnimationPlayer.prototype._queueEvent = function (name, callback) { + TransitionAnimationPlayer.prototype._queueEvent = /** + * @param {?} name + * @param {?} callback + * @return {?} + */ + function (name, callback) { getOrSetAsInMap(this._queuedCallbacks, name, []).push(callback); }; /** * @param {?} fn * @return {?} */ - TransitionAnimationPlayer.prototype.onDone = function (fn) { + TransitionAnimationPlayer.prototype.onDone = /** + * @param {?} fn + * @return {?} + */ + function (fn) { if (this.queued) { this._queueEvent('done', fn); } @@ -11014,7 +20599,11 @@ var TransitionAnimationPlayer = (function () { * @param {?} fn * @return {?} */ - TransitionAnimationPlayer.prototype.onStart = function (fn) { + TransitionAnimationPlayer.prototype.onStart = /** + * @param {?} fn + * @return {?} + */ + function (fn) { if (this.queued) { this._queueEvent('start', fn); } @@ -11024,7 +20613,11 @@ var TransitionAnimationPlayer = (function () { * @param {?} fn * @return {?} */ - TransitionAnimationPlayer.prototype.onDestroy = function (fn) { + TransitionAnimationPlayer.prototype.onDestroy = /** + * @param {?} fn + * @return {?} + */ + function (fn) { if (this.queued) { this._queueEvent('destroy', fn); } @@ -11033,56 +20626,87 @@ var TransitionAnimationPlayer = (function () { /** * @return {?} */ - TransitionAnimationPlayer.prototype.init = function () { this._player.init(); }; - /** + TransitionAnimationPlayer.prototype.init = /** * @return {?} */ - TransitionAnimationPlayer.prototype.hasStarted = function () { return this.queued ? false : this._player.hasStarted(); }; + function () { this._player.init(); }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.play = function () { !this.queued && this._player.play(); }; - /** + TransitionAnimationPlayer.prototype.hasStarted = /** * @return {?} */ - TransitionAnimationPlayer.prototype.pause = function () { !this.queued && this._player.pause(); }; + function () { return this.queued ? false : this._player.hasStarted(); }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.restart = function () { !this.queued && this._player.restart(); }; - /** + TransitionAnimationPlayer.prototype.play = /** * @return {?} */ - TransitionAnimationPlayer.prototype.finish = function () { this._player.finish(); }; + function () { !this.queued && this._player.play(); }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.destroy = function () { - this._destroyed = true; - this._player.destroy(); - }; - /** + TransitionAnimationPlayer.prototype.pause = /** * @return {?} */ - TransitionAnimationPlayer.prototype.reset = function () { !this.queued && this._player.reset(); }; + function () { !this.queued && this._player.pause(); }; /** - * @param {?} p * @return {?} */ - TransitionAnimationPlayer.prototype.setPosition = function (p) { - if (!this.queued) { - this._player.setPosition(p); - } - }; + TransitionAnimationPlayer.prototype.restart = /** + * @return {?} + */ + function () { !this.queued && this._player.restart(); }; /** * @return {?} */ - TransitionAnimationPlayer.prototype.getPosition = function () { return this.queued ? 0 : this._player.getPosition(); }; + TransitionAnimationPlayer.prototype.finish = /** + * @return {?} + */ + function () { this._player.finish(); }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.destroy = /** + * @return {?} + */ + function () { + (/** @type {?} */ (this)).destroyed = true; + this._player.destroy(); + }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.reset = /** + * @return {?} + */ + function () { !this.queued && this._player.reset(); }; + /** + * @param {?} p + * @return {?} + */ + TransitionAnimationPlayer.prototype.setPosition = /** + * @param {?} p + * @return {?} + */ + function (p) { + if (!this.queued) { + this._player.setPosition(p); + } + }; + /** + * @return {?} + */ + TransitionAnimationPlayer.prototype.getPosition = /** + * @return {?} + */ + function () { return this.queued ? 0 : this._player.getPosition(); }; Object.defineProperty(TransitionAnimationPlayer.prototype, "totalTime", { - /** + get: /** * @return {?} */ - get: function () { return this._player.totalTime; }, + function () { return this._player.totalTime; }, enumerable: true, configurable: true }); @@ -11127,12 +20751,10 @@ function deleteOrUnsetInMap(map, key, value) { * @return {?} */ function normalizeTriggerValue(value) { - switch (typeof value) { - case 'boolean': - return value ? '1' : '0'; - default: - return value != null ? value.toString() : null; - } + // we use `!= null` here because it's the most simple + // way to test against a "falsy" value without mixing + // in empty strings or a zero value. DO NOT OPTIMIZE. + return value != null ? value : null; } /** * @param {?} node @@ -11166,8 +20788,10 @@ function cloakElement(element, value) { * @return {?} */ function cloakAndComputeStyles(driver, elements, elementPropsMap, defaultStyle) { - var /** @type {?} */ cloakVals = elements.map(function (element) { return cloakElement(element); }); + var /** @type {?} */ cloakVals = []; + elements.forEach(function (element) { return cloakVals.push(cloakElement(element)); }); var /** @type {?} */ valuesMap = new Map(); + var /** @type {?} */ failedElements = []; elementPropsMap.forEach(function (props, element) { var /** @type {?} */ styles = {}; props.forEach(function (prop) { @@ -11176,12 +20800,16 @@ function cloakAndComputeStyles(driver, elements, elementPropsMap, defaultStyle) // by a parent animation element being detached. if (!value || value.length == 0) { element[REMOVAL_FLAG] = NULL_REMOVED_QUERIED_STATE; + failedElements.push(element); } }); valuesMap.set(element, styles); }); - elements.forEach(function (element, i) { return cloakElement(element, cloakVals[i]); }); - return valuesMap; + // we use a index variable here since Set.forEach(a, i) does not return + // an index value for the closure (but instead just the value) + var /** @type {?} */ i = 0; + elements.forEach(function (element) { return cloakElement(element, cloakVals[i++]); }); + return [valuesMap, failedElements]; } /** * @param {?} nodes @@ -11207,20 +20835,6 @@ function createIsRootFilterFn(nodes) { return isRoot; } var CLASSES_CACHE_KEY = '$$classes'; -/** - * @param {?} element - * @param {?} className - * @return {?} - */ -function containsClass(element, className) { - if (element.classList) { - return element.classList.contains(className); - } - else { - var /** @type {?} */ classes = element[CLASSES_CACHE_KEY]; - return classes && classes[className]; - } -} /** * @param {?} element * @param {?} className @@ -11255,43 +20869,92 @@ function removeClass(element, className) { } } /** + * @param {?} engine + * @param {?} element + * @param {?} players * @return {?} */ -function getBodyNode() { - if (typeof document != 'undefined') { - return document.body; +function removeNodesAfterAnimationDone(engine, element, players) { + optimizeGroupPlayer(players).onDone(function () { return engine.processLeaveNode(element); }); +} +/** + * @param {?} players + * @return {?} + */ +function flattenGroupPlayers(players) { + var /** @type {?} */ finalPlayers = []; + _flattenGroupPlayersRecur(players, finalPlayers); + return finalPlayers; +} +/** + * @param {?} players + * @param {?} finalPlayers + * @return {?} + */ +function _flattenGroupPlayersRecur(players, finalPlayers) { + for (var /** @type {?} */ i = 0; i < players.length; i++) { + var /** @type {?} */ player = players[i]; + if (player instanceof _angular_animations.ɵAnimationGroupPlayer) { + _flattenGroupPlayersRecur(player.players, finalPlayers); + } + else { + finalPlayers.push(/** @type {?} */ (player)); + } } - return null; } /** - * @param {?} engine + * @param {?} a + * @param {?} b + * @return {?} + */ +function objEquals(a, b) { + var /** @type {?} */ k1 = Object.keys(a); + var /** @type {?} */ k2 = Object.keys(b); + if (k1.length != k2.length) + return false; + for (var /** @type {?} */ i = 0; i < k1.length; i++) { + var /** @type {?} */ prop = k1[i]; + if (!b.hasOwnProperty(prop) || a[prop] !== b[prop]) + return false; + } + return true; +} +/** * @param {?} element - * @param {?} players + * @param {?} allPreStyleElements + * @param {?} allPostStyleElements * @return {?} */ -function removeNodesAfterAnimationDone(engine, element, players) { - optimizeGroupPlayer(players).onDone(function () { return engine.processLeaveNode(element); }); +function replacePostStylesAsPre(element, allPreStyleElements, allPostStyleElements) { + var /** @type {?} */ postEntry = allPostStyleElements.get(element); + if (!postEntry) + return false; + var /** @type {?} */ preEntry = allPreStyleElements.get(element); + if (preEntry) { + postEntry.forEach(function (data) { return /** @type {?} */ ((preEntry)).add(data); }); + } + else { + allPreStyleElements.set(element, postEntry); + } + allPostStyleElements.delete(element); + return true; } + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ var AnimationEngine = (function () { - /** - * @param {?} driver - * @param {?} normalizer - */ - function AnimationEngine(driver, normalizer) { + function AnimationEngine(_driver, normalizer) { var _this = this; + this._driver = _driver; this._triggerCache = {}; this.onRemovalComplete = function (element, context) { }; - this._transitionEngine = new TransitionAnimationEngine(driver, normalizer); - this._timelineEngine = new TimelineAnimationEngine(driver, normalizer); - this._transitionEngine.onRemovalComplete = - function (element, context) { _this.onRemovalComplete(element, context); }; + this._transitionEngine = new TransitionAnimationEngine(_driver, normalizer); + this._timelineEngine = new TimelineAnimationEngine(_driver, normalizer); + this._transitionEngine.onRemovalComplete = function (element, context) { + return _this.onRemovalComplete(element, context); + }; } /** * @param {?} componentId @@ -11301,12 +20964,20 @@ var AnimationEngine = (function () { * @param {?} metadata * @return {?} */ - AnimationEngine.prototype.registerTrigger = function (componentId, namespaceId, hostElement, name, metadata) { + AnimationEngine.prototype.registerTrigger = /** + * @param {?} componentId + * @param {?} namespaceId + * @param {?} hostElement + * @param {?} name + * @param {?} metadata + * @return {?} + */ + function (componentId, namespaceId, hostElement, name, metadata) { var /** @type {?} */ cacheKey = componentId + '-' + name; var /** @type {?} */ trigger = this._triggerCache[cacheKey]; if (!trigger) { var /** @type {?} */ errors = []; - var /** @type {?} */ ast = (buildAnimationAst(/** @type {?} */ (metadata), errors)); + var /** @type {?} */ ast = /** @type {?} */ (buildAnimationAst(this._driver, /** @type {?} */ (metadata), errors)); if (errors.length) { throw new Error("The animation trigger \"" + name + "\" has failed to build due to the following errors:\n - " + errors.join("\n - ")); } @@ -11320,7 +20991,12 @@ var AnimationEngine = (function () { * @param {?} hostElement * @return {?} */ - AnimationEngine.prototype.register = function (namespaceId, hostElement) { + AnimationEngine.prototype.register = /** + * @param {?} namespaceId + * @param {?} hostElement + * @return {?} + */ + function (namespaceId, hostElement) { this._transitionEngine.register(namespaceId, hostElement); }; /** @@ -11328,7 +21004,12 @@ var AnimationEngine = (function () { * @param {?} context * @return {?} */ - AnimationEngine.prototype.destroy = function (namespaceId, context) { + AnimationEngine.prototype.destroy = /** + * @param {?} namespaceId + * @param {?} context + * @return {?} + */ + function (namespaceId, context) { this._transitionEngine.destroy(namespaceId, context); }; /** @@ -11338,7 +21019,14 @@ var AnimationEngine = (function () { * @param {?} insertBefore * @return {?} */ - AnimationEngine.prototype.onInsert = function (namespaceId, element, parent, insertBefore) { + AnimationEngine.prototype.onInsert = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} parent + * @param {?} insertBefore + * @return {?} + */ + function (namespaceId, element, parent, insertBefore) { this._transitionEngine.insertNode(namespaceId, element, parent, insertBefore); }; /** @@ -11347,9 +21035,28 @@ var AnimationEngine = (function () { * @param {?} context * @return {?} */ - AnimationEngine.prototype.onRemove = function (namespaceId, element, context) { + AnimationEngine.prototype.onRemove = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} context + * @return {?} + */ + function (namespaceId, element, context) { this._transitionEngine.removeNode(namespaceId, element, context); }; + /** + * @param {?} element + * @param {?} disable + * @return {?} + */ + AnimationEngine.prototype.disableAnimations = /** + * @param {?} element + * @param {?} disable + * @return {?} + */ + function (element, disable) { + this._transitionEngine.markElementAsDisabled(element, disable); + }; /** * @param {?} namespaceId * @param {?} element @@ -11357,15 +21064,22 @@ var AnimationEngine = (function () { * @param {?} value * @return {?} */ - AnimationEngine.prototype.setProperty = function (namespaceId, element, property, value) { - // @@property + AnimationEngine.prototype.process = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} property + * @param {?} value + * @return {?} + */ + function (namespaceId, element, property, value) { if (property.charAt(0) == '@') { var _a = parseTimelineCommand(property), id = _a[0], action = _a[1]; - var /** @type {?} */ args = (value); + var /** @type {?} */ args = /** @type {?} */ (value); this._timelineEngine.command(id, element, action, args); - return false; } - return this._transitionEngine.trigger(namespaceId, element, property, value); + else { + this._transitionEngine.trigger(namespaceId, element, property, value); + } }; /** * @param {?} namespaceId @@ -11375,7 +21089,15 @@ var AnimationEngine = (function () { * @param {?} callback * @return {?} */ - AnimationEngine.prototype.listen = function (namespaceId, element, eventName, eventPhase, callback) { + AnimationEngine.prototype.listen = /** + * @param {?} namespaceId + * @param {?} element + * @param {?} eventName + * @param {?} eventPhase + * @param {?} callback + * @return {?} + */ + function (namespaceId, element, eventName, eventPhase, callback) { // @@listen if (eventName.charAt(0) == '@') { var _a = parseTimelineCommand(eventName), id = _a[0], action = _a[1]; @@ -11387,16 +21109,20 @@ var AnimationEngine = (function () { * @param {?=} microtaskId * @return {?} */ - AnimationEngine.prototype.flush = function (microtaskId) { + AnimationEngine.prototype.flush = /** + * @param {?=} microtaskId + * @return {?} + */ + function (microtaskId) { if (microtaskId === void 0) { microtaskId = -1; } this._transitionEngine.flush(microtaskId); }; Object.defineProperty(AnimationEngine.prototype, "players", { - /** + get: /** * @return {?} */ - get: function () { - return ((this._transitionEngine.players)) + function () { + return (/** @type {?} */ (this._transitionEngine.players)) .concat(/** @type {?} */ (this._timelineEngine.players)); }, enumerable: true, @@ -11405,23 +21131,18 @@ var AnimationEngine = (function () { /** * @return {?} */ - AnimationEngine.prototype.whenRenderingDone = function () { return this._transitionEngine.whenRenderingDone(); }; + AnimationEngine.prototype.whenRenderingDone = /** + * @return {?} + */ + function () { return this._transitionEngine.whenRenderingDone(); }; return AnimationEngine; }()); + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ var WebAnimationsPlayer = (function () { - /** - * @param {?} element - * @param {?} keyframes - * @param {?} options - * @param {?=} previousPlayers - */ function WebAnimationsPlayer(element, keyframes, options, previousPlayers) { if (previousPlayers === void 0) { previousPlayers = []; } var _this = this; @@ -11438,20 +21159,25 @@ var WebAnimationsPlayer = (function () { this._destroyed = false; this.time = 0; this.parentPlayer = null; + this.previousStyles = {}; this.currentSnapshot = {}; - this._duration = options['duration']; - this._delay = options['delay'] || 0; + this._duration = /** @type {?} */ (options['duration']); + this._delay = /** @type {?} */ (options['delay']) || 0; this.time = this._duration + this._delay; - this.previousStyles = {}; - previousPlayers.forEach(function (player) { - var styles = player.currentSnapshot; - Object.keys(styles).forEach(function (prop) { return _this.previousStyles[prop] = styles[prop]; }); - }); + if (allowPreviousPlayerStylesMerge(this._duration, this._delay)) { + previousPlayers.forEach(function (player) { + var /** @type {?} */ styles = player.currentSnapshot; + Object.keys(styles).forEach(function (prop) { return _this.previousStyles[prop] = styles[prop]; }); + }); + } } /** * @return {?} */ - WebAnimationsPlayer.prototype._onFinish = function () { + WebAnimationsPlayer.prototype._onFinish = /** + * @return {?} + */ + function () { if (!this._finished) { this._finished = true; this._onDoneFns.forEach(function (fn) { return fn(); }); @@ -11461,14 +21187,20 @@ var WebAnimationsPlayer = (function () { /** * @return {?} */ - WebAnimationsPlayer.prototype.init = function () { + WebAnimationsPlayer.prototype.init = /** + * @return {?} + */ + function () { this._buildPlayer(); this._preparePlayerBeforeStart(); }; /** * @return {?} */ - WebAnimationsPlayer.prototype._buildPlayer = function () { + WebAnimationsPlayer.prototype._buildPlayer = /** + * @return {?} + */ + function () { var _this = this; if (this._initialized) return; @@ -11498,22 +21230,27 @@ var WebAnimationsPlayer = (function () { } } } - this._player = this._triggerWebAnimation(this.element, keyframes, this.options); + (/** @type {?} */ (this)).domPlayer = + this._triggerWebAnimation(this.element, keyframes, this.options); this._finalKeyframe = keyframes.length ? keyframes[keyframes.length - 1] : {}; - this._player.addEventListener('finish', function () { return _this._onFinish(); }); + this.domPlayer.addEventListener('finish', function () { return _this._onFinish(); }); }; /** * @return {?} */ - WebAnimationsPlayer.prototype._preparePlayerBeforeStart = function () { + WebAnimationsPlayer.prototype._preparePlayerBeforeStart = /** + * @return {?} + */ + function () { // this is required so that the player doesn't start to animate right away if (this._delay) { this._resetDomPlayerState(); } else { - this._player.pause(); + this.domPlayer.pause(); } }; + /** @internal */ /** * \@internal * @param {?} element @@ -11521,65 +21258,88 @@ var WebAnimationsPlayer = (function () { * @param {?} options * @return {?} */ - WebAnimationsPlayer.prototype._triggerWebAnimation = function (element, keyframes, options) { + WebAnimationsPlayer.prototype._triggerWebAnimation = /** + * \@internal + * @param {?} element + * @param {?} keyframes + * @param {?} options + * @return {?} + */ + function (element, keyframes, options) { // jscompiler doesn't seem to know animate is a native property because it's not fully // supported yet across common browsers (we polyfill it for Edge/Safari) [CL #143630929] - return (element['animate'](keyframes, options)); + return /** @type {?} */ (element['animate'](keyframes, options)); }; - Object.defineProperty(WebAnimationsPlayer.prototype, "domPlayer", { - /** - * @return {?} - */ - get: function () { return this._player; }, - enumerable: true, - configurable: true - }); /** * @param {?} fn * @return {?} */ - WebAnimationsPlayer.prototype.onStart = function (fn) { this._onStartFns.push(fn); }; + WebAnimationsPlayer.prototype.onStart = /** + * @param {?} fn + * @return {?} + */ + function (fn) { this._onStartFns.push(fn); }; /** * @param {?} fn * @return {?} */ - WebAnimationsPlayer.prototype.onDone = function (fn) { this._onDoneFns.push(fn); }; + WebAnimationsPlayer.prototype.onDone = /** + * @param {?} fn + * @return {?} + */ + function (fn) { this._onDoneFns.push(fn); }; /** * @param {?} fn * @return {?} */ - WebAnimationsPlayer.prototype.onDestroy = function (fn) { this._onDestroyFns.push(fn); }; + WebAnimationsPlayer.prototype.onDestroy = /** + * @param {?} fn + * @return {?} + */ + function (fn) { this._onDestroyFns.push(fn); }; /** * @return {?} */ - WebAnimationsPlayer.prototype.play = function () { + WebAnimationsPlayer.prototype.play = /** + * @return {?} + */ + function () { this._buildPlayer(); if (!this.hasStarted()) { this._onStartFns.forEach(function (fn) { return fn(); }); this._onStartFns = []; this._started = true; } - this._player.play(); + this.domPlayer.play(); }; /** * @return {?} */ - WebAnimationsPlayer.prototype.pause = function () { + WebAnimationsPlayer.prototype.pause = /** + * @return {?} + */ + function () { this.init(); - this._player.pause(); + this.domPlayer.pause(); }; /** * @return {?} */ - WebAnimationsPlayer.prototype.finish = function () { + WebAnimationsPlayer.prototype.finish = /** + * @return {?} + */ + function () { this.init(); this._onFinish(); - this._player.finish(); + this.domPlayer.finish(); }; /** * @return {?} */ - WebAnimationsPlayer.prototype.reset = function () { + WebAnimationsPlayer.prototype.reset = /** + * @return {?} + */ + function () { this._resetDomPlayerState(); this._destroyed = false; this._finished = false; @@ -11588,30 +21348,42 @@ var WebAnimationsPlayer = (function () { /** * @return {?} */ - WebAnimationsPlayer.prototype._resetDomPlayerState = function () { - if (this._player) { - this._player.cancel(); + WebAnimationsPlayer.prototype._resetDomPlayerState = /** + * @return {?} + */ + function () { + if (this.domPlayer) { + this.domPlayer.cancel(); } }; /** * @return {?} */ - WebAnimationsPlayer.prototype.restart = function () { + WebAnimationsPlayer.prototype.restart = /** + * @return {?} + */ + function () { this.reset(); this.play(); }; /** * @return {?} */ - WebAnimationsPlayer.prototype.hasStarted = function () { return this._started; }; + WebAnimationsPlayer.prototype.hasStarted = /** + * @return {?} + */ + function () { return this._started; }; /** * @return {?} */ - WebAnimationsPlayer.prototype.destroy = function () { + WebAnimationsPlayer.prototype.destroy = /** + * @return {?} + */ + function () { if (!this._destroyed) { + this._destroyed = true; this._resetDomPlayerState(); this._onFinish(); - this._destroyed = true; this._onDestroyFns.forEach(function (fn) { return fn(); }); this._onDestroyFns = []; } @@ -11620,23 +21392,33 @@ var WebAnimationsPlayer = (function () { * @param {?} p * @return {?} */ - WebAnimationsPlayer.prototype.setPosition = function (p) { this._player.currentTime = p * this.time; }; + WebAnimationsPlayer.prototype.setPosition = /** + * @param {?} p + * @return {?} + */ + function (p) { this.domPlayer.currentTime = p * this.time; }; /** * @return {?} */ - WebAnimationsPlayer.prototype.getPosition = function () { return this._player.currentTime / this.time; }; + WebAnimationsPlayer.prototype.getPosition = /** + * @return {?} + */ + function () { return this.domPlayer.currentTime / this.time; }; Object.defineProperty(WebAnimationsPlayer.prototype, "totalTime", { - /** + get: /** * @return {?} */ - get: function () { return this._delay + this._duration; }, + function () { return this._delay + this._duration; }, enumerable: true, configurable: true }); /** * @return {?} */ - WebAnimationsPlayer.prototype.beforeDestroy = function () { + WebAnimationsPlayer.prototype.beforeDestroy = /** + * @return {?} + */ + function () { var _this = this; var /** @type {?} */ styles = {}; if (this.hasStarted()) { @@ -11657,24 +21439,36 @@ var WebAnimationsPlayer = (function () { * @return {?} */ function _computeStyle(element, prop) { - return ((window.getComputedStyle(element)))[prop]; + return (/** @type {?} */ (window.getComputedStyle(element)))[prop]; } + /** - * @license - * Copyright Google Inc. All Rights Reserved. - * - * Use of this source code is governed by an MIT-style license that can be - * found in the LICENSE file at https://angular.io/license + * @fileoverview added by tsickle + * @suppress {checkTypes} checked by tsc */ var WebAnimationsDriver = (function () { function WebAnimationsDriver() { } /** + * @param {?} prop + * @return {?} + */ + WebAnimationsDriver.prototype.validateStyleProperty = /** + * @param {?} prop + * @return {?} + */ + function (prop) { return validateStyleProperty(prop); }; + /** + * @param {?} element + * @param {?} selector + * @return {?} + */ + WebAnimationsDriver.prototype.matchesElement = /** * @param {?} element * @param {?} selector * @return {?} */ - WebAnimationsDriver.prototype.matchesElement = function (element, selector) { + function (element, selector) { return matchesElement(element, selector); }; /** @@ -11682,14 +21476,25 @@ var WebAnimationsDriver = (function () { * @param {?} elm2 * @return {?} */ - WebAnimationsDriver.prototype.containsElement = function (elm1, elm2) { return containsElement(elm1, elm2); }; + WebAnimationsDriver.prototype.containsElement = /** + * @param {?} elm1 + * @param {?} elm2 + * @return {?} + */ + function (elm1, elm2) { return containsElement(elm1, elm2); }; /** * @param {?} element * @param {?} selector * @param {?} multi * @return {?} */ - WebAnimationsDriver.prototype.query = function (element, selector, multi) { + WebAnimationsDriver.prototype.query = /** + * @param {?} element + * @param {?} selector + * @param {?} multi + * @return {?} + */ + function (element, selector, multi) { return invokeQuery(element, selector, multi); }; /** @@ -11698,8 +21503,14 @@ var WebAnimationsDriver = (function () { * @param {?=} defaultValue * @return {?} */ - WebAnimationsDriver.prototype.computeStyle = function (element, prop, defaultValue) { - return (((window.getComputedStyle(element)))[prop]); + WebAnimationsDriver.prototype.computeStyle = /** + * @param {?} element + * @param {?} prop + * @param {?=} defaultValue + * @return {?} + */ + function (element, prop, defaultValue) { + return /** @type {?} */ ((/** @type {?} */ (window.getComputedStyle(element)))[prop]); }; /** * @param {?} element @@ -11710,16 +21521,25 @@ var WebAnimationsDriver = (function () { * @param {?=} previousPlayers * @return {?} */ - WebAnimationsDriver.prototype.animate = function (element, keyframes, duration, delay, easing, previousPlayers) { - if (previousPlayers === void 0) { previousPlayers = []; } - var /** @type {?} */ fill = delay == 0 ? 'both' : 'forwards'; + WebAnimationsDriver.prototype.animate = /** + * @param {?} element + * @param {?} keyframes + * @param {?} duration + * @param {?} delay + * @param {?} easing + * @param {?=} previousPlayers + * @return {?} + */ + function (element, keyframes, duration, delay, easing, previousPlayers) { + if (previousPlayers === void 0) { previousPlayers = []; } + var /** @type {?} */ fill = delay == 0 ? 'both' : 'forwards'; var /** @type {?} */ playerOptions = { duration: duration, delay: delay, fill: fill }; // we check for this to avoid having a null|undefined value be present // for the easing (which results in an error for certain browsers #9752) if (easing) { playerOptions['easing'] = easing; } - var /** @type {?} */ previousWebAnimationPlayers = (previousPlayers.filter(function (player) { return player instanceof WebAnimationsPlayer; })); + var /** @type {?} */ previousWebAnimationPlayers = /** @type {?} */ (previousPlayers.filter(function (player) { return player instanceof WebAnimationsPlayer; })); return new WebAnimationsPlayer(element, keyframes, playerOptions, previousWebAnimationPlayers); }; return WebAnimationsDriver; @@ -11728,7 +21548,7 @@ var WebAnimationsDriver = (function () { * @return {?} */ function supportsWebAnimations() { - return typeof Element !== 'undefined' && typeof ((Element)).prototype['animate'] === 'function'; + return typeof Element !== 'undefined' && typeof (/** @type {?} */ (Element)).prototype['animate'] === 'function'; } exports.AnimationDriver = AnimationDriver; @@ -11749,16 +21569,16 @@ Object.defineProperty(exports, '__esModule', { value: true }); /***/ }), -/* 47 */ +/* 27 */ /***/ (function(module, exports, __webpack_require__) { (function (global, factory) { - true ? factory(exports, __webpack_require__(10), __webpack_require__(17), __webpack_require__(29), __webpack_require__(58), __webpack_require__(57), __webpack_require__(121), __webpack_require__(41), __webpack_require__(83), __webpack_require__(109), __webpack_require__(0), __webpack_require__(55), __webpack_require__(54), __webpack_require__(56)) : - typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', '@angular/http', 'rxjs/add/operator/map', 'rxjs/add/operator/catch', 'rxjs/Rx', 'rxjs/BehaviorSubject', '@angular/router', 'jsrsasign', 'rxjs/Observable', 'rxjs/add/observable/throw', 'rxjs/add/observable/interval', 'rxjs/add/observable/timer'], factory) : - (factory((global.ng = global.ng || {}, global.ng.angularAuthOidcClient = global.ng.angularAuthOidcClient || {}),global.ng.core,global.ng.common,global.ng.http,global.Rx,global.Rx,global.Rx,global.Rx,global.ng.router,global.jsrsasign,global.Rx)); -}(this, (function (exports,_angular_core,_angular_common,_angular_http,rxjs_add_operator_map,rxjs_add_operator_catch,rxjs_Rx,rxjs_BehaviorSubject,_angular_router,jsrsasign,rxjs_Observable) { 'use strict'; + true ? factory(exports, __webpack_require__(4), __webpack_require__(13), __webpack_require__(5), __webpack_require__(96), __webpack_require__(95), __webpack_require__(99), __webpack_require__(97), __webpack_require__(98), __webpack_require__(92), __webpack_require__(94), __webpack_require__(2), __webpack_require__(133), __webpack_require__(52), __webpack_require__(89), __webpack_require__(93), __webpack_require__(91)) : + typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common/http', '@angular/common', 'rxjs/add/operator/map', 'rxjs/add/operator/catch', 'rxjs/add/operator/timeInterval', 'rxjs/add/operator/pluck', 'rxjs/add/operator/take', 'rxjs/add/observable/interval', 'rxjs/add/observable/timer', 'rxjs/Observable', 'rxjs/BehaviorSubject', '@angular/router', 'jsrsasign', 'rxjs/add/observable/throw', 'rxjs/add/observable/empty'], factory) : + (factory((global.ng = global.ng || {}, global.ng.angularAuthOidcClient = global.ng.angularAuthOidcClient || {}),global.ng.core,global.ng.http,global.ng.common,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable,global.Rx.Observable,global.Rx,global.Rx,global.ng.router,global.jsrsasign)); +}(this, (function (exports,_angular_core,_angular_common_http,_angular_common,rxjs_add_operator_map,rxjs_add_operator_catch,rxjs_add_operator_timeInterval,rxjs_add_operator_pluck,rxjs_add_operator_take,rxjs_add_observable_interval,rxjs_add_observable_timer,rxjs_Observable,rxjs_BehaviorSubject,_angular_router,jsrsasign) { 'use strict'; -var DefaultConfiguration = (function () { +var DefaultConfiguration = /** @class */ (function () { function DefaultConfiguration() { this.stsServer = 'https://localhost:44318'; this.redirect_url = 'https://localhost:44311'; @@ -11769,10 +21589,13 @@ var DefaultConfiguration = (function () { // For some oidc, we require resource identifier to be provided along with the request. this.resource = ''; this.scope = 'openid email profile'; + // Only for Google Auth with particular G Suite domain, see https://developers.google.com/identity/protocols/OpenIDConnect#hd-param + this.hd_param = ''; this.post_logout_redirect_uri = 'https://localhost:44311/unauthorized'; this.start_checksession = false; this.silent_renew = true; - this.startup_route = '/dataeventrecords'; + this.silent_renew_offset_in_seconds = 0; + this.post_login_route = '/'; // HTTP 403 this.forbidden_route = '/forbidden'; // HTTP 401 @@ -11789,12 +21612,12 @@ var DefaultConfiguration = (function () { } return DefaultConfiguration; }()); -var OpenIDImplicitFlowConfiguration = (function () { +var OpenIDImplicitFlowConfiguration = /** @class */ (function () { function OpenIDImplicitFlowConfiguration() { } return OpenIDImplicitFlowConfiguration; }()); -var AuthConfiguration = (function () { +var AuthConfiguration = /** @class */ (function () { /** * @param {?} defaultConfig */ @@ -11861,6 +21684,16 @@ var AuthConfiguration = (function () { enumerable: true, configurable: true }); + Object.defineProperty(AuthConfiguration.prototype, "hd_param", { + /** + * @return {?} + */ + get: function () { + return this.openIDImplicitFlowConfiguration.hd_param || this.defaultConfig.hd_param; + }, + enumerable: true, + configurable: true + }); Object.defineProperty(AuthConfiguration.prototype, "post_logout_redirect_uri", { /** * @return {?} @@ -11891,12 +21724,22 @@ var AuthConfiguration = (function () { enumerable: true, configurable: true }); - Object.defineProperty(AuthConfiguration.prototype, "startup_route", { + Object.defineProperty(AuthConfiguration.prototype, "silent_renew_offset_in_seconds", { + /** + * @return {?} + */ + get: function () { + return this.openIDImplicitFlowConfiguration.silent_renew_offset_in_seconds || this.defaultConfig.silent_renew_offset_in_seconds; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AuthConfiguration.prototype, "post_login_route", { /** * @return {?} */ get: function () { - return this.openIDImplicitFlowConfiguration.startup_route || this.defaultConfig.startup_route; + return this.openIDImplicitFlowConfiguration.post_login_route || this.defaultConfig.post_login_route; }, enumerable: true, configurable: true @@ -12033,7 +21876,7 @@ AuthConfiguration.ctorParameters = function () { return [ * Implement this class-interface to create a custom storage. * @abstract */ -var OidcSecurityStorage = (function () { +var OidcSecurityStorage = /** @class */ (function () { function OidcSecurityStorage() { } /** @@ -12060,7 +21903,7 @@ OidcSecurityStorage.decorators = [ * @nocollapse */ OidcSecurityStorage.ctorParameters = function () { return []; }; -var BrowserStorage = (function () { +var BrowserStorage = /** @class */ (function () { /** * @param {?} authConfiguration */ @@ -12085,6 +21928,7 @@ var BrowserStorage = (function () { */ BrowserStorage.prototype.write = function (key, value) { if (this.hasStorage) { + value = value === undefined ? null : value; this.authConfiguration.storage.setItem(key, JSON.stringify(value)); } }; @@ -12099,7 +21943,7 @@ BrowserStorage.decorators = [ BrowserStorage.ctorParameters = function () { return [ { type: AuthConfiguration, }, ]; }; -var OidcSecurityCommon = (function () { +var OidcSecurityCommon = /** @class */ (function () { /** * @param {?} authConfiguration * @param {?} oidcSecurityStorage @@ -12119,6 +21963,193 @@ var OidcSecurityCommon = (function () { this.storage_silent_renew_running = 'storage_silent_renew_running'; this.storage_custom_request_params = 'storage_custom_request_params'; } + Object.defineProperty(OidcSecurityCommon.prototype, "authResult", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_auth_result); + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_auth_result, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "accessToken", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_access_token) || ''; + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_access_token, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "idToken", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_id_token) || ''; + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_id_token, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "isAuthorized", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_is_authorized); + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_is_authorized, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "userData", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_user_data); + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_user_data, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "authNonce", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_auth_nonce) || ''; + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_auth_nonce, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "authStateControl", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_auth_state_control) || ''; + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_auth_state_control, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "wellKnownEndpoints", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_well_known_endpoints); + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_well_known_endpoints, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "sessionState", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_session_state); + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_session_state, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "silentRenewRunning", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_silent_renew_running) || ''; + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_silent_renew_running, value); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(OidcSecurityCommon.prototype, "customRequestParams", { + /** + * @return {?} + */ + get: function () { + return this.retrieve(this.storage_custom_request_params); + }, + /** + * @param {?} value + * @return {?} + */ + set: function (value) { + this.store(this.storage_custom_request_params, value); + }, + enumerable: true, + configurable: true + }); /** * @return {?} */ @@ -12202,7 +22233,7 @@ OidcSecurityCommon.ctorParameters = function () { return [ { type: AuthConfiguration, }, { type: OidcSecurityStorage, }, ]; }; -var OidcSecurityValidation = (function () { +var OidcSecurityValidation = /** @class */ (function () { /** * @param {?} oidcSecurityCommon */ @@ -12397,6 +22428,10 @@ var OidcSecurityValidation = (function () { return false; } var /** @type {?} */ header_data = this.getHeaderFromToken(id_token, false); + if ((Object.keys(header_data).length === 0 && header_data.constructor === Object)) { + this.oidcSecurityCommon.logWarning('id token has no header data'); + return false; + } var /** @type {?} */ kid = header_data.kid; var /** @type {?} */ alg = header_data.alg; if ('RS256' != alg) { @@ -12537,7 +22572,7 @@ OidcSecurityValidation.decorators = [ OidcSecurityValidation.ctorParameters = function () { return [ { type: OidcSecurityCommon, }, ]; }; -var AuthWellKnownEndpoints = (function () { +var AuthWellKnownEndpoints = /** @class */ (function () { /** * @param {?} http * @param {?} authConfiguration @@ -12550,15 +22585,15 @@ var AuthWellKnownEndpoints = (function () { this.oidcSecurityCommon = oidcSecurityCommon; this.onWellKnownEndpointsLoaded = new _angular_core.EventEmitter(true); this.getWellKnownEndpoints = function () { - var /** @type {?} */ headers = new _angular_http.Headers(); - headers.append('Accept', 'application/json'); + var /** @type {?} */ headers = new _angular_common_http.HttpHeaders(); + headers = headers.set('Accept', 'application/json'); var /** @type {?} */ url = _this.authConfiguration.stsServer + '/.well-known/openid-configuration'; if (_this.authConfiguration.override_well_known_configuration) { url = _this.authConfiguration.override_well_known_configuration_url; } return _this.http.get(url, { headers: headers, - }).map(function (res) { return res.json(); }); + }); }; } /** @@ -12566,7 +22601,7 @@ var AuthWellKnownEndpoints = (function () { */ AuthWellKnownEndpoints.prototype.setupModule = function () { var _this = this; - var /** @type {?} */ data = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_well_known_endpoints); + var /** @type {?} */ data = this.oidcSecurityCommon.wellKnownEndpoints; this.oidcSecurityCommon.logDebug(data); if (data && data !== '') { this.oidcSecurityCommon.logDebug('AuthWellKnownEndpoints already defined'); @@ -12610,7 +22645,7 @@ var AuthWellKnownEndpoints = (function () { if (data.introspection_endpoint) { _this.introspection_endpoint = data.introspection_endpoint; } - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_well_known_endpoints, data); + _this.oidcSecurityCommon.wellKnownEndpoints = data; _this.oidcSecurityCommon.logDebug(data); _this.onWellKnownEndpointsLoaded.emit(); }); @@ -12625,14 +22660,14 @@ AuthWellKnownEndpoints.decorators = [ * @nocollapse */ AuthWellKnownEndpoints.ctorParameters = function () { return [ - { type: _angular_http.Http, }, + { type: _angular_common_http.HttpClient, }, { type: AuthConfiguration, }, { type: OidcSecurityCommon, }, ]; }; AuthWellKnownEndpoints.propDecorators = { 'onWellKnownEndpointsLoaded': [{ type: _angular_core.Output },], }; -var OidcSecurityCheckSession = (function () { +var OidcSecurityCheckSession = /** @class */ (function () { /** * @param {?} authConfiguration * @param {?} oidcSecurityCommon @@ -12678,9 +22713,9 @@ var OidcSecurityCheckSession = (function () { .timeInterval() .pluck('interval') .take(10000); - var /** @type {?} */ subscription = source.subscribe(function () { + source.subscribe(function () { _this.oidcSecurityCommon.logDebug(_this.sessionIframe); - var /** @type {?} */ session_state = _this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_session_state); + var /** @type {?} */ session_state = _this.oidcSecurityCommon.sessionState; if (session_state && session_state !== '') { _this.sessionIframe.contentWindow.postMessage(clientId + ' ' + session_state, _this.authConfiguration.stsServer); } @@ -12724,7 +22759,7 @@ OidcSecurityCheckSession.ctorParameters = function () { return [ OidcSecurityCheckSession.propDecorators = { 'onCheckSessionChanged': [{ type: _angular_core.Output },], }; -var OidcSecuritySilentRenew = (function () { +var OidcSecuritySilentRenew = /** @class */ (function () { /** * @param {?} oidcSecurityCommon */ @@ -12805,31 +22840,28 @@ OidcSecuritySilentRenew.decorators = [ OidcSecuritySilentRenew.ctorParameters = function () { return [ { type: OidcSecurityCommon, }, ]; }; -var OidcSecurityUserService = (function () { +var OidcSecurityUserService = /** @class */ (function () { /** * @param {?} http - * @param {?} authConfiguration * @param {?} oidcSecurityCommon * @param {?} authWellKnownEndpoints */ - function OidcSecurityUserService(http, authConfiguration, oidcSecurityCommon, authWellKnownEndpoints) { + function OidcSecurityUserService(http, oidcSecurityCommon, authWellKnownEndpoints) { var _this = this; this.http = http; - this.authConfiguration = authConfiguration; this.oidcSecurityCommon = oidcSecurityCommon; this.authWellKnownEndpoints = authWellKnownEndpoints; this.userData = ''; this.getIdentityUserData = function () { - var /** @type {?} */ headers = new _angular_http.Headers(); - headers.append('Accept', 'application/json'); + var /** @type {?} */ headers = new _angular_common_http.HttpHeaders(); + headers = headers.set('Accept', 'application/json'); var /** @type {?} */ token = _this.oidcSecurityCommon.getAccessToken(); if (token !== '') { - headers.append('Authorization', 'Bearer ' + decodeURIComponent(token)); + headers = headers.set('Authorization', 'Bearer ' + decodeURIComponent(token)); } return _this.http.get(_this.authWellKnownEndpoints.userinfo_endpoint, { headers: headers, - body: '' - }).map(function (res) { return res.json(); }); + }); }; } /** @@ -12840,13 +22872,6 @@ var OidcSecurityUserService = (function () { return this.getIdentityUserData() .map(function (data) { return _this.userData = data; }); }; - /** - * @param {?} error - * @return {?} - */ - OidcSecurityUserService.prototype.handleError = function (error) { - this.oidcSecurityCommon.logError(error); - }; return OidcSecurityUserService; }()); OidcSecurityUserService.decorators = [ @@ -12856,8 +22881,7 @@ OidcSecurityUserService.decorators = [ * @nocollapse */ OidcSecurityUserService.ctorParameters = function () { return [ - { type: _angular_http.Http, }, - { type: AuthConfiguration, }, + { type: _angular_common_http.HttpClient, }, { type: OidcSecurityCommon, }, { type: AuthWellKnownEndpoints, }, ]; }; @@ -12868,7 +22892,40 @@ AuthorizationResult.unauthorized = 3; AuthorizationResult[AuthorizationResult.authorized] = "authorized"; AuthorizationResult[AuthorizationResult.forbidden] = "forbidden"; AuthorizationResult[AuthorizationResult.unauthorized] = "unauthorized"; -var OidcSecurityService = (function () { +var UriEncoder = /** @class */ (function () { + function UriEncoder() { + } + /** + * @param {?} key + * @return {?} + */ + UriEncoder.prototype.encodeKey = function (key) { + return encodeURIComponent(key); + }; + /** + * @param {?} value + * @return {?} + */ + UriEncoder.prototype.encodeValue = function (value) { + return encodeURIComponent(value); + }; + /** + * @param {?} key + * @return {?} + */ + UriEncoder.prototype.decodeKey = function (key) { + return decodeURIComponent(key); + }; + /** + * @param {?} value + * @return {?} + */ + UriEncoder.prototype.decodeValue = function (value) { + return decodeURIComponent(value); + }; + return UriEncoder; +}()); +var OidcSecurityService = /** @class */ (function () { /** * @param {?} platformId * @param {?} http @@ -12894,6 +22951,7 @@ var OidcSecurityService = (function () { this.onAuthorizationResult = new _angular_core.EventEmitter(true); this.moduleSetup = false; this._isAuthorized = new rxjs_BehaviorSubject.BehaviorSubject(false); + this.lastUserData = undefined; this._userData = new rxjs_BehaviorSubject.BehaviorSubject(''); this.authWellKnownEndpointsLoaded = false; } @@ -12907,28 +22965,39 @@ var OidcSecurityService = (function () { this.oidcSecurityValidation = new OidcSecurityValidation(this.oidcSecurityCommon); this.oidcSecurityCheckSession.onCheckSessionChanged.subscribe(function () { _this.onCheckSessionChanged(); }); this.authWellKnownEndpoints.onWellKnownEndpointsLoaded.subscribe(function () { _this.onWellKnownEndpointsLoaded(); }); + this._userData.subscribe(function () { _this.onUserDataChanged(); }); this.oidcSecurityCommon.setupModule(); - if (this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_user_data) !== '') { - this.setUserData(this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_user_data)); + var /** @type {?} */ userData = this.oidcSecurityCommon.userData; + if (userData !== '') { + this.setUserData(userData); } - if (this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_is_authorized) !== '') { - this.setIsAuthorized(this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_is_authorized)); + var /** @type {?} */ isAuthorized = this.oidcSecurityCommon.isAuthorized; + if (isAuthorized !== undefined) { + this.setIsAuthorized(isAuthorized); + // Start the silent renew + this.runTokenValidation(); } this.oidcSecurityCommon.logDebug('STS server: ' + this.authConfiguration.stsServer); if (_angular_common.isPlatformBrowser(this.platformId)) { // Client only code. + this.authWellKnownEndpoints.onWellKnownEndpointsLoaded.subscribe(function () { + _this.moduleSetup = true; + _this.onModuleSetup.emit(); + if (_this.authConfiguration.silent_renew) { + _this.oidcSecuritySilentRenew.initRenew(); + } + if (_this.authConfiguration.start_checksession) { + _this.oidcSecurityCheckSession.init().subscribe(function () { + _this.oidcSecurityCheckSession.pollServerSession(_this.authConfiguration.client_id); + }); + } + }); this.authWellKnownEndpoints.setupModule(); - if (this.authConfiguration.silent_renew) { - this.oidcSecuritySilentRenew.initRenew(); - } - if (this.authConfiguration.start_checksession) { - this.oidcSecurityCheckSession.init().subscribe(function () { - _this.oidcSecurityCheckSession.pollServerSession(_this.authConfiguration.client_id); - }); - } } - this.moduleSetup = true; - this.onModuleSetup.emit(); + else { + this.moduleSetup = true; + this.onModuleSetup.emit(); + } }; /** * @return {?} @@ -12941,7 +23010,7 @@ var OidcSecurityService = (function () { * @return {?} */ OidcSecurityService.prototype.setUserData = function (userData) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_user_data, userData); + this.oidcSecurityCommon.userData = userData; this._userData.next(userData); }; /** @@ -12992,26 +23061,26 @@ var OidcSecurityService = (function () { * @return {?} */ OidcSecurityService.prototype.setState = function (state) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, state); + this.oidcSecurityCommon.authStateControl = state; }; /** * @return {?} */ OidcSecurityService.prototype.getState = function () { - return this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control); + return this.oidcSecurityCommon.authStateControl; }; /** * @param {?} params * @return {?} */ OidcSecurityService.prototype.setCustomRequestParameters = function (params) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_custom_request_params, params); + this.oidcSecurityCommon.customRequestParams = params; }; /** * @return {?} */ OidcSecurityService.prototype.authorize = function () { - var /** @type {?} */ data = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_well_known_endpoints); + var /** @type {?} */ data = this.oidcSecurityCommon.wellKnownEndpoints; if (data && data !== '') { this.authWellKnownEndpointsLoaded = true; } @@ -13025,14 +23094,14 @@ var OidcSecurityService = (function () { } this.resetAuthorizationData(false); this.oidcSecurityCommon.logDebug('BEGIN Authorize, no auth data'); - var /** @type {?} */ state = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control); - if (state === '') { + var /** @type {?} */ state = this.oidcSecurityCommon.authStateControl; + if (state === '' || state === null) { state = Date.now() + '' + Math.random(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, state); + this.oidcSecurityCommon.authStateControl = state; } var /** @type {?} */ nonce = 'N' + Math.random() + '' + Date.now(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_nonce, nonce); - this.oidcSecurityCommon.logDebug('AuthorizedController created. local state: ' + this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control)); + this.oidcSecurityCommon.authNonce = nonce; + this.oidcSecurityCommon.logDebug('AuthorizedController created. local state: ' + this.oidcSecurityCommon.authStateControl); var /** @type {?} */ url = this.createAuthorizeUrl(nonce, state, this.authWellKnownEndpoints.authorization_endpoint); window.location.href = url; }; @@ -13042,7 +23111,7 @@ var OidcSecurityService = (function () { */ OidcSecurityService.prototype.authorizedCallback = function (hash) { var _this = this; - var /** @type {?} */ silentRenew = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_silent_renew_running); + var /** @type {?} */ silentRenew = this.oidcSecurityCommon.silentRenewRunning; var /** @type {?} */ isRenewProcess = (silentRenew === 'running'); this.oidcSecurityCommon.logDebug('BEGIN authorizedCallback, no auth data'); this.resetAuthorizationData(isRenewProcess); @@ -13052,7 +23121,7 @@ var OidcSecurityService = (function () { result[parts[0]] = parts[1]; return result; }, {}); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_result, result); + this.oidcSecurityCommon.authResult = result; this.oidcSecurityCommon.logDebug(result); this.oidcSecurityCommon.logDebug('authorizedCallback created, begin token validation'); var /** @type {?} */ access_token = ''; @@ -13064,18 +23133,16 @@ var OidcSecurityService = (function () { _this.jwtKeys = jwtKeys; if (!result.error) { // validate state - if (_this.oidcSecurityValidation.validateStateFromHashCallback(result.state, _this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_auth_state_control))) { + if (_this.oidcSecurityValidation.validateStateFromHashCallback(result.state, _this.oidcSecurityCommon.authStateControl)) { if (_this.authConfiguration.response_type === 'id_token token') { access_token = result.access_token; } id_token = result.id_token; - var /** @type {?} */ headerDecoded = void 0; decoded_id_token = _this.oidcSecurityValidation.getPayloadFromToken(id_token, false); - headerDecoded = _this.oidcSecurityValidation.getHeaderFromToken(id_token, false); // validate jwt signature if (_this.oidcSecurityValidation.validate_signature_id_token(id_token, _this.jwtKeys)) { // validate nonce - if (_this.oidcSecurityValidation.validate_id_token_nonce(decoded_id_token, _this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_auth_nonce))) { + if (_this.oidcSecurityValidation.validate_id_token_nonce(decoded_id_token, _this.oidcSecurityCommon.authNonce)) { // validate required fields id_token if (_this.oidcSecurityValidation.validate_required_id_token(decoded_id_token)) { // validate max offset from the id_token issue to now @@ -13134,7 +23201,7 @@ var OidcSecurityService = (function () { _this.oidcSecurityCommon.logWarning('authorizedCallback incorrect state'); } } - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_silent_renew_running, ''); + _this.oidcSecurityCommon.silentRenewRunning = ''; if (authResponseIsValid) { _this.setAuthorizationData(access_token, id_token); if (_this.authConfiguration.auto_userinfo) { @@ -13144,7 +23211,7 @@ var OidcSecurityService = (function () { _this.onAuthorizationResult.emit(AuthorizationResult.authorized); } else { - _this.router.navigate([_this.authConfiguration.startup_route]); + _this.router.navigate([_this.authConfiguration.post_login_route]); } } else { @@ -13158,11 +23225,12 @@ var OidcSecurityService = (function () { }); } else { + _this.runTokenValidation(); if (_this.authConfiguration.trigger_authorization_result_event) { _this.onAuthorizationResult.emit(AuthorizationResult.authorized); } else { - _this.router.navigate([_this.authConfiguration.startup_route]); + _this.router.navigate([_this.authConfiguration.post_login_route]); } } } @@ -13188,14 +23256,14 @@ var OidcSecurityService = (function () { OidcSecurityService.prototype.getUserinfo = function (isRenewProcess, result, id_token, decoded_id_token) { var _this = this; if (isRenewProcess === void 0) { isRenewProcess = false; } - result = result ? result : this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_result); - id_token = id_token ? id_token : this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_id_token); + result = result ? result : this.oidcSecurityCommon.authResult; + id_token = id_token ? id_token : this.oidcSecurityCommon.idToken; decoded_id_token = decoded_id_token ? decoded_id_token : this.oidcSecurityValidation.getPayloadFromToken(id_token, false); - return new rxjs_Rx.Observable(function (observer) { + return new rxjs_Observable.Observable(function (observer) { // flow id_token token if (_this.authConfiguration.response_type === 'id_token token') { if (isRenewProcess) { - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_session_state, result.session_state); + _this.oidcSecurityCommon.sessionState = result.session_state; observer.next(true); observer.complete(); } @@ -13205,10 +23273,10 @@ var OidcSecurityService = (function () { _this.oidcSecurityCommon.logDebug('authorizedCallback id_token token flow'); if (_this.oidcSecurityValidation.validate_userdata_sub_id_token(decoded_id_token.sub, _this.oidcSecurityUserService.userData.sub)) { _this.setUserData(_this.oidcSecurityUserService.userData); - _this.oidcSecurityCommon.logDebug(_this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_access_token)); + _this.oidcSecurityCommon.logDebug(_this.oidcSecurityCommon.accessToken); _this.oidcSecurityCommon.logDebug(_this.oidcSecurityUserService.userData); - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_session_state, result.session_state); - _this.runTokenValidatation(); + _this.oidcSecurityCommon.sessionState = result.session_state; + _this.runTokenValidation(); observer.next(true); } else { @@ -13223,13 +23291,13 @@ var OidcSecurityService = (function () { } else { _this.oidcSecurityCommon.logDebug('authorizedCallback id_token flow'); - _this.oidcSecurityCommon.logDebug(_this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_access_token)); + _this.oidcSecurityCommon.logDebug(_this.oidcSecurityCommon.accessToken); // userData is set to the id_token decoded. No access_token. _this.oidcSecurityUserService.userData = decoded_id_token; _this.setUserData(_this.oidcSecurityUserService.userData); - _this.oidcSecurityCommon.store(_this.oidcSecurityCommon.storage_session_state, result.session_state); + _this.oidcSecurityCommon.sessionState = result.session_state; if (!isRenewProcess) { - _this.runTokenValidatation(); + _this.runTokenValidation(); } observer.next(true); observer.complete(); @@ -13244,7 +23312,7 @@ var OidcSecurityService = (function () { this.oidcSecurityCommon.logDebug('BEGIN Authorize, no auth data'); if (this.authWellKnownEndpoints.end_session_endpoint) { var /** @type {?} */ end_session_endpoint = this.authWellKnownEndpoints.end_session_endpoint; - var /** @type {?} */ id_token_hint = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_id_token); + var /** @type {?} */ id_token_hint = this.oidcSecurityCommon.idToken; var /** @type {?} */ url = this.createEndSessionUrl(end_session_endpoint, id_token_hint); this.resetAuthorizationData(false); if (this.authConfiguration.start_checksession && this.checkSessionChanged) { @@ -13263,9 +23331,9 @@ var OidcSecurityService = (function () { * @return {?} */ OidcSecurityService.prototype.successful_validation = function () { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_nonce, ''); + this.oidcSecurityCommon.authNonce = ''; if (this.authConfiguration.auto_clean_state_after_authentication) { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, ''); + this.oidcSecurityCommon.authStateControl = ''; } this.oidcSecurityCommon.logDebug('AuthorizedCallback token(s) validated, continue'); }; @@ -13274,16 +23342,16 @@ var OidcSecurityService = (function () { */ OidcSecurityService.prototype.refreshSession = function () { this.oidcSecurityCommon.logDebug('BEGIN refresh session Authorize'); - var /** @type {?} */ state = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control); - if (state === '') { + var /** @type {?} */ state = this.oidcSecurityCommon.authStateControl; + if (state === '' || state === null) { state = Date.now() + '' + Math.random(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_state_control, state); + this.oidcSecurityCommon.authStateControl = state; } var /** @type {?} */ nonce = 'N' + Math.random() + '' + Date.now(); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_auth_nonce, nonce); - this.oidcSecurityCommon.logDebug('RefreshSession created. adding myautostate: ' + this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_auth_state_control)); - var /** @type {?} */ url = this.createAuthorizeUrl(nonce, state, this.authWellKnownEndpoints.authorization_endpoint); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_silent_renew_running, 'running'); + this.oidcSecurityCommon.authNonce = nonce; + this.oidcSecurityCommon.logDebug('RefreshSession created. adding myautostate: ' + this.oidcSecurityCommon.authStateControl); + var /** @type {?} */ url = this.createAuthorizeUrl(nonce, state, this.authWellKnownEndpoints.authorization_endpoint, 'none'); + this.oidcSecurityCommon.silentRenewRunning = 'running'; this.oidcSecuritySilentRenew.startRenew(url); }; /** @@ -13292,36 +23360,43 @@ var OidcSecurityService = (function () { * @return {?} */ OidcSecurityService.prototype.setAuthorizationData = function (access_token, id_token) { - if (this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_access_token) !== '') { - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_access_token, ''); + if (this.oidcSecurityCommon.accessToken !== '') { + this.oidcSecurityCommon.accessToken = ''; } this.oidcSecurityCommon.logDebug(access_token); this.oidcSecurityCommon.logDebug(id_token); this.oidcSecurityCommon.logDebug('storing to storage, getting the roles'); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_access_token, access_token); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_id_token, id_token); + this.oidcSecurityCommon.accessToken = access_token; + this.oidcSecurityCommon.idToken = id_token; this.setIsAuthorized(true); - this.oidcSecurityCommon.store(this.oidcSecurityCommon.storage_is_authorized, true); + this.oidcSecurityCommon.isAuthorized = true; }; /** * @param {?} nonce * @param {?} state * @param {?} authorization_endpoint + * @param {?=} prompt * @return {?} */ - OidcSecurityService.prototype.createAuthorizeUrl = function (nonce, state, authorization_endpoint) { + OidcSecurityService.prototype.createAuthorizeUrl = function (nonce, state, authorization_endpoint, prompt) { var /** @type {?} */ urlParts = authorization_endpoint.split('?'); var /** @type {?} */ authorizationUrl = urlParts[0]; - var /** @type {?} */ params = new _angular_http.URLSearchParams(urlParts[1]); - params.set('client_id', this.authConfiguration.client_id); - params.set('redirect_uri', this.authConfiguration.redirect_url); - params.set('response_type', this.authConfiguration.response_type); - params.set('scope', this.authConfiguration.scope); - params.set('nonce', nonce); - params.set('state', state); - var /** @type {?} */ customParams = Object.assign({}, this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_custom_request_params)); + var /** @type {?} */ params = new _angular_common_http.HttpParams({ fromString: urlParts[1], encoder: new UriEncoder() }); + params = params.set('client_id', this.authConfiguration.client_id); + params = params.append('redirect_uri', this.authConfiguration.redirect_url); + params = params.append('response_type', this.authConfiguration.response_type); + params = params.append('scope', this.authConfiguration.scope); + params = params.append('nonce', nonce); + params = params.append('state', state); + if (prompt) { + params = params.append('prompt', prompt); + } + if (this.authConfiguration.hd_param) { + params = params.append('hd', this.authConfiguration.hd_param); + } + var /** @type {?} */ customParams = Object.assign({}, this.oidcSecurityCommon.customRequestParams); Object.keys(customParams).forEach(function (key) { - params.set(key, customParams[key]); + params = params.append(key, customParams[key].toString()); }); return authorizationUrl + "?" + params; }; @@ -13333,9 +23408,9 @@ var OidcSecurityService = (function () { OidcSecurityService.prototype.createEndSessionUrl = function (end_session_endpoint, id_token_hint) { var /** @type {?} */ urlParts = end_session_endpoint.split('?'); var /** @type {?} */ authorizationEndsessionUrl = urlParts[0]; - var /** @type {?} */ params = new _angular_http.URLSearchParams(urlParts[1]); - params.set('id_token_hint', id_token_hint); - params.set('post_logout_redirect_uri', this.authConfiguration.post_logout_redirect_uri); + var /** @type {?} */ params = new _angular_common_http.HttpParams({ fromString: urlParts[1], encoder: new UriEncoder() }); + params = params.set('id_token_hint', id_token_hint); + params = params.append('post_logout_redirect_uri', this.authConfiguration.post_logout_redirect_uri); return authorizationEndsessionUrl + "?" + params; }; /** @@ -13344,6 +23419,10 @@ var OidcSecurityService = (function () { */ OidcSecurityService.prototype.resetAuthorizationData = function (isRenewProcess) { if (!isRenewProcess) { + if (this.authConfiguration.auto_userinfo) { + // Clear user data. Fixes #97. + this.setUserData(''); + } this.setIsAuthorized(false); this.oidcSecurityCommon.resetStorageData(isRenewProcess); this.checkSessionChanged = false; @@ -13364,8 +23443,8 @@ var OidcSecurityService = (function () { } } else if (error.status == 401) { - var /** @type {?} */ silentRenew = this.oidcSecurityCommon.retrieve(this.oidcSecurityCommon.storage_silent_renew_running); - this.resetAuthorizationData(silentRenew); + var /** @type {?} */ silentRenew = this.oidcSecurityCommon.silentRenewRunning; + this.resetAuthorizationData(silentRenew !== ''); if (this.authConfiguration.trigger_authorization_result_event) { this.onAuthorizationResult.emit(AuthorizationResult.unauthorized); } @@ -13391,10 +23470,13 @@ var OidcSecurityService = (function () { /** * @return {?} */ - OidcSecurityService.prototype.runGetSigningKeys = function () { - var _this = this; - this.getSigningKeys() - .subscribe(function (jwtKeys) { return _this.jwtKeys = jwtKeys; }, function (error) { return _this.errorMessage = (error); }); + OidcSecurityService.prototype.onUserDataChanged = function () { + this.oidcSecurityCommon.logDebug("onUserDataChanged: last = " + this.lastUserData + ", new = " + this._userData.value); + if (this.lastUserData && !this._userData.value) { + this.oidcSecurityCommon.logDebug('onUserDataChanged: Logout detected.'); + // TODO should we have an action here + } + this.lastUserData = this._userData.value; }; /** * @return {?} @@ -13402,46 +23484,41 @@ var OidcSecurityService = (function () { OidcSecurityService.prototype.getSigningKeys = function () { this.oidcSecurityCommon.logDebug('jwks_uri: ' + this.authWellKnownEndpoints.jwks_uri); return this.http.get(this.authWellKnownEndpoints.jwks_uri) - .map(this.extractData) .catch(this.handleErrorGetSigningKeys); }; - /** - * @param {?} res - * @return {?} - */ - OidcSecurityService.prototype.extractData = function (res) { - var /** @type {?} */ body = res.json(); - return body; - }; /** * @param {?} error * @return {?} */ OidcSecurityService.prototype.handleErrorGetSigningKeys = function (error) { var /** @type {?} */ errMsg; - if (error instanceof _angular_http.Response) { + if (error instanceof Response) { var /** @type {?} */ body = error.json() || {}; - var /** @type {?} */ err = body.error || JSON.stringify(body); + var /** @type {?} */ err = JSON.stringify(body); errMsg = error.status + " - " + (error.statusText || '') + " " + err; } else { errMsg = error.message ? error.message : error.toString(); } console.error(errMsg); - return rxjs_Rx.Observable.throw(errMsg); + return rxjs_Observable.Observable.throw(errMsg); }; /** * @return {?} */ - OidcSecurityService.prototype.runTokenValidatation = function () { + OidcSecurityService.prototype.runTokenValidation = function () { var _this = this; - var /** @type {?} */ source = rxjs_Rx.Observable.timer(3000, 3000) + if (this.runTokenValidationRunning) { + return; + } + this.runTokenValidationRunning = true; + var /** @type {?} */ source = rxjs_Observable.Observable.timer(5000, 3000) .timeInterval() .pluck('interval') .take(10000); - var /** @type {?} */ subscription = source.subscribe(function () { - if (_this._isAuthorizedValue) { - if (_this.oidcSecurityValidation.isTokenExpired(_this.oidcSecurityCommon.retrieve(_this.oidcSecurityCommon.storage_id_token))) { + source.subscribe(function () { + if (_this._userData.value) { + if (_this.oidcSecurityValidation.isTokenExpired(_this.oidcSecurityCommon.idToken, _this.authConfiguration.silent_renew_offset_in_seconds)) { _this.oidcSecurityCommon.logDebug('IsAuthorized: id_token isTokenExpired, start silent renew if active'); if (_this.authConfiguration.silent_renew) { _this.refreshSession(); @@ -13467,7 +23544,7 @@ OidcSecurityService.decorators = [ */ OidcSecurityService.ctorParameters = function () { return [ { type: Object, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] }, - { type: _angular_http.Http, }, + { type: _angular_common_http.HttpClient, }, { type: AuthConfiguration, }, { type: _angular_router.Router, }, { type: OidcSecurityCheckSession, }, @@ -13480,7 +23557,7 @@ OidcSecurityService.propDecorators = { 'onModuleSetup': [{ type: _angular_core.Output },], 'onAuthorizationResult': [{ type: _angular_core.Output },], }; -var AuthModule = (function () { +var AuthModule = /** @class */ (function () { function AuthModule() { } /** @@ -13508,30 +23585,6 @@ var AuthModule = (function () { ] }; }; - /** - * @param {?=} token - * @return {?} - */ - AuthModule.forChild = function (token) { - if (token === void 0) { token = {}; } - return { - ngModule: AuthModule, - providers: [ - OidcSecurityService, - OidcSecurityValidation, - OidcSecurityCheckSession, - OidcSecuritySilentRenew, - OidcSecurityUserService, - OidcSecurityCommon, - AuthConfiguration, - AuthWellKnownEndpoints, - { - provide: OidcSecurityStorage, - useClass: token.storage || BrowserStorage - } - ] - }; - }; return AuthModule; }()); AuthModule.decorators = [ @@ -13551,11 +23604,11 @@ exports.OidcSecurityCommon = OidcSecurityCommon; exports.OidcSecurityStorage = OidcSecurityStorage; exports.BrowserStorage = BrowserStorage; exports.AuthWellKnownEndpoints = AuthWellKnownEndpoints; +exports.AuthorizationResult = AuthorizationResult; exports.AuthConfiguration = AuthConfiguration; exports.OpenIDImplicitFlowConfiguration = OpenIDImplicitFlowConfiguration; exports.DefaultConfiguration = DefaultConfiguration; exports.AuthModule = AuthModule; -exports.AuthorizationResult = AuthorizationResult; Object.defineProperty(exports, '__esModule', { value: true }); @@ -13564,12 +23617,12 @@ Object.defineProperty(exports, '__esModule', { value: true }); /***/ }), -/* 48 */ +/* 28 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AppComponent; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(10); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__angular_core___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__angular_core__); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; @@ -13584,8 +23637,8 @@ var AppComponent = (function () { AppComponent = __decorate([ __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["Component"])({ selector: 'app', - template: __webpack_require__(103), - styles: [__webpack_require__(375)] + template: __webpack_require__(83), + styles: [__webpack_require__(118)] }) ], AppComponent); return AppComponent; @@ -13594,20474 +23647,12143 @@ var AppComponent = (function () { /***/ }), -/* 49 */ +/* 29 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; +module.exports = Comment; -var Tokenizer = __webpack_require__(19), - HTML = __webpack_require__(11); - -//Aliases -var $ = HTML.TAG_NAMES, - NS = HTML.NAMESPACES, - ATTRS = HTML.ATTRS; +var Node = __webpack_require__(3); +var CharacterData = __webpack_require__(8); +function Comment(doc, data) { + this.nodeType = Node.COMMENT_NODE; + this.ownerDocument = doc; + this._data = data; + this._index = undefined; +} -//MIME types -var MIME_TYPES = { - TEXT_HTML: 'text/html', - APPLICATION_XML: 'application/xhtml+xml' +var nodeValue = { + get: function() { return this._data; }, + set: function(v) { + this._data = v; + if (this.rooted) + this.ownerDocument.mutateValue(this); + } }; -//Attributes -var DEFINITION_URL_ATTR = 'definitionurl', - ADJUSTED_DEFINITION_URL_ATTR = 'definitionURL', - SVG_ATTRS_ADJUSTMENT_MAP = { - 'attributename': 'attributeName', - 'attributetype': 'attributeType', - 'basefrequency': 'baseFrequency', - 'baseprofile': 'baseProfile', - 'calcmode': 'calcMode', - 'clippathunits': 'clipPathUnits', - 'diffuseconstant': 'diffuseConstant', - 'edgemode': 'edgeMode', - 'filterunits': 'filterUnits', - 'glyphref': 'glyphRef', - 'gradienttransform': 'gradientTransform', - 'gradientunits': 'gradientUnits', - 'kernelmatrix': 'kernelMatrix', - 'kernelunitlength': 'kernelUnitLength', - 'keypoints': 'keyPoints', - 'keysplines': 'keySplines', - 'keytimes': 'keyTimes', - 'lengthadjust': 'lengthAdjust', - 'limitingconeangle': 'limitingConeAngle', - 'markerheight': 'markerHeight', - 'markerunits': 'markerUnits', - 'markerwidth': 'markerWidth', - 'maskcontentunits': 'maskContentUnits', - 'maskunits': 'maskUnits', - 'numoctaves': 'numOctaves', - 'pathlength': 'pathLength', - 'patterncontentunits': 'patternContentUnits', - 'patterntransform': 'patternTransform', - 'patternunits': 'patternUnits', - 'pointsatx': 'pointsAtX', - 'pointsaty': 'pointsAtY', - 'pointsatz': 'pointsAtZ', - 'preservealpha': 'preserveAlpha', - 'preserveaspectratio': 'preserveAspectRatio', - 'primitiveunits': 'primitiveUnits', - 'refx': 'refX', - 'refy': 'refY', - 'repeatcount': 'repeatCount', - 'repeatdur': 'repeatDur', - 'requiredextensions': 'requiredExtensions', - 'requiredfeatures': 'requiredFeatures', - 'specularconstant': 'specularConstant', - 'specularexponent': 'specularExponent', - 'spreadmethod': 'spreadMethod', - 'startoffset': 'startOffset', - 'stddeviation': 'stdDeviation', - 'stitchtiles': 'stitchTiles', - 'surfacescale': 'surfaceScale', - 'systemlanguage': 'systemLanguage', - 'tablevalues': 'tableValues', - 'targetx': 'targetX', - 'targety': 'targetY', - 'textlength': 'textLength', - 'viewbox': 'viewBox', - 'viewtarget': 'viewTarget', - 'xchannelselector': 'xChannelSelector', - 'ychannelselector': 'yChannelSelector', - 'zoomandpan': 'zoomAndPan' - }, - XML_ATTRS_ADJUSTMENT_MAP = { - 'xlink:actuate': {prefix: 'xlink', name: 'actuate', namespace: NS.XLINK}, - 'xlink:arcrole': {prefix: 'xlink', name: 'arcrole', namespace: NS.XLINK}, - 'xlink:href': {prefix: 'xlink', name: 'href', namespace: NS.XLINK}, - 'xlink:role': {prefix: 'xlink', name: 'role', namespace: NS.XLINK}, - 'xlink:show': {prefix: 'xlink', name: 'show', namespace: NS.XLINK}, - 'xlink:title': {prefix: 'xlink', name: 'title', namespace: NS.XLINK}, - 'xlink:type': {prefix: 'xlink', name: 'type', namespace: NS.XLINK}, - 'xml:base': {prefix: 'xml', name: 'base', namespace: NS.XML}, - 'xml:lang': {prefix: 'xml', name: 'lang', namespace: NS.XML}, - 'xml:space': {prefix: 'xml', name: 'space', namespace: NS.XML}, - 'xmlns': {prefix: '', name: 'xmlns', namespace: NS.XMLNS}, - 'xmlns:xlink': {prefix: 'xmlns', name: 'xlink', namespace: NS.XMLNS} - - }; - -//SVG tag names adjustment map -var SVG_TAG_NAMES_ADJUSTMENT_MAP = exports.SVG_TAG_NAMES_ADJUSTMENT_MAP = { - 'altglyph': 'altGlyph', - 'altglyphdef': 'altGlyphDef', - 'altglyphitem': 'altGlyphItem', - 'animatecolor': 'animateColor', - 'animatemotion': 'animateMotion', - 'animatetransform': 'animateTransform', - 'clippath': 'clipPath', - 'feblend': 'feBlend', - 'fecolormatrix': 'feColorMatrix', - 'fecomponenttransfer': 'feComponentTransfer', - 'fecomposite': 'feComposite', - 'feconvolvematrix': 'feConvolveMatrix', - 'fediffuselighting': 'feDiffuseLighting', - 'fedisplacementmap': 'feDisplacementMap', - 'fedistantlight': 'feDistantLight', - 'feflood': 'feFlood', - 'fefunca': 'feFuncA', - 'fefuncb': 'feFuncB', - 'fefuncg': 'feFuncG', - 'fefuncr': 'feFuncR', - 'fegaussianblur': 'feGaussianBlur', - 'feimage': 'feImage', - 'femerge': 'feMerge', - 'femergenode': 'feMergeNode', - 'femorphology': 'feMorphology', - 'feoffset': 'feOffset', - 'fepointlight': 'fePointLight', - 'fespecularlighting': 'feSpecularLighting', - 'fespotlight': 'feSpotLight', - 'fetile': 'feTile', - 'feturbulence': 'feTurbulence', - 'foreignobject': 'foreignObject', - 'glyphref': 'glyphRef', - 'lineargradient': 'linearGradient', - 'radialgradient': 'radialGradient', - 'textpath': 'textPath' -}; +Comment.prototype = Object.create(CharacterData.prototype, { + nodeName: { value: '#comment' }, + nodeValue: nodeValue, + textContent: nodeValue, + data: nodeValue, -//Tags that causes exit from foreign content -var EXITS_FOREIGN_CONTENT = Object.create(null); - -EXITS_FOREIGN_CONTENT[$.B] = true; -EXITS_FOREIGN_CONTENT[$.BIG] = true; -EXITS_FOREIGN_CONTENT[$.BLOCKQUOTE] = true; -EXITS_FOREIGN_CONTENT[$.BODY] = true; -EXITS_FOREIGN_CONTENT[$.BR] = true; -EXITS_FOREIGN_CONTENT[$.CENTER] = true; -EXITS_FOREIGN_CONTENT[$.CODE] = true; -EXITS_FOREIGN_CONTENT[$.DD] = true; -EXITS_FOREIGN_CONTENT[$.DIV] = true; -EXITS_FOREIGN_CONTENT[$.DL] = true; -EXITS_FOREIGN_CONTENT[$.DT] = true; -EXITS_FOREIGN_CONTENT[$.EM] = true; -EXITS_FOREIGN_CONTENT[$.EMBED] = true; -EXITS_FOREIGN_CONTENT[$.H1] = true; -EXITS_FOREIGN_CONTENT[$.H2] = true; -EXITS_FOREIGN_CONTENT[$.H3] = true; -EXITS_FOREIGN_CONTENT[$.H4] = true; -EXITS_FOREIGN_CONTENT[$.H5] = true; -EXITS_FOREIGN_CONTENT[$.H6] = true; -EXITS_FOREIGN_CONTENT[$.HEAD] = true; -EXITS_FOREIGN_CONTENT[$.HR] = true; -EXITS_FOREIGN_CONTENT[$.I] = true; -EXITS_FOREIGN_CONTENT[$.IMG] = true; -EXITS_FOREIGN_CONTENT[$.LI] = true; -EXITS_FOREIGN_CONTENT[$.LISTING] = true; -EXITS_FOREIGN_CONTENT[$.MENU] = true; -EXITS_FOREIGN_CONTENT[$.META] = true; -EXITS_FOREIGN_CONTENT[$.NOBR] = true; -EXITS_FOREIGN_CONTENT[$.OL] = true; -EXITS_FOREIGN_CONTENT[$.P] = true; -EXITS_FOREIGN_CONTENT[$.PRE] = true; -EXITS_FOREIGN_CONTENT[$.RUBY] = true; -EXITS_FOREIGN_CONTENT[$.S] = true; -EXITS_FOREIGN_CONTENT[$.SMALL] = true; -EXITS_FOREIGN_CONTENT[$.SPAN] = true; -EXITS_FOREIGN_CONTENT[$.STRONG] = true; -EXITS_FOREIGN_CONTENT[$.STRIKE] = true; -EXITS_FOREIGN_CONTENT[$.SUB] = true; -EXITS_FOREIGN_CONTENT[$.SUP] = true; -EXITS_FOREIGN_CONTENT[$.TABLE] = true; -EXITS_FOREIGN_CONTENT[$.TT] = true; -EXITS_FOREIGN_CONTENT[$.U] = true; -EXITS_FOREIGN_CONTENT[$.UL] = true; -EXITS_FOREIGN_CONTENT[$.VAR] = true; - -//Check exit from foreign content -exports.causesExit = function (startTagToken) { - var tn = startTagToken.tagName; - var isFontWithAttrs = tn === $.FONT && (Tokenizer.getTokenAttr(startTagToken, ATTRS.COLOR) !== null || - Tokenizer.getTokenAttr(startTagToken, ATTRS.SIZE) !== null || - Tokenizer.getTokenAttr(startTagToken, ATTRS.FACE) !== null); - - return isFontWithAttrs ? true : EXITS_FOREIGN_CONTENT[tn]; -}; + // Utility methods + clone: { value: function clone() { + return new Comment(this.ownerDocument, this._data); + }}, +}); -//Token adjustments -exports.adjustTokenMathMLAttrs = function (token) { - for (var i = 0; i < token.attrs.length; i++) { - if (token.attrs[i].name === DEFINITION_URL_ATTR) { - token.attrs[i].name = ADJUSTED_DEFINITION_URL_ATTR; - break; - } - } -}; -exports.adjustTokenSVGAttrs = function (token) { - for (var i = 0; i < token.attrs.length; i++) { - var adjustedAttrName = SVG_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name]; - - if (adjustedAttrName) - token.attrs[i].name = adjustedAttrName; - } -}; - -exports.adjustTokenXMLAttrs = function (token) { - for (var i = 0; i < token.attrs.length; i++) { - var adjustedAttrEntry = XML_ATTRS_ADJUSTMENT_MAP[token.attrs[i].name]; - - if (adjustedAttrEntry) { - token.attrs[i].prefix = adjustedAttrEntry.prefix; - token.attrs[i].name = adjustedAttrEntry.name; - token.attrs[i].namespace = adjustedAttrEntry.namespace; - } - } -}; - -exports.adjustTokenSVGTagName = function (token) { - var adjustedTagName = SVG_TAG_NAMES_ADJUSTMENT_MAP[token.tagName]; - - if (adjustedTagName) - token.tagName = adjustedTagName; -}; +/***/ }), +/* 30 */ +/***/ (function(module, exports, __webpack_require__) { -//Integration points -function isMathMLTextIntegrationPoint(tn, ns) { - return ns === NS.MATHML && (tn === $.MI || tn === $.MO || tn === $.MN || tn === $.MS || tn === $.MTEXT); -} +"use strict"; -function isHtmlIntegrationPoint(tn, ns, attrs) { - if (ns === NS.MATHML && tn === $.ANNOTATION_XML) { - for (var i = 0; i < attrs.length; i++) { - if (attrs[i].name === ATTRS.ENCODING) { - var value = attrs[i].value.toLowerCase(); +module.exports = DOMException; + +var INDEX_SIZE_ERR = 1; +var HIERARCHY_REQUEST_ERR = 3; +var WRONG_DOCUMENT_ERR = 4; +var INVALID_CHARACTER_ERR = 5; +var NO_MODIFICATION_ALLOWED_ERR = 7; +var NOT_FOUND_ERR = 8; +var NOT_SUPPORTED_ERR = 9; +var INVALID_STATE_ERR = 11; +var SYNTAX_ERR = 12; +var INVALID_MODIFICATION_ERR = 13; +var NAMESPACE_ERR = 14; +var INVALID_ACCESS_ERR = 15; +var TYPE_MISMATCH_ERR = 17; +var SECURITY_ERR = 18; +var NETWORK_ERR = 19; +var ABORT_ERR = 20; +var URL_MISMATCH_ERR = 21; +var QUOTA_EXCEEDED_ERR = 22; +var TIMEOUT_ERR = 23; +var INVALID_NODE_TYPE_ERR = 24; +var DATA_CLONE_ERR = 25; + +// Code to name +var names = [ + null, // No error with code 0 + 'INDEX_SIZE_ERR', + null, // historical + 'HIERARCHY_REQUEST_ERR', + 'WRONG_DOCUMENT_ERR', + 'INVALID_CHARACTER_ERR', + null, // historical + 'NO_MODIFICATION_ALLOWED_ERR', + 'NOT_FOUND_ERR', + 'NOT_SUPPORTED_ERR', + null, // historical + 'INVALID_STATE_ERR', + 'SYNTAX_ERR', + 'INVALID_MODIFICATION_ERR', + 'NAMESPACE_ERR', + 'INVALID_ACCESS_ERR', + null, // historical + 'TYPE_MISMATCH_ERR', + 'SECURITY_ERR', + 'NETWORK_ERR', + 'ABORT_ERR', + 'URL_MISMATCH_ERR', + 'QUOTA_EXCEEDED_ERR', + 'TIMEOUT_ERR', + 'INVALID_NODE_TYPE_ERR', + 'DATA_CLONE_ERR', +]; - return value === MIME_TYPES.TEXT_HTML || value === MIME_TYPES.APPLICATION_XML; - } - } - } +// Code to message +// These strings are from the 13 May 2011 Editor's Draft of DOM Core. +// http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html +// Copyright © 2011 W3C® (MIT, ERCIM, Keio), All Rights Reserved. +// Used under the terms of the W3C Document License: +// http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231 +var messages = [ + null, // No error with code 0 + 'INDEX_SIZE_ERR (1): the index is not in the allowed range', + null, + 'HIERARCHY_REQUEST_ERR (3): the operation would yield an incorrect nodes model', + 'WRONG_DOCUMENT_ERR (4): the object is in the wrong Document, a call to importNode is required', + 'INVALID_CHARACTER_ERR (5): the string contains invalid characters', + null, + 'NO_MODIFICATION_ALLOWED_ERR (7): the object can not be modified', + 'NOT_FOUND_ERR (8): the object can not be found here', + 'NOT_SUPPORTED_ERR (9): this operation is not supported', + null, + 'INVALID_STATE_ERR (11): the object is in an invalid state', + 'SYNTAX_ERR (12): the string did not match the expected pattern', + 'INVALID_MODIFICATION_ERR (13): the object can not be modified in this way', + 'NAMESPACE_ERR (14): the operation is not allowed by Namespaces in XML', + 'INVALID_ACCESS_ERR (15): the object does not support the operation or argument', + null, + 'TYPE_MISMATCH_ERR (17): the type of the object does not match the expected type', + 'SECURITY_ERR (18): the operation is insecure', + 'NETWORK_ERR (19): a network error occurred', + 'ABORT_ERR (20): the user aborted an operation', + 'URL_MISMATCH_ERR (21): the given URL does not match another URL', + 'QUOTA_EXCEEDED_ERR (22): the quota has been exceeded', + 'TIMEOUT_ERR (23): a timeout occurred', + 'INVALID_NODE_TYPE_ERR (24): the supplied node is invalid or has an invalid ancestor for this operation', + 'DATA_CLONE_ERR (25): the object can not be cloned.' +]; - return ns === NS.SVG && (tn === $.FOREIGN_OBJECT || tn === $.DESC || tn === $.TITLE); +// Name to code +var constants = { + INDEX_SIZE_ERR: INDEX_SIZE_ERR, + DOMSTRING_SIZE_ERR: 2, // historical + HIERARCHY_REQUEST_ERR: HIERARCHY_REQUEST_ERR, + WRONG_DOCUMENT_ERR: WRONG_DOCUMENT_ERR, + INVALID_CHARACTER_ERR: INVALID_CHARACTER_ERR, + NO_DATA_ALLOWED_ERR: 6, // historical + NO_MODIFICATION_ALLOWED_ERR: NO_MODIFICATION_ALLOWED_ERR, + NOT_FOUND_ERR: NOT_FOUND_ERR, + NOT_SUPPORTED_ERR: NOT_SUPPORTED_ERR, + INUSE_ATTRIBUTE_ERR: 10, // historical + INVALID_STATE_ERR: INVALID_STATE_ERR, + SYNTAX_ERR: SYNTAX_ERR, + INVALID_MODIFICATION_ERR: INVALID_MODIFICATION_ERR, + NAMESPACE_ERR: NAMESPACE_ERR, + INVALID_ACCESS_ERR: INVALID_ACCESS_ERR, + VALIDATION_ERR: 16, // historical + TYPE_MISMATCH_ERR: TYPE_MISMATCH_ERR, + SECURITY_ERR: SECURITY_ERR, + NETWORK_ERR: NETWORK_ERR, + ABORT_ERR: ABORT_ERR, + URL_MISMATCH_ERR: URL_MISMATCH_ERR, + QUOTA_EXCEEDED_ERR: QUOTA_EXCEEDED_ERR, + TIMEOUT_ERR: TIMEOUT_ERR, + INVALID_NODE_TYPE_ERR: INVALID_NODE_TYPE_ERR, + DATA_CLONE_ERR: DATA_CLONE_ERR +}; + +function DOMException(code) { + Error.call(this); + Error.captureStackTrace(this, this.constructor); + this.code = code; + this.message = messages[code]; + this.name = names[code]; +} +DOMException.prototype.__proto__ = Error.prototype; + +// Initialize the constants on DOMException and DOMException.prototype +for(var c in constants) { + var v = { value: constants[c] }; + Object.defineProperty(DOMException, c, v); + Object.defineProperty(DOMException.prototype, c, v); } -exports.isIntegrationPoint = function (tn, ns, attrs, foreignNS) { - if ((!foreignNS || foreignNS === NS.HTML) && isHtmlIntegrationPoint(tn, ns, attrs)) - return true; - - if ((!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns)) - return true; - - return false; -}; - /***/ }), -/* 50 */ +/* 31 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; +// DOMTokenList implementation based on https://github.com/Raynos/DOM-shim +var utils = __webpack_require__(1); -var Tokenizer = __webpack_require__(19), - OpenElementStack = __webpack_require__(51), - FormattingElementList = __webpack_require__(112), - locationInfoMixin = __webpack_require__(110), - defaultTreeAdapter = __webpack_require__(36), - doctype = __webpack_require__(33), - foreignContent = __webpack_require__(49), - mergeOptions = __webpack_require__(34), - UNICODE = __webpack_require__(18), - HTML = __webpack_require__(11); - -//Aliases -var $ = HTML.TAG_NAMES, - NS = HTML.NAMESPACES, - ATTRS = HTML.ATTRS; - -var DEFAULT_OPTIONS = { - locationInfo: false, - treeAdapter: defaultTreeAdapter -}; +module.exports = DOMTokenList; -//Misc constants -var HIDDEN_INPUT_TYPE = 'hidden'; - -//Adoption agency loops iteration count -var AA_OUTER_LOOP_ITER = 8, - AA_INNER_LOOP_ITER = 3; - -//Insertion modes -var INITIAL_MODE = 'INITIAL_MODE', - BEFORE_HTML_MODE = 'BEFORE_HTML_MODE', - BEFORE_HEAD_MODE = 'BEFORE_HEAD_MODE', - IN_HEAD_MODE = 'IN_HEAD_MODE', - AFTER_HEAD_MODE = 'AFTER_HEAD_MODE', - IN_BODY_MODE = 'IN_BODY_MODE', - TEXT_MODE = 'TEXT_MODE', - IN_TABLE_MODE = 'IN_TABLE_MODE', - IN_TABLE_TEXT_MODE = 'IN_TABLE_TEXT_MODE', - IN_CAPTION_MODE = 'IN_CAPTION_MODE', - IN_COLUMN_GROUP_MODE = 'IN_COLUMN_GROUP_MODE', - IN_TABLE_BODY_MODE = 'IN_TABLE_BODY_MODE', - IN_ROW_MODE = 'IN_ROW_MODE', - IN_CELL_MODE = 'IN_CELL_MODE', - IN_SELECT_MODE = 'IN_SELECT_MODE', - IN_SELECT_IN_TABLE_MODE = 'IN_SELECT_IN_TABLE_MODE', - IN_TEMPLATE_MODE = 'IN_TEMPLATE_MODE', - AFTER_BODY_MODE = 'AFTER_BODY_MODE', - IN_FRAMESET_MODE = 'IN_FRAMESET_MODE', - AFTER_FRAMESET_MODE = 'AFTER_FRAMESET_MODE', - AFTER_AFTER_BODY_MODE = 'AFTER_AFTER_BODY_MODE', - AFTER_AFTER_FRAMESET_MODE = 'AFTER_AFTER_FRAMESET_MODE'; - -//Insertion mode reset map -var INSERTION_MODE_RESET_MAP = Object.create(null); - -INSERTION_MODE_RESET_MAP[$.TR] = IN_ROW_MODE; -INSERTION_MODE_RESET_MAP[$.TBODY] = -INSERTION_MODE_RESET_MAP[$.THEAD] = -INSERTION_MODE_RESET_MAP[$.TFOOT] = IN_TABLE_BODY_MODE; -INSERTION_MODE_RESET_MAP[$.CAPTION] = IN_CAPTION_MODE; -INSERTION_MODE_RESET_MAP[$.COLGROUP] = IN_COLUMN_GROUP_MODE; -INSERTION_MODE_RESET_MAP[$.TABLE] = IN_TABLE_MODE; -INSERTION_MODE_RESET_MAP[$.BODY] = IN_BODY_MODE; -INSERTION_MODE_RESET_MAP[$.FRAMESET] = IN_FRAMESET_MODE; - -//Template insertion mode switch map -var TEMPLATE_INSERTION_MODE_SWITCH_MAP = Object.create(null); - -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.CAPTION] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.COLGROUP] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TBODY] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TFOOT] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.THEAD] = IN_TABLE_MODE; -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.COL] = IN_COLUMN_GROUP_MODE; -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TR] = IN_TABLE_BODY_MODE; -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TD] = -TEMPLATE_INSERTION_MODE_SWITCH_MAP[$.TH] = IN_ROW_MODE; - -//Token handlers map for insertion modes -var _ = Object.create(null); - -_[INITIAL_MODE] = Object.create(null); -_[INITIAL_MODE][Tokenizer.CHARACTER_TOKEN] = -_[INITIAL_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenInInitialMode; -_[INITIAL_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = ignoreToken; -_[INITIAL_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[INITIAL_MODE][Tokenizer.DOCTYPE_TOKEN] = doctypeInInitialMode; -_[INITIAL_MODE][Tokenizer.START_TAG_TOKEN] = -_[INITIAL_MODE][Tokenizer.END_TAG_TOKEN] = -_[INITIAL_MODE][Tokenizer.EOF_TOKEN] = tokenInInitialMode; - -_[BEFORE_HTML_MODE] = Object.create(null); -_[BEFORE_HTML_MODE][Tokenizer.CHARACTER_TOKEN] = -_[BEFORE_HTML_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenBeforeHtml; -_[BEFORE_HTML_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = ignoreToken; -_[BEFORE_HTML_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[BEFORE_HTML_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[BEFORE_HTML_MODE][Tokenizer.START_TAG_TOKEN] = startTagBeforeHtml; -_[BEFORE_HTML_MODE][Tokenizer.END_TAG_TOKEN] = endTagBeforeHtml; -_[BEFORE_HTML_MODE][Tokenizer.EOF_TOKEN] = tokenBeforeHtml; - -_[BEFORE_HEAD_MODE] = Object.create(null); -_[BEFORE_HEAD_MODE][Tokenizer.CHARACTER_TOKEN] = -_[BEFORE_HEAD_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenBeforeHead; -_[BEFORE_HEAD_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = ignoreToken; -_[BEFORE_HEAD_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[BEFORE_HEAD_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[BEFORE_HEAD_MODE][Tokenizer.START_TAG_TOKEN] = startTagBeforeHead; -_[BEFORE_HEAD_MODE][Tokenizer.END_TAG_TOKEN] = endTagBeforeHead; -_[BEFORE_HEAD_MODE][Tokenizer.EOF_TOKEN] = tokenBeforeHead; - -_[IN_HEAD_MODE] = Object.create(null); -_[IN_HEAD_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_HEAD_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenInHead; -_[IN_HEAD_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_HEAD_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_HEAD_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_HEAD_MODE][Tokenizer.START_TAG_TOKEN] = startTagInHead; -_[IN_HEAD_MODE][Tokenizer.END_TAG_TOKEN] = endTagInHead; -_[IN_HEAD_MODE][Tokenizer.EOF_TOKEN] = tokenInHead; - -_[AFTER_HEAD_MODE] = Object.create(null); -_[AFTER_HEAD_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_HEAD_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenAfterHead; -_[AFTER_HEAD_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[AFTER_HEAD_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[AFTER_HEAD_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_HEAD_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterHead; -_[AFTER_HEAD_MODE][Tokenizer.END_TAG_TOKEN] = endTagAfterHead; -_[AFTER_HEAD_MODE][Tokenizer.EOF_TOKEN] = tokenAfterHead; - -_[IN_BODY_MODE] = Object.create(null); -_[IN_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagInBody; -_[IN_BODY_MODE][Tokenizer.END_TAG_TOKEN] = endTagInBody; -_[IN_BODY_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[TEXT_MODE] = Object.create(null); -_[TEXT_MODE][Tokenizer.CHARACTER_TOKEN] = -_[TEXT_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[TEXT_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[TEXT_MODE][Tokenizer.COMMENT_TOKEN] = -_[TEXT_MODE][Tokenizer.DOCTYPE_TOKEN] = -_[TEXT_MODE][Tokenizer.START_TAG_TOKEN] = ignoreToken; -_[TEXT_MODE][Tokenizer.END_TAG_TOKEN] = endTagInText; -_[TEXT_MODE][Tokenizer.EOF_TOKEN] = eofInText; - -_[IN_TABLE_MODE] = Object.create(null); -_[IN_TABLE_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_TABLE_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[IN_TABLE_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = characterInTable; -_[IN_TABLE_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_TABLE_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_TABLE_MODE][Tokenizer.START_TAG_TOKEN] = startTagInTable; -_[IN_TABLE_MODE][Tokenizer.END_TAG_TOKEN] = endTagInTable; -_[IN_TABLE_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_TABLE_TEXT_MODE] = Object.create(null); -_[IN_TABLE_TEXT_MODE][Tokenizer.CHARACTER_TOKEN] = characterInTableText; -_[IN_TABLE_TEXT_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_TABLE_TEXT_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInTableText; -_[IN_TABLE_TEXT_MODE][Tokenizer.COMMENT_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.DOCTYPE_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.START_TAG_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.END_TAG_TOKEN] = -_[IN_TABLE_TEXT_MODE][Tokenizer.EOF_TOKEN] = tokenInTableText; - -_[IN_CAPTION_MODE] = Object.create(null); -_[IN_CAPTION_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_CAPTION_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_CAPTION_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_CAPTION_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_CAPTION_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_CAPTION_MODE][Tokenizer.START_TAG_TOKEN] = startTagInCaption; -_[IN_CAPTION_MODE][Tokenizer.END_TAG_TOKEN] = endTagInCaption; -_[IN_CAPTION_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_COLUMN_GROUP_MODE] = Object.create(null); -_[IN_COLUMN_GROUP_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_COLUMN_GROUP_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenInColumnGroup; -_[IN_COLUMN_GROUP_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_COLUMN_GROUP_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_COLUMN_GROUP_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_COLUMN_GROUP_MODE][Tokenizer.START_TAG_TOKEN] = startTagInColumnGroup; -_[IN_COLUMN_GROUP_MODE][Tokenizer.END_TAG_TOKEN] = endTagInColumnGroup; -_[IN_COLUMN_GROUP_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_TABLE_BODY_MODE] = Object.create(null); -_[IN_TABLE_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_TABLE_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[IN_TABLE_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = characterInTable; -_[IN_TABLE_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_TABLE_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_TABLE_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagInTableBody; -_[IN_TABLE_BODY_MODE][Tokenizer.END_TAG_TOKEN] = endTagInTableBody; -_[IN_TABLE_BODY_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_ROW_MODE] = Object.create(null); -_[IN_ROW_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_ROW_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = -_[IN_ROW_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = characterInTable; -_[IN_ROW_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_ROW_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_ROW_MODE][Tokenizer.START_TAG_TOKEN] = startTagInRow; -_[IN_ROW_MODE][Tokenizer.END_TAG_TOKEN] = endTagInRow; -_[IN_ROW_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_CELL_MODE] = Object.create(null); -_[IN_CELL_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_CELL_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_CELL_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_CELL_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_CELL_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_CELL_MODE][Tokenizer.START_TAG_TOKEN] = startTagInCell; -_[IN_CELL_MODE][Tokenizer.END_TAG_TOKEN] = endTagInCell; -_[IN_CELL_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_SELECT_MODE] = Object.create(null); -_[IN_SELECT_MODE][Tokenizer.CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_SELECT_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_SELECT_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_SELECT_MODE][Tokenizer.START_TAG_TOKEN] = startTagInSelect; -_[IN_SELECT_MODE][Tokenizer.END_TAG_TOKEN] = endTagInSelect; -_[IN_SELECT_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_SELECT_IN_TABLE_MODE] = Object.create(null); -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.START_TAG_TOKEN] = startTagInSelectInTable; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.END_TAG_TOKEN] = endTagInSelectInTable; -_[IN_SELECT_IN_TABLE_MODE][Tokenizer.EOF_TOKEN] = eofInBody; - -_[IN_TEMPLATE_MODE] = Object.create(null); -_[IN_TEMPLATE_MODE][Tokenizer.CHARACTER_TOKEN] = characterInBody; -_[IN_TEMPLATE_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_TEMPLATE_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[IN_TEMPLATE_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_TEMPLATE_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_TEMPLATE_MODE][Tokenizer.START_TAG_TOKEN] = startTagInTemplate; -_[IN_TEMPLATE_MODE][Tokenizer.END_TAG_TOKEN] = endTagInTemplate; -_[IN_TEMPLATE_MODE][Tokenizer.EOF_TOKEN] = eofInTemplate; - -_[AFTER_BODY_MODE] = Object.create(null); -_[AFTER_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenAfterBody; -_[AFTER_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[AFTER_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendCommentToRootHtmlElement; -_[AFTER_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterBody; -_[AFTER_BODY_MODE][Tokenizer.END_TAG_TOKEN] = endTagAfterBody; -_[AFTER_BODY_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[IN_FRAMESET_MODE] = Object.create(null); -_[IN_FRAMESET_MODE][Tokenizer.CHARACTER_TOKEN] = -_[IN_FRAMESET_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[IN_FRAMESET_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[IN_FRAMESET_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[IN_FRAMESET_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[IN_FRAMESET_MODE][Tokenizer.START_TAG_TOKEN] = startTagInFrameset; -_[IN_FRAMESET_MODE][Tokenizer.END_TAG_TOKEN] = endTagInFrameset; -_[IN_FRAMESET_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[AFTER_FRAMESET_MODE] = Object.create(null); -_[AFTER_FRAMESET_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_FRAMESET_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[AFTER_FRAMESET_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = insertCharacters; -_[AFTER_FRAMESET_MODE][Tokenizer.COMMENT_TOKEN] = appendComment; -_[AFTER_FRAMESET_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_FRAMESET_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterFrameset; -_[AFTER_FRAMESET_MODE][Tokenizer.END_TAG_TOKEN] = endTagAfterFrameset; -_[AFTER_FRAMESET_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[AFTER_AFTER_BODY_MODE] = Object.create(null); -_[AFTER_AFTER_BODY_MODE][Tokenizer.CHARACTER_TOKEN] = tokenAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = tokenAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.COMMENT_TOKEN] = appendCommentToDocument; -_[AFTER_AFTER_BODY_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_AFTER_BODY_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.END_TAG_TOKEN] = tokenAfterAfterBody; -_[AFTER_AFTER_BODY_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - -_[AFTER_AFTER_FRAMESET_MODE] = Object.create(null); -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.CHARACTER_TOKEN] = -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.NULL_CHARACTER_TOKEN] = ignoreToken; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.WHITESPACE_CHARACTER_TOKEN] = whitespaceCharacterInBody; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.COMMENT_TOKEN] = appendCommentToDocument; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.DOCTYPE_TOKEN] = ignoreToken; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.START_TAG_TOKEN] = startTagAfterAfterFrameset; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.END_TAG_TOKEN] = ignoreToken; -_[AFTER_AFTER_FRAMESET_MODE][Tokenizer.EOF_TOKEN] = stopParsing; - - -//Parser -var Parser = module.exports = function (options) { - this.options = mergeOptions(DEFAULT_OPTIONS, options); - - this.treeAdapter = this.options.treeAdapter; - this.pendingScript = null; - - if (this.options.locationInfo) - locationInfoMixin.assign(this); -}; +function DOMTokenList(getter, setter) { + this._getString = getter; + this._setString = setter; + fixIndex(this, getList(this)); +} -// API -Parser.prototype.parse = function (html) { - var document = this.treeAdapter.createDocument(); +DOMTokenList.prototype = { + item: function(index) { + if (index >= this.length) { + return null; + } + return this._getString().split(" ")[index]; + }, - this._bootstrap(document, null); - this.tokenizer.write(html, true); - this._runParsingLoop(null); + contains: function(token) { + token = String(token); + handleErrors(token); + var list = getList(this); + return list.indexOf(token) > -1; + }, - return document; -}; + add: function(token) { + handleErrors(token); + var list = getList(this); + if (list.indexOf(token) > -1) { + return; + } + list.push(token); + this._setString(list.join(" ").trim()); + fixIndex(this, list); + }, -Parser.prototype.parseFragment = function (html, fragmentContext) { - //NOTE: use