Front end of the Slack clone application.

platform-browser.js 162KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392
  1. /**
  2. * @license Angular v5.2.11
  3. * (c) 2010-2018 Google, Inc. https://angular.io/
  4. * License: MIT
  5. */
  6. import { CommonModule, DOCUMENT, PlatformLocation, ɵPLATFORM_BROWSER_ID, ɵparseCookieValue } from '@angular/common';
  7. import { APP_ID, APP_INITIALIZER, ApplicationInitStatus, ApplicationModule, ApplicationRef, ErrorHandler, Inject, Injectable, InjectionToken, Injector, NgModule, NgProbeToken, NgZone, Optional, PLATFORM_ID, PLATFORM_INITIALIZER, RendererFactory2, RendererStyleFlags2, Sanitizer, SecurityContext, SkipSelf, Testability, Version, ViewEncapsulation, createPlatformFactory, getDebugNode, isDevMode, platformCore, setTestabilityGetter, ɵglobal } from '@angular/core';
  8. import { __assign, __extends } from 'tslib';
  9. /**
  10. * @fileoverview added by tsickle
  11. * @suppress {checkTypes} checked by tsc
  12. */
  13. /**
  14. * @license
  15. * Copyright Google Inc. All Rights Reserved.
  16. *
  17. * Use of this source code is governed by an MIT-style license that can be
  18. * found in the LICENSE file at https://angular.io/license
  19. */
  20. var _DOM = /** @type {?} */ ((null));
  21. /**
  22. * @return {?}
  23. */
  24. function getDOM() {
  25. return _DOM;
  26. }
  27. /**
  28. * @param {?} adapter
  29. * @return {?}
  30. */
  31. /**
  32. * @param {?} adapter
  33. * @return {?}
  34. */
  35. function setRootDomAdapter(adapter) {
  36. if (!_DOM) {
  37. _DOM = adapter;
  38. }
  39. }
  40. /**
  41. * Provides DOM operations in an environment-agnostic way.
  42. *
  43. * \@security Tread carefully! Interacting with the DOM directly is dangerous and
  44. * can introduce XSS risks.
  45. * @abstract
  46. */
  47. var DomAdapter = /** @class */ (function () {
  48. function DomAdapter() {
  49. this.resourceLoaderType = /** @type {?} */ ((null));
  50. }
  51. Object.defineProperty(DomAdapter.prototype, "attrToPropMap", {
  52. /**
  53. * Maps attribute names to their corresponding property names for cases
  54. * where attribute name doesn't match property name.
  55. */
  56. get: /**
  57. * Maps attribute names to their corresponding property names for cases
  58. * where attribute name doesn't match property name.
  59. * @return {?}
  60. */
  61. function () { return this._attrToPropMap; },
  62. set: /**
  63. * @param {?} value
  64. * @return {?}
  65. */
  66. function (value) { this._attrToPropMap = value; },
  67. enumerable: true,
  68. configurable: true
  69. });
  70. return DomAdapter;
  71. }());
  72. /**
  73. * @fileoverview added by tsickle
  74. * @suppress {checkTypes} checked by tsc
  75. */
  76. /**
  77. * @license
  78. * Copyright Google Inc. All Rights Reserved.
  79. *
  80. * Use of this source code is governed by an MIT-style license that can be
  81. * found in the LICENSE file at https://angular.io/license
  82. */
  83. /**
  84. * Provides DOM operations in any browser environment.
  85. *
  86. * \@security Tread carefully! Interacting with the DOM directly is dangerous and
  87. * can introduce XSS risks.
  88. * @abstract
  89. */
  90. var GenericBrowserDomAdapter = /** @class */ (function (_super) {
  91. __extends(GenericBrowserDomAdapter, _super);
  92. function GenericBrowserDomAdapter() {
  93. var _this = _super.call(this) || this;
  94. _this._animationPrefix = null;
  95. _this._transitionEnd = null;
  96. try {
  97. var /** @type {?} */ element_1 = _this.createElement('div', document);
  98. if (_this.getStyle(element_1, 'animationName') != null) {
  99. _this._animationPrefix = '';
  100. }
  101. else {
  102. var /** @type {?} */ domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
  103. for (var /** @type {?} */ i = 0; i < domPrefixes.length; i++) {
  104. if (_this.getStyle(element_1, domPrefixes[i] + 'AnimationName') != null) {
  105. _this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
  106. break;
  107. }
  108. }
  109. }
  110. var /** @type {?} */ transEndEventNames_1 = {
  111. WebkitTransition: 'webkitTransitionEnd',
  112. MozTransition: 'transitionend',
  113. OTransition: 'oTransitionEnd otransitionend',
  114. transition: 'transitionend'
  115. };
  116. Object.keys(transEndEventNames_1).forEach(function (key) {
  117. if (_this.getStyle(element_1, key) != null) {
  118. _this._transitionEnd = transEndEventNames_1[key];
  119. }
  120. });
  121. }
  122. catch (/** @type {?} */ e) {
  123. _this._animationPrefix = null;
  124. _this._transitionEnd = null;
  125. }
  126. return _this;
  127. }
  128. /**
  129. * @param {?} el
  130. * @return {?}
  131. */
  132. GenericBrowserDomAdapter.prototype.getDistributedNodes = /**
  133. * @param {?} el
  134. * @return {?}
  135. */
  136. function (el) { return (/** @type {?} */ (el)).getDistributedNodes(); };
  137. /**
  138. * @param {?} el
  139. * @param {?} baseUrl
  140. * @param {?} href
  141. * @return {?}
  142. */
  143. GenericBrowserDomAdapter.prototype.resolveAndSetHref = /**
  144. * @param {?} el
  145. * @param {?} baseUrl
  146. * @param {?} href
  147. * @return {?}
  148. */
  149. function (el, baseUrl, href) {
  150. el.href = href == null ? baseUrl : baseUrl + '/../' + href;
  151. };
  152. /**
  153. * @return {?}
  154. */
  155. GenericBrowserDomAdapter.prototype.supportsDOMEvents = /**
  156. * @return {?}
  157. */
  158. function () { return true; };
  159. /**
  160. * @return {?}
  161. */
  162. GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = /**
  163. * @return {?}
  164. */
  165. function () {
  166. return typeof (/** @type {?} */ (document.body)).createShadowRoot === 'function';
  167. };
  168. /**
  169. * @return {?}
  170. */
  171. GenericBrowserDomAdapter.prototype.getAnimationPrefix = /**
  172. * @return {?}
  173. */
  174. function () { return this._animationPrefix ? this._animationPrefix : ''; };
  175. /**
  176. * @return {?}
  177. */
  178. GenericBrowserDomAdapter.prototype.getTransitionEnd = /**
  179. * @return {?}
  180. */
  181. function () { return this._transitionEnd ? this._transitionEnd : ''; };
  182. /**
  183. * @return {?}
  184. */
  185. GenericBrowserDomAdapter.prototype.supportsAnimation = /**
  186. * @return {?}
  187. */
  188. function () {
  189. return this._animationPrefix != null && this._transitionEnd != null;
  190. };
  191. return GenericBrowserDomAdapter;
  192. }(DomAdapter));
  193. /**
  194. * @fileoverview added by tsickle
  195. * @suppress {checkTypes} checked by tsc
  196. */
  197. /**
  198. * @license
  199. * Copyright Google Inc. All Rights Reserved.
  200. *
  201. * Use of this source code is governed by an MIT-style license that can be
  202. * found in the LICENSE file at https://angular.io/license
  203. */
  204. var _attrToPropMap = {
  205. 'class': 'className',
  206. 'innerHtml': 'innerHTML',
  207. 'readonly': 'readOnly',
  208. 'tabindex': 'tabIndex',
  209. };
  210. var DOM_KEY_LOCATION_NUMPAD = 3;
  211. // Map to convert some key or keyIdentifier values to what will be returned by getEventKey
  212. var _keyMap = {
  213. // The following values are here for cross-browser compatibility and to match the W3C standard
  214. // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
  215. '\b': 'Backspace',
  216. '\t': 'Tab',
  217. '\x7F': 'Delete',
  218. '\x1B': 'Escape',
  219. 'Del': 'Delete',
  220. 'Esc': 'Escape',
  221. 'Left': 'ArrowLeft',
  222. 'Right': 'ArrowRight',
  223. 'Up': 'ArrowUp',
  224. 'Down': 'ArrowDown',
  225. 'Menu': 'ContextMenu',
  226. 'Scroll': 'ScrollLock',
  227. 'Win': 'OS'
  228. };
  229. // There is a bug in Chrome for numeric keypad keys:
  230. // https://code.google.com/p/chromium/issues/detail?id=155654
  231. // 1, 2, 3 ... are reported as A, B, C ...
  232. var _chromeNumKeyPadMap = {
  233. 'A': '1',
  234. 'B': '2',
  235. 'C': '3',
  236. 'D': '4',
  237. 'E': '5',
  238. 'F': '6',
  239. 'G': '7',
  240. 'H': '8',
  241. 'I': '9',
  242. 'J': '*',
  243. 'K': '+',
  244. 'M': '-',
  245. 'N': '.',
  246. 'O': '/',
  247. '\x60': '0',
  248. '\x90': 'NumLock'
  249. };
  250. var nodeContains;
  251. if (ɵglobal['Node']) {
  252. nodeContains = ɵglobal['Node'].prototype.contains || function (node) {
  253. return !!(this.compareDocumentPosition(node) & 16);
  254. };
  255. }
  256. /**
  257. * A `DomAdapter` powered by full browser DOM APIs.
  258. *
  259. * \@security Tread carefully! Interacting with the DOM directly is dangerous and
  260. * can introduce XSS risks.
  261. */
  262. var BrowserDomAdapter = /** @class */ (function (_super) {
  263. __extends(BrowserDomAdapter, _super);
  264. function BrowserDomAdapter() {
  265. return _super !== null && _super.apply(this, arguments) || this;
  266. }
  267. /**
  268. * @param {?} templateHtml
  269. * @return {?}
  270. */
  271. BrowserDomAdapter.prototype.parse = /**
  272. * @param {?} templateHtml
  273. * @return {?}
  274. */
  275. function (templateHtml) { throw new Error('parse not implemented'); };
  276. /**
  277. * @return {?}
  278. */
  279. BrowserDomAdapter.makeCurrent = /**
  280. * @return {?}
  281. */
  282. function () { setRootDomAdapter(new BrowserDomAdapter()); };
  283. /**
  284. * @param {?} element
  285. * @param {?} name
  286. * @return {?}
  287. */
  288. BrowserDomAdapter.prototype.hasProperty = /**
  289. * @param {?} element
  290. * @param {?} name
  291. * @return {?}
  292. */
  293. function (element, name) { return name in element; };
  294. /**
  295. * @param {?} el
  296. * @param {?} name
  297. * @param {?} value
  298. * @return {?}
  299. */
  300. BrowserDomAdapter.prototype.setProperty = /**
  301. * @param {?} el
  302. * @param {?} name
  303. * @param {?} value
  304. * @return {?}
  305. */
  306. function (el, name, value) { (/** @type {?} */ (el))[name] = value; };
  307. /**
  308. * @param {?} el
  309. * @param {?} name
  310. * @return {?}
  311. */
  312. BrowserDomAdapter.prototype.getProperty = /**
  313. * @param {?} el
  314. * @param {?} name
  315. * @return {?}
  316. */
  317. function (el, name) { return (/** @type {?} */ (el))[name]; };
  318. /**
  319. * @param {?} el
  320. * @param {?} methodName
  321. * @param {?} args
  322. * @return {?}
  323. */
  324. BrowserDomAdapter.prototype.invoke = /**
  325. * @param {?} el
  326. * @param {?} methodName
  327. * @param {?} args
  328. * @return {?}
  329. */
  330. function (el, methodName, args) {
  331. (_a = (/** @type {?} */ (el)))[methodName].apply(_a, args);
  332. var _a;
  333. };
  334. // TODO(tbosch): move this into a separate environment class once we have it
  335. /**
  336. * @param {?} error
  337. * @return {?}
  338. */
  339. BrowserDomAdapter.prototype.logError = /**
  340. * @param {?} error
  341. * @return {?}
  342. */
  343. function (error) {
  344. if (window.console) {
  345. if (console.error) {
  346. console.error(error);
  347. }
  348. else {
  349. console.log(error);
  350. }
  351. }
  352. };
  353. /**
  354. * @param {?} error
  355. * @return {?}
  356. */
  357. BrowserDomAdapter.prototype.log = /**
  358. * @param {?} error
  359. * @return {?}
  360. */
  361. function (error) {
  362. if (window.console) {
  363. window.console.log && window.console.log(error);
  364. }
  365. };
  366. /**
  367. * @param {?} error
  368. * @return {?}
  369. */
  370. BrowserDomAdapter.prototype.logGroup = /**
  371. * @param {?} error
  372. * @return {?}
  373. */
  374. function (error) {
  375. if (window.console) {
  376. window.console.group && window.console.group(error);
  377. }
  378. };
  379. /**
  380. * @return {?}
  381. */
  382. BrowserDomAdapter.prototype.logGroupEnd = /**
  383. * @return {?}
  384. */
  385. function () {
  386. if (window.console) {
  387. window.console.groupEnd && window.console.groupEnd();
  388. }
  389. };
  390. Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
  391. get: /**
  392. * @return {?}
  393. */
  394. function () { return _attrToPropMap; },
  395. enumerable: true,
  396. configurable: true
  397. });
  398. /**
  399. * @param {?} nodeA
  400. * @param {?} nodeB
  401. * @return {?}
  402. */
  403. BrowserDomAdapter.prototype.contains = /**
  404. * @param {?} nodeA
  405. * @param {?} nodeB
  406. * @return {?}
  407. */
  408. function (nodeA, nodeB) { return nodeContains.call(nodeA, nodeB); };
  409. /**
  410. * @param {?} el
  411. * @param {?} selector
  412. * @return {?}
  413. */
  414. BrowserDomAdapter.prototype.querySelector = /**
  415. * @param {?} el
  416. * @param {?} selector
  417. * @return {?}
  418. */
  419. function (el, selector) { return el.querySelector(selector); };
  420. /**
  421. * @param {?} el
  422. * @param {?} selector
  423. * @return {?}
  424. */
  425. BrowserDomAdapter.prototype.querySelectorAll = /**
  426. * @param {?} el
  427. * @param {?} selector
  428. * @return {?}
  429. */
  430. function (el, selector) { return el.querySelectorAll(selector); };
  431. /**
  432. * @param {?} el
  433. * @param {?} evt
  434. * @param {?} listener
  435. * @return {?}
  436. */
  437. BrowserDomAdapter.prototype.on = /**
  438. * @param {?} el
  439. * @param {?} evt
  440. * @param {?} listener
  441. * @return {?}
  442. */
  443. function (el, evt, listener) { el.addEventListener(evt, listener, false); };
  444. /**
  445. * @param {?} el
  446. * @param {?} evt
  447. * @param {?} listener
  448. * @return {?}
  449. */
  450. BrowserDomAdapter.prototype.onAndCancel = /**
  451. * @param {?} el
  452. * @param {?} evt
  453. * @param {?} listener
  454. * @return {?}
  455. */
  456. function (el, evt, listener) {
  457. el.addEventListener(evt, listener, false);
  458. // Needed to follow Dart's subscription semantic, until fix of
  459. // https://code.google.com/p/dart/issues/detail?id=17406
  460. return function () { el.removeEventListener(evt, listener, false); };
  461. };
  462. /**
  463. * @param {?} el
  464. * @param {?} evt
  465. * @return {?}
  466. */
  467. BrowserDomAdapter.prototype.dispatchEvent = /**
  468. * @param {?} el
  469. * @param {?} evt
  470. * @return {?}
  471. */
  472. function (el, evt) { el.dispatchEvent(evt); };
  473. /**
  474. * @param {?} eventType
  475. * @return {?}
  476. */
  477. BrowserDomAdapter.prototype.createMouseEvent = /**
  478. * @param {?} eventType
  479. * @return {?}
  480. */
  481. function (eventType) {
  482. var /** @type {?} */ evt = this.getDefaultDocument().createEvent('MouseEvent');
  483. evt.initEvent(eventType, true, true);
  484. return evt;
  485. };
  486. /**
  487. * @param {?} eventType
  488. * @return {?}
  489. */
  490. BrowserDomAdapter.prototype.createEvent = /**
  491. * @param {?} eventType
  492. * @return {?}
  493. */
  494. function (eventType) {
  495. var /** @type {?} */ evt = this.getDefaultDocument().createEvent('Event');
  496. evt.initEvent(eventType, true, true);
  497. return evt;
  498. };
  499. /**
  500. * @param {?} evt
  501. * @return {?}
  502. */
  503. BrowserDomAdapter.prototype.preventDefault = /**
  504. * @param {?} evt
  505. * @return {?}
  506. */
  507. function (evt) {
  508. evt.preventDefault();
  509. evt.returnValue = false;
  510. };
  511. /**
  512. * @param {?} evt
  513. * @return {?}
  514. */
  515. BrowserDomAdapter.prototype.isPrevented = /**
  516. * @param {?} evt
  517. * @return {?}
  518. */
  519. function (evt) {
  520. return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
  521. };
  522. /**
  523. * @param {?} el
  524. * @return {?}
  525. */
  526. BrowserDomAdapter.prototype.getInnerHTML = /**
  527. * @param {?} el
  528. * @return {?}
  529. */
  530. function (el) { return el.innerHTML; };
  531. /**
  532. * @param {?} el
  533. * @return {?}
  534. */
  535. BrowserDomAdapter.prototype.getTemplateContent = /**
  536. * @param {?} el
  537. * @return {?}
  538. */
  539. function (el) {
  540. return 'content' in el && this.isTemplateElement(el) ? (/** @type {?} */ (el)).content : null;
  541. };
  542. /**
  543. * @param {?} el
  544. * @return {?}
  545. */
  546. BrowserDomAdapter.prototype.getOuterHTML = /**
  547. * @param {?} el
  548. * @return {?}
  549. */
  550. function (el) { return el.outerHTML; };
  551. /**
  552. * @param {?} node
  553. * @return {?}
  554. */
  555. BrowserDomAdapter.prototype.nodeName = /**
  556. * @param {?} node
  557. * @return {?}
  558. */
  559. function (node) { return node.nodeName; };
  560. /**
  561. * @param {?} node
  562. * @return {?}
  563. */
  564. BrowserDomAdapter.prototype.nodeValue = /**
  565. * @param {?} node
  566. * @return {?}
  567. */
  568. function (node) { return node.nodeValue; };
  569. /**
  570. * @param {?} node
  571. * @return {?}
  572. */
  573. BrowserDomAdapter.prototype.type = /**
  574. * @param {?} node
  575. * @return {?}
  576. */
  577. function (node) { return node.type; };
  578. /**
  579. * @param {?} node
  580. * @return {?}
  581. */
  582. BrowserDomAdapter.prototype.content = /**
  583. * @param {?} node
  584. * @return {?}
  585. */
  586. function (node) {
  587. if (this.hasProperty(node, 'content')) {
  588. return (/** @type {?} */ (node)).content;
  589. }
  590. else {
  591. return node;
  592. }
  593. };
  594. /**
  595. * @param {?} el
  596. * @return {?}
  597. */
  598. BrowserDomAdapter.prototype.firstChild = /**
  599. * @param {?} el
  600. * @return {?}
  601. */
  602. function (el) { return el.firstChild; };
  603. /**
  604. * @param {?} el
  605. * @return {?}
  606. */
  607. BrowserDomAdapter.prototype.nextSibling = /**
  608. * @param {?} el
  609. * @return {?}
  610. */
  611. function (el) { return el.nextSibling; };
  612. /**
  613. * @param {?} el
  614. * @return {?}
  615. */
  616. BrowserDomAdapter.prototype.parentElement = /**
  617. * @param {?} el
  618. * @return {?}
  619. */
  620. function (el) { return el.parentNode; };
  621. /**
  622. * @param {?} el
  623. * @return {?}
  624. */
  625. BrowserDomAdapter.prototype.childNodes = /**
  626. * @param {?} el
  627. * @return {?}
  628. */
  629. function (el) { return el.childNodes; };
  630. /**
  631. * @param {?} el
  632. * @return {?}
  633. */
  634. BrowserDomAdapter.prototype.childNodesAsList = /**
  635. * @param {?} el
  636. * @return {?}
  637. */
  638. function (el) {
  639. var /** @type {?} */ childNodes = el.childNodes;
  640. var /** @type {?} */ res = new Array(childNodes.length);
  641. for (var /** @type {?} */ i = 0; i < childNodes.length; i++) {
  642. res[i] = childNodes[i];
  643. }
  644. return res;
  645. };
  646. /**
  647. * @param {?} el
  648. * @return {?}
  649. */
  650. BrowserDomAdapter.prototype.clearNodes = /**
  651. * @param {?} el
  652. * @return {?}
  653. */
  654. function (el) {
  655. while (el.firstChild) {
  656. el.removeChild(el.firstChild);
  657. }
  658. };
  659. /**
  660. * @param {?} el
  661. * @param {?} node
  662. * @return {?}
  663. */
  664. BrowserDomAdapter.prototype.appendChild = /**
  665. * @param {?} el
  666. * @param {?} node
  667. * @return {?}
  668. */
  669. function (el, node) { el.appendChild(node); };
  670. /**
  671. * @param {?} el
  672. * @param {?} node
  673. * @return {?}
  674. */
  675. BrowserDomAdapter.prototype.removeChild = /**
  676. * @param {?} el
  677. * @param {?} node
  678. * @return {?}
  679. */
  680. function (el, node) { el.removeChild(node); };
  681. /**
  682. * @param {?} el
  683. * @param {?} newChild
  684. * @param {?} oldChild
  685. * @return {?}
  686. */
  687. BrowserDomAdapter.prototype.replaceChild = /**
  688. * @param {?} el
  689. * @param {?} newChild
  690. * @param {?} oldChild
  691. * @return {?}
  692. */
  693. function (el, newChild, oldChild) { el.replaceChild(newChild, oldChild); };
  694. /**
  695. * @param {?} node
  696. * @return {?}
  697. */
  698. BrowserDomAdapter.prototype.remove = /**
  699. * @param {?} node
  700. * @return {?}
  701. */
  702. function (node) {
  703. if (node.parentNode) {
  704. node.parentNode.removeChild(node);
  705. }
  706. return node;
  707. };
  708. /**
  709. * @param {?} parent
  710. * @param {?} ref
  711. * @param {?} node
  712. * @return {?}
  713. */
  714. BrowserDomAdapter.prototype.insertBefore = /**
  715. * @param {?} parent
  716. * @param {?} ref
  717. * @param {?} node
  718. * @return {?}
  719. */
  720. function (parent, ref, node) { parent.insertBefore(node, ref); };
  721. /**
  722. * @param {?} parent
  723. * @param {?} ref
  724. * @param {?} nodes
  725. * @return {?}
  726. */
  727. BrowserDomAdapter.prototype.insertAllBefore = /**
  728. * @param {?} parent
  729. * @param {?} ref
  730. * @param {?} nodes
  731. * @return {?}
  732. */
  733. function (parent, ref, nodes) {
  734. nodes.forEach(function (n) { return parent.insertBefore(n, ref); });
  735. };
  736. /**
  737. * @param {?} parent
  738. * @param {?} ref
  739. * @param {?} node
  740. * @return {?}
  741. */
  742. BrowserDomAdapter.prototype.insertAfter = /**
  743. * @param {?} parent
  744. * @param {?} ref
  745. * @param {?} node
  746. * @return {?}
  747. */
  748. function (parent, ref, node) { parent.insertBefore(node, ref.nextSibling); };
  749. /**
  750. * @param {?} el
  751. * @param {?} value
  752. * @return {?}
  753. */
  754. BrowserDomAdapter.prototype.setInnerHTML = /**
  755. * @param {?} el
  756. * @param {?} value
  757. * @return {?}
  758. */
  759. function (el, value) { el.innerHTML = value; };
  760. /**
  761. * @param {?} el
  762. * @return {?}
  763. */
  764. BrowserDomAdapter.prototype.getText = /**
  765. * @param {?} el
  766. * @return {?}
  767. */
  768. function (el) { return el.textContent; };
  769. /**
  770. * @param {?} el
  771. * @param {?} value
  772. * @return {?}
  773. */
  774. BrowserDomAdapter.prototype.setText = /**
  775. * @param {?} el
  776. * @param {?} value
  777. * @return {?}
  778. */
  779. function (el, value) { el.textContent = value; };
  780. /**
  781. * @param {?} el
  782. * @return {?}
  783. */
  784. BrowserDomAdapter.prototype.getValue = /**
  785. * @param {?} el
  786. * @return {?}
  787. */
  788. function (el) { return el.value; };
  789. /**
  790. * @param {?} el
  791. * @param {?} value
  792. * @return {?}
  793. */
  794. BrowserDomAdapter.prototype.setValue = /**
  795. * @param {?} el
  796. * @param {?} value
  797. * @return {?}
  798. */
  799. function (el, value) { el.value = value; };
  800. /**
  801. * @param {?} el
  802. * @return {?}
  803. */
  804. BrowserDomAdapter.prototype.getChecked = /**
  805. * @param {?} el
  806. * @return {?}
  807. */
  808. function (el) { return el.checked; };
  809. /**
  810. * @param {?} el
  811. * @param {?} value
  812. * @return {?}
  813. */
  814. BrowserDomAdapter.prototype.setChecked = /**
  815. * @param {?} el
  816. * @param {?} value
  817. * @return {?}
  818. */
  819. function (el, value) { el.checked = value; };
  820. /**
  821. * @param {?} text
  822. * @return {?}
  823. */
  824. BrowserDomAdapter.prototype.createComment = /**
  825. * @param {?} text
  826. * @return {?}
  827. */
  828. function (text) { return this.getDefaultDocument().createComment(text); };
  829. /**
  830. * @param {?} html
  831. * @return {?}
  832. */
  833. BrowserDomAdapter.prototype.createTemplate = /**
  834. * @param {?} html
  835. * @return {?}
  836. */
  837. function (html) {
  838. var /** @type {?} */ t = this.getDefaultDocument().createElement('template');
  839. t.innerHTML = html;
  840. return t;
  841. };
  842. /**
  843. * @param {?} tagName
  844. * @param {?=} doc
  845. * @return {?}
  846. */
  847. BrowserDomAdapter.prototype.createElement = /**
  848. * @param {?} tagName
  849. * @param {?=} doc
  850. * @return {?}
  851. */
  852. function (tagName, doc) {
  853. doc = doc || this.getDefaultDocument();
  854. return doc.createElement(tagName);
  855. };
  856. /**
  857. * @param {?} ns
  858. * @param {?} tagName
  859. * @param {?=} doc
  860. * @return {?}
  861. */
  862. BrowserDomAdapter.prototype.createElementNS = /**
  863. * @param {?} ns
  864. * @param {?} tagName
  865. * @param {?=} doc
  866. * @return {?}
  867. */
  868. function (ns, tagName, doc) {
  869. doc = doc || this.getDefaultDocument();
  870. return doc.createElementNS(ns, tagName);
  871. };
  872. /**
  873. * @param {?} text
  874. * @param {?=} doc
  875. * @return {?}
  876. */
  877. BrowserDomAdapter.prototype.createTextNode = /**
  878. * @param {?} text
  879. * @param {?=} doc
  880. * @return {?}
  881. */
  882. function (text, doc) {
  883. doc = doc || this.getDefaultDocument();
  884. return doc.createTextNode(text);
  885. };
  886. /**
  887. * @param {?} attrName
  888. * @param {?} attrValue
  889. * @param {?=} doc
  890. * @return {?}
  891. */
  892. BrowserDomAdapter.prototype.createScriptTag = /**
  893. * @param {?} attrName
  894. * @param {?} attrValue
  895. * @param {?=} doc
  896. * @return {?}
  897. */
  898. function (attrName, attrValue, doc) {
  899. doc = doc || this.getDefaultDocument();
  900. var /** @type {?} */ el = /** @type {?} */ (doc.createElement('SCRIPT'));
  901. el.setAttribute(attrName, attrValue);
  902. return el;
  903. };
  904. /**
  905. * @param {?} css
  906. * @param {?=} doc
  907. * @return {?}
  908. */
  909. BrowserDomAdapter.prototype.createStyleElement = /**
  910. * @param {?} css
  911. * @param {?=} doc
  912. * @return {?}
  913. */
  914. function (css, doc) {
  915. doc = doc || this.getDefaultDocument();
  916. var /** @type {?} */ style = /** @type {?} */ (doc.createElement('style'));
  917. this.appendChild(style, this.createTextNode(css, doc));
  918. return style;
  919. };
  920. /**
  921. * @param {?} el
  922. * @return {?}
  923. */
  924. BrowserDomAdapter.prototype.createShadowRoot = /**
  925. * @param {?} el
  926. * @return {?}
  927. */
  928. function (el) { return (/** @type {?} */ (el)).createShadowRoot(); };
  929. /**
  930. * @param {?} el
  931. * @return {?}
  932. */
  933. BrowserDomAdapter.prototype.getShadowRoot = /**
  934. * @param {?} el
  935. * @return {?}
  936. */
  937. function (el) { return (/** @type {?} */ (el)).shadowRoot; };
  938. /**
  939. * @param {?} el
  940. * @return {?}
  941. */
  942. BrowserDomAdapter.prototype.getHost = /**
  943. * @param {?} el
  944. * @return {?}
  945. */
  946. function (el) { return (/** @type {?} */ (el)).host; };
  947. /**
  948. * @param {?} node
  949. * @return {?}
  950. */
  951. BrowserDomAdapter.prototype.clone = /**
  952. * @param {?} node
  953. * @return {?}
  954. */
  955. function (node) { return node.cloneNode(true); };
  956. /**
  957. * @param {?} element
  958. * @param {?} name
  959. * @return {?}
  960. */
  961. BrowserDomAdapter.prototype.getElementsByClassName = /**
  962. * @param {?} element
  963. * @param {?} name
  964. * @return {?}
  965. */
  966. function (element, name) {
  967. return element.getElementsByClassName(name);
  968. };
  969. /**
  970. * @param {?} element
  971. * @param {?} name
  972. * @return {?}
  973. */
  974. BrowserDomAdapter.prototype.getElementsByTagName = /**
  975. * @param {?} element
  976. * @param {?} name
  977. * @return {?}
  978. */
  979. function (element, name) {
  980. return element.getElementsByTagName(name);
  981. };
  982. /**
  983. * @param {?} element
  984. * @return {?}
  985. */
  986. BrowserDomAdapter.prototype.classList = /**
  987. * @param {?} element
  988. * @return {?}
  989. */
  990. function (element) { return Array.prototype.slice.call(element.classList, 0); };
  991. /**
  992. * @param {?} element
  993. * @param {?} className
  994. * @return {?}
  995. */
  996. BrowserDomAdapter.prototype.addClass = /**
  997. * @param {?} element
  998. * @param {?} className
  999. * @return {?}
  1000. */
  1001. function (element, className) { element.classList.add(className); };
  1002. /**
  1003. * @param {?} element
  1004. * @param {?} className
  1005. * @return {?}
  1006. */
  1007. BrowserDomAdapter.prototype.removeClass = /**
  1008. * @param {?} element
  1009. * @param {?} className
  1010. * @return {?}
  1011. */
  1012. function (element, className) { element.classList.remove(className); };
  1013. /**
  1014. * @param {?} element
  1015. * @param {?} className
  1016. * @return {?}
  1017. */
  1018. BrowserDomAdapter.prototype.hasClass = /**
  1019. * @param {?} element
  1020. * @param {?} className
  1021. * @return {?}
  1022. */
  1023. function (element, className) {
  1024. return element.classList.contains(className);
  1025. };
  1026. /**
  1027. * @param {?} element
  1028. * @param {?} styleName
  1029. * @param {?} styleValue
  1030. * @return {?}
  1031. */
  1032. BrowserDomAdapter.prototype.setStyle = /**
  1033. * @param {?} element
  1034. * @param {?} styleName
  1035. * @param {?} styleValue
  1036. * @return {?}
  1037. */
  1038. function (element, styleName, styleValue) {
  1039. element.style[styleName] = styleValue;
  1040. };
  1041. /**
  1042. * @param {?} element
  1043. * @param {?} stylename
  1044. * @return {?}
  1045. */
  1046. BrowserDomAdapter.prototype.removeStyle = /**
  1047. * @param {?} element
  1048. * @param {?} stylename
  1049. * @return {?}
  1050. */
  1051. function (element, stylename) {
  1052. // IE requires '' instead of null
  1053. // see https://github.com/angular/angular/issues/7916
  1054. element.style[stylename] = '';
  1055. };
  1056. /**
  1057. * @param {?} element
  1058. * @param {?} stylename
  1059. * @return {?}
  1060. */
  1061. BrowserDomAdapter.prototype.getStyle = /**
  1062. * @param {?} element
  1063. * @param {?} stylename
  1064. * @return {?}
  1065. */
  1066. function (element, stylename) { return element.style[stylename]; };
  1067. /**
  1068. * @param {?} element
  1069. * @param {?} styleName
  1070. * @param {?=} styleValue
  1071. * @return {?}
  1072. */
  1073. BrowserDomAdapter.prototype.hasStyle = /**
  1074. * @param {?} element
  1075. * @param {?} styleName
  1076. * @param {?=} styleValue
  1077. * @return {?}
  1078. */
  1079. function (element, styleName, styleValue) {
  1080. var /** @type {?} */ value = this.getStyle(element, styleName) || '';
  1081. return styleValue ? value == styleValue : value.length > 0;
  1082. };
  1083. /**
  1084. * @param {?} element
  1085. * @return {?}
  1086. */
  1087. BrowserDomAdapter.prototype.tagName = /**
  1088. * @param {?} element
  1089. * @return {?}
  1090. */
  1091. function (element) { return element.tagName; };
  1092. /**
  1093. * @param {?} element
  1094. * @return {?}
  1095. */
  1096. BrowserDomAdapter.prototype.attributeMap = /**
  1097. * @param {?} element
  1098. * @return {?}
  1099. */
  1100. function (element) {
  1101. var /** @type {?} */ res = new Map();
  1102. var /** @type {?} */ elAttrs = element.attributes;
  1103. for (var /** @type {?} */ i = 0; i < elAttrs.length; i++) {
  1104. var /** @type {?} */ attrib = elAttrs.item(i);
  1105. res.set(attrib.name, attrib.value);
  1106. }
  1107. return res;
  1108. };
  1109. /**
  1110. * @param {?} element
  1111. * @param {?} attribute
  1112. * @return {?}
  1113. */
  1114. BrowserDomAdapter.prototype.hasAttribute = /**
  1115. * @param {?} element
  1116. * @param {?} attribute
  1117. * @return {?}
  1118. */
  1119. function (element, attribute) {
  1120. return element.hasAttribute(attribute);
  1121. };
  1122. /**
  1123. * @param {?} element
  1124. * @param {?} ns
  1125. * @param {?} attribute
  1126. * @return {?}
  1127. */
  1128. BrowserDomAdapter.prototype.hasAttributeNS = /**
  1129. * @param {?} element
  1130. * @param {?} ns
  1131. * @param {?} attribute
  1132. * @return {?}
  1133. */
  1134. function (element, ns, attribute) {
  1135. return element.hasAttributeNS(ns, attribute);
  1136. };
  1137. /**
  1138. * @param {?} element
  1139. * @param {?} attribute
  1140. * @return {?}
  1141. */
  1142. BrowserDomAdapter.prototype.getAttribute = /**
  1143. * @param {?} element
  1144. * @param {?} attribute
  1145. * @return {?}
  1146. */
  1147. function (element, attribute) {
  1148. return element.getAttribute(attribute);
  1149. };
  1150. /**
  1151. * @param {?} element
  1152. * @param {?} ns
  1153. * @param {?} name
  1154. * @return {?}
  1155. */
  1156. BrowserDomAdapter.prototype.getAttributeNS = /**
  1157. * @param {?} element
  1158. * @param {?} ns
  1159. * @param {?} name
  1160. * @return {?}
  1161. */
  1162. function (element, ns, name) {
  1163. return element.getAttributeNS(ns, name);
  1164. };
  1165. /**
  1166. * @param {?} element
  1167. * @param {?} name
  1168. * @param {?} value
  1169. * @return {?}
  1170. */
  1171. BrowserDomAdapter.prototype.setAttribute = /**
  1172. * @param {?} element
  1173. * @param {?} name
  1174. * @param {?} value
  1175. * @return {?}
  1176. */
  1177. function (element, name, value) { element.setAttribute(name, value); };
  1178. /**
  1179. * @param {?} element
  1180. * @param {?} ns
  1181. * @param {?} name
  1182. * @param {?} value
  1183. * @return {?}
  1184. */
  1185. BrowserDomAdapter.prototype.setAttributeNS = /**
  1186. * @param {?} element
  1187. * @param {?} ns
  1188. * @param {?} name
  1189. * @param {?} value
  1190. * @return {?}
  1191. */
  1192. function (element, ns, name, value) {
  1193. element.setAttributeNS(ns, name, value);
  1194. };
  1195. /**
  1196. * @param {?} element
  1197. * @param {?} attribute
  1198. * @return {?}
  1199. */
  1200. BrowserDomAdapter.prototype.removeAttribute = /**
  1201. * @param {?} element
  1202. * @param {?} attribute
  1203. * @return {?}
  1204. */
  1205. function (element, attribute) { element.removeAttribute(attribute); };
  1206. /**
  1207. * @param {?} element
  1208. * @param {?} ns
  1209. * @param {?} name
  1210. * @return {?}
  1211. */
  1212. BrowserDomAdapter.prototype.removeAttributeNS = /**
  1213. * @param {?} element
  1214. * @param {?} ns
  1215. * @param {?} name
  1216. * @return {?}
  1217. */
  1218. function (element, ns, name) {
  1219. element.removeAttributeNS(ns, name);
  1220. };
  1221. /**
  1222. * @param {?} el
  1223. * @return {?}
  1224. */
  1225. BrowserDomAdapter.prototype.templateAwareRoot = /**
  1226. * @param {?} el
  1227. * @return {?}
  1228. */
  1229. function (el) { return this.isTemplateElement(el) ? this.content(el) : el; };
  1230. /**
  1231. * @return {?}
  1232. */
  1233. BrowserDomAdapter.prototype.createHtmlDocument = /**
  1234. * @return {?}
  1235. */
  1236. function () {
  1237. return document.implementation.createHTMLDocument('fakeTitle');
  1238. };
  1239. /**
  1240. * @return {?}
  1241. */
  1242. BrowserDomAdapter.prototype.getDefaultDocument = /**
  1243. * @return {?}
  1244. */
  1245. function () { return document; };
  1246. /**
  1247. * @param {?} el
  1248. * @return {?}
  1249. */
  1250. BrowserDomAdapter.prototype.getBoundingClientRect = /**
  1251. * @param {?} el
  1252. * @return {?}
  1253. */
  1254. function (el) {
  1255. try {
  1256. return el.getBoundingClientRect();
  1257. }
  1258. catch (/** @type {?} */ e) {
  1259. return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
  1260. }
  1261. };
  1262. /**
  1263. * @param {?} doc
  1264. * @return {?}
  1265. */
  1266. BrowserDomAdapter.prototype.getTitle = /**
  1267. * @param {?} doc
  1268. * @return {?}
  1269. */
  1270. function (doc) { return doc.title; };
  1271. /**
  1272. * @param {?} doc
  1273. * @param {?} newTitle
  1274. * @return {?}
  1275. */
  1276. BrowserDomAdapter.prototype.setTitle = /**
  1277. * @param {?} doc
  1278. * @param {?} newTitle
  1279. * @return {?}
  1280. */
  1281. function (doc, newTitle) { doc.title = newTitle || ''; };
  1282. /**
  1283. * @param {?} n
  1284. * @param {?} selector
  1285. * @return {?}
  1286. */
  1287. BrowserDomAdapter.prototype.elementMatches = /**
  1288. * @param {?} n
  1289. * @param {?} selector
  1290. * @return {?}
  1291. */
  1292. function (n, selector) {
  1293. if (this.isElementNode(n)) {
  1294. return n.matches && n.matches(selector) ||
  1295. n.msMatchesSelector && n.msMatchesSelector(selector) ||
  1296. n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
  1297. }
  1298. return false;
  1299. };
  1300. /**
  1301. * @param {?} el
  1302. * @return {?}
  1303. */
  1304. BrowserDomAdapter.prototype.isTemplateElement = /**
  1305. * @param {?} el
  1306. * @return {?}
  1307. */
  1308. function (el) {
  1309. return this.isElementNode(el) && el.nodeName === 'TEMPLATE';
  1310. };
  1311. /**
  1312. * @param {?} node
  1313. * @return {?}
  1314. */
  1315. BrowserDomAdapter.prototype.isTextNode = /**
  1316. * @param {?} node
  1317. * @return {?}
  1318. */
  1319. function (node) { return node.nodeType === Node.TEXT_NODE; };
  1320. /**
  1321. * @param {?} node
  1322. * @return {?}
  1323. */
  1324. BrowserDomAdapter.prototype.isCommentNode = /**
  1325. * @param {?} node
  1326. * @return {?}
  1327. */
  1328. function (node) { return node.nodeType === Node.COMMENT_NODE; };
  1329. /**
  1330. * @param {?} node
  1331. * @return {?}
  1332. */
  1333. BrowserDomAdapter.prototype.isElementNode = /**
  1334. * @param {?} node
  1335. * @return {?}
  1336. */
  1337. function (node) { return node.nodeType === Node.ELEMENT_NODE; };
  1338. /**
  1339. * @param {?} node
  1340. * @return {?}
  1341. */
  1342. BrowserDomAdapter.prototype.hasShadowRoot = /**
  1343. * @param {?} node
  1344. * @return {?}
  1345. */
  1346. function (node) {
  1347. return node.shadowRoot != null && node instanceof HTMLElement;
  1348. };
  1349. /**
  1350. * @param {?} node
  1351. * @return {?}
  1352. */
  1353. BrowserDomAdapter.prototype.isShadowRoot = /**
  1354. * @param {?} node
  1355. * @return {?}
  1356. */
  1357. function (node) { return node instanceof DocumentFragment; };
  1358. /**
  1359. * @param {?} node
  1360. * @return {?}
  1361. */
  1362. BrowserDomAdapter.prototype.importIntoDoc = /**
  1363. * @param {?} node
  1364. * @return {?}
  1365. */
  1366. function (node) { return document.importNode(this.templateAwareRoot(node), true); };
  1367. /**
  1368. * @param {?} node
  1369. * @return {?}
  1370. */
  1371. BrowserDomAdapter.prototype.adoptNode = /**
  1372. * @param {?} node
  1373. * @return {?}
  1374. */
  1375. function (node) { return document.adoptNode(node); };
  1376. /**
  1377. * @param {?} el
  1378. * @return {?}
  1379. */
  1380. BrowserDomAdapter.prototype.getHref = /**
  1381. * @param {?} el
  1382. * @return {?}
  1383. */
  1384. function (el) { return /** @type {?} */ ((el.getAttribute('href'))); };
  1385. /**
  1386. * @param {?} event
  1387. * @return {?}
  1388. */
  1389. BrowserDomAdapter.prototype.getEventKey = /**
  1390. * @param {?} event
  1391. * @return {?}
  1392. */
  1393. function (event) {
  1394. var /** @type {?} */ key = event.key;
  1395. if (key == null) {
  1396. key = event.keyIdentifier;
  1397. // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
  1398. // Safari cf
  1399. // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
  1400. if (key == null) {
  1401. return 'Unidentified';
  1402. }
  1403. if (key.startsWith('U+')) {
  1404. key = String.fromCharCode(parseInt(key.substring(2), 16));
  1405. if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
  1406. // There is a bug in Chrome for numeric keypad keys:
  1407. // https://code.google.com/p/chromium/issues/detail?id=155654
  1408. // 1, 2, 3 ... are reported as A, B, C ...
  1409. key = (/** @type {?} */ (_chromeNumKeyPadMap))[key];
  1410. }
  1411. }
  1412. }
  1413. return _keyMap[key] || key;
  1414. };
  1415. /**
  1416. * @param {?} doc
  1417. * @param {?} target
  1418. * @return {?}
  1419. */
  1420. BrowserDomAdapter.prototype.getGlobalEventTarget = /**
  1421. * @param {?} doc
  1422. * @param {?} target
  1423. * @return {?}
  1424. */
  1425. function (doc, target) {
  1426. if (target === 'window') {
  1427. return window;
  1428. }
  1429. if (target === 'document') {
  1430. return doc;
  1431. }
  1432. if (target === 'body') {
  1433. return doc.body;
  1434. }
  1435. return null;
  1436. };
  1437. /**
  1438. * @return {?}
  1439. */
  1440. BrowserDomAdapter.prototype.getHistory = /**
  1441. * @return {?}
  1442. */
  1443. function () { return window.history; };
  1444. /**
  1445. * @return {?}
  1446. */
  1447. BrowserDomAdapter.prototype.getLocation = /**
  1448. * @return {?}
  1449. */
  1450. function () { return window.location; };
  1451. /**
  1452. * @param {?} doc
  1453. * @return {?}
  1454. */
  1455. BrowserDomAdapter.prototype.getBaseHref = /**
  1456. * @param {?} doc
  1457. * @return {?}
  1458. */
  1459. function (doc) {
  1460. var /** @type {?} */ href = getBaseElementHref();
  1461. return href == null ? null : relativePath(href);
  1462. };
  1463. /**
  1464. * @return {?}
  1465. */
  1466. BrowserDomAdapter.prototype.resetBaseElement = /**
  1467. * @return {?}
  1468. */
  1469. function () { baseElement = null; };
  1470. /**
  1471. * @return {?}
  1472. */
  1473. BrowserDomAdapter.prototype.getUserAgent = /**
  1474. * @return {?}
  1475. */
  1476. function () { return window.navigator.userAgent; };
  1477. /**
  1478. * @param {?} element
  1479. * @param {?} name
  1480. * @param {?} value
  1481. * @return {?}
  1482. */
  1483. BrowserDomAdapter.prototype.setData = /**
  1484. * @param {?} element
  1485. * @param {?} name
  1486. * @param {?} value
  1487. * @return {?}
  1488. */
  1489. function (element, name, value) {
  1490. this.setAttribute(element, 'data-' + name, value);
  1491. };
  1492. /**
  1493. * @param {?} element
  1494. * @param {?} name
  1495. * @return {?}
  1496. */
  1497. BrowserDomAdapter.prototype.getData = /**
  1498. * @param {?} element
  1499. * @param {?} name
  1500. * @return {?}
  1501. */
  1502. function (element, name) {
  1503. return this.getAttribute(element, 'data-' + name);
  1504. };
  1505. /**
  1506. * @param {?} element
  1507. * @return {?}
  1508. */
  1509. BrowserDomAdapter.prototype.getComputedStyle = /**
  1510. * @param {?} element
  1511. * @return {?}
  1512. */
  1513. function (element) { return getComputedStyle(element); };
  1514. // TODO(tbosch): move this into a separate environment class once we have it
  1515. /**
  1516. * @return {?}
  1517. */
  1518. BrowserDomAdapter.prototype.supportsWebAnimation = /**
  1519. * @return {?}
  1520. */
  1521. function () {
  1522. return typeof (/** @type {?} */ (Element)).prototype['animate'] === 'function';
  1523. };
  1524. /**
  1525. * @return {?}
  1526. */
  1527. BrowserDomAdapter.prototype.performanceNow = /**
  1528. * @return {?}
  1529. */
  1530. function () {
  1531. // performance.now() is not available in all browsers, see
  1532. // http://caniuse.com/#search=performance.now
  1533. return window.performance && window.performance.now ? window.performance.now() :
  1534. new Date().getTime();
  1535. };
  1536. /**
  1537. * @return {?}
  1538. */
  1539. BrowserDomAdapter.prototype.supportsCookies = /**
  1540. * @return {?}
  1541. */
  1542. function () { return true; };
  1543. /**
  1544. * @param {?} name
  1545. * @return {?}
  1546. */
  1547. BrowserDomAdapter.prototype.getCookie = /**
  1548. * @param {?} name
  1549. * @return {?}
  1550. */
  1551. function (name) { return ɵparseCookieValue(document.cookie, name); };
  1552. /**
  1553. * @param {?} name
  1554. * @param {?} value
  1555. * @return {?}
  1556. */
  1557. BrowserDomAdapter.prototype.setCookie = /**
  1558. * @param {?} name
  1559. * @param {?} value
  1560. * @return {?}
  1561. */
  1562. function (name, value) {
  1563. // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
  1564. // not clear other cookies.
  1565. document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
  1566. };
  1567. return BrowserDomAdapter;
  1568. }(GenericBrowserDomAdapter));
  1569. var baseElement = null;
  1570. /**
  1571. * @return {?}
  1572. */
  1573. function getBaseElementHref() {
  1574. if (!baseElement) {
  1575. baseElement = /** @type {?} */ ((document.querySelector('base')));
  1576. if (!baseElement) {
  1577. return null;
  1578. }
  1579. }
  1580. return baseElement.getAttribute('href');
  1581. }
  1582. // based on urlUtils.js in AngularJS 1
  1583. var urlParsingNode;
  1584. /**
  1585. * @param {?} url
  1586. * @return {?}
  1587. */
  1588. function relativePath(url) {
  1589. if (!urlParsingNode) {
  1590. urlParsingNode = document.createElement('a');
  1591. }
  1592. urlParsingNode.setAttribute('href', url);
  1593. return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
  1594. '/' + urlParsingNode.pathname;
  1595. }
  1596. /**
  1597. * @fileoverview added by tsickle
  1598. * @suppress {checkTypes} checked by tsc
  1599. */
  1600. /**
  1601. * @license
  1602. * Copyright Google Inc. All Rights Reserved.
  1603. *
  1604. * Use of this source code is governed by an MIT-style license that can be
  1605. * found in the LICENSE file at https://angular.io/license
  1606. */
  1607. /**
  1608. * A DI Token representing the main rendering context. In a browser this is the DOM Document.
  1609. *
  1610. * Note: Document might not be available in the Application Context when Application and Rendering
  1611. * Contexts are not the same (e.g. when running the application into a Web Worker).
  1612. *
  1613. * @deprecated import from `\@angular/common` instead.
  1614. */
  1615. var DOCUMENT$1 = DOCUMENT;
  1616. /**
  1617. * @fileoverview added by tsickle
  1618. * @suppress {checkTypes} checked by tsc
  1619. */
  1620. /**
  1621. * @license
  1622. * Copyright Google Inc. All Rights Reserved.
  1623. *
  1624. * Use of this source code is governed by an MIT-style license that can be
  1625. * found in the LICENSE file at https://angular.io/license
  1626. */
  1627. /**
  1628. * @return {?}
  1629. */
  1630. function supportsState() {
  1631. return !!window.history.pushState;
  1632. }
  1633. /**
  1634. * @fileoverview added by tsickle
  1635. * @suppress {checkTypes} checked by tsc
  1636. */
  1637. /**
  1638. * @license
  1639. * Copyright Google Inc. All Rights Reserved.
  1640. *
  1641. * Use of this source code is governed by an MIT-style license that can be
  1642. * found in the LICENSE file at https://angular.io/license
  1643. */
  1644. /**
  1645. * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
  1646. * This class should not be used directly by an application developer. Instead, use
  1647. * {\@link Location}.
  1648. */
  1649. var BrowserPlatformLocation = /** @class */ (function (_super) {
  1650. __extends(BrowserPlatformLocation, _super);
  1651. function BrowserPlatformLocation(_doc) {
  1652. var _this = _super.call(this) || this;
  1653. _this._doc = _doc;
  1654. _this._init();
  1655. return _this;
  1656. }
  1657. // This is moved to its own method so that `MockPlatformLocationStrategy` can overwrite it
  1658. /** @internal */
  1659. /**
  1660. * \@internal
  1661. * @return {?}
  1662. */
  1663. BrowserPlatformLocation.prototype._init = /**
  1664. * \@internal
  1665. * @return {?}
  1666. */
  1667. function () {
  1668. (/** @type {?} */ (this)).location = getDOM().getLocation();
  1669. this._history = getDOM().getHistory();
  1670. };
  1671. /**
  1672. * @return {?}
  1673. */
  1674. BrowserPlatformLocation.prototype.getBaseHrefFromDOM = /**
  1675. * @return {?}
  1676. */
  1677. function () { return /** @type {?} */ ((getDOM().getBaseHref(this._doc))); };
  1678. /**
  1679. * @param {?} fn
  1680. * @return {?}
  1681. */
  1682. BrowserPlatformLocation.prototype.onPopState = /**
  1683. * @param {?} fn
  1684. * @return {?}
  1685. */
  1686. function (fn) {
  1687. getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('popstate', fn, false);
  1688. };
  1689. /**
  1690. * @param {?} fn
  1691. * @return {?}
  1692. */
  1693. BrowserPlatformLocation.prototype.onHashChange = /**
  1694. * @param {?} fn
  1695. * @return {?}
  1696. */
  1697. function (fn) {
  1698. getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('hashchange', fn, false);
  1699. };
  1700. Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
  1701. get: /**
  1702. * @return {?}
  1703. */
  1704. function () { return this.location.pathname; },
  1705. set: /**
  1706. * @param {?} newPath
  1707. * @return {?}
  1708. */
  1709. function (newPath) { this.location.pathname = newPath; },
  1710. enumerable: true,
  1711. configurable: true
  1712. });
  1713. Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
  1714. get: /**
  1715. * @return {?}
  1716. */
  1717. function () { return this.location.search; },
  1718. enumerable: true,
  1719. configurable: true
  1720. });
  1721. Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
  1722. get: /**
  1723. * @return {?}
  1724. */
  1725. function () { return this.location.hash; },
  1726. enumerable: true,
  1727. configurable: true
  1728. });
  1729. /**
  1730. * @param {?} state
  1731. * @param {?} title
  1732. * @param {?} url
  1733. * @return {?}
  1734. */
  1735. BrowserPlatformLocation.prototype.pushState = /**
  1736. * @param {?} state
  1737. * @param {?} title
  1738. * @param {?} url
  1739. * @return {?}
  1740. */
  1741. function (state, title, url) {
  1742. if (supportsState()) {
  1743. this._history.pushState(state, title, url);
  1744. }
  1745. else {
  1746. this.location.hash = url;
  1747. }
  1748. };
  1749. /**
  1750. * @param {?} state
  1751. * @param {?} title
  1752. * @param {?} url
  1753. * @return {?}
  1754. */
  1755. BrowserPlatformLocation.prototype.replaceState = /**
  1756. * @param {?} state
  1757. * @param {?} title
  1758. * @param {?} url
  1759. * @return {?}
  1760. */
  1761. function (state, title, url) {
  1762. if (supportsState()) {
  1763. this._history.replaceState(state, title, url);
  1764. }
  1765. else {
  1766. this.location.hash = url;
  1767. }
  1768. };
  1769. /**
  1770. * @return {?}
  1771. */
  1772. BrowserPlatformLocation.prototype.forward = /**
  1773. * @return {?}
  1774. */
  1775. function () { this._history.forward(); };
  1776. /**
  1777. * @return {?}
  1778. */
  1779. BrowserPlatformLocation.prototype.back = /**
  1780. * @return {?}
  1781. */
  1782. function () { this._history.back(); };
  1783. BrowserPlatformLocation.decorators = [
  1784. { type: Injectable },
  1785. ];
  1786. /** @nocollapse */
  1787. BrowserPlatformLocation.ctorParameters = function () { return [
  1788. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  1789. ]; };
  1790. return BrowserPlatformLocation;
  1791. }(PlatformLocation));
  1792. /**
  1793. * @fileoverview added by tsickle
  1794. * @suppress {checkTypes} checked by tsc
  1795. */
  1796. /**
  1797. * @license
  1798. * Copyright Google Inc. All Rights Reserved.
  1799. *
  1800. * Use of this source code is governed by an MIT-style license that can be
  1801. * found in the LICENSE file at https://angular.io/license
  1802. */
  1803. /**
  1804. * A service that can be used to get and add meta tags.
  1805. *
  1806. * \@experimental
  1807. */
  1808. var Meta = /** @class */ (function () {
  1809. function Meta(_doc) {
  1810. this._doc = _doc;
  1811. this._dom = getDOM();
  1812. }
  1813. /**
  1814. * @param {?} tag
  1815. * @param {?=} forceCreation
  1816. * @return {?}
  1817. */
  1818. Meta.prototype.addTag = /**
  1819. * @param {?} tag
  1820. * @param {?=} forceCreation
  1821. * @return {?}
  1822. */
  1823. function (tag, forceCreation) {
  1824. if (forceCreation === void 0) { forceCreation = false; }
  1825. if (!tag)
  1826. return null;
  1827. return this._getOrCreateElement(tag, forceCreation);
  1828. };
  1829. /**
  1830. * @param {?} tags
  1831. * @param {?=} forceCreation
  1832. * @return {?}
  1833. */
  1834. Meta.prototype.addTags = /**
  1835. * @param {?} tags
  1836. * @param {?=} forceCreation
  1837. * @return {?}
  1838. */
  1839. function (tags, forceCreation) {
  1840. var _this = this;
  1841. if (forceCreation === void 0) { forceCreation = false; }
  1842. if (!tags)
  1843. return [];
  1844. return tags.reduce(function (result, tag) {
  1845. if (tag) {
  1846. result.push(_this._getOrCreateElement(tag, forceCreation));
  1847. }
  1848. return result;
  1849. }, []);
  1850. };
  1851. /**
  1852. * @param {?} attrSelector
  1853. * @return {?}
  1854. */
  1855. Meta.prototype.getTag = /**
  1856. * @param {?} attrSelector
  1857. * @return {?}
  1858. */
  1859. function (attrSelector) {
  1860. if (!attrSelector)
  1861. return null;
  1862. return this._dom.querySelector(this._doc, "meta[" + attrSelector + "]") || null;
  1863. };
  1864. /**
  1865. * @param {?} attrSelector
  1866. * @return {?}
  1867. */
  1868. Meta.prototype.getTags = /**
  1869. * @param {?} attrSelector
  1870. * @return {?}
  1871. */
  1872. function (attrSelector) {
  1873. if (!attrSelector)
  1874. return [];
  1875. var /** @type {?} */ list = this._dom.querySelectorAll(this._doc, "meta[" + attrSelector + "]");
  1876. return list ? [].slice.call(list) : [];
  1877. };
  1878. /**
  1879. * @param {?} tag
  1880. * @param {?=} selector
  1881. * @return {?}
  1882. */
  1883. Meta.prototype.updateTag = /**
  1884. * @param {?} tag
  1885. * @param {?=} selector
  1886. * @return {?}
  1887. */
  1888. function (tag, selector) {
  1889. if (!tag)
  1890. return null;
  1891. selector = selector || this._parseSelector(tag);
  1892. var /** @type {?} */ meta = /** @type {?} */ ((this.getTag(selector)));
  1893. if (meta) {
  1894. return this._setMetaElementAttributes(tag, meta);
  1895. }
  1896. return this._getOrCreateElement(tag, true);
  1897. };
  1898. /**
  1899. * @param {?} attrSelector
  1900. * @return {?}
  1901. */
  1902. Meta.prototype.removeTag = /**
  1903. * @param {?} attrSelector
  1904. * @return {?}
  1905. */
  1906. function (attrSelector) { this.removeTagElement(/** @type {?} */ ((this.getTag(attrSelector)))); };
  1907. /**
  1908. * @param {?} meta
  1909. * @return {?}
  1910. */
  1911. Meta.prototype.removeTagElement = /**
  1912. * @param {?} meta
  1913. * @return {?}
  1914. */
  1915. function (meta) {
  1916. if (meta) {
  1917. this._dom.remove(meta);
  1918. }
  1919. };
  1920. /**
  1921. * @param {?} meta
  1922. * @param {?=} forceCreation
  1923. * @return {?}
  1924. */
  1925. Meta.prototype._getOrCreateElement = /**
  1926. * @param {?} meta
  1927. * @param {?=} forceCreation
  1928. * @return {?}
  1929. */
  1930. function (meta, forceCreation) {
  1931. if (forceCreation === void 0) { forceCreation = false; }
  1932. if (!forceCreation) {
  1933. var /** @type {?} */ selector = this._parseSelector(meta);
  1934. var /** @type {?} */ elem = /** @type {?} */ ((this.getTag(selector)));
  1935. // It's allowed to have multiple elements with the same name so it's not enough to
  1936. // just check that element with the same name already present on the page. We also need to
  1937. // check if element has tag attributes
  1938. if (elem && this._containsAttributes(meta, elem))
  1939. return elem;
  1940. }
  1941. var /** @type {?} */ element = /** @type {?} */ (this._dom.createElement('meta'));
  1942. this._setMetaElementAttributes(meta, element);
  1943. var /** @type {?} */ head = this._dom.getElementsByTagName(this._doc, 'head')[0];
  1944. this._dom.appendChild(head, element);
  1945. return element;
  1946. };
  1947. /**
  1948. * @param {?} tag
  1949. * @param {?} el
  1950. * @return {?}
  1951. */
  1952. Meta.prototype._setMetaElementAttributes = /**
  1953. * @param {?} tag
  1954. * @param {?} el
  1955. * @return {?}
  1956. */
  1957. function (tag, el) {
  1958. var _this = this;
  1959. Object.keys(tag).forEach(function (prop) { return _this._dom.setAttribute(el, prop, tag[prop]); });
  1960. return el;
  1961. };
  1962. /**
  1963. * @param {?} tag
  1964. * @return {?}
  1965. */
  1966. Meta.prototype._parseSelector = /**
  1967. * @param {?} tag
  1968. * @return {?}
  1969. */
  1970. function (tag) {
  1971. var /** @type {?} */ attr = tag.name ? 'name' : 'property';
  1972. return attr + "=\"" + tag[attr] + "\"";
  1973. };
  1974. /**
  1975. * @param {?} tag
  1976. * @param {?} elem
  1977. * @return {?}
  1978. */
  1979. Meta.prototype._containsAttributes = /**
  1980. * @param {?} tag
  1981. * @param {?} elem
  1982. * @return {?}
  1983. */
  1984. function (tag, elem) {
  1985. var _this = this;
  1986. return Object.keys(tag).every(function (key) { return _this._dom.getAttribute(elem, key) === tag[key]; });
  1987. };
  1988. Meta.decorators = [
  1989. { type: Injectable },
  1990. ];
  1991. /** @nocollapse */
  1992. Meta.ctorParameters = function () { return [
  1993. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  1994. ]; };
  1995. return Meta;
  1996. }());
  1997. /**
  1998. * @fileoverview added by tsickle
  1999. * @suppress {checkTypes} checked by tsc
  2000. */
  2001. /**
  2002. * @license
  2003. * Copyright Google Inc. All Rights Reserved.
  2004. *
  2005. * Use of this source code is governed by an MIT-style license that can be
  2006. * found in the LICENSE file at https://angular.io/license
  2007. */
  2008. /**
  2009. * An id that identifies a particular application being bootstrapped, that should
  2010. * match across the client/server boundary.
  2011. */
  2012. var TRANSITION_ID = new InjectionToken('TRANSITION_ID');
  2013. /**
  2014. * @param {?} transitionId
  2015. * @param {?} document
  2016. * @param {?} injector
  2017. * @return {?}
  2018. */
  2019. function appInitializerFactory(transitionId, document, injector) {
  2020. return function () {
  2021. // Wait for all application initializers to be completed before removing the styles set by
  2022. // the server.
  2023. injector.get(ApplicationInitStatus).donePromise.then(function () {
  2024. var /** @type {?} */ dom = getDOM();
  2025. var /** @type {?} */ styles = Array.prototype.slice.apply(dom.querySelectorAll(document, "style[ng-transition]"));
  2026. styles.filter(function (el) { return dom.getAttribute(el, 'ng-transition') === transitionId; })
  2027. .forEach(function (el) { return dom.remove(el); });
  2028. });
  2029. };
  2030. }
  2031. var SERVER_TRANSITION_PROVIDERS = [
  2032. {
  2033. provide: APP_INITIALIZER,
  2034. useFactory: appInitializerFactory,
  2035. deps: [TRANSITION_ID, DOCUMENT$1, Injector],
  2036. multi: true
  2037. },
  2038. ];
  2039. /**
  2040. * @fileoverview added by tsickle
  2041. * @suppress {checkTypes} checked by tsc
  2042. */
  2043. /**
  2044. * @license
  2045. * Copyright Google Inc. All Rights Reserved.
  2046. *
  2047. * Use of this source code is governed by an MIT-style license that can be
  2048. * found in the LICENSE file at https://angular.io/license
  2049. */
  2050. var BrowserGetTestability = /** @class */ (function () {
  2051. function BrowserGetTestability() {
  2052. }
  2053. /**
  2054. * @return {?}
  2055. */
  2056. BrowserGetTestability.init = /**
  2057. * @return {?}
  2058. */
  2059. function () { setTestabilityGetter(new BrowserGetTestability()); };
  2060. /**
  2061. * @param {?} registry
  2062. * @return {?}
  2063. */
  2064. BrowserGetTestability.prototype.addToWindow = /**
  2065. * @param {?} registry
  2066. * @return {?}
  2067. */
  2068. function (registry) {
  2069. ɵglobal['getAngularTestability'] = function (elem, findInAncestors) {
  2070. if (findInAncestors === void 0) { findInAncestors = true; }
  2071. var /** @type {?} */ testability = registry.findTestabilityInTree(elem, findInAncestors);
  2072. if (testability == null) {
  2073. throw new Error('Could not find testability for element.');
  2074. }
  2075. return testability;
  2076. };
  2077. ɵglobal['getAllAngularTestabilities'] = function () { return registry.getAllTestabilities(); };
  2078. ɵglobal['getAllAngularRootElements'] = function () { return registry.getAllRootElements(); };
  2079. var /** @type {?} */ whenAllStable = function (callback /** TODO #9100 */) {
  2080. var /** @type {?} */ testabilities = ɵglobal['getAllAngularTestabilities']();
  2081. var /** @type {?} */ count = testabilities.length;
  2082. var /** @type {?} */ didWork = false;
  2083. var /** @type {?} */ decrement = function (didWork_ /** TODO #9100 */) {
  2084. didWork = didWork || didWork_;
  2085. count--;
  2086. if (count == 0) {
  2087. callback(didWork);
  2088. }
  2089. };
  2090. testabilities.forEach(function (testability /** TODO #9100 */) {
  2091. testability.whenStable(decrement);
  2092. });
  2093. };
  2094. if (!ɵglobal['frameworkStabilizers']) {
  2095. ɵglobal['frameworkStabilizers'] = [];
  2096. }
  2097. ɵglobal['frameworkStabilizers'].push(whenAllStable);
  2098. };
  2099. /**
  2100. * @param {?} registry
  2101. * @param {?} elem
  2102. * @param {?} findInAncestors
  2103. * @return {?}
  2104. */
  2105. BrowserGetTestability.prototype.findTestabilityInTree = /**
  2106. * @param {?} registry
  2107. * @param {?} elem
  2108. * @param {?} findInAncestors
  2109. * @return {?}
  2110. */
  2111. function (registry, elem, findInAncestors) {
  2112. if (elem == null) {
  2113. return null;
  2114. }
  2115. var /** @type {?} */ t = registry.getTestability(elem);
  2116. if (t != null) {
  2117. return t;
  2118. }
  2119. else if (!findInAncestors) {
  2120. return null;
  2121. }
  2122. if (getDOM().isShadowRoot(elem)) {
  2123. return this.findTestabilityInTree(registry, getDOM().getHost(elem), true);
  2124. }
  2125. return this.findTestabilityInTree(registry, getDOM().parentElement(elem), true);
  2126. };
  2127. return BrowserGetTestability;
  2128. }());
  2129. /**
  2130. * @fileoverview added by tsickle
  2131. * @suppress {checkTypes} checked by tsc
  2132. */
  2133. /**
  2134. * @license
  2135. * Copyright Google Inc. All Rights Reserved.
  2136. *
  2137. * Use of this source code is governed by an MIT-style license that can be
  2138. * found in the LICENSE file at https://angular.io/license
  2139. */
  2140. /**
  2141. * A service that can be used to get and set the title of a current HTML document.
  2142. *
  2143. * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
  2144. * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
  2145. * (representing the `<title>` tag). Instead, this service can be used to set and get the current
  2146. * title value.
  2147. *
  2148. * \@experimental
  2149. */
  2150. var Title = /** @class */ (function () {
  2151. function Title(_doc) {
  2152. this._doc = _doc;
  2153. }
  2154. /**
  2155. * Get the title of the current HTML document.
  2156. */
  2157. /**
  2158. * Get the title of the current HTML document.
  2159. * @return {?}
  2160. */
  2161. Title.prototype.getTitle = /**
  2162. * Get the title of the current HTML document.
  2163. * @return {?}
  2164. */
  2165. function () { return getDOM().getTitle(this._doc); };
  2166. /**
  2167. * Set the title of the current HTML document.
  2168. * @param newTitle
  2169. */
  2170. /**
  2171. * Set the title of the current HTML document.
  2172. * @param {?} newTitle
  2173. * @return {?}
  2174. */
  2175. Title.prototype.setTitle = /**
  2176. * Set the title of the current HTML document.
  2177. * @param {?} newTitle
  2178. * @return {?}
  2179. */
  2180. function (newTitle) { getDOM().setTitle(this._doc, newTitle); };
  2181. Title.decorators = [
  2182. { type: Injectable },
  2183. ];
  2184. /** @nocollapse */
  2185. Title.ctorParameters = function () { return [
  2186. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  2187. ]; };
  2188. return Title;
  2189. }());
  2190. /**
  2191. * @fileoverview added by tsickle
  2192. * @suppress {checkTypes} checked by tsc
  2193. */
  2194. /**
  2195. * @license
  2196. * Copyright Google Inc. All Rights Reserved.
  2197. *
  2198. * Use of this source code is governed by an MIT-style license that can be
  2199. * found in the LICENSE file at https://angular.io/license
  2200. */
  2201. /**
  2202. * @param {?} input
  2203. * @return {?}
  2204. */
  2205. /**
  2206. * @param {?} input
  2207. * @return {?}
  2208. */
  2209. /**
  2210. * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
  2211. * `name` is `'probe'`.
  2212. * @param {?} name Name under which it will be exported. Keep in mind this will be a property of the
  2213. * global `ng` object.
  2214. * @param {?} value The value to export.
  2215. * @return {?}
  2216. */
  2217. function exportNgVar(name, value) {
  2218. if (typeof COMPILED === 'undefined' || !COMPILED) {
  2219. // Note: we can't export `ng` when using closure enhanced optimization as:
  2220. // - closure declares globals itself for minified names, which sometimes clobber our `ng` global
  2221. // - we can't declare a closure extern as the namespace `ng` is already used within Google
  2222. // for typings for angularJS (via `goog.provide('ng....')`).
  2223. var /** @type {?} */ ng = ɵglobal['ng'] = (/** @type {?} */ (ɵglobal['ng'])) || {};
  2224. ng[name] = value;
  2225. }
  2226. }
  2227. /**
  2228. * @fileoverview added by tsickle
  2229. * @suppress {checkTypes} checked by tsc
  2230. */
  2231. /**
  2232. * @license
  2233. * Copyright Google Inc. All Rights Reserved.
  2234. *
  2235. * Use of this source code is governed by an MIT-style license that can be
  2236. * found in the LICENSE file at https://angular.io/license
  2237. */
  2238. var CORE_TOKENS = {
  2239. 'ApplicationRef': ApplicationRef,
  2240. 'NgZone': NgZone,
  2241. };
  2242. var INSPECT_GLOBAL_NAME = 'probe';
  2243. var CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
  2244. /**
  2245. * Returns a {\@link DebugElement} for the given native DOM element, or
  2246. * null if the given native element does not have an Angular view associated
  2247. * with it.
  2248. * @param {?} element
  2249. * @return {?}
  2250. */
  2251. function inspectNativeElement(element) {
  2252. return getDebugNode(element);
  2253. }
  2254. /**
  2255. * @param {?} coreTokens
  2256. * @return {?}
  2257. */
  2258. function _createNgProbe(coreTokens) {
  2259. exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
  2260. exportNgVar(CORE_TOKENS_GLOBAL_NAME, __assign({}, CORE_TOKENS, _ngProbeTokensToMap(coreTokens || [])));
  2261. return function () { return inspectNativeElement; };
  2262. }
  2263. /**
  2264. * @param {?} tokens
  2265. * @return {?}
  2266. */
  2267. function _ngProbeTokensToMap(tokens) {
  2268. return tokens.reduce(function (prev, t) { return (prev[t.name] = t.token, prev); }, {});
  2269. }
  2270. /**
  2271. * Providers which support debugging Angular applications (e.g. via `ng.probe`).
  2272. */
  2273. var ELEMENT_PROBE_PROVIDERS = [
  2274. {
  2275. provide: APP_INITIALIZER,
  2276. useFactory: _createNgProbe,
  2277. deps: [
  2278. [NgProbeToken, new Optional()],
  2279. ],
  2280. multi: true,
  2281. },
  2282. ];
  2283. /**
  2284. * @fileoverview added by tsickle
  2285. * @suppress {checkTypes} checked by tsc
  2286. */
  2287. /**
  2288. * @license
  2289. * Copyright Google Inc. All Rights Reserved.
  2290. *
  2291. * Use of this source code is governed by an MIT-style license that can be
  2292. * found in the LICENSE file at https://angular.io/license
  2293. */
  2294. /**
  2295. * \@stable
  2296. */
  2297. var EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
  2298. /**
  2299. * \@stable
  2300. */
  2301. var EventManager = /** @class */ (function () {
  2302. function EventManager(plugins, _zone) {
  2303. var _this = this;
  2304. this._zone = _zone;
  2305. this._eventNameToPlugin = new Map();
  2306. plugins.forEach(function (p) { return p.manager = _this; });
  2307. this._plugins = plugins.slice().reverse();
  2308. }
  2309. /**
  2310. * @param {?} element
  2311. * @param {?} eventName
  2312. * @param {?} handler
  2313. * @return {?}
  2314. */
  2315. EventManager.prototype.addEventListener = /**
  2316. * @param {?} element
  2317. * @param {?} eventName
  2318. * @param {?} handler
  2319. * @return {?}
  2320. */
  2321. function (element, eventName, handler) {
  2322. var /** @type {?} */ plugin = this._findPluginFor(eventName);
  2323. return plugin.addEventListener(element, eventName, handler);
  2324. };
  2325. /**
  2326. * @param {?} target
  2327. * @param {?} eventName
  2328. * @param {?} handler
  2329. * @return {?}
  2330. */
  2331. EventManager.prototype.addGlobalEventListener = /**
  2332. * @param {?} target
  2333. * @param {?} eventName
  2334. * @param {?} handler
  2335. * @return {?}
  2336. */
  2337. function (target, eventName, handler) {
  2338. var /** @type {?} */ plugin = this._findPluginFor(eventName);
  2339. return plugin.addGlobalEventListener(target, eventName, handler);
  2340. };
  2341. /**
  2342. * @return {?}
  2343. */
  2344. EventManager.prototype.getZone = /**
  2345. * @return {?}
  2346. */
  2347. function () { return this._zone; };
  2348. /** @internal */
  2349. /**
  2350. * \@internal
  2351. * @param {?} eventName
  2352. * @return {?}
  2353. */
  2354. EventManager.prototype._findPluginFor = /**
  2355. * \@internal
  2356. * @param {?} eventName
  2357. * @return {?}
  2358. */
  2359. function (eventName) {
  2360. var /** @type {?} */ plugin = this._eventNameToPlugin.get(eventName);
  2361. if (plugin) {
  2362. return plugin;
  2363. }
  2364. var /** @type {?} */ plugins = this._plugins;
  2365. for (var /** @type {?} */ i = 0; i < plugins.length; i++) {
  2366. var /** @type {?} */ plugin_1 = plugins[i];
  2367. if (plugin_1.supports(eventName)) {
  2368. this._eventNameToPlugin.set(eventName, plugin_1);
  2369. return plugin_1;
  2370. }
  2371. }
  2372. throw new Error("No event manager plugin found for event " + eventName);
  2373. };
  2374. EventManager.decorators = [
  2375. { type: Injectable },
  2376. ];
  2377. /** @nocollapse */
  2378. EventManager.ctorParameters = function () { return [
  2379. { type: Array, decorators: [{ type: Inject, args: [EVENT_MANAGER_PLUGINS,] },] },
  2380. { type: NgZone, },
  2381. ]; };
  2382. return EventManager;
  2383. }());
  2384. /**
  2385. * @abstract
  2386. */
  2387. var EventManagerPlugin = /** @class */ (function () {
  2388. function EventManagerPlugin(_doc) {
  2389. this._doc = _doc;
  2390. }
  2391. /**
  2392. * @param {?} element
  2393. * @param {?} eventName
  2394. * @param {?} handler
  2395. * @return {?}
  2396. */
  2397. EventManagerPlugin.prototype.addGlobalEventListener = /**
  2398. * @param {?} element
  2399. * @param {?} eventName
  2400. * @param {?} handler
  2401. * @return {?}
  2402. */
  2403. function (element, eventName, handler) {
  2404. var /** @type {?} */ target = getDOM().getGlobalEventTarget(this._doc, element);
  2405. if (!target) {
  2406. throw new Error("Unsupported event target " + target + " for event " + eventName);
  2407. }
  2408. return this.addEventListener(target, eventName, handler);
  2409. };
  2410. return EventManagerPlugin;
  2411. }());
  2412. /**
  2413. * @fileoverview added by tsickle
  2414. * @suppress {checkTypes} checked by tsc
  2415. */
  2416. /**
  2417. * @license
  2418. * Copyright Google Inc. All Rights Reserved.
  2419. *
  2420. * Use of this source code is governed by an MIT-style license that can be
  2421. * found in the LICENSE file at https://angular.io/license
  2422. */
  2423. var SharedStylesHost = /** @class */ (function () {
  2424. function SharedStylesHost() {
  2425. /**
  2426. * \@internal
  2427. */
  2428. this._stylesSet = new Set();
  2429. }
  2430. /**
  2431. * @param {?} styles
  2432. * @return {?}
  2433. */
  2434. SharedStylesHost.prototype.addStyles = /**
  2435. * @param {?} styles
  2436. * @return {?}
  2437. */
  2438. function (styles) {
  2439. var _this = this;
  2440. var /** @type {?} */ additions = new Set();
  2441. styles.forEach(function (style) {
  2442. if (!_this._stylesSet.has(style)) {
  2443. _this._stylesSet.add(style);
  2444. additions.add(style);
  2445. }
  2446. });
  2447. this.onStylesAdded(additions);
  2448. };
  2449. /**
  2450. * @param {?} additions
  2451. * @return {?}
  2452. */
  2453. SharedStylesHost.prototype.onStylesAdded = /**
  2454. * @param {?} additions
  2455. * @return {?}
  2456. */
  2457. function (additions) { };
  2458. /**
  2459. * @return {?}
  2460. */
  2461. SharedStylesHost.prototype.getAllStyles = /**
  2462. * @return {?}
  2463. */
  2464. function () { return Array.from(this._stylesSet); };
  2465. SharedStylesHost.decorators = [
  2466. { type: Injectable },
  2467. ];
  2468. /** @nocollapse */
  2469. SharedStylesHost.ctorParameters = function () { return []; };
  2470. return SharedStylesHost;
  2471. }());
  2472. var DomSharedStylesHost = /** @class */ (function (_super) {
  2473. __extends(DomSharedStylesHost, _super);
  2474. function DomSharedStylesHost(_doc) {
  2475. var _this = _super.call(this) || this;
  2476. _this._doc = _doc;
  2477. _this._hostNodes = new Set();
  2478. _this._styleNodes = new Set();
  2479. _this._hostNodes.add(_doc.head);
  2480. return _this;
  2481. }
  2482. /**
  2483. * @param {?} styles
  2484. * @param {?} host
  2485. * @return {?}
  2486. */
  2487. DomSharedStylesHost.prototype._addStylesToHost = /**
  2488. * @param {?} styles
  2489. * @param {?} host
  2490. * @return {?}
  2491. */
  2492. function (styles, host) {
  2493. var _this = this;
  2494. styles.forEach(function (style) {
  2495. var /** @type {?} */ styleEl = _this._doc.createElement('style');
  2496. styleEl.textContent = style;
  2497. _this._styleNodes.add(host.appendChild(styleEl));
  2498. });
  2499. };
  2500. /**
  2501. * @param {?} hostNode
  2502. * @return {?}
  2503. */
  2504. DomSharedStylesHost.prototype.addHost = /**
  2505. * @param {?} hostNode
  2506. * @return {?}
  2507. */
  2508. function (hostNode) {
  2509. this._addStylesToHost(this._stylesSet, hostNode);
  2510. this._hostNodes.add(hostNode);
  2511. };
  2512. /**
  2513. * @param {?} hostNode
  2514. * @return {?}
  2515. */
  2516. DomSharedStylesHost.prototype.removeHost = /**
  2517. * @param {?} hostNode
  2518. * @return {?}
  2519. */
  2520. function (hostNode) { this._hostNodes.delete(hostNode); };
  2521. /**
  2522. * @param {?} additions
  2523. * @return {?}
  2524. */
  2525. DomSharedStylesHost.prototype.onStylesAdded = /**
  2526. * @param {?} additions
  2527. * @return {?}
  2528. */
  2529. function (additions) {
  2530. var _this = this;
  2531. this._hostNodes.forEach(function (hostNode) { return _this._addStylesToHost(additions, hostNode); });
  2532. };
  2533. /**
  2534. * @return {?}
  2535. */
  2536. DomSharedStylesHost.prototype.ngOnDestroy = /**
  2537. * @return {?}
  2538. */
  2539. function () { this._styleNodes.forEach(function (styleNode) { return getDOM().remove(styleNode); }); };
  2540. DomSharedStylesHost.decorators = [
  2541. { type: Injectable },
  2542. ];
  2543. /** @nocollapse */
  2544. DomSharedStylesHost.ctorParameters = function () { return [
  2545. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  2546. ]; };
  2547. return DomSharedStylesHost;
  2548. }(SharedStylesHost));
  2549. /**
  2550. * @fileoverview added by tsickle
  2551. * @suppress {checkTypes} checked by tsc
  2552. */
  2553. /**
  2554. * @license
  2555. * Copyright Google Inc. All Rights Reserved.
  2556. *
  2557. * Use of this source code is governed by an MIT-style license that can be
  2558. * found in the LICENSE file at https://angular.io/license
  2559. */
  2560. var NAMESPACE_URIS = {
  2561. 'svg': 'http://www.w3.org/2000/svg',
  2562. 'xhtml': 'http://www.w3.org/1999/xhtml',
  2563. 'xlink': 'http://www.w3.org/1999/xlink',
  2564. 'xml': 'http://www.w3.org/XML/1998/namespace',
  2565. 'xmlns': 'http://www.w3.org/2000/xmlns/',
  2566. };
  2567. var COMPONENT_REGEX = /%COMP%/g;
  2568. var COMPONENT_VARIABLE = '%COMP%';
  2569. var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
  2570. var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
  2571. /**
  2572. * @param {?} componentShortId
  2573. * @return {?}
  2574. */
  2575. function shimContentAttribute(componentShortId) {
  2576. return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
  2577. }
  2578. /**
  2579. * @param {?} componentShortId
  2580. * @return {?}
  2581. */
  2582. function shimHostAttribute(componentShortId) {
  2583. return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
  2584. }
  2585. /**
  2586. * @param {?} compId
  2587. * @param {?} styles
  2588. * @param {?} target
  2589. * @return {?}
  2590. */
  2591. function flattenStyles(compId, styles, target) {
  2592. for (var /** @type {?} */ i = 0; i < styles.length; i++) {
  2593. var /** @type {?} */ style = styles[i];
  2594. if (Array.isArray(style)) {
  2595. flattenStyles(compId, style, target);
  2596. }
  2597. else {
  2598. style = style.replace(COMPONENT_REGEX, compId);
  2599. target.push(style);
  2600. }
  2601. }
  2602. return target;
  2603. }
  2604. /**
  2605. * @param {?} eventHandler
  2606. * @return {?}
  2607. */
  2608. function decoratePreventDefault(eventHandler) {
  2609. return function (event) {
  2610. var /** @type {?} */ allowDefaultBehavior = eventHandler(event);
  2611. if (allowDefaultBehavior === false) {
  2612. // TODO(tbosch): move preventDefault into event plugins...
  2613. event.preventDefault();
  2614. event.returnValue = false;
  2615. }
  2616. };
  2617. }
  2618. var DomRendererFactory2 = /** @class */ (function () {
  2619. function DomRendererFactory2(eventManager, sharedStylesHost) {
  2620. this.eventManager = eventManager;
  2621. this.sharedStylesHost = sharedStylesHost;
  2622. this.rendererByCompId = new Map();
  2623. this.defaultRenderer = new DefaultDomRenderer2(eventManager);
  2624. }
  2625. /**
  2626. * @param {?} element
  2627. * @param {?} type
  2628. * @return {?}
  2629. */
  2630. DomRendererFactory2.prototype.createRenderer = /**
  2631. * @param {?} element
  2632. * @param {?} type
  2633. * @return {?}
  2634. */
  2635. function (element, type) {
  2636. if (!element || !type) {
  2637. return this.defaultRenderer;
  2638. }
  2639. switch (type.encapsulation) {
  2640. case ViewEncapsulation.Emulated: {
  2641. var /** @type {?} */ renderer = this.rendererByCompId.get(type.id);
  2642. if (!renderer) {
  2643. renderer =
  2644. new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type);
  2645. this.rendererByCompId.set(type.id, renderer);
  2646. }
  2647. (/** @type {?} */ (renderer)).applyToHost(element);
  2648. return renderer;
  2649. }
  2650. case ViewEncapsulation.Native:
  2651. return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
  2652. default: {
  2653. if (!this.rendererByCompId.has(type.id)) {
  2654. var /** @type {?} */ styles = flattenStyles(type.id, type.styles, []);
  2655. this.sharedStylesHost.addStyles(styles);
  2656. this.rendererByCompId.set(type.id, this.defaultRenderer);
  2657. }
  2658. return this.defaultRenderer;
  2659. }
  2660. }
  2661. };
  2662. /**
  2663. * @return {?}
  2664. */
  2665. DomRendererFactory2.prototype.begin = /**
  2666. * @return {?}
  2667. */
  2668. function () { };
  2669. /**
  2670. * @return {?}
  2671. */
  2672. DomRendererFactory2.prototype.end = /**
  2673. * @return {?}
  2674. */
  2675. function () { };
  2676. DomRendererFactory2.decorators = [
  2677. { type: Injectable },
  2678. ];
  2679. /** @nocollapse */
  2680. DomRendererFactory2.ctorParameters = function () { return [
  2681. { type: EventManager, },
  2682. { type: DomSharedStylesHost, },
  2683. ]; };
  2684. return DomRendererFactory2;
  2685. }());
  2686. var DefaultDomRenderer2 = /** @class */ (function () {
  2687. function DefaultDomRenderer2(eventManager) {
  2688. this.eventManager = eventManager;
  2689. this.data = Object.create(null);
  2690. }
  2691. /**
  2692. * @return {?}
  2693. */
  2694. DefaultDomRenderer2.prototype.destroy = /**
  2695. * @return {?}
  2696. */
  2697. function () { };
  2698. /**
  2699. * @param {?} name
  2700. * @param {?=} namespace
  2701. * @return {?}
  2702. */
  2703. DefaultDomRenderer2.prototype.createElement = /**
  2704. * @param {?} name
  2705. * @param {?=} namespace
  2706. * @return {?}
  2707. */
  2708. function (name, namespace) {
  2709. if (namespace) {
  2710. return document.createElementNS(NAMESPACE_URIS[namespace], name);
  2711. }
  2712. return document.createElement(name);
  2713. };
  2714. /**
  2715. * @param {?} value
  2716. * @return {?}
  2717. */
  2718. DefaultDomRenderer2.prototype.createComment = /**
  2719. * @param {?} value
  2720. * @return {?}
  2721. */
  2722. function (value) { return document.createComment(value); };
  2723. /**
  2724. * @param {?} value
  2725. * @return {?}
  2726. */
  2727. DefaultDomRenderer2.prototype.createText = /**
  2728. * @param {?} value
  2729. * @return {?}
  2730. */
  2731. function (value) { return document.createTextNode(value); };
  2732. /**
  2733. * @param {?} parent
  2734. * @param {?} newChild
  2735. * @return {?}
  2736. */
  2737. DefaultDomRenderer2.prototype.appendChild = /**
  2738. * @param {?} parent
  2739. * @param {?} newChild
  2740. * @return {?}
  2741. */
  2742. function (parent, newChild) { parent.appendChild(newChild); };
  2743. /**
  2744. * @param {?} parent
  2745. * @param {?} newChild
  2746. * @param {?} refChild
  2747. * @return {?}
  2748. */
  2749. DefaultDomRenderer2.prototype.insertBefore = /**
  2750. * @param {?} parent
  2751. * @param {?} newChild
  2752. * @param {?} refChild
  2753. * @return {?}
  2754. */
  2755. function (parent, newChild, refChild) {
  2756. if (parent) {
  2757. parent.insertBefore(newChild, refChild);
  2758. }
  2759. };
  2760. /**
  2761. * @param {?} parent
  2762. * @param {?} oldChild
  2763. * @return {?}
  2764. */
  2765. DefaultDomRenderer2.prototype.removeChild = /**
  2766. * @param {?} parent
  2767. * @param {?} oldChild
  2768. * @return {?}
  2769. */
  2770. function (parent, oldChild) {
  2771. if (parent) {
  2772. parent.removeChild(oldChild);
  2773. }
  2774. };
  2775. /**
  2776. * @param {?} selectorOrNode
  2777. * @return {?}
  2778. */
  2779. DefaultDomRenderer2.prototype.selectRootElement = /**
  2780. * @param {?} selectorOrNode
  2781. * @return {?}
  2782. */
  2783. function (selectorOrNode) {
  2784. var /** @type {?} */ el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
  2785. selectorOrNode;
  2786. if (!el) {
  2787. throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements");
  2788. }
  2789. el.textContent = '';
  2790. return el;
  2791. };
  2792. /**
  2793. * @param {?} node
  2794. * @return {?}
  2795. */
  2796. DefaultDomRenderer2.prototype.parentNode = /**
  2797. * @param {?} node
  2798. * @return {?}
  2799. */
  2800. function (node) { return node.parentNode; };
  2801. /**
  2802. * @param {?} node
  2803. * @return {?}
  2804. */
  2805. DefaultDomRenderer2.prototype.nextSibling = /**
  2806. * @param {?} node
  2807. * @return {?}
  2808. */
  2809. function (node) { return node.nextSibling; };
  2810. /**
  2811. * @param {?} el
  2812. * @param {?} name
  2813. * @param {?} value
  2814. * @param {?=} namespace
  2815. * @return {?}
  2816. */
  2817. DefaultDomRenderer2.prototype.setAttribute = /**
  2818. * @param {?} el
  2819. * @param {?} name
  2820. * @param {?} value
  2821. * @param {?=} namespace
  2822. * @return {?}
  2823. */
  2824. function (el, name, value, namespace) {
  2825. if (namespace) {
  2826. name = namespace + ":" + name;
  2827. var /** @type {?} */ namespaceUri = NAMESPACE_URIS[namespace];
  2828. if (namespaceUri) {
  2829. el.setAttributeNS(namespaceUri, name, value);
  2830. }
  2831. else {
  2832. el.setAttribute(name, value);
  2833. }
  2834. }
  2835. else {
  2836. el.setAttribute(name, value);
  2837. }
  2838. };
  2839. /**
  2840. * @param {?} el
  2841. * @param {?} name
  2842. * @param {?=} namespace
  2843. * @return {?}
  2844. */
  2845. DefaultDomRenderer2.prototype.removeAttribute = /**
  2846. * @param {?} el
  2847. * @param {?} name
  2848. * @param {?=} namespace
  2849. * @return {?}
  2850. */
  2851. function (el, name, namespace) {
  2852. if (namespace) {
  2853. var /** @type {?} */ namespaceUri = NAMESPACE_URIS[namespace];
  2854. if (namespaceUri) {
  2855. el.removeAttributeNS(namespaceUri, name);
  2856. }
  2857. else {
  2858. el.removeAttribute(namespace + ":" + name);
  2859. }
  2860. }
  2861. else {
  2862. el.removeAttribute(name);
  2863. }
  2864. };
  2865. /**
  2866. * @param {?} el
  2867. * @param {?} name
  2868. * @return {?}
  2869. */
  2870. DefaultDomRenderer2.prototype.addClass = /**
  2871. * @param {?} el
  2872. * @param {?} name
  2873. * @return {?}
  2874. */
  2875. function (el, name) { el.classList.add(name); };
  2876. /**
  2877. * @param {?} el
  2878. * @param {?} name
  2879. * @return {?}
  2880. */
  2881. DefaultDomRenderer2.prototype.removeClass = /**
  2882. * @param {?} el
  2883. * @param {?} name
  2884. * @return {?}
  2885. */
  2886. function (el, name) { el.classList.remove(name); };
  2887. /**
  2888. * @param {?} el
  2889. * @param {?} style
  2890. * @param {?} value
  2891. * @param {?} flags
  2892. * @return {?}
  2893. */
  2894. DefaultDomRenderer2.prototype.setStyle = /**
  2895. * @param {?} el
  2896. * @param {?} style
  2897. * @param {?} value
  2898. * @param {?} flags
  2899. * @return {?}
  2900. */
  2901. function (el, style, value, flags) {
  2902. if (flags & RendererStyleFlags2.DashCase) {
  2903. el.style.setProperty(style, value, !!(flags & RendererStyleFlags2.Important) ? 'important' : '');
  2904. }
  2905. else {
  2906. el.style[style] = value;
  2907. }
  2908. };
  2909. /**
  2910. * @param {?} el
  2911. * @param {?} style
  2912. * @param {?} flags
  2913. * @return {?}
  2914. */
  2915. DefaultDomRenderer2.prototype.removeStyle = /**
  2916. * @param {?} el
  2917. * @param {?} style
  2918. * @param {?} flags
  2919. * @return {?}
  2920. */
  2921. function (el, style, flags) {
  2922. if (flags & RendererStyleFlags2.DashCase) {
  2923. el.style.removeProperty(style);
  2924. }
  2925. else {
  2926. // IE requires '' instead of null
  2927. // see https://github.com/angular/angular/issues/7916
  2928. el.style[style] = '';
  2929. }
  2930. };
  2931. /**
  2932. * @param {?} el
  2933. * @param {?} name
  2934. * @param {?} value
  2935. * @return {?}
  2936. */
  2937. DefaultDomRenderer2.prototype.setProperty = /**
  2938. * @param {?} el
  2939. * @param {?} name
  2940. * @param {?} value
  2941. * @return {?}
  2942. */
  2943. function (el, name, value) {
  2944. checkNoSyntheticProp(name, 'property');
  2945. el[name] = value;
  2946. };
  2947. /**
  2948. * @param {?} node
  2949. * @param {?} value
  2950. * @return {?}
  2951. */
  2952. DefaultDomRenderer2.prototype.setValue = /**
  2953. * @param {?} node
  2954. * @param {?} value
  2955. * @return {?}
  2956. */
  2957. function (node, value) { node.nodeValue = value; };
  2958. /**
  2959. * @param {?} target
  2960. * @param {?} event
  2961. * @param {?} callback
  2962. * @return {?}
  2963. */
  2964. DefaultDomRenderer2.prototype.listen = /**
  2965. * @param {?} target
  2966. * @param {?} event
  2967. * @param {?} callback
  2968. * @return {?}
  2969. */
  2970. function (target, event, callback) {
  2971. checkNoSyntheticProp(event, 'listener');
  2972. if (typeof target === 'string') {
  2973. return /** @type {?} */ (this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback)));
  2974. }
  2975. return /** @type {?} */ ((this.eventManager.addEventListener(target, event, decoratePreventDefault(callback))));
  2976. };
  2977. return DefaultDomRenderer2;
  2978. }());
  2979. var AT_CHARCODE = '@'.charCodeAt(0);
  2980. /**
  2981. * @param {?} name
  2982. * @param {?} nameKind
  2983. * @return {?}
  2984. */
  2985. function checkNoSyntheticProp(name, nameKind) {
  2986. if (name.charCodeAt(0) === AT_CHARCODE) {
  2987. throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application.");
  2988. }
  2989. }
  2990. var EmulatedEncapsulationDomRenderer2 = /** @class */ (function (_super) {
  2991. __extends(EmulatedEncapsulationDomRenderer2, _super);
  2992. function EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, component) {
  2993. var _this = _super.call(this, eventManager) || this;
  2994. _this.component = component;
  2995. var /** @type {?} */ styles = flattenStyles(component.id, component.styles, []);
  2996. sharedStylesHost.addStyles(styles);
  2997. _this.contentAttr = shimContentAttribute(component.id);
  2998. _this.hostAttr = shimHostAttribute(component.id);
  2999. return _this;
  3000. }
  3001. /**
  3002. * @param {?} element
  3003. * @return {?}
  3004. */
  3005. EmulatedEncapsulationDomRenderer2.prototype.applyToHost = /**
  3006. * @param {?} element
  3007. * @return {?}
  3008. */
  3009. function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); };
  3010. /**
  3011. * @param {?} parent
  3012. * @param {?} name
  3013. * @return {?}
  3014. */
  3015. EmulatedEncapsulationDomRenderer2.prototype.createElement = /**
  3016. * @param {?} parent
  3017. * @param {?} name
  3018. * @return {?}
  3019. */
  3020. function (parent, name) {
  3021. var /** @type {?} */ el = _super.prototype.createElement.call(this, parent, name);
  3022. _super.prototype.setAttribute.call(this, el, this.contentAttr, '');
  3023. return el;
  3024. };
  3025. return EmulatedEncapsulationDomRenderer2;
  3026. }(DefaultDomRenderer2));
  3027. var ShadowDomRenderer = /** @class */ (function (_super) {
  3028. __extends(ShadowDomRenderer, _super);
  3029. function ShadowDomRenderer(eventManager, sharedStylesHost, hostEl, component) {
  3030. var _this = _super.call(this, eventManager) || this;
  3031. _this.sharedStylesHost = sharedStylesHost;
  3032. _this.hostEl = hostEl;
  3033. _this.component = component;
  3034. _this.shadowRoot = (/** @type {?} */ (hostEl)).createShadowRoot();
  3035. _this.sharedStylesHost.addHost(_this.shadowRoot);
  3036. var /** @type {?} */ styles = flattenStyles(component.id, component.styles, []);
  3037. for (var /** @type {?} */ i = 0; i < styles.length; i++) {
  3038. var /** @type {?} */ styleEl = document.createElement('style');
  3039. styleEl.textContent = styles[i];
  3040. _this.shadowRoot.appendChild(styleEl);
  3041. }
  3042. return _this;
  3043. }
  3044. /**
  3045. * @param {?} node
  3046. * @return {?}
  3047. */
  3048. ShadowDomRenderer.prototype.nodeOrShadowRoot = /**
  3049. * @param {?} node
  3050. * @return {?}
  3051. */
  3052. function (node) { return node === this.hostEl ? this.shadowRoot : node; };
  3053. /**
  3054. * @return {?}
  3055. */
  3056. ShadowDomRenderer.prototype.destroy = /**
  3057. * @return {?}
  3058. */
  3059. function () { this.sharedStylesHost.removeHost(this.shadowRoot); };
  3060. /**
  3061. * @param {?} parent
  3062. * @param {?} newChild
  3063. * @return {?}
  3064. */
  3065. ShadowDomRenderer.prototype.appendChild = /**
  3066. * @param {?} parent
  3067. * @param {?} newChild
  3068. * @return {?}
  3069. */
  3070. function (parent, newChild) {
  3071. return _super.prototype.appendChild.call(this, this.nodeOrShadowRoot(parent), newChild);
  3072. };
  3073. /**
  3074. * @param {?} parent
  3075. * @param {?} newChild
  3076. * @param {?} refChild
  3077. * @return {?}
  3078. */
  3079. ShadowDomRenderer.prototype.insertBefore = /**
  3080. * @param {?} parent
  3081. * @param {?} newChild
  3082. * @param {?} refChild
  3083. * @return {?}
  3084. */
  3085. function (parent, newChild, refChild) {
  3086. return _super.prototype.insertBefore.call(this, this.nodeOrShadowRoot(parent), newChild, refChild);
  3087. };
  3088. /**
  3089. * @param {?} parent
  3090. * @param {?} oldChild
  3091. * @return {?}
  3092. */
  3093. ShadowDomRenderer.prototype.removeChild = /**
  3094. * @param {?} parent
  3095. * @param {?} oldChild
  3096. * @return {?}
  3097. */
  3098. function (parent, oldChild) {
  3099. return _super.prototype.removeChild.call(this, this.nodeOrShadowRoot(parent), oldChild);
  3100. };
  3101. /**
  3102. * @param {?} node
  3103. * @return {?}
  3104. */
  3105. ShadowDomRenderer.prototype.parentNode = /**
  3106. * @param {?} node
  3107. * @return {?}
  3108. */
  3109. function (node) {
  3110. return this.nodeOrShadowRoot(_super.prototype.parentNode.call(this, this.nodeOrShadowRoot(node)));
  3111. };
  3112. return ShadowDomRenderer;
  3113. }(DefaultDomRenderer2));
  3114. /**
  3115. * @fileoverview added by tsickle
  3116. * @suppress {checkTypes} checked by tsc
  3117. */
  3118. /**
  3119. * @license
  3120. * Copyright Google Inc. All Rights Reserved.
  3121. *
  3122. * Use of this source code is governed by an MIT-style license that can be
  3123. * found in the LICENSE file at https://angular.io/license
  3124. */
  3125. var ɵ0 = function (v) {
  3126. return '__zone_symbol__' + v;
  3127. };
  3128. /**
  3129. * Detect if Zone is present. If it is then use simple zone aware 'addEventListener'
  3130. * since Angular can do much more
  3131. * efficient bookkeeping than Zone can, because we have additional information. This speeds up
  3132. * addEventListener by 3x.
  3133. */
  3134. var __symbol__ = (typeof Zone !== 'undefined') && (/** @type {?} */ (Zone))['__symbol__'] || ɵ0;
  3135. var ADD_EVENT_LISTENER = __symbol__('addEventListener');
  3136. var REMOVE_EVENT_LISTENER = __symbol__('removeEventListener');
  3137. var symbolNames = {};
  3138. var FALSE = 'FALSE';
  3139. var ANGULAR = 'ANGULAR';
  3140. var NATIVE_ADD_LISTENER = 'addEventListener';
  3141. var NATIVE_REMOVE_LISTENER = 'removeEventListener';
  3142. // use the same symbol string which is used in zone.js
  3143. var stopSymbol = '__zone_symbol__propagationStopped';
  3144. var stopMethodSymbol = '__zone_symbol__stopImmediatePropagation';
  3145. var blackListedEvents = (typeof Zone !== 'undefined') && (/** @type {?} */ (Zone))[__symbol__('BLACK_LISTED_EVENTS')];
  3146. var blackListedMap;
  3147. if (blackListedEvents) {
  3148. blackListedMap = {};
  3149. blackListedEvents.forEach(function (eventName) { blackListedMap[eventName] = eventName; });
  3150. }
  3151. var isBlackListedEvent = function (eventName) {
  3152. if (!blackListedMap) {
  3153. return false;
  3154. }
  3155. return blackListedMap.hasOwnProperty(eventName);
  3156. };
  3157. // a global listener to handle all dom event,
  3158. // so we do not need to create a closure everytime
  3159. var globalListener = function (event) {
  3160. var /** @type {?} */ symbolName = symbolNames[event.type];
  3161. if (!symbolName) {
  3162. return;
  3163. }
  3164. var /** @type {?} */ taskDatas = this[symbolName];
  3165. if (!taskDatas) {
  3166. return;
  3167. }
  3168. var /** @type {?} */ args = [event];
  3169. if (taskDatas.length === 1) {
  3170. // if taskDatas only have one element, just invoke it
  3171. var /** @type {?} */ taskData = taskDatas[0];
  3172. if (taskData.zone !== Zone.current) {
  3173. // only use Zone.run when Zone.current not equals to stored zone
  3174. return taskData.zone.run(taskData.handler, this, args);
  3175. }
  3176. else {
  3177. return taskData.handler.apply(this, args);
  3178. }
  3179. }
  3180. else {
  3181. // copy tasks as a snapshot to avoid event handlers remove
  3182. // itself or others
  3183. var /** @type {?} */ copiedTasks = taskDatas.slice();
  3184. for (var /** @type {?} */ i = 0; i < copiedTasks.length; i++) {
  3185. // if other listener call event.stopImmediatePropagation
  3186. // just break
  3187. if ((/** @type {?} */ (event))[stopSymbol] === true) {
  3188. break;
  3189. }
  3190. var /** @type {?} */ taskData = copiedTasks[i];
  3191. if (taskData.zone !== Zone.current) {
  3192. // only use Zone.run when Zone.current not equals to stored zone
  3193. taskData.zone.run(taskData.handler, this, args);
  3194. }
  3195. else {
  3196. taskData.handler.apply(this, args);
  3197. }
  3198. }
  3199. }
  3200. };
  3201. var DomEventsPlugin = /** @class */ (function (_super) {
  3202. __extends(DomEventsPlugin, _super);
  3203. function DomEventsPlugin(doc, ngZone) {
  3204. var _this = _super.call(this, doc) || this;
  3205. _this.ngZone = ngZone;
  3206. _this.patchEvent();
  3207. return _this;
  3208. }
  3209. /**
  3210. * @return {?}
  3211. */
  3212. DomEventsPlugin.prototype.patchEvent = /**
  3213. * @return {?}
  3214. */
  3215. function () {
  3216. if (!Event || !Event.prototype) {
  3217. return;
  3218. }
  3219. if ((/** @type {?} */ (Event.prototype))[stopMethodSymbol]) {
  3220. // already patched by zone.js
  3221. return;
  3222. }
  3223. var /** @type {?} */ delegate = (/** @type {?} */ (Event.prototype))[stopMethodSymbol] =
  3224. Event.prototype.stopImmediatePropagation;
  3225. Event.prototype.stopImmediatePropagation = function () {
  3226. if (this) {
  3227. this[stopSymbol] = true;
  3228. }
  3229. // should call native delegate in case
  3230. // in some enviroment part of the application
  3231. // will not use the patched Event
  3232. delegate && delegate.apply(this, arguments);
  3233. };
  3234. };
  3235. // This plugin should come last in the list of plugins, because it accepts all
  3236. // events.
  3237. /**
  3238. * @param {?} eventName
  3239. * @return {?}
  3240. */
  3241. DomEventsPlugin.prototype.supports = /**
  3242. * @param {?} eventName
  3243. * @return {?}
  3244. */
  3245. function (eventName) { return true; };
  3246. /**
  3247. * @param {?} element
  3248. * @param {?} eventName
  3249. * @param {?} handler
  3250. * @return {?}
  3251. */
  3252. DomEventsPlugin.prototype.addEventListener = /**
  3253. * @param {?} element
  3254. * @param {?} eventName
  3255. * @param {?} handler
  3256. * @return {?}
  3257. */
  3258. function (element, eventName, handler) {
  3259. var _this = this;
  3260. /**
  3261. * This code is about to add a listener to the DOM. If Zone.js is present, than
  3262. * `addEventListener` has been patched. The patched code adds overhead in both
  3263. * memory and speed (3x slower) than native. For this reason if we detect that
  3264. * Zone.js is present we use a simple version of zone aware addEventListener instead.
  3265. * The result is faster registration and the zone will be restored.
  3266. * But ZoneSpec.onScheduleTask, ZoneSpec.onInvokeTask, ZoneSpec.onCancelTask
  3267. * will not be invoked
  3268. * We also do manual zone restoration in element.ts renderEventHandlerClosure method.
  3269. *
  3270. * NOTE: it is possible that the element is from different iframe, and so we
  3271. * have to check before we execute the method.
  3272. */
  3273. var /** @type {?} */ self = this;
  3274. var /** @type {?} */ zoneJsLoaded = element[ADD_EVENT_LISTENER];
  3275. var /** @type {?} */ callback = /** @type {?} */ (handler);
  3276. // if zonejs is loaded and current zone is not ngZone
  3277. // we keep Zone.current on target for later restoration.
  3278. if (zoneJsLoaded && (!NgZone.isInAngularZone() || isBlackListedEvent(eventName))) {
  3279. var /** @type {?} */ symbolName = symbolNames[eventName];
  3280. if (!symbolName) {
  3281. symbolName = symbolNames[eventName] = __symbol__(ANGULAR + eventName + FALSE);
  3282. }
  3283. var /** @type {?} */ taskDatas = (/** @type {?} */ (element))[symbolName];
  3284. var /** @type {?} */ globalListenerRegistered = taskDatas && taskDatas.length > 0;
  3285. if (!taskDatas) {
  3286. taskDatas = (/** @type {?} */ (element))[symbolName] = [];
  3287. }
  3288. var /** @type {?} */ zone = isBlackListedEvent(eventName) ? Zone.root : Zone.current;
  3289. if (taskDatas.length === 0) {
  3290. taskDatas.push({ zone: zone, handler: callback });
  3291. }
  3292. else {
  3293. var /** @type {?} */ callbackRegistered = false;
  3294. for (var /** @type {?} */ i = 0; i < taskDatas.length; i++) {
  3295. if (taskDatas[i].handler === callback) {
  3296. callbackRegistered = true;
  3297. break;
  3298. }
  3299. }
  3300. if (!callbackRegistered) {
  3301. taskDatas.push({ zone: zone, handler: callback });
  3302. }
  3303. }
  3304. if (!globalListenerRegistered) {
  3305. element[ADD_EVENT_LISTENER](eventName, globalListener, false);
  3306. }
  3307. }
  3308. else {
  3309. element[NATIVE_ADD_LISTENER](eventName, callback, false);
  3310. }
  3311. return function () { return _this.removeEventListener(element, eventName, callback); };
  3312. };
  3313. /**
  3314. * @param {?} target
  3315. * @param {?} eventName
  3316. * @param {?} callback
  3317. * @return {?}
  3318. */
  3319. DomEventsPlugin.prototype.removeEventListener = /**
  3320. * @param {?} target
  3321. * @param {?} eventName
  3322. * @param {?} callback
  3323. * @return {?}
  3324. */
  3325. function (target, eventName, callback) {
  3326. var /** @type {?} */ underlyingRemove = target[REMOVE_EVENT_LISTENER];
  3327. // zone.js not loaded, use native removeEventListener
  3328. if (!underlyingRemove) {
  3329. return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  3330. }
  3331. var /** @type {?} */ symbolName = symbolNames[eventName];
  3332. var /** @type {?} */ taskDatas = symbolName && target[symbolName];
  3333. if (!taskDatas) {
  3334. // addEventListener not using patched version
  3335. // just call native removeEventListener
  3336. return target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  3337. }
  3338. // fix issue 20532, should be able to remove
  3339. // listener which was added inside of ngZone
  3340. var /** @type {?} */ found = false;
  3341. for (var /** @type {?} */ i = 0; i < taskDatas.length; i++) {
  3342. // remove listener from taskDatas if the callback equals
  3343. if (taskDatas[i].handler === callback) {
  3344. found = true;
  3345. taskDatas.splice(i, 1);
  3346. break;
  3347. }
  3348. }
  3349. if (found) {
  3350. if (taskDatas.length === 0) {
  3351. // all listeners are removed, we can remove the globalListener from target
  3352. underlyingRemove.apply(target, [eventName, globalListener, false]);
  3353. }
  3354. }
  3355. else {
  3356. // not found in taskDatas, the callback may be added inside of ngZone
  3357. // use native remove listener to remove the calback
  3358. target[NATIVE_REMOVE_LISTENER].apply(target, [eventName, callback, false]);
  3359. }
  3360. };
  3361. DomEventsPlugin.decorators = [
  3362. { type: Injectable },
  3363. ];
  3364. /** @nocollapse */
  3365. DomEventsPlugin.ctorParameters = function () { return [
  3366. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  3367. { type: NgZone, },
  3368. ]; };
  3369. return DomEventsPlugin;
  3370. }(EventManagerPlugin));
  3371. /**
  3372. * @fileoverview added by tsickle
  3373. * @suppress {checkTypes} checked by tsc
  3374. */
  3375. /**
  3376. * @license
  3377. * Copyright Google Inc. All Rights Reserved.
  3378. *
  3379. * Use of this source code is governed by an MIT-style license that can be
  3380. * found in the LICENSE file at https://angular.io/license
  3381. */
  3382. var EVENT_NAMES = {
  3383. // pan
  3384. 'pan': true,
  3385. 'panstart': true,
  3386. 'panmove': true,
  3387. 'panend': true,
  3388. 'pancancel': true,
  3389. 'panleft': true,
  3390. 'panright': true,
  3391. 'panup': true,
  3392. 'pandown': true,
  3393. // pinch
  3394. 'pinch': true,
  3395. 'pinchstart': true,
  3396. 'pinchmove': true,
  3397. 'pinchend': true,
  3398. 'pinchcancel': true,
  3399. 'pinchin': true,
  3400. 'pinchout': true,
  3401. // press
  3402. 'press': true,
  3403. 'pressup': true,
  3404. // rotate
  3405. 'rotate': true,
  3406. 'rotatestart': true,
  3407. 'rotatemove': true,
  3408. 'rotateend': true,
  3409. 'rotatecancel': true,
  3410. // swipe
  3411. 'swipe': true,
  3412. 'swipeleft': true,
  3413. 'swiperight': true,
  3414. 'swipeup': true,
  3415. 'swipedown': true,
  3416. // tap
  3417. 'tap': true,
  3418. };
  3419. /**
  3420. * A DI token that you can use to provide{\@link HammerGestureConfig} to Angular. Use it to configure
  3421. * Hammer gestures.
  3422. *
  3423. * \@experimental
  3424. */
  3425. var HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
  3426. /**
  3427. * @record
  3428. */
  3429. /**
  3430. * \@experimental
  3431. */
  3432. var HammerGestureConfig = /** @class */ (function () {
  3433. function HammerGestureConfig() {
  3434. this.events = [];
  3435. this.overrides = {};
  3436. }
  3437. /**
  3438. * @param {?} element
  3439. * @return {?}
  3440. */
  3441. HammerGestureConfig.prototype.buildHammer = /**
  3442. * @param {?} element
  3443. * @return {?}
  3444. */
  3445. function (element) {
  3446. var /** @type {?} */ mc = new Hammer(element);
  3447. mc.get('pinch').set({ enable: true });
  3448. mc.get('rotate').set({ enable: true });
  3449. for (var /** @type {?} */ eventName in this.overrides) {
  3450. mc.get(eventName).set(this.overrides[eventName]);
  3451. }
  3452. return mc;
  3453. };
  3454. HammerGestureConfig.decorators = [
  3455. { type: Injectable },
  3456. ];
  3457. /** @nocollapse */
  3458. HammerGestureConfig.ctorParameters = function () { return []; };
  3459. return HammerGestureConfig;
  3460. }());
  3461. var HammerGesturesPlugin = /** @class */ (function (_super) {
  3462. __extends(HammerGesturesPlugin, _super);
  3463. function HammerGesturesPlugin(doc, _config) {
  3464. var _this = _super.call(this, doc) || this;
  3465. _this._config = _config;
  3466. return _this;
  3467. }
  3468. /**
  3469. * @param {?} eventName
  3470. * @return {?}
  3471. */
  3472. HammerGesturesPlugin.prototype.supports = /**
  3473. * @param {?} eventName
  3474. * @return {?}
  3475. */
  3476. function (eventName) {
  3477. if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
  3478. return false;
  3479. }
  3480. if (!(/** @type {?} */ (window)).Hammer) {
  3481. throw new Error("Hammer.js is not loaded, can not bind " + eventName + " event");
  3482. }
  3483. return true;
  3484. };
  3485. /**
  3486. * @param {?} element
  3487. * @param {?} eventName
  3488. * @param {?} handler
  3489. * @return {?}
  3490. */
  3491. HammerGesturesPlugin.prototype.addEventListener = /**
  3492. * @param {?} element
  3493. * @param {?} eventName
  3494. * @param {?} handler
  3495. * @return {?}
  3496. */
  3497. function (element, eventName, handler) {
  3498. var _this = this;
  3499. var /** @type {?} */ zone = this.manager.getZone();
  3500. eventName = eventName.toLowerCase();
  3501. return zone.runOutsideAngular(function () {
  3502. // Creating the manager bind events, must be done outside of angular
  3503. var /** @type {?} */ mc = _this._config.buildHammer(element);
  3504. var /** @type {?} */ callback = function (eventObj) {
  3505. zone.runGuarded(function () { handler(eventObj); });
  3506. };
  3507. mc.on(eventName, callback);
  3508. return function () { return mc.off(eventName, callback); };
  3509. });
  3510. };
  3511. /**
  3512. * @param {?} eventName
  3513. * @return {?}
  3514. */
  3515. HammerGesturesPlugin.prototype.isCustomEvent = /**
  3516. * @param {?} eventName
  3517. * @return {?}
  3518. */
  3519. function (eventName) { return this._config.events.indexOf(eventName) > -1; };
  3520. HammerGesturesPlugin.decorators = [
  3521. { type: Injectable },
  3522. ];
  3523. /** @nocollapse */
  3524. HammerGesturesPlugin.ctorParameters = function () { return [
  3525. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  3526. { type: HammerGestureConfig, decorators: [{ type: Inject, args: [HAMMER_GESTURE_CONFIG,] },] },
  3527. ]; };
  3528. return HammerGesturesPlugin;
  3529. }(EventManagerPlugin));
  3530. /**
  3531. * @fileoverview added by tsickle
  3532. * @suppress {checkTypes} checked by tsc
  3533. */
  3534. /**
  3535. * @license
  3536. * Copyright Google Inc. All Rights Reserved.
  3537. *
  3538. * Use of this source code is governed by an MIT-style license that can be
  3539. * found in the LICENSE file at https://angular.io/license
  3540. */
  3541. var MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
  3542. var ɵ0$1 = function (event) { return event.altKey; };
  3543. var ɵ1$1 = function (event) { return event.ctrlKey; };
  3544. var ɵ2$1 = function (event) { return event.metaKey; };
  3545. var ɵ3 = function (event) { return event.shiftKey; };
  3546. var MODIFIER_KEY_GETTERS = {
  3547. 'alt': ɵ0$1,
  3548. 'control': ɵ1$1,
  3549. 'meta': ɵ2$1,
  3550. 'shift': ɵ3
  3551. };
  3552. /**
  3553. * \@experimental
  3554. */
  3555. var KeyEventsPlugin = /** @class */ (function (_super) {
  3556. __extends(KeyEventsPlugin, _super);
  3557. function KeyEventsPlugin(doc) {
  3558. return _super.call(this, doc) || this;
  3559. }
  3560. /**
  3561. * @param {?} eventName
  3562. * @return {?}
  3563. */
  3564. KeyEventsPlugin.prototype.supports = /**
  3565. * @param {?} eventName
  3566. * @return {?}
  3567. */
  3568. function (eventName) { return KeyEventsPlugin.parseEventName(eventName) != null; };
  3569. /**
  3570. * @param {?} element
  3571. * @param {?} eventName
  3572. * @param {?} handler
  3573. * @return {?}
  3574. */
  3575. KeyEventsPlugin.prototype.addEventListener = /**
  3576. * @param {?} element
  3577. * @param {?} eventName
  3578. * @param {?} handler
  3579. * @return {?}
  3580. */
  3581. function (element, eventName, handler) {
  3582. var /** @type {?} */ parsedEvent = /** @type {?} */ ((KeyEventsPlugin.parseEventName(eventName)));
  3583. var /** @type {?} */ outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
  3584. return this.manager.getZone().runOutsideAngular(function () {
  3585. return getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
  3586. });
  3587. };
  3588. /**
  3589. * @param {?} eventName
  3590. * @return {?}
  3591. */
  3592. KeyEventsPlugin.parseEventName = /**
  3593. * @param {?} eventName
  3594. * @return {?}
  3595. */
  3596. function (eventName) {
  3597. var /** @type {?} */ parts = eventName.toLowerCase().split('.');
  3598. var /** @type {?} */ domEventName = parts.shift();
  3599. if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
  3600. return null;
  3601. }
  3602. var /** @type {?} */ key = KeyEventsPlugin._normalizeKey(/** @type {?} */ ((parts.pop())));
  3603. var /** @type {?} */ fullKey = '';
  3604. MODIFIER_KEYS.forEach(function (modifierName) {
  3605. var /** @type {?} */ index = parts.indexOf(modifierName);
  3606. if (index > -1) {
  3607. parts.splice(index, 1);
  3608. fullKey += modifierName + '.';
  3609. }
  3610. });
  3611. fullKey += key;
  3612. if (parts.length != 0 || key.length === 0) {
  3613. // returning null instead of throwing to let another plugin process the event
  3614. return null;
  3615. }
  3616. var /** @type {?} */ result = {};
  3617. result['domEventName'] = domEventName;
  3618. result['fullKey'] = fullKey;
  3619. return result;
  3620. };
  3621. /**
  3622. * @param {?} event
  3623. * @return {?}
  3624. */
  3625. KeyEventsPlugin.getEventFullKey = /**
  3626. * @param {?} event
  3627. * @return {?}
  3628. */
  3629. function (event) {
  3630. var /** @type {?} */ fullKey = '';
  3631. var /** @type {?} */ key = getDOM().getEventKey(event);
  3632. key = key.toLowerCase();
  3633. if (key === ' ') {
  3634. key = 'space'; // for readability
  3635. }
  3636. else if (key === '.') {
  3637. key = 'dot'; // because '.' is used as a separator in event names
  3638. }
  3639. MODIFIER_KEYS.forEach(function (modifierName) {
  3640. if (modifierName != key) {
  3641. var /** @type {?} */ modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
  3642. if (modifierGetter(event)) {
  3643. fullKey += modifierName + '.';
  3644. }
  3645. }
  3646. });
  3647. fullKey += key;
  3648. return fullKey;
  3649. };
  3650. /**
  3651. * @param {?} fullKey
  3652. * @param {?} handler
  3653. * @param {?} zone
  3654. * @return {?}
  3655. */
  3656. KeyEventsPlugin.eventCallback = /**
  3657. * @param {?} fullKey
  3658. * @param {?} handler
  3659. * @param {?} zone
  3660. * @return {?}
  3661. */
  3662. function (fullKey, handler, zone) {
  3663. return function (event /** TODO #9100 */) {
  3664. if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
  3665. zone.runGuarded(function () { return handler(event); });
  3666. }
  3667. };
  3668. };
  3669. /** @internal */
  3670. /**
  3671. * \@internal
  3672. * @param {?} keyName
  3673. * @return {?}
  3674. */
  3675. KeyEventsPlugin._normalizeKey = /**
  3676. * \@internal
  3677. * @param {?} keyName
  3678. * @return {?}
  3679. */
  3680. function (keyName) {
  3681. // TODO: switch to a Map if the mapping grows too much
  3682. switch (keyName) {
  3683. case 'esc':
  3684. return 'escape';
  3685. default:
  3686. return keyName;
  3687. }
  3688. };
  3689. KeyEventsPlugin.decorators = [
  3690. { type: Injectable },
  3691. ];
  3692. /** @nocollapse */
  3693. KeyEventsPlugin.ctorParameters = function () { return [
  3694. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  3695. ]; };
  3696. return KeyEventsPlugin;
  3697. }(EventManagerPlugin));
  3698. /**
  3699. * @fileoverview added by tsickle
  3700. * @suppress {checkTypes} checked by tsc
  3701. */
  3702. /**
  3703. * @license
  3704. * Copyright Google Inc. All Rights Reserved.
  3705. *
  3706. * Use of this source code is governed by an MIT-style license that can be
  3707. * found in the LICENSE file at https://angular.io/license
  3708. */
  3709. /**
  3710. * This helper class is used to get hold of an inert tree of DOM elements containing dirty HTML
  3711. * that needs sanitizing.
  3712. * Depending upon browser support we must use one of three strategies for doing this.
  3713. * Support: Safari 10.x -> XHR strategy
  3714. * Support: Firefox -> DomParser strategy
  3715. * Default: InertDocument strategy
  3716. */
  3717. var InertBodyHelper = /** @class */ (function () {
  3718. function InertBodyHelper(defaultDoc, DOM) {
  3719. this.defaultDoc = defaultDoc;
  3720. this.DOM = DOM;
  3721. var /** @type {?} */ inertDocument = this.DOM.createHtmlDocument();
  3722. this.inertBodyElement = inertDocument.body;
  3723. if (this.inertBodyElement == null) {
  3724. // usually there should be only one body element in the document, but IE doesn't have any, so
  3725. // we need to create one.
  3726. var /** @type {?} */ inertHtml = this.DOM.createElement('html', inertDocument);
  3727. this.inertBodyElement = this.DOM.createElement('body', inertDocument);
  3728. this.DOM.appendChild(inertHtml, this.inertBodyElement);
  3729. this.DOM.appendChild(inertDocument, inertHtml);
  3730. }
  3731. this.DOM.setInnerHTML(this.inertBodyElement, '<svg><g onload="this.parentNode.remove()"></g></svg>');
  3732. if (this.inertBodyElement.querySelector && !this.inertBodyElement.querySelector('svg')) {
  3733. // We just hit the Safari 10.1 bug - which allows JS to run inside the SVG G element
  3734. // so use the XHR strategy.
  3735. this.getInertBodyElement = this.getInertBodyElement_XHR;
  3736. return;
  3737. }
  3738. this.DOM.setInnerHTML(this.inertBodyElement, '<svg><p><style><img src="</style><img src=x onerror=alert(1)//">');
  3739. if (this.inertBodyElement.querySelector && this.inertBodyElement.querySelector('svg img')) {
  3740. // We just hit the Firefox bug - which prevents the inner img JS from being sanitized
  3741. // so use the DOMParser strategy, if it is available.
  3742. // If the DOMParser is not available then we are not in Firefox (Server/WebWorker?) so we
  3743. // fall through to the default strategy below.
  3744. if (isDOMParserAvailable()) {
  3745. this.getInertBodyElement = this.getInertBodyElement_DOMParser;
  3746. return;
  3747. }
  3748. }
  3749. // None of the bugs were hit so it is safe for us to use the default InertDocument strategy
  3750. this.getInertBodyElement = this.getInertBodyElement_InertDocument;
  3751. }
  3752. /**
  3753. * Use XHR to create and fill an inert body element (on Safari 10.1)
  3754. * See
  3755. * https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
  3756. * @param {?} html
  3757. * @return {?}
  3758. */
  3759. InertBodyHelper.prototype.getInertBodyElement_XHR = /**
  3760. * Use XHR to create and fill an inert body element (on Safari 10.1)
  3761. * See
  3762. * https://github.com/cure53/DOMPurify/blob/a992d3a75031cb8bb032e5ea8399ba972bdf9a65/src/purify.js#L439-L449
  3763. * @param {?} html
  3764. * @return {?}
  3765. */
  3766. function (html) {
  3767. // We add these extra elements to ensure that the rest of the content is parsed as expected
  3768. // e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
  3769. // `<head>` tag.
  3770. html = '<body><remove></remove>' + html + '</body>';
  3771. try {
  3772. html = encodeURI(html);
  3773. }
  3774. catch (/** @type {?} */ e) {
  3775. return null;
  3776. }
  3777. var /** @type {?} */ xhr = new XMLHttpRequest();
  3778. xhr.responseType = 'document';
  3779. xhr.open('GET', 'data:text/html;charset=utf-8,' + html, false);
  3780. xhr.send(null);
  3781. var /** @type {?} */ body = xhr.response.body;
  3782. body.removeChild(/** @type {?} */ ((body.firstChild)));
  3783. return body;
  3784. };
  3785. /**
  3786. * Use DOMParser to create and fill an inert body element (on Firefox)
  3787. * See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
  3788. *
  3789. * @param {?} html
  3790. * @return {?}
  3791. */
  3792. InertBodyHelper.prototype.getInertBodyElement_DOMParser = /**
  3793. * Use DOMParser to create and fill an inert body element (on Firefox)
  3794. * See https://github.com/cure53/DOMPurify/releases/tag/0.6.7
  3795. *
  3796. * @param {?} html
  3797. * @return {?}
  3798. */
  3799. function (html) {
  3800. // We add these extra elements to ensure that the rest of the content is parsed as expected
  3801. // e.g. leading whitespace is maintained and tags like `<meta>` do not get hoisted to the
  3802. // `<head>` tag.
  3803. html = '<body><remove></remove>' + html + '</body>';
  3804. try {
  3805. var /** @type {?} */ body = /** @type {?} */ (new (/** @type {?} */ (window))
  3806. .DOMParser()
  3807. .parseFromString(html, 'text/html')
  3808. .body);
  3809. body.removeChild(/** @type {?} */ ((body.firstChild)));
  3810. return body;
  3811. }
  3812. catch (/** @type {?} */ e) {
  3813. return null;
  3814. }
  3815. };
  3816. /**
  3817. * Use an HTML5 `template` element, if supported, or an inert body element created via
  3818. * `createHtmlDocument` to create and fill an inert DOM element.
  3819. * This is the default sane strategy to use if the browser does not require one of the specialised
  3820. * strategies above.
  3821. * @param {?} html
  3822. * @return {?}
  3823. */
  3824. InertBodyHelper.prototype.getInertBodyElement_InertDocument = /**
  3825. * Use an HTML5 `template` element, if supported, or an inert body element created via
  3826. * `createHtmlDocument` to create and fill an inert DOM element.
  3827. * This is the default sane strategy to use if the browser does not require one of the specialised
  3828. * strategies above.
  3829. * @param {?} html
  3830. * @return {?}
  3831. */
  3832. function (html) {
  3833. // Prefer using <template> element if supported.
  3834. var /** @type {?} */ templateEl = this.DOM.createElement('template');
  3835. if ('content' in templateEl) {
  3836. this.DOM.setInnerHTML(templateEl, html);
  3837. return templateEl;
  3838. }
  3839. this.DOM.setInnerHTML(this.inertBodyElement, html);
  3840. // Support: IE 9-11 only
  3841. // strip custom-namespaced attributes on IE<=11
  3842. if (this.defaultDoc.documentMode) {
  3843. this.stripCustomNsAttrs(this.inertBodyElement);
  3844. }
  3845. return this.inertBodyElement;
  3846. };
  3847. /**
  3848. * When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
  3849. * attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
  3850. * 'ns1:xlink:foo').
  3851. *
  3852. * This is undesirable since we don't want to allow any of these custom attributes. This method
  3853. * strips them all.
  3854. * @param {?} el
  3855. * @return {?}
  3856. */
  3857. InertBodyHelper.prototype.stripCustomNsAttrs = /**
  3858. * When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
  3859. * attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g.
  3860. * 'ns1:xlink:foo').
  3861. *
  3862. * This is undesirable since we don't want to allow any of these custom attributes. This method
  3863. * strips them all.
  3864. * @param {?} el
  3865. * @return {?}
  3866. */
  3867. function (el) {
  3868. var _this = this;
  3869. this.DOM.attributeMap(el).forEach(function (_, attrName) {
  3870. if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
  3871. _this.DOM.removeAttribute(el, attrName);
  3872. }
  3873. });
  3874. for (var _i = 0, _a = this.DOM.childNodesAsList(el); _i < _a.length; _i++) {
  3875. var n = _a[_i];
  3876. if (this.DOM.isElementNode(n))
  3877. this.stripCustomNsAttrs(/** @type {?} */ (n));
  3878. }
  3879. };
  3880. return InertBodyHelper;
  3881. }());
  3882. /**
  3883. * We need to determine whether the DOMParser exists in the global context.
  3884. * The try-catch is because, on some browsers, trying to access this property
  3885. * on window can actually throw an error.
  3886. *
  3887. * @suppress {uselessCode}
  3888. * @return {?}
  3889. */
  3890. function isDOMParserAvailable() {
  3891. try {
  3892. return !!(/** @type {?} */ (window)).DOMParser;
  3893. }
  3894. catch (/** @type {?} */ e) {
  3895. return false;
  3896. }
  3897. }
  3898. /**
  3899. * @fileoverview added by tsickle
  3900. * @suppress {checkTypes} checked by tsc
  3901. */
  3902. /**
  3903. * @license
  3904. * Copyright Google Inc. All Rights Reserved.
  3905. *
  3906. * Use of this source code is governed by an MIT-style license that can be
  3907. * found in the LICENSE file at https://angular.io/license
  3908. */
  3909. /**
  3910. * A pattern that recognizes a commonly useful subset of URLs that are safe.
  3911. *
  3912. * This regular expression matches a subset of URLs that will not cause script
  3913. * execution if used in URL context within a HTML document. Specifically, this
  3914. * regular expression matches if (comment from here on and regex copied from
  3915. * Soy's EscapingConventions):
  3916. * (1) Either a protocol in a whitelist (http, https, mailto or ftp).
  3917. * (2) or no protocol. A protocol must be followed by a colon. The below
  3918. * allows that by allowing colons only after one of the characters [/?#].
  3919. * A colon after a hash (#) must be in the fragment.
  3920. * Otherwise, a colon after a (?) must be in a query.
  3921. * Otherwise, a colon after a single solidus (/) must be in a path.
  3922. * Otherwise, a colon after a double solidus (//) must be in the authority
  3923. * (before port).
  3924. *
  3925. * The pattern disallows &, used in HTML entity declarations before
  3926. * one of the characters in [/?#]. This disallows HTML entities used in the
  3927. * protocol name, which should never happen, e.g. "h&#116;tp" for "http".
  3928. * It also disallows HTML entities in the first path part of a relative path,
  3929. * e.g. "foo&lt;bar/baz". Our existing escaping functions should not produce
  3930. * that. More importantly, it disallows masking of a colon,
  3931. * e.g. "javascript&#58;...".
  3932. *
  3933. * This regular expression was taken from the Closure sanitization library.
  3934. */
  3935. var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
  3936. /**
  3937. * A pattern that matches safe data URLs. Only matches image, video and audio types.
  3938. */
  3939. var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+\/]+=*$/i;
  3940. /**
  3941. * @param {?} url
  3942. * @return {?}
  3943. */
  3944. function sanitizeUrl(url) {
  3945. url = String(url);
  3946. if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN))
  3947. return url;
  3948. if (isDevMode()) {
  3949. getDOM().log("WARNING: sanitizing unsafe URL value " + url + " (see http://g.co/ng/security#xss)");
  3950. }
  3951. return 'unsafe:' + url;
  3952. }
  3953. /**
  3954. * @param {?} srcset
  3955. * @return {?}
  3956. */
  3957. function sanitizeSrcset(srcset) {
  3958. srcset = String(srcset);
  3959. return srcset.split(',').map(function (srcset) { return sanitizeUrl(srcset.trim()); }).join(', ');
  3960. }
  3961. /**
  3962. * @fileoverview added by tsickle
  3963. * @suppress {checkTypes} checked by tsc
  3964. */
  3965. /**
  3966. * @license
  3967. * Copyright Google Inc. All Rights Reserved.
  3968. *
  3969. * Use of this source code is governed by an MIT-style license that can be
  3970. * found in the LICENSE file at https://angular.io/license
  3971. */
  3972. /**
  3973. * @param {?} tags
  3974. * @return {?}
  3975. */
  3976. function tagSet(tags) {
  3977. var /** @type {?} */ res = {};
  3978. for (var _i = 0, _a = tags.split(','); _i < _a.length; _i++) {
  3979. var t = _a[_i];
  3980. res[t] = true;
  3981. }
  3982. return res;
  3983. }
  3984. /**
  3985. * @param {...?} sets
  3986. * @return {?}
  3987. */
  3988. function merge() {
  3989. var sets = [];
  3990. for (var _i = 0; _i < arguments.length; _i++) {
  3991. sets[_i] = arguments[_i];
  3992. }
  3993. var /** @type {?} */ res = {};
  3994. for (var _a = 0, sets_1 = sets; _a < sets_1.length; _a++) {
  3995. var s = sets_1[_a];
  3996. for (var /** @type {?} */ v in s) {
  3997. if (s.hasOwnProperty(v))
  3998. res[v] = true;
  3999. }
  4000. }
  4001. return res;
  4002. }
  4003. // Good source of info about elements and attributes
  4004. // http://dev.w3.org/html5/spec/Overview.html#semantics
  4005. // http://simon.html5.org/html-elements
  4006. // Safe Void Elements - HTML5
  4007. // http://dev.w3.org/html5/spec/Overview.html#void-elements
  4008. var VOID_ELEMENTS = tagSet('area,br,col,hr,img,wbr');
  4009. // Elements that you can, intentionally, leave open (and which close themselves)
  4010. // http://dev.w3.org/html5/spec/Overview.html#optional-tags
  4011. var OPTIONAL_END_TAG_BLOCK_ELEMENTS = tagSet('colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr');
  4012. var OPTIONAL_END_TAG_INLINE_ELEMENTS = tagSet('rp,rt');
  4013. var OPTIONAL_END_TAG_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, OPTIONAL_END_TAG_BLOCK_ELEMENTS);
  4014. // Safe Block Elements - HTML5
  4015. var BLOCK_ELEMENTS = merge(OPTIONAL_END_TAG_BLOCK_ELEMENTS, tagSet('address,article,' +
  4016. 'aside,blockquote,caption,center,del,details,dialog,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,' +
  4017. 'h6,header,hgroup,hr,ins,main,map,menu,nav,ol,pre,section,summary,table,ul'));
  4018. // Inline Elements - HTML5
  4019. var INLINE_ELEMENTS = merge(OPTIONAL_END_TAG_INLINE_ELEMENTS, tagSet('a,abbr,acronym,audio,b,' +
  4020. 'bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,picture,q,ruby,rp,rt,s,' +
  4021. 'samp,small,source,span,strike,strong,sub,sup,time,track,tt,u,var,video'));
  4022. var VALID_ELEMENTS = merge(VOID_ELEMENTS, BLOCK_ELEMENTS, INLINE_ELEMENTS, OPTIONAL_END_TAG_ELEMENTS);
  4023. // Attributes that have href and hence need to be sanitized
  4024. var URI_ATTRS = tagSet('background,cite,href,itemtype,longdesc,poster,src,xlink:href');
  4025. // Attributes that have special href set hence need to be sanitized
  4026. var SRCSET_ATTRS = tagSet('srcset');
  4027. var HTML_ATTRS = tagSet('abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,' +
  4028. 'compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,' +
  4029. 'ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,' +
  4030. 'scope,scrolling,shape,size,sizes,span,srclang,start,summary,tabindex,target,title,translate,type,usemap,' +
  4031. 'valign,value,vspace,width');
  4032. // NB: This currently consciously doesn't support SVG. SVG sanitization has had several security
  4033. // issues in the past, so it seems safer to leave it out if possible. If support for binding SVG via
  4034. // innerHTML is required, SVG attributes should be added here.
  4035. // NB: Sanitization does not allow <form> elements or other active elements (<button> etc). Those
  4036. // can be sanitized, but they increase security surface area without a legitimate use case, so they
  4037. // are left out here.
  4038. var VALID_ATTRS = merge(URI_ATTRS, SRCSET_ATTRS, HTML_ATTRS);
  4039. /**
  4040. * SanitizingHtmlSerializer serializes a DOM fragment, stripping out any unsafe elements and unsafe
  4041. * attributes.
  4042. */
  4043. var SanitizingHtmlSerializer = /** @class */ (function () {
  4044. function SanitizingHtmlSerializer() {
  4045. this.sanitizedSomething = false;
  4046. this.buf = [];
  4047. this.DOM = getDOM();
  4048. }
  4049. /**
  4050. * @param {?} el
  4051. * @return {?}
  4052. */
  4053. SanitizingHtmlSerializer.prototype.sanitizeChildren = /**
  4054. * @param {?} el
  4055. * @return {?}
  4056. */
  4057. function (el) {
  4058. // This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
  4059. // However this code never accesses properties off of `document` before deleting its contents
  4060. // again, so it shouldn't be vulnerable to DOM clobbering.
  4061. var /** @type {?} */ current = /** @type {?} */ ((this.DOM.firstChild(el)));
  4062. while (current) {
  4063. if (this.DOM.isElementNode(current)) {
  4064. this.startElement(/** @type {?} */ (current));
  4065. }
  4066. else if (this.DOM.isTextNode(current)) {
  4067. this.chars(/** @type {?} */ ((this.DOM.nodeValue(current))));
  4068. }
  4069. else {
  4070. // Strip non-element, non-text nodes.
  4071. this.sanitizedSomething = true;
  4072. }
  4073. if (this.DOM.firstChild(current)) {
  4074. current = /** @type {?} */ ((this.DOM.firstChild(current)));
  4075. continue;
  4076. }
  4077. while (current) {
  4078. // Leaving the element. Walk up and to the right, closing tags as we go.
  4079. if (this.DOM.isElementNode(current)) {
  4080. this.endElement(/** @type {?} */ (current));
  4081. }
  4082. var /** @type {?} */ next = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.nextSibling(current))));
  4083. if (next) {
  4084. current = next;
  4085. break;
  4086. }
  4087. current = this.checkClobberedElement(current, /** @type {?} */ ((this.DOM.parentElement(current))));
  4088. }
  4089. }
  4090. return this.buf.join('');
  4091. };
  4092. /**
  4093. * @param {?} element
  4094. * @return {?}
  4095. */
  4096. SanitizingHtmlSerializer.prototype.startElement = /**
  4097. * @param {?} element
  4098. * @return {?}
  4099. */
  4100. function (element) {
  4101. var _this = this;
  4102. var /** @type {?} */ tagName = this.DOM.nodeName(element).toLowerCase();
  4103. if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
  4104. this.sanitizedSomething = true;
  4105. return;
  4106. }
  4107. this.buf.push('<');
  4108. this.buf.push(tagName);
  4109. this.DOM.attributeMap(element).forEach(function (value, attrName) {
  4110. var /** @type {?} */ lower = attrName.toLowerCase();
  4111. if (!VALID_ATTRS.hasOwnProperty(lower)) {
  4112. _this.sanitizedSomething = true;
  4113. return;
  4114. }
  4115. // TODO(martinprobst): Special case image URIs for data:image/...
  4116. if (URI_ATTRS[lower])
  4117. value = sanitizeUrl(value);
  4118. if (SRCSET_ATTRS[lower])
  4119. value = sanitizeSrcset(value);
  4120. _this.buf.push(' ');
  4121. _this.buf.push(attrName);
  4122. _this.buf.push('="');
  4123. _this.buf.push(encodeEntities(value));
  4124. _this.buf.push('"');
  4125. });
  4126. this.buf.push('>');
  4127. };
  4128. /**
  4129. * @param {?} current
  4130. * @return {?}
  4131. */
  4132. SanitizingHtmlSerializer.prototype.endElement = /**
  4133. * @param {?} current
  4134. * @return {?}
  4135. */
  4136. function (current) {
  4137. var /** @type {?} */ tagName = this.DOM.nodeName(current).toLowerCase();
  4138. if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
  4139. this.buf.push('</');
  4140. this.buf.push(tagName);
  4141. this.buf.push('>');
  4142. }
  4143. };
  4144. /**
  4145. * @param {?} chars
  4146. * @return {?}
  4147. */
  4148. SanitizingHtmlSerializer.prototype.chars = /**
  4149. * @param {?} chars
  4150. * @return {?}
  4151. */
  4152. function (chars) { this.buf.push(encodeEntities(chars)); };
  4153. /**
  4154. * @param {?} node
  4155. * @param {?} nextNode
  4156. * @return {?}
  4157. */
  4158. SanitizingHtmlSerializer.prototype.checkClobberedElement = /**
  4159. * @param {?} node
  4160. * @param {?} nextNode
  4161. * @return {?}
  4162. */
  4163. function (node, nextNode) {
  4164. if (nextNode && this.DOM.contains(node, nextNode)) {
  4165. throw new Error("Failed to sanitize html because the element is clobbered: " + this.DOM.getOuterHTML(node));
  4166. }
  4167. return nextNode;
  4168. };
  4169. return SanitizingHtmlSerializer;
  4170. }());
  4171. // Regular Expressions for parsing tags and attributes
  4172. var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
  4173. // ! to ~ is the ASCII range.
  4174. var NON_ALPHANUMERIC_REGEXP = /([^\#-~ |!])/g;
  4175. /**
  4176. * Escapes all potentially dangerous characters, so that the
  4177. * resulting string can be safely inserted into attribute or
  4178. * element text.
  4179. * @param {?} value
  4180. * @return {?}
  4181. */
  4182. function encodeEntities(value) {
  4183. return value.replace(/&/g, '&amp;')
  4184. .replace(SURROGATE_PAIR_REGEXP, function (match) {
  4185. var /** @type {?} */ hi = match.charCodeAt(0);
  4186. var /** @type {?} */ low = match.charCodeAt(1);
  4187. return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';';
  4188. })
  4189. .replace(NON_ALPHANUMERIC_REGEXP, function (match) { return '&#' + match.charCodeAt(0) + ';'; })
  4190. .replace(/</g, '&lt;')
  4191. .replace(/>/g, '&gt;');
  4192. }
  4193. var inertBodyHelper;
  4194. /**
  4195. * Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
  4196. * the DOM in a browser environment.
  4197. * @param {?} defaultDoc
  4198. * @param {?} unsafeHtmlInput
  4199. * @return {?}
  4200. */
  4201. function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
  4202. var /** @type {?} */ DOM = getDOM();
  4203. var /** @type {?} */ inertBodyElement = null;
  4204. try {
  4205. inertBodyHelper = inertBodyHelper || new InertBodyHelper(defaultDoc, DOM);
  4206. // Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
  4207. var /** @type {?} */ unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
  4208. inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
  4209. // mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
  4210. // trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
  4211. var /** @type {?} */ mXSSAttempts = 5;
  4212. var /** @type {?} */ parsedHtml = unsafeHtml;
  4213. do {
  4214. if (mXSSAttempts === 0) {
  4215. throw new Error('Failed to sanitize html because the input is unstable');
  4216. }
  4217. mXSSAttempts--;
  4218. unsafeHtml = parsedHtml;
  4219. parsedHtml = DOM.getInnerHTML(inertBodyElement);
  4220. inertBodyElement = inertBodyHelper.getInertBodyElement(unsafeHtml);
  4221. } while (unsafeHtml !== parsedHtml);
  4222. var /** @type {?} */ sanitizer = new SanitizingHtmlSerializer();
  4223. var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(inertBodyElement) || inertBodyElement);
  4224. if (isDevMode() && sanitizer.sanitizedSomething) {
  4225. DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
  4226. }
  4227. return safeHtml;
  4228. }
  4229. finally {
  4230. // In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
  4231. if (inertBodyElement) {
  4232. var /** @type {?} */ parent_1 = DOM.getTemplateContent(inertBodyElement) || inertBodyElement;
  4233. for (var _i = 0, _a = DOM.childNodesAsList(parent_1); _i < _a.length; _i++) {
  4234. var child = _a[_i];
  4235. DOM.removeChild(parent_1, child);
  4236. }
  4237. }
  4238. }
  4239. }
  4240. /**
  4241. * @fileoverview added by tsickle
  4242. * @suppress {checkTypes} checked by tsc
  4243. */
  4244. /**
  4245. * @license
  4246. * Copyright Google Inc. All Rights Reserved.
  4247. *
  4248. * Use of this source code is governed by an MIT-style license that can be
  4249. * found in the LICENSE file at https://angular.io/license
  4250. */
  4251. /**
  4252. * Regular expression for safe style values.
  4253. *
  4254. * Quotes (" and ') are allowed, but a check must be done elsewhere to ensure they're balanced.
  4255. *
  4256. * ',' allows multiple values to be assigned to the same property (e.g. background-attachment or
  4257. * font-family) and hence could allow multiple values to get injected, but that should pose no risk
  4258. * of XSS.
  4259. *
  4260. * The function expression checks only for XSS safety, not for CSS validity.
  4261. *
  4262. * This regular expression was taken from the Closure sanitization library, and augmented for
  4263. * transformation values.
  4264. */
  4265. var VALUES = '[-,."\'%_!# a-zA-Z0-9]+';
  4266. var TRANSFORMATION_FNS = '(?:matrix|translate|scale|rotate|skew|perspective)(?:X|Y|3d)?';
  4267. var COLOR_FNS = '(?:rgb|hsl)a?';
  4268. var GRADIENTS = '(?:repeating-)?(?:linear|radial)-gradient';
  4269. var CSS3_FNS = '(?:calc|attr)';
  4270. var FN_ARGS = '\\([-0-9.%, #a-zA-Z]+\\)';
  4271. var SAFE_STYLE_VALUE = new RegExp("^(" + VALUES + "|" +
  4272. ("(?:" + TRANSFORMATION_FNS + "|" + COLOR_FNS + "|" + GRADIENTS + "|" + CSS3_FNS + ")") +
  4273. (FN_ARGS + ")$"), 'g');
  4274. /**
  4275. * Matches a `url(...)` value with an arbitrary argument as long as it does
  4276. * not contain parentheses.
  4277. *
  4278. * The URL value still needs to be sanitized separately.
  4279. *
  4280. * `url(...)` values are a very common use case, e.g. for `background-image`. With carefully crafted
  4281. * CSS style rules, it is possible to construct an information leak with `url` values in CSS, e.g.
  4282. * by observing whether scroll bars are displayed, or character ranges used by a font face
  4283. * definition.
  4284. *
  4285. * Angular only allows binding CSS values (as opposed to entire CSS rules), so it is unlikely that
  4286. * binding a URL value without further cooperation from the page will cause an information leak, and
  4287. * if so, it is just a leak, not a full blown XSS vulnerability.
  4288. *
  4289. * Given the common use case, low likelihood of attack vector, and low impact of an attack, this
  4290. * code is permissive and allows URLs that sanitize otherwise.
  4291. */
  4292. var URL_RE = /^url\(([^)]+)\)$/;
  4293. /**
  4294. * Checks that quotes (" and ') are properly balanced inside a string. Assumes
  4295. * that neither escape (\) nor any other character that could result in
  4296. * breaking out of a string parsing context are allowed;
  4297. * see http://www.w3.org/TR/css3-syntax/#string-token-diagram.
  4298. *
  4299. * This code was taken from the Closure sanitization library.
  4300. * @param {?} value
  4301. * @return {?}
  4302. */
  4303. function hasBalancedQuotes(value) {
  4304. var /** @type {?} */ outsideSingle = true;
  4305. var /** @type {?} */ outsideDouble = true;
  4306. for (var /** @type {?} */ i = 0; i < value.length; i++) {
  4307. var /** @type {?} */ c = value.charAt(i);
  4308. if (c === '\'' && outsideDouble) {
  4309. outsideSingle = !outsideSingle;
  4310. }
  4311. else if (c === '"' && outsideSingle) {
  4312. outsideDouble = !outsideDouble;
  4313. }
  4314. }
  4315. return outsideSingle && outsideDouble;
  4316. }
  4317. /**
  4318. * Sanitizes the given untrusted CSS style property value (i.e. not an entire object, just a single
  4319. * value) and returns a value that is safe to use in a browser environment.
  4320. * @param {?} value
  4321. * @return {?}
  4322. */
  4323. function sanitizeStyle(value) {
  4324. value = String(value).trim(); // Make sure it's actually a string.
  4325. if (!value)
  4326. return '';
  4327. // Single url(...) values are supported, but only for URLs that sanitize cleanly. See above for
  4328. // reasoning behind this.
  4329. var /** @type {?} */ urlMatch = value.match(URL_RE);
  4330. if ((urlMatch && sanitizeUrl(urlMatch[1]) === urlMatch[1]) ||
  4331. value.match(SAFE_STYLE_VALUE) && hasBalancedQuotes(value)) {
  4332. return value; // Safe style values.
  4333. }
  4334. if (isDevMode()) {
  4335. getDOM().log("WARNING: sanitizing unsafe style value " + value + " (see http://g.co/ng/security#xss).");
  4336. }
  4337. return 'unsafe';
  4338. }
  4339. /**
  4340. * @fileoverview added by tsickle
  4341. * @suppress {checkTypes} checked by tsc
  4342. */
  4343. /**
  4344. * @license
  4345. * Copyright Google Inc. All Rights Reserved.
  4346. *
  4347. * Use of this source code is governed by an MIT-style license that can be
  4348. * found in the LICENSE file at https://angular.io/license
  4349. */
  4350. /**
  4351. * Marker interface for a value that's safe to use in a particular context.
  4352. *
  4353. * \@stable
  4354. * @record
  4355. */
  4356. /**
  4357. * Marker interface for a value that's safe to use as HTML.
  4358. *
  4359. * \@stable
  4360. * @record
  4361. */
  4362. /**
  4363. * Marker interface for a value that's safe to use as style (CSS).
  4364. *
  4365. * \@stable
  4366. * @record
  4367. */
  4368. /**
  4369. * Marker interface for a value that's safe to use as JavaScript.
  4370. *
  4371. * \@stable
  4372. * @record
  4373. */
  4374. /**
  4375. * Marker interface for a value that's safe to use as a URL linking to a document.
  4376. *
  4377. * \@stable
  4378. * @record
  4379. */
  4380. /**
  4381. * Marker interface for a value that's safe to use as a URL to load executable code from.
  4382. *
  4383. * \@stable
  4384. * @record
  4385. */
  4386. /**
  4387. * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
  4388. * values to be safe to use in the different DOM contexts.
  4389. *
  4390. * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
  4391. * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
  4392. * the website.
  4393. *
  4394. * In specific situations, it might be necessary to disable sanitization, for example if the
  4395. * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
  4396. * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
  4397. * methods, and then binding to that value from the template.
  4398. *
  4399. * These situations should be very rare, and extraordinary care must be taken to avoid creating a
  4400. * Cross Site Scripting (XSS) security bug!
  4401. *
  4402. * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
  4403. * close as possible to the source of the value, to make it easy to verify no security bug is
  4404. * created by its use.
  4405. *
  4406. * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
  4407. * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
  4408. * code. The sanitizer leaves safe values intact.
  4409. *
  4410. * \@security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
  4411. * sanitization for the value passed in. Carefully check and audit all values and code paths going
  4412. * into this call. Make sure any user data is appropriately escaped for this security context.
  4413. * For more detail, see the [Security Guide](http://g.co/ng/security).
  4414. *
  4415. * \@stable
  4416. * @abstract
  4417. */
  4418. var DomSanitizer = /** @class */ (function () {
  4419. function DomSanitizer() {
  4420. }
  4421. return DomSanitizer;
  4422. }());
  4423. var DomSanitizerImpl = /** @class */ (function (_super) {
  4424. __extends(DomSanitizerImpl, _super);
  4425. function DomSanitizerImpl(_doc) {
  4426. var _this = _super.call(this) || this;
  4427. _this._doc = _doc;
  4428. return _this;
  4429. }
  4430. /**
  4431. * @param {?} ctx
  4432. * @param {?} value
  4433. * @return {?}
  4434. */
  4435. DomSanitizerImpl.prototype.sanitize = /**
  4436. * @param {?} ctx
  4437. * @param {?} value
  4438. * @return {?}
  4439. */
  4440. function (ctx, value) {
  4441. if (value == null)
  4442. return null;
  4443. switch (ctx) {
  4444. case SecurityContext.NONE:
  4445. return /** @type {?} */ (value);
  4446. case SecurityContext.HTML:
  4447. if (value instanceof SafeHtmlImpl)
  4448. return value.changingThisBreaksApplicationSecurity;
  4449. this.checkNotSafeValue(value, 'HTML');
  4450. return sanitizeHtml(this._doc, String(value));
  4451. case SecurityContext.STYLE:
  4452. if (value instanceof SafeStyleImpl)
  4453. return value.changingThisBreaksApplicationSecurity;
  4454. this.checkNotSafeValue(value, 'Style');
  4455. return sanitizeStyle(/** @type {?} */ (value));
  4456. case SecurityContext.SCRIPT:
  4457. if (value instanceof SafeScriptImpl)
  4458. return value.changingThisBreaksApplicationSecurity;
  4459. this.checkNotSafeValue(value, 'Script');
  4460. throw new Error('unsafe value used in a script context');
  4461. case SecurityContext.URL:
  4462. if (value instanceof SafeResourceUrlImpl || value instanceof SafeUrlImpl) {
  4463. // Allow resource URLs in URL contexts, they are strictly more trusted.
  4464. return value.changingThisBreaksApplicationSecurity;
  4465. }
  4466. this.checkNotSafeValue(value, 'URL');
  4467. return sanitizeUrl(String(value));
  4468. case SecurityContext.RESOURCE_URL:
  4469. if (value instanceof SafeResourceUrlImpl) {
  4470. return value.changingThisBreaksApplicationSecurity;
  4471. }
  4472. this.checkNotSafeValue(value, 'ResourceURL');
  4473. throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
  4474. default:
  4475. throw new Error("Unexpected SecurityContext " + ctx + " (see http://g.co/ng/security#xss)");
  4476. }
  4477. };
  4478. /**
  4479. * @param {?} value
  4480. * @param {?} expectedType
  4481. * @return {?}
  4482. */
  4483. DomSanitizerImpl.prototype.checkNotSafeValue = /**
  4484. * @param {?} value
  4485. * @param {?} expectedType
  4486. * @return {?}
  4487. */
  4488. function (value, expectedType) {
  4489. if (value instanceof SafeValueImpl) {
  4490. throw new Error("Required a safe " + expectedType + ", got a " + value.getTypeName() + " " +
  4491. "(see http://g.co/ng/security#xss)");
  4492. }
  4493. };
  4494. /**
  4495. * @param {?} value
  4496. * @return {?}
  4497. */
  4498. DomSanitizerImpl.prototype.bypassSecurityTrustHtml = /**
  4499. * @param {?} value
  4500. * @return {?}
  4501. */
  4502. function (value) { return new SafeHtmlImpl(value); };
  4503. /**
  4504. * @param {?} value
  4505. * @return {?}
  4506. */
  4507. DomSanitizerImpl.prototype.bypassSecurityTrustStyle = /**
  4508. * @param {?} value
  4509. * @return {?}
  4510. */
  4511. function (value) { return new SafeStyleImpl(value); };
  4512. /**
  4513. * @param {?} value
  4514. * @return {?}
  4515. */
  4516. DomSanitizerImpl.prototype.bypassSecurityTrustScript = /**
  4517. * @param {?} value
  4518. * @return {?}
  4519. */
  4520. function (value) { return new SafeScriptImpl(value); };
  4521. /**
  4522. * @param {?} value
  4523. * @return {?}
  4524. */
  4525. DomSanitizerImpl.prototype.bypassSecurityTrustUrl = /**
  4526. * @param {?} value
  4527. * @return {?}
  4528. */
  4529. function (value) { return new SafeUrlImpl(value); };
  4530. /**
  4531. * @param {?} value
  4532. * @return {?}
  4533. */
  4534. DomSanitizerImpl.prototype.bypassSecurityTrustResourceUrl = /**
  4535. * @param {?} value
  4536. * @return {?}
  4537. */
  4538. function (value) {
  4539. return new SafeResourceUrlImpl(value);
  4540. };
  4541. DomSanitizerImpl.decorators = [
  4542. { type: Injectable },
  4543. ];
  4544. /** @nocollapse */
  4545. DomSanitizerImpl.ctorParameters = function () { return [
  4546. { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
  4547. ]; };
  4548. return DomSanitizerImpl;
  4549. }(DomSanitizer));
  4550. /**
  4551. * @abstract
  4552. */
  4553. var SafeValueImpl = /** @class */ (function () {
  4554. function SafeValueImpl(changingThisBreaksApplicationSecurity) {
  4555. // empty
  4556. this.changingThisBreaksApplicationSecurity = changingThisBreaksApplicationSecurity;
  4557. }
  4558. /**
  4559. * @return {?}
  4560. */
  4561. SafeValueImpl.prototype.toString = /**
  4562. * @return {?}
  4563. */
  4564. function () {
  4565. return "SafeValue must use [property]=binding: " + this.changingThisBreaksApplicationSecurity +
  4566. " (see http://g.co/ng/security#xss)";
  4567. };
  4568. return SafeValueImpl;
  4569. }());
  4570. var SafeHtmlImpl = /** @class */ (function (_super) {
  4571. __extends(SafeHtmlImpl, _super);
  4572. function SafeHtmlImpl() {
  4573. return _super !== null && _super.apply(this, arguments) || this;
  4574. }
  4575. /**
  4576. * @return {?}
  4577. */
  4578. SafeHtmlImpl.prototype.getTypeName = /**
  4579. * @return {?}
  4580. */
  4581. function () { return 'HTML'; };
  4582. return SafeHtmlImpl;
  4583. }(SafeValueImpl));
  4584. var SafeStyleImpl = /** @class */ (function (_super) {
  4585. __extends(SafeStyleImpl, _super);
  4586. function SafeStyleImpl() {
  4587. return _super !== null && _super.apply(this, arguments) || this;
  4588. }
  4589. /**
  4590. * @return {?}
  4591. */
  4592. SafeStyleImpl.prototype.getTypeName = /**
  4593. * @return {?}
  4594. */
  4595. function () { return 'Style'; };
  4596. return SafeStyleImpl;
  4597. }(SafeValueImpl));
  4598. var SafeScriptImpl = /** @class */ (function (_super) {
  4599. __extends(SafeScriptImpl, _super);
  4600. function SafeScriptImpl() {
  4601. return _super !== null && _super.apply(this, arguments) || this;
  4602. }
  4603. /**
  4604. * @return {?}
  4605. */
  4606. SafeScriptImpl.prototype.getTypeName = /**
  4607. * @return {?}
  4608. */
  4609. function () { return 'Script'; };
  4610. return SafeScriptImpl;
  4611. }(SafeValueImpl));
  4612. var SafeUrlImpl = /** @class */ (function (_super) {
  4613. __extends(SafeUrlImpl, _super);
  4614. function SafeUrlImpl() {
  4615. return _super !== null && _super.apply(this, arguments) || this;
  4616. }
  4617. /**
  4618. * @return {?}
  4619. */
  4620. SafeUrlImpl.prototype.getTypeName = /**
  4621. * @return {?}
  4622. */
  4623. function () { return 'URL'; };
  4624. return SafeUrlImpl;
  4625. }(SafeValueImpl));
  4626. var SafeResourceUrlImpl = /** @class */ (function (_super) {
  4627. __extends(SafeResourceUrlImpl, _super);
  4628. function SafeResourceUrlImpl() {
  4629. return _super !== null && _super.apply(this, arguments) || this;
  4630. }
  4631. /**
  4632. * @return {?}
  4633. */
  4634. SafeResourceUrlImpl.prototype.getTypeName = /**
  4635. * @return {?}
  4636. */
  4637. function () { return 'ResourceURL'; };
  4638. return SafeResourceUrlImpl;
  4639. }(SafeValueImpl));
  4640. /**
  4641. * @fileoverview added by tsickle
  4642. * @suppress {checkTypes} checked by tsc
  4643. */
  4644. /**
  4645. * @license
  4646. * Copyright Google Inc. All Rights Reserved.
  4647. *
  4648. * Use of this source code is governed by an MIT-style license that can be
  4649. * found in the LICENSE file at https://angular.io/license
  4650. */
  4651. var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
  4652. { provide: PLATFORM_ID, useValue: ɵPLATFORM_BROWSER_ID },
  4653. { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
  4654. { provide: PlatformLocation, useClass: BrowserPlatformLocation, deps: [DOCUMENT$1] },
  4655. { provide: DOCUMENT$1, useFactory: _document, deps: [] },
  4656. ];
  4657. /**
  4658. * \@security Replacing built-in sanitization providers exposes the application to XSS risks.
  4659. * Attacker-controlled data introduced by an unsanitized provider could expose your
  4660. * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
  4661. * \@experimental
  4662. */
  4663. var BROWSER_SANITIZATION_PROVIDERS = [
  4664. { provide: Sanitizer, useExisting: DomSanitizer },
  4665. { provide: DomSanitizer, useClass: DomSanitizerImpl, deps: [DOCUMENT$1] },
  4666. ];
  4667. /**
  4668. * \@stable
  4669. */
  4670. var platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
  4671. /**
  4672. * @return {?}
  4673. */
  4674. function initDomAdapter() {
  4675. BrowserDomAdapter.makeCurrent();
  4676. BrowserGetTestability.init();
  4677. }
  4678. /**
  4679. * @return {?}
  4680. */
  4681. function errorHandler() {
  4682. return new ErrorHandler();
  4683. }
  4684. /**
  4685. * @return {?}
  4686. */
  4687. function _document() {
  4688. return document;
  4689. }
  4690. /**
  4691. * The ng module for the browser.
  4692. *
  4693. * \@stable
  4694. */
  4695. var BrowserModule = /** @class */ (function () {
  4696. function BrowserModule(parentModule) {
  4697. if (parentModule) {
  4698. 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.");
  4699. }
  4700. }
  4701. /**
  4702. * Configures a browser-based application to transition from a server-rendered app, if
  4703. * one is present on the page. The specified parameters must include an application id,
  4704. * which must match between the client and server applications.
  4705. *
  4706. * @experimental
  4707. */
  4708. /**
  4709. * Configures a browser-based application to transition from a server-rendered app, if
  4710. * one is present on the page. The specified parameters must include an application id,
  4711. * which must match between the client and server applications.
  4712. *
  4713. * \@experimental
  4714. * @param {?} params
  4715. * @return {?}
  4716. */
  4717. BrowserModule.withServerTransition = /**
  4718. * Configures a browser-based application to transition from a server-rendered app, if
  4719. * one is present on the page. The specified parameters must include an application id,
  4720. * which must match between the client and server applications.
  4721. *
  4722. * \@experimental
  4723. * @param {?} params
  4724. * @return {?}
  4725. */
  4726. function (params) {
  4727. return {
  4728. ngModule: BrowserModule,
  4729. providers: [
  4730. { provide: APP_ID, useValue: params.appId },
  4731. { provide: TRANSITION_ID, useExisting: APP_ID },
  4732. SERVER_TRANSITION_PROVIDERS,
  4733. ],
  4734. };
  4735. };
  4736. BrowserModule.decorators = [
  4737. { type: NgModule, args: [{
  4738. providers: [
  4739. BROWSER_SANITIZATION_PROVIDERS,
  4740. { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
  4741. { provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true },
  4742. { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true },
  4743. { provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true },
  4744. { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig },
  4745. DomRendererFactory2,
  4746. { provide: RendererFactory2, useExisting: DomRendererFactory2 },
  4747. { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
  4748. DomSharedStylesHost,
  4749. Testability,
  4750. EventManager,
  4751. ELEMENT_PROBE_PROVIDERS,
  4752. Meta,
  4753. Title,
  4754. ],
  4755. exports: [CommonModule, ApplicationModule]
  4756. },] },
  4757. ];
  4758. /** @nocollapse */
  4759. BrowserModule.ctorParameters = function () { return [
  4760. { type: BrowserModule, decorators: [{ type: Optional }, { type: SkipSelf },] },
  4761. ]; };
  4762. return BrowserModule;
  4763. }());
  4764. /**
  4765. * @fileoverview added by tsickle
  4766. * @suppress {checkTypes} checked by tsc
  4767. */
  4768. /**
  4769. * @license
  4770. * Copyright Google Inc. All Rights Reserved.
  4771. *
  4772. * Use of this source code is governed by an MIT-style license that can be
  4773. * found in the LICENSE file at https://angular.io/license
  4774. */
  4775. var win = typeof window !== 'undefined' && window || /** @type {?} */ ({});
  4776. /**
  4777. * @fileoverview added by tsickle
  4778. * @suppress {checkTypes} checked by tsc
  4779. */
  4780. /**
  4781. * @license
  4782. * Copyright Google Inc. All Rights Reserved.
  4783. *
  4784. * Use of this source code is governed by an MIT-style license that can be
  4785. * found in the LICENSE file at https://angular.io/license
  4786. */
  4787. var ChangeDetectionPerfRecord = /** @class */ (function () {
  4788. function ChangeDetectionPerfRecord(msPerTick, numTicks) {
  4789. this.msPerTick = msPerTick;
  4790. this.numTicks = numTicks;
  4791. }
  4792. return ChangeDetectionPerfRecord;
  4793. }());
  4794. /**
  4795. * Entry point for all Angular profiling-related debug tools. This object
  4796. * corresponds to the `ng.profiler` in the dev console.
  4797. */
  4798. var AngularProfiler = /** @class */ (function () {
  4799. function AngularProfiler(ref) {
  4800. this.appRef = ref.injector.get(ApplicationRef);
  4801. }
  4802. // tslint:disable:no-console
  4803. /**
  4804. * Exercises change detection in a loop and then prints the average amount of
  4805. * time in milliseconds how long a single round of change detection takes for
  4806. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  4807. * of 500 milliseconds.
  4808. *
  4809. * Optionally, a user may pass a `config` parameter containing a map of
  4810. * options. Supported options are:
  4811. *
  4812. * `record` (boolean) - causes the profiler to record a CPU profile while
  4813. * it exercises the change detector. Example:
  4814. *
  4815. * ```
  4816. * ng.profiler.timeChangeDetection({record: true})
  4817. * ```
  4818. */
  4819. /**
  4820. * Exercises change detection in a loop and then prints the average amount of
  4821. * time in milliseconds how long a single round of change detection takes for
  4822. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  4823. * of 500 milliseconds.
  4824. *
  4825. * Optionally, a user may pass a `config` parameter containing a map of
  4826. * options. Supported options are:
  4827. *
  4828. * `record` (boolean) - causes the profiler to record a CPU profile while
  4829. * it exercises the change detector. Example:
  4830. *
  4831. * ```
  4832. * ng.profiler.timeChangeDetection({record: true})
  4833. * ```
  4834. * @param {?} config
  4835. * @return {?}
  4836. */
  4837. AngularProfiler.prototype.timeChangeDetection = /**
  4838. * Exercises change detection in a loop and then prints the average amount of
  4839. * time in milliseconds how long a single round of change detection takes for
  4840. * the current state of the UI. It runs a minimum of 5 rounds for a minimum
  4841. * of 500 milliseconds.
  4842. *
  4843. * Optionally, a user may pass a `config` parameter containing a map of
  4844. * options. Supported options are:
  4845. *
  4846. * `record` (boolean) - causes the profiler to record a CPU profile while
  4847. * it exercises the change detector. Example:
  4848. *
  4849. * ```
  4850. * ng.profiler.timeChangeDetection({record: true})
  4851. * ```
  4852. * @param {?} config
  4853. * @return {?}
  4854. */
  4855. function (config) {
  4856. var /** @type {?} */ record = config && config['record'];
  4857. var /** @type {?} */ profileName = 'Change Detection';
  4858. // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
  4859. var /** @type {?} */ isProfilerAvailable = win.console.profile != null;
  4860. if (record && isProfilerAvailable) {
  4861. win.console.profile(profileName);
  4862. }
  4863. var /** @type {?} */ start = getDOM().performanceNow();
  4864. var /** @type {?} */ numTicks = 0;
  4865. while (numTicks < 5 || (getDOM().performanceNow() - start) < 500) {
  4866. this.appRef.tick();
  4867. numTicks++;
  4868. }
  4869. var /** @type {?} */ end = getDOM().performanceNow();
  4870. if (record && isProfilerAvailable) {
  4871. // need to cast to <any> because type checker thinks there's no argument
  4872. // while in fact there is:
  4873. //
  4874. // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd
  4875. (/** @type {?} */ (win.console.profileEnd))(profileName);
  4876. }
  4877. var /** @type {?} */ msPerTick = (end - start) / numTicks;
  4878. win.console.log("ran " + numTicks + " change detection cycles");
  4879. win.console.log(msPerTick.toFixed(2) + " ms per check");
  4880. return new ChangeDetectionPerfRecord(msPerTick, numTicks);
  4881. };
  4882. return AngularProfiler;
  4883. }());
  4884. /**
  4885. * @fileoverview added by tsickle
  4886. * @suppress {checkTypes} checked by tsc
  4887. */
  4888. /**
  4889. * @license
  4890. * Copyright Google Inc. All Rights Reserved.
  4891. *
  4892. * Use of this source code is governed by an MIT-style license that can be
  4893. * found in the LICENSE file at https://angular.io/license
  4894. */
  4895. var PROFILER_GLOBAL_NAME = 'profiler';
  4896. /**
  4897. * Enabled Angular debug tools that are accessible via your browser's
  4898. * developer console.
  4899. *
  4900. * Usage:
  4901. *
  4902. * 1. Open developer console (e.g. in Chrome Ctrl + Shift + j)
  4903. * 1. Type `ng.` (usually the console will show auto-complete suggestion)
  4904. * 1. Try the change detection profiler `ng.profiler.timeChangeDetection()`
  4905. * then hit Enter.
  4906. *
  4907. * \@experimental All debugging apis are currently experimental.
  4908. * @template T
  4909. * @param {?} ref
  4910. * @return {?}
  4911. */
  4912. function enableDebugTools(ref) {
  4913. exportNgVar(PROFILER_GLOBAL_NAME, new AngularProfiler(ref));
  4914. return ref;
  4915. }
  4916. /**
  4917. * Disables Angular tools.
  4918. *
  4919. * \@experimental All debugging apis are currently experimental.
  4920. * @return {?}
  4921. */
  4922. function disableDebugTools() {
  4923. exportNgVar(PROFILER_GLOBAL_NAME, null);
  4924. }
  4925. /**
  4926. * @fileoverview added by tsickle
  4927. * @suppress {checkTypes} checked by tsc
  4928. */
  4929. /**
  4930. * @license
  4931. * Copyright Google Inc. All Rights Reserved.
  4932. *
  4933. * Use of this source code is governed by an MIT-style license that can be
  4934. * found in the LICENSE file at https://angular.io/license
  4935. */
  4936. /**
  4937. * @param {?} text
  4938. * @return {?}
  4939. */
  4940. function escapeHtml(text) {
  4941. var /** @type {?} */ escapedText = {
  4942. '&': '&a;',
  4943. '"': '&q;',
  4944. '\'': '&s;',
  4945. '<': '&l;',
  4946. '>': '&g;',
  4947. };
  4948. return text.replace(/[&"'<>]/g, function (s) { return escapedText[s]; });
  4949. }
  4950. /**
  4951. * @param {?} text
  4952. * @return {?}
  4953. */
  4954. function unescapeHtml(text) {
  4955. var /** @type {?} */ unescapedText = {
  4956. '&a;': '&',
  4957. '&q;': '"',
  4958. '&s;': '\'',
  4959. '&l;': '<',
  4960. '&g;': '>',
  4961. };
  4962. return text.replace(/&[^;]+;/g, function (s) { return unescapedText[s]; });
  4963. }
  4964. /**
  4965. * Create a `StateKey<T>` that can be used to store value of type T with `TransferState`.
  4966. *
  4967. * Example:
  4968. *
  4969. * ```
  4970. * const COUNTER_KEY = makeStateKey<number>('counter');
  4971. * let value = 10;
  4972. *
  4973. * transferState.set(COUNTER_KEY, value);
  4974. * ```
  4975. *
  4976. * \@experimental
  4977. * @template T
  4978. * @param {?} key
  4979. * @return {?}
  4980. */
  4981. function makeStateKey(key) {
  4982. return /** @type {?} */ (key);
  4983. }
  4984. /**
  4985. * A key value store that is transferred from the application on the server side to the application
  4986. * on the client side.
  4987. *
  4988. * `TransferState` will be available as an injectable token. To use it import
  4989. * `ServerTransferStateModule` on the server and `BrowserTransferStateModule` on the client.
  4990. *
  4991. * The values in the store are serialized/deserialized using JSON.stringify/JSON.parse. So only
  4992. * boolean, number, string, null and non-class objects will be serialized and deserialzied in a
  4993. * non-lossy manner.
  4994. *
  4995. * \@experimental
  4996. */
  4997. var TransferState = /** @class */ (function () {
  4998. function TransferState() {
  4999. this.store = {};
  5000. this.onSerializeCallbacks = {};
  5001. }
  5002. /** @internal */
  5003. /**
  5004. * \@internal
  5005. * @param {?} initState
  5006. * @return {?}
  5007. */
  5008. TransferState.init = /**
  5009. * \@internal
  5010. * @param {?} initState
  5011. * @return {?}
  5012. */
  5013. function (initState) {
  5014. var /** @type {?} */ transferState = new TransferState();
  5015. transferState.store = initState;
  5016. return transferState;
  5017. };
  5018. /**
  5019. * Get the value corresponding to a key. Return `defaultValue` if key is not found.
  5020. */
  5021. /**
  5022. * Get the value corresponding to a key. Return `defaultValue` if key is not found.
  5023. * @template T
  5024. * @param {?} key
  5025. * @param {?} defaultValue
  5026. * @return {?}
  5027. */
  5028. TransferState.prototype.get = /**
  5029. * Get the value corresponding to a key. Return `defaultValue` if key is not found.
  5030. * @template T
  5031. * @param {?} key
  5032. * @param {?} defaultValue
  5033. * @return {?}
  5034. */
  5035. function (key, defaultValue) {
  5036. return this.store[key] !== undefined ? /** @type {?} */ (this.store[key]) : defaultValue;
  5037. };
  5038. /**
  5039. * Set the value corresponding to a key.
  5040. */
  5041. /**
  5042. * Set the value corresponding to a key.
  5043. * @template T
  5044. * @param {?} key
  5045. * @param {?} value
  5046. * @return {?}
  5047. */
  5048. TransferState.prototype.set = /**
  5049. * Set the value corresponding to a key.
  5050. * @template T
  5051. * @param {?} key
  5052. * @param {?} value
  5053. * @return {?}
  5054. */
  5055. function (key, value) { this.store[key] = value; };
  5056. /**
  5057. * Remove a key from the store.
  5058. */
  5059. /**
  5060. * Remove a key from the store.
  5061. * @template T
  5062. * @param {?} key
  5063. * @return {?}
  5064. */
  5065. TransferState.prototype.remove = /**
  5066. * Remove a key from the store.
  5067. * @template T
  5068. * @param {?} key
  5069. * @return {?}
  5070. */
  5071. function (key) { delete this.store[key]; };
  5072. /**
  5073. * Test whether a key exists in the store.
  5074. */
  5075. /**
  5076. * Test whether a key exists in the store.
  5077. * @template T
  5078. * @param {?} key
  5079. * @return {?}
  5080. */
  5081. TransferState.prototype.hasKey = /**
  5082. * Test whether a key exists in the store.
  5083. * @template T
  5084. * @param {?} key
  5085. * @return {?}
  5086. */
  5087. function (key) { return this.store.hasOwnProperty(key); };
  5088. /**
  5089. * Register a callback to provide the value for a key when `toJson` is called.
  5090. */
  5091. /**
  5092. * Register a callback to provide the value for a key when `toJson` is called.
  5093. * @template T
  5094. * @param {?} key
  5095. * @param {?} callback
  5096. * @return {?}
  5097. */
  5098. TransferState.prototype.onSerialize = /**
  5099. * Register a callback to provide the value for a key when `toJson` is called.
  5100. * @template T
  5101. * @param {?} key
  5102. * @param {?} callback
  5103. * @return {?}
  5104. */
  5105. function (key, callback) {
  5106. this.onSerializeCallbacks[key] = callback;
  5107. };
  5108. /**
  5109. * Serialize the current state of the store to JSON.
  5110. */
  5111. /**
  5112. * Serialize the current state of the store to JSON.
  5113. * @return {?}
  5114. */
  5115. TransferState.prototype.toJson = /**
  5116. * Serialize the current state of the store to JSON.
  5117. * @return {?}
  5118. */
  5119. function () {
  5120. // Call the onSerialize callbacks and put those values into the store.
  5121. for (var /** @type {?} */ key in this.onSerializeCallbacks) {
  5122. if (this.onSerializeCallbacks.hasOwnProperty(key)) {
  5123. try {
  5124. this.store[key] = this.onSerializeCallbacks[key]();
  5125. }
  5126. catch (/** @type {?} */ e) {
  5127. console.warn('Exception in onSerialize callback: ', e);
  5128. }
  5129. }
  5130. }
  5131. return JSON.stringify(this.store);
  5132. };
  5133. TransferState.decorators = [
  5134. { type: Injectable },
  5135. ];
  5136. /** @nocollapse */
  5137. TransferState.ctorParameters = function () { return []; };
  5138. return TransferState;
  5139. }());
  5140. /**
  5141. * @param {?} doc
  5142. * @param {?} appId
  5143. * @return {?}
  5144. */
  5145. function initTransferState(doc, appId) {
  5146. // Locate the script tag with the JSON data transferred from the server.
  5147. // The id of the script tag is set to the Angular appId + 'state'.
  5148. var /** @type {?} */ script = doc.getElementById(appId + '-state');
  5149. var /** @type {?} */ initialState = {};
  5150. if (script && script.textContent) {
  5151. try {
  5152. initialState = JSON.parse(unescapeHtml(script.textContent));
  5153. }
  5154. catch (/** @type {?} */ e) {
  5155. console.warn('Exception while restoring TransferState for app ' + appId, e);
  5156. }
  5157. }
  5158. return TransferState.init(initialState);
  5159. }
  5160. /**
  5161. * NgModule to install on the client side while using the `TransferState` to transfer state from
  5162. * server to client.
  5163. *
  5164. * \@experimental
  5165. */
  5166. var BrowserTransferStateModule = /** @class */ (function () {
  5167. function BrowserTransferStateModule() {
  5168. }
  5169. BrowserTransferStateModule.decorators = [
  5170. { type: NgModule, args: [{
  5171. providers: [{ provide: TransferState, useFactory: initTransferState, deps: [DOCUMENT$1, APP_ID] }],
  5172. },] },
  5173. ];
  5174. /** @nocollapse */
  5175. BrowserTransferStateModule.ctorParameters = function () { return []; };
  5176. return BrowserTransferStateModule;
  5177. }());
  5178. /**
  5179. * @fileoverview added by tsickle
  5180. * @suppress {checkTypes} checked by tsc
  5181. */
  5182. /**
  5183. * @license
  5184. * Copyright Google Inc. All Rights Reserved.
  5185. *
  5186. * Use of this source code is governed by an MIT-style license that can be
  5187. * found in the LICENSE file at https://angular.io/license
  5188. */
  5189. /**
  5190. * Predicates for use with {\@link DebugElement}'s query functions.
  5191. *
  5192. * \@experimental All debugging apis are currently experimental.
  5193. */
  5194. var By = /** @class */ (function () {
  5195. function By() {
  5196. }
  5197. /**
  5198. * Match all elements.
  5199. *
  5200. * ## Example
  5201. *
  5202. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  5203. */
  5204. /**
  5205. * Match all elements.
  5206. *
  5207. * ## Example
  5208. *
  5209. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  5210. * @return {?}
  5211. */
  5212. By.all = /**
  5213. * Match all elements.
  5214. *
  5215. * ## Example
  5216. *
  5217. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_all'}
  5218. * @return {?}
  5219. */
  5220. function () { return function (debugElement) { return true; }; };
  5221. /**
  5222. * Match elements by the given CSS selector.
  5223. *
  5224. * ## Example
  5225. *
  5226. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  5227. */
  5228. /**
  5229. * Match elements by the given CSS selector.
  5230. *
  5231. * ## Example
  5232. *
  5233. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  5234. * @param {?} selector
  5235. * @return {?}
  5236. */
  5237. By.css = /**
  5238. * Match elements by the given CSS selector.
  5239. *
  5240. * ## Example
  5241. *
  5242. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_css'}
  5243. * @param {?} selector
  5244. * @return {?}
  5245. */
  5246. function (selector) {
  5247. return function (debugElement) {
  5248. return debugElement.nativeElement != null ?
  5249. getDOM().elementMatches(debugElement.nativeElement, selector) :
  5250. false;
  5251. };
  5252. };
  5253. /**
  5254. * Match elements that have the given directive present.
  5255. *
  5256. * ## Example
  5257. *
  5258. * {@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  5259. */
  5260. /**
  5261. * Match elements that have the given directive present.
  5262. *
  5263. * ## Example
  5264. *
  5265. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  5266. * @param {?} type
  5267. * @return {?}
  5268. */
  5269. By.directive = /**
  5270. * Match elements that have the given directive present.
  5271. *
  5272. * ## Example
  5273. *
  5274. * {\@example platform-browser/dom/debug/ts/by/by.ts region='by_directive'}
  5275. * @param {?} type
  5276. * @return {?}
  5277. */
  5278. function (type) {
  5279. return function (debugElement) { return ((debugElement.providerTokens)).indexOf(type) !== -1; };
  5280. };
  5281. return By;
  5282. }());
  5283. /**
  5284. * @fileoverview added by tsickle
  5285. * @suppress {checkTypes} checked by tsc
  5286. */
  5287. /**
  5288. * @license
  5289. * Copyright Google Inc. All Rights Reserved.
  5290. *
  5291. * Use of this source code is governed by an MIT-style license that can be
  5292. * found in the LICENSE file at https://angular.io/license
  5293. */
  5294. /**
  5295. * @fileoverview added by tsickle
  5296. * @suppress {checkTypes} checked by tsc
  5297. */
  5298. /**
  5299. * @license
  5300. * Copyright Google Inc. All Rights Reserved.
  5301. *
  5302. * Use of this source code is governed by an MIT-style license that can be
  5303. * found in the LICENSE file at https://angular.io/license
  5304. */
  5305. /**
  5306. * \@stable
  5307. */
  5308. var VERSION = new Version('5.2.11');
  5309. /**
  5310. * @fileoverview added by tsickle
  5311. * @suppress {checkTypes} checked by tsc
  5312. */
  5313. /**
  5314. * @license
  5315. * Copyright Google Inc. All Rights Reserved.
  5316. *
  5317. * Use of this source code is governed by an MIT-style license that can be
  5318. * found in the LICENSE file at https://angular.io/license
  5319. */
  5320. /**
  5321. * @fileoverview added by tsickle
  5322. * @suppress {checkTypes} checked by tsc
  5323. */
  5324. /**
  5325. * @license
  5326. * Copyright Google Inc. All Rights Reserved.
  5327. *
  5328. * Use of this source code is governed by an MIT-style license that can be
  5329. * found in the LICENSE file at https://angular.io/license
  5330. */
  5331. /**
  5332. * @module
  5333. * @description
  5334. * Entry point for all public APIs of this package.
  5335. */
  5336. // This file only reexports content of the `src` folder. Keep it that way.
  5337. /**
  5338. * @fileoverview added by tsickle
  5339. * @suppress {checkTypes} checked by tsc
  5340. */
  5341. /**
  5342. * Generated bundle index. Do not edit.
  5343. */
  5344. export { BrowserModule, platformBrowser, Meta, Title, disableDebugTools, enableDebugTools, BrowserTransferStateModule, TransferState, makeStateKey, By, DOCUMENT$1 as DOCUMENT, EVENT_MANAGER_PLUGINS, EventManager, HAMMER_GESTURE_CONFIG, HammerGestureConfig, DomSanitizer, VERSION, 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, _document as ɵb, errorHandler as ɵa, GenericBrowserDomAdapter as ɵi, SERVER_TRANSITION_PROVIDERS as ɵg, appInitializerFactory as ɵf, initTransferState as ɵc, _createNgProbe as ɵh, EventManagerPlugin as ɵd, DomSanitizerImpl as ɵe };
  5345. //# sourceMappingURL=platform-browser.js.map