UNPKG

79.1 kBJavaScriptView Raw
1/**
2 * @license Angular v9.0.5
3 * (c) 2010-2020 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import { __extends, __assign, __decorate, __param, __metadata } from 'tslib';
8import { ɵDomAdapter, ɵsetRootDomAdapter, ɵparseCookieValue, ɵgetDOM, DOCUMENT, ɵPLATFORM_BROWSER_ID, CommonModule } from '@angular/common';
9export { ɵgetDOM } from '@angular/common';
10import { ɵglobal, InjectionToken, ApplicationInitStatus, APP_INITIALIZER, Injector, setTestabilityGetter, ApplicationRef, NgZone, ɵgetDebugNodeR2, NgProbeToken, Optional, Injectable, Inject, ViewEncapsulation, APP_ID, RendererStyleFlags2, ɵConsole, NgModule, ɵɵdefineInjectable, ɵɵinject, forwardRef, SecurityContext, ɵallowSanitizationBypassAndThrow, ɵunwrapSafeValue, ɵgetSanitizationBypassType, ɵ_sanitizeUrl, ɵ_sanitizeStyle, ɵ_sanitizeHtml, ɵbypassSanitizationTrustHtml, ɵbypassSanitizationTrustStyle, ɵbypassSanitizationTrustScript, ɵbypassSanitizationTrustUrl, ɵbypassSanitizationTrustResourceUrl, INJECTOR, ErrorHandler, ɵsetDocument, PLATFORM_ID, PLATFORM_INITIALIZER, Sanitizer, createPlatformFactory, platformCore, ɵINJECTOR_SCOPE, RendererFactory2, Testability, ApplicationModule, SkipSelf, Version } from '@angular/core';
11
12/**
13 * @license
14 * Copyright Google Inc. All Rights Reserved.
15 *
16 * Use of this source code is governed by an MIT-style license that can be
17 * found in the LICENSE file at https://angular.io/license
18 */
19/**
20 * Provides DOM operations in any browser environment.
21 *
22 * @security Tread carefully! Interacting with the DOM directly is dangerous and
23 * can introduce XSS risks.
24 */
25var GenericBrowserDomAdapter = /** @class */ (function (_super) {
26 __extends(GenericBrowserDomAdapter, _super);
27 function GenericBrowserDomAdapter() {
28 return _super.call(this) || this;
29 }
30 GenericBrowserDomAdapter.prototype.supportsDOMEvents = function () { return true; };
31 return GenericBrowserDomAdapter;
32}(ɵDomAdapter));
33
34/**
35 * @license
36 * Copyright Google Inc. All Rights Reserved.
37 *
38 * Use of this source code is governed by an MIT-style license that can be
39 * found in the LICENSE file at https://angular.io/license
40 */
41var ɵ0 = function () {
42 if (ɵglobal['Node']) {
43 return ɵglobal['Node'].prototype.contains || function (node) {
44 return !!(this.compareDocumentPosition(node) & 16);
45 };
46 }
47 return undefined;
48};
49var nodeContains = (ɵ0)();
50/**
51 * A `DomAdapter` powered by full browser DOM APIs.
52 *
53 * @security Tread carefully! Interacting with the DOM directly is dangerous and
54 * can introduce XSS risks.
55 */
56/* tslint:disable:requireParameterType no-console */
57var BrowserDomAdapter = /** @class */ (function (_super) {
58 __extends(BrowserDomAdapter, _super);
59 function BrowserDomAdapter() {
60 return _super !== null && _super.apply(this, arguments) || this;
61 }
62 BrowserDomAdapter.makeCurrent = function () { ɵsetRootDomAdapter(new BrowserDomAdapter()); };
63 BrowserDomAdapter.prototype.getProperty = function (el, name) { return el[name]; };
64 BrowserDomAdapter.prototype.log = function (error) {
65 if (window.console) {
66 window.console.log && window.console.log(error);
67 }
68 };
69 BrowserDomAdapter.prototype.logGroup = function (error) {
70 if (window.console) {
71 window.console.group && window.console.group(error);
72 }
73 };
74 BrowserDomAdapter.prototype.logGroupEnd = function () {
75 if (window.console) {
76 window.console.groupEnd && window.console.groupEnd();
77 }
78 };
79 BrowserDomAdapter.prototype.onAndCancel = function (el, evt, listener) {
80 el.addEventListener(evt, listener, false);
81 // Needed to follow Dart's subscription semantic, until fix of
82 // https://code.google.com/p/dart/issues/detail?id=17406
83 return function () { el.removeEventListener(evt, listener, false); };
84 };
85 BrowserDomAdapter.prototype.dispatchEvent = function (el, evt) { el.dispatchEvent(evt); };
86 BrowserDomAdapter.prototype.remove = function (node) {
87 if (node.parentNode) {
88 node.parentNode.removeChild(node);
89 }
90 return node;
91 };
92 BrowserDomAdapter.prototype.getValue = function (el) { return el.value; };
93 BrowserDomAdapter.prototype.createElement = function (tagName, doc) {
94 doc = doc || this.getDefaultDocument();
95 return doc.createElement(tagName);
96 };
97 BrowserDomAdapter.prototype.createHtmlDocument = function () {
98 return document.implementation.createHTMLDocument('fakeTitle');
99 };
100 BrowserDomAdapter.prototype.getDefaultDocument = function () { return document; };
101 BrowserDomAdapter.prototype.isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
102 BrowserDomAdapter.prototype.isShadowRoot = function (node) { return node instanceof DocumentFragment; };
103 BrowserDomAdapter.prototype.getGlobalEventTarget = function (doc, target) {
104 if (target === 'window') {
105 return window;
106 }
107 if (target === 'document') {
108 return doc;
109 }
110 if (target === 'body') {
111 return doc.body;
112 }
113 return null;
114 };
115 BrowserDomAdapter.prototype.getHistory = function () { return window.history; };
116 BrowserDomAdapter.prototype.getLocation = function () { return window.location; };
117 BrowserDomAdapter.prototype.getBaseHref = function (doc) {
118 var href = getBaseElementHref();
119 return href == null ? null : relativePath(href);
120 };
121 BrowserDomAdapter.prototype.resetBaseElement = function () { baseElement = null; };
122 BrowserDomAdapter.prototype.getUserAgent = function () { return window.navigator.userAgent; };
123 BrowserDomAdapter.prototype.performanceNow = function () {
124 // performance.now() is not available in all browsers, see
125 // http://caniuse.com/#search=performance.now
126 return window.performance && window.performance.now ? window.performance.now() :
127 new Date().getTime();
128 };
129 BrowserDomAdapter.prototype.supportsCookies = function () { return true; };
130 BrowserDomAdapter.prototype.getCookie = function (name) { return ɵparseCookieValue(document.cookie, name); };
131 return BrowserDomAdapter;
132}(GenericBrowserDomAdapter));
133var baseElement = null;
134function getBaseElementHref() {
135 if (!baseElement) {
136 baseElement = document.querySelector('base');
137 if (!baseElement) {
138 return null;
139 }
140 }
141 return baseElement.getAttribute('href');
142}
143// based on urlUtils.js in AngularJS 1
144var urlParsingNode;
145function relativePath(url) {
146 if (!urlParsingNode) {
147 urlParsingNode = document.createElement('a');
148 }
149 urlParsingNode.setAttribute('href', url);
150 return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
151 '/' + urlParsingNode.pathname;
152}
153
154/**
155 * @license
156 * Copyright Google Inc. All Rights Reserved.
157 *
158 * Use of this source code is governed by an MIT-style license that can be
159 * found in the LICENSE file at https://angular.io/license
160 */
161/**
162 * An id that identifies a particular application being bootstrapped, that should
163 * match across the client/server boundary.
164 */
165var TRANSITION_ID = new InjectionToken('TRANSITION_ID');
166function appInitializerFactory(transitionId, document, injector) {
167 return function () {
168 // Wait for all application initializers to be completed before removing the styles set by
169 // the server.
170 injector.get(ApplicationInitStatus).donePromise.then(function () {
171 var dom = ɵgetDOM();
172 var styles = Array.prototype.slice.apply(document.querySelectorAll("style[ng-transition]"));
173 styles.filter(function (el) { return el.getAttribute('ng-transition') === transitionId; })
174 .forEach(function (el) { return dom.remove(el); });
175 });
176 };
177}
178var SERVER_TRANSITION_PROVIDERS = [
179 {
180 provide: APP_INITIALIZER,
181 useFactory: appInitializerFactory,
182 deps: [TRANSITION_ID, DOCUMENT, Injector],
183 multi: true
184 },
185];
186
187/**
188 * @license
189 * Copyright Google Inc. All Rights Reserved.
190 *
191 * Use of this source code is governed by an MIT-style license that can be
192 * found in the LICENSE file at https://angular.io/license
193 */
194var BrowserGetTestability = /** @class */ (function () {
195 function BrowserGetTestability() {
196 }
197 BrowserGetTestability.init = function () { setTestabilityGetter(new BrowserGetTestability()); };
198 BrowserGetTestability.prototype.addToWindow = function (registry) {
199 ɵglobal['getAngularTestability'] = function (elem, findInAncestors) {
200 if (findInAncestors === void 0) { findInAncestors = true; }
201 var testability = registry.findTestabilityInTree(elem, findInAncestors);
202 if (testability == null) {
203 throw new Error('Could not find testability for element.');
204 }
205 return testability;
206 };
207 ɵglobal['getAllAngularTestabilities'] = function () { return registry.getAllTestabilities(); };
208 ɵglobal['getAllAngularRootElements'] = function () { return registry.getAllRootElements(); };
209 var whenAllStable = function (callback /** TODO #9100 */) {
210 var testabilities = ɵglobal['getAllAngularTestabilities']();
211 var count = testabilities.length;
212 var didWork = false;
213 var decrement = function (didWork_ /** TODO #9100 */) {
214 didWork = didWork || didWork_;
215 count--;
216 if (count == 0) {
217 callback(didWork);
218 }
219 };
220 testabilities.forEach(function (testability /** TODO #9100 */) {
221 testability.whenStable(decrement);
222 });
223 };
224 if (!ɵglobal['frameworkStabilizers']) {
225 ɵglobal['frameworkStabilizers'] = [];
226 }
227 ɵglobal['frameworkStabilizers'].push(whenAllStable);
228 };
229 BrowserGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
230 if (elem == null) {
231 return null;
232 }
233 var t = registry.getTestability(elem);
234 if (t != null) {
235 return t;
236 }
237 else if (!findInAncestors) {
238 return null;
239 }
240 if (ɵgetDOM().isShadowRoot(elem)) {
241 return this.findTestabilityInTree(registry, elem.host, true);
242 }
243 return this.findTestabilityInTree(registry, elem.parentElement, true);
244 };
245 return BrowserGetTestability;
246}());
247
248/**
249 * @license
250 * Copyright Google Inc. All Rights Reserved.
251 *
252 * Use of this source code is governed by an MIT-style license that can be
253 * found in the LICENSE file at https://angular.io/license
254 */
255var CAMEL_CASE_REGEXP = /([A-Z])/g;
256var DASH_CASE_REGEXP = /-([a-z])/g;
257function camelCaseToDashCase(input) {
258 return input.replace(CAMEL_CASE_REGEXP, function () {
259 var m = [];
260 for (var _i = 0; _i < arguments.length; _i++) {
261 m[_i] = arguments[_i];
262 }
263 return '-' + m[1].toLowerCase();
264 });
265}
266function dashCaseToCamelCase(input) {
267 return input.replace(DASH_CASE_REGEXP, function () {
268 var m = [];
269 for (var _i = 0; _i < arguments.length; _i++) {
270 m[_i] = arguments[_i];
271 }
272 return m[1].toUpperCase();
273 });
274}
275/**
276 * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
277 * `name` is `'probe'`.
278 * @param name Name under which it will be exported. Keep in mind this will be a property of the
279 * global `ng` object.
280 * @param value The value to export.
281 */
282function exportNgVar(name, value) {
283 if (typeof COMPILED === 'undefined' || !COMPILED) {
284 // Note: we can't export `ng` when using closure enhanced optimization as:
285 // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
286 // - we can't declare a closure extern as the namespace `ng` is already used within Google
287 // for typings for angularJS (via `goog.provide('ng....')`).
288 var ng = ɵglobal['ng'] = ɵglobal['ng'] || {};
289 ng[name] = value;
290 }
291}
292
293/**
294 * @license
295 * Copyright Google Inc. All Rights Reserved.
296 *
297 * Use of this source code is governed by an MIT-style license that can be
298 * found in the LICENSE file at https://angular.io/license
299 */
300var ɵ0$1 = function () { return ({
301 'ApplicationRef': ApplicationRef,
302 'NgZone': NgZone,
303}); };
304var CORE_TOKENS = (ɵ0$1)();
305var INSPECT_GLOBAL_NAME = 'probe';
306var CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
307/**
308 * Returns a {@link DebugElement} for the given native DOM element, or
309 * null if the given native element does not have an Angular view associated
310 * with it.
311 */
312function inspectNativeElementR2(element) {
313 return ɵgetDebugNodeR2(element);
314}
315function _createNgProbeR2(coreTokens) {
316 exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElementR2);
317 exportNgVar(CORE_TOKENS_GLOBAL_NAME, __assign(__assign({}, CORE_TOKENS), _ngProbeTokensToMap(coreTokens || [])));
318 return function () { return inspectNativeElementR2; };
319}
320function _ngProbeTokensToMap(tokens) {
321 return tokens.reduce(function (prev, t) { return (prev[t.name] = t.token, prev); }, {});
322}
323/**
324 * In Ivy, we don't support NgProbe because we have our own set of testing utilities
325 * with more robust functionality.
326 *
327 * We shouldn't bring in NgProbe because it prevents DebugNode and friends from
328 * tree-shaking properly.
329 */
330var ELEMENT_PROBE_PROVIDERS__POST_R3__ = [];
331/**
332 * Providers which support debugging Angular applications (e.g. via `ng.probe`).
333 */
334var ELEMENT_PROBE_PROVIDERS__PRE_R3__ = [
335 {
336 provide: APP_INITIALIZER,
337 useFactory: _createNgProbeR2,
338 deps: [
339 [NgProbeToken, new Optional()],
340 ],
341 multi: true,
342 },
343];
344var ELEMENT_PROBE_PROVIDERS = ELEMENT_PROBE_PROVIDERS__PRE_R3__;
345
346/**
347 * @license
348 * Copyright Google Inc. All Rights Reserved.
349 *
350 * Use of this source code is governed by an MIT-style license that can be
351 * found in the LICENSE file at https://angular.io/license
352 */
353/**
354 * The injection token for the event-manager plug-in service.
355 *
356 * @publicApi
357 */
358var EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
359/**
360 * An injectable service that provides event management for Angular
361 * through a browser plug-in.
362 *
363 * @publicApi
364 */
365var EventManager = /** @class */ (function () {
366 /**
367 * Initializes an instance of the event-manager service.
368 */
369 function EventManager(plugins, _zone) {
370 var _this = this;
371 this._zone = _zone;
372 this._eventNameToPlugin = new Map();
373 plugins.forEach(function (p) { return p.manager = _this; });
374 this._plugins = plugins.slice().reverse();
375 }
376 /**
377 * Registers a handler for a specific element and event.
378 *
379 * @param element The HTML element to receive event notifications.
380 * @param eventName The name of the event to listen for.
381 * @param handler A function to call when the notification occurs. Receives the
382 * event object as an argument.
383 * @returns A callback function that can be used to remove the handler.
384 */
385 EventManager.prototype.addEventListener = function (element, eventName, handler) {
386 var plugin = this._findPluginFor(eventName);
387 return plugin.addEventListener(element, eventName, handler);
388 };
389 /**
390 * Registers a global handler for an event in a target view.
391 *
392 * @param target A target for global event notifications. One of "window", "document", or "body".
393 * @param eventName The name of the event to listen for.
394 * @param handler A function to call when the notification occurs. Receives the
395 * event object as an argument.
396 * @returns A callback function that can be used to remove the handler.
397 */
398 EventManager.prototype.addGlobalEventListener = function (target, eventName, handler) {
399 var plugin = this._findPluginFor(eventName);
400 return plugin.addGlobalEventListener(target, eventName, handler);
401 };
402 /**
403 * Retrieves the compilation zone in which event listeners are registered.
404 */
405 EventManager.prototype.getZone = function () { return this._zone; };
406 /** @internal */
407 EventManager.prototype._findPluginFor = function (eventName) {
408 var plugin = this._eventNameToPlugin.get(eventName);
409 if (plugin) {
410 return plugin;
411 }
412 var plugins = this._plugins;
413 for (var i = 0; i < plugins.length; i++) {
414 var plugin_1 = plugins[i];
415 if (plugin_1.supports(eventName)) {
416 this._eventNameToPlugin.set(eventName, plugin_1);
417 return plugin_1;
418 }
419 }
420 throw new Error("No event manager plugin found for event " + eventName);
421 };
422 EventManager = __decorate([
423 Injectable(),
424 __param(0, Inject(EVENT_MANAGER_PLUGINS)),
425 __metadata("design:paramtypes", [Array, NgZone])
426 ], EventManager);
427 return EventManager;
428}());
429var EventManagerPlugin = /** @class */ (function () {
430 function EventManagerPlugin(_doc) {
431 this._doc = _doc;
432 }
433 EventManagerPlugin.prototype.addGlobalEventListener = function (element, eventName, handler) {
434 var target = ɵgetDOM().getGlobalEventTarget(this._doc, element);
435 if (!target) {
436 throw new Error("Unsupported event target " + target + " for event " + eventName);
437 }
438 return this.addEventListener(target, eventName, handler);
439 };
440 return EventManagerPlugin;
441}());
442
443/**
444 * @license
445 * Copyright Google Inc. All Rights Reserved.
446 *
447 * Use of this source code is governed by an MIT-style license that can be
448 * found in the LICENSE file at https://angular.io/license
449 */
450var SharedStylesHost = /** @class */ (function () {
451 function SharedStylesHost() {
452 /** @internal */
453 this._stylesSet = new Set();
454 }
455 SharedStylesHost.prototype.addStyles = function (styles) {
456 var _this = this;
457 var additions = new Set();
458 styles.forEach(function (style) {
459 if (!_this._stylesSet.has(style)) {
460 _this._stylesSet.add(style);
461 additions.add(style);
462 }
463 });
464 this.onStylesAdded(additions);
465 };
466 SharedStylesHost.prototype.onStylesAdded = function (additions) { };
467 SharedStylesHost.prototype.getAllStyles = function () { return Array.from(this._stylesSet); };
468 SharedStylesHost = __decorate([
469 Injectable()
470 ], SharedStylesHost);
471 return SharedStylesHost;
472}());
473var DomSharedStylesHost = /** @class */ (function (_super) {
474 __extends(DomSharedStylesHost, _super);
475 function DomSharedStylesHost(_doc) {
476 var _this = _super.call(this) || this;
477 _this._doc = _doc;
478 _this._hostNodes = new Set();
479 _this._styleNodes = new Set();
480 _this._hostNodes.add(_doc.head);
481 return _this;
482 }
483 DomSharedStylesHost.prototype._addStylesToHost = function (styles, host) {
484 var _this = this;
485 styles.forEach(function (style) {
486 var styleEl = _this._doc.createElement('style');
487 styleEl.textContent = style;
488 _this._styleNodes.add(host.appendChild(styleEl));
489 });
490 };
491 DomSharedStylesHost.prototype.addHost = function (hostNode) {
492 this._addStylesToHost(this._stylesSet, hostNode);
493 this._hostNodes.add(hostNode);
494 };
495 DomSharedStylesHost.prototype.removeHost = function (hostNode) { this._hostNodes.delete(hostNode); };
496 DomSharedStylesHost.prototype.onStylesAdded = function (additions) {
497 var _this = this;
498 this._hostNodes.forEach(function (hostNode) { return _this._addStylesToHost(additions, hostNode); });
499 };
500 DomSharedStylesHost.prototype.ngOnDestroy = function () { this._styleNodes.forEach(function (styleNode) { return ɵgetDOM().remove(styleNode); }); };
501 DomSharedStylesHost = __decorate([
502 Injectable(),
503 __param(0, Inject(DOCUMENT)),
504 __metadata("design:paramtypes", [Object])
505 ], DomSharedStylesHost);
506 return DomSharedStylesHost;
507}(SharedStylesHost));
508
509/**
510 * @license
511 * Copyright Google Inc. All Rights Reserved.
512 *
513 * Use of this source code is governed by an MIT-style license that can be
514 * found in the LICENSE file at https://angular.io/license
515 */
516var NAMESPACE_URIS = {
517 'svg': 'http://www.w3.org/2000/svg',
518 'xhtml': 'http://www.w3.org/1999/xhtml',
519 'xlink': 'http://www.w3.org/1999/xlink',
520 'xml': 'http://www.w3.org/XML/1998/namespace',
521 'xmlns': 'http://www.w3.org/2000/xmlns/',
522};
523var COMPONENT_REGEX = /%COMP%/g;
524var NG_DEV_MODE = typeof ngDevMode === 'undefined' || !!ngDevMode;
525var COMPONENT_VARIABLE = '%COMP%';
526var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
527var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
528function shimContentAttribute(componentShortId) {
529 return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
530}
531function shimHostAttribute(componentShortId) {
532 return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
533}
534function flattenStyles(compId, styles, target) {
535 for (var i = 0; i < styles.length; i++) {
536 var style = styles[i];
537 if (Array.isArray(style)) {
538 flattenStyles(compId, style, target);
539 }
540 else {
541 style = style.replace(COMPONENT_REGEX, compId);
542 target.push(style);
543 }
544 }
545 return target;
546}
547function decoratePreventDefault(eventHandler) {
548 // `DebugNode.triggerEventHandler` needs to know if the listener was created with
549 // decoratePreventDefault or is a listener added outside the Angular context so it can handle the
550 // two differently. In the first case, the special '__ngUnwrap__' token is passed to the unwrap
551 // the listener (see below).
552 return function (event) {
553 // Ivy uses '__ngUnwrap__' as a special token that allows us to unwrap the function
554 // so that it can be invoked programmatically by `DebugNode.triggerEventHandler`. The debug_node
555 // can inspect the listener toString contents for the existence of this special token. Because
556 // the token is a string literal, it is ensured to not be modified by compiled code.
557 if (event === '__ngUnwrap__') {
558 return eventHandler;
559 }
560 var allowDefaultBehavior = eventHandler(event);
561 if (allowDefaultBehavior === false) {
562 // TODO(tbosch): move preventDefault into event plugins...
563 event.preventDefault();
564 event.returnValue = false;
565 }
566 return undefined;
567 };
568}
569var DomRendererFactory2 = /** @class */ (function () {
570 function DomRendererFactory2(eventManager, sharedStylesHost, appId) {
571 this.eventManager = eventManager;
572 this.sharedStylesHost = sharedStylesHost;
573 this.appId = appId;
574 this.rendererByCompId = new Map();
575 this.defaultRenderer = new DefaultDomRenderer2(eventManager);
576 }
577 DomRendererFactory2.prototype.createRenderer = function (element, type) {
578 if (!element || !type) {
579 return this.defaultRenderer;
580 }
581 switch (type.encapsulation) {
582 case ViewEncapsulation.Emulated: {
583 var renderer = this.rendererByCompId.get(type.id);
584 if (!renderer) {
585 renderer = new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type, this.appId);
586 this.rendererByCompId.set(type.id, renderer);
587 }
588 renderer.applyToHost(element);
589 return renderer;
590 }
591 case ViewEncapsulation.Native:
592 case ViewEncapsulation.ShadowDom:
593 return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
594 default: {
595 if (!this.rendererByCompId.has(type.id)) {
596 var styles = flattenStyles(type.id, type.styles, []);
597 this.sharedStylesHost.addStyles(styles);
598 this.rendererByCompId.set(type.id, this.defaultRenderer);
599 }
600 return this.defaultRenderer;
601 }
602 }
603 };
604 DomRendererFactory2.prototype.begin = function () { };
605 DomRendererFactory2.prototype.end = function () { };
606 DomRendererFactory2 = __decorate([
607 Injectable(),
608 __param(2, Inject(APP_ID)),
609 __metadata("design:paramtypes", [EventManager, DomSharedStylesHost, String])
610 ], DomRendererFactory2);
611 return DomRendererFactory2;
612}());
613var DefaultDomRenderer2 = /** @class */ (function () {
614 function DefaultDomRenderer2(eventManager) {
615 this.eventManager = eventManager;
616 this.data = Object.create(null);
617 }
618 DefaultDomRenderer2.prototype.destroy = function () { };
619 DefaultDomRenderer2.prototype.createElement = function (name, namespace) {
620 if (namespace) {
621 // In cases where Ivy (not ViewEngine) is giving us the actual namespace, the look up by key
622 // will result in undefined, so we just return the namespace here.
623 return document.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
624 }
625 return document.createElement(name);
626 };
627 DefaultDomRenderer2.prototype.createComment = function (value) { return document.createComment(value); };
628 DefaultDomRenderer2.prototype.createText = function (value) { return document.createTextNode(value); };
629 DefaultDomRenderer2.prototype.appendChild = function (parent, newChild) { parent.appendChild(newChild); };
630 DefaultDomRenderer2.prototype.insertBefore = function (parent, newChild, refChild) {
631 if (parent) {
632 parent.insertBefore(newChild, refChild);
633 }
634 };
635 DefaultDomRenderer2.prototype.removeChild = function (parent, oldChild) {
636 if (parent) {
637 parent.removeChild(oldChild);
638 }
639 };
640 DefaultDomRenderer2.prototype.selectRootElement = function (selectorOrNode, preserveContent) {
641 var el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
642 selectorOrNode;
643 if (!el) {
644 throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements");
645 }
646 if (!preserveContent) {
647 el.textContent = '';
648 }
649 return el;
650 };
651 DefaultDomRenderer2.prototype.parentNode = function (node) { return node.parentNode; };
652 DefaultDomRenderer2.prototype.nextSibling = function (node) { return node.nextSibling; };
653 DefaultDomRenderer2.prototype.setAttribute = function (el, name, value, namespace) {
654 if (namespace) {
655 name = namespace + ':' + name;
656 // TODO(FW-811): Ivy may cause issues here because it's passing around
657 // full URIs for namespaces, therefore this lookup will fail.
658 var namespaceUri = NAMESPACE_URIS[namespace];
659 if (namespaceUri) {
660 el.setAttributeNS(namespaceUri, name, value);
661 }
662 else {
663 el.setAttribute(name, value);
664 }
665 }
666 else {
667 el.setAttribute(name, value);
668 }
669 };
670 DefaultDomRenderer2.prototype.removeAttribute = function (el, name, namespace) {
671 if (namespace) {
672 // TODO(FW-811): Ivy may cause issues here because it's passing around
673 // full URIs for namespaces, therefore this lookup will fail.
674 var namespaceUri = NAMESPACE_URIS[namespace];
675 if (namespaceUri) {
676 el.removeAttributeNS(namespaceUri, name);
677 }
678 else {
679 // TODO(FW-811): Since ivy is passing around full URIs for namespaces
680 // this could result in properties like `http://www.w3.org/2000/svg:cx="123"`,
681 // which is wrong.
682 el.removeAttribute(namespace + ":" + name);
683 }
684 }
685 else {
686 el.removeAttribute(name);
687 }
688 };
689 DefaultDomRenderer2.prototype.addClass = function (el, name) { el.classList.add(name); };
690 DefaultDomRenderer2.prototype.removeClass = function (el, name) { el.classList.remove(name); };
691 DefaultDomRenderer2.prototype.setStyle = function (el, style, value, flags) {
692 if (flags & RendererStyleFlags2.DashCase) {
693 el.style.setProperty(style, value, !!(flags & RendererStyleFlags2.Important) ? 'important' : '');
694 }
695 else {
696 el.style[style] = value;
697 }
698 };
699 DefaultDomRenderer2.prototype.removeStyle = function (el, style, flags) {
700 if (flags & RendererStyleFlags2.DashCase) {
701 el.style.removeProperty(style);
702 }
703 else {
704 // IE requires '' instead of null
705 // see https://github.com/angular/angular/issues/7916
706 el.style[style] = '';
707 }
708 };
709 DefaultDomRenderer2.prototype.setProperty = function (el, name, value) {
710 NG_DEV_MODE && checkNoSyntheticProp(name, 'property');
711 el[name] = value;
712 };
713 DefaultDomRenderer2.prototype.setValue = function (node, value) { node.nodeValue = value; };
714 DefaultDomRenderer2.prototype.listen = function (target, event, callback) {
715 NG_DEV_MODE && checkNoSyntheticProp(event, 'listener');
716 if (typeof target === 'string') {
717 return this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback));
718 }
719 return this.eventManager.addEventListener(target, event, decoratePreventDefault(callback));
720 };
721 return DefaultDomRenderer2;
722}());
723var ɵ0$2 = function () { return '@'.charCodeAt(0); };
724var AT_CHARCODE = (ɵ0$2)();
725function checkNoSyntheticProp(name, nameKind) {
726 if (name.charCodeAt(0) === AT_CHARCODE) {
727 throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application.");
728 }
729}
730var EmulatedEncapsulationDomRenderer2 = /** @class */ (function (_super) {
731 __extends(EmulatedEncapsulationDomRenderer2, _super);
732 function EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, component, appId) {
733 var _this = _super.call(this, eventManager) || this;
734 _this.component = component;
735 var styles = flattenStyles(appId + '-' + component.id, component.styles, []);
736 sharedStylesHost.addStyles(styles);
737 _this.contentAttr = shimContentAttribute(appId + '-' + component.id);
738 _this.hostAttr = shimHostAttribute(appId + '-' + component.id);
739 return _this;
740 }
741 EmulatedEncapsulationDomRenderer2.prototype.applyToHost = function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); };
742 EmulatedEncapsulationDomRenderer2.prototype.createElement = function (parent, name) {
743 var el = _super.prototype.createElement.call(this, parent, name);
744 _super.prototype.setAttribute.call(this, el, this.contentAttr, '');
745 return el;
746 };
747 return EmulatedEncapsulationDomRenderer2;
748}(DefaultDomRenderer2));
749var ShadowDomRenderer = /** @class */ (function (_super) {
750 __extends(ShadowDomRenderer, _super);
751 function ShadowDomRenderer(eventManager, sharedStylesHost, hostEl, component) {
752 var _this = _super.call(this, eventManager) || this;
753 _this.sharedStylesHost = sharedStylesHost;
754 _this.hostEl = hostEl;
755 _this.component = component;
756 if (component.encapsulation === ViewEncapsulation.ShadowDom) {
757 _this.shadowRoot = hostEl.attachShadow({ mode: 'open' });
758 }
759 else {
760 _this.shadowRoot = hostEl.createShadowRoot();
761 }
762 _this.sharedStylesHost.addHost(_this.shadowRoot);
763 var styles = flattenStyles(component.id, component.styles, []);
764 for (var i = 0; i < styles.length; i++) {
765 var styleEl = document.createElement('style');
766 styleEl.textContent = styles[i];
767 _this.shadowRoot.appendChild(styleEl);
768 }
769 return _this;
770 }
771 ShadowDomRenderer.prototype.nodeOrShadowRoot = function (node) { return node === this.hostEl ? this.shadowRoot : node; };
772 ShadowDomRenderer.prototype.destroy = function () { this.sharedStylesHost.removeHost(this.shadowRoot); };
773 ShadowDomRenderer.prototype.appendChild = function (parent, newChild) {
774 return _super.prototype.appendChild.call(this, this.nodeOrShadowRoot(parent), newChild);
775 };
776 ShadowDomRenderer.prototype.insertBefore = function (parent, newChild, refChild) {
777 return _super.prototype.insertBefore.call(this, this.nodeOrShadowRoot(parent), newChild, refChild);
778 };
779 ShadowDomRenderer.prototype.removeChild = function (parent, oldChild) {
780 return _super.prototype.removeChild.call(this, this.nodeOrShadowRoot(parent), oldChild);
781 };
782 ShadowDomRenderer.prototype.parentNode = function (node) {
783 return this.nodeOrShadowRoot(_super.prototype.parentNode.call(this, this.nodeOrShadowRoot(node)));
784 };
785 return ShadowDomRenderer;
786}(DefaultDomRenderer2));
787
788/**
789 * @license
790 * Copyright Google Inc. All Rights Reserved.
791 *
792 * Use of this source code is governed by an MIT-style license that can be
793 * found in the LICENSE file at https://angular.io/license
794 */
795var DomEventsPlugin = /** @class */ (function (_super) {
796 __extends(DomEventsPlugin, _super);
797 function DomEventsPlugin(doc) {
798 return _super.call(this, doc) || this;
799 }
800 // This plugin should come last in the list of plugins, because it accepts all
801 // events.
802 DomEventsPlugin.prototype.supports = function (eventName) { return true; };
803 DomEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
804 var _this = this;
805 element.addEventListener(eventName, handler, false);
806 return function () { return _this.removeEventListener(element, eventName, handler); };
807 };
808 DomEventsPlugin.prototype.removeEventListener = function (target, eventName, callback) {
809 return target.removeEventListener(eventName, callback);
810 };
811 DomEventsPlugin = __decorate([
812 Injectable(),
813 __param(0, Inject(DOCUMENT)),
814 __metadata("design:paramtypes", [Object])
815 ], DomEventsPlugin);
816 return DomEventsPlugin;
817}(EventManagerPlugin));
818
819/**
820 * @license
821 * Copyright Google Inc. All Rights Reserved.
822 *
823 * Use of this source code is governed by an MIT-style license that can be
824 * found in the LICENSE file at https://angular.io/license
825 */
826/**
827 * Supported HammerJS recognizer event names.
828 */
829var EVENT_NAMES = {
830 // pan
831 'pan': true,
832 'panstart': true,
833 'panmove': true,
834 'panend': true,
835 'pancancel': true,
836 'panleft': true,
837 'panright': true,
838 'panup': true,
839 'pandown': true,
840 // pinch
841 'pinch': true,
842 'pinchstart': true,
843 'pinchmove': true,
844 'pinchend': true,
845 'pinchcancel': true,
846 'pinchin': true,
847 'pinchout': true,
848 // press
849 'press': true,
850 'pressup': true,
851 // rotate
852 'rotate': true,
853 'rotatestart': true,
854 'rotatemove': true,
855 'rotateend': true,
856 'rotatecancel': true,
857 // swipe
858 'swipe': true,
859 'swipeleft': true,
860 'swiperight': true,
861 'swipeup': true,
862 'swipedown': true,
863 // tap
864 'tap': true,
865};
866/**
867 * DI token for providing [HammerJS](http://hammerjs.github.io/) support to Angular.
868 * @see `HammerGestureConfig`
869 *
870 * @ngModule HammerModule
871 * @publicApi
872 */
873var HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
874/**
875 * Injection token used to provide a {@link HammerLoader} to Angular.
876 *
877 * @publicApi
878 */
879var HAMMER_LOADER = new InjectionToken('HammerLoader');
880/**
881 * An injectable [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
882 * for gesture recognition. Configures specific event recognition.
883 * @publicApi
884 */
885var HammerGestureConfig = /** @class */ (function () {
886 function HammerGestureConfig() {
887 /**
888 * A set of supported event names for gestures to be used in Angular.
889 * Angular supports all built-in recognizers, as listed in
890 * [HammerJS documentation](http://hammerjs.github.io/).
891 */
892 this.events = [];
893 /**
894 * Maps gesture event names to a set of configuration options
895 * that specify overrides to the default values for specific properties.
896 *
897 * The key is a supported event name to be configured,
898 * and the options object contains a set of properties, with override values
899 * to be applied to the named recognizer event.
900 * For example, to disable recognition of the rotate event, specify
901 * `{"rotate": {"enable": false}}`.
902 *
903 * Properties that are not present take the HammerJS default values.
904 * For information about which properties are supported for which events,
905 * and their allowed and default values, see
906 * [HammerJS documentation](http://hammerjs.github.io/).
907 *
908 */
909 this.overrides = {};
910 }
911 /**
912 * Creates a [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
913 * and attaches it to a given HTML element.
914 * @param element The element that will recognize gestures.
915 * @returns A HammerJS event-manager object.
916 */
917 HammerGestureConfig.prototype.buildHammer = function (element) {
918 var mc = new Hammer(element, this.options);
919 mc.get('pinch').set({ enable: true });
920 mc.get('rotate').set({ enable: true });
921 for (var eventName in this.overrides) {
922 mc.get(eventName).set(this.overrides[eventName]);
923 }
924 return mc;
925 };
926 HammerGestureConfig = __decorate([
927 Injectable()
928 ], HammerGestureConfig);
929 return HammerGestureConfig;
930}());
931/**
932 * Event plugin that adds Hammer support to an application.
933 *
934 * @ngModule HammerModule
935 */
936var HammerGesturesPlugin = /** @class */ (function (_super) {
937 __extends(HammerGesturesPlugin, _super);
938 function HammerGesturesPlugin(doc, _config, console, loader) {
939 var _this = _super.call(this, doc) || this;
940 _this._config = _config;
941 _this.console = console;
942 _this.loader = loader;
943 return _this;
944 }
945 HammerGesturesPlugin.prototype.supports = function (eventName) {
946 if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
947 return false;
948 }
949 if (!window.Hammer && !this.loader) {
950 this.console.warn("The \"" + eventName + "\" event cannot be bound because Hammer.JS is not " +
951 "loaded and no custom loader has been specified.");
952 return false;
953 }
954 return true;
955 };
956 HammerGesturesPlugin.prototype.addEventListener = function (element, eventName, handler) {
957 var _this = this;
958 var zone = this.manager.getZone();
959 eventName = eventName.toLowerCase();
960 // If Hammer is not present but a loader is specified, we defer adding the event listener
961 // until Hammer is loaded.
962 if (!window.Hammer && this.loader) {
963 // This `addEventListener` method returns a function to remove the added listener.
964 // Until Hammer is loaded, the returned function needs to *cancel* the registration rather
965 // than remove anything.
966 var cancelRegistration_1 = false;
967 var deregister_1 = function () { cancelRegistration_1 = true; };
968 this.loader()
969 .then(function () {
970 // If Hammer isn't actually loaded when the custom loader resolves, give up.
971 if (!window.Hammer) {
972 _this.console.warn("The custom HAMMER_LOADER completed, but Hammer.JS is not present.");
973 deregister_1 = function () { };
974 return;
975 }
976 if (!cancelRegistration_1) {
977 // Now that Hammer is loaded and the listener is being loaded for real,
978 // the deregistration function changes from canceling registration to removal.
979 deregister_1 = _this.addEventListener(element, eventName, handler);
980 }
981 })
982 .catch(function () {
983 _this.console.warn("The \"" + eventName + "\" event cannot be bound because the custom " +
984 "Hammer.JS loader failed.");
985 deregister_1 = function () { };
986 });
987 // Return a function that *executes* `deregister` (and not `deregister` itself) so that we
988 // can change the behavior of `deregister` once the listener is added. Using a closure in
989 // this way allows us to avoid any additional data structures to track listener removal.
990 return function () { deregister_1(); };
991 }
992 return zone.runOutsideAngular(function () {
993 // Creating the manager bind events, must be done outside of angular
994 var mc = _this._config.buildHammer(element);
995 var callback = function (eventObj) {
996 zone.runGuarded(function () { handler(eventObj); });
997 };
998 mc.on(eventName, callback);
999 return function () {
1000 mc.off(eventName, callback);
1001 // destroy mc to prevent memory leak
1002 if (typeof mc.destroy === 'function') {
1003 mc.destroy();
1004 }
1005 };
1006 });
1007 };
1008 HammerGesturesPlugin.prototype.isCustomEvent = function (eventName) { return this._config.events.indexOf(eventName) > -1; };
1009 HammerGesturesPlugin = __decorate([
1010 Injectable(),
1011 __param(0, Inject(DOCUMENT)),
1012 __param(1, Inject(HAMMER_GESTURE_CONFIG)),
1013 __param(3, Optional()), __param(3, Inject(HAMMER_LOADER)),
1014 __metadata("design:paramtypes", [Object, HammerGestureConfig, ɵConsole, Object])
1015 ], HammerGesturesPlugin);
1016 return HammerGesturesPlugin;
1017}(EventManagerPlugin));
1018/**
1019 * In Ivy, support for Hammer gestures is optional, so applications must
1020 * import the `HammerModule` at root to turn on support. This means that
1021 * Hammer-specific code can be tree-shaken away if not needed.
1022 */
1023var HAMMER_PROVIDERS__POST_R3__ = [];
1024/**
1025 * In View Engine, support for Hammer gestures is built-in by default.
1026 */
1027var HAMMER_PROVIDERS__PRE_R3__ = [
1028 {
1029 provide: EVENT_MANAGER_PLUGINS,
1030 useClass: HammerGesturesPlugin,
1031 multi: true,
1032 deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, ɵConsole, [new Optional(), HAMMER_LOADER]]
1033 },
1034 { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: [] },
1035];
1036var HAMMER_PROVIDERS = HAMMER_PROVIDERS__PRE_R3__;
1037/**
1038 * Adds support for HammerJS.
1039 *
1040 * Import this module at the root of your application so that Angular can work with
1041 * HammerJS to detect gesture events.
1042 *
1043 * Note that applications still need to include the HammerJS script itself. This module
1044 * simply sets up the coordination layer between HammerJS and Angular's EventManager.
1045 *
1046 * @publicApi
1047 */
1048var HammerModule = /** @class */ (function () {
1049 function HammerModule() {
1050 }
1051 HammerModule = __decorate([
1052 NgModule({ providers: HAMMER_PROVIDERS__PRE_R3__ })
1053 ], HammerModule);
1054 return HammerModule;
1055}());
1056
1057/**
1058 * @license
1059 * Copyright Google Inc. All Rights Reserved.
1060 *
1061 * Use of this source code is governed by an MIT-style license that can be
1062 * found in the LICENSE file at https://angular.io/license
1063 */
1064/**
1065 * Defines supported modifiers for key events.
1066 */
1067var MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
1068var DOM_KEY_LOCATION_NUMPAD = 3;
1069// Map to convert some key or keyIdentifier values to what will be returned by getEventKey
1070var _keyMap = {
1071 // The following values are here for cross-browser compatibility and to match the W3C standard
1072 // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
1073 '\b': 'Backspace',
1074 '\t': 'Tab',
1075 '\x7F': 'Delete',
1076 '\x1B': 'Escape',
1077 'Del': 'Delete',
1078 'Esc': 'Escape',
1079 'Left': 'ArrowLeft',
1080 'Right': 'ArrowRight',
1081 'Up': 'ArrowUp',
1082 'Down': 'ArrowDown',
1083 'Menu': 'ContextMenu',
1084 'Scroll': 'ScrollLock',
1085 'Win': 'OS'
1086};
1087// There is a bug in Chrome for numeric keypad keys:
1088// https://code.google.com/p/chromium/issues/detail?id=155654
1089// 1, 2, 3 ... are reported as A, B, C ...
1090var _chromeNumKeyPadMap = {
1091 'A': '1',
1092 'B': '2',
1093 'C': '3',
1094 'D': '4',
1095 'E': '5',
1096 'F': '6',
1097 'G': '7',
1098 'H': '8',
1099 'I': '9',
1100 'J': '*',
1101 'K': '+',
1102 'M': '-',
1103 'N': '.',
1104 'O': '/',
1105 '\x60': '0',
1106 '\x90': 'NumLock'
1107};
1108var ɵ0$3 = function (event) { return event.altKey; }, ɵ1 = function (event) { return event.ctrlKey; }, ɵ2 = function (event) { return event.metaKey; }, ɵ3 = function (event) { return event.shiftKey; };
1109/**
1110 * Retrieves modifiers from key-event objects.
1111 */
1112var MODIFIER_KEY_GETTERS = {
1113 'alt': ɵ0$3,
1114 'control': ɵ1,
1115 'meta': ɵ2,
1116 'shift': ɵ3
1117};
1118/**
1119 * @publicApi
1120 * A browser plug-in that provides support for handling of key events in Angular.
1121 */
1122var KeyEventsPlugin = /** @class */ (function (_super) {
1123 __extends(KeyEventsPlugin, _super);
1124 /**
1125 * Initializes an instance of the browser plug-in.
1126 * @param doc The document in which key events will be detected.
1127 */
1128 function KeyEventsPlugin(doc) {
1129 return _super.call(this, doc) || this;
1130 }
1131 KeyEventsPlugin_1 = KeyEventsPlugin;
1132 /**
1133 * Reports whether a named key event is supported.
1134 * @param eventName The event name to query.
1135 * @return True if the named key event is supported.
1136 */
1137 KeyEventsPlugin.prototype.supports = function (eventName) { return KeyEventsPlugin_1.parseEventName(eventName) != null; };
1138 /**
1139 * Registers a handler for a specific element and key event.
1140 * @param element The HTML element to receive event notifications.
1141 * @param eventName The name of the key event to listen for.
1142 * @param handler A function to call when the notification occurs. Receives the
1143 * event object as an argument.
1144 * @returns The key event that was registered.
1145 */
1146 KeyEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
1147 var parsedEvent = KeyEventsPlugin_1.parseEventName(eventName);
1148 var outsideHandler = KeyEventsPlugin_1.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
1149 return this.manager.getZone().runOutsideAngular(function () {
1150 return ɵgetDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
1151 });
1152 };
1153 KeyEventsPlugin.parseEventName = function (eventName) {
1154 var parts = eventName.toLowerCase().split('.');
1155 var domEventName = parts.shift();
1156 if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
1157 return null;
1158 }
1159 var key = KeyEventsPlugin_1._normalizeKey(parts.pop());
1160 var fullKey = '';
1161 MODIFIER_KEYS.forEach(function (modifierName) {
1162 var index = parts.indexOf(modifierName);
1163 if (index > -1) {
1164 parts.splice(index, 1);
1165 fullKey += modifierName + '.';
1166 }
1167 });
1168 fullKey += key;
1169 if (parts.length != 0 || key.length === 0) {
1170 // returning null instead of throwing to let another plugin process the event
1171 return null;
1172 }
1173 var result = {};
1174 result['domEventName'] = domEventName;
1175 result['fullKey'] = fullKey;
1176 return result;
1177 };
1178 KeyEventsPlugin.getEventFullKey = function (event) {
1179 var fullKey = '';
1180 var key = getEventKey(event);
1181 key = key.toLowerCase();
1182 if (key === ' ') {
1183 key = 'space'; // for readability
1184 }
1185 else if (key === '.') {
1186 key = 'dot'; // because '.' is used as a separator in event names
1187 }
1188 MODIFIER_KEYS.forEach(function (modifierName) {
1189 if (modifierName != key) {
1190 var modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
1191 if (modifierGetter(event)) {
1192 fullKey += modifierName + '.';
1193 }
1194 }
1195 });
1196 fullKey += key;
1197 return fullKey;
1198 };
1199 /**
1200 * Configures a handler callback for a key event.
1201 * @param fullKey The event name that combines all simultaneous keystrokes.
1202 * @param handler The function that responds to the key event.
1203 * @param zone The zone in which the event occurred.
1204 * @returns A callback function.
1205 */
1206 KeyEventsPlugin.eventCallback = function (fullKey, handler, zone) {
1207 return function (event /** TODO #9100 */) {
1208 if (KeyEventsPlugin_1.getEventFullKey(event) === fullKey) {
1209 zone.runGuarded(function () { return handler(event); });
1210 }
1211 };
1212 };
1213 /** @internal */
1214 KeyEventsPlugin._normalizeKey = function (keyName) {
1215 // TODO: switch to a Map if the mapping grows too much
1216 switch (keyName) {
1217 case 'esc':
1218 return 'escape';
1219 default:
1220 return keyName;
1221 }
1222 };
1223 var KeyEventsPlugin_1;
1224 KeyEventsPlugin = KeyEventsPlugin_1 = __decorate([
1225 Injectable(),
1226 __param(0, Inject(DOCUMENT)),
1227 __metadata("design:paramtypes", [Object])
1228 ], KeyEventsPlugin);
1229 return KeyEventsPlugin;
1230}(EventManagerPlugin));
1231function getEventKey(event) {
1232 var key = event.key;
1233 if (key == null) {
1234 key = event.keyIdentifier;
1235 // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
1236 // Safari cf
1237 // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
1238 if (key == null) {
1239 return 'Unidentified';
1240 }
1241 if (key.startsWith('U+')) {
1242 key = String.fromCharCode(parseInt(key.substring(2), 16));
1243 if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
1244 // There is a bug in Chrome for numeric keypad keys:
1245 // https://code.google.com/p/chromium/issues/detail?id=155654
1246 // 1, 2, 3 ... are reported as A, B, C ...
1247 key = _chromeNumKeyPadMap[key];
1248 }
1249 }
1250 }
1251 return _keyMap[key] || key;
1252}
1253
1254/**
1255 * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
1256 * values to be safe to use in the different DOM contexts.
1257 *
1258 * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
1259 * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
1260 * the website.
1261 *
1262 * In specific situations, it might be necessary to disable sanitization, for example if the
1263 * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
1264 * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
1265 * methods, and then binding to that value from the template.
1266 *
1267 * These situations should be very rare, and extraordinary care must be taken to avoid creating a
1268 * Cross Site Scripting (XSS) security bug!
1269 *
1270 * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
1271 * close as possible to the source of the value, to make it easy to verify no security bug is
1272 * created by its use.
1273 *
1274 * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
1275 * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
1276 * code. The sanitizer leaves safe values intact.
1277 *
1278 * @security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
1279 * sanitization for the value passed in. Carefully check and audit all values and code paths going
1280 * into this call. Make sure any user data is appropriately escaped for this security context.
1281 * For more detail, see the [Security Guide](http://g.co/ng/security).
1282 *
1283 * @publicApi
1284 */
1285var DomSanitizer = /** @class */ (function () {
1286 function DomSanitizer() {
1287 }
1288 DomSanitizer.ɵprov = ɵɵdefineInjectable({ factory: function DomSanitizer_Factory() { return ɵɵinject(DomSanitizerImpl); }, token: DomSanitizer, providedIn: "root" });
1289 DomSanitizer = __decorate([
1290 Injectable({ providedIn: 'root', useExisting: forwardRef(function () { return DomSanitizerImpl; }) })
1291 ], DomSanitizer);
1292 return DomSanitizer;
1293}());
1294function domSanitizerImplFactory(injector) {
1295 return new DomSanitizerImpl(injector.get(DOCUMENT));
1296}
1297var DomSanitizerImpl = /** @class */ (function (_super) {
1298 __extends(DomSanitizerImpl, _super);
1299 function DomSanitizerImpl(_doc) {
1300 var _this = _super.call(this) || this;
1301 _this._doc = _doc;
1302 return _this;
1303 }
1304 DomSanitizerImpl.prototype.sanitize = function (ctx, value) {
1305 if (value == null)
1306 return null;
1307 switch (ctx) {
1308 case SecurityContext.NONE:
1309 return value;
1310 case SecurityContext.HTML:
1311 if (ɵallowSanitizationBypassAndThrow(value, "HTML" /* Html */)) {
1312 return ɵunwrapSafeValue(value);
1313 }
1314 return ɵ_sanitizeHtml(this._doc, String(value));
1315 case SecurityContext.STYLE:
1316 if (ɵallowSanitizationBypassAndThrow(value, "Style" /* Style */)) {
1317 return ɵunwrapSafeValue(value);
1318 }
1319 return ɵ_sanitizeStyle(value);
1320 case SecurityContext.SCRIPT:
1321 if (ɵallowSanitizationBypassAndThrow(value, "Script" /* Script */)) {
1322 return ɵunwrapSafeValue(value);
1323 }
1324 throw new Error('unsafe value used in a script context');
1325 case SecurityContext.URL:
1326 var type = ɵgetSanitizationBypassType(value);
1327 if (ɵallowSanitizationBypassAndThrow(value, "URL" /* Url */)) {
1328 return ɵunwrapSafeValue(value);
1329 }
1330 return ɵ_sanitizeUrl(String(value));
1331 case SecurityContext.RESOURCE_URL:
1332 if (ɵallowSanitizationBypassAndThrow(value, "ResourceURL" /* ResourceUrl */)) {
1333 return ɵunwrapSafeValue(value);
1334 }
1335 throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
1336 default:
1337 throw new Error("Unexpected SecurityContext " + ctx + " (see http://g.co/ng/security#xss)");
1338 }
1339 };
1340 DomSanitizerImpl.prototype.bypassSecurityTrustHtml = function (value) { return ɵbypassSanitizationTrustHtml(value); };
1341 DomSanitizerImpl.prototype.bypassSecurityTrustStyle = function (value) { return ɵbypassSanitizationTrustStyle(value); };
1342 DomSanitizerImpl.prototype.bypassSecurityTrustScript = function (value) {
1343 return ɵbypassSanitizationTrustScript(value);
1344 };
1345 DomSanitizerImpl.prototype.bypassSecurityTrustUrl = function (value) { return ɵbypassSanitizationTrustUrl(value); };
1346 DomSanitizerImpl.prototype.bypassSecurityTrustResourceUrl = function (value) {
1347 return ɵbypassSanitizationTrustResourceUrl(value);
1348 };
1349 DomSanitizerImpl.ɵprov = ɵɵdefineInjectable({ factory: function DomSanitizerImpl_Factory() { return domSanitizerImplFactory(ɵɵinject(INJECTOR)); }, token: DomSanitizerImpl, providedIn: "root" });
1350 DomSanitizerImpl = __decorate([
1351 Injectable({ providedIn: 'root', useFactory: domSanitizerImplFactory, deps: [Injector] }),
1352 __param(0, Inject(DOCUMENT)),
1353 __metadata("design:paramtypes", [Object])
1354 ], DomSanitizerImpl);
1355 return DomSanitizerImpl;
1356}(DomSanitizer));
1357
1358/**
1359 * @license
1360 * Copyright Google Inc. All Rights Reserved.
1361 *
1362 * Use of this source code is governed by an MIT-style license that can be
1363 * found in the LICENSE file at https://angular.io/license
1364 */
1365function initDomAdapter() {
1366 BrowserDomAdapter.makeCurrent();
1367 BrowserGetTestability.init();
1368}
1369function errorHandler() {
1370 return new ErrorHandler();
1371}
1372function _document() {
1373 // Tell ivy about the global document
1374 ɵsetDocument(document);
1375 return document;
1376}
1377var ɵ0$4 = ɵPLATFORM_BROWSER_ID;
1378var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
1379 { provide: PLATFORM_ID, useValue: ɵ0$4 },
1380 { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
1381 { provide: DOCUMENT, useFactory: _document, deps: [] },
1382];
1383var BROWSER_SANITIZATION_PROVIDERS__PRE_R3__ = [
1384 { provide: Sanitizer, useExisting: DomSanitizer },
1385 { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT] },
1386];
1387var BROWSER_SANITIZATION_PROVIDERS__POST_R3__ = [];
1388/**
1389 * @security Replacing built-in sanitization providers exposes the application to XSS risks.
1390 * Attacker-controlled data introduced by an unsanitized provider could expose your
1391 * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
1392 * @publicApi
1393 */
1394var BROWSER_SANITIZATION_PROVIDERS = BROWSER_SANITIZATION_PROVIDERS__PRE_R3__;
1395/**
1396 * @publicApi
1397 */
1398var platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
1399var BROWSER_MODULE_PROVIDERS = [
1400 BROWSER_SANITIZATION_PROVIDERS,
1401 { provide: ɵINJECTOR_SCOPE, useValue: 'root' },
1402 { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
1403 {
1404 provide: EVENT_MANAGER_PLUGINS,
1405 useClass: DomEventsPlugin,
1406 multi: true,
1407 deps: [DOCUMENT, NgZone, PLATFORM_ID]
1408 },
1409 { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true, deps: [DOCUMENT] },
1410 HAMMER_PROVIDERS,
1411 {
1412 provide: DomRendererFactory2,
1413 useClass: DomRendererFactory2,
1414 deps: [EventManager, DomSharedStylesHost, APP_ID]
1415 },
1416 { provide: RendererFactory2, useExisting: DomRendererFactory2 },
1417 { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
1418 { provide: DomSharedStylesHost, useClass: DomSharedStylesHost, deps: [DOCUMENT] },
1419 { provide: Testability, useClass: Testability, deps: [NgZone] },
1420 { provide: EventManager, useClass: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone] },
1421 ELEMENT_PROBE_PROVIDERS,
1422];
1423/**
1424 * Exports required infrastructure for all Angular apps.
1425 * Included by default in all Angular apps created with the CLI
1426 * `new` command.
1427 * Re-exports `CommonModule` and `ApplicationModule`, making their
1428 * exports and providers available to all apps.
1429 *
1430 * @publicApi
1431 */
1432var BrowserModule = /** @class */ (function () {
1433 function BrowserModule(parentModule) {
1434 if (parentModule) {
1435 throw new Error("BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.");
1436 }
1437 }
1438 BrowserModule_1 = BrowserModule;
1439 /**
1440 * Configures a browser-based app to transition from a server-rendered app, if
1441 * one is present on the page.
1442 *
1443 * @param params An object containing an identifier for the app to transition.
1444 * The ID must match between the client and server versions of the app.
1445 * @returns The reconfigured `BrowserModule` to import into the app's root `AppModule`.
1446 */
1447 BrowserModule.withServerTransition = function (params) {
1448 return {
1449 ngModule: BrowserModule_1,
1450 providers: [
1451 { provide: APP_ID, useValue: params.appId },
1452 { provide: TRANSITION_ID, useExisting: APP_ID },
1453 SERVER_TRANSITION_PROVIDERS,
1454 ],
1455 };
1456 };
1457 var BrowserModule_1;
1458 BrowserModule = BrowserModule_1 = __decorate([
1459 NgModule({ providers: BROWSER_MODULE_PROVIDERS, exports: [CommonModule, ApplicationModule] }),
1460 __param(0, Optional()), __param(0, SkipSelf()), __param(0, Inject(BrowserModule_1)),
1461 __metadata("design:paramtypes", [Object])
1462 ], BrowserModule);
1463 return BrowserModule;
1464}());
1465
1466/**
1467 * Factory to create Meta service.
1468 */
1469function createMeta() {
1470 return new Meta(ɵɵinject(DOCUMENT));
1471}
1472/**
1473 * A service that can be used to get and add meta tags.
1474 *
1475 * @publicApi
1476 */
1477var Meta = /** @class */ (function () {
1478 function Meta(_doc) {
1479 this._doc = _doc;
1480 this._dom = ɵgetDOM();
1481 }
1482 Meta.prototype.addTag = function (tag, forceCreation) {
1483 if (forceCreation === void 0) { forceCreation = false; }
1484 if (!tag)
1485 return null;
1486 return this._getOrCreateElement(tag, forceCreation);
1487 };
1488 Meta.prototype.addTags = function (tags, forceCreation) {
1489 var _this = this;
1490 if (forceCreation === void 0) { forceCreation = false; }
1491 if (!tags)
1492 return [];
1493 return tags.reduce(function (result, tag) {
1494 if (tag) {
1495 result.push(_this._getOrCreateElement(tag, forceCreation));
1496 }
1497 return result;
1498 }, []);
1499 };
1500 Meta.prototype.getTag = function (attrSelector) {
1501 if (!attrSelector)
1502 return null;
1503 return this._doc.querySelector("meta[" + attrSelector + "]") || null;
1504 };
1505 Meta.prototype.getTags = function (attrSelector) {
1506 if (!attrSelector)
1507 return [];
1508 var list /*NodeList*/ = this._doc.querySelectorAll("meta[" + attrSelector + "]");
1509 return list ? [].slice.call(list) : [];
1510 };
1511 Meta.prototype.updateTag = function (tag, selector) {
1512 if (!tag)
1513 return null;
1514 selector = selector || this._parseSelector(tag);
1515 var meta = this.getTag(selector);
1516 if (meta) {
1517 return this._setMetaElementAttributes(tag, meta);
1518 }
1519 return this._getOrCreateElement(tag, true);
1520 };
1521 Meta.prototype.removeTag = function (attrSelector) { this.removeTagElement(this.getTag(attrSelector)); };
1522 Meta.prototype.removeTagElement = function (meta) {
1523 if (meta) {
1524 this._dom.remove(meta);
1525 }
1526 };
1527 Meta.prototype._getOrCreateElement = function (meta, forceCreation) {
1528 if (forceCreation === void 0) { forceCreation = false; }
1529 if (!forceCreation) {
1530 var selector = this._parseSelector(meta);
1531 var elem = this.getTag(selector);
1532 // It's allowed to have multiple elements with the same name so it's not enough to
1533 // just check that element with the same name already present on the page. We also need to
1534 // check if element has tag attributes
1535 if (elem && this._containsAttributes(meta, elem))
1536 return elem;
1537 }
1538 var element = this._dom.createElement('meta');
1539 this._setMetaElementAttributes(meta, element);
1540 var head = this._doc.getElementsByTagName('head')[0];
1541 head.appendChild(element);
1542 return element;
1543 };
1544 Meta.prototype._setMetaElementAttributes = function (tag, el) {
1545 Object.keys(tag).forEach(function (prop) { return el.setAttribute(prop, tag[prop]); });
1546 return el;
1547 };
1548 Meta.prototype._parseSelector = function (tag) {
1549 var attr = tag.name ? 'name' : 'property';
1550 return attr + "=\"" + tag[attr] + "\"";
1551 };
1552 Meta.prototype._containsAttributes = function (tag, elem) {
1553 return Object.keys(tag).every(function (key) { return elem.getAttribute(key) === tag[key]; });
1554 };
1555 Meta.ɵprov = ɵɵdefineInjectable({ factory: createMeta, token: Meta, providedIn: "root" });
1556 Meta = __decorate([
1557 Injectable({ providedIn: 'root', useFactory: createMeta, deps: [] }),
1558 __param(0, Inject(DOCUMENT)),
1559 __metadata("design:paramtypes", [Object])
1560 ], Meta);
1561 return Meta;
1562}());
1563
1564/**
1565 * Factory to create Title service.
1566 */
1567function createTitle() {
1568 return new Title(ɵɵinject(DOCUMENT));
1569}
1570/**
1571 * A service that can be used to get and set the title of a current HTML document.
1572 *
1573 * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
1574 * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
1575 * (representing the `<title>` tag). Instead, this service can be used to set and get the current
1576 * title value.
1577 *
1578 * @publicApi
1579 */
1580var Title = /** @class */ (function () {
1581 function Title(_doc) {
1582 this._doc = _doc;
1583 }
1584 /**
1585 * Get the title of the current HTML document.
1586 */
1587 Title.prototype.getTitle = function () { return this._doc.title; };
1588 /**
1589 * Set the title of the current HTML document.
1590 * @param newTitle
1591 */
1592 Title.prototype.setTitle = function (newTitle) { this._doc.title = newTitle || ''; };
1593 Title.ɵprov = ɵɵdefineInjectable({ factory: createTitle, token: Title, providedIn: "root" });
1594 Title = __decorate([
1595 Injectable({ providedIn: 'root', useFactory: createTitle, deps: [] }),
1596 __param(0, Inject(DOCUMENT)),
1597 __metadata("design:paramtypes", [Object])
1598 ], Title);
1599 return Title;
1600}());
1601
1602/**
1603 * @license
1604 * Copyright Google Inc. All Rights Reserved.
1605 *
1606 * Use of this source code is governed by an MIT-style license that can be
1607 * found in the LICENSE file at https://angular.io/license
1608 */
1609var win = typeof window !== 'undefined' && window || {};
1610
1611/**
1612 * @license
1613 * Copyright Google Inc. All Rights Reserved.
1614 *
1615 * Use of this source code is governed by an MIT-style license that can be
1616 * found in the LICENSE file at https://angular.io/license
1617 */
1618var ChangeDetectionPerfRecord = /** @class */ (function () {
1619 function ChangeDetectionPerfRecord(msPerTick, numTicks) {
1620 this.msPerTick = msPerTick;
1621 this.numTicks = numTicks;
1622 }
1623 return ChangeDetectionPerfRecord;
1624}());
1625/**
1626 * Entry point for all Angular profiling-related debug tools. This object
1627 * corresponds to the `ng.profiler` in the dev console.
1628 */
1629var AngularProfiler = /** @class */ (function () {
1630 function AngularProfiler(ref) {
1631 this.appRef = ref.injector.get(ApplicationRef);
1632 }
1633 // tslint:disable:no-console
1634 /**
1635 * Exercises change detection in a loop and then prints the average amount of
1636 * time in milliseconds how long a single round of change detection takes for
1637 * the current state of the UI. It runs a minimum of 5 rounds for a minimum
1638 * of 500 milliseconds.
1639 *
1640 * Optionally, a user may pass a `config` parameter containing a map of
1641 * options. Supported options are:
1642 *
1643 * `record` (boolean) - causes the profiler to record a CPU profile while
1644 * it exercises the change detector. Example:
1645 *
1646 * ```
1647 * ng.profiler.timeChangeDetection({record: true})
1648 * ```
1649 */
1650 AngularProfiler.prototype.timeChangeDetection = function (config) {
1651 var record = config && config['record'];
1652 var profileName = 'Change Detection';
1653 // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
1654 var isProfilerAvailable = win.console.profile != null;
1655 if (record && isProfilerAvailable) {
1656 win.console.profile(profileName);
1657 }
1658 var start = ɵgetDOM().performanceNow();
1659 var numTicks = 0;
1660 while (numTicks < 5 || (ɵgetDOM().performanceNow() - start) < 500) {
1661 this.appRef.tick();
1662 numTicks++;
1663 }
1664 var end = ɵgetDOM().performanceNow();
1665 if (record && isProfilerAvailable) {
1666 win.console.profileEnd(profileName);
1667 }
1668 var msPerTick = (end - start) / numTicks;
1669 win.console.log("ran " + numTicks + " change detection cycles");
1670 win.console.log(msPerTick.toFixed(2) + " ms per check");
1671 return new ChangeDetectionPerfRecord(msPerTick, numTicks);
1672 };
1673 return AngularProfiler;
1674}());
1675
1676/**
1677 * @license
1678 * Copyright Google Inc. All Rights Reserved.
1679 *
1680 * Use of this source code is governed by an MIT-style license that can be
1681 * found in the LICENSE file at https://angular.io/license
1682 */
1683var PROFILER_GLOBAL_NAME = 'profiler';
1684/**
1685 * Enabled Angular debug tools that are accessible via your browser's
1686 * developer console.
1687 *
1688 * Usage:
1689 *
1690 * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
1691 * 1. Type `ng.` (usually the console will show auto-complete suggestion)
1692 * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
1693 * then hit Enter.
1694 *
1695 * @publicApi
1696 */
1697function enableDebugTools(ref) {
1698 exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
1699 return ref;
1700}
1701/**
1702 * Disables Angular tools.
1703 *
1704 * @publicApi
1705 */
1706function disableDebugTools() {
1707 exportNgVar(PROFILER_GLOBAL_NAME, null);
1708}
1709
1710/**
1711 * @license
1712 * Copyright Google Inc. All Rights Reserved.
1713 *
1714 * Use of this source code is governed by an MIT-style license that can be
1715 * found in the LICENSE file at https://angular.io/license
1716 */
1717function escapeHtml(text) {
1718 var escapedText = {
1719 '&': '&a;',
1720 '"': '&q;',
1721 '\'': '&s;',
1722 '<': '&l;',
1723 '>': '&g;',
1724 };
1725 return text.replace(/[&"'<>]/g, function (s) { return escapedText[s]; });
1726}
1727function unescapeHtml(text) {
1728 var unescapedText = {
1729 '&a;': '&',
1730 '&q;': '"',
1731 '&s;': '\'',
1732 '&l;': '<',
1733 '&g;': '>',
1734 };
1735 return text.replace(/&[^;]+;/g, function (s) { return unescapedText[s]; });
1736}
1737/**
1738 * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
1739 *
1740 * Example:
1741 *
1742 * ```
1743 * const COUNTER_KEY = makeStateKey<number>('counter');
1744 * let value = 10;
1745 *
1746 * transferState.set(COUNTER_KEY, value);
1747 * ```
1748 *
1749 * @publicApi
1750 */
1751function makeStateKey(key) {
1752 return key;
1753}
1754/**
1755 * A key value store that is transferred from the application on the server side to the application
1756 * on the client side.
1757 *
1758 * `TransferState` will be available as an injectable token. To use it import
1759 * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
1760 *
1761 * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
1762 * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
1763 * non-lossy manner.
1764 *
1765 * @publicApi
1766 */
1767var TransferState = /** @class */ (function () {
1768 function TransferState() {
1769 this.store = {};
1770 this.onSerializeCallbacks = {};
1771 }
1772 TransferState_1 = TransferState;
1773 /** @internal */
1774 TransferState.init = function (initState) {
1775 var transferState = new TransferState_1();
1776 transferState.store = initState;
1777 return transferState;
1778 };
1779 /**
1780 * Get the value corresponding to a key. Return `defaultValue` if key is not found.
1781 */
1782 TransferState.prototype.get = function (key, defaultValue) {
1783 return this.store[key] !== undefined ? this.store[key] : defaultValue;
1784 };
1785 /**
1786 * Set the value corresponding to a key.
1787 */
1788 TransferState.prototype.set = function (key, value) { this.store[key] = value; };
1789 /**
1790 * Remove a key from the store.
1791 */
1792 TransferState.prototype.remove = function (key) { delete this.store[key]; };
1793 /**
1794 * Test whether a key exists in the store.
1795 */
1796 TransferState.prototype.hasKey = function (key) { return this.store.hasOwnProperty(key); };
1797 /**
1798 * Register a callback to provide the value for a key when `toJson` is called.
1799 */
1800 TransferState.prototype.onSerialize = function (key, callback) {
1801 this.onSerializeCallbacks[key] = callback;
1802 };
1803 /**
1804 * Serialize the current state of the store to JSON.
1805 */
1806 TransferState.prototype.toJson = function () {
1807 // Call the onSerialize callbacks and put those values into the store.
1808 for (var key in this.onSerializeCallbacks) {
1809 if (this.onSerializeCallbacks.hasOwnProperty(key)) {
1810 try {
1811 this.store[key] = this.onSerializeCallbacks[key]();
1812 }
1813 catch (e) {
1814 console.warn('Exception in onSerialize callback: ', e);
1815 }
1816 }
1817 }
1818 return JSON.stringify(this.store);
1819 };
1820 var TransferState_1;
1821 TransferState = TransferState_1 = __decorate([
1822 Injectable()
1823 ], TransferState);
1824 return TransferState;
1825}());
1826function initTransferState(doc, appId) {
1827 // Locate the script tag with the JSON data transferred from the server.
1828 // The id of the script tag is set to the Angular appId + 'state'.
1829 var script = doc.getElementById(appId + '-state');
1830 var initialState = {};
1831 if (script && script.textContent) {
1832 try {
1833 initialState = JSON.parse(unescapeHtml(script.textContent));
1834 }
1835 catch (e) {
1836 console.warn('Exception while restoring TransferState for app ' + appId, e);
1837 }
1838 }
1839 return TransferState.init(initialState);
1840}
1841/**
1842 * NgModule to install on the client side while using the `TransferState` to transfer state from
1843 * server to client.
1844 *
1845 * @publicApi
1846 */
1847var BrowserTransferStateModule = /** @class */ (function () {
1848 function BrowserTransferStateModule() {
1849 }
1850 BrowserTransferStateModule = __decorate([
1851 NgModule({
1852 providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT, APP_ID] }],
1853 })
1854 ], BrowserTransferStateModule);
1855 return BrowserTransferStateModule;
1856}());
1857
1858/**
1859 * @license
1860 * Copyright Google Inc. All Rights Reserved.
1861 *
1862 * Use of this source code is governed by an MIT-style license that can be
1863 * found in the LICENSE file at https://angular.io/license
1864 */
1865/**
1866 * Predicates for use with {@link DebugElement}'s query functions.
1867 *
1868 * @publicApi
1869 */
1870var By = /** @class */ (function () {
1871 function By() {
1872 }
1873 /**
1874 * Match all nodes.
1875 *
1876 * @usageNotes
1877 * ### Example
1878 *
1879 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
1880 */
1881 By.all = function () { return function () { return true; }; };
1882 /**
1883 * Match elements by the given CSS selector.
1884 *
1885 * @usageNotes
1886 * ### Example
1887 *
1888 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
1889 */
1890 By.css = function (selector) {
1891 return function (debugElement) {
1892 return debugElement.nativeElement != null ?
1893 elementMatches(debugElement.nativeElement, selector) :
1894 false;
1895 };
1896 };
1897 /**
1898 * Match nodes that have the given directive present.
1899 *
1900 * @usageNotes
1901 * ### Example
1902 *
1903 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
1904 */
1905 By.directive = function (type) {
1906 return function (debugNode) { return debugNode.providerTokens.indexOf(type) !== -1; };
1907 };
1908 return By;
1909}());
1910function elementMatches(n, selector) {
1911 if (ɵgetDOM().isElementNode(n)) {
1912 return n.matches && n.matches(selector) ||
1913 n.msMatchesSelector && n.msMatchesSelector(selector) ||
1914 n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
1915 }
1916 return false;
1917}
1918
1919/**
1920 * @license
1921 * Copyright Google Inc. All Rights Reserved.
1922 *
1923 * Use of this source code is governed by an MIT-style license that can be
1924 * found in the LICENSE file at https://angular.io/license
1925 */
1926
1927/**
1928 * @license
1929 * Copyright Google Inc. All Rights Reserved.
1930 *
1931 * Use of this source code is governed by an MIT-style license that can be
1932 * found in the LICENSE file at https://angular.io/license
1933 */
1934/**
1935 * @publicApi
1936 */
1937var VERSION = new Version('9.0.5');
1938
1939/**
1940 * @license
1941 * Copyright Google Inc. All Rights Reserved.
1942 *
1943 * Use of this source code is governed by an MIT-style license that can be
1944 * found in the LICENSE file at https://angular.io/license
1945 */
1946
1947/**
1948 * @license
1949 * Copyright Google Inc. All Rights Reserved.
1950 *
1951 * Use of this source code is governed by an MIT-style license that can be
1952 * found in the LICENSE file at https://angular.io/license
1953 */
1954// This file only reexports content of the `src` folder. Keep it that way.
1955
1956/**
1957 * @license
1958 * Copyright Google Inc. All Rights Reserved.
1959 *
1960 * Use of this source code is governed by an MIT-style license that can be
1961 * found in the LICENSE file at https://angular.io/license
1962 */
1963
1964/**
1965 * Generated bundle index. Do not edit.
1966 */
1967
1968export { BrowserModule, BrowserTransferStateModule, By, DomSanitizer, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HAMMER_LOADER, HammerGestureConfig, HammerModule, Meta, Title, TransferState, VERSION, disableDebugTools, enableDebugTools, makeStateKey, platformBrowser, BROWSER_SANITIZATION_PROVIDERS as ɵBROWSER_SANITIZATION_PROVIDERS, BROWSER_SANITIZATION_PROVIDERS__POST_R3__ as ɵBROWSER_SANITIZATION_PROVIDERS__POST_R3__, BrowserDomAdapter as ɵBrowserDomAdapter, BrowserGetTestability as ɵBrowserGetTestability, DomEventsPlugin as ɵDomEventsPlugin, DomRendererFactory2 as ɵDomRendererFactory2, DomSanitizerImpl as ɵDomSanitizerImpl, DomSharedStylesHost as ɵDomSharedStylesHost, ELEMENT_PROBE_PROVIDERS as ɵELEMENT_PROBE_PROVIDERS, ELEMENT_PROBE_PROVIDERS__POST_R3__ as ɵELEMENT_PROBE_PROVIDERS__POST_R3__, HAMMER_PROVIDERS__POST_R3__ as ɵHAMMER_PROVIDERS__POST_R3__, HammerGesturesPlugin as ɵHammerGesturesPlugin, INTERNAL_BROWSER_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS, KeyEventsPlugin as ɵKeyEventsPlugin, NAMESPACE_URIS as ɵNAMESPACE_URIS, SharedStylesHost as ɵSharedStylesHost, TRANSITION_ID as ɵTRANSITION_ID, errorHandler as ɵangular_packages_platform_browser_platform_browser_a, _document as ɵangular_packages_platform_browser_platform_browser_b, BROWSER_MODULE_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_c, createMeta as ɵangular_packages_platform_browser_platform_browser_d, createTitle as ɵangular_packages_platform_browser_platform_browser_e, initTransferState as ɵangular_packages_platform_browser_platform_browser_f, EventManagerPlugin as ɵangular_packages_platform_browser_platform_browser_g, HAMMER_PROVIDERS__PRE_R3__ as ɵangular_packages_platform_browser_platform_browser_h, HAMMER_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_i, domSanitizerImplFactory as ɵangular_packages_platform_browser_platform_browser_j, appInitializerFactory as ɵangular_packages_platform_browser_platform_browser_k, SERVER_TRANSITION_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_l, _createNgProbeR2 as ɵangular_packages_platform_browser_platform_browser_m, ELEMENT_PROBE_PROVIDERS__PRE_R3__ as ɵangular_packages_platform_browser_platform_browser_n, GenericBrowserDomAdapter as ɵangular_packages_platform_browser_platform_browser_o, escapeHtml as ɵescapeHtml, flattenStyles as ɵflattenStyles, initDomAdapter as ɵinitDomAdapter, shimContentAttribute as ɵshimContentAttribute, shimHostAttribute as ɵshimHostAttribute };
1969//# sourceMappingURL=platform-browser.js.map