build.js 142 KB

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