vue.js 265 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030
  1. /*!
  2. * Vue.js v1.0.24
  3. * (c) 2016 Evan You
  4. * Released under the MIT License.
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global.Vue = factory());
  10. }(this, function () { 'use strict';
  11. function set(obj, key, val) {
  12. if (hasOwn(obj, key)) {
  13. obj[key] = val;
  14. return;
  15. }
  16. if (obj._isVue) {
  17. set(obj._data, key, val);
  18. return;
  19. }
  20. var ob = obj.__ob__;
  21. if (!ob) {
  22. obj[key] = val;
  23. return;
  24. }
  25. ob.convert(key, val);
  26. ob.dep.notify();
  27. if (ob.vms) {
  28. var i = ob.vms.length;
  29. while (i--) {
  30. var vm = ob.vms[i];
  31. vm._proxy(key);
  32. vm._digest();
  33. }
  34. }
  35. return val;
  36. }
  37. /**
  38. * Delete a property and trigger change if necessary.
  39. *
  40. * @param {Object} obj
  41. * @param {String} key
  42. */
  43. function del(obj, key) {
  44. if (!hasOwn(obj, key)) {
  45. return;
  46. }
  47. delete obj[key];
  48. var ob = obj.__ob__;
  49. if (!ob) {
  50. if (obj._isVue) {
  51. delete obj._data[key];
  52. obj._digest();
  53. }
  54. return;
  55. }
  56. ob.dep.notify();
  57. if (ob.vms) {
  58. var i = ob.vms.length;
  59. while (i--) {
  60. var vm = ob.vms[i];
  61. vm._unproxy(key);
  62. vm._digest();
  63. }
  64. }
  65. }
  66. var hasOwnProperty = Object.prototype.hasOwnProperty;
  67. /**
  68. * Check whether the object has the property.
  69. *
  70. * @param {Object} obj
  71. * @param {String} key
  72. * @return {Boolean}
  73. */
  74. function hasOwn(obj, key) {
  75. return hasOwnProperty.call(obj, key);
  76. }
  77. /**
  78. * Check if an expression is a literal value.
  79. *
  80. * @param {String} exp
  81. * @return {Boolean}
  82. */
  83. var literalValueRE = /^\s?(true|false|-?[\d\.]+|'[^']*'|"[^"]*")\s?$/;
  84. function isLiteral(exp) {
  85. return literalValueRE.test(exp);
  86. }
  87. /**
  88. * Check if a string starts with $ or _
  89. *
  90. * @param {String} str
  91. * @return {Boolean}
  92. */
  93. function isReserved(str) {
  94. var c = (str + '').charCodeAt(0);
  95. return c === 0x24 || c === 0x5F;
  96. }
  97. /**
  98. * Guard text output, make sure undefined outputs
  99. * empty string
  100. *
  101. * @param {*} value
  102. * @return {String}
  103. */
  104. function _toString(value) {
  105. return value == null ? '' : value.toString();
  106. }
  107. /**
  108. * Check and convert possible numeric strings to numbers
  109. * before setting back to data
  110. *
  111. * @param {*} value
  112. * @return {*|Number}
  113. */
  114. function toNumber(value) {
  115. if (typeof value !== 'string') {
  116. return value;
  117. } else {
  118. var parsed = Number(value);
  119. return isNaN(parsed) ? value : parsed;
  120. }
  121. }
  122. /**
  123. * Convert string boolean literals into real booleans.
  124. *
  125. * @param {*} value
  126. * @return {*|Boolean}
  127. */
  128. function toBoolean(value) {
  129. return value === 'true' ? true : value === 'false' ? false : value;
  130. }
  131. /**
  132. * Strip quotes from a string
  133. *
  134. * @param {String} str
  135. * @return {String | false}
  136. */
  137. function stripQuotes(str) {
  138. var a = str.charCodeAt(0);
  139. var b = str.charCodeAt(str.length - 1);
  140. return a === b && (a === 0x22 || a === 0x27) ? str.slice(1, -1) : str;
  141. }
  142. /**
  143. * Camelize a hyphen-delmited string.
  144. *
  145. * @param {String} str
  146. * @return {String}
  147. */
  148. var camelizeRE = /-(\w)/g;
  149. function camelize(str) {
  150. return str.replace(camelizeRE, toUpper);
  151. }
  152. function toUpper(_, c) {
  153. return c ? c.toUpperCase() : '';
  154. }
  155. /**
  156. * Hyphenate a camelCase string.
  157. *
  158. * @param {String} str
  159. * @return {String}
  160. */
  161. var hyphenateRE = /([a-z\d])([A-Z])/g;
  162. function hyphenate(str) {
  163. return str.replace(hyphenateRE, '$1-$2').toLowerCase();
  164. }
  165. /**
  166. * Converts hyphen/underscore/slash delimitered names into
  167. * camelized classNames.
  168. *
  169. * e.g. my-component => MyComponent
  170. * some_else => SomeElse
  171. * some/comp => SomeComp
  172. *
  173. * @param {String} str
  174. * @return {String}
  175. */
  176. var classifyRE = /(?:^|[-_\/])(\w)/g;
  177. function classify(str) {
  178. return str.replace(classifyRE, toUpper);
  179. }
  180. /**
  181. * Simple bind, faster than native
  182. *
  183. * @param {Function} fn
  184. * @param {Object} ctx
  185. * @return {Function}
  186. */
  187. function bind(fn, ctx) {
  188. return function (a) {
  189. var l = arguments.length;
  190. return l ? l > 1 ? fn.apply(ctx, arguments) : fn.call(ctx, a) : fn.call(ctx);
  191. };
  192. }
  193. /**
  194. * Convert an Array-like object to a real Array.
  195. *
  196. * @param {Array-like} list
  197. * @param {Number} [start] - start index
  198. * @return {Array}
  199. */
  200. function toArray(list, start) {
  201. start = start || 0;
  202. var i = list.length - start;
  203. var ret = new Array(i);
  204. while (i--) {
  205. ret[i] = list[i + start];
  206. }
  207. return ret;
  208. }
  209. /**
  210. * Mix properties into target object.
  211. *
  212. * @param {Object} to
  213. * @param {Object} from
  214. */
  215. function extend(to, from) {
  216. var keys = Object.keys(from);
  217. var i = keys.length;
  218. while (i--) {
  219. to[keys[i]] = from[keys[i]];
  220. }
  221. return to;
  222. }
  223. /**
  224. * Quick object check - this is primarily used to tell
  225. * Objects from primitive values when we know the value
  226. * is a JSON-compliant type.
  227. *
  228. * @param {*} obj
  229. * @return {Boolean}
  230. */
  231. function isObject(obj) {
  232. return obj !== null && typeof obj === 'object';
  233. }
  234. /**
  235. * Strict object type check. Only returns true
  236. * for plain JavaScript objects.
  237. *
  238. * @param {*} obj
  239. * @return {Boolean}
  240. */
  241. var toString = Object.prototype.toString;
  242. var OBJECT_STRING = '[object Object]';
  243. function isPlainObject(obj) {
  244. return toString.call(obj) === OBJECT_STRING;
  245. }
  246. /**
  247. * Array type check.
  248. *
  249. * @param {*} obj
  250. * @return {Boolean}
  251. */
  252. var isArray = Array.isArray;
  253. /**
  254. * Define a property.
  255. *
  256. * @param {Object} obj
  257. * @param {String} key
  258. * @param {*} val
  259. * @param {Boolean} [enumerable]
  260. */
  261. function def(obj, key, val, enumerable) {
  262. Object.defineProperty(obj, key, {
  263. value: val,
  264. enumerable: !!enumerable,
  265. writable: true,
  266. configurable: true
  267. });
  268. }
  269. /**
  270. * Debounce a function so it only gets called after the
  271. * input stops arriving after the given wait period.
  272. *
  273. * @param {Function} func
  274. * @param {Number} wait
  275. * @return {Function} - the debounced function
  276. */
  277. function _debounce(func, wait) {
  278. var timeout, args, context, timestamp, result;
  279. var later = function later() {
  280. var last = Date.now() - timestamp;
  281. if (last < wait && last >= 0) {
  282. timeout = setTimeout(later, wait - last);
  283. } else {
  284. timeout = null;
  285. result = func.apply(context, args);
  286. if (!timeout) context = args = null;
  287. }
  288. };
  289. return function () {
  290. context = this;
  291. args = arguments;
  292. timestamp = Date.now();
  293. if (!timeout) {
  294. timeout = setTimeout(later, wait);
  295. }
  296. return result;
  297. };
  298. }
  299. /**
  300. * Manual indexOf because it's slightly faster than
  301. * native.
  302. *
  303. * @param {Array} arr
  304. * @param {*} obj
  305. */
  306. function indexOf(arr, obj) {
  307. var i = arr.length;
  308. while (i--) {
  309. if (arr[i] === obj) return i;
  310. }
  311. return -1;
  312. }
  313. /**
  314. * Make a cancellable version of an async callback.
  315. *
  316. * @param {Function} fn
  317. * @return {Function}
  318. */
  319. function cancellable(fn) {
  320. var cb = function cb() {
  321. if (!cb.cancelled) {
  322. return fn.apply(this, arguments);
  323. }
  324. };
  325. cb.cancel = function () {
  326. cb.cancelled = true;
  327. };
  328. return cb;
  329. }
  330. /**
  331. * Check if two values are loosely equal - that is,
  332. * if they are plain objects, do they have the same shape?
  333. *
  334. * @param {*} a
  335. * @param {*} b
  336. * @return {Boolean}
  337. */
  338. function looseEqual(a, b) {
  339. /* eslint-disable eqeqeq */
  340. return a == b || (isObject(a) && isObject(b) ? JSON.stringify(a) === JSON.stringify(b) : false);
  341. /* eslint-enable eqeqeq */
  342. }
  343. var hasProto = ('__proto__' in {});
  344. // Browser environment sniffing
  345. var inBrowser = typeof window !== 'undefined' && Object.prototype.toString.call(window) !== '[object Object]';
  346. // detect devtools
  347. var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  348. // UA sniffing for working around browser-specific quirks
  349. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  350. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  351. var isAndroid = UA && UA.indexOf('android') > 0;
  352. var isIos = UA && /(iphone|ipad|ipod|ios)/i.test(UA);
  353. var isWechat = UA && UA.indexOf('micromessenger') > 0;
  354. var transitionProp = undefined;
  355. var transitionEndEvent = undefined;
  356. var animationProp = undefined;
  357. var animationEndEvent = undefined;
  358. // Transition property/event sniffing
  359. if (inBrowser && !isIE9) {
  360. var isWebkitTrans = window.ontransitionend === undefined && window.onwebkittransitionend !== undefined;
  361. var isWebkitAnim = window.onanimationend === undefined && window.onwebkitanimationend !== undefined;
  362. transitionProp = isWebkitTrans ? 'WebkitTransition' : 'transition';
  363. transitionEndEvent = isWebkitTrans ? 'webkitTransitionEnd' : 'transitionend';
  364. animationProp = isWebkitAnim ? 'WebkitAnimation' : 'animation';
  365. animationEndEvent = isWebkitAnim ? 'webkitAnimationEnd' : 'animationend';
  366. }
  367. /**
  368. * Defer a task to execute it asynchronously. Ideally this
  369. * should be executed as a microtask, so we leverage
  370. * MutationObserver if it's available, and fallback to
  371. * setTimeout(0).
  372. *
  373. * @param {Function} cb
  374. * @param {Object} ctx
  375. */
  376. var nextTick = (function () {
  377. var callbacks = [];
  378. var pending = false;
  379. var timerFunc;
  380. function nextTickHandler() {
  381. pending = false;
  382. var copies = callbacks.slice(0);
  383. callbacks = [];
  384. for (var i = 0; i < copies.length; i++) {
  385. copies[i]();
  386. }
  387. }
  388. /* istanbul ignore if */
  389. if (typeof MutationObserver !== 'undefined' && !(isWechat && isIos)) {
  390. var counter = 1;
  391. var observer = new MutationObserver(nextTickHandler);
  392. var textNode = document.createTextNode(counter);
  393. observer.observe(textNode, {
  394. characterData: true
  395. });
  396. timerFunc = function () {
  397. counter = (counter + 1) % 2;
  398. textNode.data = counter;
  399. };
  400. } else {
  401. // webpack attempts to inject a shim for setImmediate
  402. // if it is used as a global, so we have to work around that to
  403. // avoid bundling unnecessary code.
  404. var context = inBrowser ? window : typeof global !== 'undefined' ? global : {};
  405. timerFunc = context.setImmediate || setTimeout;
  406. }
  407. return function (cb, ctx) {
  408. var func = ctx ? function () {
  409. cb.call(ctx);
  410. } : cb;
  411. callbacks.push(func);
  412. if (pending) return;
  413. pending = true;
  414. timerFunc(nextTickHandler, 0);
  415. };
  416. })();
  417. var _Set = undefined;
  418. /* istanbul ignore if */
  419. if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) {
  420. // use native Set when available.
  421. _Set = Set;
  422. } else {
  423. // a non-standard Set polyfill that only works with primitive keys.
  424. _Set = function () {
  425. this.set = Object.create(null);
  426. };
  427. _Set.prototype.has = function (key) {
  428. return this.set[key] !== undefined;
  429. };
  430. _Set.prototype.add = function (key) {
  431. this.set[key] = 1;
  432. };
  433. _Set.prototype.clear = function () {
  434. this.set = Object.create(null);
  435. };
  436. }
  437. function Cache(limit) {
  438. this.size = 0;
  439. this.limit = limit;
  440. this.head = this.tail = undefined;
  441. this._keymap = Object.create(null);
  442. }
  443. var p = Cache.prototype;
  444. /**
  445. * Put <value> into the cache associated with <key>.
  446. * Returns the entry which was removed to make room for
  447. * the new entry. Otherwise undefined is returned.
  448. * (i.e. if there was enough room already).
  449. *
  450. * @param {String} key
  451. * @param {*} value
  452. * @return {Entry|undefined}
  453. */
  454. p.put = function (key, value) {
  455. var removed;
  456. if (this.size === this.limit) {
  457. removed = this.shift();
  458. }
  459. var entry = this.get(key, true);
  460. if (!entry) {
  461. entry = {
  462. key: key
  463. };
  464. this._keymap[key] = entry;
  465. if (this.tail) {
  466. this.tail.newer = entry;
  467. entry.older = this.tail;
  468. } else {
  469. this.head = entry;
  470. }
  471. this.tail = entry;
  472. this.size++;
  473. }
  474. entry.value = value;
  475. return removed;
  476. };
  477. /**
  478. * Purge the least recently used (oldest) entry from the
  479. * cache. Returns the removed entry or undefined if the
  480. * cache was empty.
  481. */
  482. p.shift = function () {
  483. var entry = this.head;
  484. if (entry) {
  485. this.head = this.head.newer;
  486. this.head.older = undefined;
  487. entry.newer = entry.older = undefined;
  488. this._keymap[entry.key] = undefined;
  489. this.size--;
  490. }
  491. return entry;
  492. };
  493. /**
  494. * Get and register recent use of <key>. Returns the value
  495. * associated with <key> or undefined if not in cache.
  496. *
  497. * @param {String} key
  498. * @param {Boolean} returnEntry
  499. * @return {Entry|*}
  500. */
  501. p.get = function (key, returnEntry) {
  502. var entry = this._keymap[key];
  503. if (entry === undefined) return;
  504. if (entry === this.tail) {
  505. return returnEntry ? entry : entry.value;
  506. }
  507. // HEAD--------------TAIL
  508. // <.older .newer>
  509. // <--- add direction --
  510. // A B C <D> E
  511. if (entry.newer) {
  512. if (entry === this.head) {
  513. this.head = entry.newer;
  514. }
  515. entry.newer.older = entry.older; // C <-- E.
  516. }
  517. if (entry.older) {
  518. entry.older.newer = entry.newer; // C. --> E
  519. }
  520. entry.newer = undefined; // D --x
  521. entry.older = this.tail; // D. --> E
  522. if (this.tail) {
  523. this.tail.newer = entry; // E. <-- D
  524. }
  525. this.tail = entry;
  526. return returnEntry ? entry : entry.value;
  527. };
  528. var cache$1 = new Cache(1000);
  529. var filterTokenRE = /[^\s'"]+|'[^']*'|"[^"]*"/g;
  530. var reservedArgRE = /^in$|^-?\d+/;
  531. /**
  532. * Parser state
  533. */
  534. var str;
  535. var dir;
  536. var c;
  537. var prev;
  538. var i;
  539. var l;
  540. var lastFilterIndex;
  541. var inSingle;
  542. var inDouble;
  543. var curly;
  544. var square;
  545. var paren;
  546. /**
  547. * Push a filter to the current directive object
  548. */
  549. function pushFilter() {
  550. var exp = str.slice(lastFilterIndex, i).trim();
  551. var filter;
  552. if (exp) {
  553. filter = {};
  554. var tokens = exp.match(filterTokenRE);
  555. filter.name = tokens[0];
  556. if (tokens.length > 1) {
  557. filter.args = tokens.slice(1).map(processFilterArg);
  558. }
  559. }
  560. if (filter) {
  561. (dir.filters = dir.filters || []).push(filter);
  562. }
  563. lastFilterIndex = i + 1;
  564. }
  565. /**
  566. * Check if an argument is dynamic and strip quotes.
  567. *
  568. * @param {String} arg
  569. * @return {Object}
  570. */
  571. function processFilterArg(arg) {
  572. if (reservedArgRE.test(arg)) {
  573. return {
  574. value: toNumber(arg),
  575. dynamic: false
  576. };
  577. } else {
  578. var stripped = stripQuotes(arg);
  579. var dynamic = stripped === arg;
  580. return {
  581. value: dynamic ? arg : stripped,
  582. dynamic: dynamic
  583. };
  584. }
  585. }
  586. /**
  587. * Parse a directive value and extract the expression
  588. * and its filters into a descriptor.
  589. *
  590. * Example:
  591. *
  592. * "a + 1 | uppercase" will yield:
  593. * {
  594. * expression: 'a + 1',
  595. * filters: [
  596. * { name: 'uppercase', args: null }
  597. * ]
  598. * }
  599. *
  600. * @param {String} s
  601. * @return {Object}
  602. */
  603. function parseDirective(s) {
  604. var hit = cache$1.get(s);
  605. if (hit) {
  606. return hit;
  607. }
  608. // reset parser state
  609. str = s;
  610. inSingle = inDouble = false;
  611. curly = square = paren = 0;
  612. lastFilterIndex = 0;
  613. dir = {};
  614. for (i = 0, l = str.length; i < l; i++) {
  615. prev = c;
  616. c = str.charCodeAt(i);
  617. if (inSingle) {
  618. // check single quote
  619. if (c === 0x27 && prev !== 0x5C) inSingle = !inSingle;
  620. } else if (inDouble) {
  621. // check double quote
  622. if (c === 0x22 && prev !== 0x5C) inDouble = !inDouble;
  623. } else if (c === 0x7C && // pipe
  624. str.charCodeAt(i + 1) !== 0x7C && str.charCodeAt(i - 1) !== 0x7C) {
  625. if (dir.expression == null) {
  626. // first filter, end of expression
  627. lastFilterIndex = i + 1;
  628. dir.expression = str.slice(0, i).trim();
  629. } else {
  630. // already has filter
  631. pushFilter();
  632. }
  633. } else {
  634. switch (c) {
  635. case 0x22:
  636. inDouble = true;break; // "
  637. case 0x27:
  638. inSingle = true;break; // '
  639. case 0x28:
  640. paren++;break; // (
  641. case 0x29:
  642. paren--;break; // )
  643. case 0x5B:
  644. square++;break; // [
  645. case 0x5D:
  646. square--;break; // ]
  647. case 0x7B:
  648. curly++;break; // {
  649. case 0x7D:
  650. curly--;break; // }
  651. }
  652. }
  653. }
  654. if (dir.expression == null) {
  655. dir.expression = str.slice(0, i).trim();
  656. } else if (lastFilterIndex !== 0) {
  657. pushFilter();
  658. }
  659. cache$1.put(s, dir);
  660. return dir;
  661. }
  662. var directive = Object.freeze({
  663. parseDirective: parseDirective
  664. });
  665. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  666. var cache = undefined;
  667. var tagRE = undefined;
  668. var htmlRE = undefined;
  669. /**
  670. * Escape a string so it can be used in a RegExp
  671. * constructor.
  672. *
  673. * @param {String} str
  674. */
  675. function escapeRegex(str) {
  676. return str.replace(regexEscapeRE, '\\$&');
  677. }
  678. function compileRegex() {
  679. var open = escapeRegex(config.delimiters[0]);
  680. var close = escapeRegex(config.delimiters[1]);
  681. var unsafeOpen = escapeRegex(config.unsafeDelimiters[0]);
  682. var unsafeClose = escapeRegex(config.unsafeDelimiters[1]);
  683. tagRE = new RegExp(unsafeOpen + '((?:.|\\n)+?)' + unsafeClose + '|' + open + '((?:.|\\n)+?)' + close, 'g');
  684. htmlRE = new RegExp('^' + unsafeOpen + '.*' + unsafeClose + '$');
  685. // reset cache
  686. cache = new Cache(1000);
  687. }
  688. /**
  689. * Parse a template text string into an array of tokens.
  690. *
  691. * @param {String} text
  692. * @return {Array<Object> | null}
  693. * - {String} type
  694. * - {String} value
  695. * - {Boolean} [html]
  696. * - {Boolean} [oneTime]
  697. */
  698. function parseText(text) {
  699. if (!cache) {
  700. compileRegex();
  701. }
  702. var hit = cache.get(text);
  703. if (hit) {
  704. return hit;
  705. }
  706. if (!tagRE.test(text)) {
  707. return null;
  708. }
  709. var tokens = [];
  710. var lastIndex = tagRE.lastIndex = 0;
  711. var match, index, html, value, first, oneTime;
  712. /* eslint-disable no-cond-assign */
  713. while (match = tagRE.exec(text)) {
  714. /* eslint-enable no-cond-assign */
  715. index = match.index;
  716. // push text token
  717. if (index > lastIndex) {
  718. tokens.push({
  719. value: text.slice(lastIndex, index)
  720. });
  721. }
  722. // tag token
  723. html = htmlRE.test(match[0]);
  724. value = html ? match[1] : match[2];
  725. first = value.charCodeAt(0);
  726. oneTime = first === 42; // *
  727. value = oneTime ? value.slice(1) : value;
  728. tokens.push({
  729. tag: true,
  730. value: value.trim(),
  731. html: html,
  732. oneTime: oneTime
  733. });
  734. lastIndex = index + match[0].length;
  735. }
  736. if (lastIndex < text.length) {
  737. tokens.push({
  738. value: text.slice(lastIndex)
  739. });
  740. }
  741. cache.put(text, tokens);
  742. return tokens;
  743. }
  744. /**
  745. * Format a list of tokens into an expression.
  746. * e.g. tokens parsed from 'a {{b}} c' can be serialized
  747. * into one single expression as '"a " + b + " c"'.
  748. *
  749. * @param {Array} tokens
  750. * @param {Vue} [vm]
  751. * @return {String}
  752. */
  753. function tokensToExp(tokens, vm) {
  754. if (tokens.length > 1) {
  755. return tokens.map(function (token) {
  756. return formatToken(token, vm);
  757. }).join('+');
  758. } else {
  759. return formatToken(tokens[0], vm, true);
  760. }
  761. }
  762. /**
  763. * Format a single token.
  764. *
  765. * @param {Object} token
  766. * @param {Vue} [vm]
  767. * @param {Boolean} [single]
  768. * @return {String}
  769. */
  770. function formatToken(token, vm, single) {
  771. return token.tag ? token.oneTime && vm ? '"' + vm.$eval(token.value) + '"' : inlineFilters(token.value, single) : '"' + token.value + '"';
  772. }
  773. /**
  774. * For an attribute with multiple interpolation tags,
  775. * e.g. attr="some-{{thing | filter}}", in order to combine
  776. * the whole thing into a single watchable expression, we
  777. * have to inline those filters. This function does exactly
  778. * that. This is a bit hacky but it avoids heavy changes
  779. * to directive parser and watcher mechanism.
  780. *
  781. * @param {String} exp
  782. * @param {Boolean} single
  783. * @return {String}
  784. */
  785. var filterRE = /[^|]\|[^|]/;
  786. function inlineFilters(exp, single) {
  787. if (!filterRE.test(exp)) {
  788. return single ? exp : '(' + exp + ')';
  789. } else {
  790. var dir = parseDirective(exp);
  791. if (!dir.filters) {
  792. return '(' + exp + ')';
  793. } else {
  794. return 'this._applyFilters(' + dir.expression + // value
  795. ',null,' + // oldValue (null for read)
  796. JSON.stringify(dir.filters) + // filter descriptors
  797. ',false)'; // write?
  798. }
  799. }
  800. }
  801. var text = Object.freeze({
  802. compileRegex: compileRegex,
  803. parseText: parseText,
  804. tokensToExp: tokensToExp
  805. });
  806. var delimiters = ['{{', '}}'];
  807. var unsafeDelimiters = ['{{{', '}}}'];
  808. var config = Object.defineProperties({
  809. /**
  810. * Whether to print debug messages.
  811. * Also enables stack trace for warnings.
  812. *
  813. * @type {Boolean}
  814. */
  815. debug: false,
  816. /**
  817. * Whether to suppress warnings.
  818. *
  819. * @type {Boolean}
  820. */
  821. silent: false,
  822. /**
  823. * Whether to use async rendering.
  824. */
  825. async: true,
  826. /**
  827. * Whether to warn against errors caught when evaluating
  828. * expressions.
  829. */
  830. warnExpressionErrors: true,
  831. /**
  832. * Whether to allow devtools inspection.
  833. * Disabled by default in production builds.
  834. */
  835. devtools: 'development' !== 'production',
  836. /**
  837. * Internal flag to indicate the delimiters have been
  838. * changed.
  839. *
  840. * @type {Boolean}
  841. */
  842. _delimitersChanged: true,
  843. /**
  844. * List of asset types that a component can own.
  845. *
  846. * @type {Array}
  847. */
  848. _assetTypes: ['component', 'directive', 'elementDirective', 'filter', 'transition', 'partial'],
  849. /**
  850. * prop binding modes
  851. */
  852. _propBindingModes: {
  853. ONE_WAY: 0,
  854. TWO_WAY: 1,
  855. ONE_TIME: 2
  856. },
  857. /**
  858. * Max circular updates allowed in a batcher flush cycle.
  859. */
  860. _maxUpdateCount: 100
  861. }, {
  862. delimiters: { /**
  863. * Interpolation delimiters. Changing these would trigger
  864. * the text parser to re-compile the regular expressions.
  865. *
  866. * @type {Array<String>}
  867. */
  868. get: function get() {
  869. return delimiters;
  870. },
  871. set: function set(val) {
  872. delimiters = val;
  873. compileRegex();
  874. },
  875. configurable: true,
  876. enumerable: true
  877. },
  878. unsafeDelimiters: {
  879. get: function get() {
  880. return unsafeDelimiters;
  881. },
  882. set: function set(val) {
  883. unsafeDelimiters = val;
  884. compileRegex();
  885. },
  886. configurable: true,
  887. enumerable: true
  888. }
  889. });
  890. var warn = undefined;
  891. var formatComponentName = undefined;
  892. if ('development' !== 'production') {
  893. (function () {
  894. var hasConsole = typeof console !== 'undefined';
  895. warn = function (msg, vm) {
  896. if (hasConsole && !config.silent) {
  897. console.error('[Vue warn]: ' + msg + (vm ? formatComponentName(vm) : ''));
  898. }
  899. };
  900. formatComponentName = function (vm) {
  901. var name = vm._isVue ? vm.$options.name : vm.name;
  902. return name ? ' (found in component: <' + hyphenate(name) + '>)' : '';
  903. };
  904. })();
  905. }
  906. /**
  907. * Append with transition.
  908. *
  909. * @param {Element} el
  910. * @param {Element} target
  911. * @param {Vue} vm
  912. * @param {Function} [cb]
  913. */
  914. function appendWithTransition(el, target, vm, cb) {
  915. applyTransition(el, 1, function () {
  916. target.appendChild(el);
  917. }, vm, cb);
  918. }
  919. /**
  920. * InsertBefore with transition.
  921. *
  922. * @param {Element} el
  923. * @param {Element} target
  924. * @param {Vue} vm
  925. * @param {Function} [cb]
  926. */
  927. function beforeWithTransition(el, target, vm, cb) {
  928. applyTransition(el, 1, function () {
  929. before(el, target);
  930. }, vm, cb);
  931. }
  932. /**
  933. * Remove with transition.
  934. *
  935. * @param {Element} el
  936. * @param {Vue} vm
  937. * @param {Function} [cb]
  938. */
  939. function removeWithTransition(el, vm, cb) {
  940. applyTransition(el, -1, function () {
  941. remove(el);
  942. }, vm, cb);
  943. }
  944. /**
  945. * Apply transitions with an operation callback.
  946. *
  947. * @param {Element} el
  948. * @param {Number} direction
  949. * 1: enter
  950. * -1: leave
  951. * @param {Function} op - the actual DOM operation
  952. * @param {Vue} vm
  953. * @param {Function} [cb]
  954. */
  955. function applyTransition(el, direction, op, vm, cb) {
  956. var transition = el.__v_trans;
  957. if (!transition ||
  958. // skip if there are no js hooks and CSS transition is
  959. // not supported
  960. !transition.hooks && !transitionEndEvent ||
  961. // skip transitions for initial compile
  962. !vm._isCompiled ||
  963. // if the vm is being manipulated by a parent directive
  964. // during the parent's compilation phase, skip the
  965. // animation.
  966. vm.$parent && !vm.$parent._isCompiled) {
  967. op();
  968. if (cb) cb();
  969. return;
  970. }
  971. var action = direction > 0 ? 'enter' : 'leave';
  972. transition[action](op, cb);
  973. }
  974. var transition = Object.freeze({
  975. appendWithTransition: appendWithTransition,
  976. beforeWithTransition: beforeWithTransition,
  977. removeWithTransition: removeWithTransition,
  978. applyTransition: applyTransition
  979. });
  980. /**
  981. * Query an element selector if it's not an element already.
  982. *
  983. * @param {String|Element} el
  984. * @return {Element}
  985. */
  986. function query(el) {
  987. if (typeof el === 'string') {
  988. var selector = el;
  989. el = document.querySelector(el);
  990. if (!el) {
  991. 'development' !== 'production' && warn('Cannot find element: ' + selector);
  992. }
  993. }
  994. return el;
  995. }
  996. /**
  997. * Check if a node is in the document.
  998. * Note: document.documentElement.contains should work here
  999. * but always returns false for comment nodes in phantomjs,
  1000. * making unit tests difficult. This is fixed by doing the
  1001. * contains() check on the node's parentNode instead of
  1002. * the node itself.
  1003. *
  1004. * @param {Node} node
  1005. * @return {Boolean}
  1006. */
  1007. function inDoc(node) {
  1008. if (!node) return false;
  1009. var doc = node.ownerDocument.documentElement;
  1010. var parent = node.parentNode;
  1011. return doc === node || doc === parent || !!(parent && parent.nodeType === 1 && doc.contains(parent));
  1012. }
  1013. /**
  1014. * Get and remove an attribute from a node.
  1015. *
  1016. * @param {Node} node
  1017. * @param {String} _attr
  1018. */
  1019. function getAttr(node, _attr) {
  1020. var val = node.getAttribute(_attr);
  1021. if (val !== null) {
  1022. node.removeAttribute(_attr);
  1023. }
  1024. return val;
  1025. }
  1026. /**
  1027. * Get an attribute with colon or v-bind: prefix.
  1028. *
  1029. * @param {Node} node
  1030. * @param {String} name
  1031. * @return {String|null}
  1032. */
  1033. function getBindAttr(node, name) {
  1034. var val = getAttr(node, ':' + name);
  1035. if (val === null) {
  1036. val = getAttr(node, 'v-bind:' + name);
  1037. }
  1038. return val;
  1039. }
  1040. /**
  1041. * Check the presence of a bind attribute.
  1042. *
  1043. * @param {Node} node
  1044. * @param {String} name
  1045. * @return {Boolean}
  1046. */
  1047. function hasBindAttr(node, name) {
  1048. return node.hasAttribute(name) || node.hasAttribute(':' + name) || node.hasAttribute('v-bind:' + name);
  1049. }
  1050. /**
  1051. * Insert el before target
  1052. *
  1053. * @param {Element} el
  1054. * @param {Element} target
  1055. */
  1056. function before(el, target) {
  1057. if (!target.parentNode) return;
  1058. target.parentNode.insertBefore(el, target);
  1059. }
  1060. /**
  1061. * Insert el after target
  1062. *
  1063. * @param {Element} el
  1064. * @param {Element} target
  1065. */
  1066. function after(el, target) {
  1067. if (target.nextSibling) {
  1068. before(el, target.nextSibling);
  1069. } else {
  1070. target.parentNode.appendChild(el);
  1071. }
  1072. }
  1073. /**
  1074. * Remove el from DOM
  1075. *
  1076. * @param {Element} el
  1077. */
  1078. function remove(el) {
  1079. if (el.parentNode) el.parentNode.removeChild(el);
  1080. }
  1081. /**
  1082. * Prepend el to target
  1083. *
  1084. * @param {Element} el
  1085. * @param {Element} target
  1086. */
  1087. function prepend(el, target) {
  1088. if (target.firstChild) {
  1089. before(el, target.firstChild);
  1090. } else {
  1091. target.appendChild(el);
  1092. }
  1093. }
  1094. /**
  1095. * Replace target with el
  1096. *
  1097. * @param {Element} target
  1098. * @param {Element} el
  1099. */
  1100. function replace(target, el) {
  1101. var parent = target.parentNode;
  1102. if (parent) {
  1103. parent.replaceChild(el, target);
  1104. }
  1105. }
  1106. /**
  1107. * Add event listener shorthand.
  1108. *
  1109. * @param {Element} el
  1110. * @param {String} event
  1111. * @param {Function} cb
  1112. * @param {Boolean} [useCapture]
  1113. */
  1114. function on(el, event, cb, useCapture) {
  1115. el.addEventListener(event, cb, useCapture);
  1116. }
  1117. /**
  1118. * Remove event listener shorthand.
  1119. *
  1120. * @param {Element} el
  1121. * @param {String} event
  1122. * @param {Function} cb
  1123. */
  1124. function off(el, event, cb) {
  1125. el.removeEventListener(event, cb);
  1126. }
  1127. /**
  1128. * For IE9 compat: when both class and :class are present
  1129. * getAttribute('class') returns wrong value...
  1130. *
  1131. * @param {Element} el
  1132. * @return {String}
  1133. */
  1134. function getClass(el) {
  1135. var classname = el.className;
  1136. if (typeof classname === 'object') {
  1137. classname = classname.baseVal || '';
  1138. }
  1139. return classname;
  1140. }
  1141. /**
  1142. * In IE9, setAttribute('class') will result in empty class
  1143. * if the element also has the :class attribute; However in
  1144. * PhantomJS, setting `className` does not work on SVG elements...
  1145. * So we have to do a conditional check here.
  1146. *
  1147. * @param {Element} el
  1148. * @param {String} cls
  1149. */
  1150. function setClass(el, cls) {
  1151. /* istanbul ignore if */
  1152. if (isIE9 && !/svg$/.test(el.namespaceURI)) {
  1153. el.className = cls;
  1154. } else {
  1155. el.setAttribute('class', cls);
  1156. }
  1157. }
  1158. /**
  1159. * Add class with compatibility for IE & SVG
  1160. *
  1161. * @param {Element} el
  1162. * @param {String} cls
  1163. */
  1164. function addClass(el, cls) {
  1165. if (el.classList) {
  1166. el.classList.add(cls);
  1167. } else {
  1168. var cur = ' ' + getClass(el) + ' ';
  1169. if (cur.indexOf(' ' + cls + ' ') < 0) {
  1170. setClass(el, (cur + cls).trim());
  1171. }
  1172. }
  1173. }
  1174. /**
  1175. * Remove class with compatibility for IE & SVG
  1176. *
  1177. * @param {Element} el
  1178. * @param {String} cls
  1179. */
  1180. function removeClass(el, cls) {
  1181. if (el.classList) {
  1182. el.classList.remove(cls);
  1183. } else {
  1184. var cur = ' ' + getClass(el) + ' ';
  1185. var tar = ' ' + cls + ' ';
  1186. while (cur.indexOf(tar) >= 0) {
  1187. cur = cur.replace(tar, ' ');
  1188. }
  1189. setClass(el, cur.trim());
  1190. }
  1191. if (!el.className) {
  1192. el.removeAttribute('class');
  1193. }
  1194. }
  1195. /**
  1196. * Extract raw content inside an element into a temporary
  1197. * container div
  1198. *
  1199. * @param {Element} el
  1200. * @param {Boolean} asFragment
  1201. * @return {Element|DocumentFragment}
  1202. */
  1203. function extractContent(el, asFragment) {
  1204. var child;
  1205. var rawContent;
  1206. /* istanbul ignore if */
  1207. if (isTemplate(el) && isFragment(el.content)) {
  1208. el = el.content;
  1209. }
  1210. if (el.hasChildNodes()) {
  1211. trimNode(el);
  1212. rawContent = asFragment ? document.createDocumentFragment() : document.createElement('div');
  1213. /* eslint-disable no-cond-assign */
  1214. while (child = el.firstChild) {
  1215. /* eslint-enable no-cond-assign */
  1216. rawContent.appendChild(child);
  1217. }
  1218. }
  1219. return rawContent;
  1220. }
  1221. /**
  1222. * Trim possible empty head/tail text and comment
  1223. * nodes inside a parent.
  1224. *
  1225. * @param {Node} node
  1226. */
  1227. function trimNode(node) {
  1228. var child;
  1229. /* eslint-disable no-sequences */
  1230. while ((child = node.firstChild, isTrimmable(child))) {
  1231. node.removeChild(child);
  1232. }
  1233. while ((child = node.lastChild, isTrimmable(child))) {
  1234. node.removeChild(child);
  1235. }
  1236. /* eslint-enable no-sequences */
  1237. }
  1238. function isTrimmable(node) {
  1239. return node && (node.nodeType === 3 && !node.data.trim() || node.nodeType === 8);
  1240. }
  1241. /**
  1242. * Check if an element is a template tag.
  1243. * Note if the template appears inside an SVG its tagName
  1244. * will be in lowercase.
  1245. *
  1246. * @param {Element} el
  1247. */
  1248. function isTemplate(el) {
  1249. return el.tagName && el.tagName.toLowerCase() === 'template';
  1250. }
  1251. /**
  1252. * Create an "anchor" for performing dom insertion/removals.
  1253. * This is used in a number of scenarios:
  1254. * - fragment instance
  1255. * - v-html
  1256. * - v-if
  1257. * - v-for
  1258. * - component
  1259. *
  1260. * @param {String} content
  1261. * @param {Boolean} persist - IE trashes empty textNodes on
  1262. * cloneNode(true), so in certain
  1263. * cases the anchor needs to be
  1264. * non-empty to be persisted in
  1265. * templates.
  1266. * @return {Comment|Text}
  1267. */
  1268. function createAnchor(content, persist) {
  1269. var anchor = config.debug ? document.createComment(content) : document.createTextNode(persist ? ' ' : '');
  1270. anchor.__v_anchor = true;
  1271. return anchor;
  1272. }
  1273. /**
  1274. * Find a component ref attribute that starts with $.
  1275. *
  1276. * @param {Element} node
  1277. * @return {String|undefined}
  1278. */
  1279. var refRE = /^v-ref:/;
  1280. function findRef(node) {
  1281. if (node.hasAttributes()) {
  1282. var attrs = node.attributes;
  1283. for (var i = 0, l = attrs.length; i < l; i++) {
  1284. var name = attrs[i].name;
  1285. if (refRE.test(name)) {
  1286. return camelize(name.replace(refRE, ''));
  1287. }
  1288. }
  1289. }
  1290. }
  1291. /**
  1292. * Map a function to a range of nodes .
  1293. *
  1294. * @param {Node} node
  1295. * @param {Node} end
  1296. * @param {Function} op
  1297. */
  1298. function mapNodeRange(node, end, op) {
  1299. var next;
  1300. while (node !== end) {
  1301. next = node.nextSibling;
  1302. op(node);
  1303. node = next;
  1304. }
  1305. op(end);
  1306. }
  1307. /**
  1308. * Remove a range of nodes with transition, store
  1309. * the nodes in a fragment with correct ordering,
  1310. * and call callback when done.
  1311. *
  1312. * @param {Node} start
  1313. * @param {Node} end
  1314. * @param {Vue} vm
  1315. * @param {DocumentFragment} frag
  1316. * @param {Function} cb
  1317. */
  1318. function removeNodeRange(start, end, vm, frag, cb) {
  1319. var done = false;
  1320. var removed = 0;
  1321. var nodes = [];
  1322. mapNodeRange(start, end, function (node) {
  1323. if (node === end) done = true;
  1324. nodes.push(node);
  1325. removeWithTransition(node, vm, onRemoved);
  1326. });
  1327. function onRemoved() {
  1328. removed++;
  1329. if (done && removed >= nodes.length) {
  1330. for (var i = 0; i < nodes.length; i++) {
  1331. frag.appendChild(nodes[i]);
  1332. }
  1333. cb && cb();
  1334. }
  1335. }
  1336. }
  1337. /**
  1338. * Check if a node is a DocumentFragment.
  1339. *
  1340. * @param {Node} node
  1341. * @return {Boolean}
  1342. */
  1343. function isFragment(node) {
  1344. return node && node.nodeType === 11;
  1345. }
  1346. /**
  1347. * Get outerHTML of elements, taking care
  1348. * of SVG elements in IE as well.
  1349. *
  1350. * @param {Element} el
  1351. * @return {String}
  1352. */
  1353. function getOuterHTML(el) {
  1354. if (el.outerHTML) {
  1355. return el.outerHTML;
  1356. } else {
  1357. var container = document.createElement('div');
  1358. container.appendChild(el.cloneNode(true));
  1359. return container.innerHTML;
  1360. }
  1361. }
  1362. var commonTagRE = /^(div|p|span|img|a|b|i|br|ul|ol|li|h1|h2|h3|h4|h5|h6|code|pre|table|th|td|tr|form|label|input|select|option|nav|article|section|header|footer)$/i;
  1363. var reservedTagRE = /^(slot|partial|component)$/i;
  1364. var isUnknownElement = undefined;
  1365. if ('development' !== 'production') {
  1366. isUnknownElement = function (el, tag) {
  1367. if (tag.indexOf('-') > -1) {
  1368. // http://stackoverflow.com/a/28210364/1070244
  1369. return el.constructor === window.HTMLUnknownElement || el.constructor === window.HTMLElement;
  1370. } else {
  1371. return (/HTMLUnknownElement/.test(el.toString()) &&
  1372. // Chrome returns unknown for several HTML5 elements.
  1373. // https://code.google.com/p/chromium/issues/detail?id=540526
  1374. !/^(data|time|rtc|rb)$/.test(tag)
  1375. );
  1376. }
  1377. };
  1378. }
  1379. /**
  1380. * Check if an element is a component, if yes return its
  1381. * component id.
  1382. *
  1383. * @param {Element} el
  1384. * @param {Object} options
  1385. * @return {Object|undefined}
  1386. */
  1387. function checkComponentAttr(el, options) {
  1388. var tag = el.tagName.toLowerCase();
  1389. var hasAttrs = el.hasAttributes();
  1390. if (!commonTagRE.test(tag) && !reservedTagRE.test(tag)) {
  1391. if (resolveAsset(options, 'components', tag)) {
  1392. return { id: tag };
  1393. } else {
  1394. var is = hasAttrs && getIsBinding(el, options);
  1395. if (is) {
  1396. return is;
  1397. } else if ('development' !== 'production') {
  1398. var expectedTag = options._componentNameMap && options._componentNameMap[tag];
  1399. if (expectedTag) {
  1400. warn('Unknown custom element: <' + tag + '> - ' + 'did you mean <' + expectedTag + '>? ' + 'HTML is case-insensitive, remember to use kebab-case in templates.');
  1401. } else if (isUnknownElement(el, tag)) {
  1402. warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
  1403. }
  1404. }
  1405. }
  1406. } else if (hasAttrs) {
  1407. return getIsBinding(el, options);
  1408. }
  1409. }
  1410. /**
  1411. * Get "is" binding from an element.
  1412. *
  1413. * @param {Element} el
  1414. * @param {Object} options
  1415. * @return {Object|undefined}
  1416. */
  1417. function getIsBinding(el, options) {
  1418. // dynamic syntax
  1419. var exp = el.getAttribute('is');
  1420. if (exp != null) {
  1421. if (resolveAsset(options, 'components', exp)) {
  1422. el.removeAttribute('is');
  1423. return { id: exp };
  1424. }
  1425. } else {
  1426. exp = getBindAttr(el, 'is');
  1427. if (exp != null) {
  1428. return { id: exp, dynamic: true };
  1429. }
  1430. }
  1431. }
  1432. /**
  1433. * Option overwriting strategies are functions that handle
  1434. * how to merge a parent option value and a child option
  1435. * value into the final value.
  1436. *
  1437. * All strategy functions follow the same signature:
  1438. *
  1439. * @param {*} parentVal
  1440. * @param {*} childVal
  1441. * @param {Vue} [vm]
  1442. */
  1443. var strats = config.optionMergeStrategies = Object.create(null);
  1444. /**
  1445. * Helper that recursively merges two data objects together.
  1446. */
  1447. function mergeData(to, from) {
  1448. var key, toVal, fromVal;
  1449. for (key in from) {
  1450. toVal = to[key];
  1451. fromVal = from[key];
  1452. if (!hasOwn(to, key)) {
  1453. set(to, key, fromVal);
  1454. } else if (isObject(toVal) && isObject(fromVal)) {
  1455. mergeData(toVal, fromVal);
  1456. }
  1457. }
  1458. return to;
  1459. }
  1460. /**
  1461. * Data
  1462. */
  1463. strats.data = function (parentVal, childVal, vm) {
  1464. if (!vm) {
  1465. // in a Vue.extend merge, both should be functions
  1466. if (!childVal) {
  1467. return parentVal;
  1468. }
  1469. if (typeof childVal !== 'function') {
  1470. 'development' !== 'production' && warn('The "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.', vm);
  1471. return parentVal;
  1472. }
  1473. if (!parentVal) {
  1474. return childVal;
  1475. }
  1476. // when parentVal & childVal are both present,
  1477. // we need to return a function that returns the
  1478. // merged result of both functions... no need to
  1479. // check if parentVal is a function here because
  1480. // it has to be a function to pass previous merges.
  1481. return function mergedDataFn() {
  1482. return mergeData(childVal.call(this), parentVal.call(this));
  1483. };
  1484. } else if (parentVal || childVal) {
  1485. return function mergedInstanceDataFn() {
  1486. // instance merge
  1487. var instanceData = typeof childVal === 'function' ? childVal.call(vm) : childVal;
  1488. var defaultData = typeof parentVal === 'function' ? parentVal.call(vm) : undefined;
  1489. if (instanceData) {
  1490. return mergeData(instanceData, defaultData);
  1491. } else {
  1492. return defaultData;
  1493. }
  1494. };
  1495. }
  1496. };
  1497. /**
  1498. * El
  1499. */
  1500. strats.el = function (parentVal, childVal, vm) {
  1501. if (!vm && childVal && typeof childVal !== 'function') {
  1502. 'development' !== 'production' && warn('The "el" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.', vm);
  1503. return;
  1504. }
  1505. var ret = childVal || parentVal;
  1506. // invoke the element factory if this is instance merge
  1507. return vm && typeof ret === 'function' ? ret.call(vm) : ret;
  1508. };
  1509. /**
  1510. * Hooks and param attributes are merged as arrays.
  1511. */
  1512. strats.init = strats.created = strats.ready = strats.attached = strats.detached = strats.beforeCompile = strats.compiled = strats.beforeDestroy = strats.destroyed = strats.activate = function (parentVal, childVal) {
  1513. return childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal;
  1514. };
  1515. /**
  1516. * Assets
  1517. *
  1518. * When a vm is present (instance creation), we need to do
  1519. * a three-way merge between constructor options, instance
  1520. * options and parent options.
  1521. */
  1522. function mergeAssets(parentVal, childVal) {
  1523. var res = Object.create(parentVal || null);
  1524. return childVal ? extend(res, guardArrayAssets(childVal)) : res;
  1525. }
  1526. config._assetTypes.forEach(function (type) {
  1527. strats[type + 's'] = mergeAssets;
  1528. });
  1529. /**
  1530. * Events & Watchers.
  1531. *
  1532. * Events & watchers hashes should not overwrite one
  1533. * another, so we merge them as arrays.
  1534. */
  1535. strats.watch = strats.events = function (parentVal, childVal) {
  1536. if (!childVal) return parentVal;
  1537. if (!parentVal) return childVal;
  1538. var ret = {};
  1539. extend(ret, parentVal);
  1540. for (var key in childVal) {
  1541. var parent = ret[key];
  1542. var child = childVal[key];
  1543. if (parent && !isArray(parent)) {
  1544. parent = [parent];
  1545. }
  1546. ret[key] = parent ? parent.concat(child) : [child];
  1547. }
  1548. return ret;
  1549. };
  1550. /**
  1551. * Other object hashes.
  1552. */
  1553. strats.props = strats.methods = strats.computed = function (parentVal, childVal) {
  1554. if (!childVal) return parentVal;
  1555. if (!parentVal) return childVal;
  1556. var ret = Object.create(null);
  1557. extend(ret, parentVal);
  1558. extend(ret, childVal);
  1559. return ret;
  1560. };
  1561. /**
  1562. * Default strategy.
  1563. */
  1564. var defaultStrat = function defaultStrat(parentVal, childVal) {
  1565. return childVal === undefined ? parentVal : childVal;
  1566. };
  1567. /**
  1568. * Make sure component options get converted to actual
  1569. * constructors.
  1570. *
  1571. * @param {Object} options
  1572. */
  1573. function guardComponents(options) {
  1574. if (options.components) {
  1575. var components = options.components = guardArrayAssets(options.components);
  1576. var ids = Object.keys(components);
  1577. var def;
  1578. if ('development' !== 'production') {
  1579. var map = options._componentNameMap = {};
  1580. }
  1581. for (var i = 0, l = ids.length; i < l; i++) {
  1582. var key = ids[i];
  1583. if (commonTagRE.test(key) || reservedTagRE.test(key)) {
  1584. 'development' !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key);
  1585. continue;
  1586. }
  1587. // record a all lowercase <-> kebab-case mapping for
  1588. // possible custom element case error warning
  1589. if ('development' !== 'production') {
  1590. map[key.replace(/-/g, '').toLowerCase()] = hyphenate(key);
  1591. }
  1592. def = components[key];
  1593. if (isPlainObject(def)) {
  1594. components[key] = Vue.extend(def);
  1595. }
  1596. }
  1597. }
  1598. }
  1599. /**
  1600. * Ensure all props option syntax are normalized into the
  1601. * Object-based format.
  1602. *
  1603. * @param {Object} options
  1604. */
  1605. function guardProps(options) {
  1606. var props = options.props;
  1607. var i, val;
  1608. if (isArray(props)) {
  1609. options.props = {};
  1610. i = props.length;
  1611. while (i--) {
  1612. val = props[i];
  1613. if (typeof val === 'string') {
  1614. options.props[val] = null;
  1615. } else if (val.name) {
  1616. options.props[val.name] = val;
  1617. }
  1618. }
  1619. } else if (isPlainObject(props)) {
  1620. var keys = Object.keys(props);
  1621. i = keys.length;
  1622. while (i--) {
  1623. val = props[keys[i]];
  1624. if (typeof val === 'function') {
  1625. props[keys[i]] = { type: val };
  1626. }
  1627. }
  1628. }
  1629. }
  1630. /**
  1631. * Guard an Array-format assets option and converted it
  1632. * into the key-value Object format.
  1633. *
  1634. * @param {Object|Array} assets
  1635. * @return {Object}
  1636. */
  1637. function guardArrayAssets(assets) {
  1638. if (isArray(assets)) {
  1639. var res = {};
  1640. var i = assets.length;
  1641. var asset;
  1642. while (i--) {
  1643. asset = assets[i];
  1644. var id = typeof asset === 'function' ? asset.options && asset.options.name || asset.id : asset.name || asset.id;
  1645. if (!id) {
  1646. 'development' !== 'production' && warn('Array-syntax assets must provide a "name" or "id" field.');
  1647. } else {
  1648. res[id] = asset;
  1649. }
  1650. }
  1651. return res;
  1652. }
  1653. return assets;
  1654. }
  1655. /**
  1656. * Merge two option objects into a new one.
  1657. * Core utility used in both instantiation and inheritance.
  1658. *
  1659. * @param {Object} parent
  1660. * @param {Object} child
  1661. * @param {Vue} [vm] - if vm is present, indicates this is
  1662. * an instantiation merge.
  1663. */
  1664. function mergeOptions(parent, child, vm) {
  1665. guardComponents(child);
  1666. guardProps(child);
  1667. if ('development' !== 'production') {
  1668. if (child.propsData && !vm) {
  1669. warn('propsData can only be used as an instantiation option.');
  1670. }
  1671. }
  1672. var options = {};
  1673. var key;
  1674. if (child['extends']) {
  1675. parent = typeof child['extends'] === 'function' ? mergeOptions(parent, child['extends'].options, vm) : mergeOptions(parent, child['extends'], vm);
  1676. }
  1677. if (child.mixins) {
  1678. for (var i = 0, l = child.mixins.length; i < l; i++) {
  1679. parent = mergeOptions(parent, child.mixins[i], vm);
  1680. }
  1681. }
  1682. for (key in parent) {
  1683. mergeField(key);
  1684. }
  1685. for (key in child) {
  1686. if (!hasOwn(parent, key)) {
  1687. mergeField(key);
  1688. }
  1689. }
  1690. function mergeField(key) {
  1691. var strat = strats[key] || defaultStrat;
  1692. options[key] = strat(parent[key], child[key], vm, key);
  1693. }
  1694. return options;
  1695. }
  1696. /**
  1697. * Resolve an asset.
  1698. * This function is used because child instances need access
  1699. * to assets defined in its ancestor chain.
  1700. *
  1701. * @param {Object} options
  1702. * @param {String} type
  1703. * @param {String} id
  1704. * @param {Boolean} warnMissing
  1705. * @return {Object|Function}
  1706. */
  1707. function resolveAsset(options, type, id, warnMissing) {
  1708. /* istanbul ignore if */
  1709. if (typeof id !== 'string') {
  1710. return;
  1711. }
  1712. var assets = options[type];
  1713. var camelizedId;
  1714. var res = assets[id] ||
  1715. // camelCase ID
  1716. assets[camelizedId = camelize(id)] ||
  1717. // Pascal Case ID
  1718. assets[camelizedId.charAt(0).toUpperCase() + camelizedId.slice(1)];
  1719. if ('development' !== 'production' && warnMissing && !res) {
  1720. warn('Failed to resolve ' + type.slice(0, -1) + ': ' + id, options);
  1721. }
  1722. return res;
  1723. }
  1724. var uid$1 = 0;
  1725. /**
  1726. * A dep is an observable that can have multiple
  1727. * directives subscribing to it.
  1728. *
  1729. * @constructor
  1730. */
  1731. function Dep() {
  1732. this.id = uid$1++;
  1733. this.subs = [];
  1734. }
  1735. // the current target watcher being evaluated.
  1736. // this is globally unique because there could be only one
  1737. // watcher being evaluated at any time.
  1738. Dep.target = null;
  1739. /**
  1740. * Add a directive subscriber.
  1741. *
  1742. * @param {Directive} sub
  1743. */
  1744. Dep.prototype.addSub = function (sub) {
  1745. this.subs.push(sub);
  1746. };
  1747. /**
  1748. * Remove a directive subscriber.
  1749. *
  1750. * @param {Directive} sub
  1751. */
  1752. Dep.prototype.removeSub = function (sub) {
  1753. this.subs.$remove(sub);
  1754. };
  1755. /**
  1756. * Add self as a dependency to the target watcher.
  1757. */
  1758. Dep.prototype.depend = function () {
  1759. Dep.target.addDep(this);
  1760. };
  1761. /**
  1762. * Notify all subscribers of a new value.
  1763. */
  1764. Dep.prototype.notify = function () {
  1765. // stablize the subscriber list first
  1766. var subs = toArray(this.subs);
  1767. for (var i = 0, l = subs.length; i < l; i++) {
  1768. subs[i].update();
  1769. }
  1770. };
  1771. var arrayProto = Array.prototype;
  1772. var arrayMethods = Object.create(arrayProto)
  1773. /**
  1774. * Intercept mutating methods and emit events
  1775. */
  1776. ;['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'].forEach(function (method) {
  1777. // cache original method
  1778. var original = arrayProto[method];
  1779. def(arrayMethods, method, function mutator() {
  1780. // avoid leaking arguments:
  1781. // http://jsperf.com/closure-with-arguments
  1782. var i = arguments.length;
  1783. var args = new Array(i);
  1784. while (i--) {
  1785. args[i] = arguments[i];
  1786. }
  1787. var result = original.apply(this, args);
  1788. var ob = this.__ob__;
  1789. var inserted;
  1790. switch (method) {
  1791. case 'push':
  1792. inserted = args;
  1793. break;
  1794. case 'unshift':
  1795. inserted = args;
  1796. break;
  1797. case 'splice':
  1798. inserted = args.slice(2);
  1799. break;
  1800. }
  1801. if (inserted) ob.observeArray(inserted);
  1802. // notify change
  1803. ob.dep.notify();
  1804. return result;
  1805. });
  1806. });
  1807. /**
  1808. * Swap the element at the given index with a new value
  1809. * and emits corresponding event.
  1810. *
  1811. * @param {Number} index
  1812. * @param {*} val
  1813. * @return {*} - replaced element
  1814. */
  1815. def(arrayProto, '$set', function $set(index, val) {
  1816. if (index >= this.length) {
  1817. this.length = Number(index) + 1;
  1818. }
  1819. return this.splice(index, 1, val)[0];
  1820. });
  1821. /**
  1822. * Convenience method to remove the element at given index or target element reference.
  1823. *
  1824. * @param {*} item
  1825. */
  1826. def(arrayProto, '$remove', function $remove(item) {
  1827. /* istanbul ignore if */
  1828. if (!this.length) return;
  1829. var index = indexOf(this, item);
  1830. if (index > -1) {
  1831. return this.splice(index, 1);
  1832. }
  1833. });
  1834. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  1835. /**
  1836. * By default, when a reactive property is set, the new value is
  1837. * also converted to become reactive. However in certain cases, e.g.
  1838. * v-for scope alias and props, we don't want to force conversion
  1839. * because the value may be a nested value under a frozen data structure.
  1840. *
  1841. * So whenever we want to set a reactive property without forcing
  1842. * conversion on the new value, we wrap that call inside this function.
  1843. */
  1844. var shouldConvert = true;
  1845. function withoutConversion(fn) {
  1846. shouldConvert = false;
  1847. fn();
  1848. shouldConvert = true;
  1849. }
  1850. /**
  1851. * Observer class that are attached to each observed
  1852. * object. Once attached, the observer converts target
  1853. * object's property keys into getter/setters that
  1854. * collect dependencies and dispatches updates.
  1855. *
  1856. * @param {Array|Object} value
  1857. * @constructor
  1858. */
  1859. function Observer(value) {
  1860. this.value = value;
  1861. this.dep = new Dep();
  1862. def(value, '__ob__', this);
  1863. if (isArray(value)) {
  1864. var augment = hasProto ? protoAugment : copyAugment;
  1865. augment(value, arrayMethods, arrayKeys);
  1866. this.observeArray(value);
  1867. } else {
  1868. this.walk(value);
  1869. }
  1870. }
  1871. // Instance methods
  1872. /**
  1873. * Walk through each property and convert them into
  1874. * getter/setters. This method should only be called when
  1875. * value type is Object.
  1876. *
  1877. * @param {Object} obj
  1878. */
  1879. Observer.prototype.walk = function (obj) {
  1880. var keys = Object.keys(obj);
  1881. for (var i = 0, l = keys.length; i < l; i++) {
  1882. this.convert(keys[i], obj[keys[i]]);
  1883. }
  1884. };
  1885. /**
  1886. * Observe a list of Array items.
  1887. *
  1888. * @param {Array} items
  1889. */
  1890. Observer.prototype.observeArray = function (items) {
  1891. for (var i = 0, l = items.length; i < l; i++) {
  1892. observe(items[i]);
  1893. }
  1894. };
  1895. /**
  1896. * Convert a property into getter/setter so we can emit
  1897. * the events when the property is accessed/changed.
  1898. *
  1899. * @param {String} key
  1900. * @param {*} val
  1901. */
  1902. Observer.prototype.convert = function (key, val) {
  1903. defineReactive(this.value, key, val);
  1904. };
  1905. /**
  1906. * Add an owner vm, so that when $set/$delete mutations
  1907. * happen we can notify owner vms to proxy the keys and
  1908. * digest the watchers. This is only called when the object
  1909. * is observed as an instance's root $data.
  1910. *
  1911. * @param {Vue} vm
  1912. */
  1913. Observer.prototype.addVm = function (vm) {
  1914. (this.vms || (this.vms = [])).push(vm);
  1915. };
  1916. /**
  1917. * Remove an owner vm. This is called when the object is
  1918. * swapped out as an instance's $data object.
  1919. *
  1920. * @param {Vue} vm
  1921. */
  1922. Observer.prototype.removeVm = function (vm) {
  1923. this.vms.$remove(vm);
  1924. };
  1925. // helpers
  1926. /**
  1927. * Augment an target Object or Array by intercepting
  1928. * the prototype chain using __proto__
  1929. *
  1930. * @param {Object|Array} target
  1931. * @param {Object} src
  1932. */
  1933. function protoAugment(target, src) {
  1934. /* eslint-disable no-proto */
  1935. target.__proto__ = src;
  1936. /* eslint-enable no-proto */
  1937. }
  1938. /**
  1939. * Augment an target Object or Array by defining
  1940. * hidden properties.
  1941. *
  1942. * @param {Object|Array} target
  1943. * @param {Object} proto
  1944. */
  1945. function copyAugment(target, src, keys) {
  1946. for (var i = 0, l = keys.length; i < l; i++) {
  1947. var key = keys[i];
  1948. def(target, key, src[key]);
  1949. }
  1950. }
  1951. /**
  1952. * Attempt to create an observer instance for a value,
  1953. * returns the new observer if successfully observed,
  1954. * or the existing observer if the value already has one.
  1955. *
  1956. * @param {*} value
  1957. * @param {Vue} [vm]
  1958. * @return {Observer|undefined}
  1959. * @static
  1960. */
  1961. function observe(value, vm) {
  1962. if (!value || typeof value !== 'object') {
  1963. return;
  1964. }
  1965. var ob;
  1966. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  1967. ob = value.__ob__;
  1968. } else if (shouldConvert && (isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
  1969. ob = new Observer(value);
  1970. }
  1971. if (ob && vm) {
  1972. ob.addVm(vm);
  1973. }
  1974. return ob;
  1975. }
  1976. /**
  1977. * Define a reactive property on an Object.
  1978. *
  1979. * @param {Object} obj
  1980. * @param {String} key
  1981. * @param {*} val
  1982. */
  1983. function defineReactive(obj, key, val) {
  1984. var dep = new Dep();
  1985. var property = Object.getOwnPropertyDescriptor(obj, key);
  1986. if (property && property.configurable === false) {
  1987. return;
  1988. }
  1989. // cater for pre-defined getter/setters
  1990. var getter = property && property.get;
  1991. var setter = property && property.set;
  1992. var childOb = observe(val);
  1993. Object.defineProperty(obj, key, {
  1994. enumerable: true,
  1995. configurable: true,
  1996. get: function reactiveGetter() {
  1997. var value = getter ? getter.call(obj) : val;
  1998. if (Dep.target) {
  1999. dep.depend();
  2000. if (childOb) {
  2001. childOb.dep.depend();
  2002. }
  2003. if (isArray(value)) {
  2004. for (var e, i = 0, l = value.length; i < l; i++) {
  2005. e = value[i];
  2006. e && e.__ob__ && e.__ob__.dep.depend();
  2007. }
  2008. }
  2009. }
  2010. return value;
  2011. },
  2012. set: function reactiveSetter(newVal) {
  2013. var value = getter ? getter.call(obj) : val;
  2014. if (newVal === value) {
  2015. return;
  2016. }
  2017. if (setter) {
  2018. setter.call(obj, newVal);
  2019. } else {
  2020. val = newVal;
  2021. }
  2022. childOb = observe(newVal);
  2023. dep.notify();
  2024. }
  2025. });
  2026. }
  2027. var util = Object.freeze({
  2028. defineReactive: defineReactive,
  2029. set: set,
  2030. del: del,
  2031. hasOwn: hasOwn,
  2032. isLiteral: isLiteral,
  2033. isReserved: isReserved,
  2034. _toString: _toString,
  2035. toNumber: toNumber,
  2036. toBoolean: toBoolean,
  2037. stripQuotes: stripQuotes,
  2038. camelize: camelize,
  2039. hyphenate: hyphenate,
  2040. classify: classify,
  2041. bind: bind,
  2042. toArray: toArray,
  2043. extend: extend,
  2044. isObject: isObject,
  2045. isPlainObject: isPlainObject,
  2046. def: def,
  2047. debounce: _debounce,
  2048. indexOf: indexOf,
  2049. cancellable: cancellable,
  2050. looseEqual: looseEqual,
  2051. isArray: isArray,
  2052. hasProto: hasProto,
  2053. inBrowser: inBrowser,
  2054. devtools: devtools,
  2055. isIE9: isIE9,
  2056. isAndroid: isAndroid,
  2057. isIos: isIos,
  2058. isWechat: isWechat,
  2059. get transitionProp () { return transitionProp; },
  2060. get transitionEndEvent () { return transitionEndEvent; },
  2061. get animationProp () { return animationProp; },
  2062. get animationEndEvent () { return animationEndEvent; },
  2063. nextTick: nextTick,
  2064. get _Set () { return _Set; },
  2065. query: query,
  2066. inDoc: inDoc,
  2067. getAttr: getAttr,
  2068. getBindAttr: getBindAttr,
  2069. hasBindAttr: hasBindAttr,
  2070. before: before,
  2071. after: after,
  2072. remove: remove,
  2073. prepend: prepend,
  2074. replace: replace,
  2075. on: on,
  2076. off: off,
  2077. setClass: setClass,
  2078. addClass: addClass,
  2079. removeClass: removeClass,
  2080. extractContent: extractContent,
  2081. trimNode: trimNode,
  2082. isTemplate: isTemplate,
  2083. createAnchor: createAnchor,
  2084. findRef: findRef,
  2085. mapNodeRange: mapNodeRange,
  2086. removeNodeRange: removeNodeRange,
  2087. isFragment: isFragment,
  2088. getOuterHTML: getOuterHTML,
  2089. mergeOptions: mergeOptions,
  2090. resolveAsset: resolveAsset,
  2091. checkComponentAttr: checkComponentAttr,
  2092. commonTagRE: commonTagRE,
  2093. reservedTagRE: reservedTagRE,
  2094. get warn () { return warn; }
  2095. });
  2096. var uid = 0;
  2097. function initMixin (Vue) {
  2098. /**
  2099. * The main init sequence. This is called for every
  2100. * instance, including ones that are created from extended
  2101. * constructors.
  2102. *
  2103. * @param {Object} options - this options object should be
  2104. * the result of merging class
  2105. * options and the options passed
  2106. * in to the constructor.
  2107. */
  2108. Vue.prototype._init = function (options) {
  2109. options = options || {};
  2110. this.$el = null;
  2111. this.$parent = options.parent;
  2112. this.$root = this.$parent ? this.$parent.$root : this;
  2113. this.$children = [];
  2114. this.$refs = {}; // child vm references
  2115. this.$els = {}; // element references
  2116. this._watchers = []; // all watchers as an array
  2117. this._directives = []; // all directives
  2118. // a uid
  2119. this._uid = uid++;
  2120. // a flag to avoid this being observed
  2121. this._isVue = true;
  2122. // events bookkeeping
  2123. this._events = {}; // registered callbacks
  2124. this._eventsCount = {}; // for $broadcast optimization
  2125. // fragment instance properties
  2126. this._isFragment = false;
  2127. this._fragment = // @type {DocumentFragment}
  2128. this._fragmentStart = // @type {Text|Comment}
  2129. this._fragmentEnd = null; // @type {Text|Comment}
  2130. // lifecycle state
  2131. this._isCompiled = this._isDestroyed = this._isReady = this._isAttached = this._isBeingDestroyed = this._vForRemoving = false;
  2132. this._unlinkFn = null;
  2133. // context:
  2134. // if this is a transcluded component, context
  2135. // will be the common parent vm of this instance
  2136. // and its host.
  2137. this._context = options._context || this.$parent;
  2138. // scope:
  2139. // if this is inside an inline v-for, the scope
  2140. // will be the intermediate scope created for this
  2141. // repeat fragment. this is used for linking props
  2142. // and container directives.
  2143. this._scope = options._scope;
  2144. // fragment:
  2145. // if this instance is compiled inside a Fragment, it
  2146. // needs to reigster itself as a child of that fragment
  2147. // for attach/detach to work properly.
  2148. this._frag = options._frag;
  2149. if (this._frag) {
  2150. this._frag.children.push(this);
  2151. }
  2152. // push self into parent / transclusion host
  2153. if (this.$parent) {
  2154. this.$parent.$children.push(this);
  2155. }
  2156. // merge options.
  2157. options = this.$options = mergeOptions(this.constructor.options, options, this);
  2158. // set ref
  2159. this._updateRef();
  2160. // initialize data as empty object.
  2161. // it will be filled up in _initData().
  2162. this._data = {};
  2163. // call init hook
  2164. this._callHook('init');
  2165. // initialize data observation and scope inheritance.
  2166. this._initState();
  2167. // setup event system and option events.
  2168. this._initEvents();
  2169. // call created hook
  2170. this._callHook('created');
  2171. // if `el` option is passed, start compilation.
  2172. if (options.el) {
  2173. this.$mount(options.el);
  2174. }
  2175. };
  2176. }
  2177. var pathCache = new Cache(1000);
  2178. // actions
  2179. var APPEND = 0;
  2180. var PUSH = 1;
  2181. var INC_SUB_PATH_DEPTH = 2;
  2182. var PUSH_SUB_PATH = 3;
  2183. // states
  2184. var BEFORE_PATH = 0;
  2185. var IN_PATH = 1;
  2186. var BEFORE_IDENT = 2;
  2187. var IN_IDENT = 3;
  2188. var IN_SUB_PATH = 4;
  2189. var IN_SINGLE_QUOTE = 5;
  2190. var IN_DOUBLE_QUOTE = 6;
  2191. var AFTER_PATH = 7;
  2192. var ERROR = 8;
  2193. var pathStateMachine = [];
  2194. pathStateMachine[BEFORE_PATH] = {
  2195. 'ws': [BEFORE_PATH],
  2196. 'ident': [IN_IDENT, APPEND],
  2197. '[': [IN_SUB_PATH],
  2198. 'eof': [AFTER_PATH]
  2199. };
  2200. pathStateMachine[IN_PATH] = {
  2201. 'ws': [IN_PATH],
  2202. '.': [BEFORE_IDENT],
  2203. '[': [IN_SUB_PATH],
  2204. 'eof': [AFTER_PATH]
  2205. };
  2206. pathStateMachine[BEFORE_IDENT] = {
  2207. 'ws': [BEFORE_IDENT],
  2208. 'ident': [IN_IDENT, APPEND]
  2209. };
  2210. pathStateMachine[IN_IDENT] = {
  2211. 'ident': [IN_IDENT, APPEND],
  2212. '0': [IN_IDENT, APPEND],
  2213. 'number': [IN_IDENT, APPEND],
  2214. 'ws': [IN_PATH, PUSH],
  2215. '.': [BEFORE_IDENT, PUSH],
  2216. '[': [IN_SUB_PATH, PUSH],
  2217. 'eof': [AFTER_PATH, PUSH]
  2218. };
  2219. pathStateMachine[IN_SUB_PATH] = {
  2220. "'": [IN_SINGLE_QUOTE, APPEND],
  2221. '"': [IN_DOUBLE_QUOTE, APPEND],
  2222. '[': [IN_SUB_PATH, INC_SUB_PATH_DEPTH],
  2223. ']': [IN_PATH, PUSH_SUB_PATH],
  2224. 'eof': ERROR,
  2225. 'else': [IN_SUB_PATH, APPEND]
  2226. };
  2227. pathStateMachine[IN_SINGLE_QUOTE] = {
  2228. "'": [IN_SUB_PATH, APPEND],
  2229. 'eof': ERROR,
  2230. 'else': [IN_SINGLE_QUOTE, APPEND]
  2231. };
  2232. pathStateMachine[IN_DOUBLE_QUOTE] = {
  2233. '"': [IN_SUB_PATH, APPEND],
  2234. 'eof': ERROR,
  2235. 'else': [IN_DOUBLE_QUOTE, APPEND]
  2236. };
  2237. /**
  2238. * Determine the type of a character in a keypath.
  2239. *
  2240. * @param {Char} ch
  2241. * @return {String} type
  2242. */
  2243. function getPathCharType(ch) {
  2244. if (ch === undefined) {
  2245. return 'eof';
  2246. }
  2247. var code = ch.charCodeAt(0);
  2248. switch (code) {
  2249. case 0x5B: // [
  2250. case 0x5D: // ]
  2251. case 0x2E: // .
  2252. case 0x22: // "
  2253. case 0x27: // '
  2254. case 0x30:
  2255. // 0
  2256. return ch;
  2257. case 0x5F: // _
  2258. case 0x24:
  2259. // $
  2260. return 'ident';
  2261. case 0x20: // Space
  2262. case 0x09: // Tab
  2263. case 0x0A: // Newline
  2264. case 0x0D: // Return
  2265. case 0xA0: // No-break space
  2266. case 0xFEFF: // Byte Order Mark
  2267. case 0x2028: // Line Separator
  2268. case 0x2029:
  2269. // Paragraph Separator
  2270. return 'ws';
  2271. }
  2272. // a-z, A-Z
  2273. if (code >= 0x61 && code <= 0x7A || code >= 0x41 && code <= 0x5A) {
  2274. return 'ident';
  2275. }
  2276. // 1-9
  2277. if (code >= 0x31 && code <= 0x39) {
  2278. return 'number';
  2279. }
  2280. return 'else';
  2281. }
  2282. /**
  2283. * Format a subPath, return its plain form if it is
  2284. * a literal string or number. Otherwise prepend the
  2285. * dynamic indicator (*).
  2286. *
  2287. * @param {String} path
  2288. * @return {String}
  2289. */
  2290. function formatSubPath(path) {
  2291. var trimmed = path.trim();
  2292. // invalid leading 0
  2293. if (path.charAt(0) === '0' && isNaN(path)) {
  2294. return false;
  2295. }
  2296. return isLiteral(trimmed) ? stripQuotes(trimmed) : '*' + trimmed;
  2297. }
  2298. /**
  2299. * Parse a string path into an array of segments
  2300. *
  2301. * @param {String} path
  2302. * @return {Array|undefined}
  2303. */
  2304. function parse(path) {
  2305. var keys = [];
  2306. var index = -1;
  2307. var mode = BEFORE_PATH;
  2308. var subPathDepth = 0;
  2309. var c, newChar, key, type, transition, action, typeMap;
  2310. var actions = [];
  2311. actions[PUSH] = function () {
  2312. if (key !== undefined) {
  2313. keys.push(key);
  2314. key = undefined;
  2315. }
  2316. };
  2317. actions[APPEND] = function () {
  2318. if (key === undefined) {
  2319. key = newChar;
  2320. } else {
  2321. key += newChar;
  2322. }
  2323. };
  2324. actions[INC_SUB_PATH_DEPTH] = function () {
  2325. actions[APPEND]();
  2326. subPathDepth++;
  2327. };
  2328. actions[PUSH_SUB_PATH] = function () {
  2329. if (subPathDepth > 0) {
  2330. subPathDepth--;
  2331. mode = IN_SUB_PATH;
  2332. actions[APPEND]();
  2333. } else {
  2334. subPathDepth = 0;
  2335. key = formatSubPath(key);
  2336. if (key === false) {
  2337. return false;
  2338. } else {
  2339. actions[PUSH]();
  2340. }
  2341. }
  2342. };
  2343. function maybeUnescapeQuote() {
  2344. var nextChar = path[index + 1];
  2345. if (mode === IN_SINGLE_QUOTE && nextChar === "'" || mode === IN_DOUBLE_QUOTE && nextChar === '"') {
  2346. index++;
  2347. newChar = '\\' + nextChar;
  2348. actions[APPEND]();
  2349. return true;
  2350. }
  2351. }
  2352. while (mode != null) {
  2353. index++;
  2354. c = path[index];
  2355. if (c === '\\' && maybeUnescapeQuote()) {
  2356. continue;
  2357. }
  2358. type = getPathCharType(c);
  2359. typeMap = pathStateMachine[mode];
  2360. transition = typeMap[type] || typeMap['else'] || ERROR;
  2361. if (transition === ERROR) {
  2362. return; // parse error
  2363. }
  2364. mode = transition[0];
  2365. action = actions[transition[1]];
  2366. if (action) {
  2367. newChar = transition[2];
  2368. newChar = newChar === undefined ? c : newChar;
  2369. if (action() === false) {
  2370. return;
  2371. }
  2372. }
  2373. if (mode === AFTER_PATH) {
  2374. keys.raw = path;
  2375. return keys;
  2376. }
  2377. }
  2378. }
  2379. /**
  2380. * External parse that check for a cache hit first
  2381. *
  2382. * @param {String} path
  2383. * @return {Array|undefined}
  2384. */
  2385. function parsePath(path) {
  2386. var hit = pathCache.get(path);
  2387. if (!hit) {
  2388. hit = parse(path);
  2389. if (hit) {
  2390. pathCache.put(path, hit);
  2391. }
  2392. }
  2393. return hit;
  2394. }
  2395. /**
  2396. * Get from an object from a path string
  2397. *
  2398. * @param {Object} obj
  2399. * @param {String} path
  2400. */
  2401. function getPath(obj, path) {
  2402. return parseExpression(path).get(obj);
  2403. }
  2404. /**
  2405. * Warn against setting non-existent root path on a vm.
  2406. */
  2407. var warnNonExistent;
  2408. if ('development' !== 'production') {
  2409. warnNonExistent = function (path, vm) {
  2410. warn('You are setting a non-existent path "' + path.raw + '" ' + 'on a vm instance. Consider pre-initializing the property ' + 'with the "data" option for more reliable reactivity ' + 'and better performance.', vm);
  2411. };
  2412. }
  2413. /**
  2414. * Set on an object from a path
  2415. *
  2416. * @param {Object} obj
  2417. * @param {String | Array} path
  2418. * @param {*} val
  2419. */
  2420. function setPath(obj, path, val) {
  2421. var original = obj;
  2422. if (typeof path === 'string') {
  2423. path = parse(path);
  2424. }
  2425. if (!path || !isObject(obj)) {
  2426. return false;
  2427. }
  2428. var last, key;
  2429. for (var i = 0, l = path.length; i < l; i++) {
  2430. last = obj;
  2431. key = path[i];
  2432. if (key.charAt(0) === '*') {
  2433. key = parseExpression(key.slice(1)).get.call(original, original);
  2434. }
  2435. if (i < l - 1) {
  2436. obj = obj[key];
  2437. if (!isObject(obj)) {
  2438. obj = {};
  2439. if ('development' !== 'production' && last._isVue) {
  2440. warnNonExistent(path, last);
  2441. }
  2442. set(last, key, obj);
  2443. }
  2444. } else {
  2445. if (isArray(obj)) {
  2446. obj.$set(key, val);
  2447. } else if (key in obj) {
  2448. obj[key] = val;
  2449. } else {
  2450. if ('development' !== 'production' && obj._isVue) {
  2451. warnNonExistent(path, obj);
  2452. }
  2453. set(obj, key, val);
  2454. }
  2455. }
  2456. }
  2457. return true;
  2458. }
  2459. var path = Object.freeze({
  2460. parsePath: parsePath,
  2461. getPath: getPath,
  2462. setPath: setPath
  2463. });
  2464. var expressionCache = new Cache(1000);
  2465. var allowedKeywords = 'Math,Date,this,true,false,null,undefined,Infinity,NaN,' + 'isNaN,isFinite,decodeURI,decodeURIComponent,encodeURI,' + 'encodeURIComponent,parseInt,parseFloat';
  2466. var allowedKeywordsRE = new RegExp('^(' + allowedKeywords.replace(/,/g, '\\b|') + '\\b)');
  2467. // keywords that don't make sense inside expressions
  2468. var improperKeywords = 'break,case,class,catch,const,continue,debugger,default,' + 'delete,do,else,export,extends,finally,for,function,if,' + 'import,in,instanceof,let,return,super,switch,throw,try,' + 'var,while,with,yield,enum,await,implements,package,' + 'protected,static,interface,private,public';
  2469. var improperKeywordsRE = new RegExp('^(' + improperKeywords.replace(/,/g, '\\b|') + '\\b)');
  2470. var wsRE = /\s/g;
  2471. var newlineRE = /\n/g;
  2472. var saveRE = /[\{,]\s*[\w\$_]+\s*:|('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`)|new |typeof |void /g;
  2473. var restoreRE = /"(\d+)"/g;
  2474. var pathTestRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?'\]|\[".*?"\]|\[\d+\]|\[[A-Za-z_$][\w$]*\])*$/;
  2475. var identRE = /[^\w$\.](?:[A-Za-z_$][\w$]*)/g;
  2476. var booleanLiteralRE = /^(?:true|false)$/;
  2477. /**
  2478. * Save / Rewrite / Restore
  2479. *
  2480. * When rewriting paths found in an expression, it is
  2481. * possible for the same letter sequences to be found in
  2482. * strings and Object literal property keys. Therefore we
  2483. * remove and store these parts in a temporary array, and
  2484. * restore them after the path rewrite.
  2485. */
  2486. var saved = [];
  2487. /**
  2488. * Save replacer
  2489. *
  2490. * The save regex can match two possible cases:
  2491. * 1. An opening object literal
  2492. * 2. A string
  2493. * If matched as a plain string, we need to escape its
  2494. * newlines, since the string needs to be preserved when
  2495. * generating the function body.
  2496. *
  2497. * @param {String} str
  2498. * @param {String} isString - str if matched as a string
  2499. * @return {String} - placeholder with index
  2500. */
  2501. function save(str, isString) {
  2502. var i = saved.length;
  2503. saved[i] = isString ? str.replace(newlineRE, '\\n') : str;
  2504. return '"' + i + '"';
  2505. }
  2506. /**
  2507. * Path rewrite replacer
  2508. *
  2509. * @param {String} raw
  2510. * @return {String}
  2511. */
  2512. function rewrite(raw) {
  2513. var c = raw.charAt(0);
  2514. var path = raw.slice(1);
  2515. if (allowedKeywordsRE.test(path)) {
  2516. return raw;
  2517. } else {
  2518. path = path.indexOf('"') > -1 ? path.replace(restoreRE, restore) : path;
  2519. return c + 'scope.' + path;
  2520. }
  2521. }
  2522. /**
  2523. * Restore replacer
  2524. *
  2525. * @param {String} str
  2526. * @param {String} i - matched save index
  2527. * @return {String}
  2528. */
  2529. function restore(str, i) {
  2530. return saved[i];
  2531. }
  2532. /**
  2533. * Rewrite an expression, prefixing all path accessors with
  2534. * `scope.` and generate getter/setter functions.
  2535. *
  2536. * @param {String} exp
  2537. * @return {Function}
  2538. */
  2539. function compileGetter(exp) {
  2540. if (improperKeywordsRE.test(exp)) {
  2541. 'development' !== 'production' && warn('Avoid using reserved keywords in expression: ' + exp);
  2542. }
  2543. // reset state
  2544. saved.length = 0;
  2545. // save strings and object literal keys
  2546. var body = exp.replace(saveRE, save).replace(wsRE, '');
  2547. // rewrite all paths
  2548. // pad 1 space here becaue the regex matches 1 extra char
  2549. body = (' ' + body).replace(identRE, rewrite).replace(restoreRE, restore);
  2550. return makeGetterFn(body);
  2551. }
  2552. /**
  2553. * Build a getter function. Requires eval.
  2554. *
  2555. * We isolate the try/catch so it doesn't affect the
  2556. * optimization of the parse function when it is not called.
  2557. *
  2558. * @param {String} body
  2559. * @return {Function|undefined}
  2560. */
  2561. function makeGetterFn(body) {
  2562. try {
  2563. /* eslint-disable no-new-func */
  2564. return new Function('scope', 'return ' + body + ';');
  2565. /* eslint-enable no-new-func */
  2566. } catch (e) {
  2567. 'development' !== 'production' && warn('Invalid expression. ' + 'Generated function body: ' + body);
  2568. }
  2569. }
  2570. /**
  2571. * Compile a setter function for the expression.
  2572. *
  2573. * @param {String} exp
  2574. * @return {Function|undefined}
  2575. */
  2576. function compileSetter(exp) {
  2577. var path = parsePath(exp);
  2578. if (path) {
  2579. return function (scope, val) {
  2580. setPath(scope, path, val);
  2581. };
  2582. } else {
  2583. 'development' !== 'production' && warn('Invalid setter expression: ' + exp);
  2584. }
  2585. }
  2586. /**
  2587. * Parse an expression into re-written getter/setters.
  2588. *
  2589. * @param {String} exp
  2590. * @param {Boolean} needSet
  2591. * @return {Function}
  2592. */
  2593. function parseExpression(exp, needSet) {
  2594. exp = exp.trim();
  2595. // try cache
  2596. var hit = expressionCache.get(exp);
  2597. if (hit) {
  2598. if (needSet && !hit.set) {
  2599. hit.set = compileSetter(hit.exp);
  2600. }
  2601. return hit;
  2602. }
  2603. var res = { exp: exp };
  2604. res.get = isSimplePath(exp) && exp.indexOf('[') < 0
  2605. // optimized super simple getter
  2606. ? makeGetterFn('scope.' + exp)
  2607. // dynamic getter
  2608. : compileGetter(exp);
  2609. if (needSet) {
  2610. res.set = compileSetter(exp);
  2611. }
  2612. expressionCache.put(exp, res);
  2613. return res;
  2614. }
  2615. /**
  2616. * Check if an expression is a simple path.
  2617. *
  2618. * @param {String} exp
  2619. * @return {Boolean}
  2620. */
  2621. function isSimplePath(exp) {
  2622. return pathTestRE.test(exp) &&
  2623. // don't treat true/false as paths
  2624. !booleanLiteralRE.test(exp) &&
  2625. // Math constants e.g. Math.PI, Math.E etc.
  2626. exp.slice(0, 5) !== 'Math.';
  2627. }
  2628. var expression = Object.freeze({
  2629. parseExpression: parseExpression,
  2630. isSimplePath: isSimplePath
  2631. });
  2632. // we have two separate queues: one for directive updates
  2633. // and one for user watcher registered via $watch().
  2634. // we want to guarantee directive updates to be called
  2635. // before user watchers so that when user watchers are
  2636. // triggered, the DOM would have already been in updated
  2637. // state.
  2638. var queue = [];
  2639. var userQueue = [];
  2640. var has = {};
  2641. var circular = {};
  2642. var waiting = false;
  2643. /**
  2644. * Reset the batcher's state.
  2645. */
  2646. function resetBatcherState() {
  2647. queue.length = 0;
  2648. userQueue.length = 0;
  2649. has = {};
  2650. circular = {};
  2651. waiting = false;
  2652. }
  2653. /**
  2654. * Flush both queues and run the watchers.
  2655. */
  2656. function flushBatcherQueue() {
  2657. var _again = true;
  2658. _function: while (_again) {
  2659. _again = false;
  2660. runBatcherQueue(queue);
  2661. runBatcherQueue(userQueue);
  2662. // user watchers triggered more watchers,
  2663. // keep flushing until it depletes
  2664. if (queue.length) {
  2665. _again = true;
  2666. continue _function;
  2667. }
  2668. // dev tool hook
  2669. /* istanbul ignore if */
  2670. if (devtools && config.devtools) {
  2671. devtools.emit('flush');
  2672. }
  2673. resetBatcherState();
  2674. }
  2675. }
  2676. /**
  2677. * Run the watchers in a single queue.
  2678. *
  2679. * @param {Array} queue
  2680. */
  2681. function runBatcherQueue(queue) {
  2682. // do not cache length because more watchers might be pushed
  2683. // as we run existing watchers
  2684. for (var i = 0; i < queue.length; i++) {
  2685. var watcher = queue[i];
  2686. var id = watcher.id;
  2687. has[id] = null;
  2688. watcher.run();
  2689. // in dev build, check and stop circular updates.
  2690. if ('development' !== 'production' && has[id] != null) {
  2691. circular[id] = (circular[id] || 0) + 1;
  2692. if (circular[id] > config._maxUpdateCount) {
  2693. warn('You may have an infinite update loop for watcher ' + 'with expression "' + watcher.expression + '"', watcher.vm);
  2694. break;
  2695. }
  2696. }
  2697. }
  2698. queue.length = 0;
  2699. }
  2700. /**
  2701. * Push a watcher into the watcher queue.
  2702. * Jobs with duplicate IDs will be skipped unless it's
  2703. * pushed when the queue is being flushed.
  2704. *
  2705. * @param {Watcher} watcher
  2706. * properties:
  2707. * - {Number} id
  2708. * - {Function} run
  2709. */
  2710. function pushWatcher(watcher) {
  2711. var id = watcher.id;
  2712. if (has[id] == null) {
  2713. // push watcher into appropriate queue
  2714. var q = watcher.user ? userQueue : queue;
  2715. has[id] = q.length;
  2716. q.push(watcher);
  2717. // queue the flush
  2718. if (!waiting) {
  2719. waiting = true;
  2720. nextTick(flushBatcherQueue);
  2721. }
  2722. }
  2723. }
  2724. var uid$2 = 0;
  2725. /**
  2726. * A watcher parses an expression, collects dependencies,
  2727. * and fires callback when the expression value changes.
  2728. * This is used for both the $watch() api and directives.
  2729. *
  2730. * @param {Vue} vm
  2731. * @param {String|Function} expOrFn
  2732. * @param {Function} cb
  2733. * @param {Object} options
  2734. * - {Array} filters
  2735. * - {Boolean} twoWay
  2736. * - {Boolean} deep
  2737. * - {Boolean} user
  2738. * - {Boolean} sync
  2739. * - {Boolean} lazy
  2740. * - {Function} [preProcess]
  2741. * - {Function} [postProcess]
  2742. * @constructor
  2743. */
  2744. function Watcher(vm, expOrFn, cb, options) {
  2745. // mix in options
  2746. if (options) {
  2747. extend(this, options);
  2748. }
  2749. var isFn = typeof expOrFn === 'function';
  2750. this.vm = vm;
  2751. vm._watchers.push(this);
  2752. this.expression = expOrFn;
  2753. this.cb = cb;
  2754. this.id = ++uid$2; // uid for batching
  2755. this.active = true;
  2756. this.dirty = this.lazy; // for lazy watchers
  2757. this.deps = [];
  2758. this.newDeps = [];
  2759. this.depIds = new _Set();
  2760. this.newDepIds = new _Set();
  2761. this.prevError = null; // for async error stacks
  2762. // parse expression for getter/setter
  2763. if (isFn) {
  2764. this.getter = expOrFn;
  2765. this.setter = undefined;
  2766. } else {
  2767. var res = parseExpression(expOrFn, this.twoWay);
  2768. this.getter = res.get;
  2769. this.setter = res.set;
  2770. }
  2771. this.value = this.lazy ? undefined : this.get();
  2772. // state for avoiding false triggers for deep and Array
  2773. // watchers during vm._digest()
  2774. this.queued = this.shallow = false;
  2775. }
  2776. /**
  2777. * Evaluate the getter, and re-collect dependencies.
  2778. */
  2779. Watcher.prototype.get = function () {
  2780. this.beforeGet();
  2781. var scope = this.scope || this.vm;
  2782. var value;
  2783. try {
  2784. value = this.getter.call(scope, scope);
  2785. } catch (e) {
  2786. if ('development' !== 'production' && config.warnExpressionErrors) {
  2787. warn('Error when evaluating expression ' + '"' + this.expression + '": ' + e.toString(), this.vm);
  2788. }
  2789. }
  2790. // "touch" every property so they are all tracked as
  2791. // dependencies for deep watching
  2792. if (this.deep) {
  2793. traverse(value);
  2794. }
  2795. if (this.preProcess) {
  2796. value = this.preProcess(value);
  2797. }
  2798. if (this.filters) {
  2799. value = scope._applyFilters(value, null, this.filters, false);
  2800. }
  2801. if (this.postProcess) {
  2802. value = this.postProcess(value);
  2803. }
  2804. this.afterGet();
  2805. return value;
  2806. };
  2807. /**
  2808. * Set the corresponding value with the setter.
  2809. *
  2810. * @param {*} value
  2811. */
  2812. Watcher.prototype.set = function (value) {
  2813. var scope = this.scope || this.vm;
  2814. if (this.filters) {
  2815. value = scope._applyFilters(value, this.value, this.filters, true);
  2816. }
  2817. try {
  2818. this.setter.call(scope, scope, value);
  2819. } catch (e) {
  2820. if ('development' !== 'production' && config.warnExpressionErrors) {
  2821. warn('Error when evaluating setter ' + '"' + this.expression + '": ' + e.toString(), this.vm);
  2822. }
  2823. }
  2824. // two-way sync for v-for alias
  2825. var forContext = scope.$forContext;
  2826. if (forContext && forContext.alias === this.expression) {
  2827. if (forContext.filters) {
  2828. 'development' !== 'production' && warn('It seems you are using two-way binding on ' + 'a v-for alias (' + this.expression + '), and the ' + 'v-for has filters. This will not work properly. ' + 'Either remove the filters or use an array of ' + 'objects and bind to object properties instead.', this.vm);
  2829. return;
  2830. }
  2831. forContext._withLock(function () {
  2832. if (scope.$key) {
  2833. // original is an object
  2834. forContext.rawValue[scope.$key] = value;
  2835. } else {
  2836. forContext.rawValue.$set(scope.$index, value);
  2837. }
  2838. });
  2839. }
  2840. };
  2841. /**
  2842. * Prepare for dependency collection.
  2843. */
  2844. Watcher.prototype.beforeGet = function () {
  2845. Dep.target = this;
  2846. };
  2847. /**
  2848. * Add a dependency to this directive.
  2849. *
  2850. * @param {Dep} dep
  2851. */
  2852. Watcher.prototype.addDep = function (dep) {
  2853. var id = dep.id;
  2854. if (!this.newDepIds.has(id)) {
  2855. this.newDepIds.add(id);
  2856. this.newDeps.push(dep);
  2857. if (!this.depIds.has(id)) {
  2858. dep.addSub(this);
  2859. }
  2860. }
  2861. };
  2862. /**
  2863. * Clean up for dependency collection.
  2864. */
  2865. Watcher.prototype.afterGet = function () {
  2866. Dep.target = null;
  2867. var i = this.deps.length;
  2868. while (i--) {
  2869. var dep = this.deps[i];
  2870. if (!this.newDepIds.has(dep.id)) {
  2871. dep.removeSub(this);
  2872. }
  2873. }
  2874. var tmp = this.depIds;
  2875. this.depIds = this.newDepIds;
  2876. this.newDepIds = tmp;
  2877. this.newDepIds.clear();
  2878. tmp = this.deps;
  2879. this.deps = this.newDeps;
  2880. this.newDeps = tmp;
  2881. this.newDeps.length = 0;
  2882. };
  2883. /**
  2884. * Subscriber interface.
  2885. * Will be called when a dependency changes.
  2886. *
  2887. * @param {Boolean} shallow
  2888. */
  2889. Watcher.prototype.update = function (shallow) {
  2890. if (this.lazy) {
  2891. this.dirty = true;
  2892. } else if (this.sync || !config.async) {
  2893. this.run();
  2894. } else {
  2895. // if queued, only overwrite shallow with non-shallow,
  2896. // but not the other way around.
  2897. this.shallow = this.queued ? shallow ? this.shallow : false : !!shallow;
  2898. this.queued = true;
  2899. // record before-push error stack in debug mode
  2900. /* istanbul ignore if */
  2901. if ('development' !== 'production' && config.debug) {
  2902. this.prevError = new Error('[vue] async stack trace');
  2903. }
  2904. pushWatcher(this);
  2905. }
  2906. };
  2907. /**
  2908. * Batcher job interface.
  2909. * Will be called by the batcher.
  2910. */
  2911. Watcher.prototype.run = function () {
  2912. if (this.active) {
  2913. var value = this.get();
  2914. if (value !== this.value ||
  2915. // Deep watchers and watchers on Object/Arrays should fire even
  2916. // when the value is the same, because the value may
  2917. // have mutated; but only do so if this is a
  2918. // non-shallow update (caused by a vm digest).
  2919. (isObject(value) || this.deep) && !this.shallow) {
  2920. // set new value
  2921. var oldValue = this.value;
  2922. this.value = value;
  2923. // in debug + async mode, when a watcher callbacks
  2924. // throws, we also throw the saved before-push error
  2925. // so the full cross-tick stack trace is available.
  2926. var prevError = this.prevError;
  2927. /* istanbul ignore if */
  2928. if ('development' !== 'production' && config.debug && prevError) {
  2929. this.prevError = null;
  2930. try {
  2931. this.cb.call(this.vm, value, oldValue);
  2932. } catch (e) {
  2933. nextTick(function () {
  2934. throw prevError;
  2935. }, 0);
  2936. throw e;
  2937. }
  2938. } else {
  2939. this.cb.call(this.vm, value, oldValue);
  2940. }
  2941. }
  2942. this.queued = this.shallow = false;
  2943. }
  2944. };
  2945. /**
  2946. * Evaluate the value of the watcher.
  2947. * This only gets called for lazy watchers.
  2948. */
  2949. Watcher.prototype.evaluate = function () {
  2950. // avoid overwriting another watcher that is being
  2951. // collected.
  2952. var current = Dep.target;
  2953. this.value = this.get();
  2954. this.dirty = false;
  2955. Dep.target = current;
  2956. };
  2957. /**
  2958. * Depend on all deps collected by this watcher.
  2959. */
  2960. Watcher.prototype.depend = function () {
  2961. var i = this.deps.length;
  2962. while (i--) {
  2963. this.deps[i].depend();
  2964. }
  2965. };
  2966. /**
  2967. * Remove self from all dependencies' subcriber list.
  2968. */
  2969. Watcher.prototype.teardown = function () {
  2970. if (this.active) {
  2971. // remove self from vm's watcher list
  2972. // this is a somewhat expensive operation so we skip it
  2973. // if the vm is being destroyed or is performing a v-for
  2974. // re-render (the watcher list is then filtered by v-for).
  2975. if (!this.vm._isBeingDestroyed && !this.vm._vForRemoving) {
  2976. this.vm._watchers.$remove(this);
  2977. }
  2978. var i = this.deps.length;
  2979. while (i--) {
  2980. this.deps[i].removeSub(this);
  2981. }
  2982. this.active = false;
  2983. this.vm = this.cb = this.value = null;
  2984. }
  2985. };
  2986. /**
  2987. * Recrusively traverse an object to evoke all converted
  2988. * getters, so that every nested property inside the object
  2989. * is collected as a "deep" dependency.
  2990. *
  2991. * @param {*} val
  2992. */
  2993. var seenObjects = new _Set();
  2994. function traverse(val, seen) {
  2995. var i = undefined,
  2996. keys = undefined;
  2997. if (!seen) {
  2998. seen = seenObjects;
  2999. seen.clear();
  3000. }
  3001. var isA = isArray(val);
  3002. var isO = isObject(val);
  3003. if (isA || isO) {
  3004. if (val.__ob__) {
  3005. var depId = val.__ob__.dep.id;
  3006. if (seen.has(depId)) {
  3007. return;
  3008. } else {
  3009. seen.add(depId);
  3010. }
  3011. }
  3012. if (isA) {
  3013. i = val.length;
  3014. while (i--) traverse(val[i], seen);
  3015. } else if (isO) {
  3016. keys = Object.keys(val);
  3017. i = keys.length;
  3018. while (i--) traverse(val[keys[i]], seen);
  3019. }
  3020. }
  3021. }
  3022. var text$1 = {
  3023. bind: function bind() {
  3024. this.attr = this.el.nodeType === 3 ? 'data' : 'textContent';
  3025. },
  3026. update: function update(value) {
  3027. this.el[this.attr] = _toString(value);
  3028. }
  3029. };
  3030. var templateCache = new Cache(1000);
  3031. var idSelectorCache = new Cache(1000);
  3032. var map = {
  3033. efault: [0, '', ''],
  3034. legend: [1, '<fieldset>', '</fieldset>'],
  3035. tr: [2, '<table><tbody>', '</tbody></table>'],
  3036. col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>']
  3037. };
  3038. map.td = map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
  3039. map.option = map.optgroup = [1, '<select multiple="multiple">', '</select>'];
  3040. map.thead = map.tbody = map.colgroup = map.caption = map.tfoot = [1, '<table>', '</table>'];
  3041. map.g = map.defs = map.symbol = map.use = map.image = map.text = map.circle = map.ellipse = map.line = map.path = map.polygon = map.polyline = map.rect = [1, '<svg ' + 'xmlns="http://www.w3.org/2000/svg" ' + 'xmlns:xlink="http://www.w3.org/1999/xlink" ' + 'xmlns:ev="http://www.w3.org/2001/xml-events"' + 'version="1.1">', '</svg>'];
  3042. /**
  3043. * Check if a node is a supported template node with a
  3044. * DocumentFragment content.
  3045. *
  3046. * @param {Node} node
  3047. * @return {Boolean}
  3048. */
  3049. function isRealTemplate(node) {
  3050. return isTemplate(node) && isFragment(node.content);
  3051. }
  3052. var tagRE$1 = /<([\w:-]+)/;
  3053. var entityRE = /&#?\w+?;/;
  3054. /**
  3055. * Convert a string template to a DocumentFragment.
  3056. * Determines correct wrapping by tag types. Wrapping
  3057. * strategy found in jQuery & component/domify.
  3058. *
  3059. * @param {String} templateString
  3060. * @param {Boolean} raw
  3061. * @return {DocumentFragment}
  3062. */
  3063. function stringToFragment(templateString, raw) {
  3064. // try a cache hit first
  3065. var cacheKey = raw ? templateString : templateString.trim();
  3066. var hit = templateCache.get(cacheKey);
  3067. if (hit) {
  3068. return hit;
  3069. }
  3070. var frag = document.createDocumentFragment();
  3071. var tagMatch = templateString.match(tagRE$1);
  3072. var entityMatch = entityRE.test(templateString);
  3073. if (!tagMatch && !entityMatch) {
  3074. // text only, return a single text node.
  3075. frag.appendChild(document.createTextNode(templateString));
  3076. } else {
  3077. var tag = tagMatch && tagMatch[1];
  3078. var wrap = map[tag] || map.efault;
  3079. var depth = wrap[0];
  3080. var prefix = wrap[1];
  3081. var suffix = wrap[2];
  3082. var node = document.createElement('div');
  3083. node.innerHTML = prefix + templateString + suffix;
  3084. while (depth--) {
  3085. node = node.lastChild;
  3086. }
  3087. var child;
  3088. /* eslint-disable no-cond-assign */
  3089. while (child = node.firstChild) {
  3090. /* eslint-enable no-cond-assign */
  3091. frag.appendChild(child);
  3092. }
  3093. }
  3094. if (!raw) {
  3095. trimNode(frag);
  3096. }
  3097. templateCache.put(cacheKey, frag);
  3098. return frag;
  3099. }
  3100. /**
  3101. * Convert a template node to a DocumentFragment.
  3102. *
  3103. * @param {Node} node
  3104. * @return {DocumentFragment}
  3105. */
  3106. function nodeToFragment(node) {
  3107. // if its a template tag and the browser supports it,
  3108. // its content is already a document fragment. However, iOS Safari has
  3109. // bug when using directly cloned template content with touch
  3110. // events and can cause crashes when the nodes are removed from DOM, so we
  3111. // have to treat template elements as string templates. (#2805)
  3112. /* istanbul ignore if */
  3113. if (isRealTemplate(node)) {
  3114. return stringToFragment(node.innerHTML);
  3115. }
  3116. // script template
  3117. if (node.tagName === 'SCRIPT') {
  3118. return stringToFragment(node.textContent);
  3119. }
  3120. // normal node, clone it to avoid mutating the original
  3121. var clonedNode = cloneNode(node);
  3122. var frag = document.createDocumentFragment();
  3123. var child;
  3124. /* eslint-disable no-cond-assign */
  3125. while (child = clonedNode.firstChild) {
  3126. /* eslint-enable no-cond-assign */
  3127. frag.appendChild(child);
  3128. }
  3129. trimNode(frag);
  3130. return frag;
  3131. }
  3132. // Test for the presence of the Safari template cloning bug
  3133. // https://bugs.webkit.org/showug.cgi?id=137755
  3134. var hasBrokenTemplate = (function () {
  3135. /* istanbul ignore else */
  3136. if (inBrowser) {
  3137. var a = document.createElement('div');
  3138. a.innerHTML = '<template>1</template>';
  3139. return !a.cloneNode(true).firstChild.innerHTML;
  3140. } else {
  3141. return false;
  3142. }
  3143. })();
  3144. // Test for IE10/11 textarea placeholder clone bug
  3145. var hasTextareaCloneBug = (function () {
  3146. /* istanbul ignore else */
  3147. if (inBrowser) {
  3148. var t = document.createElement('textarea');
  3149. t.placeholder = 't';
  3150. return t.cloneNode(true).value === 't';
  3151. } else {
  3152. return false;
  3153. }
  3154. })();
  3155. /**
  3156. * 1. Deal with Safari cloning nested <template> bug by
  3157. * manually cloning all template instances.
  3158. * 2. Deal with IE10/11 textarea placeholder bug by setting
  3159. * the correct value after cloning.
  3160. *
  3161. * @param {Element|DocumentFragment} node
  3162. * @return {Element|DocumentFragment}
  3163. */
  3164. function cloneNode(node) {
  3165. /* istanbul ignore if */
  3166. if (!node.querySelectorAll) {
  3167. return node.cloneNode();
  3168. }
  3169. var res = node.cloneNode(true);
  3170. var i, original, cloned;
  3171. /* istanbul ignore if */
  3172. if (hasBrokenTemplate) {
  3173. var tempClone = res;
  3174. if (isRealTemplate(node)) {
  3175. node = node.content;
  3176. tempClone = res.content;
  3177. }
  3178. original = node.querySelectorAll('template');
  3179. if (original.length) {
  3180. cloned = tempClone.querySelectorAll('template');
  3181. i = cloned.length;
  3182. while (i--) {
  3183. cloned[i].parentNode.replaceChild(cloneNode(original[i]), cloned[i]);
  3184. }
  3185. }
  3186. }
  3187. /* istanbul ignore if */
  3188. if (hasTextareaCloneBug) {
  3189. if (node.tagName === 'TEXTAREA') {
  3190. res.value = node.value;
  3191. } else {
  3192. original = node.querySelectorAll('textarea');
  3193. if (original.length) {
  3194. cloned = res.querySelectorAll('textarea');
  3195. i = cloned.length;
  3196. while (i--) {
  3197. cloned[i].value = original[i].value;
  3198. }
  3199. }
  3200. }
  3201. }
  3202. return res;
  3203. }
  3204. /**
  3205. * Process the template option and normalizes it into a
  3206. * a DocumentFragment that can be used as a partial or a
  3207. * instance template.
  3208. *
  3209. * @param {*} template
  3210. * Possible values include:
  3211. * - DocumentFragment object
  3212. * - Node object of type Template
  3213. * - id selector: '#some-template-id'
  3214. * - template string: '<div><span>{{msg}}</span></div>'
  3215. * @param {Boolean} shouldClone
  3216. * @param {Boolean} raw
  3217. * inline HTML interpolation. Do not check for id
  3218. * selector and keep whitespace in the string.
  3219. * @return {DocumentFragment|undefined}
  3220. */
  3221. function parseTemplate(template, shouldClone, raw) {
  3222. var node, frag;
  3223. // if the template is already a document fragment,
  3224. // do nothing
  3225. if (isFragment(template)) {
  3226. trimNode(template);
  3227. return shouldClone ? cloneNode(template) : template;
  3228. }
  3229. if (typeof template === 'string') {
  3230. // id selector
  3231. if (!raw && template.charAt(0) === '#') {
  3232. // id selector can be cached too
  3233. frag = idSelectorCache.get(template);
  3234. if (!frag) {
  3235. node = document.getElementById(template.slice(1));
  3236. if (node) {
  3237. frag = nodeToFragment(node);
  3238. // save selector to cache
  3239. idSelectorCache.put(template, frag);
  3240. }
  3241. }
  3242. } else {
  3243. // normal string template
  3244. frag = stringToFragment(template, raw);
  3245. }
  3246. } else if (template.nodeType) {
  3247. // a direct node
  3248. frag = nodeToFragment(template);
  3249. }
  3250. return frag && shouldClone ? cloneNode(frag) : frag;
  3251. }
  3252. var template = Object.freeze({
  3253. cloneNode: cloneNode,
  3254. parseTemplate: parseTemplate
  3255. });
  3256. var html = {
  3257. bind: function bind() {
  3258. // a comment node means this is a binding for
  3259. // {{{ inline unescaped html }}}
  3260. if (this.el.nodeType === 8) {
  3261. // hold nodes
  3262. this.nodes = [];
  3263. // replace the placeholder with proper anchor
  3264. this.anchor = createAnchor('v-html');
  3265. replace(this.el, this.anchor);
  3266. }
  3267. },
  3268. update: function update(value) {
  3269. value = _toString(value);
  3270. if (this.nodes) {
  3271. this.swap(value);
  3272. } else {
  3273. this.el.innerHTML = value;
  3274. }
  3275. },
  3276. swap: function swap(value) {
  3277. // remove old nodes
  3278. var i = this.nodes.length;
  3279. while (i--) {
  3280. remove(this.nodes[i]);
  3281. }
  3282. // convert new value to a fragment
  3283. // do not attempt to retrieve from id selector
  3284. var frag = parseTemplate(value, true, true);
  3285. // save a reference to these nodes so we can remove later
  3286. this.nodes = toArray(frag.childNodes);
  3287. before(frag, this.anchor);
  3288. }
  3289. };
  3290. /**
  3291. * Abstraction for a partially-compiled fragment.
  3292. * Can optionally compile content with a child scope.
  3293. *
  3294. * @param {Function} linker
  3295. * @param {Vue} vm
  3296. * @param {DocumentFragment} frag
  3297. * @param {Vue} [host]
  3298. * @param {Object} [scope]
  3299. * @param {Fragment} [parentFrag]
  3300. */
  3301. function Fragment(linker, vm, frag, host, scope, parentFrag) {
  3302. this.children = [];
  3303. this.childFrags = [];
  3304. this.vm = vm;
  3305. this.scope = scope;
  3306. this.inserted = false;
  3307. this.parentFrag = parentFrag;
  3308. if (parentFrag) {
  3309. parentFrag.childFrags.push(this);
  3310. }
  3311. this.unlink = linker(vm, frag, host, scope, this);
  3312. var single = this.single = frag.childNodes.length === 1 &&
  3313. // do not go single mode if the only node is an anchor
  3314. !frag.childNodes[0].__v_anchor;
  3315. if (single) {
  3316. this.node = frag.childNodes[0];
  3317. this.before = singleBefore;
  3318. this.remove = singleRemove;
  3319. } else {
  3320. this.node = createAnchor('fragment-start');
  3321. this.end = createAnchor('fragment-end');
  3322. this.frag = frag;
  3323. prepend(this.node, frag);
  3324. frag.appendChild(this.end);
  3325. this.before = multiBefore;
  3326. this.remove = multiRemove;
  3327. }
  3328. this.node.__v_frag = this;
  3329. }
  3330. /**
  3331. * Call attach/detach for all components contained within
  3332. * this fragment. Also do so recursively for all child
  3333. * fragments.
  3334. *
  3335. * @param {Function} hook
  3336. */
  3337. Fragment.prototype.callHook = function (hook) {
  3338. var i, l;
  3339. for (i = 0, l = this.childFrags.length; i < l; i++) {
  3340. this.childFrags[i].callHook(hook);
  3341. }
  3342. for (i = 0, l = this.children.length; i < l; i++) {
  3343. hook(this.children[i]);
  3344. }
  3345. };
  3346. /**
  3347. * Insert fragment before target, single node version
  3348. *
  3349. * @param {Node} target
  3350. * @param {Boolean} withTransition
  3351. */
  3352. function singleBefore(target, withTransition) {
  3353. this.inserted = true;
  3354. var method = withTransition !== false ? beforeWithTransition : before;
  3355. method(this.node, target, this.vm);
  3356. if (inDoc(this.node)) {
  3357. this.callHook(attach);
  3358. }
  3359. }
  3360. /**
  3361. * Remove fragment, single node version
  3362. */
  3363. function singleRemove() {
  3364. this.inserted = false;
  3365. var shouldCallRemove = inDoc(this.node);
  3366. var self = this;
  3367. this.beforeRemove();
  3368. removeWithTransition(this.node, this.vm, function () {
  3369. if (shouldCallRemove) {
  3370. self.callHook(detach);
  3371. }
  3372. self.destroy();
  3373. });
  3374. }
  3375. /**
  3376. * Insert fragment before target, multi-nodes version
  3377. *
  3378. * @param {Node} target
  3379. * @param {Boolean} withTransition
  3380. */
  3381. function multiBefore(target, withTransition) {
  3382. this.inserted = true;
  3383. var vm = this.vm;
  3384. var method = withTransition !== false ? beforeWithTransition : before;
  3385. mapNodeRange(this.node, this.end, function (node) {
  3386. method(node, target, vm);
  3387. });
  3388. if (inDoc(this.node)) {
  3389. this.callHook(attach);
  3390. }
  3391. }
  3392. /**
  3393. * Remove fragment, multi-nodes version
  3394. */
  3395. function multiRemove() {
  3396. this.inserted = false;
  3397. var self = this;
  3398. var shouldCallRemove = inDoc(this.node);
  3399. this.beforeRemove();
  3400. removeNodeRange(this.node, this.end, this.vm, this.frag, function () {
  3401. if (shouldCallRemove) {
  3402. self.callHook(detach);
  3403. }
  3404. self.destroy();
  3405. });
  3406. }
  3407. /**
  3408. * Prepare the fragment for removal.
  3409. */
  3410. Fragment.prototype.beforeRemove = function () {
  3411. var i, l;
  3412. for (i = 0, l = this.childFrags.length; i < l; i++) {
  3413. // call the same method recursively on child
  3414. // fragments, depth-first
  3415. this.childFrags[i].beforeRemove(false);
  3416. }
  3417. for (i = 0, l = this.children.length; i < l; i++) {
  3418. // Call destroy for all contained instances,
  3419. // with remove:false and defer:true.
  3420. // Defer is necessary because we need to
  3421. // keep the children to call detach hooks
  3422. // on them.
  3423. this.children[i].$destroy(false, true);
  3424. }
  3425. var dirs = this.unlink.dirs;
  3426. for (i = 0, l = dirs.length; i < l; i++) {
  3427. // disable the watchers on all the directives
  3428. // so that the rendered content stays the same
  3429. // during removal.
  3430. dirs[i]._watcher && dirs[i]._watcher.teardown();
  3431. }
  3432. };
  3433. /**
  3434. * Destroy the fragment.
  3435. */
  3436. Fragment.prototype.destroy = function () {
  3437. if (this.parentFrag) {
  3438. this.parentFrag.childFrags.$remove(this);
  3439. }
  3440. this.node.__v_frag = null;
  3441. this.unlink();
  3442. };
  3443. /**
  3444. * Call attach hook for a Vue instance.
  3445. *
  3446. * @param {Vue} child
  3447. */
  3448. function attach(child) {
  3449. if (!child._isAttached && inDoc(child.$el)) {
  3450. child._callHook('attached');
  3451. }
  3452. }
  3453. /**
  3454. * Call detach hook for a Vue instance.
  3455. *
  3456. * @param {Vue} child
  3457. */
  3458. function detach(child) {
  3459. if (child._isAttached && !inDoc(child.$el)) {
  3460. child._callHook('detached');
  3461. }
  3462. }
  3463. var linkerCache = new Cache(5000);
  3464. /**
  3465. * A factory that can be used to create instances of a
  3466. * fragment. Caches the compiled linker if possible.
  3467. *
  3468. * @param {Vue} vm
  3469. * @param {Element|String} el
  3470. */
  3471. function FragmentFactory(vm, el) {
  3472. this.vm = vm;
  3473. var template;
  3474. var isString = typeof el === 'string';
  3475. if (isString || isTemplate(el) && !el.hasAttribute('v-if')) {
  3476. template = parseTemplate(el, true);
  3477. } else {
  3478. template = document.createDocumentFragment();
  3479. template.appendChild(el);
  3480. }
  3481. this.template = template;
  3482. // linker can be cached, but only for components
  3483. var linker;
  3484. var cid = vm.constructor.cid;
  3485. if (cid > 0) {
  3486. var cacheId = cid + (isString ? el : getOuterHTML(el));
  3487. linker = linkerCache.get(cacheId);
  3488. if (!linker) {
  3489. linker = compile(template, vm.$options, true);
  3490. linkerCache.put(cacheId, linker);
  3491. }
  3492. } else {
  3493. linker = compile(template, vm.$options, true);
  3494. }
  3495. this.linker = linker;
  3496. }
  3497. /**
  3498. * Create a fragment instance with given host and scope.
  3499. *
  3500. * @param {Vue} host
  3501. * @param {Object} scope
  3502. * @param {Fragment} parentFrag
  3503. */
  3504. FragmentFactory.prototype.create = function (host, scope, parentFrag) {
  3505. var frag = cloneNode(this.template);
  3506. return new Fragment(this.linker, this.vm, frag, host, scope, parentFrag);
  3507. };
  3508. var ON = 700;
  3509. var MODEL = 800;
  3510. var BIND = 850;
  3511. var TRANSITION = 1100;
  3512. var EL = 1500;
  3513. var COMPONENT = 1500;
  3514. var PARTIAL = 1750;
  3515. var IF = 2100;
  3516. var FOR = 2200;
  3517. var SLOT = 2300;
  3518. var uid$3 = 0;
  3519. var vFor = {
  3520. priority: FOR,
  3521. terminal: true,
  3522. params: ['track-by', 'stagger', 'enter-stagger', 'leave-stagger'],
  3523. bind: function bind() {
  3524. // support "item in/of items" syntax
  3525. var inMatch = this.expression.match(/(.*) (?:in|of) (.*)/);
  3526. if (inMatch) {
  3527. var itMatch = inMatch[1].match(/\((.*),(.*)\)/);
  3528. if (itMatch) {
  3529. this.iterator = itMatch[1].trim();
  3530. this.alias = itMatch[2].trim();
  3531. } else {
  3532. this.alias = inMatch[1].trim();
  3533. }
  3534. this.expression = inMatch[2];
  3535. }
  3536. if (!this.alias) {
  3537. 'development' !== 'production' && warn('Invalid v-for expression "' + this.descriptor.raw + '": ' + 'alias is required.', this.vm);
  3538. return;
  3539. }
  3540. // uid as a cache identifier
  3541. this.id = '__v-for__' + ++uid$3;
  3542. // check if this is an option list,
  3543. // so that we know if we need to update the <select>'s
  3544. // v-model when the option list has changed.
  3545. // because v-model has a lower priority than v-for,
  3546. // the v-model is not bound here yet, so we have to
  3547. // retrive it in the actual updateModel() function.
  3548. var tag = this.el.tagName;
  3549. this.isOption = (tag === 'OPTION' || tag === 'OPTGROUP') && this.el.parentNode.tagName === 'SELECT';
  3550. // setup anchor nodes
  3551. this.start = createAnchor('v-for-start');
  3552. this.end = createAnchor('v-for-end');
  3553. replace(this.el, this.end);
  3554. before(this.start, this.end);
  3555. // cache
  3556. this.cache = Object.create(null);
  3557. // fragment factory
  3558. this.factory = new FragmentFactory(this.vm, this.el);
  3559. },
  3560. update: function update(data) {
  3561. this.diff(data);
  3562. this.updateRef();
  3563. this.updateModel();
  3564. },
  3565. /**
  3566. * Diff, based on new data and old data, determine the
  3567. * minimum amount of DOM manipulations needed to make the
  3568. * DOM reflect the new data Array.
  3569. *
  3570. * The algorithm diffs the new data Array by storing a
  3571. * hidden reference to an owner vm instance on previously
  3572. * seen data. This allows us to achieve O(n) which is
  3573. * better than a levenshtein distance based algorithm,
  3574. * which is O(m * n).
  3575. *
  3576. * @param {Array} data
  3577. */
  3578. diff: function diff(data) {
  3579. // check if the Array was converted from an Object
  3580. var item = data[0];
  3581. var convertedFromObject = this.fromObject = isObject(item) && hasOwn(item, '$key') && hasOwn(item, '$value');
  3582. var trackByKey = this.params.trackBy;
  3583. var oldFrags = this.frags;
  3584. var frags = this.frags = new Array(data.length);
  3585. var alias = this.alias;
  3586. var iterator = this.iterator;
  3587. var start = this.start;
  3588. var end = this.end;
  3589. var inDocument = inDoc(start);
  3590. var init = !oldFrags;
  3591. var i, l, frag, key, value, primitive;
  3592. // First pass, go through the new Array and fill up
  3593. // the new frags array. If a piece of data has a cached
  3594. // instance for it, we reuse it. Otherwise build a new
  3595. // instance.
  3596. for (i = 0, l = data.length; i < l; i++) {
  3597. item = data[i];
  3598. key = convertedFromObject ? item.$key : null;
  3599. value = convertedFromObject ? item.$value : item;
  3600. primitive = !isObject(value);
  3601. frag = !init && this.getCachedFrag(value, i, key);
  3602. if (frag) {
  3603. // reusable fragment
  3604. frag.reused = true;
  3605. // update $index
  3606. frag.scope.$index = i;
  3607. // update $key
  3608. if (key) {
  3609. frag.scope.$key = key;
  3610. }
  3611. // update iterator
  3612. if (iterator) {
  3613. frag.scope[iterator] = key !== null ? key : i;
  3614. }
  3615. // update data for track-by, object repeat &
  3616. // primitive values.
  3617. if (trackByKey || convertedFromObject || primitive) {
  3618. withoutConversion(function () {
  3619. frag.scope[alias] = value;
  3620. });
  3621. }
  3622. } else {
  3623. // new isntance
  3624. frag = this.create(value, alias, i, key);
  3625. frag.fresh = !init;
  3626. }
  3627. frags[i] = frag;
  3628. if (init) {
  3629. frag.before(end);
  3630. }
  3631. }
  3632. // we're done for the initial render.
  3633. if (init) {
  3634. return;
  3635. }
  3636. // Second pass, go through the old fragments and
  3637. // destroy those who are not reused (and remove them
  3638. // from cache)
  3639. var removalIndex = 0;
  3640. var totalRemoved = oldFrags.length - frags.length;
  3641. // when removing a large number of fragments, watcher removal
  3642. // turns out to be a perf bottleneck, so we batch the watcher
  3643. // removals into a single filter call!
  3644. this.vm._vForRemoving = true;
  3645. for (i = 0, l = oldFrags.length; i < l; i++) {
  3646. frag = oldFrags[i];
  3647. if (!frag.reused) {
  3648. this.deleteCachedFrag(frag);
  3649. this.remove(frag, removalIndex++, totalRemoved, inDocument);
  3650. }
  3651. }
  3652. this.vm._vForRemoving = false;
  3653. if (removalIndex) {
  3654. this.vm._watchers = this.vm._watchers.filter(function (w) {
  3655. return w.active;
  3656. });
  3657. }
  3658. // Final pass, move/insert new fragments into the
  3659. // right place.
  3660. var targetPrev, prevEl, currentPrev;
  3661. var insertionIndex = 0;
  3662. for (i = 0, l = frags.length; i < l; i++) {
  3663. frag = frags[i];
  3664. // this is the frag that we should be after
  3665. targetPrev = frags[i - 1];
  3666. prevEl = targetPrev ? targetPrev.staggerCb ? targetPrev.staggerAnchor : targetPrev.end || targetPrev.node : start;
  3667. if (frag.reused && !frag.staggerCb) {
  3668. currentPrev = findPrevFrag(frag, start, this.id);
  3669. if (currentPrev !== targetPrev && (!currentPrev ||
  3670. // optimization for moving a single item.
  3671. // thanks to suggestions by @livoras in #1807
  3672. findPrevFrag(currentPrev, start, this.id) !== targetPrev)) {
  3673. this.move(frag, prevEl);
  3674. }
  3675. } else {
  3676. // new instance, or still in stagger.
  3677. // insert with updated stagger index.
  3678. this.insert(frag, insertionIndex++, prevEl, inDocument);
  3679. }
  3680. frag.reused = frag.fresh = false;
  3681. }
  3682. },
  3683. /**
  3684. * Create a new fragment instance.
  3685. *
  3686. * @param {*} value
  3687. * @param {String} alias
  3688. * @param {Number} index
  3689. * @param {String} [key]
  3690. * @return {Fragment}
  3691. */
  3692. create: function create(value, alias, index, key) {
  3693. var host = this._host;
  3694. // create iteration scope
  3695. var parentScope = this._scope || this.vm;
  3696. var scope = Object.create(parentScope);
  3697. // ref holder for the scope
  3698. scope.$refs = Object.create(parentScope.$refs);
  3699. scope.$els = Object.create(parentScope.$els);
  3700. // make sure point $parent to parent scope
  3701. scope.$parent = parentScope;
  3702. // for two-way binding on alias
  3703. scope.$forContext = this;
  3704. // define scope properties
  3705. // important: define the scope alias without forced conversion
  3706. // so that frozen data structures remain non-reactive.
  3707. withoutConversion(function () {
  3708. defineReactive(scope, alias, value);
  3709. });
  3710. defineReactive(scope, '$index', index);
  3711. if (key) {
  3712. defineReactive(scope, '$key', key);
  3713. } else if (scope.$key) {
  3714. // avoid accidental fallback
  3715. def(scope, '$key', null);
  3716. }
  3717. if (this.iterator) {
  3718. defineReactive(scope, this.iterator, key !== null ? key : index);
  3719. }
  3720. var frag = this.factory.create(host, scope, this._frag);
  3721. frag.forId = this.id;
  3722. this.cacheFrag(value, frag, index, key);
  3723. return frag;
  3724. },
  3725. /**
  3726. * Update the v-ref on owner vm.
  3727. */
  3728. updateRef: function updateRef() {
  3729. var ref = this.descriptor.ref;
  3730. if (!ref) return;
  3731. var hash = (this._scope || this.vm).$refs;
  3732. var refs;
  3733. if (!this.fromObject) {
  3734. refs = this.frags.map(findVmFromFrag);
  3735. } else {
  3736. refs = {};
  3737. this.frags.forEach(function (frag) {
  3738. refs[frag.scope.$key] = findVmFromFrag(frag);
  3739. });
  3740. }
  3741. hash[ref] = refs;
  3742. },
  3743. /**
  3744. * For option lists, update the containing v-model on
  3745. * parent <select>.
  3746. */
  3747. updateModel: function updateModel() {
  3748. if (this.isOption) {
  3749. var parent = this.start.parentNode;
  3750. var model = parent && parent.__v_model;
  3751. if (model) {
  3752. model.forceUpdate();
  3753. }
  3754. }
  3755. },
  3756. /**
  3757. * Insert a fragment. Handles staggering.
  3758. *
  3759. * @param {Fragment} frag
  3760. * @param {Number} index
  3761. * @param {Node} prevEl
  3762. * @param {Boolean} inDocument
  3763. */
  3764. insert: function insert(frag, index, prevEl, inDocument) {
  3765. if (frag.staggerCb) {
  3766. frag.staggerCb.cancel();
  3767. frag.staggerCb = null;
  3768. }
  3769. var staggerAmount = this.getStagger(frag, index, null, 'enter');
  3770. if (inDocument && staggerAmount) {
  3771. // create an anchor and insert it synchronously,
  3772. // so that we can resolve the correct order without
  3773. // worrying about some elements not inserted yet
  3774. var anchor = frag.staggerAnchor;
  3775. if (!anchor) {
  3776. anchor = frag.staggerAnchor = createAnchor('stagger-anchor');
  3777. anchor.__v_frag = frag;
  3778. }
  3779. after(anchor, prevEl);
  3780. var op = frag.staggerCb = cancellable(function () {
  3781. frag.staggerCb = null;
  3782. frag.before(anchor);
  3783. remove(anchor);
  3784. });
  3785. setTimeout(op, staggerAmount);
  3786. } else {
  3787. var target = prevEl.nextSibling;
  3788. /* istanbul ignore if */
  3789. if (!target) {
  3790. // reset end anchor position in case the position was messed up
  3791. // by an external drag-n-drop library.
  3792. after(this.end, prevEl);
  3793. target = this.end;
  3794. }
  3795. frag.before(target);
  3796. }
  3797. },
  3798. /**
  3799. * Remove a fragment. Handles staggering.
  3800. *
  3801. * @param {Fragment} frag
  3802. * @param {Number} index
  3803. * @param {Number} total
  3804. * @param {Boolean} inDocument
  3805. */
  3806. remove: function remove(frag, index, total, inDocument) {
  3807. if (frag.staggerCb) {
  3808. frag.staggerCb.cancel();
  3809. frag.staggerCb = null;
  3810. // it's not possible for the same frag to be removed
  3811. // twice, so if we have a pending stagger callback,
  3812. // it means this frag is queued for enter but removed
  3813. // before its transition started. Since it is already
  3814. // destroyed, we can just leave it in detached state.
  3815. return;
  3816. }
  3817. var staggerAmount = this.getStagger(frag, index, total, 'leave');
  3818. if (inDocument && staggerAmount) {
  3819. var op = frag.staggerCb = cancellable(function () {
  3820. frag.staggerCb = null;
  3821. frag.remove();
  3822. });
  3823. setTimeout(op, staggerAmount);
  3824. } else {
  3825. frag.remove();
  3826. }
  3827. },
  3828. /**
  3829. * Move a fragment to a new position.
  3830. * Force no transition.
  3831. *
  3832. * @param {Fragment} frag
  3833. * @param {Node} prevEl
  3834. */
  3835. move: function move(frag, prevEl) {
  3836. // fix a common issue with Sortable:
  3837. // if prevEl doesn't have nextSibling, this means it's
  3838. // been dragged after the end anchor. Just re-position
  3839. // the end anchor to the end of the container.
  3840. /* istanbul ignore if */
  3841. if (!prevEl.nextSibling) {
  3842. this.end.parentNode.appendChild(this.end);
  3843. }
  3844. frag.before(prevEl.nextSibling, false);
  3845. },
  3846. /**
  3847. * Cache a fragment using track-by or the object key.
  3848. *
  3849. * @param {*} value
  3850. * @param {Fragment} frag
  3851. * @param {Number} index
  3852. * @param {String} [key]
  3853. */
  3854. cacheFrag: function cacheFrag(value, frag, index, key) {
  3855. var trackByKey = this.params.trackBy;
  3856. var cache = this.cache;
  3857. var primitive = !isObject(value);
  3858. var id;
  3859. if (key || trackByKey || primitive) {
  3860. id = getTrackByKey(index, key, value, trackByKey);
  3861. if (!cache[id]) {
  3862. cache[id] = frag;
  3863. } else if (trackByKey !== '$index') {
  3864. 'development' !== 'production' && this.warnDuplicate(value);
  3865. }
  3866. } else {
  3867. id = this.id;
  3868. if (hasOwn(value, id)) {
  3869. if (value[id] === null) {
  3870. value[id] = frag;
  3871. } else {
  3872. 'development' !== 'production' && this.warnDuplicate(value);
  3873. }
  3874. } else if (Object.isExtensible(value)) {
  3875. def(value, id, frag);
  3876. } else if ('development' !== 'production') {
  3877. warn('Frozen v-for objects cannot be automatically tracked, make sure to ' + 'provide a track-by key.');
  3878. }
  3879. }
  3880. frag.raw = value;
  3881. },
  3882. /**
  3883. * Get a cached fragment from the value/index/key
  3884. *
  3885. * @param {*} value
  3886. * @param {Number} index
  3887. * @param {String} key
  3888. * @return {Fragment}
  3889. */
  3890. getCachedFrag: function getCachedFrag(value, index, key) {
  3891. var trackByKey = this.params.trackBy;
  3892. var primitive = !isObject(value);
  3893. var frag;
  3894. if (key || trackByKey || primitive) {
  3895. var id = getTrackByKey(index, key, value, trackByKey);
  3896. frag = this.cache[id];
  3897. } else {
  3898. frag = value[this.id];
  3899. }
  3900. if (frag && (frag.reused || frag.fresh)) {
  3901. 'development' !== 'production' && this.warnDuplicate(value);
  3902. }
  3903. return frag;
  3904. },
  3905. /**
  3906. * Delete a fragment from cache.
  3907. *
  3908. * @param {Fragment} frag
  3909. */
  3910. deleteCachedFrag: function deleteCachedFrag(frag) {
  3911. var value = frag.raw;
  3912. var trackByKey = this.params.trackBy;
  3913. var scope = frag.scope;
  3914. var index = scope.$index;
  3915. // fix #948: avoid accidentally fall through to
  3916. // a parent repeater which happens to have $key.
  3917. var key = hasOwn(scope, '$key') && scope.$key;
  3918. var primitive = !isObject(value);
  3919. if (trackByKey || key || primitive) {
  3920. var id = getTrackByKey(index, key, value, trackByKey);
  3921. this.cache[id] = null;
  3922. } else {
  3923. value[this.id] = null;
  3924. frag.raw = null;
  3925. }
  3926. },
  3927. /**
  3928. * Get the stagger amount for an insertion/removal.
  3929. *
  3930. * @param {Fragment} frag
  3931. * @param {Number} index
  3932. * @param {Number} total
  3933. * @param {String} type
  3934. */
  3935. getStagger: function getStagger(frag, index, total, type) {
  3936. type = type + 'Stagger';
  3937. var trans = frag.node.__v_trans;
  3938. var hooks = trans && trans.hooks;
  3939. var hook = hooks && (hooks[type] || hooks.stagger);
  3940. return hook ? hook.call(frag, index, total) : index * parseInt(this.params[type] || this.params.stagger, 10);
  3941. },
  3942. /**
  3943. * Pre-process the value before piping it through the
  3944. * filters. This is passed to and called by the watcher.
  3945. */
  3946. _preProcess: function _preProcess(value) {
  3947. // regardless of type, store the un-filtered raw value.
  3948. this.rawValue = value;
  3949. return value;
  3950. },
  3951. /**
  3952. * Post-process the value after it has been piped through
  3953. * the filters. This is passed to and called by the watcher.
  3954. *
  3955. * It is necessary for this to be called during the
  3956. * wathcer's dependency collection phase because we want
  3957. * the v-for to update when the source Object is mutated.
  3958. */
  3959. _postProcess: function _postProcess(value) {
  3960. if (isArray(value)) {
  3961. return value;
  3962. } else if (isPlainObject(value)) {
  3963. // convert plain object to array.
  3964. var keys = Object.keys(value);
  3965. var i = keys.length;
  3966. var res = new Array(i);
  3967. var key;
  3968. while (i--) {
  3969. key = keys[i];
  3970. res[i] = {
  3971. $key: key,
  3972. $value: value[key]
  3973. };
  3974. }
  3975. return res;
  3976. } else {
  3977. if (typeof value === 'number' && !isNaN(value)) {
  3978. value = range(value);
  3979. }
  3980. return value || [];
  3981. }
  3982. },
  3983. unbind: function unbind() {
  3984. if (this.descriptor.ref) {
  3985. (this._scope || this.vm).$refs[this.descriptor.ref] = null;
  3986. }
  3987. if (this.frags) {
  3988. var i = this.frags.length;
  3989. var frag;
  3990. while (i--) {
  3991. frag = this.frags[i];
  3992. this.deleteCachedFrag(frag);
  3993. frag.destroy();
  3994. }
  3995. }
  3996. }
  3997. };
  3998. /**
  3999. * Helper to find the previous element that is a fragment
  4000. * anchor. This is necessary because a destroyed frag's
  4001. * element could still be lingering in the DOM before its
  4002. * leaving transition finishes, but its inserted flag
  4003. * should have been set to false so we can skip them.
  4004. *
  4005. * If this is a block repeat, we want to make sure we only
  4006. * return frag that is bound to this v-for. (see #929)
  4007. *
  4008. * @param {Fragment} frag
  4009. * @param {Comment|Text} anchor
  4010. * @param {String} id
  4011. * @return {Fragment}
  4012. */
  4013. function findPrevFrag(frag, anchor, id) {
  4014. var el = frag.node.previousSibling;
  4015. /* istanbul ignore if */
  4016. if (!el) return;
  4017. frag = el.__v_frag;
  4018. while ((!frag || frag.forId !== id || !frag.inserted) && el !== anchor) {
  4019. el = el.previousSibling;
  4020. /* istanbul ignore if */
  4021. if (!el) return;
  4022. frag = el.__v_frag;
  4023. }
  4024. return frag;
  4025. }
  4026. /**
  4027. * Find a vm from a fragment.
  4028. *
  4029. * @param {Fragment} frag
  4030. * @return {Vue|undefined}
  4031. */
  4032. function findVmFromFrag(frag) {
  4033. var node = frag.node;
  4034. // handle multi-node frag
  4035. if (frag.end) {
  4036. while (!node.__vue__ && node !== frag.end && node.nextSibling) {
  4037. node = node.nextSibling;
  4038. }
  4039. }
  4040. return node.__vue__;
  4041. }
  4042. /**
  4043. * Create a range array from given number.
  4044. *
  4045. * @param {Number} n
  4046. * @return {Array}
  4047. */
  4048. function range(n) {
  4049. var i = -1;
  4050. var ret = new Array(Math.floor(n));
  4051. while (++i < n) {
  4052. ret[i] = i;
  4053. }
  4054. return ret;
  4055. }
  4056. /**
  4057. * Get the track by key for an item.
  4058. *
  4059. * @param {Number} index
  4060. * @param {String} key
  4061. * @param {*} value
  4062. * @param {String} [trackByKey]
  4063. */
  4064. function getTrackByKey(index, key, value, trackByKey) {
  4065. return trackByKey ? trackByKey === '$index' ? index : trackByKey.charAt(0).match(/\w/) ? getPath(value, trackByKey) : value[trackByKey] : key || value;
  4066. }
  4067. if ('development' !== 'production') {
  4068. vFor.warnDuplicate = function (value) {
  4069. warn('Duplicate value found in v-for="' + this.descriptor.raw + '": ' + JSON.stringify(value) + '. Use track-by="$index" if ' + 'you are expecting duplicate values.', this.vm);
  4070. };
  4071. }
  4072. var vIf = {
  4073. priority: IF,
  4074. terminal: true,
  4075. bind: function bind() {
  4076. var el = this.el;
  4077. if (!el.__vue__) {
  4078. // check else block
  4079. var next = el.nextElementSibling;
  4080. if (next && getAttr(next, 'v-else') !== null) {
  4081. remove(next);
  4082. this.elseEl = next;
  4083. }
  4084. // check main block
  4085. this.anchor = createAnchor('v-if');
  4086. replace(el, this.anchor);
  4087. } else {
  4088. 'development' !== 'production' && warn('v-if="' + this.expression + '" cannot be ' + 'used on an instance root element.', this.vm);
  4089. this.invalid = true;
  4090. }
  4091. },
  4092. update: function update(value) {
  4093. if (this.invalid) return;
  4094. if (value) {
  4095. if (!this.frag) {
  4096. this.insert();
  4097. }
  4098. } else {
  4099. this.remove();
  4100. }
  4101. },
  4102. insert: function insert() {
  4103. if (this.elseFrag) {
  4104. this.elseFrag.remove();
  4105. this.elseFrag = null;
  4106. }
  4107. // lazy init factory
  4108. if (!this.factory) {
  4109. this.factory = new FragmentFactory(this.vm, this.el);
  4110. }
  4111. this.frag = this.factory.create(this._host, this._scope, this._frag);
  4112. this.frag.before(this.anchor);
  4113. },
  4114. remove: function remove() {
  4115. if (this.frag) {
  4116. this.frag.remove();
  4117. this.frag = null;
  4118. }
  4119. if (this.elseEl && !this.elseFrag) {
  4120. if (!this.elseFactory) {
  4121. this.elseFactory = new FragmentFactory(this.elseEl._context || this.vm, this.elseEl);
  4122. }
  4123. this.elseFrag = this.elseFactory.create(this._host, this._scope, this._frag);
  4124. this.elseFrag.before(this.anchor);
  4125. }
  4126. },
  4127. unbind: function unbind() {
  4128. if (this.frag) {
  4129. this.frag.destroy();
  4130. }
  4131. if (this.elseFrag) {
  4132. this.elseFrag.destroy();
  4133. }
  4134. }
  4135. };
  4136. var show = {
  4137. bind: function bind() {
  4138. // check else block
  4139. var next = this.el.nextElementSibling;
  4140. if (next && getAttr(next, 'v-else') !== null) {
  4141. this.elseEl = next;
  4142. }
  4143. },
  4144. update: function update(value) {
  4145. this.apply(this.el, value);
  4146. if (this.elseEl) {
  4147. this.apply(this.elseEl, !value);
  4148. }
  4149. },
  4150. apply: function apply(el, value) {
  4151. if (inDoc(el)) {
  4152. applyTransition(el, value ? 1 : -1, toggle, this.vm);
  4153. } else {
  4154. toggle();
  4155. }
  4156. function toggle() {
  4157. el.style.display = value ? '' : 'none';
  4158. }
  4159. }
  4160. };
  4161. var text$2 = {
  4162. bind: function bind() {
  4163. var self = this;
  4164. var el = this.el;
  4165. var isRange = el.type === 'range';
  4166. var lazy = this.params.lazy;
  4167. var number = this.params.number;
  4168. var debounce = this.params.debounce;
  4169. // handle composition events.
  4170. // http://blog.evanyou.me/2014/01/03/composition-event/
  4171. // skip this for Android because it handles composition
  4172. // events quite differently. Android doesn't trigger
  4173. // composition events for language input methods e.g.
  4174. // Chinese, but instead triggers them for spelling
  4175. // suggestions... (see Discussion/#162)
  4176. var composing = false;
  4177. if (!isAndroid && !isRange) {
  4178. this.on('compositionstart', function () {
  4179. composing = true;
  4180. });
  4181. this.on('compositionend', function () {
  4182. composing = false;
  4183. // in IE11 the "compositionend" event fires AFTER
  4184. // the "input" event, so the input handler is blocked
  4185. // at the end... have to call it here.
  4186. //
  4187. // #1327: in lazy mode this is unecessary.
  4188. if (!lazy) {
  4189. self.listener();
  4190. }
  4191. });
  4192. }
  4193. // prevent messing with the input when user is typing,
  4194. // and force update on blur.
  4195. this.focused = false;
  4196. if (!isRange && !lazy) {
  4197. this.on('focus', function () {
  4198. self.focused = true;
  4199. });
  4200. this.on('blur', function () {
  4201. self.focused = false;
  4202. // do not sync value after fragment removal (#2017)
  4203. if (!self._frag || self._frag.inserted) {
  4204. self.rawListener();
  4205. }
  4206. });
  4207. }
  4208. // Now attach the main listener
  4209. this.listener = this.rawListener = function () {
  4210. if (composing || !self._bound) {
  4211. return;
  4212. }
  4213. var val = number || isRange ? toNumber(el.value) : el.value;
  4214. self.set(val);
  4215. // force update on next tick to avoid lock & same value
  4216. // also only update when user is not typing
  4217. nextTick(function () {
  4218. if (self._bound && !self.focused) {
  4219. self.update(self._watcher.value);
  4220. }
  4221. });
  4222. };
  4223. // apply debounce
  4224. if (debounce) {
  4225. this.listener = _debounce(this.listener, debounce);
  4226. }
  4227. // Support jQuery events, since jQuery.trigger() doesn't
  4228. // trigger native events in some cases and some plugins
  4229. // rely on $.trigger()
  4230. //
  4231. // We want to make sure if a listener is attached using
  4232. // jQuery, it is also removed with jQuery, that's why
  4233. // we do the check for each directive instance and
  4234. // store that check result on itself. This also allows
  4235. // easier test coverage control by unsetting the global
  4236. // jQuery variable in tests.
  4237. this.hasjQuery = typeof jQuery === 'function';
  4238. if (this.hasjQuery) {
  4239. var method = jQuery.fn.on ? 'on' : 'bind';
  4240. jQuery(el)[method]('change', this.rawListener);
  4241. if (!lazy) {
  4242. jQuery(el)[method]('input', this.listener);
  4243. }
  4244. } else {
  4245. this.on('change', this.rawListener);
  4246. if (!lazy) {
  4247. this.on('input', this.listener);
  4248. }
  4249. }
  4250. // IE9 doesn't fire input event on backspace/del/cut
  4251. if (!lazy && isIE9) {
  4252. this.on('cut', function () {
  4253. nextTick(self.listener);
  4254. });
  4255. this.on('keyup', function (e) {
  4256. if (e.keyCode === 46 || e.keyCode === 8) {
  4257. self.listener();
  4258. }
  4259. });
  4260. }
  4261. // set initial value if present
  4262. if (el.hasAttribute('value') || el.tagName === 'TEXTAREA' && el.value.trim()) {
  4263. this.afterBind = this.listener;
  4264. }
  4265. },
  4266. update: function update(value) {
  4267. this.el.value = _toString(value);
  4268. },
  4269. unbind: function unbind() {
  4270. var el = this.el;
  4271. if (this.hasjQuery) {
  4272. var method = jQuery.fn.off ? 'off' : 'unbind';
  4273. jQuery(el)[method]('change', this.listener);
  4274. jQuery(el)[method]('input', this.listener);
  4275. }
  4276. }
  4277. };
  4278. var radio = {
  4279. bind: function bind() {
  4280. var self = this;
  4281. var el = this.el;
  4282. this.getValue = function () {
  4283. // value overwrite via v-bind:value
  4284. if (el.hasOwnProperty('_value')) {
  4285. return el._value;
  4286. }
  4287. var val = el.value;
  4288. if (self.params.number) {
  4289. val = toNumber(val);
  4290. }
  4291. return val;
  4292. };
  4293. this.listener = function () {
  4294. self.set(self.getValue());
  4295. };
  4296. this.on('change', this.listener);
  4297. if (el.hasAttribute('checked')) {
  4298. this.afterBind = this.listener;
  4299. }
  4300. },
  4301. update: function update(value) {
  4302. this.el.checked = looseEqual(value, this.getValue());
  4303. }
  4304. };
  4305. var select = {
  4306. bind: function bind() {
  4307. var self = this;
  4308. var el = this.el;
  4309. // method to force update DOM using latest value.
  4310. this.forceUpdate = function () {
  4311. if (self._watcher) {
  4312. self.update(self._watcher.get());
  4313. }
  4314. };
  4315. // check if this is a multiple select
  4316. var multiple = this.multiple = el.hasAttribute('multiple');
  4317. // attach listener
  4318. this.listener = function () {
  4319. var value = getValue(el, multiple);
  4320. value = self.params.number ? isArray(value) ? value.map(toNumber) : toNumber(value) : value;
  4321. self.set(value);
  4322. };
  4323. this.on('change', this.listener);
  4324. // if has initial value, set afterBind
  4325. var initValue = getValue(el, multiple, true);
  4326. if (multiple && initValue.length || !multiple && initValue !== null) {
  4327. this.afterBind = this.listener;
  4328. }
  4329. // All major browsers except Firefox resets
  4330. // selectedIndex with value -1 to 0 when the element
  4331. // is appended to a new parent, therefore we have to
  4332. // force a DOM update whenever that happens...
  4333. this.vm.$on('hook:attached', this.forceUpdate);
  4334. },
  4335. update: function update(value) {
  4336. var el = this.el;
  4337. el.selectedIndex = -1;
  4338. var multi = this.multiple && isArray(value);
  4339. var options = el.options;
  4340. var i = options.length;
  4341. var op, val;
  4342. while (i--) {
  4343. op = options[i];
  4344. val = op.hasOwnProperty('_value') ? op._value : op.value;
  4345. /* eslint-disable eqeqeq */
  4346. op.selected = multi ? indexOf$1(value, val) > -1 : looseEqual(value, val);
  4347. /* eslint-enable eqeqeq */
  4348. }
  4349. },
  4350. unbind: function unbind() {
  4351. /* istanbul ignore next */
  4352. this.vm.$off('hook:attached', this.forceUpdate);
  4353. }
  4354. };
  4355. /**
  4356. * Get select value
  4357. *
  4358. * @param {SelectElement} el
  4359. * @param {Boolean} multi
  4360. * @param {Boolean} init
  4361. * @return {Array|*}
  4362. */
  4363. function getValue(el, multi, init) {
  4364. var res = multi ? [] : null;
  4365. var op, val, selected;
  4366. for (var i = 0, l = el.options.length; i < l; i++) {
  4367. op = el.options[i];
  4368. selected = init ? op.hasAttribute('selected') : op.selected;
  4369. if (selected) {
  4370. val = op.hasOwnProperty('_value') ? op._value : op.value;
  4371. if (multi) {
  4372. res.push(val);
  4373. } else {
  4374. return val;
  4375. }
  4376. }
  4377. }
  4378. return res;
  4379. }
  4380. /**
  4381. * Native Array.indexOf uses strict equal, but in this
  4382. * case we need to match string/numbers with custom equal.
  4383. *
  4384. * @param {Array} arr
  4385. * @param {*} val
  4386. */
  4387. function indexOf$1(arr, val) {
  4388. var i = arr.length;
  4389. while (i--) {
  4390. if (looseEqual(arr[i], val)) {
  4391. return i;
  4392. }
  4393. }
  4394. return -1;
  4395. }
  4396. var checkbox = {
  4397. bind: function bind() {
  4398. var self = this;
  4399. var el = this.el;
  4400. this.getValue = function () {
  4401. return el.hasOwnProperty('_value') ? el._value : self.params.number ? toNumber(el.value) : el.value;
  4402. };
  4403. function getBooleanValue() {
  4404. var val = el.checked;
  4405. if (val && el.hasOwnProperty('_trueValue')) {
  4406. return el._trueValue;
  4407. }
  4408. if (!val && el.hasOwnProperty('_falseValue')) {
  4409. return el._falseValue;
  4410. }
  4411. return val;
  4412. }
  4413. this.listener = function () {
  4414. var model = self._watcher.value;
  4415. if (isArray(model)) {
  4416. var val = self.getValue();
  4417. if (el.checked) {
  4418. if (indexOf(model, val) < 0) {
  4419. model.push(val);
  4420. }
  4421. } else {
  4422. model.$remove(val);
  4423. }
  4424. } else {
  4425. self.set(getBooleanValue());
  4426. }
  4427. };
  4428. this.on('change', this.listener);
  4429. if (el.hasAttribute('checked')) {
  4430. this.afterBind = this.listener;
  4431. }
  4432. },
  4433. update: function update(value) {
  4434. var el = this.el;
  4435. if (isArray(value)) {
  4436. el.checked = indexOf(value, this.getValue()) > -1;
  4437. } else {
  4438. if (el.hasOwnProperty('_trueValue')) {
  4439. el.checked = looseEqual(value, el._trueValue);
  4440. } else {
  4441. el.checked = !!value;
  4442. }
  4443. }
  4444. }
  4445. };
  4446. var handlers = {
  4447. text: text$2,
  4448. radio: radio,
  4449. select: select,
  4450. checkbox: checkbox
  4451. };
  4452. var model = {
  4453. priority: MODEL,
  4454. twoWay: true,
  4455. handlers: handlers,
  4456. params: ['lazy', 'number', 'debounce'],
  4457. /**
  4458. * Possible elements:
  4459. * <select>
  4460. * <textarea>
  4461. * <input type="*">
  4462. * - text
  4463. * - checkbox
  4464. * - radio
  4465. * - number
  4466. */
  4467. bind: function bind() {
  4468. // friendly warning...
  4469. this.checkFilters();
  4470. if (this.hasRead && !this.hasWrite) {
  4471. 'development' !== 'production' && warn('It seems you are using a read-only filter with ' + 'v-model="' + this.descriptor.raw + '". ' + 'You might want to use a two-way filter to ensure correct behavior.', this.vm);
  4472. }
  4473. var el = this.el;
  4474. var tag = el.tagName;
  4475. var handler;
  4476. if (tag === 'INPUT') {
  4477. handler = handlers[el.type] || handlers.text;
  4478. } else if (tag === 'SELECT') {
  4479. handler = handlers.select;
  4480. } else if (tag === 'TEXTAREA') {
  4481. handler = handlers.text;
  4482. } else {
  4483. 'development' !== 'production' && warn('v-model does not support element type: ' + tag, this.vm);
  4484. return;
  4485. }
  4486. el.__v_model = this;
  4487. handler.bind.call(this);
  4488. this.update = handler.update;
  4489. this._unbind = handler.unbind;
  4490. },
  4491. /**
  4492. * Check read/write filter stats.
  4493. */
  4494. checkFilters: function checkFilters() {
  4495. var filters = this.filters;
  4496. if (!filters) return;
  4497. var i = filters.length;
  4498. while (i--) {
  4499. var filter = resolveAsset(this.vm.$options, 'filters', filters[i].name);
  4500. if (typeof filter === 'function' || filter.read) {
  4501. this.hasRead = true;
  4502. }
  4503. if (filter.write) {
  4504. this.hasWrite = true;
  4505. }
  4506. }
  4507. },
  4508. unbind: function unbind() {
  4509. this.el.__v_model = null;
  4510. this._unbind && this._unbind();
  4511. }
  4512. };
  4513. // keyCode aliases
  4514. var keyCodes = {
  4515. esc: 27,
  4516. tab: 9,
  4517. enter: 13,
  4518. space: 32,
  4519. 'delete': [8, 46],
  4520. up: 38,
  4521. left: 37,
  4522. right: 39,
  4523. down: 40
  4524. };
  4525. function keyFilter(handler, keys) {
  4526. var codes = keys.map(function (key) {
  4527. var charCode = key.charCodeAt(0);
  4528. if (charCode > 47 && charCode < 58) {
  4529. return parseInt(key, 10);
  4530. }
  4531. if (key.length === 1) {
  4532. charCode = key.toUpperCase().charCodeAt(0);
  4533. if (charCode > 64 && charCode < 91) {
  4534. return charCode;
  4535. }
  4536. }
  4537. return keyCodes[key];
  4538. });
  4539. codes = [].concat.apply([], codes);
  4540. return function keyHandler(e) {
  4541. if (codes.indexOf(e.keyCode) > -1) {
  4542. return handler.call(this, e);
  4543. }
  4544. };
  4545. }
  4546. function stopFilter(handler) {
  4547. return function stopHandler(e) {
  4548. e.stopPropagation();
  4549. return handler.call(this, e);
  4550. };
  4551. }
  4552. function preventFilter(handler) {
  4553. return function preventHandler(e) {
  4554. e.preventDefault();
  4555. return handler.call(this, e);
  4556. };
  4557. }
  4558. function selfFilter(handler) {
  4559. return function selfHandler(e) {
  4560. if (e.target === e.currentTarget) {
  4561. return handler.call(this, e);
  4562. }
  4563. };
  4564. }
  4565. var on$1 = {
  4566. priority: ON,
  4567. acceptStatement: true,
  4568. keyCodes: keyCodes,
  4569. bind: function bind() {
  4570. // deal with iframes
  4571. if (this.el.tagName === 'IFRAME' && this.arg !== 'load') {
  4572. var self = this;
  4573. this.iframeBind = function () {
  4574. on(self.el.contentWindow, self.arg, self.handler, self.modifiers.capture);
  4575. };
  4576. this.on('load', this.iframeBind);
  4577. }
  4578. },
  4579. update: function update(handler) {
  4580. // stub a noop for v-on with no value,
  4581. // e.g. @mousedown.prevent
  4582. if (!this.descriptor.raw) {
  4583. handler = function () {};
  4584. }
  4585. if (typeof handler !== 'function') {
  4586. 'development' !== 'production' && warn('v-on:' + this.arg + '="' + this.expression + '" expects a function value, ' + 'got ' + handler, this.vm);
  4587. return;
  4588. }
  4589. // apply modifiers
  4590. if (this.modifiers.stop) {
  4591. handler = stopFilter(handler);
  4592. }
  4593. if (this.modifiers.prevent) {
  4594. handler = preventFilter(handler);
  4595. }
  4596. if (this.modifiers.self) {
  4597. handler = selfFilter(handler);
  4598. }
  4599. // key filter
  4600. var keys = Object.keys(this.modifiers).filter(function (key) {
  4601. return key !== 'stop' && key !== 'prevent' && key !== 'self' && key !== 'capture';
  4602. });
  4603. if (keys.length) {
  4604. handler = keyFilter(handler, keys);
  4605. }
  4606. this.reset();
  4607. this.handler = handler;
  4608. if (this.iframeBind) {
  4609. this.iframeBind();
  4610. } else {
  4611. on(this.el, this.arg, this.handler, this.modifiers.capture);
  4612. }
  4613. },
  4614. reset: function reset() {
  4615. var el = this.iframeBind ? this.el.contentWindow : this.el;
  4616. if (this.handler) {
  4617. off(el, this.arg, this.handler);
  4618. }
  4619. },
  4620. unbind: function unbind() {
  4621. this.reset();
  4622. }
  4623. };
  4624. var prefixes = ['-webkit-', '-moz-', '-ms-'];
  4625. var camelPrefixes = ['Webkit', 'Moz', 'ms'];
  4626. var importantRE = /!important;?$/;
  4627. var propCache = Object.create(null);
  4628. var testEl = null;
  4629. var style = {
  4630. deep: true,
  4631. update: function update(value) {
  4632. if (typeof value === 'string') {
  4633. this.el.style.cssText = value;
  4634. } else if (isArray(value)) {
  4635. this.handleObject(value.reduce(extend, {}));
  4636. } else {
  4637. this.handleObject(value || {});
  4638. }
  4639. },
  4640. handleObject: function handleObject(value) {
  4641. // cache object styles so that only changed props
  4642. // are actually updated.
  4643. var cache = this.cache || (this.cache = {});
  4644. var name, val;
  4645. for (name in cache) {
  4646. if (!(name in value)) {
  4647. this.handleSingle(name, null);
  4648. delete cache[name];
  4649. }
  4650. }
  4651. for (name in value) {
  4652. val = value[name];
  4653. if (val !== cache[name]) {
  4654. cache[name] = val;
  4655. this.handleSingle(name, val);
  4656. }
  4657. }
  4658. },
  4659. handleSingle: function handleSingle(prop, value) {
  4660. prop = normalize(prop);
  4661. if (!prop) return; // unsupported prop
  4662. // cast possible numbers/booleans into strings
  4663. if (value != null) value += '';
  4664. if (value) {
  4665. var isImportant = importantRE.test(value) ? 'important' : '';
  4666. if (isImportant) {
  4667. /* istanbul ignore if */
  4668. if ('development' !== 'production') {
  4669. warn('It\'s probably a bad idea to use !important with inline rules. ' + 'This feature will be deprecated in a future version of Vue.');
  4670. }
  4671. value = value.replace(importantRE, '').trim();
  4672. this.el.style.setProperty(prop.kebab, value, isImportant);
  4673. } else {
  4674. this.el.style[prop.camel] = value;
  4675. }
  4676. } else {
  4677. this.el.style[prop.camel] = '';
  4678. }
  4679. }
  4680. };
  4681. /**
  4682. * Normalize a CSS property name.
  4683. * - cache result
  4684. * - auto prefix
  4685. * - camelCase -> dash-case
  4686. *
  4687. * @param {String} prop
  4688. * @return {String}
  4689. */
  4690. function normalize(prop) {
  4691. if (propCache[prop]) {
  4692. return propCache[prop];
  4693. }
  4694. var res = prefix(prop);
  4695. propCache[prop] = propCache[res] = res;
  4696. return res;
  4697. }
  4698. /**
  4699. * Auto detect the appropriate prefix for a CSS property.
  4700. * https://gist.github.com/paulirish/523692
  4701. *
  4702. * @param {String} prop
  4703. * @return {String}
  4704. */
  4705. function prefix(prop) {
  4706. prop = hyphenate(prop);
  4707. var camel = camelize(prop);
  4708. var upper = camel.charAt(0).toUpperCase() + camel.slice(1);
  4709. if (!testEl) {
  4710. testEl = document.createElement('div');
  4711. }
  4712. var i = prefixes.length;
  4713. var prefixed;
  4714. if (camel !== 'filter' && camel in testEl.style) {
  4715. return {
  4716. kebab: prop,
  4717. camel: camel
  4718. };
  4719. }
  4720. while (i--) {
  4721. prefixed = camelPrefixes[i] + upper;
  4722. if (prefixed in testEl.style) {
  4723. return {
  4724. kebab: prefixes[i] + prop,
  4725. camel: prefixed
  4726. };
  4727. }
  4728. }
  4729. }
  4730. // xlink
  4731. var xlinkNS = 'http://www.w3.org/1999/xlink';
  4732. var xlinkRE = /^xlink:/;
  4733. // check for attributes that prohibit interpolations
  4734. var disallowedInterpAttrRE = /^v-|^:|^@|^(?:is|transition|transition-mode|debounce|track-by|stagger|enter-stagger|leave-stagger)$/;
  4735. // these attributes should also set their corresponding properties
  4736. // because they only affect the initial state of the element
  4737. var attrWithPropsRE = /^(?:value|checked|selected|muted)$/;
  4738. // these attributes expect enumrated values of "true" or "false"
  4739. // but are not boolean attributes
  4740. var enumeratedAttrRE = /^(?:draggable|contenteditable|spellcheck)$/;
  4741. // these attributes should set a hidden property for
  4742. // binding v-model to object values
  4743. var modelProps = {
  4744. value: '_value',
  4745. 'true-value': '_trueValue',
  4746. 'false-value': '_falseValue'
  4747. };
  4748. var bind$1 = {
  4749. priority: BIND,
  4750. bind: function bind() {
  4751. var attr = this.arg;
  4752. var tag = this.el.tagName;
  4753. // should be deep watch on object mode
  4754. if (!attr) {
  4755. this.deep = true;
  4756. }
  4757. // handle interpolation bindings
  4758. var descriptor = this.descriptor;
  4759. var tokens = descriptor.interp;
  4760. if (tokens) {
  4761. // handle interpolations with one-time tokens
  4762. if (descriptor.hasOneTime) {
  4763. this.expression = tokensToExp(tokens, this._scope || this.vm);
  4764. }
  4765. // only allow binding on native attributes
  4766. if (disallowedInterpAttrRE.test(attr) || attr === 'name' && (tag === 'PARTIAL' || tag === 'SLOT')) {
  4767. 'development' !== 'production' && warn(attr + '="' + descriptor.raw + '": ' + 'attribute interpolation is not allowed in Vue.js ' + 'directives and special attributes.', this.vm);
  4768. this.el.removeAttribute(attr);
  4769. this.invalid = true;
  4770. }
  4771. /* istanbul ignore if */
  4772. if ('development' !== 'production') {
  4773. var raw = attr + '="' + descriptor.raw + '": ';
  4774. // warn src
  4775. if (attr === 'src') {
  4776. warn(raw + 'interpolation in "src" attribute will cause ' + 'a 404 request. Use v-bind:src instead.', this.vm);
  4777. }
  4778. // warn style
  4779. if (attr === 'style') {
  4780. warn(raw + 'interpolation in "style" attribute will cause ' + 'the attribute to be discarded in Internet Explorer. ' + 'Use v-bind:style instead.', this.vm);
  4781. }
  4782. }
  4783. }
  4784. },
  4785. update: function update(value) {
  4786. if (this.invalid) {
  4787. return;
  4788. }
  4789. var attr = this.arg;
  4790. if (this.arg) {
  4791. this.handleSingle(attr, value);
  4792. } else {
  4793. this.handleObject(value || {});
  4794. }
  4795. },
  4796. // share object handler with v-bind:class
  4797. handleObject: style.handleObject,
  4798. handleSingle: function handleSingle(attr, value) {
  4799. var el = this.el;
  4800. var interp = this.descriptor.interp;
  4801. if (this.modifiers.camel) {
  4802. attr = camelize(attr);
  4803. }
  4804. if (!interp && attrWithPropsRE.test(attr) && attr in el) {
  4805. var attrValue = attr === 'value' ? value == null // IE9 will set input.value to "null" for null...
  4806. ? '' : value : value;
  4807. if (el[attr] !== attrValue) {
  4808. el[attr] = attrValue;
  4809. }
  4810. }
  4811. // set model props
  4812. var modelProp = modelProps[attr];
  4813. if (!interp && modelProp) {
  4814. el[modelProp] = value;
  4815. // update v-model if present
  4816. var model = el.__v_model;
  4817. if (model) {
  4818. model.listener();
  4819. }
  4820. }
  4821. // do not set value attribute for textarea
  4822. if (attr === 'value' && el.tagName === 'TEXTAREA') {
  4823. el.removeAttribute(attr);
  4824. return;
  4825. }
  4826. // update attribute
  4827. if (enumeratedAttrRE.test(attr)) {
  4828. el.setAttribute(attr, value ? 'true' : 'false');
  4829. } else if (value != null && value !== false) {
  4830. if (attr === 'class') {
  4831. // handle edge case #1960:
  4832. // class interpolation should not overwrite Vue transition class
  4833. if (el.__v_trans) {
  4834. value += ' ' + el.__v_trans.id + '-transition';
  4835. }
  4836. setClass(el, value);
  4837. } else if (xlinkRE.test(attr)) {
  4838. el.setAttributeNS(xlinkNS, attr, value === true ? '' : value);
  4839. } else {
  4840. el.setAttribute(attr, value === true ? '' : value);
  4841. }
  4842. } else {
  4843. el.removeAttribute(attr);
  4844. }
  4845. }
  4846. };
  4847. var el = {
  4848. priority: EL,
  4849. bind: function bind() {
  4850. /* istanbul ignore if */
  4851. if (!this.arg) {
  4852. return;
  4853. }
  4854. var id = this.id = camelize(this.arg);
  4855. var refs = (this._scope || this.vm).$els;
  4856. if (hasOwn(refs, id)) {
  4857. refs[id] = this.el;
  4858. } else {
  4859. defineReactive(refs, id, this.el);
  4860. }
  4861. },
  4862. unbind: function unbind() {
  4863. var refs = (this._scope || this.vm).$els;
  4864. if (refs[this.id] === this.el) {
  4865. refs[this.id] = null;
  4866. }
  4867. }
  4868. };
  4869. var ref = {
  4870. bind: function bind() {
  4871. 'development' !== 'production' && warn('v-ref:' + this.arg + ' must be used on a child ' + 'component. Found on <' + this.el.tagName.toLowerCase() + '>.', this.vm);
  4872. }
  4873. };
  4874. var cloak = {
  4875. bind: function bind() {
  4876. var el = this.el;
  4877. this.vm.$once('pre-hook:compiled', function () {
  4878. el.removeAttribute('v-cloak');
  4879. });
  4880. }
  4881. };
  4882. // must export plain object
  4883. var directives = {
  4884. text: text$1,
  4885. html: html,
  4886. 'for': vFor,
  4887. 'if': vIf,
  4888. show: show,
  4889. model: model,
  4890. on: on$1,
  4891. bind: bind$1,
  4892. el: el,
  4893. ref: ref,
  4894. cloak: cloak
  4895. };
  4896. var vClass = {
  4897. deep: true,
  4898. update: function update(value) {
  4899. if (!value) {
  4900. this.cleanup();
  4901. } else if (typeof value === 'string') {
  4902. this.setClass(value.trim().split(/\s+/));
  4903. } else {
  4904. this.setClass(normalize$1(value));
  4905. }
  4906. },
  4907. setClass: function setClass(value) {
  4908. this.cleanup(value);
  4909. for (var i = 0, l = value.length; i < l; i++) {
  4910. var val = value[i];
  4911. if (val) {
  4912. apply(this.el, val, addClass);
  4913. }
  4914. }
  4915. this.prevKeys = value;
  4916. },
  4917. cleanup: function cleanup(value) {
  4918. var prevKeys = this.prevKeys;
  4919. if (!prevKeys) return;
  4920. var i = prevKeys.length;
  4921. while (i--) {
  4922. var key = prevKeys[i];
  4923. if (!value || value.indexOf(key) < 0) {
  4924. apply(this.el, key, removeClass);
  4925. }
  4926. }
  4927. }
  4928. };
  4929. /**
  4930. * Normalize objects and arrays (potentially containing objects)
  4931. * into array of strings.
  4932. *
  4933. * @param {Object|Array<String|Object>} value
  4934. * @return {Array<String>}
  4935. */
  4936. function normalize$1(value) {
  4937. var res = [];
  4938. if (isArray(value)) {
  4939. for (var i = 0, l = value.length; i < l; i++) {
  4940. var _key = value[i];
  4941. if (_key) {
  4942. if (typeof _key === 'string') {
  4943. res.push(_key);
  4944. } else {
  4945. for (var k in _key) {
  4946. if (_key[k]) res.push(k);
  4947. }
  4948. }
  4949. }
  4950. }
  4951. } else if (isObject(value)) {
  4952. for (var key in value) {
  4953. if (value[key]) res.push(key);
  4954. }
  4955. }
  4956. return res;
  4957. }
  4958. /**
  4959. * Add or remove a class/classes on an element
  4960. *
  4961. * @param {Element} el
  4962. * @param {String} key The class name. This may or may not
  4963. * contain a space character, in such a
  4964. * case we'll deal with multiple class
  4965. * names at once.
  4966. * @param {Function} fn
  4967. */
  4968. function apply(el, key, fn) {
  4969. key = key.trim();
  4970. if (key.indexOf(' ') === -1) {
  4971. fn(el, key);
  4972. return;
  4973. }
  4974. // The key contains one or more space characters.
  4975. // Since a class name doesn't accept such characters, we
  4976. // treat it as multiple classes.
  4977. var keys = key.split(/\s+/);
  4978. for (var i = 0, l = keys.length; i < l; i++) {
  4979. fn(el, keys[i]);
  4980. }
  4981. }
  4982. var component = {
  4983. priority: COMPONENT,
  4984. params: ['keep-alive', 'transition-mode', 'inline-template'],
  4985. /**
  4986. * Setup. Two possible usages:
  4987. *
  4988. * - static:
  4989. * <comp> or <div v-component="comp">
  4990. *
  4991. * - dynamic:
  4992. * <component :is="view">
  4993. */
  4994. bind: function bind() {
  4995. if (!this.el.__vue__) {
  4996. // keep-alive cache
  4997. this.keepAlive = this.params.keepAlive;
  4998. if (this.keepAlive) {
  4999. this.cache = {};
  5000. }
  5001. // check inline-template
  5002. if (this.params.inlineTemplate) {
  5003. // extract inline template as a DocumentFragment
  5004. this.inlineTemplate = extractContent(this.el, true);
  5005. }
  5006. // component resolution related state
  5007. this.pendingComponentCb = this.Component = null;
  5008. // transition related state
  5009. this.pendingRemovals = 0;
  5010. this.pendingRemovalCb = null;
  5011. // create a ref anchor
  5012. this.anchor = createAnchor('v-component');
  5013. replace(this.el, this.anchor);
  5014. // remove is attribute.
  5015. // this is removed during compilation, but because compilation is
  5016. // cached, when the component is used elsewhere this attribute
  5017. // will remain at link time.
  5018. this.el.removeAttribute('is');
  5019. this.el.removeAttribute(':is');
  5020. // remove ref, same as above
  5021. if (this.descriptor.ref) {
  5022. this.el.removeAttribute('v-ref:' + hyphenate(this.descriptor.ref));
  5023. }
  5024. // if static, build right now.
  5025. if (this.literal) {
  5026. this.setComponent(this.expression);
  5027. }
  5028. } else {
  5029. 'development' !== 'production' && warn('cannot mount component "' + this.expression + '" ' + 'on already mounted element: ' + this.el);
  5030. }
  5031. },
  5032. /**
  5033. * Public update, called by the watcher in the dynamic
  5034. * literal scenario, e.g. <component :is="view">
  5035. */
  5036. update: function update(value) {
  5037. if (!this.literal) {
  5038. this.setComponent(value);
  5039. }
  5040. },
  5041. /**
  5042. * Switch dynamic components. May resolve the component
  5043. * asynchronously, and perform transition based on
  5044. * specified transition mode. Accepts a few additional
  5045. * arguments specifically for vue-router.
  5046. *
  5047. * The callback is called when the full transition is
  5048. * finished.
  5049. *
  5050. * @param {String} value
  5051. * @param {Function} [cb]
  5052. */
  5053. setComponent: function setComponent(value, cb) {
  5054. this.invalidatePending();
  5055. if (!value) {
  5056. // just remove current
  5057. this.unbuild(true);
  5058. this.remove(this.childVM, cb);
  5059. this.childVM = null;
  5060. } else {
  5061. var self = this;
  5062. this.resolveComponent(value, function () {
  5063. self.mountComponent(cb);
  5064. });
  5065. }
  5066. },
  5067. /**
  5068. * Resolve the component constructor to use when creating
  5069. * the child vm.
  5070. *
  5071. * @param {String|Function} value
  5072. * @param {Function} cb
  5073. */
  5074. resolveComponent: function resolveComponent(value, cb) {
  5075. var self = this;
  5076. this.pendingComponentCb = cancellable(function (Component) {
  5077. self.ComponentName = Component.options.name || (typeof value === 'string' ? value : null);
  5078. self.Component = Component;
  5079. cb();
  5080. });
  5081. this.vm._resolveComponent(value, this.pendingComponentCb);
  5082. },
  5083. /**
  5084. * Create a new instance using the current constructor and
  5085. * replace the existing instance. This method doesn't care
  5086. * whether the new component and the old one are actually
  5087. * the same.
  5088. *
  5089. * @param {Function} [cb]
  5090. */
  5091. mountComponent: function mountComponent(cb) {
  5092. // actual mount
  5093. this.unbuild(true);
  5094. var self = this;
  5095. var activateHooks = this.Component.options.activate;
  5096. var cached = this.getCached();
  5097. var newComponent = this.build();
  5098. if (activateHooks && !cached) {
  5099. this.waitingFor = newComponent;
  5100. callActivateHooks(activateHooks, newComponent, function () {
  5101. if (self.waitingFor !== newComponent) {
  5102. return;
  5103. }
  5104. self.waitingFor = null;
  5105. self.transition(newComponent, cb);
  5106. });
  5107. } else {
  5108. // update ref for kept-alive component
  5109. if (cached) {
  5110. newComponent._updateRef();
  5111. }
  5112. this.transition(newComponent, cb);
  5113. }
  5114. },
  5115. /**
  5116. * When the component changes or unbinds before an async
  5117. * constructor is resolved, we need to invalidate its
  5118. * pending callback.
  5119. */
  5120. invalidatePending: function invalidatePending() {
  5121. if (this.pendingComponentCb) {
  5122. this.pendingComponentCb.cancel();
  5123. this.pendingComponentCb = null;
  5124. }
  5125. },
  5126. /**
  5127. * Instantiate/insert a new child vm.
  5128. * If keep alive and has cached instance, insert that
  5129. * instance; otherwise build a new one and cache it.
  5130. *
  5131. * @param {Object} [extraOptions]
  5132. * @return {Vue} - the created instance
  5133. */
  5134. build: function build(extraOptions) {
  5135. var cached = this.getCached();
  5136. if (cached) {
  5137. return cached;
  5138. }
  5139. if (this.Component) {
  5140. // default options
  5141. var options = {
  5142. name: this.ComponentName,
  5143. el: cloneNode(this.el),
  5144. template: this.inlineTemplate,
  5145. // make sure to add the child with correct parent
  5146. // if this is a transcluded component, its parent
  5147. // should be the transclusion host.
  5148. parent: this._host || this.vm,
  5149. // if no inline-template, then the compiled
  5150. // linker can be cached for better performance.
  5151. _linkerCachable: !this.inlineTemplate,
  5152. _ref: this.descriptor.ref,
  5153. _asComponent: true,
  5154. _isRouterView: this._isRouterView,
  5155. // if this is a transcluded component, context
  5156. // will be the common parent vm of this instance
  5157. // and its host.
  5158. _context: this.vm,
  5159. // if this is inside an inline v-for, the scope
  5160. // will be the intermediate scope created for this
  5161. // repeat fragment. this is used for linking props
  5162. // and container directives.
  5163. _scope: this._scope,
  5164. // pass in the owner fragment of this component.
  5165. // this is necessary so that the fragment can keep
  5166. // track of its contained components in order to
  5167. // call attach/detach hooks for them.
  5168. _frag: this._frag
  5169. };
  5170. // extra options
  5171. // in 1.0.0 this is used by vue-router only
  5172. /* istanbul ignore if */
  5173. if (extraOptions) {
  5174. extend(options, extraOptions);
  5175. }
  5176. var child = new this.Component(options);
  5177. if (this.keepAlive) {
  5178. this.cache[this.Component.cid] = child;
  5179. }
  5180. /* istanbul ignore if */
  5181. if ('development' !== 'production' && this.el.hasAttribute('transition') && child._isFragment) {
  5182. warn('Transitions will not work on a fragment instance. ' + 'Template: ' + child.$options.template, child);
  5183. }
  5184. return child;
  5185. }
  5186. },
  5187. /**
  5188. * Try to get a cached instance of the current component.
  5189. *
  5190. * @return {Vue|undefined}
  5191. */
  5192. getCached: function getCached() {
  5193. return this.keepAlive && this.cache[this.Component.cid];
  5194. },
  5195. /**
  5196. * Teardown the current child, but defers cleanup so
  5197. * that we can separate the destroy and removal steps.
  5198. *
  5199. * @param {Boolean} defer
  5200. */
  5201. unbuild: function unbuild(defer) {
  5202. if (this.waitingFor) {
  5203. if (!this.keepAlive) {
  5204. this.waitingFor.$destroy();
  5205. }
  5206. this.waitingFor = null;
  5207. }
  5208. var child = this.childVM;
  5209. if (!child || this.keepAlive) {
  5210. if (child) {
  5211. // remove ref
  5212. child._inactive = true;
  5213. child._updateRef(true);
  5214. }
  5215. return;
  5216. }
  5217. // the sole purpose of `deferCleanup` is so that we can
  5218. // "deactivate" the vm right now and perform DOM removal
  5219. // later.
  5220. child.$destroy(false, defer);
  5221. },
  5222. /**
  5223. * Remove current destroyed child and manually do
  5224. * the cleanup after removal.
  5225. *
  5226. * @param {Function} cb
  5227. */
  5228. remove: function remove(child, cb) {
  5229. var keepAlive = this.keepAlive;
  5230. if (child) {
  5231. // we may have a component switch when a previous
  5232. // component is still being transitioned out.
  5233. // we want to trigger only one lastest insertion cb
  5234. // when the existing transition finishes. (#1119)
  5235. this.pendingRemovals++;
  5236. this.pendingRemovalCb = cb;
  5237. var self = this;
  5238. child.$remove(function () {
  5239. self.pendingRemovals--;
  5240. if (!keepAlive) child._cleanup();
  5241. if (!self.pendingRemovals && self.pendingRemovalCb) {
  5242. self.pendingRemovalCb();
  5243. self.pendingRemovalCb = null;
  5244. }
  5245. });
  5246. } else if (cb) {
  5247. cb();
  5248. }
  5249. },
  5250. /**
  5251. * Actually swap the components, depending on the
  5252. * transition mode. Defaults to simultaneous.
  5253. *
  5254. * @param {Vue} target
  5255. * @param {Function} [cb]
  5256. */
  5257. transition: function transition(target, cb) {
  5258. var self = this;
  5259. var current = this.childVM;
  5260. // for devtool inspection
  5261. if (current) current._inactive = true;
  5262. target._inactive = false;
  5263. this.childVM = target;
  5264. switch (self.params.transitionMode) {
  5265. case 'in-out':
  5266. target.$before(self.anchor, function () {
  5267. self.remove(current, cb);
  5268. });
  5269. break;
  5270. case 'out-in':
  5271. self.remove(current, function () {
  5272. target.$before(self.anchor, cb);
  5273. });
  5274. break;
  5275. default:
  5276. self.remove(current);
  5277. target.$before(self.anchor, cb);
  5278. }
  5279. },
  5280. /**
  5281. * Unbind.
  5282. */
  5283. unbind: function unbind() {
  5284. this.invalidatePending();
  5285. // Do not defer cleanup when unbinding
  5286. this.unbuild();
  5287. // destroy all keep-alive cached instances
  5288. if (this.cache) {
  5289. for (var key in this.cache) {
  5290. this.cache[key].$destroy();
  5291. }
  5292. this.cache = null;
  5293. }
  5294. }
  5295. };
  5296. /**
  5297. * Call activate hooks in order (asynchronous)
  5298. *
  5299. * @param {Array} hooks
  5300. * @param {Vue} vm
  5301. * @param {Function} cb
  5302. */
  5303. function callActivateHooks(hooks, vm, cb) {
  5304. var total = hooks.length;
  5305. var called = 0;
  5306. hooks[0].call(vm, next);
  5307. function next() {
  5308. if (++called >= total) {
  5309. cb();
  5310. } else {
  5311. hooks[called].call(vm, next);
  5312. }
  5313. }
  5314. }
  5315. var propBindingModes = config._propBindingModes;
  5316. var empty = {};
  5317. // regexes
  5318. var identRE$1 = /^[$_a-zA-Z]+[\w$]*$/;
  5319. var settablePathRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\[[^\[\]]+\])*$/;
  5320. /**
  5321. * Compile props on a root element and return
  5322. * a props link function.
  5323. *
  5324. * @param {Element|DocumentFragment} el
  5325. * @param {Array} propOptions
  5326. * @param {Vue} vm
  5327. * @return {Function} propsLinkFn
  5328. */
  5329. function compileProps(el, propOptions, vm) {
  5330. var props = [];
  5331. var names = Object.keys(propOptions);
  5332. var i = names.length;
  5333. var options, name, attr, value, path, parsed, prop;
  5334. while (i--) {
  5335. name = names[i];
  5336. options = propOptions[name] || empty;
  5337. if ('development' !== 'production' && name === '$data') {
  5338. warn('Do not use $data as prop.', vm);
  5339. continue;
  5340. }
  5341. // props could contain dashes, which will be
  5342. // interpreted as minus calculations by the parser
  5343. // so we need to camelize the path here
  5344. path = camelize(name);
  5345. if (!identRE$1.test(path)) {
  5346. 'development' !== 'production' && warn('Invalid prop key: "' + name + '". Prop keys ' + 'must be valid identifiers.', vm);
  5347. continue;
  5348. }
  5349. prop = {
  5350. name: name,
  5351. path: path,
  5352. options: options,
  5353. mode: propBindingModes.ONE_WAY,
  5354. raw: null
  5355. };
  5356. attr = hyphenate(name);
  5357. // first check dynamic version
  5358. if ((value = getBindAttr(el, attr)) === null) {
  5359. if ((value = getBindAttr(el, attr + '.sync')) !== null) {
  5360. prop.mode = propBindingModes.TWO_WAY;
  5361. } else if ((value = getBindAttr(el, attr + '.once')) !== null) {
  5362. prop.mode = propBindingModes.ONE_TIME;
  5363. }
  5364. }
  5365. if (value !== null) {
  5366. // has dynamic binding!
  5367. prop.raw = value;
  5368. parsed = parseDirective(value);
  5369. value = parsed.expression;
  5370. prop.filters = parsed.filters;
  5371. // check binding type
  5372. if (isLiteral(value) && !parsed.filters) {
  5373. // for expressions containing literal numbers and
  5374. // booleans, there's no need to setup a prop binding,
  5375. // so we can optimize them as a one-time set.
  5376. prop.optimizedLiteral = true;
  5377. } else {
  5378. prop.dynamic = true;
  5379. // check non-settable path for two-way bindings
  5380. if ('development' !== 'production' && prop.mode === propBindingModes.TWO_WAY && !settablePathRE.test(value)) {
  5381. prop.mode = propBindingModes.ONE_WAY;
  5382. warn('Cannot bind two-way prop with non-settable ' + 'parent path: ' + value, vm);
  5383. }
  5384. }
  5385. prop.parentPath = value;
  5386. // warn required two-way
  5387. if ('development' !== 'production' && options.twoWay && prop.mode !== propBindingModes.TWO_WAY) {
  5388. warn('Prop "' + name + '" expects a two-way binding type.', vm);
  5389. }
  5390. } else if ((value = getAttr(el, attr)) !== null) {
  5391. // has literal binding!
  5392. prop.raw = value;
  5393. } else if ('development' !== 'production') {
  5394. // check possible camelCase prop usage
  5395. var lowerCaseName = path.toLowerCase();
  5396. value = /[A-Z\-]/.test(name) && (el.getAttribute(lowerCaseName) || el.getAttribute(':' + lowerCaseName) || el.getAttribute('v-bind:' + lowerCaseName) || el.getAttribute(':' + lowerCaseName + '.once') || el.getAttribute('v-bind:' + lowerCaseName + '.once') || el.getAttribute(':' + lowerCaseName + '.sync') || el.getAttribute('v-bind:' + lowerCaseName + '.sync'));
  5397. if (value) {
  5398. warn('Possible usage error for prop `' + lowerCaseName + '` - ' + 'did you mean `' + attr + '`? HTML is case-insensitive, remember to use ' + 'kebab-case for props in templates.', vm);
  5399. } else if (options.required) {
  5400. // warn missing required
  5401. warn('Missing required prop: ' + name, vm);
  5402. }
  5403. }
  5404. // push prop
  5405. props.push(prop);
  5406. }
  5407. return makePropsLinkFn(props);
  5408. }
  5409. /**
  5410. * Build a function that applies props to a vm.
  5411. *
  5412. * @param {Array} props
  5413. * @return {Function} propsLinkFn
  5414. */
  5415. function makePropsLinkFn(props) {
  5416. return function propsLinkFn(vm, scope) {
  5417. // store resolved props info
  5418. vm._props = {};
  5419. var inlineProps = vm.$options.propsData;
  5420. var i = props.length;
  5421. var prop, path, options, value, raw;
  5422. while (i--) {
  5423. prop = props[i];
  5424. raw = prop.raw;
  5425. path = prop.path;
  5426. options = prop.options;
  5427. vm._props[path] = prop;
  5428. if (inlineProps && hasOwn(inlineProps, path)) {
  5429. initProp(vm, prop, inlineProps[path]);
  5430. }if (raw === null) {
  5431. // initialize absent prop
  5432. initProp(vm, prop, undefined);
  5433. } else if (prop.dynamic) {
  5434. // dynamic prop
  5435. if (prop.mode === propBindingModes.ONE_TIME) {
  5436. // one time binding
  5437. value = (scope || vm._context || vm).$get(prop.parentPath);
  5438. initProp(vm, prop, value);
  5439. } else {
  5440. if (vm._context) {
  5441. // dynamic binding
  5442. vm._bindDir({
  5443. name: 'prop',
  5444. def: propDef,
  5445. prop: prop
  5446. }, null, null, scope); // el, host, scope
  5447. } else {
  5448. // root instance
  5449. initProp(vm, prop, vm.$get(prop.parentPath));
  5450. }
  5451. }
  5452. } else if (prop.optimizedLiteral) {
  5453. // optimized literal, cast it and just set once
  5454. var stripped = stripQuotes(raw);
  5455. value = stripped === raw ? toBoolean(toNumber(raw)) : stripped;
  5456. initProp(vm, prop, value);
  5457. } else {
  5458. // string literal, but we need to cater for
  5459. // Boolean props with no value, or with same
  5460. // literal value (e.g. disabled="disabled")
  5461. // see https://github.com/vuejs/vue-loader/issues/182
  5462. value = options.type === Boolean && (raw === '' || raw === hyphenate(prop.name)) ? true : raw;
  5463. initProp(vm, prop, value);
  5464. }
  5465. }
  5466. };
  5467. }
  5468. /**
  5469. * Process a prop with a rawValue, applying necessary coersions,
  5470. * default values & assertions and call the given callback with
  5471. * processed value.
  5472. *
  5473. * @param {Vue} vm
  5474. * @param {Object} prop
  5475. * @param {*} rawValue
  5476. * @param {Function} fn
  5477. */
  5478. function processPropValue(vm, prop, rawValue, fn) {
  5479. var isSimple = prop.dynamic && isSimplePath(prop.parentPath);
  5480. var value = rawValue;
  5481. if (value === undefined) {
  5482. value = getPropDefaultValue(vm, prop);
  5483. }
  5484. value = coerceProp(prop, value);
  5485. var coerced = value !== rawValue;
  5486. if (!assertProp(prop, value, vm)) {
  5487. value = undefined;
  5488. }
  5489. if (isSimple && !coerced) {
  5490. withoutConversion(function () {
  5491. fn(value);
  5492. });
  5493. } else {
  5494. fn(value);
  5495. }
  5496. }
  5497. /**
  5498. * Set a prop's initial value on a vm and its data object.
  5499. *
  5500. * @param {Vue} vm
  5501. * @param {Object} prop
  5502. * @param {*} value
  5503. */
  5504. function initProp(vm, prop, value) {
  5505. processPropValue(vm, prop, value, function (value) {
  5506. defineReactive(vm, prop.path, value);
  5507. });
  5508. }
  5509. /**
  5510. * Update a prop's value on a vm.
  5511. *
  5512. * @param {Vue} vm
  5513. * @param {Object} prop
  5514. * @param {*} value
  5515. */
  5516. function updateProp(vm, prop, value) {
  5517. processPropValue(vm, prop, value, function (value) {
  5518. vm[prop.path] = value;
  5519. });
  5520. }
  5521. /**
  5522. * Get the default value of a prop.
  5523. *
  5524. * @param {Vue} vm
  5525. * @param {Object} prop
  5526. * @return {*}
  5527. */
  5528. function getPropDefaultValue(vm, prop) {
  5529. // no default, return undefined
  5530. var options = prop.options;
  5531. if (!hasOwn(options, 'default')) {
  5532. // absent boolean value defaults to false
  5533. return options.type === Boolean ? false : undefined;
  5534. }
  5535. var def = options['default'];
  5536. // warn against non-factory defaults for Object & Array
  5537. if (isObject(def)) {
  5538. 'development' !== 'production' && warn('Invalid default value for prop "' + prop.name + '": ' + 'Props with type Object/Array must use a factory function ' + 'to return the default value.', vm);
  5539. }
  5540. // call factory function for non-Function types
  5541. return typeof def === 'function' && options.type !== Function ? def.call(vm) : def;
  5542. }
  5543. /**
  5544. * Assert whether a prop is valid.
  5545. *
  5546. * @param {Object} prop
  5547. * @param {*} value
  5548. * @param {Vue} vm
  5549. */
  5550. function assertProp(prop, value, vm) {
  5551. if (!prop.options.required && ( // non-required
  5552. prop.raw === null || // abscent
  5553. value == null) // null or undefined
  5554. ) {
  5555. return true;
  5556. }
  5557. var options = prop.options;
  5558. var type = options.type;
  5559. var valid = !type;
  5560. var expectedTypes = [];
  5561. if (type) {
  5562. if (!isArray(type)) {
  5563. type = [type];
  5564. }
  5565. for (var i = 0; i < type.length && !valid; i++) {
  5566. var assertedType = assertType(value, type[i]);
  5567. expectedTypes.push(assertedType.expectedType);
  5568. valid = assertedType.valid;
  5569. }
  5570. }
  5571. if (!valid) {
  5572. if ('development' !== 'production') {
  5573. warn('Invalid prop: type check failed for prop "' + prop.name + '".' + ' Expected ' + expectedTypes.map(formatType).join(', ') + ', got ' + formatValue(value) + '.', vm);
  5574. }
  5575. return false;
  5576. }
  5577. var validator = options.validator;
  5578. if (validator) {
  5579. if (!validator(value)) {
  5580. 'development' !== 'production' && warn('Invalid prop: custom validator check failed for prop "' + prop.name + '".', vm);
  5581. return false;
  5582. }
  5583. }
  5584. return true;
  5585. }
  5586. /**
  5587. * Force parsing value with coerce option.
  5588. *
  5589. * @param {*} value
  5590. * @param {Object} options
  5591. * @return {*}
  5592. */
  5593. function coerceProp(prop, value) {
  5594. var coerce = prop.options.coerce;
  5595. if (!coerce) {
  5596. return value;
  5597. }
  5598. // coerce is a function
  5599. return coerce(value);
  5600. }
  5601. /**
  5602. * Assert the type of a value
  5603. *
  5604. * @param {*} value
  5605. * @param {Function} type
  5606. * @return {Object}
  5607. */
  5608. function assertType(value, type) {
  5609. var valid;
  5610. var expectedType;
  5611. if (type === String) {
  5612. expectedType = 'string';
  5613. valid = typeof value === expectedType;
  5614. } else if (type === Number) {
  5615. expectedType = 'number';
  5616. valid = typeof value === expectedType;
  5617. } else if (type === Boolean) {
  5618. expectedType = 'boolean';
  5619. valid = typeof value === expectedType;
  5620. } else if (type === Function) {
  5621. expectedType = 'function';
  5622. valid = typeof value === expectedType;
  5623. } else if (type === Object) {
  5624. expectedType = 'object';
  5625. valid = isPlainObject(value);
  5626. } else if (type === Array) {
  5627. expectedType = 'array';
  5628. valid = isArray(value);
  5629. } else {
  5630. valid = value instanceof type;
  5631. }
  5632. return {
  5633. valid: valid,
  5634. expectedType: expectedType
  5635. };
  5636. }
  5637. /**
  5638. * Format type for output
  5639. *
  5640. * @param {String} type
  5641. * @return {String}
  5642. */
  5643. function formatType(type) {
  5644. return type ? type.charAt(0).toUpperCase() + type.slice(1) : 'custom type';
  5645. }
  5646. /**
  5647. * Format value
  5648. *
  5649. * @param {*} value
  5650. * @return {String}
  5651. */
  5652. function formatValue(val) {
  5653. return Object.prototype.toString.call(val).slice(8, -1);
  5654. }
  5655. var bindingModes = config._propBindingModes;
  5656. var propDef = {
  5657. bind: function bind() {
  5658. var child = this.vm;
  5659. var parent = child._context;
  5660. // passed in from compiler directly
  5661. var prop = this.descriptor.prop;
  5662. var childKey = prop.path;
  5663. var parentKey = prop.parentPath;
  5664. var twoWay = prop.mode === bindingModes.TWO_WAY;
  5665. var parentWatcher = this.parentWatcher = new Watcher(parent, parentKey, function (val) {
  5666. updateProp(child, prop, val);
  5667. }, {
  5668. twoWay: twoWay,
  5669. filters: prop.filters,
  5670. // important: props need to be observed on the
  5671. // v-for scope if present
  5672. scope: this._scope
  5673. });
  5674. // set the child initial value.
  5675. initProp(child, prop, parentWatcher.value);
  5676. // setup two-way binding
  5677. if (twoWay) {
  5678. // important: defer the child watcher creation until
  5679. // the created hook (after data observation)
  5680. var self = this;
  5681. child.$once('pre-hook:created', function () {
  5682. self.childWatcher = new Watcher(child, childKey, function (val) {
  5683. parentWatcher.set(val);
  5684. }, {
  5685. // ensure sync upward before parent sync down.
  5686. // this is necessary in cases e.g. the child
  5687. // mutates a prop array, then replaces it. (#1683)
  5688. sync: true
  5689. });
  5690. });
  5691. }
  5692. },
  5693. unbind: function unbind() {
  5694. this.parentWatcher.teardown();
  5695. if (this.childWatcher) {
  5696. this.childWatcher.teardown();
  5697. }
  5698. }
  5699. };
  5700. var queue$1 = [];
  5701. var queued = false;
  5702. /**
  5703. * Push a job into the queue.
  5704. *
  5705. * @param {Function} job
  5706. */
  5707. function pushJob(job) {
  5708. queue$1.push(job);
  5709. if (!queued) {
  5710. queued = true;
  5711. nextTick(flush);
  5712. }
  5713. }
  5714. /**
  5715. * Flush the queue, and do one forced reflow before
  5716. * triggering transitions.
  5717. */
  5718. function flush() {
  5719. // Force layout
  5720. var f = document.documentElement.offsetHeight;
  5721. for (var i = 0; i < queue$1.length; i++) {
  5722. queue$1[i]();
  5723. }
  5724. queue$1 = [];
  5725. queued = false;
  5726. // dummy return, so js linters don't complain about
  5727. // unused variable f
  5728. return f;
  5729. }
  5730. var TYPE_TRANSITION = 'transition';
  5731. var TYPE_ANIMATION = 'animation';
  5732. var transDurationProp = transitionProp + 'Duration';
  5733. var animDurationProp = animationProp + 'Duration';
  5734. /**
  5735. * If a just-entered element is applied the
  5736. * leave class while its enter transition hasn't started yet,
  5737. * and the transitioned property has the same value for both
  5738. * enter/leave, then the leave transition will be skipped and
  5739. * the transitionend event never fires. This function ensures
  5740. * its callback to be called after a transition has started
  5741. * by waiting for double raf.
  5742. *
  5743. * It falls back to setTimeout on devices that support CSS
  5744. * transitions but not raf (e.g. Android 4.2 browser) - since
  5745. * these environments are usually slow, we are giving it a
  5746. * relatively large timeout.
  5747. */
  5748. var raf = inBrowser && window.requestAnimationFrame;
  5749. var waitForTransitionStart = raf
  5750. /* istanbul ignore next */
  5751. ? function (fn) {
  5752. raf(function () {
  5753. raf(fn);
  5754. });
  5755. } : function (fn) {
  5756. setTimeout(fn, 50);
  5757. };
  5758. /**
  5759. * A Transition object that encapsulates the state and logic
  5760. * of the transition.
  5761. *
  5762. * @param {Element} el
  5763. * @param {String} id
  5764. * @param {Object} hooks
  5765. * @param {Vue} vm
  5766. */
  5767. function Transition(el, id, hooks, vm) {
  5768. this.id = id;
  5769. this.el = el;
  5770. this.enterClass = hooks && hooks.enterClass || id + '-enter';
  5771. this.leaveClass = hooks && hooks.leaveClass || id + '-leave';
  5772. this.hooks = hooks;
  5773. this.vm = vm;
  5774. // async state
  5775. this.pendingCssEvent = this.pendingCssCb = this.cancel = this.pendingJsCb = this.op = this.cb = null;
  5776. this.justEntered = false;
  5777. this.entered = this.left = false;
  5778. this.typeCache = {};
  5779. // check css transition type
  5780. this.type = hooks && hooks.type;
  5781. /* istanbul ignore if */
  5782. if ('development' !== 'production') {
  5783. if (this.type && this.type !== TYPE_TRANSITION && this.type !== TYPE_ANIMATION) {
  5784. warn('invalid CSS transition type for transition="' + this.id + '": ' + this.type, vm);
  5785. }
  5786. }
  5787. // bind
  5788. var self = this;['enterNextTick', 'enterDone', 'leaveNextTick', 'leaveDone'].forEach(function (m) {
  5789. self[m] = bind(self[m], self);
  5790. });
  5791. }
  5792. var p$1 = Transition.prototype;
  5793. /**
  5794. * Start an entering transition.
  5795. *
  5796. * 1. enter transition triggered
  5797. * 2. call beforeEnter hook
  5798. * 3. add enter class
  5799. * 4. insert/show element
  5800. * 5. call enter hook (with possible explicit js callback)
  5801. * 6. reflow
  5802. * 7. based on transition type:
  5803. * - transition:
  5804. * remove class now, wait for transitionend,
  5805. * then done if there's no explicit js callback.
  5806. * - animation:
  5807. * wait for animationend, remove class,
  5808. * then done if there's no explicit js callback.
  5809. * - no css transition:
  5810. * done now if there's no explicit js callback.
  5811. * 8. wait for either done or js callback, then call
  5812. * afterEnter hook.
  5813. *
  5814. * @param {Function} op - insert/show the element
  5815. * @param {Function} [cb]
  5816. */
  5817. p$1.enter = function (op, cb) {
  5818. this.cancelPending();
  5819. this.callHook('beforeEnter');
  5820. this.cb = cb;
  5821. addClass(this.el, this.enterClass);
  5822. op();
  5823. this.entered = false;
  5824. this.callHookWithCb('enter');
  5825. if (this.entered) {
  5826. return; // user called done synchronously.
  5827. }
  5828. this.cancel = this.hooks && this.hooks.enterCancelled;
  5829. pushJob(this.enterNextTick);
  5830. };
  5831. /**
  5832. * The "nextTick" phase of an entering transition, which is
  5833. * to be pushed into a queue and executed after a reflow so
  5834. * that removing the class can trigger a CSS transition.
  5835. */
  5836. p$1.enterNextTick = function () {
  5837. var _this = this;
  5838. // prevent transition skipping
  5839. this.justEntered = true;
  5840. waitForTransitionStart(function () {
  5841. _this.justEntered = false;
  5842. });
  5843. var enterDone = this.enterDone;
  5844. var type = this.getCssTransitionType(this.enterClass);
  5845. if (!this.pendingJsCb) {
  5846. if (type === TYPE_TRANSITION) {
  5847. // trigger transition by removing enter class now
  5848. removeClass(this.el, this.enterClass);
  5849. this.setupCssCb(transitionEndEvent, enterDone);
  5850. } else if (type === TYPE_ANIMATION) {
  5851. this.setupCssCb(animationEndEvent, enterDone);
  5852. } else {
  5853. enterDone();
  5854. }
  5855. } else if (type === TYPE_TRANSITION) {
  5856. removeClass(this.el, this.enterClass);
  5857. }
  5858. };
  5859. /**
  5860. * The "cleanup" phase of an entering transition.
  5861. */
  5862. p$1.enterDone = function () {
  5863. this.entered = true;
  5864. this.cancel = this.pendingJsCb = null;
  5865. removeClass(this.el, this.enterClass);
  5866. this.callHook('afterEnter');
  5867. if (this.cb) this.cb();
  5868. };
  5869. /**
  5870. * Start a leaving transition.
  5871. *
  5872. * 1. leave transition triggered.
  5873. * 2. call beforeLeave hook
  5874. * 3. add leave class (trigger css transition)
  5875. * 4. call leave hook (with possible explicit js callback)
  5876. * 5. reflow if no explicit js callback is provided
  5877. * 6. based on transition type:
  5878. * - transition or animation:
  5879. * wait for end event, remove class, then done if
  5880. * there's no explicit js callback.
  5881. * - no css transition:
  5882. * done if there's no explicit js callback.
  5883. * 7. wait for either done or js callback, then call
  5884. * afterLeave hook.
  5885. *
  5886. * @param {Function} op - remove/hide the element
  5887. * @param {Function} [cb]
  5888. */
  5889. p$1.leave = function (op, cb) {
  5890. this.cancelPending();
  5891. this.callHook('beforeLeave');
  5892. this.op = op;
  5893. this.cb = cb;
  5894. addClass(this.el, this.leaveClass);
  5895. this.left = false;
  5896. this.callHookWithCb('leave');
  5897. if (this.left) {
  5898. return; // user called done synchronously.
  5899. }
  5900. this.cancel = this.hooks && this.hooks.leaveCancelled;
  5901. // only need to handle leaveDone if
  5902. // 1. the transition is already done (synchronously called
  5903. // by the user, which causes this.op set to null)
  5904. // 2. there's no explicit js callback
  5905. if (this.op && !this.pendingJsCb) {
  5906. // if a CSS transition leaves immediately after enter,
  5907. // the transitionend event never fires. therefore we
  5908. // detect such cases and end the leave immediately.
  5909. if (this.justEntered) {
  5910. this.leaveDone();
  5911. } else {
  5912. pushJob(this.leaveNextTick);
  5913. }
  5914. }
  5915. };
  5916. /**
  5917. * The "nextTick" phase of a leaving transition.
  5918. */
  5919. p$1.leaveNextTick = function () {
  5920. var type = this.getCssTransitionType(this.leaveClass);
  5921. if (type) {
  5922. var event = type === TYPE_TRANSITION ? transitionEndEvent : animationEndEvent;
  5923. this.setupCssCb(event, this.leaveDone);
  5924. } else {
  5925. this.leaveDone();
  5926. }
  5927. };
  5928. /**
  5929. * The "cleanup" phase of a leaving transition.
  5930. */
  5931. p$1.leaveDone = function () {
  5932. this.left = true;
  5933. this.cancel = this.pendingJsCb = null;
  5934. this.op();
  5935. removeClass(this.el, this.leaveClass);
  5936. this.callHook('afterLeave');
  5937. if (this.cb) this.cb();
  5938. this.op = null;
  5939. };
  5940. /**
  5941. * Cancel any pending callbacks from a previously running
  5942. * but not finished transition.
  5943. */
  5944. p$1.cancelPending = function () {
  5945. this.op = this.cb = null;
  5946. var hasPending = false;
  5947. if (this.pendingCssCb) {
  5948. hasPending = true;
  5949. off(this.el, this.pendingCssEvent, this.pendingCssCb);
  5950. this.pendingCssEvent = this.pendingCssCb = null;
  5951. }
  5952. if (this.pendingJsCb) {
  5953. hasPending = true;
  5954. this.pendingJsCb.cancel();
  5955. this.pendingJsCb = null;
  5956. }
  5957. if (hasPending) {
  5958. removeClass(this.el, this.enterClass);
  5959. removeClass(this.el, this.leaveClass);
  5960. }
  5961. if (this.cancel) {
  5962. this.cancel.call(this.vm, this.el);
  5963. this.cancel = null;
  5964. }
  5965. };
  5966. /**
  5967. * Call a user-provided synchronous hook function.
  5968. *
  5969. * @param {String} type
  5970. */
  5971. p$1.callHook = function (type) {
  5972. if (this.hooks && this.hooks[type]) {
  5973. this.hooks[type].call(this.vm, this.el);
  5974. }
  5975. };
  5976. /**
  5977. * Call a user-provided, potentially-async hook function.
  5978. * We check for the length of arguments to see if the hook
  5979. * expects a `done` callback. If true, the transition's end
  5980. * will be determined by when the user calls that callback;
  5981. * otherwise, the end is determined by the CSS transition or
  5982. * animation.
  5983. *
  5984. * @param {String} type
  5985. */
  5986. p$1.callHookWithCb = function (type) {
  5987. var hook = this.hooks && this.hooks[type];
  5988. if (hook) {
  5989. if (hook.length > 1) {
  5990. this.pendingJsCb = cancellable(this[type + 'Done']);
  5991. }
  5992. hook.call(this.vm, this.el, this.pendingJsCb);
  5993. }
  5994. };
  5995. /**
  5996. * Get an element's transition type based on the
  5997. * calculated styles.
  5998. *
  5999. * @param {String} className
  6000. * @return {Number}
  6001. */
  6002. p$1.getCssTransitionType = function (className) {
  6003. /* istanbul ignore if */
  6004. if (!transitionEndEvent ||
  6005. // skip CSS transitions if page is not visible -
  6006. // this solves the issue of transitionend events not
  6007. // firing until the page is visible again.
  6008. // pageVisibility API is supported in IE10+, same as
  6009. // CSS transitions.
  6010. document.hidden ||
  6011. // explicit js-only transition
  6012. this.hooks && this.hooks.css === false ||
  6013. // element is hidden
  6014. isHidden(this.el)) {
  6015. return;
  6016. }
  6017. var type = this.type || this.typeCache[className];
  6018. if (type) return type;
  6019. var inlineStyles = this.el.style;
  6020. var computedStyles = window.getComputedStyle(this.el);
  6021. var transDuration = inlineStyles[transDurationProp] || computedStyles[transDurationProp];
  6022. if (transDuration && transDuration !== '0s') {
  6023. type = TYPE_TRANSITION;
  6024. } else {
  6025. var animDuration = inlineStyles[animDurationProp] || computedStyles[animDurationProp];
  6026. if (animDuration && animDuration !== '0s') {
  6027. type = TYPE_ANIMATION;
  6028. }
  6029. }
  6030. if (type) {
  6031. this.typeCache[className] = type;
  6032. }
  6033. return type;
  6034. };
  6035. /**
  6036. * Setup a CSS transitionend/animationend callback.
  6037. *
  6038. * @param {String} event
  6039. * @param {Function} cb
  6040. */
  6041. p$1.setupCssCb = function (event, cb) {
  6042. this.pendingCssEvent = event;
  6043. var self = this;
  6044. var el = this.el;
  6045. var onEnd = this.pendingCssCb = function (e) {
  6046. if (e.target === el) {
  6047. off(el, event, onEnd);
  6048. self.pendingCssEvent = self.pendingCssCb = null;
  6049. if (!self.pendingJsCb && cb) {
  6050. cb();
  6051. }
  6052. }
  6053. };
  6054. on(el, event, onEnd);
  6055. };
  6056. /**
  6057. * Check if an element is hidden - in that case we can just
  6058. * skip the transition alltogether.
  6059. *
  6060. * @param {Element} el
  6061. * @return {Boolean}
  6062. */
  6063. function isHidden(el) {
  6064. if (/svg$/.test(el.namespaceURI)) {
  6065. // SVG elements do not have offset(Width|Height)
  6066. // so we need to check the client rect
  6067. var rect = el.getBoundingClientRect();
  6068. return !(rect.width || rect.height);
  6069. } else {
  6070. return !(el.offsetWidth || el.offsetHeight || el.getClientRects().length);
  6071. }
  6072. }
  6073. var transition$1 = {
  6074. priority: TRANSITION,
  6075. update: function update(id, oldId) {
  6076. var el = this.el;
  6077. // resolve on owner vm
  6078. var hooks = resolveAsset(this.vm.$options, 'transitions', id);
  6079. id = id || 'v';
  6080. el.__v_trans = new Transition(el, id, hooks, this.vm);
  6081. if (oldId) {
  6082. removeClass(el, oldId + '-transition');
  6083. }
  6084. addClass(el, id + '-transition');
  6085. }
  6086. };
  6087. var internalDirectives = {
  6088. style: style,
  6089. 'class': vClass,
  6090. component: component,
  6091. prop: propDef,
  6092. transition: transition$1
  6093. };
  6094. // special binding prefixes
  6095. var bindRE = /^v-bind:|^:/;
  6096. var onRE = /^v-on:|^@/;
  6097. var dirAttrRE = /^v-([^:]+)(?:$|:(.*)$)/;
  6098. var modifierRE = /\.[^\.]+/g;
  6099. var transitionRE = /^(v-bind:|:)?transition$/;
  6100. // default directive priority
  6101. var DEFAULT_PRIORITY = 1000;
  6102. var DEFAULT_TERMINAL_PRIORITY = 2000;
  6103. /**
  6104. * Compile a template and return a reusable composite link
  6105. * function, which recursively contains more link functions
  6106. * inside. This top level compile function would normally
  6107. * be called on instance root nodes, but can also be used
  6108. * for partial compilation if the partial argument is true.
  6109. *
  6110. * The returned composite link function, when called, will
  6111. * return an unlink function that tearsdown all directives
  6112. * created during the linking phase.
  6113. *
  6114. * @param {Element|DocumentFragment} el
  6115. * @param {Object} options
  6116. * @param {Boolean} partial
  6117. * @return {Function}
  6118. */
  6119. function compile(el, options, partial) {
  6120. // link function for the node itself.
  6121. var nodeLinkFn = partial || !options._asComponent ? compileNode(el, options) : null;
  6122. // link function for the childNodes
  6123. var childLinkFn = !(nodeLinkFn && nodeLinkFn.terminal) && !isScript(el) && el.hasChildNodes() ? compileNodeList(el.childNodes, options) : null;
  6124. /**
  6125. * A composite linker function to be called on a already
  6126. * compiled piece of DOM, which instantiates all directive
  6127. * instances.
  6128. *
  6129. * @param {Vue} vm
  6130. * @param {Element|DocumentFragment} el
  6131. * @param {Vue} [host] - host vm of transcluded content
  6132. * @param {Object} [scope] - v-for scope
  6133. * @param {Fragment} [frag] - link context fragment
  6134. * @return {Function|undefined}
  6135. */
  6136. return function compositeLinkFn(vm, el, host, scope, frag) {
  6137. // cache childNodes before linking parent, fix #657
  6138. var childNodes = toArray(el.childNodes);
  6139. // link
  6140. var dirs = linkAndCapture(function compositeLinkCapturer() {
  6141. if (nodeLinkFn) nodeLinkFn(vm, el, host, scope, frag);
  6142. if (childLinkFn) childLinkFn(vm, childNodes, host, scope, frag);
  6143. }, vm);
  6144. return makeUnlinkFn(vm, dirs);
  6145. };
  6146. }
  6147. /**
  6148. * Apply a linker to a vm/element pair and capture the
  6149. * directives created during the process.
  6150. *
  6151. * @param {Function} linker
  6152. * @param {Vue} vm
  6153. */
  6154. function linkAndCapture(linker, vm) {
  6155. /* istanbul ignore if */
  6156. if ('development' === 'production') {}
  6157. var originalDirCount = vm._directives.length;
  6158. linker();
  6159. var dirs = vm._directives.slice(originalDirCount);
  6160. dirs.sort(directiveComparator);
  6161. for (var i = 0, l = dirs.length; i < l; i++) {
  6162. dirs[i]._bind();
  6163. }
  6164. return dirs;
  6165. }
  6166. /**
  6167. * Directive priority sort comparator
  6168. *
  6169. * @param {Object} a
  6170. * @param {Object} b
  6171. */
  6172. function directiveComparator(a, b) {
  6173. a = a.descriptor.def.priority || DEFAULT_PRIORITY;
  6174. b = b.descriptor.def.priority || DEFAULT_PRIORITY;
  6175. return a > b ? -1 : a === b ? 0 : 1;
  6176. }
  6177. /**
  6178. * Linker functions return an unlink function that
  6179. * tearsdown all directives instances generated during
  6180. * the process.
  6181. *
  6182. * We create unlink functions with only the necessary
  6183. * information to avoid retaining additional closures.
  6184. *
  6185. * @param {Vue} vm
  6186. * @param {Array} dirs
  6187. * @param {Vue} [context]
  6188. * @param {Array} [contextDirs]
  6189. * @return {Function}
  6190. */
  6191. function makeUnlinkFn(vm, dirs, context, contextDirs) {
  6192. function unlink(destroying) {
  6193. teardownDirs(vm, dirs, destroying);
  6194. if (context && contextDirs) {
  6195. teardownDirs(context, contextDirs);
  6196. }
  6197. }
  6198. // expose linked directives
  6199. unlink.dirs = dirs;
  6200. return unlink;
  6201. }
  6202. /**
  6203. * Teardown partial linked directives.
  6204. *
  6205. * @param {Vue} vm
  6206. * @param {Array} dirs
  6207. * @param {Boolean} destroying
  6208. */
  6209. function teardownDirs(vm, dirs, destroying) {
  6210. var i = dirs.length;
  6211. while (i--) {
  6212. dirs[i]._teardown();
  6213. if ('development' !== 'production' && !destroying) {
  6214. vm._directives.$remove(dirs[i]);
  6215. }
  6216. }
  6217. }
  6218. /**
  6219. * Compile link props on an instance.
  6220. *
  6221. * @param {Vue} vm
  6222. * @param {Element} el
  6223. * @param {Object} props
  6224. * @param {Object} [scope]
  6225. * @return {Function}
  6226. */
  6227. function compileAndLinkProps(vm, el, props, scope) {
  6228. var propsLinkFn = compileProps(el, props, vm);
  6229. var propDirs = linkAndCapture(function () {
  6230. propsLinkFn(vm, scope);
  6231. }, vm);
  6232. return makeUnlinkFn(vm, propDirs);
  6233. }
  6234. /**
  6235. * Compile the root element of an instance.
  6236. *
  6237. * 1. attrs on context container (context scope)
  6238. * 2. attrs on the component template root node, if
  6239. * replace:true (child scope)
  6240. *
  6241. * If this is a fragment instance, we only need to compile 1.
  6242. *
  6243. * @param {Element} el
  6244. * @param {Object} options
  6245. * @param {Object} contextOptions
  6246. * @return {Function}
  6247. */
  6248. function compileRoot(el, options, contextOptions) {
  6249. var containerAttrs = options._containerAttrs;
  6250. var replacerAttrs = options._replacerAttrs;
  6251. var contextLinkFn, replacerLinkFn;
  6252. // only need to compile other attributes for
  6253. // non-fragment instances
  6254. if (el.nodeType !== 11) {
  6255. // for components, container and replacer need to be
  6256. // compiled separately and linked in different scopes.
  6257. if (options._asComponent) {
  6258. // 2. container attributes
  6259. if (containerAttrs && contextOptions) {
  6260. contextLinkFn = compileDirectives(containerAttrs, contextOptions);
  6261. }
  6262. if (replacerAttrs) {
  6263. // 3. replacer attributes
  6264. replacerLinkFn = compileDirectives(replacerAttrs, options);
  6265. }
  6266. } else {
  6267. // non-component, just compile as a normal element.
  6268. replacerLinkFn = compileDirectives(el.attributes, options);
  6269. }
  6270. } else if ('development' !== 'production' && containerAttrs) {
  6271. // warn container directives for fragment instances
  6272. var names = containerAttrs.filter(function (attr) {
  6273. // allow vue-loader/vueify scoped css attributes
  6274. return attr.name.indexOf('_v-') < 0 &&
  6275. // allow event listeners
  6276. !onRE.test(attr.name) &&
  6277. // allow slots
  6278. attr.name !== 'slot';
  6279. }).map(function (attr) {
  6280. return '"' + attr.name + '"';
  6281. });
  6282. if (names.length) {
  6283. var plural = names.length > 1;
  6284. warn('Attribute' + (plural ? 's ' : ' ') + names.join(', ') + (plural ? ' are' : ' is') + ' ignored on component ' + '<' + options.el.tagName.toLowerCase() + '> because ' + 'the component is a fragment instance: ' + 'http://vuejs.org/guide/components.html#Fragment-Instance');
  6285. }
  6286. }
  6287. options._containerAttrs = options._replacerAttrs = null;
  6288. return function rootLinkFn(vm, el, scope) {
  6289. // link context scope dirs
  6290. var context = vm._context;
  6291. var contextDirs;
  6292. if (context && contextLinkFn) {
  6293. contextDirs = linkAndCapture(function () {
  6294. contextLinkFn(context, el, null, scope);
  6295. }, context);
  6296. }
  6297. // link self
  6298. var selfDirs = linkAndCapture(function () {
  6299. if (replacerLinkFn) replacerLinkFn(vm, el);
  6300. }, vm);
  6301. // return the unlink function that tearsdown context
  6302. // container directives.
  6303. return makeUnlinkFn(vm, selfDirs, context, contextDirs);
  6304. };
  6305. }
  6306. /**
  6307. * Compile a node and return a nodeLinkFn based on the
  6308. * node type.
  6309. *
  6310. * @param {Node} node
  6311. * @param {Object} options
  6312. * @return {Function|null}
  6313. */
  6314. function compileNode(node, options) {
  6315. var type = node.nodeType;
  6316. if (type === 1 && !isScript(node)) {
  6317. return compileElement(node, options);
  6318. } else if (type === 3 && node.data.trim()) {
  6319. return compileTextNode(node, options);
  6320. } else {
  6321. return null;
  6322. }
  6323. }
  6324. /**
  6325. * Compile an element and return a nodeLinkFn.
  6326. *
  6327. * @param {Element} el
  6328. * @param {Object} options
  6329. * @return {Function|null}
  6330. */
  6331. function compileElement(el, options) {
  6332. // preprocess textareas.
  6333. // textarea treats its text content as the initial value.
  6334. // just bind it as an attr directive for value.
  6335. if (el.tagName === 'TEXTAREA') {
  6336. var tokens = parseText(el.value);
  6337. if (tokens) {
  6338. el.setAttribute(':value', tokensToExp(tokens));
  6339. el.value = '';
  6340. }
  6341. }
  6342. var linkFn;
  6343. var hasAttrs = el.hasAttributes();
  6344. var attrs = hasAttrs && toArray(el.attributes);
  6345. // check terminal directives (for & if)
  6346. if (hasAttrs) {
  6347. linkFn = checkTerminalDirectives(el, attrs, options);
  6348. }
  6349. // check element directives
  6350. if (!linkFn) {
  6351. linkFn = checkElementDirectives(el, options);
  6352. }
  6353. // check component
  6354. if (!linkFn) {
  6355. linkFn = checkComponent(el, options);
  6356. }
  6357. // normal directives
  6358. if (!linkFn && hasAttrs) {
  6359. linkFn = compileDirectives(attrs, options);
  6360. }
  6361. return linkFn;
  6362. }
  6363. /**
  6364. * Compile a textNode and return a nodeLinkFn.
  6365. *
  6366. * @param {TextNode} node
  6367. * @param {Object} options
  6368. * @return {Function|null} textNodeLinkFn
  6369. */
  6370. function compileTextNode(node, options) {
  6371. // skip marked text nodes
  6372. if (node._skip) {
  6373. return removeText;
  6374. }
  6375. var tokens = parseText(node.wholeText);
  6376. if (!tokens) {
  6377. return null;
  6378. }
  6379. // mark adjacent text nodes as skipped,
  6380. // because we are using node.wholeText to compile
  6381. // all adjacent text nodes together. This fixes
  6382. // issues in IE where sometimes it splits up a single
  6383. // text node into multiple ones.
  6384. var next = node.nextSibling;
  6385. while (next && next.nodeType === 3) {
  6386. next._skip = true;
  6387. next = next.nextSibling;
  6388. }
  6389. var frag = document.createDocumentFragment();
  6390. var el, token;
  6391. for (var i = 0, l = tokens.length; i < l; i++) {
  6392. token = tokens[i];
  6393. el = token.tag ? processTextToken(token, options) : document.createTextNode(token.value);
  6394. frag.appendChild(el);
  6395. }
  6396. return makeTextNodeLinkFn(tokens, frag, options);
  6397. }
  6398. /**
  6399. * Linker for an skipped text node.
  6400. *
  6401. * @param {Vue} vm
  6402. * @param {Text} node
  6403. */
  6404. function removeText(vm, node) {
  6405. remove(node);
  6406. }
  6407. /**
  6408. * Process a single text token.
  6409. *
  6410. * @param {Object} token
  6411. * @param {Object} options
  6412. * @return {Node}
  6413. */
  6414. function processTextToken(token, options) {
  6415. var el;
  6416. if (token.oneTime) {
  6417. el = document.createTextNode(token.value);
  6418. } else {
  6419. if (token.html) {
  6420. el = document.createComment('v-html');
  6421. setTokenType('html');
  6422. } else {
  6423. // IE will clean up empty textNodes during
  6424. // frag.cloneNode(true), so we have to give it
  6425. // something here...
  6426. el = document.createTextNode(' ');
  6427. setTokenType('text');
  6428. }
  6429. }
  6430. function setTokenType(type) {
  6431. if (token.descriptor) return;
  6432. var parsed = parseDirective(token.value);
  6433. token.descriptor = {
  6434. name: type,
  6435. def: directives[type],
  6436. expression: parsed.expression,
  6437. filters: parsed.filters
  6438. };
  6439. }
  6440. return el;
  6441. }
  6442. /**
  6443. * Build a function that processes a textNode.
  6444. *
  6445. * @param {Array<Object>} tokens
  6446. * @param {DocumentFragment} frag
  6447. */
  6448. function makeTextNodeLinkFn(tokens, frag) {
  6449. return function textNodeLinkFn(vm, el, host, scope) {
  6450. var fragClone = frag.cloneNode(true);
  6451. var childNodes = toArray(fragClone.childNodes);
  6452. var token, value, node;
  6453. for (var i = 0, l = tokens.length; i < l; i++) {
  6454. token = tokens[i];
  6455. value = token.value;
  6456. if (token.tag) {
  6457. node = childNodes[i];
  6458. if (token.oneTime) {
  6459. value = (scope || vm).$eval(value);
  6460. if (token.html) {
  6461. replace(node, parseTemplate(value, true));
  6462. } else {
  6463. node.data = value;
  6464. }
  6465. } else {
  6466. vm._bindDir(token.descriptor, node, host, scope);
  6467. }
  6468. }
  6469. }
  6470. replace(el, fragClone);
  6471. };
  6472. }
  6473. /**
  6474. * Compile a node list and return a childLinkFn.
  6475. *
  6476. * @param {NodeList} nodeList
  6477. * @param {Object} options
  6478. * @return {Function|undefined}
  6479. */
  6480. function compileNodeList(nodeList, options) {
  6481. var linkFns = [];
  6482. var nodeLinkFn, childLinkFn, node;
  6483. for (var i = 0, l = nodeList.length; i < l; i++) {
  6484. node = nodeList[i];
  6485. nodeLinkFn = compileNode(node, options);
  6486. childLinkFn = !(nodeLinkFn && nodeLinkFn.terminal) && node.tagName !== 'SCRIPT' && node.hasChildNodes() ? compileNodeList(node.childNodes, options) : null;
  6487. linkFns.push(nodeLinkFn, childLinkFn);
  6488. }
  6489. return linkFns.length ? makeChildLinkFn(linkFns) : null;
  6490. }
  6491. /**
  6492. * Make a child link function for a node's childNodes.
  6493. *
  6494. * @param {Array<Function>} linkFns
  6495. * @return {Function} childLinkFn
  6496. */
  6497. function makeChildLinkFn(linkFns) {
  6498. return function childLinkFn(vm, nodes, host, scope, frag) {
  6499. var node, nodeLinkFn, childrenLinkFn;
  6500. for (var i = 0, n = 0, l = linkFns.length; i < l; n++) {
  6501. node = nodes[n];
  6502. nodeLinkFn = linkFns[i++];
  6503. childrenLinkFn = linkFns[i++];
  6504. // cache childNodes before linking parent, fix #657
  6505. var childNodes = toArray(node.childNodes);
  6506. if (nodeLinkFn) {
  6507. nodeLinkFn(vm, node, host, scope, frag);
  6508. }
  6509. if (childrenLinkFn) {
  6510. childrenLinkFn(vm, childNodes, host, scope, frag);
  6511. }
  6512. }
  6513. };
  6514. }
  6515. /**
  6516. * Check for element directives (custom elements that should
  6517. * be resovled as terminal directives).
  6518. *
  6519. * @param {Element} el
  6520. * @param {Object} options
  6521. */
  6522. function checkElementDirectives(el, options) {
  6523. var tag = el.tagName.toLowerCase();
  6524. if (commonTagRE.test(tag)) {
  6525. return;
  6526. }
  6527. var def = resolveAsset(options, 'elementDirectives', tag);
  6528. if (def) {
  6529. return makeTerminalNodeLinkFn(el, tag, '', options, def);
  6530. }
  6531. }
  6532. /**
  6533. * Check if an element is a component. If yes, return
  6534. * a component link function.
  6535. *
  6536. * @param {Element} el
  6537. * @param {Object} options
  6538. * @return {Function|undefined}
  6539. */
  6540. function checkComponent(el, options) {
  6541. var component = checkComponentAttr(el, options);
  6542. if (component) {
  6543. var ref = findRef(el);
  6544. var descriptor = {
  6545. name: 'component',
  6546. ref: ref,
  6547. expression: component.id,
  6548. def: internalDirectives.component,
  6549. modifiers: {
  6550. literal: !component.dynamic
  6551. }
  6552. };
  6553. var componentLinkFn = function componentLinkFn(vm, el, host, scope, frag) {
  6554. if (ref) {
  6555. defineReactive((scope || vm).$refs, ref, null);
  6556. }
  6557. vm._bindDir(descriptor, el, host, scope, frag);
  6558. };
  6559. componentLinkFn.terminal = true;
  6560. return componentLinkFn;
  6561. }
  6562. }
  6563. /**
  6564. * Check an element for terminal directives in fixed order.
  6565. * If it finds one, return a terminal link function.
  6566. *
  6567. * @param {Element} el
  6568. * @param {Array} attrs
  6569. * @param {Object} options
  6570. * @return {Function} terminalLinkFn
  6571. */
  6572. function checkTerminalDirectives(el, attrs, options) {
  6573. // skip v-pre
  6574. if (getAttr(el, 'v-pre') !== null) {
  6575. return skip;
  6576. }
  6577. // skip v-else block, but only if following v-if
  6578. if (el.hasAttribute('v-else')) {
  6579. var prev = el.previousElementSibling;
  6580. if (prev && prev.hasAttribute('v-if')) {
  6581. return skip;
  6582. }
  6583. }
  6584. var attr, name, value, modifiers, matched, dirName, rawName, arg, def, termDef;
  6585. for (var i = 0, j = attrs.length; i < j; i++) {
  6586. attr = attrs[i];
  6587. name = attr.name.replace(modifierRE, '');
  6588. if (matched = name.match(dirAttrRE)) {
  6589. def = resolveAsset(options, 'directives', matched[1]);
  6590. if (def && def.terminal) {
  6591. if (!termDef || (def.priority || DEFAULT_TERMINAL_PRIORITY) > termDef.priority) {
  6592. termDef = def;
  6593. rawName = attr.name;
  6594. modifiers = parseModifiers(attr.name);
  6595. value = attr.value;
  6596. dirName = matched[1];
  6597. arg = matched[2];
  6598. }
  6599. }
  6600. }
  6601. }
  6602. if (termDef) {
  6603. return makeTerminalNodeLinkFn(el, dirName, value, options, termDef, rawName, arg, modifiers);
  6604. }
  6605. }
  6606. function skip() {}
  6607. skip.terminal = true;
  6608. /**
  6609. * Build a node link function for a terminal directive.
  6610. * A terminal link function terminates the current
  6611. * compilation recursion and handles compilation of the
  6612. * subtree in the directive.
  6613. *
  6614. * @param {Element} el
  6615. * @param {String} dirName
  6616. * @param {String} value
  6617. * @param {Object} options
  6618. * @param {Object} def
  6619. * @param {String} [rawName]
  6620. * @param {String} [arg]
  6621. * @param {Object} [modifiers]
  6622. * @return {Function} terminalLinkFn
  6623. */
  6624. function makeTerminalNodeLinkFn(el, dirName, value, options, def, rawName, arg, modifiers) {
  6625. var parsed = parseDirective(value);
  6626. var descriptor = {
  6627. name: dirName,
  6628. arg: arg,
  6629. expression: parsed.expression,
  6630. filters: parsed.filters,
  6631. raw: value,
  6632. attr: rawName,
  6633. modifiers: modifiers,
  6634. def: def
  6635. };
  6636. // check ref for v-for and router-view
  6637. if (dirName === 'for' || dirName === 'router-view') {
  6638. descriptor.ref = findRef(el);
  6639. }
  6640. var fn = function terminalNodeLinkFn(vm, el, host, scope, frag) {
  6641. if (descriptor.ref) {
  6642. defineReactive((scope || vm).$refs, descriptor.ref, null);
  6643. }
  6644. vm._bindDir(descriptor, el, host, scope, frag);
  6645. };
  6646. fn.terminal = true;
  6647. return fn;
  6648. }
  6649. /**
  6650. * Compile the directives on an element and return a linker.
  6651. *
  6652. * @param {Array|NamedNodeMap} attrs
  6653. * @param {Object} options
  6654. * @return {Function}
  6655. */
  6656. function compileDirectives(attrs, options) {
  6657. var i = attrs.length;
  6658. var dirs = [];
  6659. var attr, name, value, rawName, rawValue, dirName, arg, modifiers, dirDef, tokens, matched;
  6660. while (i--) {
  6661. attr = attrs[i];
  6662. name = rawName = attr.name;
  6663. value = rawValue = attr.value;
  6664. tokens = parseText(value);
  6665. // reset arg
  6666. arg = null;
  6667. // check modifiers
  6668. modifiers = parseModifiers(name);
  6669. name = name.replace(modifierRE, '');
  6670. // attribute interpolations
  6671. if (tokens) {
  6672. value = tokensToExp(tokens);
  6673. arg = name;
  6674. pushDir('bind', directives.bind, tokens);
  6675. // warn against mixing mustaches with v-bind
  6676. if ('development' !== 'production') {
  6677. if (name === 'class' && Array.prototype.some.call(attrs, function (attr) {
  6678. return attr.name === ':class' || attr.name === 'v-bind:class';
  6679. })) {
  6680. warn('class="' + rawValue + '": Do not mix mustache interpolation ' + 'and v-bind for "class" on the same element. Use one or the other.', options);
  6681. }
  6682. }
  6683. } else
  6684. // special attribute: transition
  6685. if (transitionRE.test(name)) {
  6686. modifiers.literal = !bindRE.test(name);
  6687. pushDir('transition', internalDirectives.transition);
  6688. } else
  6689. // event handlers
  6690. if (onRE.test(name)) {
  6691. arg = name.replace(onRE, '');
  6692. pushDir('on', directives.on);
  6693. } else
  6694. // attribute bindings
  6695. if (bindRE.test(name)) {
  6696. dirName = name.replace(bindRE, '');
  6697. if (dirName === 'style' || dirName === 'class') {
  6698. pushDir(dirName, internalDirectives[dirName]);
  6699. } else {
  6700. arg = dirName;
  6701. pushDir('bind', directives.bind);
  6702. }
  6703. } else
  6704. // normal directives
  6705. if (matched = name.match(dirAttrRE)) {
  6706. dirName = matched[1];
  6707. arg = matched[2];
  6708. // skip v-else (when used with v-show)
  6709. if (dirName === 'else') {
  6710. continue;
  6711. }
  6712. dirDef = resolveAsset(options, 'directives', dirName, true);
  6713. if (dirDef) {
  6714. pushDir(dirName, dirDef);
  6715. }
  6716. }
  6717. }
  6718. /**
  6719. * Push a directive.
  6720. *
  6721. * @param {String} dirName
  6722. * @param {Object|Function} def
  6723. * @param {Array} [interpTokens]
  6724. */
  6725. function pushDir(dirName, def, interpTokens) {
  6726. var hasOneTimeToken = interpTokens && hasOneTime(interpTokens);
  6727. var parsed = !hasOneTimeToken && parseDirective(value);
  6728. dirs.push({
  6729. name: dirName,
  6730. attr: rawName,
  6731. raw: rawValue,
  6732. def: def,
  6733. arg: arg,
  6734. modifiers: modifiers,
  6735. // conversion from interpolation strings with one-time token
  6736. // to expression is differed until directive bind time so that we
  6737. // have access to the actual vm context for one-time bindings.
  6738. expression: parsed && parsed.expression,
  6739. filters: parsed && parsed.filters,
  6740. interp: interpTokens,
  6741. hasOneTime: hasOneTimeToken
  6742. });
  6743. }
  6744. if (dirs.length) {
  6745. return makeNodeLinkFn(dirs);
  6746. }
  6747. }
  6748. /**
  6749. * Parse modifiers from directive attribute name.
  6750. *
  6751. * @param {String} name
  6752. * @return {Object}
  6753. */
  6754. function parseModifiers(name) {
  6755. var res = Object.create(null);
  6756. var match = name.match(modifierRE);
  6757. if (match) {
  6758. var i = match.length;
  6759. while (i--) {
  6760. res[match[i].slice(1)] = true;
  6761. }
  6762. }
  6763. return res;
  6764. }
  6765. /**
  6766. * Build a link function for all directives on a single node.
  6767. *
  6768. * @param {Array} directives
  6769. * @return {Function} directivesLinkFn
  6770. */
  6771. function makeNodeLinkFn(directives) {
  6772. return function nodeLinkFn(vm, el, host, scope, frag) {
  6773. // reverse apply because it's sorted low to high
  6774. var i = directives.length;
  6775. while (i--) {
  6776. vm._bindDir(directives[i], el, host, scope, frag);
  6777. }
  6778. };
  6779. }
  6780. /**
  6781. * Check if an interpolation string contains one-time tokens.
  6782. *
  6783. * @param {Array} tokens
  6784. * @return {Boolean}
  6785. */
  6786. function hasOneTime(tokens) {
  6787. var i = tokens.length;
  6788. while (i--) {
  6789. if (tokens[i].oneTime) return true;
  6790. }
  6791. }
  6792. function isScript(el) {
  6793. return el.tagName === 'SCRIPT' && (!el.hasAttribute('type') || el.getAttribute('type') === 'text/javascript');
  6794. }
  6795. var specialCharRE = /[^\w\-:\.]/;
  6796. /**
  6797. * Process an element or a DocumentFragment based on a
  6798. * instance option object. This allows us to transclude
  6799. * a template node/fragment before the instance is created,
  6800. * so the processed fragment can then be cloned and reused
  6801. * in v-for.
  6802. *
  6803. * @param {Element} el
  6804. * @param {Object} options
  6805. * @return {Element|DocumentFragment}
  6806. */
  6807. function transclude(el, options) {
  6808. // extract container attributes to pass them down
  6809. // to compiler, because they need to be compiled in
  6810. // parent scope. we are mutating the options object here
  6811. // assuming the same object will be used for compile
  6812. // right after this.
  6813. if (options) {
  6814. options._containerAttrs = extractAttrs(el);
  6815. }
  6816. // for template tags, what we want is its content as
  6817. // a documentFragment (for fragment instances)
  6818. if (isTemplate(el)) {
  6819. el = parseTemplate(el);
  6820. }
  6821. if (options) {
  6822. if (options._asComponent && !options.template) {
  6823. options.template = '<slot></slot>';
  6824. }
  6825. if (options.template) {
  6826. options._content = extractContent(el);
  6827. el = transcludeTemplate(el, options);
  6828. }
  6829. }
  6830. if (isFragment(el)) {
  6831. // anchors for fragment instance
  6832. // passing in `persist: true` to avoid them being
  6833. // discarded by IE during template cloning
  6834. prepend(createAnchor('v-start', true), el);
  6835. el.appendChild(createAnchor('v-end', true));
  6836. }
  6837. return el;
  6838. }
  6839. /**
  6840. * Process the template option.
  6841. * If the replace option is true this will swap the $el.
  6842. *
  6843. * @param {Element} el
  6844. * @param {Object} options
  6845. * @return {Element|DocumentFragment}
  6846. */
  6847. function transcludeTemplate(el, options) {
  6848. var template = options.template;
  6849. var frag = parseTemplate(template, true);
  6850. if (frag) {
  6851. var replacer = frag.firstChild;
  6852. var tag = replacer.tagName && replacer.tagName.toLowerCase();
  6853. if (options.replace) {
  6854. /* istanbul ignore if */
  6855. if (el === document.body) {
  6856. 'development' !== 'production' && warn('You are mounting an instance with a template to ' + '<body>. This will replace <body> entirely. You ' + 'should probably use `replace: false` here.');
  6857. }
  6858. // there are many cases where the instance must
  6859. // become a fragment instance: basically anything that
  6860. // can create more than 1 root nodes.
  6861. if (
  6862. // multi-children template
  6863. frag.childNodes.length > 1 ||
  6864. // non-element template
  6865. replacer.nodeType !== 1 ||
  6866. // single nested component
  6867. tag === 'component' || resolveAsset(options, 'components', tag) || hasBindAttr(replacer, 'is') ||
  6868. // element directive
  6869. resolveAsset(options, 'elementDirectives', tag) ||
  6870. // for block
  6871. replacer.hasAttribute('v-for') ||
  6872. // if block
  6873. replacer.hasAttribute('v-if')) {
  6874. return frag;
  6875. } else {
  6876. options._replacerAttrs = extractAttrs(replacer);
  6877. mergeAttrs(el, replacer);
  6878. return replacer;
  6879. }
  6880. } else {
  6881. el.appendChild(frag);
  6882. return el;
  6883. }
  6884. } else {
  6885. 'development' !== 'production' && warn('Invalid template option: ' + template);
  6886. }
  6887. }
  6888. /**
  6889. * Helper to extract a component container's attributes
  6890. * into a plain object array.
  6891. *
  6892. * @param {Element} el
  6893. * @return {Array}
  6894. */
  6895. function extractAttrs(el) {
  6896. if (el.nodeType === 1 && el.hasAttributes()) {
  6897. return toArray(el.attributes);
  6898. }
  6899. }
  6900. /**
  6901. * Merge the attributes of two elements, and make sure
  6902. * the class names are merged properly.
  6903. *
  6904. * @param {Element} from
  6905. * @param {Element} to
  6906. */
  6907. function mergeAttrs(from, to) {
  6908. var attrs = from.attributes;
  6909. var i = attrs.length;
  6910. var name, value;
  6911. while (i--) {
  6912. name = attrs[i].name;
  6913. value = attrs[i].value;
  6914. if (!to.hasAttribute(name) && !specialCharRE.test(name)) {
  6915. to.setAttribute(name, value);
  6916. } else if (name === 'class' && !parseText(value) && (value = value.trim())) {
  6917. value.split(/\s+/).forEach(function (cls) {
  6918. addClass(to, cls);
  6919. });
  6920. }
  6921. }
  6922. }
  6923. /**
  6924. * Scan and determine slot content distribution.
  6925. * We do this during transclusion instead at compile time so that
  6926. * the distribution is decoupled from the compilation order of
  6927. * the slots.
  6928. *
  6929. * @param {Element|DocumentFragment} template
  6930. * @param {Element} content
  6931. * @param {Vue} vm
  6932. */
  6933. function resolveSlots(vm, content) {
  6934. if (!content) {
  6935. return;
  6936. }
  6937. var contents = vm._slotContents = Object.create(null);
  6938. var el, name;
  6939. for (var i = 0, l = content.children.length; i < l; i++) {
  6940. el = content.children[i];
  6941. /* eslint-disable no-cond-assign */
  6942. if (name = el.getAttribute('slot')) {
  6943. (contents[name] || (contents[name] = [])).push(el);
  6944. }
  6945. /* eslint-enable no-cond-assign */
  6946. if ('development' !== 'production' && getBindAttr(el, 'slot')) {
  6947. warn('The "slot" attribute must be static.', vm.$parent);
  6948. }
  6949. }
  6950. for (name in contents) {
  6951. contents[name] = extractFragment(contents[name], content);
  6952. }
  6953. if (content.hasChildNodes()) {
  6954. var nodes = content.childNodes;
  6955. if (nodes.length === 1 && nodes[0].nodeType === 3 && !nodes[0].data.trim()) {
  6956. return;
  6957. }
  6958. contents['default'] = extractFragment(content.childNodes, content);
  6959. }
  6960. }
  6961. /**
  6962. * Extract qualified content nodes from a node list.
  6963. *
  6964. * @param {NodeList} nodes
  6965. * @return {DocumentFragment}
  6966. */
  6967. function extractFragment(nodes, parent) {
  6968. var frag = document.createDocumentFragment();
  6969. nodes = toArray(nodes);
  6970. for (var i = 0, l = nodes.length; i < l; i++) {
  6971. var node = nodes[i];
  6972. if (isTemplate(node) && !node.hasAttribute('v-if') && !node.hasAttribute('v-for')) {
  6973. parent.removeChild(node);
  6974. node = parseTemplate(node, true);
  6975. }
  6976. frag.appendChild(node);
  6977. }
  6978. return frag;
  6979. }
  6980. var compiler = Object.freeze({
  6981. compile: compile,
  6982. compileAndLinkProps: compileAndLinkProps,
  6983. compileRoot: compileRoot,
  6984. transclude: transclude,
  6985. resolveSlots: resolveSlots
  6986. });
  6987. function stateMixin (Vue) {
  6988. /**
  6989. * Accessor for `$data` property, since setting $data
  6990. * requires observing the new object and updating
  6991. * proxied properties.
  6992. */
  6993. Object.defineProperty(Vue.prototype, '$data', {
  6994. get: function get() {
  6995. return this._data;
  6996. },
  6997. set: function set(newData) {
  6998. if (newData !== this._data) {
  6999. this._setData(newData);
  7000. }
  7001. }
  7002. });
  7003. /**
  7004. * Setup the scope of an instance, which contains:
  7005. * - observed data
  7006. * - computed properties
  7007. * - user methods
  7008. * - meta properties
  7009. */
  7010. Vue.prototype._initState = function () {
  7011. this._initProps();
  7012. this._initMeta();
  7013. this._initMethods();
  7014. this._initData();
  7015. this._initComputed();
  7016. };
  7017. /**
  7018. * Initialize props.
  7019. */
  7020. Vue.prototype._initProps = function () {
  7021. var options = this.$options;
  7022. var el = options.el;
  7023. var props = options.props;
  7024. if (props && !el) {
  7025. 'development' !== 'production' && warn('Props will not be compiled if no `el` option is ' + 'provided at instantiation.', this);
  7026. }
  7027. // make sure to convert string selectors into element now
  7028. el = options.el = query(el);
  7029. this._propsUnlinkFn = el && el.nodeType === 1 && props
  7030. // props must be linked in proper scope if inside v-for
  7031. ? compileAndLinkProps(this, el, props, this._scope) : null;
  7032. };
  7033. /**
  7034. * Initialize the data.
  7035. */
  7036. Vue.prototype._initData = function () {
  7037. var dataFn = this.$options.data;
  7038. var data = this._data = dataFn ? dataFn() : {};
  7039. if (!isPlainObject(data)) {
  7040. data = {};
  7041. 'development' !== 'production' && warn('data functions should return an object.', this);
  7042. }
  7043. var props = this._props;
  7044. // proxy data on instance
  7045. var keys = Object.keys(data);
  7046. var i, key;
  7047. i = keys.length;
  7048. while (i--) {
  7049. key = keys[i];
  7050. // there are two scenarios where we can proxy a data key:
  7051. // 1. it's not already defined as a prop
  7052. // 2. it's provided via a instantiation option AND there are no
  7053. // template prop present
  7054. if (!props || !hasOwn(props, key)) {
  7055. this._proxy(key);
  7056. } else if ('development' !== 'production') {
  7057. warn('Data field "' + key + '" is already defined ' + 'as a prop. To provide default value for a prop, use the "default" ' + 'prop option; if you want to pass prop values to an instantiation ' + 'call, use the "propsData" option.', this);
  7058. }
  7059. }
  7060. // observe data
  7061. observe(data, this);
  7062. };
  7063. /**
  7064. * Swap the instance's $data. Called in $data's setter.
  7065. *
  7066. * @param {Object} newData
  7067. */
  7068. Vue.prototype._setData = function (newData) {
  7069. newData = newData || {};
  7070. var oldData = this._data;
  7071. this._data = newData;
  7072. var keys, key, i;
  7073. // unproxy keys not present in new data
  7074. keys = Object.keys(oldData);
  7075. i = keys.length;
  7076. while (i--) {
  7077. key = keys[i];
  7078. if (!(key in newData)) {
  7079. this._unproxy(key);
  7080. }
  7081. }
  7082. // proxy keys not already proxied,
  7083. // and trigger change for changed values
  7084. keys = Object.keys(newData);
  7085. i = keys.length;
  7086. while (i--) {
  7087. key = keys[i];
  7088. if (!hasOwn(this, key)) {
  7089. // new property
  7090. this._proxy(key);
  7091. }
  7092. }
  7093. oldData.__ob__.removeVm(this);
  7094. observe(newData, this);
  7095. this._digest();
  7096. };
  7097. /**
  7098. * Proxy a property, so that
  7099. * vm.prop === vm._data.prop
  7100. *
  7101. * @param {String} key
  7102. */
  7103. Vue.prototype._proxy = function (key) {
  7104. if (!isReserved(key)) {
  7105. // need to store ref to self here
  7106. // because these getter/setters might
  7107. // be called by child scopes via
  7108. // prototype inheritance.
  7109. var self = this;
  7110. Object.defineProperty(self, key, {
  7111. configurable: true,
  7112. enumerable: true,
  7113. get: function proxyGetter() {
  7114. return self._data[key];
  7115. },
  7116. set: function proxySetter(val) {
  7117. self._data[key] = val;
  7118. }
  7119. });
  7120. }
  7121. };
  7122. /**
  7123. * Unproxy a property.
  7124. *
  7125. * @param {String} key
  7126. */
  7127. Vue.prototype._unproxy = function (key) {
  7128. if (!isReserved(key)) {
  7129. delete this[key];
  7130. }
  7131. };
  7132. /**
  7133. * Force update on every watcher in scope.
  7134. */
  7135. Vue.prototype._digest = function () {
  7136. for (var i = 0, l = this._watchers.length; i < l; i++) {
  7137. this._watchers[i].update(true); // shallow updates
  7138. }
  7139. };
  7140. /**
  7141. * Setup computed properties. They are essentially
  7142. * special getter/setters
  7143. */
  7144. function noop() {}
  7145. Vue.prototype._initComputed = function () {
  7146. var computed = this.$options.computed;
  7147. if (computed) {
  7148. for (var key in computed) {
  7149. var userDef = computed[key];
  7150. var def = {
  7151. enumerable: true,
  7152. configurable: true
  7153. };
  7154. if (typeof userDef === 'function') {
  7155. def.get = makeComputedGetter(userDef, this);
  7156. def.set = noop;
  7157. } else {
  7158. def.get = userDef.get ? userDef.cache !== false ? makeComputedGetter(userDef.get, this) : bind(userDef.get, this) : noop;
  7159. def.set = userDef.set ? bind(userDef.set, this) : noop;
  7160. }
  7161. Object.defineProperty(this, key, def);
  7162. }
  7163. }
  7164. };
  7165. function makeComputedGetter(getter, owner) {
  7166. var watcher = new Watcher(owner, getter, null, {
  7167. lazy: true
  7168. });
  7169. return function computedGetter() {
  7170. if (watcher.dirty) {
  7171. watcher.evaluate();
  7172. }
  7173. if (Dep.target) {
  7174. watcher.depend();
  7175. }
  7176. return watcher.value;
  7177. };
  7178. }
  7179. /**
  7180. * Setup instance methods. Methods must be bound to the
  7181. * instance since they might be passed down as a prop to
  7182. * child components.
  7183. */
  7184. Vue.prototype._initMethods = function () {
  7185. var methods = this.$options.methods;
  7186. if (methods) {
  7187. for (var key in methods) {
  7188. this[key] = bind(methods[key], this);
  7189. }
  7190. }
  7191. };
  7192. /**
  7193. * Initialize meta information like $index, $key & $value.
  7194. */
  7195. Vue.prototype._initMeta = function () {
  7196. var metas = this.$options._meta;
  7197. if (metas) {
  7198. for (var key in metas) {
  7199. defineReactive(this, key, metas[key]);
  7200. }
  7201. }
  7202. };
  7203. }
  7204. var eventRE = /^v-on:|^@/;
  7205. function eventsMixin (Vue) {
  7206. /**
  7207. * Setup the instance's option events & watchers.
  7208. * If the value is a string, we pull it from the
  7209. * instance's methods by name.
  7210. */
  7211. Vue.prototype._initEvents = function () {
  7212. var options = this.$options;
  7213. if (options._asComponent) {
  7214. registerComponentEvents(this, options.el);
  7215. }
  7216. registerCallbacks(this, '$on', options.events);
  7217. registerCallbacks(this, '$watch', options.watch);
  7218. };
  7219. /**
  7220. * Register v-on events on a child component
  7221. *
  7222. * @param {Vue} vm
  7223. * @param {Element} el
  7224. */
  7225. function registerComponentEvents(vm, el) {
  7226. var attrs = el.attributes;
  7227. var name, value, handler;
  7228. for (var i = 0, l = attrs.length; i < l; i++) {
  7229. name = attrs[i].name;
  7230. if (eventRE.test(name)) {
  7231. name = name.replace(eventRE, '');
  7232. // force the expression into a statement so that
  7233. // it always dynamically resolves the method to call (#2670)
  7234. // kinda ugly hack, but does the job.
  7235. value = attrs[i].value;
  7236. if (isSimplePath(value)) {
  7237. value += '.apply(this, $arguments)';
  7238. }
  7239. handler = (vm._scope || vm._context).$eval(value, true);
  7240. handler._fromParent = true;
  7241. vm.$on(name.replace(eventRE), handler);
  7242. }
  7243. }
  7244. }
  7245. /**
  7246. * Register callbacks for option events and watchers.
  7247. *
  7248. * @param {Vue} vm
  7249. * @param {String} action
  7250. * @param {Object} hash
  7251. */
  7252. function registerCallbacks(vm, action, hash) {
  7253. if (!hash) return;
  7254. var handlers, key, i, j;
  7255. for (key in hash) {
  7256. handlers = hash[key];
  7257. if (isArray(handlers)) {
  7258. for (i = 0, j = handlers.length; i < j; i++) {
  7259. register(vm, action, key, handlers[i]);
  7260. }
  7261. } else {
  7262. register(vm, action, key, handlers);
  7263. }
  7264. }
  7265. }
  7266. /**
  7267. * Helper to register an event/watch callback.
  7268. *
  7269. * @param {Vue} vm
  7270. * @param {String} action
  7271. * @param {String} key
  7272. * @param {Function|String|Object} handler
  7273. * @param {Object} [options]
  7274. */
  7275. function register(vm, action, key, handler, options) {
  7276. var type = typeof handler;
  7277. if (type === 'function') {
  7278. vm[action](key, handler, options);
  7279. } else if (type === 'string') {
  7280. var methods = vm.$options.methods;
  7281. var method = methods && methods[handler];
  7282. if (method) {
  7283. vm[action](key, method, options);
  7284. } else {
  7285. 'development' !== 'production' && warn('Unknown method: "' + handler + '" when ' + 'registering callback for ' + action + ': "' + key + '".', vm);
  7286. }
  7287. } else if (handler && type === 'object') {
  7288. register(vm, action, key, handler.handler, handler);
  7289. }
  7290. }
  7291. /**
  7292. * Setup recursive attached/detached calls
  7293. */
  7294. Vue.prototype._initDOMHooks = function () {
  7295. this.$on('hook:attached', onAttached);
  7296. this.$on('hook:detached', onDetached);
  7297. };
  7298. /**
  7299. * Callback to recursively call attached hook on children
  7300. */
  7301. function onAttached() {
  7302. if (!this._isAttached) {
  7303. this._isAttached = true;
  7304. this.$children.forEach(callAttach);
  7305. }
  7306. }
  7307. /**
  7308. * Iterator to call attached hook
  7309. *
  7310. * @param {Vue} child
  7311. */
  7312. function callAttach(child) {
  7313. if (!child._isAttached && inDoc(child.$el)) {
  7314. child._callHook('attached');
  7315. }
  7316. }
  7317. /**
  7318. * Callback to recursively call detached hook on children
  7319. */
  7320. function onDetached() {
  7321. if (this._isAttached) {
  7322. this._isAttached = false;
  7323. this.$children.forEach(callDetach);
  7324. }
  7325. }
  7326. /**
  7327. * Iterator to call detached hook
  7328. *
  7329. * @param {Vue} child
  7330. */
  7331. function callDetach(child) {
  7332. if (child._isAttached && !inDoc(child.$el)) {
  7333. child._callHook('detached');
  7334. }
  7335. }
  7336. /**
  7337. * Trigger all handlers for a hook
  7338. *
  7339. * @param {String} hook
  7340. */
  7341. Vue.prototype._callHook = function (hook) {
  7342. this.$emit('pre-hook:' + hook);
  7343. var handlers = this.$options[hook];
  7344. if (handlers) {
  7345. for (var i = 0, j = handlers.length; i < j; i++) {
  7346. handlers[i].call(this);
  7347. }
  7348. }
  7349. this.$emit('hook:' + hook);
  7350. };
  7351. }
  7352. function noop() {}
  7353. /**
  7354. * A directive links a DOM element with a piece of data,
  7355. * which is the result of evaluating an expression.
  7356. * It registers a watcher with the expression and calls
  7357. * the DOM update function when a change is triggered.
  7358. *
  7359. * @param {Object} descriptor
  7360. * - {String} name
  7361. * - {Object} def
  7362. * - {String} expression
  7363. * - {Array<Object>} [filters]
  7364. * - {Object} [modifiers]
  7365. * - {Boolean} literal
  7366. * - {String} attr
  7367. * - {String} arg
  7368. * - {String} raw
  7369. * - {String} [ref]
  7370. * - {Array<Object>} [interp]
  7371. * - {Boolean} [hasOneTime]
  7372. * @param {Vue} vm
  7373. * @param {Node} el
  7374. * @param {Vue} [host] - transclusion host component
  7375. * @param {Object} [scope] - v-for scope
  7376. * @param {Fragment} [frag] - owner fragment
  7377. * @constructor
  7378. */
  7379. function Directive(descriptor, vm, el, host, scope, frag) {
  7380. this.vm = vm;
  7381. this.el = el;
  7382. // copy descriptor properties
  7383. this.descriptor = descriptor;
  7384. this.name = descriptor.name;
  7385. this.expression = descriptor.expression;
  7386. this.arg = descriptor.arg;
  7387. this.modifiers = descriptor.modifiers;
  7388. this.filters = descriptor.filters;
  7389. this.literal = this.modifiers && this.modifiers.literal;
  7390. // private
  7391. this._locked = false;
  7392. this._bound = false;
  7393. this._listeners = null;
  7394. // link context
  7395. this._host = host;
  7396. this._scope = scope;
  7397. this._frag = frag;
  7398. // store directives on node in dev mode
  7399. if ('development' !== 'production' && this.el) {
  7400. this.el._vue_directives = this.el._vue_directives || [];
  7401. this.el._vue_directives.push(this);
  7402. }
  7403. }
  7404. /**
  7405. * Initialize the directive, mixin definition properties,
  7406. * setup the watcher, call definition bind() and update()
  7407. * if present.
  7408. */
  7409. Directive.prototype._bind = function () {
  7410. var name = this.name;
  7411. var descriptor = this.descriptor;
  7412. // remove attribute
  7413. if ((name !== 'cloak' || this.vm._isCompiled) && this.el && this.el.removeAttribute) {
  7414. var attr = descriptor.attr || 'v-' + name;
  7415. this.el.removeAttribute(attr);
  7416. }
  7417. // copy def properties
  7418. var def = descriptor.def;
  7419. if (typeof def === 'function') {
  7420. this.update = def;
  7421. } else {
  7422. extend(this, def);
  7423. }
  7424. // setup directive params
  7425. this._setupParams();
  7426. // initial bind
  7427. if (this.bind) {
  7428. this.bind();
  7429. }
  7430. this._bound = true;
  7431. if (this.literal) {
  7432. this.update && this.update(descriptor.raw);
  7433. } else if ((this.expression || this.modifiers) && (this.update || this.twoWay) && !this._checkStatement()) {
  7434. // wrapped updater for context
  7435. var dir = this;
  7436. if (this.update) {
  7437. this._update = function (val, oldVal) {
  7438. if (!dir._locked) {
  7439. dir.update(val, oldVal);
  7440. }
  7441. };
  7442. } else {
  7443. this._update = noop;
  7444. }
  7445. var preProcess = this._preProcess ? bind(this._preProcess, this) : null;
  7446. var postProcess = this._postProcess ? bind(this._postProcess, this) : null;
  7447. var watcher = this._watcher = new Watcher(this.vm, this.expression, this._update, // callback
  7448. {
  7449. filters: this.filters,
  7450. twoWay: this.twoWay,
  7451. deep: this.deep,
  7452. preProcess: preProcess,
  7453. postProcess: postProcess,
  7454. scope: this._scope
  7455. });
  7456. // v-model with inital inline value need to sync back to
  7457. // model instead of update to DOM on init. They would
  7458. // set the afterBind hook to indicate that.
  7459. if (this.afterBind) {
  7460. this.afterBind();
  7461. } else if (this.update) {
  7462. this.update(watcher.value);
  7463. }
  7464. }
  7465. };
  7466. /**
  7467. * Setup all param attributes, e.g. track-by,
  7468. * transition-mode, etc...
  7469. */
  7470. Directive.prototype._setupParams = function () {
  7471. if (!this.params) {
  7472. return;
  7473. }
  7474. var params = this.params;
  7475. // swap the params array with a fresh object.
  7476. this.params = Object.create(null);
  7477. var i = params.length;
  7478. var key, val, mappedKey;
  7479. while (i--) {
  7480. key = hyphenate(params[i]);
  7481. mappedKey = camelize(key);
  7482. val = getBindAttr(this.el, key);
  7483. if (val != null) {
  7484. // dynamic
  7485. this._setupParamWatcher(mappedKey, val);
  7486. } else {
  7487. // static
  7488. val = getAttr(this.el, key);
  7489. if (val != null) {
  7490. this.params[mappedKey] = val === '' ? true : val;
  7491. }
  7492. }
  7493. }
  7494. };
  7495. /**
  7496. * Setup a watcher for a dynamic param.
  7497. *
  7498. * @param {String} key
  7499. * @param {String} expression
  7500. */
  7501. Directive.prototype._setupParamWatcher = function (key, expression) {
  7502. var self = this;
  7503. var called = false;
  7504. var unwatch = (this._scope || this.vm).$watch(expression, function (val, oldVal) {
  7505. self.params[key] = val;
  7506. // since we are in immediate mode,
  7507. // only call the param change callbacks if this is not the first update.
  7508. if (called) {
  7509. var cb = self.paramWatchers && self.paramWatchers[key];
  7510. if (cb) {
  7511. cb.call(self, val, oldVal);
  7512. }
  7513. } else {
  7514. called = true;
  7515. }
  7516. }, {
  7517. immediate: true,
  7518. user: false
  7519. });(this._paramUnwatchFns || (this._paramUnwatchFns = [])).push(unwatch);
  7520. };
  7521. /**
  7522. * Check if the directive is a function caller
  7523. * and if the expression is a callable one. If both true,
  7524. * we wrap up the expression and use it as the event
  7525. * handler.
  7526. *
  7527. * e.g. on-click="a++"
  7528. *
  7529. * @return {Boolean}
  7530. */
  7531. Directive.prototype._checkStatement = function () {
  7532. var expression = this.expression;
  7533. if (expression && this.acceptStatement && !isSimplePath(expression)) {
  7534. var fn = parseExpression(expression).get;
  7535. var scope = this._scope || this.vm;
  7536. var handler = function handler(e) {
  7537. scope.$event = e;
  7538. fn.call(scope, scope);
  7539. scope.$event = null;
  7540. };
  7541. if (this.filters) {
  7542. handler = scope._applyFilters(handler, null, this.filters);
  7543. }
  7544. this.update(handler);
  7545. return true;
  7546. }
  7547. };
  7548. /**
  7549. * Set the corresponding value with the setter.
  7550. * This should only be used in two-way directives
  7551. * e.g. v-model.
  7552. *
  7553. * @param {*} value
  7554. * @public
  7555. */
  7556. Directive.prototype.set = function (value) {
  7557. /* istanbul ignore else */
  7558. if (this.twoWay) {
  7559. this._withLock(function () {
  7560. this._watcher.set(value);
  7561. });
  7562. } else if ('development' !== 'production') {
  7563. warn('Directive.set() can only be used inside twoWay' + 'directives.');
  7564. }
  7565. };
  7566. /**
  7567. * Execute a function while preventing that function from
  7568. * triggering updates on this directive instance.
  7569. *
  7570. * @param {Function} fn
  7571. */
  7572. Directive.prototype._withLock = function (fn) {
  7573. var self = this;
  7574. self._locked = true;
  7575. fn.call(self);
  7576. nextTick(function () {
  7577. self._locked = false;
  7578. });
  7579. };
  7580. /**
  7581. * Convenience method that attaches a DOM event listener
  7582. * to the directive element and autometically tears it down
  7583. * during unbind.
  7584. *
  7585. * @param {String} event
  7586. * @param {Function} handler
  7587. * @param {Boolean} [useCapture]
  7588. */
  7589. Directive.prototype.on = function (event, handler, useCapture) {
  7590. on(this.el, event, handler, useCapture);(this._listeners || (this._listeners = [])).push([event, handler]);
  7591. };
  7592. /**
  7593. * Teardown the watcher and call unbind.
  7594. */
  7595. Directive.prototype._teardown = function () {
  7596. if (this._bound) {
  7597. this._bound = false;
  7598. if (this.unbind) {
  7599. this.unbind();
  7600. }
  7601. if (this._watcher) {
  7602. this._watcher.teardown();
  7603. }
  7604. var listeners = this._listeners;
  7605. var i;
  7606. if (listeners) {
  7607. i = listeners.length;
  7608. while (i--) {
  7609. off(this.el, listeners[i][0], listeners[i][1]);
  7610. }
  7611. }
  7612. var unwatchFns = this._paramUnwatchFns;
  7613. if (unwatchFns) {
  7614. i = unwatchFns.length;
  7615. while (i--) {
  7616. unwatchFns[i]();
  7617. }
  7618. }
  7619. if ('development' !== 'production' && this.el) {
  7620. this.el._vue_directives.$remove(this);
  7621. }
  7622. this.vm = this.el = this._watcher = this._listeners = null;
  7623. }
  7624. };
  7625. function lifecycleMixin (Vue) {
  7626. /**
  7627. * Update v-ref for component.
  7628. *
  7629. * @param {Boolean} remove
  7630. */
  7631. Vue.prototype._updateRef = function (remove) {
  7632. var ref = this.$options._ref;
  7633. if (ref) {
  7634. var refs = (this._scope || this._context).$refs;
  7635. if (remove) {
  7636. if (refs[ref] === this) {
  7637. refs[ref] = null;
  7638. }
  7639. } else {
  7640. refs[ref] = this;
  7641. }
  7642. }
  7643. };
  7644. /**
  7645. * Transclude, compile and link element.
  7646. *
  7647. * If a pre-compiled linker is available, that means the
  7648. * passed in element will be pre-transcluded and compiled
  7649. * as well - all we need to do is to call the linker.
  7650. *
  7651. * Otherwise we need to call transclude/compile/link here.
  7652. *
  7653. * @param {Element} el
  7654. */
  7655. Vue.prototype._compile = function (el) {
  7656. var options = this.$options;
  7657. // transclude and init element
  7658. // transclude can potentially replace original
  7659. // so we need to keep reference; this step also injects
  7660. // the template and caches the original attributes
  7661. // on the container node and replacer node.
  7662. var original = el;
  7663. el = transclude(el, options);
  7664. this._initElement(el);
  7665. // handle v-pre on root node (#2026)
  7666. if (el.nodeType === 1 && getAttr(el, 'v-pre') !== null) {
  7667. return;
  7668. }
  7669. // root is always compiled per-instance, because
  7670. // container attrs and props can be different every time.
  7671. var contextOptions = this._context && this._context.$options;
  7672. var rootLinker = compileRoot(el, options, contextOptions);
  7673. // resolve slot distribution
  7674. resolveSlots(this, options._content);
  7675. // compile and link the rest
  7676. var contentLinkFn;
  7677. var ctor = this.constructor;
  7678. // component compilation can be cached
  7679. // as long as it's not using inline-template
  7680. if (options._linkerCachable) {
  7681. contentLinkFn = ctor.linker;
  7682. if (!contentLinkFn) {
  7683. contentLinkFn = ctor.linker = compile(el, options);
  7684. }
  7685. }
  7686. // link phase
  7687. // make sure to link root with prop scope!
  7688. var rootUnlinkFn = rootLinker(this, el, this._scope);
  7689. var contentUnlinkFn = contentLinkFn ? contentLinkFn(this, el) : compile(el, options)(this, el);
  7690. // register composite unlink function
  7691. // to be called during instance destruction
  7692. this._unlinkFn = function () {
  7693. rootUnlinkFn();
  7694. // passing destroying: true to avoid searching and
  7695. // splicing the directives
  7696. contentUnlinkFn(true);
  7697. };
  7698. // finally replace original
  7699. if (options.replace) {
  7700. replace(original, el);
  7701. }
  7702. this._isCompiled = true;
  7703. this._callHook('compiled');
  7704. };
  7705. /**
  7706. * Initialize instance element. Called in the public
  7707. * $mount() method.
  7708. *
  7709. * @param {Element} el
  7710. */
  7711. Vue.prototype._initElement = function (el) {
  7712. if (isFragment(el)) {
  7713. this._isFragment = true;
  7714. this.$el = this._fragmentStart = el.firstChild;
  7715. this._fragmentEnd = el.lastChild;
  7716. // set persisted text anchors to empty
  7717. if (this._fragmentStart.nodeType === 3) {
  7718. this._fragmentStart.data = this._fragmentEnd.data = '';
  7719. }
  7720. this._fragment = el;
  7721. } else {
  7722. this.$el = el;
  7723. }
  7724. this.$el.__vue__ = this;
  7725. this._callHook('beforeCompile');
  7726. };
  7727. /**
  7728. * Create and bind a directive to an element.
  7729. *
  7730. * @param {Object} descriptor - parsed directive descriptor
  7731. * @param {Node} node - target node
  7732. * @param {Vue} [host] - transclusion host component
  7733. * @param {Object} [scope] - v-for scope
  7734. * @param {Fragment} [frag] - owner fragment
  7735. */
  7736. Vue.prototype._bindDir = function (descriptor, node, host, scope, frag) {
  7737. this._directives.push(new Directive(descriptor, this, node, host, scope, frag));
  7738. };
  7739. /**
  7740. * Teardown an instance, unobserves the data, unbind all the
  7741. * directives, turn off all the event listeners, etc.
  7742. *
  7743. * @param {Boolean} remove - whether to remove the DOM node.
  7744. * @param {Boolean} deferCleanup - if true, defer cleanup to
  7745. * be called later
  7746. */
  7747. Vue.prototype._destroy = function (remove, deferCleanup) {
  7748. if (this._isBeingDestroyed) {
  7749. if (!deferCleanup) {
  7750. this._cleanup();
  7751. }
  7752. return;
  7753. }
  7754. var destroyReady;
  7755. var pendingRemoval;
  7756. var self = this;
  7757. // Cleanup should be called either synchronously or asynchronoysly as
  7758. // callback of this.$remove(), or if remove and deferCleanup are false.
  7759. // In any case it should be called after all other removing, unbinding and
  7760. // turning of is done
  7761. var cleanupIfPossible = function cleanupIfPossible() {
  7762. if (destroyReady && !pendingRemoval && !deferCleanup) {
  7763. self._cleanup();
  7764. }
  7765. };
  7766. // remove DOM element
  7767. if (remove && this.$el) {
  7768. pendingRemoval = true;
  7769. this.$remove(function () {
  7770. pendingRemoval = false;
  7771. cleanupIfPossible();
  7772. });
  7773. }
  7774. this._callHook('beforeDestroy');
  7775. this._isBeingDestroyed = true;
  7776. var i;
  7777. // remove self from parent. only necessary
  7778. // if parent is not being destroyed as well.
  7779. var parent = this.$parent;
  7780. if (parent && !parent._isBeingDestroyed) {
  7781. parent.$children.$remove(this);
  7782. // unregister ref (remove: true)
  7783. this._updateRef(true);
  7784. }
  7785. // destroy all children.
  7786. i = this.$children.length;
  7787. while (i--) {
  7788. this.$children[i].$destroy();
  7789. }
  7790. // teardown props
  7791. if (this._propsUnlinkFn) {
  7792. this._propsUnlinkFn();
  7793. }
  7794. // teardown all directives. this also tearsdown all
  7795. // directive-owned watchers.
  7796. if (this._unlinkFn) {
  7797. this._unlinkFn();
  7798. }
  7799. i = this._watchers.length;
  7800. while (i--) {
  7801. this._watchers[i].teardown();
  7802. }
  7803. // remove reference to self on $el
  7804. if (this.$el) {
  7805. this.$el.__vue__ = null;
  7806. }
  7807. destroyReady = true;
  7808. cleanupIfPossible();
  7809. };
  7810. /**
  7811. * Clean up to ensure garbage collection.
  7812. * This is called after the leave transition if there
  7813. * is any.
  7814. */
  7815. Vue.prototype._cleanup = function () {
  7816. if (this._isDestroyed) {
  7817. return;
  7818. }
  7819. // remove self from owner fragment
  7820. // do it in cleanup so that we can call $destroy with
  7821. // defer right when a fragment is about to be removed.
  7822. if (this._frag) {
  7823. this._frag.children.$remove(this);
  7824. }
  7825. // remove reference from data ob
  7826. // frozen object may not have observer.
  7827. if (this._data && this._data.__ob__) {
  7828. this._data.__ob__.removeVm(this);
  7829. }
  7830. // Clean up references to private properties and other
  7831. // instances. preserve reference to _data so that proxy
  7832. // accessors still work. The only potential side effect
  7833. // here is that mutating the instance after it's destroyed
  7834. // may affect the state of other components that are still
  7835. // observing the same object, but that seems to be a
  7836. // reasonable responsibility for the user rather than
  7837. // always throwing an error on them.
  7838. this.$el = this.$parent = this.$root = this.$children = this._watchers = this._context = this._scope = this._directives = null;
  7839. // call the last hook...
  7840. this._isDestroyed = true;
  7841. this._callHook('destroyed');
  7842. // turn off all instance listeners.
  7843. this.$off();
  7844. };
  7845. }
  7846. function miscMixin (Vue) {
  7847. /**
  7848. * Apply a list of filter (descriptors) to a value.
  7849. * Using plain for loops here because this will be called in
  7850. * the getter of any watcher with filters so it is very
  7851. * performance sensitive.
  7852. *
  7853. * @param {*} value
  7854. * @param {*} [oldValue]
  7855. * @param {Array} filters
  7856. * @param {Boolean} write
  7857. * @return {*}
  7858. */
  7859. Vue.prototype._applyFilters = function (value, oldValue, filters, write) {
  7860. var filter, fn, args, arg, offset, i, l, j, k;
  7861. for (i = 0, l = filters.length; i < l; i++) {
  7862. filter = filters[write ? l - i - 1 : i];
  7863. fn = resolveAsset(this.$options, 'filters', filter.name, true);
  7864. if (!fn) continue;
  7865. fn = write ? fn.write : fn.read || fn;
  7866. if (typeof fn !== 'function') continue;
  7867. args = write ? [value, oldValue] : [value];
  7868. offset = write ? 2 : 1;
  7869. if (filter.args) {
  7870. for (j = 0, k = filter.args.length; j < k; j++) {
  7871. arg = filter.args[j];
  7872. args[j + offset] = arg.dynamic ? this.$get(arg.value) : arg.value;
  7873. }
  7874. }
  7875. value = fn.apply(this, args);
  7876. }
  7877. return value;
  7878. };
  7879. /**
  7880. * Resolve a component, depending on whether the component
  7881. * is defined normally or using an async factory function.
  7882. * Resolves synchronously if already resolved, otherwise
  7883. * resolves asynchronously and caches the resolved
  7884. * constructor on the factory.
  7885. *
  7886. * @param {String|Function} value
  7887. * @param {Function} cb
  7888. */
  7889. Vue.prototype._resolveComponent = function (value, cb) {
  7890. var factory;
  7891. if (typeof value === 'function') {
  7892. factory = value;
  7893. } else {
  7894. factory = resolveAsset(this.$options, 'components', value, true);
  7895. }
  7896. /* istanbul ignore if */
  7897. if (!factory) {
  7898. return;
  7899. }
  7900. // async component factory
  7901. if (!factory.options) {
  7902. if (factory.resolved) {
  7903. // cached
  7904. cb(factory.resolved);
  7905. } else if (factory.requested) {
  7906. // pool callbacks
  7907. factory.pendingCallbacks.push(cb);
  7908. } else {
  7909. factory.requested = true;
  7910. var cbs = factory.pendingCallbacks = [cb];
  7911. factory.call(this, function resolve(res) {
  7912. if (isPlainObject(res)) {
  7913. res = Vue.extend(res);
  7914. }
  7915. // cache resolved
  7916. factory.resolved = res;
  7917. // invoke callbacks
  7918. for (var i = 0, l = cbs.length; i < l; i++) {
  7919. cbs[i](res);
  7920. }
  7921. }, function reject(reason) {
  7922. 'development' !== 'production' && warn('Failed to resolve async component' + (typeof value === 'string' ? ': ' + value : '') + '. ' + (reason ? '\nReason: ' + reason : ''));
  7923. });
  7924. }
  7925. } else {
  7926. // normal component
  7927. cb(factory);
  7928. }
  7929. };
  7930. }
  7931. var filterRE$1 = /[^|]\|[^|]/;
  7932. function dataAPI (Vue) {
  7933. /**
  7934. * Get the value from an expression on this vm.
  7935. *
  7936. * @param {String} exp
  7937. * @param {Boolean} [asStatement]
  7938. * @return {*}
  7939. */
  7940. Vue.prototype.$get = function (exp, asStatement) {
  7941. var res = parseExpression(exp);
  7942. if (res) {
  7943. if (asStatement) {
  7944. var self = this;
  7945. return function statementHandler() {
  7946. self.$arguments = toArray(arguments);
  7947. var result = res.get.call(self, self);
  7948. self.$arguments = null;
  7949. return result;
  7950. };
  7951. } else {
  7952. try {
  7953. return res.get.call(this, this);
  7954. } catch (e) {}
  7955. }
  7956. }
  7957. };
  7958. /**
  7959. * Set the value from an expression on this vm.
  7960. * The expression must be a valid left-hand
  7961. * expression in an assignment.
  7962. *
  7963. * @param {String} exp
  7964. * @param {*} val
  7965. */
  7966. Vue.prototype.$set = function (exp, val) {
  7967. var res = parseExpression(exp, true);
  7968. if (res && res.set) {
  7969. res.set.call(this, this, val);
  7970. }
  7971. };
  7972. /**
  7973. * Delete a property on the VM
  7974. *
  7975. * @param {String} key
  7976. */
  7977. Vue.prototype.$delete = function (key) {
  7978. del(this._data, key);
  7979. };
  7980. /**
  7981. * Watch an expression, trigger callback when its
  7982. * value changes.
  7983. *
  7984. * @param {String|Function} expOrFn
  7985. * @param {Function} cb
  7986. * @param {Object} [options]
  7987. * - {Boolean} deep
  7988. * - {Boolean} immediate
  7989. * @return {Function} - unwatchFn
  7990. */
  7991. Vue.prototype.$watch = function (expOrFn, cb, options) {
  7992. var vm = this;
  7993. var parsed;
  7994. if (typeof expOrFn === 'string') {
  7995. parsed = parseDirective(expOrFn);
  7996. expOrFn = parsed.expression;
  7997. }
  7998. var watcher = new Watcher(vm, expOrFn, cb, {
  7999. deep: options && options.deep,
  8000. sync: options && options.sync,
  8001. filters: parsed && parsed.filters,
  8002. user: !options || options.user !== false
  8003. });
  8004. if (options && options.immediate) {
  8005. cb.call(vm, watcher.value);
  8006. }
  8007. return function unwatchFn() {
  8008. watcher.teardown();
  8009. };
  8010. };
  8011. /**
  8012. * Evaluate a text directive, including filters.
  8013. *
  8014. * @param {String} text
  8015. * @param {Boolean} [asStatement]
  8016. * @return {String}
  8017. */
  8018. Vue.prototype.$eval = function (text, asStatement) {
  8019. // check for filters.
  8020. if (filterRE$1.test(text)) {
  8021. var dir = parseDirective(text);
  8022. // the filter regex check might give false positive
  8023. // for pipes inside strings, so it's possible that
  8024. // we don't get any filters here
  8025. var val = this.$get(dir.expression, asStatement);
  8026. return dir.filters ? this._applyFilters(val, null, dir.filters) : val;
  8027. } else {
  8028. // no filter
  8029. return this.$get(text, asStatement);
  8030. }
  8031. };
  8032. /**
  8033. * Interpolate a piece of template text.
  8034. *
  8035. * @param {String} text
  8036. * @return {String}
  8037. */
  8038. Vue.prototype.$interpolate = function (text) {
  8039. var tokens = parseText(text);
  8040. var vm = this;
  8041. if (tokens) {
  8042. if (tokens.length === 1) {
  8043. return vm.$eval(tokens[0].value) + '';
  8044. } else {
  8045. return tokens.map(function (token) {
  8046. return token.tag ? vm.$eval(token.value) : token.value;
  8047. }).join('');
  8048. }
  8049. } else {
  8050. return text;
  8051. }
  8052. };
  8053. /**
  8054. * Log instance data as a plain JS object
  8055. * so that it is easier to inspect in console.
  8056. * This method assumes console is available.
  8057. *
  8058. * @param {String} [path]
  8059. */
  8060. Vue.prototype.$log = function (path) {
  8061. var data = path ? getPath(this._data, path) : this._data;
  8062. if (data) {
  8063. data = clean(data);
  8064. }
  8065. // include computed fields
  8066. if (!path) {
  8067. var key;
  8068. for (key in this.$options.computed) {
  8069. data[key] = clean(this[key]);
  8070. }
  8071. if (this._props) {
  8072. for (key in this._props) {
  8073. data[key] = clean(this[key]);
  8074. }
  8075. }
  8076. }
  8077. console.log(data);
  8078. };
  8079. /**
  8080. * "clean" a getter/setter converted object into a plain
  8081. * object copy.
  8082. *
  8083. * @param {Object} - obj
  8084. * @return {Object}
  8085. */
  8086. function clean(obj) {
  8087. return JSON.parse(JSON.stringify(obj));
  8088. }
  8089. }
  8090. function domAPI (Vue) {
  8091. /**
  8092. * Convenience on-instance nextTick. The callback is
  8093. * auto-bound to the instance, and this avoids component
  8094. * modules having to rely on the global Vue.
  8095. *
  8096. * @param {Function} fn
  8097. */
  8098. Vue.prototype.$nextTick = function (fn) {
  8099. nextTick(fn, this);
  8100. };
  8101. /**
  8102. * Append instance to target
  8103. *
  8104. * @param {Node} target
  8105. * @param {Function} [cb]
  8106. * @param {Boolean} [withTransition] - defaults to true
  8107. */
  8108. Vue.prototype.$appendTo = function (target, cb, withTransition) {
  8109. return insert(this, target, cb, withTransition, append, appendWithTransition);
  8110. };
  8111. /**
  8112. * Prepend instance to target
  8113. *
  8114. * @param {Node} target
  8115. * @param {Function} [cb]
  8116. * @param {Boolean} [withTransition] - defaults to true
  8117. */
  8118. Vue.prototype.$prependTo = function (target, cb, withTransition) {
  8119. target = query(target);
  8120. if (target.hasChildNodes()) {
  8121. this.$before(target.firstChild, cb, withTransition);
  8122. } else {
  8123. this.$appendTo(target, cb, withTransition);
  8124. }
  8125. return this;
  8126. };
  8127. /**
  8128. * Insert instance before target
  8129. *
  8130. * @param {Node} target
  8131. * @param {Function} [cb]
  8132. * @param {Boolean} [withTransition] - defaults to true
  8133. */
  8134. Vue.prototype.$before = function (target, cb, withTransition) {
  8135. return insert(this, target, cb, withTransition, beforeWithCb, beforeWithTransition);
  8136. };
  8137. /**
  8138. * Insert instance after target
  8139. *
  8140. * @param {Node} target
  8141. * @param {Function} [cb]
  8142. * @param {Boolean} [withTransition] - defaults to true
  8143. */
  8144. Vue.prototype.$after = function (target, cb, withTransition) {
  8145. target = query(target);
  8146. if (target.nextSibling) {
  8147. this.$before(target.nextSibling, cb, withTransition);
  8148. } else {
  8149. this.$appendTo(target.parentNode, cb, withTransition);
  8150. }
  8151. return this;
  8152. };
  8153. /**
  8154. * Remove instance from DOM
  8155. *
  8156. * @param {Function} [cb]
  8157. * @param {Boolean} [withTransition] - defaults to true
  8158. */
  8159. Vue.prototype.$remove = function (cb, withTransition) {
  8160. if (!this.$el.parentNode) {
  8161. return cb && cb();
  8162. }
  8163. var inDocument = this._isAttached && inDoc(this.$el);
  8164. // if we are not in document, no need to check
  8165. // for transitions
  8166. if (!inDocument) withTransition = false;
  8167. var self = this;
  8168. var realCb = function realCb() {
  8169. if (inDocument) self._callHook('detached');
  8170. if (cb) cb();
  8171. };
  8172. if (this._isFragment) {
  8173. removeNodeRange(this._fragmentStart, this._fragmentEnd, this, this._fragment, realCb);
  8174. } else {
  8175. var op = withTransition === false ? removeWithCb : removeWithTransition;
  8176. op(this.$el, this, realCb);
  8177. }
  8178. return this;
  8179. };
  8180. /**
  8181. * Shared DOM insertion function.
  8182. *
  8183. * @param {Vue} vm
  8184. * @param {Element} target
  8185. * @param {Function} [cb]
  8186. * @param {Boolean} [withTransition]
  8187. * @param {Function} op1 - op for non-transition insert
  8188. * @param {Function} op2 - op for transition insert
  8189. * @return vm
  8190. */
  8191. function insert(vm, target, cb, withTransition, op1, op2) {
  8192. target = query(target);
  8193. var targetIsDetached = !inDoc(target);
  8194. var op = withTransition === false || targetIsDetached ? op1 : op2;
  8195. var shouldCallHook = !targetIsDetached && !vm._isAttached && !inDoc(vm.$el);
  8196. if (vm._isFragment) {
  8197. mapNodeRange(vm._fragmentStart, vm._fragmentEnd, function (node) {
  8198. op(node, target, vm);
  8199. });
  8200. cb && cb();
  8201. } else {
  8202. op(vm.$el, target, vm, cb);
  8203. }
  8204. if (shouldCallHook) {
  8205. vm._callHook('attached');
  8206. }
  8207. return vm;
  8208. }
  8209. /**
  8210. * Check for selectors
  8211. *
  8212. * @param {String|Element} el
  8213. */
  8214. function query(el) {
  8215. return typeof el === 'string' ? document.querySelector(el) : el;
  8216. }
  8217. /**
  8218. * Append operation that takes a callback.
  8219. *
  8220. * @param {Node} el
  8221. * @param {Node} target
  8222. * @param {Vue} vm - unused
  8223. * @param {Function} [cb]
  8224. */
  8225. function append(el, target, vm, cb) {
  8226. target.appendChild(el);
  8227. if (cb) cb();
  8228. }
  8229. /**
  8230. * InsertBefore operation that takes a callback.
  8231. *
  8232. * @param {Node} el
  8233. * @param {Node} target
  8234. * @param {Vue} vm - unused
  8235. * @param {Function} [cb]
  8236. */
  8237. function beforeWithCb(el, target, vm, cb) {
  8238. before(el, target);
  8239. if (cb) cb();
  8240. }
  8241. /**
  8242. * Remove operation that takes a callback.
  8243. *
  8244. * @param {Node} el
  8245. * @param {Vue} vm - unused
  8246. * @param {Function} [cb]
  8247. */
  8248. function removeWithCb(el, vm, cb) {
  8249. remove(el);
  8250. if (cb) cb();
  8251. }
  8252. }
  8253. function eventsAPI (Vue) {
  8254. /**
  8255. * Listen on the given `event` with `fn`.
  8256. *
  8257. * @param {String} event
  8258. * @param {Function} fn
  8259. */
  8260. Vue.prototype.$on = function (event, fn) {
  8261. (this._events[event] || (this._events[event] = [])).push(fn);
  8262. modifyListenerCount(this, event, 1);
  8263. return this;
  8264. };
  8265. /**
  8266. * Adds an `event` listener that will be invoked a single
  8267. * time then automatically removed.
  8268. *
  8269. * @param {String} event
  8270. * @param {Function} fn
  8271. */
  8272. Vue.prototype.$once = function (event, fn) {
  8273. var self = this;
  8274. function on() {
  8275. self.$off(event, on);
  8276. fn.apply(this, arguments);
  8277. }
  8278. on.fn = fn;
  8279. this.$on(event, on);
  8280. return this;
  8281. };
  8282. /**
  8283. * Remove the given callback for `event` or all
  8284. * registered callbacks.
  8285. *
  8286. * @param {String} event
  8287. * @param {Function} fn
  8288. */
  8289. Vue.prototype.$off = function (event, fn) {
  8290. var cbs;
  8291. // all
  8292. if (!arguments.length) {
  8293. if (this.$parent) {
  8294. for (event in this._events) {
  8295. cbs = this._events[event];
  8296. if (cbs) {
  8297. modifyListenerCount(this, event, -cbs.length);
  8298. }
  8299. }
  8300. }
  8301. this._events = {};
  8302. return this;
  8303. }
  8304. // specific event
  8305. cbs = this._events[event];
  8306. if (!cbs) {
  8307. return this;
  8308. }
  8309. if (arguments.length === 1) {
  8310. modifyListenerCount(this, event, -cbs.length);
  8311. this._events[event] = null;
  8312. return this;
  8313. }
  8314. // specific handler
  8315. var cb;
  8316. var i = cbs.length;
  8317. while (i--) {
  8318. cb = cbs[i];
  8319. if (cb === fn || cb.fn === fn) {
  8320. modifyListenerCount(this, event, -1);
  8321. cbs.splice(i, 1);
  8322. break;
  8323. }
  8324. }
  8325. return this;
  8326. };
  8327. /**
  8328. * Trigger an event on self.
  8329. *
  8330. * @param {String|Object} event
  8331. * @return {Boolean} shouldPropagate
  8332. */
  8333. Vue.prototype.$emit = function (event) {
  8334. var isSource = typeof event === 'string';
  8335. event = isSource ? event : event.name;
  8336. var cbs = this._events[event];
  8337. var shouldPropagate = isSource || !cbs;
  8338. if (cbs) {
  8339. cbs = cbs.length > 1 ? toArray(cbs) : cbs;
  8340. // this is a somewhat hacky solution to the question raised
  8341. // in #2102: for an inline component listener like <comp @test="doThis">,
  8342. // the propagation handling is somewhat broken. Therefore we
  8343. // need to treat these inline callbacks differently.
  8344. var hasParentCbs = isSource && cbs.some(function (cb) {
  8345. return cb._fromParent;
  8346. });
  8347. if (hasParentCbs) {
  8348. shouldPropagate = false;
  8349. }
  8350. var args = toArray(arguments, 1);
  8351. for (var i = 0, l = cbs.length; i < l; i++) {
  8352. var cb = cbs[i];
  8353. var res = cb.apply(this, args);
  8354. if (res === true && (!hasParentCbs || cb._fromParent)) {
  8355. shouldPropagate = true;
  8356. }
  8357. }
  8358. }
  8359. return shouldPropagate;
  8360. };
  8361. /**
  8362. * Recursively broadcast an event to all children instances.
  8363. *
  8364. * @param {String|Object} event
  8365. * @param {...*} additional arguments
  8366. */
  8367. Vue.prototype.$broadcast = function (event) {
  8368. var isSource = typeof event === 'string';
  8369. event = isSource ? event : event.name;
  8370. // if no child has registered for this event,
  8371. // then there's no need to broadcast.
  8372. if (!this._eventsCount[event]) return;
  8373. var children = this.$children;
  8374. var args = toArray(arguments);
  8375. if (isSource) {
  8376. // use object event to indicate non-source emit
  8377. // on children
  8378. args[0] = { name: event, source: this };
  8379. }
  8380. for (var i = 0, l = children.length; i < l; i++) {
  8381. var child = children[i];
  8382. var shouldPropagate = child.$emit.apply(child, args);
  8383. if (shouldPropagate) {
  8384. child.$broadcast.apply(child, args);
  8385. }
  8386. }
  8387. return this;
  8388. };
  8389. /**
  8390. * Recursively propagate an event up the parent chain.
  8391. *
  8392. * @param {String} event
  8393. * @param {...*} additional arguments
  8394. */
  8395. Vue.prototype.$dispatch = function (event) {
  8396. var shouldPropagate = this.$emit.apply(this, arguments);
  8397. if (!shouldPropagate) return;
  8398. var parent = this.$parent;
  8399. var args = toArray(arguments);
  8400. // use object event to indicate non-source emit
  8401. // on parents
  8402. args[0] = { name: event, source: this };
  8403. while (parent) {
  8404. shouldPropagate = parent.$emit.apply(parent, args);
  8405. parent = shouldPropagate ? parent.$parent : null;
  8406. }
  8407. return this;
  8408. };
  8409. /**
  8410. * Modify the listener counts on all parents.
  8411. * This bookkeeping allows $broadcast to return early when
  8412. * no child has listened to a certain event.
  8413. *
  8414. * @param {Vue} vm
  8415. * @param {String} event
  8416. * @param {Number} count
  8417. */
  8418. var hookRE = /^hook:/;
  8419. function modifyListenerCount(vm, event, count) {
  8420. var parent = vm.$parent;
  8421. // hooks do not get broadcasted so no need
  8422. // to do bookkeeping for them
  8423. if (!parent || !count || hookRE.test(event)) return;
  8424. while (parent) {
  8425. parent._eventsCount[event] = (parent._eventsCount[event] || 0) + count;
  8426. parent = parent.$parent;
  8427. }
  8428. }
  8429. }
  8430. function lifecycleAPI (Vue) {
  8431. /**
  8432. * Set instance target element and kick off the compilation
  8433. * process. The passed in `el` can be a selector string, an
  8434. * existing Element, or a DocumentFragment (for block
  8435. * instances).
  8436. *
  8437. * @param {Element|DocumentFragment|string} el
  8438. * @public
  8439. */
  8440. Vue.prototype.$mount = function (el) {
  8441. if (this._isCompiled) {
  8442. 'development' !== 'production' && warn('$mount() should be called only once.', this);
  8443. return;
  8444. }
  8445. el = query(el);
  8446. if (!el) {
  8447. el = document.createElement('div');
  8448. }
  8449. this._compile(el);
  8450. this._initDOMHooks();
  8451. if (inDoc(this.$el)) {
  8452. this._callHook('attached');
  8453. ready.call(this);
  8454. } else {
  8455. this.$once('hook:attached', ready);
  8456. }
  8457. return this;
  8458. };
  8459. /**
  8460. * Mark an instance as ready.
  8461. */
  8462. function ready() {
  8463. this._isAttached = true;
  8464. this._isReady = true;
  8465. this._callHook('ready');
  8466. }
  8467. /**
  8468. * Teardown the instance, simply delegate to the internal
  8469. * _destroy.
  8470. *
  8471. * @param {Boolean} remove
  8472. * @param {Boolean} deferCleanup
  8473. */
  8474. Vue.prototype.$destroy = function (remove, deferCleanup) {
  8475. this._destroy(remove, deferCleanup);
  8476. };
  8477. /**
  8478. * Partially compile a piece of DOM and return a
  8479. * decompile function.
  8480. *
  8481. * @param {Element|DocumentFragment} el
  8482. * @param {Vue} [host]
  8483. * @param {Object} [scope]
  8484. * @param {Fragment} [frag]
  8485. * @return {Function}
  8486. */
  8487. Vue.prototype.$compile = function (el, host, scope, frag) {
  8488. return compile(el, this.$options, true)(this, el, host, scope, frag);
  8489. };
  8490. }
  8491. /**
  8492. * The exposed Vue constructor.
  8493. *
  8494. * API conventions:
  8495. * - public API methods/properties are prefixed with `$`
  8496. * - internal methods/properties are prefixed with `_`
  8497. * - non-prefixed properties are assumed to be proxied user
  8498. * data.
  8499. *
  8500. * @constructor
  8501. * @param {Object} [options]
  8502. * @public
  8503. */
  8504. function Vue(options) {
  8505. this._init(options);
  8506. }
  8507. // install internals
  8508. initMixin(Vue);
  8509. stateMixin(Vue);
  8510. eventsMixin(Vue);
  8511. lifecycleMixin(Vue);
  8512. miscMixin(Vue);
  8513. // install instance APIs
  8514. dataAPI(Vue);
  8515. domAPI(Vue);
  8516. eventsAPI(Vue);
  8517. lifecycleAPI(Vue);
  8518. var slot = {
  8519. priority: SLOT,
  8520. params: ['name'],
  8521. bind: function bind() {
  8522. // this was resolved during component transclusion
  8523. var name = this.params.name || 'default';
  8524. var content = this.vm._slotContents && this.vm._slotContents[name];
  8525. if (!content || !content.hasChildNodes()) {
  8526. this.fallback();
  8527. } else {
  8528. this.compile(content.cloneNode(true), this.vm._context, this.vm);
  8529. }
  8530. },
  8531. compile: function compile(content, context, host) {
  8532. if (content && context) {
  8533. if (this.el.hasChildNodes() && content.childNodes.length === 1 && content.childNodes[0].nodeType === 1 && content.childNodes[0].hasAttribute('v-if')) {
  8534. // if the inserted slot has v-if
  8535. // inject fallback content as the v-else
  8536. var elseBlock = document.createElement('template');
  8537. elseBlock.setAttribute('v-else', '');
  8538. elseBlock.innerHTML = this.el.innerHTML;
  8539. // the else block should be compiled in child scope
  8540. elseBlock._context = this.vm;
  8541. content.appendChild(elseBlock);
  8542. }
  8543. var scope = host ? host._scope : this._scope;
  8544. this.unlink = context.$compile(content, host, scope, this._frag);
  8545. }
  8546. if (content) {
  8547. replace(this.el, content);
  8548. } else {
  8549. remove(this.el);
  8550. }
  8551. },
  8552. fallback: function fallback() {
  8553. this.compile(extractContent(this.el, true), this.vm);
  8554. },
  8555. unbind: function unbind() {
  8556. if (this.unlink) {
  8557. this.unlink();
  8558. }
  8559. }
  8560. };
  8561. var partial = {
  8562. priority: PARTIAL,
  8563. params: ['name'],
  8564. // watch changes to name for dynamic partials
  8565. paramWatchers: {
  8566. name: function name(value) {
  8567. vIf.remove.call(this);
  8568. if (value) {
  8569. this.insert(value);
  8570. }
  8571. }
  8572. },
  8573. bind: function bind() {
  8574. this.anchor = createAnchor('v-partial');
  8575. replace(this.el, this.anchor);
  8576. this.insert(this.params.name);
  8577. },
  8578. insert: function insert(id) {
  8579. var partial = resolveAsset(this.vm.$options, 'partials', id, true);
  8580. if (partial) {
  8581. this.factory = new FragmentFactory(this.vm, partial);
  8582. vIf.insert.call(this);
  8583. }
  8584. },
  8585. unbind: function unbind() {
  8586. if (this.frag) {
  8587. this.frag.destroy();
  8588. }
  8589. }
  8590. };
  8591. var elementDirectives = {
  8592. slot: slot,
  8593. partial: partial
  8594. };
  8595. var convertArray = vFor._postProcess;
  8596. /**
  8597. * Limit filter for arrays
  8598. *
  8599. * @param {Number} n
  8600. * @param {Number} offset (Decimal expected)
  8601. */
  8602. function limitBy(arr, n, offset) {
  8603. offset = offset ? parseInt(offset, 10) : 0;
  8604. n = toNumber(n);
  8605. return typeof n === 'number' ? arr.slice(offset, offset + n) : arr;
  8606. }
  8607. /**
  8608. * Filter filter for arrays
  8609. *
  8610. * @param {String} search
  8611. * @param {String} [delimiter]
  8612. * @param {String} ...dataKeys
  8613. */
  8614. function filterBy(arr, search, delimiter) {
  8615. arr = convertArray(arr);
  8616. if (search == null) {
  8617. return arr;
  8618. }
  8619. if (typeof search === 'function') {
  8620. return arr.filter(search);
  8621. }
  8622. // cast to lowercase string
  8623. search = ('' + search).toLowerCase();
  8624. // allow optional `in` delimiter
  8625. // because why not
  8626. var n = delimiter === 'in' ? 3 : 2;
  8627. // extract and flatten keys
  8628. var keys = Array.prototype.concat.apply([], toArray(arguments, n));
  8629. var res = [];
  8630. var item, key, val, j;
  8631. for (var i = 0, l = arr.length; i < l; i++) {
  8632. item = arr[i];
  8633. val = item && item.$value || item;
  8634. j = keys.length;
  8635. if (j) {
  8636. while (j--) {
  8637. key = keys[j];
  8638. if (key === '$key' && contains(item.$key, search) || contains(getPath(val, key), search)) {
  8639. res.push(item);
  8640. break;
  8641. }
  8642. }
  8643. } else if (contains(item, search)) {
  8644. res.push(item);
  8645. }
  8646. }
  8647. return res;
  8648. }
  8649. /**
  8650. * Filter filter for arrays
  8651. *
  8652. * @param {String|Array<String>|Function} ...sortKeys
  8653. * @param {Number} [order]
  8654. */
  8655. function orderBy(arr) {
  8656. var comparator = null;
  8657. var sortKeys = undefined;
  8658. arr = convertArray(arr);
  8659. // determine order (last argument)
  8660. var args = toArray(arguments, 1);
  8661. var order = args[args.length - 1];
  8662. if (typeof order === 'number') {
  8663. order = order < 0 ? -1 : 1;
  8664. args = args.length > 1 ? args.slice(0, -1) : args;
  8665. } else {
  8666. order = 1;
  8667. }
  8668. // determine sortKeys & comparator
  8669. var firstArg = args[0];
  8670. if (!firstArg) {
  8671. return arr;
  8672. } else if (typeof firstArg === 'function') {
  8673. // custom comparator
  8674. comparator = function (a, b) {
  8675. return firstArg(a, b) * order;
  8676. };
  8677. } else {
  8678. // string keys. flatten first
  8679. sortKeys = Array.prototype.concat.apply([], args);
  8680. comparator = function (a, b, i) {
  8681. i = i || 0;
  8682. return i >= sortKeys.length - 1 ? baseCompare(a, b, i) : baseCompare(a, b, i) || comparator(a, b, i + 1);
  8683. };
  8684. }
  8685. function baseCompare(a, b, sortKeyIndex) {
  8686. var sortKey = sortKeys[sortKeyIndex];
  8687. if (sortKey) {
  8688. if (sortKey !== '$key') {
  8689. if (isObject(a) && '$value' in a) a = a.$value;
  8690. if (isObject(b) && '$value' in b) b = b.$value;
  8691. }
  8692. a = isObject(a) ? getPath(a, sortKey) : a;
  8693. b = isObject(b) ? getPath(b, sortKey) : b;
  8694. }
  8695. return a === b ? 0 : a > b ? order : -order;
  8696. }
  8697. // sort on a copy to avoid mutating original array
  8698. return arr.slice().sort(comparator);
  8699. }
  8700. /**
  8701. * String contain helper
  8702. *
  8703. * @param {*} val
  8704. * @param {String} search
  8705. */
  8706. function contains(val, search) {
  8707. var i;
  8708. if (isPlainObject(val)) {
  8709. var keys = Object.keys(val);
  8710. i = keys.length;
  8711. while (i--) {
  8712. if (contains(val[keys[i]], search)) {
  8713. return true;
  8714. }
  8715. }
  8716. } else if (isArray(val)) {
  8717. i = val.length;
  8718. while (i--) {
  8719. if (contains(val[i], search)) {
  8720. return true;
  8721. }
  8722. }
  8723. } else if (val != null) {
  8724. return val.toString().toLowerCase().indexOf(search) > -1;
  8725. }
  8726. }
  8727. var digitsRE = /(\d{3})(?=\d)/g;
  8728. // asset collections must be a plain object.
  8729. var filters = {
  8730. orderBy: orderBy,
  8731. filterBy: filterBy,
  8732. limitBy: limitBy,
  8733. /**
  8734. * Stringify value.
  8735. *
  8736. * @param {Number} indent
  8737. */
  8738. json: {
  8739. read: function read(value, indent) {
  8740. return typeof value === 'string' ? value : JSON.stringify(value, null, Number(indent) || 2);
  8741. },
  8742. write: function write(value) {
  8743. try {
  8744. return JSON.parse(value);
  8745. } catch (e) {
  8746. return value;
  8747. }
  8748. }
  8749. },
  8750. /**
  8751. * 'abc' => 'Abc'
  8752. */
  8753. capitalize: function capitalize(value) {
  8754. if (!value && value !== 0) return '';
  8755. value = value.toString();
  8756. return value.charAt(0).toUpperCase() + value.slice(1);
  8757. },
  8758. /**
  8759. * 'abc' => 'ABC'
  8760. */
  8761. uppercase: function uppercase(value) {
  8762. return value || value === 0 ? value.toString().toUpperCase() : '';
  8763. },
  8764. /**
  8765. * 'AbC' => 'abc'
  8766. */
  8767. lowercase: function lowercase(value) {
  8768. return value || value === 0 ? value.toString().toLowerCase() : '';
  8769. },
  8770. /**
  8771. * 12345 => $12,345.00
  8772. *
  8773. * @param {String} sign
  8774. * @param {Number} decimals Decimal places
  8775. */
  8776. currency: function currency(value, _currency, decimals) {
  8777. value = parseFloat(value);
  8778. if (!isFinite(value) || !value && value !== 0) return '';
  8779. _currency = _currency != null ? _currency : '$';
  8780. decimals = decimals != null ? decimals : 2;
  8781. var stringified = Math.abs(value).toFixed(decimals);
  8782. var _int = decimals ? stringified.slice(0, -1 - decimals) : stringified;
  8783. var i = _int.length % 3;
  8784. var head = i > 0 ? _int.slice(0, i) + (_int.length > 3 ? ',' : '') : '';
  8785. var _float = decimals ? stringified.slice(-1 - decimals) : '';
  8786. var sign = value < 0 ? '-' : '';
  8787. return sign + _currency + head + _int.slice(i).replace(digitsRE, '$1,') + _float;
  8788. },
  8789. /**
  8790. * 'item' => 'items'
  8791. *
  8792. * @params
  8793. * an array of strings corresponding to
  8794. * the single, double, triple ... forms of the word to
  8795. * be pluralized. When the number to be pluralized
  8796. * exceeds the length of the args, it will use the last
  8797. * entry in the array.
  8798. *
  8799. * e.g. ['single', 'double', 'triple', 'multiple']
  8800. */
  8801. pluralize: function pluralize(value) {
  8802. var args = toArray(arguments, 1);
  8803. return args.length > 1 ? args[value % 10 - 1] || args[args.length - 1] : args[0] + (value === 1 ? '' : 's');
  8804. },
  8805. /**
  8806. * Debounce a handler function.
  8807. *
  8808. * @param {Function} handler
  8809. * @param {Number} delay = 300
  8810. * @return {Function}
  8811. */
  8812. debounce: function debounce(handler, delay) {
  8813. if (!handler) return;
  8814. if (!delay) {
  8815. delay = 300;
  8816. }
  8817. return _debounce(handler, delay);
  8818. }
  8819. };
  8820. function installGlobalAPI (Vue) {
  8821. /**
  8822. * Vue and every constructor that extends Vue has an
  8823. * associated options object, which can be accessed during
  8824. * compilation steps as `this.constructor.options`.
  8825. *
  8826. * These can be seen as the default options of every
  8827. * Vue instance.
  8828. */
  8829. Vue.options = {
  8830. directives: directives,
  8831. elementDirectives: elementDirectives,
  8832. filters: filters,
  8833. transitions: {},
  8834. components: {},
  8835. partials: {},
  8836. replace: true
  8837. };
  8838. /**
  8839. * Expose useful internals
  8840. */
  8841. Vue.util = util;
  8842. Vue.config = config;
  8843. Vue.set = set;
  8844. Vue['delete'] = del;
  8845. Vue.nextTick = nextTick;
  8846. /**
  8847. * The following are exposed for advanced usage / plugins
  8848. */
  8849. Vue.compiler = compiler;
  8850. Vue.FragmentFactory = FragmentFactory;
  8851. Vue.internalDirectives = internalDirectives;
  8852. Vue.parsers = {
  8853. path: path,
  8854. text: text,
  8855. template: template,
  8856. directive: directive,
  8857. expression: expression
  8858. };
  8859. /**
  8860. * Each instance constructor, including Vue, has a unique
  8861. * cid. This enables us to create wrapped "child
  8862. * constructors" for prototypal inheritance and cache them.
  8863. */
  8864. Vue.cid = 0;
  8865. var cid = 1;
  8866. /**
  8867. * Class inheritance
  8868. *
  8869. * @param {Object} extendOptions
  8870. */
  8871. Vue.extend = function (extendOptions) {
  8872. extendOptions = extendOptions || {};
  8873. var Super = this;
  8874. var isFirstExtend = Super.cid === 0;
  8875. if (isFirstExtend && extendOptions._Ctor) {
  8876. return extendOptions._Ctor;
  8877. }
  8878. var name = extendOptions.name || Super.options.name;
  8879. if ('development' !== 'production') {
  8880. if (!/^[a-zA-Z][\w-]*$/.test(name)) {
  8881. warn('Invalid component name: "' + name + '". Component names ' + 'can only contain alphanumeric characaters and the hyphen.');
  8882. name = null;
  8883. }
  8884. }
  8885. var Sub = createClass(name || 'VueComponent');
  8886. Sub.prototype = Object.create(Super.prototype);
  8887. Sub.prototype.constructor = Sub;
  8888. Sub.cid = cid++;
  8889. Sub.options = mergeOptions(Super.options, extendOptions);
  8890. Sub['super'] = Super;
  8891. // allow further extension
  8892. Sub.extend = Super.extend;
  8893. // create asset registers, so extended classes
  8894. // can have their private assets too.
  8895. config._assetTypes.forEach(function (type) {
  8896. Sub[type] = Super[type];
  8897. });
  8898. // enable recursive self-lookup
  8899. if (name) {
  8900. Sub.options.components[name] = Sub;
  8901. }
  8902. // cache constructor
  8903. if (isFirstExtend) {
  8904. extendOptions._Ctor = Sub;
  8905. }
  8906. return Sub;
  8907. };
  8908. /**
  8909. * A function that returns a sub-class constructor with the
  8910. * given name. This gives us much nicer output when
  8911. * logging instances in the console.
  8912. *
  8913. * @param {String} name
  8914. * @return {Function}
  8915. */
  8916. function createClass(name) {
  8917. /* eslint-disable no-new-func */
  8918. return new Function('return function ' + classify(name) + ' (options) { this._init(options) }')();
  8919. /* eslint-enable no-new-func */
  8920. }
  8921. /**
  8922. * Plugin system
  8923. *
  8924. * @param {Object} plugin
  8925. */
  8926. Vue.use = function (plugin) {
  8927. /* istanbul ignore if */
  8928. if (plugin.installed) {
  8929. return;
  8930. }
  8931. // additional parameters
  8932. var args = toArray(arguments, 1);
  8933. args.unshift(this);
  8934. if (typeof plugin.install === 'function') {
  8935. plugin.install.apply(plugin, args);
  8936. } else {
  8937. plugin.apply(null, args);
  8938. }
  8939. plugin.installed = true;
  8940. return this;
  8941. };
  8942. /**
  8943. * Apply a global mixin by merging it into the default
  8944. * options.
  8945. */
  8946. Vue.mixin = function (mixin) {
  8947. Vue.options = mergeOptions(Vue.options, mixin);
  8948. };
  8949. /**
  8950. * Create asset registration methods with the following
  8951. * signature:
  8952. *
  8953. * @param {String} id
  8954. * @param {*} definition
  8955. */
  8956. config._assetTypes.forEach(function (type) {
  8957. Vue[type] = function (id, definition) {
  8958. if (!definition) {
  8959. return this.options[type + 's'][id];
  8960. } else {
  8961. /* istanbul ignore if */
  8962. if ('development' !== 'production') {
  8963. if (type === 'component' && (commonTagRE.test(id) || reservedTagRE.test(id))) {
  8964. warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + id);
  8965. }
  8966. }
  8967. if (type === 'component' && isPlainObject(definition)) {
  8968. definition.name = id;
  8969. definition = Vue.extend(definition);
  8970. }
  8971. this.options[type + 's'][id] = definition;
  8972. return definition;
  8973. }
  8974. };
  8975. });
  8976. // expose internal transition API
  8977. extend(Vue.transition, transition);
  8978. }
  8979. installGlobalAPI(Vue);
  8980. Vue.version = '1.0.24';
  8981. // devtools global hook
  8982. /* istanbul ignore next */
  8983. setTimeout(function () {
  8984. if (config.devtools) {
  8985. if (devtools) {
  8986. devtools.emit('init', Vue);
  8987. } else if ('development' !== 'production' && inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent)) {
  8988. console.log('Download the Vue Devtools for a better development experience:\n' + 'https://github.com/vuejs/vue-devtools');
  8989. }
  8990. }
  8991. }, 0);
  8992. return Vue;
  8993. }));