UNPKG

75.6 kBJavaScriptView Raw
1/**
2 * @license Angular v10.0.9
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 // NOTE: Please don't rewrite this as so, as it will break JSCompiler property renaming.
1202 // The code must remain in the `result['domEventName']` form.
1203 // return {domEventName, fullKey};
1204 const result = {};
1205 result['domEventName'] = domEventName;
1206 result['fullKey'] = fullKey;
1207 return result;
1208 }
1209 static getEventFullKey(event) {
1210 let fullKey = '';
1211 let key = getEventKey(event);
1212 key = key.toLowerCase();
1213 if (key === ' ') {
1214 key = 'space'; // for readability
1215 }
1216 else if (key === '.') {
1217 key = 'dot'; // because '.' is used as a separator in event names
1218 }
1219 MODIFIER_KEYS.forEach(modifierName => {
1220 if (modifierName != key) {
1221 const modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
1222 if (modifierGetter(event)) {
1223 fullKey += modifierName + '.';
1224 }
1225 }
1226 });
1227 fullKey += key;
1228 return fullKey;
1229 }
1230 /**
1231 * Configures a handler callback for a key event.
1232 * @param fullKey The event name that combines all simultaneous keystrokes.
1233 * @param handler The function that responds to the key event.
1234 * @param zone The zone in which the event occurred.
1235 * @returns A callback function.
1236 */
1237 static eventCallback(fullKey, handler, zone) {
1238 return (event /** TODO #9100 */) => {
1239 if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
1240 zone.runGuarded(() => handler(event));
1241 }
1242 };
1243 }
1244 /** @internal */
1245 static _normalizeKey(keyName) {
1246 // TODO: switch to a Map if the mapping grows too much
1247 switch (keyName) {
1248 case 'esc':
1249 return 'escape';
1250 default:
1251 return keyName;
1252 }
1253 }
1254}
1255KeyEventsPlugin.decorators = [
1256 { type: Injectable }
1257];
1258KeyEventsPlugin.ctorParameters = () => [
1259 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
1260];
1261function getEventKey(event) {
1262 let key = event.key;
1263 if (key == null) {
1264 key = event.keyIdentifier;
1265 // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
1266 // Safari cf
1267 // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
1268 if (key == null) {
1269 return 'Unidentified';
1270 }
1271 if (key.startsWith('U+')) {
1272 key = String.fromCharCode(parseInt(key.substring(2), 16));
1273 if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
1274 // There is a bug in Chrome for numeric keypad keys:
1275 // https://code.google.com/p/chromium/issues/detail?id=155654
1276 // 1, 2, 3 ... are reported as A, B, C ...
1277 key = _chromeNumKeyPadMap[key];
1278 }
1279 }
1280 }
1281 return _keyMap[key] || key;
1282}
1283
1284/**
1285 * @license
1286 * Copyright Google LLC All Rights Reserved.
1287 *
1288 * Use of this source code is governed by an MIT-style license that can be
1289 * found in the LICENSE file at https://angular.io/license
1290 */
1291/**
1292 * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
1293 * values to be safe to use in the different DOM contexts.
1294 *
1295 * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
1296 * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
1297 * the website.
1298 *
1299 * In specific situations, it might be necessary to disable sanitization, for example if the
1300 * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
1301 * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
1302 * methods, and then binding to that value from the template.
1303 *
1304 * These situations should be very rare, and extraordinary care must be taken to avoid creating a
1305 * Cross Site Scripting (XSS) security bug!
1306 *
1307 * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
1308 * close as possible to the source of the value, to make it easy to verify no security bug is
1309 * created by its use.
1310 *
1311 * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
1312 * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
1313 * code. The sanitizer leaves safe values intact.
1314 *
1315 * @security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
1316 * sanitization for the value passed in. Carefully check and audit all values and code paths going
1317 * into this call. Make sure any user data is appropriately escaped for this security context.
1318 * For more detail, see the [Security Guide](http://g.co/ng/security).
1319 *
1320 * @publicApi
1321 */
1322class DomSanitizer {
1323}
1324DomSanitizer.ɵprov = ɵɵdefineInjectable({ factory: function DomSanitizer_Factory() { return ɵɵinject(DomSanitizerImpl); }, token: DomSanitizer, providedIn: "root" });
1325DomSanitizer.decorators = [
1326 { type: Injectable, args: [{ providedIn: 'root', useExisting: forwardRef(() => DomSanitizerImpl) },] }
1327];
1328function domSanitizerImplFactory(injector) {
1329 return new DomSanitizerImpl(injector.get(DOCUMENT));
1330}
1331class DomSanitizerImpl extends DomSanitizer {
1332 constructor(_doc) {
1333 super();
1334 this._doc = _doc;
1335 }
1336 sanitize(ctx, value) {
1337 if (value == null)
1338 return null;
1339 switch (ctx) {
1340 case SecurityContext.NONE:
1341 return value;
1342 case SecurityContext.HTML:
1343 if (ɵallowSanitizationBypassAndThrow(value, "HTML" /* Html */)) {
1344 return ɵunwrapSafeValue(value);
1345 }
1346 return ɵ_sanitizeHtml(this._doc, String(value));
1347 case SecurityContext.STYLE:
1348 if (ɵallowSanitizationBypassAndThrow(value, "Style" /* Style */)) {
1349 return ɵunwrapSafeValue(value);
1350 }
1351 return value;
1352 case SecurityContext.SCRIPT:
1353 if (ɵallowSanitizationBypassAndThrow(value, "Script" /* Script */)) {
1354 return ɵunwrapSafeValue(value);
1355 }
1356 throw new Error('unsafe value used in a script context');
1357 case SecurityContext.URL:
1358 const type = ɵgetSanitizationBypassType(value);
1359 if (ɵallowSanitizationBypassAndThrow(value, "URL" /* Url */)) {
1360 return ɵunwrapSafeValue(value);
1361 }
1362 return ɵ_sanitizeUrl(String(value));
1363 case SecurityContext.RESOURCE_URL:
1364 if (ɵallowSanitizationBypassAndThrow(value, "ResourceURL" /* ResourceUrl */)) {
1365 return ɵunwrapSafeValue(value);
1366 }
1367 throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
1368 default:
1369 throw new Error(`Unexpected SecurityContext ${ctx} (see http://g.co/ng/security#xss)`);
1370 }
1371 }
1372 bypassSecurityTrustHtml(value) {
1373 return ɵbypassSanitizationTrustHtml(value);
1374 }
1375 bypassSecurityTrustStyle(value) {
1376 return ɵbypassSanitizationTrustStyle(value);
1377 }
1378 bypassSecurityTrustScript(value) {
1379 return ɵbypassSanitizationTrustScript(value);
1380 }
1381 bypassSecurityTrustUrl(value) {
1382 return ɵbypassSanitizationTrustUrl(value);
1383 }
1384 bypassSecurityTrustResourceUrl(value) {
1385 return ɵbypassSanitizationTrustResourceUrl(value);
1386 }
1387}
1388DomSanitizerImpl.ɵprov = ɵɵdefineInjectable({ factory: function DomSanitizerImpl_Factory() { return domSanitizerImplFactory(ɵɵinject(INJECTOR)); }, token: DomSanitizerImpl, providedIn: "root" });
1389DomSanitizerImpl.decorators = [
1390 { type: Injectable, args: [{ providedIn: 'root', useFactory: domSanitizerImplFactory, deps: [Injector] },] }
1391];
1392DomSanitizerImpl.ctorParameters = () => [
1393 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
1394];
1395
1396/**
1397 * @license
1398 * Copyright Google LLC All Rights Reserved.
1399 *
1400 * Use of this source code is governed by an MIT-style license that can be
1401 * found in the LICENSE file at https://angular.io/license
1402 */
1403function initDomAdapter() {
1404 BrowserDomAdapter.makeCurrent();
1405 BrowserGetTestability.init();
1406}
1407function errorHandler() {
1408 return new ErrorHandler();
1409}
1410function _document() {
1411 // Tell ivy about the global document
1412 ɵsetDocument(document);
1413 return document;
1414}
1415const ɵ0$4 = ɵPLATFORM_BROWSER_ID;
1416const INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
1417 { provide: PLATFORM_ID, useValue: ɵ0$4 },
1418 { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
1419 { provide: DOCUMENT, useFactory: _document, deps: [] },
1420];
1421const BROWSER_SANITIZATION_PROVIDERS__PRE_R3__ = [
1422 { provide: Sanitizer, useExisting: DomSanitizer },
1423 { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT] },
1424];
1425const BROWSER_SANITIZATION_PROVIDERS__POST_R3__ = [];
1426/**
1427 * @security Replacing built-in sanitization providers exposes the application to XSS risks.
1428 * Attacker-controlled data introduced by an unsanitized provider could expose your
1429 * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
1430 * @publicApi
1431 */
1432const BROWSER_SANITIZATION_PROVIDERS = BROWSER_SANITIZATION_PROVIDERS__PRE_R3__;
1433/**
1434 * A factory function that returns a `PlatformRef` instance associated with browser service
1435 * providers.
1436 *
1437 * @publicApi
1438 */
1439const platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
1440const BROWSER_MODULE_PROVIDERS = [
1441 BROWSER_SANITIZATION_PROVIDERS,
1442 { provide: ɵINJECTOR_SCOPE, useValue: 'root' },
1443 { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
1444 {
1445 provide: EVENT_MANAGER_PLUGINS,
1446 useClass: DomEventsPlugin,
1447 multi: true,
1448 deps: [DOCUMENT, NgZone, PLATFORM_ID]
1449 },
1450 { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true, deps: [DOCUMENT] },
1451 HAMMER_PROVIDERS,
1452 {
1453 provide: DomRendererFactory2,
1454 useClass: DomRendererFactory2,
1455 deps: [EventManager, DomSharedStylesHost, APP_ID]
1456 },
1457 { provide: RendererFactory2, useExisting: DomRendererFactory2 },
1458 { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
1459 { provide: DomSharedStylesHost, useClass: DomSharedStylesHost, deps: [DOCUMENT] },
1460 { provide: Testability, useClass: Testability, deps: [NgZone] },
1461 { provide: EventManager, useClass: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone] },
1462 ELEMENT_PROBE_PROVIDERS,
1463];
1464/**
1465 * Exports required infrastructure for all Angular apps.
1466 * Included by default in all Angular apps created with the CLI
1467 * `new` command.
1468 * Re-exports `CommonModule` and `ApplicationModule`, making their
1469 * exports and providers available to all apps.
1470 *
1471 * @publicApi
1472 */
1473class BrowserModule {
1474 constructor(parentModule) {
1475 if (parentModule) {
1476 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.`);
1477 }
1478 }
1479 /**
1480 * Configures a browser-based app to transition from a server-rendered app, if
1481 * one is present on the page.
1482 *
1483 * @param params An object containing an identifier for the app to transition.
1484 * The ID must match between the client and server versions of the app.
1485 * @returns The reconfigured `BrowserModule` to import into the app's root `AppModule`.
1486 */
1487 static withServerTransition(params) {
1488 return {
1489 ngModule: BrowserModule,
1490 providers: [
1491 { provide: APP_ID, useValue: params.appId },
1492 { provide: TRANSITION_ID, useExisting: APP_ID },
1493 SERVER_TRANSITION_PROVIDERS,
1494 ],
1495 };
1496 }
1497}
1498BrowserModule.decorators = [
1499 { type: NgModule, args: [{ providers: BROWSER_MODULE_PROVIDERS, exports: [CommonModule, ApplicationModule] },] }
1500];
1501BrowserModule.ctorParameters = () => [
1502 { type: BrowserModule, decorators: [{ type: Optional }, { type: SkipSelf }, { type: Inject, args: [BrowserModule,] }] }
1503];
1504
1505/**
1506 * @license
1507 * Copyright Google LLC All Rights Reserved.
1508 *
1509 * Use of this source code is governed by an MIT-style license that can be
1510 * found in the LICENSE file at https://angular.io/license
1511 */
1512/**
1513 * Factory to create a `Meta` service instance for the current DOM document.
1514 */
1515function createMeta() {
1516 return new Meta(ɵɵinject(DOCUMENT));
1517}
1518/**
1519 * A service for managing HTML `<meta>` tags.
1520 *
1521 * Properties of the `MetaDefinition` object match the attributes of the
1522 * HTML `<meta>` tag. These tags define document metadata that is important for
1523 * things like configuring a Content Security Policy, defining browser compatibility
1524 * and security settings, setting HTTP Headers, defining rich content for social sharing,
1525 * and Search Engine Optimization (SEO).
1526 *
1527 * To identify specific `<meta>` tags in a document, use an attribute selection
1528 * string in the format `"tag_attribute='value string'"`.
1529 * For example, an `attrSelector` value of `"name='description'"` matches a tag
1530 * whose `name` attribute has the value `"description"`.
1531 * Selectors are used with the `querySelector()` Document method,
1532 * in the format `meta[{attrSelector}]`.
1533 *
1534 * @see [HTML meta tag](https://developer.mozilla.org/docs/Web/HTML/Element/meta)
1535 * @see [Document.querySelector()](https://developer.mozilla.org/docs/Web/API/Document/querySelector)
1536 *
1537 *
1538 * @publicApi
1539 */
1540class Meta {
1541 constructor(_doc) {
1542 this._doc = _doc;
1543 this._dom = ɵgetDOM();
1544 }
1545 /**
1546 * Retrieves or creates a specific `<meta>` tag element in the current HTML document.
1547 * In searching for an existing tag, Angular attempts to match the `name` or `property` attribute
1548 * values in the provided tag definition, and verifies that all other attribute values are equal.
1549 * If an existing element is found, it is returned and is not modified in any way.
1550 * @param tag The definition of a `<meta>` element to match or create.
1551 * @param forceCreation True to create a new element without checking whether one already exists.
1552 * @returns The existing element with the same attributes and values if found,
1553 * the new element if no match is found, or `null` if the tag parameter is not defined.
1554 */
1555 addTag(tag, forceCreation = false) {
1556 if (!tag)
1557 return null;
1558 return this._getOrCreateElement(tag, forceCreation);
1559 }
1560 /**
1561 * Retrieves or creates a set of `<meta>` tag elements in the current HTML document.
1562 * In searching for an existing tag, Angular attempts to match the `name` or `property` attribute
1563 * values in the provided tag definition, and verifies that all other attribute values are equal.
1564 * @param tags An array of tag definitions to match or create.
1565 * @param forceCreation True to create new elements without checking whether they already exist.
1566 * @returns The matching elements if found, or the new elements.
1567 */
1568 addTags(tags, forceCreation = false) {
1569 if (!tags)
1570 return [];
1571 return tags.reduce((result, tag) => {
1572 if (tag) {
1573 result.push(this._getOrCreateElement(tag, forceCreation));
1574 }
1575 return result;
1576 }, []);
1577 }
1578 /**
1579 * Retrieves a `<meta>` tag element in the current HTML document.
1580 * @param attrSelector The tag attribute and value to match against, in the format
1581 * `"tag_attribute='value string'"`.
1582 * @returns The matching element, if any.
1583 */
1584 getTag(attrSelector) {
1585 if (!attrSelector)
1586 return null;
1587 return this._doc.querySelector(`meta[${attrSelector}]`) || null;
1588 }
1589 /**
1590 * Retrieves a set of `<meta>` tag elements in the current HTML document.
1591 * @param attrSelector The tag attribute and value to match against, in the format
1592 * `"tag_attribute='value string'"`.
1593 * @returns The matching elements, if any.
1594 */
1595 getTags(attrSelector) {
1596 if (!attrSelector)
1597 return [];
1598 const list /*NodeList*/ = this._doc.querySelectorAll(`meta[${attrSelector}]`);
1599 return list ? [].slice.call(list) : [];
1600 }
1601 /**
1602 * Modifies an existing `<meta>` tag element in the current HTML document.
1603 * @param tag The tag description with which to replace the existing tag content.
1604 * @param selector A tag attribute and value to match against, to identify
1605 * an existing tag. A string in the format `"tag_attribute=`value string`"`.
1606 * If not supplied, matches a tag with the same `name` or `property` attribute value as the
1607 * replacement tag.
1608 * @return The modified element.
1609 */
1610 updateTag(tag, selector) {
1611 if (!tag)
1612 return null;
1613 selector = selector || this._parseSelector(tag);
1614 const meta = this.getTag(selector);
1615 if (meta) {
1616 return this._setMetaElementAttributes(tag, meta);
1617 }
1618 return this._getOrCreateElement(tag, true);
1619 }
1620 /**
1621 * Removes an existing `<meta>` tag element from the current HTML document.
1622 * @param attrSelector A tag attribute and value to match against, to identify
1623 * an existing tag. A string in the format `"tag_attribute=`value string`"`.
1624 */
1625 removeTag(attrSelector) {
1626 this.removeTagElement(this.getTag(attrSelector));
1627 }
1628 /**
1629 * Removes an existing `<meta>` tag element from the current HTML document.
1630 * @param meta The tag definition to match against to identify an existing tag.
1631 */
1632 removeTagElement(meta) {
1633 if (meta) {
1634 this._dom.remove(meta);
1635 }
1636 }
1637 _getOrCreateElement(meta, forceCreation = false) {
1638 if (!forceCreation) {
1639 const selector = this._parseSelector(meta);
1640 const elem = this.getTag(selector);
1641 // It's allowed to have multiple elements with the same name so it's not enough to
1642 // just check that element with the same name already present on the page. We also need to
1643 // check if element has tag attributes
1644 if (elem && this._containsAttributes(meta, elem))
1645 return elem;
1646 }
1647 const element = this._dom.createElement('meta');
1648 this._setMetaElementAttributes(meta, element);
1649 const head = this._doc.getElementsByTagName('head')[0];
1650 head.appendChild(element);
1651 return element;
1652 }
1653 _setMetaElementAttributes(tag, el) {
1654 Object.keys(tag).forEach((prop) => el.setAttribute(prop, tag[prop]));
1655 return el;
1656 }
1657 _parseSelector(tag) {
1658 const attr = tag.name ? 'name' : 'property';
1659 return `${attr}="${tag[attr]}"`;
1660 }
1661 _containsAttributes(tag, elem) {
1662 return Object.keys(tag).every((key) => elem.getAttribute(key) === tag[key]);
1663 }
1664}
1665Meta.ɵprov = ɵɵdefineInjectable({ factory: createMeta, token: Meta, providedIn: "root" });
1666Meta.decorators = [
1667 { type: Injectable, args: [{ providedIn: 'root', useFactory: createMeta, deps: [] },] }
1668];
1669Meta.ctorParameters = () => [
1670 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
1671];
1672
1673/**
1674 * @license
1675 * Copyright Google LLC All Rights Reserved.
1676 *
1677 * Use of this source code is governed by an MIT-style license that can be
1678 * found in the LICENSE file at https://angular.io/license
1679 */
1680/**
1681 * Factory to create Title service.
1682 */
1683function createTitle() {
1684 return new Title(ɵɵinject(DOCUMENT));
1685}
1686/**
1687 * A service that can be used to get and set the title of a current HTML document.
1688 *
1689 * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
1690 * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
1691 * (representing the `<title>` tag). Instead, this service can be used to set and get the current
1692 * title value.
1693 *
1694 * @publicApi
1695 */
1696class Title {
1697 constructor(_doc) {
1698 this._doc = _doc;
1699 }
1700 /**
1701 * Get the title of the current HTML document.
1702 */
1703 getTitle() {
1704 return this._doc.title;
1705 }
1706 /**
1707 * Set the title of the current HTML document.
1708 * @param newTitle
1709 */
1710 setTitle(newTitle) {
1711 this._doc.title = newTitle || '';
1712 }
1713}
1714Title.ɵprov = ɵɵdefineInjectable({ factory: createTitle, token: Title, providedIn: "root" });
1715Title.decorators = [
1716 { type: Injectable, args: [{ providedIn: 'root', useFactory: createTitle, deps: [] },] }
1717];
1718Title.ctorParameters = () => [
1719 { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
1720];
1721
1722/**
1723 * @license
1724 * Copyright Google LLC All Rights Reserved.
1725 *
1726 * Use of this source code is governed by an MIT-style license that can be
1727 * found in the LICENSE file at https://angular.io/license
1728 */
1729const win = typeof window !== 'undefined' && window || {};
1730
1731/**
1732 * @license
1733 * Copyright Google LLC All Rights Reserved.
1734 *
1735 * Use of this source code is governed by an MIT-style license that can be
1736 * found in the LICENSE file at https://angular.io/license
1737 */
1738class ChangeDetectionPerfRecord {
1739 constructor(msPerTick, numTicks) {
1740 this.msPerTick = msPerTick;
1741 this.numTicks = numTicks;
1742 }
1743}
1744/**
1745 * Entry point for all Angular profiling-related debug tools. This object
1746 * corresponds to the `ng.profiler` in the dev console.
1747 */
1748class AngularProfiler {
1749 constructor(ref) {
1750 this.appRef = ref.injector.get(ApplicationRef);
1751 }
1752 // tslint:disable:no-console
1753 /**
1754 * Exercises change detection in a loop and then prints the average amount of
1755 * time in milliseconds how long a single round of change detection takes for
1756 * the current state of the UI. It runs a minimum of 5 rounds for a minimum
1757 * of 500 milliseconds.
1758 *
1759 * Optionally, a user may pass a `config` parameter containing a map of
1760 * options. Supported options are:
1761 *
1762 * `record` (boolean) - causes the profiler to record a CPU profile while
1763 * it exercises the change detector. Example:
1764 *
1765 * ```
1766 * ng.profiler.timeChangeDetection({record: true})
1767 * ```
1768 */
1769 timeChangeDetection(config) {
1770 const record = config && config['record'];
1771 const profileName = 'Change Detection';
1772 // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
1773 const isProfilerAvailable = win.console.profile != null;
1774 if (record && isProfilerAvailable) {
1775 win.console.profile(profileName);
1776 }
1777 const start = ɵgetDOM().performanceNow();
1778 let numTicks = 0;
1779 while (numTicks < 5 || (ɵgetDOM().performanceNow() - start) < 500) {
1780 this.appRef.tick();
1781 numTicks++;
1782 }
1783 const end = ɵgetDOM().performanceNow();
1784 if (record && isProfilerAvailable) {
1785 win.console.profileEnd(profileName);
1786 }
1787 const msPerTick = (end - start) / numTicks;
1788 win.console.log(`ran ${numTicks} change detection cycles`);
1789 win.console.log(`${msPerTick.toFixed(2)} ms per check`);
1790 return new ChangeDetectionPerfRecord(msPerTick, numTicks);
1791 }
1792}
1793
1794/**
1795 * @license
1796 * Copyright Google LLC All Rights Reserved.
1797 *
1798 * Use of this source code is governed by an MIT-style license that can be
1799 * found in the LICENSE file at https://angular.io/license
1800 */
1801const PROFILER_GLOBAL_NAME = 'profiler';
1802/**
1803 * Enabled Angular debug tools that are accessible via your browser's
1804 * developer console.
1805 *
1806 * Usage:
1807 *
1808 * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
1809 * 1. Type `ng.` (usually the console will show auto-complete suggestion)
1810 * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
1811 * then hit Enter.
1812 *
1813 * @publicApi
1814 */
1815function enableDebugTools(ref) {
1816 exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
1817 return ref;
1818}
1819/**
1820 * Disables Angular tools.
1821 *
1822 * @publicApi
1823 */
1824function disableDebugTools() {
1825 exportNgVar(PROFILER_GLOBAL_NAME, null);
1826}
1827
1828/**
1829 * @license
1830 * Copyright Google LLC All Rights Reserved.
1831 *
1832 * Use of this source code is governed by an MIT-style license that can be
1833 * found in the LICENSE file at https://angular.io/license
1834 */
1835function escapeHtml(text) {
1836 const escapedText = {
1837 '&': '&a;',
1838 '"': '&q;',
1839 '\'': '&s;',
1840 '<': '&l;',
1841 '>': '&g;',
1842 };
1843 return text.replace(/[&"'<>]/g, s => escapedText[s]);
1844}
1845function unescapeHtml(text) {
1846 const unescapedText = {
1847 '&a;': '&',
1848 '&q;': '"',
1849 '&s;': '\'',
1850 '&l;': '<',
1851 '&g;': '>',
1852 };
1853 return text.replace(/&[^;]+;/g, s => unescapedText[s]);
1854}
1855/**
1856 * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
1857 *
1858 * Example:
1859 *
1860 * ```
1861 * const COUNTER_KEY = makeStateKey<number>('counter');
1862 * let value = 10;
1863 *
1864 * transferState.set(COUNTER_KEY, value);
1865 * ```
1866 *
1867 * @publicApi
1868 */
1869function makeStateKey(key) {
1870 return key;
1871}
1872/**
1873 * A key value store that is transferred from the application on the server side to the application
1874 * on the client side.
1875 *
1876 * `TransferState` will be available as an injectable token. To use it import
1877 * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
1878 *
1879 * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
1880 * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
1881 * non-lossy manner.
1882 *
1883 * @publicApi
1884 */
1885class TransferState {
1886 constructor() {
1887 this.store = {};
1888 this.onSerializeCallbacks = {};
1889 }
1890 /** @internal */
1891 static init(initState) {
1892 const transferState = new TransferState();
1893 transferState.store = initState;
1894 return transferState;
1895 }
1896 /**
1897 * Get the value corresponding to a key. Return `defaultValue` if key is not found.
1898 */
1899 get(key, defaultValue) {
1900 return this.store[key] !== undefined ? this.store[key] : defaultValue;
1901 }
1902 /**
1903 * Set the value corresponding to a key.
1904 */
1905 set(key, value) {
1906 this.store[key] = value;
1907 }
1908 /**
1909 * Remove a key from the store.
1910 */
1911 remove(key) {
1912 delete this.store[key];
1913 }
1914 /**
1915 * Test whether a key exists in the store.
1916 */
1917 hasKey(key) {
1918 return this.store.hasOwnProperty(key);
1919 }
1920 /**
1921 * Register a callback to provide the value for a key when `toJson` is called.
1922 */
1923 onSerialize(key, callback) {
1924 this.onSerializeCallbacks[key] = callback;
1925 }
1926 /**
1927 * Serialize the current state of the store to JSON.
1928 */
1929 toJson() {
1930 // Call the onSerialize callbacks and put those values into the store.
1931 for (const key in this.onSerializeCallbacks) {
1932 if (this.onSerializeCallbacks.hasOwnProperty(key)) {
1933 try {
1934 this.store[key] = this.onSerializeCallbacks[key]();
1935 }
1936 catch (e) {
1937 console.warn('Exception in onSerialize callback: ', e);
1938 }
1939 }
1940 }
1941 return JSON.stringify(this.store);
1942 }
1943}
1944TransferState.decorators = [
1945 { type: Injectable }
1946];
1947function initTransferState(doc, appId) {
1948 // Locate the script tag with the JSON data transferred from the server.
1949 // The id of the script tag is set to the Angular appId + 'state'.
1950 const script = doc.getElementById(appId + '-state');
1951 let initialState = {};
1952 if (script && script.textContent) {
1953 try {
1954 initialState = JSON.parse(unescapeHtml(script.textContent));
1955 }
1956 catch (e) {
1957 console.warn('Exception while restoring TransferState for app ' + appId, e);
1958 }
1959 }
1960 return TransferState.init(initialState);
1961}
1962/**
1963 * NgModule to install on the client side while using the `TransferState` to transfer state from
1964 * server to client.
1965 *
1966 * @publicApi
1967 */
1968class BrowserTransferStateModule {
1969}
1970BrowserTransferStateModule.decorators = [
1971 { type: NgModule, args: [{
1972 providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT, APP_ID] }],
1973 },] }
1974];
1975
1976/**
1977 * @license
1978 * Copyright Google LLC All Rights Reserved.
1979 *
1980 * Use of this source code is governed by an MIT-style license that can be
1981 * found in the LICENSE file at https://angular.io/license
1982 */
1983/**
1984 * Predicates for use with {@link DebugElement}'s query functions.
1985 *
1986 * @publicApi
1987 */
1988class By {
1989 /**
1990 * Match all nodes.
1991 *
1992 * @usageNotes
1993 * ### Example
1994 *
1995 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
1996 */
1997 static all() {
1998 return () => true;
1999 }
2000 /**
2001 * Match elements by the given CSS selector.
2002 *
2003 * @usageNotes
2004 * ### Example
2005 *
2006 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
2007 */
2008 static css(selector) {
2009 return (debugElement) => {
2010 return debugElement.nativeElement != null ?
2011 elementMatches(debugElement.nativeElement, selector) :
2012 false;
2013 };
2014 }
2015 /**
2016 * Match nodes that have the given directive present.
2017 *
2018 * @usageNotes
2019 * ### Example
2020 *
2021 * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
2022 */
2023 static directive(type) {
2024 return (debugNode) => debugNode.providerTokens.indexOf(type) !== -1;
2025 }
2026}
2027function elementMatches(n, selector) {
2028 if (ɵgetDOM().isElementNode(n)) {
2029 return n.matches && n.matches(selector) ||
2030 n.msMatchesSelector && n.msMatchesSelector(selector) ||
2031 n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
2032 }
2033 return false;
2034}
2035
2036/**
2037 * @license
2038 * Copyright Google LLC All Rights Reserved.
2039 *
2040 * Use of this source code is governed by an MIT-style license that can be
2041 * found in the LICENSE file at https://angular.io/license
2042 */
2043
2044/**
2045 * @license
2046 * Copyright Google LLC All Rights Reserved.
2047 *
2048 * Use of this source code is governed by an MIT-style license that can be
2049 * found in the LICENSE file at https://angular.io/license
2050 */
2051/**
2052 * @publicApi
2053 */
2054const VERSION = new Version('10.0.9');
2055
2056/**
2057 * @license
2058 * Copyright Google LLC All Rights Reserved.
2059 *
2060 * Use of this source code is governed by an MIT-style license that can be
2061 * found in the LICENSE file at https://angular.io/license
2062 */
2063
2064/**
2065 * @license
2066 * Copyright Google LLC All Rights Reserved.
2067 *
2068 * Use of this source code is governed by an MIT-style license that can be
2069 * found in the LICENSE file at https://angular.io/license
2070 */
2071// This file only reexports content of the `src` folder. Keep it that way.
2072
2073/**
2074 * @license
2075 * Copyright Google LLC All Rights Reserved.
2076 *
2077 * Use of this source code is governed by an MIT-style license that can be
2078 * found in the LICENSE file at https://angular.io/license
2079 */
2080
2081/**
2082 * Generated bundle index. Do not edit.
2083 */
2084
2085export { 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 };
2086//# sourceMappingURL=platform-browser.js.map