platform-browser.js 102 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538
  1. /**
  2. * @license Angular v8.1.3
  3. * (c) 2010-2019 Google LLC. https://angular.io/
  4. * License: MIT
  5. */
  6. import { __extends, __spread, __decorate, __param, __metadata, __assign } from 'tslib';
  7. import { ɵparseCookieValue, DOCUMENT, PlatformLocation, isPlatformServer, CommonModule, ɵPLATFORM_BROWSER_ID } from '@angular/common';
  8. import { ɵglobal, Injectable, Inject, InjectionToken, ApplicationInitStatus, APP_INITIALIZER, Injector, setTestabilityGetter, NgProbeToken, Optional, ApplicationRef, NgZone, getDebugNode, ViewEncapsulation, APP_ID, RendererStyleFlags2, PLATFORM_ID, ɵConsole, SecurityContext, ɵ_sanitizeHtml, ɵ_sanitizeStyle, ɵ_sanitizeUrl, PLATFORM_INITIALIZER, Sanitizer, createPlatformFactory, platformCore, ErrorHandler, ɵAPP_ROOT, RendererFactory2, Testability, NgModule, ApplicationModule, SkipSelf, ɵɵinject, ɵɵdefineInjectable, Version } from '@angular/core';
  9. /**
  10. * @license
  11. * Copyright Google Inc. All Rights Reserved.
  12. *
  13. * Use of this source code is governed by an MIT-style license that can be
  14. * found in the LICENSE file at https://angular.io/license
  15. */
  16. var _DOM = null;
  17. function getDOM() {
  18. return _DOM;
  19. }
  20. function setRootDomAdapter(adapter) {
  21. if (!_DOM) {
  22. _DOM = adapter;
  23. }
  24. }
  25. /* tslint:disable:requireParameterType */
  26. /**
  27. * Provides DOM operations in an environment-agnostic way.
  28. *
  29. * @security Tread carefully! Interacting with the DOM directly is dangerous and
  30. * can introduce XSS risks.
  31. */
  32. var DomAdapter = /** @class */ (function () {
  33. function DomAdapter() {
  34. this.resourceLoaderType = null;
  35. }
  36. Object.defineProperty(DomAdapter.prototype, "attrToPropMap", {
  37. /**
  38. * Maps attribute names to their corresponding property names for cases
  39. * where attribute name doesn't match property name.
  40. */
  41. get: function () { return this._attrToPropMap; },
  42. set: function (value) { this._attrToPropMap = value; },
  43. enumerable: true,
  44. configurable: true
  45. });
  46. return DomAdapter;
  47. }());
  48. /**
  49. * @license
  50. * Copyright Google Inc. All Rights Reserved.
  51. *
  52. * Use of this source code is governed by an MIT-style license that can be
  53. * found in the LICENSE file at https://angular.io/license
  54. */
  55. /**
  56. * Provides DOM operations in any browser environment.
  57. *
  58. * @security Tread carefully! Interacting with the DOM directly is dangerous and
  59. * can introduce XSS risks.
  60. */
  61. var GenericBrowserDomAdapter = /** @class */ (function (_super) {
  62. __extends(GenericBrowserDomAdapter, _super);
  63. function GenericBrowserDomAdapter() {
  64. var _this = _super.call(this) || this;
  65. _this._animationPrefix = null;
  66. _this._transitionEnd = null;
  67. try {
  68. var element_1 = _this.createElement('div', document);
  69. if (_this.getStyle(element_1, 'animationName') != null) {
  70. _this._animationPrefix = '';
  71. }
  72. else {
  73. var domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
  74. for (var i = 0; i < domPrefixes.length; i++) {
  75. if (_this.getStyle(element_1, domPrefixes[i] + 'AnimationName') != null) {
  76. _this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
  77. break;
  78. }
  79. }
  80. }
  81. var transEndEventNames_1 = {
  82. WebkitTransition: 'webkitTransitionEnd',
  83. MozTransition: 'transitionend',
  84. OTransition: 'oTransitionEnd otransitionend',
  85. transition: 'transitionend'
  86. };
  87. Object.keys(transEndEventNames_1).forEach(function (key) {
  88. if (_this.getStyle(element_1, key) != null) {
  89. _this._transitionEnd = transEndEventNames_1[key];
  90. }
  91. });
  92. }
  93. catch (_a) {
  94. _this._animationPrefix = null;
  95. _this._transitionEnd = null;
  96. }
  97. return _this;
  98. }
  99. GenericBrowserDomAdapter.prototype.getDistributedNodes = function (el) { return el.getDistributedNodes(); };
  100. GenericBrowserDomAdapter.prototype.resolveAndSetHref = function (el, baseUrl, href) {
  101. el.href = href == null ? baseUrl : baseUrl + '/../' + href;
  102. };
  103. GenericBrowserDomAdapter.prototype.supportsDOMEvents = function () { return true; };
  104. GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = function () {
  105. return typeof document.body.createShadowRoot === 'function';
  106. };
  107. GenericBrowserDomAdapter.prototype.getAnimationPrefix = function () { return this._animationPrefix ? this._animationPrefix : ''; };
  108. GenericBrowserDomAdapter.prototype.getTransitionEnd = function () { return this._transitionEnd ? this._transitionEnd : ''; };
  109. GenericBrowserDomAdapter.prototype.supportsAnimation = function () {
  110. return this._animationPrefix != null && this._transitionEnd != null;
  111. };
  112. return GenericBrowserDomAdapter;
  113. }(DomAdapter));
  114. /**
  115. * @license
  116. * Copyright Google Inc. All Rights Reserved.
  117. *
  118. * Use of this source code is governed by an MIT-style license that can be
  119. * found in the LICENSE file at https://angular.io/license
  120. */
  121. var _attrToPropMap = {
  122. 'class': 'className',
  123. 'innerHtml': 'innerHTML',
  124. 'readonly': 'readOnly',
  125. 'tabindex': 'tabIndex',
  126. };
  127. var DOM_KEY_LOCATION_NUMPAD = 3;
  128. // Map to convert some key or keyIdentifier values to what will be returned by getEventKey
  129. var _keyMap = {
  130. // The following values are here for cross-browser compatibility and to match the W3C standard
  131. // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
  132. '\b': 'Backspace',
  133. '\t': 'Tab',
  134. '\x7F': 'Delete',
  135. '\x1B': 'Escape',
  136. 'Del': 'Delete',
  137. 'Esc': 'Escape',
  138. 'Left': 'ArrowLeft',
  139. 'Right': 'ArrowRight',
  140. 'Up': 'ArrowUp',
  141. 'Down': 'ArrowDown',
  142. 'Menu': 'ContextMenu',
  143. 'Scroll': 'ScrollLock',
  144. 'Win': 'OS'
  145. };
  146. // There is a bug in Chrome for numeric keypad keys:
  147. // https://code.google.com/p/chromium/issues/detail?id=155654
  148. // 1, 2, 3 ... are reported as A, B, C ...
  149. var _chromeNumKeyPadMap = {
  150. 'A': '1',
  151. 'B': '2',
  152. 'C': '3',
  153. 'D': '4',
  154. 'E': '5',
  155. 'F': '6',
  156. 'G': '7',
  157. 'H': '8',
  158. 'I': '9',
  159. 'J': '*',
  160. 'K': '+',
  161. 'M': '-',
  162. 'N': '.',
  163. 'O': '/',
  164. '\x60': '0',
  165. '\x90': 'NumLock'
  166. };
  167. var ɵ0 = function () {
  168. if (ɵglobal['Node']) {
  169. return ɵglobal['Node'].prototype.contains || function (node) {
  170. return !!(this.compareDocumentPosition(node) & 16);
  171. };
  172. }
  173. return undefined;
  174. };
  175. var nodeContains = (ɵ0)();
  176. /**
  177. * A `DomAdapter` powered by full browser DOM APIs.
  178. *
  179. * @security Tread carefully! Interacting with the DOM directly is dangerous and
  180. * can introduce XSS risks.
  181. */
  182. /* tslint:disable:requireParameterType no-console */
  183. var BrowserDomAdapter = /** @class */ (function (_super) {
  184. __extends(BrowserDomAdapter, _super);
  185. function BrowserDomAdapter() {
  186. return _super !== null && _super.apply(this, arguments) || this;
  187. }
  188. BrowserDomAdapter.prototype.parse = function (templateHtml) { throw new Error('parse not implemented'); };
  189. BrowserDomAdapter.makeCurrent = function () { setRootDomAdapter(new BrowserDomAdapter()); };
  190. BrowserDomAdapter.prototype.hasProperty = function (element, name) { return name in element; };
  191. BrowserDomAdapter.prototype.setProperty = function (el, name, value) { el[name] = value; };
  192. BrowserDomAdapter.prototype.getProperty = function (el, name) { return el[name]; };
  193. BrowserDomAdapter.prototype.invoke = function (el, methodName, args) {
  194. var _a;
  195. (_a = el)[methodName].apply(_a, __spread(args));
  196. };
  197. // TODO(tbosch): move this into a separate environment class once we have it
  198. BrowserDomAdapter.prototype.logError = function (error) {
  199. if (window.console) {
  200. if (console.error) {
  201. console.error(error);
  202. }
  203. else {
  204. console.log(error);
  205. }
  206. }
  207. };
  208. BrowserDomAdapter.prototype.log = function (error) {
  209. if (window.console) {
  210. window.console.log && window.console.log(error);
  211. }
  212. };
  213. BrowserDomAdapter.prototype.logGroup = function (error) {
  214. if (window.console) {
  215. window.console.group && window.console.group(error);
  216. }
  217. };
  218. BrowserDomAdapter.prototype.logGroupEnd = function () {
  219. if (window.console) {
  220. window.console.groupEnd && window.console.groupEnd();
  221. }
  222. };
  223. Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
  224. get: function () { return _attrToPropMap; },
  225. enumerable: true,
  226. configurable: true
  227. });
  228. BrowserDomAdapter.prototype.contains = function (nodeA, nodeB) { return nodeContains.call(nodeA, nodeB); };
  229. BrowserDomAdapter.prototype.querySelector = function (el, selector) { return el.querySelector(selector); };
  230. BrowserDomAdapter.prototype.querySelectorAll = function (el, selector) { return el.querySelectorAll(selector); };
  231. BrowserDomAdapter.prototype.on = function (el, evt, listener) { el.addEventListener(evt, listener, false); };
  232. BrowserDomAdapter.prototype.onAndCancel = function (el, evt, listener) {
  233. el.addEventListener(evt, listener, false);
  234. // Needed to follow Dart's subscription semantic, until fix of
  235. // https://code.google.com/p/dart/issues/detail?id=17406
  236. return function () { el.removeEventListener(evt, listener, false); };
  237. };
  238. BrowserDomAdapter.prototype.dispatchEvent = function (el, evt) { el.dispatchEvent(evt); };
  239. BrowserDomAdapter.prototype.createMouseEvent = function (eventType) {
  240. var evt = this.getDefaultDocument().createEvent('MouseEvent');
  241. evt.initEvent(eventType, true, true);
  242. return evt;
  243. };
  244. BrowserDomAdapter.prototype.createEvent = function (eventType) {
  245. var evt = this.getDefaultDocument().createEvent('Event');
  246. evt.initEvent(eventType, true, true);
  247. return evt;
  248. };
  249. BrowserDomAdapter.prototype.preventDefault = function (evt) {
  250. evt.preventDefault();
  251. evt.returnValue = false;
  252. };
  253. BrowserDomAdapter.prototype.isPrevented = function (evt) {
  254. return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
  255. };
  256. BrowserDomAdapter.prototype.getInnerHTML = function (el) { return el.innerHTML; };
  257. BrowserDomAdapter.prototype.getTemplateContent = function (el) {
  258. return 'content' in el && this.isTemplateElement(el) ? el.content : null;
  259. };
  260. BrowserDomAdapter.prototype.getOuterHTML = function (el) { return el.outerHTML; };
  261. BrowserDomAdapter.prototype.nodeName = function (node) { return node.nodeName; };
  262. BrowserDomAdapter.prototype.nodeValue = function (node) { return node.nodeValue; };
  263. BrowserDomAdapter.prototype.type = function (node) { return node.type; };
  264. BrowserDomAdapter.prototype.content = function (node) {
  265. if (this.hasProperty(node, 'content')) {
  266. return node.content;
  267. }
  268. else {
  269. return node;
  270. }
  271. };
  272. BrowserDomAdapter.prototype.firstChild = function (el) { return el.firstChild; };
  273. BrowserDomAdapter.prototype.nextSibling = function (el) { return el.nextSibling; };
  274. BrowserDomAdapter.prototype.parentElement = function (el) { return el.parentNode; };
  275. BrowserDomAdapter.prototype.childNodes = function (el) { return el.childNodes; };
  276. BrowserDomAdapter.prototype.childNodesAsList = function (el) {
  277. var childNodes = el.childNodes;
  278. var res = new Array(childNodes.length);
  279. for (var i = 0; i < childNodes.length; i++) {
  280. res[i] = childNodes[i];
  281. }
  282. return res;
  283. };
  284. BrowserDomAdapter.prototype.clearNodes = function (el) {
  285. while (el.firstChild) {
  286. el.removeChild(el.firstChild);
  287. }
  288. };
  289. BrowserDomAdapter.prototype.appendChild = function (el, node) { el.appendChild(node); };
  290. BrowserDomAdapter.prototype.removeChild = function (el, node) { el.removeChild(node); };
  291. BrowserDomAdapter.prototype.replaceChild = function (el, newChild, oldChild) { el.replaceChild(newChild, oldChild); };
  292. BrowserDomAdapter.prototype.remove = function (node) {
  293. if (node.parentNode) {
  294. node.parentNode.removeChild(node);
  295. }
  296. return node;
  297. };
  298. BrowserDomAdapter.prototype.insertBefore = function (parent, ref, node) { parent.insertBefore(node, ref); };
  299. BrowserDomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) {
  300. nodes.forEach(function (n) { return parent.insertBefore(n, ref); });
  301. };
  302. BrowserDomAdapter.prototype.insertAfter = function (parent, ref, node) { parent.insertBefore(node, ref.nextSibling); };
  303. BrowserDomAdapter.prototype.setInnerHTML = function (el, value) { el.innerHTML = value; };
  304. BrowserDomAdapter.prototype.getText = function (el) { return el.textContent; };
  305. BrowserDomAdapter.prototype.setText = function (el, value) { el.textContent = value; };
  306. BrowserDomAdapter.prototype.getValue = function (el) { return el.value; };
  307. BrowserDomAdapter.prototype.setValue = function (el, value) { el.value = value; };
  308. BrowserDomAdapter.prototype.getChecked = function (el) { return el.checked; };
  309. BrowserDomAdapter.prototype.setChecked = function (el, value) { el.checked = value; };
  310. BrowserDomAdapter.prototype.createComment = function (text) { return this.getDefaultDocument().createComment(text); };
  311. BrowserDomAdapter.prototype.createTemplate = function (html) {
  312. var t = this.getDefaultDocument().createElement('template');
  313. t.innerHTML = html;
  314. return t;
  315. };
  316. BrowserDomAdapter.prototype.createElement = function (tagName, doc) {
  317. doc = doc || this.getDefaultDocument();
  318. return doc.createElement(tagName);
  319. };
  320. BrowserDomAdapter.prototype.createElementNS = function (ns, tagName, doc) {
  321. doc = doc || this.getDefaultDocument();
  322. return doc.createElementNS(ns, tagName);
  323. };
  324. BrowserDomAdapter.prototype.createTextNode = function (text, doc) {
  325. doc = doc || this.getDefaultDocument();
  326. return doc.createTextNode(text);
  327. };
  328. BrowserDomAdapter.prototype.createScriptTag = function (attrName, attrValue, doc) {
  329. doc = doc || this.getDefaultDocument();
  330. var el = doc.createElement('SCRIPT');
  331. el.setAttribute(attrName, attrValue);
  332. return el;
  333. };
  334. BrowserDomAdapter.prototype.createStyleElement = function (css, doc) {
  335. doc = doc || this.getDefaultDocument();
  336. var style = doc.createElement('style');
  337. this.appendChild(style, this.createTextNode(css, doc));
  338. return style;
  339. };
  340. BrowserDomAdapter.prototype.createShadowRoot = function (el) { return el.createShadowRoot(); };
  341. BrowserDomAdapter.prototype.getShadowRoot = function (el) { return el.shadowRoot; };
  342. BrowserDomAdapter.prototype.getHost = function (el) { return el.host; };
  343. BrowserDomAdapter.prototype.clone = function (node) { return node.cloneNode(true); };
  344. BrowserDomAdapter.prototype.getElementsByClassName = function (element, name) {
  345. return element.getElementsByClassName(name);
  346. };
  347. BrowserDomAdapter.prototype.getElementsByTagName = function (element, name) {
  348. return element.getElementsByTagName(name);
  349. };
  350. BrowserDomAdapter.prototype.classList = function (element) { return Array.prototype.slice.call(element.classList, 0); };
  351. BrowserDomAdapter.prototype.addClass = function (element, className) { element.classList.add(className); };
  352. BrowserDomAdapter.prototype.removeClass = function (element, className) { element.classList.remove(className); };
  353. BrowserDomAdapter.prototype.hasClass = function (element, className) {
  354. return element.classList.contains(className);
  355. };
  356. BrowserDomAdapter.prototype.setStyle = function (element, styleName, styleValue) {
  357. element.style[styleName] = styleValue;
  358. };
  359. BrowserDomAdapter.prototype.removeStyle = function (element, stylename) {
  360. // IE requires '' instead of null
  361. // see https://github.com/angular/angular/issues/7916
  362. element.style[stylename] = '';
  363. };
  364. BrowserDomAdapter.prototype.getStyle = function (element, stylename) { return element.style[stylename]; };
  365. BrowserDomAdapter.prototype.hasStyle = function (element, styleName, styleValue) {
  366. var value = this.getStyle(element, styleName) || '';
  367. return styleValue ? value == styleValue : value.length > 0;
  368. };
  369. BrowserDomAdapter.prototype.tagName = function (element) { return element.tagName; };
  370. BrowserDomAdapter.prototype.attributeMap = function (element) {
  371. var res = new Map();
  372. var elAttrs = element.attributes;
  373. for (var i = 0; i < elAttrs.length; i++) {
  374. var attrib = elAttrs.item(i);
  375. res.set(attrib.name, attrib.value);
  376. }
  377. return res;
  378. };
  379. BrowserDomAdapter.prototype.hasAttribute = function (element, attribute) {
  380. return element.hasAttribute(attribute);
  381. };
  382. BrowserDomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) {
  383. return element.hasAttributeNS(ns, attribute);
  384. };
  385. BrowserDomAdapter.prototype.getAttribute = function (element, attribute) {
  386. return element.getAttribute(attribute);
  387. };
  388. BrowserDomAdapter.prototype.getAttributeNS = function (element, ns, name) {
  389. return element.getAttributeNS(ns, name);
  390. };
  391. BrowserDomAdapter.prototype.setAttribute = function (element, name, value) { element.setAttribute(name, value); };
  392. BrowserDomAdapter.prototype.setAttributeNS = function (element, ns, name, value) {
  393. element.setAttributeNS(ns, name, value);
  394. };
  395. BrowserDomAdapter.prototype.removeAttribute = function (element, attribute) { element.removeAttribute(attribute); };
  396. BrowserDomAdapter.prototype.removeAttributeNS = function (element, ns, name) {
  397. element.removeAttributeNS(ns, name);
  398. };
  399. BrowserDomAdapter.prototype.templateAwareRoot = function (el) { return this.isTemplateElement(el) ? this.content(el) : el; };
  400. BrowserDomAdapter.prototype.createHtmlDocument = function () {
  401. return document.implementation.createHTMLDocument('fakeTitle');
  402. };
  403. BrowserDomAdapter.prototype.getDefaultDocument = function () { return document; };
  404. BrowserDomAdapter.prototype.getBoundingClientRect = function (el) {
  405. try {
  406. return el.getBoundingClientRect();
  407. }
  408. catch (_a) {
  409. return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
  410. }
  411. };
  412. BrowserDomAdapter.prototype.getTitle = function (doc) { return doc.title; };
  413. BrowserDomAdapter.prototype.setTitle = function (doc, newTitle) { doc.title = newTitle || ''; };
  414. BrowserDomAdapter.prototype.elementMatches = function (n, selector) {
  415. if (this.isElementNode(n)) {
  416. return n.matches && n.matches(selector) ||
  417. n.msMatchesSelector && n.msMatchesSelector(selector) ||
  418. n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
  419. }
  420. return false;
  421. };
  422. BrowserDomAdapter.prototype.isTemplateElement = function (el) {
  423. return this.isElementNode(el) && el.nodeName === 'TEMPLATE';
  424. };
  425. BrowserDomAdapter.prototype.isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
  426. BrowserDomAdapter.prototype.isCommentNode = function (node) { return node.nodeType === Node.COMMENT_NODE; };
  427. BrowserDomAdapter.prototype.isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
  428. BrowserDomAdapter.prototype.hasShadowRoot = function (node) {
  429. return node.shadowRoot != null && node instanceof HTMLElement;
  430. };
  431. BrowserDomAdapter.prototype.isShadowRoot = function (node) { return node instanceof DocumentFragment; };
  432. BrowserDomAdapter.prototype.importIntoDoc = function (node) { return document.importNode(this.templateAwareRoot(node), true); };
  433. BrowserDomAdapter.prototype.adoptNode = function (node) { return document.adoptNode(node); };
  434. BrowserDomAdapter.prototype.getHref = function (el) { return el.getAttribute('href'); };
  435. BrowserDomAdapter.prototype.getEventKey = function (event) {
  436. var key = event.key;
  437. if (key == null) {
  438. key = event.keyIdentifier;
  439. // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
  440. // Safari cf
  441. // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
  442. if (key == null) {
  443. return 'Unidentified';
  444. }
  445. if (key.startsWith('U+')) {
  446. key = String.fromCharCode(parseInt(key.substring(2), 16));
  447. if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
  448. // There is a bug in Chrome for numeric keypad keys:
  449. // https://code.google.com/p/chromium/issues/detail?id=155654
  450. // 1, 2, 3 ... are reported as A, B, C ...
  451. key = _chromeNumKeyPadMap[key];
  452. }
  453. }
  454. }
  455. return _keyMap[key] || key;
  456. };
  457. BrowserDomAdapter.prototype.getGlobalEventTarget = function (doc, target) {
  458. if (target === 'window') {
  459. return window;
  460. }
  461. if (target === 'document') {
  462. return doc;
  463. }
  464. if (target === 'body') {
  465. return doc.body;
  466. }
  467. return null;
  468. };
  469. BrowserDomAdapter.prototype.getHistory = function () { return window.history; };
  470. BrowserDomAdapter.prototype.getLocation = function () { return window.location; };
  471. BrowserDomAdapter.prototype.getBaseHref = function (doc) {
  472. var href = getBaseElementHref();
  473. return href == null ? null : relativePath(href);
  474. };
  475. BrowserDomAdapter.prototype.resetBaseElement = function () { baseElement = null; };
  476. BrowserDomAdapter.prototype.getUserAgent = function () { return window.navigator.userAgent; };
  477. BrowserDomAdapter.prototype.setData = function (element, name, value) {
  478. this.setAttribute(element, 'data-' + name, value);
  479. };
  480. BrowserDomAdapter.prototype.getData = function (element, name) {
  481. return this.getAttribute(element, 'data-' + name);
  482. };
  483. BrowserDomAdapter.prototype.getComputedStyle = function (element) { return getComputedStyle(element); };
  484. // TODO(tbosch): move this into a separate environment class once we have it
  485. BrowserDomAdapter.prototype.supportsWebAnimation = function () {
  486. return typeof Element.prototype['animate'] === 'function';
  487. };
  488. BrowserDomAdapter.prototype.performanceNow = function () {
  489. // performance.now() is not available in all browsers, see
  490. // http://caniuse.com/#search=performance.now
  491. return window.performance && window.performance.now ? window.performance.now() :
  492. new Date().getTime();
  493. };
  494. BrowserDomAdapter.prototype.supportsCookies = function () { return true; };
  495. BrowserDomAdapter.prototype.getCookie = function (name) { return ɵparseCookieValue(document.cookie, name); };
  496. BrowserDomAdapter.prototype.setCookie = function (name, value) {
  497. // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
  498. // not clear other cookies.
  499. document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
  500. };
  501. return BrowserDomAdapter;
  502. }(GenericBrowserDomAdapter));
  503. var baseElement = null;
  504. function getBaseElementHref() {
  505. if (!baseElement) {
  506. baseElement = document.querySelector('base');
  507. if (!baseElement) {
  508. return null;
  509. }
  510. }
  511. return baseElement.getAttribute('href');
  512. }
  513. // based on urlUtils.js in AngularJS 1
  514. var urlParsingNode;
  515. function relativePath(url) {
  516. if (!urlParsingNode) {
  517. urlParsingNode = document.createElement('a');
  518. }
  519. urlParsingNode.setAttribute('href', url);
  520. return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
  521. '/' + urlParsingNode.pathname;
  522. }
  523. /**
  524. * @license
  525. * Copyright Google Inc. All Rights Reserved.
  526. *
  527. * Use of this source code is governed by an MIT-style license that can be
  528. * found in the LICENSE file at https://angular.io/license
  529. */
  530. function supportsState() {
  531. return !!window.history.pushState;
  532. }
  533. /**
  534. * @license
  535. * Copyright Google Inc. All Rights Reserved.
  536. *
  537. * Use of this source code is governed by an MIT-style license that can be
  538. * found in the LICENSE file at https://angular.io/license
  539. */
  540. /**
  541. * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
  542. * This class should not be used directly by an application developer. Instead, use
  543. * {@link Location}.
  544. */
  545. var BrowserPlatformLocation = /** @class */ (function (_super) {
  546. __extends(BrowserPlatformLocation, _super);
  547. function BrowserPlatformLocation(_doc) {
  548. var _this = _super.call(this) || this;
  549. _this._doc = _doc;
  550. _this._init();
  551. return _this;
  552. }
  553. // This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
  554. /** @internal */
  555. BrowserPlatformLocation.prototype._init = function () {
  556. this.location = getDOM().getLocation();
  557. this._history = getDOM().getHistory();
  558. };
  559. BrowserPlatformLocation.prototype.getBaseHrefFromDOM = function () { return getDOM().getBaseHref(this._doc); };
  560. BrowserPlatformLocation.prototype.onPopState = function (fn) {
  561. getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('popstate', fn, false);
  562. };
  563. BrowserPlatformLocation.prototype.onHashChange = function (fn) {
  564. getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('hashchange', fn, false);
  565. };
  566. Object.defineProperty(BrowserPlatformLocation.prototype, "href", {
  567. get: function () { return this.location.href; },
  568. enumerable: true,
  569. configurable: true
  570. });
  571. Object.defineProperty(BrowserPlatformLocation.prototype, "protocol", {
  572. get: function () { return this.location.protocol; },
  573. enumerable: true,
  574. configurable: true
  575. });
  576. Object.defineProperty(BrowserPlatformLocation.prototype, "hostname", {
  577. get: function () { return this.location.hostname; },
  578. enumerable: true,
  579. configurable: true
  580. });
  581. Object.defineProperty(BrowserPlatformLocation.prototype, "port", {
  582. get: function () { return this.location.port; },
  583. enumerable: true,
  584. configurable: true
  585. });
  586. Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
  587. get: function () { return this.location.pathname; },
  588. set: function (newPath) { this.location.pathname = newPath; },
  589. enumerable: true,
  590. configurable: true
  591. });
  592. Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
  593. get: function () { return this.location.search; },
  594. enumerable: true,
  595. configurable: true
  596. });
  597. Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
  598. get: function () { return this.location.hash; },
  599. enumerable: true,
  600. configurable: true
  601. });
  602. BrowserPlatformLocation.prototype.pushState = function (state, title, url) {
  603. if (supportsState()) {
  604. this._history.pushState(state, title, url);
  605. }
  606. else {
  607. this.location.hash = url;
  608. }
  609. };
  610. BrowserPlatformLocation.prototype.replaceState = function (state, title, url) {
  611. if (supportsState()) {
  612. this._history.replaceState(state, title, url);
  613. }
  614. else {
  615. this.location.hash = url;
  616. }
  617. };
  618. BrowserPlatformLocation.prototype.forward = function () { this._history.forward(); };
  619. BrowserPlatformLocation.prototype.back = function () { this._history.back(); };
  620. BrowserPlatformLocation.prototype.getState = function () { return this._history.state; };
  621. BrowserPlatformLocation = __decorate([
  622. Injectable(),
  623. __param(0, Inject(DOCUMENT)),
  624. __metadata("design:paramtypes", [Object])
  625. ], BrowserPlatformLocation);
  626. return BrowserPlatformLocation;
  627. }(PlatformLocation));
  628. /**
  629. * @license
  630. * Copyright Google Inc. All Rights Reserved.
  631. *
  632. * Use of this source code is governed by an MIT-style license that can be
  633. * found in the LICENSE file at https://angular.io/license
  634. */
  635. /**
  636. * An id that identifies a particular application being bootstrapped, that should
  637. * match across the client/server boundary.
  638. */
  639. var TRANSITION_ID = new InjectionToken('TRANSITION_ID');
  640. function appInitializerFactory(transitionId, document, injector) {
  641. return function () {
  642. // Wait for all application initializers to be completed before removing the styles set by
  643. // the server.
  644. injector.get(ApplicationInitStatus).donePromise.then(function () {
  645. var dom = getDOM();
  646. var styles = Array.prototype.slice.apply(dom.querySelectorAll(document, "style[ng-transition]"));
  647. styles.filter(function (el) { return dom.getAttribute(el, 'ng-transition') === transitionId; })
  648. .forEach(function (el) { return dom.remove(el); });
  649. });
  650. };
  651. }
  652. var SERVER_TRANSITION_PROVIDERS = [
  653. {
  654. provide: APP_INITIALIZER,
  655. useFactory: appInitializerFactory,
  656. deps: [TRANSITION_ID, DOCUMENT, Injector],
  657. multi: true
  658. },
  659. ];
  660. /**
  661. * @license
  662. * Copyright Google Inc. All Rights Reserved.
  663. *
  664. * Use of this source code is governed by an MIT-style license that can be
  665. * found in the LICENSE file at https://angular.io/license
  666. */
  667. var BrowserGetTestability = /** @class */ (function () {
  668. function BrowserGetTestability() {
  669. }
  670. BrowserGetTestability.init = function () { setTestabilityGetter(new BrowserGetTestability()); };
  671. BrowserGetTestability.prototype.addToWindow = function (registry) {
  672. ɵglobal['getAngularTestability'] = function (elem, findInAncestors) {
  673. if (findInAncestors === void 0) { findInAncestors = true; }
  674. var testability = registry.findTestabilityInTree(elem, findInAncestors);
  675. if (testability == null) {
  676. throw new Error('Could not find testability for element.');
  677. }
  678. return testability;
  679. };
  680. ɵglobal['getAllAngularTestabilities'] = function () { return registry.getAllTestabilities(); };
  681. ɵglobal['getAllAngularRootElements'] = function () { return registry.getAllRootElements(); };
  682. var whenAllStable = function (callback /** TODO #9100 */) {
  683. var testabilities = ɵglobal['getAllAngularTestabilities']();
  684. var count = testabilities.length;
  685. var didWork = false;
  686. var decrement = function (didWork_ /** TODO #9100 */) {
  687. didWork = didWork || didWork_;
  688. count--;
  689. if (count == 0) {
  690. callback(didWork);
  691. }
  692. };
  693. testabilities.forEach(function (testability /** TODO #9100 */) {
  694. testability.whenStable(decrement);
  695. });
  696. };
  697. if (!ɵglobal['frameworkStabilizers']) {
  698. ɵglobal['frameworkStabilizers'] = [];
  699. }
  700. ɵglobal['frameworkStabilizers'].push(whenAllStable);
  701. };
  702. BrowserGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
  703. if (elem == null) {
  704. return null;
  705. }
  706. var t = registry.getTestability(elem);
  707. if (t != null) {
  708. return t;
  709. }
  710. else if (!findInAncestors) {
  711. return null;
  712. }
  713. if (getDOM().isShadowRoot(elem)) {
  714. return this.findTestabilityInTree(registry, getDOM().getHost(elem), true);
  715. }
  716. return this.findTestabilityInTree(registry, getDOM().parentElement(elem), true);
  717. };
  718. return BrowserGetTestability;
  719. }());
  720. /**
  721. * @license
  722. * Copyright Google Inc. All Rights Reserved.
  723. *
  724. * Use of this source code is governed by an MIT-style license that can be
  725. * found in the LICENSE file at https://angular.io/license
  726. */
  727. /**
  728. * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
  729. * `name` is `'probe'`.
  730. * @param name Name under which it will be exported. Keep in mind this will be a property of the
  731. * global `ng` object.
  732. * @param value The value to export.
  733. */
  734. function exportNgVar(name, value) {
  735. if (typeof COMPILED === 'undefined' || !COMPILED) {
  736. // Note: we can't export `ng` when using closure enhanced optimization as:
  737. // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
  738. // - we can't declare a closure extern as the namespace `ng` is already used within Google
  739. // for typings for angularJS (via `goog.provide('ng....')`).
  740. var ng = ɵglobal['ng'] = ɵglobal['ng'] || {};
  741. ng[name] = value;
  742. }
  743. }
  744. /**
  745. * @license
  746. * Copyright Google Inc. All Rights Reserved.
  747. *
  748. * Use of this source code is governed by an MIT-style license that can be
  749. * found in the LICENSE file at https://angular.io/license
  750. */
  751. var ɵ0$1 = function () { return ({
  752. 'ApplicationRef': ApplicationRef,
  753. 'NgZone': NgZone,
  754. }); };
  755. var CORE_TOKENS = (ɵ0$1)();
  756. var INSPECT_GLOBAL_NAME = 'probe';
  757. var CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
  758. /**
  759. * Returns a {@link DebugElement} for the given native DOM element, or
  760. * null if the given native element does not have an Angular view associated
  761. * with it.
  762. */
  763. function inspectNativeElement(element) {
  764. return getDebugNode(element);
  765. }
  766. function _createNgProbe(coreTokens) {
  767. exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
  768. exportNgVar(CORE_TOKENS_GLOBAL_NAME, __assign({}, CORE_TOKENS, _ngProbeTokensToMap(coreTokens || [])));
  769. return function () { return inspectNativeElement; };
  770. }
  771. function _ngProbeTokensToMap(tokens) {
  772. return tokens.reduce(function (prev, t) { return (prev[t.name] = t.token, prev); }, {});
  773. }
  774. /**
  775. * In Ivy, we don't support NgProbe because we have our own set of testing utilities
  776. * with more robust functionality.
  777. *
  778. * We shouldn't bring in NgProbe because it prevents DebugNode and friends from
  779. * tree-shaking properly.
  780. */
  781. var ELEMENT_PROBE_PROVIDERS__POST_R3__ = [];
  782. /**
  783. * Providers which support debugging Angular applications (e.g. via `ng.probe`).
  784. */
  785. var ELEMENT_PROBE_PROVIDERS__PRE_R3__ = [
  786. {
  787. provide: APP_INITIALIZER,
  788. useFactory: _createNgProbe,
  789. deps: [
  790. [NgProbeToken, new Optional()],
  791. ],
  792. multi: true,
  793. },
  794. ];
  795. var ELEMENT_PROBE_PROVIDERS = ELEMENT_PROBE_PROVIDERS__PRE_R3__;
  796. /**
  797. * @license
  798. * Copyright Google Inc. All Rights Reserved.
  799. *
  800. * Use of this source code is governed by an MIT-style license that can be
  801. * found in the LICENSE file at https://angular.io/license
  802. */
  803. /**
  804. * The injection token for the event-manager plug-in service.
  805. *
  806. * @publicApi
  807. */
  808. var EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
  809. /**
  810. * An injectable service that provides event management for Angular
  811. * through a browser plug-in.
  812. *
  813. * @publicApi
  814. */
  815. var EventManager = /** @class */ (function () {
  816. /**
  817. * Initializes an instance of the event-manager service.
  818. */
  819. function EventManager(plugins, _zone) {
  820. var _this = this;
  821. this._zone = _zone;
  822. this._eventNameToPlugin = new Map();
  823. plugins.forEach(function (p) { return p.manager = _this; });
  824. this._plugins = plugins.slice().reverse();
  825. }
  826. /**
  827. * Registers a handler for a specific element and event.
  828. *
  829. * @param element The HTML element to receive event notifications.
  830. * @param eventName The name of the event to listen for.
  831. * @param handler A function to call when the notification occurs. Receives the
  832. * event object as an argument.
  833. * @returns A callback function that can be used to remove the handler.
  834. */
  835. EventManager.prototype.addEventListener = function (element, eventName, handler) {
  836. var plugin = this._findPluginFor(eventName);
  837. return plugin.addEventListener(element, eventName, handler);
  838. };
  839. /**
  840. * Registers a global handler for an event in a target view.
  841. *
  842. * @param target A target for global event notifications. One of "window", "document", or "body".
  843. * @param eventName The name of the event to listen for.
  844. * @param handler A function to call when the notification occurs. Receives the
  845. * event object as an argument.
  846. * @returns A callback function that can be used to remove the handler.
  847. */
  848. EventManager.prototype.addGlobalEventListener = function (target, eventName, handler) {
  849. var plugin = this._findPluginFor(eventName);
  850. return plugin.addGlobalEventListener(target, eventName, handler);
  851. };
  852. /**
  853. * Retrieves the compilation zone in which event listeners are registered.
  854. */
  855. EventManager.prototype.getZone = function () { return this._zone; };
  856. /** @internal */
  857. EventManager.prototype._findPluginFor = function (eventName) {
  858. var plugin = this._eventNameToPlugin.get(eventName);
  859. if (plugin) {
  860. return plugin;
  861. }
  862. var plugins = this._plugins;
  863. for (var i = 0; i < plugins.length; i++) {
  864. var plugin_1 = plugins[i];
  865. if (plugin_1.supports(eventName)) {
  866. this._eventNameToPlugin.set(eventName, plugin_1);
  867. return plugin_1;
  868. }
  869. }
  870. throw new Error("No event manager plugin found for event " + eventName);
  871. };
  872. EventManager = __decorate([
  873. Injectable(),
  874. __param(0, Inject(EVENT_MANAGER_PLUGINS)),
  875. __metadata("design:paramtypes", [Array, NgZone])
  876. ], EventManager);
  877. return EventManager;
  878. }());
  879. var EventManagerPlugin = /** @class */ (function () {
  880. function EventManagerPlugin(_doc) {
  881. this._doc = _doc;
  882. }
  883. EventManagerPlugin.prototype.addGlobalEventListener = function (element, eventName, handler) {
  884. var target = getDOM().getGlobalEventTarget(this._doc, element);
  885. if (!target) {
  886. throw new Error("Unsupported event target " + target + " for event " + eventName);
  887. }
  888. return this.addEventListener(target, eventName, handler);
  889. };
  890. return EventManagerPlugin;
  891. }());
  892. /**
  893. * @license
  894. * Copyright Google Inc. All Rights Reserved.
  895. *
  896. * Use of this source code is governed by an MIT-style license that can be
  897. * found in the LICENSE file at https://angular.io/license
  898. */
  899. var SharedStylesHost = /** @class */ (function () {
  900. function SharedStylesHost() {
  901. /** @internal */
  902. this._stylesSet = new Set();
  903. }
  904. SharedStylesHost.prototype.addStyles = function (styles) {
  905. var _this = this;
  906. var additions = new Set();
  907. styles.forEach(function (style) {
  908. if (!_this._stylesSet.has(style)) {
  909. _this._stylesSet.add(style);
  910. additions.add(style);
  911. }
  912. });
  913. this.onStylesAdded(additions);
  914. };
  915. SharedStylesHost.prototype.onStylesAdded = function (additions) { };
  916. SharedStylesHost.prototype.getAllStyles = function () { return Array.from(this._stylesSet); };
  917. SharedStylesHost = __decorate([
  918. Injectable()
  919. ], SharedStylesHost);
  920. return SharedStylesHost;
  921. }());
  922. var DomSharedStylesHost = /** @class */ (function (_super) {
  923. __extends(DomSharedStylesHost, _super);
  924. function DomSharedStylesHost(_doc) {
  925. var _this = _super.call(this) || this;
  926. _this._doc = _doc;
  927. _this._hostNodes = new Set();
  928. _this._styleNodes = new Set();
  929. _this._hostNodes.add(_doc.head);
  930. return _this;
  931. }
  932. DomSharedStylesHost.prototype._addStylesToHost = function (styles, host) {
  933. var _this = this;
  934. styles.forEach(function (style) {
  935. var styleEl = _this._doc.createElement('style');
  936. styleEl.textContent = style;
  937. _this._styleNodes.add(host.appendChild(styleEl));
  938. });
  939. };
  940. DomSharedStylesHost.prototype.addHost = function (hostNode) {
  941. this._addStylesToHost(this._stylesSet, hostNode);
  942. this._hostNodes.add(hostNode);
  943. };
  944. DomSharedStylesHost.prototype.removeHost = function (hostNode) { this._hostNodes.delete(hostNode); };
  945. DomSharedStylesHost.prototype.onStylesAdded = function (additions) {
  946. var _this = this;
  947. this._hostNodes.forEach(function (hostNode) { return _this._addStylesToHost(additions, hostNode); });
  948. };
  949. DomSharedStylesHost.prototype.ngOnDestroy = function () { this._styleNodes.forEach(function (styleNode) { return getDOM().remove(styleNode); }); };
  950. DomSharedStylesHost = __decorate([
  951. Injectable(),
  952. __param(0, Inject(DOCUMENT)),
  953. __metadata("design:paramtypes", [Object])
  954. ], DomSharedStylesHost);
  955. return DomSharedStylesHost;
  956. }(SharedStylesHost));
  957. /**
  958. * @license
  959. * Copyright Google Inc. All Rights Reserved.
  960. *
  961. * Use of this source code is governed by an MIT-style license that can be
  962. * found in the LICENSE file at https://angular.io/license
  963. */
  964. var NAMESPACE_URIS = {
  965. 'svg': 'http://www.w3.org/2000/svg',
  966. 'xhtml': 'http://www.w3.org/1999/xhtml',
  967. 'xlink': 'http://www.w3.org/1999/xlink',
  968. 'xml': 'http://www.w3.org/XML/1998/namespace',
  969. 'xmlns': 'http://www.w3.org/2000/xmlns/',
  970. };
  971. var COMPONENT_REGEX = /%COMP%/g;
  972. var COMPONENT_VARIABLE = '%COMP%';
  973. var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
  974. var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
  975. function shimContentAttribute(componentShortId) {
  976. return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
  977. }
  978. function shimHostAttribute(componentShortId) {
  979. return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
  980. }
  981. function flattenStyles(compId, styles, target) {
  982. for (var i = 0; i < styles.length; i++) {
  983. var style = styles[i];
  984. if (Array.isArray(style)) {
  985. flattenStyles(compId, style, target);
  986. }
  987. else {
  988. style = style.replace(COMPONENT_REGEX, compId);
  989. target.push(style);
  990. }
  991. }
  992. return target;
  993. }
  994. function decoratePreventDefault(eventHandler) {
  995. return function (event) {
  996. var allowDefaultBehavior = eventHandler(event);
  997. if (allowDefaultBehavior === false) {
  998. // TODO(tbosch): move preventDefault into event plugins...
  999. event.preventDefault();
  1000. event.returnValue = false;
  1001. }
  1002. };
  1003. }
  1004. var DomRendererFactory2 = /** @class */ (function () {
  1005. function DomRendererFactory2(eventManager, sharedStylesHost, appId) {
  1006. this.eventManager = eventManager;
  1007. this.sharedStylesHost = sharedStylesHost;
  1008. this.appId = appId;
  1009. this.rendererByCompId = new Map();
  1010. this.defaultRenderer = new DefaultDomRenderer2(eventManager);
  1011. }
  1012. DomRendererFactory2.prototype.createRenderer = function (element, type) {
  1013. if (!element || !type) {
  1014. return this.defaultRenderer;
  1015. }
  1016. switch (type.encapsulation) {
  1017. case ViewEncapsulation.Emulated: {
  1018. var renderer = this.rendererByCompId.get(type.id);
  1019. if (!renderer) {
  1020. renderer = new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type, this.appId);
  1021. this.rendererByCompId.set(type.id, renderer);
  1022. }
  1023. renderer.applyToHost(element);
  1024. return renderer;
  1025. }
  1026. case ViewEncapsulation.Native:
  1027. case ViewEncapsulation.ShadowDom:
  1028. return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
  1029. default: {
  1030. if (!this.rendererByCompId.has(type.id)) {
  1031. var styles = flattenStyles(type.id, type.styles, []);
  1032. this.sharedStylesHost.addStyles(styles);
  1033. this.rendererByCompId.set(type.id, this.defaultRenderer);
  1034. }
  1035. return this.defaultRenderer;
  1036. }
  1037. }
  1038. };
  1039. DomRendererFactory2.prototype.begin = function () { };
  1040. DomRendererFactory2.prototype.end = function () { };
  1041. DomRendererFactory2 = __decorate([
  1042. Injectable(),
  1043. __param(2, Inject(APP_ID)),
  1044. __metadata("design:paramtypes", [EventManager, DomSharedStylesHost, String])
  1045. ], DomRendererFactory2);
  1046. return DomRendererFactory2;
  1047. }());
  1048. var DefaultDomRenderer2 = /** @class */ (function () {
  1049. function DefaultDomRenderer2(eventManager) {
  1050. this.eventManager = eventManager;
  1051. this.data = Object.create(null);
  1052. }
  1053. DefaultDomRenderer2.prototype.destroy = function () { };
  1054. DefaultDomRenderer2.prototype.createElement = function (name, namespace) {
  1055. if (namespace) {
  1056. // In cases where Ivy (not ViewEngine) is giving us the actual namespace, the look up by key
  1057. // will result in undefined, so we just return the namespace here.
  1058. return document.createElementNS(NAMESPACE_URIS[namespace] || namespace, name);
  1059. }
  1060. return document.createElement(name);
  1061. };
  1062. DefaultDomRenderer2.prototype.createComment = function (value) { return document.createComment(value); };
  1063. DefaultDomRenderer2.prototype.createText = function (value) { return document.createTextNode(value); };
  1064. DefaultDomRenderer2.prototype.appendChild = function (parent, newChild) { parent.appendChild(newChild); };
  1065. DefaultDomRenderer2.prototype.insertBefore = function (parent, newChild, refChild) {
  1066. if (parent) {
  1067. parent.insertBefore(newChild, refChild);
  1068. }
  1069. };
  1070. DefaultDomRenderer2.prototype.removeChild = function (parent, oldChild) {
  1071. if (parent) {
  1072. parent.removeChild(oldChild);
  1073. }
  1074. };
  1075. DefaultDomRenderer2.prototype.selectRootElement = function (selectorOrNode, preserveContent) {
  1076. var el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
  1077. selectorOrNode;
  1078. if (!el) {
  1079. throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements");
  1080. }
  1081. if (!preserveContent) {
  1082. el.textContent = '';
  1083. }
  1084. return el;
  1085. };
  1086. DefaultDomRenderer2.prototype.parentNode = function (node) { return node.parentNode; };
  1087. DefaultDomRenderer2.prototype.nextSibling = function (node) { return node.nextSibling; };
  1088. DefaultDomRenderer2.prototype.setAttribute = function (el, name, value, namespace) {
  1089. if (namespace) {
  1090. name = namespace + ':' + name;
  1091. // TODO(benlesh): Ivy may cause issues here because it's passing around
  1092. // full URIs for namespaces, therefore this lookup will fail.
  1093. var namespaceUri = NAMESPACE_URIS[namespace];
  1094. if (namespaceUri) {
  1095. el.setAttributeNS(namespaceUri, name, value);
  1096. }
  1097. else {
  1098. el.setAttribute(name, value);
  1099. }
  1100. }
  1101. else {
  1102. el.setAttribute(name, value);
  1103. }
  1104. };
  1105. DefaultDomRenderer2.prototype.removeAttribute = function (el, name, namespace) {
  1106. if (namespace) {
  1107. // TODO(benlesh): Ivy may cause issues here because it's passing around
  1108. // full URIs for namespaces, therefore this lookup will fail.
  1109. var namespaceUri = NAMESPACE_URIS[namespace];
  1110. if (namespaceUri) {
  1111. el.removeAttributeNS(namespaceUri, name);
  1112. }
  1113. else {
  1114. // TODO(benlesh): Since ivy is passing around full URIs for namespaces
  1115. // this could result in properties like `http://www.w3.org/2000/svg:cx="123"`,
  1116. // which is wrong.
  1117. el.removeAttribute(namespace + ":" + name);
  1118. }
  1119. }
  1120. else {
  1121. el.removeAttribute(name);
  1122. }
  1123. };
  1124. DefaultDomRenderer2.prototype.addClass = function (el, name) { el.classList.add(name); };
  1125. DefaultDomRenderer2.prototype.removeClass = function (el, name) { el.classList.remove(name); };
  1126. DefaultDomRenderer2.prototype.setStyle = function (el, style, value, flags) {
  1127. if (flags & RendererStyleFlags2.DashCase) {
  1128. el.style.setProperty(style, value, !!(flags & RendererStyleFlags2.Important) ? 'important' : '');
  1129. }
  1130. else {
  1131. el.style[style] = value;
  1132. }
  1133. };
  1134. DefaultDomRenderer2.prototype.removeStyle = function (el, style, flags) {
  1135. if (flags & RendererStyleFlags2.DashCase) {
  1136. el.style.removeProperty(style);
  1137. }
  1138. else {
  1139. // IE requires '' instead of null
  1140. // see https://github.com/angular/angular/issues/7916
  1141. el.style[style] = '';
  1142. }
  1143. };
  1144. DefaultDomRenderer2.prototype.setProperty = function (el, name, value) {
  1145. checkNoSyntheticProp(name, 'property');
  1146. el[name] = value;
  1147. };
  1148. DefaultDomRenderer2.prototype.setValue = function (node, value) { node.nodeValue = value; };
  1149. DefaultDomRenderer2.prototype.listen = function (target, event, callback) {
  1150. checkNoSyntheticProp(event, 'listener');
  1151. if (typeof target === 'string') {
  1152. return this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback));
  1153. }
  1154. return this.eventManager.addEventListener(target, event, decoratePreventDefault(callback));
  1155. };
  1156. return DefaultDomRenderer2;
  1157. }());
  1158. var ɵ0$2 = function () { return '@'.charCodeAt(0); };
  1159. var AT_CHARCODE = (ɵ0$2)();
  1160. function checkNoSyntheticProp(name, nameKind) {
  1161. if (name.charCodeAt(0) === AT_CHARCODE) {
  1162. throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application.");
  1163. }
  1164. }
  1165. var EmulatedEncapsulationDomRenderer2 = /** @class */ (function (_super) {
  1166. __extends(EmulatedEncapsulationDomRenderer2, _super);
  1167. function EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, component, appId) {
  1168. var _this = _super.call(this, eventManager) || this;
  1169. _this.component = component;
  1170. var styles = flattenStyles(appId + '-' + component.id, component.styles, []);
  1171. sharedStylesHost.addStyles(styles);
  1172. _this.contentAttr = shimContentAttribute(appId + '-' + component.id);
  1173. _this.hostAttr = shimHostAttribute(appId + '-' + component.id);
  1174. return _this;
  1175. }
  1176. EmulatedEncapsulationDomRenderer2.prototype.applyToHost = function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); };
  1177. EmulatedEncapsulationDomRenderer2.prototype.createElement = function (parent, name) {
  1178. var el = _super.prototype.createElement.call(this, parent, name);
  1179. _super.prototype.setAttribute.call(this, el, this.contentAttr, '');
  1180. return el;
  1181. };
  1182. return EmulatedEncapsulationDomRenderer2;
  1183. }(DefaultDomRenderer2));
  1184. var ShadowDomRenderer = /** @class */ (function (_super) {
  1185. __extends(ShadowDomRenderer, _super);
  1186. function ShadowDomRenderer(eventManager, sharedStylesHost, hostEl, component) {
  1187. var _this = _super.call(this, eventManager) || this;
  1188. _this.sharedStylesHost = sharedStylesHost;
  1189. _this.hostEl = hostEl;
  1190. _this.component = component;
  1191. if (component.encapsulation === ViewEncapsulation.ShadowDom) {
  1192. _this.shadowRoot = hostEl.attachShadow({ mode: 'open' });
  1193. }
  1194. else {
  1195. _this.shadowRoot = hostEl.createShadowRoot();
  1196. }
  1197. _this.sharedStylesHost.addHost(_this.shadowRoot);
  1198. var styles = flattenStyles(component.id, component.styles, []);
  1199. for (var i = 0; i < styles.length; i++) {
  1200. var styleEl = document.createElement('style');
  1201. styleEl.textContent = styles[i];
  1202. _this.shadowRoot.appendChild(styleEl);
  1203. }
  1204. return _this;
  1205. }
  1206. ShadowDomRenderer.prototype.nodeOrShadowRoot = function (node) { return node === this.hostEl ? this.shadowRoot : node; };
  1207. ShadowDomRenderer.prototype.destroy = function () { this.sharedStylesHost.removeHost(this.shadowRoot); };
  1208. ShadowDomRenderer.prototype.appendChild = function (parent, newChild) {
  1209. return _super.prototype.appendChild.call(this, this.nodeOrShadowRoot(parent), newChild);
  1210. };
  1211. ShadowDomRenderer.prototype.insertBefore = function (parent, newChild, refChild) {
  1212. return _super.prototype.insertBefore.call(this, this.nodeOrShadowRoot(parent), newChild, refChild);
  1213. };
  1214. ShadowDomRenderer.prototype.removeChild = function (parent, oldChild) {
  1215. return _super.prototype.removeChild.call(this, this.nodeOrShadowRoot(parent), oldChild);
  1216. };
  1217. ShadowDomRenderer.prototype.parentNode = function (node) {
  1218. return this.nodeOrShadowRoot(_super.prototype.parentNode.call(this, this.nodeOrShadowRoot(node)));
  1219. };
  1220. return ShadowDomRenderer;
  1221. }(DefaultDomRenderer2));
  1222. /**
  1223. * @license
  1224. * Copyright Google Inc. All Rights Reserved.
  1225. *
  1226. * Use of this source code is governed by an MIT-style license that can be
  1227. * found in the LICENSE file at https://angular.io/license
  1228. */
  1229. var ɵ0$3 = function () { return (typeof Zone !== 'undefined') && Zone['__symbol__'] ||
  1230. function (v) { return '__zone_symbol__' + v; }; };
  1231. /**
  1232. * Detect if Zone is present. If it is then use simple zone aware 'addEventListener'
  1233. * since Angular can do much more
  1234. * efficient bookkeeping than Zone can, because we have additional information. This speeds up
  1235. * addEventListener by 3x.
  1236. */
  1237. var __symbol__ = (ɵ0$3)();
  1238. var ADD_EVENT_LISTENER = __symbol__('addEventListener');
  1239. var REMOVE_EVENT_LISTENER = __symbol__('removeEventListener');
  1240. var symbolNames = {};
  1241. var FALSE = 'FALSE';
  1242. var ANGULAR = 'ANGULAR';
  1243. var NATIVE_ADD_LISTENER = 'addEventListener';
  1244. var NATIVE_REMOVE_LISTENER = 'removeEventListener';
  1245. // use the same symbol string which is used in zone.js
  1246. var stopSymbol = '__zone_symbol__propagationStopped';
  1247. var stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
  1248. var ɵ1 = function () {
  1249. var blackListedEvents = (typeof Zone !== 'undefined') && Zone[__symbol__('BLACK_LISTED_EVENTS')];
  1250. if (blackListedEvents) {
  1251. var res_1 = {};
  1252. blackListedEvents.forEach(function (eventName) { res_1[eventName] = eventName; });
  1253. return res_1;
  1254. }
  1255. return undefined;
  1256. };
  1257. var blackListedMap = (ɵ1)();
  1258. var isBlackListedEvent = function (eventName) {
  1259. if (!blackListedMap) {
  1260. return false;
  1261. }
  1262. return blackListedMap.hasOwnProperty(eventName);
  1263. };
  1264. // a global listener to handle all dom event,
  1265. // so we do not need to create a closure every time
  1266. var globalListener = function (event) {
  1267. var symbolName = symbolNames[event.type];
  1268. if (!symbolName) {
  1269. return;
  1270. }
  1271. var taskDatas = this[symbolName];
  1272. if (!taskDatas) {
  1273. return;
  1274. }
  1275. var args = [event];
  1276. if (taskDatas.length === 1) {
  1277. // if taskDatas only have one element, just invoke it
  1278. var taskData = taskDatas[0];
  1279. if (taskData.zone !== Zone.current) {
  1280. // only use Zone.run when Zone.current not equals to stored zone
  1281. return taskData.zone.run(taskData.handler, this, args);
  1282. }
  1283. else {
  1284. return taskData.handler.apply(this, args);
  1285. }
  1286. }
  1287. else {
  1288. // copy tasks as a snapshot to avoid event handlers remove
  1289. // itself or others
  1290. var copiedTasks = taskDatas.slice();
  1291. for (var i = 0; i < copiedTasks.length; i++) {
  1292. // if other listener call event.stopImmediatePropagation
  1293. // just break
  1294. if (event[stopSymbol] === true) {
  1295. break;
  1296. }
  1297. var taskData = copiedTasks[i];
  1298. if (taskData.zone !== Zone.current) {
  1299. // only use Zone.run when Zone.current not equals to stored zone
  1300. taskData.zone.run(taskData.handler, this, args);
  1301. }
  1302. else {
  1303. taskData.handler.apply(this, args);
  1304. }
  1305. }
  1306. }
  1307. };
  1308. var DomEventsPlugin = /** @class */ (function (_super) {
  1309. __extends(DomEventsPlugin, _super);
  1310. function DomEventsPlugin(doc, ngZone, platformId) {
  1311. var _this = _super.call(this, doc) || this;
  1312. _this.ngZone = ngZone;
  1313. if (!platformId || !isPlatformServer(platformId)) {
  1314. _this.patchEvent();
  1315. }
  1316. return _this;
  1317. }
  1318. DomEventsPlugin.prototype.patchEvent = function () {
  1319. if (typeof Event === 'undefined' || !Event || !Event.prototype) {
  1320. return;
  1321. }
  1322. if (Event.prototype[stopMethodSymbol]) {
  1323. // already patched by zone.js
  1324. return;
  1325. }
  1326. var delegate = Event.prototype[stopMethodSymbol] =
  1327. Event.prototype.stopImmediatePropagation;
  1328. Event.prototype.stopImmediatePropagation = function () {
  1329. if (this) {
  1330. this[stopSymbol] = true;
  1331. }
  1332. // should call native delegate in case
  1333. // in some environment part of the application
  1334. // will not use the patched Event
  1335. delegate && delegate.apply(this, arguments);
  1336. };
  1337. };
  1338. // This plugin should come last in the list of plugins, because it accepts all
  1339. // events.
  1340. DomEventsPlugin.prototype.supports = function (eventName) { return true; };
  1341. DomEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
  1342. var _this = this;
  1343. var zoneJsLoaded = element[ADD_EVENT_LISTENER];
  1344. var callback = handler;
  1345. // if zonejs is loaded and current zone is not ngZone
  1346. // we keep Zone.current on target for later restoration.
  1347. if (zoneJsLoaded && (!NgZone.isInAngularZone() || isBlackListedEvent(eventName))) {
  1348. var symbolName = symbolNames[eventName];
  1349. if (!symbolName) {
  1350. symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
  1351. }
  1352. var taskDatas = element[symbolName];
  1353. var globalListenerRegistered = taskDatas && taskDatas.length > 0;
  1354. if (!taskDatas) {
  1355. taskDatas = element[symbolName] = [];
  1356. }
  1357. var zone = isBlackListedEvent(eventName) ? Zone.root : Zone.current;
  1358. if (taskDatas.length === 0) {
  1359. taskDatas.push({ zone: zone, handler: callback });
  1360. }
  1361. else {
  1362. var callbackRegistered = false;
  1363. for (var i = 0; i < taskDatas.length; i++) {
  1364. if (taskDatas[i].handler === callback) {
  1365. callbackRegistered = true;
  1366. break;
  1367. }
  1368. }
  1369. if (!callbackRegistered) {
  1370. taskDatas.push({ zone: zone, handler: callback });
  1371. }
  1372. }
  1373. if (!globalListenerRegistered) {
  1374. element[ADD_EVENT_LISTENER](eventName, globalListener, false);
  1375. }
  1376. }
  1377. else {
  1378. element[NATIVE_ADD_LISTENER](eventName, callback, false);
  1379. }
  1380. return function () { return _this.removeEventListener(element, eventName, callback); };
  1381. };
  1382. DomEventsPlugin.prototype.removeEventListener = function (target, eventName, callback) {
  1383. var underlyingRemove = target[REMOVE_EVENT_LISTENER];
  1384. // zone.js not loaded, use native removeEventListener
  1385. if (!underlyingRemove) {
  1386. return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  1387. }
  1388. var symbolName = symbolNames[eventName];
  1389. var taskDatas = symbolName && target[symbolName];
  1390. if (!taskDatas) {
  1391. // addEventListener not using patched version
  1392. // just call native removeEventListener
  1393. return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  1394. }
  1395. // fix issue 20532, should be able to remove
  1396. // listener which was added inside of ngZone
  1397. var found = false;
  1398. for (var i = 0; i < taskDatas.length; i++) {
  1399. // remove listener from taskDatas if the callback equals
  1400. if (taskDatas[i].handler === callback) {
  1401. found = true;
  1402. taskDatas.splice(i, 1);
  1403. break;
  1404. }
  1405. }
  1406. if (found) {
  1407. if (taskDatas.length === 0) {
  1408. // all listeners are removed, we can remove the globalListener from target
  1409. underlyingRemove.apply(target, [eventName, globalListener, false]);
  1410. }
  1411. }
  1412. else {
  1413. // not found in taskDatas, the callback may be added inside of ngZone
  1414. // use native remove listener to remove the callback
  1415. target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  1416. }
  1417. };
  1418. DomEventsPlugin = __decorate([
  1419. Injectable(),
  1420. __param(0, Inject(DOCUMENT)),
  1421. __param(2, Optional()), __param(2, Inject(PLATFORM_ID)),
  1422. __metadata("design:paramtypes", [Object, NgZone, Object])
  1423. ], DomEventsPlugin);
  1424. return DomEventsPlugin;
  1425. }(EventManagerPlugin));
  1426. /**
  1427. * @license
  1428. * Copyright Google Inc. All Rights Reserved.
  1429. *
  1430. * Use of this source code is governed by an MIT-style license that can be
  1431. * found in the LICENSE file at https://angular.io/license
  1432. */
  1433. /**
  1434. * Supported HammerJS recognizer event names.
  1435. */
  1436. var EVENT_NAMES = {
  1437. // pan
  1438. 'pan': true,
  1439. 'panstart': true,
  1440. 'panmove': true,
  1441. 'panend': true,
  1442. 'pancancel': true,
  1443. 'panleft': true,
  1444. 'panright': true,
  1445. 'panup': true,
  1446. 'pandown': true,
  1447. // pinch
  1448. 'pinch': true,
  1449. 'pinchstart': true,
  1450. 'pinchmove': true,
  1451. 'pinchend': true,
  1452. 'pinchcancel': true,
  1453. 'pinchin': true,
  1454. 'pinchout': true,
  1455. // press
  1456. 'press': true,
  1457. 'pressup': true,
  1458. // rotate
  1459. 'rotate': true,
  1460. 'rotatestart': true,
  1461. 'rotatemove': true,
  1462. 'rotateend': true,
  1463. 'rotatecancel': true,
  1464. // swipe
  1465. 'swipe': true,
  1466. 'swipeleft': true,
  1467. 'swiperight': true,
  1468. 'swipeup': true,
  1469. 'swipedown': true,
  1470. // tap
  1471. 'tap': true,
  1472. };
  1473. /**
  1474. * DI token for providing [HammerJS](http://hammerjs.github.io/) support to Angular.
  1475. * @see `HammerGestureConfig`
  1476. *
  1477. * @publicApi
  1478. */
  1479. var HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
  1480. /**
  1481. * Injection token used to provide a {@link HammerLoader} to Angular.
  1482. *
  1483. * @publicApi
  1484. */
  1485. var HAMMER_LOADER = new InjectionToken('HammerLoader');
  1486. /**
  1487. * An injectable [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
  1488. * for gesture recognition. Configures specific event recognition.
  1489. * @publicApi
  1490. */
  1491. var HammerGestureConfig = /** @class */ (function () {
  1492. function HammerGestureConfig() {
  1493. /**
  1494. * A set of supported event names for gestures to be used in Angular.
  1495. * Angular supports all built-in recognizers, as listed in
  1496. * [HammerJS documentation](http://hammerjs.github.io/).
  1497. */
  1498. this.events = [];
  1499. /**
  1500. * Maps gesture event names to a set of configuration options
  1501. * that specify overrides to the default values for specific properties.
  1502. *
  1503. * The key is a supported event name to be configured,
  1504. * and the options object contains a set of properties, with override values
  1505. * to be applied to the named recognizer event.
  1506. * For example, to disable recognition of the rotate event, specify
  1507. * `{"rotate": {"enable": false}}`.
  1508. *
  1509. * Properties that are not present take the HammerJS default values.
  1510. * For information about which properties are supported for which events,
  1511. * and their allowed and default values, see
  1512. * [HammerJS documentation](http://hammerjs.github.io/).
  1513. *
  1514. */
  1515. this.overrides = {};
  1516. }
  1517. /**
  1518. * Creates a [HammerJS Manager](http://hammerjs.github.io/api/#hammer.manager)
  1519. * and attaches it to a given HTML element.
  1520. * @param element The element that will recognize gestures.
  1521. * @returns A HammerJS event-manager object.
  1522. */
  1523. HammerGestureConfig.prototype.buildHammer = function (element) {
  1524. var mc = new Hammer(element, this.options);
  1525. mc.get('pinch').set({ enable: true });
  1526. mc.get('rotate').set({ enable: true });
  1527. for (var eventName in this.overrides) {
  1528. mc.get(eventName).set(this.overrides[eventName]);
  1529. }
  1530. return mc;
  1531. };
  1532. HammerGestureConfig = __decorate([
  1533. Injectable()
  1534. ], HammerGestureConfig);
  1535. return HammerGestureConfig;
  1536. }());
  1537. var HammerGesturesPlugin = /** @class */ (function (_super) {
  1538. __extends(HammerGesturesPlugin, _super);
  1539. function HammerGesturesPlugin(doc, _config, console, loader) {
  1540. var _this = _super.call(this, doc) || this;
  1541. _this._config = _config;
  1542. _this.console = console;
  1543. _this.loader = loader;
  1544. return _this;
  1545. }
  1546. HammerGesturesPlugin.prototype.supports = function (eventName) {
  1547. if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
  1548. return false;
  1549. }
  1550. if (!window.Hammer && !this.loader) {
  1551. this.console.warn("The \"" + eventName + "\" event cannot be bound because Hammer.JS is not " +
  1552. "loaded and no custom loader has been specified.");
  1553. return false;
  1554. }
  1555. return true;
  1556. };
  1557. HammerGesturesPlugin.prototype.addEventListener = function (element, eventName, handler) {
  1558. var _this = this;
  1559. var zone = this.manager.getZone();
  1560. eventName = eventName.toLowerCase();
  1561. // If Hammer is not present but a loader is specified, we defer adding the event listener
  1562. // until Hammer is loaded.
  1563. if (!window.Hammer && this.loader) {
  1564. // This `addEventListener` method returns a function to remove the added listener.
  1565. // Until Hammer is loaded, the returned function needs to *cancel* the registration rather
  1566. // than remove anything.
  1567. var cancelRegistration_1 = false;
  1568. var deregister_1 = function () { cancelRegistration_1 = true; };
  1569. this.loader()
  1570. .then(function () {
  1571. // If Hammer isn't actually loaded when the custom loader resolves, give up.
  1572. if (!window.Hammer) {
  1573. _this.console.warn("The custom HAMMER_LOADER completed, but Hammer.JS is not present.");
  1574. deregister_1 = function () { };
  1575. return;
  1576. }
  1577. if (!cancelRegistration_1) {
  1578. // Now that Hammer is loaded and the listener is being loaded for real,
  1579. // the deregistration function changes from canceling registration to removal.
  1580. deregister_1 = _this.addEventListener(element, eventName, handler);
  1581. }
  1582. })
  1583. .catch(function () {
  1584. _this.console.warn("The \"" + eventName + "\" event cannot be bound because the custom " +
  1585. "Hammer.JS loader failed.");
  1586. deregister_1 = function () { };
  1587. });
  1588. // Return a function that *executes* `deregister` (and not `deregister` itself) so that we
  1589. // can change the behavior of `deregister` once the listener is added. Using a closure in
  1590. // this way allows us to avoid any additional data structures to track listener removal.
  1591. return function () { deregister_1(); };
  1592. }
  1593. return zone.runOutsideAngular(function () {
  1594. // Creating the manager bind events, must be done outside of angular
  1595. var mc = _this._config.buildHammer(element);
  1596. var callback = function (eventObj) {
  1597. zone.runGuarded(function () { handler(eventObj); });
  1598. };
  1599. mc.on(eventName, callback);
  1600. return function () {
  1601. mc.off(eventName, callback);
  1602. // destroy mc to prevent memory leak
  1603. if (typeof mc.destroy === 'function') {
  1604. mc.destroy();
  1605. }
  1606. };
  1607. });
  1608. };
  1609. HammerGesturesPlugin.prototype.isCustomEvent = function (eventName) { return this._config.events.indexOf(eventName) > -1; };
  1610. HammerGesturesPlugin = __decorate([
  1611. Injectable(),
  1612. __param(0, Inject(DOCUMENT)),
  1613. __param(1, Inject(HAMMER_GESTURE_CONFIG)),
  1614. __param(3, Optional()), __param(3, Inject(HAMMER_LOADER)),
  1615. __metadata("design:paramtypes", [Object, HammerGestureConfig, ɵConsole, Object])
  1616. ], HammerGesturesPlugin);
  1617. return HammerGesturesPlugin;
  1618. }(EventManagerPlugin));
  1619. /**
  1620. * @license
  1621. * Copyright Google Inc. All Rights Reserved.
  1622. *
  1623. * Use of this source code is governed by an MIT-style license that can be
  1624. * found in the LICENSE file at https://angular.io/license
  1625. */
  1626. /**
  1627. * Defines supported modifiers for key events.
  1628. */
  1629. var MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
  1630. var ɵ0$4 = function (event) { return event.altKey; }, ɵ1$1 = function (event) { return event.ctrlKey; }, ɵ2 = function (event) { return event.metaKey; }, ɵ3 = function (event) { return event.shiftKey; };
  1631. /**
  1632. * Retrieves modifiers from key-event objects.
  1633. */
  1634. var MODIFIER_KEY_GETTERS = {
  1635. 'alt': ɵ0$4,
  1636. 'control': ɵ1$1,
  1637. 'meta': ɵ2,
  1638. 'shift': ɵ3
  1639. };
  1640. /**
  1641. * @publicApi
  1642. * A browser plug-in that provides support for handling of key events in Angular.
  1643. */
  1644. var KeyEventsPlugin = /** @class */ (function (_super) {
  1645. __extends(KeyEventsPlugin, _super);
  1646. /**
  1647. * Initializes an instance of the browser plug-in.
  1648. * @param doc The document in which key events will be detected.
  1649. */
  1650. function KeyEventsPlugin(doc) {
  1651. return _super.call(this, doc) || this;
  1652. }
  1653. KeyEventsPlugin_1 = KeyEventsPlugin;
  1654. /**
  1655. * Reports whether a named key event is supported.
  1656. * @param eventName The event name to query.
  1657. * @return True if the named key event is supported.
  1658. */
  1659. KeyEventsPlugin.prototype.supports = function (eventName) { return KeyEventsPlugin_1.parseEventName(eventName) != null; };
  1660. /**
  1661. * Registers a handler for a specific element and key event.
  1662. * @param element The HTML element to receive event notifications.
  1663. * @param eventName The name of the key event to listen for.
  1664. * @param handler A function to call when the notification occurs. Receives the
  1665. * event object as an argument.
  1666. * @returns The key event that was registered.
  1667. */
  1668. KeyEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
  1669. var parsedEvent = KeyEventsPlugin_1.parseEventName(eventName);
  1670. var outsideHandler = KeyEventsPlugin_1.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
  1671. return this.manager.getZone().runOutsideAngular(function () {
  1672. return getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
  1673. });
  1674. };
  1675. KeyEventsPlugin.parseEventName = function (eventName) {
  1676. var parts = eventName.toLowerCase().split('.');
  1677. var domEventName = parts.shift();
  1678. if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
  1679. return null;
  1680. }
  1681. var key = KeyEventsPlugin_1._normalizeKey(parts.pop());
  1682. var fullKey = '';
  1683. MODIFIER_KEYS.forEach(function (modifierName) {
  1684. var index = parts.indexOf(modifierName);
  1685. if (index > -1) {
  1686. parts.splice(index, 1);
  1687. fullKey += modifierName + '.';
  1688. }
  1689. });
  1690. fullKey += key;
  1691. if (parts.length != 0 || key.length === 0) {
  1692. // returning null instead of throwing to let another plugin process the event
  1693. return null;
  1694. }
  1695. var result = {};
  1696. result['domEventName'] = domEventName;
  1697. result['fullKey'] = fullKey;
  1698. return result;
  1699. };
  1700. KeyEventsPlugin.getEventFullKey = function (event) {
  1701. var fullKey = '';
  1702. var key = getDOM().getEventKey(event);
  1703. key = key.toLowerCase();
  1704. if (key === ' ') {
  1705. key = 'space'; // for readability
  1706. }
  1707. else if (key === '.') {
  1708. key = 'dot'; // because '.' is used as a separator in event names
  1709. }
  1710. MODIFIER_KEYS.forEach(function (modifierName) {
  1711. if (modifierName != key) {
  1712. var modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
  1713. if (modifierGetter(event)) {
  1714. fullKey += modifierName + '.';
  1715. }
  1716. }
  1717. });
  1718. fullKey += key;
  1719. return fullKey;
  1720. };
  1721. /**
  1722. * Configures a handler callback for a key event.
  1723. * @param fullKey The event name that combines all simultaneous keystrokes.
  1724. * @param handler The function that responds to the key event.
  1725. * @param zone The zone in which the event occurred.
  1726. * @returns A callback function.
  1727. */
  1728. KeyEventsPlugin.eventCallback = function (fullKey, handler, zone) {
  1729. return function (event /** TODO #9100 */) {
  1730. if (KeyEventsPlugin_1.getEventFullKey(event) === fullKey) {
  1731. zone.runGuarded(function () { return handler(event); });
  1732. }
  1733. };
  1734. };
  1735. /** @internal */
  1736. KeyEventsPlugin._normalizeKey = function (keyName) {
  1737. // TODO: switch to a Map if the mapping grows too much
  1738. switch (keyName) {
  1739. case 'esc':
  1740. return 'escape';
  1741. default:
  1742. return keyName;
  1743. }
  1744. };
  1745. var KeyEventsPlugin_1;
  1746. KeyEventsPlugin = KeyEventsPlugin_1 = __decorate([
  1747. Injectable(),
  1748. __param(0, Inject(DOCUMENT)),
  1749. __metadata("design:paramtypes", [Object])
  1750. ], KeyEventsPlugin);
  1751. return KeyEventsPlugin;
  1752. }(EventManagerPlugin));
  1753. /**
  1754. * @license
  1755. * Copyright Google Inc. All Rights Reserved.
  1756. *
  1757. * Use of this source code is governed by an MIT-style license that can be
  1758. * found in the LICENSE file at https://angular.io/license
  1759. */
  1760. /**
  1761. * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
  1762. * values to be safe to use in the different DOM contexts.
  1763. *
  1764. * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
  1765. * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
  1766. * the website.
  1767. *
  1768. * In specific situations, it might be necessary to disable sanitization, for example if the
  1769. * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
  1770. * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
  1771. * methods, and then binding to that value from the template.
  1772. *
  1773. * These situations should be very rare, and extraordinary care must be taken to avoid creating a
  1774. * Cross Site Scripting (XSS) security bug!
  1775. *
  1776. * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
  1777. * close as possible to the source of the value, to make it easy to verify no security bug is
  1778. * created by its use.
  1779. *
  1780. * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
  1781. * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
  1782. * code. The sanitizer leaves safe values intact.
  1783. *
  1784. * @security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
  1785. * sanitization for the value passed in. Carefully check and audit all values and code paths going
  1786. * into this call. Make sure any user data is appropriately escaped for this security context.
  1787. * For more detail, see the [Security Guide](http://g.co/ng/security).
  1788. *
  1789. * @publicApi
  1790. */
  1791. var DomSanitizer = /** @class */ (function () {
  1792. function DomSanitizer() {
  1793. }
  1794. return DomSanitizer;
  1795. }());
  1796. var DomSanitizerImpl = /** @class */ (function (_super) {
  1797. __extends(DomSanitizerImpl, _super);
  1798. function DomSanitizerImpl(_doc) {
  1799. var _this = _super.call(this) || this;
  1800. _this._doc = _doc;
  1801. return _this;
  1802. }
  1803. DomSanitizerImpl.prototype.sanitize = function (ctx, value) {
  1804. if (value == null)
  1805. return null;
  1806. switch (ctx) {
  1807. case SecurityContext.NONE:
  1808. return value;
  1809. case SecurityContext.HTML:
  1810. if (value instanceof SafeHtmlImpl)
  1811. return value.changingThisBreaksApplicationSecurity;
  1812. this.checkNotSafeValue(value, 'HTML');
  1813. return ɵ_sanitizeHtml(this._doc, String(value));
  1814. case SecurityContext.STYLE:
  1815. if (value instanceof SafeStyleImpl)
  1816. return value.changingThisBreaksApplicationSecurity;
  1817. this.checkNotSafeValue(value, 'Style');
  1818. return ɵ_sanitizeStyle(value);
  1819. case SecurityContext.SCRIPT:
  1820. if (value instanceof SafeScriptImpl)
  1821. return value.changingThisBreaksApplicationSecurity;
  1822. this.checkNotSafeValue(value, 'Script');
  1823. throw new Error('unsafe value used in a script context');
  1824. case SecurityContext.URL:
  1825. if (value instanceof SafeResourceUrlImpl || value instanceof SafeUrlImpl) {
  1826. // Allow resource URLs in URL contexts, they are strictly more trusted.
  1827. return value.changingThisBreaksApplicationSecurity;
  1828. }
  1829. this.checkNotSafeValue(value, 'URL');
  1830. return ɵ_sanitizeUrl(String(value));
  1831. case SecurityContext.RESOURCE_URL:
  1832. if (value instanceof SafeResourceUrlImpl) {
  1833. return value.changingThisBreaksApplicationSecurity;
  1834. }
  1835. this.checkNotSafeValue(value, 'ResourceURL');
  1836. throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
  1837. default:
  1838. throw new Error("Unexpected SecurityContext " + ctx + " (see http://g.co/ng/security#xss)");
  1839. }
  1840. };
  1841. DomSanitizerImpl.prototype.checkNotSafeValue = function (value, expectedType) {
  1842. if (value instanceof SafeValueImpl) {
  1843. throw new Error("Required a safe " + expectedType + ", got a " + value.getTypeName() + " " +
  1844. "(see http://g.co/ng/security#xss)");
  1845. }
  1846. };
  1847. DomSanitizerImpl.prototype.bypassSecurityTrustHtml = function (value) { return new SafeHtmlImpl(value); };
  1848. DomSanitizerImpl.prototype.bypassSecurityTrustStyle = function (value) { return new SafeStyleImpl(value); };
  1849. DomSanitizerImpl.prototype.bypassSecurityTrustScript = function (value) { return new SafeScriptImpl(value); };
  1850. DomSanitizerImpl.prototype.bypassSecurityTrustUrl = function (value) { return new SafeUrlImpl(value); };
  1851. DomSanitizerImpl.prototype.bypassSecurityTrustResourceUrl = function (value) {
  1852. return new SafeResourceUrlImpl(value);
  1853. };
  1854. DomSanitizerImpl = __decorate([
  1855. Injectable(),
  1856. __param(0, Inject(DOCUMENT)),
  1857. __metadata("design:paramtypes", [Object])
  1858. ], DomSanitizerImpl);
  1859. return DomSanitizerImpl;
  1860. }(DomSanitizer));
  1861. var SafeValueImpl = /** @class */ (function () {
  1862. function SafeValueImpl(changingThisBreaksApplicationSecurity) {
  1863. this.changingThisBreaksApplicationSecurity = changingThisBreaksApplicationSecurity;
  1864. // empty
  1865. }
  1866. SafeValueImpl.prototype.toString = function () {
  1867. return "SafeValue must use [property]=binding: " + this.changingThisBreaksApplicationSecurity +
  1868. " (see http://g.co/ng/security#xss)";
  1869. };
  1870. return SafeValueImpl;
  1871. }());
  1872. var SafeHtmlImpl = /** @class */ (function (_super) {
  1873. __extends(SafeHtmlImpl, _super);
  1874. function SafeHtmlImpl() {
  1875. return _super !== null && _super.apply(this, arguments) || this;
  1876. }
  1877. SafeHtmlImpl.prototype.getTypeName = function () { return 'HTML'; };
  1878. return SafeHtmlImpl;
  1879. }(SafeValueImpl));
  1880. var SafeStyleImpl = /** @class */ (function (_super) {
  1881. __extends(SafeStyleImpl, _super);
  1882. function SafeStyleImpl() {
  1883. return _super !== null && _super.apply(this, arguments) || this;
  1884. }
  1885. SafeStyleImpl.prototype.getTypeName = function () { return 'Style'; };
  1886. return SafeStyleImpl;
  1887. }(SafeValueImpl));
  1888. var SafeScriptImpl = /** @class */ (function (_super) {
  1889. __extends(SafeScriptImpl, _super);
  1890. function SafeScriptImpl() {
  1891. return _super !== null && _super.apply(this, arguments) || this;
  1892. }
  1893. SafeScriptImpl.prototype.getTypeName = function () { return 'Script'; };
  1894. return SafeScriptImpl;
  1895. }(SafeValueImpl));
  1896. var SafeUrlImpl = /** @class */ (function (_super) {
  1897. __extends(SafeUrlImpl, _super);
  1898. function SafeUrlImpl() {
  1899. return _super !== null && _super.apply(this, arguments) || this;
  1900. }
  1901. SafeUrlImpl.prototype.getTypeName = function () { return 'URL'; };
  1902. return SafeUrlImpl;
  1903. }(SafeValueImpl));
  1904. var SafeResourceUrlImpl = /** @class */ (function (_super) {
  1905. __extends(SafeResourceUrlImpl, _super);
  1906. function SafeResourceUrlImpl() {
  1907. return _super !== null && _super.apply(this, arguments) || this;
  1908. }
  1909. SafeResourceUrlImpl.prototype.getTypeName = function () { return 'ResourceURL'; };
  1910. return SafeResourceUrlImpl;
  1911. }(SafeValueImpl));
  1912. /**
  1913. * @license
  1914. * Copyright Google Inc. All Rights Reserved.
  1915. *
  1916. * Use of this source code is governed by an MIT-style license that can be
  1917. * found in the LICENSE file at https://angular.io/license
  1918. */
  1919. var ɵ0$5 = ɵPLATFORM_BROWSER_ID;
  1920. var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
  1921. { provide: PLATFORM_ID, useValue: ɵ0$5 },
  1922. { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
  1923. { provide: PlatformLocation, useClass: BrowserPlatformLocation, deps: [DOCUMENT] },
  1924. { provide: DOCUMENT, useFactory: _document, deps: [] },
  1925. ];
  1926. /**
  1927. * @security Replacing built-in sanitization providers exposes the application to XSS risks.
  1928. * Attacker-controlled data introduced by an unsanitized provider could expose your
  1929. * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
  1930. * @publicApi
  1931. */
  1932. var BROWSER_SANITIZATION_PROVIDERS = [
  1933. { provide: Sanitizer, useExisting: DomSanitizer },
  1934. { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT] },
  1935. ];
  1936. /**
  1937. * @publicApi
  1938. */
  1939. var platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
  1940. function initDomAdapter() {
  1941. BrowserDomAdapter.makeCurrent();
  1942. BrowserGetTestability.init();
  1943. }
  1944. function errorHandler() {
  1945. return new ErrorHandler();
  1946. }
  1947. function _document() {
  1948. return document;
  1949. }
  1950. var BROWSER_MODULE_PROVIDERS = [
  1951. BROWSER_SANITIZATION_PROVIDERS,
  1952. { provide: ɵAPP_ROOT, useValue: true },
  1953. { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
  1954. {
  1955. provide: EVENT_MANAGER_PLUGINS,
  1956. useClass: DomEventsPlugin,
  1957. multi: true,
  1958. deps: [DOCUMENT, NgZone, PLATFORM_ID]
  1959. },
  1960. { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true, deps: [DOCUMENT] },
  1961. {
  1962. provide: EVENT_MANAGER_PLUGINS,
  1963. useClass: HammerGesturesPlugin,
  1964. multi: true,
  1965. deps: [DOCUMENT, HAMMER_GESTURE_CONFIG, ɵConsole, [new Optional(), HAMMER_LOADER]]
  1966. },
  1967. { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig, deps: [] },
  1968. {
  1969. provide: DomRendererFactory2,
  1970. useClass: DomRendererFactory2,
  1971. deps: [EventManager, DomSharedStylesHost, APP_ID]
  1972. },
  1973. { provide: RendererFactory2, useExisting: DomRendererFactory2 },
  1974. { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
  1975. { provide: DomSharedStylesHost, useClass: DomSharedStylesHost, deps: [DOCUMENT] },
  1976. { provide: Testability, useClass: Testability, deps: [NgZone] },
  1977. { provide: EventManager, useClass: EventManager, deps: [EVENT_MANAGER_PLUGINS, NgZone] },
  1978. ELEMENT_PROBE_PROVIDERS,
  1979. ];
  1980. /**
  1981. * Exports required infrastructure for all Angular apps.
  1982. * Included by default in all Angular apps created with the CLI
  1983. * `new` command.
  1984. * Re-exports `CommonModule` and `ApplicationModule`, making their
  1985. * exports and providers available to all apps.
  1986. *
  1987. * @publicApi
  1988. */
  1989. var BrowserModule = /** @class */ (function () {
  1990. function BrowserModule(parentModule) {
  1991. if (parentModule) {
  1992. 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.");
  1993. }
  1994. }
  1995. BrowserModule_1 = BrowserModule;
  1996. /**
  1997. * Configures a browser-based app to transition from a server-rendered app, if
  1998. * one is present on the page.
  1999. *
  2000. * @param params An object containing an identifier for the app to transition.
  2001. * The ID must match between the client and server versions of the app.
  2002. * @returns The reconfigured `BrowserModule` to import into the app's root `AppModule`.
  2003. */
  2004. BrowserModule.withServerTransition = function (params) {
  2005. return {
  2006. ngModule: BrowserModule_1,
  2007. providers: [
  2008. { provide: APP_ID, useValue: params.appId },
  2009. { provide: TRANSITION_ID, useExisting: APP_ID },
  2010. SERVER_TRANSITION_PROVIDERS,
  2011. ],
  2012. };
  2013. };
  2014. var BrowserModule_1;
  2015. BrowserModule = BrowserModule_1 = __decorate([
  2016. NgModule({ providers: BROWSER_MODULE_PROVIDERS, exports: [CommonModule, ApplicationModule] }),
  2017. __param(0, Optional()), __param(0, SkipSelf()), __param(0, Inject(BrowserModule_1)),
  2018. __metadata("design:paramtypes", [Object])
  2019. ], BrowserModule);
  2020. return BrowserModule;
  2021. }());
  2022. /**
  2023. * Factory to create Meta service.
  2024. */
  2025. function createMeta() {
  2026. return new Meta(ɵɵinject(DOCUMENT));
  2027. }
  2028. /**
  2029. * A service that can be used to get and add meta tags.
  2030. *
  2031. * @publicApi
  2032. */
  2033. var Meta = /** @class */ (function () {
  2034. function Meta(_doc) {
  2035. this._doc = _doc;
  2036. this._dom = getDOM();
  2037. }
  2038. Meta.prototype.addTag = function (tag, forceCreation) {
  2039. if (forceCreation === void 0) { forceCreation = false; }
  2040. if (!tag)
  2041. return null;
  2042. return this._getOrCreateElement(tag, forceCreation);
  2043. };
  2044. Meta.prototype.addTags = function (tags, forceCreation) {
  2045. var _this = this;
  2046. if (forceCreation === void 0) { forceCreation = false; }
  2047. if (!tags)
  2048. return [];
  2049. return tags.reduce(function (result, tag) {
  2050. if (tag) {
  2051. result.push(_this._getOrCreateElement(tag, forceCreation));
  2052. }
  2053. return result;
  2054. }, []);
  2055. };
  2056. Meta.prototype.getTag = function (attrSelector) {
  2057. if (!attrSelector)
  2058. return null;
  2059. return this._dom.querySelector(this._doc, "meta[" + attrSelector + "]") || null;
  2060. };
  2061. Meta.prototype.getTags = function (attrSelector) {
  2062. if (!attrSelector)
  2063. return [];
  2064. var list /*NodeList*/ = this._dom.querySelectorAll(this._doc, "meta[" + attrSelector + "]");
  2065. return list ? [].slice.call(list) : [];
  2066. };
  2067. Meta.prototype.updateTag = function (tag, selector) {
  2068. if (!tag)
  2069. return null;
  2070. selector = selector || this._parseSelector(tag);
  2071. var meta = this.getTag(selector);
  2072. if (meta) {
  2073. return this._setMetaElementAttributes(tag, meta);
  2074. }
  2075. return this._getOrCreateElement(tag, true);
  2076. };
  2077. Meta.prototype.removeTag = function (attrSelector) { this.removeTagElement(this.getTag(attrSelector)); };
  2078. Meta.prototype.removeTagElement = function (meta) {
  2079. if (meta) {
  2080. this._dom.remove(meta);
  2081. }
  2082. };
  2083. Meta.prototype._getOrCreateElement = function (meta, forceCreation) {
  2084. if (forceCreation === void 0) { forceCreation = false; }
  2085. if (!forceCreation) {
  2086. var selector = this._parseSelector(meta);
  2087. var elem = this.getTag(selector);
  2088. // It's allowed to have multiple elements with the same name so it's not enough to
  2089. // just check that element with the same name already present on the page. We also need to
  2090. // check if element has tag attributes
  2091. if (elem && this._containsAttributes(meta, elem))
  2092. return elem;
  2093. }
  2094. var element = this._dom.createElement('meta');
  2095. this._setMetaElementAttributes(meta, element);
  2096. var head = this._dom.getElementsByTagName(this._doc, 'head')[0];
  2097. this._dom.appendChild(head, element);
  2098. return element;
  2099. };
  2100. Meta.prototype._setMetaElementAttributes = function (tag, el) {
  2101. var _this = this;
  2102. Object.keys(tag).forEach(function (prop) { return _this._dom.setAttribute(el, prop, tag[prop]); });
  2103. return el;
  2104. };
  2105. Meta.prototype._parseSelector = function (tag) {
  2106. var attr = tag.name ? 'name' : 'property';
  2107. return attr + "=\"" + tag[attr] + "\"";
  2108. };
  2109. Meta.prototype._containsAttributes = function (tag, elem) {
  2110. var _this = this;
  2111. return Object.keys(tag).every(function (key) { return _this._dom.getAttribute(elem, key) === tag[key]; });
  2112. };
  2113. Meta.ngInjectableDef = ɵɵdefineInjectable({ factory: createMeta, token: Meta, providedIn: "root" });
  2114. Meta = __decorate([
  2115. Injectable({ providedIn: 'root', useFactory: createMeta, deps: [] }),
  2116. __param(0, Inject(DOCUMENT)),
  2117. __metadata("design:paramtypes", [Object])
  2118. ], Meta);
  2119. return Meta;
  2120. }());
  2121. /**
  2122. * Factory to create Title service.
  2123. */
  2124. function createTitle() {
  2125. return new Title(ɵɵinject(DOCUMENT));
  2126. }
  2127. /**
  2128. * A service that can be used to get and set the title of a current HTML document.
  2129. *
  2130. * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
  2131. * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
  2132. * (representing the `<title>` tag). Instead, this service can be used to set and get the current
  2133. * title value.
  2134. *
  2135. * @publicApi
  2136. */
  2137. var Title = /** @class */ (function () {
  2138. function Title(_doc) {
  2139. this._doc = _doc;
  2140. }
  2141. /**
  2142. * Get the title of the current HTML document.
  2143. */
  2144. Title.prototype.getTitle = function () { return getDOM().getTitle(this._doc); };
  2145. /**
  2146. * Set the title of the current HTML document.
  2147. * @param newTitle
  2148. */
  2149. Title.prototype.setTitle = function (newTitle) { getDOM().setTitle(this._doc, newTitle); };
  2150. Title.ngInjectableDef = ɵɵdefineInjectable({ factory: createTitle, token: Title, providedIn: "root" });
  2151. Title = __decorate([
  2152. Injectable({ providedIn: 'root', useFactory: createTitle, deps: [] }),
  2153. __param(0, Inject(DOCUMENT)),
  2154. __metadata("design:paramtypes", [Object])
  2155. ], Title);
  2156. return Title;
  2157. }());
  2158. /**
  2159. * @license
  2160. * Copyright Google Inc. All Rights Reserved.
  2161. *
  2162. * Use of this source code is governed by an MIT-style license that can be
  2163. * found in the LICENSE file at https://angular.io/license
  2164. */
  2165. var win = typeof window !== 'undefined' && window || {};
  2166. /**
  2167. * @license
  2168. * Copyright Google Inc. All Rights Reserved.
  2169. *
  2170. * Use of this source code is governed by an MIT-style license that can be
  2171. * found in the LICENSE file at https://angular.io/license
  2172. */
  2173. var ChangeDetectionPerfRecord = /** @class */ (function () {
  2174. function ChangeDetectionPerfRecord(msPerTick, numTicks) {
  2175. this.msPerTick = msPerTick;
  2176. this.numTicks = numTicks;
  2177. }
  2178. return ChangeDetectionPerfRecord;
  2179. }());
  2180. /**
  2181. * Entry point for all Angular profiling-related debug tools. This object
  2182. * corresponds to the `ng.profiler` in the dev console.
  2183. */
  2184. var AngularProfiler = /** @class */ (function () {
  2185. function AngularProfiler(ref) {
  2186. this.appRef = ref.injector.get(ApplicationRef);
  2187. }
  2188. // tslint:disable:no-console
  2189. /**
  2190. * Exercises change detection in a loop and then prints the average amount of
  2191. * time in milliseconds how long a single round of change detection takes for
  2192. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  2193. * of 500 milliseconds.
  2194. *
  2195. * Optionally, a user may pass a `config` parameter containing a map of
  2196. * options. Supported options are:
  2197. *
  2198. * `record` (boolean) - causes the profiler to record a CPU profile while
  2199. * it exercises the change detector. Example:
  2200. *
  2201. * ```
  2202. * ng.profiler.timeChangeDetection({record: true})
  2203. * ```
  2204. */
  2205. AngularProfiler.prototype.timeChangeDetection = function (config) {
  2206. var record = config && config['record'];
  2207. var profileName = 'Change Detection';
  2208. // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
  2209. var isProfilerAvailable = win.console.profile != null;
  2210. if (record && isProfilerAvailable) {
  2211. win.console.profile(profileName);
  2212. }
  2213. var start = getDOM().performanceNow();
  2214. var numTicks = 0;
  2215. while (numTicks < 5 || (getDOM().performanceNow() - start) < 500) {
  2216. this.appRef.tick();
  2217. numTicks++;
  2218. }
  2219. var end = getDOM().performanceNow();
  2220. if (record && isProfilerAvailable) {
  2221. win.console.profileEnd(profileName);
  2222. }
  2223. var msPerTick = (end - start) / numTicks;
  2224. win.console.log("ran " + numTicks + " change detection cycles");
  2225. win.console.log(msPerTick.toFixed(2) + " ms per check");
  2226. return new ChangeDetectionPerfRecord(msPerTick, numTicks);
  2227. };
  2228. return AngularProfiler;
  2229. }());
  2230. /**
  2231. * @license
  2232. * Copyright Google Inc. All Rights Reserved.
  2233. *
  2234. * Use of this source code is governed by an MIT-style license that can be
  2235. * found in the LICENSE file at https://angular.io/license
  2236. */
  2237. var PROFILER_GLOBAL_NAME = 'profiler';
  2238. /**
  2239. * Enabled Angular debug tools that are accessible via your browser's
  2240. * developer console.
  2241. *
  2242. * Usage:
  2243. *
  2244. * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
  2245. * 1. Type `ng.` (usually the console will show auto-complete suggestion)
  2246. * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
  2247. * then hit Enter.
  2248. *
  2249. * @publicApi
  2250. */
  2251. function enableDebugTools(ref) {
  2252. exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
  2253. return ref;
  2254. }
  2255. /**
  2256. * Disables Angular tools.
  2257. *
  2258. * @publicApi
  2259. */
  2260. function disableDebugTools() {
  2261. exportNgVar(PROFILER_GLOBAL_NAME, null);
  2262. }
  2263. /**
  2264. * @license
  2265. * Copyright Google Inc. All Rights Reserved.
  2266. *
  2267. * Use of this source code is governed by an MIT-style license that can be
  2268. * found in the LICENSE file at https://angular.io/license
  2269. */
  2270. function escapeHtml(text) {
  2271. var escapedText = {
  2272. '&': '&a;',
  2273. '"': '&q;',
  2274. '\'': '&s;',
  2275. '<': '&l;',
  2276. '>': '&g;',
  2277. };
  2278. return text.replace(/[&"'<>]/g, function (s) { return escapedText[s]; });
  2279. }
  2280. function unescapeHtml(text) {
  2281. var unescapedText = {
  2282. '&a;': '&',
  2283. '&q;': '"',
  2284. '&s;': '\'',
  2285. '&l;': '<',
  2286. '&g;': '>',
  2287. };
  2288. return text.replace(/&[^;]+;/g, function (s) { return unescapedText[s]; });
  2289. }
  2290. /**
  2291. * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
  2292. *
  2293. * Example:
  2294. *
  2295. * ```
  2296. * const COUNTER_KEY = makeStateKey<number>('counter');
  2297. * let value = 10;
  2298. *
  2299. * transferState.set(COUNTER_KEY, value);
  2300. * ```
  2301. *
  2302. * @publicApi
  2303. */
  2304. function makeStateKey(key) {
  2305. return key;
  2306. }
  2307. /**
  2308. * A key value store that is transferred from the application on the server side to the application
  2309. * on the client side.
  2310. *
  2311. * `TransferState` will be available as an injectable token. To use it import
  2312. * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
  2313. *
  2314. * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
  2315. * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
  2316. * non-lossy manner.
  2317. *
  2318. * @publicApi
  2319. */
  2320. var TransferState = /** @class */ (function () {
  2321. function TransferState() {
  2322. this.store = {};
  2323. this.onSerializeCallbacks = {};
  2324. }
  2325. TransferState_1 = TransferState;
  2326. /** @internal */
  2327. TransferState.init = function (initState) {
  2328. var transferState = new TransferState_1();
  2329. transferState.store = initState;
  2330. return transferState;
  2331. };
  2332. /**
  2333. * Get the value corresponding to a key. Return `defaultValue` if key is not found.
  2334. */
  2335. TransferState.prototype.get = function (key, defaultValue) {
  2336. return this.store[key] !== undefined ? this.store[key] : defaultValue;
  2337. };
  2338. /**
  2339. * Set the value corresponding to a key.
  2340. */
  2341. TransferState.prototype.set = function (key, value) { this.store[key] = value; };
  2342. /**
  2343. * Remove a key from the store.
  2344. */
  2345. TransferState.prototype.remove = function (key) { delete this.store[key]; };
  2346. /**
  2347. * Test whether a key exists in the store.
  2348. */
  2349. TransferState.prototype.hasKey = function (key) { return this.store.hasOwnProperty(key); };
  2350. /**
  2351. * Register a callback to provide the value for a key when `toJson` is called.
  2352. */
  2353. TransferState.prototype.onSerialize = function (key, callback) {
  2354. this.onSerializeCallbacks[key] = callback;
  2355. };
  2356. /**
  2357. * Serialize the current state of the store to JSON.
  2358. */
  2359. TransferState.prototype.toJson = function () {
  2360. // Call the onSerialize callbacks and put those values into the store.
  2361. for (var key in this.onSerializeCallbacks) {
  2362. if (this.onSerializeCallbacks.hasOwnProperty(key)) {
  2363. try {
  2364. this.store[key] = this.onSerializeCallbacks[key]();
  2365. }
  2366. catch (e) {
  2367. console.warn('Exception in onSerialize callback: ', e);
  2368. }
  2369. }
  2370. }
  2371. return JSON.stringify(this.store);
  2372. };
  2373. var TransferState_1;
  2374. TransferState = TransferState_1 = __decorate([
  2375. Injectable()
  2376. ], TransferState);
  2377. return TransferState;
  2378. }());
  2379. function initTransferState(doc, appId) {
  2380. // Locate the script tag with the JSON data transferred from the server.
  2381. // The id of the script tag is set to the Angular appId + 'state'.
  2382. var script = doc.getElementById(appId + '-state');
  2383. var initialState = {};
  2384. if (script && script.textContent) {
  2385. try {
  2386. initialState = JSON.parse(unescapeHtml(script.textContent));
  2387. }
  2388. catch (e) {
  2389. console.warn('Exception while restoring TransferState for app ' + appId, e);
  2390. }
  2391. }
  2392. return TransferState.init(initialState);
  2393. }
  2394. /**
  2395. * NgModule to install on the client side while using the `TransferState` to transfer state from
  2396. * server to client.
  2397. *
  2398. * @publicApi
  2399. */
  2400. var BrowserTransferStateModule = /** @class */ (function () {
  2401. function BrowserTransferStateModule() {
  2402. }
  2403. BrowserTransferStateModule = __decorate([
  2404. NgModule({
  2405. providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT, APP_ID] }],
  2406. })
  2407. ], BrowserTransferStateModule);
  2408. return BrowserTransferStateModule;
  2409. }());
  2410. /**
  2411. * @license
  2412. * Copyright Google Inc. All Rights Reserved.
  2413. *
  2414. * Use of this source code is governed by an MIT-style license that can be
  2415. * found in the LICENSE file at https://angular.io/license
  2416. */
  2417. /**
  2418. * Predicates for use with {@link DebugElement}'s query functions.
  2419. *
  2420. * @publicApi
  2421. */
  2422. var By = /** @class */ (function () {
  2423. function By() {
  2424. }
  2425. /**
  2426. * Match all elements.
  2427. *
  2428. * @usageNotes
  2429. * ### Example
  2430. *
  2431. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  2432. */
  2433. By.all = function () { return function (debugElement) { return true; }; };
  2434. /**
  2435. * Match elements by the given CSS selector.
  2436. *
  2437. * @usageNotes
  2438. * ### Example
  2439. *
  2440. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  2441. */
  2442. By.css = function (selector) {
  2443. return function (debugElement) {
  2444. return debugElement.nativeElement != null ?
  2445. getDOM().elementMatches(debugElement.nativeElement, selector) :
  2446. false;
  2447. };
  2448. };
  2449. /**
  2450. * Match elements that have the given directive present.
  2451. *
  2452. * @usageNotes
  2453. * ### Example
  2454. *
  2455. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  2456. */
  2457. By.directive = function (type) {
  2458. return function (debugElement) { return debugElement.providerTokens.indexOf(type) !== -1; };
  2459. };
  2460. return By;
  2461. }());
  2462. /**
  2463. * @license
  2464. * Copyright Google Inc. All Rights Reserved.
  2465. *
  2466. * Use of this source code is governed by an MIT-style license that can be
  2467. * found in the LICENSE file at https://angular.io/license
  2468. */
  2469. /**
  2470. * @license
  2471. * Copyright Google Inc. All Rights Reserved.
  2472. *
  2473. * Use of this source code is governed by an MIT-style license that can be
  2474. * found in the LICENSE file at https://angular.io/license
  2475. */
  2476. /**
  2477. * @publicApi
  2478. */
  2479. var VERSION = new Version('8.1.3');
  2480. /**
  2481. * @license
  2482. * Copyright Google Inc. All Rights Reserved.
  2483. *
  2484. * Use of this source code is governed by an MIT-style license that can be
  2485. * found in the LICENSE file at https://angular.io/license
  2486. */
  2487. /**
  2488. * @license
  2489. * Copyright Google Inc. All Rights Reserved.
  2490. *
  2491. * Use of this source code is governed by an MIT-style license that can be
  2492. * found in the LICENSE file at https://angular.io/license
  2493. */
  2494. // This file only reexports content of the `src` folder. Keep it that way.
  2495. /**
  2496. * @license
  2497. * Copyright Google Inc. All Rights Reserved.
  2498. *
  2499. * Use of this source code is governed by an MIT-style license that can be
  2500. * found in the LICENSE file at https://angular.io/license
  2501. */
  2502. /**
  2503. * Generated bundle index. Do not edit.
  2504. */
  2505. export { BROWSER_MODULE_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_c, _document as ɵangular_packages_platform_browser_platform_browser_b, errorHandler as ɵangular_packages_platform_browser_platform_browser_a, GenericBrowserDomAdapter as ɵangular_packages_platform_browser_platform_browser_l, createMeta as ɵangular_packages_platform_browser_platform_browser_d, SERVER_TRANSITION_PROVIDERS as ɵangular_packages_platform_browser_platform_browser_i, appInitializerFactory as ɵangular_packages_platform_browser_platform_browser_h, createTitle as ɵangular_packages_platform_browser_platform_browser_e, initTransferState as ɵangular_packages_platform_browser_platform_browser_f, ELEMENT_PROBE_PROVIDERS__PRE_R3__ as ɵangular_packages_platform_browser_platform_browser_k, _createNgProbe as ɵangular_packages_platform_browser_platform_browser_j, EventManagerPlugin as ɵangular_packages_platform_browser_platform_browser_g, BrowserModule, platformBrowser, Meta, Title, disableDebugTools, enableDebugTools, BrowserTransferStateModule, TransferState, makeStateKey, By, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HAMMER_LOADER, HammerGestureConfig, DomSanitizer, VERSION, ELEMENT_PROBE_PROVIDERS__POST_R3__ as ɵELEMENT_PROBE_PROVIDERS__POST_R3__, BROWSER_SANITIZATION_PROVIDERS as ɵBROWSER_SANITIZATION_PROVIDERS, INTERNAL_BROWSER_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS, initDomAdapter as ɵinitDomAdapter, BrowserDomAdapter as ɵBrowserDomAdapter, BrowserPlatformLocation as ɵBrowserPlatformLocation, TRANSITION_ID as ɵTRANSITION_ID, BrowserGetTestability as ɵBrowserGetTestability, escapeHtml as ɵescapeHtml, ELEMENT_PROBE_PROVIDERS as ɵELEMENT_PROBE_PROVIDERS, DomAdapter as ɵDomAdapter, getDOM as ɵgetDOM, setRootDomAdapter as ɵsetRootDomAdapter, DomRendererFactory2 as ɵDomRendererFactory2, NAMESPACE_URIS as ɵNAMESPACE_URIS, flattenStyles as ɵflattenStyles, shimContentAttribute as ɵshimContentAttribute, shimHostAttribute as ɵshimHostAttribute, DomEventsPlugin as ɵDomEventsPlugin, HammerGesturesPlugin as ɵHammerGesturesPlugin, KeyEventsPlugin as ɵKeyEventsPlugin, DomSharedStylesHost as ɵDomSharedStylesHost, SharedStylesHost as ɵSharedStylesHost, DomSanitizerImpl as ɵDomSanitizerImpl };
  2506. //# sourceMappingURL=platform-browser.js.map