選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

vue.js 304KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063
  1. /*!
  2. * Vue.js v2.5.21
  3. * (c) 2014-2018 Evan You
  4. * Released under the MIT License.
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global.Vue = factory());
  10. }(this, (function () { 'use strict';
  11. /* */
  12. var emptyObject = Object.freeze({});
  13. // These helpers produce better VM code in JS engines due to their
  14. // explicitness and function inlining.
  15. function isUndef (v) {
  16. return v === undefined || v === null
  17. }
  18. function isDef (v) {
  19. return v !== undefined && v !== null
  20. }
  21. function isTrue (v) {
  22. return v === true
  23. }
  24. function isFalse (v) {
  25. return v === false
  26. }
  27. /**
  28. * Check if value is primitive.
  29. */
  30. function isPrimitive (value) {
  31. return (
  32. typeof value === 'string' ||
  33. typeof value === 'number' ||
  34. // $flow-disable-line
  35. typeof value === 'symbol' ||
  36. typeof value === 'boolean'
  37. )
  38. }
  39. /**
  40. * Quick object check - this is primarily used to tell
  41. * Objects from primitive values when we know the value
  42. * is a JSON-compliant type.
  43. */
  44. function isObject (obj) {
  45. return obj !== null && typeof obj === 'object'
  46. }
  47. /**
  48. * Get the raw type string of a value, e.g., [object Object].
  49. */
  50. var _toString = Object.prototype.toString;
  51. function toRawType (value) {
  52. return _toString.call(value).slice(8, -1)
  53. }
  54. /**
  55. * Strict object type check. Only returns true
  56. * for plain JavaScript objects.
  57. */
  58. function isPlainObject (obj) {
  59. return _toString.call(obj) === '[object Object]'
  60. }
  61. function isRegExp (v) {
  62. return _toString.call(v) === '[object RegExp]'
  63. }
  64. /**
  65. * Check if val is a valid array index.
  66. */
  67. function isValidArrayIndex (val) {
  68. var n = parseFloat(String(val));
  69. return n >= 0 && Math.floor(n) === n && isFinite(val)
  70. }
  71. /**
  72. * Convert a value to a string that is actually rendered.
  73. */
  74. function toString (val) {
  75. return val == null
  76. ? ''
  77. : typeof val === 'object'
  78. ? JSON.stringify(val, null, 2)
  79. : String(val)
  80. }
  81. /**
  82. * Convert an input value to a number for persistence.
  83. * If the conversion fails, return original string.
  84. */
  85. function toNumber (val) {
  86. var n = parseFloat(val);
  87. return isNaN(n) ? val : n
  88. }
  89. /**
  90. * Make a map and return a function for checking if a key
  91. * is in that map.
  92. */
  93. function makeMap (
  94. str,
  95. expectsLowerCase
  96. ) {
  97. var map = Object.create(null);
  98. var list = str.split(',');
  99. for (var i = 0; i < list.length; i++) {
  100. map[list[i]] = true;
  101. }
  102. return expectsLowerCase
  103. ? function (val) { return map[val.toLowerCase()]; }
  104. : function (val) { return map[val]; }
  105. }
  106. /**
  107. * Check if a tag is a built-in tag.
  108. */
  109. var isBuiltInTag = makeMap('slot,component', true);
  110. /**
  111. * Check if an attribute is a reserved attribute.
  112. */
  113. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  114. /**
  115. * Remove an item from an array.
  116. */
  117. function remove (arr, item) {
  118. if (arr.length) {
  119. var index = arr.indexOf(item);
  120. if (index > -1) {
  121. return arr.splice(index, 1)
  122. }
  123. }
  124. }
  125. /**
  126. * Check whether an object has the property.
  127. */
  128. var hasOwnProperty = Object.prototype.hasOwnProperty;
  129. function hasOwn (obj, key) {
  130. return hasOwnProperty.call(obj, key)
  131. }
  132. /**
  133. * Create a cached version of a pure function.
  134. */
  135. function cached (fn) {
  136. var cache = Object.create(null);
  137. return (function cachedFn (str) {
  138. var hit = cache[str];
  139. return hit || (cache[str] = fn(str))
  140. })
  141. }
  142. /**
  143. * Camelize a hyphen-delimited string.
  144. */
  145. var camelizeRE = /-(\w)/g;
  146. var camelize = cached(function (str) {
  147. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  148. });
  149. /**
  150. * Capitalize a string.
  151. */
  152. var capitalize = cached(function (str) {
  153. return str.charAt(0).toUpperCase() + str.slice(1)
  154. });
  155. /**
  156. * Hyphenate a camelCase string.
  157. */
  158. var hyphenateRE = /\B([A-Z])/g;
  159. var hyphenate = cached(function (str) {
  160. return str.replace(hyphenateRE, '-$1').toLowerCase()
  161. });
  162. /**
  163. * Simple bind polyfill for environments that do not support it,
  164. * e.g., PhantomJS 1.x. Technically, we don't need this anymore
  165. * since native bind is now performant enough in most browsers.
  166. * But removing it would mean breaking code that was able to run in
  167. * PhantomJS 1.x, so this must be kept for backward compatibility.
  168. */
  169. /* istanbul ignore next */
  170. function polyfillBind (fn, ctx) {
  171. function boundFn (a) {
  172. var l = arguments.length;
  173. return l
  174. ? l > 1
  175. ? fn.apply(ctx, arguments)
  176. : fn.call(ctx, a)
  177. : fn.call(ctx)
  178. }
  179. boundFn._length = fn.length;
  180. return boundFn
  181. }
  182. function nativeBind (fn, ctx) {
  183. return fn.bind(ctx)
  184. }
  185. var bind = Function.prototype.bind
  186. ? nativeBind
  187. : polyfillBind;
  188. /**
  189. * Convert an Array-like object to a real Array.
  190. */
  191. function toArray (list, start) {
  192. start = start || 0;
  193. var i = list.length - start;
  194. var ret = new Array(i);
  195. while (i--) {
  196. ret[i] = list[i + start];
  197. }
  198. return ret
  199. }
  200. /**
  201. * Mix properties into target object.
  202. */
  203. function extend (to, _from) {
  204. for (var key in _from) {
  205. to[key] = _from[key];
  206. }
  207. return to
  208. }
  209. /**
  210. * Merge an Array of Objects into a single Object.
  211. */
  212. function toObject (arr) {
  213. var res = {};
  214. for (var i = 0; i < arr.length; i++) {
  215. if (arr[i]) {
  216. extend(res, arr[i]);
  217. }
  218. }
  219. return res
  220. }
  221. /* eslint-disable no-unused-vars */
  222. /**
  223. * Perform no operation.
  224. * Stubbing args to make Flow happy without leaving useless transpiled code
  225. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/).
  226. */
  227. function noop (a, b, c) {}
  228. /**
  229. * Always return false.
  230. */
  231. var no = function (a, b, c) { return false; };
  232. /* eslint-enable no-unused-vars */
  233. /**
  234. * Return the same value.
  235. */
  236. var identity = function (_) { return _; };
  237. /**
  238. * Generate a string containing static keys from compiler modules.
  239. */
  240. function genStaticKeys (modules) {
  241. return modules.reduce(function (keys, m) {
  242. return keys.concat(m.staticKeys || [])
  243. }, []).join(',')
  244. }
  245. /**
  246. * Check if two values are loosely equal - that is,
  247. * if they are plain objects, do they have the same shape?
  248. */
  249. function looseEqual (a, b) {
  250. if (a === b) { return true }
  251. var isObjectA = isObject(a);
  252. var isObjectB = isObject(b);
  253. if (isObjectA && isObjectB) {
  254. try {
  255. var isArrayA = Array.isArray(a);
  256. var isArrayB = Array.isArray(b);
  257. if (isArrayA && isArrayB) {
  258. return a.length === b.length && a.every(function (e, i) {
  259. return looseEqual(e, b[i])
  260. })
  261. } else if (a instanceof Date && b instanceof Date) {
  262. return a.getTime() === b.getTime()
  263. } else if (!isArrayA && !isArrayB) {
  264. var keysA = Object.keys(a);
  265. var keysB = Object.keys(b);
  266. return keysA.length === keysB.length && keysA.every(function (key) {
  267. return looseEqual(a[key], b[key])
  268. })
  269. } else {
  270. /* istanbul ignore next */
  271. return false
  272. }
  273. } catch (e) {
  274. /* istanbul ignore next */
  275. return false
  276. }
  277. } else if (!isObjectA && !isObjectB) {
  278. return String(a) === String(b)
  279. } else {
  280. return false
  281. }
  282. }
  283. /**
  284. * Return the first index at which a loosely equal value can be
  285. * found in the array (if value is a plain object, the array must
  286. * contain an object of the same shape), or -1 if it is not present.
  287. */
  288. function looseIndexOf (arr, val) {
  289. for (var i = 0; i < arr.length; i++) {
  290. if (looseEqual(arr[i], val)) { return i }
  291. }
  292. return -1
  293. }
  294. /**
  295. * Ensure a function is called only once.
  296. */
  297. function once (fn) {
  298. var called = false;
  299. return function () {
  300. if (!called) {
  301. called = true;
  302. fn.apply(this, arguments);
  303. }
  304. }
  305. }
  306. var SSR_ATTR = 'data-server-rendered';
  307. var ASSET_TYPES = [
  308. 'component',
  309. 'directive',
  310. 'filter'
  311. ];
  312. var LIFECYCLE_HOOKS = [
  313. 'beforeCreate',
  314. 'created',
  315. 'beforeMount',
  316. 'mounted',
  317. 'beforeUpdate',
  318. 'updated',
  319. 'beforeDestroy',
  320. 'destroyed',
  321. 'activated',
  322. 'deactivated',
  323. 'errorCaptured'
  324. ];
  325. /* */
  326. var config = ({
  327. /**
  328. * Option merge strategies (used in core/util/options)
  329. */
  330. // $flow-disable-line
  331. optionMergeStrategies: Object.create(null),
  332. /**
  333. * Whether to suppress warnings.
  334. */
  335. silent: false,
  336. /**
  337. * Show production mode tip message on boot?
  338. */
  339. productionTip: "development" !== 'production',
  340. /**
  341. * Whether to enable devtools
  342. */
  343. devtools: "development" !== 'production',
  344. /**
  345. * Whether to record perf
  346. */
  347. performance: false,
  348. /**
  349. * Error handler for watcher errors
  350. */
  351. errorHandler: null,
  352. /**
  353. * Warn handler for watcher warns
  354. */
  355. warnHandler: null,
  356. /**
  357. * Ignore certain custom elements
  358. */
  359. ignoredElements: [],
  360. /**
  361. * Custom user key aliases for v-on
  362. */
  363. // $flow-disable-line
  364. keyCodes: Object.create(null),
  365. /**
  366. * Check if a tag is reserved so that it cannot be registered as a
  367. * component. This is platform-dependent and may be overwritten.
  368. */
  369. isReservedTag: no,
  370. /**
  371. * Check if an attribute is reserved so that it cannot be used as a component
  372. * prop. This is platform-dependent and may be overwritten.
  373. */
  374. isReservedAttr: no,
  375. /**
  376. * Check if a tag is an unknown element.
  377. * Platform-dependent.
  378. */
  379. isUnknownElement: no,
  380. /**
  381. * Get the namespace of an element
  382. */
  383. getTagNamespace: noop,
  384. /**
  385. * Parse the real tag name for the specific platform.
  386. */
  387. parsePlatformTagName: identity,
  388. /**
  389. * Check if an attribute must be bound using property, e.g. value
  390. * Platform-dependent.
  391. */
  392. mustUseProp: no,
  393. /**
  394. * Perform updates asynchronously. Intended to be used by Vue Test Utils
  395. * This will significantly reduce performance if set to false.
  396. */
  397. async: true,
  398. /**
  399. * Exposed for legacy reasons
  400. */
  401. _lifecycleHooks: LIFECYCLE_HOOKS
  402. });
  403. /* */
  404. /**
  405. * Check if a string starts with $ or _
  406. */
  407. function isReserved (str) {
  408. var c = (str + '').charCodeAt(0);
  409. return c === 0x24 || c === 0x5F
  410. }
  411. /**
  412. * Define a property.
  413. */
  414. function def (obj, key, val, enumerable) {
  415. Object.defineProperty(obj, key, {
  416. value: val,
  417. enumerable: !!enumerable,
  418. writable: true,
  419. configurable: true
  420. });
  421. }
  422. /**
  423. * Parse simple path.
  424. */
  425. var bailRE = /[^\w.$]/;
  426. function parsePath (path) {
  427. if (bailRE.test(path)) {
  428. return
  429. }
  430. var segments = path.split('.');
  431. return function (obj) {
  432. for (var i = 0; i < segments.length; i++) {
  433. if (!obj) { return }
  434. obj = obj[segments[i]];
  435. }
  436. return obj
  437. }
  438. }
  439. /* */
  440. // can we use __proto__?
  441. var hasProto = '__proto__' in {};
  442. // Browser environment sniffing
  443. var inBrowser = typeof window !== 'undefined';
  444. var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
  445. var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
  446. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  447. var isIE = UA && /msie|trident/.test(UA);
  448. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  449. var isEdge = UA && UA.indexOf('edge/') > 0;
  450. var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
  451. var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
  452. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  453. // Firefox has a "watch" function on Object.prototype...
  454. var nativeWatch = ({}).watch;
  455. var supportsPassive = false;
  456. if (inBrowser) {
  457. try {
  458. var opts = {};
  459. Object.defineProperty(opts, 'passive', ({
  460. get: function get () {
  461. /* istanbul ignore next */
  462. supportsPassive = true;
  463. }
  464. })); // https://github.com/facebook/flow/issues/285
  465. window.addEventListener('test-passive', null, opts);
  466. } catch (e) {}
  467. }
  468. // this needs to be lazy-evaled because vue may be required before
  469. // vue-server-renderer can set VUE_ENV
  470. var _isServer;
  471. var isServerRendering = function () {
  472. if (_isServer === undefined) {
  473. /* istanbul ignore if */
  474. if (!inBrowser && !inWeex && typeof global !== 'undefined') {
  475. // detect presence of vue-server-renderer and avoid
  476. // Webpack shimming the process
  477. _isServer = global['process'] && global['process'].env.VUE_ENV === 'server';
  478. } else {
  479. _isServer = false;
  480. }
  481. }
  482. return _isServer
  483. };
  484. // detect devtools
  485. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  486. /* istanbul ignore next */
  487. function isNative (Ctor) {
  488. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  489. }
  490. var hasSymbol =
  491. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  492. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  493. var _Set;
  494. /* istanbul ignore if */ // $flow-disable-line
  495. if (typeof Set !== 'undefined' && isNative(Set)) {
  496. // use native Set when available.
  497. _Set = Set;
  498. } else {
  499. // a non-standard Set polyfill that only works with primitive keys.
  500. _Set = /*@__PURE__*/(function () {
  501. function Set () {
  502. this.set = Object.create(null);
  503. }
  504. Set.prototype.has = function has (key) {
  505. return this.set[key] === true
  506. };
  507. Set.prototype.add = function add (key) {
  508. this.set[key] = true;
  509. };
  510. Set.prototype.clear = function clear () {
  511. this.set = Object.create(null);
  512. };
  513. return Set;
  514. }());
  515. }
  516. /* */
  517. var warn = noop;
  518. var tip = noop;
  519. var generateComponentTrace = (noop); // work around flow check
  520. var formatComponentName = (noop);
  521. {
  522. var hasConsole = typeof console !== 'undefined';
  523. var classifyRE = /(?:^|[-_])(\w)/g;
  524. var classify = function (str) { return str
  525. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  526. .replace(/[-_]/g, ''); };
  527. warn = function (msg, vm) {
  528. var trace = vm ? generateComponentTrace(vm) : '';
  529. if (config.warnHandler) {
  530. config.warnHandler.call(null, msg, vm, trace);
  531. } else if (hasConsole && (!config.silent)) {
  532. console.error(("[Vue warn]: " + msg + trace));
  533. }
  534. };
  535. tip = function (msg, vm) {
  536. if (hasConsole && (!config.silent)) {
  537. console.warn("[Vue tip]: " + msg + (
  538. vm ? generateComponentTrace(vm) : ''
  539. ));
  540. }
  541. };
  542. formatComponentName = function (vm, includeFile) {
  543. if (vm.$root === vm) {
  544. return '<Root>'
  545. }
  546. var options = typeof vm === 'function' && vm.cid != null
  547. ? vm.options
  548. : vm._isVue
  549. ? vm.$options || vm.constructor.options
  550. : vm || {};
  551. var name = options.name || options._componentTag;
  552. var file = options.__file;
  553. if (!name && file) {
  554. var match = file.match(/([^/\\]+)\.vue$/);
  555. name = match && match[1];
  556. }
  557. return (
  558. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  559. (file && includeFile !== false ? (" at " + file) : '')
  560. )
  561. };
  562. var repeat = function (str, n) {
  563. var res = '';
  564. while (n) {
  565. if (n % 2 === 1) { res += str; }
  566. if (n > 1) { str += str; }
  567. n >>= 1;
  568. }
  569. return res
  570. };
  571. generateComponentTrace = function (vm) {
  572. if (vm._isVue && vm.$parent) {
  573. var tree = [];
  574. var currentRecursiveSequence = 0;
  575. while (vm) {
  576. if (tree.length > 0) {
  577. var last = tree[tree.length - 1];
  578. if (last.constructor === vm.constructor) {
  579. currentRecursiveSequence++;
  580. vm = vm.$parent;
  581. continue
  582. } else if (currentRecursiveSequence > 0) {
  583. tree[tree.length - 1] = [last, currentRecursiveSequence];
  584. currentRecursiveSequence = 0;
  585. }
  586. }
  587. tree.push(vm);
  588. vm = vm.$parent;
  589. }
  590. return '\n\nfound in\n\n' + tree
  591. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  592. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  593. : formatComponentName(vm))); })
  594. .join('\n')
  595. } else {
  596. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  597. }
  598. };
  599. }
  600. /* */
  601. var uid = 0;
  602. /**
  603. * A dep is an observable that can have multiple
  604. * directives subscribing to it.
  605. */
  606. var Dep = function Dep () {
  607. this.id = uid++;
  608. this.subs = [];
  609. };
  610. Dep.prototype.addSub = function addSub (sub) {
  611. this.subs.push(sub);
  612. };
  613. Dep.prototype.removeSub = function removeSub (sub) {
  614. remove(this.subs, sub);
  615. };
  616. Dep.prototype.depend = function depend () {
  617. if (Dep.target) {
  618. Dep.target.addDep(this);
  619. }
  620. };
  621. Dep.prototype.notify = function notify () {
  622. // stabilize the subscriber list first
  623. var subs = this.subs.slice();
  624. if (!config.async) {
  625. // subs aren't sorted in scheduler if not running async
  626. // we need to sort them now to make sure they fire in correct
  627. // order
  628. subs.sort(function (a, b) { return a.id - b.id; });
  629. }
  630. for (var i = 0, l = subs.length; i < l; i++) {
  631. subs[i].update();
  632. }
  633. };
  634. // the current target watcher being evaluated.
  635. // this is globally unique because there could be only one
  636. // watcher being evaluated at any time.
  637. Dep.target = null;
  638. var targetStack = [];
  639. function pushTarget (target) {
  640. targetStack.push(target);
  641. Dep.target = target;
  642. }
  643. function popTarget () {
  644. targetStack.pop();
  645. Dep.target = targetStack[targetStack.length - 1];
  646. }
  647. /* */
  648. var VNode = function VNode (
  649. tag,
  650. data,
  651. children,
  652. text,
  653. elm,
  654. context,
  655. componentOptions,
  656. asyncFactory
  657. ) {
  658. this.tag = tag;
  659. this.data = data;
  660. this.children = children;
  661. this.text = text;
  662. this.elm = elm;
  663. this.ns = undefined;
  664. this.context = context;
  665. this.fnContext = undefined;
  666. this.fnOptions = undefined;
  667. this.fnScopeId = undefined;
  668. this.key = data && data.key;
  669. this.componentOptions = componentOptions;
  670. this.componentInstance = undefined;
  671. this.parent = undefined;
  672. this.raw = false;
  673. this.isStatic = false;
  674. this.isRootInsert = true;
  675. this.isComment = false;
  676. this.isCloned = false;
  677. this.isOnce = false;
  678. this.asyncFactory = asyncFactory;
  679. this.asyncMeta = undefined;
  680. this.isAsyncPlaceholder = false;
  681. };
  682. var prototypeAccessors = { child: { configurable: true } };
  683. // DEPRECATED: alias for componentInstance for backwards compat.
  684. /* istanbul ignore next */
  685. prototypeAccessors.child.get = function () {
  686. return this.componentInstance
  687. };
  688. Object.defineProperties( VNode.prototype, prototypeAccessors );
  689. var createEmptyVNode = function (text) {
  690. if ( text === void 0 ) text = '';
  691. var node = new VNode();
  692. node.text = text;
  693. node.isComment = true;
  694. return node
  695. };
  696. function createTextVNode (val) {
  697. return new VNode(undefined, undefined, undefined, String(val))
  698. }
  699. // optimized shallow clone
  700. // used for static nodes and slot nodes because they may be reused across
  701. // multiple renders, cloning them avoids errors when DOM manipulations rely
  702. // on their elm reference.
  703. function cloneVNode (vnode) {
  704. var cloned = new VNode(
  705. vnode.tag,
  706. vnode.data,
  707. // #7975
  708. // clone children array to avoid mutating original in case of cloning
  709. // a child.
  710. vnode.children && vnode.children.slice(),
  711. vnode.text,
  712. vnode.elm,
  713. vnode.context,
  714. vnode.componentOptions,
  715. vnode.asyncFactory
  716. );
  717. cloned.ns = vnode.ns;
  718. cloned.isStatic = vnode.isStatic;
  719. cloned.key = vnode.key;
  720. cloned.isComment = vnode.isComment;
  721. cloned.fnContext = vnode.fnContext;
  722. cloned.fnOptions = vnode.fnOptions;
  723. cloned.fnScopeId = vnode.fnScopeId;
  724. cloned.asyncMeta = vnode.asyncMeta;
  725. cloned.isCloned = true;
  726. return cloned
  727. }
  728. /*
  729. * not type checking this file because flow doesn't play well with
  730. * dynamically accessing methods on Array prototype
  731. */
  732. var arrayProto = Array.prototype;
  733. var arrayMethods = Object.create(arrayProto);
  734. var methodsToPatch = [
  735. 'push',
  736. 'pop',
  737. 'shift',
  738. 'unshift',
  739. 'splice',
  740. 'sort',
  741. 'reverse'
  742. ];
  743. /**
  744. * Intercept mutating methods and emit events
  745. */
  746. methodsToPatch.forEach(function (method) {
  747. // cache original method
  748. var original = arrayProto[method];
  749. def(arrayMethods, method, function mutator () {
  750. var args = [], len = arguments.length;
  751. while ( len-- ) args[ len ] = arguments[ len ];
  752. var result = original.apply(this, args);
  753. var ob = this.__ob__;
  754. var inserted;
  755. switch (method) {
  756. case 'push':
  757. case 'unshift':
  758. inserted = args;
  759. break
  760. case 'splice':
  761. inserted = args.slice(2);
  762. break
  763. }
  764. if (inserted) { ob.observeArray(inserted); }
  765. // notify change
  766. ob.dep.notify();
  767. return result
  768. });
  769. });
  770. /* */
  771. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  772. /**
  773. * In some cases we may want to disable observation inside a component's
  774. * update computation.
  775. */
  776. var shouldObserve = true;
  777. function toggleObserving (value) {
  778. shouldObserve = value;
  779. }
  780. /**
  781. * Observer class that is attached to each observed
  782. * object. Once attached, the observer converts the target
  783. * object's property keys into getter/setters that
  784. * collect dependencies and dispatch updates.
  785. */
  786. var Observer = function Observer (value) {
  787. this.value = value;
  788. this.dep = new Dep();
  789. this.vmCount = 0;
  790. def(value, '__ob__', this);
  791. if (Array.isArray(value)) {
  792. if (hasProto) {
  793. protoAugment(value, arrayMethods);
  794. } else {
  795. copyAugment(value, arrayMethods, arrayKeys);
  796. }
  797. this.observeArray(value);
  798. } else {
  799. this.walk(value);
  800. }
  801. };
  802. /**
  803. * Walk through all properties and convert them into
  804. * getter/setters. This method should only be called when
  805. * value type is Object.
  806. */
  807. Observer.prototype.walk = function walk (obj) {
  808. var keys = Object.keys(obj);
  809. for (var i = 0; i < keys.length; i++) {
  810. defineReactive$$1(obj, keys[i]);
  811. }
  812. };
  813. /**
  814. * Observe a list of Array items.
  815. */
  816. Observer.prototype.observeArray = function observeArray (items) {
  817. for (var i = 0, l = items.length; i < l; i++) {
  818. observe(items[i]);
  819. }
  820. };
  821. // helpers
  822. /**
  823. * Augment a target Object or Array by intercepting
  824. * the prototype chain using __proto__
  825. */
  826. function protoAugment (target, src) {
  827. /* eslint-disable no-proto */
  828. target.__proto__ = src;
  829. /* eslint-enable no-proto */
  830. }
  831. /**
  832. * Augment a target Object or Array by defining
  833. * hidden properties.
  834. */
  835. /* istanbul ignore next */
  836. function copyAugment (target, src, keys) {
  837. for (var i = 0, l = keys.length; i < l; i++) {
  838. var key = keys[i];
  839. def(target, key, src[key]);
  840. }
  841. }
  842. /**
  843. * Attempt to create an observer instance for a value,
  844. * returns the new observer if successfully observed,
  845. * or the existing observer if the value already has one.
  846. */
  847. function observe (value, asRootData) {
  848. if (!isObject(value) || value instanceof VNode) {
  849. return
  850. }
  851. var ob;
  852. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  853. ob = value.__ob__;
  854. } else if (
  855. shouldObserve &&
  856. !isServerRendering() &&
  857. (Array.isArray(value) || isPlainObject(value)) &&
  858. Object.isExtensible(value) &&
  859. !value._isVue
  860. ) {
  861. ob = new Observer(value);
  862. }
  863. if (asRootData && ob) {
  864. ob.vmCount++;
  865. }
  866. return ob
  867. }
  868. /**
  869. * Define a reactive property on an Object.
  870. */
  871. function defineReactive$$1 (
  872. obj,
  873. key,
  874. val,
  875. customSetter,
  876. shallow
  877. ) {
  878. var dep = new Dep();
  879. var property = Object.getOwnPropertyDescriptor(obj, key);
  880. if (property && property.configurable === false) {
  881. return
  882. }
  883. // cater for pre-defined getter/setters
  884. var getter = property && property.get;
  885. var setter = property && property.set;
  886. if ((!getter || setter) && arguments.length === 2) {
  887. val = obj[key];
  888. }
  889. var childOb = !shallow && observe(val);
  890. Object.defineProperty(obj, key, {
  891. enumerable: true,
  892. configurable: true,
  893. get: function reactiveGetter () {
  894. var value = getter ? getter.call(obj) : val;
  895. if (Dep.target) {
  896. dep.depend();
  897. if (childOb) {
  898. childOb.dep.depend();
  899. if (Array.isArray(value)) {
  900. dependArray(value);
  901. }
  902. }
  903. }
  904. return value
  905. },
  906. set: function reactiveSetter (newVal) {
  907. var value = getter ? getter.call(obj) : val;
  908. /* eslint-disable no-self-compare */
  909. if (newVal === value || (newVal !== newVal && value !== value)) {
  910. return
  911. }
  912. /* eslint-enable no-self-compare */
  913. if (customSetter) {
  914. customSetter();
  915. }
  916. // #7981: for accessor properties without setter
  917. if (getter && !setter) { return }
  918. if (setter) {
  919. setter.call(obj, newVal);
  920. } else {
  921. val = newVal;
  922. }
  923. childOb = !shallow && observe(newVal);
  924. dep.notify();
  925. }
  926. });
  927. }
  928. /**
  929. * Set a property on an object. Adds the new property and
  930. * triggers change notification if the property doesn't
  931. * already exist.
  932. */
  933. function set (target, key, val) {
  934. if (isUndef(target) || isPrimitive(target)
  935. ) {
  936. warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
  937. }
  938. if (Array.isArray(target) && isValidArrayIndex(key)) {
  939. target.length = Math.max(target.length, key);
  940. target.splice(key, 1, val);
  941. return val
  942. }
  943. if (key in target && !(key in Object.prototype)) {
  944. target[key] = val;
  945. return val
  946. }
  947. var ob = (target).__ob__;
  948. if (target._isVue || (ob && ob.vmCount)) {
  949. warn(
  950. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  951. 'at runtime - declare it upfront in the data option.'
  952. );
  953. return val
  954. }
  955. if (!ob) {
  956. target[key] = val;
  957. return val
  958. }
  959. defineReactive$$1(ob.value, key, val);
  960. ob.dep.notify();
  961. return val
  962. }
  963. /**
  964. * Delete a property and trigger change if necessary.
  965. */
  966. function del (target, key) {
  967. if (isUndef(target) || isPrimitive(target)
  968. ) {
  969. warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
  970. }
  971. if (Array.isArray(target) && isValidArrayIndex(key)) {
  972. target.splice(key, 1);
  973. return
  974. }
  975. var ob = (target).__ob__;
  976. if (target._isVue || (ob && ob.vmCount)) {
  977. warn(
  978. 'Avoid deleting properties on a Vue instance or its root $data ' +
  979. '- just set it to null.'
  980. );
  981. return
  982. }
  983. if (!hasOwn(target, key)) {
  984. return
  985. }
  986. delete target[key];
  987. if (!ob) {
  988. return
  989. }
  990. ob.dep.notify();
  991. }
  992. /**
  993. * Collect dependencies on array elements when the array is touched, since
  994. * we cannot intercept array element access like property getters.
  995. */
  996. function dependArray (value) {
  997. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  998. e = value[i];
  999. e && e.__ob__ && e.__ob__.dep.depend();
  1000. if (Array.isArray(e)) {
  1001. dependArray(e);
  1002. }
  1003. }
  1004. }
  1005. /* */
  1006. /**
  1007. * Option overwriting strategies are functions that handle
  1008. * how to merge a parent option value and a child option
  1009. * value into the final value.
  1010. */
  1011. var strats = config.optionMergeStrategies;
  1012. /**
  1013. * Options with restrictions
  1014. */
  1015. {
  1016. strats.el = strats.propsData = function (parent, child, vm, key) {
  1017. if (!vm) {
  1018. warn(
  1019. "option \"" + key + "\" can only be used during instance " +
  1020. 'creation with the `new` keyword.'
  1021. );
  1022. }
  1023. return defaultStrat(parent, child)
  1024. };
  1025. }
  1026. /**
  1027. * Helper that recursively merges two data objects together.
  1028. */
  1029. function mergeData (to, from) {
  1030. if (!from) { return to }
  1031. var key, toVal, fromVal;
  1032. var keys = Object.keys(from);
  1033. for (var i = 0; i < keys.length; i++) {
  1034. key = keys[i];
  1035. toVal = to[key];
  1036. fromVal = from[key];
  1037. if (!hasOwn(to, key)) {
  1038. set(to, key, fromVal);
  1039. } else if (
  1040. toVal !== fromVal &&
  1041. isPlainObject(toVal) &&
  1042. isPlainObject(fromVal)
  1043. ) {
  1044. mergeData(toVal, fromVal);
  1045. }
  1046. }
  1047. return to
  1048. }
  1049. /**
  1050. * Data
  1051. */
  1052. function mergeDataOrFn (
  1053. parentVal,
  1054. childVal,
  1055. vm
  1056. ) {
  1057. if (!vm) {
  1058. // in a Vue.extend merge, both should be functions
  1059. if (!childVal) {
  1060. return parentVal
  1061. }
  1062. if (!parentVal) {
  1063. return childVal
  1064. }
  1065. // when parentVal & childVal are both present,
  1066. // we need to return a function that returns the
  1067. // merged result of both functions... no need to
  1068. // check if parentVal is a function here because
  1069. // it has to be a function to pass previous merges.
  1070. return function mergedDataFn () {
  1071. return mergeData(
  1072. typeof childVal === 'function' ? childVal.call(this, this) : childVal,
  1073. typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
  1074. )
  1075. }
  1076. } else {
  1077. return function mergedInstanceDataFn () {
  1078. // instance merge
  1079. var instanceData = typeof childVal === 'function'
  1080. ? childVal.call(vm, vm)
  1081. : childVal;
  1082. var defaultData = typeof parentVal === 'function'
  1083. ? parentVal.call(vm, vm)
  1084. : parentVal;
  1085. if (instanceData) {
  1086. return mergeData(instanceData, defaultData)
  1087. } else {
  1088. return defaultData
  1089. }
  1090. }
  1091. }
  1092. }
  1093. strats.data = function (
  1094. parentVal,
  1095. childVal,
  1096. vm
  1097. ) {
  1098. if (!vm) {
  1099. if (childVal && typeof childVal !== 'function') {
  1100. warn(
  1101. 'The "data" option should be a function ' +
  1102. 'that returns a per-instance value in component ' +
  1103. 'definitions.',
  1104. vm
  1105. );
  1106. return parentVal
  1107. }
  1108. return mergeDataOrFn(parentVal, childVal)
  1109. }
  1110. return mergeDataOrFn(parentVal, childVal, vm)
  1111. };
  1112. /**
  1113. * Hooks and props are merged as arrays.
  1114. */
  1115. function mergeHook (
  1116. parentVal,
  1117. childVal
  1118. ) {
  1119. return childVal
  1120. ? parentVal
  1121. ? parentVal.concat(childVal)
  1122. : Array.isArray(childVal)
  1123. ? childVal
  1124. : [childVal]
  1125. : parentVal
  1126. }
  1127. LIFECYCLE_HOOKS.forEach(function (hook) {
  1128. strats[hook] = mergeHook;
  1129. });
  1130. /**
  1131. * Assets
  1132. *
  1133. * When a vm is present (instance creation), we need to do
  1134. * a three-way merge between constructor options, instance
  1135. * options and parent options.
  1136. */
  1137. function mergeAssets (
  1138. parentVal,
  1139. childVal,
  1140. vm,
  1141. key
  1142. ) {
  1143. var res = Object.create(parentVal || null);
  1144. if (childVal) {
  1145. assertObjectType(key, childVal, vm);
  1146. return extend(res, childVal)
  1147. } else {
  1148. return res
  1149. }
  1150. }
  1151. ASSET_TYPES.forEach(function (type) {
  1152. strats[type + 's'] = mergeAssets;
  1153. });
  1154. /**
  1155. * Watchers.
  1156. *
  1157. * Watchers hashes should not overwrite one
  1158. * another, so we merge them as arrays.
  1159. */
  1160. strats.watch = function (
  1161. parentVal,
  1162. childVal,
  1163. vm,
  1164. key
  1165. ) {
  1166. // work around Firefox's Object.prototype.watch...
  1167. if (parentVal === nativeWatch) { parentVal = undefined; }
  1168. if (childVal === nativeWatch) { childVal = undefined; }
  1169. /* istanbul ignore if */
  1170. if (!childVal) { return Object.create(parentVal || null) }
  1171. {
  1172. assertObjectType(key, childVal, vm);
  1173. }
  1174. if (!parentVal) { return childVal }
  1175. var ret = {};
  1176. extend(ret, parentVal);
  1177. for (var key$1 in childVal) {
  1178. var parent = ret[key$1];
  1179. var child = childVal[key$1];
  1180. if (parent && !Array.isArray(parent)) {
  1181. parent = [parent];
  1182. }
  1183. ret[key$1] = parent
  1184. ? parent.concat(child)
  1185. : Array.isArray(child) ? child : [child];
  1186. }
  1187. return ret
  1188. };
  1189. /**
  1190. * Other object hashes.
  1191. */
  1192. strats.props =
  1193. strats.methods =
  1194. strats.inject =
  1195. strats.computed = function (
  1196. parentVal,
  1197. childVal,
  1198. vm,
  1199. key
  1200. ) {
  1201. if (childVal && "development" !== 'production') {
  1202. assertObjectType(key, childVal, vm);
  1203. }
  1204. if (!parentVal) { return childVal }
  1205. var ret = Object.create(null);
  1206. extend(ret, parentVal);
  1207. if (childVal) { extend(ret, childVal); }
  1208. return ret
  1209. };
  1210. strats.provide = mergeDataOrFn;
  1211. /**
  1212. * Default strategy.
  1213. */
  1214. var defaultStrat = function (parentVal, childVal) {
  1215. return childVal === undefined
  1216. ? parentVal
  1217. : childVal
  1218. };
  1219. /**
  1220. * Validate component names
  1221. */
  1222. function checkComponents (options) {
  1223. for (var key in options.components) {
  1224. validateComponentName(key);
  1225. }
  1226. }
  1227. function validateComponentName (name) {
  1228. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  1229. warn(
  1230. 'Invalid component name: "' + name + '". Component names ' +
  1231. 'can only contain alphanumeric characters and the hyphen, ' +
  1232. 'and must start with a letter.'
  1233. );
  1234. }
  1235. if (isBuiltInTag(name) || config.isReservedTag(name)) {
  1236. warn(
  1237. 'Do not use built-in or reserved HTML elements as component ' +
  1238. 'id: ' + name
  1239. );
  1240. }
  1241. }
  1242. /**
  1243. * Ensure all props option syntax are normalized into the
  1244. * Object-based format.
  1245. */
  1246. function normalizeProps (options, vm) {
  1247. var props = options.props;
  1248. if (!props) { return }
  1249. var res = {};
  1250. var i, val, name;
  1251. if (Array.isArray(props)) {
  1252. i = props.length;
  1253. while (i--) {
  1254. val = props[i];
  1255. if (typeof val === 'string') {
  1256. name = camelize(val);
  1257. res[name] = { type: null };
  1258. } else {
  1259. warn('props must be strings when using array syntax.');
  1260. }
  1261. }
  1262. } else if (isPlainObject(props)) {
  1263. for (var key in props) {
  1264. val = props[key];
  1265. name = camelize(key);
  1266. res[name] = isPlainObject(val)
  1267. ? val
  1268. : { type: val };
  1269. }
  1270. } else {
  1271. warn(
  1272. "Invalid value for option \"props\": expected an Array or an Object, " +
  1273. "but got " + (toRawType(props)) + ".",
  1274. vm
  1275. );
  1276. }
  1277. options.props = res;
  1278. }
  1279. /**
  1280. * Normalize all injections into Object-based format
  1281. */
  1282. function normalizeInject (options, vm) {
  1283. var inject = options.inject;
  1284. if (!inject) { return }
  1285. var normalized = options.inject = {};
  1286. if (Array.isArray(inject)) {
  1287. for (var i = 0; i < inject.length; i++) {
  1288. normalized[inject[i]] = { from: inject[i] };
  1289. }
  1290. } else if (isPlainObject(inject)) {
  1291. for (var key in inject) {
  1292. var val = inject[key];
  1293. normalized[key] = isPlainObject(val)
  1294. ? extend({ from: key }, val)
  1295. : { from: val };
  1296. }
  1297. } else {
  1298. warn(
  1299. "Invalid value for option \"inject\": expected an Array or an Object, " +
  1300. "but got " + (toRawType(inject)) + ".",
  1301. vm
  1302. );
  1303. }
  1304. }
  1305. /**
  1306. * Normalize raw function directives into object format.
  1307. */
  1308. function normalizeDirectives (options) {
  1309. var dirs = options.directives;
  1310. if (dirs) {
  1311. for (var key in dirs) {
  1312. var def = dirs[key];
  1313. if (typeof def === 'function') {
  1314. dirs[key] = { bind: def, update: def };
  1315. }
  1316. }
  1317. }
  1318. }
  1319. function assertObjectType (name, value, vm) {
  1320. if (!isPlainObject(value)) {
  1321. warn(
  1322. "Invalid value for option \"" + name + "\": expected an Object, " +
  1323. "but got " + (toRawType(value)) + ".",
  1324. vm
  1325. );
  1326. }
  1327. }
  1328. /**
  1329. * Merge two option objects into a new one.
  1330. * Core utility used in both instantiation and inheritance.
  1331. */
  1332. function mergeOptions (
  1333. parent,
  1334. child,
  1335. vm
  1336. ) {
  1337. {
  1338. checkComponents(child);
  1339. }
  1340. if (typeof child === 'function') {
  1341. child = child.options;
  1342. }
  1343. normalizeProps(child, vm);
  1344. normalizeInject(child, vm);
  1345. normalizeDirectives(child);
  1346. // Apply extends and mixins on the child options,
  1347. // but only if it is a raw options object that isn't
  1348. // the result of another mergeOptions call.
  1349. // Only merged options has the _base property.
  1350. if (!child._base) {
  1351. if (child.extends) {
  1352. parent = mergeOptions(parent, child.extends, vm);
  1353. }
  1354. if (child.mixins) {
  1355. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1356. parent = mergeOptions(parent, child.mixins[i], vm);
  1357. }
  1358. }
  1359. }
  1360. var options = {};
  1361. var key;
  1362. for (key in parent) {
  1363. mergeField(key);
  1364. }
  1365. for (key in child) {
  1366. if (!hasOwn(parent, key)) {
  1367. mergeField(key);
  1368. }
  1369. }
  1370. function mergeField (key) {
  1371. var strat = strats[key] || defaultStrat;
  1372. options[key] = strat(parent[key], child[key], vm, key);
  1373. }
  1374. return options
  1375. }
  1376. /**
  1377. * Resolve an asset.
  1378. * This function is used because child instances need access
  1379. * to assets defined in its ancestor chain.
  1380. */
  1381. function resolveAsset (
  1382. options,
  1383. type,
  1384. id,
  1385. warnMissing
  1386. ) {
  1387. /* istanbul ignore if */
  1388. if (typeof id !== 'string') {
  1389. return
  1390. }
  1391. var assets = options[type];
  1392. // check local registration variations first
  1393. if (hasOwn(assets, id)) { return assets[id] }
  1394. var camelizedId = camelize(id);
  1395. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  1396. var PascalCaseId = capitalize(camelizedId);
  1397. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  1398. // fallback to prototype chain
  1399. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1400. if (warnMissing && !res) {
  1401. warn(
  1402. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1403. options
  1404. );
  1405. }
  1406. return res
  1407. }
  1408. /* */
  1409. function validateProp (
  1410. key,
  1411. propOptions,
  1412. propsData,
  1413. vm
  1414. ) {
  1415. var prop = propOptions[key];
  1416. var absent = !hasOwn(propsData, key);
  1417. var value = propsData[key];
  1418. // boolean casting
  1419. var booleanIndex = getTypeIndex(Boolean, prop.type);
  1420. if (booleanIndex > -1) {
  1421. if (absent && !hasOwn(prop, 'default')) {
  1422. value = false;
  1423. } else if (value === '' || value === hyphenate(key)) {
  1424. // only cast empty string / same name to boolean if
  1425. // boolean has higher priority
  1426. var stringIndex = getTypeIndex(String, prop.type);
  1427. if (stringIndex < 0 || booleanIndex < stringIndex) {
  1428. value = true;
  1429. }
  1430. }
  1431. }
  1432. // check default value
  1433. if (value === undefined) {
  1434. value = getPropDefaultValue(vm, prop, key);
  1435. // since the default value is a fresh copy,
  1436. // make sure to observe it.
  1437. var prevShouldObserve = shouldObserve;
  1438. toggleObserving(true);
  1439. observe(value);
  1440. toggleObserving(prevShouldObserve);
  1441. }
  1442. {
  1443. assertProp(prop, key, value, vm, absent);
  1444. }
  1445. return value
  1446. }
  1447. /**
  1448. * Get the default value of a prop.
  1449. */
  1450. function getPropDefaultValue (vm, prop, key) {
  1451. // no default, return undefined
  1452. if (!hasOwn(prop, 'default')) {
  1453. return undefined
  1454. }
  1455. var def = prop.default;
  1456. // warn against non-factory defaults for Object & Array
  1457. if (isObject(def)) {
  1458. warn(
  1459. 'Invalid default value for prop "' + key + '": ' +
  1460. 'Props with type Object/Array must use a factory function ' +
  1461. 'to return the default value.',
  1462. vm
  1463. );
  1464. }
  1465. // the raw prop value was also undefined from previous render,
  1466. // return previous default value to avoid unnecessary watcher trigger
  1467. if (vm && vm.$options.propsData &&
  1468. vm.$options.propsData[key] === undefined &&
  1469. vm._props[key] !== undefined
  1470. ) {
  1471. return vm._props[key]
  1472. }
  1473. // call factory function for non-Function types
  1474. // a value is Function if its prototype is function even across different execution context
  1475. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1476. ? def.call(vm)
  1477. : def
  1478. }
  1479. /**
  1480. * Assert whether a prop is valid.
  1481. */
  1482. function assertProp (
  1483. prop,
  1484. name,
  1485. value,
  1486. vm,
  1487. absent
  1488. ) {
  1489. if (prop.required && absent) {
  1490. warn(
  1491. 'Missing required prop: "' + name + '"',
  1492. vm
  1493. );
  1494. return
  1495. }
  1496. if (value == null && !prop.required) {
  1497. return
  1498. }
  1499. var type = prop.type;
  1500. var valid = !type || type === true;
  1501. var expectedTypes = [];
  1502. if (type) {
  1503. if (!Array.isArray(type)) {
  1504. type = [type];
  1505. }
  1506. for (var i = 0; i < type.length && !valid; i++) {
  1507. var assertedType = assertType(value, type[i]);
  1508. expectedTypes.push(assertedType.expectedType || '');
  1509. valid = assertedType.valid;
  1510. }
  1511. }
  1512. if (!valid) {
  1513. warn(
  1514. getInvalidTypeMessage(name, value, expectedTypes),
  1515. vm
  1516. );
  1517. return
  1518. }
  1519. var validator = prop.validator;
  1520. if (validator) {
  1521. if (!validator(value)) {
  1522. warn(
  1523. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1524. vm
  1525. );
  1526. }
  1527. }
  1528. }
  1529. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  1530. function assertType (value, type) {
  1531. var valid;
  1532. var expectedType = getType(type);
  1533. if (simpleCheckRE.test(expectedType)) {
  1534. var t = typeof value;
  1535. valid = t === expectedType.toLowerCase();
  1536. // for primitive wrapper objects
  1537. if (!valid && t === 'object') {
  1538. valid = value instanceof type;
  1539. }
  1540. } else if (expectedType === 'Object') {
  1541. valid = isPlainObject(value);
  1542. } else if (expectedType === 'Array') {
  1543. valid = Array.isArray(value);
  1544. } else {
  1545. valid = value instanceof type;
  1546. }
  1547. return {
  1548. valid: valid,
  1549. expectedType: expectedType
  1550. }
  1551. }
  1552. /**
  1553. * Use function string name to check built-in types,
  1554. * because a simple equality check will fail when running
  1555. * across different vms / iframes.
  1556. */
  1557. function getType (fn) {
  1558. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  1559. return match ? match[1] : ''
  1560. }
  1561. function isSameType (a, b) {
  1562. return getType(a) === getType(b)
  1563. }
  1564. function getTypeIndex (type, expectedTypes) {
  1565. if (!Array.isArray(expectedTypes)) {
  1566. return isSameType(expectedTypes, type) ? 0 : -1
  1567. }
  1568. for (var i = 0, len = expectedTypes.length; i < len; i++) {
  1569. if (isSameType(expectedTypes[i], type)) {
  1570. return i
  1571. }
  1572. }
  1573. return -1
  1574. }
  1575. function getInvalidTypeMessage (name, value, expectedTypes) {
  1576. var message = "Invalid prop: type check failed for prop \"" + name + "\"." +
  1577. " Expected " + (expectedTypes.map(capitalize).join(', '));
  1578. var expectedType = expectedTypes[0];
  1579. var receivedType = toRawType(value);
  1580. var expectedValue = styleValue(value, expectedType);
  1581. var receivedValue = styleValue(value, receivedType);
  1582. // check if we need to specify expected value
  1583. if (expectedTypes.length === 1 &&
  1584. isExplicable(expectedType) &&
  1585. !isBoolean(expectedType, receivedType)) {
  1586. message += " with value " + expectedValue;
  1587. }
  1588. message += ", got " + receivedType + " ";
  1589. // check if we need to specify received value
  1590. if (isExplicable(receivedType)) {
  1591. message += "with value " + receivedValue + ".";
  1592. }
  1593. return message
  1594. }
  1595. function styleValue (value, type) {
  1596. if (type === 'String') {
  1597. return ("\"" + value + "\"")
  1598. } else if (type === 'Number') {
  1599. return ("" + (Number(value)))
  1600. } else {
  1601. return ("" + value)
  1602. }
  1603. }
  1604. function isExplicable (value) {
  1605. var explicitTypes = ['string', 'number', 'boolean'];
  1606. return explicitTypes.some(function (elem) { return value.toLowerCase() === elem; })
  1607. }
  1608. function isBoolean () {
  1609. var args = [], len = arguments.length;
  1610. while ( len-- ) args[ len ] = arguments[ len ];
  1611. return args.some(function (elem) { return elem.toLowerCase() === 'boolean'; })
  1612. }
  1613. /* */
  1614. function handleError (err, vm, info) {
  1615. if (vm) {
  1616. var cur = vm;
  1617. while ((cur = cur.$parent)) {
  1618. var hooks = cur.$options.errorCaptured;
  1619. if (hooks) {
  1620. for (var i = 0; i < hooks.length; i++) {
  1621. try {
  1622. var capture = hooks[i].call(cur, err, vm, info) === false;
  1623. if (capture) { return }
  1624. } catch (e) {
  1625. globalHandleError(e, cur, 'errorCaptured hook');
  1626. }
  1627. }
  1628. }
  1629. }
  1630. }
  1631. globalHandleError(err, vm, info);
  1632. }
  1633. function globalHandleError (err, vm, info) {
  1634. if (config.errorHandler) {
  1635. try {
  1636. return config.errorHandler.call(null, err, vm, info)
  1637. } catch (e) {
  1638. logError(e, null, 'config.errorHandler');
  1639. }
  1640. }
  1641. logError(err, vm, info);
  1642. }
  1643. function logError (err, vm, info) {
  1644. {
  1645. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  1646. }
  1647. /* istanbul ignore else */
  1648. if ((inBrowser || inWeex) && typeof console !== 'undefined') {
  1649. console.error(err);
  1650. } else {
  1651. throw err
  1652. }
  1653. }
  1654. /* */
  1655. var callbacks = [];
  1656. var pending = false;
  1657. function flushCallbacks () {
  1658. pending = false;
  1659. var copies = callbacks.slice(0);
  1660. callbacks.length = 0;
  1661. for (var i = 0; i < copies.length; i++) {
  1662. copies[i]();
  1663. }
  1664. }
  1665. // Here we have async deferring wrappers using both microtasks and (macro) tasks.
  1666. // In < 2.4 we used microtasks everywhere, but there are some scenarios where
  1667. // microtasks have too high a priority and fire in between supposedly
  1668. // sequential events (e.g. #4521, #6690) or even between bubbling of the same
  1669. // event (#6566). However, using (macro) tasks everywhere also has subtle problems
  1670. // when state is changed right before repaint (e.g. #6813, out-in transitions).
  1671. // Here we use microtask by default, but expose a way to force (macro) task when
  1672. // needed (e.g. in event handlers attached by v-on).
  1673. var microTimerFunc;
  1674. var macroTimerFunc;
  1675. var useMacroTask = false;
  1676. // Determine (macro) task defer implementation.
  1677. // Technically setImmediate should be the ideal choice, but it's only available
  1678. // in IE. The only polyfill that consistently queues the callback after all DOM
  1679. // events triggered in the same loop is by using MessageChannel.
  1680. /* istanbul ignore if */
  1681. if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  1682. macroTimerFunc = function () {
  1683. setImmediate(flushCallbacks);
  1684. };
  1685. } else if (typeof MessageChannel !== 'undefined' && (
  1686. isNative(MessageChannel) ||
  1687. // PhantomJS
  1688. MessageChannel.toString() === '[object MessageChannelConstructor]'
  1689. )) {
  1690. var channel = new MessageChannel();
  1691. var port = channel.port2;
  1692. channel.port1.onmessage = flushCallbacks;
  1693. macroTimerFunc = function () {
  1694. port.postMessage(1);
  1695. };
  1696. } else {
  1697. /* istanbul ignore next */
  1698. macroTimerFunc = function () {
  1699. setTimeout(flushCallbacks, 0);
  1700. };
  1701. }
  1702. // Determine microtask defer implementation.
  1703. /* istanbul ignore next, $flow-disable-line */
  1704. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  1705. var p = Promise.resolve();
  1706. microTimerFunc = function () {
  1707. p.then(flushCallbacks);
  1708. // in problematic UIWebViews, Promise.then doesn't completely break, but
  1709. // it can get stuck in a weird state where callbacks are pushed into the
  1710. // microtask queue but the queue isn't being flushed, until the browser
  1711. // needs to do some other work, e.g. handle a timer. Therefore we can
  1712. // "force" the microtask queue to be flushed by adding an empty timer.
  1713. if (isIOS) { setTimeout(noop); }
  1714. };
  1715. } else {
  1716. // fallback to macro
  1717. microTimerFunc = macroTimerFunc;
  1718. }
  1719. /**
  1720. * Wrap a function so that if any code inside triggers state change,
  1721. * the changes are queued using a (macro) task instead of a microtask.
  1722. */
  1723. function withMacroTask (fn) {
  1724. return fn._withTask || (fn._withTask = function () {
  1725. useMacroTask = true;
  1726. try {
  1727. return fn.apply(null, arguments)
  1728. } finally {
  1729. useMacroTask = false;
  1730. }
  1731. })
  1732. }
  1733. function nextTick (cb, ctx) {
  1734. var _resolve;
  1735. callbacks.push(function () {
  1736. if (cb) {
  1737. try {
  1738. cb.call(ctx);
  1739. } catch (e) {
  1740. handleError(e, ctx, 'nextTick');
  1741. }
  1742. } else if (_resolve) {
  1743. _resolve(ctx);
  1744. }
  1745. });
  1746. if (!pending) {
  1747. pending = true;
  1748. if (useMacroTask) {
  1749. macroTimerFunc();
  1750. } else {
  1751. microTimerFunc();
  1752. }
  1753. }
  1754. // $flow-disable-line
  1755. if (!cb && typeof Promise !== 'undefined') {
  1756. return new Promise(function (resolve) {
  1757. _resolve = resolve;
  1758. })
  1759. }
  1760. }
  1761. /* */
  1762. var mark;
  1763. var measure;
  1764. {
  1765. var perf = inBrowser && window.performance;
  1766. /* istanbul ignore if */
  1767. if (
  1768. perf &&
  1769. perf.mark &&
  1770. perf.measure &&
  1771. perf.clearMarks &&
  1772. perf.clearMeasures
  1773. ) {
  1774. mark = function (tag) { return perf.mark(tag); };
  1775. measure = function (name, startTag, endTag) {
  1776. perf.measure(name, startTag, endTag);
  1777. perf.clearMarks(startTag);
  1778. perf.clearMarks(endTag);
  1779. perf.clearMeasures(name);
  1780. };
  1781. }
  1782. }
  1783. /* not type checking this file because flow doesn't play well with Proxy */
  1784. var initProxy;
  1785. {
  1786. var allowedGlobals = makeMap(
  1787. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  1788. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  1789. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  1790. 'require' // for Webpack/Browserify
  1791. );
  1792. var warnNonPresent = function (target, key) {
  1793. warn(
  1794. "Property or method \"" + key + "\" is not defined on the instance but " +
  1795. 'referenced during render. Make sure that this property is reactive, ' +
  1796. 'either in the data option, or for class-based components, by ' +
  1797. 'initializing the property. ' +
  1798. 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
  1799. target
  1800. );
  1801. };
  1802. var warnReservedPrefix = function (target, key) {
  1803. warn(
  1804. "Property \"" + key + "\" must be accessed with \"$data." + key + "\" because " +
  1805. 'properties starting with "$" or "_" are not proxied in the Vue instance to ' +
  1806. 'prevent conflicts with Vue internals' +
  1807. 'See: https://vuejs.org/v2/api/#data',
  1808. target
  1809. );
  1810. };
  1811. var hasProxy =
  1812. typeof Proxy !== 'undefined' && isNative(Proxy);
  1813. if (hasProxy) {
  1814. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
  1815. config.keyCodes = new Proxy(config.keyCodes, {
  1816. set: function set (target, key, value) {
  1817. if (isBuiltInModifier(key)) {
  1818. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  1819. return false
  1820. } else {
  1821. target[key] = value;
  1822. return true
  1823. }
  1824. }
  1825. });
  1826. }
  1827. var hasHandler = {
  1828. has: function has (target, key) {
  1829. var has = key in target;
  1830. var isAllowed = allowedGlobals(key) ||
  1831. (typeof key === 'string' && key.charAt(0) === '_' && !(key in target.$data));
  1832. if (!has && !isAllowed) {
  1833. if (key in target.$data) { warnReservedPrefix(target, key); }
  1834. else { warnNonPresent(target, key); }
  1835. }
  1836. return has || !isAllowed
  1837. }
  1838. };
  1839. var getHandler = {
  1840. get: function get (target, key) {
  1841. if (typeof key === 'string' && !(key in target)) {
  1842. if (key in target.$data) { warnReservedPrefix(target, key); }
  1843. else { warnNonPresent(target, key); }
  1844. }
  1845. return target[key]
  1846. }
  1847. };
  1848. initProxy = function initProxy (vm) {
  1849. if (hasProxy) {
  1850. // determine which proxy handler to use
  1851. var options = vm.$options;
  1852. var handlers = options.render && options.render._withStripped
  1853. ? getHandler
  1854. : hasHandler;
  1855. vm._renderProxy = new Proxy(vm, handlers);
  1856. } else {
  1857. vm._renderProxy = vm;
  1858. }
  1859. };
  1860. }
  1861. /* */
  1862. var seenObjects = new _Set();
  1863. /**
  1864. * Recursively traverse an object to evoke all converted
  1865. * getters, so that every nested property inside the object
  1866. * is collected as a "deep" dependency.
  1867. */
  1868. function traverse (val) {
  1869. _traverse(val, seenObjects);
  1870. seenObjects.clear();
  1871. }
  1872. function _traverse (val, seen) {
  1873. var i, keys;
  1874. var isA = Array.isArray(val);
  1875. if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
  1876. return
  1877. }
  1878. if (val.__ob__) {
  1879. var depId = val.__ob__.dep.id;
  1880. if (seen.has(depId)) {
  1881. return
  1882. }
  1883. seen.add(depId);
  1884. }
  1885. if (isA) {
  1886. i = val.length;
  1887. while (i--) { _traverse(val[i], seen); }
  1888. } else {
  1889. keys = Object.keys(val);
  1890. i = keys.length;
  1891. while (i--) { _traverse(val[keys[i]], seen); }
  1892. }
  1893. }
  1894. /* */
  1895. var normalizeEvent = cached(function (name) {
  1896. var passive = name.charAt(0) === '&';
  1897. name = passive ? name.slice(1) : name;
  1898. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  1899. name = once$$1 ? name.slice(1) : name;
  1900. var capture = name.charAt(0) === '!';
  1901. name = capture ? name.slice(1) : name;
  1902. return {
  1903. name: name,
  1904. once: once$$1,
  1905. capture: capture,
  1906. passive: passive
  1907. }
  1908. });
  1909. function createFnInvoker (fns) {
  1910. function invoker () {
  1911. var arguments$1 = arguments;
  1912. var fns = invoker.fns;
  1913. if (Array.isArray(fns)) {
  1914. var cloned = fns.slice();
  1915. for (var i = 0; i < cloned.length; i++) {
  1916. cloned[i].apply(null, arguments$1);
  1917. }
  1918. } else {
  1919. // return handler return value for single handlers
  1920. return fns.apply(null, arguments)
  1921. }
  1922. }
  1923. invoker.fns = fns;
  1924. return invoker
  1925. }
  1926. function updateListeners (
  1927. on,
  1928. oldOn,
  1929. add,
  1930. remove$$1,
  1931. createOnceHandler,
  1932. vm
  1933. ) {
  1934. var name, def$$1, cur, old, event;
  1935. for (name in on) {
  1936. def$$1 = cur = on[name];
  1937. old = oldOn[name];
  1938. event = normalizeEvent(name);
  1939. if (isUndef(cur)) {
  1940. warn(
  1941. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  1942. vm
  1943. );
  1944. } else if (isUndef(old)) {
  1945. if (isUndef(cur.fns)) {
  1946. cur = on[name] = createFnInvoker(cur);
  1947. }
  1948. if (isTrue(event.once)) {
  1949. cur = on[name] = createOnceHandler(event.name, cur, event.capture);
  1950. }
  1951. add(event.name, cur, event.capture, event.passive, event.params);
  1952. } else if (cur !== old) {
  1953. old.fns = cur;
  1954. on[name] = old;
  1955. }
  1956. }
  1957. for (name in oldOn) {
  1958. if (isUndef(on[name])) {
  1959. event = normalizeEvent(name);
  1960. remove$$1(event.name, oldOn[name], event.capture);
  1961. }
  1962. }
  1963. }
  1964. /* */
  1965. function mergeVNodeHook (def, hookKey, hook) {
  1966. if (def instanceof VNode) {
  1967. def = def.data.hook || (def.data.hook = {});
  1968. }
  1969. var invoker;
  1970. var oldHook = def[hookKey];
  1971. function wrappedHook () {
  1972. hook.apply(this, arguments);
  1973. // important: remove merged hook to ensure it's called only once
  1974. // and prevent memory leak
  1975. remove(invoker.fns, wrappedHook);
  1976. }
  1977. if (isUndef(oldHook)) {
  1978. // no existing hook
  1979. invoker = createFnInvoker([wrappedHook]);
  1980. } else {
  1981. /* istanbul ignore if */
  1982. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1983. // already a merged invoker
  1984. invoker = oldHook;
  1985. invoker.fns.push(wrappedHook);
  1986. } else {
  1987. // existing plain hook
  1988. invoker = createFnInvoker([oldHook, wrappedHook]);
  1989. }
  1990. }
  1991. invoker.merged = true;
  1992. def[hookKey] = invoker;
  1993. }
  1994. /* */
  1995. function extractPropsFromVNodeData (
  1996. data,
  1997. Ctor,
  1998. tag
  1999. ) {
  2000. // we are only extracting raw values here.
  2001. // validation and default values are handled in the child
  2002. // component itself.
  2003. var propOptions = Ctor.options.props;
  2004. if (isUndef(propOptions)) {
  2005. return
  2006. }
  2007. var res = {};
  2008. var attrs = data.attrs;
  2009. var props = data.props;
  2010. if (isDef(attrs) || isDef(props)) {
  2011. for (var key in propOptions) {
  2012. var altKey = hyphenate(key);
  2013. {
  2014. var keyInLowerCase = key.toLowerCase();
  2015. if (
  2016. key !== keyInLowerCase &&
  2017. attrs && hasOwn(attrs, keyInLowerCase)
  2018. ) {
  2019. tip(
  2020. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  2021. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  2022. " \"" + key + "\". " +
  2023. "Note that HTML attributes are case-insensitive and camelCased " +
  2024. "props need to use their kebab-case equivalents when using in-DOM " +
  2025. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  2026. );
  2027. }
  2028. }
  2029. checkProp(res, props, key, altKey, true) ||
  2030. checkProp(res, attrs, key, altKey, false);
  2031. }
  2032. }
  2033. return res
  2034. }
  2035. function checkProp (
  2036. res,
  2037. hash,
  2038. key,
  2039. altKey,
  2040. preserve
  2041. ) {
  2042. if (isDef(hash)) {
  2043. if (hasOwn(hash, key)) {
  2044. res[key] = hash[key];
  2045. if (!preserve) {
  2046. delete hash[key];
  2047. }
  2048. return true
  2049. } else if (hasOwn(hash, altKey)) {
  2050. res[key] = hash[altKey];
  2051. if (!preserve) {
  2052. delete hash[altKey];
  2053. }
  2054. return true
  2055. }
  2056. }
  2057. return false
  2058. }
  2059. /* */
  2060. // The template compiler attempts to minimize the need for normalization by
  2061. // statically analyzing the template at compile time.
  2062. //
  2063. // For plain HTML markup, normalization can be completely skipped because the
  2064. // generated render function is guaranteed to return Array<VNode>. There are
  2065. // two cases where extra normalization is needed:
  2066. // 1. When the children contains components - because a functional component
  2067. // may return an Array instead of a single root. In this case, just a simple
  2068. // normalization is needed - if any child is an Array, we flatten the whole
  2069. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  2070. // because functional components already normalize their own children.
  2071. function simpleNormalizeChildren (children) {
  2072. for (var i = 0; i < children.length; i++) {
  2073. if (Array.isArray(children[i])) {
  2074. return Array.prototype.concat.apply([], children)
  2075. }
  2076. }
  2077. return children
  2078. }
  2079. // 2. When the children contains constructs that always generated nested Arrays,
  2080. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  2081. // with hand-written render functions / JSX. In such cases a full normalization
  2082. // is needed to cater to all possible types of children values.
  2083. function normalizeChildren (children) {
  2084. return isPrimitive(children)
  2085. ? [createTextVNode(children)]
  2086. : Array.isArray(children)
  2087. ? normalizeArrayChildren(children)
  2088. : undefined
  2089. }
  2090. function isTextNode (node) {
  2091. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  2092. }
  2093. function normalizeArrayChildren (children, nestedIndex) {
  2094. var res = [];
  2095. var i, c, lastIndex, last;
  2096. for (i = 0; i < children.length; i++) {
  2097. c = children[i];
  2098. if (isUndef(c) || typeof c === 'boolean') { continue }
  2099. lastIndex = res.length - 1;
  2100. last = res[lastIndex];
  2101. // nested
  2102. if (Array.isArray(c)) {
  2103. if (c.length > 0) {
  2104. c = normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i));
  2105. // merge adjacent text nodes
  2106. if (isTextNode(c[0]) && isTextNode(last)) {
  2107. res[lastIndex] = createTextVNode(last.text + (c[0]).text);
  2108. c.shift();
  2109. }
  2110. res.push.apply(res, c);
  2111. }
  2112. } else if (isPrimitive(c)) {
  2113. if (isTextNode(last)) {
  2114. // merge adjacent text nodes
  2115. // this is necessary for SSR hydration because text nodes are
  2116. // essentially merged when rendered to HTML strings
  2117. res[lastIndex] = createTextVNode(last.text + c);
  2118. } else if (c !== '') {
  2119. // convert primitive to vnode
  2120. res.push(createTextVNode(c));
  2121. }
  2122. } else {
  2123. if (isTextNode(c) && isTextNode(last)) {
  2124. // merge adjacent text nodes
  2125. res[lastIndex] = createTextVNode(last.text + c.text);
  2126. } else {
  2127. // default key for nested array children (likely generated by v-for)
  2128. if (isTrue(children._isVList) &&
  2129. isDef(c.tag) &&
  2130. isUndef(c.key) &&
  2131. isDef(nestedIndex)) {
  2132. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  2133. }
  2134. res.push(c);
  2135. }
  2136. }
  2137. }
  2138. return res
  2139. }
  2140. /* */
  2141. function ensureCtor (comp, base) {
  2142. if (
  2143. comp.__esModule ||
  2144. (hasSymbol && comp[Symbol.toStringTag] === 'Module')
  2145. ) {
  2146. comp = comp.default;
  2147. }
  2148. return isObject(comp)
  2149. ? base.extend(comp)
  2150. : comp
  2151. }
  2152. function createAsyncPlaceholder (
  2153. factory,
  2154. data,
  2155. context,
  2156. children,
  2157. tag
  2158. ) {
  2159. var node = createEmptyVNode();
  2160. node.asyncFactory = factory;
  2161. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  2162. return node
  2163. }
  2164. function resolveAsyncComponent (
  2165. factory,
  2166. baseCtor,
  2167. context
  2168. ) {
  2169. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  2170. return factory.errorComp
  2171. }
  2172. if (isDef(factory.resolved)) {
  2173. return factory.resolved
  2174. }
  2175. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  2176. return factory.loadingComp
  2177. }
  2178. if (isDef(factory.contexts)) {
  2179. // already pending
  2180. factory.contexts.push(context);
  2181. } else {
  2182. var contexts = factory.contexts = [context];
  2183. var sync = true;
  2184. var forceRender = function (renderCompleted) {
  2185. for (var i = 0, l = contexts.length; i < l; i++) {
  2186. contexts[i].$forceUpdate();
  2187. }
  2188. if (renderCompleted) {
  2189. contexts.length = 0;
  2190. }
  2191. };
  2192. var resolve = once(function (res) {
  2193. // cache resolved
  2194. factory.resolved = ensureCtor(res, baseCtor);
  2195. // invoke callbacks only if this is not a synchronous resolve
  2196. // (async resolves are shimmed as synchronous during SSR)
  2197. if (!sync) {
  2198. forceRender(true);
  2199. }
  2200. });
  2201. var reject = once(function (reason) {
  2202. warn(
  2203. "Failed to resolve async component: " + (String(factory)) +
  2204. (reason ? ("\nReason: " + reason) : '')
  2205. );
  2206. if (isDef(factory.errorComp)) {
  2207. factory.error = true;
  2208. forceRender(true);
  2209. }
  2210. });
  2211. var res = factory(resolve, reject);
  2212. if (isObject(res)) {
  2213. if (typeof res.then === 'function') {
  2214. // () => Promise
  2215. if (isUndef(factory.resolved)) {
  2216. res.then(resolve, reject);
  2217. }
  2218. } else if (isDef(res.component) && typeof res.component.then === 'function') {
  2219. res.component.then(resolve, reject);
  2220. if (isDef(res.error)) {
  2221. factory.errorComp = ensureCtor(res.error, baseCtor);
  2222. }
  2223. if (isDef(res.loading)) {
  2224. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  2225. if (res.delay === 0) {
  2226. factory.loading = true;
  2227. } else {
  2228. setTimeout(function () {
  2229. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  2230. factory.loading = true;
  2231. forceRender(false);
  2232. }
  2233. }, res.delay || 200);
  2234. }
  2235. }
  2236. if (isDef(res.timeout)) {
  2237. setTimeout(function () {
  2238. if (isUndef(factory.resolved)) {
  2239. reject(
  2240. "timeout (" + (res.timeout) + "ms)"
  2241. );
  2242. }
  2243. }, res.timeout);
  2244. }
  2245. }
  2246. }
  2247. sync = false;
  2248. // return in case resolved synchronously
  2249. return factory.loading
  2250. ? factory.loadingComp
  2251. : factory.resolved
  2252. }
  2253. }
  2254. /* */
  2255. function isAsyncPlaceholder (node) {
  2256. return node.isComment && node.asyncFactory
  2257. }
  2258. /* */
  2259. function getFirstComponentChild (children) {
  2260. if (Array.isArray(children)) {
  2261. for (var i = 0; i < children.length; i++) {
  2262. var c = children[i];
  2263. if (isDef(c) && (isDef(c.componentOptions) || isAsyncPlaceholder(c))) {
  2264. return c
  2265. }
  2266. }
  2267. }
  2268. }
  2269. /* */
  2270. /* */
  2271. function initEvents (vm) {
  2272. vm._events = Object.create(null);
  2273. vm._hasHookEvent = false;
  2274. // init parent attached events
  2275. var listeners = vm.$options._parentListeners;
  2276. if (listeners) {
  2277. updateComponentListeners(vm, listeners);
  2278. }
  2279. }
  2280. var target;
  2281. function add (event, fn) {
  2282. target.$on(event, fn);
  2283. }
  2284. function remove$1 (event, fn) {
  2285. target.$off(event, fn);
  2286. }
  2287. function createOnceHandler (event, fn) {
  2288. var _target = target;
  2289. return function onceHandler () {
  2290. var res = fn.apply(null, arguments);
  2291. if (res !== null) {
  2292. _target.$off(event, onceHandler);
  2293. }
  2294. }
  2295. }
  2296. function updateComponentListeners (
  2297. vm,
  2298. listeners,
  2299. oldListeners
  2300. ) {
  2301. target = vm;
  2302. updateListeners(listeners, oldListeners || {}, add, remove$1, createOnceHandler, vm);
  2303. target = undefined;
  2304. }
  2305. function eventsMixin (Vue) {
  2306. var hookRE = /^hook:/;
  2307. Vue.prototype.$on = function (event, fn) {
  2308. var vm = this;
  2309. if (Array.isArray(event)) {
  2310. for (var i = 0, l = event.length; i < l; i++) {
  2311. vm.$on(event[i], fn);
  2312. }
  2313. } else {
  2314. (vm._events[event] || (vm._events[event] = [])).push(fn);
  2315. // optimize hook:event cost by using a boolean flag marked at registration
  2316. // instead of a hash lookup
  2317. if (hookRE.test(event)) {
  2318. vm._hasHookEvent = true;
  2319. }
  2320. }
  2321. return vm
  2322. };
  2323. Vue.prototype.$once = function (event, fn) {
  2324. var vm = this;
  2325. function on () {
  2326. vm.$off(event, on);
  2327. fn.apply(vm, arguments);
  2328. }
  2329. on.fn = fn;
  2330. vm.$on(event, on);
  2331. return vm
  2332. };
  2333. Vue.prototype.$off = function (event, fn) {
  2334. var vm = this;
  2335. // all
  2336. if (!arguments.length) {
  2337. vm._events = Object.create(null);
  2338. return vm
  2339. }
  2340. // array of events
  2341. if (Array.isArray(event)) {
  2342. for (var i = 0, l = event.length; i < l; i++) {
  2343. vm.$off(event[i], fn);
  2344. }
  2345. return vm
  2346. }
  2347. // specific event
  2348. var cbs = vm._events[event];
  2349. if (!cbs) {
  2350. return vm
  2351. }
  2352. if (!fn) {
  2353. vm._events[event] = null;
  2354. return vm
  2355. }
  2356. if (fn) {
  2357. // specific handler
  2358. var cb;
  2359. var i$1 = cbs.length;
  2360. while (i$1--) {
  2361. cb = cbs[i$1];
  2362. if (cb === fn || cb.fn === fn) {
  2363. cbs.splice(i$1, 1);
  2364. break
  2365. }
  2366. }
  2367. }
  2368. return vm
  2369. };
  2370. Vue.prototype.$emit = function (event) {
  2371. var vm = this;
  2372. {
  2373. var lowerCaseEvent = event.toLowerCase();
  2374. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2375. tip(
  2376. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  2377. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  2378. "Note that HTML attributes are case-insensitive and you cannot use " +
  2379. "v-on to listen to camelCase events when using in-DOM templates. " +
  2380. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  2381. );
  2382. }
  2383. }
  2384. var cbs = vm._events[event];
  2385. if (cbs) {
  2386. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2387. var args = toArray(arguments, 1);
  2388. for (var i = 0, l = cbs.length; i < l; i++) {
  2389. try {
  2390. cbs[i].apply(vm, args);
  2391. } catch (e) {
  2392. handleError(e, vm, ("event handler for \"" + event + "\""));
  2393. }
  2394. }
  2395. }
  2396. return vm
  2397. };
  2398. }
  2399. /* */
  2400. /**
  2401. * Runtime helper for resolving raw children VNodes into a slot object.
  2402. */
  2403. function resolveSlots (
  2404. children,
  2405. context
  2406. ) {
  2407. var slots = {};
  2408. if (!children) {
  2409. return slots
  2410. }
  2411. for (var i = 0, l = children.length; i < l; i++) {
  2412. var child = children[i];
  2413. var data = child.data;
  2414. // remove slot attribute if the node is resolved as a Vue slot node
  2415. if (data && data.attrs && data.attrs.slot) {
  2416. delete data.attrs.slot;
  2417. }
  2418. // named slots should only be respected if the vnode was rendered in the
  2419. // same context.
  2420. if ((child.context === context || child.fnContext === context) &&
  2421. data && data.slot != null
  2422. ) {
  2423. var name = data.slot;
  2424. var slot = (slots[name] || (slots[name] = []));
  2425. if (child.tag === 'template') {
  2426. slot.push.apply(slot, child.children || []);
  2427. } else {
  2428. slot.push(child);
  2429. }
  2430. } else {
  2431. (slots.default || (slots.default = [])).push(child);
  2432. }
  2433. }
  2434. // ignore slots that contains only whitespace
  2435. for (var name$1 in slots) {
  2436. if (slots[name$1].every(isWhitespace)) {
  2437. delete slots[name$1];
  2438. }
  2439. }
  2440. return slots
  2441. }
  2442. function isWhitespace (node) {
  2443. return (node.isComment && !node.asyncFactory) || node.text === ' '
  2444. }
  2445. function resolveScopedSlots (
  2446. fns, // see flow/vnode
  2447. res
  2448. ) {
  2449. res = res || {};
  2450. for (var i = 0; i < fns.length; i++) {
  2451. if (Array.isArray(fns[i])) {
  2452. resolveScopedSlots(fns[i], res);
  2453. } else {
  2454. res[fns[i].key] = fns[i].fn;
  2455. }
  2456. }
  2457. return res
  2458. }
  2459. /* */
  2460. var activeInstance = null;
  2461. var isUpdatingChildComponent = false;
  2462. function setActiveInstance(vm) {
  2463. var prevActiveInstance = activeInstance;
  2464. activeInstance = vm;
  2465. return function () {
  2466. activeInstance = prevActiveInstance;
  2467. }
  2468. }
  2469. function initLifecycle (vm) {
  2470. var options = vm.$options;
  2471. // locate first non-abstract parent
  2472. var parent = options.parent;
  2473. if (parent && !options.abstract) {
  2474. while (parent.$options.abstract && parent.$parent) {
  2475. parent = parent.$parent;
  2476. }
  2477. parent.$children.push(vm);
  2478. }
  2479. vm.$parent = parent;
  2480. vm.$root = parent ? parent.$root : vm;
  2481. vm.$children = [];
  2482. vm.$refs = {};
  2483. vm._watcher = null;
  2484. vm._inactive = null;
  2485. vm._directInactive = false;
  2486. vm._isMounted = false;
  2487. vm._isDestroyed = false;
  2488. vm._isBeingDestroyed = false;
  2489. }
  2490. function lifecycleMixin (Vue) {
  2491. Vue.prototype._update = function (vnode, hydrating) {
  2492. var vm = this;
  2493. var prevEl = vm.$el;
  2494. var prevVnode = vm._vnode;
  2495. var restoreActiveInstance = setActiveInstance(vm);
  2496. vm._vnode = vnode;
  2497. // Vue.prototype.__patch__ is injected in entry points
  2498. // based on the rendering backend used.
  2499. if (!prevVnode) {
  2500. // initial render
  2501. vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */);
  2502. } else {
  2503. // updates
  2504. vm.$el = vm.__patch__(prevVnode, vnode);
  2505. }
  2506. restoreActiveInstance();
  2507. // update __vue__ reference
  2508. if (prevEl) {
  2509. prevEl.__vue__ = null;
  2510. }
  2511. if (vm.$el) {
  2512. vm.$el.__vue__ = vm;
  2513. }
  2514. // if parent is an HOC, update its $el as well
  2515. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  2516. vm.$parent.$el = vm.$el;
  2517. }
  2518. // updated hook is called by the scheduler to ensure that children are
  2519. // updated in a parent's updated hook.
  2520. };
  2521. Vue.prototype.$forceUpdate = function () {
  2522. var vm = this;
  2523. if (vm._watcher) {
  2524. vm._watcher.update();
  2525. }
  2526. };
  2527. Vue.prototype.$destroy = function () {
  2528. var vm = this;
  2529. if (vm._isBeingDestroyed) {
  2530. return
  2531. }
  2532. callHook(vm, 'beforeDestroy');
  2533. vm._isBeingDestroyed = true;
  2534. // remove self from parent
  2535. var parent = vm.$parent;
  2536. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2537. remove(parent.$children, vm);
  2538. }
  2539. // teardown watchers
  2540. if (vm._watcher) {
  2541. vm._watcher.teardown();
  2542. }
  2543. var i = vm._watchers.length;
  2544. while (i--) {
  2545. vm._watchers[i].teardown();
  2546. }
  2547. // remove reference from data ob
  2548. // frozen object may not have observer.
  2549. if (vm._data.__ob__) {
  2550. vm._data.__ob__.vmCount--;
  2551. }
  2552. // call the last hook...
  2553. vm._isDestroyed = true;
  2554. // invoke destroy hooks on current rendered tree
  2555. vm.__patch__(vm._vnode, null);
  2556. // fire destroyed hook
  2557. callHook(vm, 'destroyed');
  2558. // turn off all instance listeners.
  2559. vm.$off();
  2560. // remove __vue__ reference
  2561. if (vm.$el) {
  2562. vm.$el.__vue__ = null;
  2563. }
  2564. // release circular reference (#6759)
  2565. if (vm.$vnode) {
  2566. vm.$vnode.parent = null;
  2567. }
  2568. };
  2569. }
  2570. function mountComponent (
  2571. vm,
  2572. el,
  2573. hydrating
  2574. ) {
  2575. vm.$el = el;
  2576. if (!vm.$options.render) {
  2577. vm.$options.render = createEmptyVNode;
  2578. {
  2579. /* istanbul ignore if */
  2580. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2581. vm.$options.el || el) {
  2582. warn(
  2583. 'You are using the runtime-only build of Vue where the template ' +
  2584. 'compiler is not available. Either pre-compile the templates into ' +
  2585. 'render functions, or use the compiler-included build.',
  2586. vm
  2587. );
  2588. } else {
  2589. warn(
  2590. 'Failed to mount component: template or render function not defined.',
  2591. vm
  2592. );
  2593. }
  2594. }
  2595. }
  2596. callHook(vm, 'beforeMount');
  2597. var updateComponent;
  2598. /* istanbul ignore if */
  2599. if (config.performance && mark) {
  2600. updateComponent = function () {
  2601. var name = vm._name;
  2602. var id = vm._uid;
  2603. var startTag = "vue-perf-start:" + id;
  2604. var endTag = "vue-perf-end:" + id;
  2605. mark(startTag);
  2606. var vnode = vm._render();
  2607. mark(endTag);
  2608. measure(("vue " + name + " render"), startTag, endTag);
  2609. mark(startTag);
  2610. vm._update(vnode, hydrating);
  2611. mark(endTag);
  2612. measure(("vue " + name + " patch"), startTag, endTag);
  2613. };
  2614. } else {
  2615. updateComponent = function () {
  2616. vm._update(vm._render(), hydrating);
  2617. };
  2618. }
  2619. // we set this to vm._watcher inside the watcher's constructor
  2620. // since the watcher's initial patch may call $forceUpdate (e.g. inside child
  2621. // component's mounted hook), which relies on vm._watcher being already defined
  2622. new Watcher(vm, updateComponent, noop, {
  2623. before: function before () {
  2624. if (vm._isMounted && !vm._isDestroyed) {
  2625. callHook(vm, 'beforeUpdate');
  2626. }
  2627. }
  2628. }, true /* isRenderWatcher */);
  2629. hydrating = false;
  2630. // manually mounted instance, call mounted on self
  2631. // mounted is called for render-created child components in its inserted hook
  2632. if (vm.$vnode == null) {
  2633. vm._isMounted = true;
  2634. callHook(vm, 'mounted');
  2635. }
  2636. return vm
  2637. }
  2638. function updateChildComponent (
  2639. vm,
  2640. propsData,
  2641. listeners,
  2642. parentVnode,
  2643. renderChildren
  2644. ) {
  2645. {
  2646. isUpdatingChildComponent = true;
  2647. }
  2648. // determine whether component has slot children
  2649. // we need to do this before overwriting $options._renderChildren
  2650. var hasChildren = !!(
  2651. renderChildren || // has new static slots
  2652. vm.$options._renderChildren || // has old static slots
  2653. parentVnode.data.scopedSlots || // has new scoped slots
  2654. vm.$scopedSlots !== emptyObject // has old scoped slots
  2655. );
  2656. vm.$options._parentVnode = parentVnode;
  2657. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  2658. if (vm._vnode) { // update child tree's parent
  2659. vm._vnode.parent = parentVnode;
  2660. }
  2661. vm.$options._renderChildren = renderChildren;
  2662. // update $attrs and $listeners hash
  2663. // these are also reactive so they may trigger child update if the child
  2664. // used them during render
  2665. vm.$attrs = parentVnode.data.attrs || emptyObject;
  2666. vm.$listeners = listeners || emptyObject;
  2667. // update props
  2668. if (propsData && vm.$options.props) {
  2669. toggleObserving(false);
  2670. var props = vm._props;
  2671. var propKeys = vm.$options._propKeys || [];
  2672. for (var i = 0; i < propKeys.length; i++) {
  2673. var key = propKeys[i];
  2674. var propOptions = vm.$options.props; // wtf flow?
  2675. props[key] = validateProp(key, propOptions, propsData, vm);
  2676. }
  2677. toggleObserving(true);
  2678. // keep a copy of raw propsData
  2679. vm.$options.propsData = propsData;
  2680. }
  2681. // update listeners
  2682. listeners = listeners || emptyObject;
  2683. var oldListeners = vm.$options._parentListeners;
  2684. vm.$options._parentListeners = listeners;
  2685. updateComponentListeners(vm, listeners, oldListeners);
  2686. // resolve slots + force update if has children
  2687. if (hasChildren) {
  2688. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  2689. vm.$forceUpdate();
  2690. }
  2691. {
  2692. isUpdatingChildComponent = false;
  2693. }
  2694. }
  2695. function isInInactiveTree (vm) {
  2696. while (vm && (vm = vm.$parent)) {
  2697. if (vm._inactive) { return true }
  2698. }
  2699. return false
  2700. }
  2701. function activateChildComponent (vm, direct) {
  2702. if (direct) {
  2703. vm._directInactive = false;
  2704. if (isInInactiveTree(vm)) {
  2705. return
  2706. }
  2707. } else if (vm._directInactive) {
  2708. return
  2709. }
  2710. if (vm._inactive || vm._inactive === null) {
  2711. vm._inactive = false;
  2712. for (var i = 0; i < vm.$children.length; i++) {
  2713. activateChildComponent(vm.$children[i]);
  2714. }
  2715. callHook(vm, 'activated');
  2716. }
  2717. }
  2718. function deactivateChildComponent (vm, direct) {
  2719. if (direct) {
  2720. vm._directInactive = true;
  2721. if (isInInactiveTree(vm)) {
  2722. return
  2723. }
  2724. }
  2725. if (!vm._inactive) {
  2726. vm._inactive = true;
  2727. for (var i = 0; i < vm.$children.length; i++) {
  2728. deactivateChildComponent(vm.$children[i]);
  2729. }
  2730. callHook(vm, 'deactivated');
  2731. }
  2732. }
  2733. function callHook (vm, hook) {
  2734. // #7573 disable dep collection when invoking lifecycle hooks
  2735. pushTarget();
  2736. var handlers = vm.$options[hook];
  2737. if (handlers) {
  2738. for (var i = 0, j = handlers.length; i < j; i++) {
  2739. try {
  2740. handlers[i].call(vm);
  2741. } catch (e) {
  2742. handleError(e, vm, (hook + " hook"));
  2743. }
  2744. }
  2745. }
  2746. if (vm._hasHookEvent) {
  2747. vm.$emit('hook:' + hook);
  2748. }
  2749. popTarget();
  2750. }
  2751. /* */
  2752. var MAX_UPDATE_COUNT = 100;
  2753. var queue = [];
  2754. var activatedChildren = [];
  2755. var has = {};
  2756. var circular = {};
  2757. var waiting = false;
  2758. var flushing = false;
  2759. var index = 0;
  2760. /**
  2761. * Reset the scheduler's state.
  2762. */
  2763. function resetSchedulerState () {
  2764. index = queue.length = activatedChildren.length = 0;
  2765. has = {};
  2766. {
  2767. circular = {};
  2768. }
  2769. waiting = flushing = false;
  2770. }
  2771. /**
  2772. * Flush both queues and run the watchers.
  2773. */
  2774. function flushSchedulerQueue () {
  2775. flushing = true;
  2776. var watcher, id;
  2777. // Sort queue before flush.
  2778. // This ensures that:
  2779. // 1. Components are updated from parent to child. (because parent is always
  2780. // created before the child)
  2781. // 2. A component's user watchers are run before its render watcher (because
  2782. // user watchers are created before the render watcher)
  2783. // 3. If a component is destroyed during a parent component's watcher run,
  2784. // its watchers can be skipped.
  2785. queue.sort(function (a, b) { return a.id - b.id; });
  2786. // do not cache length because more watchers might be pushed
  2787. // as we run existing watchers
  2788. for (index = 0; index < queue.length; index++) {
  2789. watcher = queue[index];
  2790. if (watcher.before) {
  2791. watcher.before();
  2792. }
  2793. id = watcher.id;
  2794. has[id] = null;
  2795. watcher.run();
  2796. // in dev build, check and stop circular updates.
  2797. if (has[id] != null) {
  2798. circular[id] = (circular[id] || 0) + 1;
  2799. if (circular[id] > MAX_UPDATE_COUNT) {
  2800. warn(
  2801. 'You may have an infinite update loop ' + (
  2802. watcher.user
  2803. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  2804. : "in a component render function."
  2805. ),
  2806. watcher.vm
  2807. );
  2808. break
  2809. }
  2810. }
  2811. }
  2812. // keep copies of post queues before resetting state
  2813. var activatedQueue = activatedChildren.slice();
  2814. var updatedQueue = queue.slice();
  2815. resetSchedulerState();
  2816. // call component updated and activated hooks
  2817. callActivatedHooks(activatedQueue);
  2818. callUpdatedHooks(updatedQueue);
  2819. // devtool hook
  2820. /* istanbul ignore if */
  2821. if (devtools && config.devtools) {
  2822. devtools.emit('flush');
  2823. }
  2824. }
  2825. function callUpdatedHooks (queue) {
  2826. var i = queue.length;
  2827. while (i--) {
  2828. var watcher = queue[i];
  2829. var vm = watcher.vm;
  2830. if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
  2831. callHook(vm, 'updated');
  2832. }
  2833. }
  2834. }
  2835. /**
  2836. * Queue a kept-alive component that was activated during patch.
  2837. * The queue will be processed after the entire tree has been patched.
  2838. */
  2839. function queueActivatedComponent (vm) {
  2840. // setting _inactive to false here so that a render function can
  2841. // rely on checking whether it's in an inactive tree (e.g. router-view)
  2842. vm._inactive = false;
  2843. activatedChildren.push(vm);
  2844. }
  2845. function callActivatedHooks (queue) {
  2846. for (var i = 0; i < queue.length; i++) {
  2847. queue[i]._inactive = true;
  2848. activateChildComponent(queue[i], true /* true */);
  2849. }
  2850. }
  2851. /**
  2852. * Push a watcher into the watcher queue.
  2853. * Jobs with duplicate IDs will be skipped unless it's
  2854. * pushed when the queue is being flushed.
  2855. */
  2856. function queueWatcher (watcher) {
  2857. var id = watcher.id;
  2858. if (has[id] == null) {
  2859. has[id] = true;
  2860. if (!flushing) {
  2861. queue.push(watcher);
  2862. } else {
  2863. // if already flushing, splice the watcher based on its id
  2864. // if already past its id, it will be run next immediately.
  2865. var i = queue.length - 1;
  2866. while (i > index && queue[i].id > watcher.id) {
  2867. i--;
  2868. }
  2869. queue.splice(i + 1, 0, watcher);
  2870. }
  2871. // queue the flush
  2872. if (!waiting) {
  2873. waiting = true;
  2874. if (!config.async) {
  2875. flushSchedulerQueue();
  2876. return
  2877. }
  2878. nextTick(flushSchedulerQueue);
  2879. }
  2880. }
  2881. }
  2882. /* */
  2883. var uid$1 = 0;
  2884. /**
  2885. * A watcher parses an expression, collects dependencies,
  2886. * and fires callback when the expression value changes.
  2887. * This is used for both the $watch() api and directives.
  2888. */
  2889. var Watcher = function Watcher (
  2890. vm,
  2891. expOrFn,
  2892. cb,
  2893. options,
  2894. isRenderWatcher
  2895. ) {
  2896. this.vm = vm;
  2897. if (isRenderWatcher) {
  2898. vm._watcher = this;
  2899. }
  2900. vm._watchers.push(this);
  2901. // options
  2902. if (options) {
  2903. this.deep = !!options.deep;
  2904. this.user = !!options.user;
  2905. this.lazy = !!options.lazy;
  2906. this.sync = !!options.sync;
  2907. this.before = options.before;
  2908. } else {
  2909. this.deep = this.user = this.lazy = this.sync = false;
  2910. }
  2911. this.cb = cb;
  2912. this.id = ++uid$1; // uid for batching
  2913. this.active = true;
  2914. this.dirty = this.lazy; // for lazy watchers
  2915. this.deps = [];
  2916. this.newDeps = [];
  2917. this.depIds = new _Set();
  2918. this.newDepIds = new _Set();
  2919. this.expression = expOrFn.toString();
  2920. // parse expression for getter
  2921. if (typeof expOrFn === 'function') {
  2922. this.getter = expOrFn;
  2923. } else {
  2924. this.getter = parsePath(expOrFn);
  2925. if (!this.getter) {
  2926. this.getter = noop;
  2927. warn(
  2928. "Failed watching path: \"" + expOrFn + "\" " +
  2929. 'Watcher only accepts simple dot-delimited paths. ' +
  2930. 'For full control, use a function instead.',
  2931. vm
  2932. );
  2933. }
  2934. }
  2935. this.value = this.lazy
  2936. ? undefined
  2937. : this.get();
  2938. };
  2939. /**
  2940. * Evaluate the getter, and re-collect dependencies.
  2941. */
  2942. Watcher.prototype.get = function get () {
  2943. pushTarget(this);
  2944. var value;
  2945. var vm = this.vm;
  2946. try {
  2947. value = this.getter.call(vm, vm);
  2948. } catch (e) {
  2949. if (this.user) {
  2950. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  2951. } else {
  2952. throw e
  2953. }
  2954. } finally {
  2955. // "touch" every property so they are all tracked as
  2956. // dependencies for deep watching
  2957. if (this.deep) {
  2958. traverse(value);
  2959. }
  2960. popTarget();
  2961. this.cleanupDeps();
  2962. }
  2963. return value
  2964. };
  2965. /**
  2966. * Add a dependency to this directive.
  2967. */
  2968. Watcher.prototype.addDep = function addDep (dep) {
  2969. var id = dep.id;
  2970. if (!this.newDepIds.has(id)) {
  2971. this.newDepIds.add(id);
  2972. this.newDeps.push(dep);
  2973. if (!this.depIds.has(id)) {
  2974. dep.addSub(this);
  2975. }
  2976. }
  2977. };
  2978. /**
  2979. * Clean up for dependency collection.
  2980. */
  2981. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  2982. var i = this.deps.length;
  2983. while (i--) {
  2984. var dep = this.deps[i];
  2985. if (!this.newDepIds.has(dep.id)) {
  2986. dep.removeSub(this);
  2987. }
  2988. }
  2989. var tmp = this.depIds;
  2990. this.depIds = this.newDepIds;
  2991. this.newDepIds = tmp;
  2992. this.newDepIds.clear();
  2993. tmp = this.deps;
  2994. this.deps = this.newDeps;
  2995. this.newDeps = tmp;
  2996. this.newDeps.length = 0;
  2997. };
  2998. /**
  2999. * Subscriber interface.
  3000. * Will be called when a dependency changes.
  3001. */
  3002. Watcher.prototype.update = function update () {
  3003. /* istanbul ignore else */
  3004. if (this.lazy) {
  3005. this.dirty = true;
  3006. } else if (this.sync) {
  3007. this.run();
  3008. } else {
  3009. queueWatcher(this);
  3010. }
  3011. };
  3012. /**
  3013. * Scheduler job interface.
  3014. * Will be called by the scheduler.
  3015. */
  3016. Watcher.prototype.run = function run () {
  3017. if (this.active) {
  3018. var value = this.get();
  3019. if (
  3020. value !== this.value ||
  3021. // Deep watchers and watchers on Object/Arrays should fire even
  3022. // when the value is the same, because the value may
  3023. // have mutated.
  3024. isObject(value) ||
  3025. this.deep
  3026. ) {
  3027. // set new value
  3028. var oldValue = this.value;
  3029. this.value = value;
  3030. if (this.user) {
  3031. try {
  3032. this.cb.call(this.vm, value, oldValue);
  3033. } catch (e) {
  3034. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  3035. }
  3036. } else {
  3037. this.cb.call(this.vm, value, oldValue);
  3038. }
  3039. }
  3040. }
  3041. };
  3042. /**
  3043. * Evaluate the value of the watcher.
  3044. * This only gets called for lazy watchers.
  3045. */
  3046. Watcher.prototype.evaluate = function evaluate () {
  3047. this.value = this.get();
  3048. this.dirty = false;
  3049. };
  3050. /**
  3051. * Depend on all deps collected by this watcher.
  3052. */
  3053. Watcher.prototype.depend = function depend () {
  3054. var i = this.deps.length;
  3055. while (i--) {
  3056. this.deps[i].depend();
  3057. }
  3058. };
  3059. /**
  3060. * Remove self from all dependencies' subscriber list.
  3061. */
  3062. Watcher.prototype.teardown = function teardown () {
  3063. if (this.active) {
  3064. // remove self from vm's watcher list
  3065. // this is a somewhat expensive operation so we skip it
  3066. // if the vm is being destroyed.
  3067. if (!this.vm._isBeingDestroyed) {
  3068. remove(this.vm._watchers, this);
  3069. }
  3070. var i = this.deps.length;
  3071. while (i--) {
  3072. this.deps[i].removeSub(this);
  3073. }
  3074. this.active = false;
  3075. }
  3076. };
  3077. /* */
  3078. var sharedPropertyDefinition = {
  3079. enumerable: true,
  3080. configurable: true,
  3081. get: noop,
  3082. set: noop
  3083. };
  3084. function proxy (target, sourceKey, key) {
  3085. sharedPropertyDefinition.get = function proxyGetter () {
  3086. return this[sourceKey][key]
  3087. };
  3088. sharedPropertyDefinition.set = function proxySetter (val) {
  3089. this[sourceKey][key] = val;
  3090. };
  3091. Object.defineProperty(target, key, sharedPropertyDefinition);
  3092. }
  3093. function initState (vm) {
  3094. vm._watchers = [];
  3095. var opts = vm.$options;
  3096. if (opts.props) { initProps(vm, opts.props); }
  3097. if (opts.methods) { initMethods(vm, opts.methods); }
  3098. if (opts.data) {
  3099. initData(vm);
  3100. } else {
  3101. observe(vm._data = {}, true /* asRootData */);
  3102. }
  3103. if (opts.computed) { initComputed(vm, opts.computed); }
  3104. if (opts.watch && opts.watch !== nativeWatch) {
  3105. initWatch(vm, opts.watch);
  3106. }
  3107. }
  3108. function initProps (vm, propsOptions) {
  3109. var propsData = vm.$options.propsData || {};
  3110. var props = vm._props = {};
  3111. // cache prop keys so that future props updates can iterate using Array
  3112. // instead of dynamic object key enumeration.
  3113. var keys = vm.$options._propKeys = [];
  3114. var isRoot = !vm.$parent;
  3115. // root instance props should be converted
  3116. if (!isRoot) {
  3117. toggleObserving(false);
  3118. }
  3119. var loop = function ( key ) {
  3120. keys.push(key);
  3121. var value = validateProp(key, propsOptions, propsData, vm);
  3122. /* istanbul ignore else */
  3123. {
  3124. var hyphenatedKey = hyphenate(key);
  3125. if (isReservedAttribute(hyphenatedKey) ||
  3126. config.isReservedAttr(hyphenatedKey)) {
  3127. warn(
  3128. ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."),
  3129. vm
  3130. );
  3131. }
  3132. defineReactive$$1(props, key, value, function () {
  3133. if (!isRoot && !isUpdatingChildComponent) {
  3134. warn(
  3135. "Avoid mutating a prop directly since the value will be " +
  3136. "overwritten whenever the parent component re-renders. " +
  3137. "Instead, use a data or computed property based on the prop's " +
  3138. "value. Prop being mutated: \"" + key + "\"",
  3139. vm
  3140. );
  3141. }
  3142. });
  3143. }
  3144. // static props are already proxied on the component's prototype
  3145. // during Vue.extend(). We only need to proxy props defined at
  3146. // instantiation here.
  3147. if (!(key in vm)) {
  3148. proxy(vm, "_props", key);
  3149. }
  3150. };
  3151. for (var key in propsOptions) loop( key );
  3152. toggleObserving(true);
  3153. }
  3154. function initData (vm) {
  3155. var data = vm.$options.data;
  3156. data = vm._data = typeof data === 'function'
  3157. ? getData(data, vm)
  3158. : data || {};
  3159. if (!isPlainObject(data)) {
  3160. data = {};
  3161. warn(
  3162. 'data functions should return an object:\n' +
  3163. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  3164. vm
  3165. );
  3166. }
  3167. // proxy data on instance
  3168. var keys = Object.keys(data);
  3169. var props = vm.$options.props;
  3170. var methods = vm.$options.methods;
  3171. var i = keys.length;
  3172. while (i--) {
  3173. var key = keys[i];
  3174. {
  3175. if (methods && hasOwn(methods, key)) {
  3176. warn(
  3177. ("Method \"" + key + "\" has already been defined as a data property."),
  3178. vm
  3179. );
  3180. }
  3181. }
  3182. if (props && hasOwn(props, key)) {
  3183. warn(
  3184. "The data property \"" + key + "\" is already declared as a prop. " +
  3185. "Use prop default value instead.",
  3186. vm
  3187. );
  3188. } else if (!isReserved(key)) {
  3189. proxy(vm, "_data", key);
  3190. }
  3191. }
  3192. // observe data
  3193. observe(data, true /* asRootData */);
  3194. }
  3195. function getData (data, vm) {
  3196. // #7573 disable dep collection when invoking data getters
  3197. pushTarget();
  3198. try {
  3199. return data.call(vm, vm)
  3200. } catch (e) {
  3201. handleError(e, vm, "data()");
  3202. return {}
  3203. } finally {
  3204. popTarget();
  3205. }
  3206. }
  3207. var computedWatcherOptions = { lazy: true };
  3208. function initComputed (vm, computed) {
  3209. // $flow-disable-line
  3210. var watchers = vm._computedWatchers = Object.create(null);
  3211. // computed properties are just getters during SSR
  3212. var isSSR = isServerRendering();
  3213. for (var key in computed) {
  3214. var userDef = computed[key];
  3215. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  3216. if (getter == null) {
  3217. warn(
  3218. ("Getter is missing for computed property \"" + key + "\"."),
  3219. vm
  3220. );
  3221. }
  3222. if (!isSSR) {
  3223. // create internal watcher for the computed property.
  3224. watchers[key] = new Watcher(
  3225. vm,
  3226. getter || noop,
  3227. noop,
  3228. computedWatcherOptions
  3229. );
  3230. }
  3231. // component-defined computed properties are already defined on the
  3232. // component prototype. We only need to define computed properties defined
  3233. // at instantiation here.
  3234. if (!(key in vm)) {
  3235. defineComputed(vm, key, userDef);
  3236. } else {
  3237. if (key in vm.$data) {
  3238. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  3239. } else if (vm.$options.props && key in vm.$options.props) {
  3240. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  3241. }
  3242. }
  3243. }
  3244. }
  3245. function defineComputed (
  3246. target,
  3247. key,
  3248. userDef
  3249. ) {
  3250. var shouldCache = !isServerRendering();
  3251. if (typeof userDef === 'function') {
  3252. sharedPropertyDefinition.get = shouldCache
  3253. ? createComputedGetter(key)
  3254. : createGetterInvoker(userDef);
  3255. sharedPropertyDefinition.set = noop;
  3256. } else {
  3257. sharedPropertyDefinition.get = userDef.get
  3258. ? shouldCache && userDef.cache !== false
  3259. ? createComputedGetter(key)
  3260. : createGetterInvoker(userDef.get)
  3261. : noop;
  3262. sharedPropertyDefinition.set = userDef.set || noop;
  3263. }
  3264. if (sharedPropertyDefinition.set === noop) {
  3265. sharedPropertyDefinition.set = function () {
  3266. warn(
  3267. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  3268. this
  3269. );
  3270. };
  3271. }
  3272. Object.defineProperty(target, key, sharedPropertyDefinition);
  3273. }
  3274. function createComputedGetter (key) {
  3275. return function computedGetter () {
  3276. var watcher = this._computedWatchers && this._computedWatchers[key];
  3277. if (watcher) {
  3278. if (watcher.dirty) {
  3279. watcher.evaluate();
  3280. }
  3281. if (Dep.target) {
  3282. watcher.depend();
  3283. }
  3284. return watcher.value
  3285. }
  3286. }
  3287. }
  3288. function createGetterInvoker(fn) {
  3289. return function computedGetter () {
  3290. return fn.call(this, this)
  3291. }
  3292. }
  3293. function initMethods (vm, methods) {
  3294. var props = vm.$options.props;
  3295. for (var key in methods) {
  3296. {
  3297. if (typeof methods[key] !== 'function') {
  3298. warn(
  3299. "Method \"" + key + "\" has type \"" + (typeof methods[key]) + "\" in the component definition. " +
  3300. "Did you reference the function correctly?",
  3301. vm
  3302. );
  3303. }
  3304. if (props && hasOwn(props, key)) {
  3305. warn(
  3306. ("Method \"" + key + "\" has already been defined as a prop."),
  3307. vm
  3308. );
  3309. }
  3310. if ((key in vm) && isReserved(key)) {
  3311. warn(
  3312. "Method \"" + key + "\" conflicts with an existing Vue instance method. " +
  3313. "Avoid defining component methods that start with _ or $."
  3314. );
  3315. }
  3316. }
  3317. vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm);
  3318. }
  3319. }
  3320. function initWatch (vm, watch) {
  3321. for (var key in watch) {
  3322. var handler = watch[key];
  3323. if (Array.isArray(handler)) {
  3324. for (var i = 0; i < handler.length; i++) {
  3325. createWatcher(vm, key, handler[i]);
  3326. }
  3327. } else {
  3328. createWatcher(vm, key, handler);
  3329. }
  3330. }
  3331. }
  3332. function createWatcher (
  3333. vm,
  3334. expOrFn,
  3335. handler,
  3336. options
  3337. ) {
  3338. if (isPlainObject(handler)) {
  3339. options = handler;
  3340. handler = handler.handler;
  3341. }
  3342. if (typeof handler === 'string') {
  3343. handler = vm[handler];
  3344. }
  3345. return vm.$watch(expOrFn, handler, options)
  3346. }
  3347. function stateMixin (Vue) {
  3348. // flow somehow has problems with directly declared definition object
  3349. // when using Object.defineProperty, so we have to procedurally build up
  3350. // the object here.
  3351. var dataDef = {};
  3352. dataDef.get = function () { return this._data };
  3353. var propsDef = {};
  3354. propsDef.get = function () { return this._props };
  3355. {
  3356. dataDef.set = function () {
  3357. warn(
  3358. 'Avoid replacing instance root $data. ' +
  3359. 'Use nested data properties instead.',
  3360. this
  3361. );
  3362. };
  3363. propsDef.set = function () {
  3364. warn("$props is readonly.", this);
  3365. };
  3366. }
  3367. Object.defineProperty(Vue.prototype, '$data', dataDef);
  3368. Object.defineProperty(Vue.prototype, '$props', propsDef);
  3369. Vue.prototype.$set = set;
  3370. Vue.prototype.$delete = del;
  3371. Vue.prototype.$watch = function (
  3372. expOrFn,
  3373. cb,
  3374. options
  3375. ) {
  3376. var vm = this;
  3377. if (isPlainObject(cb)) {
  3378. return createWatcher(vm, expOrFn, cb, options)
  3379. }
  3380. options = options || {};
  3381. options.user = true;
  3382. var watcher = new Watcher(vm, expOrFn, cb, options);
  3383. if (options.immediate) {
  3384. try {
  3385. cb.call(vm, watcher.value);
  3386. } catch (error) {
  3387. handleError(error, vm, ("callback for immediate watcher \"" + (watcher.expression) + "\""));
  3388. }
  3389. }
  3390. return function unwatchFn () {
  3391. watcher.teardown();
  3392. }
  3393. };
  3394. }
  3395. /* */
  3396. function initProvide (vm) {
  3397. var provide = vm.$options.provide;
  3398. if (provide) {
  3399. vm._provided = typeof provide === 'function'
  3400. ? provide.call(vm)
  3401. : provide;
  3402. }
  3403. }
  3404. function initInjections (vm) {
  3405. var result = resolveInject(vm.$options.inject, vm);
  3406. if (result) {
  3407. toggleObserving(false);
  3408. Object.keys(result).forEach(function (key) {
  3409. /* istanbul ignore else */
  3410. {
  3411. defineReactive$$1(vm, key, result[key], function () {
  3412. warn(
  3413. "Avoid mutating an injected value directly since the changes will be " +
  3414. "overwritten whenever the provided component re-renders. " +
  3415. "injection being mutated: \"" + key + "\"",
  3416. vm
  3417. );
  3418. });
  3419. }
  3420. });
  3421. toggleObserving(true);
  3422. }
  3423. }
  3424. function resolveInject (inject, vm) {
  3425. if (inject) {
  3426. // inject is :any because flow is not smart enough to figure out cached
  3427. var result = Object.create(null);
  3428. var keys = hasSymbol
  3429. ? Reflect.ownKeys(inject).filter(function (key) {
  3430. /* istanbul ignore next */
  3431. return Object.getOwnPropertyDescriptor(inject, key).enumerable
  3432. })
  3433. : Object.keys(inject);
  3434. for (var i = 0; i < keys.length; i++) {
  3435. var key = keys[i];
  3436. var provideKey = inject[key].from;
  3437. var source = vm;
  3438. while (source) {
  3439. if (source._provided && hasOwn(source._provided, provideKey)) {
  3440. result[key] = source._provided[provideKey];
  3441. break
  3442. }
  3443. source = source.$parent;
  3444. }
  3445. if (!source) {
  3446. if ('default' in inject[key]) {
  3447. var provideDefault = inject[key].default;
  3448. result[key] = typeof provideDefault === 'function'
  3449. ? provideDefault.call(vm)
  3450. : provideDefault;
  3451. } else {
  3452. warn(("Injection \"" + key + "\" not found"), vm);
  3453. }
  3454. }
  3455. }
  3456. return result
  3457. }
  3458. }
  3459. /* */
  3460. /**
  3461. * Runtime helper for rendering v-for lists.
  3462. */
  3463. function renderList (
  3464. val,
  3465. render
  3466. ) {
  3467. var ret, i, l, keys, key;
  3468. if (Array.isArray(val) || typeof val === 'string') {
  3469. ret = new Array(val.length);
  3470. for (i = 0, l = val.length; i < l; i++) {
  3471. ret[i] = render(val[i], i);
  3472. }
  3473. } else if (typeof val === 'number') {
  3474. ret = new Array(val);
  3475. for (i = 0; i < val; i++) {
  3476. ret[i] = render(i + 1, i);
  3477. }
  3478. } else if (isObject(val)) {
  3479. keys = Object.keys(val);
  3480. ret = new Array(keys.length);
  3481. for (i = 0, l = keys.length; i < l; i++) {
  3482. key = keys[i];
  3483. ret[i] = render(val[key], key, i);
  3484. }
  3485. }
  3486. if (!isDef(ret)) {
  3487. ret = [];
  3488. }
  3489. (ret)._isVList = true;
  3490. return ret
  3491. }
  3492. /* */
  3493. /**
  3494. * Runtime helper for rendering <slot>
  3495. */
  3496. function renderSlot (
  3497. name,
  3498. fallback,
  3499. props,
  3500. bindObject
  3501. ) {
  3502. var scopedSlotFn = this.$scopedSlots[name];
  3503. var nodes;
  3504. if (scopedSlotFn) { // scoped slot
  3505. props = props || {};
  3506. if (bindObject) {
  3507. if (!isObject(bindObject)) {
  3508. warn(
  3509. 'slot v-bind without argument expects an Object',
  3510. this
  3511. );
  3512. }
  3513. props = extend(extend({}, bindObject), props);
  3514. }
  3515. nodes = scopedSlotFn(props) || fallback;
  3516. } else {
  3517. nodes = this.$slots[name] || fallback;
  3518. }
  3519. var target = props && props.slot;
  3520. if (target) {
  3521. return this.$createElement('template', { slot: target }, nodes)
  3522. } else {
  3523. return nodes
  3524. }
  3525. }
  3526. /* */
  3527. /**
  3528. * Runtime helper for resolving filters
  3529. */
  3530. function resolveFilter (id) {
  3531. return resolveAsset(this.$options, 'filters', id, true) || identity
  3532. }
  3533. /* */
  3534. function isKeyNotMatch (expect, actual) {
  3535. if (Array.isArray(expect)) {
  3536. return expect.indexOf(actual) === -1
  3537. } else {
  3538. return expect !== actual
  3539. }
  3540. }
  3541. /**
  3542. * Runtime helper for checking keyCodes from config.
  3543. * exposed as Vue.prototype._k
  3544. * passing in eventKeyName as last argument separately for backwards compat
  3545. */
  3546. function checkKeyCodes (
  3547. eventKeyCode,
  3548. key,
  3549. builtInKeyCode,
  3550. eventKeyName,
  3551. builtInKeyName
  3552. ) {
  3553. var mappedKeyCode = config.keyCodes[key] || builtInKeyCode;
  3554. if (builtInKeyName && eventKeyName && !config.keyCodes[key]) {
  3555. return isKeyNotMatch(builtInKeyName, eventKeyName)
  3556. } else if (mappedKeyCode) {
  3557. return isKeyNotMatch(mappedKeyCode, eventKeyCode)
  3558. } else if (eventKeyName) {
  3559. return hyphenate(eventKeyName) !== key
  3560. }
  3561. }
  3562. /* */
  3563. /**
  3564. * Runtime helper for merging v-bind="object" into a VNode's data.
  3565. */
  3566. function bindObjectProps (
  3567. data,
  3568. tag,
  3569. value,
  3570. asProp,
  3571. isSync
  3572. ) {
  3573. if (value) {
  3574. if (!isObject(value)) {
  3575. warn(
  3576. 'v-bind without argument expects an Object or Array value',
  3577. this
  3578. );
  3579. } else {
  3580. if (Array.isArray(value)) {
  3581. value = toObject(value);
  3582. }
  3583. var hash;
  3584. var loop = function ( key ) {
  3585. if (
  3586. key === 'class' ||
  3587. key === 'style' ||
  3588. isReservedAttribute(key)
  3589. ) {
  3590. hash = data;
  3591. } else {
  3592. var type = data.attrs && data.attrs.type;
  3593. hash = asProp || config.mustUseProp(tag, type, key)
  3594. ? data.domProps || (data.domProps = {})
  3595. : data.attrs || (data.attrs = {});
  3596. }
  3597. var camelizedKey = camelize(key);
  3598. if (!(key in hash) && !(camelizedKey in hash)) {
  3599. hash[key] = value[key];
  3600. if (isSync) {
  3601. var on = data.on || (data.on = {});
  3602. on[("update:" + camelizedKey)] = function ($event) {
  3603. value[key] = $event;
  3604. };
  3605. }
  3606. }
  3607. };
  3608. for (var key in value) loop( key );
  3609. }
  3610. }
  3611. return data
  3612. }
  3613. /* */
  3614. /**
  3615. * Runtime helper for rendering static trees.
  3616. */
  3617. function renderStatic (
  3618. index,
  3619. isInFor
  3620. ) {
  3621. var cached = this._staticTrees || (this._staticTrees = []);
  3622. var tree = cached[index];
  3623. // if has already-rendered static tree and not inside v-for,
  3624. // we can reuse the same tree.
  3625. if (tree && !isInFor) {
  3626. return tree
  3627. }
  3628. // otherwise, render a fresh tree.
  3629. tree = cached[index] = this.$options.staticRenderFns[index].call(
  3630. this._renderProxy,
  3631. null,
  3632. this // for render fns generated for functional component templates
  3633. );
  3634. markStatic(tree, ("__static__" + index), false);
  3635. return tree
  3636. }
  3637. /**
  3638. * Runtime helper for v-once.
  3639. * Effectively it means marking the node as static with a unique key.
  3640. */
  3641. function markOnce (
  3642. tree,
  3643. index,
  3644. key
  3645. ) {
  3646. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  3647. return tree
  3648. }
  3649. function markStatic (
  3650. tree,
  3651. key,
  3652. isOnce
  3653. ) {
  3654. if (Array.isArray(tree)) {
  3655. for (var i = 0; i < tree.length; i++) {
  3656. if (tree[i] && typeof tree[i] !== 'string') {
  3657. markStaticNode(tree[i], (key + "_" + i), isOnce);
  3658. }
  3659. }
  3660. } else {
  3661. markStaticNode(tree, key, isOnce);
  3662. }
  3663. }
  3664. function markStaticNode (node, key, isOnce) {
  3665. node.isStatic = true;
  3666. node.key = key;
  3667. node.isOnce = isOnce;
  3668. }
  3669. /* */
  3670. function bindObjectListeners (data, value) {
  3671. if (value) {
  3672. if (!isPlainObject(value)) {
  3673. warn(
  3674. 'v-on without argument expects an Object value',
  3675. this
  3676. );
  3677. } else {
  3678. var on = data.on = data.on ? extend({}, data.on) : {};
  3679. for (var key in value) {
  3680. var existing = on[key];
  3681. var ours = value[key];
  3682. on[key] = existing ? [].concat(existing, ours) : ours;
  3683. }
  3684. }
  3685. }
  3686. return data
  3687. }
  3688. /* */
  3689. function installRenderHelpers (target) {
  3690. target._o = markOnce;
  3691. target._n = toNumber;
  3692. target._s = toString;
  3693. target._l = renderList;
  3694. target._t = renderSlot;
  3695. target._q = looseEqual;
  3696. target._i = looseIndexOf;
  3697. target._m = renderStatic;
  3698. target._f = resolveFilter;
  3699. target._k = checkKeyCodes;
  3700. target._b = bindObjectProps;
  3701. target._v = createTextVNode;
  3702. target._e = createEmptyVNode;
  3703. target._u = resolveScopedSlots;
  3704. target._g = bindObjectListeners;
  3705. }
  3706. /* */
  3707. function FunctionalRenderContext (
  3708. data,
  3709. props,
  3710. children,
  3711. parent,
  3712. Ctor
  3713. ) {
  3714. var options = Ctor.options;
  3715. // ensure the createElement function in functional components
  3716. // gets a unique context - this is necessary for correct named slot check
  3717. var contextVm;
  3718. if (hasOwn(parent, '_uid')) {
  3719. contextVm = Object.create(parent);
  3720. // $flow-disable-line
  3721. contextVm._original = parent;
  3722. } else {
  3723. // the context vm passed in is a functional context as well.
  3724. // in this case we want to make sure we are able to get a hold to the
  3725. // real context instance.
  3726. contextVm = parent;
  3727. // $flow-disable-line
  3728. parent = parent._original;
  3729. }
  3730. var isCompiled = isTrue(options._compiled);
  3731. var needNormalization = !isCompiled;
  3732. this.data = data;
  3733. this.props = props;
  3734. this.children = children;
  3735. this.parent = parent;
  3736. this.listeners = data.on || emptyObject;
  3737. this.injections = resolveInject(options.inject, parent);
  3738. this.slots = function () { return resolveSlots(children, parent); };
  3739. // support for compiled functional template
  3740. if (isCompiled) {
  3741. // exposing $options for renderStatic()
  3742. this.$options = options;
  3743. // pre-resolve slots for renderSlot()
  3744. this.$slots = this.slots();
  3745. this.$scopedSlots = data.scopedSlots || emptyObject;
  3746. }
  3747. if (options._scopeId) {
  3748. this._c = function (a, b, c, d) {
  3749. var vnode = createElement(contextVm, a, b, c, d, needNormalization);
  3750. if (vnode && !Array.isArray(vnode)) {
  3751. vnode.fnScopeId = options._scopeId;
  3752. vnode.fnContext = parent;
  3753. }
  3754. return vnode
  3755. };
  3756. } else {
  3757. this._c = function (a, b, c, d) { return createElement(contextVm, a, b, c, d, needNormalization); };
  3758. }
  3759. }
  3760. installRenderHelpers(FunctionalRenderContext.prototype);
  3761. function createFunctionalComponent (
  3762. Ctor,
  3763. propsData,
  3764. data,
  3765. contextVm,
  3766. children
  3767. ) {
  3768. var options = Ctor.options;
  3769. var props = {};
  3770. var propOptions = options.props;
  3771. if (isDef(propOptions)) {
  3772. for (var key in propOptions) {
  3773. props[key] = validateProp(key, propOptions, propsData || emptyObject);
  3774. }
  3775. } else {
  3776. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  3777. if (isDef(data.props)) { mergeProps(props, data.props); }
  3778. }
  3779. var renderContext = new FunctionalRenderContext(
  3780. data,
  3781. props,
  3782. children,
  3783. contextVm,
  3784. Ctor
  3785. );
  3786. var vnode = options.render.call(null, renderContext._c, renderContext);
  3787. if (vnode instanceof VNode) {
  3788. return cloneAndMarkFunctionalResult(vnode, data, renderContext.parent, options, renderContext)
  3789. } else if (Array.isArray(vnode)) {
  3790. var vnodes = normalizeChildren(vnode) || [];
  3791. var res = new Array(vnodes.length);
  3792. for (var i = 0; i < vnodes.length; i++) {
  3793. res[i] = cloneAndMarkFunctionalResult(vnodes[i], data, renderContext.parent, options, renderContext);
  3794. }
  3795. return res
  3796. }
  3797. }
  3798. function cloneAndMarkFunctionalResult (vnode, data, contextVm, options, renderContext) {
  3799. // #7817 clone node before setting fnContext, otherwise if the node is reused
  3800. // (e.g. it was from a cached normal slot) the fnContext causes named slots
  3801. // that should not be matched to match.
  3802. var clone = cloneVNode(vnode);
  3803. clone.fnContext = contextVm;
  3804. clone.fnOptions = options;
  3805. {
  3806. (clone.devtoolsMeta = clone.devtoolsMeta || {}).renderContext = renderContext;
  3807. }
  3808. if (data.slot) {
  3809. (clone.data || (clone.data = {})).slot = data.slot;
  3810. }
  3811. return clone
  3812. }
  3813. function mergeProps (to, from) {
  3814. for (var key in from) {
  3815. to[camelize(key)] = from[key];
  3816. }
  3817. }
  3818. /* */
  3819. /* */
  3820. /* */
  3821. /* */
  3822. // inline hooks to be invoked on component VNodes during patch
  3823. var componentVNodeHooks = {
  3824. init: function init (vnode, hydrating) {
  3825. if (
  3826. vnode.componentInstance &&
  3827. !vnode.componentInstance._isDestroyed &&
  3828. vnode.data.keepAlive
  3829. ) {
  3830. // kept-alive components, treat as a patch
  3831. var mountedNode = vnode; // work around flow
  3832. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  3833. } else {
  3834. var child = vnode.componentInstance = createComponentInstanceForVnode(
  3835. vnode,
  3836. activeInstance
  3837. );
  3838. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  3839. }
  3840. },
  3841. prepatch: function prepatch (oldVnode, vnode) {
  3842. var options = vnode.componentOptions;
  3843. var child = vnode.componentInstance = oldVnode.componentInstance;
  3844. updateChildComponent(
  3845. child,
  3846. options.propsData, // updated props
  3847. options.listeners, // updated listeners
  3848. vnode, // new parent vnode
  3849. options.children // new children
  3850. );
  3851. },
  3852. insert: function insert (vnode) {
  3853. var context = vnode.context;
  3854. var componentInstance = vnode.componentInstance;
  3855. if (!componentInstance._isMounted) {
  3856. componentInstance._isMounted = true;
  3857. callHook(componentInstance, 'mounted');
  3858. }
  3859. if (vnode.data.keepAlive) {
  3860. if (context._isMounted) {
  3861. // vue-router#1212
  3862. // During updates, a kept-alive component's child components may
  3863. // change, so directly walking the tree here may call activated hooks
  3864. // on incorrect children. Instead we push them into a queue which will
  3865. // be processed after the whole patch process ended.
  3866. queueActivatedComponent(componentInstance);
  3867. } else {
  3868. activateChildComponent(componentInstance, true /* direct */);
  3869. }
  3870. }
  3871. },
  3872. destroy: function destroy (vnode) {
  3873. var componentInstance = vnode.componentInstance;
  3874. if (!componentInstance._isDestroyed) {
  3875. if (!vnode.data.keepAlive) {
  3876. componentInstance.$destroy();
  3877. } else {
  3878. deactivateChildComponent(componentInstance, true /* direct */);
  3879. }
  3880. }
  3881. }
  3882. };
  3883. var hooksToMerge = Object.keys(componentVNodeHooks);
  3884. function createComponent (
  3885. Ctor,
  3886. data,
  3887. context,
  3888. children,
  3889. tag
  3890. ) {
  3891. if (isUndef(Ctor)) {
  3892. return
  3893. }
  3894. var baseCtor = context.$options._base;
  3895. // plain options object: turn it into a constructor
  3896. if (isObject(Ctor)) {
  3897. Ctor = baseCtor.extend(Ctor);
  3898. }
  3899. // if at this stage it's not a constructor or an async component factory,
  3900. // reject.
  3901. if (typeof Ctor !== 'function') {
  3902. {
  3903. warn(("Invalid Component definition: " + (String(Ctor))), context);
  3904. }
  3905. return
  3906. }
  3907. // async component
  3908. var asyncFactory;
  3909. if (isUndef(Ctor.cid)) {
  3910. asyncFactory = Ctor;
  3911. Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
  3912. if (Ctor === undefined) {
  3913. // return a placeholder node for async component, which is rendered
  3914. // as a comment node but preserves all the raw information for the node.
  3915. // the information will be used for async server-rendering and hydration.
  3916. return createAsyncPlaceholder(
  3917. asyncFactory,
  3918. data,
  3919. context,
  3920. children,
  3921. tag
  3922. )
  3923. }
  3924. }
  3925. data = data || {};
  3926. // resolve constructor options in case global mixins are applied after
  3927. // component constructor creation
  3928. resolveConstructorOptions(Ctor);
  3929. // transform component v-model data into props & events
  3930. if (isDef(data.model)) {
  3931. transformModel(Ctor.options, data);
  3932. }
  3933. // extract props
  3934. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  3935. // functional component
  3936. if (isTrue(Ctor.options.functional)) {
  3937. return createFunctionalComponent(Ctor, propsData, data, context, children)
  3938. }
  3939. // extract listeners, since these needs to be treated as
  3940. // child component listeners instead of DOM listeners
  3941. var listeners = data.on;
  3942. // replace with listeners with .native modifier
  3943. // so it gets processed during parent component patch.
  3944. data.on = data.nativeOn;
  3945. if (isTrue(Ctor.options.abstract)) {
  3946. // abstract components do not keep anything
  3947. // other than props & listeners & slot
  3948. // work around flow
  3949. var slot = data.slot;
  3950. data = {};
  3951. if (slot) {
  3952. data.slot = slot;
  3953. }
  3954. }
  3955. // install component management hooks onto the placeholder node
  3956. installComponentHooks(data);
  3957. // return a placeholder vnode
  3958. var name = Ctor.options.name || tag;
  3959. var vnode = new VNode(
  3960. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  3961. data, undefined, undefined, undefined, context,
  3962. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  3963. asyncFactory
  3964. );
  3965. return vnode
  3966. }
  3967. function createComponentInstanceForVnode (
  3968. vnode, // we know it's MountedComponentVNode but flow doesn't
  3969. parent // activeInstance in lifecycle state
  3970. ) {
  3971. var options = {
  3972. _isComponent: true,
  3973. _parentVnode: vnode,
  3974. parent: parent
  3975. };
  3976. // check inline-template render functions
  3977. var inlineTemplate = vnode.data.inlineTemplate;
  3978. if (isDef(inlineTemplate)) {
  3979. options.render = inlineTemplate.render;
  3980. options.staticRenderFns = inlineTemplate.staticRenderFns;
  3981. }
  3982. return new vnode.componentOptions.Ctor(options)
  3983. }
  3984. function installComponentHooks (data) {
  3985. var hooks = data.hook || (data.hook = {});
  3986. for (var i = 0; i < hooksToMerge.length; i++) {
  3987. var key = hooksToMerge[i];
  3988. var existing = hooks[key];
  3989. var toMerge = componentVNodeHooks[key];
  3990. if (existing !== toMerge && !(existing && existing._merged)) {
  3991. hooks[key] = existing ? mergeHook$1(toMerge, existing) : toMerge;
  3992. }
  3993. }
  3994. }
  3995. function mergeHook$1 (f1, f2) {
  3996. var merged = function (a, b) {
  3997. // flow complains about extra args which is why we use any
  3998. f1(a, b);
  3999. f2(a, b);
  4000. };
  4001. merged._merged = true;
  4002. return merged
  4003. }
  4004. // transform component v-model info (value and callback) into
  4005. // prop and event handler respectively.
  4006. function transformModel (options, data) {
  4007. var prop = (options.model && options.model.prop) || 'value';
  4008. var event = (options.model && options.model.event) || 'input'
  4009. ;(data.props || (data.props = {}))[prop] = data.model.value;
  4010. var on = data.on || (data.on = {});
  4011. var existing = on[event];
  4012. var callback = data.model.callback;
  4013. if (isDef(existing)) {
  4014. if (
  4015. Array.isArray(existing)
  4016. ? existing.indexOf(callback) === -1
  4017. : existing !== callback
  4018. ) {
  4019. on[event] = [callback].concat(existing);
  4020. }
  4021. } else {
  4022. on[event] = callback;
  4023. }
  4024. }
  4025. /* */
  4026. var SIMPLE_NORMALIZE = 1;
  4027. var ALWAYS_NORMALIZE = 2;
  4028. // wrapper function for providing a more flexible interface
  4029. // without getting yelled at by flow
  4030. function createElement (
  4031. context,
  4032. tag,
  4033. data,
  4034. children,
  4035. normalizationType,
  4036. alwaysNormalize
  4037. ) {
  4038. if (Array.isArray(data) || isPrimitive(data)) {
  4039. normalizationType = children;
  4040. children = data;
  4041. data = undefined;
  4042. }
  4043. if (isTrue(alwaysNormalize)) {
  4044. normalizationType = ALWAYS_NORMALIZE;
  4045. }
  4046. return _createElement(context, tag, data, children, normalizationType)
  4047. }
  4048. function _createElement (
  4049. context,
  4050. tag,
  4051. data,
  4052. children,
  4053. normalizationType
  4054. ) {
  4055. if (isDef(data) && isDef((data).__ob__)) {
  4056. warn(
  4057. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  4058. 'Always create fresh vnode data objects in each render!',
  4059. context
  4060. );
  4061. return createEmptyVNode()
  4062. }
  4063. // object syntax in v-bind
  4064. if (isDef(data) && isDef(data.is)) {
  4065. tag = data.is;
  4066. }
  4067. if (!tag) {
  4068. // in case of component :is set to falsy value
  4069. return createEmptyVNode()
  4070. }
  4071. // warn against non-primitive key
  4072. if (isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  4073. ) {
  4074. {
  4075. warn(
  4076. 'Avoid using non-primitive value as key, ' +
  4077. 'use string/number value instead.',
  4078. context
  4079. );
  4080. }
  4081. }
  4082. // support single function children as default scoped slot
  4083. if (Array.isArray(children) &&
  4084. typeof children[0] === 'function'
  4085. ) {
  4086. data = data || {};
  4087. data.scopedSlots = { default: children[0] };
  4088. children.length = 0;
  4089. }
  4090. if (normalizationType === ALWAYS_NORMALIZE) {
  4091. children = normalizeChildren(children);
  4092. } else if (normalizationType === SIMPLE_NORMALIZE) {
  4093. children = simpleNormalizeChildren(children);
  4094. }
  4095. var vnode, ns;
  4096. if (typeof tag === 'string') {
  4097. var Ctor;
  4098. ns = (context.$vnode && context.$vnode.ns) || config.getTagNamespace(tag);
  4099. if (config.isReservedTag(tag)) {
  4100. // platform built-in elements
  4101. vnode = new VNode(
  4102. config.parsePlatformTagName(tag), data, children,
  4103. undefined, undefined, context
  4104. );
  4105. } else if ((!data || !data.pre) && isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  4106. // component
  4107. vnode = createComponent(Ctor, data, context, children, tag);
  4108. } else {
  4109. // unknown or unlisted namespaced elements
  4110. // check at runtime because it may get assigned a namespace when its
  4111. // parent normalizes children
  4112. vnode = new VNode(
  4113. tag, data, children,
  4114. undefined, undefined, context
  4115. );
  4116. }
  4117. } else {
  4118. // direct component options / constructor
  4119. vnode = createComponent(tag, data, context, children);
  4120. }
  4121. if (Array.isArray(vnode)) {
  4122. return vnode
  4123. } else if (isDef(vnode)) {
  4124. if (isDef(ns)) { applyNS(vnode, ns); }
  4125. if (isDef(data)) { registerDeepBindings(data); }
  4126. return vnode
  4127. } else {
  4128. return createEmptyVNode()
  4129. }
  4130. }
  4131. function applyNS (vnode, ns, force) {
  4132. vnode.ns = ns;
  4133. if (vnode.tag === 'foreignObject') {
  4134. // use default namespace inside foreignObject
  4135. ns = undefined;
  4136. force = true;
  4137. }
  4138. if (isDef(vnode.children)) {
  4139. for (var i = 0, l = vnode.children.length; i < l; i++) {
  4140. var child = vnode.children[i];
  4141. if (isDef(child.tag) && (
  4142. isUndef(child.ns) || (isTrue(force) && child.tag !== 'svg'))) {
  4143. applyNS(child, ns, force);
  4144. }
  4145. }
  4146. }
  4147. }
  4148. // ref #5318
  4149. // necessary to ensure parent re-render when deep bindings like :style and
  4150. // :class are used on slot nodes
  4151. function registerDeepBindings (data) {
  4152. if (isObject(data.style)) {
  4153. traverse(data.style);
  4154. }
  4155. if (isObject(data.class)) {
  4156. traverse(data.class);
  4157. }
  4158. }
  4159. /* */
  4160. function initRender (vm) {
  4161. vm._vnode = null; // the root of the child tree
  4162. vm._staticTrees = null; // v-once cached trees
  4163. var options = vm.$options;
  4164. var parentVnode = vm.$vnode = options._parentVnode; // the placeholder node in parent tree
  4165. var renderContext = parentVnode && parentVnode.context;
  4166. vm.$slots = resolveSlots(options._renderChildren, renderContext);
  4167. vm.$scopedSlots = emptyObject;
  4168. // bind the createElement fn to this instance
  4169. // so that we get proper render context inside it.
  4170. // args order: tag, data, children, normalizationType, alwaysNormalize
  4171. // internal version is used by render functions compiled from templates
  4172. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  4173. // normalization is always applied for the public version, used in
  4174. // user-written render functions.
  4175. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  4176. // $attrs & $listeners are exposed for easier HOC creation.
  4177. // they need to be reactive so that HOCs using them are always updated
  4178. var parentData = parentVnode && parentVnode.data;
  4179. /* istanbul ignore else */
  4180. {
  4181. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs || emptyObject, function () {
  4182. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  4183. }, true);
  4184. defineReactive$$1(vm, '$listeners', options._parentListeners || emptyObject, function () {
  4185. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  4186. }, true);
  4187. }
  4188. }
  4189. function renderMixin (Vue) {
  4190. // install runtime convenience helpers
  4191. installRenderHelpers(Vue.prototype);
  4192. Vue.prototype.$nextTick = function (fn) {
  4193. return nextTick(fn, this)
  4194. };
  4195. Vue.prototype._render = function () {
  4196. var vm = this;
  4197. var ref = vm.$options;
  4198. var render = ref.render;
  4199. var _parentVnode = ref._parentVnode;
  4200. if (_parentVnode) {
  4201. vm.$scopedSlots = _parentVnode.data.scopedSlots || emptyObject;
  4202. }
  4203. // set parent vnode. this allows render functions to have access
  4204. // to the data on the placeholder node.
  4205. vm.$vnode = _parentVnode;
  4206. // render self
  4207. var vnode;
  4208. try {
  4209. vnode = render.call(vm._renderProxy, vm.$createElement);
  4210. } catch (e) {
  4211. handleError(e, vm, "render");
  4212. // return error render result,
  4213. // or previous vnode to prevent render error causing blank component
  4214. /* istanbul ignore else */
  4215. if (vm.$options.renderError) {
  4216. try {
  4217. vnode = vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e);
  4218. } catch (e) {
  4219. handleError(e, vm, "renderError");
  4220. vnode = vm._vnode;
  4221. }
  4222. } else {
  4223. vnode = vm._vnode;
  4224. }
  4225. }
  4226. // return empty vnode in case the render function errored out
  4227. if (!(vnode instanceof VNode)) {
  4228. if (Array.isArray(vnode)) {
  4229. warn(
  4230. 'Multiple root nodes returned from render function. Render function ' +
  4231. 'should return a single root node.',
  4232. vm
  4233. );
  4234. }
  4235. vnode = createEmptyVNode();
  4236. }
  4237. // set parent
  4238. vnode.parent = _parentVnode;
  4239. return vnode
  4240. };
  4241. }
  4242. /* */
  4243. var uid$3 = 0;
  4244. function initMixin (Vue) {
  4245. Vue.prototype._init = function (options) {
  4246. var vm = this;
  4247. // a uid
  4248. vm._uid = uid$3++;
  4249. var startTag, endTag;
  4250. /* istanbul ignore if */
  4251. if (config.performance && mark) {
  4252. startTag = "vue-perf-start:" + (vm._uid);
  4253. endTag = "vue-perf-end:" + (vm._uid);
  4254. mark(startTag);
  4255. }
  4256. // a flag to avoid this being observed
  4257. vm._isVue = true;
  4258. // merge options
  4259. if (options && options._isComponent) {
  4260. // optimize internal component instantiation
  4261. // since dynamic options merging is pretty slow, and none of the
  4262. // internal component options needs special treatment.
  4263. initInternalComponent(vm, options);
  4264. } else {
  4265. vm.$options = mergeOptions(
  4266. resolveConstructorOptions(vm.constructor),
  4267. options || {},
  4268. vm
  4269. );
  4270. }
  4271. /* istanbul ignore else */
  4272. {
  4273. initProxy(vm);
  4274. }
  4275. // expose real self
  4276. vm._self = vm;
  4277. initLifecycle(vm);
  4278. initEvents(vm);
  4279. initRender(vm);
  4280. callHook(vm, 'beforeCreate');
  4281. initInjections(vm); // resolve injections before data/props
  4282. initState(vm);
  4283. initProvide(vm); // resolve provide after data/props
  4284. callHook(vm, 'created');
  4285. /* istanbul ignore if */
  4286. if (config.performance && mark) {
  4287. vm._name = formatComponentName(vm, false);
  4288. mark(endTag);
  4289. measure(("vue " + (vm._name) + " init"), startTag, endTag);
  4290. }
  4291. if (vm.$options.el) {
  4292. vm.$mount(vm.$options.el);
  4293. }
  4294. };
  4295. }
  4296. function initInternalComponent (vm, options) {
  4297. var opts = vm.$options = Object.create(vm.constructor.options);
  4298. // doing this because it's faster than dynamic enumeration.
  4299. var parentVnode = options._parentVnode;
  4300. opts.parent = options.parent;
  4301. opts._parentVnode = parentVnode;
  4302. var vnodeComponentOptions = parentVnode.componentOptions;
  4303. opts.propsData = vnodeComponentOptions.propsData;
  4304. opts._parentListeners = vnodeComponentOptions.listeners;
  4305. opts._renderChildren = vnodeComponentOptions.children;
  4306. opts._componentTag = vnodeComponentOptions.tag;
  4307. if (options.render) {
  4308. opts.render = options.render;
  4309. opts.staticRenderFns = options.staticRenderFns;
  4310. }
  4311. }
  4312. function resolveConstructorOptions (Ctor) {
  4313. var options = Ctor.options;
  4314. if (Ctor.super) {
  4315. var superOptions = resolveConstructorOptions(Ctor.super);
  4316. var cachedSuperOptions = Ctor.superOptions;
  4317. if (superOptions !== cachedSuperOptions) {
  4318. // super option changed,
  4319. // need to resolve new options.
  4320. Ctor.superOptions = superOptions;
  4321. // check if there are any late-modified/attached options (#4976)
  4322. var modifiedOptions = resolveModifiedOptions(Ctor);
  4323. // update base extend options
  4324. if (modifiedOptions) {
  4325. extend(Ctor.extendOptions, modifiedOptions);
  4326. }
  4327. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  4328. if (options.name) {
  4329. options.components[options.name] = Ctor;
  4330. }
  4331. }
  4332. }
  4333. return options
  4334. }
  4335. function resolveModifiedOptions (Ctor) {
  4336. var modified;
  4337. var latest = Ctor.options;
  4338. var extended = Ctor.extendOptions;
  4339. var sealed = Ctor.sealedOptions;
  4340. for (var key in latest) {
  4341. if (latest[key] !== sealed[key]) {
  4342. if (!modified) { modified = {}; }
  4343. modified[key] = dedupe(latest[key], extended[key], sealed[key]);
  4344. }
  4345. }
  4346. return modified
  4347. }
  4348. function dedupe (latest, extended, sealed) {
  4349. // compare latest and sealed to ensure lifecycle hooks won't be duplicated
  4350. // between merges
  4351. if (Array.isArray(latest)) {
  4352. var res = [];
  4353. sealed = Array.isArray(sealed) ? sealed : [sealed];
  4354. extended = Array.isArray(extended) ? extended : [extended];
  4355. for (var i = 0; i < latest.length; i++) {
  4356. // push original options and not sealed options to exclude duplicated options
  4357. if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) {
  4358. res.push(latest[i]);
  4359. }
  4360. }
  4361. return res
  4362. } else {
  4363. return latest
  4364. }
  4365. }
  4366. function Vue (options) {
  4367. if (!(this instanceof Vue)
  4368. ) {
  4369. warn('Vue is a constructor and should be called with the `new` keyword');
  4370. }
  4371. this._init(options);
  4372. }
  4373. initMixin(Vue);
  4374. stateMixin(Vue);
  4375. eventsMixin(Vue);
  4376. lifecycleMixin(Vue);
  4377. renderMixin(Vue);
  4378. /* */
  4379. function initUse (Vue) {
  4380. Vue.use = function (plugin) {
  4381. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  4382. if (installedPlugins.indexOf(plugin) > -1) {
  4383. return this
  4384. }
  4385. // additional parameters
  4386. var args = toArray(arguments, 1);
  4387. args.unshift(this);
  4388. if (typeof plugin.install === 'function') {
  4389. plugin.install.apply(plugin, args);
  4390. } else if (typeof plugin === 'function') {
  4391. plugin.apply(null, args);
  4392. }
  4393. installedPlugins.push(plugin);
  4394. return this
  4395. };
  4396. }
  4397. /* */
  4398. function initMixin$1 (Vue) {
  4399. Vue.mixin = function (mixin) {
  4400. this.options = mergeOptions(this.options, mixin);
  4401. return this
  4402. };
  4403. }
  4404. /* */
  4405. function initExtend (Vue) {
  4406. /**
  4407. * Each instance constructor, including Vue, has a unique
  4408. * cid. This enables us to create wrapped "child
  4409. * constructors" for prototypal inheritance and cache them.
  4410. */
  4411. Vue.cid = 0;
  4412. var cid = 1;
  4413. /**
  4414. * Class inheritance
  4415. */
  4416. Vue.extend = function (extendOptions) {
  4417. extendOptions = extendOptions || {};
  4418. var Super = this;
  4419. var SuperId = Super.cid;
  4420. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  4421. if (cachedCtors[SuperId]) {
  4422. return cachedCtors[SuperId]
  4423. }
  4424. var name = extendOptions.name || Super.options.name;
  4425. if (name) {
  4426. validateComponentName(name);
  4427. }
  4428. var Sub = function VueComponent (options) {
  4429. this._init(options);
  4430. };
  4431. Sub.prototype = Object.create(Super.prototype);
  4432. Sub.prototype.constructor = Sub;
  4433. Sub.cid = cid++;
  4434. Sub.options = mergeOptions(
  4435. Super.options,
  4436. extendOptions
  4437. );
  4438. Sub['super'] = Super;
  4439. // For props and computed properties, we define the proxy getters on
  4440. // the Vue instances at extension time, on the extended prototype. This
  4441. // avoids Object.defineProperty calls for each instance created.
  4442. if (Sub.options.props) {
  4443. initProps$1(Sub);
  4444. }
  4445. if (Sub.options.computed) {
  4446. initComputed$1(Sub);
  4447. }
  4448. // allow further extension/mixin/plugin usage
  4449. Sub.extend = Super.extend;
  4450. Sub.mixin = Super.mixin;
  4451. Sub.use = Super.use;
  4452. // create asset registers, so extended classes
  4453. // can have their private assets too.
  4454. ASSET_TYPES.forEach(function (type) {
  4455. Sub[type] = Super[type];
  4456. });
  4457. // enable recursive self-lookup
  4458. if (name) {
  4459. Sub.options.components[name] = Sub;
  4460. }
  4461. // keep a reference to the super options at extension time.
  4462. // later at instantiation we can check if Super's options have
  4463. // been updated.
  4464. Sub.superOptions = Super.options;
  4465. Sub.extendOptions = extendOptions;
  4466. Sub.sealedOptions = extend({}, Sub.options);
  4467. // cache constructor
  4468. cachedCtors[SuperId] = Sub;
  4469. return Sub
  4470. };
  4471. }
  4472. function initProps$1 (Comp) {
  4473. var props = Comp.options.props;
  4474. for (var key in props) {
  4475. proxy(Comp.prototype, "_props", key);
  4476. }
  4477. }
  4478. function initComputed$1 (Comp) {
  4479. var computed = Comp.options.computed;
  4480. for (var key in computed) {
  4481. defineComputed(Comp.prototype, key, computed[key]);
  4482. }
  4483. }
  4484. /* */
  4485. function initAssetRegisters (Vue) {
  4486. /**
  4487. * Create asset registration methods.
  4488. */
  4489. ASSET_TYPES.forEach(function (type) {
  4490. Vue[type] = function (
  4491. id,
  4492. definition
  4493. ) {
  4494. if (!definition) {
  4495. return this.options[type + 's'][id]
  4496. } else {
  4497. /* istanbul ignore if */
  4498. if (type === 'component') {
  4499. validateComponentName(id);
  4500. }
  4501. if (type === 'component' && isPlainObject(definition)) {
  4502. definition.name = definition.name || id;
  4503. definition = this.options._base.extend(definition);
  4504. }
  4505. if (type === 'directive' && typeof definition === 'function') {
  4506. definition = { bind: definition, update: definition };
  4507. }
  4508. this.options[type + 's'][id] = definition;
  4509. return definition
  4510. }
  4511. };
  4512. });
  4513. }
  4514. /* */
  4515. function getComponentName (opts) {
  4516. return opts && (opts.Ctor.options.name || opts.tag)
  4517. }
  4518. function matches (pattern, name) {
  4519. if (Array.isArray(pattern)) {
  4520. return pattern.indexOf(name) > -1
  4521. } else if (typeof pattern === 'string') {
  4522. return pattern.split(',').indexOf(name) > -1
  4523. } else if (isRegExp(pattern)) {
  4524. return pattern.test(name)
  4525. }
  4526. /* istanbul ignore next */
  4527. return false
  4528. }
  4529. function pruneCache (keepAliveInstance, filter) {
  4530. var cache = keepAliveInstance.cache;
  4531. var keys = keepAliveInstance.keys;
  4532. var _vnode = keepAliveInstance._vnode;
  4533. for (var key in cache) {
  4534. var cachedNode = cache[key];
  4535. if (cachedNode) {
  4536. var name = getComponentName(cachedNode.componentOptions);
  4537. if (name && !filter(name)) {
  4538. pruneCacheEntry(cache, key, keys, _vnode);
  4539. }
  4540. }
  4541. }
  4542. }
  4543. function pruneCacheEntry (
  4544. cache,
  4545. key,
  4546. keys,
  4547. current
  4548. ) {
  4549. var cached$$1 = cache[key];
  4550. if (cached$$1 && (!current || cached$$1.tag !== current.tag)) {
  4551. cached$$1.componentInstance.$destroy();
  4552. }
  4553. cache[key] = null;
  4554. remove(keys, key);
  4555. }
  4556. var patternTypes = [String, RegExp, Array];
  4557. var KeepAlive = {
  4558. name: 'keep-alive',
  4559. abstract: true,
  4560. props: {
  4561. include: patternTypes,
  4562. exclude: patternTypes,
  4563. max: [String, Number]
  4564. },
  4565. created: function created () {
  4566. this.cache = Object.create(null);
  4567. this.keys = [];
  4568. },
  4569. destroyed: function destroyed () {
  4570. for (var key in this.cache) {
  4571. pruneCacheEntry(this.cache, key, this.keys);
  4572. }
  4573. },
  4574. mounted: function mounted () {
  4575. var this$1 = this;
  4576. this.$watch('include', function (val) {
  4577. pruneCache(this$1, function (name) { return matches(val, name); });
  4578. });
  4579. this.$watch('exclude', function (val) {
  4580. pruneCache(this$1, function (name) { return !matches(val, name); });
  4581. });
  4582. },
  4583. render: function render () {
  4584. var slot = this.$slots.default;
  4585. var vnode = getFirstComponentChild(slot);
  4586. var componentOptions = vnode && vnode.componentOptions;
  4587. if (componentOptions) {
  4588. // check pattern
  4589. var name = getComponentName(componentOptions);
  4590. var ref = this;
  4591. var include = ref.include;
  4592. var exclude = ref.exclude;
  4593. if (
  4594. // not included
  4595. (include && (!name || !matches(include, name))) ||
  4596. // excluded
  4597. (exclude && name && matches(exclude, name))
  4598. ) {
  4599. return vnode
  4600. }
  4601. var ref$1 = this;
  4602. var cache = ref$1.cache;
  4603. var keys = ref$1.keys;
  4604. var key = vnode.key == null
  4605. // same constructor may get registered as different local components
  4606. // so cid alone is not enough (#3269)
  4607. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  4608. : vnode.key;
  4609. if (cache[key]) {
  4610. vnode.componentInstance = cache[key].componentInstance;
  4611. // make current key freshest
  4612. remove(keys, key);
  4613. keys.push(key);
  4614. } else {
  4615. cache[key] = vnode;
  4616. keys.push(key);
  4617. // prune oldest entry
  4618. if (this.max && keys.length > parseInt(this.max)) {
  4619. pruneCacheEntry(cache, keys[0], keys, this._vnode);
  4620. }
  4621. }
  4622. vnode.data.keepAlive = true;
  4623. }
  4624. return vnode || (slot && slot[0])
  4625. }
  4626. };
  4627. var builtInComponents = {
  4628. KeepAlive: KeepAlive
  4629. };
  4630. /* */
  4631. function initGlobalAPI (Vue) {
  4632. // config
  4633. var configDef = {};
  4634. configDef.get = function () { return config; };
  4635. {
  4636. configDef.set = function () {
  4637. warn(
  4638. 'Do not replace the Vue.config object, set individual fields instead.'
  4639. );
  4640. };
  4641. }
  4642. Object.defineProperty(Vue, 'config', configDef);
  4643. // exposed util methods.
  4644. // NOTE: these are not considered part of the public API - avoid relying on
  4645. // them unless you are aware of the risk.
  4646. Vue.util = {
  4647. warn: warn,
  4648. extend: extend,
  4649. mergeOptions: mergeOptions,
  4650. defineReactive: defineReactive$$1
  4651. };
  4652. Vue.set = set;
  4653. Vue.delete = del;
  4654. Vue.nextTick = nextTick;
  4655. Vue.options = Object.create(null);
  4656. ASSET_TYPES.forEach(function (type) {
  4657. Vue.options[type + 's'] = Object.create(null);
  4658. });
  4659. // this is used to identify the "base" constructor to extend all plain-object
  4660. // components with in Weex's multi-instance scenarios.
  4661. Vue.options._base = Vue;
  4662. extend(Vue.options.components, builtInComponents);
  4663. initUse(Vue);
  4664. initMixin$1(Vue);
  4665. initExtend(Vue);
  4666. initAssetRegisters(Vue);
  4667. }
  4668. initGlobalAPI(Vue);
  4669. Object.defineProperty(Vue.prototype, '$isServer', {
  4670. get: isServerRendering
  4671. });
  4672. Object.defineProperty(Vue.prototype, '$ssrContext', {
  4673. get: function get () {
  4674. /* istanbul ignore next */
  4675. return this.$vnode && this.$vnode.ssrContext
  4676. }
  4677. });
  4678. // expose FunctionalRenderContext for ssr runtime helper installation
  4679. Object.defineProperty(Vue, 'FunctionalRenderContext', {
  4680. value: FunctionalRenderContext
  4681. });
  4682. Vue.version = '2.5.21';
  4683. /* */
  4684. // these are reserved for web because they are directly compiled away
  4685. // during template compilation
  4686. var isReservedAttr = makeMap('style,class');
  4687. // attributes that should be using props for binding
  4688. var acceptValue = makeMap('input,textarea,option,select,progress');
  4689. var mustUseProp = function (tag, type, attr) {
  4690. return (
  4691. (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
  4692. (attr === 'selected' && tag === 'option') ||
  4693. (attr === 'checked' && tag === 'input') ||
  4694. (attr === 'muted' && tag === 'video')
  4695. )
  4696. };
  4697. var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
  4698. var isBooleanAttr = makeMap(
  4699. 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
  4700. 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
  4701. 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
  4702. 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
  4703. 'required,reversed,scoped,seamless,selected,sortable,translate,' +
  4704. 'truespeed,typemustmatch,visible'
  4705. );
  4706. var xlinkNS = 'http://www.w3.org/1999/xlink';
  4707. var isXlink = function (name) {
  4708. return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
  4709. };
  4710. var getXlinkProp = function (name) {
  4711. return isXlink(name) ? name.slice(6, name.length) : ''
  4712. };
  4713. var isFalsyAttrValue = function (val) {
  4714. return val == null || val === false
  4715. };
  4716. /* */
  4717. function genClassForVnode (vnode) {
  4718. var data = vnode.data;
  4719. var parentNode = vnode;
  4720. var childNode = vnode;
  4721. while (isDef(childNode.componentInstance)) {
  4722. childNode = childNode.componentInstance._vnode;
  4723. if (childNode && childNode.data) {
  4724. data = mergeClassData(childNode.data, data);
  4725. }
  4726. }
  4727. while (isDef(parentNode = parentNode.parent)) {
  4728. if (parentNode && parentNode.data) {
  4729. data = mergeClassData(data, parentNode.data);
  4730. }
  4731. }
  4732. return renderClass(data.staticClass, data.class)
  4733. }
  4734. function mergeClassData (child, parent) {
  4735. return {
  4736. staticClass: concat(child.staticClass, parent.staticClass),
  4737. class: isDef(child.class)
  4738. ? [child.class, parent.class]
  4739. : parent.class
  4740. }
  4741. }
  4742. function renderClass (
  4743. staticClass,
  4744. dynamicClass
  4745. ) {
  4746. if (isDef(staticClass) || isDef(dynamicClass)) {
  4747. return concat(staticClass, stringifyClass(dynamicClass))
  4748. }
  4749. /* istanbul ignore next */
  4750. return ''
  4751. }
  4752. function concat (a, b) {
  4753. return a ? b ? (a + ' ' + b) : a : (b || '')
  4754. }
  4755. function stringifyClass (value) {
  4756. if (Array.isArray(value)) {
  4757. return stringifyArray(value)
  4758. }
  4759. if (isObject(value)) {
  4760. return stringifyObject(value)
  4761. }
  4762. if (typeof value === 'string') {
  4763. return value
  4764. }
  4765. /* istanbul ignore next */
  4766. return ''
  4767. }
  4768. function stringifyArray (value) {
  4769. var res = '';
  4770. var stringified;
  4771. for (var i = 0, l = value.length; i < l; i++) {
  4772. if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
  4773. if (res) { res += ' '; }
  4774. res += stringified;
  4775. }
  4776. }
  4777. return res
  4778. }
  4779. function stringifyObject (value) {
  4780. var res = '';
  4781. for (var key in value) {
  4782. if (value[key]) {
  4783. if (res) { res += ' '; }
  4784. res += key;
  4785. }
  4786. }
  4787. return res
  4788. }
  4789. /* */
  4790. var namespaceMap = {
  4791. svg: 'http://www.w3.org/2000/svg',
  4792. math: 'http://www.w3.org/1998/Math/MathML'
  4793. };
  4794. var isHTMLTag = makeMap(
  4795. 'html,body,base,head,link,meta,style,title,' +
  4796. 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
  4797. 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
  4798. 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
  4799. 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
  4800. 'embed,object,param,source,canvas,script,noscript,del,ins,' +
  4801. 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
  4802. 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
  4803. 'output,progress,select,textarea,' +
  4804. 'details,dialog,menu,menuitem,summary,' +
  4805. 'content,element,shadow,template,blockquote,iframe,tfoot'
  4806. );
  4807. // this map is intentionally selective, only covering SVG elements that may
  4808. // contain child elements.
  4809. var isSVG = makeMap(
  4810. 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
  4811. 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
  4812. 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
  4813. true
  4814. );
  4815. var isPreTag = function (tag) { return tag === 'pre'; };
  4816. var isReservedTag = function (tag) {
  4817. return isHTMLTag(tag) || isSVG(tag)
  4818. };
  4819. function getTagNamespace (tag) {
  4820. if (isSVG(tag)) {
  4821. return 'svg'
  4822. }
  4823. // basic support for MathML
  4824. // note it doesn't support other MathML elements being component roots
  4825. if (tag === 'math') {
  4826. return 'math'
  4827. }
  4828. }
  4829. var unknownElementCache = Object.create(null);
  4830. function isUnknownElement (tag) {
  4831. /* istanbul ignore if */
  4832. if (!inBrowser) {
  4833. return true
  4834. }
  4835. if (isReservedTag(tag)) {
  4836. return false
  4837. }
  4838. tag = tag.toLowerCase();
  4839. /* istanbul ignore if */
  4840. if (unknownElementCache[tag] != null) {
  4841. return unknownElementCache[tag]
  4842. }
  4843. var el = document.createElement(tag);
  4844. if (tag.indexOf('-') > -1) {
  4845. // http://stackoverflow.com/a/28210364/1070244
  4846. return (unknownElementCache[tag] = (
  4847. el.constructor === window.HTMLUnknownElement ||
  4848. el.constructor === window.HTMLElement
  4849. ))
  4850. } else {
  4851. return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
  4852. }
  4853. }
  4854. var isTextInputType = makeMap('text,number,password,search,email,tel,url');
  4855. /* */
  4856. /**
  4857. * Query an element selector if it's not an element already.
  4858. */
  4859. function query (el) {
  4860. if (typeof el === 'string') {
  4861. var selected = document.querySelector(el);
  4862. if (!selected) {
  4863. warn(
  4864. 'Cannot find element: ' + el
  4865. );
  4866. return document.createElement('div')
  4867. }
  4868. return selected
  4869. } else {
  4870. return el
  4871. }
  4872. }
  4873. /* */
  4874. function createElement$1 (tagName, vnode) {
  4875. var elm = document.createElement(tagName);
  4876. if (tagName !== 'select') {
  4877. return elm
  4878. }
  4879. // false or null will remove the attribute but undefined will not
  4880. if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
  4881. elm.setAttribute('multiple', 'multiple');
  4882. }
  4883. return elm
  4884. }
  4885. function createElementNS (namespace, tagName) {
  4886. return document.createElementNS(namespaceMap[namespace], tagName)
  4887. }
  4888. function createTextNode (text) {
  4889. return document.createTextNode(text)
  4890. }
  4891. function createComment (text) {
  4892. return document.createComment(text)
  4893. }
  4894. function insertBefore (parentNode, newNode, referenceNode) {
  4895. parentNode.insertBefore(newNode, referenceNode);
  4896. }
  4897. function removeChild (node, child) {
  4898. node.removeChild(child);
  4899. }
  4900. function appendChild (node, child) {
  4901. node.appendChild(child);
  4902. }
  4903. function parentNode (node) {
  4904. return node.parentNode
  4905. }
  4906. function nextSibling (node) {
  4907. return node.nextSibling
  4908. }
  4909. function tagName (node) {
  4910. return node.tagName
  4911. }
  4912. function setTextContent (node, text) {
  4913. node.textContent = text;
  4914. }
  4915. function setStyleScope (node, scopeId) {
  4916. node.setAttribute(scopeId, '');
  4917. }
  4918. var nodeOps = /*#__PURE__*/Object.freeze({
  4919. createElement: createElement$1,
  4920. createElementNS: createElementNS,
  4921. createTextNode: createTextNode,
  4922. createComment: createComment,
  4923. insertBefore: insertBefore,
  4924. removeChild: removeChild,
  4925. appendChild: appendChild,
  4926. parentNode: parentNode,
  4927. nextSibling: nextSibling,
  4928. tagName: tagName,
  4929. setTextContent: setTextContent,
  4930. setStyleScope: setStyleScope
  4931. });
  4932. /* */
  4933. var ref = {
  4934. create: function create (_, vnode) {
  4935. registerRef(vnode);
  4936. },
  4937. update: function update (oldVnode, vnode) {
  4938. if (oldVnode.data.ref !== vnode.data.ref) {
  4939. registerRef(oldVnode, true);
  4940. registerRef(vnode);
  4941. }
  4942. },
  4943. destroy: function destroy (vnode) {
  4944. registerRef(vnode, true);
  4945. }
  4946. };
  4947. function registerRef (vnode, isRemoval) {
  4948. var key = vnode.data.ref;
  4949. if (!isDef(key)) { return }
  4950. var vm = vnode.context;
  4951. var ref = vnode.componentInstance || vnode.elm;
  4952. var refs = vm.$refs;
  4953. if (isRemoval) {
  4954. if (Array.isArray(refs[key])) {
  4955. remove(refs[key], ref);
  4956. } else if (refs[key] === ref) {
  4957. refs[key] = undefined;
  4958. }
  4959. } else {
  4960. if (vnode.data.refInFor) {
  4961. if (!Array.isArray(refs[key])) {
  4962. refs[key] = [ref];
  4963. } else if (refs[key].indexOf(ref) < 0) {
  4964. // $flow-disable-line
  4965. refs[key].push(ref);
  4966. }
  4967. } else {
  4968. refs[key] = ref;
  4969. }
  4970. }
  4971. }
  4972. /**
  4973. * Virtual DOM patching algorithm based on Snabbdom by
  4974. * Simon Friis Vindum (@paldepind)
  4975. * Licensed under the MIT License
  4976. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  4977. *
  4978. * modified by Evan You (@yyx990803)
  4979. *
  4980. * Not type-checking this because this file is perf-critical and the cost
  4981. * of making flow understand it is not worth it.
  4982. */
  4983. var emptyNode = new VNode('', {}, []);
  4984. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  4985. function sameVnode (a, b) {
  4986. return (
  4987. a.key === b.key && (
  4988. (
  4989. a.tag === b.tag &&
  4990. a.isComment === b.isComment &&
  4991. isDef(a.data) === isDef(b.data) &&
  4992. sameInputType(a, b)
  4993. ) || (
  4994. isTrue(a.isAsyncPlaceholder) &&
  4995. a.asyncFactory === b.asyncFactory &&
  4996. isUndef(b.asyncFactory.error)
  4997. )
  4998. )
  4999. )
  5000. }
  5001. function sameInputType (a, b) {
  5002. if (a.tag !== 'input') { return true }
  5003. var i;
  5004. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  5005. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  5006. return typeA === typeB || isTextInputType(typeA) && isTextInputType(typeB)
  5007. }
  5008. function createKeyToOldIdx (children, beginIdx, endIdx) {
  5009. var i, key;
  5010. var map = {};
  5011. for (i = beginIdx; i <= endIdx; ++i) {
  5012. key = children[i].key;
  5013. if (isDef(key)) { map[key] = i; }
  5014. }
  5015. return map
  5016. }
  5017. function createPatchFunction (backend) {
  5018. var i, j;
  5019. var cbs = {};
  5020. var modules = backend.modules;
  5021. var nodeOps = backend.nodeOps;
  5022. for (i = 0; i < hooks.length; ++i) {
  5023. cbs[hooks[i]] = [];
  5024. for (j = 0; j < modules.length; ++j) {
  5025. if (isDef(modules[j][hooks[i]])) {
  5026. cbs[hooks[i]].push(modules[j][hooks[i]]);
  5027. }
  5028. }
  5029. }
  5030. function emptyNodeAt (elm) {
  5031. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  5032. }
  5033. function createRmCb (childElm, listeners) {
  5034. function remove$$1 () {
  5035. if (--remove$$1.listeners === 0) {
  5036. removeNode(childElm);
  5037. }
  5038. }
  5039. remove$$1.listeners = listeners;
  5040. return remove$$1
  5041. }
  5042. function removeNode (el) {
  5043. var parent = nodeOps.parentNode(el);
  5044. // element may have already been removed due to v-html / v-text
  5045. if (isDef(parent)) {
  5046. nodeOps.removeChild(parent, el);
  5047. }
  5048. }
  5049. function isUnknownElement$$1 (vnode, inVPre) {
  5050. return (
  5051. !inVPre &&
  5052. !vnode.ns &&
  5053. !(
  5054. config.ignoredElements.length &&
  5055. config.ignoredElements.some(function (ignore) {
  5056. return isRegExp(ignore)
  5057. ? ignore.test(vnode.tag)
  5058. : ignore === vnode.tag
  5059. })
  5060. ) &&
  5061. config.isUnknownElement(vnode.tag)
  5062. )
  5063. }
  5064. var creatingElmInVPre = 0;
  5065. function createElm (
  5066. vnode,
  5067. insertedVnodeQueue,
  5068. parentElm,
  5069. refElm,
  5070. nested,
  5071. ownerArray,
  5072. index
  5073. ) {
  5074. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5075. // This vnode was used in a previous render!
  5076. // now it's used as a new node, overwriting its elm would cause
  5077. // potential patch errors down the road when it's used as an insertion
  5078. // reference node. Instead, we clone the node on-demand before creating
  5079. // associated DOM element for it.
  5080. vnode = ownerArray[index] = cloneVNode(vnode);
  5081. }
  5082. vnode.isRootInsert = !nested; // for transition enter check
  5083. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  5084. return
  5085. }
  5086. var data = vnode.data;
  5087. var children = vnode.children;
  5088. var tag = vnode.tag;
  5089. if (isDef(tag)) {
  5090. {
  5091. if (data && data.pre) {
  5092. creatingElmInVPre++;
  5093. }
  5094. if (isUnknownElement$$1(vnode, creatingElmInVPre)) {
  5095. warn(
  5096. 'Unknown custom element: <' + tag + '> - did you ' +
  5097. 'register the component correctly? For recursive components, ' +
  5098. 'make sure to provide the "name" option.',
  5099. vnode.context
  5100. );
  5101. }
  5102. }
  5103. vnode.elm = vnode.ns
  5104. ? nodeOps.createElementNS(vnode.ns, tag)
  5105. : nodeOps.createElement(tag, vnode);
  5106. setScope(vnode);
  5107. /* istanbul ignore if */
  5108. {
  5109. createChildren(vnode, children, insertedVnodeQueue);
  5110. if (isDef(data)) {
  5111. invokeCreateHooks(vnode, insertedVnodeQueue);
  5112. }
  5113. insert(parentElm, vnode.elm, refElm);
  5114. }
  5115. if (data && data.pre) {
  5116. creatingElmInVPre--;
  5117. }
  5118. } else if (isTrue(vnode.isComment)) {
  5119. vnode.elm = nodeOps.createComment(vnode.text);
  5120. insert(parentElm, vnode.elm, refElm);
  5121. } else {
  5122. vnode.elm = nodeOps.createTextNode(vnode.text);
  5123. insert(parentElm, vnode.elm, refElm);
  5124. }
  5125. }
  5126. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5127. var i = vnode.data;
  5128. if (isDef(i)) {
  5129. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  5130. if (isDef(i = i.hook) && isDef(i = i.init)) {
  5131. i(vnode, false /* hydrating */);
  5132. }
  5133. // after calling the init hook, if the vnode is a child component
  5134. // it should've created a child instance and mounted it. the child
  5135. // component also has set the placeholder vnode's elm.
  5136. // in that case we can just return the element and be done.
  5137. if (isDef(vnode.componentInstance)) {
  5138. initComponent(vnode, insertedVnodeQueue);
  5139. insert(parentElm, vnode.elm, refElm);
  5140. if (isTrue(isReactivated)) {
  5141. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  5142. }
  5143. return true
  5144. }
  5145. }
  5146. }
  5147. function initComponent (vnode, insertedVnodeQueue) {
  5148. if (isDef(vnode.data.pendingInsert)) {
  5149. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  5150. vnode.data.pendingInsert = null;
  5151. }
  5152. vnode.elm = vnode.componentInstance.$el;
  5153. if (isPatchable(vnode)) {
  5154. invokeCreateHooks(vnode, insertedVnodeQueue);
  5155. setScope(vnode);
  5156. } else {
  5157. // empty component root.
  5158. // skip all element-related modules except for ref (#3455)
  5159. registerRef(vnode);
  5160. // make sure to invoke the insert hook
  5161. insertedVnodeQueue.push(vnode);
  5162. }
  5163. }
  5164. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  5165. var i;
  5166. // hack for #4339: a reactivated component with inner transition
  5167. // does not trigger because the inner node's created hooks are not called
  5168. // again. It's not ideal to involve module-specific logic in here but
  5169. // there doesn't seem to be a better way to do it.
  5170. var innerNode = vnode;
  5171. while (innerNode.componentInstance) {
  5172. innerNode = innerNode.componentInstance._vnode;
  5173. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  5174. for (i = 0; i < cbs.activate.length; ++i) {
  5175. cbs.activate[i](emptyNode, innerNode);
  5176. }
  5177. insertedVnodeQueue.push(innerNode);
  5178. break
  5179. }
  5180. }
  5181. // unlike a newly created component,
  5182. // a reactivated keep-alive component doesn't insert itself
  5183. insert(parentElm, vnode.elm, refElm);
  5184. }
  5185. function insert (parent, elm, ref$$1) {
  5186. if (isDef(parent)) {
  5187. if (isDef(ref$$1)) {
  5188. if (nodeOps.parentNode(ref$$1) === parent) {
  5189. nodeOps.insertBefore(parent, elm, ref$$1);
  5190. }
  5191. } else {
  5192. nodeOps.appendChild(parent, elm);
  5193. }
  5194. }
  5195. }
  5196. function createChildren (vnode, children, insertedVnodeQueue) {
  5197. if (Array.isArray(children)) {
  5198. {
  5199. checkDuplicateKeys(children);
  5200. }
  5201. for (var i = 0; i < children.length; ++i) {
  5202. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true, children, i);
  5203. }
  5204. } else if (isPrimitive(vnode.text)) {
  5205. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(String(vnode.text)));
  5206. }
  5207. }
  5208. function isPatchable (vnode) {
  5209. while (vnode.componentInstance) {
  5210. vnode = vnode.componentInstance._vnode;
  5211. }
  5212. return isDef(vnode.tag)
  5213. }
  5214. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  5215. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  5216. cbs.create[i$1](emptyNode, vnode);
  5217. }
  5218. i = vnode.data.hook; // Reuse variable
  5219. if (isDef(i)) {
  5220. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  5221. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  5222. }
  5223. }
  5224. // set scope id attribute for scoped CSS.
  5225. // this is implemented as a special case to avoid the overhead
  5226. // of going through the normal attribute patching process.
  5227. function setScope (vnode) {
  5228. var i;
  5229. if (isDef(i = vnode.fnScopeId)) {
  5230. nodeOps.setStyleScope(vnode.elm, i);
  5231. } else {
  5232. var ancestor = vnode;
  5233. while (ancestor) {
  5234. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  5235. nodeOps.setStyleScope(vnode.elm, i);
  5236. }
  5237. ancestor = ancestor.parent;
  5238. }
  5239. }
  5240. // for slot content they should also get the scopeId from the host instance.
  5241. if (isDef(i = activeInstance) &&
  5242. i !== vnode.context &&
  5243. i !== vnode.fnContext &&
  5244. isDef(i = i.$options._scopeId)
  5245. ) {
  5246. nodeOps.setStyleScope(vnode.elm, i);
  5247. }
  5248. }
  5249. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  5250. for (; startIdx <= endIdx; ++startIdx) {
  5251. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm, false, vnodes, startIdx);
  5252. }
  5253. }
  5254. function invokeDestroyHook (vnode) {
  5255. var i, j;
  5256. var data = vnode.data;
  5257. if (isDef(data)) {
  5258. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  5259. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  5260. }
  5261. if (isDef(i = vnode.children)) {
  5262. for (j = 0; j < vnode.children.length; ++j) {
  5263. invokeDestroyHook(vnode.children[j]);
  5264. }
  5265. }
  5266. }
  5267. function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
  5268. for (; startIdx <= endIdx; ++startIdx) {
  5269. var ch = vnodes[startIdx];
  5270. if (isDef(ch)) {
  5271. if (isDef(ch.tag)) {
  5272. removeAndInvokeRemoveHook(ch);
  5273. invokeDestroyHook(ch);
  5274. } else { // Text node
  5275. removeNode(ch.elm);
  5276. }
  5277. }
  5278. }
  5279. }
  5280. function removeAndInvokeRemoveHook (vnode, rm) {
  5281. if (isDef(rm) || isDef(vnode.data)) {
  5282. var i;
  5283. var listeners = cbs.remove.length + 1;
  5284. if (isDef(rm)) {
  5285. // we have a recursively passed down rm callback
  5286. // increase the listeners count
  5287. rm.listeners += listeners;
  5288. } else {
  5289. // directly removing
  5290. rm = createRmCb(vnode.elm, listeners);
  5291. }
  5292. // recursively invoke hooks on child component root node
  5293. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  5294. removeAndInvokeRemoveHook(i, rm);
  5295. }
  5296. for (i = 0; i < cbs.remove.length; ++i) {
  5297. cbs.remove[i](vnode, rm);
  5298. }
  5299. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  5300. i(vnode, rm);
  5301. } else {
  5302. rm();
  5303. }
  5304. } else {
  5305. removeNode(vnode.elm);
  5306. }
  5307. }
  5308. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  5309. var oldStartIdx = 0;
  5310. var newStartIdx = 0;
  5311. var oldEndIdx = oldCh.length - 1;
  5312. var oldStartVnode = oldCh[0];
  5313. var oldEndVnode = oldCh[oldEndIdx];
  5314. var newEndIdx = newCh.length - 1;
  5315. var newStartVnode = newCh[0];
  5316. var newEndVnode = newCh[newEndIdx];
  5317. var oldKeyToIdx, idxInOld, vnodeToMove, refElm;
  5318. // removeOnly is a special flag used only by <transition-group>
  5319. // to ensure removed elements stay in correct relative positions
  5320. // during leaving transitions
  5321. var canMove = !removeOnly;
  5322. {
  5323. checkDuplicateKeys(newCh);
  5324. }
  5325. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  5326. if (isUndef(oldStartVnode)) {
  5327. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  5328. } else if (isUndef(oldEndVnode)) {
  5329. oldEndVnode = oldCh[--oldEndIdx];
  5330. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  5331. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5332. oldStartVnode = oldCh[++oldStartIdx];
  5333. newStartVnode = newCh[++newStartIdx];
  5334. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  5335. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5336. oldEndVnode = oldCh[--oldEndIdx];
  5337. newEndVnode = newCh[--newEndIdx];
  5338. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  5339. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue, newCh, newEndIdx);
  5340. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  5341. oldStartVnode = oldCh[++oldStartIdx];
  5342. newEndVnode = newCh[--newEndIdx];
  5343. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  5344. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5345. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  5346. oldEndVnode = oldCh[--oldEndIdx];
  5347. newStartVnode = newCh[++newStartIdx];
  5348. } else {
  5349. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  5350. idxInOld = isDef(newStartVnode.key)
  5351. ? oldKeyToIdx[newStartVnode.key]
  5352. : findIdxInOld(newStartVnode, oldCh, oldStartIdx, oldEndIdx);
  5353. if (isUndef(idxInOld)) { // New element
  5354. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5355. } else {
  5356. vnodeToMove = oldCh[idxInOld];
  5357. if (sameVnode(vnodeToMove, newStartVnode)) {
  5358. patchVnode(vnodeToMove, newStartVnode, insertedVnodeQueue, newCh, newStartIdx);
  5359. oldCh[idxInOld] = undefined;
  5360. canMove && nodeOps.insertBefore(parentElm, vnodeToMove.elm, oldStartVnode.elm);
  5361. } else {
  5362. // same key but different element. treat as new element
  5363. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm, false, newCh, newStartIdx);
  5364. }
  5365. }
  5366. newStartVnode = newCh[++newStartIdx];
  5367. }
  5368. }
  5369. if (oldStartIdx > oldEndIdx) {
  5370. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  5371. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  5372. } else if (newStartIdx > newEndIdx) {
  5373. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  5374. }
  5375. }
  5376. function checkDuplicateKeys (children) {
  5377. var seenKeys = {};
  5378. for (var i = 0; i < children.length; i++) {
  5379. var vnode = children[i];
  5380. var key = vnode.key;
  5381. if (isDef(key)) {
  5382. if (seenKeys[key]) {
  5383. warn(
  5384. ("Duplicate keys detected: '" + key + "'. This may cause an update error."),
  5385. vnode.context
  5386. );
  5387. } else {
  5388. seenKeys[key] = true;
  5389. }
  5390. }
  5391. }
  5392. }
  5393. function findIdxInOld (node, oldCh, start, end) {
  5394. for (var i = start; i < end; i++) {
  5395. var c = oldCh[i];
  5396. if (isDef(c) && sameVnode(node, c)) { return i }
  5397. }
  5398. }
  5399. function patchVnode (
  5400. oldVnode,
  5401. vnode,
  5402. insertedVnodeQueue,
  5403. ownerArray,
  5404. index,
  5405. removeOnly
  5406. ) {
  5407. if (oldVnode === vnode) {
  5408. return
  5409. }
  5410. if (isDef(vnode.elm) && isDef(ownerArray)) {
  5411. // clone reused vnode
  5412. vnode = ownerArray[index] = cloneVNode(vnode);
  5413. }
  5414. var elm = vnode.elm = oldVnode.elm;
  5415. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  5416. if (isDef(vnode.asyncFactory.resolved)) {
  5417. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  5418. } else {
  5419. vnode.isAsyncPlaceholder = true;
  5420. }
  5421. return
  5422. }
  5423. // reuse element for static trees.
  5424. // note we only do this if the vnode is cloned -
  5425. // if the new node is not cloned it means the render functions have been
  5426. // reset by the hot-reload-api and we need to do a proper re-render.
  5427. if (isTrue(vnode.isStatic) &&
  5428. isTrue(oldVnode.isStatic) &&
  5429. vnode.key === oldVnode.key &&
  5430. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  5431. ) {
  5432. vnode.componentInstance = oldVnode.componentInstance;
  5433. return
  5434. }
  5435. var i;
  5436. var data = vnode.data;
  5437. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  5438. i(oldVnode, vnode);
  5439. }
  5440. var oldCh = oldVnode.children;
  5441. var ch = vnode.children;
  5442. if (isDef(data) && isPatchable(vnode)) {
  5443. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  5444. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  5445. }
  5446. if (isUndef(vnode.text)) {
  5447. if (isDef(oldCh) && isDef(ch)) {
  5448. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  5449. } else if (isDef(ch)) {
  5450. {
  5451. checkDuplicateKeys(ch);
  5452. }
  5453. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  5454. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  5455. } else if (isDef(oldCh)) {
  5456. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  5457. } else if (isDef(oldVnode.text)) {
  5458. nodeOps.setTextContent(elm, '');
  5459. }
  5460. } else if (oldVnode.text !== vnode.text) {
  5461. nodeOps.setTextContent(elm, vnode.text);
  5462. }
  5463. if (isDef(data)) {
  5464. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  5465. }
  5466. }
  5467. function invokeInsertHook (vnode, queue, initial) {
  5468. // delay insert hooks for component root nodes, invoke them after the
  5469. // element is really inserted
  5470. if (isTrue(initial) && isDef(vnode.parent)) {
  5471. vnode.parent.data.pendingInsert = queue;
  5472. } else {
  5473. for (var i = 0; i < queue.length; ++i) {
  5474. queue[i].data.hook.insert(queue[i]);
  5475. }
  5476. }
  5477. }
  5478. var hydrationBailed = false;
  5479. // list of modules that can skip create hook during hydration because they
  5480. // are already rendered on the client or has no need for initialization
  5481. // Note: style is excluded because it relies on initial clone for future
  5482. // deep updates (#7063).
  5483. var isRenderedModule = makeMap('attrs,class,staticClass,staticStyle,key');
  5484. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  5485. function hydrate (elm, vnode, insertedVnodeQueue, inVPre) {
  5486. var i;
  5487. var tag = vnode.tag;
  5488. var data = vnode.data;
  5489. var children = vnode.children;
  5490. inVPre = inVPre || (data && data.pre);
  5491. vnode.elm = elm;
  5492. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  5493. vnode.isAsyncPlaceholder = true;
  5494. return true
  5495. }
  5496. // assert node match
  5497. {
  5498. if (!assertNodeMatch(elm, vnode, inVPre)) {
  5499. return false
  5500. }
  5501. }
  5502. if (isDef(data)) {
  5503. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  5504. if (isDef(i = vnode.componentInstance)) {
  5505. // child component. it should have hydrated its own tree.
  5506. initComponent(vnode, insertedVnodeQueue);
  5507. return true
  5508. }
  5509. }
  5510. if (isDef(tag)) {
  5511. if (isDef(children)) {
  5512. // empty element, allow client to pick up and populate children
  5513. if (!elm.hasChildNodes()) {
  5514. createChildren(vnode, children, insertedVnodeQueue);
  5515. } else {
  5516. // v-html and domProps: innerHTML
  5517. if (isDef(i = data) && isDef(i = i.domProps) && isDef(i = i.innerHTML)) {
  5518. if (i !== elm.innerHTML) {
  5519. /* istanbul ignore if */
  5520. if (typeof console !== 'undefined' &&
  5521. !hydrationBailed
  5522. ) {
  5523. hydrationBailed = true;
  5524. console.warn('Parent: ', elm);
  5525. console.warn('server innerHTML: ', i);
  5526. console.warn('client innerHTML: ', elm.innerHTML);
  5527. }
  5528. return false
  5529. }
  5530. } else {
  5531. // iterate and compare children lists
  5532. var childrenMatch = true;
  5533. var childNode = elm.firstChild;
  5534. for (var i$1 = 0; i$1 < children.length; i$1++) {
  5535. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue, inVPre)) {
  5536. childrenMatch = false;
  5537. break
  5538. }
  5539. childNode = childNode.nextSibling;
  5540. }
  5541. // if childNode is not null, it means the actual childNodes list is
  5542. // longer than the virtual children list.
  5543. if (!childrenMatch || childNode) {
  5544. /* istanbul ignore if */
  5545. if (typeof console !== 'undefined' &&
  5546. !hydrationBailed
  5547. ) {
  5548. hydrationBailed = true;
  5549. console.warn('Parent: ', elm);
  5550. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  5551. }
  5552. return false
  5553. }
  5554. }
  5555. }
  5556. }
  5557. if (isDef(data)) {
  5558. var fullInvoke = false;
  5559. for (var key in data) {
  5560. if (!isRenderedModule(key)) {
  5561. fullInvoke = true;
  5562. invokeCreateHooks(vnode, insertedVnodeQueue);
  5563. break
  5564. }
  5565. }
  5566. if (!fullInvoke && data['class']) {
  5567. // ensure collecting deps for deep class bindings for future updates
  5568. traverse(data['class']);
  5569. }
  5570. }
  5571. } else if (elm.data !== vnode.text) {
  5572. elm.data = vnode.text;
  5573. }
  5574. return true
  5575. }
  5576. function assertNodeMatch (node, vnode, inVPre) {
  5577. if (isDef(vnode.tag)) {
  5578. return vnode.tag.indexOf('vue-component') === 0 || (
  5579. !isUnknownElement$$1(vnode, inVPre) &&
  5580. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  5581. )
  5582. } else {
  5583. return node.nodeType === (vnode.isComment ? 8 : 3)
  5584. }
  5585. }
  5586. return function patch (oldVnode, vnode, hydrating, removeOnly) {
  5587. if (isUndef(vnode)) {
  5588. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  5589. return
  5590. }
  5591. var isInitialPatch = false;
  5592. var insertedVnodeQueue = [];
  5593. if (isUndef(oldVnode)) {
  5594. // empty mount (likely as component), create new root element
  5595. isInitialPatch = true;
  5596. createElm(vnode, insertedVnodeQueue);
  5597. } else {
  5598. var isRealElement = isDef(oldVnode.nodeType);
  5599. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  5600. // patch existing root node
  5601. patchVnode(oldVnode, vnode, insertedVnodeQueue, null, null, removeOnly);
  5602. } else {
  5603. if (isRealElement) {
  5604. // mounting to a real element
  5605. // check if this is server-rendered content and if we can perform
  5606. // a successful hydration.
  5607. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  5608. oldVnode.removeAttribute(SSR_ATTR);
  5609. hydrating = true;
  5610. }
  5611. if (isTrue(hydrating)) {
  5612. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  5613. invokeInsertHook(vnode, insertedVnodeQueue, true);
  5614. return oldVnode
  5615. } else {
  5616. warn(
  5617. 'The client-side rendered virtual DOM tree is not matching ' +
  5618. 'server-rendered content. This is likely caused by incorrect ' +
  5619. 'HTML markup, for example nesting block-level elements inside ' +
  5620. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  5621. 'full client-side render.'
  5622. );
  5623. }
  5624. }
  5625. // either not server-rendered, or hydration failed.
  5626. // create an empty node and replace it
  5627. oldVnode = emptyNodeAt(oldVnode);
  5628. }
  5629. // replacing existing element
  5630. var oldElm = oldVnode.elm;
  5631. var parentElm = nodeOps.parentNode(oldElm);
  5632. // create new node
  5633. createElm(
  5634. vnode,
  5635. insertedVnodeQueue,
  5636. // extremely rare edge case: do not insert if old element is in a
  5637. // leaving transition. Only happens when combining transition +
  5638. // keep-alive + HOCs. (#4590)
  5639. oldElm._leaveCb ? null : parentElm,
  5640. nodeOps.nextSibling(oldElm)
  5641. );
  5642. // update parent placeholder node element, recursively
  5643. if (isDef(vnode.parent)) {
  5644. var ancestor = vnode.parent;
  5645. var patchable = isPatchable(vnode);
  5646. while (ancestor) {
  5647. for (var i = 0; i < cbs.destroy.length; ++i) {
  5648. cbs.destroy[i](ancestor);
  5649. }
  5650. ancestor.elm = vnode.elm;
  5651. if (patchable) {
  5652. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  5653. cbs.create[i$1](emptyNode, ancestor);
  5654. }
  5655. // #6513
  5656. // invoke insert hooks that may have been merged by create hooks.
  5657. // e.g. for directives that uses the "inserted" hook.
  5658. var insert = ancestor.data.hook.insert;
  5659. if (insert.merged) {
  5660. // start at index 1 to avoid re-invoking component mounted hook
  5661. for (var i$2 = 1; i$2 < insert.fns.length; i$2++) {
  5662. insert.fns[i$2]();
  5663. }
  5664. }
  5665. } else {
  5666. registerRef(ancestor);
  5667. }
  5668. ancestor = ancestor.parent;
  5669. }
  5670. }
  5671. // destroy old node
  5672. if (isDef(parentElm)) {
  5673. removeVnodes(parentElm, [oldVnode], 0, 0);
  5674. } else if (isDef(oldVnode.tag)) {
  5675. invokeDestroyHook(oldVnode);
  5676. }
  5677. }
  5678. }
  5679. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  5680. return vnode.elm
  5681. }
  5682. }
  5683. /* */
  5684. var directives = {
  5685. create: updateDirectives,
  5686. update: updateDirectives,
  5687. destroy: function unbindDirectives (vnode) {
  5688. updateDirectives(vnode, emptyNode);
  5689. }
  5690. };
  5691. function updateDirectives (oldVnode, vnode) {
  5692. if (oldVnode.data.directives || vnode.data.directives) {
  5693. _update(oldVnode, vnode);
  5694. }
  5695. }
  5696. function _update (oldVnode, vnode) {
  5697. var isCreate = oldVnode === emptyNode;
  5698. var isDestroy = vnode === emptyNode;
  5699. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  5700. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  5701. var dirsWithInsert = [];
  5702. var dirsWithPostpatch = [];
  5703. var key, oldDir, dir;
  5704. for (key in newDirs) {
  5705. oldDir = oldDirs[key];
  5706. dir = newDirs[key];
  5707. if (!oldDir) {
  5708. // new directive, bind
  5709. callHook$1(dir, 'bind', vnode, oldVnode);
  5710. if (dir.def && dir.def.inserted) {
  5711. dirsWithInsert.push(dir);
  5712. }
  5713. } else {
  5714. // existing directive, update
  5715. dir.oldValue = oldDir.value;
  5716. callHook$1(dir, 'update', vnode, oldVnode);
  5717. if (dir.def && dir.def.componentUpdated) {
  5718. dirsWithPostpatch.push(dir);
  5719. }
  5720. }
  5721. }
  5722. if (dirsWithInsert.length) {
  5723. var callInsert = function () {
  5724. for (var i = 0; i < dirsWithInsert.length; i++) {
  5725. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  5726. }
  5727. };
  5728. if (isCreate) {
  5729. mergeVNodeHook(vnode, 'insert', callInsert);
  5730. } else {
  5731. callInsert();
  5732. }
  5733. }
  5734. if (dirsWithPostpatch.length) {
  5735. mergeVNodeHook(vnode, 'postpatch', function () {
  5736. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  5737. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  5738. }
  5739. });
  5740. }
  5741. if (!isCreate) {
  5742. for (key in oldDirs) {
  5743. if (!newDirs[key]) {
  5744. // no longer present, unbind
  5745. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  5746. }
  5747. }
  5748. }
  5749. }
  5750. var emptyModifiers = Object.create(null);
  5751. function normalizeDirectives$1 (
  5752. dirs,
  5753. vm
  5754. ) {
  5755. var res = Object.create(null);
  5756. if (!dirs) {
  5757. // $flow-disable-line
  5758. return res
  5759. }
  5760. var i, dir;
  5761. for (i = 0; i < dirs.length; i++) {
  5762. dir = dirs[i];
  5763. if (!dir.modifiers) {
  5764. // $flow-disable-line
  5765. dir.modifiers = emptyModifiers;
  5766. }
  5767. res[getRawDirName(dir)] = dir;
  5768. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  5769. }
  5770. // $flow-disable-line
  5771. return res
  5772. }
  5773. function getRawDirName (dir) {
  5774. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  5775. }
  5776. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  5777. var fn = dir.def && dir.def[hook];
  5778. if (fn) {
  5779. try {
  5780. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  5781. } catch (e) {
  5782. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  5783. }
  5784. }
  5785. }
  5786. var baseModules = [
  5787. ref,
  5788. directives
  5789. ];
  5790. /* */
  5791. function updateAttrs (oldVnode, vnode) {
  5792. var opts = vnode.componentOptions;
  5793. if (isDef(opts) && opts.Ctor.options.inheritAttrs === false) {
  5794. return
  5795. }
  5796. if (isUndef(oldVnode.data.attrs) && isUndef(vnode.data.attrs)) {
  5797. return
  5798. }
  5799. var key, cur, old;
  5800. var elm = vnode.elm;
  5801. var oldAttrs = oldVnode.data.attrs || {};
  5802. var attrs = vnode.data.attrs || {};
  5803. // clone observed objects, as the user probably wants to mutate it
  5804. if (isDef(attrs.__ob__)) {
  5805. attrs = vnode.data.attrs = extend({}, attrs);
  5806. }
  5807. for (key in attrs) {
  5808. cur = attrs[key];
  5809. old = oldAttrs[key];
  5810. if (old !== cur) {
  5811. setAttr(elm, key, cur);
  5812. }
  5813. }
  5814. // #4391: in IE9, setting type can reset value for input[type=radio]
  5815. // #6666: IE/Edge forces progress value down to 1 before setting a max
  5816. /* istanbul ignore if */
  5817. if ((isIE || isEdge) && attrs.value !== oldAttrs.value) {
  5818. setAttr(elm, 'value', attrs.value);
  5819. }
  5820. for (key in oldAttrs) {
  5821. if (isUndef(attrs[key])) {
  5822. if (isXlink(key)) {
  5823. elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
  5824. } else if (!isEnumeratedAttr(key)) {
  5825. elm.removeAttribute(key);
  5826. }
  5827. }
  5828. }
  5829. }
  5830. function setAttr (el, key, value) {
  5831. if (el.tagName.indexOf('-') > -1) {
  5832. baseSetAttr(el, key, value);
  5833. } else if (isBooleanAttr(key)) {
  5834. // set attribute for blank value
  5835. // e.g. <option disabled>Select one</option>
  5836. if (isFalsyAttrValue(value)) {
  5837. el.removeAttribute(key);
  5838. } else {
  5839. // technically allowfullscreen is a boolean attribute for <iframe>,
  5840. // but Flash expects a value of "true" when used on <embed> tag
  5841. value = key === 'allowfullscreen' && el.tagName === 'EMBED'
  5842. ? 'true'
  5843. : key;
  5844. el.setAttribute(key, value);
  5845. }
  5846. } else if (isEnumeratedAttr(key)) {
  5847. el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
  5848. } else if (isXlink(key)) {
  5849. if (isFalsyAttrValue(value)) {
  5850. el.removeAttributeNS(xlinkNS, getXlinkProp(key));
  5851. } else {
  5852. el.setAttributeNS(xlinkNS, key, value);
  5853. }
  5854. } else {
  5855. baseSetAttr(el, key, value);
  5856. }
  5857. }
  5858. function baseSetAttr (el, key, value) {
  5859. if (isFalsyAttrValue(value)) {
  5860. el.removeAttribute(key);
  5861. } else {
  5862. // #7138: IE10 & 11 fires input event when setting placeholder on
  5863. // <textarea>... block the first input event and remove the blocker
  5864. // immediately.
  5865. /* istanbul ignore if */
  5866. if (
  5867. isIE && !isIE9 &&
  5868. (el.tagName === 'TEXTAREA' || el.tagName === 'INPUT') &&
  5869. key === 'placeholder' && !el.__ieph
  5870. ) {
  5871. var blocker = function (e) {
  5872. e.stopImmediatePropagation();
  5873. el.removeEventListener('input', blocker);
  5874. };
  5875. el.addEventListener('input', blocker);
  5876. // $flow-disable-line
  5877. el.__ieph = true; /* IE placeholder patched */
  5878. }
  5879. el.setAttribute(key, value);
  5880. }
  5881. }
  5882. var attrs = {
  5883. create: updateAttrs,
  5884. update: updateAttrs
  5885. };
  5886. /* */
  5887. function updateClass (oldVnode, vnode) {
  5888. var el = vnode.elm;
  5889. var data = vnode.data;
  5890. var oldData = oldVnode.data;
  5891. if (
  5892. isUndef(data.staticClass) &&
  5893. isUndef(data.class) && (
  5894. isUndef(oldData) || (
  5895. isUndef(oldData.staticClass) &&
  5896. isUndef(oldData.class)
  5897. )
  5898. )
  5899. ) {
  5900. return
  5901. }
  5902. var cls = genClassForVnode(vnode);
  5903. // handle transition classes
  5904. var transitionClass = el._transitionClasses;
  5905. if (isDef(transitionClass)) {
  5906. cls = concat(cls, stringifyClass(transitionClass));
  5907. }
  5908. // set the class
  5909. if (cls !== el._prevClass) {
  5910. el.setAttribute('class', cls);
  5911. el._prevClass = cls;
  5912. }
  5913. }
  5914. var klass = {
  5915. create: updateClass,
  5916. update: updateClass
  5917. };
  5918. /* */
  5919. var validDivisionCharRE = /[\w).+\-_$\]]/;
  5920. function parseFilters (exp) {
  5921. var inSingle = false;
  5922. var inDouble = false;
  5923. var inTemplateString = false;
  5924. var inRegex = false;
  5925. var curly = 0;
  5926. var square = 0;
  5927. var paren = 0;
  5928. var lastFilterIndex = 0;
  5929. var c, prev, i, expression, filters;
  5930. for (i = 0; i < exp.length; i++) {
  5931. prev = c;
  5932. c = exp.charCodeAt(i);
  5933. if (inSingle) {
  5934. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  5935. } else if (inDouble) {
  5936. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  5937. } else if (inTemplateString) {
  5938. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  5939. } else if (inRegex) {
  5940. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  5941. } else if (
  5942. c === 0x7C && // pipe
  5943. exp.charCodeAt(i + 1) !== 0x7C &&
  5944. exp.charCodeAt(i - 1) !== 0x7C &&
  5945. !curly && !square && !paren
  5946. ) {
  5947. if (expression === undefined) {
  5948. // first filter, end of expression
  5949. lastFilterIndex = i + 1;
  5950. expression = exp.slice(0, i).trim();
  5951. } else {
  5952. pushFilter();
  5953. }
  5954. } else {
  5955. switch (c) {
  5956. case 0x22: inDouble = true; break // "
  5957. case 0x27: inSingle = true; break // '
  5958. case 0x60: inTemplateString = true; break // `
  5959. case 0x28: paren++; break // (
  5960. case 0x29: paren--; break // )
  5961. case 0x5B: square++; break // [
  5962. case 0x5D: square--; break // ]
  5963. case 0x7B: curly++; break // {
  5964. case 0x7D: curly--; break // }
  5965. }
  5966. if (c === 0x2f) { // /
  5967. var j = i - 1;
  5968. var p = (void 0);
  5969. // find first non-whitespace prev char
  5970. for (; j >= 0; j--) {
  5971. p = exp.charAt(j);
  5972. if (p !== ' ') { break }
  5973. }
  5974. if (!p || !validDivisionCharRE.test(p)) {
  5975. inRegex = true;
  5976. }
  5977. }
  5978. }
  5979. }
  5980. if (expression === undefined) {
  5981. expression = exp.slice(0, i).trim();
  5982. } else if (lastFilterIndex !== 0) {
  5983. pushFilter();
  5984. }
  5985. function pushFilter () {
  5986. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  5987. lastFilterIndex = i + 1;
  5988. }
  5989. if (filters) {
  5990. for (i = 0; i < filters.length; i++) {
  5991. expression = wrapFilter(expression, filters[i]);
  5992. }
  5993. }
  5994. return expression
  5995. }
  5996. function wrapFilter (exp, filter) {
  5997. var i = filter.indexOf('(');
  5998. if (i < 0) {
  5999. // _f: resolveFilter
  6000. return ("_f(\"" + filter + "\")(" + exp + ")")
  6001. } else {
  6002. var name = filter.slice(0, i);
  6003. var args = filter.slice(i + 1);
  6004. return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
  6005. }
  6006. }
  6007. /* */
  6008. function baseWarn (msg) {
  6009. console.error(("[Vue compiler]: " + msg));
  6010. }
  6011. function pluckModuleFunction (
  6012. modules,
  6013. key
  6014. ) {
  6015. return modules
  6016. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  6017. : []
  6018. }
  6019. function addProp (el, name, value) {
  6020. (el.props || (el.props = [])).push({ name: name, value: value });
  6021. el.plain = false;
  6022. }
  6023. function addAttr (el, name, value) {
  6024. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  6025. el.plain = false;
  6026. }
  6027. // add a raw attr (use this in preTransforms)
  6028. function addRawAttr (el, name, value) {
  6029. el.attrsMap[name] = value;
  6030. el.attrsList.push({ name: name, value: value });
  6031. }
  6032. function addDirective (
  6033. el,
  6034. name,
  6035. rawName,
  6036. value,
  6037. arg,
  6038. modifiers
  6039. ) {
  6040. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  6041. el.plain = false;
  6042. }
  6043. function addHandler (
  6044. el,
  6045. name,
  6046. value,
  6047. modifiers,
  6048. important,
  6049. warn
  6050. ) {
  6051. modifiers = modifiers || emptyObject;
  6052. // warn prevent and passive modifier
  6053. /* istanbul ignore if */
  6054. if (
  6055. warn &&
  6056. modifiers.prevent && modifiers.passive
  6057. ) {
  6058. warn(
  6059. 'passive and prevent can\'t be used together. ' +
  6060. 'Passive handler can\'t prevent default event.'
  6061. );
  6062. }
  6063. // normalize click.right and click.middle since they don't actually fire
  6064. // this is technically browser-specific, but at least for now browsers are
  6065. // the only target envs that have right/middle clicks.
  6066. if (name === 'click') {
  6067. if (modifiers.right) {
  6068. name = 'contextmenu';
  6069. delete modifiers.right;
  6070. } else if (modifiers.middle) {
  6071. name = 'mouseup';
  6072. }
  6073. }
  6074. // check capture modifier
  6075. if (modifiers.capture) {
  6076. delete modifiers.capture;
  6077. name = '!' + name; // mark the event as captured
  6078. }
  6079. if (modifiers.once) {
  6080. delete modifiers.once;
  6081. name = '~' + name; // mark the event as once
  6082. }
  6083. /* istanbul ignore if */
  6084. if (modifiers.passive) {
  6085. delete modifiers.passive;
  6086. name = '&' + name; // mark the event as passive
  6087. }
  6088. var events;
  6089. if (modifiers.native) {
  6090. delete modifiers.native;
  6091. events = el.nativeEvents || (el.nativeEvents = {});
  6092. } else {
  6093. events = el.events || (el.events = {});
  6094. }
  6095. var newHandler = {
  6096. value: value.trim()
  6097. };
  6098. if (modifiers !== emptyObject) {
  6099. newHandler.modifiers = modifiers;
  6100. }
  6101. var handlers = events[name];
  6102. /* istanbul ignore if */
  6103. if (Array.isArray(handlers)) {
  6104. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  6105. } else if (handlers) {
  6106. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  6107. } else {
  6108. events[name] = newHandler;
  6109. }
  6110. el.plain = false;
  6111. }
  6112. function getBindingAttr (
  6113. el,
  6114. name,
  6115. getStatic
  6116. ) {
  6117. var dynamicValue =
  6118. getAndRemoveAttr(el, ':' + name) ||
  6119. getAndRemoveAttr(el, 'v-bind:' + name);
  6120. if (dynamicValue != null) {
  6121. return parseFilters(dynamicValue)
  6122. } else if (getStatic !== false) {
  6123. var staticValue = getAndRemoveAttr(el, name);
  6124. if (staticValue != null) {
  6125. return JSON.stringify(staticValue)
  6126. }
  6127. }
  6128. }
  6129. // note: this only removes the attr from the Array (attrsList) so that it
  6130. // doesn't get processed by processAttrs.
  6131. // By default it does NOT remove it from the map (attrsMap) because the map is
  6132. // needed during codegen.
  6133. function getAndRemoveAttr (
  6134. el,
  6135. name,
  6136. removeFromMap
  6137. ) {
  6138. var val;
  6139. if ((val = el.attrsMap[name]) != null) {
  6140. var list = el.attrsList;
  6141. for (var i = 0, l = list.length; i < l; i++) {
  6142. if (list[i].name === name) {
  6143. list.splice(i, 1);
  6144. break
  6145. }
  6146. }
  6147. }
  6148. if (removeFromMap) {
  6149. delete el.attrsMap[name];
  6150. }
  6151. return val
  6152. }
  6153. /* */
  6154. /**
  6155. * Cross-platform code generation for component v-model
  6156. */
  6157. function genComponentModel (
  6158. el,
  6159. value,
  6160. modifiers
  6161. ) {
  6162. var ref = modifiers || {};
  6163. var number = ref.number;
  6164. var trim = ref.trim;
  6165. var baseValueExpression = '$$v';
  6166. var valueExpression = baseValueExpression;
  6167. if (trim) {
  6168. valueExpression =
  6169. "(typeof " + baseValueExpression + " === 'string'" +
  6170. "? " + baseValueExpression + ".trim()" +
  6171. ": " + baseValueExpression + ")";
  6172. }
  6173. if (number) {
  6174. valueExpression = "_n(" + valueExpression + ")";
  6175. }
  6176. var assignment = genAssignmentCode(value, valueExpression);
  6177. el.model = {
  6178. value: ("(" + value + ")"),
  6179. expression: JSON.stringify(value),
  6180. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  6181. };
  6182. }
  6183. /**
  6184. * Cross-platform codegen helper for generating v-model value assignment code.
  6185. */
  6186. function genAssignmentCode (
  6187. value,
  6188. assignment
  6189. ) {
  6190. var res = parseModel(value);
  6191. if (res.key === null) {
  6192. return (value + "=" + assignment)
  6193. } else {
  6194. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  6195. }
  6196. }
  6197. /**
  6198. * Parse a v-model expression into a base path and a final key segment.
  6199. * Handles both dot-path and possible square brackets.
  6200. *
  6201. * Possible cases:
  6202. *
  6203. * - test
  6204. * - test[key]
  6205. * - test[test1[key]]
  6206. * - test["a"][key]
  6207. * - xxx.test[a[a].test1[key]]
  6208. * - test.xxx.a["asa"][test1[key]]
  6209. *
  6210. */
  6211. var len, str, chr, index$1, expressionPos, expressionEndPos;
  6212. function parseModel (val) {
  6213. // Fix https://github.com/vuejs/vue/pull/7730
  6214. // allow v-model="obj.val " (trailing whitespace)
  6215. val = val.trim();
  6216. len = val.length;
  6217. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  6218. index$1 = val.lastIndexOf('.');
  6219. if (index$1 > -1) {
  6220. return {
  6221. exp: val.slice(0, index$1),
  6222. key: '"' + val.slice(index$1 + 1) + '"'
  6223. }
  6224. } else {
  6225. return {
  6226. exp: val,
  6227. key: null
  6228. }
  6229. }
  6230. }
  6231. str = val;
  6232. index$1 = expressionPos = expressionEndPos = 0;
  6233. while (!eof()) {
  6234. chr = next();
  6235. /* istanbul ignore if */
  6236. if (isStringStart(chr)) {
  6237. parseString(chr);
  6238. } else if (chr === 0x5B) {
  6239. parseBracket(chr);
  6240. }
  6241. }
  6242. return {
  6243. exp: val.slice(0, expressionPos),
  6244. key: val.slice(expressionPos + 1, expressionEndPos)
  6245. }
  6246. }
  6247. function next () {
  6248. return str.charCodeAt(++index$1)
  6249. }
  6250. function eof () {
  6251. return index$1 >= len
  6252. }
  6253. function isStringStart (chr) {
  6254. return chr === 0x22 || chr === 0x27
  6255. }
  6256. function parseBracket (chr) {
  6257. var inBracket = 1;
  6258. expressionPos = index$1;
  6259. while (!eof()) {
  6260. chr = next();
  6261. if (isStringStart(chr)) {
  6262. parseString(chr);
  6263. continue
  6264. }
  6265. if (chr === 0x5B) { inBracket++; }
  6266. if (chr === 0x5D) { inBracket--; }
  6267. if (inBracket === 0) {
  6268. expressionEndPos = index$1;
  6269. break
  6270. }
  6271. }
  6272. }
  6273. function parseString (chr) {
  6274. var stringQuote = chr;
  6275. while (!eof()) {
  6276. chr = next();
  6277. if (chr === stringQuote) {
  6278. break
  6279. }
  6280. }
  6281. }
  6282. /* */
  6283. var warn$1;
  6284. // in some cases, the event used has to be determined at runtime
  6285. // so we used some reserved tokens during compile.
  6286. var RANGE_TOKEN = '__r';
  6287. var CHECKBOX_RADIO_TOKEN = '__c';
  6288. function model (
  6289. el,
  6290. dir,
  6291. _warn
  6292. ) {
  6293. warn$1 = _warn;
  6294. var value = dir.value;
  6295. var modifiers = dir.modifiers;
  6296. var tag = el.tag;
  6297. var type = el.attrsMap.type;
  6298. {
  6299. // inputs with type="file" are read only and setting the input's
  6300. // value will throw an error.
  6301. if (tag === 'input' && type === 'file') {
  6302. warn$1(
  6303. "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
  6304. "File inputs are read only. Use a v-on:change listener instead."
  6305. );
  6306. }
  6307. }
  6308. if (el.component) {
  6309. genComponentModel(el, value, modifiers);
  6310. // component v-model doesn't need extra runtime
  6311. return false
  6312. } else if (tag === 'select') {
  6313. genSelect(el, value, modifiers);
  6314. } else if (tag === 'input' && type === 'checkbox') {
  6315. genCheckboxModel(el, value, modifiers);
  6316. } else if (tag === 'input' && type === 'radio') {
  6317. genRadioModel(el, value, modifiers);
  6318. } else if (tag === 'input' || tag === 'textarea') {
  6319. genDefaultModel(el, value, modifiers);
  6320. } else if (!config.isReservedTag(tag)) {
  6321. genComponentModel(el, value, modifiers);
  6322. // component v-model doesn't need extra runtime
  6323. return false
  6324. } else {
  6325. warn$1(
  6326. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  6327. "v-model is not supported on this element type. " +
  6328. 'If you are working with contenteditable, it\'s recommended to ' +
  6329. 'wrap a library dedicated for that purpose inside a custom component.'
  6330. );
  6331. }
  6332. // ensure runtime directive metadata
  6333. return true
  6334. }
  6335. function genCheckboxModel (
  6336. el,
  6337. value,
  6338. modifiers
  6339. ) {
  6340. var number = modifiers && modifiers.number;
  6341. var valueBinding = getBindingAttr(el, 'value') || 'null';
  6342. var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
  6343. var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
  6344. addProp(el, 'checked',
  6345. "Array.isArray(" + value + ")" +
  6346. "?_i(" + value + "," + valueBinding + ")>-1" + (
  6347. trueValueBinding === 'true'
  6348. ? (":(" + value + ")")
  6349. : (":_q(" + value + "," + trueValueBinding + ")")
  6350. )
  6351. );
  6352. addHandler(el, 'change',
  6353. "var $$a=" + value + "," +
  6354. '$$el=$event.target,' +
  6355. "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
  6356. 'if(Array.isArray($$a)){' +
  6357. "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
  6358. '$$i=_i($$a,$$v);' +
  6359. "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
  6360. "else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
  6361. "}else{" + (genAssignmentCode(value, '$$c')) + "}",
  6362. null, true
  6363. );
  6364. }
  6365. function genRadioModel (
  6366. el,
  6367. value,
  6368. modifiers
  6369. ) {
  6370. var number = modifiers && modifiers.number;
  6371. var valueBinding = getBindingAttr(el, 'value') || 'null';
  6372. valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
  6373. addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
  6374. addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
  6375. }
  6376. function genSelect (
  6377. el,
  6378. value,
  6379. modifiers
  6380. ) {
  6381. var number = modifiers && modifiers.number;
  6382. var selectedVal = "Array.prototype.filter" +
  6383. ".call($event.target.options,function(o){return o.selected})" +
  6384. ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
  6385. "return " + (number ? '_n(val)' : 'val') + "})";
  6386. var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
  6387. var code = "var $$selectedVal = " + selectedVal + ";";
  6388. code = code + " " + (genAssignmentCode(value, assignment));
  6389. addHandler(el, 'change', code, null, true);
  6390. }
  6391. function genDefaultModel (
  6392. el,
  6393. value,
  6394. modifiers
  6395. ) {
  6396. var type = el.attrsMap.type;
  6397. // warn if v-bind:value conflicts with v-model
  6398. // except for inputs with v-bind:type
  6399. {
  6400. var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
  6401. var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
  6402. if (value$1 && !typeBinding) {
  6403. var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
  6404. warn$1(
  6405. binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
  6406. 'because the latter already expands to a value binding internally'
  6407. );
  6408. }
  6409. }
  6410. var ref = modifiers || {};
  6411. var lazy = ref.lazy;
  6412. var number = ref.number;
  6413. var trim = ref.trim;
  6414. var needCompositionGuard = !lazy && type !== 'range';
  6415. var event = lazy
  6416. ? 'change'
  6417. : type === 'range'
  6418. ? RANGE_TOKEN
  6419. : 'input';
  6420. var valueExpression = '$event.target.value';
  6421. if (trim) {
  6422. valueExpression = "$event.target.value.trim()";
  6423. }
  6424. if (number) {
  6425. valueExpression = "_n(" + valueExpression + ")";
  6426. }
  6427. var code = genAssignmentCode(value, valueExpression);
  6428. if (needCompositionGuard) {
  6429. code = "if($event.target.composing)return;" + code;
  6430. }
  6431. addProp(el, 'value', ("(" + value + ")"));
  6432. addHandler(el, event, code, null, true);
  6433. if (trim || number) {
  6434. addHandler(el, 'blur', '$forceUpdate()');
  6435. }
  6436. }
  6437. /* */
  6438. // normalize v-model event tokens that can only be determined at runtime.
  6439. // it's important to place the event as the first in the array because
  6440. // the whole point is ensuring the v-model callback gets called before
  6441. // user-attached handlers.
  6442. function normalizeEvents (on) {
  6443. /* istanbul ignore if */
  6444. if (isDef(on[RANGE_TOKEN])) {
  6445. // IE input[type=range] only supports `change` event
  6446. var event = isIE ? 'change' : 'input';
  6447. on[event] = [].concat(on[RANGE_TOKEN], on[event] || []);
  6448. delete on[RANGE_TOKEN];
  6449. }
  6450. // This was originally intended to fix #4521 but no longer necessary
  6451. // after 2.5. Keeping it for backwards compat with generated code from < 2.4
  6452. /* istanbul ignore if */
  6453. if (isDef(on[CHECKBOX_RADIO_TOKEN])) {
  6454. on.change = [].concat(on[CHECKBOX_RADIO_TOKEN], on.change || []);
  6455. delete on[CHECKBOX_RADIO_TOKEN];
  6456. }
  6457. }
  6458. var target$1;
  6459. function createOnceHandler$1 (event, handler, capture) {
  6460. var _target = target$1; // save current target element in closure
  6461. return function onceHandler () {
  6462. var res = handler.apply(null, arguments);
  6463. if (res !== null) {
  6464. remove$2(event, onceHandler, capture, _target);
  6465. }
  6466. }
  6467. }
  6468. function add$1 (
  6469. event,
  6470. handler,
  6471. capture,
  6472. passive
  6473. ) {
  6474. handler = withMacroTask(handler);
  6475. target$1.addEventListener(
  6476. event,
  6477. handler,
  6478. supportsPassive
  6479. ? { capture: capture, passive: passive }
  6480. : capture
  6481. );
  6482. }
  6483. function remove$2 (
  6484. event,
  6485. handler,
  6486. capture,
  6487. _target
  6488. ) {
  6489. (_target || target$1).removeEventListener(
  6490. event,
  6491. handler._withTask || handler,
  6492. capture
  6493. );
  6494. }
  6495. function updateDOMListeners (oldVnode, vnode) {
  6496. if (isUndef(oldVnode.data.on) && isUndef(vnode.data.on)) {
  6497. return
  6498. }
  6499. var on = vnode.data.on || {};
  6500. var oldOn = oldVnode.data.on || {};
  6501. target$1 = vnode.elm;
  6502. normalizeEvents(on);
  6503. updateListeners(on, oldOn, add$1, remove$2, createOnceHandler$1, vnode.context);
  6504. target$1 = undefined;
  6505. }
  6506. var events = {
  6507. create: updateDOMListeners,
  6508. update: updateDOMListeners
  6509. };
  6510. /* */
  6511. function updateDOMProps (oldVnode, vnode) {
  6512. if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
  6513. return
  6514. }
  6515. var key, cur;
  6516. var elm = vnode.elm;
  6517. var oldProps = oldVnode.data.domProps || {};
  6518. var props = vnode.data.domProps || {};
  6519. // clone observed objects, as the user probably wants to mutate it
  6520. if (isDef(props.__ob__)) {
  6521. props = vnode.data.domProps = extend({}, props);
  6522. }
  6523. for (key in oldProps) {
  6524. if (isUndef(props[key])) {
  6525. elm[key] = '';
  6526. }
  6527. }
  6528. for (key in props) {
  6529. cur = props[key];
  6530. // ignore children if the node has textContent or innerHTML,
  6531. // as these will throw away existing DOM nodes and cause removal errors
  6532. // on subsequent patches (#3360)
  6533. if (key === 'textContent' || key === 'innerHTML') {
  6534. if (vnode.children) { vnode.children.length = 0; }
  6535. if (cur === oldProps[key]) { continue }
  6536. // #6601 work around Chrome version <= 55 bug where single textNode
  6537. // replaced by innerHTML/textContent retains its parentNode property
  6538. if (elm.childNodes.length === 1) {
  6539. elm.removeChild(elm.childNodes[0]);
  6540. }
  6541. }
  6542. if (key === 'value') {
  6543. // store value as _value as well since
  6544. // non-string values will be stringified
  6545. elm._value = cur;
  6546. // avoid resetting cursor position when value is the same
  6547. var strCur = isUndef(cur) ? '' : String(cur);
  6548. if (shouldUpdateValue(elm, strCur)) {
  6549. elm.value = strCur;
  6550. }
  6551. } else {
  6552. elm[key] = cur;
  6553. }
  6554. }
  6555. }
  6556. // check platforms/web/util/attrs.js acceptValue
  6557. function shouldUpdateValue (elm, checkVal) {
  6558. return (!elm.composing && (
  6559. elm.tagName === 'OPTION' ||
  6560. isNotInFocusAndDirty(elm, checkVal) ||
  6561. isDirtyWithModifiers(elm, checkVal)
  6562. ))
  6563. }
  6564. function isNotInFocusAndDirty (elm, checkVal) {
  6565. // return true when textbox (.number and .trim) loses focus and its value is
  6566. // not equal to the updated value
  6567. var notInFocus = true;
  6568. // #6157
  6569. // work around IE bug when accessing document.activeElement in an iframe
  6570. try { notInFocus = document.activeElement !== elm; } catch (e) {}
  6571. return notInFocus && elm.value !== checkVal
  6572. }
  6573. function isDirtyWithModifiers (elm, newVal) {
  6574. var value = elm.value;
  6575. var modifiers = elm._vModifiers; // injected by v-model runtime
  6576. if (isDef(modifiers)) {
  6577. if (modifiers.lazy) {
  6578. // inputs with lazy should only be updated when not in focus
  6579. return false
  6580. }
  6581. if (modifiers.number) {
  6582. return toNumber(value) !== toNumber(newVal)
  6583. }
  6584. if (modifiers.trim) {
  6585. return value.trim() !== newVal.trim()
  6586. }
  6587. }
  6588. return value !== newVal
  6589. }
  6590. var domProps = {
  6591. create: updateDOMProps,
  6592. update: updateDOMProps
  6593. };
  6594. /* */
  6595. var parseStyleText = cached(function (cssText) {
  6596. var res = {};
  6597. var listDelimiter = /;(?![^(]*\))/g;
  6598. var propertyDelimiter = /:(.+)/;
  6599. cssText.split(listDelimiter).forEach(function (item) {
  6600. if (item) {
  6601. var tmp = item.split(propertyDelimiter);
  6602. tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
  6603. }
  6604. });
  6605. return res
  6606. });
  6607. // merge static and dynamic style data on the same vnode
  6608. function normalizeStyleData (data) {
  6609. var style = normalizeStyleBinding(data.style);
  6610. // static style is pre-processed into an object during compilation
  6611. // and is always a fresh object, so it's safe to merge into it
  6612. return data.staticStyle
  6613. ? extend(data.staticStyle, style)
  6614. : style
  6615. }
  6616. // normalize possible array / string values into Object
  6617. function normalizeStyleBinding (bindingStyle) {
  6618. if (Array.isArray(bindingStyle)) {
  6619. return toObject(bindingStyle)
  6620. }
  6621. if (typeof bindingStyle === 'string') {
  6622. return parseStyleText(bindingStyle)
  6623. }
  6624. return bindingStyle
  6625. }
  6626. /**
  6627. * parent component style should be after child's
  6628. * so that parent component's style could override it
  6629. */
  6630. function getStyle (vnode, checkChild) {
  6631. var res = {};
  6632. var styleData;
  6633. if (checkChild) {
  6634. var childNode = vnode;
  6635. while (childNode.componentInstance) {
  6636. childNode = childNode.componentInstance._vnode;
  6637. if (
  6638. childNode && childNode.data &&
  6639. (styleData = normalizeStyleData(childNode.data))
  6640. ) {
  6641. extend(res, styleData);
  6642. }
  6643. }
  6644. }
  6645. if ((styleData = normalizeStyleData(vnode.data))) {
  6646. extend(res, styleData);
  6647. }
  6648. var parentNode = vnode;
  6649. while ((parentNode = parentNode.parent)) {
  6650. if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
  6651. extend(res, styleData);
  6652. }
  6653. }
  6654. return res
  6655. }
  6656. /* */
  6657. var cssVarRE = /^--/;
  6658. var importantRE = /\s*!important$/;
  6659. var setProp = function (el, name, val) {
  6660. /* istanbul ignore if */
  6661. if (cssVarRE.test(name)) {
  6662. el.style.setProperty(name, val);
  6663. } else if (importantRE.test(val)) {
  6664. el.style.setProperty(name, val.replace(importantRE, ''), 'important');
  6665. } else {
  6666. var normalizedName = normalize(name);
  6667. if (Array.isArray(val)) {
  6668. // Support values array created by autoprefixer, e.g.
  6669. // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
  6670. // Set them one by one, and the browser will only set those it can recognize
  6671. for (var i = 0, len = val.length; i < len; i++) {
  6672. el.style[normalizedName] = val[i];
  6673. }
  6674. } else {
  6675. el.style[normalizedName] = val;
  6676. }
  6677. }
  6678. };
  6679. var vendorNames = ['Webkit', 'Moz', 'ms'];
  6680. var emptyStyle;
  6681. var normalize = cached(function (prop) {
  6682. emptyStyle = emptyStyle || document.createElement('div').style;
  6683. prop = camelize(prop);
  6684. if (prop !== 'filter' && (prop in emptyStyle)) {
  6685. return prop
  6686. }
  6687. var capName = prop.charAt(0).toUpperCase() + prop.slice(1);
  6688. for (var i = 0; i < vendorNames.length; i++) {
  6689. var name = vendorNames[i] + capName;
  6690. if (name in emptyStyle) {
  6691. return name
  6692. }
  6693. }
  6694. });
  6695. function updateStyle (oldVnode, vnode) {
  6696. var data = vnode.data;
  6697. var oldData = oldVnode.data;
  6698. if (isUndef(data.staticStyle) && isUndef(data.style) &&
  6699. isUndef(oldData.staticStyle) && isUndef(oldData.style)
  6700. ) {
  6701. return
  6702. }
  6703. var cur, name;
  6704. var el = vnode.elm;
  6705. var oldStaticStyle = oldData.staticStyle;
  6706. var oldStyleBinding = oldData.normalizedStyle || oldData.style || {};
  6707. // if static style exists, stylebinding already merged into it when doing normalizeStyleData
  6708. var oldStyle = oldStaticStyle || oldStyleBinding;
  6709. var style = normalizeStyleBinding(vnode.data.style) || {};
  6710. // store normalized style under a different key for next diff
  6711. // make sure to clone it if it's reactive, since the user likely wants
  6712. // to mutate it.
  6713. vnode.data.normalizedStyle = isDef(style.__ob__)
  6714. ? extend({}, style)
  6715. : style;
  6716. var newStyle = getStyle(vnode, true);
  6717. for (name in oldStyle) {
  6718. if (isUndef(newStyle[name])) {
  6719. setProp(el, name, '');
  6720. }
  6721. }
  6722. for (name in newStyle) {
  6723. cur = newStyle[name];
  6724. if (cur !== oldStyle[name]) {
  6725. // ie9 setting to null has no effect, must use empty string
  6726. setProp(el, name, cur == null ? '' : cur);
  6727. }
  6728. }
  6729. }
  6730. var style = {
  6731. create: updateStyle,
  6732. update: updateStyle
  6733. };
  6734. /* */
  6735. var whitespaceRE = /\s+/;
  6736. /**
  6737. * Add class with compatibility for SVG since classList is not supported on
  6738. * SVG elements in IE
  6739. */
  6740. function addClass (el, cls) {
  6741. /* istanbul ignore if */
  6742. if (!cls || !(cls = cls.trim())) {
  6743. return
  6744. }
  6745. /* istanbul ignore else */
  6746. if (el.classList) {
  6747. if (cls.indexOf(' ') > -1) {
  6748. cls.split(whitespaceRE).forEach(function (c) { return el.classList.add(c); });
  6749. } else {
  6750. el.classList.add(cls);
  6751. }
  6752. } else {
  6753. var cur = " " + (el.getAttribute('class') || '') + " ";
  6754. if (cur.indexOf(' ' + cls + ' ') < 0) {
  6755. el.setAttribute('class', (cur + cls).trim());
  6756. }
  6757. }
  6758. }
  6759. /**
  6760. * Remove class with compatibility for SVG since classList is not supported on
  6761. * SVG elements in IE
  6762. */
  6763. function removeClass (el, cls) {
  6764. /* istanbul ignore if */
  6765. if (!cls || !(cls = cls.trim())) {
  6766. return
  6767. }
  6768. /* istanbul ignore else */
  6769. if (el.classList) {
  6770. if (cls.indexOf(' ') > -1) {
  6771. cls.split(whitespaceRE).forEach(function (c) { return el.classList.remove(c); });
  6772. } else {
  6773. el.classList.remove(cls);
  6774. }
  6775. if (!el.classList.length) {
  6776. el.removeAttribute('class');
  6777. }
  6778. } else {
  6779. var cur = " " + (el.getAttribute('class') || '') + " ";
  6780. var tar = ' ' + cls + ' ';
  6781. while (cur.indexOf(tar) >= 0) {
  6782. cur = cur.replace(tar, ' ');
  6783. }
  6784. cur = cur.trim();
  6785. if (cur) {
  6786. el.setAttribute('class', cur);
  6787. } else {
  6788. el.removeAttribute('class');
  6789. }
  6790. }
  6791. }
  6792. /* */
  6793. function resolveTransition (def$$1) {
  6794. if (!def$$1) {
  6795. return
  6796. }
  6797. /* istanbul ignore else */
  6798. if (typeof def$$1 === 'object') {
  6799. var res = {};
  6800. if (def$$1.css !== false) {
  6801. extend(res, autoCssTransition(def$$1.name || 'v'));
  6802. }
  6803. extend(res, def$$1);
  6804. return res
  6805. } else if (typeof def$$1 === 'string') {
  6806. return autoCssTransition(def$$1)
  6807. }
  6808. }
  6809. var autoCssTransition = cached(function (name) {
  6810. return {
  6811. enterClass: (name + "-enter"),
  6812. enterToClass: (name + "-enter-to"),
  6813. enterActiveClass: (name + "-enter-active"),
  6814. leaveClass: (name + "-leave"),
  6815. leaveToClass: (name + "-leave-to"),
  6816. leaveActiveClass: (name + "-leave-active")
  6817. }
  6818. });
  6819. var hasTransition = inBrowser && !isIE9;
  6820. var TRANSITION = 'transition';
  6821. var ANIMATION = 'animation';
  6822. // Transition property/event sniffing
  6823. var transitionProp = 'transition';
  6824. var transitionEndEvent = 'transitionend';
  6825. var animationProp = 'animation';
  6826. var animationEndEvent = 'animationend';
  6827. if (hasTransition) {
  6828. /* istanbul ignore if */
  6829. if (window.ontransitionend === undefined &&
  6830. window.onwebkittransitionend !== undefined
  6831. ) {
  6832. transitionProp = 'WebkitTransition';
  6833. transitionEndEvent = 'webkitTransitionEnd';
  6834. }
  6835. if (window.onanimationend === undefined &&
  6836. window.onwebkitanimationend !== undefined
  6837. ) {
  6838. animationProp = 'WebkitAnimation';
  6839. animationEndEvent = 'webkitAnimationEnd';
  6840. }
  6841. }
  6842. // binding to window is necessary to make hot reload work in IE in strict mode
  6843. var raf = inBrowser
  6844. ? window.requestAnimationFrame
  6845. ? window.requestAnimationFrame.bind(window)
  6846. : setTimeout
  6847. : /* istanbul ignore next */ function (fn) { return fn(); };
  6848. function nextFrame (fn) {
  6849. raf(function () {
  6850. raf(fn);
  6851. });
  6852. }
  6853. function addTransitionClass (el, cls) {
  6854. var transitionClasses = el._transitionClasses || (el._transitionClasses = []);
  6855. if (transitionClasses.indexOf(cls) < 0) {
  6856. transitionClasses.push(cls);
  6857. addClass(el, cls);
  6858. }
  6859. }
  6860. function removeTransitionClass (el, cls) {
  6861. if (el._transitionClasses) {
  6862. remove(el._transitionClasses, cls);
  6863. }
  6864. removeClass(el, cls);
  6865. }
  6866. function whenTransitionEnds (
  6867. el,
  6868. expectedType,
  6869. cb
  6870. ) {
  6871. var ref = getTransitionInfo(el, expectedType);
  6872. var type = ref.type;
  6873. var timeout = ref.timeout;
  6874. var propCount = ref.propCount;
  6875. if (!type) { return cb() }
  6876. var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
  6877. var ended = 0;
  6878. var end = function () {
  6879. el.removeEventListener(event, onEnd);
  6880. cb();
  6881. };
  6882. var onEnd = function (e) {
  6883. if (e.target === el) {
  6884. if (++ended >= propCount) {
  6885. end();
  6886. }
  6887. }
  6888. };
  6889. setTimeout(function () {
  6890. if (ended < propCount) {
  6891. end();
  6892. }
  6893. }, timeout + 1);
  6894. el.addEventListener(event, onEnd);
  6895. }
  6896. var transformRE = /\b(transform|all)(,|$)/;
  6897. function getTransitionInfo (el, expectedType) {
  6898. var styles = window.getComputedStyle(el);
  6899. // JSDOM may return undefined for transition properties
  6900. var transitionDelays = (styles[transitionProp + 'Delay'] || '').split(', ');
  6901. var transitionDurations = (styles[transitionProp + 'Duration'] || '').split(', ');
  6902. var transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  6903. var animationDelays = (styles[animationProp + 'Delay'] || '').split(', ');
  6904. var animationDurations = (styles[animationProp + 'Duration'] || '').split(', ');
  6905. var animationTimeout = getTimeout(animationDelays, animationDurations);
  6906. var type;
  6907. var timeout = 0;
  6908. var propCount = 0;
  6909. /* istanbul ignore if */
  6910. if (expectedType === TRANSITION) {
  6911. if (transitionTimeout > 0) {
  6912. type = TRANSITION;
  6913. timeout = transitionTimeout;
  6914. propCount = transitionDurations.length;
  6915. }
  6916. } else if (expectedType === ANIMATION) {
  6917. if (animationTimeout > 0) {
  6918. type = ANIMATION;
  6919. timeout = animationTimeout;
  6920. propCount = animationDurations.length;
  6921. }
  6922. } else {
  6923. timeout = Math.max(transitionTimeout, animationTimeout);
  6924. type = timeout > 0
  6925. ? transitionTimeout > animationTimeout
  6926. ? TRANSITION
  6927. : ANIMATION
  6928. : null;
  6929. propCount = type
  6930. ? type === TRANSITION
  6931. ? transitionDurations.length
  6932. : animationDurations.length
  6933. : 0;
  6934. }
  6935. var hasTransform =
  6936. type === TRANSITION &&
  6937. transformRE.test(styles[transitionProp + 'Property']);
  6938. return {
  6939. type: type,
  6940. timeout: timeout,
  6941. propCount: propCount,
  6942. hasTransform: hasTransform
  6943. }
  6944. }
  6945. function getTimeout (delays, durations) {
  6946. /* istanbul ignore next */
  6947. while (delays.length < durations.length) {
  6948. delays = delays.concat(delays);
  6949. }
  6950. return Math.max.apply(null, durations.map(function (d, i) {
  6951. return toMs(d) + toMs(delays[i])
  6952. }))
  6953. }
  6954. // Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
  6955. // in a locale-dependent way, using a comma instead of a dot.
  6956. // If comma is not replaced with a dot, the input will be rounded down (i.e. acting
  6957. // as a floor function) causing unexpected behaviors
  6958. function toMs (s) {
  6959. return Number(s.slice(0, -1).replace(',', '.')) * 1000
  6960. }
  6961. /* */
  6962. function enter (vnode, toggleDisplay) {
  6963. var el = vnode.elm;
  6964. // call leave callback now
  6965. if (isDef(el._leaveCb)) {
  6966. el._leaveCb.cancelled = true;
  6967. el._leaveCb();
  6968. }
  6969. var data = resolveTransition(vnode.data.transition);
  6970. if (isUndef(data)) {
  6971. return
  6972. }
  6973. /* istanbul ignore if */
  6974. if (isDef(el._enterCb) || el.nodeType !== 1) {
  6975. return
  6976. }
  6977. var css = data.css;
  6978. var type = data.type;
  6979. var enterClass = data.enterClass;
  6980. var enterToClass = data.enterToClass;
  6981. var enterActiveClass = data.enterActiveClass;
  6982. var appearClass = data.appearClass;
  6983. var appearToClass = data.appearToClass;
  6984. var appearActiveClass = data.appearActiveClass;
  6985. var beforeEnter = data.beforeEnter;
  6986. var enter = data.enter;
  6987. var afterEnter = data.afterEnter;
  6988. var enterCancelled = data.enterCancelled;
  6989. var beforeAppear = data.beforeAppear;
  6990. var appear = data.appear;
  6991. var afterAppear = data.afterAppear;
  6992. var appearCancelled = data.appearCancelled;
  6993. var duration = data.duration;
  6994. // activeInstance will always be the <transition> component managing this
  6995. // transition. One edge case to check is when the <transition> is placed
  6996. // as the root node of a child component. In that case we need to check
  6997. // <transition>'s parent for appear check.
  6998. var context = activeInstance;
  6999. var transitionNode = activeInstance.$vnode;
  7000. while (transitionNode && transitionNode.parent) {
  7001. transitionNode = transitionNode.parent;
  7002. context = transitionNode.context;
  7003. }
  7004. var isAppear = !context._isMounted || !vnode.isRootInsert;
  7005. if (isAppear && !appear && appear !== '') {
  7006. return
  7007. }
  7008. var startClass = isAppear && appearClass
  7009. ? appearClass
  7010. : enterClass;
  7011. var activeClass = isAppear && appearActiveClass
  7012. ? appearActiveClass
  7013. : enterActiveClass;
  7014. var toClass = isAppear && appearToClass
  7015. ? appearToClass
  7016. : enterToClass;
  7017. var beforeEnterHook = isAppear
  7018. ? (beforeAppear || beforeEnter)
  7019. : beforeEnter;
  7020. var enterHook = isAppear
  7021. ? (typeof appear === 'function' ? appear : enter)
  7022. : enter;
  7023. var afterEnterHook = isAppear
  7024. ? (afterAppear || afterEnter)
  7025. : afterEnter;
  7026. var enterCancelledHook = isAppear
  7027. ? (appearCancelled || enterCancelled)
  7028. : enterCancelled;
  7029. var explicitEnterDuration = toNumber(
  7030. isObject(duration)
  7031. ? duration.enter
  7032. : duration
  7033. );
  7034. if (explicitEnterDuration != null) {
  7035. checkDuration(explicitEnterDuration, 'enter', vnode);
  7036. }
  7037. var expectsCSS = css !== false && !isIE9;
  7038. var userWantsControl = getHookArgumentsLength(enterHook);
  7039. var cb = el._enterCb = once(function () {
  7040. if (expectsCSS) {
  7041. removeTransitionClass(el, toClass);
  7042. removeTransitionClass(el, activeClass);
  7043. }
  7044. if (cb.cancelled) {
  7045. if (expectsCSS) {
  7046. removeTransitionClass(el, startClass);
  7047. }
  7048. enterCancelledHook && enterCancelledHook(el);
  7049. } else {
  7050. afterEnterHook && afterEnterHook(el);
  7051. }
  7052. el._enterCb = null;
  7053. });
  7054. if (!vnode.data.show) {
  7055. // remove pending leave element on enter by injecting an insert hook
  7056. mergeVNodeHook(vnode, 'insert', function () {
  7057. var parent = el.parentNode;
  7058. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  7059. if (pendingNode &&
  7060. pendingNode.tag === vnode.tag &&
  7061. pendingNode.elm._leaveCb
  7062. ) {
  7063. pendingNode.elm._leaveCb();
  7064. }
  7065. enterHook && enterHook(el, cb);
  7066. });
  7067. }
  7068. // start enter transition
  7069. beforeEnterHook && beforeEnterHook(el);
  7070. if (expectsCSS) {
  7071. addTransitionClass(el, startClass);
  7072. addTransitionClass(el, activeClass);
  7073. nextFrame(function () {
  7074. removeTransitionClass(el, startClass);
  7075. if (!cb.cancelled) {
  7076. addTransitionClass(el, toClass);
  7077. if (!userWantsControl) {
  7078. if (isValidDuration(explicitEnterDuration)) {
  7079. setTimeout(cb, explicitEnterDuration);
  7080. } else {
  7081. whenTransitionEnds(el, type, cb);
  7082. }
  7083. }
  7084. }
  7085. });
  7086. }
  7087. if (vnode.data.show) {
  7088. toggleDisplay && toggleDisplay();
  7089. enterHook && enterHook(el, cb);
  7090. }
  7091. if (!expectsCSS && !userWantsControl) {
  7092. cb();
  7093. }
  7094. }
  7095. function leave (vnode, rm) {
  7096. var el = vnode.elm;
  7097. // call enter callback now
  7098. if (isDef(el._enterCb)) {
  7099. el._enterCb.cancelled = true;
  7100. el._enterCb();
  7101. }
  7102. var data = resolveTransition(vnode.data.transition);
  7103. if (isUndef(data) || el.nodeType !== 1) {
  7104. return rm()
  7105. }
  7106. /* istanbul ignore if */
  7107. if (isDef(el._leaveCb)) {
  7108. return
  7109. }
  7110. var css = data.css;
  7111. var type = data.type;
  7112. var leaveClass = data.leaveClass;
  7113. var leaveToClass = data.leaveToClass;
  7114. var leaveActiveClass = data.leaveActiveClass;
  7115. var beforeLeave = data.beforeLeave;
  7116. var leave = data.leave;
  7117. var afterLeave = data.afterLeave;
  7118. var leaveCancelled = data.leaveCancelled;
  7119. var delayLeave = data.delayLeave;
  7120. var duration = data.duration;
  7121. var expectsCSS = css !== false && !isIE9;
  7122. var userWantsControl = getHookArgumentsLength(leave);
  7123. var explicitLeaveDuration = toNumber(
  7124. isObject(duration)
  7125. ? duration.leave
  7126. : duration
  7127. );
  7128. if (isDef(explicitLeaveDuration)) {
  7129. checkDuration(explicitLeaveDuration, 'leave', vnode);
  7130. }
  7131. var cb = el._leaveCb = once(function () {
  7132. if (el.parentNode && el.parentNode._pending) {
  7133. el.parentNode._pending[vnode.key] = null;
  7134. }
  7135. if (expectsCSS) {
  7136. removeTransitionClass(el, leaveToClass);
  7137. removeTransitionClass(el, leaveActiveClass);
  7138. }
  7139. if (cb.cancelled) {
  7140. if (expectsCSS) {
  7141. removeTransitionClass(el, leaveClass);
  7142. }
  7143. leaveCancelled && leaveCancelled(el);
  7144. } else {
  7145. rm();
  7146. afterLeave && afterLeave(el);
  7147. }
  7148. el._leaveCb = null;
  7149. });
  7150. if (delayLeave) {
  7151. delayLeave(performLeave);
  7152. } else {
  7153. performLeave();
  7154. }
  7155. function performLeave () {
  7156. // the delayed leave may have already been cancelled
  7157. if (cb.cancelled) {
  7158. return
  7159. }
  7160. // record leaving element
  7161. if (!vnode.data.show && el.parentNode) {
  7162. (el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key)] = vnode;
  7163. }
  7164. beforeLeave && beforeLeave(el);
  7165. if (expectsCSS) {
  7166. addTransitionClass(el, leaveClass);
  7167. addTransitionClass(el, leaveActiveClass);
  7168. nextFrame(function () {
  7169. removeTransitionClass(el, leaveClass);
  7170. if (!cb.cancelled) {
  7171. addTransitionClass(el, leaveToClass);
  7172. if (!userWantsControl) {
  7173. if (isValidDuration(explicitLeaveDuration)) {
  7174. setTimeout(cb, explicitLeaveDuration);
  7175. } else {
  7176. whenTransitionEnds(el, type, cb);
  7177. }
  7178. }
  7179. }
  7180. });
  7181. }
  7182. leave && leave(el, cb);
  7183. if (!expectsCSS && !userWantsControl) {
  7184. cb();
  7185. }
  7186. }
  7187. }
  7188. // only used in dev mode
  7189. function checkDuration (val, name, vnode) {
  7190. if (typeof val !== 'number') {
  7191. warn(
  7192. "<transition> explicit " + name + " duration is not a valid number - " +
  7193. "got " + (JSON.stringify(val)) + ".",
  7194. vnode.context
  7195. );
  7196. } else if (isNaN(val)) {
  7197. warn(
  7198. "<transition> explicit " + name + " duration is NaN - " +
  7199. 'the duration expression might be incorrect.',
  7200. vnode.context
  7201. );
  7202. }
  7203. }
  7204. function isValidDuration (val) {
  7205. return typeof val === 'number' && !isNaN(val)
  7206. }
  7207. /**
  7208. * Normalize a transition hook's argument length. The hook may be:
  7209. * - a merged hook (invoker) with the original in .fns
  7210. * - a wrapped component method (check ._length)
  7211. * - a plain function (.length)
  7212. */
  7213. function getHookArgumentsLength (fn) {
  7214. if (isUndef(fn)) {
  7215. return false
  7216. }
  7217. var invokerFns = fn.fns;
  7218. if (isDef(invokerFns)) {
  7219. // invoker
  7220. return getHookArgumentsLength(
  7221. Array.isArray(invokerFns)
  7222. ? invokerFns[0]
  7223. : invokerFns
  7224. )
  7225. } else {
  7226. return (fn._length || fn.length) > 1
  7227. }
  7228. }
  7229. function _enter (_, vnode) {
  7230. if (vnode.data.show !== true) {
  7231. enter(vnode);
  7232. }
  7233. }
  7234. var transition = inBrowser ? {
  7235. create: _enter,
  7236. activate: _enter,
  7237. remove: function remove$$1 (vnode, rm) {
  7238. /* istanbul ignore else */
  7239. if (vnode.data.show !== true) {
  7240. leave(vnode, rm);
  7241. } else {
  7242. rm();
  7243. }
  7244. }
  7245. } : {};
  7246. var platformModules = [
  7247. attrs,
  7248. klass,
  7249. events,
  7250. domProps,
  7251. style,
  7252. transition
  7253. ];
  7254. /* */
  7255. // the directive module should be applied last, after all
  7256. // built-in modules have been applied.
  7257. var modules = platformModules.concat(baseModules);
  7258. var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules });
  7259. /**
  7260. * Not type checking this file because flow doesn't like attaching
  7261. * properties to Elements.
  7262. */
  7263. /* istanbul ignore if */
  7264. if (isIE9) {
  7265. // http://www.matts411.com/post/internet-explorer-9-oninput/
  7266. document.addEventListener('selectionchange', function () {
  7267. var el = document.activeElement;
  7268. if (el && el.vmodel) {
  7269. trigger(el, 'input');
  7270. }
  7271. });
  7272. }
  7273. var directive = {
  7274. inserted: function inserted (el, binding, vnode, oldVnode) {
  7275. if (vnode.tag === 'select') {
  7276. // #6903
  7277. if (oldVnode.elm && !oldVnode.elm._vOptions) {
  7278. mergeVNodeHook(vnode, 'postpatch', function () {
  7279. directive.componentUpdated(el, binding, vnode);
  7280. });
  7281. } else {
  7282. setSelected(el, binding, vnode.context);
  7283. }
  7284. el._vOptions = [].map.call(el.options, getValue);
  7285. } else if (vnode.tag === 'textarea' || isTextInputType(el.type)) {
  7286. el._vModifiers = binding.modifiers;
  7287. if (!binding.modifiers.lazy) {
  7288. el.addEventListener('compositionstart', onCompositionStart);
  7289. el.addEventListener('compositionend', onCompositionEnd);
  7290. // Safari < 10.2 & UIWebView doesn't fire compositionend when
  7291. // switching focus before confirming composition choice
  7292. // this also fixes the issue where some browsers e.g. iOS Chrome
  7293. // fires "change" instead of "input" on autocomplete.
  7294. el.addEventListener('change', onCompositionEnd);
  7295. /* istanbul ignore if */
  7296. if (isIE9) {
  7297. el.vmodel = true;
  7298. }
  7299. }
  7300. }
  7301. },
  7302. componentUpdated: function componentUpdated (el, binding, vnode) {
  7303. if (vnode.tag === 'select') {
  7304. setSelected(el, binding, vnode.context);
  7305. // in case the options rendered by v-for have changed,
  7306. // it's possible that the value is out-of-sync with the rendered options.
  7307. // detect such cases and filter out values that no longer has a matching
  7308. // option in the DOM.
  7309. var prevOptions = el._vOptions;
  7310. var curOptions = el._vOptions = [].map.call(el.options, getValue);
  7311. if (curOptions.some(function (o, i) { return !looseEqual(o, prevOptions[i]); })) {
  7312. // trigger change event if
  7313. // no matching option found for at least one value
  7314. var needReset = el.multiple
  7315. ? binding.value.some(function (v) { return hasNoMatchingOption(v, curOptions); })
  7316. : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions);
  7317. if (needReset) {
  7318. trigger(el, 'change');
  7319. }
  7320. }
  7321. }
  7322. }
  7323. };
  7324. function setSelected (el, binding, vm) {
  7325. actuallySetSelected(el, binding, vm);
  7326. /* istanbul ignore if */
  7327. if (isIE || isEdge) {
  7328. setTimeout(function () {
  7329. actuallySetSelected(el, binding, vm);
  7330. }, 0);
  7331. }
  7332. }
  7333. function actuallySetSelected (el, binding, vm) {
  7334. var value = binding.value;
  7335. var isMultiple = el.multiple;
  7336. if (isMultiple && !Array.isArray(value)) {
  7337. warn(
  7338. "<select multiple v-model=\"" + (binding.expression) + "\"> " +
  7339. "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)),
  7340. vm
  7341. );
  7342. return
  7343. }
  7344. var selected, option;
  7345. for (var i = 0, l = el.options.length; i < l; i++) {
  7346. option = el.options[i];
  7347. if (isMultiple) {
  7348. selected = looseIndexOf(value, getValue(option)) > -1;
  7349. if (option.selected !== selected) {
  7350. option.selected = selected;
  7351. }
  7352. } else {
  7353. if (looseEqual(getValue(option), value)) {
  7354. if (el.selectedIndex !== i) {
  7355. el.selectedIndex = i;
  7356. }
  7357. return
  7358. }
  7359. }
  7360. }
  7361. if (!isMultiple) {
  7362. el.selectedIndex = -1;
  7363. }
  7364. }
  7365. function hasNoMatchingOption (value, options) {
  7366. return options.every(function (o) { return !looseEqual(o, value); })
  7367. }
  7368. function getValue (option) {
  7369. return '_value' in option
  7370. ? option._value
  7371. : option.value
  7372. }
  7373. function onCompositionStart (e) {
  7374. e.target.composing = true;
  7375. }
  7376. function onCompositionEnd (e) {
  7377. // prevent triggering an input event for no reason
  7378. if (!e.target.composing) { return }
  7379. e.target.composing = false;
  7380. trigger(e.target, 'input');
  7381. }
  7382. function trigger (el, type) {
  7383. var e = document.createEvent('HTMLEvents');
  7384. e.initEvent(type, true, true);
  7385. el.dispatchEvent(e);
  7386. }
  7387. /* */
  7388. // recursively search for possible transition defined inside the component root
  7389. function locateNode (vnode) {
  7390. return vnode.componentInstance && (!vnode.data || !vnode.data.transition)
  7391. ? locateNode(vnode.componentInstance._vnode)
  7392. : vnode
  7393. }
  7394. var show = {
  7395. bind: function bind (el, ref, vnode) {
  7396. var value = ref.value;
  7397. vnode = locateNode(vnode);
  7398. var transition$$1 = vnode.data && vnode.data.transition;
  7399. var originalDisplay = el.__vOriginalDisplay =
  7400. el.style.display === 'none' ? '' : el.style.display;
  7401. if (value && transition$$1) {
  7402. vnode.data.show = true;
  7403. enter(vnode, function () {
  7404. el.style.display = originalDisplay;
  7405. });
  7406. } else {
  7407. el.style.display = value ? originalDisplay : 'none';
  7408. }
  7409. },
  7410. update: function update (el, ref, vnode) {
  7411. var value = ref.value;
  7412. var oldValue = ref.oldValue;
  7413. /* istanbul ignore if */
  7414. if (!value === !oldValue) { return }
  7415. vnode = locateNode(vnode);
  7416. var transition$$1 = vnode.data && vnode.data.transition;
  7417. if (transition$$1) {
  7418. vnode.data.show = true;
  7419. if (value) {
  7420. enter(vnode, function () {
  7421. el.style.display = el.__vOriginalDisplay;
  7422. });
  7423. } else {
  7424. leave(vnode, function () {
  7425. el.style.display = 'none';
  7426. });
  7427. }
  7428. } else {
  7429. el.style.display = value ? el.__vOriginalDisplay : 'none';
  7430. }
  7431. },
  7432. unbind: function unbind (
  7433. el,
  7434. binding,
  7435. vnode,
  7436. oldVnode,
  7437. isDestroy
  7438. ) {
  7439. if (!isDestroy) {
  7440. el.style.display = el.__vOriginalDisplay;
  7441. }
  7442. }
  7443. };
  7444. var platformDirectives = {
  7445. model: directive,
  7446. show: show
  7447. };
  7448. /* */
  7449. var transitionProps = {
  7450. name: String,
  7451. appear: Boolean,
  7452. css: Boolean,
  7453. mode: String,
  7454. type: String,
  7455. enterClass: String,
  7456. leaveClass: String,
  7457. enterToClass: String,
  7458. leaveToClass: String,
  7459. enterActiveClass: String,
  7460. leaveActiveClass: String,
  7461. appearClass: String,
  7462. appearActiveClass: String,
  7463. appearToClass: String,
  7464. duration: [Number, String, Object]
  7465. };
  7466. // in case the child is also an abstract component, e.g. <keep-alive>
  7467. // we want to recursively retrieve the real component to be rendered
  7468. function getRealChild (vnode) {
  7469. var compOptions = vnode && vnode.componentOptions;
  7470. if (compOptions && compOptions.Ctor.options.abstract) {
  7471. return getRealChild(getFirstComponentChild(compOptions.children))
  7472. } else {
  7473. return vnode
  7474. }
  7475. }
  7476. function extractTransitionData (comp) {
  7477. var data = {};
  7478. var options = comp.$options;
  7479. // props
  7480. for (var key in options.propsData) {
  7481. data[key] = comp[key];
  7482. }
  7483. // events.
  7484. // extract listeners and pass them directly to the transition methods
  7485. var listeners = options._parentListeners;
  7486. for (var key$1 in listeners) {
  7487. data[camelize(key$1)] = listeners[key$1];
  7488. }
  7489. return data
  7490. }
  7491. function placeholder (h, rawChild) {
  7492. if (/\d-keep-alive$/.test(rawChild.tag)) {
  7493. return h('keep-alive', {
  7494. props: rawChild.componentOptions.propsData
  7495. })
  7496. }
  7497. }
  7498. function hasParentTransition (vnode) {
  7499. while ((vnode = vnode.parent)) {
  7500. if (vnode.data.transition) {
  7501. return true
  7502. }
  7503. }
  7504. }
  7505. function isSameChild (child, oldChild) {
  7506. return oldChild.key === child.key && oldChild.tag === child.tag
  7507. }
  7508. var isNotTextNode = function (c) { return c.tag || isAsyncPlaceholder(c); };
  7509. var isVShowDirective = function (d) { return d.name === 'show'; };
  7510. var Transition = {
  7511. name: 'transition',
  7512. props: transitionProps,
  7513. abstract: true,
  7514. render: function render (h) {
  7515. var this$1 = this;
  7516. var children = this.$slots.default;
  7517. if (!children) {
  7518. return
  7519. }
  7520. // filter out text nodes (possible whitespaces)
  7521. children = children.filter(isNotTextNode);
  7522. /* istanbul ignore if */
  7523. if (!children.length) {
  7524. return
  7525. }
  7526. // warn multiple elements
  7527. if (children.length > 1) {
  7528. warn(
  7529. '<transition> can only be used on a single element. Use ' +
  7530. '<transition-group> for lists.',
  7531. this.$parent
  7532. );
  7533. }
  7534. var mode = this.mode;
  7535. // warn invalid mode
  7536. if (mode && mode !== 'in-out' && mode !== 'out-in'
  7537. ) {
  7538. warn(
  7539. 'invalid <transition> mode: ' + mode,
  7540. this.$parent
  7541. );
  7542. }
  7543. var rawChild = children[0];
  7544. // if this is a component root node and the component's
  7545. // parent container node also has transition, skip.
  7546. if (hasParentTransition(this.$vnode)) {
  7547. return rawChild
  7548. }
  7549. // apply transition data to child
  7550. // use getRealChild() to ignore abstract components e.g. keep-alive
  7551. var child = getRealChild(rawChild);
  7552. /* istanbul ignore if */
  7553. if (!child) {
  7554. return rawChild
  7555. }
  7556. if (this._leaving) {
  7557. return placeholder(h, rawChild)
  7558. }
  7559. // ensure a key that is unique to the vnode type and to this transition
  7560. // component instance. This key will be used to remove pending leaving nodes
  7561. // during entering.
  7562. var id = "__transition-" + (this._uid) + "-";
  7563. child.key = child.key == null
  7564. ? child.isComment
  7565. ? id + 'comment'
  7566. : id + child.tag
  7567. : isPrimitive(child.key)
  7568. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  7569. : child.key;
  7570. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  7571. var oldRawChild = this._vnode;
  7572. var oldChild = getRealChild(oldRawChild);
  7573. // mark v-show
  7574. // so that the transition module can hand over the control to the directive
  7575. if (child.data.directives && child.data.directives.some(isVShowDirective)) {
  7576. child.data.show = true;
  7577. }
  7578. if (
  7579. oldChild &&
  7580. oldChild.data &&
  7581. !isSameChild(child, oldChild) &&
  7582. !isAsyncPlaceholder(oldChild) &&
  7583. // #6687 component root is a comment node
  7584. !(oldChild.componentInstance && oldChild.componentInstance._vnode.isComment)
  7585. ) {
  7586. // replace old child transition data with fresh one
  7587. // important for dynamic transitions!
  7588. var oldData = oldChild.data.transition = extend({}, data);
  7589. // handle transition mode
  7590. if (mode === 'out-in') {
  7591. // return placeholder node and queue update when leave finishes
  7592. this._leaving = true;
  7593. mergeVNodeHook(oldData, 'afterLeave', function () {
  7594. this$1._leaving = false;
  7595. this$1.$forceUpdate();
  7596. });
  7597. return placeholder(h, rawChild)
  7598. } else if (mode === 'in-out') {
  7599. if (isAsyncPlaceholder(child)) {
  7600. return oldRawChild
  7601. }
  7602. var delayedLeave;
  7603. var performLeave = function () { delayedLeave(); };
  7604. mergeVNodeHook(data, 'afterEnter', performLeave);
  7605. mergeVNodeHook(data, 'enterCancelled', performLeave);
  7606. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  7607. }
  7608. }
  7609. return rawChild
  7610. }
  7611. };
  7612. /* */
  7613. var props = extend({
  7614. tag: String,
  7615. moveClass: String
  7616. }, transitionProps);
  7617. delete props.mode;
  7618. var TransitionGroup = {
  7619. props: props,
  7620. beforeMount: function beforeMount () {
  7621. var this$1 = this;
  7622. var update = this._update;
  7623. this._update = function (vnode, hydrating) {
  7624. var restoreActiveInstance = setActiveInstance(this$1);
  7625. // force removing pass
  7626. this$1.__patch__(
  7627. this$1._vnode,
  7628. this$1.kept,
  7629. false, // hydrating
  7630. true // removeOnly (!important, avoids unnecessary moves)
  7631. );
  7632. this$1._vnode = this$1.kept;
  7633. restoreActiveInstance();
  7634. update.call(this$1, vnode, hydrating);
  7635. };
  7636. },
  7637. render: function render (h) {
  7638. var tag = this.tag || this.$vnode.data.tag || 'span';
  7639. var map = Object.create(null);
  7640. var prevChildren = this.prevChildren = this.children;
  7641. var rawChildren = this.$slots.default || [];
  7642. var children = this.children = [];
  7643. var transitionData = extractTransitionData(this);
  7644. for (var i = 0; i < rawChildren.length; i++) {
  7645. var c = rawChildren[i];
  7646. if (c.tag) {
  7647. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  7648. children.push(c);
  7649. map[c.key] = c
  7650. ;(c.data || (c.data = {})).transition = transitionData;
  7651. } else {
  7652. var opts = c.componentOptions;
  7653. var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag;
  7654. warn(("<transition-group> children must be keyed: <" + name + ">"));
  7655. }
  7656. }
  7657. }
  7658. if (prevChildren) {
  7659. var kept = [];
  7660. var removed = [];
  7661. for (var i$1 = 0; i$1 < prevChildren.length; i$1++) {
  7662. var c$1 = prevChildren[i$1];
  7663. c$1.data.transition = transitionData;
  7664. c$1.data.pos = c$1.elm.getBoundingClientRect();
  7665. if (map[c$1.key]) {
  7666. kept.push(c$1);
  7667. } else {
  7668. removed.push(c$1);
  7669. }
  7670. }
  7671. this.kept = h(tag, null, kept);
  7672. this.removed = removed;
  7673. }
  7674. return h(tag, null, children)
  7675. },
  7676. updated: function updated () {
  7677. var children = this.prevChildren;
  7678. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  7679. if (!children.length || !this.hasMove(children[0].elm, moveClass)) {
  7680. return
  7681. }
  7682. // we divide the work into three loops to avoid mixing DOM reads and writes
  7683. // in each iteration - which helps prevent layout thrashing.
  7684. children.forEach(callPendingCbs);
  7685. children.forEach(recordPosition);
  7686. children.forEach(applyTranslation);
  7687. // force reflow to put everything in position
  7688. // assign to this to avoid being removed in tree-shaking
  7689. // $flow-disable-line
  7690. this._reflow = document.body.offsetHeight;
  7691. children.forEach(function (c) {
  7692. if (c.data.moved) {
  7693. var el = c.elm;
  7694. var s = el.style;
  7695. addTransitionClass(el, moveClass);
  7696. s.transform = s.WebkitTransform = s.transitionDuration = '';
  7697. el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
  7698. if (e && e.target !== el) {
  7699. return
  7700. }
  7701. if (!e || /transform$/.test(e.propertyName)) {
  7702. el.removeEventListener(transitionEndEvent, cb);
  7703. el._moveCb = null;
  7704. removeTransitionClass(el, moveClass);
  7705. }
  7706. });
  7707. }
  7708. });
  7709. },
  7710. methods: {
  7711. hasMove: function hasMove (el, moveClass) {
  7712. /* istanbul ignore if */
  7713. if (!hasTransition) {
  7714. return false
  7715. }
  7716. /* istanbul ignore if */
  7717. if (this._hasMove) {
  7718. return this._hasMove
  7719. }
  7720. // Detect whether an element with the move class applied has
  7721. // CSS transitions. Since the element may be inside an entering
  7722. // transition at this very moment, we make a clone of it and remove
  7723. // all other transition classes applied to ensure only the move class
  7724. // is applied.
  7725. var clone = el.cloneNode();
  7726. if (el._transitionClasses) {
  7727. el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); });
  7728. }
  7729. addClass(clone, moveClass);
  7730. clone.style.display = 'none';
  7731. this.$el.appendChild(clone);
  7732. var info = getTransitionInfo(clone);
  7733. this.$el.removeChild(clone);
  7734. return (this._hasMove = info.hasTransform)
  7735. }
  7736. }
  7737. };
  7738. function callPendingCbs (c) {
  7739. /* istanbul ignore if */
  7740. if (c.elm._moveCb) {
  7741. c.elm._moveCb();
  7742. }
  7743. /* istanbul ignore if */
  7744. if (c.elm._enterCb) {
  7745. c.elm._enterCb();
  7746. }
  7747. }
  7748. function recordPosition (c) {
  7749. c.data.newPos = c.elm.getBoundingClientRect();
  7750. }
  7751. function applyTranslation (c) {
  7752. var oldPos = c.data.pos;
  7753. var newPos = c.data.newPos;
  7754. var dx = oldPos.left - newPos.left;
  7755. var dy = oldPos.top - newPos.top;
  7756. if (dx || dy) {
  7757. c.data.moved = true;
  7758. var s = c.elm.style;
  7759. s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)";
  7760. s.transitionDuration = '0s';
  7761. }
  7762. }
  7763. var platformComponents = {
  7764. Transition: Transition,
  7765. TransitionGroup: TransitionGroup
  7766. };
  7767. /* */
  7768. // install platform specific utils
  7769. Vue.config.mustUseProp = mustUseProp;
  7770. Vue.config.isReservedTag = isReservedTag;
  7771. Vue.config.isReservedAttr = isReservedAttr;
  7772. Vue.config.getTagNamespace = getTagNamespace;
  7773. Vue.config.isUnknownElement = isUnknownElement;
  7774. // install platform runtime directives & components
  7775. extend(Vue.options.directives, platformDirectives);
  7776. extend(Vue.options.components, platformComponents);
  7777. // install platform patch function
  7778. Vue.prototype.__patch__ = inBrowser ? patch : noop;
  7779. // public mount method
  7780. Vue.prototype.$mount = function (
  7781. el,
  7782. hydrating
  7783. ) {
  7784. el = el && inBrowser ? query(el) : undefined;
  7785. return mountComponent(this, el, hydrating)
  7786. };
  7787. // devtools global hook
  7788. /* istanbul ignore next */
  7789. if (inBrowser) {
  7790. setTimeout(function () {
  7791. if (config.devtools) {
  7792. if (devtools) {
  7793. devtools.emit('init', Vue);
  7794. } else if (
  7795. isChrome
  7796. ) {
  7797. console[console.info ? 'info' : 'log'](
  7798. 'Download the Vue Devtools extension for a better development experience:\n' +
  7799. 'https://github.com/vuejs/vue-devtools'
  7800. );
  7801. }
  7802. }
  7803. if (config.productionTip !== false &&
  7804. typeof console !== 'undefined'
  7805. ) {
  7806. console[console.info ? 'info' : 'log'](
  7807. "You are running Vue in development mode.\n" +
  7808. "Make sure to turn on production mode when deploying for production.\n" +
  7809. "See more tips at https://vuejs.org/guide/deployment.html"
  7810. );
  7811. }
  7812. }, 0);
  7813. }
  7814. /* */
  7815. var defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g;
  7816. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  7817. var buildRegex = cached(function (delimiters) {
  7818. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  7819. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  7820. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  7821. });
  7822. function parseText (
  7823. text,
  7824. delimiters
  7825. ) {
  7826. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  7827. if (!tagRE.test(text)) {
  7828. return
  7829. }
  7830. var tokens = [];
  7831. var rawTokens = [];
  7832. var lastIndex = tagRE.lastIndex = 0;
  7833. var match, index, tokenValue;
  7834. while ((match = tagRE.exec(text))) {
  7835. index = match.index;
  7836. // push text token
  7837. if (index > lastIndex) {
  7838. rawTokens.push(tokenValue = text.slice(lastIndex, index));
  7839. tokens.push(JSON.stringify(tokenValue));
  7840. }
  7841. // tag token
  7842. var exp = parseFilters(match[1].trim());
  7843. tokens.push(("_s(" + exp + ")"));
  7844. rawTokens.push({ '@binding': exp });
  7845. lastIndex = index + match[0].length;
  7846. }
  7847. if (lastIndex < text.length) {
  7848. rawTokens.push(tokenValue = text.slice(lastIndex));
  7849. tokens.push(JSON.stringify(tokenValue));
  7850. }
  7851. return {
  7852. expression: tokens.join('+'),
  7853. tokens: rawTokens
  7854. }
  7855. }
  7856. /* */
  7857. function transformNode (el, options) {
  7858. var warn = options.warn || baseWarn;
  7859. var staticClass = getAndRemoveAttr(el, 'class');
  7860. if (staticClass) {
  7861. var res = parseText(staticClass, options.delimiters);
  7862. if (res) {
  7863. warn(
  7864. "class=\"" + staticClass + "\": " +
  7865. 'Interpolation inside attributes has been removed. ' +
  7866. 'Use v-bind or the colon shorthand instead. For example, ' +
  7867. 'instead of <div class="{{ val }}">, use <div :class="val">.'
  7868. );
  7869. }
  7870. }
  7871. if (staticClass) {
  7872. el.staticClass = JSON.stringify(staticClass);
  7873. }
  7874. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  7875. if (classBinding) {
  7876. el.classBinding = classBinding;
  7877. }
  7878. }
  7879. function genData (el) {
  7880. var data = '';
  7881. if (el.staticClass) {
  7882. data += "staticClass:" + (el.staticClass) + ",";
  7883. }
  7884. if (el.classBinding) {
  7885. data += "class:" + (el.classBinding) + ",";
  7886. }
  7887. return data
  7888. }
  7889. var klass$1 = {
  7890. staticKeys: ['staticClass'],
  7891. transformNode: transformNode,
  7892. genData: genData
  7893. };
  7894. /* */
  7895. function transformNode$1 (el, options) {
  7896. var warn = options.warn || baseWarn;
  7897. var staticStyle = getAndRemoveAttr(el, 'style');
  7898. if (staticStyle) {
  7899. /* istanbul ignore if */
  7900. {
  7901. var res = parseText(staticStyle, options.delimiters);
  7902. if (res) {
  7903. warn(
  7904. "style=\"" + staticStyle + "\": " +
  7905. 'Interpolation inside attributes has been removed. ' +
  7906. 'Use v-bind or the colon shorthand instead. For example, ' +
  7907. 'instead of <div style="{{ val }}">, use <div :style="val">.'
  7908. );
  7909. }
  7910. }
  7911. el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
  7912. }
  7913. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  7914. if (styleBinding) {
  7915. el.styleBinding = styleBinding;
  7916. }
  7917. }
  7918. function genData$1 (el) {
  7919. var data = '';
  7920. if (el.staticStyle) {
  7921. data += "staticStyle:" + (el.staticStyle) + ",";
  7922. }
  7923. if (el.styleBinding) {
  7924. data += "style:(" + (el.styleBinding) + "),";
  7925. }
  7926. return data
  7927. }
  7928. var style$1 = {
  7929. staticKeys: ['staticStyle'],
  7930. transformNode: transformNode$1,
  7931. genData: genData$1
  7932. };
  7933. /* */
  7934. var decoder;
  7935. var he = {
  7936. decode: function decode (html) {
  7937. decoder = decoder || document.createElement('div');
  7938. decoder.innerHTML = html;
  7939. return decoder.textContent
  7940. }
  7941. };
  7942. /* */
  7943. var isUnaryTag = makeMap(
  7944. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  7945. 'link,meta,param,source,track,wbr'
  7946. );
  7947. // Elements that you can, intentionally, leave open
  7948. // (and which close themselves)
  7949. var canBeLeftOpenTag = makeMap(
  7950. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  7951. );
  7952. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  7953. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  7954. var isNonPhrasingTag = makeMap(
  7955. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  7956. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  7957. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  7958. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  7959. 'title,tr,track'
  7960. );
  7961. /**
  7962. * Not type-checking this file because it's mostly vendor code.
  7963. */
  7964. // Regular Expressions for parsing tags and attributes
  7965. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  7966. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  7967. // but for Vue templates we can enforce a simple charset
  7968. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  7969. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  7970. var startTagOpen = new RegExp(("^<" + qnameCapture));
  7971. var startTagClose = /^\s*(\/?)>/;
  7972. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  7973. var doctype = /^<!DOCTYPE [^>]+>/i;
  7974. // #7298: escape - to avoid being pased as HTML comment when inlined in page
  7975. var comment = /^<!\--/;
  7976. var conditionalComment = /^<!\[/;
  7977. // Special Elements (can contain anything)
  7978. var isPlainTextElement = makeMap('script,style,textarea', true);
  7979. var reCache = {};
  7980. var decodingMap = {
  7981. '&lt;': '<',
  7982. '&gt;': '>',
  7983. '&quot;': '"',
  7984. '&amp;': '&',
  7985. '&#10;': '\n',
  7986. '&#9;': '\t'
  7987. };
  7988. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  7989. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g;
  7990. // #5992
  7991. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  7992. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  7993. function decodeAttr (value, shouldDecodeNewlines) {
  7994. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  7995. return value.replace(re, function (match) { return decodingMap[match]; })
  7996. }
  7997. function parseHTML (html, options) {
  7998. var stack = [];
  7999. var expectHTML = options.expectHTML;
  8000. var isUnaryTag$$1 = options.isUnaryTag || no;
  8001. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  8002. var index = 0;
  8003. var last, lastTag;
  8004. while (html) {
  8005. last = html;
  8006. // Make sure we're not in a plaintext content element like script/style
  8007. if (!lastTag || !isPlainTextElement(lastTag)) {
  8008. var textEnd = html.indexOf('<');
  8009. if (textEnd === 0) {
  8010. // Comment:
  8011. if (comment.test(html)) {
  8012. var commentEnd = html.indexOf('-->');
  8013. if (commentEnd >= 0) {
  8014. if (options.shouldKeepComment) {
  8015. options.comment(html.substring(4, commentEnd));
  8016. }
  8017. advance(commentEnd + 3);
  8018. continue
  8019. }
  8020. }
  8021. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  8022. if (conditionalComment.test(html)) {
  8023. var conditionalEnd = html.indexOf(']>');
  8024. if (conditionalEnd >= 0) {
  8025. advance(conditionalEnd + 2);
  8026. continue
  8027. }
  8028. }
  8029. // Doctype:
  8030. var doctypeMatch = html.match(doctype);
  8031. if (doctypeMatch) {
  8032. advance(doctypeMatch[0].length);
  8033. continue
  8034. }
  8035. // End tag:
  8036. var endTagMatch = html.match(endTag);
  8037. if (endTagMatch) {
  8038. var curIndex = index;
  8039. advance(endTagMatch[0].length);
  8040. parseEndTag(endTagMatch[1], curIndex, index);
  8041. continue
  8042. }
  8043. // Start tag:
  8044. var startTagMatch = parseStartTag();
  8045. if (startTagMatch) {
  8046. handleStartTag(startTagMatch);
  8047. if (shouldIgnoreFirstNewline(startTagMatch.tagName, html)) {
  8048. advance(1);
  8049. }
  8050. continue
  8051. }
  8052. }
  8053. var text = (void 0), rest = (void 0), next = (void 0);
  8054. if (textEnd >= 0) {
  8055. rest = html.slice(textEnd);
  8056. while (
  8057. !endTag.test(rest) &&
  8058. !startTagOpen.test(rest) &&
  8059. !comment.test(rest) &&
  8060. !conditionalComment.test(rest)
  8061. ) {
  8062. // < in plain text, be forgiving and treat it as text
  8063. next = rest.indexOf('<', 1);
  8064. if (next < 0) { break }
  8065. textEnd += next;
  8066. rest = html.slice(textEnd);
  8067. }
  8068. text = html.substring(0, textEnd);
  8069. advance(textEnd);
  8070. }
  8071. if (textEnd < 0) {
  8072. text = html;
  8073. html = '';
  8074. }
  8075. if (options.chars && text) {
  8076. options.chars(text);
  8077. }
  8078. } else {
  8079. var endTagLength = 0;
  8080. var stackedTag = lastTag.toLowerCase();
  8081. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  8082. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  8083. endTagLength = endTag.length;
  8084. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  8085. text = text
  8086. .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
  8087. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  8088. }
  8089. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  8090. text = text.slice(1);
  8091. }
  8092. if (options.chars) {
  8093. options.chars(text);
  8094. }
  8095. return ''
  8096. });
  8097. index += html.length - rest$1.length;
  8098. html = rest$1;
  8099. parseEndTag(stackedTag, index - endTagLength, index);
  8100. }
  8101. if (html === last) {
  8102. options.chars && options.chars(html);
  8103. if (!stack.length && options.warn) {
  8104. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  8105. }
  8106. break
  8107. }
  8108. }
  8109. // Clean up any remaining tags
  8110. parseEndTag();
  8111. function advance (n) {
  8112. index += n;
  8113. html = html.substring(n);
  8114. }
  8115. function parseStartTag () {
  8116. var start = html.match(startTagOpen);
  8117. if (start) {
  8118. var match = {
  8119. tagName: start[1],
  8120. attrs: [],
  8121. start: index
  8122. };
  8123. advance(start[0].length);
  8124. var end, attr;
  8125. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  8126. advance(attr[0].length);
  8127. match.attrs.push(attr);
  8128. }
  8129. if (end) {
  8130. match.unarySlash = end[1];
  8131. advance(end[0].length);
  8132. match.end = index;
  8133. return match
  8134. }
  8135. }
  8136. }
  8137. function handleStartTag (match) {
  8138. var tagName = match.tagName;
  8139. var unarySlash = match.unarySlash;
  8140. if (expectHTML) {
  8141. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  8142. parseEndTag(lastTag);
  8143. }
  8144. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  8145. parseEndTag(tagName);
  8146. }
  8147. }
  8148. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  8149. var l = match.attrs.length;
  8150. var attrs = new Array(l);
  8151. for (var i = 0; i < l; i++) {
  8152. var args = match.attrs[i];
  8153. var value = args[3] || args[4] || args[5] || '';
  8154. var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
  8155. ? options.shouldDecodeNewlinesForHref
  8156. : options.shouldDecodeNewlines;
  8157. attrs[i] = {
  8158. name: args[1],
  8159. value: decodeAttr(value, shouldDecodeNewlines)
  8160. };
  8161. }
  8162. if (!unary) {
  8163. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  8164. lastTag = tagName;
  8165. }
  8166. if (options.start) {
  8167. options.start(tagName, attrs, unary, match.start, match.end);
  8168. }
  8169. }
  8170. function parseEndTag (tagName, start, end) {
  8171. var pos, lowerCasedTagName;
  8172. if (start == null) { start = index; }
  8173. if (end == null) { end = index; }
  8174. // Find the closest opened tag of the same type
  8175. if (tagName) {
  8176. lowerCasedTagName = tagName.toLowerCase();
  8177. for (pos = stack.length - 1; pos >= 0; pos--) {
  8178. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  8179. break
  8180. }
  8181. }
  8182. } else {
  8183. // If no tag name is provided, clean shop
  8184. pos = 0;
  8185. }
  8186. if (pos >= 0) {
  8187. // Close all the open elements, up the stack
  8188. for (var i = stack.length - 1; i >= pos; i--) {
  8189. if (i > pos || !tagName &&
  8190. options.warn
  8191. ) {
  8192. options.warn(
  8193. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  8194. );
  8195. }
  8196. if (options.end) {
  8197. options.end(stack[i].tag, start, end);
  8198. }
  8199. }
  8200. // Remove the open elements from the stack
  8201. stack.length = pos;
  8202. lastTag = pos && stack[pos - 1].tag;
  8203. } else if (lowerCasedTagName === 'br') {
  8204. if (options.start) {
  8205. options.start(tagName, [], true, start, end);
  8206. }
  8207. } else if (lowerCasedTagName === 'p') {
  8208. if (options.start) {
  8209. options.start(tagName, [], false, start, end);
  8210. }
  8211. if (options.end) {
  8212. options.end(tagName, start, end);
  8213. }
  8214. }
  8215. }
  8216. }
  8217. /* */
  8218. var onRE = /^@|^v-on:/;
  8219. var dirRE = /^v-|^@|^:/;
  8220. var forAliasRE = /([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/;
  8221. var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
  8222. var stripParensRE = /^\(|\)$/g;
  8223. var argRE = /:(.*)$/;
  8224. var bindRE = /^:|^v-bind:/;
  8225. var modifierRE = /\.[^.]+/g;
  8226. var decodeHTMLCached = cached(he.decode);
  8227. // configurable state
  8228. var warn$2;
  8229. var delimiters;
  8230. var transforms;
  8231. var preTransforms;
  8232. var postTransforms;
  8233. var platformIsPreTag;
  8234. var platformMustUseProp;
  8235. var platformGetTagNamespace;
  8236. function createASTElement (
  8237. tag,
  8238. attrs,
  8239. parent
  8240. ) {
  8241. return {
  8242. type: 1,
  8243. tag: tag,
  8244. attrsList: attrs,
  8245. attrsMap: makeAttrsMap(attrs),
  8246. parent: parent,
  8247. children: []
  8248. }
  8249. }
  8250. /**
  8251. * Convert HTML string to AST.
  8252. */
  8253. function parse (
  8254. template,
  8255. options
  8256. ) {
  8257. warn$2 = options.warn || baseWarn;
  8258. platformIsPreTag = options.isPreTag || no;
  8259. platformMustUseProp = options.mustUseProp || no;
  8260. platformGetTagNamespace = options.getTagNamespace || no;
  8261. transforms = pluckModuleFunction(options.modules, 'transformNode');
  8262. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  8263. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  8264. delimiters = options.delimiters;
  8265. var stack = [];
  8266. var preserveWhitespace = options.preserveWhitespace !== false;
  8267. var root;
  8268. var currentParent;
  8269. var inVPre = false;
  8270. var inPre = false;
  8271. var warned = false;
  8272. function warnOnce (msg) {
  8273. if (!warned) {
  8274. warned = true;
  8275. warn$2(msg);
  8276. }
  8277. }
  8278. function closeElement (element) {
  8279. // check pre state
  8280. if (element.pre) {
  8281. inVPre = false;
  8282. }
  8283. if (platformIsPreTag(element.tag)) {
  8284. inPre = false;
  8285. }
  8286. // apply post-transforms
  8287. for (var i = 0; i < postTransforms.length; i++) {
  8288. postTransforms[i](element, options);
  8289. }
  8290. }
  8291. parseHTML(template, {
  8292. warn: warn$2,
  8293. expectHTML: options.expectHTML,
  8294. isUnaryTag: options.isUnaryTag,
  8295. canBeLeftOpenTag: options.canBeLeftOpenTag,
  8296. shouldDecodeNewlines: options.shouldDecodeNewlines,
  8297. shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
  8298. shouldKeepComment: options.comments,
  8299. start: function start (tag, attrs, unary) {
  8300. // check namespace.
  8301. // inherit parent ns if there is one
  8302. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  8303. // handle IE svg bug
  8304. /* istanbul ignore if */
  8305. if (isIE && ns === 'svg') {
  8306. attrs = guardIESVGBug(attrs);
  8307. }
  8308. var element = createASTElement(tag, attrs, currentParent);
  8309. if (ns) {
  8310. element.ns = ns;
  8311. }
  8312. if (isForbiddenTag(element) && !isServerRendering()) {
  8313. element.forbidden = true;
  8314. warn$2(
  8315. 'Templates should only be responsible for mapping the state to the ' +
  8316. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  8317. "<" + tag + ">" + ', as they will not be parsed.'
  8318. );
  8319. }
  8320. // apply pre-transforms
  8321. for (var i = 0; i < preTransforms.length; i++) {
  8322. element = preTransforms[i](element, options) || element;
  8323. }
  8324. if (!inVPre) {
  8325. processPre(element);
  8326. if (element.pre) {
  8327. inVPre = true;
  8328. }
  8329. }
  8330. if (platformIsPreTag(element.tag)) {
  8331. inPre = true;
  8332. }
  8333. if (inVPre) {
  8334. processRawAttrs(element);
  8335. } else if (!element.processed) {
  8336. // structural directives
  8337. processFor(element);
  8338. processIf(element);
  8339. processOnce(element);
  8340. // element-scope stuff
  8341. processElement(element, options);
  8342. }
  8343. function checkRootConstraints (el) {
  8344. {
  8345. if (el.tag === 'slot' || el.tag === 'template') {
  8346. warnOnce(
  8347. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  8348. 'contain multiple nodes.'
  8349. );
  8350. }
  8351. if (el.attrsMap.hasOwnProperty('v-for')) {
  8352. warnOnce(
  8353. 'Cannot use v-for on stateful component root element because ' +
  8354. 'it renders multiple elements.'
  8355. );
  8356. }
  8357. }
  8358. }
  8359. // tree management
  8360. if (!root) {
  8361. root = element;
  8362. checkRootConstraints(root);
  8363. } else if (!stack.length) {
  8364. // allow root elements with v-if, v-else-if and v-else
  8365. if (root.if && (element.elseif || element.else)) {
  8366. checkRootConstraints(element);
  8367. addIfCondition(root, {
  8368. exp: element.elseif,
  8369. block: element
  8370. });
  8371. } else {
  8372. warnOnce(
  8373. "Component template should contain exactly one root element. " +
  8374. "If you are using v-if on multiple elements, " +
  8375. "use v-else-if to chain them instead."
  8376. );
  8377. }
  8378. }
  8379. if (currentParent && !element.forbidden) {
  8380. if (element.elseif || element.else) {
  8381. processIfConditions(element, currentParent);
  8382. } else if (element.slotScope) { // scoped slot
  8383. currentParent.plain = false;
  8384. var name = element.slotTarget || '"default"'
  8385. ;(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  8386. } else {
  8387. currentParent.children.push(element);
  8388. element.parent = currentParent;
  8389. }
  8390. }
  8391. if (!unary) {
  8392. currentParent = element;
  8393. stack.push(element);
  8394. } else {
  8395. closeElement(element);
  8396. }
  8397. },
  8398. end: function end () {
  8399. // remove trailing whitespace
  8400. var element = stack[stack.length - 1];
  8401. var lastNode = element.children[element.children.length - 1];
  8402. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  8403. element.children.pop();
  8404. }
  8405. // pop stack
  8406. stack.length -= 1;
  8407. currentParent = stack[stack.length - 1];
  8408. closeElement(element);
  8409. },
  8410. chars: function chars (text) {
  8411. if (!currentParent) {
  8412. {
  8413. if (text === template) {
  8414. warnOnce(
  8415. 'Component template requires a root element, rather than just text.'
  8416. );
  8417. } else if ((text = text.trim())) {
  8418. warnOnce(
  8419. ("text \"" + text + "\" outside root element will be ignored.")
  8420. );
  8421. }
  8422. }
  8423. return
  8424. }
  8425. // IE textarea placeholder bug
  8426. /* istanbul ignore if */
  8427. if (isIE &&
  8428. currentParent.tag === 'textarea' &&
  8429. currentParent.attrsMap.placeholder === text
  8430. ) {
  8431. return
  8432. }
  8433. var children = currentParent.children;
  8434. text = inPre || text.trim()
  8435. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  8436. // only preserve whitespace if its not right after a starting tag
  8437. : preserveWhitespace && children.length ? ' ' : '';
  8438. if (text) {
  8439. var res;
  8440. if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
  8441. children.push({
  8442. type: 2,
  8443. expression: res.expression,
  8444. tokens: res.tokens,
  8445. text: text
  8446. });
  8447. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  8448. children.push({
  8449. type: 3,
  8450. text: text
  8451. });
  8452. }
  8453. }
  8454. },
  8455. comment: function comment (text) {
  8456. currentParent.children.push({
  8457. type: 3,
  8458. text: text,
  8459. isComment: true
  8460. });
  8461. }
  8462. });
  8463. return root
  8464. }
  8465. function processPre (el) {
  8466. if (getAndRemoveAttr(el, 'v-pre') != null) {
  8467. el.pre = true;
  8468. }
  8469. }
  8470. function processRawAttrs (el) {
  8471. var l = el.attrsList.length;
  8472. if (l) {
  8473. var attrs = el.attrs = new Array(l);
  8474. for (var i = 0; i < l; i++) {
  8475. attrs[i] = {
  8476. name: el.attrsList[i].name,
  8477. value: JSON.stringify(el.attrsList[i].value)
  8478. };
  8479. }
  8480. } else if (!el.pre) {
  8481. // non root node in pre blocks with no attributes
  8482. el.plain = true;
  8483. }
  8484. }
  8485. function processElement (element, options) {
  8486. processKey(element);
  8487. // determine whether this is a plain element after
  8488. // removing structural attributes
  8489. element.plain = !element.key && !element.attrsList.length;
  8490. processRef(element);
  8491. processSlot(element);
  8492. processComponent(element);
  8493. for (var i = 0; i < transforms.length; i++) {
  8494. element = transforms[i](element, options) || element;
  8495. }
  8496. processAttrs(element);
  8497. }
  8498. function processKey (el) {
  8499. var exp = getBindingAttr(el, 'key');
  8500. if (exp) {
  8501. {
  8502. if (el.tag === 'template') {
  8503. warn$2("<template> cannot be keyed. Place the key on real elements instead.");
  8504. }
  8505. if (el.for) {
  8506. var iterator = el.iterator2 || el.iterator1;
  8507. var parent = el.parent;
  8508. if (iterator && iterator === exp && parent && parent.tag === 'transition-group') {
  8509. warn$2(
  8510. "Do not use v-for index as key on <transition-group> children, " +
  8511. "this is the same as not using keys."
  8512. );
  8513. }
  8514. }
  8515. }
  8516. el.key = exp;
  8517. }
  8518. }
  8519. function processRef (el) {
  8520. var ref = getBindingAttr(el, 'ref');
  8521. if (ref) {
  8522. el.ref = ref;
  8523. el.refInFor = checkInFor(el);
  8524. }
  8525. }
  8526. function processFor (el) {
  8527. var exp;
  8528. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  8529. var res = parseFor(exp);
  8530. if (res) {
  8531. extend(el, res);
  8532. } else {
  8533. warn$2(
  8534. ("Invalid v-for expression: " + exp)
  8535. );
  8536. }
  8537. }
  8538. }
  8539. function parseFor (exp) {
  8540. var inMatch = exp.match(forAliasRE);
  8541. if (!inMatch) { return }
  8542. var res = {};
  8543. res.for = inMatch[2].trim();
  8544. var alias = inMatch[1].trim().replace(stripParensRE, '');
  8545. var iteratorMatch = alias.match(forIteratorRE);
  8546. if (iteratorMatch) {
  8547. res.alias = alias.replace(forIteratorRE, '').trim();
  8548. res.iterator1 = iteratorMatch[1].trim();
  8549. if (iteratorMatch[2]) {
  8550. res.iterator2 = iteratorMatch[2].trim();
  8551. }
  8552. } else {
  8553. res.alias = alias;
  8554. }
  8555. return res
  8556. }
  8557. function processIf (el) {
  8558. var exp = getAndRemoveAttr(el, 'v-if');
  8559. if (exp) {
  8560. el.if = exp;
  8561. addIfCondition(el, {
  8562. exp: exp,
  8563. block: el
  8564. });
  8565. } else {
  8566. if (getAndRemoveAttr(el, 'v-else') != null) {
  8567. el.else = true;
  8568. }
  8569. var elseif = getAndRemoveAttr(el, 'v-else-if');
  8570. if (elseif) {
  8571. el.elseif = elseif;
  8572. }
  8573. }
  8574. }
  8575. function processIfConditions (el, parent) {
  8576. var prev = findPrevElement(parent.children);
  8577. if (prev && prev.if) {
  8578. addIfCondition(prev, {
  8579. exp: el.elseif,
  8580. block: el
  8581. });
  8582. } else {
  8583. warn$2(
  8584. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  8585. "used on element <" + (el.tag) + "> without corresponding v-if."
  8586. );
  8587. }
  8588. }
  8589. function findPrevElement (children) {
  8590. var i = children.length;
  8591. while (i--) {
  8592. if (children[i].type === 1) {
  8593. return children[i]
  8594. } else {
  8595. if (children[i].text !== ' ') {
  8596. warn$2(
  8597. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  8598. "will be ignored."
  8599. );
  8600. }
  8601. children.pop();
  8602. }
  8603. }
  8604. }
  8605. function addIfCondition (el, condition) {
  8606. if (!el.ifConditions) {
  8607. el.ifConditions = [];
  8608. }
  8609. el.ifConditions.push(condition);
  8610. }
  8611. function processOnce (el) {
  8612. var once$$1 = getAndRemoveAttr(el, 'v-once');
  8613. if (once$$1 != null) {
  8614. el.once = true;
  8615. }
  8616. }
  8617. function processSlot (el) {
  8618. if (el.tag === 'slot') {
  8619. el.slotName = getBindingAttr(el, 'name');
  8620. if (el.key) {
  8621. warn$2(
  8622. "`key` does not work on <slot> because slots are abstract outlets " +
  8623. "and can possibly expand into multiple elements. " +
  8624. "Use the key on a wrapping element instead."
  8625. );
  8626. }
  8627. } else {
  8628. var slotScope;
  8629. if (el.tag === 'template') {
  8630. slotScope = getAndRemoveAttr(el, 'scope');
  8631. /* istanbul ignore if */
  8632. if (slotScope) {
  8633. warn$2(
  8634. "the \"scope\" attribute for scoped slots have been deprecated and " +
  8635. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  8636. "can also be used on plain elements in addition to <template> to " +
  8637. "denote scoped slots.",
  8638. true
  8639. );
  8640. }
  8641. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  8642. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  8643. /* istanbul ignore if */
  8644. if (el.attrsMap['v-for']) {
  8645. warn$2(
  8646. "Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
  8647. "(v-for takes higher priority). Use a wrapper <template> for the " +
  8648. "scoped slot to make it clearer.",
  8649. true
  8650. );
  8651. }
  8652. el.slotScope = slotScope;
  8653. }
  8654. var slotTarget = getBindingAttr(el, 'slot');
  8655. if (slotTarget) {
  8656. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  8657. // preserve slot as an attribute for native shadow DOM compat
  8658. // only for non-scoped slots.
  8659. if (el.tag !== 'template' && !el.slotScope) {
  8660. addAttr(el, 'slot', slotTarget);
  8661. }
  8662. }
  8663. }
  8664. }
  8665. function processComponent (el) {
  8666. var binding;
  8667. if ((binding = getBindingAttr(el, 'is'))) {
  8668. el.component = binding;
  8669. }
  8670. if (getAndRemoveAttr(el, 'inline-template') != null) {
  8671. el.inlineTemplate = true;
  8672. }
  8673. }
  8674. function processAttrs (el) {
  8675. var list = el.attrsList;
  8676. var i, l, name, rawName, value, modifiers, isProp;
  8677. for (i = 0, l = list.length; i < l; i++) {
  8678. name = rawName = list[i].name;
  8679. value = list[i].value;
  8680. if (dirRE.test(name)) {
  8681. // mark element as dynamic
  8682. el.hasBindings = true;
  8683. // modifiers
  8684. modifiers = parseModifiers(name);
  8685. if (modifiers) {
  8686. name = name.replace(modifierRE, '');
  8687. }
  8688. if (bindRE.test(name)) { // v-bind
  8689. name = name.replace(bindRE, '');
  8690. value = parseFilters(value);
  8691. isProp = false;
  8692. if (
  8693. value.trim().length === 0
  8694. ) {
  8695. warn$2(
  8696. ("The value for a v-bind expression cannot be empty. Found in \"v-bind:" + name + "\"")
  8697. );
  8698. }
  8699. if (modifiers) {
  8700. if (modifiers.prop) {
  8701. isProp = true;
  8702. name = camelize(name);
  8703. if (name === 'innerHtml') { name = 'innerHTML'; }
  8704. }
  8705. if (modifiers.camel) {
  8706. name = camelize(name);
  8707. }
  8708. if (modifiers.sync) {
  8709. addHandler(
  8710. el,
  8711. ("update:" + (camelize(name))),
  8712. genAssignmentCode(value, "$event")
  8713. );
  8714. }
  8715. }
  8716. if (isProp || (
  8717. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  8718. )) {
  8719. addProp(el, name, value);
  8720. } else {
  8721. addAttr(el, name, value);
  8722. }
  8723. } else if (onRE.test(name)) { // v-on
  8724. name = name.replace(onRE, '');
  8725. addHandler(el, name, value, modifiers, false, warn$2);
  8726. } else { // normal directives
  8727. name = name.replace(dirRE, '');
  8728. // parse arg
  8729. var argMatch = name.match(argRE);
  8730. var arg = argMatch && argMatch[1];
  8731. if (arg) {
  8732. name = name.slice(0, -(arg.length + 1));
  8733. }
  8734. addDirective(el, name, rawName, value, arg, modifiers);
  8735. if (name === 'model') {
  8736. checkForAliasModel(el, value);
  8737. }
  8738. }
  8739. } else {
  8740. // literal attribute
  8741. {
  8742. var res = parseText(value, delimiters);
  8743. if (res) {
  8744. warn$2(
  8745. name + "=\"" + value + "\": " +
  8746. 'Interpolation inside attributes has been removed. ' +
  8747. 'Use v-bind or the colon shorthand instead. For example, ' +
  8748. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  8749. );
  8750. }
  8751. }
  8752. addAttr(el, name, JSON.stringify(value));
  8753. // #6887 firefox doesn't update muted state if set via attribute
  8754. // even immediately after element creation
  8755. if (!el.component &&
  8756. name === 'muted' &&
  8757. platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  8758. addProp(el, name, 'true');
  8759. }
  8760. }
  8761. }
  8762. }
  8763. function checkInFor (el) {
  8764. var parent = el;
  8765. while (parent) {
  8766. if (parent.for !== undefined) {
  8767. return true
  8768. }
  8769. parent = parent.parent;
  8770. }
  8771. return false
  8772. }
  8773. function parseModifiers (name) {
  8774. var match = name.match(modifierRE);
  8775. if (match) {
  8776. var ret = {};
  8777. match.forEach(function (m) { ret[m.slice(1)] = true; });
  8778. return ret
  8779. }
  8780. }
  8781. function makeAttrsMap (attrs) {
  8782. var map = {};
  8783. for (var i = 0, l = attrs.length; i < l; i++) {
  8784. if (
  8785. map[attrs[i].name] && !isIE && !isEdge
  8786. ) {
  8787. warn$2('duplicate attribute: ' + attrs[i].name);
  8788. }
  8789. map[attrs[i].name] = attrs[i].value;
  8790. }
  8791. return map
  8792. }
  8793. // for script (e.g. type="x/template") or style, do not decode content
  8794. function isTextTag (el) {
  8795. return el.tag === 'script' || el.tag === 'style'
  8796. }
  8797. function isForbiddenTag (el) {
  8798. return (
  8799. el.tag === 'style' ||
  8800. (el.tag === 'script' && (
  8801. !el.attrsMap.type ||
  8802. el.attrsMap.type === 'text/javascript'
  8803. ))
  8804. )
  8805. }
  8806. var ieNSBug = /^xmlns:NS\d+/;
  8807. var ieNSPrefix = /^NS\d+:/;
  8808. /* istanbul ignore next */
  8809. function guardIESVGBug (attrs) {
  8810. var res = [];
  8811. for (var i = 0; i < attrs.length; i++) {
  8812. var attr = attrs[i];
  8813. if (!ieNSBug.test(attr.name)) {
  8814. attr.name = attr.name.replace(ieNSPrefix, '');
  8815. res.push(attr);
  8816. }
  8817. }
  8818. return res
  8819. }
  8820. function checkForAliasModel (el, value) {
  8821. var _el = el;
  8822. while (_el) {
  8823. if (_el.for && _el.alias === value) {
  8824. warn$2(
  8825. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  8826. "You are binding v-model directly to a v-for iteration alias. " +
  8827. "This will not be able to modify the v-for source array because " +
  8828. "writing to the alias is like modifying a function local variable. " +
  8829. "Consider using an array of objects and use v-model on an object property instead."
  8830. );
  8831. }
  8832. _el = _el.parent;
  8833. }
  8834. }
  8835. /* */
  8836. function preTransformNode (el, options) {
  8837. if (el.tag === 'input') {
  8838. var map = el.attrsMap;
  8839. if (!map['v-model']) {
  8840. return
  8841. }
  8842. var typeBinding;
  8843. if (map[':type'] || map['v-bind:type']) {
  8844. typeBinding = getBindingAttr(el, 'type');
  8845. }
  8846. if (!map.type && !typeBinding && map['v-bind']) {
  8847. typeBinding = "(" + (map['v-bind']) + ").type";
  8848. }
  8849. if (typeBinding) {
  8850. var ifCondition = getAndRemoveAttr(el, 'v-if', true);
  8851. var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
  8852. var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
  8853. var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
  8854. // 1. checkbox
  8855. var branch0 = cloneASTElement(el);
  8856. // process for on the main node
  8857. processFor(branch0);
  8858. addRawAttr(branch0, 'type', 'checkbox');
  8859. processElement(branch0, options);
  8860. branch0.processed = true; // prevent it from double-processed
  8861. branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
  8862. addIfCondition(branch0, {
  8863. exp: branch0.if,
  8864. block: branch0
  8865. });
  8866. // 2. add radio else-if condition
  8867. var branch1 = cloneASTElement(el);
  8868. getAndRemoveAttr(branch1, 'v-for', true);
  8869. addRawAttr(branch1, 'type', 'radio');
  8870. processElement(branch1, options);
  8871. addIfCondition(branch0, {
  8872. exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
  8873. block: branch1
  8874. });
  8875. // 3. other
  8876. var branch2 = cloneASTElement(el);
  8877. getAndRemoveAttr(branch2, 'v-for', true);
  8878. addRawAttr(branch2, ':type', typeBinding);
  8879. processElement(branch2, options);
  8880. addIfCondition(branch0, {
  8881. exp: ifCondition,
  8882. block: branch2
  8883. });
  8884. if (hasElse) {
  8885. branch0.else = true;
  8886. } else if (elseIfCondition) {
  8887. branch0.elseif = elseIfCondition;
  8888. }
  8889. return branch0
  8890. }
  8891. }
  8892. }
  8893. function cloneASTElement (el) {
  8894. return createASTElement(el.tag, el.attrsList.slice(), el.parent)
  8895. }
  8896. var model$1 = {
  8897. preTransformNode: preTransformNode
  8898. };
  8899. var modules$1 = [
  8900. klass$1,
  8901. style$1,
  8902. model$1
  8903. ];
  8904. /* */
  8905. function text (el, dir) {
  8906. if (dir.value) {
  8907. addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
  8908. }
  8909. }
  8910. /* */
  8911. function html (el, dir) {
  8912. if (dir.value) {
  8913. addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
  8914. }
  8915. }
  8916. var directives$1 = {
  8917. model: model,
  8918. text: text,
  8919. html: html
  8920. };
  8921. /* */
  8922. var baseOptions = {
  8923. expectHTML: true,
  8924. modules: modules$1,
  8925. directives: directives$1,
  8926. isPreTag: isPreTag,
  8927. isUnaryTag: isUnaryTag,
  8928. mustUseProp: mustUseProp,
  8929. canBeLeftOpenTag: canBeLeftOpenTag,
  8930. isReservedTag: isReservedTag,
  8931. getTagNamespace: getTagNamespace,
  8932. staticKeys: genStaticKeys(modules$1)
  8933. };
  8934. /* */
  8935. var isStaticKey;
  8936. var isPlatformReservedTag;
  8937. var genStaticKeysCached = cached(genStaticKeys$1);
  8938. /**
  8939. * Goal of the optimizer: walk the generated template AST tree
  8940. * and detect sub-trees that are purely static, i.e. parts of
  8941. * the DOM that never needs to change.
  8942. *
  8943. * Once we detect these sub-trees, we can:
  8944. *
  8945. * 1. Hoist them into constants, so that we no longer need to
  8946. * create fresh nodes for them on each re-render;
  8947. * 2. Completely skip them in the patching process.
  8948. */
  8949. function optimize (root, options) {
  8950. if (!root) { return }
  8951. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  8952. isPlatformReservedTag = options.isReservedTag || no;
  8953. // first pass: mark all non-static nodes.
  8954. markStatic$1(root);
  8955. // second pass: mark static roots.
  8956. markStaticRoots(root, false);
  8957. }
  8958. function genStaticKeys$1 (keys) {
  8959. return makeMap(
  8960. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  8961. (keys ? ',' + keys : '')
  8962. )
  8963. }
  8964. function markStatic$1 (node) {
  8965. node.static = isStatic(node);
  8966. if (node.type === 1) {
  8967. // do not make component slot content static. this avoids
  8968. // 1. components not able to mutate slot nodes
  8969. // 2. static slot content fails for hot-reloading
  8970. if (
  8971. !isPlatformReservedTag(node.tag) &&
  8972. node.tag !== 'slot' &&
  8973. node.attrsMap['inline-template'] == null
  8974. ) {
  8975. return
  8976. }
  8977. for (var i = 0, l = node.children.length; i < l; i++) {
  8978. var child = node.children[i];
  8979. markStatic$1(child);
  8980. if (!child.static) {
  8981. node.static = false;
  8982. }
  8983. }
  8984. if (node.ifConditions) {
  8985. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  8986. var block = node.ifConditions[i$1].block;
  8987. markStatic$1(block);
  8988. if (!block.static) {
  8989. node.static = false;
  8990. }
  8991. }
  8992. }
  8993. }
  8994. }
  8995. function markStaticRoots (node, isInFor) {
  8996. if (node.type === 1) {
  8997. if (node.static || node.once) {
  8998. node.staticInFor = isInFor;
  8999. }
  9000. // For a node to qualify as a static root, it should have children that
  9001. // are not just static text. Otherwise the cost of hoisting out will
  9002. // outweigh the benefits and it's better off to just always render it fresh.
  9003. if (node.static && node.children.length && !(
  9004. node.children.length === 1 &&
  9005. node.children[0].type === 3
  9006. )) {
  9007. node.staticRoot = true;
  9008. return
  9009. } else {
  9010. node.staticRoot = false;
  9011. }
  9012. if (node.children) {
  9013. for (var i = 0, l = node.children.length; i < l; i++) {
  9014. markStaticRoots(node.children[i], isInFor || !!node.for);
  9015. }
  9016. }
  9017. if (node.ifConditions) {
  9018. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  9019. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  9020. }
  9021. }
  9022. }
  9023. }
  9024. function isStatic (node) {
  9025. if (node.type === 2) { // expression
  9026. return false
  9027. }
  9028. if (node.type === 3) { // text
  9029. return true
  9030. }
  9031. return !!(node.pre || (
  9032. !node.hasBindings && // no dynamic bindings
  9033. !node.if && !node.for && // not v-if or v-for or v-else
  9034. !isBuiltInTag(node.tag) && // not a built-in
  9035. isPlatformReservedTag(node.tag) && // not a component
  9036. !isDirectChildOfTemplateFor(node) &&
  9037. Object.keys(node).every(isStaticKey)
  9038. ))
  9039. }
  9040. function isDirectChildOfTemplateFor (node) {
  9041. while (node.parent) {
  9042. node = node.parent;
  9043. if (node.tag !== 'template') {
  9044. return false
  9045. }
  9046. if (node.for) {
  9047. return true
  9048. }
  9049. }
  9050. return false
  9051. }
  9052. /* */
  9053. var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  9054. var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
  9055. // KeyboardEvent.keyCode aliases
  9056. var keyCodes = {
  9057. esc: 27,
  9058. tab: 9,
  9059. enter: 13,
  9060. space: 32,
  9061. up: 38,
  9062. left: 37,
  9063. right: 39,
  9064. down: 40,
  9065. 'delete': [8, 46]
  9066. };
  9067. // KeyboardEvent.key aliases
  9068. var keyNames = {
  9069. // #7880: IE11 and Edge use `Esc` for Escape key name.
  9070. esc: ['Esc', 'Escape'],
  9071. tab: 'Tab',
  9072. enter: 'Enter',
  9073. // #9112: IE11 uses `Spacebar` for Space key name.
  9074. space: [' ', 'Spacebar'],
  9075. // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
  9076. up: ['Up', 'ArrowUp'],
  9077. left: ['Left', 'ArrowLeft'],
  9078. right: ['Right', 'ArrowRight'],
  9079. down: ['Down', 'ArrowDown'],
  9080. // #9112: IE11 uses `Del` for Delete key name.
  9081. 'delete': ['Backspace', 'Delete', 'Del']
  9082. };
  9083. // #4868: modifiers that prevent the execution of the listener
  9084. // need to explicitly return null so that we can determine whether to remove
  9085. // the listener for .once
  9086. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  9087. var modifierCode = {
  9088. stop: '$event.stopPropagation();',
  9089. prevent: '$event.preventDefault();',
  9090. self: genGuard("$event.target !== $event.currentTarget"),
  9091. ctrl: genGuard("!$event.ctrlKey"),
  9092. shift: genGuard("!$event.shiftKey"),
  9093. alt: genGuard("!$event.altKey"),
  9094. meta: genGuard("!$event.metaKey"),
  9095. left: genGuard("'button' in $event && $event.button !== 0"),
  9096. middle: genGuard("'button' in $event && $event.button !== 1"),
  9097. right: genGuard("'button' in $event && $event.button !== 2")
  9098. };
  9099. function genHandlers (
  9100. events,
  9101. isNative
  9102. ) {
  9103. var res = isNative ? 'nativeOn:{' : 'on:{';
  9104. for (var name in events) {
  9105. res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
  9106. }
  9107. return res.slice(0, -1) + '}'
  9108. }
  9109. function genHandler (
  9110. name,
  9111. handler
  9112. ) {
  9113. if (!handler) {
  9114. return 'function(){}'
  9115. }
  9116. if (Array.isArray(handler)) {
  9117. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  9118. }
  9119. var isMethodPath = simplePathRE.test(handler.value);
  9120. var isFunctionExpression = fnExpRE.test(handler.value);
  9121. if (!handler.modifiers) {
  9122. if (isMethodPath || isFunctionExpression) {
  9123. return handler.value
  9124. }
  9125. return ("function($event){" + (handler.value) + "}") // inline statement
  9126. } else {
  9127. var code = '';
  9128. var genModifierCode = '';
  9129. var keys = [];
  9130. for (var key in handler.modifiers) {
  9131. if (modifierCode[key]) {
  9132. genModifierCode += modifierCode[key];
  9133. // left/right
  9134. if (keyCodes[key]) {
  9135. keys.push(key);
  9136. }
  9137. } else if (key === 'exact') {
  9138. var modifiers = (handler.modifiers);
  9139. genModifierCode += genGuard(
  9140. ['ctrl', 'shift', 'alt', 'meta']
  9141. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  9142. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  9143. .join('||')
  9144. );
  9145. } else {
  9146. keys.push(key);
  9147. }
  9148. }
  9149. if (keys.length) {
  9150. code += genKeyFilter(keys);
  9151. }
  9152. // Make sure modifiers like prevent and stop get executed after key filtering
  9153. if (genModifierCode) {
  9154. code += genModifierCode;
  9155. }
  9156. var handlerCode = isMethodPath
  9157. ? ("return " + (handler.value) + "($event)")
  9158. : isFunctionExpression
  9159. ? ("return (" + (handler.value) + ")($event)")
  9160. : handler.value;
  9161. return ("function($event){" + code + handlerCode + "}")
  9162. }
  9163. }
  9164. function genKeyFilter (keys) {
  9165. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  9166. }
  9167. function genFilterCode (key) {
  9168. var keyVal = parseInt(key, 10);
  9169. if (keyVal) {
  9170. return ("$event.keyCode!==" + keyVal)
  9171. }
  9172. var keyCode = keyCodes[key];
  9173. var keyName = keyNames[key];
  9174. return (
  9175. "_k($event.keyCode," +
  9176. (JSON.stringify(key)) + "," +
  9177. (JSON.stringify(keyCode)) + "," +
  9178. "$event.key," +
  9179. "" + (JSON.stringify(keyName)) +
  9180. ")"
  9181. )
  9182. }
  9183. /* */
  9184. function on (el, dir) {
  9185. if (dir.modifiers) {
  9186. warn("v-on without argument does not support modifiers.");
  9187. }
  9188. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  9189. }
  9190. /* */
  9191. function bind$1 (el, dir) {
  9192. el.wrapData = function (code) {
  9193. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  9194. };
  9195. }
  9196. /* */
  9197. var baseDirectives = {
  9198. on: on,
  9199. bind: bind$1,
  9200. cloak: noop
  9201. };
  9202. /* */
  9203. var CodegenState = function CodegenState (options) {
  9204. this.options = options;
  9205. this.warn = options.warn || baseWarn;
  9206. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  9207. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  9208. this.directives = extend(extend({}, baseDirectives), options.directives);
  9209. var isReservedTag = options.isReservedTag || no;
  9210. this.maybeComponent = function (el) { return !(isReservedTag(el.tag) && !el.component); };
  9211. this.onceId = 0;
  9212. this.staticRenderFns = [];
  9213. this.pre = false;
  9214. };
  9215. function generate (
  9216. ast,
  9217. options
  9218. ) {
  9219. var state = new CodegenState(options);
  9220. var code = ast ? genElement(ast, state) : '_c("div")';
  9221. return {
  9222. render: ("with(this){return " + code + "}"),
  9223. staticRenderFns: state.staticRenderFns
  9224. }
  9225. }
  9226. function genElement (el, state) {
  9227. if (el.parent) {
  9228. el.pre = el.pre || el.parent.pre;
  9229. }
  9230. if (el.staticRoot && !el.staticProcessed) {
  9231. return genStatic(el, state)
  9232. } else if (el.once && !el.onceProcessed) {
  9233. return genOnce(el, state)
  9234. } else if (el.for && !el.forProcessed) {
  9235. return genFor(el, state)
  9236. } else if (el.if && !el.ifProcessed) {
  9237. return genIf(el, state)
  9238. } else if (el.tag === 'template' && !el.slotTarget && !state.pre) {
  9239. return genChildren(el, state) || 'void 0'
  9240. } else if (el.tag === 'slot') {
  9241. return genSlot(el, state)
  9242. } else {
  9243. // component or element
  9244. var code;
  9245. if (el.component) {
  9246. code = genComponent(el.component, el, state);
  9247. } else {
  9248. var data;
  9249. if (!el.plain || (el.pre && state.maybeComponent(el))) {
  9250. data = genData$2(el, state);
  9251. }
  9252. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  9253. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  9254. }
  9255. // module transforms
  9256. for (var i = 0; i < state.transforms.length; i++) {
  9257. code = state.transforms[i](el, code);
  9258. }
  9259. return code
  9260. }
  9261. }
  9262. // hoist static sub-trees out
  9263. function genStatic (el, state) {
  9264. el.staticProcessed = true;
  9265. // Some elements (templates) need to behave differently inside of a v-pre
  9266. // node. All pre nodes are static roots, so we can use this as a location to
  9267. // wrap a state change and reset it upon exiting the pre node.
  9268. var originalPreState = state.pre;
  9269. if (el.pre) {
  9270. state.pre = el.pre;
  9271. }
  9272. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  9273. state.pre = originalPreState;
  9274. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  9275. }
  9276. // v-once
  9277. function genOnce (el, state) {
  9278. el.onceProcessed = true;
  9279. if (el.if && !el.ifProcessed) {
  9280. return genIf(el, state)
  9281. } else if (el.staticInFor) {
  9282. var key = '';
  9283. var parent = el.parent;
  9284. while (parent) {
  9285. if (parent.for) {
  9286. key = parent.key;
  9287. break
  9288. }
  9289. parent = parent.parent;
  9290. }
  9291. if (!key) {
  9292. state.warn(
  9293. "v-once can only be used inside v-for that is keyed. "
  9294. );
  9295. return genElement(el, state)
  9296. }
  9297. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  9298. } else {
  9299. return genStatic(el, state)
  9300. }
  9301. }
  9302. function genIf (
  9303. el,
  9304. state,
  9305. altGen,
  9306. altEmpty
  9307. ) {
  9308. el.ifProcessed = true; // avoid recursion
  9309. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  9310. }
  9311. function genIfConditions (
  9312. conditions,
  9313. state,
  9314. altGen,
  9315. altEmpty
  9316. ) {
  9317. if (!conditions.length) {
  9318. return altEmpty || '_e()'
  9319. }
  9320. var condition = conditions.shift();
  9321. if (condition.exp) {
  9322. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  9323. } else {
  9324. return ("" + (genTernaryExp(condition.block)))
  9325. }
  9326. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  9327. function genTernaryExp (el) {
  9328. return altGen
  9329. ? altGen(el, state)
  9330. : el.once
  9331. ? genOnce(el, state)
  9332. : genElement(el, state)
  9333. }
  9334. }
  9335. function genFor (
  9336. el,
  9337. state,
  9338. altGen,
  9339. altHelper
  9340. ) {
  9341. var exp = el.for;
  9342. var alias = el.alias;
  9343. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  9344. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  9345. if (state.maybeComponent(el) &&
  9346. el.tag !== 'slot' &&
  9347. el.tag !== 'template' &&
  9348. !el.key
  9349. ) {
  9350. state.warn(
  9351. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  9352. "v-for should have explicit keys. " +
  9353. "See https://vuejs.org/guide/list.html#key for more info.",
  9354. true /* tip */
  9355. );
  9356. }
  9357. el.forProcessed = true; // avoid recursion
  9358. return (altHelper || '_l') + "((" + exp + ")," +
  9359. "function(" + alias + iterator1 + iterator2 + "){" +
  9360. "return " + ((altGen || genElement)(el, state)) +
  9361. '})'
  9362. }
  9363. function genData$2 (el, state) {
  9364. var data = '{';
  9365. // directives first.
  9366. // directives may mutate the el's other properties before they are generated.
  9367. var dirs = genDirectives(el, state);
  9368. if (dirs) { data += dirs + ','; }
  9369. // key
  9370. if (el.key) {
  9371. data += "key:" + (el.key) + ",";
  9372. }
  9373. // ref
  9374. if (el.ref) {
  9375. data += "ref:" + (el.ref) + ",";
  9376. }
  9377. if (el.refInFor) {
  9378. data += "refInFor:true,";
  9379. }
  9380. // pre
  9381. if (el.pre) {
  9382. data += "pre:true,";
  9383. }
  9384. // record original tag name for components using "is" attribute
  9385. if (el.component) {
  9386. data += "tag:\"" + (el.tag) + "\",";
  9387. }
  9388. // module data generation functions
  9389. for (var i = 0; i < state.dataGenFns.length; i++) {
  9390. data += state.dataGenFns[i](el);
  9391. }
  9392. // attributes
  9393. if (el.attrs) {
  9394. data += "attrs:{" + (genProps(el.attrs)) + "},";
  9395. }
  9396. // DOM props
  9397. if (el.props) {
  9398. data += "domProps:{" + (genProps(el.props)) + "},";
  9399. }
  9400. // event handlers
  9401. if (el.events) {
  9402. data += (genHandlers(el.events, false)) + ",";
  9403. }
  9404. if (el.nativeEvents) {
  9405. data += (genHandlers(el.nativeEvents, true)) + ",";
  9406. }
  9407. // slot target
  9408. // only for non-scoped slots
  9409. if (el.slotTarget && !el.slotScope) {
  9410. data += "slot:" + (el.slotTarget) + ",";
  9411. }
  9412. // scoped slots
  9413. if (el.scopedSlots) {
  9414. data += (genScopedSlots(el.scopedSlots, state)) + ",";
  9415. }
  9416. // component v-model
  9417. if (el.model) {
  9418. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  9419. }
  9420. // inline-template
  9421. if (el.inlineTemplate) {
  9422. var inlineTemplate = genInlineTemplate(el, state);
  9423. if (inlineTemplate) {
  9424. data += inlineTemplate + ",";
  9425. }
  9426. }
  9427. data = data.replace(/,$/, '') + '}';
  9428. // v-bind data wrap
  9429. if (el.wrapData) {
  9430. data = el.wrapData(data);
  9431. }
  9432. // v-on data wrap
  9433. if (el.wrapListeners) {
  9434. data = el.wrapListeners(data);
  9435. }
  9436. return data
  9437. }
  9438. function genDirectives (el, state) {
  9439. var dirs = el.directives;
  9440. if (!dirs) { return }
  9441. var res = 'directives:[';
  9442. var hasRuntime = false;
  9443. var i, l, dir, needRuntime;
  9444. for (i = 0, l = dirs.length; i < l; i++) {
  9445. dir = dirs[i];
  9446. needRuntime = true;
  9447. var gen = state.directives[dir.name];
  9448. if (gen) {
  9449. // compile-time directive that manipulates AST.
  9450. // returns true if it also needs a runtime counterpart.
  9451. needRuntime = !!gen(el, dir, state.warn);
  9452. }
  9453. if (needRuntime) {
  9454. hasRuntime = true;
  9455. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  9456. }
  9457. }
  9458. if (hasRuntime) {
  9459. return res.slice(0, -1) + ']'
  9460. }
  9461. }
  9462. function genInlineTemplate (el, state) {
  9463. var ast = el.children[0];
  9464. if (el.children.length !== 1 || ast.type !== 1) {
  9465. state.warn('Inline-template components must have exactly one child element.');
  9466. }
  9467. if (ast.type === 1) {
  9468. var inlineRenderFns = generate(ast, state.options);
  9469. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  9470. }
  9471. }
  9472. function genScopedSlots (
  9473. slots,
  9474. state
  9475. ) {
  9476. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
  9477. return genScopedSlot(key, slots[key], state)
  9478. }).join(',')) + "])")
  9479. }
  9480. function genScopedSlot (
  9481. key,
  9482. el,
  9483. state
  9484. ) {
  9485. if (el.for && !el.forProcessed) {
  9486. return genForScopedSlot(key, el, state)
  9487. }
  9488. var fn = "function(" + (String(el.slotScope)) + "){" +
  9489. "return " + (el.tag === 'template'
  9490. ? el.if
  9491. ? ("(" + (el.if) + ")?" + (genChildren(el, state) || 'undefined') + ":undefined")
  9492. : genChildren(el, state) || 'undefined'
  9493. : genElement(el, state)) + "}";
  9494. return ("{key:" + key + ",fn:" + fn + "}")
  9495. }
  9496. function genForScopedSlot (
  9497. key,
  9498. el,
  9499. state
  9500. ) {
  9501. var exp = el.for;
  9502. var alias = el.alias;
  9503. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  9504. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  9505. el.forProcessed = true; // avoid recursion
  9506. return "_l((" + exp + ")," +
  9507. "function(" + alias + iterator1 + iterator2 + "){" +
  9508. "return " + (genScopedSlot(key, el, state)) +
  9509. '})'
  9510. }
  9511. function genChildren (
  9512. el,
  9513. state,
  9514. checkSkip,
  9515. altGenElement,
  9516. altGenNode
  9517. ) {
  9518. var children = el.children;
  9519. if (children.length) {
  9520. var el$1 = children[0];
  9521. // optimize single v-for
  9522. if (children.length === 1 &&
  9523. el$1.for &&
  9524. el$1.tag !== 'template' &&
  9525. el$1.tag !== 'slot'
  9526. ) {
  9527. var normalizationType = checkSkip
  9528. ? state.maybeComponent(el$1) ? ",1" : ",0"
  9529. : "";
  9530. return ("" + ((altGenElement || genElement)(el$1, state)) + normalizationType)
  9531. }
  9532. var normalizationType$1 = checkSkip
  9533. ? getNormalizationType(children, state.maybeComponent)
  9534. : 0;
  9535. var gen = altGenNode || genNode;
  9536. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType$1 ? ("," + normalizationType$1) : ''))
  9537. }
  9538. }
  9539. // determine the normalization needed for the children array.
  9540. // 0: no normalization needed
  9541. // 1: simple normalization needed (possible 1-level deep nested array)
  9542. // 2: full normalization needed
  9543. function getNormalizationType (
  9544. children,
  9545. maybeComponent
  9546. ) {
  9547. var res = 0;
  9548. for (var i = 0; i < children.length; i++) {
  9549. var el = children[i];
  9550. if (el.type !== 1) {
  9551. continue
  9552. }
  9553. if (needsNormalization(el) ||
  9554. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  9555. res = 2;
  9556. break
  9557. }
  9558. if (maybeComponent(el) ||
  9559. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  9560. res = 1;
  9561. }
  9562. }
  9563. return res
  9564. }
  9565. function needsNormalization (el) {
  9566. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  9567. }
  9568. function genNode (node, state) {
  9569. if (node.type === 1) {
  9570. return genElement(node, state)
  9571. } else if (node.type === 3 && node.isComment) {
  9572. return genComment(node)
  9573. } else {
  9574. return genText(node)
  9575. }
  9576. }
  9577. function genText (text) {
  9578. return ("_v(" + (text.type === 2
  9579. ? text.expression // no need for () because already wrapped in _s()
  9580. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  9581. }
  9582. function genComment (comment) {
  9583. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  9584. }
  9585. function genSlot (el, state) {
  9586. var slotName = el.slotName || '"default"';
  9587. var children = genChildren(el, state);
  9588. var res = "_t(" + slotName + (children ? ("," + children) : '');
  9589. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  9590. var bind$$1 = el.attrsMap['v-bind'];
  9591. if ((attrs || bind$$1) && !children) {
  9592. res += ",null";
  9593. }
  9594. if (attrs) {
  9595. res += "," + attrs;
  9596. }
  9597. if (bind$$1) {
  9598. res += (attrs ? '' : ',null') + "," + bind$$1;
  9599. }
  9600. return res + ')'
  9601. }
  9602. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  9603. function genComponent (
  9604. componentName,
  9605. el,
  9606. state
  9607. ) {
  9608. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  9609. return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
  9610. }
  9611. function genProps (props) {
  9612. var res = '';
  9613. for (var i = 0; i < props.length; i++) {
  9614. var prop = props[i];
  9615. /* istanbul ignore if */
  9616. {
  9617. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  9618. }
  9619. }
  9620. return res.slice(0, -1)
  9621. }
  9622. // #3895, #4268
  9623. function transformSpecialNewlines (text) {
  9624. return text
  9625. .replace(/\u2028/g, '\\u2028')
  9626. .replace(/\u2029/g, '\\u2029')
  9627. }
  9628. /* */
  9629. // these keywords should not appear inside expressions, but operators like
  9630. // typeof, instanceof and in are allowed
  9631. var prohibitedKeywordRE = new RegExp('\\b' + (
  9632. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  9633. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  9634. 'extends,finally,continue,debugger,function,arguments'
  9635. ).split(',').join('\\b|\\b') + '\\b');
  9636. // these unary operators should not be used as property/method names
  9637. var unaryOperatorsRE = new RegExp('\\b' + (
  9638. 'delete,typeof,void'
  9639. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  9640. // strip strings in expressions
  9641. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  9642. // detect problematic expressions in a template
  9643. function detectErrors (ast) {
  9644. var errors = [];
  9645. if (ast) {
  9646. checkNode(ast, errors);
  9647. }
  9648. return errors
  9649. }
  9650. function checkNode (node, errors) {
  9651. if (node.type === 1) {
  9652. for (var name in node.attrsMap) {
  9653. if (dirRE.test(name)) {
  9654. var value = node.attrsMap[name];
  9655. if (value) {
  9656. if (name === 'v-for') {
  9657. checkFor(node, ("v-for=\"" + value + "\""), errors);
  9658. } else if (onRE.test(name)) {
  9659. checkEvent(value, (name + "=\"" + value + "\""), errors);
  9660. } else {
  9661. checkExpression(value, (name + "=\"" + value + "\""), errors);
  9662. }
  9663. }
  9664. }
  9665. }
  9666. if (node.children) {
  9667. for (var i = 0; i < node.children.length; i++) {
  9668. checkNode(node.children[i], errors);
  9669. }
  9670. }
  9671. } else if (node.type === 2) {
  9672. checkExpression(node.expression, node.text, errors);
  9673. }
  9674. }
  9675. function checkEvent (exp, text, errors) {
  9676. var stipped = exp.replace(stripStringRE, '');
  9677. var keywordMatch = stipped.match(unaryOperatorsRE);
  9678. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  9679. errors.push(
  9680. "avoid using JavaScript unary operator as property name: " +
  9681. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  9682. );
  9683. }
  9684. checkExpression(exp, text, errors);
  9685. }
  9686. function checkFor (node, text, errors) {
  9687. checkExpression(node.for || '', text, errors);
  9688. checkIdentifier(node.alias, 'v-for alias', text, errors);
  9689. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  9690. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  9691. }
  9692. function checkIdentifier (
  9693. ident,
  9694. type,
  9695. text,
  9696. errors
  9697. ) {
  9698. if (typeof ident === 'string') {
  9699. try {
  9700. new Function(("var " + ident + "=_"));
  9701. } catch (e) {
  9702. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  9703. }
  9704. }
  9705. }
  9706. function checkExpression (exp, text, errors) {
  9707. try {
  9708. new Function(("return " + exp));
  9709. } catch (e) {
  9710. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  9711. if (keywordMatch) {
  9712. errors.push(
  9713. "avoid using JavaScript keyword as property name: " +
  9714. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim())
  9715. );
  9716. } else {
  9717. errors.push(
  9718. "invalid expression: " + (e.message) + " in\n\n" +
  9719. " " + exp + "\n\n" +
  9720. " Raw expression: " + (text.trim()) + "\n"
  9721. );
  9722. }
  9723. }
  9724. }
  9725. /* */
  9726. function createFunction (code, errors) {
  9727. try {
  9728. return new Function(code)
  9729. } catch (err) {
  9730. errors.push({ err: err, code: code });
  9731. return noop
  9732. }
  9733. }
  9734. function createCompileToFunctionFn (compile) {
  9735. var cache = Object.create(null);
  9736. return function compileToFunctions (
  9737. template,
  9738. options,
  9739. vm
  9740. ) {
  9741. options = extend({}, options);
  9742. var warn$$1 = options.warn || warn;
  9743. delete options.warn;
  9744. /* istanbul ignore if */
  9745. {
  9746. // detect possible CSP restriction
  9747. try {
  9748. new Function('return 1');
  9749. } catch (e) {
  9750. if (e.toString().match(/unsafe-eval|CSP/)) {
  9751. warn$$1(
  9752. 'It seems you are using the standalone build of Vue.js in an ' +
  9753. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  9754. 'The template compiler cannot work in this environment. Consider ' +
  9755. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  9756. 'templates into render functions.'
  9757. );
  9758. }
  9759. }
  9760. }
  9761. // check cache
  9762. var key = options.delimiters
  9763. ? String(options.delimiters) + template
  9764. : template;
  9765. if (cache[key]) {
  9766. return cache[key]
  9767. }
  9768. // compile
  9769. var compiled = compile(template, options);
  9770. // check compilation errors/tips
  9771. {
  9772. if (compiled.errors && compiled.errors.length) {
  9773. warn$$1(
  9774. "Error compiling template:\n\n" + template + "\n\n" +
  9775. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  9776. vm
  9777. );
  9778. }
  9779. if (compiled.tips && compiled.tips.length) {
  9780. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  9781. }
  9782. }
  9783. // turn code into functions
  9784. var res = {};
  9785. var fnGenErrors = [];
  9786. res.render = createFunction(compiled.render, fnGenErrors);
  9787. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  9788. return createFunction(code, fnGenErrors)
  9789. });
  9790. // check function generation errors.
  9791. // this should only happen if there is a bug in the compiler itself.
  9792. // mostly for codegen development use
  9793. /* istanbul ignore if */
  9794. {
  9795. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  9796. warn$$1(
  9797. "Failed to generate render function:\n\n" +
  9798. fnGenErrors.map(function (ref) {
  9799. var err = ref.err;
  9800. var code = ref.code;
  9801. return ((err.toString()) + " in\n\n" + code + "\n");
  9802. }).join('\n'),
  9803. vm
  9804. );
  9805. }
  9806. }
  9807. return (cache[key] = res)
  9808. }
  9809. }
  9810. /* */
  9811. function createCompilerCreator (baseCompile) {
  9812. return function createCompiler (baseOptions) {
  9813. function compile (
  9814. template,
  9815. options
  9816. ) {
  9817. var finalOptions = Object.create(baseOptions);
  9818. var errors = [];
  9819. var tips = [];
  9820. finalOptions.warn = function (msg, tip) {
  9821. (tip ? tips : errors).push(msg);
  9822. };
  9823. if (options) {
  9824. // merge custom modules
  9825. if (options.modules) {
  9826. finalOptions.modules =
  9827. (baseOptions.modules || []).concat(options.modules);
  9828. }
  9829. // merge custom directives
  9830. if (options.directives) {
  9831. finalOptions.directives = extend(
  9832. Object.create(baseOptions.directives || null),
  9833. options.directives
  9834. );
  9835. }
  9836. // copy other options
  9837. for (var key in options) {
  9838. if (key !== 'modules' && key !== 'directives') {
  9839. finalOptions[key] = options[key];
  9840. }
  9841. }
  9842. }
  9843. var compiled = baseCompile(template, finalOptions);
  9844. {
  9845. errors.push.apply(errors, detectErrors(compiled.ast));
  9846. }
  9847. compiled.errors = errors;
  9848. compiled.tips = tips;
  9849. return compiled
  9850. }
  9851. return {
  9852. compile: compile,
  9853. compileToFunctions: createCompileToFunctionFn(compile)
  9854. }
  9855. }
  9856. }
  9857. /* */
  9858. // `createCompilerCreator` allows creating compilers that use alternative
  9859. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  9860. // Here we just export a default compiler using the default parts.
  9861. var createCompiler = createCompilerCreator(function baseCompile (
  9862. template,
  9863. options
  9864. ) {
  9865. var ast = parse(template.trim(), options);
  9866. if (options.optimize !== false) {
  9867. optimize(ast, options);
  9868. }
  9869. var code = generate(ast, options);
  9870. return {
  9871. ast: ast,
  9872. render: code.render,
  9873. staticRenderFns: code.staticRenderFns
  9874. }
  9875. });
  9876. /* */
  9877. var ref$1 = createCompiler(baseOptions);
  9878. var compile = ref$1.compile;
  9879. var compileToFunctions = ref$1.compileToFunctions;
  9880. /* */
  9881. // check whether current browser encodes a char inside attribute values
  9882. var div;
  9883. function getShouldDecode (href) {
  9884. div = div || document.createElement('div');
  9885. div.innerHTML = href ? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
  9886. return div.innerHTML.indexOf('&#10;') > 0
  9887. }
  9888. // #3663: IE encodes newlines inside attribute values while other browsers don't
  9889. var shouldDecodeNewlines = inBrowser ? getShouldDecode(false) : false;
  9890. // #6828: chrome encodes content in a[href]
  9891. var shouldDecodeNewlinesForHref = inBrowser ? getShouldDecode(true) : false;
  9892. /* */
  9893. var idToTemplate = cached(function (id) {
  9894. var el = query(id);
  9895. return el && el.innerHTML
  9896. });
  9897. var mount = Vue.prototype.$mount;
  9898. Vue.prototype.$mount = function (
  9899. el,
  9900. hydrating
  9901. ) {
  9902. el = el && query(el);
  9903. /* istanbul ignore if */
  9904. if (el === document.body || el === document.documentElement) {
  9905. warn(
  9906. "Do not mount Vue to <html> or <body> - mount to normal elements instead."
  9907. );
  9908. return this
  9909. }
  9910. var options = this.$options;
  9911. // resolve template/el and convert to render function
  9912. if (!options.render) {
  9913. var template = options.template;
  9914. if (template) {
  9915. if (typeof template === 'string') {
  9916. if (template.charAt(0) === '#') {
  9917. template = idToTemplate(template);
  9918. /* istanbul ignore if */
  9919. if (!template) {
  9920. warn(
  9921. ("Template element not found or is empty: " + (options.template)),
  9922. this
  9923. );
  9924. }
  9925. }
  9926. } else if (template.nodeType) {
  9927. template = template.innerHTML;
  9928. } else {
  9929. {
  9930. warn('invalid template option:' + template, this);
  9931. }
  9932. return this
  9933. }
  9934. } else if (el) {
  9935. template = getOuterHTML(el);
  9936. }
  9937. if (template) {
  9938. /* istanbul ignore if */
  9939. if (config.performance && mark) {
  9940. mark('compile');
  9941. }
  9942. var ref = compileToFunctions(template, {
  9943. shouldDecodeNewlines: shouldDecodeNewlines,
  9944. shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref,
  9945. delimiters: options.delimiters,
  9946. comments: options.comments
  9947. }, this);
  9948. var render = ref.render;
  9949. var staticRenderFns = ref.staticRenderFns;
  9950. options.render = render;
  9951. options.staticRenderFns = staticRenderFns;
  9952. /* istanbul ignore if */
  9953. if (config.performance && mark) {
  9954. mark('compile end');
  9955. measure(("vue " + (this._name) + " compile"), 'compile', 'compile end');
  9956. }
  9957. }
  9958. }
  9959. return mount.call(this, el, hydrating)
  9960. };
  9961. /**
  9962. * Get outerHTML of elements, taking care
  9963. * of SVG elements in IE as well.
  9964. */
  9965. function getOuterHTML (el) {
  9966. if (el.outerHTML) {
  9967. return el.outerHTML
  9968. } else {
  9969. var container = document.createElement('div');
  9970. container.appendChild(el.cloneNode(true));
  9971. return container.innerHTML
  9972. }
  9973. }
  9974. Vue.compile = compileToFunctions;
  9975. return Vue;
  9976. })));