UNPKG

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