1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { ɵgetDOM as getDOM } from '@angular/common';
|
---|
9 | import { NgZone, ɵglobal as global } from '@angular/core';
|
---|
10 | export class BrowserDetection {
|
---|
11 | constructor(ua) {
|
---|
12 | this._overrideUa = ua;
|
---|
13 | }
|
---|
14 | get _ua() {
|
---|
15 | if (typeof this._overrideUa === 'string') {
|
---|
16 | return this._overrideUa;
|
---|
17 | }
|
---|
18 | return getDOM() ? getDOM().getUserAgent() : '';
|
---|
19 | }
|
---|
20 | static setup() {
|
---|
21 | return new BrowserDetection(null);
|
---|
22 | }
|
---|
23 | get isFirefox() {
|
---|
24 | return this._ua.indexOf('Firefox') > -1;
|
---|
25 | }
|
---|
26 | get isAndroid() {
|
---|
27 | return this._ua.indexOf('Mozilla/5.0') > -1 && this._ua.indexOf('Android') > -1 &&
|
---|
28 | this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Chrome') == -1 &&
|
---|
29 | this._ua.indexOf('IEMobile') == -1;
|
---|
30 | }
|
---|
31 | get isEdge() {
|
---|
32 | return this._ua.indexOf('Edge') > -1;
|
---|
33 | }
|
---|
34 | get isIE() {
|
---|
35 | return this._ua.indexOf('Trident') > -1;
|
---|
36 | }
|
---|
37 | get isWebkit() {
|
---|
38 | return this._ua.indexOf('AppleWebKit') > -1 && this._ua.indexOf('Edge') == -1 &&
|
---|
39 | this._ua.indexOf('IEMobile') == -1;
|
---|
40 | }
|
---|
41 | get isIOS7() {
|
---|
42 | return (this._ua.indexOf('iPhone OS 7') > -1 || this._ua.indexOf('iPad OS 7') > -1) &&
|
---|
43 | this._ua.indexOf('IEMobile') == -1;
|
---|
44 | }
|
---|
45 | get isSlow() {
|
---|
46 | return this.isAndroid || this.isIE || this.isIOS7;
|
---|
47 | }
|
---|
48 | get isChromeDesktop() {
|
---|
49 | return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Mobile Safari') == -1 &&
|
---|
50 | this._ua.indexOf('Edge') == -1;
|
---|
51 | }
|
---|
52 | // "Old Chrome" means Chrome 3X, where there are some discrepancies in the Intl API.
|
---|
53 | // Android 4.4 and 5.X have such browsers by default (respectively 30 and 39).
|
---|
54 | get isOldChrome() {
|
---|
55 | return this._ua.indexOf('Chrome') > -1 && this._ua.indexOf('Chrome/3') > -1 &&
|
---|
56 | this._ua.indexOf('Edge') == -1;
|
---|
57 | }
|
---|
58 | get supportsCustomElements() {
|
---|
59 | return (typeof global.customElements !== 'undefined');
|
---|
60 | }
|
---|
61 | get supportsDeprecatedCustomCustomElementsV0() {
|
---|
62 | return (typeof document.registerElement !== 'undefined');
|
---|
63 | }
|
---|
64 | get supportsRegExUnicodeFlag() {
|
---|
65 | return RegExp.prototype.hasOwnProperty('unicode');
|
---|
66 | }
|
---|
67 | get supportsShadowDom() {
|
---|
68 | const testEl = document.createElement('div');
|
---|
69 | return (typeof testEl.attachShadow !== 'undefined');
|
---|
70 | }
|
---|
71 | get supportsDeprecatedShadowDomV0() {
|
---|
72 | const testEl = document.createElement('div');
|
---|
73 | return (typeof testEl.createShadowRoot !== 'undefined');
|
---|
74 | }
|
---|
75 | }
|
---|
76 | export const browserDetection = BrowserDetection.setup();
|
---|
77 | export function dispatchEvent(element, eventType) {
|
---|
78 | const evt = getDOM().getDefaultDocument().createEvent('Event');
|
---|
79 | evt.initEvent(eventType, true, true);
|
---|
80 | getDOM().dispatchEvent(element, evt);
|
---|
81 | }
|
---|
82 | export function createMouseEvent(eventType) {
|
---|
83 | const evt = getDOM().getDefaultDocument().createEvent('MouseEvent');
|
---|
84 | evt.initEvent(eventType, true, true);
|
---|
85 | return evt;
|
---|
86 | }
|
---|
87 | export function el(html) {
|
---|
88 | return getContent(createTemplate(html)).firstChild;
|
---|
89 | }
|
---|
90 | export function normalizeCSS(css) {
|
---|
91 | return css.replace(/\s+/g, ' ')
|
---|
92 | .replace(/:\s/g, ':')
|
---|
93 | .replace(/'/g, '"')
|
---|
94 | .replace(/ }/g, '}')
|
---|
95 | .replace(/url\((\"|\s)(.+)(\"|\s)\)(\s*)/g, (...match) => `url("${match[2]}")`)
|
---|
96 | .replace(/\[(.+)=([^"\]]+)\]/g, (...match) => `[${match[1]}="${match[2]}"]`);
|
---|
97 | }
|
---|
98 | function getAttributeMap(element) {
|
---|
99 | const res = new Map();
|
---|
100 | const elAttrs = element.attributes;
|
---|
101 | for (let i = 0; i < elAttrs.length; i++) {
|
---|
102 | const attrib = elAttrs.item(i);
|
---|
103 | res.set(attrib.name, attrib.value);
|
---|
104 | }
|
---|
105 | return res;
|
---|
106 | }
|
---|
107 | const _selfClosingTags = ['br', 'hr', 'input'];
|
---|
108 | export function stringifyElement(el /** TODO #9100 */) {
|
---|
109 | let result = '';
|
---|
110 | if (getDOM().isElementNode(el)) {
|
---|
111 | const tagName = el.tagName.toLowerCase();
|
---|
112 | // Opening tag
|
---|
113 | result += `<${tagName}`;
|
---|
114 | // Attributes in an ordered way
|
---|
115 | const attributeMap = getAttributeMap(el);
|
---|
116 | const sortedKeys = Array.from(attributeMap.keys()).sort();
|
---|
117 | for (const key of sortedKeys) {
|
---|
118 | const lowerCaseKey = key.toLowerCase();
|
---|
119 | let attValue = attributeMap.get(key);
|
---|
120 | if (typeof attValue !== 'string') {
|
---|
121 | result += ` ${lowerCaseKey}`;
|
---|
122 | }
|
---|
123 | else {
|
---|
124 | // Browsers order style rules differently. Order them alphabetically for consistency.
|
---|
125 | if (lowerCaseKey === 'style') {
|
---|
126 | attValue = attValue.split(/; ?/).filter(s => !!s).sort().map(s => `${s};`).join(' ');
|
---|
127 | }
|
---|
128 | result += ` ${lowerCaseKey}="${attValue}"`;
|
---|
129 | }
|
---|
130 | }
|
---|
131 | result += '>';
|
---|
132 | // Children
|
---|
133 | const childrenRoot = templateAwareRoot(el);
|
---|
134 | const children = childrenRoot ? childrenRoot.childNodes : [];
|
---|
135 | for (let j = 0; j < children.length; j++) {
|
---|
136 | result += stringifyElement(children[j]);
|
---|
137 | }
|
---|
138 | // Closing tag
|
---|
139 | if (_selfClosingTags.indexOf(tagName) == -1) {
|
---|
140 | result += `</${tagName}>`;
|
---|
141 | }
|
---|
142 | }
|
---|
143 | else if (isCommentNode(el)) {
|
---|
144 | result += `<!--${el.nodeValue}-->`;
|
---|
145 | }
|
---|
146 | else {
|
---|
147 | result += el.textContent;
|
---|
148 | }
|
---|
149 | return result;
|
---|
150 | }
|
---|
151 | export function createNgZone() {
|
---|
152 | return new NgZone({ enableLongStackTrace: true, shouldCoalesceEventChangeDetection: false });
|
---|
153 | }
|
---|
154 | export function isCommentNode(node) {
|
---|
155 | return node.nodeType === Node.COMMENT_NODE;
|
---|
156 | }
|
---|
157 | export function isTextNode(node) {
|
---|
158 | return node.nodeType === Node.TEXT_NODE;
|
---|
159 | }
|
---|
160 | export function getContent(node) {
|
---|
161 | if ('content' in node) {
|
---|
162 | return node.content;
|
---|
163 | }
|
---|
164 | else {
|
---|
165 | return node;
|
---|
166 | }
|
---|
167 | }
|
---|
168 | export function templateAwareRoot(el) {
|
---|
169 | return getDOM().isElementNode(el) && el.nodeName === 'TEMPLATE' ? getContent(el) : el;
|
---|
170 | }
|
---|
171 | export function setCookie(name, value) {
|
---|
172 | // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
|
---|
173 | // not clear other cookies.
|
---|
174 | document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
|
---|
175 | }
|
---|
176 | export function supportsWebAnimation() {
|
---|
177 | return typeof Element.prototype['animate'] === 'function';
|
---|
178 | }
|
---|
179 | export function hasStyle(element, styleName, styleValue) {
|
---|
180 | const value = element.style[styleName] || '';
|
---|
181 | return styleValue ? value == styleValue : value.length > 0;
|
---|
182 | }
|
---|
183 | export function hasClass(element, className) {
|
---|
184 | return element.classList.contains(className);
|
---|
185 | }
|
---|
186 | export function sortedClassList(element) {
|
---|
187 | return Array.prototype.slice.call(element.classList, 0).sort();
|
---|
188 | }
|
---|
189 | export function createTemplate(html) {
|
---|
190 | const t = getDOM().getDefaultDocument().createElement('template');
|
---|
191 | t.innerHTML = html;
|
---|
192 | return t;
|
---|
193 | }
|
---|
194 | export function childNodesAsList(el) {
|
---|
195 | const childNodes = el.childNodes;
|
---|
196 | const res = [];
|
---|
197 | for (let i = 0; i < childNodes.length; i++) {
|
---|
198 | res[i] = childNodes[i];
|
---|
199 | }
|
---|
200 | return res;
|
---|
201 | }
|
---|
202 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnJvd3Nlcl91dGlsLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvcGxhdGZvcm0tYnJvd3Nlci90ZXN0aW5nL3NyYy9icm93c2VyX3V0aWwudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUFDLE9BQU8sSUFBSSxNQUFNLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUNsRCxPQUFPLEVBQUMsTUFBTSxFQUFFLE9BQU8sSUFBSSxNQUFNLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFFeEQsTUFBTSxPQUFPLGdCQUFnQjtJQWMzQixZQUFZLEVBQWU7UUFDekIsSUFBSSxDQUFDLFdBQVcsR0FBRyxFQUFFLENBQUM7SUFDeEIsQ0FBQztJQWRELElBQVksR0FBRztRQUNiLElBQUksT0FBTyxJQUFJLENBQUMsV0FBVyxLQUFLLFFBQVEsRUFBRTtZQUN4QyxPQUFPLElBQUksQ0FBQyxXQUFXLENBQUM7U0FDekI7UUFFRCxPQUFPLE1BQU0sRUFBRSxDQUFDLENBQUMsQ0FBQyxNQUFNLEVBQUUsQ0FBQyxZQUFZLEVBQUUsQ0FBQyxDQUFDLENBQUMsRUF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