build.js 128 KB

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