UNPKG

9.8 kBJavaScriptView Raw
1/**
2 * @license Angular v13.0.3
3 * (c) 2010-2021 Google LLC. https://angular.io/
4 * License: MIT
5 */
6
7import * as i0 from '@angular/core';
8import { ɵglobal, NgZone, PLATFORM_INITIALIZER, createPlatformFactory, platformCore, APP_ID, NgModule } from '@angular/core';
9import { ɵBrowserDomAdapter, BrowserModule } from '@angular/platform-browser';
10import { ɵgetDOM } from '@angular/common';
11
12/**
13 * @license
14 * Copyright Google LLC All Rights Reserved.
15 *
16 * Use of this source code is governed by an MIT-style license that can be
17 * found in the LICENSE file at https://angular.io/license
18 */
19class BrowserDetection {
20 constructor(ua) {
21 this._overrideUa = ua;
22 }
23 get _ua() {
24 if (typeof this._overrideUa === 'string') {
25 return this._overrideUa;
26 }
27 return ɵgetDOM() ? ɵgetDOM().getUserAgent() : '';
28 }
29 static setup() {
30 return new BrowserDetection(null);
31 }
32 get isFirefox() {
33 return this._ua.indexOf('Firefox') > -1;
34 }
35 get isAndroid() {
36 return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&
37 this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1 &&
38 this._ua.indexOf('IEMobile') == -1;
39 }
40 get isEdge() {
41 return this._ua.indexOf('Edge') > -1;
42 }
43 get isIE() {
44 return this._ua.indexOf('Trident') > -1;
45 }
46 get isWebkit() {
47 return this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Edge') == -1 &&
48 this._ua.indexOf('IEMobile') == -1;
49 }
50 get isIOS7() {
51 return (this._ua.indexOf('iPhone OS 7') > -1 || this._ua.indexOf('iPad OS 7') > -1) &&
52 this._ua.indexOf('IEMobile') == -1;
53 }
54 get isSlow() {
55 return this.isAndroid || this.isIE || this.isIOS7;
56 }
57 get isChromeDesktop() {
58 return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
59 this._ua.indexOf('Edge') == -1;
60 }
61 // "Old Chrome" means Chrome 3X, where there are some discrepancies in the Intl API.
62 // Android 4.4 and 5.X have such browsers by default (respectively 30 and 39).
63 get isOldChrome() {
64 return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
65 this._ua.indexOf('Edge') == -1;
66 }
67 get supportsCustomElements() {
68 return (typeof ɵglobal.customElements !== 'undefined');
69 }
70 get supportsDeprecatedCustomCustomElementsV0() {
71 return (typeof document.registerElement !== 'undefined');
72 }
73 get supportsRegExUnicodeFlag() {
74 return RegExp.prototype.hasOwnProperty('unicode');
75 }
76 get supportsShadowDom() {
77 const testEl = document.createElement('div');
78 return (typeof testEl.attachShadow !== 'undefined');
79 }
80 get supportsDeprecatedShadowDomV0() {
81 const testEl = document.createElement('div');
82 return (typeof testEl.createShadowRoot !== 'undefined');
83 }
84}
85const browserDetection = BrowserDetection.setup();
86function dispatchEvent(element, eventType) {
87 const evt = ɵgetDOM().getDefaultDocument().createEvent('Event');
88 evt.initEvent(eventType, true, true);
89 ɵgetDOM().dispatchEvent(element, evt);
90}
91function createMouseEvent(eventType) {
92 const evt = ɵgetDOM().getDefaultDocument().createEvent('MouseEvent');
93 evt.initEvent(eventType, true, true);
94 return evt;
95}
96function el(html) {
97 return getContent(createTemplate(html)).firstChild;
98}
99function normalizeCSS(css) {
100 return css.replace(/\s+/g, ' ')
101 .replace(/:\s/g, ':')
102 .replace(/'/g, '"')
103 .replace(/ }/g, '}')
104 .replace(/url\((\"|\s)(.+)(\"|\s)\)(\s*)/g, (...match) => `url("${match[2]}")`)
105 .replace(/\[(.+)=([^"\]]+)\]/g, (...match) => `[${match[1]}="${match[2]}"]`);
106}
107function getAttributeMap(element) {
108 const res = new Map();
109 const elAttrs = element.attributes;
110 for (let i = 0; i < elAttrs.length; i++) {
111 const attrib = elAttrs.item(i);
112 res.set(attrib.name, attrib.value);
113 }
114 return res;
115}
116const _selfClosingTags = ['br', 'hr', 'input'];
117function stringifyElement(el /** TODO #9100 */) {
118 let result = '';
119 if (ɵgetDOM().isElementNode(el)) {
120 const tagName = el.tagName.toLowerCase();
121 // Opening tag
122 result += `<${tagName}`;
123 // Attributes in an ordered way
124 const attributeMap = getAttributeMap(el);
125 const sortedKeys = Array.from(attributeMap.keys()).sort();
126 for (const key of sortedKeys) {
127 const lowerCaseKey = key.toLowerCase();
128 let attValue = attributeMap.get(key);
129 if (typeof attValue !== 'string') {
130 result += ` ${lowerCaseKey}`;
131 }
132 else {
133 // Browsers order style rules differently. Order them alphabetically for consistency.
134 if (lowerCaseKey === 'style') {
135 attValue = attValue.split(/; ?/).filter(s => !!s).sort().map(s => `${s};`).join(' ');
136 }
137 result += ` ${lowerCaseKey}="${attValue}"`;
138 }
139 }
140 result += '>';
141 // Children
142 const childrenRoot = templateAwareRoot(el);
143 const children = childrenRoot ? childrenRoot.childNodes : [];
144 for (let j = 0; j < children.length; j++) {
145 result += stringifyElement(children[j]);
146 }
147 // Closing tag
148 if (_selfClosingTags.indexOf(tagName) == -1) {
149 result += `</${tagName}>`;
150 }
151 }
152 else if (isCommentNode(el)) {
153 result += `<!--${el.nodeValue}-->`;
154 }
155 else {
156 result += el.textContent;
157 }
158 return result;
159}
160function createNgZone() {
161 return new NgZone({ enableLongStackTrace: true, shouldCoalesceEventChangeDetection: false });
162}
163function isCommentNode(node) {
164 return node.nodeType === Node.COMMENT_NODE;
165}
166function isTextNode(node) {
167 return node.nodeType === Node.TEXT_NODE;
168}
169function getContent(node) {
170 if ('content' in node) {
171 return node.content;
172 }
173 else {
174 return node;
175 }
176}
177function templateAwareRoot(el) {
178 return ɵgetDOM().isElementNode(el) && el.nodeName === 'TEMPLATE' ? getContent(el) : el;
179}
180function setCookie(name, value) {
181 // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
182 // not clear other cookies.
183 document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
184}
185function supportsWebAnimation() {
186 return typeof Element.prototype['animate'] === 'function';
187}
188function hasStyle(element, styleName, styleValue) {
189 const value = element.style[styleName] || '';
190 return styleValue ? value == styleValue : value.length > 0;
191}
192function hasClass(element, className) {
193 return element.classList.contains(className);
194}
195function sortedClassList(element) {
196 return Array.prototype.slice.call(element.classList, 0).sort();
197}
198function createTemplate(html) {
199 const t = ɵgetDOM().getDefaultDocument().createElement('template');
200 t.innerHTML = html;
201 return t;
202}
203function childNodesAsList(el) {
204 const childNodes = el.childNodes;
205 const res = [];
206 for (let i = 0; i < childNodes.length; i++) {
207 res[i] = childNodes[i];
208 }
209 return res;
210}
211
212/**
213 * @license
214 * Copyright Google LLC All Rights Reserved.
215 *
216 * Use of this source code is governed by an MIT-style license that can be
217 * found in the LICENSE file at https://angular.io/license
218 */
219function initBrowserTests() {
220 ɵBrowserDomAdapter.makeCurrent();
221 BrowserDetection.setup();
222}
223const _TEST_BROWSER_PLATFORM_PROVIDERS = [{ provide: PLATFORM_INITIALIZER, useValue: initBrowserTests, multi: true }];
224/**
225 * Platform for testing
226 *
227 * @publicApi
228 */
229const platformBrowserTesting = createPlatformFactory(platformCore, 'browserTesting', _TEST_BROWSER_PLATFORM_PROVIDERS);
230/**
231 * NgModule for testing.
232 *
233 * @publicApi
234 */
235class BrowserTestingModule {
236}
237BrowserTestingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
238BrowserTestingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, exports: [BrowserModule] });
239BrowserTestingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, providers: [
240 { provide: APP_ID, useValue: 'a' },
241 { provide: NgZone, useFactory: createNgZone },
242 ], imports: [BrowserModule] });
243i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: BrowserTestingModule, decorators: [{
244 type: NgModule,
245 args: [{
246 exports: [BrowserModule],
247 providers: [
248 { provide: APP_ID, useValue: 'a' },
249 { provide: NgZone, useFactory: createNgZone },
250 ]
251 }]
252 }] });
253
254/**
255 * @license
256 * Copyright Google LLC All Rights Reserved.
257 *
258 * Use of this source code is governed by an MIT-style license that can be
259 * found in the LICENSE file at https://angular.io/license
260 */
261
262/**
263 * @license
264 * Copyright Google LLC All Rights Reserved.
265 *
266 * Use of this source code is governed by an MIT-style license that can be
267 * found in the LICENSE file at https://angular.io/license
268 */
269
270/**
271 * @license
272 * Copyright Google LLC All Rights Reserved.
273 *
274 * Use of this source code is governed by an MIT-style license that can be
275 * found in the LICENSE file at https://angular.io/license
276 */
277
278/**
279 * Generated bundle index. Do not edit.
280 */
281
282export { BrowserTestingModule, platformBrowserTesting };
283//# sourceMappingURL=testing.mjs.map