factory.js 167 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542
  1. 'use strict';
  2. module.exports = function weexFactory (exports, renderer) {
  3. /* */
  4. // these helpers produces better vm code in JS engines due to their
  5. // explicitness and function inlining
  6. function isUndef (v) {
  7. return v === undefined || v === null
  8. }
  9. function isDef (v) {
  10. return v !== undefined && v !== null
  11. }
  12. function isTrue (v) {
  13. return v === true
  14. }
  15. function isFalse (v) {
  16. return v === false
  17. }
  18. /**
  19. * Check if value is primitive
  20. */
  21. function isPrimitive (value) {
  22. return (
  23. typeof value === 'string' ||
  24. typeof value === 'number' ||
  25. typeof value === 'boolean'
  26. )
  27. }
  28. /**
  29. * Quick object check - this is primarily used to tell
  30. * Objects from primitive values when we know the value
  31. * is a JSON-compliant type.
  32. */
  33. function isObject (obj) {
  34. return obj !== null && typeof obj === 'object'
  35. }
  36. var _toString = Object.prototype.toString;
  37. /**
  38. * Strict object type check. Only returns true
  39. * for plain JavaScript objects.
  40. */
  41. function isPlainObject (obj) {
  42. return _toString.call(obj) === '[object Object]'
  43. }
  44. function isRegExp (v) {
  45. return _toString.call(v) === '[object RegExp]'
  46. }
  47. /**
  48. * Check if val is a valid array index.
  49. */
  50. function isValidArrayIndex (val) {
  51. var n = parseFloat(val);
  52. return n >= 0 && Math.floor(n) === n && isFinite(val)
  53. }
  54. /**
  55. * Convert a value to a string that is actually rendered.
  56. */
  57. function toString (val) {
  58. return val == null
  59. ? ''
  60. : typeof val === 'object'
  61. ? JSON.stringify(val, null, 2)
  62. : String(val)
  63. }
  64. /**
  65. * Convert a input value to a number for persistence.
  66. * If the conversion fails, return original string.
  67. */
  68. function toNumber (val) {
  69. var n = parseFloat(val);
  70. return isNaN(n) ? val : n
  71. }
  72. /**
  73. * Make a map and return a function for checking if a key
  74. * is in that map.
  75. */
  76. function makeMap (
  77. str,
  78. expectsLowerCase
  79. ) {
  80. var map = Object.create(null);
  81. var list = str.split(',');
  82. for (var i = 0; i < list.length; i++) {
  83. map[list[i]] = true;
  84. }
  85. return expectsLowerCase
  86. ? function (val) { return map[val.toLowerCase()]; }
  87. : function (val) { return map[val]; }
  88. }
  89. /**
  90. * Check if a tag is a built-in tag.
  91. */
  92. var isBuiltInTag = makeMap('slot,component', true);
  93. /**
  94. * Check if a attribute is a reserved attribute.
  95. */
  96. var isReservedAttribute = makeMap('key,ref,slot,is');
  97. /**
  98. * Remove an item from an array
  99. */
  100. function remove (arr, item) {
  101. if (arr.length) {
  102. var index = arr.indexOf(item);
  103. if (index > -1) {
  104. return arr.splice(index, 1)
  105. }
  106. }
  107. }
  108. /**
  109. * Check whether the object has the property.
  110. */
  111. var hasOwnProperty = Object.prototype.hasOwnProperty;
  112. function hasOwn (obj, key) {
  113. return hasOwnProperty.call(obj, key)
  114. }
  115. /**
  116. * Create a cached version of a pure function.
  117. */
  118. function cached (fn) {
  119. var cache = Object.create(null);
  120. return (function cachedFn (str) {
  121. var hit = cache[str];
  122. return hit || (cache[str] = fn(str))
  123. })
  124. }
  125. /**
  126. * Camelize a hyphen-delimited string.
  127. */
  128. var camelizeRE = /-(\w)/g;
  129. var camelize = cached(function (str) {
  130. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  131. });
  132. /**
  133. * Capitalize a string.
  134. */
  135. var capitalize = cached(function (str) {
  136. return str.charAt(0).toUpperCase() + str.slice(1)
  137. });
  138. /**
  139. * Hyphenate a camelCase string.
  140. */
  141. var hyphenateRE = /([^-])([A-Z])/g;
  142. var hyphenate = cached(function (str) {
  143. return str
  144. .replace(hyphenateRE, '$1-$2')
  145. .replace(hyphenateRE, '$1-$2')
  146. .toLowerCase()
  147. });
  148. /**
  149. * Simple bind, faster than native
  150. */
  151. function bind (fn, ctx) {
  152. function boundFn (a) {
  153. var l = arguments.length;
  154. return l
  155. ? l > 1
  156. ? fn.apply(ctx, arguments)
  157. : fn.call(ctx, a)
  158. : fn.call(ctx)
  159. }
  160. // record original fn length
  161. boundFn._length = fn.length;
  162. return boundFn
  163. }
  164. /**
  165. * Convert an Array-like object to a real Array.
  166. */
  167. function toArray (list, start) {
  168. start = start || 0;
  169. var i = list.length - start;
  170. var ret = new Array(i);
  171. while (i--) {
  172. ret[i] = list[i + start];
  173. }
  174. return ret
  175. }
  176. /**
  177. * Mix properties into target object.
  178. */
  179. function extend (to, _from) {
  180. for (var key in _from) {
  181. to[key] = _from[key];
  182. }
  183. return to
  184. }
  185. /**
  186. * Merge an Array of Objects into a single Object.
  187. */
  188. function toObject (arr) {
  189. var res = {};
  190. for (var i = 0; i < arr.length; i++) {
  191. if (arr[i]) {
  192. extend(res, arr[i]);
  193. }
  194. }
  195. return res
  196. }
  197. /**
  198. * Perform no operation.
  199. * Stubbing args to make Flow happy without leaving useless transpiled code
  200. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
  201. */
  202. function noop (a, b, c) {}
  203. /**
  204. * Always return false.
  205. */
  206. var no = function (a, b, c) { return false; };
  207. /**
  208. * Return same value
  209. */
  210. var identity = function (_) { return _; };
  211. /**
  212. * Generate a static keys string from compiler modules.
  213. */
  214. /**
  215. * Check if two values are loosely equal - that is,
  216. * if they are plain objects, do they have the same shape?
  217. */
  218. function looseEqual (a, b) {
  219. if (a === b) { return true }
  220. var isObjectA = isObject(a);
  221. var isObjectB = isObject(b);
  222. if (isObjectA && isObjectB) {
  223. try {
  224. var isArrayA = Array.isArray(a);
  225. var isArrayB = Array.isArray(b);
  226. if (isArrayA && isArrayB) {
  227. return a.length === b.length && a.every(function (e, i) {
  228. return looseEqual(e, b[i])
  229. })
  230. } else if (!isArrayA && !isArrayB) {
  231. var keysA = Object.keys(a);
  232. var keysB = Object.keys(b);
  233. return keysA.length === keysB.length && keysA.every(function (key) {
  234. return looseEqual(a[key], b[key])
  235. })
  236. } else {
  237. /* istanbul ignore next */
  238. return false
  239. }
  240. } catch (e) {
  241. /* istanbul ignore next */
  242. return false
  243. }
  244. } else if (!isObjectA && !isObjectB) {
  245. return String(a) === String(b)
  246. } else {
  247. return false
  248. }
  249. }
  250. function looseIndexOf (arr, val) {
  251. for (var i = 0; i < arr.length; i++) {
  252. if (looseEqual(arr[i], val)) { return i }
  253. }
  254. return -1
  255. }
  256. /**
  257. * Ensure a function is called only once.
  258. */
  259. function once (fn) {
  260. var called = false;
  261. return function () {
  262. if (!called) {
  263. called = true;
  264. fn.apply(this, arguments);
  265. }
  266. }
  267. }
  268. var SSR_ATTR = 'data-server-rendered';
  269. var ASSET_TYPES = [
  270. 'component',
  271. 'directive',
  272. 'filter'
  273. ];
  274. var LIFECYCLE_HOOKS = [
  275. 'beforeCreate',
  276. 'created',
  277. 'beforeMount',
  278. 'mounted',
  279. 'beforeUpdate',
  280. 'updated',
  281. 'beforeDestroy',
  282. 'destroyed',
  283. 'activated',
  284. 'deactivated'
  285. ];
  286. /* */
  287. var config = ({
  288. /**
  289. * Option merge strategies (used in core/util/options)
  290. */
  291. optionMergeStrategies: Object.create(null),
  292. /**
  293. * Whether to suppress warnings.
  294. */
  295. silent: false,
  296. /**
  297. * Show production mode tip message on boot?
  298. */
  299. productionTip: process.env.NODE_ENV !== 'production',
  300. /**
  301. * Whether to enable devtools
  302. */
  303. devtools: process.env.NODE_ENV !== 'production',
  304. /**
  305. * Whether to record perf
  306. */
  307. performance: false,
  308. /**
  309. * Error handler for watcher errors
  310. */
  311. errorHandler: null,
  312. /**
  313. * Warn handler for watcher warns
  314. */
  315. warnHandler: null,
  316. /**
  317. * Ignore certain custom elements
  318. */
  319. ignoredElements: [],
  320. /**
  321. * Custom user key aliases for v-on
  322. */
  323. keyCodes: Object.create(null),
  324. /**
  325. * Check if a tag is reserved so that it cannot be registered as a
  326. * component. This is platform-dependent and may be overwritten.
  327. */
  328. isReservedTag: no,
  329. /**
  330. * Check if an attribute is reserved so that it cannot be used as a component
  331. * prop. This is platform-dependent and may be overwritten.
  332. */
  333. isReservedAttr: no,
  334. /**
  335. * Check if a tag is an unknown element.
  336. * Platform-dependent.
  337. */
  338. isUnknownElement: no,
  339. /**
  340. * Get the namespace of an element
  341. */
  342. getTagNamespace: noop,
  343. /**
  344. * Parse the real tag name for the specific platform.
  345. */
  346. parsePlatformTagName: identity,
  347. /**
  348. * Check if an attribute must be bound using property, e.g. value
  349. * Platform-dependent.
  350. */
  351. mustUseProp: no,
  352. /**
  353. * Exposed for legacy reasons
  354. */
  355. _lifecycleHooks: LIFECYCLE_HOOKS
  356. });
  357. /* */
  358. var emptyObject = Object.freeze({});
  359. /**
  360. * Check if a string starts with $ or _
  361. */
  362. function isReserved (str) {
  363. var c = (str + '').charCodeAt(0);
  364. return c === 0x24 || c === 0x5F
  365. }
  366. /**
  367. * Define a property.
  368. */
  369. function def (obj, key, val, enumerable) {
  370. Object.defineProperty(obj, key, {
  371. value: val,
  372. enumerable: !!enumerable,
  373. writable: true,
  374. configurable: true
  375. });
  376. }
  377. /**
  378. * Parse simple path.
  379. */
  380. var bailRE = /[^\w.$]/;
  381. function parsePath (path) {
  382. if (bailRE.test(path)) {
  383. return
  384. }
  385. var segments = path.split('.');
  386. return function (obj) {
  387. for (var i = 0; i < segments.length; i++) {
  388. if (!obj) { return }
  389. obj = obj[segments[i]];
  390. }
  391. return obj
  392. }
  393. }
  394. /* */
  395. var warn = noop;
  396. var tip = noop;
  397. var formatComponentName = (null); // work around flow check
  398. if (process.env.NODE_ENV !== 'production') {
  399. var hasConsole = typeof console !== 'undefined';
  400. var classifyRE = /(?:^|[-_])(\w)/g;
  401. var classify = function (str) { return str
  402. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  403. .replace(/[-_]/g, ''); };
  404. warn = function (msg, vm) {
  405. var trace = vm ? generateComponentTrace(vm) : '';
  406. if (config.warnHandler) {
  407. config.warnHandler.call(null, msg, vm, trace);
  408. } else if (hasConsole && (!config.silent)) {
  409. console.error(("[Vue warn]: " + msg + trace));
  410. }
  411. };
  412. tip = function (msg, vm) {
  413. if (hasConsole && (!config.silent)) {
  414. console.warn("[Vue tip]: " + msg + (
  415. vm ? generateComponentTrace(vm) : ''
  416. ));
  417. }
  418. };
  419. formatComponentName = function (vm, includeFile) {
  420. if (vm.$root === vm) {
  421. return '<Root>'
  422. }
  423. var name = typeof vm === 'string'
  424. ? vm
  425. : typeof vm === 'function' && vm.options
  426. ? vm.options.name
  427. : vm._isVue
  428. ? vm.$options.name || vm.$options._componentTag
  429. : vm.name;
  430. var file = vm._isVue && vm.$options.__file;
  431. if (!name && file) {
  432. var match = file.match(/([^/\\]+)\.vue$/);
  433. name = match && match[1];
  434. }
  435. return (
  436. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  437. (file && includeFile !== false ? (" at " + file) : '')
  438. )
  439. };
  440. var repeat = function (str, n) {
  441. var res = '';
  442. while (n) {
  443. if (n % 2 === 1) { res += str; }
  444. if (n > 1) { str += str; }
  445. n >>= 1;
  446. }
  447. return res
  448. };
  449. var generateComponentTrace = function (vm) {
  450. if (vm._isVue && vm.$parent) {
  451. var tree = [];
  452. var currentRecursiveSequence = 0;
  453. while (vm) {
  454. if (tree.length > 0) {
  455. var last = tree[tree.length - 1];
  456. if (last.constructor === vm.constructor) {
  457. currentRecursiveSequence++;
  458. vm = vm.$parent;
  459. continue
  460. } else if (currentRecursiveSequence > 0) {
  461. tree[tree.length - 1] = [last, currentRecursiveSequence];
  462. currentRecursiveSequence = 0;
  463. }
  464. }
  465. tree.push(vm);
  466. vm = vm.$parent;
  467. }
  468. return '\n\nfound in\n\n' + tree
  469. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  470. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  471. : formatComponentName(vm))); })
  472. .join('\n')
  473. } else {
  474. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  475. }
  476. };
  477. }
  478. /* */
  479. function handleError (err, vm, info) {
  480. if (config.errorHandler) {
  481. config.errorHandler.call(null, err, vm, info);
  482. } else {
  483. if (process.env.NODE_ENV !== 'production') {
  484. warn(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  485. }
  486. /* istanbul ignore else */
  487. if (inBrowser && typeof console !== 'undefined') {
  488. console.error(err);
  489. } else {
  490. throw err
  491. }
  492. }
  493. }
  494. /* */
  495. /* globals MutationObserver */
  496. // can we use __proto__?
  497. var hasProto = '__proto__' in {};
  498. // Browser environment sniffing
  499. var inBrowser = typeof window !== 'undefined';
  500. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  501. var isIE = UA && /msie|trident/.test(UA);
  502. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  503. var isEdge = UA && UA.indexOf('edge/') > 0;
  504. var isAndroid = UA && UA.indexOf('android') > 0;
  505. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  506. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  507. // Firefix has a "watch" function on Object.prototype...
  508. var nativeWatch = ({}).watch;
  509. var supportsPassive = false;
  510. if (inBrowser) {
  511. try {
  512. var opts = {};
  513. Object.defineProperty(opts, 'passive', ({
  514. get: function get () {
  515. /* istanbul ignore next */
  516. supportsPassive = true;
  517. }
  518. })); // https://github.com/facebook/flow/issues/285
  519. window.addEventListener('test-passive', null, opts);
  520. } catch (e) {}
  521. }
  522. // this needs to be lazy-evaled because vue may be required before
  523. // vue-server-renderer can set VUE_ENV
  524. var _isServer;
  525. var isServerRendering = function () {
  526. if (_isServer === undefined) {
  527. /* istanbul ignore if */
  528. if (!inBrowser && typeof global !== 'undefined') {
  529. // detect presence of vue-server-renderer and avoid
  530. // Webpack shimming the process
  531. _isServer = global['process'].env.VUE_ENV === 'server';
  532. } else {
  533. _isServer = false;
  534. }
  535. }
  536. return _isServer
  537. };
  538. // detect devtools
  539. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  540. /* istanbul ignore next */
  541. function isNative (Ctor) {
  542. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  543. }
  544. var hasSymbol =
  545. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  546. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  547. /**
  548. * Defer a task to execute it asynchronously.
  549. */
  550. var nextTick = (function () {
  551. var callbacks = [];
  552. var pending = false;
  553. var timerFunc;
  554. function nextTickHandler () {
  555. pending = false;
  556. var copies = callbacks.slice(0);
  557. callbacks.length = 0;
  558. for (var i = 0; i < copies.length; i++) {
  559. copies[i]();
  560. }
  561. }
  562. // the nextTick behavior leverages the microtask queue, which can be accessed
  563. // via either native Promise.then or MutationObserver.
  564. // MutationObserver has wider support, however it is seriously bugged in
  565. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  566. // completely stops working after triggering a few times... so, if native
  567. // Promise is available, we will use it:
  568. /* istanbul ignore if */
  569. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  570. var p = Promise.resolve();
  571. var logError = function (err) { console.error(err); };
  572. timerFunc = function () {
  573. p.then(nextTickHandler).catch(logError);
  574. // in problematic UIWebViews, Promise.then doesn't completely break, but
  575. // it can get stuck in a weird state where callbacks are pushed into the
  576. // microtask queue but the queue isn't being flushed, until the browser
  577. // needs to do some other work, e.g. handle a timer. Therefore we can
  578. // "force" the microtask queue to be flushed by adding an empty timer.
  579. if (isIOS) { setTimeout(noop); }
  580. };
  581. } else if (typeof MutationObserver !== 'undefined' && (
  582. isNative(MutationObserver) ||
  583. // PhantomJS and iOS 7.x
  584. MutationObserver.toString() === '[object MutationObserverConstructor]'
  585. )) {
  586. // use MutationObserver where native Promise is not available,
  587. // e.g. PhantomJS IE11, iOS7, Android 4.4
  588. var counter = 1;
  589. var observer = new MutationObserver(nextTickHandler);
  590. var textNode = document.createTextNode(String(counter));
  591. observer.observe(textNode, {
  592. characterData: true
  593. });
  594. timerFunc = function () {
  595. counter = (counter + 1) % 2;
  596. textNode.data = String(counter);
  597. };
  598. } else {
  599. // fallback to setTimeout
  600. /* istanbul ignore next */
  601. timerFunc = function () {
  602. setTimeout(nextTickHandler, 0);
  603. };
  604. }
  605. return function queueNextTick (cb, ctx) {
  606. var _resolve;
  607. callbacks.push(function () {
  608. if (cb) {
  609. try {
  610. cb.call(ctx);
  611. } catch (e) {
  612. handleError(e, ctx, 'nextTick');
  613. }
  614. } else if (_resolve) {
  615. _resolve(ctx);
  616. }
  617. });
  618. if (!pending) {
  619. pending = true;
  620. timerFunc();
  621. }
  622. if (!cb && typeof Promise !== 'undefined') {
  623. return new Promise(function (resolve, reject) {
  624. _resolve = resolve;
  625. })
  626. }
  627. }
  628. })();
  629. var _Set;
  630. /* istanbul ignore if */
  631. if (typeof Set !== 'undefined' && isNative(Set)) {
  632. // use native Set when available.
  633. _Set = Set;
  634. } else {
  635. // a non-standard Set polyfill that only works with primitive keys.
  636. _Set = (function () {
  637. function Set () {
  638. this.set = Object.create(null);
  639. }
  640. Set.prototype.has = function has (key) {
  641. return this.set[key] === true
  642. };
  643. Set.prototype.add = function add (key) {
  644. this.set[key] = true;
  645. };
  646. Set.prototype.clear = function clear () {
  647. this.set = Object.create(null);
  648. };
  649. return Set;
  650. }());
  651. }
  652. /* */
  653. var uid$1 = 0;
  654. /**
  655. * A dep is an observable that can have multiple
  656. * directives subscribing to it.
  657. */
  658. var Dep = function Dep () {
  659. this.id = uid$1++;
  660. this.subs = [];
  661. };
  662. Dep.prototype.addSub = function addSub (sub) {
  663. this.subs.push(sub);
  664. };
  665. Dep.prototype.removeSub = function removeSub (sub) {
  666. remove(this.subs, sub);
  667. };
  668. Dep.prototype.depend = function depend () {
  669. if (Dep.target) {
  670. Dep.target.addDep(this);
  671. }
  672. };
  673. Dep.prototype.notify = function notify () {
  674. // stabilize the subscriber list first
  675. var subs = this.subs.slice();
  676. for (var i = 0, l = subs.length; i < l; i++) {
  677. subs[i].update();
  678. }
  679. };
  680. // the current target watcher being evaluated.
  681. // this is globally unique because there could be only one
  682. // watcher being evaluated at any time.
  683. Dep.target = null;
  684. var targetStack = [];
  685. function pushTarget (_target) {
  686. if (Dep.target) { targetStack.push(Dep.target); }
  687. Dep.target = _target;
  688. }
  689. function popTarget () {
  690. Dep.target = targetStack.pop();
  691. }
  692. /*
  693. * not type checking this file because flow doesn't play well with
  694. * dynamically accessing methods on Array prototype
  695. */
  696. var arrayProto = Array.prototype;
  697. var arrayMethods = Object.create(arrayProto);[
  698. 'push',
  699. 'pop',
  700. 'shift',
  701. 'unshift',
  702. 'splice',
  703. 'sort',
  704. 'reverse'
  705. ]
  706. .forEach(function (method) {
  707. // cache original method
  708. var original = arrayProto[method];
  709. def(arrayMethods, method, function mutator () {
  710. var args = [], len = arguments.length;
  711. while ( len-- ) args[ len ] = arguments[ len ];
  712. var result = original.apply(this, args);
  713. var ob = this.__ob__;
  714. var inserted;
  715. switch (method) {
  716. case 'push':
  717. case 'unshift':
  718. inserted = args;
  719. break
  720. case 'splice':
  721. inserted = args.slice(2);
  722. break
  723. }
  724. if (inserted) { ob.observeArray(inserted); }
  725. // notify change
  726. ob.dep.notify();
  727. return result
  728. });
  729. });
  730. /* */
  731. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  732. /**
  733. * By default, when a reactive property is set, the new value is
  734. * also converted to become reactive. However when passing down props,
  735. * we don't want to force conversion because the value may be a nested value
  736. * under a frozen data structure. Converting it would defeat the optimization.
  737. */
  738. var observerState = {
  739. shouldConvert: true
  740. };
  741. /**
  742. * Observer class that are attached to each observed
  743. * object. Once attached, the observer converts target
  744. * object's property keys into getter/setters that
  745. * collect dependencies and dispatches updates.
  746. */
  747. var Observer = function Observer (value) {
  748. this.value = value;
  749. this.dep = new Dep();
  750. this.vmCount = 0;
  751. def(value, '__ob__', this);
  752. if (Array.isArray(value)) {
  753. var augment = hasProto
  754. ? protoAugment
  755. : copyAugment;
  756. augment(value, arrayMethods, arrayKeys);
  757. this.observeArray(value);
  758. } else {
  759. this.walk(value);
  760. }
  761. };
  762. /**
  763. * Walk through each property and convert them into
  764. * getter/setters. This method should only be called when
  765. * value type is Object.
  766. */
  767. Observer.prototype.walk = function walk (obj) {
  768. var keys = Object.keys(obj);
  769. for (var i = 0; i < keys.length; i++) {
  770. defineReactive$$1(obj, keys[i], obj[keys[i]]);
  771. }
  772. };
  773. /**
  774. * Observe a list of Array items.
  775. */
  776. Observer.prototype.observeArray = function observeArray (items) {
  777. for (var i = 0, l = items.length; i < l; i++) {
  778. observe(items[i]);
  779. }
  780. };
  781. // helpers
  782. /**
  783. * Augment an target Object or Array by intercepting
  784. * the prototype chain using __proto__
  785. */
  786. function protoAugment (target, src, keys) {
  787. /* eslint-disable no-proto */
  788. target.__proto__ = src;
  789. /* eslint-enable no-proto */
  790. }
  791. /**
  792. * Augment an target Object or Array by defining
  793. * hidden properties.
  794. */
  795. /* istanbul ignore next */
  796. function copyAugment (target, src, keys) {
  797. for (var i = 0, l = keys.length; i < l; i++) {
  798. var key = keys[i];
  799. def(target, key, src[key]);
  800. }
  801. }
  802. /**
  803. * Attempt to create an observer instance for a value,
  804. * returns the new observer if successfully observed,
  805. * or the existing observer if the value already has one.
  806. */
  807. function observe (value, asRootData) {
  808. if (!isObject(value)) {
  809. return
  810. }
  811. var ob;
  812. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  813. ob = value.__ob__;
  814. } else if (
  815. observerState.shouldConvert &&
  816. !isServerRendering() &&
  817. (Array.isArray(value) || isPlainObject(value)) &&
  818. Object.isExtensible(value) &&
  819. !value._isVue
  820. ) {
  821. ob = new Observer(value);
  822. }
  823. if (asRootData && ob) {
  824. ob.vmCount++;
  825. }
  826. return ob
  827. }
  828. /**
  829. * Define a reactive property on an Object.
  830. */
  831. function defineReactive$$1 (
  832. obj,
  833. key,
  834. val,
  835. customSetter,
  836. shallow
  837. ) {
  838. var dep = new Dep();
  839. var property = Object.getOwnPropertyDescriptor(obj, key);
  840. if (property && property.configurable === false) {
  841. return
  842. }
  843. // cater for pre-defined getter/setters
  844. var getter = property && property.get;
  845. var setter = property && property.set;
  846. var childOb = !shallow && observe(val);
  847. Object.defineProperty(obj, key, {
  848. enumerable: true,
  849. configurable: true,
  850. get: function reactiveGetter () {
  851. var value = getter ? getter.call(obj) : val;
  852. if (Dep.target) {
  853. dep.depend();
  854. if (childOb) {
  855. childOb.dep.depend();
  856. }
  857. if (Array.isArray(value)) {
  858. dependArray(value);
  859. }
  860. }
  861. return value
  862. },
  863. set: function reactiveSetter (newVal) {
  864. var value = getter ? getter.call(obj) : val;
  865. /* eslint-disable no-self-compare */
  866. if (newVal === value || (newVal !== newVal && value !== value)) {
  867. return
  868. }
  869. /* eslint-enable no-self-compare */
  870. if (process.env.NODE_ENV !== 'production' && customSetter) {
  871. customSetter();
  872. }
  873. if (setter) {
  874. setter.call(obj, newVal);
  875. } else {
  876. val = newVal;
  877. }
  878. childOb = !shallow && observe(newVal);
  879. dep.notify();
  880. }
  881. });
  882. }
  883. /**
  884. * Set a property on an object. Adds the new property and
  885. * triggers change notification if the property doesn't
  886. * already exist.
  887. */
  888. function set (target, key, val) {
  889. if (Array.isArray(target) && isValidArrayIndex(key)) {
  890. target.length = Math.max(target.length, key);
  891. target.splice(key, 1, val);
  892. return val
  893. }
  894. if (hasOwn(target, key)) {
  895. target[key] = val;
  896. return val
  897. }
  898. var ob = (target).__ob__;
  899. if (target._isVue || (ob && ob.vmCount)) {
  900. process.env.NODE_ENV !== 'production' && warn(
  901. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  902. 'at runtime - declare it upfront in the data option.'
  903. );
  904. return val
  905. }
  906. if (!ob) {
  907. target[key] = val;
  908. return val
  909. }
  910. defineReactive$$1(ob.value, key, val);
  911. ob.dep.notify();
  912. return val
  913. }
  914. /**
  915. * Delete a property and trigger change if necessary.
  916. */
  917. function del (target, key) {
  918. if (Array.isArray(target) && isValidArrayIndex(key)) {
  919. target.splice(key, 1);
  920. return
  921. }
  922. var ob = (target).__ob__;
  923. if (target._isVue || (ob && ob.vmCount)) {
  924. process.env.NODE_ENV !== 'production' && warn(
  925. 'Avoid deleting properties on a Vue instance or its root $data ' +
  926. '- just set it to null.'
  927. );
  928. return
  929. }
  930. if (!hasOwn(target, key)) {
  931. return
  932. }
  933. delete target[key];
  934. if (!ob) {
  935. return
  936. }
  937. ob.dep.notify();
  938. }
  939. /**
  940. * Collect dependencies on array elements when the array is touched, since
  941. * we cannot intercept array element access like property getters.
  942. */
  943. function dependArray (value) {
  944. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  945. e = value[i];
  946. e && e.__ob__ && e.__ob__.dep.depend();
  947. if (Array.isArray(e)) {
  948. dependArray(e);
  949. }
  950. }
  951. }
  952. /* */
  953. /**
  954. * Option overwriting strategies are functions that handle
  955. * how to merge a parent option value and a child option
  956. * value into the final value.
  957. */
  958. var strats = config.optionMergeStrategies;
  959. /**
  960. * Options with restrictions
  961. */
  962. if (process.env.NODE_ENV !== 'production') {
  963. strats.el = strats.propsData = function (parent, child, vm, key) {
  964. if (!vm) {
  965. warn(
  966. "option \"" + key + "\" can only be used during instance " +
  967. 'creation with the `new` keyword.'
  968. );
  969. }
  970. return defaultStrat(parent, child)
  971. };
  972. }
  973. /**
  974. * Helper that recursively merges two data objects together.
  975. */
  976. function mergeData (to, from) {
  977. if (!from) { return to }
  978. var key, toVal, fromVal;
  979. var keys = Object.keys(from);
  980. for (var i = 0; i < keys.length; i++) {
  981. key = keys[i];
  982. toVal = to[key];
  983. fromVal = from[key];
  984. if (!hasOwn(to, key)) {
  985. set(to, key, fromVal);
  986. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  987. mergeData(toVal, fromVal);
  988. }
  989. }
  990. return to
  991. }
  992. /**
  993. * Data
  994. */
  995. function mergeDataOrFn (
  996. parentVal,
  997. childVal,
  998. vm
  999. ) {
  1000. if (!vm) {
  1001. // in a Vue.extend merge, both should be functions
  1002. if (!childVal) {
  1003. return parentVal
  1004. }
  1005. if (!parentVal) {
  1006. return childVal
  1007. }
  1008. // when parentVal & childVal are both present,
  1009. // we need to return a function that returns the
  1010. // merged result of both functions... no need to
  1011. // check if parentVal is a function here because
  1012. // it has to be a function to pass previous merges.
  1013. return function mergedDataFn () {
  1014. return mergeData(
  1015. typeof childVal === 'function' ? childVal.call(this) : childVal,
  1016. typeof parentVal === 'function' ? parentVal.call(this) : parentVal
  1017. )
  1018. }
  1019. } else if (parentVal || childVal) {
  1020. return function mergedInstanceDataFn () {
  1021. // instance merge
  1022. var instanceData = typeof childVal === 'function'
  1023. ? childVal.call(vm)
  1024. : childVal;
  1025. var defaultData = typeof parentVal === 'function'
  1026. ? parentVal.call(vm)
  1027. : undefined;
  1028. if (instanceData) {
  1029. return mergeData(instanceData, defaultData)
  1030. } else {
  1031. return defaultData
  1032. }
  1033. }
  1034. }
  1035. }
  1036. strats.data = function (
  1037. parentVal,
  1038. childVal,
  1039. vm
  1040. ) {
  1041. if (!vm) {
  1042. if (childVal && typeof childVal !== 'function') {
  1043. process.env.NODE_ENV !== 'production' && warn(
  1044. 'The "data" option should be a function ' +
  1045. 'that returns a per-instance value in component ' +
  1046. 'definitions.',
  1047. vm
  1048. );
  1049. return parentVal
  1050. }
  1051. return mergeDataOrFn.call(this, parentVal, childVal)
  1052. }
  1053. return mergeDataOrFn(parentVal, childVal, vm)
  1054. };
  1055. /**
  1056. * Hooks and props are merged as arrays.
  1057. */
  1058. function mergeHook (
  1059. parentVal,
  1060. childVal
  1061. ) {
  1062. return childVal
  1063. ? parentVal
  1064. ? parentVal.concat(childVal)
  1065. : Array.isArray(childVal)
  1066. ? childVal
  1067. : [childVal]
  1068. : parentVal
  1069. }
  1070. LIFECYCLE_HOOKS.forEach(function (hook) {
  1071. strats[hook] = mergeHook;
  1072. });
  1073. /**
  1074. * Assets
  1075. *
  1076. * When a vm is present (instance creation), we need to do
  1077. * a three-way merge between constructor options, instance
  1078. * options and parent options.
  1079. */
  1080. function mergeAssets (parentVal, childVal) {
  1081. var res = Object.create(parentVal || null);
  1082. return childVal
  1083. ? extend(res, childVal)
  1084. : res
  1085. }
  1086. ASSET_TYPES.forEach(function (type) {
  1087. strats[type + 's'] = mergeAssets;
  1088. });
  1089. /**
  1090. * Watchers.
  1091. *
  1092. * Watchers hashes should not overwrite one
  1093. * another, so we merge them as arrays.
  1094. */
  1095. strats.watch = function (parentVal, childVal) {
  1096. // work around Firefox's Object.prototype.watch...
  1097. if (parentVal === nativeWatch) { parentVal = undefined; }
  1098. if (childVal === nativeWatch) { childVal = undefined; }
  1099. /* istanbul ignore if */
  1100. if (!childVal) { return Object.create(parentVal || null) }
  1101. if (!parentVal) { return childVal }
  1102. var ret = {};
  1103. extend(ret, parentVal);
  1104. for (var key in childVal) {
  1105. var parent = ret[key];
  1106. var child = childVal[key];
  1107. if (parent && !Array.isArray(parent)) {
  1108. parent = [parent];
  1109. }
  1110. ret[key] = parent
  1111. ? parent.concat(child)
  1112. : Array.isArray(child) ? child : [child];
  1113. }
  1114. return ret
  1115. };
  1116. /**
  1117. * Other object hashes.
  1118. */
  1119. strats.props =
  1120. strats.methods =
  1121. strats.inject =
  1122. strats.computed = function (parentVal, childVal) {
  1123. if (!parentVal) { return childVal }
  1124. var ret = Object.create(null);
  1125. extend(ret, parentVal);
  1126. if (childVal) { extend(ret, childVal); }
  1127. return ret
  1128. };
  1129. strats.provide = mergeDataOrFn;
  1130. /**
  1131. * Default strategy.
  1132. */
  1133. var defaultStrat = function (parentVal, childVal) {
  1134. return childVal === undefined
  1135. ? parentVal
  1136. : childVal
  1137. };
  1138. /**
  1139. * Validate component names
  1140. */
  1141. function checkComponents (options) {
  1142. for (var key in options.components) {
  1143. var lower = key.toLowerCase();
  1144. if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
  1145. warn(
  1146. 'Do not use built-in or reserved HTML elements as component ' +
  1147. 'id: ' + key
  1148. );
  1149. }
  1150. }
  1151. }
  1152. /**
  1153. * Ensure all props option syntax are normalized into the
  1154. * Object-based format.
  1155. */
  1156. function normalizeProps (options) {
  1157. var props = options.props;
  1158. if (!props) { return }
  1159. var res = {};
  1160. var i, val, name;
  1161. if (Array.isArray(props)) {
  1162. i = props.length;
  1163. while (i--) {
  1164. val = props[i];
  1165. if (typeof val === 'string') {
  1166. name = camelize(val);
  1167. res[name] = { type: null };
  1168. } else if (process.env.NODE_ENV !== 'production') {
  1169. warn('props must be strings when using array syntax.');
  1170. }
  1171. }
  1172. } else if (isPlainObject(props)) {
  1173. for (var key in props) {
  1174. val = props[key];
  1175. name = camelize(key);
  1176. res[name] = isPlainObject(val)
  1177. ? val
  1178. : { type: val };
  1179. }
  1180. }
  1181. options.props = res;
  1182. }
  1183. /**
  1184. * Normalize all injections into Object-based format
  1185. */
  1186. function normalizeInject (options) {
  1187. var inject = options.inject;
  1188. if (Array.isArray(inject)) {
  1189. var normalized = options.inject = {};
  1190. for (var i = 0; i < inject.length; i++) {
  1191. normalized[inject[i]] = inject[i];
  1192. }
  1193. }
  1194. }
  1195. /**
  1196. * Normalize raw function directives into object format.
  1197. */
  1198. function normalizeDirectives (options) {
  1199. var dirs = options.directives;
  1200. if (dirs) {
  1201. for (var key in dirs) {
  1202. var def = dirs[key];
  1203. if (typeof def === 'function') {
  1204. dirs[key] = { bind: def, update: def };
  1205. }
  1206. }
  1207. }
  1208. }
  1209. /**
  1210. * Merge two option objects into a new one.
  1211. * Core utility used in both instantiation and inheritance.
  1212. */
  1213. function mergeOptions (
  1214. parent,
  1215. child,
  1216. vm
  1217. ) {
  1218. if (process.env.NODE_ENV !== 'production') {
  1219. checkComponents(child);
  1220. }
  1221. if (typeof child === 'function') {
  1222. child = child.options;
  1223. }
  1224. normalizeProps(child);
  1225. normalizeInject(child);
  1226. normalizeDirectives(child);
  1227. var extendsFrom = child.extends;
  1228. if (extendsFrom) {
  1229. parent = mergeOptions(parent, extendsFrom, vm);
  1230. }
  1231. if (child.mixins) {
  1232. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1233. parent = mergeOptions(parent, child.mixins[i], vm);
  1234. }
  1235. }
  1236. var options = {};
  1237. var key;
  1238. for (key in parent) {
  1239. mergeField(key);
  1240. }
  1241. for (key in child) {
  1242. if (!hasOwn(parent, key)) {
  1243. mergeField(key);
  1244. }
  1245. }
  1246. function mergeField (key) {
  1247. var strat = strats[key] || defaultStrat;
  1248. options[key] = strat(parent[key], child[key], vm, key);
  1249. }
  1250. return options
  1251. }
  1252. /**
  1253. * Resolve an asset.
  1254. * This function is used because child instances need access
  1255. * to assets defined in its ancestor chain.
  1256. */
  1257. function resolveAsset (
  1258. options,
  1259. type,
  1260. id,
  1261. warnMissing
  1262. ) {
  1263. /* istanbul ignore if */
  1264. if (typeof id !== 'string') {
  1265. return
  1266. }
  1267. var assets = options[type];
  1268. // check local registration variations first
  1269. if (hasOwn(assets, id)) { return assets[id] }
  1270. var camelizedId = camelize(id);
  1271. if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
  1272. var PascalCaseId = capitalize(camelizedId);
  1273. if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
  1274. // fallback to prototype chain
  1275. var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
  1276. if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
  1277. warn(
  1278. 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
  1279. options
  1280. );
  1281. }
  1282. return res
  1283. }
  1284. /* */
  1285. function validateProp (
  1286. key,
  1287. propOptions,
  1288. propsData,
  1289. vm
  1290. ) {
  1291. var prop = propOptions[key];
  1292. var absent = !hasOwn(propsData, key);
  1293. var value = propsData[key];
  1294. // handle boolean props
  1295. if (isType(Boolean, prop.type)) {
  1296. if (absent && !hasOwn(prop, 'default')) {
  1297. value = false;
  1298. } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
  1299. value = true;
  1300. }
  1301. }
  1302. // check default value
  1303. if (value === undefined) {
  1304. value = getPropDefaultValue(vm, prop, key);
  1305. // since the default value is a fresh copy,
  1306. // make sure to observe it.
  1307. var prevShouldConvert = observerState.shouldConvert;
  1308. observerState.shouldConvert = true;
  1309. observe(value);
  1310. observerState.shouldConvert = prevShouldConvert;
  1311. }
  1312. if (process.env.NODE_ENV !== 'production') {
  1313. assertProp(prop, key, value, vm, absent);
  1314. }
  1315. return value
  1316. }
  1317. /**
  1318. * Get the default value of a prop.
  1319. */
  1320. function getPropDefaultValue (vm, prop, key) {
  1321. // no default, return undefined
  1322. if (!hasOwn(prop, 'default')) {
  1323. return undefined
  1324. }
  1325. var def = prop.default;
  1326. // warn against non-factory defaults for Object & Array
  1327. if (process.env.NODE_ENV !== 'production' && isObject(def)) {
  1328. warn(
  1329. 'Invalid default value for prop "' + key + '": ' +
  1330. 'Props with type Object/Array must use a factory function ' +
  1331. 'to return the default value.',
  1332. vm
  1333. );
  1334. }
  1335. // the raw prop value was also undefined from previous render,
  1336. // return previous default value to avoid unnecessary watcher trigger
  1337. if (vm && vm.$options.propsData &&
  1338. vm.$options.propsData[key] === undefined &&
  1339. vm._props[key] !== undefined
  1340. ) {
  1341. return vm._props[key]
  1342. }
  1343. // call factory function for non-Function types
  1344. // a value is Function if its prototype is function even across different execution context
  1345. return typeof def === 'function' && getType(prop.type) !== 'Function'
  1346. ? def.call(vm)
  1347. : def
  1348. }
  1349. /**
  1350. * Assert whether a prop is valid.
  1351. */
  1352. function assertProp (
  1353. prop,
  1354. name,
  1355. value,
  1356. vm,
  1357. absent
  1358. ) {
  1359. if (prop.required && absent) {
  1360. warn(
  1361. 'Missing required prop: "' + name + '"',
  1362. vm
  1363. );
  1364. return
  1365. }
  1366. if (value == null && !prop.required) {
  1367. return
  1368. }
  1369. var type = prop.type;
  1370. var valid = !type || type === true;
  1371. var expectedTypes = [];
  1372. if (type) {
  1373. if (!Array.isArray(type)) {
  1374. type = [type];
  1375. }
  1376. for (var i = 0; i < type.length && !valid; i++) {
  1377. var assertedType = assertType(value, type[i]);
  1378. expectedTypes.push(assertedType.expectedType || '');
  1379. valid = assertedType.valid;
  1380. }
  1381. }
  1382. if (!valid) {
  1383. warn(
  1384. 'Invalid prop: type check failed for prop "' + name + '".' +
  1385. ' Expected ' + expectedTypes.map(capitalize).join(', ') +
  1386. ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
  1387. vm
  1388. );
  1389. return
  1390. }
  1391. var validator = prop.validator;
  1392. if (validator) {
  1393. if (!validator(value)) {
  1394. warn(
  1395. 'Invalid prop: custom validator check failed for prop "' + name + '".',
  1396. vm
  1397. );
  1398. }
  1399. }
  1400. }
  1401. var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
  1402. function assertType (value, type) {
  1403. var valid;
  1404. var expectedType = getType(type);
  1405. if (simpleCheckRE.test(expectedType)) {
  1406. valid = typeof value === expectedType.toLowerCase();
  1407. } else if (expectedType === 'Object') {
  1408. valid = isPlainObject(value);
  1409. } else if (expectedType === 'Array') {
  1410. valid = Array.isArray(value);
  1411. } else {
  1412. valid = value instanceof type;
  1413. }
  1414. return {
  1415. valid: valid,
  1416. expectedType: expectedType
  1417. }
  1418. }
  1419. /**
  1420. * Use function string name to check built-in types,
  1421. * because a simple equality check will fail when running
  1422. * across different vms / iframes.
  1423. */
  1424. function getType (fn) {
  1425. var match = fn && fn.toString().match(/^\s*function (\w+)/);
  1426. return match ? match[1] : ''
  1427. }
  1428. function isType (type, fn) {
  1429. if (!Array.isArray(fn)) {
  1430. return getType(fn) === getType(type)
  1431. }
  1432. for (var i = 0, len = fn.length; i < len; i++) {
  1433. if (getType(fn[i]) === getType(type)) {
  1434. return true
  1435. }
  1436. }
  1437. /* istanbul ignore next */
  1438. return false
  1439. }
  1440. /* */
  1441. /* not type checking this file because flow doesn't play well with Proxy */
  1442. var initProxy;
  1443. if (process.env.NODE_ENV !== 'production') {
  1444. var allowedGlobals = makeMap(
  1445. 'Infinity,undefined,NaN,isFinite,isNaN,' +
  1446. 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
  1447. 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
  1448. 'require' // for Webpack/Browserify
  1449. );
  1450. var warnNonPresent = function (target, key) {
  1451. warn(
  1452. "Property or method \"" + key + "\" is not defined on the instance but " +
  1453. "referenced during render. Make sure to declare reactive data " +
  1454. "properties in the data option.",
  1455. target
  1456. );
  1457. };
  1458. var hasProxy =
  1459. typeof Proxy !== 'undefined' &&
  1460. Proxy.toString().match(/native code/);
  1461. if (hasProxy) {
  1462. var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta');
  1463. config.keyCodes = new Proxy(config.keyCodes, {
  1464. set: function set (target, key, value) {
  1465. if (isBuiltInModifier(key)) {
  1466. warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
  1467. return false
  1468. } else {
  1469. target[key] = value;
  1470. return true
  1471. }
  1472. }
  1473. });
  1474. }
  1475. var hasHandler = {
  1476. has: function has (target, key) {
  1477. var has = key in target;
  1478. var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
  1479. if (!has && !isAllowed) {
  1480. warnNonPresent(target, key);
  1481. }
  1482. return has || !isAllowed
  1483. }
  1484. };
  1485. var getHandler = {
  1486. get: function get (target, key) {
  1487. if (typeof key === 'string' && !(key in target)) {
  1488. warnNonPresent(target, key);
  1489. }
  1490. return target[key]
  1491. }
  1492. };
  1493. initProxy = function initProxy (vm) {
  1494. if (hasProxy) {
  1495. // determine which proxy handler to use
  1496. var options = vm.$options;
  1497. var handlers = options.render && options.render._withStripped
  1498. ? getHandler
  1499. : hasHandler;
  1500. vm._renderProxy = new Proxy(vm, handlers);
  1501. } else {
  1502. vm._renderProxy = vm;
  1503. }
  1504. };
  1505. }
  1506. var mark;
  1507. var measure;
  1508. if (process.env.NODE_ENV !== 'production') {
  1509. var perf = inBrowser && window.performance;
  1510. /* istanbul ignore if */
  1511. if (
  1512. perf &&
  1513. perf.mark &&
  1514. perf.measure &&
  1515. perf.clearMarks &&
  1516. perf.clearMeasures
  1517. ) {
  1518. mark = function (tag) { return perf.mark(tag); };
  1519. measure = function (name, startTag, endTag) {
  1520. perf.measure(name, startTag, endTag);
  1521. perf.clearMarks(startTag);
  1522. perf.clearMarks(endTag);
  1523. perf.clearMeasures(name);
  1524. };
  1525. }
  1526. }
  1527. /* */
  1528. var VNode = function VNode (
  1529. tag,
  1530. data,
  1531. children,
  1532. text,
  1533. elm,
  1534. context,
  1535. componentOptions,
  1536. asyncFactory
  1537. ) {
  1538. this.tag = tag;
  1539. this.data = data;
  1540. this.children = children;
  1541. this.text = text;
  1542. this.elm = elm;
  1543. this.ns = undefined;
  1544. this.context = context;
  1545. this.functionalContext = undefined;
  1546. this.key = data && data.key;
  1547. this.componentOptions = componentOptions;
  1548. this.componentInstance = undefined;
  1549. this.parent = undefined;
  1550. this.raw = false;
  1551. this.isStatic = false;
  1552. this.isRootInsert = true;
  1553. this.isComment = false;
  1554. this.isCloned = false;
  1555. this.isOnce = false;
  1556. this.asyncFactory = asyncFactory;
  1557. this.asyncMeta = undefined;
  1558. this.isAsyncPlaceholder = false;
  1559. };
  1560. var prototypeAccessors = { child: {} };
  1561. // DEPRECATED: alias for componentInstance for backwards compat.
  1562. /* istanbul ignore next */
  1563. prototypeAccessors.child.get = function () {
  1564. return this.componentInstance
  1565. };
  1566. Object.defineProperties( VNode.prototype, prototypeAccessors );
  1567. var createEmptyVNode = function (text) {
  1568. if ( text === void 0 ) text = '';
  1569. var node = new VNode();
  1570. node.text = text;
  1571. node.isComment = true;
  1572. return node
  1573. };
  1574. function createTextVNode (val) {
  1575. return new VNode(undefined, undefined, undefined, String(val))
  1576. }
  1577. // optimized shallow clone
  1578. // used for static nodes and slot nodes because they may be reused across
  1579. // multiple renders, cloning them avoids errors when DOM manipulations rely
  1580. // on their elm reference.
  1581. function cloneVNode (vnode) {
  1582. var cloned = new VNode(
  1583. vnode.tag,
  1584. vnode.data,
  1585. vnode.children,
  1586. vnode.text,
  1587. vnode.elm,
  1588. vnode.context,
  1589. vnode.componentOptions,
  1590. vnode.asyncFactory
  1591. );
  1592. cloned.ns = vnode.ns;
  1593. cloned.isStatic = vnode.isStatic;
  1594. cloned.key = vnode.key;
  1595. cloned.isComment = vnode.isComment;
  1596. cloned.isCloned = true;
  1597. return cloned
  1598. }
  1599. function cloneVNodes (vnodes) {
  1600. var len = vnodes.length;
  1601. var res = new Array(len);
  1602. for (var i = 0; i < len; i++) {
  1603. res[i] = cloneVNode(vnodes[i]);
  1604. }
  1605. return res
  1606. }
  1607. /* */
  1608. var normalizeEvent = cached(function (name) {
  1609. var passive = name.charAt(0) === '&';
  1610. name = passive ? name.slice(1) : name;
  1611. var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first
  1612. name = once$$1 ? name.slice(1) : name;
  1613. var capture = name.charAt(0) === '!';
  1614. name = capture ? name.slice(1) : name;
  1615. return {
  1616. name: name,
  1617. once: once$$1,
  1618. capture: capture,
  1619. passive: passive
  1620. }
  1621. });
  1622. function createFnInvoker (fns) {
  1623. function invoker () {
  1624. var arguments$1 = arguments;
  1625. var fns = invoker.fns;
  1626. if (Array.isArray(fns)) {
  1627. var cloned = fns.slice();
  1628. for (var i = 0; i < cloned.length; i++) {
  1629. cloned[i].apply(null, arguments$1);
  1630. }
  1631. } else {
  1632. // return handler return value for single handlers
  1633. return fns.apply(null, arguments)
  1634. }
  1635. }
  1636. invoker.fns = fns;
  1637. return invoker
  1638. }
  1639. function updateListeners (
  1640. on,
  1641. oldOn,
  1642. add,
  1643. remove$$1,
  1644. vm
  1645. ) {
  1646. var name, cur, old, event;
  1647. for (name in on) {
  1648. cur = on[name];
  1649. old = oldOn[name];
  1650. event = normalizeEvent(name);
  1651. if (isUndef(cur)) {
  1652. process.env.NODE_ENV !== 'production' && warn(
  1653. "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
  1654. vm
  1655. );
  1656. } else if (isUndef(old)) {
  1657. if (isUndef(cur.fns)) {
  1658. cur = on[name] = createFnInvoker(cur);
  1659. }
  1660. add(event.name, cur, event.once, event.capture, event.passive);
  1661. } else if (cur !== old) {
  1662. old.fns = cur;
  1663. on[name] = old;
  1664. }
  1665. }
  1666. for (name in oldOn) {
  1667. if (isUndef(on[name])) {
  1668. event = normalizeEvent(name);
  1669. remove$$1(event.name, oldOn[name], event.capture);
  1670. }
  1671. }
  1672. }
  1673. /* */
  1674. function mergeVNodeHook (def, hookKey, hook) {
  1675. var invoker;
  1676. var oldHook = def[hookKey];
  1677. function wrappedHook () {
  1678. hook.apply(this, arguments);
  1679. // important: remove merged hook to ensure it's called only once
  1680. // and prevent memory leak
  1681. remove(invoker.fns, wrappedHook);
  1682. }
  1683. if (isUndef(oldHook)) {
  1684. // no existing hook
  1685. invoker = createFnInvoker([wrappedHook]);
  1686. } else {
  1687. /* istanbul ignore if */
  1688. if (isDef(oldHook.fns) && isTrue(oldHook.merged)) {
  1689. // already a merged invoker
  1690. invoker = oldHook;
  1691. invoker.fns.push(wrappedHook);
  1692. } else {
  1693. // existing plain hook
  1694. invoker = createFnInvoker([oldHook, wrappedHook]);
  1695. }
  1696. }
  1697. invoker.merged = true;
  1698. def[hookKey] = invoker;
  1699. }
  1700. /* */
  1701. function extractPropsFromVNodeData (
  1702. data,
  1703. Ctor,
  1704. tag
  1705. ) {
  1706. // we are only extracting raw values here.
  1707. // validation and default values are handled in the child
  1708. // component itself.
  1709. var propOptions = Ctor.options.props;
  1710. if (isUndef(propOptions)) {
  1711. return
  1712. }
  1713. var res = {};
  1714. var attrs = data.attrs;
  1715. var props = data.props;
  1716. if (isDef(attrs) || isDef(props)) {
  1717. for (var key in propOptions) {
  1718. var altKey = hyphenate(key);
  1719. if (process.env.NODE_ENV !== 'production') {
  1720. var keyInLowerCase = key.toLowerCase();
  1721. if (
  1722. key !== keyInLowerCase &&
  1723. attrs && hasOwn(attrs, keyInLowerCase)
  1724. ) {
  1725. tip(
  1726. "Prop \"" + keyInLowerCase + "\" is passed to component " +
  1727. (formatComponentName(tag || Ctor)) + ", but the declared prop name is" +
  1728. " \"" + key + "\". " +
  1729. "Note that HTML attributes are case-insensitive and camelCased " +
  1730. "props need to use their kebab-case equivalents when using in-DOM " +
  1731. "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"."
  1732. );
  1733. }
  1734. }
  1735. checkProp(res, props, key, altKey, true) ||
  1736. checkProp(res, attrs, key, altKey, false);
  1737. }
  1738. }
  1739. return res
  1740. }
  1741. function checkProp (
  1742. res,
  1743. hash,
  1744. key,
  1745. altKey,
  1746. preserve
  1747. ) {
  1748. if (isDef(hash)) {
  1749. if (hasOwn(hash, key)) {
  1750. res[key] = hash[key];
  1751. if (!preserve) {
  1752. delete hash[key];
  1753. }
  1754. return true
  1755. } else if (hasOwn(hash, altKey)) {
  1756. res[key] = hash[altKey];
  1757. if (!preserve) {
  1758. delete hash[altKey];
  1759. }
  1760. return true
  1761. }
  1762. }
  1763. return false
  1764. }
  1765. /* */
  1766. // The template compiler attempts to minimize the need for normalization by
  1767. // statically analyzing the template at compile time.
  1768. //
  1769. // For plain HTML markup, normalization can be completely skipped because the
  1770. // generated render function is guaranteed to return Array<VNode>. There are
  1771. // two cases where extra normalization is needed:
  1772. // 1. When the children contains components - because a functional component
  1773. // may return an Array instead of a single root. In this case, just a simple
  1774. // normalization is needed - if any child is an Array, we flatten the whole
  1775. // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
  1776. // because functional components already normalize their own children.
  1777. function simpleNormalizeChildren (children) {
  1778. for (var i = 0; i < children.length; i++) {
  1779. if (Array.isArray(children[i])) {
  1780. return Array.prototype.concat.apply([], children)
  1781. }
  1782. }
  1783. return children
  1784. }
  1785. // 2. When the children contains constructs that always generated nested Arrays,
  1786. // e.g. <template>, <slot>, v-for, or when the children is provided by user
  1787. // with hand-written render functions / JSX. In such cases a full normalization
  1788. // is needed to cater to all possible types of children values.
  1789. function normalizeChildren (children) {
  1790. return isPrimitive(children)
  1791. ? [createTextVNode(children)]
  1792. : Array.isArray(children)
  1793. ? normalizeArrayChildren(children)
  1794. : undefined
  1795. }
  1796. function isTextNode (node) {
  1797. return isDef(node) && isDef(node.text) && isFalse(node.isComment)
  1798. }
  1799. function normalizeArrayChildren (children, nestedIndex) {
  1800. var res = [];
  1801. var i, c, last;
  1802. for (i = 0; i < children.length; i++) {
  1803. c = children[i];
  1804. if (isUndef(c) || typeof c === 'boolean') { continue }
  1805. last = res[res.length - 1];
  1806. // nested
  1807. if (Array.isArray(c)) {
  1808. res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
  1809. } else if (isPrimitive(c)) {
  1810. if (isTextNode(last)) {
  1811. // merge adjacent text nodes
  1812. // this is necessary for SSR hydration because text nodes are
  1813. // essentially merged when rendered to HTML strings
  1814. (last).text += String(c);
  1815. } else if (c !== '') {
  1816. // convert primitive to vnode
  1817. res.push(createTextVNode(c));
  1818. }
  1819. } else {
  1820. if (isTextNode(c) && isTextNode(last)) {
  1821. // merge adjacent text nodes
  1822. res[res.length - 1] = createTextVNode(last.text + c.text);
  1823. } else {
  1824. // default key for nested array children (likely generated by v-for)
  1825. if (isTrue(children._isVList) &&
  1826. isDef(c.tag) &&
  1827. isUndef(c.key) &&
  1828. isDef(nestedIndex)) {
  1829. c.key = "__vlist" + nestedIndex + "_" + i + "__";
  1830. }
  1831. res.push(c);
  1832. }
  1833. }
  1834. }
  1835. return res
  1836. }
  1837. /* */
  1838. function ensureCtor (comp, base) {
  1839. if (comp.__esModule && comp.default) {
  1840. comp = comp.default;
  1841. }
  1842. return isObject(comp)
  1843. ? base.extend(comp)
  1844. : comp
  1845. }
  1846. function createAsyncPlaceholder (
  1847. factory,
  1848. data,
  1849. context,
  1850. children,
  1851. tag
  1852. ) {
  1853. var node = createEmptyVNode();
  1854. node.asyncFactory = factory;
  1855. node.asyncMeta = { data: data, context: context, children: children, tag: tag };
  1856. return node
  1857. }
  1858. function resolveAsyncComponent (
  1859. factory,
  1860. baseCtor,
  1861. context
  1862. ) {
  1863. if (isTrue(factory.error) && isDef(factory.errorComp)) {
  1864. return factory.errorComp
  1865. }
  1866. if (isDef(factory.resolved)) {
  1867. return factory.resolved
  1868. }
  1869. if (isTrue(factory.loading) && isDef(factory.loadingComp)) {
  1870. return factory.loadingComp
  1871. }
  1872. if (isDef(factory.contexts)) {
  1873. // already pending
  1874. factory.contexts.push(context);
  1875. } else {
  1876. var contexts = factory.contexts = [context];
  1877. var sync = true;
  1878. var forceRender = function () {
  1879. for (var i = 0, l = contexts.length; i < l; i++) {
  1880. contexts[i].$forceUpdate();
  1881. }
  1882. };
  1883. var resolve = once(function (res) {
  1884. // cache resolved
  1885. factory.resolved = ensureCtor(res, baseCtor);
  1886. // invoke callbacks only if this is not a synchronous resolve
  1887. // (async resolves are shimmed as synchronous during SSR)
  1888. if (!sync) {
  1889. forceRender();
  1890. }
  1891. });
  1892. var reject = once(function (reason) {
  1893. process.env.NODE_ENV !== 'production' && warn(
  1894. "Failed to resolve async component: " + (String(factory)) +
  1895. (reason ? ("\nReason: " + reason) : '')
  1896. );
  1897. if (isDef(factory.errorComp)) {
  1898. factory.error = true;
  1899. forceRender();
  1900. }
  1901. });
  1902. var res = factory(resolve, reject);
  1903. if (isObject(res)) {
  1904. if (typeof res.then === 'function') {
  1905. // () => Promise
  1906. if (isUndef(factory.resolved)) {
  1907. res.then(resolve, reject);
  1908. }
  1909. } else if (isDef(res.component) && typeof res.component.then === 'function') {
  1910. res.component.then(resolve, reject);
  1911. if (isDef(res.error)) {
  1912. factory.errorComp = ensureCtor(res.error, baseCtor);
  1913. }
  1914. if (isDef(res.loading)) {
  1915. factory.loadingComp = ensureCtor(res.loading, baseCtor);
  1916. if (res.delay === 0) {
  1917. factory.loading = true;
  1918. } else {
  1919. setTimeout(function () {
  1920. if (isUndef(factory.resolved) && isUndef(factory.error)) {
  1921. factory.loading = true;
  1922. forceRender();
  1923. }
  1924. }, res.delay || 200);
  1925. }
  1926. }
  1927. if (isDef(res.timeout)) {
  1928. setTimeout(function () {
  1929. if (isUndef(factory.resolved)) {
  1930. reject(
  1931. process.env.NODE_ENV !== 'production'
  1932. ? ("timeout (" + (res.timeout) + "ms)")
  1933. : null
  1934. );
  1935. }
  1936. }, res.timeout);
  1937. }
  1938. }
  1939. }
  1940. sync = false;
  1941. // return in case resolved synchronously
  1942. return factory.loading
  1943. ? factory.loadingComp
  1944. : factory.resolved
  1945. }
  1946. }
  1947. /* */
  1948. function getFirstComponentChild (children) {
  1949. if (Array.isArray(children)) {
  1950. for (var i = 0; i < children.length; i++) {
  1951. var c = children[i];
  1952. if (isDef(c) && isDef(c.componentOptions)) {
  1953. return c
  1954. }
  1955. }
  1956. }
  1957. }
  1958. /* */
  1959. /* */
  1960. function initEvents (vm) {
  1961. vm._events = Object.create(null);
  1962. vm._hasHookEvent = false;
  1963. // init parent attached events
  1964. var listeners = vm.$options._parentListeners;
  1965. if (listeners) {
  1966. updateComponentListeners(vm, listeners);
  1967. }
  1968. }
  1969. var target;
  1970. function add (event, fn, once$$1) {
  1971. if (once$$1) {
  1972. target.$once(event, fn);
  1973. } else {
  1974. target.$on(event, fn);
  1975. }
  1976. }
  1977. function remove$1 (event, fn) {
  1978. target.$off(event, fn);
  1979. }
  1980. function updateComponentListeners (
  1981. vm,
  1982. listeners,
  1983. oldListeners
  1984. ) {
  1985. target = vm;
  1986. updateListeners(listeners, oldListeners || {}, add, remove$1, vm);
  1987. }
  1988. function eventsMixin (Vue) {
  1989. var hookRE = /^hook:/;
  1990. Vue.prototype.$on = function (event, fn) {
  1991. var this$1 = this;
  1992. var vm = this;
  1993. if (Array.isArray(event)) {
  1994. for (var i = 0, l = event.length; i < l; i++) {
  1995. this$1.$on(event[i], fn);
  1996. }
  1997. } else {
  1998. (vm._events[event] || (vm._events[event] = [])).push(fn);
  1999. // optimize hook:event cost by using a boolean flag marked at registration
  2000. // instead of a hash lookup
  2001. if (hookRE.test(event)) {
  2002. vm._hasHookEvent = true;
  2003. }
  2004. }
  2005. return vm
  2006. };
  2007. Vue.prototype.$once = function (event, fn) {
  2008. var vm = this;
  2009. function on () {
  2010. vm.$off(event, on);
  2011. fn.apply(vm, arguments);
  2012. }
  2013. on.fn = fn;
  2014. vm.$on(event, on);
  2015. return vm
  2016. };
  2017. Vue.prototype.$off = function (event, fn) {
  2018. var this$1 = this;
  2019. var vm = this;
  2020. // all
  2021. if (!arguments.length) {
  2022. vm._events = Object.create(null);
  2023. return vm
  2024. }
  2025. // array of events
  2026. if (Array.isArray(event)) {
  2027. for (var i$1 = 0, l = event.length; i$1 < l; i$1++) {
  2028. this$1.$off(event[i$1], fn);
  2029. }
  2030. return vm
  2031. }
  2032. // specific event
  2033. var cbs = vm._events[event];
  2034. if (!cbs) {
  2035. return vm
  2036. }
  2037. if (arguments.length === 1) {
  2038. vm._events[event] = null;
  2039. return vm
  2040. }
  2041. // specific handler
  2042. var cb;
  2043. var i = cbs.length;
  2044. while (i--) {
  2045. cb = cbs[i];
  2046. if (cb === fn || cb.fn === fn) {
  2047. cbs.splice(i, 1);
  2048. break
  2049. }
  2050. }
  2051. return vm
  2052. };
  2053. Vue.prototype.$emit = function (event) {
  2054. var vm = this;
  2055. if (process.env.NODE_ENV !== 'production') {
  2056. var lowerCaseEvent = event.toLowerCase();
  2057. if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) {
  2058. tip(
  2059. "Event \"" + lowerCaseEvent + "\" is emitted in component " +
  2060. (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " +
  2061. "Note that HTML attributes are case-insensitive and you cannot use " +
  2062. "v-on to listen to camelCase events when using in-DOM templates. " +
  2063. "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"."
  2064. );
  2065. }
  2066. }
  2067. var cbs = vm._events[event];
  2068. if (cbs) {
  2069. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  2070. var args = toArray(arguments, 1);
  2071. for (var i = 0, l = cbs.length; i < l; i++) {
  2072. try {
  2073. cbs[i].apply(vm, args);
  2074. } catch (e) {
  2075. handleError(e, vm, ("event handler for \"" + event + "\""));
  2076. }
  2077. }
  2078. }
  2079. return vm
  2080. };
  2081. }
  2082. /* */
  2083. /**
  2084. * Runtime helper for resolving raw children VNodes into a slot object.
  2085. */
  2086. function resolveSlots (
  2087. children,
  2088. context
  2089. ) {
  2090. var slots = {};
  2091. if (!children) {
  2092. return slots
  2093. }
  2094. var defaultSlot = [];
  2095. for (var i = 0, l = children.length; i < l; i++) {
  2096. var child = children[i];
  2097. // named slots should only be respected if the vnode was rendered in the
  2098. // same context.
  2099. if ((child.context === context || child.functionalContext === context) &&
  2100. child.data && child.data.slot != null
  2101. ) {
  2102. var name = child.data.slot;
  2103. var slot = (slots[name] || (slots[name] = []));
  2104. if (child.tag === 'template') {
  2105. slot.push.apply(slot, child.children);
  2106. } else {
  2107. slot.push(child);
  2108. }
  2109. } else {
  2110. defaultSlot.push(child);
  2111. }
  2112. }
  2113. // ignore whitespace
  2114. if (!defaultSlot.every(isWhitespace)) {
  2115. slots.default = defaultSlot;
  2116. }
  2117. return slots
  2118. }
  2119. function isWhitespace (node) {
  2120. return node.isComment || node.text === ' '
  2121. }
  2122. function resolveScopedSlots (
  2123. fns, // see flow/vnode
  2124. res
  2125. ) {
  2126. res = res || {};
  2127. for (var i = 0; i < fns.length; i++) {
  2128. if (Array.isArray(fns[i])) {
  2129. resolveScopedSlots(fns[i], res);
  2130. } else {
  2131. res[fns[i].key] = fns[i].fn;
  2132. }
  2133. }
  2134. return res
  2135. }
  2136. /* */
  2137. var activeInstance = null;
  2138. var isUpdatingChildComponent = false;
  2139. function initLifecycle (vm) {
  2140. var options = vm.$options;
  2141. // locate first non-abstract parent
  2142. var parent = options.parent;
  2143. if (parent && !options.abstract) {
  2144. while (parent.$options.abstract && parent.$parent) {
  2145. parent = parent.$parent;
  2146. }
  2147. parent.$children.push(vm);
  2148. }
  2149. vm.$parent = parent;
  2150. vm.$root = parent ? parent.$root : vm;
  2151. vm.$children = [];
  2152. vm.$refs = {};
  2153. vm._watcher = null;
  2154. vm._inactive = null;
  2155. vm._directInactive = false;
  2156. vm._isMounted = false;
  2157. vm._isDestroyed = false;
  2158. vm._isBeingDestroyed = false;
  2159. }
  2160. function lifecycleMixin (Vue) {
  2161. Vue.prototype._update = function (vnode, hydrating) {
  2162. var vm = this;
  2163. if (vm._isMounted) {
  2164. callHook(vm, 'beforeUpdate');
  2165. }
  2166. var prevEl = vm.$el;
  2167. var prevVnode = vm._vnode;
  2168. var prevActiveInstance = activeInstance;
  2169. activeInstance = vm;
  2170. vm._vnode = vnode;
  2171. // Vue.prototype.__patch__ is injected in entry points
  2172. // based on the rendering backend used.
  2173. if (!prevVnode) {
  2174. // initial render
  2175. vm.$el = vm.__patch__(
  2176. vm.$el, vnode, hydrating, false /* removeOnly */,
  2177. vm.$options._parentElm,
  2178. vm.$options._refElm
  2179. );
  2180. // no need for the ref nodes after initial patch
  2181. // this prevents keeping a detached DOM tree in memory (#5851)
  2182. vm.$options._parentElm = vm.$options._refElm = null;
  2183. } else {
  2184. // updates
  2185. vm.$el = vm.__patch__(prevVnode, vnode);
  2186. }
  2187. activeInstance = prevActiveInstance;
  2188. // update __vue__ reference
  2189. if (prevEl) {
  2190. prevEl.__vue__ = null;
  2191. }
  2192. if (vm.$el) {
  2193. vm.$el.__vue__ = vm;
  2194. }
  2195. // if parent is an HOC, update its $el as well
  2196. if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
  2197. vm.$parent.$el = vm.$el;
  2198. }
  2199. // updated hook is called by the scheduler to ensure that children are
  2200. // updated in a parent's updated hook.
  2201. };
  2202. Vue.prototype.$forceUpdate = function () {
  2203. var vm = this;
  2204. if (vm._watcher) {
  2205. vm._watcher.update();
  2206. }
  2207. };
  2208. Vue.prototype.$destroy = function () {
  2209. var vm = this;
  2210. if (vm._isBeingDestroyed) {
  2211. return
  2212. }
  2213. callHook(vm, 'beforeDestroy');
  2214. vm._isBeingDestroyed = true;
  2215. // remove self from parent
  2216. var parent = vm.$parent;
  2217. if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
  2218. remove(parent.$children, vm);
  2219. }
  2220. // teardown watchers
  2221. if (vm._watcher) {
  2222. vm._watcher.teardown();
  2223. }
  2224. var i = vm._watchers.length;
  2225. while (i--) {
  2226. vm._watchers[i].teardown();
  2227. }
  2228. // remove reference from data ob
  2229. // frozen object may not have observer.
  2230. if (vm._data.__ob__) {
  2231. vm._data.__ob__.vmCount--;
  2232. }
  2233. // call the last hook...
  2234. vm._isDestroyed = true;
  2235. // invoke destroy hooks on current rendered tree
  2236. vm.__patch__(vm._vnode, null);
  2237. // fire destroyed hook
  2238. callHook(vm, 'destroyed');
  2239. // turn off all instance listeners.
  2240. vm.$off();
  2241. // remove __vue__ reference
  2242. if (vm.$el) {
  2243. vm.$el.__vue__ = null;
  2244. }
  2245. };
  2246. }
  2247. function mountComponent (
  2248. vm,
  2249. el,
  2250. hydrating
  2251. ) {
  2252. vm.$el = el;
  2253. if (!vm.$options.render) {
  2254. vm.$options.render = createEmptyVNode;
  2255. if (process.env.NODE_ENV !== 'production') {
  2256. /* istanbul ignore if */
  2257. if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') ||
  2258. vm.$options.el || el) {
  2259. warn(
  2260. 'You are using the runtime-only build of Vue where the template ' +
  2261. 'compiler is not available. Either pre-compile the templates into ' +
  2262. 'render functions, or use the compiler-included build.',
  2263. vm
  2264. );
  2265. } else {
  2266. warn(
  2267. 'Failed to mount component: template or render function not defined.',
  2268. vm
  2269. );
  2270. }
  2271. }
  2272. }
  2273. callHook(vm, 'beforeMount');
  2274. var updateComponent;
  2275. /* istanbul ignore if */
  2276. if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
  2277. updateComponent = function () {
  2278. var name = vm._name;
  2279. var id = vm._uid;
  2280. var startTag = "vue-perf-start:" + id;
  2281. var endTag = "vue-perf-end:" + id;
  2282. mark(startTag);
  2283. var vnode = vm._render();
  2284. mark(endTag);
  2285. measure((name + " render"), startTag, endTag);
  2286. mark(startTag);
  2287. vm._update(vnode, hydrating);
  2288. mark(endTag);
  2289. measure((name + " patch"), startTag, endTag);
  2290. };
  2291. } else {
  2292. updateComponent = function () {
  2293. vm._update(vm._render(), hydrating);
  2294. };
  2295. }
  2296. vm._watcher = new Watcher(vm, updateComponent, noop);
  2297. hydrating = false;
  2298. // manually mounted instance, call mounted on self
  2299. // mounted is called for render-created child components in its inserted hook
  2300. if (vm.$vnode == null) {
  2301. vm._isMounted = true;
  2302. callHook(vm, 'mounted');
  2303. }
  2304. return vm
  2305. }
  2306. function updateChildComponent (
  2307. vm,
  2308. propsData,
  2309. listeners,
  2310. parentVnode,
  2311. renderChildren
  2312. ) {
  2313. if (process.env.NODE_ENV !== 'production') {
  2314. isUpdatingChildComponent = true;
  2315. }
  2316. // determine whether component has slot children
  2317. // we need to do this before overwriting $options._renderChildren
  2318. var hasChildren = !!(
  2319. renderChildren || // has new static slots
  2320. vm.$options._renderChildren || // has old static slots
  2321. parentVnode.data.scopedSlots || // has new scoped slots
  2322. vm.$scopedSlots !== emptyObject // has old scoped slots
  2323. );
  2324. vm.$options._parentVnode = parentVnode;
  2325. vm.$vnode = parentVnode; // update vm's placeholder node without re-render
  2326. if (vm._vnode) { // update child tree's parent
  2327. vm._vnode.parent = parentVnode;
  2328. }
  2329. vm.$options._renderChildren = renderChildren;
  2330. // update $attrs and $listensers hash
  2331. // these are also reactive so they may trigger child update if the child
  2332. // used them during render
  2333. vm.$attrs = parentVnode.data && parentVnode.data.attrs;
  2334. vm.$listeners = listeners;
  2335. // update props
  2336. if (propsData && vm.$options.props) {
  2337. observerState.shouldConvert = false;
  2338. var props = vm._props;
  2339. var propKeys = vm.$options._propKeys || [];
  2340. for (var i = 0; i < propKeys.length; i++) {
  2341. var key = propKeys[i];
  2342. props[key] = validateProp(key, vm.$options.props, propsData, vm);
  2343. }
  2344. observerState.shouldConvert = true;
  2345. // keep a copy of raw propsData
  2346. vm.$options.propsData = propsData;
  2347. }
  2348. // update listeners
  2349. if (listeners) {
  2350. var oldListeners = vm.$options._parentListeners;
  2351. vm.$options._parentListeners = listeners;
  2352. updateComponentListeners(vm, listeners, oldListeners);
  2353. }
  2354. // resolve slots + force update if has children
  2355. if (hasChildren) {
  2356. vm.$slots = resolveSlots(renderChildren, parentVnode.context);
  2357. vm.$forceUpdate();
  2358. }
  2359. if (process.env.NODE_ENV !== 'production') {
  2360. isUpdatingChildComponent = false;
  2361. }
  2362. }
  2363. function isInInactiveTree (vm) {
  2364. while (vm && (vm = vm.$parent)) {
  2365. if (vm._inactive) { return true }
  2366. }
  2367. return false
  2368. }
  2369. function activateChildComponent (vm, direct) {
  2370. if (direct) {
  2371. vm._directInactive = false;
  2372. if (isInInactiveTree(vm)) {
  2373. return
  2374. }
  2375. } else if (vm._directInactive) {
  2376. return
  2377. }
  2378. if (vm._inactive || vm._inactive === null) {
  2379. vm._inactive = false;
  2380. for (var i = 0; i < vm.$children.length; i++) {
  2381. activateChildComponent(vm.$children[i]);
  2382. }
  2383. callHook(vm, 'activated');
  2384. }
  2385. }
  2386. function deactivateChildComponent (vm, direct) {
  2387. if (direct) {
  2388. vm._directInactive = true;
  2389. if (isInInactiveTree(vm)) {
  2390. return
  2391. }
  2392. }
  2393. if (!vm._inactive) {
  2394. vm._inactive = true;
  2395. for (var i = 0; i < vm.$children.length; i++) {
  2396. deactivateChildComponent(vm.$children[i]);
  2397. }
  2398. callHook(vm, 'deactivated');
  2399. }
  2400. }
  2401. function callHook (vm, hook) {
  2402. var handlers = vm.$options[hook];
  2403. if (handlers) {
  2404. for (var i = 0, j = handlers.length; i < j; i++) {
  2405. try {
  2406. handlers[i].call(vm);
  2407. } catch (e) {
  2408. handleError(e, vm, (hook + " hook"));
  2409. }
  2410. }
  2411. }
  2412. if (vm._hasHookEvent) {
  2413. vm.$emit('hook:' + hook);
  2414. }
  2415. }
  2416. /* */
  2417. var MAX_UPDATE_COUNT = 100;
  2418. var queue = [];
  2419. var activatedChildren = [];
  2420. var has = {};
  2421. var circular = {};
  2422. var waiting = false;
  2423. var flushing = false;
  2424. var index = 0;
  2425. /**
  2426. * Reset the scheduler's state.
  2427. */
  2428. function resetSchedulerState () {
  2429. index = queue.length = activatedChildren.length = 0;
  2430. has = {};
  2431. if (process.env.NODE_ENV !== 'production') {
  2432. circular = {};
  2433. }
  2434. waiting = flushing = false;
  2435. }
  2436. /**
  2437. * Flush both queues and run the watchers.
  2438. */
  2439. function flushSchedulerQueue () {
  2440. flushing = true;
  2441. var watcher, id;
  2442. // Sort queue before flush.
  2443. // This ensures that:
  2444. // 1. Components are updated from parent to child. (because parent is always
  2445. // created before the child)
  2446. // 2. A component's user watchers are run before its render watcher (because
  2447. // user watchers are created before the render watcher)
  2448. // 3. If a component is destroyed during a parent component's watcher run,
  2449. // its watchers can be skipped.
  2450. queue.sort(function (a, b) { return a.id - b.id; });
  2451. // do not cache length because more watchers might be pushed
  2452. // as we run existing watchers
  2453. for (index = 0; index < queue.length; index++) {
  2454. watcher = queue[index];
  2455. id = watcher.id;
  2456. has[id] = null;
  2457. watcher.run();
  2458. // in dev build, check and stop circular updates.
  2459. if (process.env.NODE_ENV !== 'production' && has[id] != null) {
  2460. circular[id] = (circular[id] || 0) + 1;
  2461. if (circular[id] > MAX_UPDATE_COUNT) {
  2462. warn(
  2463. 'You may have an infinite update loop ' + (
  2464. watcher.user
  2465. ? ("in watcher with expression \"" + (watcher.expression) + "\"")
  2466. : "in a component render function."
  2467. ),
  2468. watcher.vm
  2469. );
  2470. break
  2471. }
  2472. }
  2473. }
  2474. // keep copies of post queues before resetting state
  2475. var activatedQueue = activatedChildren.slice();
  2476. var updatedQueue = queue.slice();
  2477. resetSchedulerState();
  2478. // call component updated and activated hooks
  2479. callActivatedHooks(activatedQueue);
  2480. callUpdatedHooks(updatedQueue);
  2481. // devtool hook
  2482. /* istanbul ignore if */
  2483. if (devtools && config.devtools) {
  2484. devtools.emit('flush');
  2485. }
  2486. }
  2487. function callUpdatedHooks (queue) {
  2488. var i = queue.length;
  2489. while (i--) {
  2490. var watcher = queue[i];
  2491. var vm = watcher.vm;
  2492. if (vm._watcher === watcher && vm._isMounted) {
  2493. callHook(vm, 'updated');
  2494. }
  2495. }
  2496. }
  2497. /**
  2498. * Queue a kept-alive component that was activated during patch.
  2499. * The queue will be processed after the entire tree has been patched.
  2500. */
  2501. function queueActivatedComponent (vm) {
  2502. // setting _inactive to false here so that a render function can
  2503. // rely on checking whether it's in an inactive tree (e.g. router-view)
  2504. vm._inactive = false;
  2505. activatedChildren.push(vm);
  2506. }
  2507. function callActivatedHooks (queue) {
  2508. for (var i = 0; i < queue.length; i++) {
  2509. queue[i]._inactive = true;
  2510. activateChildComponent(queue[i], true /* true */);
  2511. }
  2512. }
  2513. /**
  2514. * Push a watcher into the watcher queue.
  2515. * Jobs with duplicate IDs will be skipped unless it's
  2516. * pushed when the queue is being flushed.
  2517. */
  2518. function queueWatcher (watcher) {
  2519. var id = watcher.id;
  2520. if (has[id] == null) {
  2521. has[id] = true;
  2522. if (!flushing) {
  2523. queue.push(watcher);
  2524. } else {
  2525. // if already flushing, splice the watcher based on its id
  2526. // if already past its id, it will be run next immediately.
  2527. var i = queue.length - 1;
  2528. while (i > index && queue[i].id > watcher.id) {
  2529. i--;
  2530. }
  2531. queue.splice(i + 1, 0, watcher);
  2532. }
  2533. // queue the flush
  2534. if (!waiting) {
  2535. waiting = true;
  2536. nextTick(flushSchedulerQueue);
  2537. }
  2538. }
  2539. }
  2540. /* */
  2541. var uid$2 = 0;
  2542. /**
  2543. * A watcher parses an expression, collects dependencies,
  2544. * and fires callback when the expression value changes.
  2545. * This is used for both the $watch() api and directives.
  2546. */
  2547. var Watcher = function Watcher (
  2548. vm,
  2549. expOrFn,
  2550. cb,
  2551. options
  2552. ) {
  2553. this.vm = vm;
  2554. vm._watchers.push(this);
  2555. // options
  2556. if (options) {
  2557. this.deep = !!options.deep;
  2558. this.user = !!options.user;
  2559. this.lazy = !!options.lazy;
  2560. this.sync = !!options.sync;
  2561. } else {
  2562. this.deep = this.user = this.lazy = this.sync = false;
  2563. }
  2564. this.cb = cb;
  2565. this.id = ++uid$2; // uid for batching
  2566. this.active = true;
  2567. this.dirty = this.lazy; // for lazy watchers
  2568. this.deps = [];
  2569. this.newDeps = [];
  2570. this.depIds = new _Set();
  2571. this.newDepIds = new _Set();
  2572. this.expression = process.env.NODE_ENV !== 'production'
  2573. ? expOrFn.toString()
  2574. : '';
  2575. // parse expression for getter
  2576. if (typeof expOrFn === 'function') {
  2577. this.getter = expOrFn;
  2578. } else {
  2579. this.getter = parsePath(expOrFn);
  2580. if (!this.getter) {
  2581. this.getter = function () {};
  2582. process.env.NODE_ENV !== 'production' && warn(
  2583. "Failed watching path: \"" + expOrFn + "\" " +
  2584. 'Watcher only accepts simple dot-delimited paths. ' +
  2585. 'For full control, use a function instead.',
  2586. vm
  2587. );
  2588. }
  2589. }
  2590. this.value = this.lazy
  2591. ? undefined
  2592. : this.get();
  2593. };
  2594. /**
  2595. * Evaluate the getter, and re-collect dependencies.
  2596. */
  2597. Watcher.prototype.get = function get () {
  2598. pushTarget(this);
  2599. var value;
  2600. var vm = this.vm;
  2601. try {
  2602. value = this.getter.call(vm, vm);
  2603. } catch (e) {
  2604. if (this.user) {
  2605. handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\""));
  2606. } else {
  2607. throw e
  2608. }
  2609. } finally {
  2610. // "touch" every property so they are all tracked as
  2611. // dependencies for deep watching
  2612. if (this.deep) {
  2613. traverse(value);
  2614. }
  2615. popTarget();
  2616. this.cleanupDeps();
  2617. }
  2618. return value
  2619. };
  2620. /**
  2621. * Add a dependency to this directive.
  2622. */
  2623. Watcher.prototype.addDep = function addDep (dep) {
  2624. var id = dep.id;
  2625. if (!this.newDepIds.has(id)) {
  2626. this.newDepIds.add(id);
  2627. this.newDeps.push(dep);
  2628. if (!this.depIds.has(id)) {
  2629. dep.addSub(this);
  2630. }
  2631. }
  2632. };
  2633. /**
  2634. * Clean up for dependency collection.
  2635. */
  2636. Watcher.prototype.cleanupDeps = function cleanupDeps () {
  2637. var this$1 = this;
  2638. var i = this.deps.length;
  2639. while (i--) {
  2640. var dep = this$1.deps[i];
  2641. if (!this$1.newDepIds.has(dep.id)) {
  2642. dep.removeSub(this$1);
  2643. }
  2644. }
  2645. var tmp = this.depIds;
  2646. this.depIds = this.newDepIds;
  2647. this.newDepIds = tmp;
  2648. this.newDepIds.clear();
  2649. tmp = this.deps;
  2650. this.deps = this.newDeps;
  2651. this.newDeps = tmp;
  2652. this.newDeps.length = 0;
  2653. };
  2654. /**
  2655. * Subscriber interface.
  2656. * Will be called when a dependency changes.
  2657. */
  2658. Watcher.prototype.update = function update () {
  2659. /* istanbul ignore else */
  2660. if (this.lazy) {
  2661. this.dirty = true;
  2662. } else if (this.sync) {
  2663. this.run();
  2664. } else {
  2665. queueWatcher(this);
  2666. }
  2667. };
  2668. /**
  2669. * Scheduler job interface.
  2670. * Will be called by the scheduler.
  2671. */
  2672. Watcher.prototype.run = function run () {
  2673. if (this.active) {
  2674. var value = this.get();
  2675. if (
  2676. value !== this.value ||
  2677. // Deep watchers and watchers on Object/Arrays should fire even
  2678. // when the value is the same, because the value may
  2679. // have mutated.
  2680. isObject(value) ||
  2681. this.deep
  2682. ) {
  2683. // set new value
  2684. var oldValue = this.value;
  2685. this.value = value;
  2686. if (this.user) {
  2687. try {
  2688. this.cb.call(this.vm, value, oldValue);
  2689. } catch (e) {
  2690. handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\""));
  2691. }
  2692. } else {
  2693. this.cb.call(this.vm, value, oldValue);
  2694. }
  2695. }
  2696. }
  2697. };
  2698. /**
  2699. * Evaluate the value of the watcher.
  2700. * This only gets called for lazy watchers.
  2701. */
  2702. Watcher.prototype.evaluate = function evaluate () {
  2703. this.value = this.get();
  2704. this.dirty = false;
  2705. };
  2706. /**
  2707. * Depend on all deps collected by this watcher.
  2708. */
  2709. Watcher.prototype.depend = function depend () {
  2710. var this$1 = this;
  2711. var i = this.deps.length;
  2712. while (i--) {
  2713. this$1.deps[i].depend();
  2714. }
  2715. };
  2716. /**
  2717. * Remove self from all dependencies' subscriber list.
  2718. */
  2719. Watcher.prototype.teardown = function teardown () {
  2720. var this$1 = this;
  2721. if (this.active) {
  2722. // remove self from vm's watcher list
  2723. // this is a somewhat expensive operation so we skip it
  2724. // if the vm is being destroyed.
  2725. if (!this.vm._isBeingDestroyed) {
  2726. remove(this.vm._watchers, this);
  2727. }
  2728. var i = this.deps.length;
  2729. while (i--) {
  2730. this$1.deps[i].removeSub(this$1);
  2731. }
  2732. this.active = false;
  2733. }
  2734. };
  2735. /**
  2736. * Recursively traverse an object to evoke all converted
  2737. * getters, so that every nested property inside the object
  2738. * is collected as a "deep" dependency.
  2739. */
  2740. var seenObjects = new _Set();
  2741. function traverse (val) {
  2742. seenObjects.clear();
  2743. _traverse(val, seenObjects);
  2744. }
  2745. function _traverse (val, seen) {
  2746. var i, keys;
  2747. var isA = Array.isArray(val);
  2748. if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
  2749. return
  2750. }
  2751. if (val.__ob__) {
  2752. var depId = val.__ob__.dep.id;
  2753. if (seen.has(depId)) {
  2754. return
  2755. }
  2756. seen.add(depId);
  2757. }
  2758. if (isA) {
  2759. i = val.length;
  2760. while (i--) { _traverse(val[i], seen); }
  2761. } else {
  2762. keys = Object.keys(val);
  2763. i = keys.length;
  2764. while (i--) { _traverse(val[keys[i]], seen); }
  2765. }
  2766. }
  2767. /* */
  2768. var sharedPropertyDefinition = {
  2769. enumerable: true,
  2770. configurable: true,
  2771. get: noop,
  2772. set: noop
  2773. };
  2774. function proxy (target, sourceKey, key) {
  2775. sharedPropertyDefinition.get = function proxyGetter () {
  2776. return this[sourceKey][key]
  2777. };
  2778. sharedPropertyDefinition.set = function proxySetter (val) {
  2779. this[sourceKey][key] = val;
  2780. };
  2781. Object.defineProperty(target, key, sharedPropertyDefinition);
  2782. }
  2783. function initState (vm) {
  2784. vm._watchers = [];
  2785. var opts = vm.$options;
  2786. if (opts.props) { initProps(vm, opts.props); }
  2787. if (opts.methods) { initMethods(vm, opts.methods); }
  2788. if (opts.data) {
  2789. initData(vm);
  2790. } else {
  2791. observe(vm._data = {}, true /* asRootData */);
  2792. }
  2793. if (opts.computed) { initComputed(vm, opts.computed); }
  2794. if (opts.watch && opts.watch !== nativeWatch) {
  2795. initWatch(vm, opts.watch);
  2796. }
  2797. }
  2798. function checkOptionType (vm, name) {
  2799. var option = vm.$options[name];
  2800. if (!isPlainObject(option)) {
  2801. warn(
  2802. ("component option \"" + name + "\" should be an object."),
  2803. vm
  2804. );
  2805. }
  2806. }
  2807. function initProps (vm, propsOptions) {
  2808. var propsData = vm.$options.propsData || {};
  2809. var props = vm._props = {};
  2810. // cache prop keys so that future props updates can iterate using Array
  2811. // instead of dynamic object key enumeration.
  2812. var keys = vm.$options._propKeys = [];
  2813. var isRoot = !vm.$parent;
  2814. // root instance props should be converted
  2815. observerState.shouldConvert = isRoot;
  2816. var loop = function ( key ) {
  2817. keys.push(key);
  2818. var value = validateProp(key, propsOptions, propsData, vm);
  2819. /* istanbul ignore else */
  2820. if (process.env.NODE_ENV !== 'production') {
  2821. if (isReservedAttribute(key) || config.isReservedAttr(key)) {
  2822. warn(
  2823. ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
  2824. vm
  2825. );
  2826. }
  2827. defineReactive$$1(props, key, value, function () {
  2828. if (vm.$parent && !isUpdatingChildComponent) {
  2829. warn(
  2830. "Avoid mutating a prop directly since the value will be " +
  2831. "overwritten whenever the parent component re-renders. " +
  2832. "Instead, use a data or computed property based on the prop's " +
  2833. "value. Prop being mutated: \"" + key + "\"",
  2834. vm
  2835. );
  2836. }
  2837. });
  2838. } else {
  2839. defineReactive$$1(props, key, value);
  2840. }
  2841. // static props are already proxied on the component's prototype
  2842. // during Vue.extend(). We only need to proxy props defined at
  2843. // instantiation here.
  2844. if (!(key in vm)) {
  2845. proxy(vm, "_props", key);
  2846. }
  2847. };
  2848. for (var key in propsOptions) loop( key );
  2849. observerState.shouldConvert = true;
  2850. }
  2851. function initData (vm) {
  2852. var data = vm.$options.data;
  2853. data = vm._data = typeof data === 'function'
  2854. ? getData(data, vm)
  2855. : data || {};
  2856. if (!isPlainObject(data)) {
  2857. data = {};
  2858. process.env.NODE_ENV !== 'production' && warn(
  2859. 'data functions should return an object:\n' +
  2860. 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
  2861. vm
  2862. );
  2863. }
  2864. // proxy data on instance
  2865. var keys = Object.keys(data);
  2866. var props = vm.$options.props;
  2867. var methods = vm.$options.methods;
  2868. var i = keys.length;
  2869. while (i--) {
  2870. var key = keys[i];
  2871. if (process.env.NODE_ENV !== 'production') {
  2872. if (methods && hasOwn(methods, key)) {
  2873. warn(
  2874. ("method \"" + key + "\" has already been defined as a data property."),
  2875. vm
  2876. );
  2877. }
  2878. }
  2879. if (props && hasOwn(props, key)) {
  2880. process.env.NODE_ENV !== 'production' && warn(
  2881. "The data property \"" + key + "\" is already declared as a prop. " +
  2882. "Use prop default value instead.",
  2883. vm
  2884. );
  2885. } else if (!isReserved(key)) {
  2886. proxy(vm, "_data", key);
  2887. }
  2888. }
  2889. // observe data
  2890. observe(data, true /* asRootData */);
  2891. }
  2892. function getData (data, vm) {
  2893. try {
  2894. return data.call(vm)
  2895. } catch (e) {
  2896. handleError(e, vm, "data()");
  2897. return {}
  2898. }
  2899. }
  2900. var computedWatcherOptions = { lazy: true };
  2901. function initComputed (vm, computed) {
  2902. process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'computed');
  2903. var watchers = vm._computedWatchers = Object.create(null);
  2904. for (var key in computed) {
  2905. var userDef = computed[key];
  2906. var getter = typeof userDef === 'function' ? userDef : userDef.get;
  2907. if (process.env.NODE_ENV !== 'production' && getter == null) {
  2908. warn(
  2909. ("Getter is missing for computed property \"" + key + "\"."),
  2910. vm
  2911. );
  2912. }
  2913. // create internal watcher for the computed property.
  2914. watchers[key] = new Watcher(vm, getter || noop, noop, computedWatcherOptions);
  2915. // component-defined computed properties are already defined on the
  2916. // component prototype. We only need to define computed properties defined
  2917. // at instantiation here.
  2918. if (!(key in vm)) {
  2919. defineComputed(vm, key, userDef);
  2920. } else if (process.env.NODE_ENV !== 'production') {
  2921. if (key in vm.$data) {
  2922. warn(("The computed property \"" + key + "\" is already defined in data."), vm);
  2923. } else if (vm.$options.props && key in vm.$options.props) {
  2924. warn(("The computed property \"" + key + "\" is already defined as a prop."), vm);
  2925. }
  2926. }
  2927. }
  2928. }
  2929. function defineComputed (target, key, userDef) {
  2930. if (typeof userDef === 'function') {
  2931. sharedPropertyDefinition.get = createComputedGetter(key);
  2932. sharedPropertyDefinition.set = noop;
  2933. } else {
  2934. sharedPropertyDefinition.get = userDef.get
  2935. ? userDef.cache !== false
  2936. ? createComputedGetter(key)
  2937. : userDef.get
  2938. : noop;
  2939. sharedPropertyDefinition.set = userDef.set
  2940. ? userDef.set
  2941. : noop;
  2942. }
  2943. if (process.env.NODE_ENV !== 'production' &&
  2944. sharedPropertyDefinition.set === noop) {
  2945. sharedPropertyDefinition.set = function () {
  2946. warn(
  2947. ("Computed property \"" + key + "\" was assigned to but it has no setter."),
  2948. this
  2949. );
  2950. };
  2951. }
  2952. Object.defineProperty(target, key, sharedPropertyDefinition);
  2953. }
  2954. function createComputedGetter (key) {
  2955. return function computedGetter () {
  2956. var watcher = this._computedWatchers && this._computedWatchers[key];
  2957. if (watcher) {
  2958. if (watcher.dirty) {
  2959. watcher.evaluate();
  2960. }
  2961. if (Dep.target) {
  2962. watcher.depend();
  2963. }
  2964. return watcher.value
  2965. }
  2966. }
  2967. }
  2968. function initMethods (vm, methods) {
  2969. process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'methods');
  2970. var props = vm.$options.props;
  2971. for (var key in methods) {
  2972. vm[key] = methods[key] == null ? noop : bind(methods[key], vm);
  2973. if (process.env.NODE_ENV !== 'production') {
  2974. if (methods[key] == null) {
  2975. warn(
  2976. "method \"" + key + "\" has an undefined value in the component definition. " +
  2977. "Did you reference the function correctly?",
  2978. vm
  2979. );
  2980. }
  2981. if (props && hasOwn(props, key)) {
  2982. warn(
  2983. ("method \"" + key + "\" has already been defined as a prop."),
  2984. vm
  2985. );
  2986. }
  2987. }
  2988. }
  2989. }
  2990. function initWatch (vm, watch) {
  2991. process.env.NODE_ENV !== 'production' && checkOptionType(vm, 'watch');
  2992. for (var key in watch) {
  2993. var handler = watch[key];
  2994. if (Array.isArray(handler)) {
  2995. for (var i = 0; i < handler.length; i++) {
  2996. createWatcher(vm, key, handler[i]);
  2997. }
  2998. } else {
  2999. createWatcher(vm, key, handler);
  3000. }
  3001. }
  3002. }
  3003. function createWatcher (
  3004. vm,
  3005. keyOrFn,
  3006. handler,
  3007. options
  3008. ) {
  3009. if (isPlainObject(handler)) {
  3010. options = handler;
  3011. handler = handler.handler;
  3012. }
  3013. if (typeof handler === 'string') {
  3014. handler = vm[handler];
  3015. }
  3016. return vm.$watch(keyOrFn, handler, options)
  3017. }
  3018. function stateMixin (Vue) {
  3019. // flow somehow has problems with directly declared definition object
  3020. // when using Object.defineProperty, so we have to procedurally build up
  3021. // the object here.
  3022. var dataDef = {};
  3023. dataDef.get = function () { return this._data };
  3024. var propsDef = {};
  3025. propsDef.get = function () { return this._props };
  3026. if (process.env.NODE_ENV !== 'production') {
  3027. dataDef.set = function (newData) {
  3028. warn(
  3029. 'Avoid replacing instance root $data. ' +
  3030. 'Use nested data properties instead.',
  3031. this
  3032. );
  3033. };
  3034. propsDef.set = function () {
  3035. warn("$props is readonly.", this);
  3036. };
  3037. }
  3038. Object.defineProperty(Vue.prototype, '$data', dataDef);
  3039. Object.defineProperty(Vue.prototype, '$props', propsDef);
  3040. Vue.prototype.$set = set;
  3041. Vue.prototype.$delete = del;
  3042. Vue.prototype.$watch = function (
  3043. expOrFn,
  3044. cb,
  3045. options
  3046. ) {
  3047. var vm = this;
  3048. if (isPlainObject(cb)) {
  3049. return createWatcher(vm, expOrFn, cb, options)
  3050. }
  3051. options = options || {};
  3052. options.user = true;
  3053. var watcher = new Watcher(vm, expOrFn, cb, options);
  3054. if (options.immediate) {
  3055. cb.call(vm, watcher.value);
  3056. }
  3057. return function unwatchFn () {
  3058. watcher.teardown();
  3059. }
  3060. };
  3061. }
  3062. /* */
  3063. function initProvide (vm) {
  3064. var provide = vm.$options.provide;
  3065. if (provide) {
  3066. vm._provided = typeof provide === 'function'
  3067. ? provide.call(vm)
  3068. : provide;
  3069. }
  3070. }
  3071. function initInjections (vm) {
  3072. var result = resolveInject(vm.$options.inject, vm);
  3073. if (result) {
  3074. observerState.shouldConvert = false;
  3075. Object.keys(result).forEach(function (key) {
  3076. /* istanbul ignore else */
  3077. if (process.env.NODE_ENV !== 'production') {
  3078. defineReactive$$1(vm, key, result[key], function () {
  3079. warn(
  3080. "Avoid mutating an injected value directly since the changes will be " +
  3081. "overwritten whenever the provided component re-renders. " +
  3082. "injection being mutated: \"" + key + "\"",
  3083. vm
  3084. );
  3085. });
  3086. } else {
  3087. defineReactive$$1(vm, key, result[key]);
  3088. }
  3089. });
  3090. observerState.shouldConvert = true;
  3091. }
  3092. }
  3093. function resolveInject (inject, vm) {
  3094. if (inject) {
  3095. // inject is :any because flow is not smart enough to figure out cached
  3096. var result = Object.create(null);
  3097. var keys = hasSymbol
  3098. ? Reflect.ownKeys(inject)
  3099. : Object.keys(inject);
  3100. for (var i = 0; i < keys.length; i++) {
  3101. var key = keys[i];
  3102. var provideKey = inject[key];
  3103. var source = vm;
  3104. while (source) {
  3105. if (source._provided && provideKey in source._provided) {
  3106. result[key] = source._provided[provideKey];
  3107. break
  3108. }
  3109. source = source.$parent;
  3110. }
  3111. if (process.env.NODE_ENV !== 'production' && !source) {
  3112. warn(("Injection \"" + key + "\" not found"), vm);
  3113. }
  3114. }
  3115. return result
  3116. }
  3117. }
  3118. /* */
  3119. function createFunctionalComponent (
  3120. Ctor,
  3121. propsData,
  3122. data,
  3123. context,
  3124. children
  3125. ) {
  3126. var props = {};
  3127. var propOptions = Ctor.options.props;
  3128. if (isDef(propOptions)) {
  3129. for (var key in propOptions) {
  3130. props[key] = validateProp(key, propOptions, propsData || {});
  3131. }
  3132. } else {
  3133. if (isDef(data.attrs)) { mergeProps(props, data.attrs); }
  3134. if (isDef(data.props)) { mergeProps(props, data.props); }
  3135. }
  3136. // ensure the createElement function in functional components
  3137. // gets a unique context - this is necessary for correct named slot check
  3138. var _context = Object.create(context);
  3139. var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
  3140. var vnode = Ctor.options.render.call(null, h, {
  3141. data: data,
  3142. props: props,
  3143. children: children,
  3144. parent: context,
  3145. listeners: data.on || {},
  3146. injections: resolveInject(Ctor.options.inject, context),
  3147. slots: function () { return resolveSlots(children, context); }
  3148. });
  3149. if (vnode instanceof VNode) {
  3150. vnode.functionalContext = context;
  3151. vnode.functionalOptions = Ctor.options;
  3152. if (data.slot) {
  3153. (vnode.data || (vnode.data = {})).slot = data.slot;
  3154. }
  3155. }
  3156. return vnode
  3157. }
  3158. function mergeProps (to, from) {
  3159. for (var key in from) {
  3160. to[camelize(key)] = from[key];
  3161. }
  3162. }
  3163. /* */
  3164. // hooks to be invoked on component VNodes during patch
  3165. var componentVNodeHooks = {
  3166. init: function init (
  3167. vnode,
  3168. hydrating,
  3169. parentElm,
  3170. refElm
  3171. ) {
  3172. if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
  3173. var child = vnode.componentInstance = createComponentInstanceForVnode(
  3174. vnode,
  3175. activeInstance,
  3176. parentElm,
  3177. refElm
  3178. );
  3179. child.$mount(hydrating ? vnode.elm : undefined, hydrating);
  3180. } else if (vnode.data.keepAlive) {
  3181. // kept-alive components, treat as a patch
  3182. var mountedNode = vnode; // work around flow
  3183. componentVNodeHooks.prepatch(mountedNode, mountedNode);
  3184. }
  3185. },
  3186. prepatch: function prepatch (oldVnode, vnode) {
  3187. var options = vnode.componentOptions;
  3188. var child = vnode.componentInstance = oldVnode.componentInstance;
  3189. updateChildComponent(
  3190. child,
  3191. options.propsData, // updated props
  3192. options.listeners, // updated listeners
  3193. vnode, // new parent vnode
  3194. options.children // new children
  3195. );
  3196. },
  3197. insert: function insert (vnode) {
  3198. var context = vnode.context;
  3199. var componentInstance = vnode.componentInstance;
  3200. if (!componentInstance._isMounted) {
  3201. componentInstance._isMounted = true;
  3202. callHook(componentInstance, 'mounted');
  3203. }
  3204. if (vnode.data.keepAlive) {
  3205. if (context._isMounted) {
  3206. // vue-router#1212
  3207. // During updates, a kept-alive component's child components may
  3208. // change, so directly walking the tree here may call activated hooks
  3209. // on incorrect children. Instead we push them into a queue which will
  3210. // be processed after the whole patch process ended.
  3211. queueActivatedComponent(componentInstance);
  3212. } else {
  3213. activateChildComponent(componentInstance, true /* direct */);
  3214. }
  3215. }
  3216. },
  3217. destroy: function destroy (vnode) {
  3218. var componentInstance = vnode.componentInstance;
  3219. if (!componentInstance._isDestroyed) {
  3220. if (!vnode.data.keepAlive) {
  3221. componentInstance.$destroy();
  3222. } else {
  3223. deactivateChildComponent(componentInstance, true /* direct */);
  3224. }
  3225. }
  3226. }
  3227. };
  3228. var hooksToMerge = Object.keys(componentVNodeHooks);
  3229. function createComponent (
  3230. Ctor,
  3231. data,
  3232. context,
  3233. children,
  3234. tag
  3235. ) {
  3236. if (isUndef(Ctor)) {
  3237. return
  3238. }
  3239. var baseCtor = context.$options._base;
  3240. // plain options object: turn it into a constructor
  3241. if (isObject(Ctor)) {
  3242. Ctor = baseCtor.extend(Ctor);
  3243. }
  3244. // if at this stage it's not a constructor or an async component factory,
  3245. // reject.
  3246. if (typeof Ctor !== 'function') {
  3247. if (process.env.NODE_ENV !== 'production') {
  3248. warn(("Invalid Component definition: " + (String(Ctor))), context);
  3249. }
  3250. return
  3251. }
  3252. // async component
  3253. var asyncFactory;
  3254. if (isUndef(Ctor.cid)) {
  3255. asyncFactory = Ctor;
  3256. Ctor = resolveAsyncComponent(asyncFactory, baseCtor, context);
  3257. if (Ctor === undefined) {
  3258. // return a placeholder node for async component, which is rendered
  3259. // as a comment node but preserves all the raw information for the node.
  3260. // the information will be used for async server-rendering and hydration.
  3261. return createAsyncPlaceholder(
  3262. asyncFactory,
  3263. data,
  3264. context,
  3265. children,
  3266. tag
  3267. )
  3268. }
  3269. }
  3270. data = data || {};
  3271. // resolve constructor options in case global mixins are applied after
  3272. // component constructor creation
  3273. resolveConstructorOptions(Ctor);
  3274. // transform component v-model data into props & events
  3275. if (isDef(data.model)) {
  3276. transformModel(Ctor.options, data);
  3277. }
  3278. // extract props
  3279. var propsData = extractPropsFromVNodeData(data, Ctor, tag);
  3280. // functional component
  3281. if (isTrue(Ctor.options.functional)) {
  3282. return createFunctionalComponent(Ctor, propsData, data, context, children)
  3283. }
  3284. // extract listeners, since these needs to be treated as
  3285. // child component listeners instead of DOM listeners
  3286. var listeners = data.on;
  3287. // replace with listeners with .native modifier
  3288. // so it gets processed during parent component patch.
  3289. data.on = data.nativeOn;
  3290. if (isTrue(Ctor.options.abstract)) {
  3291. // abstract components do not keep anything
  3292. // other than props & listeners & slot
  3293. // work around flow
  3294. var slot = data.slot;
  3295. data = {};
  3296. if (slot) {
  3297. data.slot = slot;
  3298. }
  3299. }
  3300. // merge component management hooks onto the placeholder node
  3301. mergeHooks(data);
  3302. // return a placeholder vnode
  3303. var name = Ctor.options.name || tag;
  3304. var vnode = new VNode(
  3305. ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
  3306. data, undefined, undefined, undefined, context,
  3307. { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children },
  3308. asyncFactory
  3309. );
  3310. return vnode
  3311. }
  3312. function createComponentInstanceForVnode (
  3313. vnode, // we know it's MountedComponentVNode but flow doesn't
  3314. parent, // activeInstance in lifecycle state
  3315. parentElm,
  3316. refElm
  3317. ) {
  3318. var vnodeComponentOptions = vnode.componentOptions;
  3319. var options = {
  3320. _isComponent: true,
  3321. parent: parent,
  3322. propsData: vnodeComponentOptions.propsData,
  3323. _componentTag: vnodeComponentOptions.tag,
  3324. _parentVnode: vnode,
  3325. _parentListeners: vnodeComponentOptions.listeners,
  3326. _renderChildren: vnodeComponentOptions.children,
  3327. _parentElm: parentElm || null,
  3328. _refElm: refElm || null
  3329. };
  3330. // check inline-template render functions
  3331. var inlineTemplate = vnode.data.inlineTemplate;
  3332. if (isDef(inlineTemplate)) {
  3333. options.render = inlineTemplate.render;
  3334. options.staticRenderFns = inlineTemplate.staticRenderFns;
  3335. }
  3336. return new vnodeComponentOptions.Ctor(options)
  3337. }
  3338. function mergeHooks (data) {
  3339. if (!data.hook) {
  3340. data.hook = {};
  3341. }
  3342. for (var i = 0; i < hooksToMerge.length; i++) {
  3343. var key = hooksToMerge[i];
  3344. var fromParent = data.hook[key];
  3345. var ours = componentVNodeHooks[key];
  3346. data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
  3347. }
  3348. }
  3349. function mergeHook$1 (one, two) {
  3350. return function (a, b, c, d) {
  3351. one(a, b, c, d);
  3352. two(a, b, c, d);
  3353. }
  3354. }
  3355. // transform component v-model info (value and callback) into
  3356. // prop and event handler respectively.
  3357. function transformModel (options, data) {
  3358. var prop = (options.model && options.model.prop) || 'value';
  3359. var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value;
  3360. var on = data.on || (data.on = {});
  3361. if (isDef(on[event])) {
  3362. on[event] = [data.model.callback].concat(on[event]);
  3363. } else {
  3364. on[event] = data.model.callback;
  3365. }
  3366. }
  3367. /* */
  3368. var SIMPLE_NORMALIZE = 1;
  3369. var ALWAYS_NORMALIZE = 2;
  3370. // wrapper function for providing a more flexible interface
  3371. // without getting yelled at by flow
  3372. function createElement (
  3373. context,
  3374. tag,
  3375. data,
  3376. children,
  3377. normalizationType,
  3378. alwaysNormalize
  3379. ) {
  3380. if (Array.isArray(data) || isPrimitive(data)) {
  3381. normalizationType = children;
  3382. children = data;
  3383. data = undefined;
  3384. }
  3385. if (isTrue(alwaysNormalize)) {
  3386. normalizationType = ALWAYS_NORMALIZE;
  3387. }
  3388. return _createElement(context, tag, data, children, normalizationType)
  3389. }
  3390. function _createElement (
  3391. context,
  3392. tag,
  3393. data,
  3394. children,
  3395. normalizationType
  3396. ) {
  3397. if (isDef(data) && isDef((data).__ob__)) {
  3398. process.env.NODE_ENV !== 'production' && warn(
  3399. "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
  3400. 'Always create fresh vnode data objects in each render!',
  3401. context
  3402. );
  3403. return createEmptyVNode()
  3404. }
  3405. // object syntax in v-bind
  3406. if (isDef(data) && isDef(data.is)) {
  3407. tag = data.is;
  3408. }
  3409. if (!tag) {
  3410. // in case of component :is set to falsy value
  3411. return createEmptyVNode()
  3412. }
  3413. // warn against non-primitive key
  3414. if (process.env.NODE_ENV !== 'production' &&
  3415. isDef(data) && isDef(data.key) && !isPrimitive(data.key)
  3416. ) {
  3417. warn(
  3418. 'Avoid using non-primitive value as key, ' +
  3419. 'use string/number value instead.',
  3420. context
  3421. );
  3422. }
  3423. // support single function children as default scoped slot
  3424. if (Array.isArray(children) &&
  3425. typeof children[0] === 'function'
  3426. ) {
  3427. data = data || {};
  3428. data.scopedSlots = { default: children[0] };
  3429. children.length = 0;
  3430. }
  3431. if (normalizationType === ALWAYS_NORMALIZE) {
  3432. children = normalizeChildren(children);
  3433. } else if (normalizationType === SIMPLE_NORMALIZE) {
  3434. children = simpleNormalizeChildren(children);
  3435. }
  3436. var vnode, ns;
  3437. if (typeof tag === 'string') {
  3438. var Ctor;
  3439. ns = config.getTagNamespace(tag);
  3440. if (config.isReservedTag(tag)) {
  3441. // platform built-in elements
  3442. vnode = new VNode(
  3443. config.parsePlatformTagName(tag), data, children,
  3444. undefined, undefined, context
  3445. );
  3446. } else if (isDef(Ctor = resolveAsset(context.$options, 'components', tag))) {
  3447. // component
  3448. vnode = createComponent(Ctor, data, context, children, tag);
  3449. } else {
  3450. // unknown or unlisted namespaced elements
  3451. // check at runtime because it may get assigned a namespace when its
  3452. // parent normalizes children
  3453. vnode = new VNode(
  3454. tag, data, children,
  3455. undefined, undefined, context
  3456. );
  3457. }
  3458. } else {
  3459. // direct component options / constructor
  3460. vnode = createComponent(tag, data, context, children);
  3461. }
  3462. if (isDef(vnode)) {
  3463. if (ns) { applyNS(vnode, ns); }
  3464. return vnode
  3465. } else {
  3466. return createEmptyVNode()
  3467. }
  3468. }
  3469. function applyNS (vnode, ns) {
  3470. vnode.ns = ns;
  3471. if (vnode.tag === 'foreignObject') {
  3472. // use default namespace inside foreignObject
  3473. return
  3474. }
  3475. if (isDef(vnode.children)) {
  3476. for (var i = 0, l = vnode.children.length; i < l; i++) {
  3477. var child = vnode.children[i];
  3478. if (isDef(child.tag) && isUndef(child.ns)) {
  3479. applyNS(child, ns);
  3480. }
  3481. }
  3482. }
  3483. }
  3484. /* */
  3485. /**
  3486. * Runtime helper for rendering v-for lists.
  3487. */
  3488. function renderList (
  3489. val,
  3490. render
  3491. ) {
  3492. var ret, i, l, keys, key;
  3493. if (Array.isArray(val) || typeof val === 'string') {
  3494. ret = new Array(val.length);
  3495. for (i = 0, l = val.length; i < l; i++) {
  3496. ret[i] = render(val[i], i);
  3497. }
  3498. } else if (typeof val === 'number') {
  3499. ret = new Array(val);
  3500. for (i = 0; i < val; i++) {
  3501. ret[i] = render(i + 1, i);
  3502. }
  3503. } else if (isObject(val)) {
  3504. keys = Object.keys(val);
  3505. ret = new Array(keys.length);
  3506. for (i = 0, l = keys.length; i < l; i++) {
  3507. key = keys[i];
  3508. ret[i] = render(val[key], key, i);
  3509. }
  3510. }
  3511. if (isDef(ret)) {
  3512. (ret)._isVList = true;
  3513. }
  3514. return ret
  3515. }
  3516. /* */
  3517. /**
  3518. * Runtime helper for rendering <slot>
  3519. */
  3520. function renderSlot (
  3521. name,
  3522. fallback,
  3523. props,
  3524. bindObject
  3525. ) {
  3526. var scopedSlotFn = this.$scopedSlots[name];
  3527. if (scopedSlotFn) { // scoped slot
  3528. props = props || {};
  3529. if (bindObject) {
  3530. props = extend(extend({}, bindObject), props);
  3531. }
  3532. return scopedSlotFn(props) || fallback
  3533. } else {
  3534. var slotNodes = this.$slots[name];
  3535. // warn duplicate slot usage
  3536. if (slotNodes && process.env.NODE_ENV !== 'production') {
  3537. slotNodes._rendered && warn(
  3538. "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
  3539. "- this will likely cause render errors.",
  3540. this
  3541. );
  3542. slotNodes._rendered = true;
  3543. }
  3544. return slotNodes || fallback
  3545. }
  3546. }
  3547. /* */
  3548. /**
  3549. * Runtime helper for resolving filters
  3550. */
  3551. function resolveFilter (id) {
  3552. return resolveAsset(this.$options, 'filters', id, true) || identity
  3553. }
  3554. /* */
  3555. /**
  3556. * Runtime helper for checking keyCodes from config.
  3557. */
  3558. function checkKeyCodes (
  3559. eventKeyCode,
  3560. key,
  3561. builtInAlias
  3562. ) {
  3563. var keyCodes = config.keyCodes[key] || builtInAlias;
  3564. if (Array.isArray(keyCodes)) {
  3565. return keyCodes.indexOf(eventKeyCode) === -1
  3566. } else {
  3567. return keyCodes !== eventKeyCode
  3568. }
  3569. }
  3570. /* */
  3571. /**
  3572. * Runtime helper for merging v-bind="object" into a VNode's data.
  3573. */
  3574. function bindObjectProps (
  3575. data,
  3576. tag,
  3577. value,
  3578. asProp,
  3579. isSync
  3580. ) {
  3581. if (value) {
  3582. if (!isObject(value)) {
  3583. process.env.NODE_ENV !== 'production' && warn(
  3584. 'v-bind without argument expects an Object or Array value',
  3585. this
  3586. );
  3587. } else {
  3588. if (Array.isArray(value)) {
  3589. value = toObject(value);
  3590. }
  3591. var hash;
  3592. var loop = function ( key ) {
  3593. if (
  3594. key === 'class' ||
  3595. key === 'style' ||
  3596. isReservedAttribute(key)
  3597. ) {
  3598. hash = data;
  3599. } else {
  3600. var type = data.attrs && data.attrs.type;
  3601. hash = asProp || config.mustUseProp(tag, type, key)
  3602. ? data.domProps || (data.domProps = {})
  3603. : data.attrs || (data.attrs = {});
  3604. }
  3605. if (!(key in hash)) {
  3606. hash[key] = value[key];
  3607. if (isSync) {
  3608. var on = data.on || (data.on = {});
  3609. on[("update:" + key)] = function ($event) {
  3610. value[key] = $event;
  3611. };
  3612. }
  3613. }
  3614. };
  3615. for (var key in value) loop( key );
  3616. }
  3617. }
  3618. return data
  3619. }
  3620. /* */
  3621. /**
  3622. * Runtime helper for rendering static trees.
  3623. */
  3624. function renderStatic (
  3625. index,
  3626. isInFor
  3627. ) {
  3628. var tree = this._staticTrees[index];
  3629. // if has already-rendered static tree and not inside v-for,
  3630. // we can reuse the same tree by doing a shallow clone.
  3631. if (tree && !isInFor) {
  3632. return Array.isArray(tree)
  3633. ? cloneVNodes(tree)
  3634. : cloneVNode(tree)
  3635. }
  3636. // otherwise, render a fresh tree.
  3637. tree = this._staticTrees[index] =
  3638. this.$options.staticRenderFns[index].call(this._renderProxy);
  3639. markStatic(tree, ("__static__" + index), false);
  3640. return tree
  3641. }
  3642. /**
  3643. * Runtime helper for v-once.
  3644. * Effectively it means marking the node as static with a unique key.
  3645. */
  3646. function markOnce (
  3647. tree,
  3648. index,
  3649. key
  3650. ) {
  3651. markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
  3652. return tree
  3653. }
  3654. function markStatic (
  3655. tree,
  3656. key,
  3657. isOnce
  3658. ) {
  3659. if (Array.isArray(tree)) {
  3660. for (var i = 0; i < tree.length; i++) {
  3661. if (tree[i] && typeof tree[i] !== 'string') {
  3662. markStaticNode(tree[i], (key + "_" + i), isOnce);
  3663. }
  3664. }
  3665. } else {
  3666. markStaticNode(tree, key, isOnce);
  3667. }
  3668. }
  3669. function markStaticNode (node, key, isOnce) {
  3670. node.isStatic = true;
  3671. node.key = key;
  3672. node.isOnce = isOnce;
  3673. }
  3674. /* */
  3675. function bindObjectListeners (data, value) {
  3676. if (value) {
  3677. if (!isPlainObject(value)) {
  3678. process.env.NODE_ENV !== 'production' && warn(
  3679. 'v-on without argument expects an Object value',
  3680. this
  3681. );
  3682. } else {
  3683. var on = data.on = data.on ? extend({}, data.on) : {};
  3684. for (var key in value) {
  3685. var existing = on[key];
  3686. var ours = value[key];
  3687. on[key] = existing ? [].concat(ours, existing) : ours;
  3688. }
  3689. }
  3690. }
  3691. return data
  3692. }
  3693. /* */
  3694. function initRender (vm) {
  3695. vm._vnode = null; // the root of the child tree
  3696. vm._staticTrees = null;
  3697. var parentVnode = vm.$vnode = vm.$options._parentVnode; // the placeholder node in parent tree
  3698. var renderContext = parentVnode && parentVnode.context;
  3699. vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
  3700. vm.$scopedSlots = emptyObject;
  3701. // bind the createElement fn to this instance
  3702. // so that we get proper render context inside it.
  3703. // args order: tag, data, children, normalizationType, alwaysNormalize
  3704. // internal version is used by render functions compiled from templates
  3705. vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
  3706. // normalization is always applied for the public version, used in
  3707. // user-written render functions.
  3708. vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
  3709. // $attrs & $listeners are exposed for easier HOC creation.
  3710. // they need to be reactive so that HOCs using them are always updated
  3711. var parentData = parentVnode && parentVnode.data;
  3712. /* istanbul ignore else */
  3713. if (process.env.NODE_ENV !== 'production') {
  3714. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, function () {
  3715. !isUpdatingChildComponent && warn("$attrs is readonly.", vm);
  3716. }, true);
  3717. defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, function () {
  3718. !isUpdatingChildComponent && warn("$listeners is readonly.", vm);
  3719. }, true);
  3720. } else {
  3721. defineReactive$$1(vm, '$attrs', parentData && parentData.attrs, null, true);
  3722. defineReactive$$1(vm, '$listeners', vm.$options._parentListeners, null, true);
  3723. }
  3724. }
  3725. function renderMixin (Vue) {
  3726. Vue.prototype.$nextTick = function (fn) {
  3727. return nextTick(fn, this)
  3728. };
  3729. Vue.prototype._render = function () {
  3730. var vm = this;
  3731. var ref = vm.$options;
  3732. var render = ref.render;
  3733. var staticRenderFns = ref.staticRenderFns;
  3734. var _parentVnode = ref._parentVnode;
  3735. if (vm._isMounted) {
  3736. // clone slot nodes on re-renders
  3737. for (var key in vm.$slots) {
  3738. vm.$slots[key] = cloneVNodes(vm.$slots[key]);
  3739. }
  3740. }
  3741. vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject;
  3742. if (staticRenderFns && !vm._staticTrees) {
  3743. vm._staticTrees = [];
  3744. }
  3745. // set parent vnode. this allows render functions to have access
  3746. // to the data on the placeholder node.
  3747. vm.$vnode = _parentVnode;
  3748. // render self
  3749. var vnode;
  3750. try {
  3751. vnode = render.call(vm._renderProxy, vm.$createElement);
  3752. } catch (e) {
  3753. handleError(e, vm, "render function");
  3754. // return error render result,
  3755. // or previous vnode to prevent render error causing blank component
  3756. /* istanbul ignore else */
  3757. if (process.env.NODE_ENV !== 'production') {
  3758. vnode = vm.$options.renderError
  3759. ? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e)
  3760. : vm._vnode;
  3761. } else {
  3762. vnode = vm._vnode;
  3763. }
  3764. }
  3765. // return empty vnode in case the render function errored out
  3766. if (!(vnode instanceof VNode)) {
  3767. if (process.env.NODE_ENV !== 'production' && Array.isArray(vnode)) {
  3768. warn(
  3769. 'Multiple root nodes returned from render function. Render function ' +
  3770. 'should return a single root node.',
  3771. vm
  3772. );
  3773. }
  3774. vnode = createEmptyVNode();
  3775. }
  3776. // set parent
  3777. vnode.parent = _parentVnode;
  3778. return vnode
  3779. };
  3780. // internal render helpers.
  3781. // these are exposed on the instance prototype to reduce generated render
  3782. // code size.
  3783. Vue.prototype._o = markOnce;
  3784. Vue.prototype._n = toNumber;
  3785. Vue.prototype._s = toString;
  3786. Vue.prototype._l = renderList;
  3787. Vue.prototype._t = renderSlot;
  3788. Vue.prototype._q = looseEqual;
  3789. Vue.prototype._i = looseIndexOf;
  3790. Vue.prototype._m = renderStatic;
  3791. Vue.prototype._f = resolveFilter;
  3792. Vue.prototype._k = checkKeyCodes;
  3793. Vue.prototype._b = bindObjectProps;
  3794. Vue.prototype._v = createTextVNode;
  3795. Vue.prototype._e = createEmptyVNode;
  3796. Vue.prototype._u = resolveScopedSlots;
  3797. Vue.prototype._g = bindObjectListeners;
  3798. }
  3799. /* */
  3800. var uid = 0;
  3801. function initMixin (Vue) {
  3802. Vue.prototype._init = function (options) {
  3803. var vm = this;
  3804. // a uid
  3805. vm._uid = uid++;
  3806. var startTag, endTag;
  3807. /* istanbul ignore if */
  3808. if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
  3809. startTag = "vue-perf-init:" + (vm._uid);
  3810. endTag = "vue-perf-end:" + (vm._uid);
  3811. mark(startTag);
  3812. }
  3813. // a flag to avoid this being observed
  3814. vm._isVue = true;
  3815. // merge options
  3816. if (options && options._isComponent) {
  3817. // optimize internal component instantiation
  3818. // since dynamic options merging is pretty slow, and none of the
  3819. // internal component options needs special treatment.
  3820. initInternalComponent(vm, options);
  3821. } else {
  3822. vm.$options = mergeOptions(
  3823. resolveConstructorOptions(vm.constructor),
  3824. options || {},
  3825. vm
  3826. );
  3827. }
  3828. /* istanbul ignore else */
  3829. if (process.env.NODE_ENV !== 'production') {
  3830. initProxy(vm);
  3831. } else {
  3832. vm._renderProxy = vm;
  3833. }
  3834. // expose real self
  3835. vm._self = vm;
  3836. initLifecycle(vm);
  3837. initEvents(vm);
  3838. initRender(vm);
  3839. callHook(vm, 'beforeCreate');
  3840. initInjections(vm); // resolve injections before data/props
  3841. initState(vm);
  3842. initProvide(vm); // resolve provide after data/props
  3843. callHook(vm, 'created');
  3844. /* istanbul ignore if */
  3845. if (process.env.NODE_ENV !== 'production' && config.performance && mark) {
  3846. vm._name = formatComponentName(vm, false);
  3847. mark(endTag);
  3848. measure(((vm._name) + " init"), startTag, endTag);
  3849. }
  3850. if (vm.$options.el) {
  3851. vm.$mount(vm.$options.el);
  3852. }
  3853. };
  3854. }
  3855. function initInternalComponent (vm, options) {
  3856. var opts = vm.$options = Object.create(vm.constructor.options);
  3857. // doing this because it's faster than dynamic enumeration.
  3858. opts.parent = options.parent;
  3859. opts.propsData = options.propsData;
  3860. opts._parentVnode = options._parentVnode;
  3861. opts._parentListeners = options._parentListeners;
  3862. opts._renderChildren = options._renderChildren;
  3863. opts._componentTag = options._componentTag;
  3864. opts._parentElm = options._parentElm;
  3865. opts._refElm = options._refElm;
  3866. if (options.render) {
  3867. opts.render = options.render;
  3868. opts.staticRenderFns = options.staticRenderFns;
  3869. }
  3870. }
  3871. function resolveConstructorOptions (Ctor) {
  3872. var options = Ctor.options;
  3873. if (Ctor.super) {
  3874. var superOptions = resolveConstructorOptions(Ctor.super);
  3875. var cachedSuperOptions = Ctor.superOptions;
  3876. if (superOptions !== cachedSuperOptions) {
  3877. // super option changed,
  3878. // need to resolve new options.
  3879. Ctor.superOptions = superOptions;
  3880. // check if there are any late-modified/attached options (#4976)
  3881. var modifiedOptions = resolveModifiedOptions(Ctor);
  3882. // update base extend options
  3883. if (modifiedOptions) {
  3884. extend(Ctor.extendOptions, modifiedOptions);
  3885. }
  3886. options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions);
  3887. if (options.name) {
  3888. options.components[options.name] = Ctor;
  3889. }
  3890. }
  3891. }
  3892. return options
  3893. }
  3894. function resolveModifiedOptions (Ctor) {
  3895. var modified;
  3896. var latest = Ctor.options;
  3897. var extended = Ctor.extendOptions;
  3898. var sealed = Ctor.sealedOptions;
  3899. for (var key in latest) {
  3900. if (latest[key] !== sealed[key]) {
  3901. if (!modified) { modified = {}; }
  3902. modified[key] = dedupe(latest[key], extended[key], sealed[key]);
  3903. }
  3904. }
  3905. return modified
  3906. }
  3907. function dedupe (latest, extended, sealed) {
  3908. // compare latest and sealed to ensure lifecycle hooks won't be duplicated
  3909. // between merges
  3910. if (Array.isArray(latest)) {
  3911. var res = [];
  3912. sealed = Array.isArray(sealed) ? sealed : [sealed];
  3913. extended = Array.isArray(extended) ? extended : [extended];
  3914. for (var i = 0; i < latest.length; i++) {
  3915. // push original options and not sealed options to exclude duplicated options
  3916. if (extended.indexOf(latest[i]) >= 0 || sealed.indexOf(latest[i]) < 0) {
  3917. res.push(latest[i]);
  3918. }
  3919. }
  3920. return res
  3921. } else {
  3922. return latest
  3923. }
  3924. }
  3925. function Vue$2 (options) {
  3926. if (process.env.NODE_ENV !== 'production' &&
  3927. !(this instanceof Vue$2)
  3928. ) {
  3929. warn('Vue is a constructor and should be called with the `new` keyword');
  3930. }
  3931. this._init(options);
  3932. }
  3933. initMixin(Vue$2);
  3934. stateMixin(Vue$2);
  3935. eventsMixin(Vue$2);
  3936. lifecycleMixin(Vue$2);
  3937. renderMixin(Vue$2);
  3938. /* */
  3939. function initUse (Vue) {
  3940. Vue.use = function (plugin) {
  3941. var installedPlugins = (this._installedPlugins || (this._installedPlugins = []));
  3942. if (installedPlugins.indexOf(plugin) > -1) {
  3943. return this
  3944. }
  3945. // additional parameters
  3946. var args = toArray(arguments, 1);
  3947. args.unshift(this);
  3948. if (typeof plugin.install === 'function') {
  3949. plugin.install.apply(plugin, args);
  3950. } else if (typeof plugin === 'function') {
  3951. plugin.apply(null, args);
  3952. }
  3953. installedPlugins.push(plugin);
  3954. return this
  3955. };
  3956. }
  3957. /* */
  3958. function initMixin$1 (Vue) {
  3959. Vue.mixin = function (mixin) {
  3960. this.options = mergeOptions(this.options, mixin);
  3961. return this
  3962. };
  3963. }
  3964. /* */
  3965. function initExtend (Vue) {
  3966. /**
  3967. * Each instance constructor, including Vue, has a unique
  3968. * cid. This enables us to create wrapped "child
  3969. * constructors" for prototypal inheritance and cache them.
  3970. */
  3971. Vue.cid = 0;
  3972. var cid = 1;
  3973. /**
  3974. * Class inheritance
  3975. */
  3976. Vue.extend = function (extendOptions) {
  3977. extendOptions = extendOptions || {};
  3978. var Super = this;
  3979. var SuperId = Super.cid;
  3980. var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
  3981. if (cachedCtors[SuperId]) {
  3982. return cachedCtors[SuperId]
  3983. }
  3984. var name = extendOptions.name || Super.options.name;
  3985. if (process.env.NODE_ENV !== 'production') {
  3986. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  3987. warn(
  3988. 'Invalid component name: "' + name + '". Component names ' +
  3989. 'can only contain alphanumeric characters and the hyphen, ' +
  3990. 'and must start with a letter.'
  3991. );
  3992. }
  3993. }
  3994. var Sub = function VueComponent (options) {
  3995. this._init(options);
  3996. };
  3997. Sub.prototype = Object.create(Super.prototype);
  3998. Sub.prototype.constructor = Sub;
  3999. Sub.cid = cid++;
  4000. Sub.options = mergeOptions(
  4001. Super.options,
  4002. extendOptions
  4003. );
  4004. Sub['super'] = Super;
  4005. // For props and computed properties, we define the proxy getters on
  4006. // the Vue instances at extension time, on the extended prototype. This
  4007. // avoids Object.defineProperty calls for each instance created.
  4008. if (Sub.options.props) {
  4009. initProps$1(Sub);
  4010. }
  4011. if (Sub.options.computed) {
  4012. initComputed$1(Sub);
  4013. }
  4014. // allow further extension/mixin/plugin usage
  4015. Sub.extend = Super.extend;
  4016. Sub.mixin = Super.mixin;
  4017. Sub.use = Super.use;
  4018. // create asset registers, so extended classes
  4019. // can have their private assets too.
  4020. ASSET_TYPES.forEach(function (type) {
  4021. Sub[type] = Super[type];
  4022. });
  4023. // enable recursive self-lookup
  4024. if (name) {
  4025. Sub.options.components[name] = Sub;
  4026. }
  4027. // keep a reference to the super options at extension time.
  4028. // later at instantiation we can check if Super's options have
  4029. // been updated.
  4030. Sub.superOptions = Super.options;
  4031. Sub.extendOptions = extendOptions;
  4032. Sub.sealedOptions = extend({}, Sub.options);
  4033. // cache constructor
  4034. cachedCtors[SuperId] = Sub;
  4035. return Sub
  4036. };
  4037. }
  4038. function initProps$1 (Comp) {
  4039. var props = Comp.options.props;
  4040. for (var key in props) {
  4041. proxy(Comp.prototype, "_props", key);
  4042. }
  4043. }
  4044. function initComputed$1 (Comp) {
  4045. var computed = Comp.options.computed;
  4046. for (var key in computed) {
  4047. defineComputed(Comp.prototype, key, computed[key]);
  4048. }
  4049. }
  4050. /* */
  4051. function initAssetRegisters (Vue) {
  4052. /**
  4053. * Create asset registration methods.
  4054. */
  4055. ASSET_TYPES.forEach(function (type) {
  4056. Vue[type] = function (
  4057. id,
  4058. definition
  4059. ) {
  4060. if (!definition) {
  4061. return this.options[type + 's'][id]
  4062. } else {
  4063. /* istanbul ignore if */
  4064. if (process.env.NODE_ENV !== 'production') {
  4065. if (type === 'component' && config.isReservedTag(id)) {
  4066. warn(
  4067. 'Do not use built-in or reserved HTML elements as component ' +
  4068. 'id: ' + id
  4069. );
  4070. }
  4071. }
  4072. if (type === 'component' && isPlainObject(definition)) {
  4073. definition.name = definition.name || id;
  4074. definition = this.options._base.extend(definition);
  4075. }
  4076. if (type === 'directive' && typeof definition === 'function') {
  4077. definition = { bind: definition, update: definition };
  4078. }
  4079. this.options[type + 's'][id] = definition;
  4080. return definition
  4081. }
  4082. };
  4083. });
  4084. }
  4085. /* */
  4086. var patternTypes = [String, RegExp, Array];
  4087. function getComponentName (opts) {
  4088. return opts && (opts.Ctor.options.name || opts.tag)
  4089. }
  4090. function matches (pattern, name) {
  4091. if (Array.isArray(pattern)) {
  4092. return pattern.indexOf(name) > -1
  4093. } else if (typeof pattern === 'string') {
  4094. return pattern.split(',').indexOf(name) > -1
  4095. } else if (isRegExp(pattern)) {
  4096. return pattern.test(name)
  4097. }
  4098. /* istanbul ignore next */
  4099. return false
  4100. }
  4101. function pruneCache (cache, current, filter) {
  4102. for (var key in cache) {
  4103. var cachedNode = cache[key];
  4104. if (cachedNode) {
  4105. var name = getComponentName(cachedNode.componentOptions);
  4106. if (name && !filter(name)) {
  4107. if (cachedNode !== current) {
  4108. pruneCacheEntry(cachedNode);
  4109. }
  4110. cache[key] = null;
  4111. }
  4112. }
  4113. }
  4114. }
  4115. function pruneCacheEntry (vnode) {
  4116. if (vnode) {
  4117. vnode.componentInstance.$destroy();
  4118. }
  4119. }
  4120. var KeepAlive = {
  4121. name: 'keep-alive',
  4122. abstract: true,
  4123. props: {
  4124. include: patternTypes,
  4125. exclude: patternTypes
  4126. },
  4127. created: function created () {
  4128. this.cache = Object.create(null);
  4129. },
  4130. destroyed: function destroyed () {
  4131. var this$1 = this;
  4132. for (var key in this$1.cache) {
  4133. pruneCacheEntry(this$1.cache[key]);
  4134. }
  4135. },
  4136. watch: {
  4137. include: function include (val) {
  4138. pruneCache(this.cache, this._vnode, function (name) { return matches(val, name); });
  4139. },
  4140. exclude: function exclude (val) {
  4141. pruneCache(this.cache, this._vnode, function (name) { return !matches(val, name); });
  4142. }
  4143. },
  4144. render: function render () {
  4145. var vnode = getFirstComponentChild(this.$slots.default);
  4146. var componentOptions = vnode && vnode.componentOptions;
  4147. if (componentOptions) {
  4148. // check pattern
  4149. var name = getComponentName(componentOptions);
  4150. if (name && (
  4151. (this.include && !matches(this.include, name)) ||
  4152. (this.exclude && matches(this.exclude, name))
  4153. )) {
  4154. return vnode
  4155. }
  4156. var key = vnode.key == null
  4157. // same constructor may get registered as different local components
  4158. // so cid alone is not enough (#3269)
  4159. ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
  4160. : vnode.key;
  4161. if (this.cache[key]) {
  4162. vnode.componentInstance = this.cache[key].componentInstance;
  4163. } else {
  4164. this.cache[key] = vnode;
  4165. }
  4166. vnode.data.keepAlive = true;
  4167. }
  4168. return vnode
  4169. }
  4170. };
  4171. var builtInComponents = {
  4172. KeepAlive: KeepAlive
  4173. };
  4174. /* */
  4175. function initGlobalAPI (Vue) {
  4176. // config
  4177. var configDef = {};
  4178. configDef.get = function () { return config; };
  4179. if (process.env.NODE_ENV !== 'production') {
  4180. configDef.set = function () {
  4181. warn(
  4182. 'Do not replace the Vue.config object, set individual fields instead.'
  4183. );
  4184. };
  4185. }
  4186. Object.defineProperty(Vue, 'config', configDef);
  4187. // exposed util methods.
  4188. // NOTE: these are not considered part of the public API - avoid relying on
  4189. // them unless you are aware of the risk.
  4190. Vue.util = {
  4191. warn: warn,
  4192. extend: extend,
  4193. mergeOptions: mergeOptions,
  4194. defineReactive: defineReactive$$1
  4195. };
  4196. Vue.set = set;
  4197. Vue.delete = del;
  4198. Vue.nextTick = nextTick;
  4199. Vue.options = Object.create(null);
  4200. ASSET_TYPES.forEach(function (type) {
  4201. Vue.options[type + 's'] = Object.create(null);
  4202. });
  4203. // this is used to identify the "base" constructor to extend all plain-object
  4204. // components with in Weex's multi-instance scenarios.
  4205. Vue.options._base = Vue;
  4206. extend(Vue.options.components, builtInComponents);
  4207. initUse(Vue);
  4208. initMixin$1(Vue);
  4209. initExtend(Vue);
  4210. initAssetRegisters(Vue);
  4211. }
  4212. initGlobalAPI(Vue$2);
  4213. Object.defineProperty(Vue$2.prototype, '$isServer', {
  4214. get: isServerRendering
  4215. });
  4216. Object.defineProperty(Vue$2.prototype, '$ssrContext', {
  4217. get: function get () {
  4218. /* istanbul ignore next */
  4219. return this.$vnode && this.$vnode.ssrContext
  4220. }
  4221. });
  4222. Vue$2.version = '2.4.2';
  4223. /* globals renderer */
  4224. // renderer is injected by weex factory wrapper
  4225. var namespaceMap = {};
  4226. function createElement$1 (tagName) {
  4227. return new renderer.Element(tagName)
  4228. }
  4229. function createElementNS (namespace, tagName) {
  4230. return new renderer.Element(namespace + ':' + tagName)
  4231. }
  4232. function createTextNode (text) {
  4233. return new renderer.TextNode(text)
  4234. }
  4235. function createComment (text) {
  4236. return new renderer.Comment(text)
  4237. }
  4238. function insertBefore (node, target, before) {
  4239. if (target.nodeType === 3) {
  4240. if (node.type === 'text') {
  4241. node.setAttr('value', target.text);
  4242. target.parentNode = node;
  4243. } else {
  4244. var text = createElement$1('text');
  4245. text.setAttr('value', target.text);
  4246. node.insertBefore(text, before);
  4247. }
  4248. return
  4249. }
  4250. node.insertBefore(target, before);
  4251. }
  4252. function removeChild (node, child) {
  4253. if (child.nodeType === 3) {
  4254. node.setAttr('value', '');
  4255. return
  4256. }
  4257. node.removeChild(child);
  4258. }
  4259. function appendChild (node, child) {
  4260. if (child.nodeType === 3) {
  4261. if (node.type === 'text') {
  4262. node.setAttr('value', child.text);
  4263. child.parentNode = node;
  4264. } else {
  4265. var text = createElement$1('text');
  4266. text.setAttr('value', child.text);
  4267. node.appendChild(text);
  4268. }
  4269. return
  4270. }
  4271. node.appendChild(child);
  4272. }
  4273. function parentNode (node) {
  4274. return node.parentNode
  4275. }
  4276. function nextSibling (node) {
  4277. return node.nextSibling
  4278. }
  4279. function tagName (node) {
  4280. return node.type
  4281. }
  4282. function setTextContent (node, text) {
  4283. node.parentNode.setAttr('value', text);
  4284. }
  4285. function setAttribute (node, key, val) {
  4286. node.setAttr(key, val);
  4287. }
  4288. var nodeOps = Object.freeze({
  4289. namespaceMap: namespaceMap,
  4290. createElement: createElement$1,
  4291. createElementNS: createElementNS,
  4292. createTextNode: createTextNode,
  4293. createComment: createComment,
  4294. insertBefore: insertBefore,
  4295. removeChild: removeChild,
  4296. appendChild: appendChild,
  4297. parentNode: parentNode,
  4298. nextSibling: nextSibling,
  4299. tagName: tagName,
  4300. setTextContent: setTextContent,
  4301. setAttribute: setAttribute
  4302. });
  4303. /* */
  4304. var ref = {
  4305. create: function create (_, vnode) {
  4306. registerRef(vnode);
  4307. },
  4308. update: function update (oldVnode, vnode) {
  4309. if (oldVnode.data.ref !== vnode.data.ref) {
  4310. registerRef(oldVnode, true);
  4311. registerRef(vnode);
  4312. }
  4313. },
  4314. destroy: function destroy (vnode) {
  4315. registerRef(vnode, true);
  4316. }
  4317. };
  4318. function registerRef (vnode, isRemoval) {
  4319. var key = vnode.data.ref;
  4320. if (!key) { return }
  4321. var vm = vnode.context;
  4322. var ref = vnode.componentInstance || vnode.elm;
  4323. var refs = vm.$refs;
  4324. if (isRemoval) {
  4325. if (Array.isArray(refs[key])) {
  4326. remove(refs[key], ref);
  4327. } else if (refs[key] === ref) {
  4328. refs[key] = undefined;
  4329. }
  4330. } else {
  4331. if (vnode.data.refInFor) {
  4332. if (!Array.isArray(refs[key])) {
  4333. refs[key] = [ref];
  4334. } else if (refs[key].indexOf(ref) < 0) {
  4335. // $flow-disable-line
  4336. refs[key].push(ref);
  4337. }
  4338. } else {
  4339. refs[key] = ref;
  4340. }
  4341. }
  4342. }
  4343. /**
  4344. * Virtual DOM patching algorithm based on Snabbdom by
  4345. * Simon Friis Vindum (@paldepind)
  4346. * Licensed under the MIT License
  4347. * https://github.com/paldepind/snabbdom/blob/master/LICENSE
  4348. *
  4349. * modified by Evan You (@yyx990803)
  4350. *
  4351. /*
  4352. * Not type-checking this because this file is perf-critical and the cost
  4353. * of making flow understand it is not worth it.
  4354. */
  4355. var emptyNode = new VNode('', {}, []);
  4356. var hooks = ['create', 'activate', 'update', 'remove', 'destroy'];
  4357. function sameVnode (a, b) {
  4358. return (
  4359. a.key === b.key && (
  4360. (
  4361. a.tag === b.tag &&
  4362. a.isComment === b.isComment &&
  4363. isDef(a.data) === isDef(b.data) &&
  4364. sameInputType(a, b)
  4365. ) || (
  4366. isTrue(a.isAsyncPlaceholder) &&
  4367. a.asyncFactory === b.asyncFactory &&
  4368. isUndef(b.asyncFactory.error)
  4369. )
  4370. )
  4371. )
  4372. }
  4373. // Some browsers do not support dynamically changing type for <input>
  4374. // so they need to be treated as different nodes
  4375. function sameInputType (a, b) {
  4376. if (a.tag !== 'input') { return true }
  4377. var i;
  4378. var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type;
  4379. var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type;
  4380. return typeA === typeB
  4381. }
  4382. function createKeyToOldIdx (children, beginIdx, endIdx) {
  4383. var i, key;
  4384. var map = {};
  4385. for (i = beginIdx; i <= endIdx; ++i) {
  4386. key = children[i].key;
  4387. if (isDef(key)) { map[key] = i; }
  4388. }
  4389. return map
  4390. }
  4391. function createPatchFunction (backend) {
  4392. var i, j;
  4393. var cbs = {};
  4394. var modules = backend.modules;
  4395. var nodeOps = backend.nodeOps;
  4396. for (i = 0; i < hooks.length; ++i) {
  4397. cbs[hooks[i]] = [];
  4398. for (j = 0; j < modules.length; ++j) {
  4399. if (isDef(modules[j][hooks[i]])) {
  4400. cbs[hooks[i]].push(modules[j][hooks[i]]);
  4401. }
  4402. }
  4403. }
  4404. function emptyNodeAt (elm) {
  4405. return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
  4406. }
  4407. function createRmCb (childElm, listeners) {
  4408. function remove$$1 () {
  4409. if (--remove$$1.listeners === 0) {
  4410. removeNode(childElm);
  4411. }
  4412. }
  4413. remove$$1.listeners = listeners;
  4414. return remove$$1
  4415. }
  4416. function removeNode (el) {
  4417. var parent = nodeOps.parentNode(el);
  4418. // element may have already been removed due to v-html / v-text
  4419. if (isDef(parent)) {
  4420. nodeOps.removeChild(parent, el);
  4421. }
  4422. }
  4423. var inPre = 0;
  4424. function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
  4425. vnode.isRootInsert = !nested; // for transition enter check
  4426. if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
  4427. return
  4428. }
  4429. var data = vnode.data;
  4430. var children = vnode.children;
  4431. var tag = vnode.tag;
  4432. if (isDef(tag)) {
  4433. if (process.env.NODE_ENV !== 'production') {
  4434. if (data && data.pre) {
  4435. inPre++;
  4436. }
  4437. if (
  4438. !inPre &&
  4439. !vnode.ns &&
  4440. !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) &&
  4441. config.isUnknownElement(tag)
  4442. ) {
  4443. warn(
  4444. 'Unknown custom element: <' + tag + '> - did you ' +
  4445. 'register the component correctly? For recursive components, ' +
  4446. 'make sure to provide the "name" option.',
  4447. vnode.context
  4448. );
  4449. }
  4450. }
  4451. vnode.elm = vnode.ns
  4452. ? nodeOps.createElementNS(vnode.ns, tag)
  4453. : nodeOps.createElement(tag, vnode);
  4454. setScope(vnode);
  4455. /* istanbul ignore if */
  4456. {
  4457. // in Weex, the default insertion order is parent-first.
  4458. // List items can be optimized to use children-first insertion
  4459. // with append="tree".
  4460. var appendAsTree = isDef(data) && isTrue(data.appendAsTree);
  4461. if (!appendAsTree) {
  4462. if (isDef(data)) {
  4463. invokeCreateHooks(vnode, insertedVnodeQueue);
  4464. }
  4465. insert(parentElm, vnode.elm, refElm);
  4466. }
  4467. createChildren(vnode, children, insertedVnodeQueue);
  4468. if (appendAsTree) {
  4469. if (isDef(data)) {
  4470. invokeCreateHooks(vnode, insertedVnodeQueue);
  4471. }
  4472. insert(parentElm, vnode.elm, refElm);
  4473. }
  4474. }
  4475. if (process.env.NODE_ENV !== 'production' && data && data.pre) {
  4476. inPre--;
  4477. }
  4478. } else if (isTrue(vnode.isComment)) {
  4479. vnode.elm = nodeOps.createComment(vnode.text);
  4480. insert(parentElm, vnode.elm, refElm);
  4481. } else {
  4482. vnode.elm = nodeOps.createTextNode(vnode.text);
  4483. insert(parentElm, vnode.elm, refElm);
  4484. }
  4485. }
  4486. function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  4487. var i = vnode.data;
  4488. if (isDef(i)) {
  4489. var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
  4490. if (isDef(i = i.hook) && isDef(i = i.init)) {
  4491. i(vnode, false /* hydrating */, parentElm, refElm);
  4492. }
  4493. // after calling the init hook, if the vnode is a child component
  4494. // it should've created a child instance and mounted it. the child
  4495. // component also has set the placeholder vnode's elm.
  4496. // in that case we can just return the element and be done.
  4497. if (isDef(vnode.componentInstance)) {
  4498. initComponent(vnode, insertedVnodeQueue);
  4499. if (isTrue(isReactivated)) {
  4500. reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
  4501. }
  4502. return true
  4503. }
  4504. }
  4505. }
  4506. function initComponent (vnode, insertedVnodeQueue) {
  4507. if (isDef(vnode.data.pendingInsert)) {
  4508. insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
  4509. vnode.data.pendingInsert = null;
  4510. }
  4511. vnode.elm = vnode.componentInstance.$el;
  4512. if (isPatchable(vnode)) {
  4513. invokeCreateHooks(vnode, insertedVnodeQueue);
  4514. setScope(vnode);
  4515. } else {
  4516. // empty component root.
  4517. // skip all element-related modules except for ref (#3455)
  4518. registerRef(vnode);
  4519. // make sure to invoke the insert hook
  4520. insertedVnodeQueue.push(vnode);
  4521. }
  4522. }
  4523. function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
  4524. var i;
  4525. // hack for #4339: a reactivated component with inner transition
  4526. // does not trigger because the inner node's created hooks are not called
  4527. // again. It's not ideal to involve module-specific logic in here but
  4528. // there doesn't seem to be a better way to do it.
  4529. var innerNode = vnode;
  4530. while (innerNode.componentInstance) {
  4531. innerNode = innerNode.componentInstance._vnode;
  4532. if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
  4533. for (i = 0; i < cbs.activate.length; ++i) {
  4534. cbs.activate[i](emptyNode, innerNode);
  4535. }
  4536. insertedVnodeQueue.push(innerNode);
  4537. break
  4538. }
  4539. }
  4540. // unlike a newly created component,
  4541. // a reactivated keep-alive component doesn't insert itself
  4542. insert(parentElm, vnode.elm, refElm);
  4543. }
  4544. function insert (parent, elm, ref$$1) {
  4545. if (isDef(parent)) {
  4546. if (isDef(ref$$1)) {
  4547. if (ref$$1.parentNode === parent) {
  4548. nodeOps.insertBefore(parent, elm, ref$$1);
  4549. }
  4550. } else {
  4551. nodeOps.appendChild(parent, elm);
  4552. }
  4553. }
  4554. }
  4555. function createChildren (vnode, children, insertedVnodeQueue) {
  4556. if (Array.isArray(children)) {
  4557. for (var i = 0; i < children.length; ++i) {
  4558. createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
  4559. }
  4560. } else if (isPrimitive(vnode.text)) {
  4561. nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
  4562. }
  4563. }
  4564. function isPatchable (vnode) {
  4565. while (vnode.componentInstance) {
  4566. vnode = vnode.componentInstance._vnode;
  4567. }
  4568. return isDef(vnode.tag)
  4569. }
  4570. function invokeCreateHooks (vnode, insertedVnodeQueue) {
  4571. for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
  4572. cbs.create[i$1](emptyNode, vnode);
  4573. }
  4574. i = vnode.data.hook; // Reuse variable
  4575. if (isDef(i)) {
  4576. if (isDef(i.create)) { i.create(emptyNode, vnode); }
  4577. if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); }
  4578. }
  4579. }
  4580. // set scope id attribute for scoped CSS.
  4581. // this is implemented as a special case to avoid the overhead
  4582. // of going through the normal attribute patching process.
  4583. function setScope (vnode) {
  4584. var i;
  4585. var ancestor = vnode;
  4586. while (ancestor) {
  4587. if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) {
  4588. nodeOps.setAttribute(vnode.elm, i, '');
  4589. }
  4590. ancestor = ancestor.parent;
  4591. }
  4592. // for slot content they should also get the scopeId from the host instance.
  4593. if (isDef(i = activeInstance) &&
  4594. i !== vnode.context &&
  4595. isDef(i = i.$options._scopeId)
  4596. ) {
  4597. nodeOps.setAttribute(vnode.elm, i, '');
  4598. }
  4599. }
  4600. function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
  4601. for (; startIdx <= endIdx; ++startIdx) {
  4602. createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm);
  4603. }
  4604. }
  4605. function invokeDestroyHook (vnode) {
  4606. var i, j;
  4607. var data = vnode.data;
  4608. if (isDef(data)) {
  4609. if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
  4610. for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
  4611. }
  4612. if (isDef(i = vnode.children)) {
  4613. for (j = 0; j < vnode.children.length; ++j) {
  4614. invokeDestroyHook(vnode.children[j]);
  4615. }
  4616. }
  4617. }
  4618. function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
  4619. for (; startIdx <= endIdx; ++startIdx) {
  4620. var ch = vnodes[startIdx];
  4621. if (isDef(ch)) {
  4622. if (isDef(ch.tag)) {
  4623. removeAndInvokeRemoveHook(ch);
  4624. invokeDestroyHook(ch);
  4625. } else { // Text node
  4626. removeNode(ch.elm);
  4627. }
  4628. }
  4629. }
  4630. }
  4631. function removeAndInvokeRemoveHook (vnode, rm) {
  4632. if (isDef(rm) || isDef(vnode.data)) {
  4633. var i;
  4634. var listeners = cbs.remove.length + 1;
  4635. if (isDef(rm)) {
  4636. // we have a recursively passed down rm callback
  4637. // increase the listeners count
  4638. rm.listeners += listeners;
  4639. } else {
  4640. // directly removing
  4641. rm = createRmCb(vnode.elm, listeners);
  4642. }
  4643. // recursively invoke hooks on child component root node
  4644. if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
  4645. removeAndInvokeRemoveHook(i, rm);
  4646. }
  4647. for (i = 0; i < cbs.remove.length; ++i) {
  4648. cbs.remove[i](vnode, rm);
  4649. }
  4650. if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
  4651. i(vnode, rm);
  4652. } else {
  4653. rm();
  4654. }
  4655. } else {
  4656. removeNode(vnode.elm);
  4657. }
  4658. }
  4659. function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
  4660. var oldStartIdx = 0;
  4661. var newStartIdx = 0;
  4662. var oldEndIdx = oldCh.length - 1;
  4663. var oldStartVnode = oldCh[0];
  4664. var oldEndVnode = oldCh[oldEndIdx];
  4665. var newEndIdx = newCh.length - 1;
  4666. var newStartVnode = newCh[0];
  4667. var newEndVnode = newCh[newEndIdx];
  4668. var oldKeyToIdx, idxInOld, elmToMove, refElm;
  4669. // removeOnly is a special flag used only by <transition-group>
  4670. // to ensure removed elements stay in correct relative positions
  4671. // during leaving transitions
  4672. var canMove = !removeOnly;
  4673. while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
  4674. if (isUndef(oldStartVnode)) {
  4675. oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
  4676. } else if (isUndef(oldEndVnode)) {
  4677. oldEndVnode = oldCh[--oldEndIdx];
  4678. } else if (sameVnode(oldStartVnode, newStartVnode)) {
  4679. patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
  4680. oldStartVnode = oldCh[++oldStartIdx];
  4681. newStartVnode = newCh[++newStartIdx];
  4682. } else if (sameVnode(oldEndVnode, newEndVnode)) {
  4683. patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
  4684. oldEndVnode = oldCh[--oldEndIdx];
  4685. newEndVnode = newCh[--newEndIdx];
  4686. } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
  4687. patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
  4688. canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
  4689. oldStartVnode = oldCh[++oldStartIdx];
  4690. newEndVnode = newCh[--newEndIdx];
  4691. } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
  4692. patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
  4693. canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
  4694. oldEndVnode = oldCh[--oldEndIdx];
  4695. newStartVnode = newCh[++newStartIdx];
  4696. } else {
  4697. if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
  4698. idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
  4699. if (isUndef(idxInOld)) { // New element
  4700. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  4701. newStartVnode = newCh[++newStartIdx];
  4702. } else {
  4703. elmToMove = oldCh[idxInOld];
  4704. /* istanbul ignore if */
  4705. if (process.env.NODE_ENV !== 'production' && !elmToMove) {
  4706. warn(
  4707. 'It seems there are duplicate keys that is causing an update error. ' +
  4708. 'Make sure each v-for item has a unique key.'
  4709. );
  4710. }
  4711. if (sameVnode(elmToMove, newStartVnode)) {
  4712. patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
  4713. oldCh[idxInOld] = undefined;
  4714. canMove && nodeOps.insertBefore(parentElm, elmToMove.elm, oldStartVnode.elm);
  4715. newStartVnode = newCh[++newStartIdx];
  4716. } else {
  4717. // same key but different element. treat as new element
  4718. createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
  4719. newStartVnode = newCh[++newStartIdx];
  4720. }
  4721. }
  4722. }
  4723. }
  4724. if (oldStartIdx > oldEndIdx) {
  4725. refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
  4726. addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
  4727. } else if (newStartIdx > newEndIdx) {
  4728. removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
  4729. }
  4730. }
  4731. function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
  4732. if (oldVnode === vnode) {
  4733. return
  4734. }
  4735. var elm = vnode.elm = oldVnode.elm;
  4736. if (isTrue(oldVnode.isAsyncPlaceholder)) {
  4737. if (isDef(vnode.asyncFactory.resolved)) {
  4738. hydrate(oldVnode.elm, vnode, insertedVnodeQueue);
  4739. } else {
  4740. vnode.isAsyncPlaceholder = true;
  4741. }
  4742. return
  4743. }
  4744. // reuse element for static trees.
  4745. // note we only do this if the vnode is cloned -
  4746. // if the new node is not cloned it means the render functions have been
  4747. // reset by the hot-reload-api and we need to do a proper re-render.
  4748. if (isTrue(vnode.isStatic) &&
  4749. isTrue(oldVnode.isStatic) &&
  4750. vnode.key === oldVnode.key &&
  4751. (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))
  4752. ) {
  4753. vnode.componentInstance = oldVnode.componentInstance;
  4754. return
  4755. }
  4756. var i;
  4757. var data = vnode.data;
  4758. if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) {
  4759. i(oldVnode, vnode);
  4760. }
  4761. var oldCh = oldVnode.children;
  4762. var ch = vnode.children;
  4763. if (isDef(data) && isPatchable(vnode)) {
  4764. for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
  4765. if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
  4766. }
  4767. if (isUndef(vnode.text)) {
  4768. if (isDef(oldCh) && isDef(ch)) {
  4769. if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
  4770. } else if (isDef(ch)) {
  4771. if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
  4772. addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
  4773. } else if (isDef(oldCh)) {
  4774. removeVnodes(elm, oldCh, 0, oldCh.length - 1);
  4775. } else if (isDef(oldVnode.text)) {
  4776. nodeOps.setTextContent(elm, '');
  4777. }
  4778. } else if (oldVnode.text !== vnode.text) {
  4779. nodeOps.setTextContent(elm, vnode.text);
  4780. }
  4781. if (isDef(data)) {
  4782. if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
  4783. }
  4784. }
  4785. function invokeInsertHook (vnode, queue, initial) {
  4786. // delay insert hooks for component root nodes, invoke them after the
  4787. // element is really inserted
  4788. if (isTrue(initial) && isDef(vnode.parent)) {
  4789. vnode.parent.data.pendingInsert = queue;
  4790. } else {
  4791. for (var i = 0; i < queue.length; ++i) {
  4792. queue[i].data.hook.insert(queue[i]);
  4793. }
  4794. }
  4795. }
  4796. var bailed = false;
  4797. // list of modules that can skip create hook during hydration because they
  4798. // are already rendered on the client or has no need for initialization
  4799. var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key');
  4800. // Note: this is a browser-only function so we can assume elms are DOM nodes.
  4801. function hydrate (elm, vnode, insertedVnodeQueue) {
  4802. if (isTrue(vnode.isComment) && isDef(vnode.asyncFactory)) {
  4803. vnode.elm = elm;
  4804. vnode.isAsyncPlaceholder = true;
  4805. return true
  4806. }
  4807. if (process.env.NODE_ENV !== 'production') {
  4808. if (!assertNodeMatch(elm, vnode)) {
  4809. return false
  4810. }
  4811. }
  4812. vnode.elm = elm;
  4813. var tag = vnode.tag;
  4814. var data = vnode.data;
  4815. var children = vnode.children;
  4816. if (isDef(data)) {
  4817. if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
  4818. if (isDef(i = vnode.componentInstance)) {
  4819. // child component. it should have hydrated its own tree.
  4820. initComponent(vnode, insertedVnodeQueue);
  4821. return true
  4822. }
  4823. }
  4824. if (isDef(tag)) {
  4825. if (isDef(children)) {
  4826. // empty element, allow client to pick up and populate children
  4827. if (!elm.hasChildNodes()) {
  4828. createChildren(vnode, children, insertedVnodeQueue);
  4829. } else {
  4830. var childrenMatch = true;
  4831. var childNode = elm.firstChild;
  4832. for (var i$1 = 0; i$1 < children.length; i$1++) {
  4833. if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
  4834. childrenMatch = false;
  4835. break
  4836. }
  4837. childNode = childNode.nextSibling;
  4838. }
  4839. // if childNode is not null, it means the actual childNodes list is
  4840. // longer than the virtual children list.
  4841. if (!childrenMatch || childNode) {
  4842. if (process.env.NODE_ENV !== 'production' &&
  4843. typeof console !== 'undefined' &&
  4844. !bailed
  4845. ) {
  4846. bailed = true;
  4847. console.warn('Parent: ', elm);
  4848. console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
  4849. }
  4850. return false
  4851. }
  4852. }
  4853. }
  4854. if (isDef(data)) {
  4855. for (var key in data) {
  4856. if (!isRenderedModule(key)) {
  4857. invokeCreateHooks(vnode, insertedVnodeQueue);
  4858. break
  4859. }
  4860. }
  4861. }
  4862. } else if (elm.data !== vnode.text) {
  4863. elm.data = vnode.text;
  4864. }
  4865. return true
  4866. }
  4867. function assertNodeMatch (node, vnode) {
  4868. if (isDef(vnode.tag)) {
  4869. return (
  4870. vnode.tag.indexOf('vue-component') === 0 ||
  4871. vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
  4872. )
  4873. } else {
  4874. return node.nodeType === (vnode.isComment ? 8 : 3)
  4875. }
  4876. }
  4877. return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
  4878. if (isUndef(vnode)) {
  4879. if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); }
  4880. return
  4881. }
  4882. var isInitialPatch = false;
  4883. var insertedVnodeQueue = [];
  4884. if (isUndef(oldVnode)) {
  4885. // empty mount (likely as component), create new root element
  4886. isInitialPatch = true;
  4887. createElm(vnode, insertedVnodeQueue, parentElm, refElm);
  4888. } else {
  4889. var isRealElement = isDef(oldVnode.nodeType);
  4890. if (!isRealElement && sameVnode(oldVnode, vnode)) {
  4891. // patch existing root node
  4892. patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
  4893. } else {
  4894. if (isRealElement) {
  4895. // mounting to a real element
  4896. // check if this is server-rendered content and if we can perform
  4897. // a successful hydration.
  4898. if (oldVnode.nodeType === 1 && oldVnode.hasAttribute(SSR_ATTR)) {
  4899. oldVnode.removeAttribute(SSR_ATTR);
  4900. hydrating = true;
  4901. }
  4902. if (isTrue(hydrating)) {
  4903. if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
  4904. invokeInsertHook(vnode, insertedVnodeQueue, true);
  4905. return oldVnode
  4906. } else if (process.env.NODE_ENV !== 'production') {
  4907. warn(
  4908. 'The client-side rendered virtual DOM tree is not matching ' +
  4909. 'server-rendered content. This is likely caused by incorrect ' +
  4910. 'HTML markup, for example nesting block-level elements inside ' +
  4911. '<p>, or missing <tbody>. Bailing hydration and performing ' +
  4912. 'full client-side render.'
  4913. );
  4914. }
  4915. }
  4916. // either not server-rendered, or hydration failed.
  4917. // create an empty node and replace it
  4918. oldVnode = emptyNodeAt(oldVnode);
  4919. }
  4920. // replacing existing element
  4921. var oldElm = oldVnode.elm;
  4922. var parentElm$1 = nodeOps.parentNode(oldElm);
  4923. createElm(
  4924. vnode,
  4925. insertedVnodeQueue,
  4926. // extremely rare edge case: do not insert if old element is in a
  4927. // leaving transition. Only happens when combining transition +
  4928. // keep-alive + HOCs. (#4590)
  4929. oldElm._leaveCb ? null : parentElm$1,
  4930. nodeOps.nextSibling(oldElm)
  4931. );
  4932. if (isDef(vnode.parent)) {
  4933. // component root element replaced.
  4934. // update parent placeholder node element, recursively
  4935. var ancestor = vnode.parent;
  4936. while (ancestor) {
  4937. ancestor.elm = vnode.elm;
  4938. ancestor = ancestor.parent;
  4939. }
  4940. if (isPatchable(vnode)) {
  4941. for (var i = 0; i < cbs.create.length; ++i) {
  4942. cbs.create[i](emptyNode, vnode.parent);
  4943. }
  4944. }
  4945. }
  4946. if (isDef(parentElm$1)) {
  4947. removeVnodes(parentElm$1, [oldVnode], 0, 0);
  4948. } else if (isDef(oldVnode.tag)) {
  4949. invokeDestroyHook(oldVnode);
  4950. }
  4951. }
  4952. }
  4953. invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
  4954. return vnode.elm
  4955. }
  4956. }
  4957. /* */
  4958. var directives = {
  4959. create: updateDirectives,
  4960. update: updateDirectives,
  4961. destroy: function unbindDirectives (vnode) {
  4962. updateDirectives(vnode, emptyNode);
  4963. }
  4964. };
  4965. function updateDirectives (oldVnode, vnode) {
  4966. if (oldVnode.data.directives || vnode.data.directives) {
  4967. _update(oldVnode, vnode);
  4968. }
  4969. }
  4970. function _update (oldVnode, vnode) {
  4971. var isCreate = oldVnode === emptyNode;
  4972. var isDestroy = vnode === emptyNode;
  4973. var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
  4974. var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
  4975. var dirsWithInsert = [];
  4976. var dirsWithPostpatch = [];
  4977. var key, oldDir, dir;
  4978. for (key in newDirs) {
  4979. oldDir = oldDirs[key];
  4980. dir = newDirs[key];
  4981. if (!oldDir) {
  4982. // new directive, bind
  4983. callHook$1(dir, 'bind', vnode, oldVnode);
  4984. if (dir.def && dir.def.inserted) {
  4985. dirsWithInsert.push(dir);
  4986. }
  4987. } else {
  4988. // existing directive, update
  4989. dir.oldValue = oldDir.value;
  4990. callHook$1(dir, 'update', vnode, oldVnode);
  4991. if (dir.def && dir.def.componentUpdated) {
  4992. dirsWithPostpatch.push(dir);
  4993. }
  4994. }
  4995. }
  4996. if (dirsWithInsert.length) {
  4997. var callInsert = function () {
  4998. for (var i = 0; i < dirsWithInsert.length; i++) {
  4999. callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
  5000. }
  5001. };
  5002. if (isCreate) {
  5003. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert);
  5004. } else {
  5005. callInsert();
  5006. }
  5007. }
  5008. if (dirsWithPostpatch.length) {
  5009. mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
  5010. for (var i = 0; i < dirsWithPostpatch.length; i++) {
  5011. callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
  5012. }
  5013. });
  5014. }
  5015. if (!isCreate) {
  5016. for (key in oldDirs) {
  5017. if (!newDirs[key]) {
  5018. // no longer present, unbind
  5019. callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
  5020. }
  5021. }
  5022. }
  5023. }
  5024. var emptyModifiers = Object.create(null);
  5025. function normalizeDirectives$1 (
  5026. dirs,
  5027. vm
  5028. ) {
  5029. var res = Object.create(null);
  5030. if (!dirs) {
  5031. return res
  5032. }
  5033. var i, dir;
  5034. for (i = 0; i < dirs.length; i++) {
  5035. dir = dirs[i];
  5036. if (!dir.modifiers) {
  5037. dir.modifiers = emptyModifiers;
  5038. }
  5039. res[getRawDirName(dir)] = dir;
  5040. dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
  5041. }
  5042. return res
  5043. }
  5044. function getRawDirName (dir) {
  5045. return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
  5046. }
  5047. function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
  5048. var fn = dir.def && dir.def[hook];
  5049. if (fn) {
  5050. try {
  5051. fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
  5052. } catch (e) {
  5053. handleError(e, vnode.context, ("directive " + (dir.name) + " " + hook + " hook"));
  5054. }
  5055. }
  5056. }
  5057. var baseModules = [
  5058. ref,
  5059. directives
  5060. ];
  5061. /* */
  5062. function updateAttrs (oldVnode, vnode) {
  5063. if (!oldVnode.data.attrs && !vnode.data.attrs) {
  5064. return
  5065. }
  5066. var key, cur, old;
  5067. var elm = vnode.elm;
  5068. var oldAttrs = oldVnode.data.attrs || {};
  5069. var attrs = vnode.data.attrs || {};
  5070. // clone observed objects, as the user probably wants to mutate it
  5071. if (attrs.__ob__) {
  5072. attrs = vnode.data.attrs = extend({}, attrs);
  5073. }
  5074. for (key in attrs) {
  5075. cur = attrs[key];
  5076. old = oldAttrs[key];
  5077. if (old !== cur) {
  5078. elm.setAttr(key, cur);
  5079. }
  5080. }
  5081. for (key in oldAttrs) {
  5082. if (attrs[key] == null) {
  5083. elm.setAttr(key);
  5084. }
  5085. }
  5086. }
  5087. var attrs = {
  5088. create: updateAttrs,
  5089. update: updateAttrs
  5090. };
  5091. /* */
  5092. function updateClass (oldVnode, vnode) {
  5093. var el = vnode.elm;
  5094. var ctx = vnode.context;
  5095. var data = vnode.data;
  5096. var oldData = oldVnode.data;
  5097. if (!data.staticClass &&
  5098. !data.class &&
  5099. (!oldData || (!oldData.staticClass && !oldData.class))
  5100. ) {
  5101. return
  5102. }
  5103. var oldClassList = [];
  5104. // unlike web, weex vnode staticClass is an Array
  5105. var oldStaticClass = oldData.staticClass;
  5106. if (oldStaticClass) {
  5107. oldClassList.push.apply(oldClassList, oldStaticClass);
  5108. }
  5109. if (oldData.class) {
  5110. oldClassList.push.apply(oldClassList, oldData.class);
  5111. }
  5112. var classList = [];
  5113. // unlike web, weex vnode staticClass is an Array
  5114. var staticClass = data.staticClass;
  5115. if (staticClass) {
  5116. classList.push.apply(classList, staticClass);
  5117. }
  5118. if (data.class) {
  5119. classList.push.apply(classList, data.class);
  5120. }
  5121. var style = getStyle(oldClassList, classList, ctx);
  5122. for (var key in style) {
  5123. el.setStyle(key, style[key]);
  5124. }
  5125. }
  5126. function getStyle (oldClassList, classList, ctx) {
  5127. // style is a weex-only injected object
  5128. // compiled from <style> tags in weex files
  5129. var stylesheet = ctx.$options.style || {};
  5130. var result = {};
  5131. classList.forEach(function (name) {
  5132. var style = stylesheet[name];
  5133. extend(result, style);
  5134. });
  5135. oldClassList.forEach(function (name) {
  5136. var style = stylesheet[name];
  5137. for (var key in style) {
  5138. if (!result.hasOwnProperty(key)) {
  5139. result[key] = '';
  5140. }
  5141. }
  5142. });
  5143. return result
  5144. }
  5145. var klass = {
  5146. create: updateClass,
  5147. update: updateClass
  5148. };
  5149. /* */
  5150. var target$1;
  5151. function add$1 (
  5152. event,
  5153. handler,
  5154. once,
  5155. capture
  5156. ) {
  5157. if (capture) {
  5158. console.log('Weex do not support event in bubble phase.');
  5159. return
  5160. }
  5161. if (once) {
  5162. var oldHandler = handler;
  5163. var _target = target$1; // save current target element in closure
  5164. handler = function (ev) {
  5165. var res = arguments.length === 1
  5166. ? oldHandler(ev)
  5167. : oldHandler.apply(null, arguments);
  5168. if (res !== null) {
  5169. remove$2(event, null, null, _target);
  5170. }
  5171. };
  5172. }
  5173. target$1.addEvent(event, handler);
  5174. }
  5175. function remove$2 (
  5176. event,
  5177. handler,
  5178. capture,
  5179. _target
  5180. ) {
  5181. (_target || target$1).removeEvent(event);
  5182. }
  5183. function updateDOMListeners (oldVnode, vnode) {
  5184. if (!oldVnode.data.on && !vnode.data.on) {
  5185. return
  5186. }
  5187. var on = vnode.data.on || {};
  5188. var oldOn = oldVnode.data.on || {};
  5189. target$1 = vnode.elm;
  5190. updateListeners(on, oldOn, add$1, remove$2, vnode.context);
  5191. }
  5192. var events = {
  5193. create: updateDOMListeners,
  5194. update: updateDOMListeners
  5195. };
  5196. /* */
  5197. var normalize = cached(camelize);
  5198. function createStyle (oldVnode, vnode) {
  5199. if (!vnode.data.staticStyle) {
  5200. updateStyle(oldVnode, vnode);
  5201. return
  5202. }
  5203. var elm = vnode.elm;
  5204. var staticStyle = vnode.data.staticStyle;
  5205. for (var name in staticStyle) {
  5206. if (staticStyle[name]) {
  5207. elm.setStyle(normalize(name), staticStyle[name]);
  5208. }
  5209. }
  5210. updateStyle(oldVnode, vnode);
  5211. }
  5212. function updateStyle (oldVnode, vnode) {
  5213. if (!oldVnode.data.style && !vnode.data.style) {
  5214. return
  5215. }
  5216. var cur, name;
  5217. var elm = vnode.elm;
  5218. var oldStyle = oldVnode.data.style || {};
  5219. var style = vnode.data.style || {};
  5220. var needClone = style.__ob__;
  5221. // handle array syntax
  5222. if (Array.isArray(style)) {
  5223. style = vnode.data.style = toObject$1(style);
  5224. }
  5225. // clone the style for future updates,
  5226. // in case the user mutates the style object in-place.
  5227. if (needClone) {
  5228. style = vnode.data.style = extend({}, style);
  5229. }
  5230. for (name in oldStyle) {
  5231. if (!style[name]) {
  5232. elm.setStyle(normalize(name), '');
  5233. }
  5234. }
  5235. for (name in style) {
  5236. cur = style[name];
  5237. elm.setStyle(normalize(name), cur);
  5238. }
  5239. }
  5240. function toObject$1 (arr) {
  5241. var res = {};
  5242. for (var i = 0; i < arr.length; i++) {
  5243. if (arr[i]) {
  5244. extend(res, arr[i]);
  5245. }
  5246. }
  5247. return res
  5248. }
  5249. var style = {
  5250. create: createStyle,
  5251. update: updateStyle
  5252. };
  5253. /* */
  5254. /**
  5255. * Add class with compatibility for SVG since classList is not supported on
  5256. * SVG elements in IE
  5257. */
  5258. /**
  5259. * Remove class with compatibility for SVG since classList is not supported on
  5260. * SVG elements in IE
  5261. */
  5262. /* */
  5263. function resolveTransition (def$$1) {
  5264. if (!def$$1) {
  5265. return
  5266. }
  5267. /* istanbul ignore else */
  5268. if (typeof def$$1 === 'object') {
  5269. var res = {};
  5270. if (def$$1.css !== false) {
  5271. extend(res, autoCssTransition(def$$1.name || 'v'));
  5272. }
  5273. extend(res, def$$1);
  5274. return res
  5275. } else if (typeof def$$1 === 'string') {
  5276. return autoCssTransition(def$$1)
  5277. }
  5278. }
  5279. var autoCssTransition = cached(function (name) {
  5280. return {
  5281. enterClass: (name + "-enter"),
  5282. enterToClass: (name + "-enter-to"),
  5283. enterActiveClass: (name + "-enter-active"),
  5284. leaveClass: (name + "-leave"),
  5285. leaveToClass: (name + "-leave-to"),
  5286. leaveActiveClass: (name + "-leave-active")
  5287. }
  5288. });
  5289. // Transition property/event sniffing
  5290. // binding to window is necessary to make hot reload work in IE in strict mode
  5291. var raf = inBrowser && window.requestAnimationFrame
  5292. ? window.requestAnimationFrame.bind(window)
  5293. : setTimeout;
  5294. var transition = {
  5295. create: enter,
  5296. activate: enter,
  5297. remove: leave
  5298. };
  5299. function enter (_, vnode) {
  5300. var el = vnode.elm;
  5301. // call leave callback now
  5302. if (el._leaveCb) {
  5303. el._leaveCb.cancelled = true;
  5304. el._leaveCb();
  5305. }
  5306. var data = resolveTransition(vnode.data.transition);
  5307. if (!data) {
  5308. return
  5309. }
  5310. /* istanbul ignore if */
  5311. if (el._enterCb) {
  5312. return
  5313. }
  5314. var enterClass = data.enterClass;
  5315. var enterToClass = data.enterToClass;
  5316. var enterActiveClass = data.enterActiveClass;
  5317. var appearClass = data.appearClass;
  5318. var appearToClass = data.appearToClass;
  5319. var appearActiveClass = data.appearActiveClass;
  5320. var beforeEnter = data.beforeEnter;
  5321. var enter = data.enter;
  5322. var afterEnter = data.afterEnter;
  5323. var enterCancelled = data.enterCancelled;
  5324. var beforeAppear = data.beforeAppear;
  5325. var appear = data.appear;
  5326. var afterAppear = data.afterAppear;
  5327. var appearCancelled = data.appearCancelled;
  5328. var context = activeInstance;
  5329. var transitionNode = activeInstance.$vnode;
  5330. while (transitionNode && transitionNode.parent) {
  5331. transitionNode = transitionNode.parent;
  5332. context = transitionNode.context;
  5333. }
  5334. var isAppear = !context._isMounted || !vnode.isRootInsert;
  5335. if (isAppear && !appear && appear !== '') {
  5336. return
  5337. }
  5338. var startClass = isAppear ? appearClass : enterClass;
  5339. var toClass = isAppear ? appearToClass : enterToClass;
  5340. var activeClass = isAppear ? appearActiveClass : enterActiveClass;
  5341. var beforeEnterHook = isAppear ? (beforeAppear || beforeEnter) : beforeEnter;
  5342. var enterHook = isAppear ? (typeof appear === 'function' ? appear : enter) : enter;
  5343. var afterEnterHook = isAppear ? (afterAppear || afterEnter) : afterEnter;
  5344. var enterCancelledHook = isAppear ? (appearCancelled || enterCancelled) : enterCancelled;
  5345. var userWantsControl =
  5346. enterHook &&
  5347. // enterHook may be a bound method which exposes
  5348. // the length of original fn as _length
  5349. (enterHook._length || enterHook.length) > 1;
  5350. var stylesheet = vnode.context.$options.style || {};
  5351. var startState = stylesheet[startClass];
  5352. var transitionProperties = (stylesheet['@TRANSITION'] && stylesheet['@TRANSITION'][activeClass]) || {};
  5353. var endState = getEnterTargetState(el, stylesheet, startClass, toClass, activeClass, vnode.context);
  5354. var needAnimation = Object.keys(endState).length > 0;
  5355. var cb = el._enterCb = once(function () {
  5356. if (cb.cancelled) {
  5357. enterCancelledHook && enterCancelledHook(el);
  5358. } else {
  5359. afterEnterHook && afterEnterHook(el);
  5360. }
  5361. el._enterCb = null;
  5362. });
  5363. // We need to wait until the native element has been inserted, but currently
  5364. // there's no API to do that. So we have to wait "one frame" - not entirely
  5365. // sure if this is guaranteed to be enough (e.g. on slow devices?)
  5366. setTimeout(function () {
  5367. var parent = el.parentNode;
  5368. var pendingNode = parent && parent._pending && parent._pending[vnode.key];
  5369. if (pendingNode &&
  5370. pendingNode.context === vnode.context &&
  5371. pendingNode.tag === vnode.tag &&
  5372. pendingNode.elm._leaveCb
  5373. ) {
  5374. pendingNode.elm._leaveCb();
  5375. }
  5376. enterHook && enterHook(el, cb);
  5377. if (needAnimation) {
  5378. var animation = vnode.context.$requireWeexModule('animation');
  5379. animation.transition(el.ref, {
  5380. styles: endState,
  5381. duration: transitionProperties.duration || 0,
  5382. delay: transitionProperties.delay || 0,
  5383. timingFunction: transitionProperties.timingFunction || 'linear'
  5384. }, userWantsControl ? noop : cb);
  5385. } else if (!userWantsControl) {
  5386. cb();
  5387. }
  5388. }, 16);
  5389. // start enter transition
  5390. beforeEnterHook && beforeEnterHook(el);
  5391. if (startState) {
  5392. for (var key in startState) {
  5393. el.setStyle(key, startState[key]);
  5394. }
  5395. }
  5396. if (!needAnimation && !userWantsControl) {
  5397. cb();
  5398. }
  5399. }
  5400. function leave (vnode, rm) {
  5401. var el = vnode.elm;
  5402. // call enter callback now
  5403. if (el._enterCb) {
  5404. el._enterCb.cancelled = true;
  5405. el._enterCb();
  5406. }
  5407. var data = resolveTransition(vnode.data.transition);
  5408. if (!data) {
  5409. return rm()
  5410. }
  5411. if (el._leaveCb) {
  5412. return
  5413. }
  5414. var leaveClass = data.leaveClass;
  5415. var leaveToClass = data.leaveToClass;
  5416. var leaveActiveClass = data.leaveActiveClass;
  5417. var beforeLeave = data.beforeLeave;
  5418. var leave = data.leave;
  5419. var afterLeave = data.afterLeave;
  5420. var leaveCancelled = data.leaveCancelled;
  5421. var delayLeave = data.delayLeave;
  5422. var userWantsControl =
  5423. leave &&
  5424. // leave hook may be a bound method which exposes
  5425. // the length of original fn as _length
  5426. (leave._length || leave.length) > 1;
  5427. var stylesheet = vnode.context.$options.style || {};
  5428. var startState = stylesheet[leaveClass];
  5429. var endState = stylesheet[leaveToClass] || stylesheet[leaveActiveClass];
  5430. var transitionProperties = (stylesheet['@TRANSITION'] && stylesheet['@TRANSITION'][leaveActiveClass]) || {};
  5431. var cb = el._leaveCb = once(function () {
  5432. if (el.parentNode && el.parentNode._pending) {
  5433. el.parentNode._pending[vnode.key] = null;
  5434. }
  5435. if (cb.cancelled) {
  5436. leaveCancelled && leaveCancelled(el);
  5437. } else {
  5438. rm();
  5439. afterLeave && afterLeave(el);
  5440. }
  5441. el._leaveCb = null;
  5442. });
  5443. if (delayLeave) {
  5444. delayLeave(performLeave);
  5445. } else {
  5446. performLeave();
  5447. }
  5448. function performLeave () {
  5449. var animation = vnode.context.$requireWeexModule('animation');
  5450. // the delayed leave may have already been cancelled
  5451. if (cb.cancelled) {
  5452. return
  5453. }
  5454. // record leaving element
  5455. if (!vnode.data.show) {
  5456. (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode;
  5457. }
  5458. beforeLeave && beforeLeave(el);
  5459. if (startState) {
  5460. animation.transition(el.ref, {
  5461. styles: startState
  5462. }, next);
  5463. } else {
  5464. next();
  5465. }
  5466. function next () {
  5467. animation.transition(el.ref, {
  5468. styles: endState,
  5469. duration: transitionProperties.duration || 0,
  5470. delay: transitionProperties.delay || 0,
  5471. timingFunction: transitionProperties.timingFunction || 'linear'
  5472. }, userWantsControl ? noop : cb);
  5473. }
  5474. leave && leave(el, cb);
  5475. if (!endState && !userWantsControl) {
  5476. cb();
  5477. }
  5478. }
  5479. }
  5480. // determine the target animation style for an entering transition.
  5481. function getEnterTargetState (el, stylesheet, startClass, endClass, activeClass, vm) {
  5482. var targetState = {};
  5483. var startState = stylesheet[startClass];
  5484. var endState = stylesheet[endClass];
  5485. var activeState = stylesheet[activeClass];
  5486. // 1. fallback to element's default styling
  5487. if (startState) {
  5488. for (var key in startState) {
  5489. targetState[key] = el.style[key];
  5490. if (
  5491. process.env.NODE_ENV !== 'production' &&
  5492. targetState[key] == null &&
  5493. (!activeState || activeState[key] == null) &&
  5494. (!endState || endState[key] == null)
  5495. ) {
  5496. warn(
  5497. "transition property \"" + key + "\" is declared in enter starting class (." + startClass + "), " +
  5498. "but not declared anywhere in enter ending class (." + endClass + "), " +
  5499. "enter active cass (." + activeClass + ") or the element's default styling. " +
  5500. "Note in Weex, CSS properties need explicit values to be transitionable."
  5501. );
  5502. }
  5503. }
  5504. }
  5505. // 2. if state is mixed in active state, extract them while excluding
  5506. // transition properties
  5507. if (activeState) {
  5508. for (var key$1 in activeState) {
  5509. if (key$1.indexOf('transition') !== 0) {
  5510. targetState[key$1] = activeState[key$1];
  5511. }
  5512. }
  5513. }
  5514. // 3. explicit endState has highest priority
  5515. if (endState) {
  5516. extend(targetState, endState);
  5517. }
  5518. return targetState
  5519. }
  5520. var platformModules = [
  5521. attrs,
  5522. klass,
  5523. events,
  5524. style,
  5525. transition
  5526. ];
  5527. /* */
  5528. // the directive module should be applied last, after all
  5529. // built-in modules have been applied.
  5530. var modules = platformModules.concat(baseModules);
  5531. var patch = createPatchFunction({
  5532. nodeOps: nodeOps,
  5533. modules: modules,
  5534. LONG_LIST_THRESHOLD: 10
  5535. });
  5536. var platformDirectives = {
  5537. };
  5538. /* */
  5539. // Provides transition support for a single element/component.
  5540. // supports transition mode (out-in / in-out)
  5541. var transitionProps = {
  5542. name: String,
  5543. appear: Boolean,
  5544. css: Boolean,
  5545. mode: String,
  5546. type: String,
  5547. enterClass: String,
  5548. leaveClass: String,
  5549. enterToClass: String,
  5550. leaveToClass: String,
  5551. enterActiveClass: String,
  5552. leaveActiveClass: String,
  5553. appearClass: String,
  5554. appearActiveClass: String,
  5555. appearToClass: String,
  5556. duration: [Number, String, Object]
  5557. };
  5558. // in case the child is also an abstract component, e.g. <keep-alive>
  5559. // we want to recursively retrieve the real component to be rendered
  5560. function getRealChild (vnode) {
  5561. var compOptions = vnode && vnode.componentOptions;
  5562. if (compOptions && compOptions.Ctor.options.abstract) {
  5563. return getRealChild(getFirstComponentChild(compOptions.children))
  5564. } else {
  5565. return vnode
  5566. }
  5567. }
  5568. function extractTransitionData (comp) {
  5569. var data = {};
  5570. var options = comp.$options;
  5571. // props
  5572. for (var key in options.propsData) {
  5573. data[key] = comp[key];
  5574. }
  5575. // events.
  5576. // extract listeners and pass them directly to the transition methods
  5577. var listeners = options._parentListeners;
  5578. for (var key$1 in listeners) {
  5579. data[camelize(key$1)] = listeners[key$1];
  5580. }
  5581. return data
  5582. }
  5583. function placeholder (h, rawChild) {
  5584. if (/\d-keep-alive$/.test(rawChild.tag)) {
  5585. return h('keep-alive', {
  5586. props: rawChild.componentOptions.propsData
  5587. })
  5588. }
  5589. }
  5590. function hasParentTransition (vnode) {
  5591. while ((vnode = vnode.parent)) {
  5592. if (vnode.data.transition) {
  5593. return true
  5594. }
  5595. }
  5596. }
  5597. function isSameChild (child, oldChild) {
  5598. return oldChild.key === child.key && oldChild.tag === child.tag
  5599. }
  5600. function isAsyncPlaceholder (node) {
  5601. return node.isComment && node.asyncFactory
  5602. }
  5603. var Transition$1 = {
  5604. name: 'transition',
  5605. props: transitionProps,
  5606. abstract: true,
  5607. render: function render (h) {
  5608. var this$1 = this;
  5609. var children = this.$options._renderChildren;
  5610. if (!children) {
  5611. return
  5612. }
  5613. // filter out text nodes (possible whitespaces)
  5614. children = children.filter(function (c) { return c.tag || isAsyncPlaceholder(c); });
  5615. /* istanbul ignore if */
  5616. if (!children.length) {
  5617. return
  5618. }
  5619. // warn multiple elements
  5620. if (process.env.NODE_ENV !== 'production' && children.length > 1) {
  5621. warn(
  5622. '<transition> can only be used on a single element. Use ' +
  5623. '<transition-group> for lists.',
  5624. this.$parent
  5625. );
  5626. }
  5627. var mode = this.mode;
  5628. // warn invalid mode
  5629. if (process.env.NODE_ENV !== 'production' &&
  5630. mode && mode !== 'in-out' && mode !== 'out-in'
  5631. ) {
  5632. warn(
  5633. 'invalid <transition> mode: ' + mode,
  5634. this.$parent
  5635. );
  5636. }
  5637. var rawChild = children[0];
  5638. // if this is a component root node and the component's
  5639. // parent container node also has transition, skip.
  5640. if (hasParentTransition(this.$vnode)) {
  5641. return rawChild
  5642. }
  5643. // apply transition data to child
  5644. // use getRealChild() to ignore abstract components e.g. keep-alive
  5645. var child = getRealChild(rawChild);
  5646. /* istanbul ignore if */
  5647. if (!child) {
  5648. return rawChild
  5649. }
  5650. if (this._leaving) {
  5651. return placeholder(h, rawChild)
  5652. }
  5653. // ensure a key that is unique to the vnode type and to this transition
  5654. // component instance. This key will be used to remove pending leaving nodes
  5655. // during entering.
  5656. var id = "__transition-" + (this._uid) + "-";
  5657. child.key = child.key == null
  5658. ? child.isComment
  5659. ? id + 'comment'
  5660. : id + child.tag
  5661. : isPrimitive(child.key)
  5662. ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key)
  5663. : child.key;
  5664. var data = (child.data || (child.data = {})).transition = extractTransitionData(this);
  5665. var oldRawChild = this._vnode;
  5666. var oldChild = getRealChild(oldRawChild);
  5667. // mark v-show
  5668. // so that the transition module can hand over the control to the directive
  5669. if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) {
  5670. child.data.show = true;
  5671. }
  5672. if (
  5673. oldChild &&
  5674. oldChild.data &&
  5675. !isSameChild(child, oldChild) &&
  5676. !isAsyncPlaceholder(oldChild)
  5677. ) {
  5678. // replace old child transition data with fresh one
  5679. // important for dynamic transitions!
  5680. var oldData = oldChild && (oldChild.data.transition = extend({}, data));
  5681. // handle transition mode
  5682. if (mode === 'out-in') {
  5683. // return placeholder node and queue update when leave finishes
  5684. this._leaving = true;
  5685. mergeVNodeHook(oldData, 'afterLeave', function () {
  5686. this$1._leaving = false;
  5687. this$1.$forceUpdate();
  5688. });
  5689. return placeholder(h, rawChild)
  5690. } else if (mode === 'in-out') {
  5691. if (isAsyncPlaceholder(child)) {
  5692. return oldRawChild
  5693. }
  5694. var delayedLeave;
  5695. var performLeave = function () { delayedLeave(); };
  5696. mergeVNodeHook(data, 'afterEnter', performLeave);
  5697. mergeVNodeHook(data, 'enterCancelled', performLeave);
  5698. mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; });
  5699. }
  5700. }
  5701. return rawChild
  5702. }
  5703. };
  5704. // reuse same transition component logic from web
  5705. var props = extend({
  5706. tag: String,
  5707. moveClass: String
  5708. }, transitionProps);
  5709. delete props.mode;
  5710. var TransitionGroup = {
  5711. props: props,
  5712. created: function created () {
  5713. var dom = this.$requireWeexModule('dom');
  5714. this.getPosition = function (el) { return new Promise(function (resolve, reject) {
  5715. dom.getComponentRect(el.ref, function (res) {
  5716. if (!res.result) {
  5717. reject(new Error(("failed to get rect for element: " + (el.tag))));
  5718. } else {
  5719. resolve(res.size);
  5720. }
  5721. });
  5722. }); };
  5723. var animation = this.$requireWeexModule('animation');
  5724. this.animate = function (el, options) { return new Promise(function (resolve) {
  5725. animation.transition(el.ref, options, resolve);
  5726. }); };
  5727. },
  5728. render: function render (h) {
  5729. var tag = this.tag || this.$vnode.data.tag || 'span';
  5730. var map = Object.create(null);
  5731. var prevChildren = this.prevChildren = this.children;
  5732. var rawChildren = this.$slots.default || [];
  5733. var children = this.children = [];
  5734. var transitionData = extractTransitionData(this);
  5735. for (var i = 0; i < rawChildren.length; i++) {
  5736. var c = rawChildren[i];
  5737. if (c.tag) {
  5738. if (c.key != null && String(c.key).indexOf('__vlist') !== 0) {
  5739. children.push(c);
  5740. map[c.key] = c
  5741. ;(c.data || (c.data = {})).transition = transitionData;
  5742. } else if (process.env.NODE_ENV !== 'production') {
  5743. var opts = c.componentOptions;
  5744. var name = opts
  5745. ? (opts.Ctor.options.name || opts.tag)
  5746. : c.tag;
  5747. warn(("<transition-group> children must be keyed: <" + name + ">"));
  5748. }
  5749. }
  5750. }
  5751. if (prevChildren) {
  5752. var kept = [];
  5753. var removed = [];
  5754. prevChildren.forEach(function (c) {
  5755. c.data.transition = transitionData;
  5756. // TODO: record before patch positions
  5757. if (map[c.key]) {
  5758. kept.push(c);
  5759. } else {
  5760. removed.push(c);
  5761. }
  5762. });
  5763. this.kept = h(tag, null, kept);
  5764. this.removed = removed;
  5765. }
  5766. return h(tag, null, children)
  5767. },
  5768. beforeUpdate: function beforeUpdate () {
  5769. // force removing pass
  5770. this.__patch__(
  5771. this._vnode,
  5772. this.kept,
  5773. false, // hydrating
  5774. true // removeOnly (!important, avoids unnecessary moves)
  5775. );
  5776. this._vnode = this.kept;
  5777. },
  5778. updated: function updated () {
  5779. var children = this.prevChildren;
  5780. var moveClass = this.moveClass || ((this.name || 'v') + '-move');
  5781. var moveData = children.length && this.getMoveData(children[0].context, moveClass);
  5782. if (!moveData) {
  5783. return
  5784. }
  5785. // TODO: finish implementing move animations once
  5786. // we have access to sync getComponentRect()
  5787. // children.forEach(callPendingCbs)
  5788. // Promise.all(children.map(c => {
  5789. // const oldPos = c.data.pos
  5790. // const newPos = c.data.newPos
  5791. // const dx = oldPos.left - newPos.left
  5792. // const dy = oldPos.top - newPos.top
  5793. // if (dx || dy) {
  5794. // c.data.moved = true
  5795. // return this.animate(c.elm, {
  5796. // styles: {
  5797. // transform: `translate(${dx}px,${dy}px)`
  5798. // }
  5799. // })
  5800. // }
  5801. // })).then(() => {
  5802. // children.forEach(c => {
  5803. // if (c.data.moved) {
  5804. // this.animate(c.elm, {
  5805. // styles: {
  5806. // transform: ''
  5807. // },
  5808. // duration: moveData.duration || 0,
  5809. // delay: moveData.delay || 0,
  5810. // timingFunction: moveData.timingFunction || 'linear'
  5811. // })
  5812. // }
  5813. // })
  5814. // })
  5815. },
  5816. methods: {
  5817. getMoveData: function getMoveData (context, moveClass) {
  5818. var stylesheet = context.$options.style || {};
  5819. return stylesheet['@TRANSITION'] && stylesheet['@TRANSITION'][moveClass]
  5820. }
  5821. }
  5822. };
  5823. // function callPendingCbs (c) {
  5824. // /* istanbul ignore if */
  5825. // if (c.elm._moveCb) {
  5826. // c.elm._moveCb()
  5827. // }
  5828. // /* istanbul ignore if */
  5829. // if (c.elm._enterCb) {
  5830. // c.elm._enterCb()
  5831. // }
  5832. // }
  5833. var platformComponents = {
  5834. Transition: Transition$1,
  5835. TransitionGroup: TransitionGroup
  5836. };
  5837. /* globals renderer */
  5838. var isReservedTag = makeMap(
  5839. 'template,script,style,element,content,slot,link,meta,svg,view,' +
  5840. 'a,div,img,image,text,span,richtext,input,switch,textarea,spinner,select,' +
  5841. 'slider,slider-neighbor,indicator,trisition,trisition-group,canvas,' +
  5842. 'list,cell,header,loading,loading-indicator,refresh,scrollable,scroller,' +
  5843. 'video,web,embed,tabbar,tabheader,datepicker,timepicker,marquee,countdown',
  5844. true
  5845. );
  5846. // Elements that you can, intentionally, leave open (and which close themselves)
  5847. // more flexable than web
  5848. var canBeLeftOpenTag = makeMap(
  5849. 'web,spinner,switch,video,textarea,canvas,' +
  5850. 'indicator,marquee,countdown',
  5851. true
  5852. );
  5853. var isUnaryTag = makeMap(
  5854. 'embed,img,image,input,link,meta',
  5855. true
  5856. );
  5857. function mustUseProp () { /* console.log('mustUseProp') */ }
  5858. function isUnknownElement () { /* console.log('isUnknownElement') */ }
  5859. function query (el, document) {
  5860. // renderer is injected by weex factory wrapper
  5861. var placeholder = new renderer.Comment('root');
  5862. placeholder.hasAttribute = placeholder.removeAttribute = function () {}; // hack for patch
  5863. document.documentElement.appendChild(placeholder);
  5864. return placeholder
  5865. }
  5866. /* */
  5867. // install platform specific utils
  5868. Vue$2.config.mustUseProp = mustUseProp;
  5869. Vue$2.config.isReservedTag = isReservedTag;
  5870. Vue$2.config.isUnknownElement = isUnknownElement;
  5871. // install platform runtime directives and components
  5872. Vue$2.options.directives = platformDirectives;
  5873. Vue$2.options.components = platformComponents;
  5874. // install platform patch function
  5875. Vue$2.prototype.__patch__ = patch;
  5876. // wrap mount
  5877. Vue$2.prototype.$mount = function (
  5878. el,
  5879. hydrating
  5880. ) {
  5881. return mountComponent(
  5882. this,
  5883. el && query(el, this.$document),
  5884. hydrating
  5885. )
  5886. };
  5887. // this entry is built and wrapped with a factory function
  5888. // used to generate a fresh copy of Vue for every Weex instance.
  5889. exports.Vue = Vue$2;
  5890. }