build.js 122 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var deindent = _interopDefault(require('de-indent'));
  5. var he = _interopDefault(require('he'));
  6. /* */
  7. var emptyObject = Object.freeze({});
  8. // These helpers produce better VM code in JS engines due to their
  9. // explicitness and function inlining.
  10. function isUndef (v) {
  11. return v === undefined || v === null
  12. }
  13. /**
  14. * Check if value is primitive.
  15. */
  16. function isPrimitive (value) {
  17. return (
  18. typeof value === 'string' ||
  19. typeof value === 'number' ||
  20. // $flow-disable-line
  21. typeof value === 'symbol' ||
  22. typeof value === 'boolean'
  23. )
  24. }
  25. /**
  26. * Quick object check - this is primarily used to tell
  27. * Objects from primitive values when we know the value
  28. * is a JSON-compliant type.
  29. */
  30. function isObject (obj) {
  31. return obj !== null && typeof obj === 'object'
  32. }
  33. /**
  34. * Get the raw type string of a value, e.g., [object Object].
  35. */
  36. var _toString = Object.prototype.toString;
  37. function toRawType (value) {
  38. return _toString.call(value).slice(8, -1)
  39. }
  40. /**
  41. * Strict object type check. Only returns true
  42. * for plain JavaScript objects.
  43. */
  44. function isPlainObject (obj) {
  45. return _toString.call(obj) === '[object Object]'
  46. }
  47. /**
  48. * Check if val is a valid array index.
  49. */
  50. function isValidArrayIndex (val) {
  51. var n = parseFloat(String(val));
  52. return n >= 0 && Math.floor(n) === n && isFinite(val)
  53. }
  54. /**
  55. * Make a map and return a function for checking if a key
  56. * is in that map.
  57. */
  58. function makeMap (
  59. str,
  60. expectsLowerCase
  61. ) {
  62. var map = Object.create(null);
  63. var list = str.split(',');
  64. for (var i = 0; i < list.length; i++) {
  65. map[list[i]] = true;
  66. }
  67. return expectsLowerCase
  68. ? function (val) { return map[val.toLowerCase()]; }
  69. : function (val) { return map[val]; }
  70. }
  71. /**
  72. * Check if a tag is a built-in tag.
  73. */
  74. var isBuiltInTag = makeMap('slot,component', true);
  75. /**
  76. * Check if an attribute is a reserved attribute.
  77. */
  78. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  79. /**
  80. * Remove an item from an array.
  81. */
  82. function remove (arr, item) {
  83. if (arr.length) {
  84. var index = arr.indexOf(item);
  85. if (index > -1) {
  86. return arr.splice(index, 1)
  87. }
  88. }
  89. }
  90. /**
  91. * Check whether an object has the property.
  92. */
  93. var hasOwnProperty = Object.prototype.hasOwnProperty;
  94. function hasOwn (obj, key) {
  95. return hasOwnProperty.call(obj, key)
  96. }
  97. /**
  98. * Create a cached version of a pure function.
  99. */
  100. function cached (fn) {
  101. var cache = Object.create(null);
  102. return (function cachedFn (str) {
  103. var hit = cache[str];
  104. return hit || (cache[str] = fn(str))
  105. })
  106. }
  107. /**
  108. * Camelize a hyphen-delimited string.
  109. */
  110. var camelizeRE = /-(\w)/g;
  111. var camelize = cached(function (str) {
  112. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  113. });
  114. /**
  115. * Simple bind polyfill for environments that do not support it,
  116. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  117. * since native bind is now performant enough in most browsers.
  118. * But removing it would mean breaking code that was able to run in
  119. * PhantomJS 1.x, so this must be kept for backward compatibility.
  120. */
  121. /* istanbul ignore next */
  122. function polyfillBind (fn, ctx) {
  123. function boundFn (a) {
  124. var l = arguments.length;
  125. return l
  126. ? l > 1
  127. ? fn.apply(ctx, arguments)
  128. : fn.call(ctx, a)
  129. : fn.call(ctx)
  130. }
  131. boundFn._length = fn.length;
  132. return boundFn
  133. }
  134. function nativeBind (fn, ctx) {
  135. return fn.bind(ctx)
  136. }
  137. var bind = Function.prototype.bind
  138. ? nativeBind
  139. : polyfillBind;
  140. /**
  141. * Mix properties into target object.
  142. */
  143. function extend (to, _from) {
  144. for (var key in _from) {
  145. to[key] = _from[key];
  146. }
  147. return to
  148. }
  149. /* eslint-disable no-unused-vars */
  150. /**
  151. * Perform no operation.
  152. * Stubbing args to make Flow happy without leaving useless transpiled code
  153. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  154. */
  155. function noop (a, b, c) {}
  156. /**
  157. * Always return false.
  158. */
  159. var no = function (a, b, c) { return false; };
  160. /* eslint-enable no-unused-vars */
  161. /**
  162. * Return the same value.
  163. */
  164. var identity = function (_) { return _; };
  165. /**
  166. * Generate a string containing static keys from compiler modules.
  167. */
  168. function genStaticKeys (modules) {
  169. return modules.reduce(function (keys, m) {
  170. return keys.concat(m.staticKeys || [])
  171. }, []).join(',')
  172. }
  173. /* */
  174. var isUnaryTag = makeMap(
  175. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  176. 'link,meta,param,source,track,wbr'
  177. );
  178. // Elements that you can, intentionally, leave open
  179. // (and which close themselves)
  180. var canBeLeftOpenTag = makeMap(
  181. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  182. );
  183. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  184. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  185. var isNonPhrasingTag = makeMap(
  186. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  187. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  188. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  189. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  190. 'title,tr,track'
  191. );
  192. /**
  193. * Not type-checking this file because it's mostly vendor code.
  194. */
  195. // Regular Expressions for parsing tags and attributes
  196. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  197. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  198. // but for Vue templates we can enforce a simple charset
  199. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  200. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  201. var startTagOpen = new RegExp(("^<" + qnameCapture));
  202. var startTagClose = /^\s*(\/?)>/;
  203. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  204. var doctype = /^<!DOCTYPE [^>]+>/i;
  205. // #7298: escape - to avoid being pased as HTML comment when inlined in page
  206. var comment = /^<!\--/;
  207. var conditionalComment = /^<!\[/;
  208. // Special Elements (can contain anything)
  209. var isPlainTextElement = makeMap('script,style,textarea', true);
  210. var reCache = {};
  211. var decodingMap = {
  212. '&lt;': '<',
  213. '&gt;': '>',
  214. '&quot;': '"',
  215. '&amp;': '&',
  216. '&#10;': '\n',
  217. '&#9;': '\t'
  218. };
  219. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  220. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g;
  221. // #5992
  222. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  223. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  224. function decodeAttr (value, shouldDecodeNewlines) {
  225. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  226. return value.replace(re, function (match) { return decodingMap[match]; })
  227. }
  228. function parseHTML (html, options) {
  229. var stack = [];
  230. var expectHTML = options.expectHTML;
  231. var isUnaryTag$$1 = options.isUnaryTag || no;
  232. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  233. var index = 0;
  234. var last, lastTag;
  235. while (html) {
  236. last = html;
  237. // Make sure we're not in a plaintext content element like script/style
  238. if (!lastTag || !isPlainTextElement(lastTag)) {
  239. var textEnd = html.indexOf('<');
  240. if (textEnd === 0) {
  241. // Comment:
  242. if (comment.test(html)) {
  243. var commentEnd = html.indexOf('-->');
  244. if (commentEnd >= 0) {
  245. if (options.shouldKeepComment) {
  246. options.comment(html.substring(4, commentEnd));
  247. }
  248. advance(commentEnd + 3);
  249. continue
  250. }
  251. }
  252. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  253. if (conditionalComment.test(html)) {
  254. var conditionalEnd = html.indexOf(']>');
  255. if (conditionalEnd >= 0) {
  256. advance(conditionalEnd + 2);
  257. continue
  258. }
  259. }
  260. // Doctype:
  261. var doctypeMatch = html.match(doctype);
  262. if (doctypeMatch) {
  263. advance(doctypeMatch[0].length);
  264. continue
  265. }
  266. // End tag:
  267. var endTagMatch = html.match(endTag);
  268. if (endTagMatch) {
  269. var curIndex = index;
  270. advance(endTagMatch[0].length);
  271. parseEndTag(endTagMatch[1], curIndex, index);
  272. continue
  273. }
  274. // Start tag:
  275. var startTagMatch = parseStartTag();
  276. if (startTagMatch) {
  277. handleStartTag(startTagMatch);
  278. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  279. advance(1);
  280. }
  281. continue
  282. }
  283. }
  284. var text = (void 0), rest = (void 0), next = (void 0);
  285. if (textEnd >= 0) {
  286. rest = html.slice(textEnd);
  287. while (
  288. !endTag.test(rest) &&
  289. !startTagOpen.test(rest) &&
  290. !comment.test(rest) &&
  291. !conditionalComment.test(rest)
  292. ) {
  293. // < in plain text, be forgiving and treat it as text
  294. next = rest.indexOf('<', 1);
  295. if (next < 0) { break }
  296. textEnd += next;
  297. rest = html.slice(textEnd);
  298. }
  299. text = html.substring(0, textEnd);
  300. advance(textEnd);
  301. }
  302. if (textEnd < 0) {
  303. text = html;
  304. html = '';
  305. }
  306. if (options.chars && text) {
  307. options.chars(text);
  308. }
  309. } else {
  310. var endTagLength = 0;
  311. var stackedTag = lastTag.toLowerCase();
  312. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  313. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  314. endTagLength = endTag.length;
  315. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  316. text = text
  317. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  318. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  319. }
  320. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  321. text = text.slice(1);
  322. }
  323. if (options.chars) {
  324. options.chars(text);
  325. }
  326. return ''
  327. });
  328. index += html.length - rest$1.length;
  329. html = rest$1;
  330. parseEndTag(stackedTag, index - endTagLength, index);
  331. }
  332. if (html === last) {
  333. options.chars && options.chars(html);
  334. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  335. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  336. }
  337. break
  338. }
  339. }
  340. // Clean up any remaining tags
  341. parseEndTag();
  342. function advance (n) {
  343. index += n;
  344. html = html.substring(n);
  345. }
  346. function parseStartTag () {
  347. var start = html.match(startTagOpen);
  348. if (start) {
  349. var match = {
  350. tagName: start[1],
  351. attrs: [],
  352. start: index
  353. };
  354. advance(start[0].length);
  355. var end, attr;
  356. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  357. advance(attr[0].length);
  358. match.attrs.push(attr);
  359. }
  360. if (end) {
  361. match.unarySlash = end[1];
  362. advance(end[0].length);
  363. match.end = index;
  364. return match
  365. }
  366. }
  367. }
  368. function handleStartTag (match) {
  369. var tagName = match.tagName;
  370. var unarySlash = match.unarySlash;
  371. if (expectHTML) {
  372. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  373. parseEndTag(lastTag);
  374. }
  375. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  376. parseEndTag(tagName);
  377. }
  378. }
  379. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  380. var l = match.attrs.length;
  381. var attrs = new Array(l);
  382. for (var i = 0; i < l; i++) {
  383. var args = match.attrs[i];
  384. var value = args[3] || args[4] || args[5] || '';
  385. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  386. ? options.shouldDecodeNewlinesForHref
  387. : options.shouldDecodeNewlines;
  388. attrs[i] = {
  389. name: args[1],
  390. value: decodeAttr(value, shouldDecodeNewlines)
  391. };
  392. }
  393. if (!unary) {
  394. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  395. lastTag = tagName;
  396. }
  397. if (options.start) {
  398. options.start(tagName, attrs, unary, match.start, match.end);
  399. }
  400. }
  401. function parseEndTag (tagName, start, end) {
  402. var pos, lowerCasedTagName;
  403. if (start == null) { start = index; }
  404. if (end == null) { end = index; }
  405. // Find the closest opened tag of the same type
  406. if (tagName) {
  407. lowerCasedTagName = tagName.toLowerCase();
  408. for (pos = stack.length - 1; pos >= 0; pos--) {
  409. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  410. break
  411. }
  412. }
  413. } else {
  414. // If no tag name is provided, clean shop
  415. pos = 0;
  416. }
  417. if (pos >= 0) {
  418. // Close all the open elements, up the stack
  419. for (var i = stack.length - 1; i >= pos; i--) {
  420. if (process.env.NODE_ENV !== 'production' &&
  421. (i > pos || !tagName) &&
  422. options.warn
  423. ) {
  424. options.warn(
  425. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  426. );
  427. }
  428. if (options.end) {
  429. options.end(stack[i].tag, start, end);
  430. }
  431. }
  432. // Remove the open elements from the stack
  433. stack.length = pos;
  434. lastTag = pos && stack[pos - 1].tag;
  435. } else if (lowerCasedTagName === 'br') {
  436. if (options.start) {
  437. options.start(tagName, [], true, start, end);
  438. }
  439. } else if (lowerCasedTagName === 'p') {
  440. if (options.start) {
  441. options.start(tagName, [], false, start, end);
  442. }
  443. if (options.end) {
  444. options.end(tagName, start, end);
  445. }
  446. }
  447. }
  448. }
  449. /* */
  450. var splitRE = /\r?\n/g;
  451. var replaceRE = /./g;
  452. var isSpecialTag = makeMap('script,style,template', true);
  453. /**
  454. * Parse a single-file component (*.vue) file into an SFC Descriptor Object.
  455. */
  456. function parseComponent (
  457. content,
  458. options
  459. ) {
  460. if ( options === void 0 ) options = {};
  461. var sfc = {
  462. template: null,
  463. script: null,
  464. styles: [],
  465. customBlocks: []
  466. };
  467. var depth = 0;
  468. var currentBlock = null;
  469. function start (
  470. tag,
  471. attrs,
  472. unary,
  473. start,
  474. end
  475. ) {
  476. if (depth === 0) {
  477. currentBlock = {
  478. type: tag,
  479. content: '',
  480. start: end,
  481. attrs: attrs.reduce(function (cumulated, ref) {
  482. var name = ref.name;
  483. var value = ref.value;
  484. cumulated[name] = value || true;
  485. return cumulated
  486. }, {})
  487. };
  488. if (isSpecialTag(tag)) {
  489. checkAttrs(currentBlock, attrs);
  490. if (tag === 'style') {
  491. sfc.styles.push(currentBlock);
  492. } else {
  493. sfc[tag] = currentBlock;
  494. }
  495. } else { // custom blocks
  496. sfc.customBlocks.push(currentBlock);
  497. }
  498. }
  499. if (!unary) {
  500. depth++;
  501. }
  502. }
  503. function checkAttrs (block, attrs) {
  504. for (var i = 0; i < attrs.length; i++) {
  505. var attr = attrs[i];
  506. if (attr.name === 'lang') {
  507. block.lang = attr.value;
  508. }
  509. if (attr.name === 'scoped') {
  510. block.scoped = true;
  511. }
  512. if (attr.name === 'module') {
  513. block.module = attr.value || true;
  514. }
  515. if (attr.name === 'src') {
  516. block.src = attr.value;
  517. }
  518. }
  519. }
  520. function end (tag, start) {
  521. if (depth === 1 && currentBlock) {
  522. currentBlock.end = start;
  523. var text = deindent(content.slice(currentBlock.start, currentBlock.end));
  524. // pad content so that linters and pre-processors can output correct
  525. // line numbers in errors and warnings
  526. if (currentBlock.type !== 'template' && options.pad) {
  527. text = padContent(currentBlock, options.pad) + text;
  528. }
  529. currentBlock.content = text;
  530. currentBlock = null;
  531. }
  532. depth--;
  533. }
  534. function padContent (block, pad) {
  535. if (pad === 'space') {
  536. return content.slice(0, block.start).replace(replaceRE, ' ')
  537. } else {
  538. var offset = content.slice(0, block.start).split(splitRE).length;
  539. var padChar = block.type === 'script' && !block.lang
  540. ? '//\n'
  541. : '\n';
  542. return Array(offset).join(padChar)
  543. }
  544. }
  545. parseHTML(content, {
  546. start: start,
  547. end: end
  548. });
  549. return sfc
  550. }
  551. /* */
  552. /**
  553. * Define a property.
  554. */
  555. function def (obj, key, val, enumerable) {
  556. Object.defineProperty(obj, key, {
  557. value: val,
  558. enumerable: !!enumerable,
  559. writable: true,
  560. configurable: true
  561. });
  562. }
  563. /* */
  564. // can we use __proto__?
  565. var hasProto = '__proto__' in {};
  566. // Browser environment sniffing
  567. var inBrowser = typeof window !== 'undefined';
  568. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  569. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  570. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  571. var isIE = UA && /msie|trident/.test(UA);
  572. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  573. var isEdge = UA && UA.indexOf('edge/') > 0;
  574. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  575. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  576. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  577. // Firefox has a "watch" function on Object.prototype...
  578. var nativeWatch = ({}).watch;
  579. if (inBrowser) {
  580. try {
  581. var opts = {};
  582. Object.defineProperty(opts, 'passive', ({
  583. get: function get () {
  584. }
  585. })); // https://github.com/facebook/flow/issues/285
  586. window.addEventListener('test-passive', null, opts);
  587. } catch (e) {}
  588. }
  589. // this needs to be lazy-evaled because vue may be required before
  590. // vue-server-renderer can set VUE_ENV
  591. var _isServer;
  592. var isServerRendering = function () {
  593. if (_isServer === undefined) {
  594. /* istanbul ignore if */
  595. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  596. // detect presence of vue-server-renderer and avoid
  597. // Webpack shimming the process
  598. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  599. } else {
  600. _isServer = false;
  601. }
  602. }
  603. return _isServer
  604. };
  605. // detect devtools
  606. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  607. /* istanbul ignore next */
  608. function isNative (Ctor) {
  609. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  610. }
  611. var hasSymbol =
  612. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  613. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  614. var _Set;
  615. /* istanbul ignore if */ // $flow-disable-line
  616. if (typeof Set !== 'undefined' && isNative(Set)) {
  617. // use native Set when available.
  618. _Set = Set;
  619. } else {
  620. // a non-standard Set polyfill that only works with primitive keys.
  621. _Set = /*@__PURE__*/(function () {
  622. function Set () {
  623. this.set = Object.create(null);
  624. }
  625. Set.prototype.has = function has (key) {
  626. return this.set[key] === true
  627. };
  628. Set.prototype.add = function add (key) {
  629. this.set[key] = true;
  630. };
  631. Set.prototype.clear = function clear () {
  632. this.set = Object.create(null);
  633. };
  634. return Set;
  635. }());
  636. }
  637. var ASSET_TYPES = [
  638. 'component',
  639. 'directive',
  640. 'filter'
  641. ];
  642. var LIFECYCLE_HOOKS = [
  643. 'beforeCreate',
  644. 'created',
  645. 'beforeMount',
  646. 'mounted',
  647. 'beforeUpdate',
  648. 'updated',
  649. 'beforeDestroy',
  650. 'destroyed',
  651. 'activated',
  652. 'deactivated',
  653. 'errorCaptured'
  654. ];
  655. /* */
  656. var config = ({
  657. /**
  658. * Option merge strategies (used in core/util/options)
  659. */
  660. // $flow-disable-line
  661. optionMergeStrategies: Object.create(null),
  662. /**
  663. * Whether to suppress warnings.
  664. */
  665. silent: false,
  666. /**
  667. * Show production mode tip message on boot?
  668. */
  669. productionTip: process.env.NODE_ENV !== 'production',
  670. /**
  671. * Whether to enable devtools
  672. */
  673. devtools: process.env.NODE_ENV !== 'production',
  674. /**
  675. * Whether to record perf
  676. */
  677. performance: false,
  678. /**
  679. * Error handler for watcher errors
  680. */
  681. errorHandler: null,
  682. /**
  683. * Warn handler for watcher warns
  684. */
  685. warnHandler: null,
  686. /**
  687. * Ignore certain custom elements
  688. */
  689. ignoredElements: [],
  690. /**
  691. * Custom user key aliases for v-on
  692. */
  693. // $flow-disable-line
  694. keyCodes: Object.create(null),
  695. /**
  696. * Check if a tag is reserved so that it cannot be registered as a
  697. * component. This is platform-dependent and may be overwritten.
  698. */
  699. isReservedTag: no,
  700. /**
  701. * Check if an attribute is reserved so that it cannot be used as a component
  702. * prop. This is platform-dependent and may be overwritten.
  703. */
  704. isReservedAttr: no,
  705. /**
  706. * Check if a tag is an unknown element.
  707. * Platform-dependent.
  708. */
  709. isUnknownElement: no,
  710. /**
  711. * Get the namespace of an element
  712. */
  713. getTagNamespace: noop,
  714. /**
  715. * Parse the real tag name for the specific platform.
  716. */
  717. parsePlatformTagName: identity,
  718. /**
  719. * Check if an attribute must be bound using property, e.g. value
  720. * Platform-dependent.
  721. */
  722. mustUseProp: no,
  723. /**
  724. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  725. * This will significantly reduce performance if set to false.
  726. */
  727. async: true,
  728. /**
  729. * Exposed for legacy reasons
  730. */
  731. _lifecycleHooks: LIFECYCLE_HOOKS
  732. });
  733. /* */
  734. var warn = noop;
  735. var tip = noop;
  736. var generateComponentTrace = (noop); // work around flow check
  737. var formatComponentName = (noop);
  738. if (process.env.NODE_ENV !== 'production') {
  739. var hasConsole = typeof console !== 'undefined';
  740. var classifyRE = /(?:^|[-_])(\w)/g;
  741. var classify = function (str) { return str
  742. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  743. .replace(/[-_]/g, ''); };
  744. warn = function (msg, vm) {
  745. var trace = vm ? generateComponentTrace(vm) : '';
  746. if (hasConsole && (!config.silent)) {
  747. console.error(("[Vue warn]: " + msg + trace));
  748. }
  749. };
  750. tip = function (msg, vm) {
  751. if (hasConsole && (!config.silent)) {
  752. console.warn("[Vue tip]: " + msg + (
  753. vm ? generateComponentTrace(vm) : ''
  754. ));
  755. }
  756. };
  757. formatComponentName = function (vm, includeFile) {
  758. if (vm.$root === vm) {
  759. return '<Root>'
  760. }
  761. var options = typeof vm === 'function' && vm.cid != null
  762. ? vm.options
  763. : vm._isVue
  764. ? vm.$options || vm.constructor.options
  765. : vm || {};
  766. var name = options.name || options._componentTag;
  767. var file = options.__file;
  768. if (!name && file) {
  769. var match = file.match(/([^/\\]+)\.vue$/);
  770. name = match && match[1];
  771. }
  772. return (
  773. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  774. (file && includeFile !== false ? (" at " + file) : '')
  775. )
  776. };
  777. var repeat = function (str, n) {
  778. var res = '';
  779. while (n) {
  780. if (n % 2 === 1) { res += str; }
  781. if (n > 1) { str += str; }
  782. n >>= 1;
  783. }
  784. return res
  785. };
  786. generateComponentTrace = function (vm) {
  787. if (vm._isVue && vm.$parent) {
  788. var tree = [];
  789. var currentRecursiveSequence = 0;
  790. while (vm) {
  791. if (tree.length > 0) {
  792. var last = tree[tree.length - 1];
  793. if (last.constructor === vm.constructor) {
  794. currentRecursiveSequence++;
  795. vm = vm.$parent;
  796. continue
  797. } else if (currentRecursiveSequence > 0) {
  798. tree[tree.length - 1] = [last, currentRecursiveSequence];
  799. currentRecursiveSequence = 0;
  800. }
  801. }
  802. tree.push(vm);
  803. vm = vm.$parent;
  804. }
  805. return '\n\nfound in\n\n' + tree
  806. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  807. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  808. : formatComponentName(vm))); })
  809. .join('\n')
  810. } else {
  811. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  812. }
  813. };
  814. }
  815. /* */
  816. var uid = 0;
  817. /**
  818. * A dep is an observable that can have multiple
  819. * directives subscribing to it.
  820. */
  821. var Dep = function Dep () {
  822. this.id = uid++;
  823. this.subs = [];
  824. };
  825. Dep.prototype.addSub = function addSub (sub) {
  826. this.subs.push(sub);
  827. };
  828. Dep.prototype.removeSub = function removeSub (sub) {
  829. remove(this.subs, sub);
  830. };
  831. Dep.prototype.depend = function depend () {
  832. if (Dep.target) {
  833. Dep.target.addDep(this);
  834. }
  835. };
  836. Dep.prototype.notify = function notify () {
  837. // stabilize the subscriber list first
  838. var subs = this.subs.slice();
  839. if (process.env.NODE_ENV !== 'production' && !config.async) {
  840. // subs aren't sorted in scheduler if not running async
  841. // we need to sort them now to make sure they fire in correct
  842. // order
  843. subs.sort(function (a, b) { return a.id - b.id; });
  844. }
  845. for (var i = 0, l = subs.length; i < l; i++) {
  846. subs[i].update();
  847. }
  848. };
  849. // the current target watcher being evaluated.
  850. // this is globally unique because there could be only one
  851. // watcher being evaluated at any time.
  852. Dep.target = null;
  853. /* */
  854. var VNode = function VNode (
  855. tag,
  856. data,
  857. children,
  858. text,
  859. elm,
  860. context,
  861. componentOptions,
  862. asyncFactory
  863. ) {
  864. this.tag = tag;
  865. this.data = data;
  866. this.children = children;
  867. this.text = text;
  868. this.elm = elm;
  869. this.ns = undefined;
  870. this.context = context;
  871. this.fnContext = undefined;
  872. this.fnOptions = undefined;
  873. this.fnScopeId = undefined;
  874. this.key = data && data.key;
  875. this.componentOptions = componentOptions;
  876. this.componentInstance = undefined;
  877. this.parent = undefined;
  878. this.raw = false;
  879. this.isStatic = false;
  880. this.isRootInsert = true;
  881. this.isComment = false;
  882. this.isCloned = false;
  883. this.isOnce = false;
  884. this.asyncFactory = asyncFactory;
  885. this.asyncMeta = undefined;
  886. this.isAsyncPlaceholder = false;
  887. };
  888. var prototypeAccessors = { child: { configurable: true } };
  889. // DEPRECATED: alias for componentInstance for backwards compat.
  890. /* istanbul ignore next */
  891. prototypeAccessors.child.get = function () {
  892. return this.componentInstance
  893. };
  894. Object.defineProperties( VNode.prototype, prototypeAccessors );
  895. /*
  896. * not type checking this file because flow doesn't play well with
  897. * dynamically accessing methods on Array prototype
  898. */
  899. var arrayProto = Array.prototype;
  900. var arrayMethods = Object.create(arrayProto);
  901. var methodsToPatch = [
  902. 'push',
  903. 'pop',
  904. 'shift',
  905. 'unshift',
  906. 'splice',
  907. 'sort',
  908. 'reverse'
  909. ];
  910. /**
  911. * Intercept mutating methods and emit events
  912. */
  913. methodsToPatch.forEach(function (method) {
  914. // cache original method
  915. var original = arrayProto[method];
  916. def(arrayMethods, method, function mutator () {
  917. var args = [], len = arguments.length;
  918. while ( len-- ) args[ len ] = arguments[ len ];
  919. var result = original.apply(this, args);
  920. var ob = this.__ob__;
  921. var inserted;
  922. switch (method) {
  923. case 'push':
  924. case 'unshift':
  925. inserted = args;
  926. break
  927. case 'splice':
  928. inserted = args.slice(2);
  929. break
  930. }
  931. if (inserted) { ob.observeArray(inserted); }
  932. // notify change
  933. ob.dep.notify();
  934. return result
  935. });
  936. });
  937. /* */
  938. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  939. /**
  940. * In some cases we may want to disable observation inside a component's
  941. * update computation.
  942. */
  943. var shouldObserve = true;
  944. /**
  945. * Observer class that is attached to each observed
  946. * object. Once attached, the observer converts the target
  947. * object's property keys into getter/setters that
  948. * collect dependencies and dispatch updates.
  949. */
  950. var Observer = function Observer (value) {
  951. this.value = value;
  952. this.dep = new Dep();
  953. this.vmCount = 0;
  954. def(value, '__ob__', this);
  955. if (Array.isArray(value)) {
  956. if (hasProto) {
  957. protoAugment(value, arrayMethods);
  958. } else {
  959. copyAugment(value, arrayMethods, arrayKeys);
  960. }
  961. this.observeArray(value);
  962. } else {
  963. this.walk(value);
  964. }
  965. };
  966. /**
  967. * Walk through all properties and convert them into
  968. * getter/setters. This method should only be called when
  969. * value type is Object.
  970. */
  971. Observer.prototype.walk = function walk (obj) {
  972. var keys = Object.keys(obj);
  973. for (var i = 0; i < keys.length; i++) {
  974. defineReactive$$1(obj, keys[i]);
  975. }
  976. };
  977. /**
  978. * Observe a list of Array items.
  979. */
  980. Observer.prototype.observeArray = function observeArray (items) {
  981. for (var i = 0, l = items.length; i < l; i++) {
  982. observe(items[i]);
  983. }
  984. };
  985. // helpers
  986. /**
  987. * Augment a target Object or Array by intercepting
  988. * the prototype chain using __proto__
  989. */
  990. function protoAugment (target, src) {
  991. /* eslint-disable no-proto */
  992. target.__proto__ = src;
  993. /* eslint-enable no-proto */
  994. }
  995. /**
  996. * Augment a target Object or Array by defining
  997. * hidden properties.
  998. */
  999. /* istanbul ignore next */
  1000. function copyAugment (target, src, keys) {
  1001. for (var i = 0, l = keys.length; i < l; i++) {
  1002. var key = keys[i];
  1003. def(target, key, src[key]);
  1004. }
  1005. }
  1006. /**
  1007. * Attempt to create an observer instance for a value,
  1008. * returns the new observer if successfully observed,
  1009. * or the existing observer if the value already has one.
  1010. */
  1011. function observe (value, asRootData) {
  1012. if (!isObject(value) || value instanceof VNode) {
  1013. return
  1014. }
  1015. var ob;
  1016. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  1017. ob = value.__ob__;
  1018. } else if (
  1019. shouldObserve &&
  1020. !isServerRendering() &&
  1021. (Array.isArray(value) || isPlainObject(value)) &&
  1022. Object.isExtensible(value) &&
  1023. !value._isVue
  1024. ) {
  1025. ob = new Observer(value);
  1026. }
  1027. if (asRootData && ob) {
  1028. ob.vmCount++;
  1029. }
  1030. return ob
  1031. }
  1032. /**
  1033. * Define a reactive property on an Object.
  1034. */
  1035. function defineReactive$$1 (
  1036. obj,
  1037. key,
  1038. val,
  1039. customSetter,
  1040. shallow
  1041. ) {
  1042. var dep = new Dep();
  1043. var property = Object.getOwnPropertyDescriptor(obj, key);
  1044. if (property && property.configurable === false) {
  1045. return
  1046. }
  1047. // cater for pre-defined getter/setters
  1048. var getter = property && property.get;
  1049. var setter = property && property.set;
  1050. if ((!getter || setter) && arguments.length === 2) {
  1051. val = obj[key];
  1052. }
  1053. var childOb = !shallow && observe(val);
  1054. Object.defineProperty(obj, key, {
  1055. enumerable: true,
  1056. configurable: true,
  1057. get: function reactiveGetter () {
  1058. var value = getter ? getter.call(obj) : val;
  1059. if (Dep.target) {
  1060. dep.depend();
  1061. if (childOb) {
  1062. childOb.dep.depend();
  1063. if (Array.isArray(value)) {
  1064. dependArray(value);
  1065. }
  1066. }
  1067. }
  1068. return value
  1069. },
  1070. set: function reactiveSetter (newVal) {
  1071. var value = getter ? getter.call(obj) : val;
  1072. /* eslint-disable no-self-compare */
  1073. if (newVal === value || (newVal !== newVal && value !== value)) {
  1074. return
  1075. }
  1076. /* eslint-enable no-self-compare */
  1077. if (process.env.NODE_ENV !== 'production' && customSetter) {
  1078. customSetter();
  1079. }
  1080. // #7981: for accessor properties without setter
  1081. if (getter && !setter) { return }
  1082. if (setter) {
  1083. setter.call(obj, newVal);
  1084. } else {
  1085. val = newVal;
  1086. }
  1087. childOb = !shallow && observe(newVal);
  1088. dep.notify();
  1089. }
  1090. });
  1091. }
  1092. /**
  1093. * Set a property on an object. Adds the new property and
  1094. * triggers change notification if the property doesn't
  1095. * already exist.
  1096. */
  1097. function set (target, key, val) {
  1098. if (process.env.NODE_ENV !== 'production' &&
  1099. (isUndef(target) || isPrimitive(target))
  1100. ) {
  1101. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  1102. }
  1103. if (Array.isArray(target) && isValidArrayIndex(key)) {
  1104. target.length = Math.max(target.length, key);
  1105. target.splice(key, 1, val);
  1106. return val
  1107. }
  1108. if (key in target && !(key in Object.prototype)) {
  1109. target[key] = val;
  1110. return val
  1111. }
  1112. var ob = (target).__ob__;
  1113. if (target._isVue || (ob && ob.vmCount)) {
  1114. process.env.NODE_ENV !== 'production' && warn(
  1115. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  1116. 'at runtime - declare it upfront in the data option.'
  1117. );
  1118. return val
  1119. }
  1120. if (!ob) {
  1121. target[key] = val;
  1122. return val
  1123. }
  1124. defineReactive$$1(ob.value, key, val);
  1125. ob.dep.notify();
  1126. return val
  1127. }
  1128. /**
  1129. * Collect dependencies on array elements when the array is touched, since
  1130. * we cannot intercept array element access like property getters.
  1131. */
  1132. function dependArray (value) {
  1133. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  1134. e = value[i];
  1135. e && e.__ob__ && e.__ob__.dep.depend();
  1136. if (Array.isArray(e)) {
  1137. dependArray(e);
  1138. }
  1139. }
  1140. }
  1141. /* */
  1142. /**
  1143. * Option overwriting strategies are functions that handle
  1144. * how to merge a parent option value and a child option
  1145. * value into the final value.
  1146. */
  1147. var strats = config.optionMergeStrategies;
  1148. /**
  1149. * Options with restrictions
  1150. */
  1151. if (process.env.NODE_ENV !== 'production') {
  1152. strats.el = strats.propsData = function (parent, child, vm, key) {
  1153. if (!vm) {
  1154. warn(
  1155. "option \"" + key + "\" can only be used during instance " +
  1156. 'creation with the `new` keyword.'
  1157. );
  1158. }
  1159. return defaultStrat(parent, child)
  1160. };
  1161. }
  1162. /**
  1163. * Helper that recursively merges two data objects together.
  1164. */
  1165. function mergeData (to, from) {
  1166. if (!from) { return to }
  1167. var key, toVal, fromVal;
  1168. var keys = Object.keys(from);
  1169. for (var i = 0; i < keys.length; i++) {
  1170. key = keys[i];
  1171. toVal = to[key];
  1172. fromVal = from[key];
  1173. if (!hasOwn(to, key)) {
  1174. set(to, key, fromVal);
  1175. } else if (
  1176. toVal !== fromVal &&
  1177. isPlainObject(toVal) &&
  1178. isPlainObject(fromVal)
  1179. ) {
  1180. mergeData(toVal, fromVal);
  1181. }
  1182. }
  1183. return to
  1184. }
  1185. /**
  1186. * Data
  1187. */
  1188. function mergeDataOrFn (
  1189. parentVal,
  1190. childVal,
  1191. vm
  1192. ) {
  1193. if (!vm) {
  1194. // in a Vue.extend merge, both should be functions
  1195. if (!childVal) {
  1196. return parentVal
  1197. }
  1198. if (!parentVal) {
  1199. return childVal
  1200. }
  1201. // when parentVal & childVal are both present,
  1202. // we need to return a function that returns the
  1203. // merged result of both functions... no need to
  1204. // check if parentVal is a function here because
  1205. // it has to be a function to pass previous merges.
  1206. return function mergedDataFn () {
  1207. return mergeData(
  1208. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1209. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1210. )
  1211. }
  1212. } else {
  1213. return function mergedInstanceDataFn () {
  1214. // instance merge
  1215. var instanceData = typeof childVal === 'function'
  1216. ? childVal.call(vm, vm)
  1217. : childVal;
  1218. var defaultData = typeof parentVal === 'function'
  1219. ? parentVal.call(vm, vm)
  1220. : parentVal;
  1221. if (instanceData) {
  1222. return mergeData(instanceData, defaultData)
  1223. } else {
  1224. return defaultData
  1225. }
  1226. }
  1227. }
  1228. }
  1229. strats.data = function (
  1230. parentVal,
  1231. childVal,
  1232. vm
  1233. ) {
  1234. if (!vm) {
  1235. if (childVal && typeof childVal !== 'function') {
  1236. process.env.NODE_ENV !== 'production' && warn(
  1237. 'The "data" option should be a function ' +
  1238. 'that returns a per-instance value in component ' +
  1239. 'definitions.',
  1240. vm
  1241. );
  1242. return parentVal
  1243. }
  1244. return mergeDataOrFn(parentVal, childVal)
  1245. }
  1246. return mergeDataOrFn(parentVal, childVal, vm)
  1247. };
  1248. /**
  1249. * Hooks and props are merged as arrays.
  1250. */
  1251. function mergeHook (
  1252. parentVal,
  1253. childVal
  1254. ) {
  1255. return childVal
  1256. ? parentVal
  1257. ? parentVal.concat(childVal)
  1258. : Array.isArray(childVal)
  1259. ? childVal
  1260. : [childVal]
  1261. : parentVal
  1262. }
  1263. LIFECYCLE_HOOKS.forEach(function (hook) {
  1264. strats[hook] = mergeHook;
  1265. });
  1266. /**
  1267. * Assets
  1268. *
  1269. * When a vm is present (instance creation), we need to do
  1270. * a three-way merge between constructor options, instance
  1271. * options and parent options.
  1272. */
  1273. function mergeAssets (
  1274. parentVal,
  1275. childVal,
  1276. vm,
  1277. key
  1278. ) {
  1279. var res = Object.create(parentVal || null);
  1280. if (childVal) {
  1281. process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
  1282. return extend(res, childVal)
  1283. } else {
  1284. return res
  1285. }
  1286. }
  1287. ASSET_TYPES.forEach(function (type) {
  1288. strats[type + 's'] = mergeAssets;
  1289. });
  1290. /**
  1291. * Watchers.
  1292. *
  1293. * Watchers hashes should not overwrite one
  1294. * another, so we merge them as arrays.
  1295. */
  1296. strats.watch = function (
  1297. parentVal,
  1298. childVal,
  1299. vm,
  1300. key
  1301. ) {
  1302. // work around Firefox's Object.prototype.watch...
  1303. if (parentVal === nativeWatch) { parentVal = undefined; }
  1304. if (childVal === nativeWatch) { childVal = undefined; }
  1305. /* istanbul ignore if */
  1306. if (!childVal) { return Object.create(parentVal || null) }
  1307. if (process.env.NODE_ENV !== 'production') {
  1308. assertObjectType(key, childVal, vm);
  1309. }
  1310. if (!parentVal) { return childVal }
  1311. var ret = {};
  1312. extend(ret, parentVal);
  1313. for (var key$1 in childVal) {
  1314. var parent = ret[key$1];
  1315. var child = childVal[key$1];
  1316. if (parent && !Array.isArray(parent)) {
  1317. parent = [parent];
  1318. }
  1319. ret[key$1] = parent
  1320. ? parent.concat(child)
  1321. : Array.isArray(child) ? child : [child];
  1322. }
  1323. return ret
  1324. };
  1325. /**
  1326. * Other object hashes.
  1327. */
  1328. strats.props =
  1329. strats.methods =
  1330. strats.inject =
  1331. strats.computed = function (
  1332. parentVal,
  1333. childVal,
  1334. vm,
  1335. key
  1336. ) {
  1337. if (childVal && process.env.NODE_ENV !== 'production') {
  1338. assertObjectType(key, childVal, vm);
  1339. }
  1340. if (!parentVal) { return childVal }
  1341. var ret = Object.create(null);
  1342. extend(ret, parentVal);
  1343. if (childVal) { extend(ret, childVal); }
  1344. return ret
  1345. };
  1346. strats.provide = mergeDataOrFn;
  1347. /**
  1348. * Default strategy.
  1349. */
  1350. var defaultStrat = function (parentVal, childVal) {
  1351. return childVal === undefined
  1352. ? parentVal
  1353. : childVal
  1354. };
  1355. function assertObjectType (name, value, vm) {
  1356. if (!isPlainObject(value)) {
  1357. warn(
  1358. "Invalid value for option \"" + name + "\": expected an Object, " +
  1359. "but got " + (toRawType(value)) + ".",
  1360. vm
  1361. );
  1362. }
  1363. }
  1364. /* */
  1365. /* */
  1366. /* */
  1367. var callbacks = [];
  1368. function flushCallbacks () {
  1369. var copies = callbacks.slice(0);
  1370. callbacks.length = 0;
  1371. for (var i = 0; i < copies.length; i++) {
  1372. copies[i]();
  1373. }
  1374. }
  1375. // Determine (macro) task defer implementation.
  1376. // Technically setImmediate should be the ideal choice, but it's only available
  1377. // in IE. The only polyfill that consistently queues the callback after all DOM
  1378. // events triggered in the same loop is by using MessageChannel.
  1379. /* istanbul ignore if */
  1380. if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) ; else if (typeof MessageChannel !== 'undefined' && (
  1381. isNative(MessageChannel) ||
  1382. // PhantomJS
  1383. MessageChannel.toString() === '[object MessageChannelConstructor]'
  1384. )) {
  1385. var channel = new MessageChannel();
  1386. channel.port1.onmessage = flushCallbacks;
  1387. }
  1388. // Determine microtask defer implementation.
  1389. /* istanbul ignore next, $flow-disable-line */
  1390. if (typeof Promise !== 'undefined' && isNative(Promise)) ;
  1391. /* */
  1392. /* */
  1393. // these are reserved for web because they are directly compiled away
  1394. // during template compilation
  1395. var isReservedAttr = makeMap('style,class');
  1396. // attributes that should be using props for binding
  1397. var acceptValue = makeMap('input,textarea,option,select,progress');
  1398. var mustUseProp = function (tag, type, attr) {
  1399. return (
  1400. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  1401. (attr === 'selected' && tag === 'option') ||
  1402. (attr === 'checked' && tag === 'input') ||
  1403. (attr === 'muted' && tag === 'video')
  1404. )
  1405. };
  1406. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  1407. var isBooleanAttr = makeMap(
  1408. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  1409. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  1410. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  1411. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  1412. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  1413. 'truespeed,typemustmatch,visible'
  1414. );
  1415. /* */
  1416. /* */
  1417. var isHTMLTag = makeMap(
  1418. 'html,body,base,head,link,meta,style,title,' +
  1419. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  1420. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  1421. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  1422. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  1423. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  1424. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  1425. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  1426. 'output,progress,select,textarea,' +
  1427. 'details,dialog,menu,menuitem,summary,' +
  1428. 'content,element,shadow,template,blockquote,iframe,tfoot'
  1429. );
  1430. // this map is intentionally selective, only covering SVG elements that may
  1431. // contain child elements.
  1432. var isSVG = makeMap(
  1433. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  1434. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  1435. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  1436. true
  1437. );
  1438. var isPreTag = function (tag) { return tag === 'pre'; };
  1439. var isReservedTag = function (tag) {
  1440. return isHTMLTag(tag) || isSVG(tag)
  1441. };
  1442. function getTagNamespace (tag) {
  1443. if (isSVG(tag)) {
  1444. return 'svg'
  1445. }
  1446. // basic support for MathML
  1447. // note it doesn't support other MathML elements being component roots
  1448. if (tag === 'math') {
  1449. return 'math'
  1450. }
  1451. }
  1452. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  1453. /* */
  1454. /* */
  1455. var validDivisionCharRE = /[\w).+\-_$\]]/;
  1456. function parseFilters (exp) {
  1457. var inSingle = false;
  1458. var inDouble = false;
  1459. var inTemplateString = false;
  1460. var inRegex = false;
  1461. var curly = 0;
  1462. var square = 0;
  1463. var paren = 0;
  1464. var lastFilterIndex = 0;
  1465. var c, prev, i, expression, filters;
  1466. for (i = 0; i < exp.length; i++) {
  1467. prev = c;
  1468. c = exp.charCodeAt(i);
  1469. if (inSingle) {
  1470. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  1471. } else if (inDouble) {
  1472. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  1473. } else if (inTemplateString) {
  1474. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  1475. } else if (inRegex) {
  1476. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  1477. } else if (
  1478. c === 0x7C && // pipe
  1479. exp.charCodeAt(i + 1) !== 0x7C &&
  1480. exp.charCodeAt(i - 1) !== 0x7C &&
  1481. !curly && !square && !paren
  1482. ) {
  1483. if (expression === undefined) {
  1484. // first filter, end of expression
  1485. lastFilterIndex = i + 1;
  1486. expression = exp.slice(0, i).trim();
  1487. } else {
  1488. pushFilter();
  1489. }
  1490. } else {
  1491. switch (c) {
  1492. case 0x22: inDouble = true; break // "
  1493. case 0x27: inSingle = true; break // '
  1494. case 0x60: inTemplateString = true; break // `
  1495. case 0x28: paren++; break // (
  1496. case 0x29: paren--; break // )
  1497. case 0x5B: square++; break // [
  1498. case 0x5D: square--; break // ]
  1499. case 0x7B: curly++; break // {
  1500. case 0x7D: curly--; break // }
  1501. }
  1502. if (c === 0x2f) { // /
  1503. var j = i - 1;
  1504. var p = (void 0);
  1505. // find first non-whitespace prev char
  1506. for (; j >= 0; j--) {
  1507. p = exp.charAt(j);
  1508. if (p !== ' ') { break }
  1509. }
  1510. if (!p || !validDivisionCharRE.test(p)) {
  1511. inRegex = true;
  1512. }
  1513. }
  1514. }
  1515. }
  1516. if (expression === undefined) {
  1517. expression = exp.slice(0, i).trim();
  1518. } else if (lastFilterIndex !== 0) {
  1519. pushFilter();
  1520. }
  1521. function pushFilter () {
  1522. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  1523. lastFilterIndex = i + 1;
  1524. }
  1525. if (filters) {
  1526. for (i = 0; i < filters.length; i++) {
  1527. expression = wrapFilter(expression, filters[i]);
  1528. }
  1529. }
  1530. return expression
  1531. }
  1532. function wrapFilter (exp, filter) {
  1533. var i = filter.indexOf('(');
  1534. if (i < 0) {
  1535. // _f: resolveFilter
  1536. return ("_f(\"" + filter + "\")(" + exp + ")")
  1537. } else {
  1538. var name = filter.slice(0, i);
  1539. var args = filter.slice(i + 1);
  1540. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  1541. }
  1542. }
  1543. /* */
  1544. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  1545. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  1546. var buildRegex = cached(function (delimiters) {
  1547. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  1548. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  1549. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  1550. });
  1551. function parseText (
  1552. text,
  1553. delimiters
  1554. ) {
  1555. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  1556. if (!tagRE.test(text)) {
  1557. return
  1558. }
  1559. var tokens = [];
  1560. var rawTokens = [];
  1561. var lastIndex = tagRE.lastIndex = 0;
  1562. var match, index, tokenValue;
  1563. while ((match = tagRE.exec(text))) {
  1564. index = match.index;
  1565. // push text token
  1566. if (index > lastIndex) {
  1567. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  1568. tokens.push(JSON.stringify(tokenValue));
  1569. }
  1570. // tag token
  1571. var exp = parseFilters(match[1].trim());
  1572. tokens.push(("_s(" + exp + ")"));
  1573. rawTokens.push({ '@binding': exp });
  1574. lastIndex = index + match[0].length;
  1575. }
  1576. if (lastIndex < text.length) {
  1577. rawTokens.push(tokenValue = text.slice(lastIndex));
  1578. tokens.push(JSON.stringify(tokenValue));
  1579. }
  1580. return {
  1581. expression: tokens.join('+'),
  1582. tokens: rawTokens
  1583. }
  1584. }
  1585. /* */
  1586. function baseWarn (msg) {
  1587. console.error(("[Vue compiler]: " + msg));
  1588. }
  1589. function pluckModuleFunction (
  1590. modules,
  1591. key
  1592. ) {
  1593. return modules
  1594. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  1595. : []
  1596. }
  1597. function addProp (el, name, value) {
  1598. (el.props || (el.props = [])).push({ name: name, value: value });
  1599. el.plain = false;
  1600. }
  1601. function addAttr (el, name, value) {
  1602. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  1603. el.plain = false;
  1604. }
  1605. // add a raw attr (use this in preTransforms)
  1606. function addRawAttr (el, name, value) {
  1607. el.attrsMap[name] = value;
  1608. el.attrsList.push({ name: name, value: value });
  1609. }
  1610. function addDirective (
  1611. el,
  1612. name,
  1613. rawName,
  1614. value,
  1615. arg,
  1616. modifiers
  1617. ) {
  1618. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  1619. el.plain = false;
  1620. }
  1621. function addHandler (
  1622. el,
  1623. name,
  1624. value,
  1625. modifiers,
  1626. important,
  1627. warn
  1628. ) {
  1629. modifiers = modifiers || emptyObject;
  1630. // warn prevent and passive modifier
  1631. /* istanbul ignore if */
  1632. if (
  1633. process.env.NODE_ENV !== 'production' && warn &&
  1634. modifiers.prevent && modifiers.passive
  1635. ) {
  1636. warn(
  1637. 'passive and prevent can\'t be used together. ' +
  1638. 'Passive handler can\'t prevent default event.'
  1639. );
  1640. }
  1641. // normalize click.right and click.middle since they don't actually fire
  1642. // this is technically browser-specific, but at least for now browsers are
  1643. // the only target envs that have right/middle clicks.
  1644. if (name === 'click') {
  1645. if (modifiers.right) {
  1646. name = 'contextmenu';
  1647. delete modifiers.right;
  1648. } else if (modifiers.middle) {
  1649. name = 'mouseup';
  1650. }
  1651. }
  1652. // check capture modifier
  1653. if (modifiers.capture) {
  1654. delete modifiers.capture;
  1655. name = '!' + name; // mark the event as captured
  1656. }
  1657. if (modifiers.once) {
  1658. delete modifiers.once;
  1659. name = '~' + name; // mark the event as once
  1660. }
  1661. /* istanbul ignore if */
  1662. if (modifiers.passive) {
  1663. delete modifiers.passive;
  1664. name = '&' + name; // mark the event as passive
  1665. }
  1666. var events;
  1667. if (modifiers.native) {
  1668. delete modifiers.native;
  1669. events = el.nativeEvents || (el.nativeEvents = {});
  1670. } else {
  1671. events = el.events || (el.events = {});
  1672. }
  1673. var newHandler = {
  1674. value: value.trim()
  1675. };
  1676. if (modifiers !== emptyObject) {
  1677. newHandler.modifiers = modifiers;
  1678. }
  1679. var handlers = events[name];
  1680. /* istanbul ignore if */
  1681. if (Array.isArray(handlers)) {
  1682. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  1683. } else if (handlers) {
  1684. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  1685. } else {
  1686. events[name] = newHandler;
  1687. }
  1688. el.plain = false;
  1689. }
  1690. function getBindingAttr (
  1691. el,
  1692. name,
  1693. getStatic
  1694. ) {
  1695. var dynamicValue =
  1696. getAndRemoveAttr(el, ':' + name) ||
  1697. getAndRemoveAttr(el, 'v-bind:' + name);
  1698. if (dynamicValue != null) {
  1699. return parseFilters(dynamicValue)
  1700. } else if (getStatic !== false) {
  1701. var staticValue = getAndRemoveAttr(el, name);
  1702. if (staticValue != null) {
  1703. return JSON.stringify(staticValue)
  1704. }
  1705. }
  1706. }
  1707. // note: this only removes the attr from the Array (attrsList) so that it
  1708. // doesn't get processed by processAttrs.
  1709. // By default it does NOT remove it from the map (attrsMap) because the map is
  1710. // needed during codegen.
  1711. function getAndRemoveAttr (
  1712. el,
  1713. name,
  1714. removeFromMap
  1715. ) {
  1716. var val;
  1717. if ((val = el.attrsMap[name]) != null) {
  1718. var list = el.attrsList;
  1719. for (var i = 0, l = list.length; i < l; i++) {
  1720. if (list[i].name === name) {
  1721. list.splice(i, 1);
  1722. break
  1723. }
  1724. }
  1725. }
  1726. if (removeFromMap) {
  1727. delete el.attrsMap[name];
  1728. }
  1729. return val
  1730. }
  1731. /* */
  1732. function transformNode (el, options) {
  1733. var warn = options.warn || baseWarn;
  1734. var staticClass = getAndRemoveAttr(el, 'class');
  1735. if (process.env.NODE_ENV !== 'production' && staticClass) {
  1736. var res = parseText(staticClass, options.delimiters);
  1737. if (res) {
  1738. warn(
  1739. "class=\"" + staticClass + "\": " +
  1740. 'Interpolation inside attributes has been removed. ' +
  1741. 'Use v-bind or the colon shorthand instead. For example, ' +
  1742. 'instead of <div class="{{ val }}">, use <div :class="val">.'
  1743. );
  1744. }
  1745. }
  1746. if (staticClass) {
  1747. el.staticClass = JSON.stringify(staticClass);
  1748. }
  1749. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  1750. if (classBinding) {
  1751. el.classBinding = classBinding;
  1752. }
  1753. }
  1754. function genData (el) {
  1755. var data = '';
  1756. if (el.staticClass) {
  1757. data += "staticClass:" + (el.staticClass) + ",";
  1758. }
  1759. if (el.classBinding) {
  1760. data += "class:" + (el.classBinding) + ",";
  1761. }
  1762. return data
  1763. }
  1764. var klass = {
  1765. staticKeys: ['staticClass'],
  1766. transformNode: transformNode,
  1767. genData: genData
  1768. };
  1769. /* */
  1770. var parseStyleText = cached(function (cssText) {
  1771. var res = {};
  1772. var listDelimiter = /;(?![^(]*\))/g;
  1773. var propertyDelimiter = /:(.+)/;
  1774. cssText.split(listDelimiter).forEach(function (item) {
  1775. if (item) {
  1776. var tmp = item.split(propertyDelimiter);
  1777. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  1778. }
  1779. });
  1780. return res
  1781. });
  1782. /* */
  1783. function transformNode$1 (el, options) {
  1784. var warn = options.warn || baseWarn;
  1785. var staticStyle = getAndRemoveAttr(el, 'style');
  1786. if (staticStyle) {
  1787. /* istanbul ignore if */
  1788. if (process.env.NODE_ENV !== 'production') {
  1789. var res = parseText(staticStyle, options.delimiters);
  1790. if (res) {
  1791. warn(
  1792. "style=\"" + staticStyle + "\": " +
  1793. 'Interpolation inside attributes has been removed. ' +
  1794. 'Use v-bind or the colon shorthand instead. For example, ' +
  1795. 'instead of <div style="{{ val }}">, use <div :style="val">.'
  1796. );
  1797. }
  1798. }
  1799. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  1800. }
  1801. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  1802. if (styleBinding) {
  1803. el.styleBinding = styleBinding;
  1804. }
  1805. }
  1806. function genData$1 (el) {
  1807. var data = '';
  1808. if (el.staticStyle) {
  1809. data += "staticStyle:" + (el.staticStyle) + ",";
  1810. }
  1811. if (el.styleBinding) {
  1812. data += "style:(" + (el.styleBinding) + "),";
  1813. }
  1814. return data
  1815. }
  1816. var style = {
  1817. staticKeys: ['staticStyle'],
  1818. transformNode: transformNode$1,
  1819. genData: genData$1
  1820. };
  1821. /* */
  1822. /**
  1823. * Cross-platform code generation for component v-model
  1824. */
  1825. function genComponentModel (
  1826. el,
  1827. value,
  1828. modifiers
  1829. ) {
  1830. var ref = modifiers || {};
  1831. var number = ref.number;
  1832. var trim = ref.trim;
  1833. var baseValueExpression = '$$v';
  1834. var valueExpression = baseValueExpression;
  1835. if (trim) {
  1836. valueExpression =
  1837. "(typeof " + baseValueExpression + " === 'string'" +
  1838. "? " + baseValueExpression + ".trim()" +
  1839. ": " + baseValueExpression + ")";
  1840. }
  1841. if (number) {
  1842. valueExpression = "_n(" + valueExpression + ")";
  1843. }
  1844. var assignment = genAssignmentCode(value, valueExpression);
  1845. el.model = {
  1846. value: ("(" + value + ")"),
  1847. expression: JSON.stringify(value),
  1848. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  1849. };
  1850. }
  1851. /**
  1852. * Cross-platform codegen helper for generating v-model value assignment code.
  1853. */
  1854. function genAssignmentCode (
  1855. value,
  1856. assignment
  1857. ) {
  1858. var res = parseModel(value);
  1859. if (res.key === null) {
  1860. return (value + "=" + assignment)
  1861. } else {
  1862. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  1863. }
  1864. }
  1865. /**
  1866. * Parse a v-model expression into a base path and a final key segment.
  1867. * Handles both dot-path and possible square brackets.
  1868. *
  1869. * Possible cases:
  1870. *
  1871. * - test
  1872. * - test[key]
  1873. * - test[test1[key]]
  1874. * - test["a"][key]
  1875. * - xxx.test[a[a].test1[key]]
  1876. * - test.xxx.a["asa"][test1[key]]
  1877. *
  1878. */
  1879. var len, str, chr, index, expressionPos, expressionEndPos;
  1880. function parseModel (val) {
  1881. // Fix https://github.com/vuejs/vue/pull/7730
  1882. // allow v-model="obj.val " (trailing whitespace)
  1883. val = val.trim();
  1884. len = val.length;
  1885. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  1886. index = val.lastIndexOf('.');
  1887. if (index > -1) {
  1888. return {
  1889. exp: val.slice(0, index),
  1890. key: '"' + val.slice(index + 1) + '"'
  1891. }
  1892. } else {
  1893. return {
  1894. exp: val,
  1895. key: null
  1896. }
  1897. }
  1898. }
  1899. str = val;
  1900. index = expressionPos = expressionEndPos = 0;
  1901. while (!eof()) {
  1902. chr = next();
  1903. /* istanbul ignore if */
  1904. if (isStringStart(chr)) {
  1905. parseString(chr);
  1906. } else if (chr === 0x5B) {
  1907. parseBracket(chr);
  1908. }
  1909. }
  1910. return {
  1911. exp: val.slice(0, expressionPos),
  1912. key: val.slice(expressionPos + 1, expressionEndPos)
  1913. }
  1914. }
  1915. function next () {
  1916. return str.charCodeAt(++index)
  1917. }
  1918. function eof () {
  1919. return index >= len
  1920. }
  1921. function isStringStart (chr) {
  1922. return chr === 0x22 || chr === 0x27
  1923. }
  1924. function parseBracket (chr) {
  1925. var inBracket = 1;
  1926. expressionPos = index;
  1927. while (!eof()) {
  1928. chr = next();
  1929. if (isStringStart(chr)) {
  1930. parseString(chr);
  1931. continue
  1932. }
  1933. if (chr === 0x5B) { inBracket++; }
  1934. if (chr === 0x5D) { inBracket--; }
  1935. if (inBracket === 0) {
  1936. expressionEndPos = index;
  1937. break
  1938. }
  1939. }
  1940. }
  1941. function parseString (chr) {
  1942. var stringQuote = chr;
  1943. while (!eof()) {
  1944. chr = next();
  1945. if (chr === stringQuote) {
  1946. break
  1947. }
  1948. }
  1949. }
  1950. /* */
  1951. var onRE = /^@|^v-on:/;
  1952. var dirRE = /^v-|^@|^:/;
  1953. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  1954. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  1955. var stripParensRE = /^\(|\)$/g;
  1956. var argRE = /:(.*)$/;
  1957. var bindRE = /^:|^v-bind:/;
  1958. var modifierRE = /\.[^.]+/g;
  1959. var decodeHTMLCached = cached(he.decode);
  1960. // configurable state
  1961. var warn$1;
  1962. var delimiters;
  1963. var transforms;
  1964. var preTransforms;
  1965. var postTransforms;
  1966. var platformIsPreTag;
  1967. var platformMustUseProp;
  1968. var platformGetTagNamespace;
  1969. function createASTElement (
  1970. tag,
  1971. attrs,
  1972. parent
  1973. ) {
  1974. return {
  1975. type: 1,
  1976. tag: tag,
  1977. attrsList: attrs,
  1978. attrsMap: makeAttrsMap(attrs),
  1979. parent: parent,
  1980. children: []
  1981. }
  1982. }
  1983. /**
  1984. * Convert HTML string to AST.
  1985. */
  1986. function parse (
  1987. template,
  1988. options
  1989. ) {
  1990. warn$1 = options.warn || baseWarn;
  1991. platformIsPreTag = options.isPreTag || no;
  1992. platformMustUseProp = options.mustUseProp || no;
  1993. platformGetTagNamespace = options.getTagNamespace || no;
  1994. transforms = pluckModuleFunction(options.modules, 'transformNode');
  1995. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  1996. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  1997. delimiters = options.delimiters;
  1998. var stack = [];
  1999. var preserveWhitespace = options.preserveWhitespace !== false;
  2000. var root;
  2001. var currentParent;
  2002. var inVPre = false;
  2003. var inPre = false;
  2004. var warned = false;
  2005. function warnOnce (msg) {
  2006. if (!warned) {
  2007. warned = true;
  2008. warn$1(msg);
  2009. }
  2010. }
  2011. function closeElement (element) {
  2012. // check pre state
  2013. if (element.pre) {
  2014. inVPre = false;
  2015. }
  2016. if (platformIsPreTag(element.tag)) {
  2017. inPre = false;
  2018. }
  2019. // apply post-transforms
  2020. for (var i = 0; i < postTransforms.length; i++) {
  2021. postTransforms[i](element, options);
  2022. }
  2023. }
  2024. parseHTML(template, {
  2025. warn: warn$1,
  2026. expectHTML: options.expectHTML,
  2027. isUnaryTag: options.isUnaryTag,
  2028. canBeLeftOpenTag: options.canBeLeftOpenTag,
  2029. shouldDecodeNewlines: options.shouldDecodeNewlines,
  2030. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  2031. shouldKeepComment: options.comments,
  2032. start: function start (tag, attrs, unary) {
  2033. // check namespace.
  2034. // inherit parent ns if there is one
  2035. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  2036. // handle IE svg bug
  2037. /* istanbul ignore if */
  2038. if (isIE && ns === 'svg') {
  2039. attrs = guardIESVGBug(attrs);
  2040. }
  2041. var element = createASTElement(tag, attrs, currentParent);
  2042. if (ns) {
  2043. element.ns = ns;
  2044. }
  2045. if (isForbiddenTag(element) && !isServerRendering()) {
  2046. element.forbidden = true;
  2047. process.env.NODE_ENV !== 'production' && warn$1(
  2048. 'Templates should only be responsible for mapping the state to the ' +
  2049. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  2050. "<" + tag + ">" + ', as they will not be parsed.'
  2051. );
  2052. }
  2053. // apply pre-transforms
  2054. for (var i = 0; i < preTransforms.length; i++) {
  2055. element = preTransforms[i](element, options) || element;
  2056. }
  2057. if (!inVPre) {
  2058. processPre(element);
  2059. if (element.pre) {
  2060. inVPre = true;
  2061. }
  2062. }
  2063. if (platformIsPreTag(element.tag)) {
  2064. inPre = true;
  2065. }
  2066. if (inVPre) {
  2067. processRawAttrs(element);
  2068. } else if (!element.processed) {
  2069. // structural directives
  2070. processFor(element);
  2071. processIf(element);
  2072. processOnce(element);
  2073. // element-scope stuff
  2074. processElement(element, options);
  2075. }
  2076. function checkRootConstraints (el) {
  2077. if (process.env.NODE_ENV !== 'production') {
  2078. if (el.tag === 'slot' || el.tag === 'template') {
  2079. warnOnce(
  2080. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  2081. 'contain multiple nodes.'
  2082. );
  2083. }
  2084. if (el.attrsMap.hasOwnProperty('v-for')) {
  2085. warnOnce(
  2086. 'Cannot use v-for on stateful component root element because ' +
  2087. 'it renders multiple elements.'
  2088. );
  2089. }
  2090. }
  2091. }
  2092. // tree management
  2093. if (!root) {
  2094. root = element;
  2095. checkRootConstraints(root);
  2096. } else if (!stack.length) {
  2097. // allow root elements with v-if, v-else-if and v-else
  2098. if (root.if && (element.elseif || element.else)) {
  2099. checkRootConstraints(element);
  2100. addIfCondition(root, {
  2101. exp: element.elseif,
  2102. block: element
  2103. });
  2104. } else if (process.env.NODE_ENV !== 'production') {
  2105. warnOnce(
  2106. "Component template should contain exactly one root element. " +
  2107. "If you are using v-if on multiple elements, " +
  2108. "use v-else-if to chain them instead."
  2109. );
  2110. }
  2111. }
  2112. if (currentParent && !element.forbidden) {
  2113. if (element.elseif || element.else) {
  2114. processIfConditions(element, currentParent);
  2115. } else if (element.slotScope) { // scoped slot
  2116. currentParent.plain = false;
  2117. var name = element.slotTarget || '"default"'
  2118. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  2119. } else {
  2120. currentParent.children.push(element);
  2121. element.parent = currentParent;
  2122. }
  2123. }
  2124. if (!unary) {
  2125. currentParent = element;
  2126. stack.push(element);
  2127. } else {
  2128. closeElement(element);
  2129. }
  2130. },
  2131. end: function end () {
  2132. // remove trailing whitespace
  2133. var element = stack[stack.length - 1];
  2134. var lastNode = element.children[element.children.length - 1];
  2135. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  2136. element.children.pop();
  2137. }
  2138. // pop stack
  2139. stack.length -= 1;
  2140. currentParent = stack[stack.length - 1];
  2141. closeElement(element);
  2142. },
  2143. chars: function chars (text) {
  2144. if (!currentParent) {
  2145. if (process.env.NODE_ENV !== 'production') {
  2146. if (text === template) {
  2147. warnOnce(
  2148. 'Component template requires a root element, rather than just text.'
  2149. );
  2150. } else if ((text = text.trim())) {
  2151. warnOnce(
  2152. ("text \"" + text + "\" outside root element will be ignored.")
  2153. );
  2154. }
  2155. }
  2156. return
  2157. }
  2158. // IE textarea placeholder bug
  2159. /* istanbul ignore if */
  2160. if (isIE &&
  2161. currentParent.tag === 'textarea' &&
  2162. currentParent.attrsMap.placeholder === text
  2163. ) {
  2164. return
  2165. }
  2166. var children = currentParent.children;
  2167. text = inPre || text.trim()
  2168. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  2169. // only preserve whitespace if its not right after a starting tag
  2170. : preserveWhitespace && children.length ? ' ' : '';
  2171. if (text) {
  2172. var res;
  2173. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  2174. children.push({
  2175. type: 2,
  2176. expression: res.expression,
  2177. tokens: res.tokens,
  2178. text: text
  2179. });
  2180. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  2181. children.push({
  2182. type: 3,
  2183. text: text
  2184. });
  2185. }
  2186. }
  2187. },
  2188. comment: function comment (text) {
  2189. currentParent.children.push({
  2190. type: 3,
  2191. text: text,
  2192. isComment: true
  2193. });
  2194. }
  2195. });
  2196. return root
  2197. }
  2198. function processPre (el) {
  2199. if (getAndRemoveAttr(el, 'v-pre') != null) {
  2200. el.pre = true;
  2201. }
  2202. }
  2203. function processRawAttrs (el) {
  2204. var l = el.attrsList.length;
  2205. if (l) {
  2206. var attrs = el.attrs = new Array(l);
  2207. for (var i = 0; i < l; i++) {
  2208. attrs[i] = {
  2209. name: el.attrsList[i].name,
  2210. value: JSON.stringify(el.attrsList[i].value)
  2211. };
  2212. }
  2213. } else if (!el.pre) {
  2214. // non root node in pre blocks with no attributes
  2215. el.plain = true;
  2216. }
  2217. }
  2218. function processElement (element, options) {
  2219. processKey(element);
  2220. // determine whether this is a plain element after
  2221. // removing structural attributes
  2222. element.plain = !element.key && !element.attrsList.length;
  2223. processRef(element);
  2224. processSlot(element);
  2225. processComponent(element);
  2226. for (var i = 0; i < transforms.length; i++) {
  2227. element = transforms[i](element, options) || element;
  2228. }
  2229. processAttrs(element);
  2230. }
  2231. function processKey (el) {
  2232. var exp = getBindingAttr(el, 'key');
  2233. if (exp) {
  2234. if (process.env.NODE_ENV !== 'production') {
  2235. if (el.tag === 'template') {
  2236. warn$1("<template> cannot be keyed. Place the key on real elements instead.");
  2237. }
  2238. if (el.for) {
  2239. var iterator = el.iterator2 || el.iterator1;
  2240. var parent = el.parent;
  2241. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  2242. warn$1(
  2243. "Do not use v-for index as key on <transition-group> children, " +
  2244. "this is the same as not using keys."
  2245. );
  2246. }
  2247. }
  2248. }
  2249. el.key = exp;
  2250. }
  2251. }
  2252. function processRef (el) {
  2253. var ref = getBindingAttr(el, 'ref');
  2254. if (ref) {
  2255. el.ref = ref;
  2256. el.refInFor = checkInFor(el);
  2257. }
  2258. }
  2259. function processFor (el) {
  2260. var exp;
  2261. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  2262. var res = parseFor(exp);
  2263. if (res) {
  2264. extend(el, res);
  2265. } else if (process.env.NODE_ENV !== 'production') {
  2266. warn$1(
  2267. ("Invalid v-for expression: " + exp)
  2268. );
  2269. }
  2270. }
  2271. }
  2272. function parseFor (exp) {
  2273. var inMatch = exp.match(forAliasRE);
  2274. if (!inMatch) { return }
  2275. var res = {};
  2276. res.for = inMatch[2].trim();
  2277. var alias = inMatch[1].trim().replace(stripParensRE, '');
  2278. var iteratorMatch = alias.match(forIteratorRE);
  2279. if (iteratorMatch) {
  2280. res.alias = alias.replace(forIteratorRE, '').trim();
  2281. res.iterator1 = iteratorMatch[1].trim();
  2282. if (iteratorMatch[2]) {
  2283. res.iterator2 = iteratorMatch[2].trim();
  2284. }
  2285. } else {
  2286. res.alias = alias;
  2287. }
  2288. return res
  2289. }
  2290. function processIf (el) {
  2291. var exp = getAndRemoveAttr(el, 'v-if');
  2292. if (exp) {
  2293. el.if = exp;
  2294. addIfCondition(el, {
  2295. exp: exp,
  2296. block: el
  2297. });
  2298. } else {
  2299. if (getAndRemoveAttr(el, 'v-else') != null) {
  2300. el.else = true;
  2301. }
  2302. var elseif = getAndRemoveAttr(el, 'v-else-if');
  2303. if (elseif) {
  2304. el.elseif = elseif;
  2305. }
  2306. }
  2307. }
  2308. function processIfConditions (el, parent) {
  2309. var prev = findPrevElement(parent.children);
  2310. if (prev && prev.if) {
  2311. addIfCondition(prev, {
  2312. exp: el.elseif,
  2313. block: el
  2314. });
  2315. } else if (process.env.NODE_ENV !== 'production') {
  2316. warn$1(
  2317. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  2318. "used on element <" + (el.tag) + "> without corresponding v-if."
  2319. );
  2320. }
  2321. }
  2322. function findPrevElement (children) {
  2323. var i = children.length;
  2324. while (i--) {
  2325. if (children[i].type === 1) {
  2326. return children[i]
  2327. } else {
  2328. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  2329. warn$1(
  2330. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  2331. "will be ignored."
  2332. );
  2333. }
  2334. children.pop();
  2335. }
  2336. }
  2337. }
  2338. function addIfCondition (el, condition) {
  2339. if (!el.ifConditions) {
  2340. el.ifConditions = [];
  2341. }
  2342. el.ifConditions.push(condition);
  2343. }
  2344. function processOnce (el) {
  2345. var once$$1 = getAndRemoveAttr(el, 'v-once');
  2346. if (once$$1 != null) {
  2347. el.once = true;
  2348. }
  2349. }
  2350. function processSlot (el) {
  2351. if (el.tag === 'slot') {
  2352. el.slotName = getBindingAttr(el, 'name');
  2353. if (process.env.NODE_ENV !== 'production' && el.key) {
  2354. warn$1(
  2355. "`key` does not work on <slot> because slots are abstract outlets " +
  2356. "and can possibly expand into multiple elements. " +
  2357. "Use the key on a wrapping element instead."
  2358. );
  2359. }
  2360. } else {
  2361. var slotScope;
  2362. if (el.tag === 'template') {
  2363. slotScope = getAndRemoveAttr(el, 'scope');
  2364. /* istanbul ignore if */
  2365. if (process.env.NODE_ENV !== 'production' && slotScope) {
  2366. warn$1(
  2367. "the \"scope\" attribute for scoped slots have been deprecated and " +
  2368. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  2369. "can also be used on plain elements in addition to <template> to " +
  2370. "denote scoped slots.",
  2371. true
  2372. );
  2373. }
  2374. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  2375. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  2376. /* istanbul ignore if */
  2377. if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
  2378. warn$1(
  2379. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  2380. "(v-for takes higher priority). Use a wrapper <template> for the " +
  2381. "scoped slot to make it clearer.",
  2382. true
  2383. );
  2384. }
  2385. el.slotScope = slotScope;
  2386. }
  2387. var slotTarget = getBindingAttr(el, 'slot');
  2388. if (slotTarget) {
  2389. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  2390. // preserve slot as an attribute for native shadow DOM compat
  2391. // only for non-scoped slots.
  2392. if (el.tag !== 'template' && !el.slotScope) {
  2393. addAttr(el, 'slot', slotTarget);
  2394. }
  2395. }
  2396. }
  2397. }
  2398. function processComponent (el) {
  2399. var binding;
  2400. if ((binding = getBindingAttr(el, 'is'))) {
  2401. el.component = binding;
  2402. }
  2403. if (getAndRemoveAttr(el, 'inline-template') != null) {
  2404. el.inlineTemplate = true;
  2405. }
  2406. }
  2407. function processAttrs (el) {
  2408. var list = el.attrsList;
  2409. var i, l, name, rawName, value, modifiers, isProp;
  2410. for (i = 0, l = list.length; i < l; i++) {
  2411. name = rawName = list[i].name;
  2412. value = list[i].value;
  2413. if (dirRE.test(name)) {
  2414. // mark element as dynamic
  2415. el.hasBindings = true;
  2416. // modifiers
  2417. modifiers = parseModifiers(name);
  2418. if (modifiers) {
  2419. name = name.replace(modifierRE, '');
  2420. }
  2421. if (bindRE.test(name)) { // v-bind
  2422. name = name.replace(bindRE, '');
  2423. value = parseFilters(value);
  2424. isProp = false;
  2425. if (
  2426. process.env.NODE_ENV !== 'production' &&
  2427. value.trim().length === 0
  2428. ) {
  2429. warn$1(
  2430. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  2431. );
  2432. }
  2433. if (modifiers) {
  2434. if (modifiers.prop) {
  2435. isProp = true;
  2436. name = camelize(name);
  2437. if (name === 'innerHtml') { name = 'innerHTML'; }
  2438. }
  2439. if (modifiers.camel) {
  2440. name = camelize(name);
  2441. }
  2442. if (modifiers.sync) {
  2443. addHandler(
  2444. el,
  2445. ("update:" + (camelize(name))),
  2446. genAssignmentCode(value, "$event")
  2447. );
  2448. }
  2449. }
  2450. if (isProp || (
  2451. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  2452. )) {
  2453. addProp(el, name, value);
  2454. } else {
  2455. addAttr(el, name, value);
  2456. }
  2457. } else if (onRE.test(name)) { // v-on
  2458. name = name.replace(onRE, '');
  2459. addHandler(el, name, value, modifiers, false, warn$1);
  2460. } else { // normal directives
  2461. name = name.replace(dirRE, '');
  2462. // parse arg
  2463. var argMatch = name.match(argRE);
  2464. var arg = argMatch && argMatch[1];
  2465. if (arg) {
  2466. name = name.slice(0, -(arg.length + 1));
  2467. }
  2468. addDirective(el, name, rawName, value, arg, modifiers);
  2469. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  2470. checkForAliasModel(el, value);
  2471. }
  2472. }
  2473. } else {
  2474. // literal attribute
  2475. if (process.env.NODE_ENV !== 'production') {
  2476. var res = parseText(value, delimiters);
  2477. if (res) {
  2478. warn$1(
  2479. name + "=\"" + value + "\": " +
  2480. 'Interpolation inside attributes has been removed. ' +
  2481. 'Use v-bind or the colon shorthand instead. For example, ' +
  2482. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  2483. );
  2484. }
  2485. }
  2486. addAttr(el, name, JSON.stringify(value));
  2487. // #6887 firefox doesn't update muted state if set via attribute
  2488. // even immediately after element creation
  2489. if (!el.component &&
  2490. name === 'muted' &&
  2491. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  2492. addProp(el, name, 'true');
  2493. }
  2494. }
  2495. }
  2496. }
  2497. function checkInFor (el) {
  2498. var parent = el;
  2499. while (parent) {
  2500. if (parent.for !== undefined) {
  2501. return true
  2502. }
  2503. parent = parent.parent;
  2504. }
  2505. return false
  2506. }
  2507. function parseModifiers (name) {
  2508. var match = name.match(modifierRE);
  2509. if (match) {
  2510. var ret = {};
  2511. match.forEach(function (m) { ret[m.slice(1)] = true; });
  2512. return ret
  2513. }
  2514. }
  2515. function makeAttrsMap (attrs) {
  2516. var map = {};
  2517. for (var i = 0, l = attrs.length; i < l; i++) {
  2518. if (
  2519. process.env.NODE_ENV !== 'production' &&
  2520. map[attrs[i].name] && !isIE && !isEdge
  2521. ) {
  2522. warn$1('duplicate attribute: ' + attrs[i].name);
  2523. }
  2524. map[attrs[i].name] = attrs[i].value;
  2525. }
  2526. return map
  2527. }
  2528. // for script (e.g. type="x/template") or style, do not decode content
  2529. function isTextTag (el) {
  2530. return el.tag === 'script' || el.tag === 'style'
  2531. }
  2532. function isForbiddenTag (el) {
  2533. return (
  2534. el.tag === 'style' ||
  2535. (el.tag === 'script' && (
  2536. !el.attrsMap.type ||
  2537. el.attrsMap.type === 'text/javascript'
  2538. ))
  2539. )
  2540. }
  2541. var ieNSBug = /^xmlns:NS\d+/;
  2542. var ieNSPrefix = /^NS\d+:/;
  2543. /* istanbul ignore next */
  2544. function guardIESVGBug (attrs) {
  2545. var res = [];
  2546. for (var i = 0; i < attrs.length; i++) {
  2547. var attr = attrs[i];
  2548. if (!ieNSBug.test(attr.name)) {
  2549. attr.name = attr.name.replace(ieNSPrefix, '');
  2550. res.push(attr);
  2551. }
  2552. }
  2553. return res
  2554. }
  2555. function checkForAliasModel (el, value) {
  2556. var _el = el;
  2557. while (_el) {
  2558. if (_el.for && _el.alias === value) {
  2559. warn$1(
  2560. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  2561. "You are binding v-model directly to a v-for iteration alias. " +
  2562. "This will not be able to modify the v-for source array because " +
  2563. "writing to the alias is like modifying a function local variable. " +
  2564. "Consider using an array of objects and use v-model on an object property instead."
  2565. );
  2566. }
  2567. _el = _el.parent;
  2568. }
  2569. }
  2570. /* */
  2571. function preTransformNode (el, options) {
  2572. if (el.tag === 'input') {
  2573. var map = el.attrsMap;
  2574. if (!map['v-model']) {
  2575. return
  2576. }
  2577. var typeBinding;
  2578. if (map[':type'] || map['v-bind:type']) {
  2579. typeBinding = getBindingAttr(el, 'type');
  2580. }
  2581. if (!map.type && !typeBinding && map['v-bind']) {
  2582. typeBinding = "(" + (map['v-bind']) + ").type";
  2583. }
  2584. if (typeBinding) {
  2585. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  2586. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  2587. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  2588. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  2589. // 1. checkbox
  2590. var branch0 = cloneASTElement(el);
  2591. // process for on the main node
  2592. processFor(branch0);
  2593. addRawAttr(branch0, 'type', 'checkbox');
  2594. processElement(branch0, options);
  2595. branch0.processed = true; // prevent it from double-processed
  2596. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  2597. addIfCondition(branch0, {
  2598. exp: branch0.if,
  2599. block: branch0
  2600. });
  2601. // 2. add radio else-if condition
  2602. var branch1 = cloneASTElement(el);
  2603. getAndRemoveAttr(branch1, 'v-for', true);
  2604. addRawAttr(branch1, 'type', 'radio');
  2605. processElement(branch1, options);
  2606. addIfCondition(branch0, {
  2607. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  2608. block: branch1
  2609. });
  2610. // 3. other
  2611. var branch2 = cloneASTElement(el);
  2612. getAndRemoveAttr(branch2, 'v-for', true);
  2613. addRawAttr(branch2, ':type', typeBinding);
  2614. processElement(branch2, options);
  2615. addIfCondition(branch0, {
  2616. exp: ifCondition,
  2617. block: branch2
  2618. });
  2619. if (hasElse) {
  2620. branch0.else = true;
  2621. } else if (elseIfCondition) {
  2622. branch0.elseif = elseIfCondition;
  2623. }
  2624. return branch0
  2625. }
  2626. }
  2627. }
  2628. function cloneASTElement (el) {
  2629. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  2630. }
  2631. var model = {
  2632. preTransformNode: preTransformNode
  2633. };
  2634. var modules = [
  2635. klass,
  2636. style,
  2637. model
  2638. ];
  2639. /* */
  2640. var warn$2;
  2641. // in some cases, the event used has to be determined at runtime
  2642. // so we used some reserved tokens during compile.
  2643. var RANGE_TOKEN = '__r';
  2644. function model$1 (
  2645. el,
  2646. dir,
  2647. _warn
  2648. ) {
  2649. warn$2 = _warn;
  2650. var value = dir.value;
  2651. var modifiers = dir.modifiers;
  2652. var tag = el.tag;
  2653. var type = el.attrsMap.type;
  2654. if (process.env.NODE_ENV !== 'production') {
  2655. // inputs with type="file" are read only and setting the input's
  2656. // value will throw an error.
  2657. if (tag === 'input' && type === 'file') {
  2658. warn$2(
  2659. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  2660. "File inputs are read only. Use a v-on:change listener instead."
  2661. );
  2662. }
  2663. }
  2664. if (el.component) {
  2665. genComponentModel(el, value, modifiers);
  2666. // component v-model doesn't need extra runtime
  2667. return false
  2668. } else if (tag === 'select') {
  2669. genSelect(el, value, modifiers);
  2670. } else if (tag === 'input' && type === 'checkbox') {
  2671. genCheckboxModel(el, value, modifiers);
  2672. } else if (tag === 'input' && type === 'radio') {
  2673. genRadioModel(el, value, modifiers);
  2674. } else if (tag === 'input' || tag === 'textarea') {
  2675. genDefaultModel(el, value, modifiers);
  2676. } else if (!config.isReservedTag(tag)) {
  2677. genComponentModel(el, value, modifiers);
  2678. // component v-model doesn't need extra runtime
  2679. return false
  2680. } else if (process.env.NODE_ENV !== 'production') {
  2681. warn$2(
  2682. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  2683. "v-model is not supported on this element type. " +
  2684. 'If you are working with contenteditable, it\'s recommended to ' +
  2685. 'wrap a library dedicated for that purpose inside a custom component.'
  2686. );
  2687. }
  2688. // ensure runtime directive metadata
  2689. return true
  2690. }
  2691. function genCheckboxModel (
  2692. el,
  2693. value,
  2694. modifiers
  2695. ) {
  2696. var number = modifiers && modifiers.number;
  2697. var valueBinding = getBindingAttr(el, 'value') || 'null';
  2698. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  2699. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  2700. addProp(el, 'checked',
  2701. "Array.isArray(" + value + ")" +
  2702. "?_i(" + value + "," + valueBinding + ")>-1" + (
  2703. trueValueBinding === 'true'
  2704. ? (":(" + value + ")")
  2705. : (":_q(" + value + "," + trueValueBinding + ")")
  2706. )
  2707. );
  2708. addHandler(el, 'change',
  2709. "var $$a=" + value + "," +
  2710. '$$el=$event.target,' +
  2711. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  2712. 'if(Array.isArray($$a)){' +
  2713. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  2714. '$$i=_i($$a,$$v);' +
  2715. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  2716. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  2717. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  2718. null, true
  2719. );
  2720. }
  2721. function genRadioModel (
  2722. el,
  2723. value,
  2724. modifiers
  2725. ) {
  2726. var number = modifiers && modifiers.number;
  2727. var valueBinding = getBindingAttr(el, 'value') || 'null';
  2728. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  2729. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  2730. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  2731. }
  2732. function genSelect (
  2733. el,
  2734. value,
  2735. modifiers
  2736. ) {
  2737. var number = modifiers && modifiers.number;
  2738. var selectedVal = "Array.prototype.filter" +
  2739. ".call($event.target.options,function(o){return o.selected})" +
  2740. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  2741. "return " + (number ? '_n(val)' : 'val') + "})";
  2742. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  2743. var code = "var $$selectedVal = " + selectedVal + ";";
  2744. code = code + " " + (genAssignmentCode(value, assignment));
  2745. addHandler(el, 'change', code, null, true);
  2746. }
  2747. function genDefaultModel (
  2748. el,
  2749. value,
  2750. modifiers
  2751. ) {
  2752. var type = el.attrsMap.type;
  2753. // warn if v-bind:value conflicts with v-model
  2754. // except for inputs with v-bind:type
  2755. if (process.env.NODE_ENV !== 'production') {
  2756. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  2757. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  2758. if (value$1 && !typeBinding) {
  2759. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  2760. warn$2(
  2761. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  2762. 'because the latter already expands to a value binding internally'
  2763. );
  2764. }
  2765. }
  2766. var ref = modifiers || {};
  2767. var lazy = ref.lazy;
  2768. var number = ref.number;
  2769. var trim = ref.trim;
  2770. var needCompositionGuard = !lazy && type !== 'range';
  2771. var event = lazy
  2772. ? 'change'
  2773. : type === 'range'
  2774. ? RANGE_TOKEN
  2775. : 'input';
  2776. var valueExpression = '$event.target.value';
  2777. if (trim) {
  2778. valueExpression = "$event.target.value.trim()";
  2779. }
  2780. if (number) {
  2781. valueExpression = "_n(" + valueExpression + ")";
  2782. }
  2783. var code = genAssignmentCode(value, valueExpression);
  2784. if (needCompositionGuard) {
  2785. code = "if($event.target.composing)return;" + code;
  2786. }
  2787. addProp(el, 'value', ("(" + value + ")"));
  2788. addHandler(el, event, code, null, true);
  2789. if (trim || number) {
  2790. addHandler(el, 'blur', '$forceUpdate()');
  2791. }
  2792. }
  2793. /* */
  2794. function text (el, dir) {
  2795. if (dir.value) {
  2796. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
  2797. }
  2798. }
  2799. /* */
  2800. function html (el, dir) {
  2801. if (dir.value) {
  2802. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
  2803. }
  2804. }
  2805. var directives = {
  2806. model: model$1,
  2807. text: text,
  2808. html: html
  2809. };
  2810. /* */
  2811. var baseOptions = {
  2812. expectHTML: true,
  2813. modules: modules,
  2814. directives: directives,
  2815. isPreTag: isPreTag,
  2816. isUnaryTag: isUnaryTag,
  2817. mustUseProp: mustUseProp,
  2818. canBeLeftOpenTag: canBeLeftOpenTag,
  2819. isReservedTag: isReservedTag,
  2820. getTagNamespace: getTagNamespace,
  2821. staticKeys: genStaticKeys(modules)
  2822. };
  2823. /* */
  2824. var isStaticKey;
  2825. var isPlatformReservedTag;
  2826. var genStaticKeysCached = cached(genStaticKeys$1);
  2827. /**
  2828. * Goal of the optimizer: walk the generated template AST tree
  2829. * and detect sub-trees that are purely static, i.e. parts of
  2830. * the DOM that never needs to change.
  2831. *
  2832. * Once we detect these sub-trees, we can:
  2833. *
  2834. * 1. Hoist them into constants, so that we no longer need to
  2835. * create fresh nodes for them on each re-render;
  2836. * 2. Completely skip them in the patching process.
  2837. */
  2838. function optimize (root, options) {
  2839. if (!root) { return }
  2840. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  2841. isPlatformReservedTag = options.isReservedTag || no;
  2842. // first pass: mark all non-static nodes.
  2843. markStatic(root);
  2844. // second pass: mark static roots.
  2845. markStaticRoots(root, false);
  2846. }
  2847. function genStaticKeys$1 (keys) {
  2848. return makeMap(
  2849. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  2850. (keys ? ',' + keys : '')
  2851. )
  2852. }
  2853. function markStatic (node) {
  2854. node.static = isStatic(node);
  2855. if (node.type === 1) {
  2856. // do not make component slot content static. this avoids
  2857. // 1. components not able to mutate slot nodes
  2858. // 2. static slot content fails for hot-reloading
  2859. if (
  2860. !isPlatformReservedTag(node.tag) &&
  2861. node.tag !== 'slot' &&
  2862. node.attrsMap['inline-template'] == null
  2863. ) {
  2864. return
  2865. }
  2866. for (var i = 0, l = node.children.length; i < l; i++) {
  2867. var child = node.children[i];
  2868. markStatic(child);
  2869. if (!child.static) {
  2870. node.static = false;
  2871. }
  2872. }
  2873. if (node.ifConditions) {
  2874. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  2875. var block = node.ifConditions[i$1].block;
  2876. markStatic(block);
  2877. if (!block.static) {
  2878. node.static = false;
  2879. }
  2880. }
  2881. }
  2882. }
  2883. }
  2884. function markStaticRoots (node, isInFor) {
  2885. if (node.type === 1) {
  2886. if (node.static || node.once) {
  2887. node.staticInFor = isInFor;
  2888. }
  2889. // For a node to qualify as a static root, it should have children that
  2890. // are not just static text. Otherwise the cost of hoisting out will
  2891. // outweigh the benefits and it's better off to just always render it fresh.
  2892. if (node.static && node.children.length && !(
  2893. node.children.length === 1 &&
  2894. node.children[0].type === 3
  2895. )) {
  2896. node.staticRoot = true;
  2897. return
  2898. } else {
  2899. node.staticRoot = false;
  2900. }
  2901. if (node.children) {
  2902. for (var i = 0, l = node.children.length; i < l; i++) {
  2903. markStaticRoots(node.children[i], isInFor || !!node.for);
  2904. }
  2905. }
  2906. if (node.ifConditions) {
  2907. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  2908. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  2909. }
  2910. }
  2911. }
  2912. }
  2913. function isStatic (node) {
  2914. if (node.type === 2) { // expression
  2915. return false
  2916. }
  2917. if (node.type === 3) { // text
  2918. return true
  2919. }
  2920. return !!(node.pre || (
  2921. !node.hasBindings && // no dynamic bindings
  2922. !node.if && !node.for && // not v-if or v-for or v-else
  2923. !isBuiltInTag(node.tag) && // not a built-in
  2924. isPlatformReservedTag(node.tag) && // not a component
  2925. !isDirectChildOfTemplateFor(node) &&
  2926. Object.keys(node).every(isStaticKey)
  2927. ))
  2928. }
  2929. function isDirectChildOfTemplateFor (node) {
  2930. while (node.parent) {
  2931. node = node.parent;
  2932. if (node.tag !== 'template') {
  2933. return false
  2934. }
  2935. if (node.for) {
  2936. return true
  2937. }
  2938. }
  2939. return false
  2940. }
  2941. /* */
  2942. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  2943. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  2944. // KeyboardEvent.keyCode aliases
  2945. var keyCodes = {
  2946. esc: 27,
  2947. tab: 9,
  2948. enter: 13,
  2949. space: 32,
  2950. up: 38,
  2951. left: 37,
  2952. right: 39,
  2953. down: 40,
  2954. 'delete': [8, 46]
  2955. };
  2956. // KeyboardEvent.key aliases
  2957. var keyNames = {
  2958. // #7880: IE11 and Edge use `Esc` for Escape key name.
  2959. esc: ['Esc', 'Escape'],
  2960. tab: 'Tab',
  2961. enter: 'Enter',
  2962. // #9112: IE11 uses `Spacebar` for Space key name.
  2963. space: [' ', 'Spacebar'],
  2964. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  2965. up: ['Up', 'ArrowUp'],
  2966. left: ['Left', 'ArrowLeft'],
  2967. right: ['Right', 'ArrowRight'],
  2968. down: ['Down', 'ArrowDown'],
  2969. // #9112: IE11 uses `Del` for Delete key name.
  2970. 'delete': ['Backspace', 'Delete', 'Del']
  2971. };
  2972. // #4868: modifiers that prevent the execution of the listener
  2973. // need to explicitly return null so that we can determine whether to remove
  2974. // the listener for .once
  2975. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  2976. var modifierCode = {
  2977. stop: '$event.stopPropagation();',
  2978. prevent: '$event.preventDefault();',
  2979. self: genGuard("$event.target !== $event.currentTarget"),
  2980. ctrl: genGuard("!$event.ctrlKey"),
  2981. shift: genGuard("!$event.shiftKey"),
  2982. alt: genGuard("!$event.altKey"),
  2983. meta: genGuard("!$event.metaKey"),
  2984. left: genGuard("'button' in $event && $event.button !== 0"),
  2985. middle: genGuard("'button' in $event && $event.button !== 1"),
  2986. right: genGuard("'button' in $event && $event.button !== 2")
  2987. };
  2988. function genHandlers (
  2989. events,
  2990. isNative
  2991. ) {
  2992. var res = isNative ? 'nativeOn:{' : 'on:{';
  2993. for (var name in events) {
  2994. res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
  2995. }
  2996. return res.slice(0, -1) + '}'
  2997. }
  2998. function genHandler (
  2999. name,
  3000. handler
  3001. ) {
  3002. if (!handler) {
  3003. return 'function(){}'
  3004. }
  3005. if (Array.isArray(handler)) {
  3006. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  3007. }
  3008. var isMethodPath = simplePathRE.test(handler.value);
  3009. var isFunctionExpression = fnExpRE.test(handler.value);
  3010. if (!handler.modifiers) {
  3011. if (isMethodPath || isFunctionExpression) {
  3012. return handler.value
  3013. }
  3014. return ("function($event){" + (handler.value) + "}") // inline statement
  3015. } else {
  3016. var code = '';
  3017. var genModifierCode = '';
  3018. var keys = [];
  3019. for (var key in handler.modifiers) {
  3020. if (modifierCode[key]) {
  3021. genModifierCode += modifierCode[key];
  3022. // left/right
  3023. if (keyCodes[key]) {
  3024. keys.push(key);
  3025. }
  3026. } else if (key === 'exact') {
  3027. var modifiers = (handler.modifiers);
  3028. genModifierCode += genGuard(
  3029. ['ctrl', 'shift', 'alt', 'meta']
  3030. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  3031. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  3032. .join('||')
  3033. );
  3034. } else {
  3035. keys.push(key);
  3036. }
  3037. }
  3038. if (keys.length) {
  3039. code += genKeyFilter(keys);
  3040. }
  3041. // Make sure modifiers like prevent and stop get executed after key filtering
  3042. if (genModifierCode) {
  3043. code += genModifierCode;
  3044. }
  3045. var handlerCode = isMethodPath
  3046. ? ("return " + (handler.value) + "($event)")
  3047. : isFunctionExpression
  3048. ? ("return (" + (handler.value) + ")($event)")
  3049. : handler.value;
  3050. return ("function($event){" + code + handlerCode + "}")
  3051. }
  3052. }
  3053. function genKeyFilter (keys) {
  3054. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  3055. }
  3056. function genFilterCode (key) {
  3057. var keyVal = parseInt(key, 10);
  3058. if (keyVal) {
  3059. return ("$event.keyCode!==" + keyVal)
  3060. }
  3061. var keyCode = keyCodes[key];
  3062. var keyName = keyNames[key];
  3063. return (
  3064. "_k($event.keyCode," +
  3065. (JSON.stringify(key)) + "," +
  3066. (JSON.stringify(keyCode)) + "," +
  3067. "$event.key," +
  3068. "" + (JSON.stringify(keyName)) +
  3069. ")"
  3070. )
  3071. }
  3072. /* */
  3073. function on (el, dir) {
  3074. if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
  3075. warn("v-on without argument does not support modifiers.");
  3076. }
  3077. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  3078. }
  3079. /* */
  3080. function bind$1 (el, dir) {
  3081. el.wrapData = function (code) {
  3082. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  3083. };
  3084. }
  3085. /* */
  3086. var baseDirectives = {
  3087. on: on,
  3088. bind: bind$1,
  3089. cloak: noop
  3090. };
  3091. /* */
  3092. var CodegenState = function CodegenState (options) {
  3093. this.options = options;
  3094. this.warn = options.warn || baseWarn;
  3095. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  3096. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  3097. this.directives = extend(extend({}, baseDirectives), options.directives);
  3098. var isReservedTag = options.isReservedTag || no;
  3099. this.maybeComponent = function (el) { return !(isReservedTag(el.tag) && !el.component); };
  3100. this.onceId = 0;
  3101. this.staticRenderFns = [];
  3102. this.pre = false;
  3103. };
  3104. function generate (
  3105. ast,
  3106. options
  3107. ) {
  3108. var state = new CodegenState(options);
  3109. var code = ast ? genElement(ast, state) : '_c("div")';
  3110. return {
  3111. render: ("with(this){return " + code + "}"),
  3112. staticRenderFns: state.staticRenderFns
  3113. }
  3114. }
  3115. function genElement (el, state) {
  3116. if (el.parent) {
  3117. el.pre = el.pre || el.parent.pre;
  3118. }
  3119. if (el.staticRoot && !el.staticProcessed) {
  3120. return genStatic(el, state)
  3121. } else if (el.once && !el.onceProcessed) {
  3122. return genOnce(el, state)
  3123. } else if (el.for && !el.forProcessed) {
  3124. return genFor(el, state)
  3125. } else if (el.if && !el.ifProcessed) {
  3126. return genIf(el, state)
  3127. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  3128. return genChildren(el, state) || 'void 0'
  3129. } else if (el.tag === 'slot') {
  3130. return genSlot(el, state)
  3131. } else {
  3132. // component or element
  3133. var code;
  3134. if (el.component) {
  3135. code = genComponent(el.component, el, state);
  3136. } else {
  3137. var data;
  3138. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  3139. data = genData$2(el, state);
  3140. }
  3141. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  3142. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  3143. }
  3144. // module transforms
  3145. for (var i = 0; i < state.transforms.length; i++) {
  3146. code = state.transforms[i](el, code);
  3147. }
  3148. return code
  3149. }
  3150. }
  3151. // hoist static sub-trees out
  3152. function genStatic (el, state) {
  3153. el.staticProcessed = true;
  3154. // Some elements (templates) need to behave differently inside of a v-pre
  3155. // node. All pre nodes are static roots, so we can use this as a location to
  3156. // wrap a state change and reset it upon exiting the pre node.
  3157. var originalPreState = state.pre;
  3158. if (el.pre) {
  3159. state.pre = el.pre;
  3160. }
  3161. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  3162. state.pre = originalPreState;
  3163. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  3164. }
  3165. // v-once
  3166. function genOnce (el, state) {
  3167. el.onceProcessed = true;
  3168. if (el.if && !el.ifProcessed) {
  3169. return genIf(el, state)
  3170. } else if (el.staticInFor) {
  3171. var key = '';
  3172. var parent = el.parent;
  3173. while (parent) {
  3174. if (parent.for) {
  3175. key = parent.key;
  3176. break
  3177. }
  3178. parent = parent.parent;
  3179. }
  3180. if (!key) {
  3181. process.env.NODE_ENV !== 'production' && state.warn(
  3182. "v-once can only be used inside v-for that is keyed. "
  3183. );
  3184. return genElement(el, state)
  3185. }
  3186. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  3187. } else {
  3188. return genStatic(el, state)
  3189. }
  3190. }
  3191. function genIf (
  3192. el,
  3193. state,
  3194. altGen,
  3195. altEmpty
  3196. ) {
  3197. el.ifProcessed = true; // avoid recursion
  3198. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  3199. }
  3200. function genIfConditions (
  3201. conditions,
  3202. state,
  3203. altGen,
  3204. altEmpty
  3205. ) {
  3206. if (!conditions.length) {
  3207. return altEmpty || '_e()'
  3208. }
  3209. var condition = conditions.shift();
  3210. if (condition.exp) {
  3211. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  3212. } else {
  3213. return ("" + (genTernaryExp(condition.block)))
  3214. }
  3215. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  3216. function genTernaryExp (el) {
  3217. return altGen
  3218. ? altGen(el, state)
  3219. : el.once
  3220. ? genOnce(el, state)
  3221. : genElement(el, state)
  3222. }
  3223. }
  3224. function genFor (
  3225. el,
  3226. state,
  3227. altGen,
  3228. altHelper
  3229. ) {
  3230. var exp = el.for;
  3231. var alias = el.alias;
  3232. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  3233. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  3234. if (process.env.NODE_ENV !== 'production' &&
  3235. state.maybeComponent(el) &&
  3236. el.tag !== 'slot' &&
  3237. el.tag !== 'template' &&
  3238. !el.key
  3239. ) {
  3240. state.warn(
  3241. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  3242. "v-for should have explicit keys. " +
  3243. "See https://vuejs.org/guide/list.html#key for more info.",
  3244. true /* tip */
  3245. );
  3246. }
  3247. el.forProcessed = true; // avoid recursion
  3248. return (altHelper || '_l') + "((" + exp + ")," +
  3249. "function(" + alias + iterator1 + iterator2 + "){" +
  3250. "return " + ((altGen || genElement)(el, state)) +
  3251. '})'
  3252. }
  3253. function genData$2 (el, state) {
  3254. var data = '{';
  3255. // directives first.
  3256. // directives may mutate the el's other properties before they are generated.
  3257. var dirs = genDirectives(el, state);
  3258. if (dirs) { data += dirs + ','; }
  3259. // key
  3260. if (el.key) {
  3261. data += "key:" + (el.key) + ",";
  3262. }
  3263. // ref
  3264. if (el.ref) {
  3265. data += "ref:" + (el.ref) + ",";
  3266. }
  3267. if (el.refInFor) {
  3268. data += "refInFor:true,";
  3269. }
  3270. // pre
  3271. if (el.pre) {
  3272. data += "pre:true,";
  3273. }
  3274. // record original tag name for components using "is" attribute
  3275. if (el.component) {
  3276. data += "tag:\"" + (el.tag) + "\",";
  3277. }
  3278. // module data generation functions
  3279. for (var i = 0; i < state.dataGenFns.length; i++) {
  3280. data += state.dataGenFns[i](el);
  3281. }
  3282. // attributes
  3283. if (el.attrs) {
  3284. data += "attrs:{" + (genProps(el.attrs)) + "},";
  3285. }
  3286. // DOM props
  3287. if (el.props) {
  3288. data += "domProps:{" + (genProps(el.props)) + "},";
  3289. }
  3290. // event handlers
  3291. if (el.events) {
  3292. data += (genHandlers(el.events, false)) + ",";
  3293. }
  3294. if (el.nativeEvents) {
  3295. data += (genHandlers(el.nativeEvents, true)) + ",";
  3296. }
  3297. // slot target
  3298. // only for non-scoped slots
  3299. if (el.slotTarget && !el.slotScope) {
  3300. data += "slot:" + (el.slotTarget) + ",";
  3301. }
  3302. // scoped slots
  3303. if (el.scopedSlots) {
  3304. data += (genScopedSlots(el.scopedSlots, state)) + ",";
  3305. }
  3306. // component v-model
  3307. if (el.model) {
  3308. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  3309. }
  3310. // inline-template
  3311. if (el.inlineTemplate) {
  3312. var inlineTemplate = genInlineTemplate(el, state);
  3313. if (inlineTemplate) {
  3314. data += inlineTemplate + ",";
  3315. }
  3316. }
  3317. data = data.replace(/,$/, '') + '}';
  3318. // v-bind data wrap
  3319. if (el.wrapData) {
  3320. data = el.wrapData(data);
  3321. }
  3322. // v-on data wrap
  3323. if (el.wrapListeners) {
  3324. data = el.wrapListeners(data);
  3325. }
  3326. return data
  3327. }
  3328. function genDirectives (el, state) {
  3329. var dirs = el.directives;
  3330. if (!dirs) { return }
  3331. var res = 'directives:[';
  3332. var hasRuntime = false;
  3333. var i, l, dir, needRuntime;
  3334. for (i = 0, l = dirs.length; i < l; i++) {
  3335. dir = dirs[i];
  3336. needRuntime = true;
  3337. var gen = state.directives[dir.name];
  3338. if (gen) {
  3339. // compile-time directive that manipulates AST.
  3340. // returns true if it also needs a runtime counterpart.
  3341. needRuntime = !!gen(el, dir, state.warn);
  3342. }
  3343. if (needRuntime) {
  3344. hasRuntime = true;
  3345. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  3346. }
  3347. }
  3348. if (hasRuntime) {
  3349. return res.slice(0, -1) + ']'
  3350. }
  3351. }
  3352. function genInlineTemplate (el, state) {
  3353. var ast = el.children[0];
  3354. if (process.env.NODE_ENV !== 'production' && (
  3355. el.children.length !== 1 || ast.type !== 1
  3356. )) {
  3357. state.warn('Inline-template components must have exactly one child element.');
  3358. }
  3359. if (ast.type === 1) {
  3360. var inlineRenderFns = generate(ast, state.options);
  3361. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  3362. }
  3363. }
  3364. function genScopedSlots (
  3365. slots,
  3366. state
  3367. ) {
  3368. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
  3369. return genScopedSlot(key, slots[key], state)
  3370. }).join(',')) + "])")
  3371. }
  3372. function genScopedSlot (
  3373. key,
  3374. el,
  3375. state
  3376. ) {
  3377. if (el.for && !el.forProcessed) {
  3378. return genForScopedSlot(key, el, state)
  3379. }
  3380. var fn = "function(" + (String(el.slotScope)) + "){" +
  3381. "return " + (el.tag === 'template'
  3382. ? el.if
  3383. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  3384. : genChildren(el, state) || 'undefined'
  3385. : genElement(el, state)) + "}";
  3386. return ("{key:" + key + ",fn:" + fn + "}")
  3387. }
  3388. function genForScopedSlot (
  3389. key,
  3390. el,
  3391. state
  3392. ) {
  3393. var exp = el.for;
  3394. var alias = el.alias;
  3395. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  3396. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  3397. el.forProcessed = true; // avoid recursion
  3398. return "_l((" + exp + ")," +
  3399. "function(" + alias + iterator1 + iterator2 + "){" +
  3400. "return " + (genScopedSlot(key, el, state)) +
  3401. '})'
  3402. }
  3403. function genChildren (
  3404. el,
  3405. state,
  3406. checkSkip,
  3407. altGenElement,
  3408. altGenNode
  3409. ) {
  3410. var children = el.children;
  3411. if (children.length) {
  3412. var el$1 = children[0];
  3413. // optimize single v-for
  3414. if (children.length === 1 &&
  3415. el$1.for &&
  3416. el$1.tag !== 'template' &&
  3417. el$1.tag !== 'slot'
  3418. ) {
  3419. var normalizationType = checkSkip
  3420. ? state.maybeComponent(el$1) ? ",1" : ",0"
  3421. : "";
  3422. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  3423. }
  3424. var normalizationType$1 = checkSkip
  3425. ? getNormalizationType(children, state.maybeComponent)
  3426. : 0;
  3427. var gen = altGenNode || genNode;
  3428. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  3429. }
  3430. }
  3431. // determine the normalization needed for the children array.
  3432. // 0: no normalization needed
  3433. // 1: simple normalization needed (possible 1-level deep nested array)
  3434. // 2: full normalization needed
  3435. function getNormalizationType (
  3436. children,
  3437. maybeComponent
  3438. ) {
  3439. var res = 0;
  3440. for (var i = 0; i < children.length; i++) {
  3441. var el = children[i];
  3442. if (el.type !== 1) {
  3443. continue
  3444. }
  3445. if (needsNormalization(el) ||
  3446. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  3447. res = 2;
  3448. break
  3449. }
  3450. if (maybeComponent(el) ||
  3451. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  3452. res = 1;
  3453. }
  3454. }
  3455. return res
  3456. }
  3457. function needsNormalization (el) {
  3458. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  3459. }
  3460. function genNode (node, state) {
  3461. if (node.type === 1) {
  3462. return genElement(node, state)
  3463. } else if (node.type === 3 && node.isComment) {
  3464. return genComment(node)
  3465. } else {
  3466. return genText(node)
  3467. }
  3468. }
  3469. function genText (text) {
  3470. return ("_v(" + (text.type === 2
  3471. ? text.expression // no need for () because already wrapped in _s()
  3472. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  3473. }
  3474. function genComment (comment) {
  3475. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  3476. }
  3477. function genSlot (el, state) {
  3478. var slotName = el.slotName || '"default"';
  3479. var children = genChildren(el, state);
  3480. var res = "_t(" + slotName + (children ? ("," + children) : '');
  3481. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  3482. var bind$$1 = el.attrsMap['v-bind'];
  3483. if ((attrs || bind$$1) && !children) {
  3484. res += ",null";
  3485. }
  3486. if (attrs) {
  3487. res += "," + attrs;
  3488. }
  3489. if (bind$$1) {
  3490. res += (attrs ? '' : ',null') + "," + bind$$1;
  3491. }
  3492. return res + ')'
  3493. }
  3494. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  3495. function genComponent (
  3496. componentName,
  3497. el,
  3498. state
  3499. ) {
  3500. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  3501. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  3502. }
  3503. function genProps (props) {
  3504. var res = '';
  3505. for (var i = 0; i < props.length; i++) {
  3506. var prop = props[i];
  3507. /* istanbul ignore if */
  3508. {
  3509. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  3510. }
  3511. }
  3512. return res.slice(0, -1)
  3513. }
  3514. // #3895, #4268
  3515. function transformSpecialNewlines (text) {
  3516. return text
  3517. .replace(/\u2028/g, '\\u2028')
  3518. .replace(/\u2029/g, '\\u2029')
  3519. }
  3520. /* */
  3521. // these keywords should not appear inside expressions, but operators like
  3522. // typeof, instanceof and in are allowed
  3523. var prohibitedKeywordRE = new RegExp('\\b' + (
  3524. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  3525. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  3526. 'extends,finally,continue,debugger,function,arguments'
  3527. ).split(',').join('\\b|\\b') + '\\b');
  3528. // these unary operators should not be used as property/method names
  3529. var unaryOperatorsRE = new RegExp('\\b' + (
  3530. 'delete,typeof,void'
  3531. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  3532. // strip strings in expressions
  3533. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  3534. // detect problematic expressions in a template
  3535. function detectErrors (ast) {
  3536. var errors = [];
  3537. if (ast) {
  3538. checkNode(ast, errors);
  3539. }
  3540. return errors
  3541. }
  3542. function checkNode (node, errors) {
  3543. if (node.type === 1) {
  3544. for (var name in node.attrsMap) {
  3545. if (dirRE.test(name)) {
  3546. var value = node.attrsMap[name];
  3547. if (value) {
  3548. if (name === 'v-for') {
  3549. checkFor(node, ("v-for=\"" + value + "\""), errors);
  3550. } else if (onRE.test(name)) {
  3551. checkEvent(value, (name + "=\"" + value + "\""), errors);
  3552. } else {
  3553. checkExpression(value, (name + "=\"" + value + "\""), errors);
  3554. }
  3555. }
  3556. }
  3557. }
  3558. if (node.children) {
  3559. for (var i = 0; i < node.children.length; i++) {
  3560. checkNode(node.children[i], errors);
  3561. }
  3562. }
  3563. } else if (node.type === 2) {
  3564. checkExpression(node.expression, node.text, errors);
  3565. }
  3566. }
  3567. function checkEvent (exp, text, errors) {
  3568. var stipped = exp.replace(stripStringRE, '');
  3569. var keywordMatch = stipped.match(unaryOperatorsRE);
  3570. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  3571. errors.push(
  3572. "avoid using JavaScript unary operator as property name: " +
  3573. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  3574. );
  3575. }
  3576. checkExpression(exp, text, errors);
  3577. }
  3578. function checkFor (node, text, errors) {
  3579. checkExpression(node.for || '', text, errors);
  3580. checkIdentifier(node.alias, 'v-for alias', text, errors);
  3581. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  3582. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  3583. }
  3584. function checkIdentifier (
  3585. ident,
  3586. type,
  3587. text,
  3588. errors
  3589. ) {
  3590. if (typeof ident === 'string') {
  3591. try {
  3592. new Function(("var " + ident + "=_"));
  3593. } catch (e) {
  3594. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  3595. }
  3596. }
  3597. }
  3598. function checkExpression (exp, text, errors) {
  3599. try {
  3600. new Function(("return " + exp));
  3601. } catch (e) {
  3602. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  3603. if (keywordMatch) {
  3604. errors.push(
  3605. "avoid using JavaScript keyword as property name: " +
  3606. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim())
  3607. );
  3608. } else {
  3609. errors.push(
  3610. "invalid expression: " + (e.message) + " in\n\n" +
  3611. " " + exp + "\n\n" +
  3612. " Raw expression: " + (text.trim()) + "\n"
  3613. );
  3614. }
  3615. }
  3616. }
  3617. /* */
  3618. function createFunction (code, errors) {
  3619. try {
  3620. return new Function(code)
  3621. } catch (err) {
  3622. errors.push({ err: err, code: code });
  3623. return noop
  3624. }
  3625. }
  3626. function createCompileToFunctionFn (compile) {
  3627. var cache = Object.create(null);
  3628. return function compileToFunctions (
  3629. template,
  3630. options,
  3631. vm
  3632. ) {
  3633. options = extend({}, options);
  3634. var warn$$1 = options.warn || warn;
  3635. delete options.warn;
  3636. /* istanbul ignore if */
  3637. if (process.env.NODE_ENV !== 'production') {
  3638. // detect possible CSP restriction
  3639. try {
  3640. new Function('return 1');
  3641. } catch (e) {
  3642. if (e.toString().match(/unsafe-eval|CSP/)) {
  3643. warn$$1(
  3644. 'It seems you are using the standalone build of Vue.js in an ' +
  3645. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  3646. 'The template compiler cannot work in this environment. Consider ' +
  3647. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  3648. 'templates into render functions.'
  3649. );
  3650. }
  3651. }
  3652. }
  3653. // check cache
  3654. var key = options.delimiters
  3655. ? String(options.delimiters) + template
  3656. : template;
  3657. if (cache[key]) {
  3658. return cache[key]
  3659. }
  3660. // compile
  3661. var compiled = compile(template, options);
  3662. // check compilation errors/tips
  3663. if (process.env.NODE_ENV !== 'production') {
  3664. if (compiled.errors && compiled.errors.length) {
  3665. warn$$1(
  3666. "Error compiling template:\n\n" + template + "\n\n" +
  3667. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  3668. vm
  3669. );
  3670. }
  3671. if (compiled.tips && compiled.tips.length) {
  3672. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  3673. }
  3674. }
  3675. // turn code into functions
  3676. var res = {};
  3677. var fnGenErrors = [];
  3678. res.render = createFunction(compiled.render, fnGenErrors);
  3679. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  3680. return createFunction(code, fnGenErrors)
  3681. });
  3682. // check function generation errors.
  3683. // this should only happen if there is a bug in the compiler itself.
  3684. // mostly for codegen development use
  3685. /* istanbul ignore if */
  3686. if (process.env.NODE_ENV !== 'production') {
  3687. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  3688. warn$$1(
  3689. "Failed to generate render function:\n\n" +
  3690. fnGenErrors.map(function (ref) {
  3691. var err = ref.err;
  3692. var code = ref.code;
  3693. return ((err.toString()) + " in\n\n" + code + "\n");
  3694. }).join('\n'),
  3695. vm
  3696. );
  3697. }
  3698. }
  3699. return (cache[key] = res)
  3700. }
  3701. }
  3702. /* */
  3703. function createCompilerCreator (baseCompile) {
  3704. return function createCompiler (baseOptions) {
  3705. function compile (
  3706. template,
  3707. options
  3708. ) {
  3709. var finalOptions = Object.create(baseOptions);
  3710. var errors = [];
  3711. var tips = [];
  3712. finalOptions.warn = function (msg, tip) {
  3713. (tip ? tips : errors).push(msg);
  3714. };
  3715. if (options) {
  3716. // merge custom modules
  3717. if (options.modules) {
  3718. finalOptions.modules =
  3719. (baseOptions.modules || []).concat(options.modules);
  3720. }
  3721. // merge custom directives
  3722. if (options.directives) {
  3723. finalOptions.directives = extend(
  3724. Object.create(baseOptions.directives || null),
  3725. options.directives
  3726. );
  3727. }
  3728. // copy other options
  3729. for (var key in options) {
  3730. if (key !== 'modules' && key !== 'directives') {
  3731. finalOptions[key] = options[key];
  3732. }
  3733. }
  3734. }
  3735. var compiled = baseCompile(template, finalOptions);
  3736. if (process.env.NODE_ENV !== 'production') {
  3737. errors.push.apply(errors, detectErrors(compiled.ast));
  3738. }
  3739. compiled.errors = errors;
  3740. compiled.tips = tips;
  3741. return compiled
  3742. }
  3743. return {
  3744. compile: compile,
  3745. compileToFunctions: createCompileToFunctionFn(compile)
  3746. }
  3747. }
  3748. }
  3749. /* */
  3750. // `createCompilerCreator` allows creating compilers that use alternative
  3751. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  3752. // Here we just export a default compiler using the default parts.
  3753. var createCompiler = createCompilerCreator(function baseCompile (
  3754. template,
  3755. options
  3756. ) {
  3757. var ast = parse(template.trim(), options);
  3758. if (options.optimize !== false) {
  3759. optimize(ast, options);
  3760. }
  3761. var code = generate(ast, options);
  3762. return {
  3763. ast: ast,
  3764. render: code.render,
  3765. staticRenderFns: code.staticRenderFns
  3766. }
  3767. });
  3768. /* */
  3769. var ref = createCompiler(baseOptions);
  3770. var compile = ref.compile;
  3771. var compileToFunctions = ref.compileToFunctions;
  3772. /* */
  3773. var isAttr = makeMap(
  3774. 'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
  3775. 'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
  3776. 'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' +
  3777. 'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' +
  3778. 'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' +
  3779. 'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
  3780. 'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
  3781. 'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
  3782. 'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
  3783. 'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
  3784. 'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
  3785. 'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
  3786. 'target,title,type,usemap,value,width,wrap'
  3787. );
  3788. /* istanbul ignore next */
  3789. var isRenderableAttr = function (name) {
  3790. return (
  3791. isAttr(name) ||
  3792. name.indexOf('data-') === 0 ||
  3793. name.indexOf('aria-') === 0
  3794. )
  3795. };
  3796. var propsToAttrMap = {
  3797. acceptCharset: 'accept-charset',
  3798. className: 'class',
  3799. htmlFor: 'for',
  3800. httpEquiv: 'http-equiv'
  3801. };
  3802. var ESC = {
  3803. '<': '&lt;',
  3804. '>': '&gt;',
  3805. '"': '&quot;',
  3806. '&': '&amp;'
  3807. };
  3808. function escape (s) {
  3809. return s.replace(/[<>"&]/g, escapeChar)
  3810. }
  3811. function escapeChar (a) {
  3812. return ESC[a] || a
  3813. }
  3814. /* */
  3815. var plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
  3816. // let the model AST transform translate v-model into appropriate
  3817. // props bindings
  3818. function applyModelTransform (el, state) {
  3819. if (el.directives) {
  3820. for (var i = 0; i < el.directives.length; i++) {
  3821. var dir = el.directives[i];
  3822. if (dir.name === 'model') {
  3823. state.directives.model(el, dir, state.warn);
  3824. // remove value for textarea as its converted to text
  3825. if (el.tag === 'textarea' && el.props) {
  3826. el.props = el.props.filter(function (p) { return p.name !== 'value'; });
  3827. }
  3828. break
  3829. }
  3830. }
  3831. }
  3832. }
  3833. function genAttrSegments (
  3834. attrs
  3835. ) {
  3836. return attrs.map(function (ref) {
  3837. var name = ref.name;
  3838. var value = ref.value;
  3839. return genAttrSegment(name, value);
  3840. })
  3841. }
  3842. function genDOMPropSegments (
  3843. props,
  3844. attrs
  3845. ) {
  3846. var segments = [];
  3847. props.forEach(function (ref) {
  3848. var name = ref.name;
  3849. var value = ref.value;
  3850. name = propsToAttrMap[name] || name.toLowerCase();
  3851. if (isRenderableAttr(name) &&
  3852. !(attrs && attrs.some(function (a) { return a.name === name; }))
  3853. ) {
  3854. segments.push(genAttrSegment(name, value));
  3855. }
  3856. });
  3857. return segments
  3858. }
  3859. function genAttrSegment (name, value) {
  3860. if (plainStringRE.test(value)) {
  3861. // force double quote
  3862. value = value.replace(/^'|'$/g, '"');
  3863. // force enumerated attr to "true"
  3864. if (isEnumeratedAttr(name) && value !== "\"false\"") {
  3865. value = "\"true\"";
  3866. }
  3867. return {
  3868. type: RAW,
  3869. value: isBooleanAttr(name)
  3870. ? (" " + name + "=\"" + name + "\"")
  3871. : value === '""'
  3872. ? (" " + name)
  3873. : (" " + name + "=\"" + (JSON.parse(value)) + "\"")
  3874. }
  3875. } else {
  3876. return {
  3877. type: EXPRESSION,
  3878. value: ("_ssrAttr(" + (JSON.stringify(name)) + "," + value + ")")
  3879. }
  3880. }
  3881. }
  3882. function genClassSegments (
  3883. staticClass,
  3884. classBinding
  3885. ) {
  3886. if (staticClass && !classBinding) {
  3887. return [{ type: RAW, value: (" class=\"" + (JSON.parse(staticClass)) + "\"") }]
  3888. } else {
  3889. return [{
  3890. type: EXPRESSION,
  3891. value: ("_ssrClass(" + (staticClass || 'null') + "," + (classBinding || 'null') + ")")
  3892. }]
  3893. }
  3894. }
  3895. function genStyleSegments (
  3896. staticStyle,
  3897. parsedStaticStyle,
  3898. styleBinding,
  3899. vShowExpression
  3900. ) {
  3901. if (staticStyle && !styleBinding && !vShowExpression) {
  3902. return [{ type: RAW, value: (" style=" + (JSON.stringify(staticStyle))) }]
  3903. } else {
  3904. return [{
  3905. type: EXPRESSION,
  3906. value: ("_ssrStyle(" + (parsedStaticStyle || 'null') + "," + (styleBinding || 'null') + ", " + (vShowExpression
  3907. ? ("{ display: (" + vShowExpression + ") ? '' : 'none' }")
  3908. : 'null') + ")")
  3909. }]
  3910. }
  3911. }
  3912. /* */
  3913. // optimizability constants
  3914. var optimizability = {
  3915. FALSE: 0, // whole sub tree un-optimizable
  3916. FULL: 1, // whole sub tree optimizable
  3917. SELF: 2, // self optimizable but has some un-optimizable children
  3918. CHILDREN: 3, // self un-optimizable but have fully optimizable children
  3919. PARTIAL: 4 // self un-optimizable with some un-optimizable children
  3920. };
  3921. var isPlatformReservedTag$1;
  3922. function optimize$1 (root, options) {
  3923. if (!root) { return }
  3924. isPlatformReservedTag$1 = options.isReservedTag || no;
  3925. walk(root, true);
  3926. }
  3927. function walk (node, isRoot) {
  3928. if (isUnOptimizableTree(node)) {
  3929. node.ssrOptimizability = optimizability.FALSE;
  3930. return
  3931. }
  3932. // root node or nodes with custom directives should always be a VNode
  3933. var selfUnoptimizable = isRoot || hasCustomDirective(node);
  3934. var check = function (child) {
  3935. if (child.ssrOptimizability !== optimizability.FULL) {
  3936. node.ssrOptimizability = selfUnoptimizable
  3937. ? optimizability.PARTIAL
  3938. : optimizability.SELF;
  3939. }
  3940. };
  3941. if (selfUnoptimizable) {
  3942. node.ssrOptimizability = optimizability.CHILDREN;
  3943. }
  3944. if (node.type === 1) {
  3945. for (var i = 0, l = node.children.length; i < l; i++) {
  3946. var child = node.children[i];
  3947. walk(child);
  3948. check(child);
  3949. }
  3950. if (node.ifConditions) {
  3951. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  3952. var block = node.ifConditions[i$1].block;
  3953. walk(block, isRoot);
  3954. check(block);
  3955. }
  3956. }
  3957. if (node.ssrOptimizability == null ||
  3958. (!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))
  3959. ) {
  3960. node.ssrOptimizability = optimizability.FULL;
  3961. } else {
  3962. node.children = optimizeSiblings(node);
  3963. }
  3964. } else {
  3965. node.ssrOptimizability = optimizability.FULL;
  3966. }
  3967. }
  3968. function optimizeSiblings (el) {
  3969. var children = el.children;
  3970. var optimizedChildren = [];
  3971. var currentOptimizableGroup = [];
  3972. var pushGroup = function () {
  3973. if (currentOptimizableGroup.length) {
  3974. optimizedChildren.push({
  3975. type: 1,
  3976. parent: el,
  3977. tag: 'template',
  3978. attrsList: [],
  3979. attrsMap: {},
  3980. children: currentOptimizableGroup,
  3981. ssrOptimizability: optimizability.FULL
  3982. });
  3983. }
  3984. currentOptimizableGroup = [];
  3985. };
  3986. for (var i = 0; i < children.length; i++) {
  3987. var c = children[i];
  3988. if (c.ssrOptimizability === optimizability.FULL) {
  3989. currentOptimizableGroup.push(c);
  3990. } else {
  3991. // wrap fully-optimizable adjacent siblings inside a template tag
  3992. // so that they can be optimized into a single ssrNode by codegen
  3993. pushGroup();
  3994. optimizedChildren.push(c);
  3995. }
  3996. }
  3997. pushGroup();
  3998. return optimizedChildren
  3999. }
  4000. function isUnOptimizableTree (node) {
  4001. if (node.type === 2 || node.type === 3) { // text or expression
  4002. return false
  4003. }
  4004. return (
  4005. isBuiltInTag(node.tag) || // built-in (slot, component)
  4006. !isPlatformReservedTag$1(node.tag) || // custom component
  4007. !!node.component || // "is" component
  4008. isSelectWithModel(node) // <select v-model> requires runtime inspection
  4009. )
  4010. }
  4011. var isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
  4012. function hasCustomDirective (node) {
  4013. return (
  4014. node.type === 1 &&
  4015. node.directives &&
  4016. node.directives.some(function (d) { return !isBuiltInDir(d.name); })
  4017. )
  4018. }
  4019. // <select v-model> cannot be optimized because it requires a runtime check
  4020. // to determine proper selected option
  4021. function isSelectWithModel (node) {
  4022. return (
  4023. node.type === 1 &&
  4024. node.tag === 'select' &&
  4025. node.directives != null &&
  4026. node.directives.some(function (d) { return d.name === 'model'; })
  4027. )
  4028. }
  4029. /* */
  4030. // segment types
  4031. var RAW = 0;
  4032. var INTERPOLATION = 1;
  4033. var EXPRESSION = 2;
  4034. function generate$1 (
  4035. ast,
  4036. options
  4037. ) {
  4038. var state = new CodegenState(options);
  4039. var code = ast ? genSSRElement(ast, state) : '_c("div")';
  4040. return {
  4041. render: ("with(this){return " + code + "}"),
  4042. staticRenderFns: state.staticRenderFns
  4043. }
  4044. }
  4045. function genSSRElement (el, state) {
  4046. if (el.for && !el.forProcessed) {
  4047. return genFor(el, state, genSSRElement)
  4048. } else if (el.if && !el.ifProcessed) {
  4049. return genIf(el, state, genSSRElement)
  4050. } else if (el.tag === 'template' && !el.slotTarget) {
  4051. return el.ssrOptimizability === optimizability.FULL
  4052. ? genChildrenAsStringNode(el, state)
  4053. : genSSRChildren(el, state) || 'void 0'
  4054. }
  4055. switch (el.ssrOptimizability) {
  4056. case optimizability.FULL:
  4057. // stringify whole tree
  4058. return genStringElement(el, state)
  4059. case optimizability.SELF:
  4060. // stringify self and check children
  4061. return genStringElementWithChildren(el, state)
  4062. case optimizability.CHILDREN:
  4063. // generate self as VNode and stringify children
  4064. return genNormalElement(el, state, true)
  4065. case optimizability.PARTIAL:
  4066. // generate self as VNode and check children
  4067. return genNormalElement(el, state, false)
  4068. default:
  4069. // bail whole tree
  4070. return genElement(el, state)
  4071. }
  4072. }
  4073. function genNormalElement (el, state, stringifyChildren) {
  4074. var data = el.plain ? undefined : genData$2(el, state);
  4075. var children = stringifyChildren
  4076. ? ("[" + (genChildrenAsStringNode(el, state)) + "]")
  4077. : genSSRChildren(el, state, true);
  4078. return ("_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")")
  4079. }
  4080. function genSSRChildren (el, state, checkSkip) {
  4081. return genChildren(el, state, checkSkip, genSSRElement, genSSRNode)
  4082. }
  4083. function genSSRNode (el, state) {
  4084. return el.type === 1
  4085. ? genSSRElement(el, state)
  4086. : genText(el)
  4087. }
  4088. function genChildrenAsStringNode (el, state) {
  4089. return el.children.length
  4090. ? ("_ssrNode(" + (flattenSegments(childrenToSegments(el, state))) + ")")
  4091. : ''
  4092. }
  4093. function genStringElement (el, state) {
  4094. return ("_ssrNode(" + (elementToString(el, state)) + ")")
  4095. }
  4096. function genStringElementWithChildren (el, state) {
  4097. var children = genSSRChildren(el, state, true);
  4098. return ("_ssrNode(" + (flattenSegments(elementToOpenTagSegments(el, state))) + ",\"</" + (el.tag) + ">\"" + (children ? ("," + children) : '') + ")")
  4099. }
  4100. function elementToString (el, state) {
  4101. return ("(" + (flattenSegments(elementToSegments(el, state))) + ")")
  4102. }
  4103. function elementToSegments (el, state) {
  4104. // v-for / v-if
  4105. if (el.for && !el.forProcessed) {
  4106. el.forProcessed = true;
  4107. return [{
  4108. type: EXPRESSION,
  4109. value: genFor(el, state, elementToString, '_ssrList')
  4110. }]
  4111. } else if (el.if && !el.ifProcessed) {
  4112. el.ifProcessed = true;
  4113. return [{
  4114. type: EXPRESSION,
  4115. value: genIf(el, state, elementToString, '"<!---->"')
  4116. }]
  4117. } else if (el.tag === 'template') {
  4118. return childrenToSegments(el, state)
  4119. }
  4120. var openSegments = elementToOpenTagSegments(el, state);
  4121. var childrenSegments = childrenToSegments(el, state);
  4122. var ref = state.options;
  4123. var isUnaryTag = ref.isUnaryTag;
  4124. var close = (isUnaryTag && isUnaryTag(el.tag))
  4125. ? []
  4126. : [{ type: RAW, value: ("</" + (el.tag) + ">") }];
  4127. return openSegments.concat(childrenSegments, close)
  4128. }
  4129. function elementToOpenTagSegments (el, state) {
  4130. applyModelTransform(el, state);
  4131. var binding;
  4132. var segments = [{ type: RAW, value: ("<" + (el.tag)) }];
  4133. // attrs
  4134. if (el.attrs) {
  4135. segments.push.apply(segments, genAttrSegments(el.attrs));
  4136. }
  4137. // domProps
  4138. if (el.props) {
  4139. segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
  4140. }
  4141. // v-bind="object"
  4142. if ((binding = el.attrsMap['v-bind'])) {
  4143. segments.push({ type: EXPRESSION, value: ("_ssrAttrs(" + binding + ")") });
  4144. }
  4145. // v-bind.prop="object"
  4146. if ((binding = el.attrsMap['v-bind.prop'])) {
  4147. segments.push({ type: EXPRESSION, value: ("_ssrDOMProps(" + binding + ")") });
  4148. }
  4149. // class
  4150. if (el.staticClass || el.classBinding) {
  4151. segments.push.apply(
  4152. segments,
  4153. genClassSegments(el.staticClass, el.classBinding)
  4154. );
  4155. }
  4156. // style & v-show
  4157. if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
  4158. segments.push.apply(
  4159. segments,
  4160. genStyleSegments(
  4161. el.attrsMap.style,
  4162. el.staticStyle,
  4163. el.styleBinding,
  4164. el.attrsMap['v-show']
  4165. )
  4166. );
  4167. }
  4168. // _scopedId
  4169. if (state.options.scopeId) {
  4170. segments.push({ type: RAW, value: (" " + (state.options.scopeId)) });
  4171. }
  4172. segments.push({ type: RAW, value: ">" });
  4173. return segments
  4174. }
  4175. function childrenToSegments (el, state) {
  4176. var binding;
  4177. if ((binding = el.attrsMap['v-html'])) {
  4178. return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
  4179. }
  4180. if ((binding = el.attrsMap['v-text'])) {
  4181. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  4182. }
  4183. if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
  4184. return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
  4185. }
  4186. return el.children
  4187. ? nodesToSegments(el.children, state)
  4188. : []
  4189. }
  4190. function nodesToSegments (
  4191. children,
  4192. state
  4193. ) {
  4194. var segments = [];
  4195. for (var i = 0; i < children.length; i++) {
  4196. var c = children[i];
  4197. if (c.type === 1) {
  4198. segments.push.apply(segments, elementToSegments(c, state));
  4199. } else if (c.type === 2) {
  4200. segments.push({ type: INTERPOLATION, value: c.expression });
  4201. } else if (c.type === 3) {
  4202. segments.push({ type: RAW, value: escape(c.text) });
  4203. }
  4204. }
  4205. return segments
  4206. }
  4207. function flattenSegments (segments) {
  4208. var mergedSegments = [];
  4209. var textBuffer = '';
  4210. var pushBuffer = function () {
  4211. if (textBuffer) {
  4212. mergedSegments.push(JSON.stringify(textBuffer));
  4213. textBuffer = '';
  4214. }
  4215. };
  4216. for (var i = 0; i < segments.length; i++) {
  4217. var s = segments[i];
  4218. if (s.type === RAW) {
  4219. textBuffer += s.value;
  4220. } else if (s.type === INTERPOLATION) {
  4221. pushBuffer();
  4222. mergedSegments.push(("_ssrEscape(" + (s.value) + ")"));
  4223. } else if (s.type === EXPRESSION) {
  4224. pushBuffer();
  4225. mergedSegments.push(("(" + (s.value) + ")"));
  4226. }
  4227. }
  4228. pushBuffer();
  4229. return mergedSegments.join('+')
  4230. }
  4231. /* */
  4232. var createCompiler$1 = createCompilerCreator(function baseCompile (
  4233. template,
  4234. options
  4235. ) {
  4236. var ast = parse(template.trim(), options);
  4237. optimize$1(ast, options);
  4238. var code = generate$1(ast, options);
  4239. return {
  4240. ast: ast,
  4241. render: code.render,
  4242. staticRenderFns: code.staticRenderFns
  4243. }
  4244. });
  4245. /* */
  4246. var ref$1 = createCompiler$1(baseOptions);
  4247. var compile$1 = ref$1.compile;
  4248. var compileToFunctions$1 = ref$1.compileToFunctions;
  4249. /* */
  4250. exports.parseComponent = parseComponent;
  4251. exports.compile = compile;
  4252. exports.compileToFunctions = compileToFunctions;
  4253. exports.ssrCompile = compile$1;
  4254. exports.ssrCompileToFunctions = compileToFunctions$1;