build.js 142 KB

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