fea21d07929a3bfd1791e338b3643845.js 309 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913
  1. "no use strict";
  2. !(function(window) {
  3. if (typeof window.window != "undefined" && window.document)
  4. return;
  5. if (window.require && window.define)
  6. return;
  7. if (!window.console) {
  8. window.console = function() {
  9. var msgs = Array.prototype.slice.call(arguments, 0);
  10. postMessage({type: "log", data: msgs});
  11. };
  12. window.console.error =
  13. window.console.warn =
  14. window.console.log =
  15. window.console.trace = window.console;
  16. }
  17. window.window = window;
  18. window.ace = window;
  19. window.onerror = function(message, file, line, col, err) {
  20. postMessage({type: "error", data: {
  21. message: message,
  22. data: err && err.data,
  23. file: file,
  24. line: line,
  25. col: col,
  26. stack: err && err.stack
  27. }});
  28. };
  29. window.normalizeModule = function(parentId, moduleName) {
  30. // normalize plugin requires
  31. if (moduleName.indexOf("!") !== -1) {
  32. var chunks = moduleName.split("!");
  33. return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
  34. }
  35. // normalize relative requires
  36. if (moduleName.charAt(0) == ".") {
  37. var base = parentId.split("/").slice(0, -1).join("/");
  38. moduleName = (base ? base + "/" : "") + moduleName;
  39. while (moduleName.indexOf(".") !== -1 && previous != moduleName) {
  40. var previous = moduleName;
  41. moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
  42. }
  43. }
  44. return moduleName;
  45. };
  46. window.require = function require(parentId, id) {
  47. if (!id) {
  48. id = parentId;
  49. parentId = null;
  50. }
  51. if (!id.charAt)
  52. throw new Error("worker.js require() accepts only (parentId, id) as arguments");
  53. id = window.normalizeModule(parentId, id);
  54. var module = window.require.modules[id];
  55. if (module) {
  56. if (!module.initialized) {
  57. module.initialized = true;
  58. module.exports = module.factory().exports;
  59. }
  60. return module.exports;
  61. }
  62. if (!window.require.tlns)
  63. return console.log("unable to load " + id);
  64. var path = resolveModuleId(id, window.require.tlns);
  65. if (path.slice(-3) != ".js") path += ".js";
  66. window.require.id = id;
  67. window.require.modules[id] = {}; // prevent infinite loop on broken modules
  68. importScripts(path);
  69. return window.require(parentId, id);
  70. };
  71. function resolveModuleId(id, paths) {
  72. var testPath = id, tail = "";
  73. while (testPath) {
  74. var alias = paths[testPath];
  75. if (typeof alias == "string") {
  76. return alias + tail;
  77. } else if (alias) {
  78. return alias.location.replace(/\/*$/, "/") + (tail || alias.main || alias.name);
  79. } else if (alias === false) {
  80. return "";
  81. }
  82. var i = testPath.lastIndexOf("/");
  83. if (i === -1) break;
  84. tail = testPath.substr(i) + tail;
  85. testPath = testPath.slice(0, i);
  86. }
  87. return id;
  88. }
  89. window.require.modules = {};
  90. window.require.tlns = {};
  91. window.define = function(id, deps, factory) {
  92. if (arguments.length == 2) {
  93. factory = deps;
  94. if (typeof id != "string") {
  95. deps = id;
  96. id = window.require.id;
  97. }
  98. } else if (arguments.length == 1) {
  99. factory = id;
  100. deps = [];
  101. id = window.require.id;
  102. }
  103. if (typeof factory != "function") {
  104. window.require.modules[id] = {
  105. exports: factory,
  106. initialized: true
  107. };
  108. return;
  109. }
  110. if (!deps.length)
  111. // If there is no dependencies, we inject "require", "exports" and
  112. // "module" as dependencies, to provide CommonJS compatibility.
  113. deps = ["require", "exports", "module"];
  114. var req = function(childId) {
  115. return window.require(id, childId);
  116. };
  117. window.require.modules[id] = {
  118. exports: {},
  119. factory: function() {
  120. var module = this;
  121. var returnExports = factory.apply(this, deps.slice(0, factory.length).map(function(dep) {
  122. switch (dep) {
  123. // Because "require", "exports" and "module" aren't actual
  124. // dependencies, we must handle them seperately.
  125. case "require": return req;
  126. case "exports": return module.exports;
  127. case "module": return module;
  128. // But for all other dependencies, we can just go ahead and
  129. // require them.
  130. default: return req(dep);
  131. }
  132. }));
  133. if (returnExports)
  134. module.exports = returnExports;
  135. return module;
  136. }
  137. };
  138. };
  139. window.define.amd = {};
  140. window.require.tlns = {};
  141. window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
  142. for (var i in topLevelNamespaces)
  143. this.require.tlns[i] = topLevelNamespaces[i];
  144. };
  145. window.initSender = function initSender() {
  146. var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
  147. var oop = window.require("ace/lib/oop");
  148. var Sender = function() {};
  149. (function() {
  150. oop.implement(this, EventEmitter);
  151. this.callback = function(data, callbackId) {
  152. postMessage({
  153. type: "call",
  154. id: callbackId,
  155. data: data
  156. });
  157. };
  158. this.emit = function(name, data) {
  159. postMessage({
  160. type: "event",
  161. name: name,
  162. data: data
  163. });
  164. };
  165. }).call(Sender.prototype);
  166. return new Sender();
  167. };
  168. var main = window.main = null;
  169. var sender = window.sender = null;
  170. window.onmessage = function(e) {
  171. var msg = e.data;
  172. if (msg.event && sender) {
  173. sender._signal(msg.event, msg.data);
  174. }
  175. else if (msg.command) {
  176. if (main[msg.command])
  177. main[msg.command].apply(main, msg.args);
  178. else if (window[msg.command])
  179. window[msg.command].apply(window, msg.args);
  180. else
  181. throw new Error("Unknown command:" + msg.command);
  182. }
  183. else if (msg.init) {
  184. window.initBaseUrls(msg.tlns);
  185. sender = window.sender = window.initSender();
  186. var clazz = this.require(msg.module)[msg.classname];
  187. main = window.main = new clazz(sender);
  188. }
  189. };
  190. })(this);
  191. ace.define("ace/lib/oop",[], function(require, exports, module){"use strict";
  192. exports.inherits = function (ctor, superCtor) {
  193. ctor.super_ = superCtor;
  194. ctor.prototype = Object.create(superCtor.prototype, {
  195. constructor: {
  196. value: ctor,
  197. enumerable: false,
  198. writable: true,
  199. configurable: true
  200. }
  201. });
  202. };
  203. exports.mixin = function (obj, mixin) {
  204. for (var key in mixin) {
  205. obj[key] = mixin[key];
  206. }
  207. return obj;
  208. };
  209. exports.implement = function (proto, mixin) {
  210. exports.mixin(proto, mixin);
  211. };
  212. });
  213. ace.define("ace/lib/deep_copy",[], function(require, exports, module){exports.deepCopy = function deepCopy(obj) {
  214. if (typeof obj !== "object" || !obj)
  215. return obj;
  216. var copy;
  217. if (Array.isArray(obj)) {
  218. copy = [];
  219. for (var key = 0; key < obj.length; key++) {
  220. copy[key] = deepCopy(obj[key]);
  221. }
  222. return copy;
  223. }
  224. if (Object.prototype.toString.call(obj) !== "[object Object]")
  225. return obj;
  226. copy = {};
  227. for (var key in obj)
  228. copy[key] = deepCopy(obj[key]);
  229. return copy;
  230. };
  231. });
  232. ace.define("ace/lib/lang",[], function(require, exports, module){"use strict";
  233. exports.last = function (a) {
  234. return a[a.length - 1];
  235. };
  236. exports.stringReverse = function (string) {
  237. return string.split("").reverse().join("");
  238. };
  239. exports.stringRepeat = function (string, count) {
  240. var result = '';
  241. while (count > 0) {
  242. if (count & 1)
  243. result += string;
  244. if (count >>= 1)
  245. string += string;
  246. }
  247. return result;
  248. };
  249. var trimBeginRegexp = /^\s\s*/;
  250. var trimEndRegexp = /\s\s*$/;
  251. exports.stringTrimLeft = function (string) {
  252. return string.replace(trimBeginRegexp, '');
  253. };
  254. exports.stringTrimRight = function (string) {
  255. return string.replace(trimEndRegexp, '');
  256. };
  257. exports.copyObject = function (obj) {
  258. var copy = {};
  259. for (var key in obj) {
  260. copy[key] = obj[key];
  261. }
  262. return copy;
  263. };
  264. exports.copyArray = function (array) {
  265. var copy = [];
  266. for (var i = 0, l = array.length; i < l; i++) {
  267. if (array[i] && typeof array[i] == "object")
  268. copy[i] = this.copyObject(array[i]);
  269. else
  270. copy[i] = array[i];
  271. }
  272. return copy;
  273. };
  274. exports.deepCopy = require("./deep_copy").deepCopy;
  275. exports.arrayToMap = function (arr) {
  276. var map = {};
  277. for (var i = 0; i < arr.length; i++) {
  278. map[arr[i]] = 1;
  279. }
  280. return map;
  281. };
  282. exports.createMap = function (props) {
  283. var map = Object.create(null);
  284. for (var i in props) {
  285. map[i] = props[i];
  286. }
  287. return map;
  288. };
  289. exports.arrayRemove = function (array, value) {
  290. for (var i = 0; i <= array.length; i++) {
  291. if (value === array[i]) {
  292. array.splice(i, 1);
  293. }
  294. }
  295. };
  296. exports.escapeRegExp = function (str) {
  297. return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
  298. };
  299. exports.escapeHTML = function (str) {
  300. return ("" + str).replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
  301. };
  302. exports.getMatchOffsets = function (string, regExp) {
  303. var matches = [];
  304. string.replace(regExp, function (str) {
  305. matches.push({
  306. offset: arguments[arguments.length - 2],
  307. length: str.length
  308. });
  309. });
  310. return matches;
  311. };
  312. exports.deferredCall = function (fcn) {
  313. var timer = null;
  314. var callback = function () {
  315. timer = null;
  316. fcn();
  317. };
  318. var deferred = function (timeout) {
  319. deferred.cancel();
  320. timer = setTimeout(callback, timeout || 0);
  321. return deferred;
  322. };
  323. deferred.schedule = deferred;
  324. deferred.call = function () {
  325. this.cancel();
  326. fcn();
  327. return deferred;
  328. };
  329. deferred.cancel = function () {
  330. clearTimeout(timer);
  331. timer = null;
  332. return deferred;
  333. };
  334. deferred.isPending = function () {
  335. return timer;
  336. };
  337. return deferred;
  338. };
  339. exports.delayedCall = function (fcn, defaultTimeout) {
  340. var timer = null;
  341. var callback = function () {
  342. timer = null;
  343. fcn();
  344. };
  345. var _self = function (timeout) {
  346. if (timer == null)
  347. timer = setTimeout(callback, timeout || defaultTimeout);
  348. };
  349. _self.delay = function (timeout) {
  350. timer && clearTimeout(timer);
  351. timer = setTimeout(callback, timeout || defaultTimeout);
  352. };
  353. _self.schedule = _self;
  354. _self.call = function () {
  355. this.cancel();
  356. fcn();
  357. };
  358. _self.cancel = function () {
  359. timer && clearTimeout(timer);
  360. timer = null;
  361. };
  362. _self.isPending = function () {
  363. return timer;
  364. };
  365. return _self;
  366. };
  367. exports.supportsLookbehind = function () {
  368. try {
  369. new RegExp('(?<=.)');
  370. }
  371. catch (e) {
  372. return false;
  373. }
  374. return true;
  375. };
  376. exports.skipEmptyMatch = function (line, last, supportsUnicodeFlag) {
  377. return supportsUnicodeFlag && line.codePointAt(last) > 0xffff ? 2 : 1;
  378. };
  379. });
  380. ace.define("ace/apply_delta",[], function(require, exports, module){"use strict";
  381. function throwDeltaError(delta, errorText) {
  382. console.log("Invalid Delta:", delta);
  383. throw "Invalid Delta: " + errorText;
  384. }
  385. function positionInDocument(docLines, position) {
  386. return position.row >= 0 && position.row < docLines.length &&
  387. position.column >= 0 && position.column <= docLines[position.row].length;
  388. }
  389. function validateDelta(docLines, delta) {
  390. if (delta.action != "insert" && delta.action != "remove")
  391. throwDeltaError(delta, "delta.action must be 'insert' or 'remove'");
  392. if (!(delta.lines instanceof Array))
  393. throwDeltaError(delta, "delta.lines must be an Array");
  394. if (!delta.start || !delta.end)
  395. throwDeltaError(delta, "delta.start/end must be an present");
  396. var start = delta.start;
  397. if (!positionInDocument(docLines, delta.start))
  398. throwDeltaError(delta, "delta.start must be contained in document");
  399. var end = delta.end;
  400. if (delta.action == "remove" && !positionInDocument(docLines, end))
  401. throwDeltaError(delta, "delta.end must contained in document for 'remove' actions");
  402. var numRangeRows = end.row - start.row;
  403. var numRangeLastLineChars = (end.column - (numRangeRows == 0 ? start.column : 0));
  404. if (numRangeRows != delta.lines.length - 1 || delta.lines[numRangeRows].length != numRangeLastLineChars)
  405. throwDeltaError(delta, "delta.range must match delta lines");
  406. }
  407. exports.applyDelta = function (docLines, delta, doNotValidate) {
  408. var row = delta.start.row;
  409. var startColumn = delta.start.column;
  410. var line = docLines[row] || "";
  411. switch (delta.action) {
  412. case "insert":
  413. var lines = delta.lines;
  414. if (lines.length === 1) {
  415. docLines[row] = line.substring(0, startColumn) + delta.lines[0] + line.substring(startColumn);
  416. }
  417. else {
  418. var args = [row, 1].concat(delta.lines);
  419. docLines.splice.apply(docLines, args);
  420. docLines[row] = line.substring(0, startColumn) + docLines[row];
  421. docLines[row + delta.lines.length - 1] += line.substring(startColumn);
  422. }
  423. break;
  424. case "remove":
  425. var endColumn = delta.end.column;
  426. var endRow = delta.end.row;
  427. if (row === endRow) {
  428. docLines[row] = line.substring(0, startColumn) + line.substring(endColumn);
  429. }
  430. else {
  431. docLines.splice(row, endRow - row + 1, line.substring(0, startColumn) + docLines[endRow].substring(endColumn));
  432. }
  433. break;
  434. }
  435. };
  436. });
  437. ace.define("ace/lib/event_emitter",[], function(require, exports, module){"use strict";
  438. var EventEmitter = {};
  439. var stopPropagation = function () { this.propagationStopped = true; };
  440. var preventDefault = function () { this.defaultPrevented = true; };
  441. EventEmitter._emit =
  442. EventEmitter._dispatchEvent = function (eventName, e) {
  443. this._eventRegistry || (this._eventRegistry = {});
  444. this._defaultHandlers || (this._defaultHandlers = {});
  445. var listeners = this._eventRegistry[eventName] || [];
  446. var defaultHandler = this._defaultHandlers[eventName];
  447. if (!listeners.length && !defaultHandler)
  448. return;
  449. if (typeof e != "object" || !e)
  450. e = {};
  451. if (!e.type)
  452. e.type = eventName;
  453. if (!e.stopPropagation)
  454. e.stopPropagation = stopPropagation;
  455. if (!e.preventDefault)
  456. e.preventDefault = preventDefault;
  457. listeners = listeners.slice();
  458. for (var i = 0; i < listeners.length; i++) {
  459. listeners[i](e, this);
  460. if (e.propagationStopped)
  461. break;
  462. }
  463. if (defaultHandler && !e.defaultPrevented)
  464. return defaultHandler(e, this);
  465. };
  466. EventEmitter._signal = function (eventName, e) {
  467. var listeners = (this._eventRegistry || {})[eventName];
  468. if (!listeners)
  469. return;
  470. listeners = listeners.slice();
  471. for (var i = 0; i < listeners.length; i++)
  472. listeners[i](e, this);
  473. };
  474. EventEmitter.once = function (eventName, callback) {
  475. var _self = this;
  476. this.on(eventName, function newCallback() {
  477. _self.off(eventName, newCallback);
  478. callback.apply(null, arguments);
  479. });
  480. if (!callback) {
  481. return new Promise(function (resolve) {
  482. callback = resolve;
  483. });
  484. }
  485. };
  486. EventEmitter.setDefaultHandler = function (eventName, callback) {
  487. var handlers = this._defaultHandlers;
  488. if (!handlers)
  489. handlers = this._defaultHandlers = { _disabled_: {} };
  490. if (handlers[eventName]) {
  491. var old = handlers[eventName];
  492. var disabled = handlers._disabled_[eventName];
  493. if (!disabled)
  494. handlers._disabled_[eventName] = disabled = [];
  495. disabled.push(old);
  496. var i = disabled.indexOf(callback);
  497. if (i != -1)
  498. disabled.splice(i, 1);
  499. }
  500. handlers[eventName] = callback;
  501. };
  502. EventEmitter.removeDefaultHandler = function (eventName, callback) {
  503. var handlers = this._defaultHandlers;
  504. if (!handlers)
  505. return;
  506. var disabled = handlers._disabled_[eventName];
  507. if (handlers[eventName] == callback) {
  508. if (disabled)
  509. this.setDefaultHandler(eventName, disabled.pop());
  510. }
  511. else if (disabled) {
  512. var i = disabled.indexOf(callback);
  513. if (i != -1)
  514. disabled.splice(i, 1);
  515. }
  516. };
  517. EventEmitter.on =
  518. EventEmitter.addEventListener = function (eventName, callback, capturing) {
  519. this._eventRegistry = this._eventRegistry || {};
  520. var listeners = this._eventRegistry[eventName];
  521. if (!listeners)
  522. listeners = this._eventRegistry[eventName] = [];
  523. if (listeners.indexOf(callback) == -1)
  524. listeners[capturing ? "unshift" : "push"](callback);
  525. return callback;
  526. };
  527. EventEmitter.off =
  528. EventEmitter.removeListener =
  529. EventEmitter.removeEventListener = function (eventName, callback) {
  530. this._eventRegistry = this._eventRegistry || {};
  531. var listeners = this._eventRegistry[eventName];
  532. if (!listeners)
  533. return;
  534. var index = listeners.indexOf(callback);
  535. if (index !== -1)
  536. listeners.splice(index, 1);
  537. };
  538. EventEmitter.removeAllListeners = function (eventName) {
  539. if (!eventName)
  540. this._eventRegistry = this._defaultHandlers = undefined;
  541. if (this._eventRegistry)
  542. this._eventRegistry[eventName] = undefined;
  543. if (this._defaultHandlers)
  544. this._defaultHandlers[eventName] = undefined;
  545. };
  546. exports.EventEmitter = EventEmitter;
  547. });
  548. ace.define("ace/range",[], function(require, exports, module){"use strict";
  549. var Range = /** @class */ (function () {
  550. function Range(startRow, startColumn, endRow, endColumn) {
  551. this.start = {
  552. row: startRow,
  553. column: startColumn
  554. };
  555. this.end = {
  556. row: endRow,
  557. column: endColumn
  558. };
  559. }
  560. Range.prototype.isEqual = function (range) {
  561. return this.start.row === range.start.row &&
  562. this.end.row === range.end.row &&
  563. this.start.column === range.start.column &&
  564. this.end.column === range.end.column;
  565. };
  566. Range.prototype.toString = function () {
  567. return ("Range: [" + this.start.row + "/" + this.start.column +
  568. "] -> [" + this.end.row + "/" + this.end.column + "]");
  569. };
  570. Range.prototype.contains = function (row, column) {
  571. return this.compare(row, column) == 0;
  572. };
  573. Range.prototype.compareRange = function (range) {
  574. var cmp, end = range.end, start = range.start;
  575. cmp = this.compare(end.row, end.column);
  576. if (cmp == 1) {
  577. cmp = this.compare(start.row, start.column);
  578. if (cmp == 1) {
  579. return 2;
  580. }
  581. else if (cmp == 0) {
  582. return 1;
  583. }
  584. else {
  585. return 0;
  586. }
  587. }
  588. else if (cmp == -1) {
  589. return -2;
  590. }
  591. else {
  592. cmp = this.compare(start.row, start.column);
  593. if (cmp == -1) {
  594. return -1;
  595. }
  596. else if (cmp == 1) {
  597. return 42;
  598. }
  599. else {
  600. return 0;
  601. }
  602. }
  603. };
  604. Range.prototype.comparePoint = function (p) {
  605. return this.compare(p.row, p.column);
  606. };
  607. Range.prototype.containsRange = function (range) {
  608. return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
  609. };
  610. Range.prototype.intersects = function (range) {
  611. var cmp = this.compareRange(range);
  612. return (cmp == -1 || cmp == 0 || cmp == 1);
  613. };
  614. Range.prototype.isEnd = function (row, column) {
  615. return this.end.row == row && this.end.column == column;
  616. };
  617. Range.prototype.isStart = function (row, column) {
  618. return this.start.row == row && this.start.column == column;
  619. };
  620. Range.prototype.setStart = function (row, column) {
  621. if (typeof row == "object") {
  622. this.start.column = row.column;
  623. this.start.row = row.row;
  624. }
  625. else {
  626. this.start.row = row;
  627. this.start.column = column;
  628. }
  629. };
  630. Range.prototype.setEnd = function (row, column) {
  631. if (typeof row == "object") {
  632. this.end.column = row.column;
  633. this.end.row = row.row;
  634. }
  635. else {
  636. this.end.row = row;
  637. this.end.column = column;
  638. }
  639. };
  640. Range.prototype.inside = function (row, column) {
  641. if (this.compare(row, column) == 0) {
  642. if (this.isEnd(row, column) || this.isStart(row, column)) {
  643. return false;
  644. }
  645. else {
  646. return true;
  647. }
  648. }
  649. return false;
  650. };
  651. Range.prototype.insideStart = function (row, column) {
  652. if (this.compare(row, column) == 0) {
  653. if (this.isEnd(row, column)) {
  654. return false;
  655. }
  656. else {
  657. return true;
  658. }
  659. }
  660. return false;
  661. };
  662. Range.prototype.insideEnd = function (row, column) {
  663. if (this.compare(row, column) == 0) {
  664. if (this.isStart(row, column)) {
  665. return false;
  666. }
  667. else {
  668. return true;
  669. }
  670. }
  671. return false;
  672. };
  673. Range.prototype.compare = function (row, column) {
  674. if (!this.isMultiLine()) {
  675. if (row === this.start.row) {
  676. return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
  677. }
  678. }
  679. if (row < this.start.row)
  680. return -1;
  681. if (row > this.end.row)
  682. return 1;
  683. if (this.start.row === row)
  684. return column >= this.start.column ? 0 : -1;
  685. if (this.end.row === row)
  686. return column <= this.end.column ? 0 : 1;
  687. return 0;
  688. };
  689. Range.prototype.compareStart = function (row, column) {
  690. if (this.start.row == row && this.start.column == column) {
  691. return -1;
  692. }
  693. else {
  694. return this.compare(row, column);
  695. }
  696. };
  697. Range.prototype.compareEnd = function (row, column) {
  698. if (this.end.row == row && this.end.column == column) {
  699. return 1;
  700. }
  701. else {
  702. return this.compare(row, column);
  703. }
  704. };
  705. Range.prototype.compareInside = function (row, column) {
  706. if (this.end.row == row && this.end.column == column) {
  707. return 1;
  708. }
  709. else if (this.start.row == row && this.start.column == column) {
  710. return -1;
  711. }
  712. else {
  713. return this.compare(row, column);
  714. }
  715. };
  716. Range.prototype.clipRows = function (firstRow, lastRow) {
  717. if (this.end.row > lastRow)
  718. var end = { row: lastRow + 1, column: 0 };
  719. else if (this.end.row < firstRow)
  720. var end = { row: firstRow, column: 0 };
  721. if (this.start.row > lastRow)
  722. var start = { row: lastRow + 1, column: 0 };
  723. else if (this.start.row < firstRow)
  724. var start = { row: firstRow, column: 0 };
  725. return Range.fromPoints(start || this.start, end || this.end);
  726. };
  727. Range.prototype.extend = function (row, column) {
  728. var cmp = this.compare(row, column);
  729. if (cmp == 0)
  730. return this;
  731. else if (cmp == -1)
  732. var start = { row: row, column: column };
  733. else
  734. var end = { row: row, column: column };
  735. return Range.fromPoints(start || this.start, end || this.end);
  736. };
  737. Range.prototype.isEmpty = function () {
  738. return (this.start.row === this.end.row && this.start.column === this.end.column);
  739. };
  740. Range.prototype.isMultiLine = function () {
  741. return (this.start.row !== this.end.row);
  742. };
  743. Range.prototype.clone = function () {
  744. return Range.fromPoints(this.start, this.end);
  745. };
  746. Range.prototype.collapseRows = function () {
  747. if (this.end.column == 0)
  748. return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row - 1), 0);
  749. else
  750. return new Range(this.start.row, 0, this.end.row, 0);
  751. };
  752. Range.prototype.toScreenRange = function (session) {
  753. var screenPosStart = session.documentToScreenPosition(this.start);
  754. var screenPosEnd = session.documentToScreenPosition(this.end);
  755. return new Range(screenPosStart.row, screenPosStart.column, screenPosEnd.row, screenPosEnd.column);
  756. };
  757. Range.prototype.moveBy = function (row, column) {
  758. this.start.row += row;
  759. this.start.column += column;
  760. this.end.row += row;
  761. this.end.column += column;
  762. };
  763. return Range;
  764. }());
  765. Range.fromPoints = function (start, end) {
  766. return new Range(start.row, start.column, end.row, end.column);
  767. };
  768. Range.comparePoints = function (p1, p2) {
  769. return p1.row - p2.row || p1.column - p2.column;
  770. };
  771. exports.Range = Range;
  772. });
  773. ace.define("ace/anchor",[], function(require, exports, module){"use strict";
  774. var oop = require("./lib/oop");
  775. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  776. var Anchor = /** @class */ (function () {
  777. function Anchor(doc, row, column) {
  778. this.$onChange = this.onChange.bind(this);
  779. this.attach(doc);
  780. if (typeof row != "number")
  781. this.setPosition(row.row, row.column);
  782. else
  783. this.setPosition(row, column);
  784. }
  785. Anchor.prototype.getPosition = function () {
  786. return this.$clipPositionToDocument(this.row, this.column);
  787. };
  788. Anchor.prototype.getDocument = function () {
  789. return this.document;
  790. };
  791. Anchor.prototype.onChange = function (delta) {
  792. if (delta.start.row == delta.end.row && delta.start.row != this.row)
  793. return;
  794. if (delta.start.row > this.row)
  795. return;
  796. var point = $getTransformedPoint(delta, { row: this.row, column: this.column }, this.$insertRight);
  797. this.setPosition(point.row, point.column, true);
  798. };
  799. Anchor.prototype.setPosition = function (row, column, noClip) {
  800. var pos;
  801. if (noClip) {
  802. pos = {
  803. row: row,
  804. column: column
  805. };
  806. }
  807. else {
  808. pos = this.$clipPositionToDocument(row, column);
  809. }
  810. if (this.row == pos.row && this.column == pos.column)
  811. return;
  812. var old = {
  813. row: this.row,
  814. column: this.column
  815. };
  816. this.row = pos.row;
  817. this.column = pos.column;
  818. this._signal("change", {
  819. old: old,
  820. value: pos
  821. });
  822. };
  823. Anchor.prototype.detach = function () {
  824. this.document.off("change", this.$onChange);
  825. };
  826. Anchor.prototype.attach = function (doc) {
  827. this.document = doc || this.document;
  828. this.document.on("change", this.$onChange);
  829. };
  830. Anchor.prototype.$clipPositionToDocument = function (row, column) {
  831. var pos = {};
  832. if (row >= this.document.getLength()) {
  833. pos.row = Math.max(0, this.document.getLength() - 1);
  834. pos.column = this.document.getLine(pos.row).length;
  835. }
  836. else if (row < 0) {
  837. pos.row = 0;
  838. pos.column = 0;
  839. }
  840. else {
  841. pos.row = row;
  842. pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
  843. }
  844. if (column < 0)
  845. pos.column = 0;
  846. return pos;
  847. };
  848. return Anchor;
  849. }());
  850. Anchor.prototype.$insertRight = false;
  851. oop.implement(Anchor.prototype, EventEmitter);
  852. function $pointsInOrder(point1, point2, equalPointsInOrder) {
  853. var bColIsAfter = equalPointsInOrder ? point1.column <= point2.column : point1.column < point2.column;
  854. return (point1.row < point2.row) || (point1.row == point2.row && bColIsAfter);
  855. }
  856. function $getTransformedPoint(delta, point, moveIfEqual) {
  857. var deltaIsInsert = delta.action == "insert";
  858. var deltaRowShift = (deltaIsInsert ? 1 : -1) * (delta.end.row - delta.start.row);
  859. var deltaColShift = (deltaIsInsert ? 1 : -1) * (delta.end.column - delta.start.column);
  860. var deltaStart = delta.start;
  861. var deltaEnd = deltaIsInsert ? deltaStart : delta.end; // Collapse insert range.
  862. if ($pointsInOrder(point, deltaStart, moveIfEqual)) {
  863. return {
  864. row: point.row,
  865. column: point.column
  866. };
  867. }
  868. if ($pointsInOrder(deltaEnd, point, !moveIfEqual)) {
  869. return {
  870. row: point.row + deltaRowShift,
  871. column: point.column + (point.row == deltaEnd.row ? deltaColShift : 0)
  872. };
  873. }
  874. return {
  875. row: deltaStart.row,
  876. column: deltaStart.column
  877. };
  878. }
  879. exports.Anchor = Anchor;
  880. });
  881. ace.define("ace/document",[], function(require, exports, module){"use strict";
  882. var oop = require("./lib/oop");
  883. var applyDelta = require("./apply_delta").applyDelta;
  884. var EventEmitter = require("./lib/event_emitter").EventEmitter;
  885. var Range = require("./range").Range;
  886. var Anchor = require("./anchor").Anchor;
  887. var Document = /** @class */ (function () {
  888. function Document(textOrLines) {
  889. this.$lines = [""];
  890. if (textOrLines.length === 0) {
  891. this.$lines = [""];
  892. }
  893. else if (Array.isArray(textOrLines)) {
  894. this.insertMergedLines({ row: 0, column: 0 }, textOrLines);
  895. }
  896. else {
  897. this.insert({ row: 0, column: 0 }, textOrLines);
  898. }
  899. }
  900. Document.prototype.setValue = function (text) {
  901. var len = this.getLength() - 1;
  902. this.remove(new Range(0, 0, len, this.getLine(len).length));
  903. this.insert({ row: 0, column: 0 }, text || "");
  904. };
  905. Document.prototype.getValue = function () {
  906. return this.getAllLines().join(this.getNewLineCharacter());
  907. };
  908. Document.prototype.createAnchor = function (row, column) {
  909. return new Anchor(this, row, column);
  910. };
  911. Document.prototype.$detectNewLine = function (text) {
  912. var match = text.match(/^.*?(\r\n|\r|\n)/m);
  913. this.$autoNewLine = match ? match[1] : "\n";
  914. this._signal("changeNewLineMode");
  915. };
  916. Document.prototype.getNewLineCharacter = function () {
  917. switch (this.$newLineMode) {
  918. case "windows":
  919. return "\r\n";
  920. case "unix":
  921. return "\n";
  922. default:
  923. return this.$autoNewLine || "\n";
  924. }
  925. };
  926. Document.prototype.setNewLineMode = function (newLineMode) {
  927. if (this.$newLineMode === newLineMode)
  928. return;
  929. this.$newLineMode = newLineMode;
  930. this._signal("changeNewLineMode");
  931. };
  932. Document.prototype.getNewLineMode = function () {
  933. return this.$newLineMode;
  934. };
  935. Document.prototype.isNewLine = function (text) {
  936. return (text == "\r\n" || text == "\r" || text == "\n");
  937. };
  938. Document.prototype.getLine = function (row) {
  939. return this.$lines[row] || "";
  940. };
  941. Document.prototype.getLines = function (firstRow, lastRow) {
  942. return this.$lines.slice(firstRow, lastRow + 1);
  943. };
  944. Document.prototype.getAllLines = function () {
  945. return this.getLines(0, this.getLength());
  946. };
  947. Document.prototype.getLength = function () {
  948. return this.$lines.length;
  949. };
  950. Document.prototype.getTextRange = function (range) {
  951. return this.getLinesForRange(range).join(this.getNewLineCharacter());
  952. };
  953. Document.prototype.getLinesForRange = function (range) {
  954. var lines;
  955. if (range.start.row === range.end.row) {
  956. lines = [this.getLine(range.start.row).substring(range.start.column, range.end.column)];
  957. }
  958. else {
  959. lines = this.getLines(range.start.row, range.end.row);
  960. lines[0] = (lines[0] || "").substring(range.start.column);
  961. var l = lines.length - 1;
  962. if (range.end.row - range.start.row == l)
  963. lines[l] = lines[l].substring(0, range.end.column);
  964. }
  965. return lines;
  966. };
  967. Document.prototype.insertLines = function (row, lines) {
  968. console.warn("Use of document.insertLines is deprecated. Use the insertFullLines method instead.");
  969. return this.insertFullLines(row, lines);
  970. };
  971. Document.prototype.removeLines = function (firstRow, lastRow) {
  972. console.warn("Use of document.removeLines is deprecated. Use the removeFullLines method instead.");
  973. return this.removeFullLines(firstRow, lastRow);
  974. };
  975. Document.prototype.insertNewLine = function (position) {
  976. console.warn("Use of document.insertNewLine is deprecated. Use insertMergedLines(position, ['', '']) instead.");
  977. return this.insertMergedLines(position, ["", ""]);
  978. };
  979. Document.prototype.insert = function (position, text) {
  980. if (this.getLength() <= 1)
  981. this.$detectNewLine(text);
  982. return this.insertMergedLines(position, this.$split(text));
  983. };
  984. Document.prototype.insertInLine = function (position, text) {
  985. var start = this.clippedPos(position.row, position.column);
  986. var end = this.pos(position.row, position.column + text.length);
  987. this.applyDelta({
  988. start: start,
  989. end: end,
  990. action: "insert",
  991. lines: [text]
  992. }, true);
  993. return this.clonePos(end);
  994. };
  995. Document.prototype.clippedPos = function (row, column) {
  996. var length = this.getLength();
  997. if (row === undefined) {
  998. row = length;
  999. }
  1000. else if (row < 0) {
  1001. row = 0;
  1002. }
  1003. else if (row >= length) {
  1004. row = length - 1;
  1005. column = undefined;
  1006. }
  1007. var line = this.getLine(row);
  1008. if (column == undefined)
  1009. column = line.length;
  1010. column = Math.min(Math.max(column, 0), line.length);
  1011. return { row: row, column: column };
  1012. };
  1013. Document.prototype.clonePos = function (pos) {
  1014. return { row: pos.row, column: pos.column };
  1015. };
  1016. Document.prototype.pos = function (row, column) {
  1017. return { row: row, column: column };
  1018. };
  1019. Document.prototype.$clipPosition = function (position) {
  1020. var length = this.getLength();
  1021. if (position.row >= length) {
  1022. position.row = Math.max(0, length - 1);
  1023. position.column = this.getLine(length - 1).length;
  1024. }
  1025. else {
  1026. position.row = Math.max(0, position.row);
  1027. position.column = Math.min(Math.max(position.column, 0), this.getLine(position.row).length);
  1028. }
  1029. return position;
  1030. };
  1031. Document.prototype.insertFullLines = function (row, lines) {
  1032. row = Math.min(Math.max(row, 0), this.getLength());
  1033. var column = 0;
  1034. if (row < this.getLength()) {
  1035. lines = lines.concat([""]);
  1036. column = 0;
  1037. }
  1038. else {
  1039. lines = [""].concat(lines);
  1040. row--;
  1041. column = this.$lines[row].length;
  1042. }
  1043. this.insertMergedLines({ row: row, column: column }, lines);
  1044. };
  1045. Document.prototype.insertMergedLines = function (position, lines) {
  1046. var start = this.clippedPos(position.row, position.column);
  1047. var end = {
  1048. row: start.row + lines.length - 1,
  1049. column: (lines.length == 1 ? start.column : 0) + lines[lines.length - 1].length
  1050. };
  1051. this.applyDelta({
  1052. start: start,
  1053. end: end,
  1054. action: "insert",
  1055. lines: lines
  1056. });
  1057. return this.clonePos(end);
  1058. };
  1059. Document.prototype.remove = function (range) {
  1060. var start = this.clippedPos(range.start.row, range.start.column);
  1061. var end = this.clippedPos(range.end.row, range.end.column);
  1062. this.applyDelta({
  1063. start: start,
  1064. end: end,
  1065. action: "remove",
  1066. lines: this.getLinesForRange({ start: start, end: end })
  1067. });
  1068. return this.clonePos(start);
  1069. };
  1070. Document.prototype.removeInLine = function (row, startColumn, endColumn) {
  1071. var start = this.clippedPos(row, startColumn);
  1072. var end = this.clippedPos(row, endColumn);
  1073. this.applyDelta({
  1074. start: start,
  1075. end: end,
  1076. action: "remove",
  1077. lines: this.getLinesForRange({ start: start, end: end })
  1078. }, true);
  1079. return this.clonePos(start);
  1080. };
  1081. Document.prototype.removeFullLines = function (firstRow, lastRow) {
  1082. firstRow = Math.min(Math.max(0, firstRow), this.getLength() - 1);
  1083. lastRow = Math.min(Math.max(0, lastRow), this.getLength() - 1);
  1084. var deleteFirstNewLine = lastRow == this.getLength() - 1 && firstRow > 0;
  1085. var deleteLastNewLine = lastRow < this.getLength() - 1;
  1086. var startRow = (deleteFirstNewLine ? firstRow - 1 : firstRow);
  1087. var startCol = (deleteFirstNewLine ? this.getLine(startRow).length : 0);
  1088. var endRow = (deleteLastNewLine ? lastRow + 1 : lastRow);
  1089. var endCol = (deleteLastNewLine ? 0 : this.getLine(endRow).length);
  1090. var range = new Range(startRow, startCol, endRow, endCol);
  1091. var deletedLines = this.$lines.slice(firstRow, lastRow + 1);
  1092. this.applyDelta({
  1093. start: range.start,
  1094. end: range.end,
  1095. action: "remove",
  1096. lines: this.getLinesForRange(range)
  1097. });
  1098. return deletedLines;
  1099. };
  1100. Document.prototype.removeNewLine = function (row) {
  1101. if (row < this.getLength() - 1 && row >= 0) {
  1102. this.applyDelta({
  1103. start: this.pos(row, this.getLine(row).length),
  1104. end: this.pos(row + 1, 0),
  1105. action: "remove",
  1106. lines: ["", ""]
  1107. });
  1108. }
  1109. };
  1110. Document.prototype.replace = function (range, text) {
  1111. if (!(range instanceof Range))
  1112. range = Range.fromPoints(range.start, range.end);
  1113. if (text.length === 0 && range.isEmpty())
  1114. return range.start;
  1115. if (text == this.getTextRange(range))
  1116. return range.end;
  1117. this.remove(range);
  1118. var end;
  1119. if (text) {
  1120. end = this.insert(range.start, text);
  1121. }
  1122. else {
  1123. end = range.start;
  1124. }
  1125. return end;
  1126. };
  1127. Document.prototype.applyDeltas = function (deltas) {
  1128. for (var i = 0; i < deltas.length; i++) {
  1129. this.applyDelta(deltas[i]);
  1130. }
  1131. };
  1132. Document.prototype.revertDeltas = function (deltas) {
  1133. for (var i = deltas.length - 1; i >= 0; i--) {
  1134. this.revertDelta(deltas[i]);
  1135. }
  1136. };
  1137. Document.prototype.applyDelta = function (delta, doNotValidate) {
  1138. var isInsert = delta.action == "insert";
  1139. if (isInsert ? delta.lines.length <= 1 && !delta.lines[0]
  1140. : !Range.comparePoints(delta.start, delta.end)) {
  1141. return;
  1142. }
  1143. if (isInsert && delta.lines.length > 20000) {
  1144. this.$splitAndapplyLargeDelta(delta, 20000);
  1145. }
  1146. else {
  1147. applyDelta(this.$lines, delta, doNotValidate);
  1148. this._signal("change", delta);
  1149. }
  1150. };
  1151. Document.prototype.$safeApplyDelta = function (delta) {
  1152. var docLength = this.$lines.length;
  1153. if (delta.action == "remove" && delta.start.row < docLength && delta.end.row < docLength
  1154. || delta.action == "insert" && delta.start.row <= docLength) {
  1155. this.applyDelta(delta);
  1156. }
  1157. };
  1158. Document.prototype.$splitAndapplyLargeDelta = function (delta, MAX) {
  1159. var lines = delta.lines;
  1160. var l = lines.length - MAX + 1;
  1161. var row = delta.start.row;
  1162. var column = delta.start.column;
  1163. for (var from = 0, to = 0; from < l; from = to) {
  1164. to += MAX - 1;
  1165. var chunk = lines.slice(from, to);
  1166. chunk.push("");
  1167. this.applyDelta({
  1168. start: this.pos(row + from, column),
  1169. end: this.pos(row + to, column = 0),
  1170. action: delta.action,
  1171. lines: chunk
  1172. }, true);
  1173. }
  1174. delta.lines = lines.slice(from);
  1175. delta.start.row = row + from;
  1176. delta.start.column = column;
  1177. this.applyDelta(delta, true);
  1178. };
  1179. Document.prototype.revertDelta = function (delta) {
  1180. this.$safeApplyDelta({
  1181. start: this.clonePos(delta.start),
  1182. end: this.clonePos(delta.end),
  1183. action: (delta.action == "insert" ? "remove" : "insert"),
  1184. lines: delta.lines.slice()
  1185. });
  1186. };
  1187. Document.prototype.indexToPosition = function (index, startRow) {
  1188. var lines = this.$lines || this.getAllLines();
  1189. var newlineLength = this.getNewLineCharacter().length;
  1190. for (var i = startRow || 0, l = lines.length; i < l; i++) {
  1191. index -= lines[i].length + newlineLength;
  1192. if (index < 0)
  1193. return { row: i, column: index + lines[i].length + newlineLength };
  1194. }
  1195. return { row: l - 1, column: index + lines[l - 1].length + newlineLength };
  1196. };
  1197. Document.prototype.positionToIndex = function (pos, startRow) {
  1198. var lines = this.$lines || this.getAllLines();
  1199. var newlineLength = this.getNewLineCharacter().length;
  1200. var index = 0;
  1201. var row = Math.min(pos.row, lines.length);
  1202. for (var i = startRow || 0; i < row; ++i)
  1203. index += lines[i].length + newlineLength;
  1204. return index + pos.column;
  1205. };
  1206. Document.prototype.$split = function (text) {
  1207. return text.split(/\r\n|\r|\n/);
  1208. };
  1209. return Document;
  1210. }());
  1211. Document.prototype.$autoNewLine = "";
  1212. Document.prototype.$newLineMode = "auto";
  1213. oop.implement(Document.prototype, EventEmitter);
  1214. exports.Document = Document;
  1215. });
  1216. ace.define("ace/worker/mirror",[], function(require, exports, module) {
  1217. "use strict";
  1218. var Document = require("../document").Document;
  1219. var lang = require("../lib/lang");
  1220. var Mirror = exports.Mirror = function(sender) {
  1221. this.sender = sender;
  1222. var doc = this.doc = new Document("");
  1223. var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  1224. var _self = this;
  1225. sender.on("change", function(e) {
  1226. var data = e.data;
  1227. if (data[0].start) {
  1228. doc.applyDeltas(data);
  1229. } else {
  1230. for (var i = 0; i < data.length; i += 2) {
  1231. var d, err;
  1232. if (Array.isArray(data[i+1])) {
  1233. d = {action: "insert", start: data[i], lines: data[i+1]};
  1234. } else {
  1235. d = {action: "remove", start: data[i], end: data[i+1]};
  1236. }
  1237. if ((d.action == "insert" ? d.start : d.end).row >= doc.$lines.length) {
  1238. err = new Error("Invalid delta");
  1239. err.data = {
  1240. path: _self.$path,
  1241. linesLength: doc.$lines.length,
  1242. start: d.start,
  1243. end: d.end
  1244. };
  1245. throw err;
  1246. }
  1247. doc.applyDelta(d, true);
  1248. }
  1249. }
  1250. if (_self.$timeout)
  1251. return deferredUpdate.schedule(_self.$timeout);
  1252. _self.onUpdate();
  1253. });
  1254. };
  1255. (function() {
  1256. this.$timeout = 500;
  1257. this.setTimeout = function(timeout) {
  1258. this.$timeout = timeout;
  1259. };
  1260. this.setValue = function(value) {
  1261. this.doc.setValue(value);
  1262. this.deferredUpdate.schedule(this.$timeout);
  1263. };
  1264. this.getValue = function(callbackId) {
  1265. this.sender.callback(this.doc.getValue(), callbackId);
  1266. };
  1267. this.onUpdate = function() {
  1268. };
  1269. this.isPending = function() {
  1270. return this.deferredUpdate.isPending();
  1271. };
  1272. }).call(Mirror.prototype);
  1273. });
  1274. ace.define("ace/mode/css/csslint",[], function(require, exports, module) {
  1275. var CSSLint = (function(){
  1276. var module = module || {},
  1277. exports = exports || {};
  1278. var parserlib = (function () {
  1279. var require;
  1280. require=(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  1281. "use strict";
  1282. var Colors = module.exports = {
  1283. __proto__ : null,
  1284. aliceblue : "#f0f8ff",
  1285. antiquewhite : "#faebd7",
  1286. aqua : "#00ffff",
  1287. aquamarine : "#7fffd4",
  1288. azure : "#f0ffff",
  1289. beige : "#f5f5dc",
  1290. bisque : "#ffe4c4",
  1291. black : "#000000",
  1292. blanchedalmond : "#ffebcd",
  1293. blue : "#0000ff",
  1294. blueviolet : "#8a2be2",
  1295. brown : "#a52a2a",
  1296. burlywood : "#deb887",
  1297. cadetblue : "#5f9ea0",
  1298. chartreuse : "#7fff00",
  1299. chocolate : "#d2691e",
  1300. coral : "#ff7f50",
  1301. cornflowerblue : "#6495ed",
  1302. cornsilk : "#fff8dc",
  1303. crimson : "#dc143c",
  1304. cyan : "#00ffff",
  1305. darkblue : "#00008b",
  1306. darkcyan : "#008b8b",
  1307. darkgoldenrod : "#b8860b",
  1308. darkgray : "#a9a9a9",
  1309. darkgreen : "#006400",
  1310. darkgrey : "#a9a9a9",
  1311. darkkhaki : "#bdb76b",
  1312. darkmagenta : "#8b008b",
  1313. darkolivegreen : "#556b2f",
  1314. darkorange : "#ff8c00",
  1315. darkorchid : "#9932cc",
  1316. darkred : "#8b0000",
  1317. darksalmon : "#e9967a",
  1318. darkseagreen : "#8fbc8f",
  1319. darkslateblue : "#483d8b",
  1320. darkslategray : "#2f4f4f",
  1321. darkslategrey : "#2f4f4f",
  1322. darkturquoise : "#00ced1",
  1323. darkviolet : "#9400d3",
  1324. deeppink : "#ff1493",
  1325. deepskyblue : "#00bfff",
  1326. dimgray : "#696969",
  1327. dimgrey : "#696969",
  1328. dodgerblue : "#1e90ff",
  1329. firebrick : "#b22222",
  1330. floralwhite : "#fffaf0",
  1331. forestgreen : "#228b22",
  1332. fuchsia : "#ff00ff",
  1333. gainsboro : "#dcdcdc",
  1334. ghostwhite : "#f8f8ff",
  1335. gold : "#ffd700",
  1336. goldenrod : "#daa520",
  1337. gray : "#808080",
  1338. green : "#008000",
  1339. greenyellow : "#adff2f",
  1340. grey : "#808080",
  1341. honeydew : "#f0fff0",
  1342. hotpink : "#ff69b4",
  1343. indianred : "#cd5c5c",
  1344. indigo : "#4b0082",
  1345. ivory : "#fffff0",
  1346. khaki : "#f0e68c",
  1347. lavender : "#e6e6fa",
  1348. lavenderblush : "#fff0f5",
  1349. lawngreen : "#7cfc00",
  1350. lemonchiffon : "#fffacd",
  1351. lightblue : "#add8e6",
  1352. lightcoral : "#f08080",
  1353. lightcyan : "#e0ffff",
  1354. lightgoldenrodyellow : "#fafad2",
  1355. lightgray : "#d3d3d3",
  1356. lightgreen : "#90ee90",
  1357. lightgrey : "#d3d3d3",
  1358. lightpink : "#ffb6c1",
  1359. lightsalmon : "#ffa07a",
  1360. lightseagreen : "#20b2aa",
  1361. lightskyblue : "#87cefa",
  1362. lightslategray : "#778899",
  1363. lightslategrey : "#778899",
  1364. lightsteelblue : "#b0c4de",
  1365. lightyellow : "#ffffe0",
  1366. lime : "#00ff00",
  1367. limegreen : "#32cd32",
  1368. linen : "#faf0e6",
  1369. magenta : "#ff00ff",
  1370. maroon : "#800000",
  1371. mediumaquamarine : "#66cdaa",
  1372. mediumblue : "#0000cd",
  1373. mediumorchid : "#ba55d3",
  1374. mediumpurple : "#9370db",
  1375. mediumseagreen : "#3cb371",
  1376. mediumslateblue : "#7b68ee",
  1377. mediumspringgreen : "#00fa9a",
  1378. mediumturquoise : "#48d1cc",
  1379. mediumvioletred : "#c71585",
  1380. midnightblue : "#191970",
  1381. mintcream : "#f5fffa",
  1382. mistyrose : "#ffe4e1",
  1383. moccasin : "#ffe4b5",
  1384. navajowhite : "#ffdead",
  1385. navy : "#000080",
  1386. oldlace : "#fdf5e6",
  1387. olive : "#808000",
  1388. olivedrab : "#6b8e23",
  1389. orange : "#ffa500",
  1390. orangered : "#ff4500",
  1391. orchid : "#da70d6",
  1392. palegoldenrod : "#eee8aa",
  1393. palegreen : "#98fb98",
  1394. paleturquoise : "#afeeee",
  1395. palevioletred : "#db7093",
  1396. papayawhip : "#ffefd5",
  1397. peachpuff : "#ffdab9",
  1398. peru : "#cd853f",
  1399. pink : "#ffc0cb",
  1400. plum : "#dda0dd",
  1401. powderblue : "#b0e0e6",
  1402. purple : "#800080",
  1403. rebeccapurple : "#663399",
  1404. red : "#ff0000",
  1405. rosybrown : "#bc8f8f",
  1406. royalblue : "#4169e1",
  1407. saddlebrown : "#8b4513",
  1408. salmon : "#fa8072",
  1409. sandybrown : "#f4a460",
  1410. seagreen : "#2e8b57",
  1411. seashell : "#fff5ee",
  1412. sienna : "#a0522d",
  1413. silver : "#c0c0c0",
  1414. skyblue : "#87ceeb",
  1415. slateblue : "#6a5acd",
  1416. slategray : "#708090",
  1417. slategrey : "#708090",
  1418. snow : "#fffafa",
  1419. springgreen : "#00ff7f",
  1420. steelblue : "#4682b4",
  1421. tan : "#d2b48c",
  1422. teal : "#008080",
  1423. thistle : "#d8bfd8",
  1424. tomato : "#ff6347",
  1425. turquoise : "#40e0d0",
  1426. violet : "#ee82ee",
  1427. wheat : "#f5deb3",
  1428. white : "#ffffff",
  1429. whitesmoke : "#f5f5f5",
  1430. yellow : "#ffff00",
  1431. yellowgreen : "#9acd32",
  1432. currentColor : "The value of the 'color' property.",
  1433. activeborder : "Active window border.",
  1434. activecaption : "Active window caption.",
  1435. appworkspace : "Background color of multiple document interface.",
  1436. background : "Desktop background.",
  1437. buttonface : "The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1438. buttonhighlight : "The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1439. buttonshadow : "The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
  1440. buttontext : "Text on push buttons.",
  1441. captiontext : "Text in caption, size box, and scrollbar arrow box.",
  1442. graytext : "Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
  1443. greytext : "Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
  1444. highlight : "Item(s) selected in a control.",
  1445. highlighttext : "Text of item(s) selected in a control.",
  1446. inactiveborder : "Inactive window border.",
  1447. inactivecaption : "Inactive window caption.",
  1448. inactivecaptiontext : "Color of text in an inactive caption.",
  1449. infobackground : "Background color for tooltip controls.",
  1450. infotext : "Text color for tooltip controls.",
  1451. menu : "Menu background.",
  1452. menutext : "Text in menus.",
  1453. scrollbar : "Scroll bar gray area.",
  1454. threeddarkshadow : "The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1455. threedface : "The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1456. threedhighlight : "The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1457. threedlightshadow : "The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1458. threedshadow : "The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
  1459. window : "Window background.",
  1460. windowframe : "Window frame.",
  1461. windowtext : "Text in windows."
  1462. };
  1463. },{}],2:[function(require,module,exports){
  1464. "use strict";
  1465. module.exports = Combinator;
  1466. var SyntaxUnit = require("../util/SyntaxUnit");
  1467. var Parser = require("./Parser");
  1468. function Combinator(text, line, col) {
  1469. SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
  1470. this.type = "unknown";
  1471. if (/^\s+$/.test(text)) {
  1472. this.type = "descendant";
  1473. } else if (text === ">") {
  1474. this.type = "child";
  1475. } else if (text === "+") {
  1476. this.type = "adjacent-sibling";
  1477. } else if (text === "~") {
  1478. this.type = "sibling";
  1479. }
  1480. }
  1481. Combinator.prototype = new SyntaxUnit();
  1482. Combinator.prototype.constructor = Combinator;
  1483. },{"../util/SyntaxUnit":26,"./Parser":6}],3:[function(require,module,exports){
  1484. "use strict";
  1485. module.exports = Matcher;
  1486. var StringReader = require("../util/StringReader");
  1487. var SyntaxError = require("../util/SyntaxError");
  1488. function Matcher(matchFunc, toString) {
  1489. this.match = function(expression) {
  1490. var result;
  1491. expression.mark();
  1492. result = matchFunc(expression);
  1493. if (result) {
  1494. expression.drop();
  1495. } else {
  1496. expression.restore();
  1497. }
  1498. return result;
  1499. };
  1500. this.toString = typeof toString === "function" ? toString : function() {
  1501. return toString;
  1502. };
  1503. }
  1504. Matcher.prec = {
  1505. MOD: 5,
  1506. SEQ: 4,
  1507. ANDAND: 3,
  1508. OROR: 2,
  1509. ALT: 1
  1510. };
  1511. Matcher.parse = function(str) {
  1512. var reader, eat, expr, oror, andand, seq, mod, term, result;
  1513. reader = new StringReader(str);
  1514. eat = function(matcher) {
  1515. var result = reader.readMatch(matcher);
  1516. if (result === null) {
  1517. throw new SyntaxError(
  1518. "Expected " + matcher, reader.getLine(), reader.getCol());
  1519. }
  1520. return result;
  1521. };
  1522. expr = function() {
  1523. var m = [ oror() ];
  1524. while (reader.readMatch(" | ") !== null) {
  1525. m.push(oror());
  1526. }
  1527. return m.length === 1 ? m[0] : Matcher.alt.apply(Matcher, m);
  1528. };
  1529. oror = function() {
  1530. var m = [ andand() ];
  1531. while (reader.readMatch(" || ") !== null) {
  1532. m.push(andand());
  1533. }
  1534. return m.length === 1 ? m[0] : Matcher.oror.apply(Matcher, m);
  1535. };
  1536. andand = function() {
  1537. var m = [ seq() ];
  1538. while (reader.readMatch(" && ") !== null) {
  1539. m.push(seq());
  1540. }
  1541. return m.length === 1 ? m[0] : Matcher.andand.apply(Matcher, m);
  1542. };
  1543. seq = function() {
  1544. var m = [ mod() ];
  1545. while (reader.readMatch(/^ (?![&|\]])/) !== null) {
  1546. m.push(mod());
  1547. }
  1548. return m.length === 1 ? m[0] : Matcher.seq.apply(Matcher, m);
  1549. };
  1550. mod = function() {
  1551. var m = term();
  1552. if (reader.readMatch("?") !== null) {
  1553. return m.question();
  1554. } else if (reader.readMatch("*") !== null) {
  1555. return m.star();
  1556. } else if (reader.readMatch("+") !== null) {
  1557. return m.plus();
  1558. } else if (reader.readMatch("#") !== null) {
  1559. return m.hash();
  1560. } else if (reader.readMatch(/^\{\s*/) !== null) {
  1561. var min = eat(/^\d+/);
  1562. eat(/^\s*,\s*/);
  1563. var max = eat(/^\d+/);
  1564. eat(/^\s*\}/);
  1565. return m.braces(Number(min), Number(max));
  1566. }
  1567. return m;
  1568. };
  1569. term = function() {
  1570. if (reader.readMatch("[ ") !== null) {
  1571. var m = expr();
  1572. eat(" ]");
  1573. return m;
  1574. }
  1575. return Matcher.fromType(eat(/^[^ ?*+#{]+/));
  1576. };
  1577. result = expr();
  1578. if (!reader.eof()) {
  1579. throw new SyntaxError(
  1580. "Expected end of string", reader.getLine(), reader.getCol());
  1581. }
  1582. return result;
  1583. };
  1584. Matcher.cast = function(m) {
  1585. if (m instanceof Matcher) {
  1586. return m;
  1587. }
  1588. return Matcher.parse(m);
  1589. };
  1590. Matcher.fromType = function(type) {
  1591. var ValidationTypes = require("./ValidationTypes");
  1592. return new Matcher(function(expression) {
  1593. return expression.hasNext() && ValidationTypes.isType(expression, type);
  1594. }, type);
  1595. };
  1596. Matcher.seq = function() {
  1597. var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
  1598. if (ms.length === 1) {
  1599. return ms[0];
  1600. }
  1601. return new Matcher(function(expression) {
  1602. var i, result = true;
  1603. for (i = 0; result && i < ms.length; i++) {
  1604. result = ms[i].match(expression);
  1605. }
  1606. return result;
  1607. }, function(prec) {
  1608. var p = Matcher.prec.SEQ;
  1609. var s = ms.map(function(m) {
  1610. return m.toString(p);
  1611. }).join(" ");
  1612. if (prec > p) {
  1613. s = "[ " + s + " ]";
  1614. }
  1615. return s;
  1616. });
  1617. };
  1618. Matcher.alt = function() {
  1619. var ms = Array.prototype.slice.call(arguments).map(Matcher.cast);
  1620. if (ms.length === 1) {
  1621. return ms[0];
  1622. }
  1623. return new Matcher(function(expression) {
  1624. var i, result = false;
  1625. for (i = 0; !result && i < ms.length; i++) {
  1626. result = ms[i].match(expression);
  1627. }
  1628. return result;
  1629. }, function(prec) {
  1630. var p = Matcher.prec.ALT;
  1631. var s = ms.map(function(m) {
  1632. return m.toString(p);
  1633. }).join(" | ");
  1634. if (prec > p) {
  1635. s = "[ " + s + " ]";
  1636. }
  1637. return s;
  1638. });
  1639. };
  1640. Matcher.many = function(required) {
  1641. var ms = Array.prototype.slice.call(arguments, 1).reduce(function(acc, v) {
  1642. if (v.expand) {
  1643. var ValidationTypes = require("./ValidationTypes");
  1644. acc.push.apply(acc, ValidationTypes.complex[v.expand].options);
  1645. } else {
  1646. acc.push(Matcher.cast(v));
  1647. }
  1648. return acc;
  1649. }, []);
  1650. if (required === true) {
  1651. required = ms.map(function() {
  1652. return true;
  1653. });
  1654. }
  1655. var result = new Matcher(function(expression) {
  1656. var seen = [], max = 0, pass = 0;
  1657. var success = function(matchCount) {
  1658. if (pass === 0) {
  1659. max = Math.max(matchCount, max);
  1660. return matchCount === ms.length;
  1661. } else {
  1662. return matchCount === max;
  1663. }
  1664. };
  1665. var tryMatch = function(matchCount) {
  1666. for (var i = 0; i < ms.length; i++) {
  1667. if (seen[i]) {
  1668. continue;
  1669. }
  1670. expression.mark();
  1671. if (ms[i].match(expression)) {
  1672. seen[i] = true;
  1673. if (tryMatch(matchCount + (required === false || required[i] ? 1 : 0))) {
  1674. expression.drop();
  1675. return true;
  1676. }
  1677. expression.restore();
  1678. seen[i] = false;
  1679. } else {
  1680. expression.drop();
  1681. }
  1682. }
  1683. return success(matchCount);
  1684. };
  1685. if (!tryMatch(0)) {
  1686. pass++;
  1687. tryMatch(0);
  1688. }
  1689. if (required === false) {
  1690. return max > 0;
  1691. }
  1692. for (var i = 0; i < ms.length; i++) {
  1693. if (required[i] && !seen[i]) {
  1694. return false;
  1695. }
  1696. }
  1697. return true;
  1698. }, function(prec) {
  1699. var p = required === false ? Matcher.prec.OROR : Matcher.prec.ANDAND;
  1700. var s = ms.map(function(m, i) {
  1701. if (required !== false && !required[i]) {
  1702. return m.toString(Matcher.prec.MOD) + "?";
  1703. }
  1704. return m.toString(p);
  1705. }).join(required === false ? " || " : " && ");
  1706. if (prec > p) {
  1707. s = "[ " + s + " ]";
  1708. }
  1709. return s;
  1710. });
  1711. result.options = ms;
  1712. return result;
  1713. };
  1714. Matcher.andand = function() {
  1715. var args = Array.prototype.slice.call(arguments);
  1716. args.unshift(true);
  1717. return Matcher.many.apply(Matcher, args);
  1718. };
  1719. Matcher.oror = function() {
  1720. var args = Array.prototype.slice.call(arguments);
  1721. args.unshift(false);
  1722. return Matcher.many.apply(Matcher, args);
  1723. };
  1724. Matcher.prototype = {
  1725. constructor: Matcher,
  1726. match: function() {
  1727. throw new Error("unimplemented");
  1728. },
  1729. toString: function() {
  1730. throw new Error("unimplemented");
  1731. },
  1732. func: function() {
  1733. return this.match.bind(this);
  1734. },
  1735. then: function(m) {
  1736. return Matcher.seq(this, m);
  1737. },
  1738. or: function(m) {
  1739. return Matcher.alt(this, m);
  1740. },
  1741. andand: function(m) {
  1742. return Matcher.many(true, this, m);
  1743. },
  1744. oror: function(m) {
  1745. return Matcher.many(false, this, m);
  1746. },
  1747. star: function() {
  1748. return this.braces(0, Infinity, "*");
  1749. },
  1750. plus: function() {
  1751. return this.braces(1, Infinity, "+");
  1752. },
  1753. question: function() {
  1754. return this.braces(0, 1, "?");
  1755. },
  1756. hash: function() {
  1757. return this.braces(1, Infinity, "#", Matcher.cast(","));
  1758. },
  1759. braces: function(min, max, marker, optSep) {
  1760. var m1 = this, m2 = optSep ? optSep.then(this) : this;
  1761. if (!marker) {
  1762. marker = "{" + min + "," + max + "}";
  1763. }
  1764. return new Matcher(function(expression) {
  1765. var result = true, i;
  1766. for (i = 0; i < max; i++) {
  1767. if (i > 0 && optSep) {
  1768. result = m2.match(expression);
  1769. } else {
  1770. result = m1.match(expression);
  1771. }
  1772. if (!result) {
  1773. break;
  1774. }
  1775. }
  1776. return i >= min;
  1777. }, function() {
  1778. return m1.toString(Matcher.prec.MOD) + marker;
  1779. });
  1780. }
  1781. };
  1782. },{"../util/StringReader":24,"../util/SyntaxError":25,"./ValidationTypes":21}],4:[function(require,module,exports){
  1783. "use strict";
  1784. module.exports = MediaFeature;
  1785. var SyntaxUnit = require("../util/SyntaxUnit");
  1786. var Parser = require("./Parser");
  1787. function MediaFeature(name, value) {
  1788. SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
  1789. this.name = name;
  1790. this.value = value;
  1791. }
  1792. MediaFeature.prototype = new SyntaxUnit();
  1793. MediaFeature.prototype.constructor = MediaFeature;
  1794. },{"../util/SyntaxUnit":26,"./Parser":6}],5:[function(require,module,exports){
  1795. "use strict";
  1796. module.exports = MediaQuery;
  1797. var SyntaxUnit = require("../util/SyntaxUnit");
  1798. var Parser = require("./Parser");
  1799. function MediaQuery(modifier, mediaType, features, line, col) {
  1800. SyntaxUnit.call(this, (modifier ? modifier + " " : "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
  1801. this.modifier = modifier;
  1802. this.mediaType = mediaType;
  1803. this.features = features;
  1804. }
  1805. MediaQuery.prototype = new SyntaxUnit();
  1806. MediaQuery.prototype.constructor = MediaQuery;
  1807. },{"../util/SyntaxUnit":26,"./Parser":6}],6:[function(require,module,exports){
  1808. "use strict";
  1809. module.exports = Parser;
  1810. var EventTarget = require("../util/EventTarget");
  1811. var SyntaxError = require("../util/SyntaxError");
  1812. var SyntaxUnit = require("../util/SyntaxUnit");
  1813. var Combinator = require("./Combinator");
  1814. var MediaFeature = require("./MediaFeature");
  1815. var MediaQuery = require("./MediaQuery");
  1816. var PropertyName = require("./PropertyName");
  1817. var PropertyValue = require("./PropertyValue");
  1818. var PropertyValuePart = require("./PropertyValuePart");
  1819. var Selector = require("./Selector");
  1820. var SelectorPart = require("./SelectorPart");
  1821. var SelectorSubPart = require("./SelectorSubPart");
  1822. var TokenStream = require("./TokenStream");
  1823. var Tokens = require("./Tokens");
  1824. var Validation = require("./Validation");
  1825. function Parser(options) {
  1826. EventTarget.call(this);
  1827. this.options = options || {};
  1828. this._tokenStream = null;
  1829. }
  1830. Parser.DEFAULT_TYPE = 0;
  1831. Parser.COMBINATOR_TYPE = 1;
  1832. Parser.MEDIA_FEATURE_TYPE = 2;
  1833. Parser.MEDIA_QUERY_TYPE = 3;
  1834. Parser.PROPERTY_NAME_TYPE = 4;
  1835. Parser.PROPERTY_VALUE_TYPE = 5;
  1836. Parser.PROPERTY_VALUE_PART_TYPE = 6;
  1837. Parser.SELECTOR_TYPE = 7;
  1838. Parser.SELECTOR_PART_TYPE = 8;
  1839. Parser.SELECTOR_SUB_PART_TYPE = 9;
  1840. Parser.prototype = function() {
  1841. var proto = new EventTarget(), // new prototype
  1842. prop,
  1843. additions = {
  1844. __proto__: null,
  1845. constructor: Parser,
  1846. DEFAULT_TYPE : 0,
  1847. COMBINATOR_TYPE : 1,
  1848. MEDIA_FEATURE_TYPE : 2,
  1849. MEDIA_QUERY_TYPE : 3,
  1850. PROPERTY_NAME_TYPE : 4,
  1851. PROPERTY_VALUE_TYPE : 5,
  1852. PROPERTY_VALUE_PART_TYPE : 6,
  1853. SELECTOR_TYPE : 7,
  1854. SELECTOR_PART_TYPE : 8,
  1855. SELECTOR_SUB_PART_TYPE : 9,
  1856. _stylesheet: function() {
  1857. var tokenStream = this._tokenStream,
  1858. count,
  1859. token,
  1860. tt;
  1861. this.fire("startstylesheet");
  1862. this._charset();
  1863. this._skipCruft();
  1864. while (tokenStream.peek() === Tokens.IMPORT_SYM) {
  1865. this._import();
  1866. this._skipCruft();
  1867. }
  1868. while (tokenStream.peek() === Tokens.NAMESPACE_SYM) {
  1869. this._namespace();
  1870. this._skipCruft();
  1871. }
  1872. tt = tokenStream.peek();
  1873. while (tt > Tokens.EOF) {
  1874. try {
  1875. switch (tt) {
  1876. case Tokens.MEDIA_SYM:
  1877. this._media();
  1878. this._skipCruft();
  1879. break;
  1880. case Tokens.PAGE_SYM:
  1881. this._page();
  1882. this._skipCruft();
  1883. break;
  1884. case Tokens.FONT_FACE_SYM:
  1885. this._font_face();
  1886. this._skipCruft();
  1887. break;
  1888. case Tokens.KEYFRAMES_SYM:
  1889. this._keyframes();
  1890. this._skipCruft();
  1891. break;
  1892. case Tokens.VIEWPORT_SYM:
  1893. this._viewport();
  1894. this._skipCruft();
  1895. break;
  1896. case Tokens.DOCUMENT_SYM:
  1897. this._document();
  1898. this._skipCruft();
  1899. break;
  1900. case Tokens.SUPPORTS_SYM:
  1901. this._supports();
  1902. this._skipCruft();
  1903. break;
  1904. case Tokens.UNKNOWN_SYM: // unknown @ rule
  1905. tokenStream.get();
  1906. if (!this.options.strict) {
  1907. this.fire({
  1908. type: "error",
  1909. error: null,
  1910. message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
  1911. line: tokenStream.LT(0).startLine,
  1912. col: tokenStream.LT(0).startCol
  1913. });
  1914. count = 0;
  1915. while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) {
  1916. count++; // keep track of nesting depth
  1917. }
  1918. while (count) {
  1919. tokenStream.advance([Tokens.RBRACE]);
  1920. count--;
  1921. }
  1922. } else {
  1923. throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
  1924. }
  1925. break;
  1926. case Tokens.S:
  1927. this._readWhitespace();
  1928. break;
  1929. default:
  1930. if (!this._ruleset()) {
  1931. switch (tt) {
  1932. case Tokens.CHARSET_SYM:
  1933. token = tokenStream.LT(1);
  1934. this._charset(false);
  1935. throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol);
  1936. case Tokens.IMPORT_SYM:
  1937. token = tokenStream.LT(1);
  1938. this._import(false);
  1939. throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol);
  1940. case Tokens.NAMESPACE_SYM:
  1941. token = tokenStream.LT(1);
  1942. this._namespace(false);
  1943. throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol);
  1944. default:
  1945. tokenStream.get(); // get the last token
  1946. this._unexpectedToken(tokenStream.token());
  1947. }
  1948. }
  1949. }
  1950. } catch (ex) {
  1951. if (ex instanceof SyntaxError && !this.options.strict) {
  1952. this.fire({
  1953. type: "error",
  1954. error: ex,
  1955. message: ex.message,
  1956. line: ex.line,
  1957. col: ex.col
  1958. });
  1959. } else {
  1960. throw ex;
  1961. }
  1962. }
  1963. tt = tokenStream.peek();
  1964. }
  1965. if (tt !== Tokens.EOF) {
  1966. this._unexpectedToken(tokenStream.token());
  1967. }
  1968. this.fire("endstylesheet");
  1969. },
  1970. _charset: function(emit) {
  1971. var tokenStream = this._tokenStream,
  1972. charset,
  1973. token,
  1974. line,
  1975. col;
  1976. if (tokenStream.match(Tokens.CHARSET_SYM)) {
  1977. line = tokenStream.token().startLine;
  1978. col = tokenStream.token().startCol;
  1979. this._readWhitespace();
  1980. tokenStream.mustMatch(Tokens.STRING);
  1981. token = tokenStream.token();
  1982. charset = token.value;
  1983. this._readWhitespace();
  1984. tokenStream.mustMatch(Tokens.SEMICOLON);
  1985. if (emit !== false) {
  1986. this.fire({
  1987. type: "charset",
  1988. charset:charset,
  1989. line: line,
  1990. col: col
  1991. });
  1992. }
  1993. }
  1994. },
  1995. _import: function(emit) {
  1996. var tokenStream = this._tokenStream,
  1997. uri,
  1998. importToken,
  1999. mediaList = [];
  2000. tokenStream.mustMatch(Tokens.IMPORT_SYM);
  2001. importToken = tokenStream.token();
  2002. this._readWhitespace();
  2003. tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
  2004. uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
  2005. this._readWhitespace();
  2006. mediaList = this._media_query_list();
  2007. tokenStream.mustMatch(Tokens.SEMICOLON);
  2008. this._readWhitespace();
  2009. if (emit !== false) {
  2010. this.fire({
  2011. type: "import",
  2012. uri: uri,
  2013. media: mediaList,
  2014. line: importToken.startLine,
  2015. col: importToken.startCol
  2016. });
  2017. }
  2018. },
  2019. _namespace: function(emit) {
  2020. var tokenStream = this._tokenStream,
  2021. line,
  2022. col,
  2023. prefix,
  2024. uri;
  2025. tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
  2026. line = tokenStream.token().startLine;
  2027. col = tokenStream.token().startCol;
  2028. this._readWhitespace();
  2029. if (tokenStream.match(Tokens.IDENT)) {
  2030. prefix = tokenStream.token().value;
  2031. this._readWhitespace();
  2032. }
  2033. tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
  2034. uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
  2035. this._readWhitespace();
  2036. tokenStream.mustMatch(Tokens.SEMICOLON);
  2037. this._readWhitespace();
  2038. if (emit !== false) {
  2039. this.fire({
  2040. type: "namespace",
  2041. prefix: prefix,
  2042. uri: uri,
  2043. line: line,
  2044. col: col
  2045. });
  2046. }
  2047. },
  2048. _supports: function(emit) {
  2049. var tokenStream = this._tokenStream,
  2050. line,
  2051. col;
  2052. if (tokenStream.match(Tokens.SUPPORTS_SYM)) {
  2053. line = tokenStream.token().startLine;
  2054. col = tokenStream.token().startCol;
  2055. this._readWhitespace();
  2056. this._supports_condition();
  2057. this._readWhitespace();
  2058. tokenStream.mustMatch(Tokens.LBRACE);
  2059. this._readWhitespace();
  2060. if (emit !== false) {
  2061. this.fire({
  2062. type: "startsupports",
  2063. line: line,
  2064. col: col
  2065. });
  2066. }
  2067. while (true) {
  2068. if (!this._ruleset()) {
  2069. break;
  2070. }
  2071. }
  2072. tokenStream.mustMatch(Tokens.RBRACE);
  2073. this._readWhitespace();
  2074. this.fire({
  2075. type: "endsupports",
  2076. line: line,
  2077. col: col
  2078. });
  2079. }
  2080. },
  2081. _supports_condition: function() {
  2082. var tokenStream = this._tokenStream,
  2083. ident;
  2084. if (tokenStream.match(Tokens.IDENT)) {
  2085. ident = tokenStream.token().value.toLowerCase();
  2086. if (ident === "not") {
  2087. tokenStream.mustMatch(Tokens.S);
  2088. this._supports_condition_in_parens();
  2089. } else {
  2090. tokenStream.unget();
  2091. }
  2092. } else {
  2093. this._supports_condition_in_parens();
  2094. this._readWhitespace();
  2095. while (tokenStream.peek() === Tokens.IDENT) {
  2096. ident = tokenStream.LT(1).value.toLowerCase();
  2097. if (ident === "and" || ident === "or") {
  2098. tokenStream.mustMatch(Tokens.IDENT);
  2099. this._readWhitespace();
  2100. this._supports_condition_in_parens();
  2101. this._readWhitespace();
  2102. }
  2103. }
  2104. }
  2105. },
  2106. _supports_condition_in_parens: function() {
  2107. var tokenStream = this._tokenStream,
  2108. ident;
  2109. if (tokenStream.match(Tokens.LPAREN)) {
  2110. this._readWhitespace();
  2111. if (tokenStream.match(Tokens.IDENT)) {
  2112. ident = tokenStream.token().value.toLowerCase();
  2113. if (ident === "not") {
  2114. this._readWhitespace();
  2115. this._supports_condition();
  2116. this._readWhitespace();
  2117. tokenStream.mustMatch(Tokens.RPAREN);
  2118. } else {
  2119. tokenStream.unget();
  2120. this._supports_declaration_condition(false);
  2121. }
  2122. } else {
  2123. this._supports_condition();
  2124. this._readWhitespace();
  2125. tokenStream.mustMatch(Tokens.RPAREN);
  2126. }
  2127. } else {
  2128. this._supports_declaration_condition();
  2129. }
  2130. },
  2131. _supports_declaration_condition: function(requireStartParen) {
  2132. var tokenStream = this._tokenStream;
  2133. if (requireStartParen !== false) {
  2134. tokenStream.mustMatch(Tokens.LPAREN);
  2135. }
  2136. this._readWhitespace();
  2137. this._declaration();
  2138. tokenStream.mustMatch(Tokens.RPAREN);
  2139. },
  2140. _media: function() {
  2141. var tokenStream = this._tokenStream,
  2142. line,
  2143. col,
  2144. mediaList; // = [];
  2145. tokenStream.mustMatch(Tokens.MEDIA_SYM);
  2146. line = tokenStream.token().startLine;
  2147. col = tokenStream.token().startCol;
  2148. this._readWhitespace();
  2149. mediaList = this._media_query_list();
  2150. tokenStream.mustMatch(Tokens.LBRACE);
  2151. this._readWhitespace();
  2152. this.fire({
  2153. type: "startmedia",
  2154. media: mediaList,
  2155. line: line,
  2156. col: col
  2157. });
  2158. while (true) {
  2159. if (tokenStream.peek() === Tokens.PAGE_SYM) {
  2160. this._page();
  2161. } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) {
  2162. this._font_face();
  2163. } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) {
  2164. this._viewport();
  2165. } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM) {
  2166. this._document();
  2167. } else if (tokenStream.peek() === Tokens.SUPPORTS_SYM) {
  2168. this._supports();
  2169. } else if (tokenStream.peek() === Tokens.MEDIA_SYM) {
  2170. this._media();
  2171. } else if (!this._ruleset()) {
  2172. break;
  2173. }
  2174. }
  2175. tokenStream.mustMatch(Tokens.RBRACE);
  2176. this._readWhitespace();
  2177. this.fire({
  2178. type: "endmedia",
  2179. media: mediaList,
  2180. line: line,
  2181. col: col
  2182. });
  2183. },
  2184. _media_query_list: function() {
  2185. var tokenStream = this._tokenStream,
  2186. mediaList = [];
  2187. this._readWhitespace();
  2188. if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN) {
  2189. mediaList.push(this._media_query());
  2190. }
  2191. while (tokenStream.match(Tokens.COMMA)) {
  2192. this._readWhitespace();
  2193. mediaList.push(this._media_query());
  2194. }
  2195. return mediaList;
  2196. },
  2197. _media_query: function() {
  2198. var tokenStream = this._tokenStream,
  2199. type = null,
  2200. ident = null,
  2201. token = null,
  2202. expressions = [];
  2203. if (tokenStream.match(Tokens.IDENT)) {
  2204. ident = tokenStream.token().value.toLowerCase();
  2205. if (ident !== "only" && ident !== "not") {
  2206. tokenStream.unget();
  2207. ident = null;
  2208. } else {
  2209. token = tokenStream.token();
  2210. }
  2211. }
  2212. this._readWhitespace();
  2213. if (tokenStream.peek() === Tokens.IDENT) {
  2214. type = this._media_type();
  2215. if (token === null) {
  2216. token = tokenStream.token();
  2217. }
  2218. } else if (tokenStream.peek() === Tokens.LPAREN) {
  2219. if (token === null) {
  2220. token = tokenStream.LT(1);
  2221. }
  2222. expressions.push(this._media_expression());
  2223. }
  2224. if (type === null && expressions.length === 0) {
  2225. return null;
  2226. } else {
  2227. this._readWhitespace();
  2228. while (tokenStream.match(Tokens.IDENT)) {
  2229. if (tokenStream.token().value.toLowerCase() !== "and") {
  2230. this._unexpectedToken(tokenStream.token());
  2231. }
  2232. this._readWhitespace();
  2233. expressions.push(this._media_expression());
  2234. }
  2235. }
  2236. return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
  2237. },
  2238. _media_type: function() {
  2239. return this._media_feature();
  2240. },
  2241. _media_expression: function() {
  2242. var tokenStream = this._tokenStream,
  2243. feature = null,
  2244. token,
  2245. expression = null;
  2246. tokenStream.mustMatch(Tokens.LPAREN);
  2247. this._readWhitespace();
  2248. feature = this._media_feature();
  2249. this._readWhitespace();
  2250. if (tokenStream.match(Tokens.COLON)) {
  2251. this._readWhitespace();
  2252. token = tokenStream.LT(1);
  2253. expression = this._expression();
  2254. }
  2255. tokenStream.mustMatch(Tokens.RPAREN);
  2256. this._readWhitespace();
  2257. return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null);
  2258. },
  2259. _media_feature: function() {
  2260. var tokenStream = this._tokenStream;
  2261. this._readWhitespace();
  2262. tokenStream.mustMatch(Tokens.IDENT);
  2263. return SyntaxUnit.fromToken(tokenStream.token());
  2264. },
  2265. _page: function() {
  2266. var tokenStream = this._tokenStream,
  2267. line,
  2268. col,
  2269. identifier = null,
  2270. pseudoPage = null;
  2271. tokenStream.mustMatch(Tokens.PAGE_SYM);
  2272. line = tokenStream.token().startLine;
  2273. col = tokenStream.token().startCol;
  2274. this._readWhitespace();
  2275. if (tokenStream.match(Tokens.IDENT)) {
  2276. identifier = tokenStream.token().value;
  2277. if (identifier.toLowerCase() === "auto") {
  2278. this._unexpectedToken(tokenStream.token());
  2279. }
  2280. }
  2281. if (tokenStream.peek() === Tokens.COLON) {
  2282. pseudoPage = this._pseudo_page();
  2283. }
  2284. this._readWhitespace();
  2285. this.fire({
  2286. type: "startpage",
  2287. id: identifier,
  2288. pseudo: pseudoPage,
  2289. line: line,
  2290. col: col
  2291. });
  2292. this._readDeclarations(true, true);
  2293. this.fire({
  2294. type: "endpage",
  2295. id: identifier,
  2296. pseudo: pseudoPage,
  2297. line: line,
  2298. col: col
  2299. });
  2300. },
  2301. _margin: function() {
  2302. var tokenStream = this._tokenStream,
  2303. line,
  2304. col,
  2305. marginSym = this._margin_sym();
  2306. if (marginSym) {
  2307. line = tokenStream.token().startLine;
  2308. col = tokenStream.token().startCol;
  2309. this.fire({
  2310. type: "startpagemargin",
  2311. margin: marginSym,
  2312. line: line,
  2313. col: col
  2314. });
  2315. this._readDeclarations(true);
  2316. this.fire({
  2317. type: "endpagemargin",
  2318. margin: marginSym,
  2319. line: line,
  2320. col: col
  2321. });
  2322. return true;
  2323. } else {
  2324. return false;
  2325. }
  2326. },
  2327. _margin_sym: function() {
  2328. var tokenStream = this._tokenStream;
  2329. if (tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM,
  2330. Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM,
  2331. Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM,
  2332. Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM,
  2333. Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM,
  2334. Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM,
  2335. Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) {
  2336. return SyntaxUnit.fromToken(tokenStream.token());
  2337. } else {
  2338. return null;
  2339. }
  2340. },
  2341. _pseudo_page: function() {
  2342. var tokenStream = this._tokenStream;
  2343. tokenStream.mustMatch(Tokens.COLON);
  2344. tokenStream.mustMatch(Tokens.IDENT);
  2345. return tokenStream.token().value;
  2346. },
  2347. _font_face: function() {
  2348. var tokenStream = this._tokenStream,
  2349. line,
  2350. col;
  2351. tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
  2352. line = tokenStream.token().startLine;
  2353. col = tokenStream.token().startCol;
  2354. this._readWhitespace();
  2355. this.fire({
  2356. type: "startfontface",
  2357. line: line,
  2358. col: col
  2359. });
  2360. this._readDeclarations(true);
  2361. this.fire({
  2362. type: "endfontface",
  2363. line: line,
  2364. col: col
  2365. });
  2366. },
  2367. _viewport: function() {
  2368. var tokenStream = this._tokenStream,
  2369. line,
  2370. col;
  2371. tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
  2372. line = tokenStream.token().startLine;
  2373. col = tokenStream.token().startCol;
  2374. this._readWhitespace();
  2375. this.fire({
  2376. type: "startviewport",
  2377. line: line,
  2378. col: col
  2379. });
  2380. this._readDeclarations(true);
  2381. this.fire({
  2382. type: "endviewport",
  2383. line: line,
  2384. col: col
  2385. });
  2386. },
  2387. _document: function() {
  2388. var tokenStream = this._tokenStream,
  2389. token,
  2390. functions = [],
  2391. prefix = "";
  2392. tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
  2393. token = tokenStream.token();
  2394. if (/^@-([^-]+)-/.test(token.value)) {
  2395. prefix = RegExp.$1;
  2396. }
  2397. this._readWhitespace();
  2398. functions.push(this._document_function());
  2399. while (tokenStream.match(Tokens.COMMA)) {
  2400. this._readWhitespace();
  2401. functions.push(this._document_function());
  2402. }
  2403. tokenStream.mustMatch(Tokens.LBRACE);
  2404. this._readWhitespace();
  2405. this.fire({
  2406. type: "startdocument",
  2407. functions: functions,
  2408. prefix: prefix,
  2409. line: token.startLine,
  2410. col: token.startCol
  2411. });
  2412. var ok = true;
  2413. while (ok) {
  2414. switch (tokenStream.peek()) {
  2415. case Tokens.PAGE_SYM:
  2416. this._page();
  2417. break;
  2418. case Tokens.FONT_FACE_SYM:
  2419. this._font_face();
  2420. break;
  2421. case Tokens.VIEWPORT_SYM:
  2422. this._viewport();
  2423. break;
  2424. case Tokens.MEDIA_SYM:
  2425. this._media();
  2426. break;
  2427. case Tokens.KEYFRAMES_SYM:
  2428. this._keyframes();
  2429. break;
  2430. case Tokens.DOCUMENT_SYM:
  2431. this._document();
  2432. break;
  2433. default:
  2434. ok = Boolean(this._ruleset());
  2435. }
  2436. }
  2437. tokenStream.mustMatch(Tokens.RBRACE);
  2438. token = tokenStream.token();
  2439. this._readWhitespace();
  2440. this.fire({
  2441. type: "enddocument",
  2442. functions: functions,
  2443. prefix: prefix,
  2444. line: token.startLine,
  2445. col: token.startCol
  2446. });
  2447. },
  2448. _document_function: function() {
  2449. var tokenStream = this._tokenStream,
  2450. value;
  2451. if (tokenStream.match(Tokens.URI)) {
  2452. value = tokenStream.token().value;
  2453. this._readWhitespace();
  2454. } else {
  2455. value = this._function();
  2456. }
  2457. return value;
  2458. },
  2459. _operator: function(inFunction) {
  2460. var tokenStream = this._tokenStream,
  2461. token = null;
  2462. if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) ||
  2463. inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS])) {
  2464. token = tokenStream.token();
  2465. this._readWhitespace();
  2466. }
  2467. return token ? PropertyValuePart.fromToken(token) : null;
  2468. },
  2469. _combinator: function() {
  2470. var tokenStream = this._tokenStream,
  2471. value = null,
  2472. token;
  2473. if (tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) {
  2474. token = tokenStream.token();
  2475. value = new Combinator(token.value, token.startLine, token.startCol);
  2476. this._readWhitespace();
  2477. }
  2478. return value;
  2479. },
  2480. _unary_operator: function() {
  2481. var tokenStream = this._tokenStream;
  2482. if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])) {
  2483. return tokenStream.token().value;
  2484. } else {
  2485. return null;
  2486. }
  2487. },
  2488. _property: function() {
  2489. var tokenStream = this._tokenStream,
  2490. value = null,
  2491. hack = null,
  2492. propertyName = "",
  2493. token,
  2494. line,
  2495. col;
  2496. if (tokenStream.peek() === Tokens.STAR && this.options.starHack) {
  2497. tokenStream.get();
  2498. token = tokenStream.token();
  2499. hack = token.value;
  2500. line = token.startLine;
  2501. col = token.startCol;
  2502. }
  2503. if (tokenStream.peek() === Tokens.MINUS) {
  2504. tokenStream.get();
  2505. token = tokenStream.token();
  2506. propertyName = token.value;
  2507. line = token.startLine;
  2508. col = token.startCol;
  2509. }
  2510. if (tokenStream.match(Tokens.IDENT)) {
  2511. token = tokenStream.token();
  2512. propertyName += token.value;
  2513. if (propertyName.charAt(0) === "_" && this.options.underscoreHack) {
  2514. hack = "_";
  2515. propertyName = propertyName.substring(1);
  2516. }
  2517. value = new PropertyName(propertyName, hack, line || token.startLine, col || token.startCol);
  2518. this._readWhitespace();
  2519. } else {
  2520. var tt = tokenStream.peek();
  2521. if (tt !== Tokens.EOF && tt !== Tokens.RBRACE) {
  2522. this._unexpectedToken(tokenStream.LT(1));
  2523. }
  2524. }
  2525. return value;
  2526. },
  2527. _ruleset: function() {
  2528. var tokenStream = this._tokenStream,
  2529. tt,
  2530. selectors;
  2531. try {
  2532. selectors = this._selectors_group();
  2533. } catch (ex) {
  2534. if (ex instanceof SyntaxError && !this.options.strict) {
  2535. this.fire({
  2536. type: "error",
  2537. error: ex,
  2538. message: ex.message,
  2539. line: ex.line,
  2540. col: ex.col
  2541. });
  2542. tt = tokenStream.advance([Tokens.RBRACE]);
  2543. if (tt === Tokens.RBRACE) {
  2544. } else {
  2545. throw ex;
  2546. }
  2547. } else {
  2548. throw ex;
  2549. }
  2550. return true;
  2551. }
  2552. if (selectors) {
  2553. this.fire({
  2554. type: "startrule",
  2555. selectors: selectors,
  2556. line: selectors[0].line,
  2557. col: selectors[0].col
  2558. });
  2559. this._readDeclarations(true);
  2560. this.fire({
  2561. type: "endrule",
  2562. selectors: selectors,
  2563. line: selectors[0].line,
  2564. col: selectors[0].col
  2565. });
  2566. }
  2567. return selectors;
  2568. },
  2569. _selectors_group: function() {
  2570. var tokenStream = this._tokenStream,
  2571. selectors = [],
  2572. selector;
  2573. selector = this._selector();
  2574. if (selector !== null) {
  2575. selectors.push(selector);
  2576. while (tokenStream.match(Tokens.COMMA)) {
  2577. this._readWhitespace();
  2578. selector = this._selector();
  2579. if (selector !== null) {
  2580. selectors.push(selector);
  2581. } else {
  2582. this._unexpectedToken(tokenStream.LT(1));
  2583. }
  2584. }
  2585. }
  2586. return selectors.length ? selectors : null;
  2587. },
  2588. _selector: function() {
  2589. var tokenStream = this._tokenStream,
  2590. selector = [],
  2591. nextSelector = null,
  2592. combinator = null,
  2593. ws = null;
  2594. nextSelector = this._simple_selector_sequence();
  2595. if (nextSelector === null) {
  2596. return null;
  2597. }
  2598. selector.push(nextSelector);
  2599. do {
  2600. combinator = this._combinator();
  2601. if (combinator !== null) {
  2602. selector.push(combinator);
  2603. nextSelector = this._simple_selector_sequence();
  2604. if (nextSelector === null) {
  2605. this._unexpectedToken(tokenStream.LT(1));
  2606. } else {
  2607. selector.push(nextSelector);
  2608. }
  2609. } else {
  2610. if (this._readWhitespace()) {
  2611. ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
  2612. combinator = this._combinator();
  2613. nextSelector = this._simple_selector_sequence();
  2614. if (nextSelector === null) {
  2615. if (combinator !== null) {
  2616. this._unexpectedToken(tokenStream.LT(1));
  2617. }
  2618. } else {
  2619. if (combinator !== null) {
  2620. selector.push(combinator);
  2621. } else {
  2622. selector.push(ws);
  2623. }
  2624. selector.push(nextSelector);
  2625. }
  2626. } else {
  2627. break;
  2628. }
  2629. }
  2630. } while (true);
  2631. return new Selector(selector, selector[0].line, selector[0].col);
  2632. },
  2633. _simple_selector_sequence: function() {
  2634. var tokenStream = this._tokenStream,
  2635. elementName = null,
  2636. modifiers = [],
  2637. selectorText = "",
  2638. components = [
  2639. function() {
  2640. return tokenStream.match(Tokens.HASH) ?
  2641. new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
  2642. null;
  2643. },
  2644. this._class,
  2645. this._attrib,
  2646. this._pseudo,
  2647. this._negation
  2648. ],
  2649. i = 0,
  2650. len = components.length,
  2651. component = null,
  2652. line,
  2653. col;
  2654. line = tokenStream.LT(1).startLine;
  2655. col = tokenStream.LT(1).startCol;
  2656. elementName = this._type_selector();
  2657. if (!elementName) {
  2658. elementName = this._universal();
  2659. }
  2660. if (elementName !== null) {
  2661. selectorText += elementName;
  2662. }
  2663. while (true) {
  2664. if (tokenStream.peek() === Tokens.S) {
  2665. break;
  2666. }
  2667. while (i < len && component === null) {
  2668. component = components[i++].call(this);
  2669. }
  2670. if (component === null) {
  2671. if (selectorText === "") {
  2672. return null;
  2673. } else {
  2674. break;
  2675. }
  2676. } else {
  2677. i = 0;
  2678. modifiers.push(component);
  2679. selectorText += component.toString();
  2680. component = null;
  2681. }
  2682. }
  2683. return selectorText !== "" ?
  2684. new SelectorPart(elementName, modifiers, selectorText, line, col) :
  2685. null;
  2686. },
  2687. _type_selector: function() {
  2688. var tokenStream = this._tokenStream,
  2689. ns = this._namespace_prefix(),
  2690. elementName = this._element_name();
  2691. if (!elementName) {
  2692. if (ns) {
  2693. tokenStream.unget();
  2694. if (ns.length > 1) {
  2695. tokenStream.unget();
  2696. }
  2697. }
  2698. return null;
  2699. } else {
  2700. if (ns) {
  2701. elementName.text = ns + elementName.text;
  2702. elementName.col -= ns.length;
  2703. }
  2704. return elementName;
  2705. }
  2706. },
  2707. _class: function() {
  2708. var tokenStream = this._tokenStream,
  2709. token;
  2710. if (tokenStream.match(Tokens.DOT)) {
  2711. tokenStream.mustMatch(Tokens.IDENT);
  2712. token = tokenStream.token();
  2713. return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
  2714. } else {
  2715. return null;
  2716. }
  2717. },
  2718. _element_name: function() {
  2719. var tokenStream = this._tokenStream,
  2720. token;
  2721. if (tokenStream.match(Tokens.IDENT)) {
  2722. token = tokenStream.token();
  2723. return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
  2724. } else {
  2725. return null;
  2726. }
  2727. },
  2728. _namespace_prefix: function() {
  2729. var tokenStream = this._tokenStream,
  2730. value = "";
  2731. if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) {
  2732. if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) {
  2733. value += tokenStream.token().value;
  2734. }
  2735. tokenStream.mustMatch(Tokens.PIPE);
  2736. value += "|";
  2737. }
  2738. return value.length ? value : null;
  2739. },
  2740. _universal: function() {
  2741. var tokenStream = this._tokenStream,
  2742. value = "",
  2743. ns;
  2744. ns = this._namespace_prefix();
  2745. if (ns) {
  2746. value += ns;
  2747. }
  2748. if (tokenStream.match(Tokens.STAR)) {
  2749. value += "*";
  2750. }
  2751. return value.length ? value : null;
  2752. },
  2753. _attrib: function() {
  2754. var tokenStream = this._tokenStream,
  2755. value = null,
  2756. ns,
  2757. token;
  2758. if (tokenStream.match(Tokens.LBRACKET)) {
  2759. token = tokenStream.token();
  2760. value = token.value;
  2761. value += this._readWhitespace();
  2762. ns = this._namespace_prefix();
  2763. if (ns) {
  2764. value += ns;
  2765. }
  2766. tokenStream.mustMatch(Tokens.IDENT);
  2767. value += tokenStream.token().value;
  2768. value += this._readWhitespace();
  2769. if (tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH,
  2770. Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])) {
  2771. value += tokenStream.token().value;
  2772. value += this._readWhitespace();
  2773. tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
  2774. value += tokenStream.token().value;
  2775. value += this._readWhitespace();
  2776. }
  2777. tokenStream.mustMatch(Tokens.RBRACKET);
  2778. return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
  2779. } else {
  2780. return null;
  2781. }
  2782. },
  2783. _pseudo: function() {
  2784. var tokenStream = this._tokenStream,
  2785. pseudo = null,
  2786. colons = ":",
  2787. line,
  2788. col;
  2789. if (tokenStream.match(Tokens.COLON)) {
  2790. if (tokenStream.match(Tokens.COLON)) {
  2791. colons += ":";
  2792. }
  2793. if (tokenStream.match(Tokens.IDENT)) {
  2794. pseudo = tokenStream.token().value;
  2795. line = tokenStream.token().startLine;
  2796. col = tokenStream.token().startCol - colons.length;
  2797. } else if (tokenStream.peek() === Tokens.FUNCTION) {
  2798. line = tokenStream.LT(1).startLine;
  2799. col = tokenStream.LT(1).startCol - colons.length;
  2800. pseudo = this._functional_pseudo();
  2801. }
  2802. if (pseudo) {
  2803. pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
  2804. } else {
  2805. var startLine = tokenStream.LT(1).startLine,
  2806. startCol = tokenStream.LT(0).startCol;
  2807. throw new SyntaxError("Expected a `FUNCTION` or `IDENT` after colon at line " + startLine + ", col " + startCol + ".", startLine, startCol);
  2808. }
  2809. }
  2810. return pseudo;
  2811. },
  2812. _functional_pseudo: function() {
  2813. var tokenStream = this._tokenStream,
  2814. value = null;
  2815. if (tokenStream.match(Tokens.FUNCTION)) {
  2816. value = tokenStream.token().value;
  2817. value += this._readWhitespace();
  2818. value += this._expression();
  2819. tokenStream.mustMatch(Tokens.RPAREN);
  2820. value += ")";
  2821. }
  2822. return value;
  2823. },
  2824. _expression: function() {
  2825. var tokenStream = this._tokenStream,
  2826. value = "";
  2827. while (tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION,
  2828. Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH,
  2829. Tokens.FREQ, Tokens.ANGLE, Tokens.TIME,
  2830. Tokens.RESOLUTION, Tokens.SLASH])) {
  2831. value += tokenStream.token().value;
  2832. value += this._readWhitespace();
  2833. }
  2834. return value.length ? value : null;
  2835. },
  2836. _negation: function() {
  2837. var tokenStream = this._tokenStream,
  2838. line,
  2839. col,
  2840. value = "",
  2841. arg,
  2842. subpart = null;
  2843. if (tokenStream.match(Tokens.NOT)) {
  2844. value = tokenStream.token().value;
  2845. line = tokenStream.token().startLine;
  2846. col = tokenStream.token().startCol;
  2847. value += this._readWhitespace();
  2848. arg = this._negation_arg();
  2849. value += arg;
  2850. value += this._readWhitespace();
  2851. tokenStream.match(Tokens.RPAREN);
  2852. value += tokenStream.token().value;
  2853. subpart = new SelectorSubPart(value, "not", line, col);
  2854. subpart.args.push(arg);
  2855. }
  2856. return subpart;
  2857. },
  2858. _negation_arg: function() {
  2859. var tokenStream = this._tokenStream,
  2860. args = [
  2861. this._type_selector,
  2862. this._universal,
  2863. function() {
  2864. return tokenStream.match(Tokens.HASH) ?
  2865. new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) :
  2866. null;
  2867. },
  2868. this._class,
  2869. this._attrib,
  2870. this._pseudo
  2871. ],
  2872. arg = null,
  2873. i = 0,
  2874. len = args.length,
  2875. line,
  2876. col,
  2877. part;
  2878. line = tokenStream.LT(1).startLine;
  2879. col = tokenStream.LT(1).startCol;
  2880. while (i < len && arg === null) {
  2881. arg = args[i].call(this);
  2882. i++;
  2883. }
  2884. if (arg === null) {
  2885. this._unexpectedToken(tokenStream.LT(1));
  2886. }
  2887. if (arg.type === "elementName") {
  2888. part = new SelectorPart(arg, [], arg.toString(), line, col);
  2889. } else {
  2890. part = new SelectorPart(null, [arg], arg.toString(), line, col);
  2891. }
  2892. return part;
  2893. },
  2894. _declaration: function() {
  2895. var tokenStream = this._tokenStream,
  2896. property = null,
  2897. expr = null,
  2898. prio = null,
  2899. invalid = null,
  2900. propertyName = "";
  2901. property = this._property();
  2902. if (property !== null) {
  2903. tokenStream.mustMatch(Tokens.COLON);
  2904. this._readWhitespace();
  2905. expr = this._expr();
  2906. if (!expr || expr.length === 0) {
  2907. this._unexpectedToken(tokenStream.LT(1));
  2908. }
  2909. prio = this._prio();
  2910. propertyName = property.toString();
  2911. if (this.options.starHack && property.hack === "*" ||
  2912. this.options.underscoreHack && property.hack === "_") {
  2913. propertyName = property.text;
  2914. }
  2915. try {
  2916. this._validateProperty(propertyName, expr);
  2917. } catch (ex) {
  2918. invalid = ex;
  2919. }
  2920. this.fire({
  2921. type: "property",
  2922. property: property,
  2923. value: expr,
  2924. important: prio,
  2925. line: property.line,
  2926. col: property.col,
  2927. invalid: invalid
  2928. });
  2929. return true;
  2930. } else {
  2931. return false;
  2932. }
  2933. },
  2934. _prio: function() {
  2935. var tokenStream = this._tokenStream,
  2936. result = tokenStream.match(Tokens.IMPORTANT_SYM);
  2937. this._readWhitespace();
  2938. return result;
  2939. },
  2940. _expr: function(inFunction) {
  2941. var values = [],
  2942. value = null,
  2943. operator = null;
  2944. value = this._term(inFunction);
  2945. if (value !== null) {
  2946. values.push(value);
  2947. do {
  2948. operator = this._operator(inFunction);
  2949. if (operator) {
  2950. values.push(operator);
  2951. } /*else {
  2952. values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col));
  2953. valueParts = [];
  2954. }*/
  2955. value = this._term(inFunction);
  2956. if (value === null) {
  2957. break;
  2958. } else {
  2959. values.push(value);
  2960. }
  2961. } while (true);
  2962. }
  2963. return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
  2964. },
  2965. _term: function(inFunction) {
  2966. var tokenStream = this._tokenStream,
  2967. unary = null,
  2968. value = null,
  2969. endChar = null,
  2970. part = null,
  2971. token,
  2972. line,
  2973. col;
  2974. unary = this._unary_operator();
  2975. if (unary !== null) {
  2976. line = tokenStream.token().startLine;
  2977. col = tokenStream.token().startCol;
  2978. }
  2979. if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) {
  2980. value = this._ie_function();
  2981. if (unary === null) {
  2982. line = tokenStream.token().startLine;
  2983. col = tokenStream.token().startCol;
  2984. }
  2985. } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) {
  2986. token = tokenStream.token();
  2987. endChar = token.endChar;
  2988. value = token.value + this._expr(inFunction).text;
  2989. if (unary === null) {
  2990. line = tokenStream.token().startLine;
  2991. col = tokenStream.token().startCol;
  2992. }
  2993. tokenStream.mustMatch(Tokens.type(endChar));
  2994. value += endChar;
  2995. this._readWhitespace();
  2996. } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH,
  2997. Tokens.ANGLE, Tokens.TIME,
  2998. Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])) {
  2999. value = tokenStream.token().value;
  3000. if (unary === null) {
  3001. line = tokenStream.token().startLine;
  3002. col = tokenStream.token().startCol;
  3003. part = PropertyValuePart.fromToken(tokenStream.token());
  3004. }
  3005. this._readWhitespace();
  3006. } else {
  3007. token = this._hexcolor();
  3008. if (token === null) {
  3009. if (unary === null) {
  3010. line = tokenStream.LT(1).startLine;
  3011. col = tokenStream.LT(1).startCol;
  3012. }
  3013. if (value === null) {
  3014. if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters) {
  3015. value = this._ie_function();
  3016. } else {
  3017. value = this._function();
  3018. }
  3019. }
  3020. } else {
  3021. value = token.value;
  3022. if (unary === null) {
  3023. line = token.startLine;
  3024. col = token.startCol;
  3025. }
  3026. }
  3027. }
  3028. return part !== null ? part : value !== null ?
  3029. new PropertyValuePart(unary !== null ? unary + value : value, line, col) :
  3030. null;
  3031. },
  3032. _function: function() {
  3033. var tokenStream = this._tokenStream,
  3034. functionText = null,
  3035. expr = null,
  3036. lt;
  3037. if (tokenStream.match(Tokens.FUNCTION)) {
  3038. functionText = tokenStream.token().value;
  3039. this._readWhitespace();
  3040. expr = this._expr(true);
  3041. functionText += expr;
  3042. if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) {
  3043. do {
  3044. if (this._readWhitespace()) {
  3045. functionText += tokenStream.token().value;
  3046. }
  3047. if (tokenStream.LA(0) === Tokens.COMMA) {
  3048. functionText += tokenStream.token().value;
  3049. }
  3050. tokenStream.match(Tokens.IDENT);
  3051. functionText += tokenStream.token().value;
  3052. tokenStream.match(Tokens.EQUALS);
  3053. functionText += tokenStream.token().value;
  3054. lt = tokenStream.peek();
  3055. while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
  3056. tokenStream.get();
  3057. functionText += tokenStream.token().value;
  3058. lt = tokenStream.peek();
  3059. }
  3060. } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
  3061. }
  3062. tokenStream.match(Tokens.RPAREN);
  3063. functionText += ")";
  3064. this._readWhitespace();
  3065. }
  3066. return functionText;
  3067. },
  3068. _ie_function: function() {
  3069. var tokenStream = this._tokenStream,
  3070. functionText = null,
  3071. lt;
  3072. if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) {
  3073. functionText = tokenStream.token().value;
  3074. do {
  3075. if (this._readWhitespace()) {
  3076. functionText += tokenStream.token().value;
  3077. }
  3078. if (tokenStream.LA(0) === Tokens.COMMA) {
  3079. functionText += tokenStream.token().value;
  3080. }
  3081. tokenStream.match(Tokens.IDENT);
  3082. functionText += tokenStream.token().value;
  3083. tokenStream.match(Tokens.EQUALS);
  3084. functionText += tokenStream.token().value;
  3085. lt = tokenStream.peek();
  3086. while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
  3087. tokenStream.get();
  3088. functionText += tokenStream.token().value;
  3089. lt = tokenStream.peek();
  3090. }
  3091. } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
  3092. tokenStream.match(Tokens.RPAREN);
  3093. functionText += ")";
  3094. this._readWhitespace();
  3095. }
  3096. return functionText;
  3097. },
  3098. _hexcolor: function() {
  3099. var tokenStream = this._tokenStream,
  3100. token = null,
  3101. color;
  3102. if (tokenStream.match(Tokens.HASH)) {
  3103. token = tokenStream.token();
  3104. color = token.value;
  3105. if (!/#[a-f0-9]{3,6}/i.test(color)) {
  3106. throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  3107. }
  3108. this._readWhitespace();
  3109. }
  3110. return token;
  3111. },
  3112. _keyframes: function() {
  3113. var tokenStream = this._tokenStream,
  3114. token,
  3115. tt,
  3116. name,
  3117. prefix = "";
  3118. tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
  3119. token = tokenStream.token();
  3120. if (/^@-([^-]+)-/.test(token.value)) {
  3121. prefix = RegExp.$1;
  3122. }
  3123. this._readWhitespace();
  3124. name = this._keyframe_name();
  3125. this._readWhitespace();
  3126. tokenStream.mustMatch(Tokens.LBRACE);
  3127. this.fire({
  3128. type: "startkeyframes",
  3129. name: name,
  3130. prefix: prefix,
  3131. line: token.startLine,
  3132. col: token.startCol
  3133. });
  3134. this._readWhitespace();
  3135. tt = tokenStream.peek();
  3136. while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
  3137. this._keyframe_rule();
  3138. this._readWhitespace();
  3139. tt = tokenStream.peek();
  3140. }
  3141. this.fire({
  3142. type: "endkeyframes",
  3143. name: name,
  3144. prefix: prefix,
  3145. line: token.startLine,
  3146. col: token.startCol
  3147. });
  3148. this._readWhitespace();
  3149. tokenStream.mustMatch(Tokens.RBRACE);
  3150. this._readWhitespace();
  3151. },
  3152. _keyframe_name: function() {
  3153. var tokenStream = this._tokenStream;
  3154. tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
  3155. return SyntaxUnit.fromToken(tokenStream.token());
  3156. },
  3157. _keyframe_rule: function() {
  3158. var keyList = this._key_list();
  3159. this.fire({
  3160. type: "startkeyframerule",
  3161. keys: keyList,
  3162. line: keyList[0].line,
  3163. col: keyList[0].col
  3164. });
  3165. this._readDeclarations(true);
  3166. this.fire({
  3167. type: "endkeyframerule",
  3168. keys: keyList,
  3169. line: keyList[0].line,
  3170. col: keyList[0].col
  3171. });
  3172. },
  3173. _key_list: function() {
  3174. var tokenStream = this._tokenStream,
  3175. keyList = [];
  3176. keyList.push(this._key());
  3177. this._readWhitespace();
  3178. while (tokenStream.match(Tokens.COMMA)) {
  3179. this._readWhitespace();
  3180. keyList.push(this._key());
  3181. this._readWhitespace();
  3182. }
  3183. return keyList;
  3184. },
  3185. _key: function() {
  3186. var tokenStream = this._tokenStream,
  3187. token;
  3188. if (tokenStream.match(Tokens.PERCENTAGE)) {
  3189. return SyntaxUnit.fromToken(tokenStream.token());
  3190. } else if (tokenStream.match(Tokens.IDENT)) {
  3191. token = tokenStream.token();
  3192. if (/from|to/i.test(token.value)) {
  3193. return SyntaxUnit.fromToken(token);
  3194. }
  3195. tokenStream.unget();
  3196. }
  3197. this._unexpectedToken(tokenStream.LT(1));
  3198. },
  3199. _skipCruft: function() {
  3200. while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) {
  3201. }
  3202. },
  3203. _readDeclarations: function(checkStart, readMargins) {
  3204. var tokenStream = this._tokenStream,
  3205. tt;
  3206. this._readWhitespace();
  3207. if (checkStart) {
  3208. tokenStream.mustMatch(Tokens.LBRACE);
  3209. }
  3210. this._readWhitespace();
  3211. try {
  3212. while (true) {
  3213. if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())) {
  3214. } else if (this._declaration()) {
  3215. if (!tokenStream.match(Tokens.SEMICOLON)) {
  3216. break;
  3217. }
  3218. } else {
  3219. break;
  3220. }
  3221. this._readWhitespace();
  3222. }
  3223. tokenStream.mustMatch(Tokens.RBRACE);
  3224. this._readWhitespace();
  3225. } catch (ex) {
  3226. if (ex instanceof SyntaxError && !this.options.strict) {
  3227. this.fire({
  3228. type: "error",
  3229. error: ex,
  3230. message: ex.message,
  3231. line: ex.line,
  3232. col: ex.col
  3233. });
  3234. tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
  3235. if (tt === Tokens.SEMICOLON) {
  3236. this._readDeclarations(false, readMargins);
  3237. } else if (tt !== Tokens.EOF && tt !== Tokens.RBRACE) {
  3238. throw ex;
  3239. }
  3240. } else {
  3241. throw ex;
  3242. }
  3243. }
  3244. },
  3245. _readWhitespace: function() {
  3246. var tokenStream = this._tokenStream,
  3247. ws = "";
  3248. while (tokenStream.match(Tokens.S)) {
  3249. ws += tokenStream.token().value;
  3250. }
  3251. return ws;
  3252. },
  3253. _unexpectedToken: function(token) {
  3254. throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  3255. },
  3256. _verifyEnd: function() {
  3257. if (this._tokenStream.LA(1) !== Tokens.EOF) {
  3258. this._unexpectedToken(this._tokenStream.LT(1));
  3259. }
  3260. },
  3261. _validateProperty: function(property, value) {
  3262. Validation.validate(property, value);
  3263. },
  3264. parse: function(input) {
  3265. this._tokenStream = new TokenStream(input, Tokens);
  3266. this._stylesheet();
  3267. },
  3268. parseStyleSheet: function(input) {
  3269. return this.parse(input);
  3270. },
  3271. parseMediaQuery: function(input) {
  3272. this._tokenStream = new TokenStream(input, Tokens);
  3273. var result = this._media_query();
  3274. this._verifyEnd();
  3275. return result;
  3276. },
  3277. parsePropertyValue: function(input) {
  3278. this._tokenStream = new TokenStream(input, Tokens);
  3279. this._readWhitespace();
  3280. var result = this._expr();
  3281. this._readWhitespace();
  3282. this._verifyEnd();
  3283. return result;
  3284. },
  3285. parseRule: function(input) {
  3286. this._tokenStream = new TokenStream(input, Tokens);
  3287. this._readWhitespace();
  3288. var result = this._ruleset();
  3289. this._readWhitespace();
  3290. this._verifyEnd();
  3291. return result;
  3292. },
  3293. parseSelector: function(input) {
  3294. this._tokenStream = new TokenStream(input, Tokens);
  3295. this._readWhitespace();
  3296. var result = this._selector();
  3297. this._readWhitespace();
  3298. this._verifyEnd();
  3299. return result;
  3300. },
  3301. parseStyleAttribute: function(input) {
  3302. input += "}"; // for error recovery in _readDeclarations()
  3303. this._tokenStream = new TokenStream(input, Tokens);
  3304. this._readDeclarations();
  3305. }
  3306. };
  3307. for (prop in additions) {
  3308. if (Object.prototype.hasOwnProperty.call(additions, prop)) {
  3309. proto[prop] = additions[prop];
  3310. }
  3311. }
  3312. return proto;
  3313. }();
  3314. },{"../util/EventTarget":23,"../util/SyntaxError":25,"../util/SyntaxUnit":26,"./Combinator":2,"./MediaFeature":4,"./MediaQuery":5,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./TokenStream":17,"./Tokens":18,"./Validation":19}],7:[function(require,module,exports){
  3315. "use strict";
  3316. var Properties = module.exports = {
  3317. __proto__: null,
  3318. "align-items" : "flex-start | flex-end | center | baseline | stretch",
  3319. "align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
  3320. "align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
  3321. "all" : "initial | inherit | unset",
  3322. "-webkit-align-items" : "flex-start | flex-end | center | baseline | stretch",
  3323. "-webkit-align-content" : "flex-start | flex-end | center | space-between | space-around | stretch",
  3324. "-webkit-align-self" : "auto | flex-start | flex-end | center | baseline | stretch",
  3325. "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
  3326. "alignment-baseline" : "auto | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3327. "animation" : 1,
  3328. "animation-delay" : "<time>#",
  3329. "animation-direction" : "<single-animation-direction>#",
  3330. "animation-duration" : "<time>#",
  3331. "animation-fill-mode" : "[ none | forwards | backwards | both ]#",
  3332. "animation-iteration-count" : "[ <number> | infinite ]#",
  3333. "animation-name" : "[ none | <single-animation-name> ]#",
  3334. "animation-play-state" : "[ running | paused ]#",
  3335. "animation-timing-function" : 1,
  3336. "-moz-animation-delay" : "<time>#",
  3337. "-moz-animation-direction" : "[ normal | alternate ]#",
  3338. "-moz-animation-duration" : "<time>#",
  3339. "-moz-animation-iteration-count" : "[ <number> | infinite ]#",
  3340. "-moz-animation-name" : "[ none | <single-animation-name> ]#",
  3341. "-moz-animation-play-state" : "[ running | paused ]#",
  3342. "-ms-animation-delay" : "<time>#",
  3343. "-ms-animation-direction" : "[ normal | alternate ]#",
  3344. "-ms-animation-duration" : "<time>#",
  3345. "-ms-animation-iteration-count" : "[ <number> | infinite ]#",
  3346. "-ms-animation-name" : "[ none | <single-animation-name> ]#",
  3347. "-ms-animation-play-state" : "[ running | paused ]#",
  3348. "-webkit-animation-delay" : "<time>#",
  3349. "-webkit-animation-direction" : "[ normal | alternate ]#",
  3350. "-webkit-animation-duration" : "<time>#",
  3351. "-webkit-animation-fill-mode" : "[ none | forwards | backwards | both ]#",
  3352. "-webkit-animation-iteration-count" : "[ <number> | infinite ]#",
  3353. "-webkit-animation-name" : "[ none | <single-animation-name> ]#",
  3354. "-webkit-animation-play-state" : "[ running | paused ]#",
  3355. "-o-animation-delay" : "<time>#",
  3356. "-o-animation-direction" : "[ normal | alternate ]#",
  3357. "-o-animation-duration" : "<time>#",
  3358. "-o-animation-iteration-count" : "[ <number> | infinite ]#",
  3359. "-o-animation-name" : "[ none | <single-animation-name> ]#",
  3360. "-o-animation-play-state" : "[ running | paused ]#",
  3361. "appearance" : "none | auto",
  3362. "-moz-appearance" : "none | button | button-arrow-down | button-arrow-next | button-arrow-previous | button-arrow-up | button-bevel | button-focus | caret | checkbox | checkbox-container | checkbox-label | checkmenuitem | dualbutton | groupbox | listbox | listitem | menuarrow | menubar | menucheckbox | menuimage | menuitem | menuitemtext | menulist | menulist-button | menulist-text | menulist-textfield | menupopup | menuradio | menuseparator | meterbar | meterchunk | progressbar | progressbar-vertical | progresschunk | progresschunk-vertical | radio | radio-container | radio-label | radiomenuitem | range | range-thumb | resizer | resizerpanel | scale-horizontal | scalethumbend | scalethumb-horizontal | scalethumbstart | scalethumbtick | scalethumb-vertical | scale-vertical | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical | searchfield | separator | sheet | spinner | spinner-downbutton | spinner-textfield | spinner-upbutton | splitter | statusbar | statusbarpanel | tab | tabpanel | tabpanels | tab-scroll-arrow-back | tab-scroll-arrow-forward | textfield | textfield-multiline | toolbar | toolbarbutton | toolbarbutton-dropdown | toolbargripper | toolbox | tooltip | treeheader | treeheadercell | treeheadersortarrow | treeitem | treeline | treetwisty | treetwistyopen | treeview | -moz-mac-unified-toolbar | -moz-win-borderless-glass | -moz-win-browsertabbar-toolbox | -moz-win-communicationstext | -moz-win-communications-toolbox | -moz-win-exclude-glass | -moz-win-glass | -moz-win-mediatext | -moz-win-media-toolbox | -moz-window-button-box | -moz-window-button-box-maximized | -moz-window-button-close | -moz-window-button-maximize | -moz-window-button-minimize | -moz-window-button-restore | -moz-window-frame-bottom | -moz-window-frame-left | -moz-window-frame-right | -moz-window-titlebar | -moz-window-titlebar-maximized",
  3363. "-ms-appearance" : "none | icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
  3364. "-webkit-appearance" : "none | button | button-bevel | caps-lock-indicator | caret | checkbox | default-button | listbox | listitem | media-fullscreen-button | media-mute-button | media-play-button | media-seek-back-button | media-seek-forward-button | media-slider | media-sliderthumb | menulist | menulist-button | menulist-text | menulist-textfield | push-button | radio | searchfield | searchfield-cancel-button | searchfield-decoration | searchfield-results-button | searchfield-results-decoration | slider-horizontal | slider-vertical | sliderthumb-horizontal | sliderthumb-vertical | square-button | textarea | textfield | scrollbarbutton-down | scrollbarbutton-left | scrollbarbutton-right | scrollbarbutton-up | scrollbargripper-horizontal | scrollbargripper-vertical | scrollbarthumb-horizontal | scrollbarthumb-vertical | scrollbartrack-horizontal | scrollbartrack-vertical",
  3365. "-o-appearance" : "none | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal",
  3366. "azimuth" : "<azimuth>",
  3367. "backface-visibility" : "visible | hidden",
  3368. "background" : 1,
  3369. "background-attachment" : "<attachment>#",
  3370. "background-clip" : "<box>#",
  3371. "background-color" : "<color>",
  3372. "background-image" : "<bg-image>#",
  3373. "background-origin" : "<box>#",
  3374. "background-position" : "<bg-position>",
  3375. "background-repeat" : "<repeat-style>#",
  3376. "background-size" : "<bg-size>#",
  3377. "baseline-shift" : "baseline | sub | super | <percentage> | <length>",
  3378. "behavior" : 1,
  3379. "binding" : 1,
  3380. "bleed" : "<length>",
  3381. "bookmark-label" : "<content> | <attr> | <string>",
  3382. "bookmark-level" : "none | <integer>",
  3383. "bookmark-state" : "open | closed",
  3384. "bookmark-target" : "none | <uri> | <attr>",
  3385. "border" : "<border-width> || <border-style> || <color>",
  3386. "border-bottom" : "<border-width> || <border-style> || <color>",
  3387. "border-bottom-color" : "<color>",
  3388. "border-bottom-left-radius" : "<x-one-radius>",
  3389. "border-bottom-right-radius" : "<x-one-radius>",
  3390. "border-bottom-style" : "<border-style>",
  3391. "border-bottom-width" : "<border-width>",
  3392. "border-collapse" : "collapse | separate",
  3393. "border-color" : "<color>{1,4}",
  3394. "border-image" : 1,
  3395. "border-image-outset" : "[ <length> | <number> ]{1,4}",
  3396. "border-image-repeat" : "[ stretch | repeat | round | space ]{1,2}",
  3397. "border-image-slice" : "<border-image-slice>",
  3398. "border-image-source" : "<image> | none",
  3399. "border-image-width" : "[ <length> | <percentage> | <number> | auto ]{1,4}",
  3400. "border-left" : "<border-width> || <border-style> || <color>",
  3401. "border-left-color" : "<color>",
  3402. "border-left-style" : "<border-style>",
  3403. "border-left-width" : "<border-width>",
  3404. "border-radius" : "<border-radius>",
  3405. "border-right" : "<border-width> || <border-style> || <color>",
  3406. "border-right-color" : "<color>",
  3407. "border-right-style" : "<border-style>",
  3408. "border-right-width" : "<border-width>",
  3409. "border-spacing" : "<length>{1,2}",
  3410. "border-style" : "<border-style>{1,4}",
  3411. "border-top" : "<border-width> || <border-style> || <color>",
  3412. "border-top-color" : "<color>",
  3413. "border-top-left-radius" : "<x-one-radius>",
  3414. "border-top-right-radius" : "<x-one-radius>",
  3415. "border-top-style" : "<border-style>",
  3416. "border-top-width" : "<border-width>",
  3417. "border-width" : "<border-width>{1,4}",
  3418. "bottom" : "<margin-width>",
  3419. "-moz-box-align" : "start | end | center | baseline | stretch",
  3420. "-moz-box-decoration-break" : "slice | clone",
  3421. "-moz-box-direction" : "normal | reverse",
  3422. "-moz-box-flex" : "<number>",
  3423. "-moz-box-flex-group" : "<integer>",
  3424. "-moz-box-lines" : "single | multiple",
  3425. "-moz-box-ordinal-group" : "<integer>",
  3426. "-moz-box-orient" : "horizontal | vertical | inline-axis | block-axis",
  3427. "-moz-box-pack" : "start | end | center | justify",
  3428. "-o-box-decoration-break" : "slice | clone",
  3429. "-webkit-box-align" : "start | end | center | baseline | stretch",
  3430. "-webkit-box-decoration-break" : "slice | clone",
  3431. "-webkit-box-direction" : "normal | reverse",
  3432. "-webkit-box-flex" : "<number>",
  3433. "-webkit-box-flex-group" : "<integer>",
  3434. "-webkit-box-lines" : "single | multiple",
  3435. "-webkit-box-ordinal-group" : "<integer>",
  3436. "-webkit-box-orient" : "horizontal | vertical | inline-axis | block-axis",
  3437. "-webkit-box-pack" : "start | end | center | justify",
  3438. "box-decoration-break" : "slice | clone",
  3439. "box-shadow" : "<box-shadow>",
  3440. "box-sizing" : "content-box | border-box",
  3441. "break-after" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
  3442. "break-before" : "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
  3443. "break-inside" : "auto | avoid | avoid-page | avoid-column",
  3444. "caption-side" : "top | bottom",
  3445. "clear" : "none | right | left | both",
  3446. "clip" : "<shape> | auto",
  3447. "-webkit-clip-path" : "<clip-source> | <clip-path> | none",
  3448. "clip-path" : "<clip-source> | <clip-path> | none",
  3449. "clip-rule" : "nonzero | evenodd",
  3450. "color" : "<color>",
  3451. "color-interpolation" : "auto | sRGB | linearRGB",
  3452. "color-interpolation-filters" : "auto | sRGB | linearRGB",
  3453. "color-profile" : 1,
  3454. "color-rendering" : "auto | optimizeSpeed | optimizeQuality",
  3455. "column-count" : "<integer> | auto", // https ://www.w3.org/TR/css3-multicol/
  3456. "column-fill" : "auto | balance",
  3457. "column-gap" : "<length> | normal",
  3458. "column-rule" : "<border-width> || <border-style> || <color>",
  3459. "column-rule-color" : "<color>",
  3460. "column-rule-style" : "<border-style>",
  3461. "column-rule-width" : "<border-width>",
  3462. "column-span" : "none | all",
  3463. "column-width" : "<length> | auto",
  3464. "columns" : 1,
  3465. "content" : 1,
  3466. "counter-increment" : 1,
  3467. "counter-reset" : 1,
  3468. "crop" : "<shape> | auto",
  3469. "cue" : "cue-after | cue-before",
  3470. "cue-after" : 1,
  3471. "cue-before" : 1,
  3472. "cursor" : 1,
  3473. "direction" : "ltr | rtl",
  3474. "display" : "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
  3475. "dominant-baseline" : "auto | use-script | no-change | reset-size | ideographic | alphabetic | hanging | mathematical | central | middle | text-after-edge | text-before-edge",
  3476. "drop-initial-after-adjust" : "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
  3477. "drop-initial-after-align" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3478. "drop-initial-before-adjust" : "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
  3479. "drop-initial-before-align" : "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
  3480. "drop-initial-size" : "auto | line | <length> | <percentage>",
  3481. "drop-initial-value" : "<integer>",
  3482. "elevation" : "<angle> | below | level | above | higher | lower",
  3483. "empty-cells" : "show | hide",
  3484. "enable-background" : 1,
  3485. "fill" : "<paint>",
  3486. "fill-opacity" : "<opacity-value>",
  3487. "fill-rule" : "nonzero | evenodd",
  3488. "filter" : "<filter-function-list> | none",
  3489. "fit" : "fill | hidden | meet | slice",
  3490. "fit-position" : 1,
  3491. "flex" : "<flex>",
  3492. "flex-basis" : "<width>",
  3493. "flex-direction" : "row | row-reverse | column | column-reverse",
  3494. "flex-flow" : "<flex-direction> || <flex-wrap>",
  3495. "flex-grow" : "<number>",
  3496. "flex-shrink" : "<number>",
  3497. "flex-wrap" : "nowrap | wrap | wrap-reverse",
  3498. "-webkit-flex" : "<flex>",
  3499. "-webkit-flex-basis" : "<width>",
  3500. "-webkit-flex-direction" : "row | row-reverse | column | column-reverse",
  3501. "-webkit-flex-flow" : "<flex-direction> || <flex-wrap>",
  3502. "-webkit-flex-grow" : "<number>",
  3503. "-webkit-flex-shrink" : "<number>",
  3504. "-webkit-flex-wrap" : "nowrap | wrap | wrap-reverse",
  3505. "-ms-flex" : "<flex>",
  3506. "-ms-flex-align" : "start | end | center | stretch | baseline",
  3507. "-ms-flex-direction" : "row | row-reverse | column | column-reverse",
  3508. "-ms-flex-order" : "<number>",
  3509. "-ms-flex-pack" : "start | end | center | justify | distribute",
  3510. "-ms-flex-wrap" : "nowrap | wrap | wrap-reverse",
  3511. "float" : "left | right | none",
  3512. "float-offset" : 1,
  3513. "flood-color" : 1,
  3514. "flood-opacity" : "<opacity-value>",
  3515. "font" : "<font-shorthand> | caption | icon | menu | message-box | small-caption | status-bar",
  3516. "font-family" : "<font-family>",
  3517. "font-feature-settings" : "<feature-tag-value> | normal",
  3518. "font-kerning" : "auto | normal | none",
  3519. "font-size" : "<font-size>",
  3520. "font-size-adjust" : "<number> | none",
  3521. "font-stretch" : "<font-stretch>",
  3522. "font-style" : "<font-style>",
  3523. "font-variant" : "<font-variant> | normal | none",
  3524. "font-variant-alternates" : "<font-variant-alternates> | normal",
  3525. "font-variant-caps" : "<font-variant-caps> | normal",
  3526. "font-variant-east-asian" : "<font-variant-east-asian> | normal",
  3527. "font-variant-ligatures" : "<font-variant-ligatures> | normal | none",
  3528. "font-variant-numeric" : "<font-variant-numeric> | normal",
  3529. "font-variant-position" : "normal | sub | super",
  3530. "font-weight" : "<font-weight>",
  3531. "gap" : "[ <length> | <percentage> ]{1,2}",
  3532. "glyph-orientation-horizontal" : "<glyph-angle>",
  3533. "glyph-orientation-vertical" : "auto | <glyph-angle>",
  3534. "grid" : 1,
  3535. "grid-area" : 1,
  3536. "grid-auto-columns" : 1,
  3537. "grid-auto-flow" : 1,
  3538. "grid-auto-position" : 1,
  3539. "grid-auto-rows" : 1,
  3540. "grid-cell-stacking" : "columns | rows | layer",
  3541. "grid-column" : 1,
  3542. "grid-columns" : 1,
  3543. "grid-column-align" : "start | end | center | stretch",
  3544. "grid-column-sizing" : 1,
  3545. "grid-column-start" : 1,
  3546. "grid-column-end" : 1,
  3547. "grid-column-span" : "<integer>",
  3548. "grid-flow" : "none | rows | columns",
  3549. "grid-gap" : "[ <length> | <percentage> ]{1,2}",
  3550. "grid-layer" : "<integer>",
  3551. "grid-row" : 1,
  3552. "grid-rows" : 1,
  3553. "grid-row-align" : "start | end | center | stretch",
  3554. "grid-row-gap" : 1,
  3555. "grid-row-start" : 1,
  3556. "grid-row-end" : 1,
  3557. "grid-row-span" : "<integer>",
  3558. "grid-row-sizing" : 1,
  3559. "grid-template" : 1,
  3560. "grid-template-areas" : 1,
  3561. "grid-template-columns" : 1,
  3562. "grid-template-rows" : 1,
  3563. "hanging-punctuation" : 1,
  3564. "height" : "<margin-width> | <content-sizing>",
  3565. "hyphenate-after" : "<integer> | auto",
  3566. "hyphenate-before" : "<integer> | auto",
  3567. "hyphenate-character" : "<string> | auto",
  3568. "hyphenate-lines" : "no-limit | <integer>",
  3569. "hyphenate-resource" : 1,
  3570. "hyphens" : "none | manual | auto",
  3571. "icon" : 1,
  3572. "image-orientation" : "angle | auto",
  3573. "image-rendering" : "auto | optimizeSpeed | optimizeQuality",
  3574. "image-resolution" : 1,
  3575. "ime-mode" : "auto | normal | active | inactive | disabled",
  3576. "inline-box-align" : "last | <integer>",
  3577. "justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
  3578. "-webkit-justify-content" : "flex-start | flex-end | center | space-between | space-around | space-evenly | stretch",
  3579. "kerning" : "auto | <length>",
  3580. "left" : "<margin-width>",
  3581. "letter-spacing" : "<length> | normal",
  3582. "line-height" : "<line-height>",
  3583. "line-break" : "auto | loose | normal | strict",
  3584. "line-stacking" : 1,
  3585. "line-stacking-ruby" : "exclude-ruby | include-ruby",
  3586. "line-stacking-shift" : "consider-shifts | disregard-shifts",
  3587. "line-stacking-strategy" : "inline-line-height | block-line-height | max-height | grid-height",
  3588. "list-style" : 1,
  3589. "list-style-image" : "<uri> | none",
  3590. "list-style-position" : "inside | outside",
  3591. "list-style-type" : "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none",
  3592. "margin" : "<margin-width>{1,4}",
  3593. "margin-bottom" : "<margin-width>",
  3594. "margin-left" : "<margin-width>",
  3595. "margin-right" : "<margin-width>",
  3596. "margin-top" : "<margin-width>",
  3597. "mark" : 1,
  3598. "mark-after" : 1,
  3599. "mark-before" : 1,
  3600. "marker" : 1,
  3601. "marker-end" : 1,
  3602. "marker-mid" : 1,
  3603. "marker-start" : 1,
  3604. "marks" : 1,
  3605. "marquee-direction" : 1,
  3606. "marquee-play-count" : 1,
  3607. "marquee-speed" : 1,
  3608. "marquee-style" : 1,
  3609. "mask" : 1,
  3610. "max-height" : "<length> | <percentage> | <content-sizing> | none",
  3611. "max-width" : "<length> | <percentage> | <content-sizing> | none",
  3612. "min-height" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
  3613. "min-width" : "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats",
  3614. "mix-blend-mode" : "<blend-mode>",
  3615. "move-to" : 1,
  3616. "nav-down" : 1,
  3617. "nav-index" : 1,
  3618. "nav-left" : 1,
  3619. "nav-right" : 1,
  3620. "nav-up" : 1,
  3621. "object-fit" : "fill | contain | cover | none | scale-down",
  3622. "object-position" : "<position>",
  3623. "opacity" : "<opacity-value>",
  3624. "order" : "<integer>",
  3625. "-webkit-order" : "<integer>",
  3626. "orphans" : "<integer>",
  3627. "outline" : 1,
  3628. "outline-color" : "<color> | invert",
  3629. "outline-offset" : 1,
  3630. "outline-style" : "<border-style>",
  3631. "outline-width" : "<border-width>",
  3632. "overflow" : "visible | hidden | scroll | auto",
  3633. "overflow-style" : 1,
  3634. "overflow-wrap" : "normal | break-word",
  3635. "overflow-x" : 1,
  3636. "overflow-y" : 1,
  3637. "padding" : "<padding-width>{1,4}",
  3638. "padding-bottom" : "<padding-width>",
  3639. "padding-left" : "<padding-width>",
  3640. "padding-right" : "<padding-width>",
  3641. "padding-top" : "<padding-width>",
  3642. "page" : 1,
  3643. "page-break-after" : "auto | always | avoid | left | right",
  3644. "page-break-before" : "auto | always | avoid | left | right",
  3645. "page-break-inside" : "auto | avoid",
  3646. "page-policy" : 1,
  3647. "pause" : 1,
  3648. "pause-after" : 1,
  3649. "pause-before" : 1,
  3650. "perspective" : 1,
  3651. "perspective-origin" : 1,
  3652. "phonemes" : 1,
  3653. "pitch" : 1,
  3654. "pitch-range" : 1,
  3655. "play-during" : 1,
  3656. "pointer-events" : "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all",
  3657. "position" : "static | relative | absolute | fixed | sticky | -webkit-sticky",
  3658. "presentation-level" : 1,
  3659. "punctuation-trim" : 1,
  3660. "quotes" : 1,
  3661. "rendering-intent" : 1,
  3662. "resize" : 1,
  3663. "rest" : 1,
  3664. "rest-after" : 1,
  3665. "rest-before" : 1,
  3666. "richness" : 1,
  3667. "right" : "<margin-width>",
  3668. "rotation" : 1,
  3669. "rotation-point" : 1,
  3670. "ruby-align" : 1,
  3671. "ruby-overhang" : 1,
  3672. "ruby-position" : 1,
  3673. "ruby-span" : 1,
  3674. "shape-rendering" : "auto | optimizeSpeed | crispEdges | geometricPrecision",
  3675. "size" : 1,
  3676. "speak" : "normal | none | spell-out",
  3677. "speak-header" : "once | always",
  3678. "speak-numeral" : "digits | continuous",
  3679. "speak-punctuation" : "code | none",
  3680. "speech-rate" : 1,
  3681. "src" : 1,
  3682. "stop-color" : 1,
  3683. "stop-opacity" : "<opacity-value>",
  3684. "stress" : 1,
  3685. "string-set" : 1,
  3686. "stroke" : "<paint>",
  3687. "stroke-dasharray" : "none | <dasharray>",
  3688. "stroke-dashoffset" : "<percentage> | <length>",
  3689. "stroke-linecap" : "butt | round | square",
  3690. "stroke-linejoin" : "miter | round | bevel",
  3691. "stroke-miterlimit" : "<miterlimit>",
  3692. "stroke-opacity" : "<opacity-value>",
  3693. "stroke-width" : "<percentage> | <length>",
  3694. "table-layout" : "auto | fixed",
  3695. "tab-size" : "<integer> | <length>",
  3696. "target" : 1,
  3697. "target-name" : 1,
  3698. "target-new" : 1,
  3699. "target-position" : 1,
  3700. "text-align" : "left | right | center | justify | match-parent | start | end",
  3701. "text-align-last" : 1,
  3702. "text-anchor" : "start | middle | end",
  3703. "text-decoration" : "<text-decoration-line> || <text-decoration-style> || <text-decoration-color>",
  3704. "text-decoration-color" : "<text-decoration-color>",
  3705. "text-decoration-line" : "<text-decoration-line>",
  3706. "text-decoration-style" : "<text-decoration-style>",
  3707. "text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
  3708. "-webkit-text-decoration-skip" : "none | [ objects || spaces || ink || edges || box-decoration ]",
  3709. "text-underline-position" : "auto | [ under || [ left | right ] ]",
  3710. "text-emphasis" : 1,
  3711. "text-height" : 1,
  3712. "text-indent" : "<length> | <percentage>",
  3713. "text-justify" : "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
  3714. "text-outline" : 1,
  3715. "text-overflow" : 1,
  3716. "text-rendering" : "auto | optimizeSpeed | optimizeLegibility | geometricPrecision",
  3717. "text-shadow" : 1,
  3718. "text-transform" : "capitalize | uppercase | lowercase | none",
  3719. "text-wrap" : "normal | none | avoid",
  3720. "top" : "<margin-width>",
  3721. "-ms-touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
  3722. "touch-action" : "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
  3723. "transform" : 1,
  3724. "transform-origin" : 1,
  3725. "transform-style" : 1,
  3726. "transition" : 1,
  3727. "transition-delay" : 1,
  3728. "transition-duration" : 1,
  3729. "transition-property" : 1,
  3730. "transition-timing-function" : 1,
  3731. "unicode-bidi" : "normal | embed | isolate | bidi-override | isolate-override | plaintext",
  3732. "user-modify" : "read-only | read-write | write-only",
  3733. "user-select" : "auto | text | none | contain | all",
  3734. "vertical-align" : "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length>",
  3735. "visibility" : "visible | hidden | collapse",
  3736. "voice-balance" : 1,
  3737. "voice-duration" : 1,
  3738. "voice-family" : 1,
  3739. "voice-pitch" : 1,
  3740. "voice-pitch-range" : 1,
  3741. "voice-rate" : 1,
  3742. "voice-stress" : 1,
  3743. "voice-volume" : 1,
  3744. "volume" : 1,
  3745. "white-space" : "normal | pre | nowrap | pre-wrap | pre-line | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap", // https ://perishablepress.com/wrapping-content/
  3746. "white-space-collapse" : 1,
  3747. "widows" : "<integer>",
  3748. "width" : "<length> | <percentage> | <content-sizing> | auto",
  3749. "will-change" : "<will-change>",
  3750. "word-break" : "normal | keep-all | break-all | break-word",
  3751. "word-spacing" : "<length> | normal",
  3752. "word-wrap" : "normal | break-word",
  3753. "writing-mode" : "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb",
  3754. "z-index" : "<integer> | auto",
  3755. "zoom" : "<number> | <percentage> | normal"
  3756. };
  3757. },{}],8:[function(require,module,exports){
  3758. "use strict";
  3759. module.exports = PropertyName;
  3760. var SyntaxUnit = require("../util/SyntaxUnit");
  3761. var Parser = require("./Parser");
  3762. function PropertyName(text, hack, line, col) {
  3763. SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
  3764. this.hack = hack;
  3765. }
  3766. PropertyName.prototype = new SyntaxUnit();
  3767. PropertyName.prototype.constructor = PropertyName;
  3768. PropertyName.prototype.toString = function() {
  3769. return (this.hack ? this.hack : "") + this.text;
  3770. };
  3771. },{"../util/SyntaxUnit":26,"./Parser":6}],9:[function(require,module,exports){
  3772. "use strict";
  3773. module.exports = PropertyValue;
  3774. var SyntaxUnit = require("../util/SyntaxUnit");
  3775. var Parser = require("./Parser");
  3776. function PropertyValue(parts, line, col) {
  3777. SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
  3778. this.parts = parts;
  3779. }
  3780. PropertyValue.prototype = new SyntaxUnit();
  3781. PropertyValue.prototype.constructor = PropertyValue;
  3782. },{"../util/SyntaxUnit":26,"./Parser":6}],10:[function(require,module,exports){
  3783. "use strict";
  3784. module.exports = PropertyValueIterator;
  3785. function PropertyValueIterator(value) {
  3786. this._i = 0;
  3787. this._parts = value.parts;
  3788. this._marks = [];
  3789. this.value = value;
  3790. }
  3791. PropertyValueIterator.prototype.count = function() {
  3792. return this._parts.length;
  3793. };
  3794. PropertyValueIterator.prototype.isFirst = function() {
  3795. return this._i === 0;
  3796. };
  3797. PropertyValueIterator.prototype.hasNext = function() {
  3798. return this._i < this._parts.length;
  3799. };
  3800. PropertyValueIterator.prototype.mark = function() {
  3801. this._marks.push(this._i);
  3802. };
  3803. PropertyValueIterator.prototype.peek = function(count) {
  3804. return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
  3805. };
  3806. PropertyValueIterator.prototype.next = function() {
  3807. return this.hasNext() ? this._parts[this._i++] : null;
  3808. };
  3809. PropertyValueIterator.prototype.previous = function() {
  3810. return this._i > 0 ? this._parts[--this._i] : null;
  3811. };
  3812. PropertyValueIterator.prototype.restore = function() {
  3813. if (this._marks.length) {
  3814. this._i = this._marks.pop();
  3815. }
  3816. };
  3817. PropertyValueIterator.prototype.drop = function() {
  3818. this._marks.pop();
  3819. };
  3820. },{}],11:[function(require,module,exports){
  3821. "use strict";
  3822. module.exports = PropertyValuePart;
  3823. var SyntaxUnit = require("../util/SyntaxUnit");
  3824. var Colors = require("./Colors");
  3825. var Parser = require("./Parser");
  3826. var Tokens = require("./Tokens");
  3827. function PropertyValuePart(text, line, col, optionalHint) {
  3828. var hint = optionalHint || {};
  3829. SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
  3830. this.type = "unknown";
  3831. var temp;
  3832. if (/^([+-]?[\d.]+)([a-z]+)$/i.test(text)) { // dimension
  3833. this.type = "dimension";
  3834. this.value = Number(RegExp.$1);
  3835. this.units = RegExp.$2;
  3836. switch (this.units.toLowerCase()) {
  3837. case "em":
  3838. case "rem":
  3839. case "ex":
  3840. case "px":
  3841. case "cm":
  3842. case "mm":
  3843. case "in":
  3844. case "pt":
  3845. case "pc":
  3846. case "ch":
  3847. case "vh":
  3848. case "vw":
  3849. case "vmax":
  3850. case "vmin":
  3851. this.type = "length";
  3852. break;
  3853. case "fr":
  3854. this.type = "grid";
  3855. break;
  3856. case "deg":
  3857. case "rad":
  3858. case "grad":
  3859. case "turn":
  3860. this.type = "angle";
  3861. break;
  3862. case "ms":
  3863. case "s":
  3864. this.type = "time";
  3865. break;
  3866. case "hz":
  3867. case "khz":
  3868. this.type = "frequency";
  3869. break;
  3870. case "dpi":
  3871. case "dpcm":
  3872. this.type = "resolution";
  3873. break;
  3874. }
  3875. } else if (/^([+-]?[\d.]+)%$/i.test(text)) { // percentage
  3876. this.type = "percentage";
  3877. this.value = Number(RegExp.$1);
  3878. } else if (/^([+-]?\d+)$/i.test(text)) { // integer
  3879. this.type = "integer";
  3880. this.value = Number(RegExp.$1);
  3881. } else if (/^([+-]?[\d.]+)$/i.test(text)) { // number
  3882. this.type = "number";
  3883. this.value = Number(RegExp.$1);
  3884. } else if (/^#([a-f0-9]{3,6})/i.test(text)) { // hexcolor
  3885. this.type = "color";
  3886. temp = RegExp.$1;
  3887. if (temp.length === 3) {
  3888. this.red = parseInt(temp.charAt(0) + temp.charAt(0), 16);
  3889. this.green = parseInt(temp.charAt(1) + temp.charAt(1), 16);
  3890. this.blue = parseInt(temp.charAt(2) + temp.charAt(2), 16);
  3891. } else {
  3892. this.red = parseInt(temp.substring(0, 2), 16);
  3893. this.green = parseInt(temp.substring(2, 4), 16);
  3894. this.blue = parseInt(temp.substring(4, 6), 16);
  3895. }
  3896. } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)) { // rgb() color with absolute numbers
  3897. this.type = "color";
  3898. this.red = Number(RegExp.$1);
  3899. this.green = Number(RegExp.$2);
  3900. this.blue = Number(RegExp.$3);
  3901. } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // rgb() color with percentages
  3902. this.type = "color";
  3903. this.red = Number(RegExp.$1) * 255 / 100;
  3904. this.green = Number(RegExp.$2) * 255 / 100;
  3905. this.blue = Number(RegExp.$3) * 255 / 100;
  3906. } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with absolute numbers
  3907. this.type = "color";
  3908. this.red = Number(RegExp.$1);
  3909. this.green = Number(RegExp.$2);
  3910. this.blue = Number(RegExp.$3);
  3911. this.alpha = Number(RegExp.$4);
  3912. } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // rgba() color with percentages
  3913. this.type = "color";
  3914. this.red = Number(RegExp.$1) * 255 / 100;
  3915. this.green = Number(RegExp.$2) * 255 / 100;
  3916. this.blue = Number(RegExp.$3) * 255 / 100;
  3917. this.alpha = Number(RegExp.$4);
  3918. } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) { // hsl()
  3919. this.type = "color";
  3920. this.hue = Number(RegExp.$1);
  3921. this.saturation = Number(RegExp.$2) / 100;
  3922. this.lightness = Number(RegExp.$3) / 100;
  3923. } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d.]+)\s*\)/i.test(text)) { // hsla() color with percentages
  3924. this.type = "color";
  3925. this.hue = Number(RegExp.$1);
  3926. this.saturation = Number(RegExp.$2) / 100;
  3927. this.lightness = Number(RegExp.$3) / 100;
  3928. this.alpha = Number(RegExp.$4);
  3929. } else if (/^url\(("([^\\"]|\.)*")\)/i.test(text)) { // URI
  3930. this.type = "uri";
  3931. this.uri = PropertyValuePart.parseString(RegExp.$1);
  3932. } else if (/^([^(]+)\(/i.test(text)) {
  3933. this.type = "function";
  3934. this.name = RegExp.$1;
  3935. this.value = text;
  3936. } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)) { // double-quoted string
  3937. this.type = "string";
  3938. this.value = PropertyValuePart.parseString(text);
  3939. } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)) { // single-quoted string
  3940. this.type = "string";
  3941. this.value = PropertyValuePart.parseString(text);
  3942. } else if (Colors[text.toLowerCase()]) { // named color
  3943. this.type = "color";
  3944. temp = Colors[text.toLowerCase()].substring(1);
  3945. this.red = parseInt(temp.substring(0, 2), 16);
  3946. this.green = parseInt(temp.substring(2, 4), 16);
  3947. this.blue = parseInt(temp.substring(4, 6), 16);
  3948. } else if (/^[,/]$/.test(text)) {
  3949. this.type = "operator";
  3950. this.value = text;
  3951. } else if (/^-?[a-z_\u00A0-\uFFFF][a-z0-9\-_\u00A0-\uFFFF]*$/i.test(text)) {
  3952. this.type = "identifier";
  3953. this.value = text;
  3954. }
  3955. this.wasIdent = Boolean(hint.ident);
  3956. }
  3957. PropertyValuePart.prototype = new SyntaxUnit();
  3958. PropertyValuePart.prototype.constructor = PropertyValuePart;
  3959. PropertyValuePart.parseString = function(str) {
  3960. str = str.slice(1, -1); // Strip surrounding single/double quotes
  3961. var replacer = function(match, esc) {
  3962. if (/^(\n|\r\n|\r|\f)$/.test(esc)) {
  3963. return "";
  3964. }
  3965. var m = /^[0-9a-f]{1,6}/i.exec(esc);
  3966. if (m) {
  3967. var codePoint = parseInt(m[0], 16);
  3968. if (String.fromCodePoint) {
  3969. return String.fromCodePoint(codePoint);
  3970. } else {
  3971. return String.fromCharCode(codePoint);
  3972. }
  3973. }
  3974. return esc;
  3975. };
  3976. return str.replace(/\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
  3977. replacer);
  3978. };
  3979. PropertyValuePart.serializeString = function(value) {
  3980. var replacer = function(match, c) {
  3981. if (c === "\"") {
  3982. return "\\" + c;
  3983. }
  3984. var cp = String.codePointAt ? String.codePointAt(0) :
  3985. String.charCodeAt(0);
  3986. return "\\" + cp.toString(16) + " ";
  3987. };
  3988. return "\"" + value.replace(/["\r\n\f]/g, replacer) + "\"";
  3989. };
  3990. PropertyValuePart.fromToken = function(token) {
  3991. var part = new PropertyValuePart(token.value, token.startLine, token.startCol, {
  3992. ident: token.type === Tokens.IDENT
  3993. });
  3994. return part;
  3995. };
  3996. },{"../util/SyntaxUnit":26,"./Colors":1,"./Parser":6,"./Tokens":18}],12:[function(require,module,exports){
  3997. "use strict";
  3998. var Pseudos = module.exports = {
  3999. __proto__: null,
  4000. ":first-letter": 1,
  4001. ":first-line": 1,
  4002. ":before": 1,
  4003. ":after": 1
  4004. };
  4005. Pseudos.ELEMENT = 1;
  4006. Pseudos.CLASS = 2;
  4007. Pseudos.isElement = function(pseudo) {
  4008. return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
  4009. };
  4010. },{}],13:[function(require,module,exports){
  4011. "use strict";
  4012. module.exports = Selector;
  4013. var SyntaxUnit = require("../util/SyntaxUnit");
  4014. var Parser = require("./Parser");
  4015. var Specificity = require("./Specificity");
  4016. function Selector(parts, line, col) {
  4017. SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
  4018. this.parts = parts;
  4019. this.specificity = Specificity.calculate(this);
  4020. }
  4021. Selector.prototype = new SyntaxUnit();
  4022. Selector.prototype.constructor = Selector;
  4023. },{"../util/SyntaxUnit":26,"./Parser":6,"./Specificity":16}],14:[function(require,module,exports){
  4024. "use strict";
  4025. module.exports = SelectorPart;
  4026. var SyntaxUnit = require("../util/SyntaxUnit");
  4027. var Parser = require("./Parser");
  4028. function SelectorPart(elementName, modifiers, text, line, col) {
  4029. SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
  4030. this.elementName = elementName;
  4031. this.modifiers = modifiers;
  4032. }
  4033. SelectorPart.prototype = new SyntaxUnit();
  4034. SelectorPart.prototype.constructor = SelectorPart;
  4035. },{"../util/SyntaxUnit":26,"./Parser":6}],15:[function(require,module,exports){
  4036. "use strict";
  4037. module.exports = SelectorSubPart;
  4038. var SyntaxUnit = require("../util/SyntaxUnit");
  4039. var Parser = require("./Parser");
  4040. function SelectorSubPart(text, type, line, col) {
  4041. SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
  4042. this.type = type;
  4043. this.args = [];
  4044. }
  4045. SelectorSubPart.prototype = new SyntaxUnit();
  4046. SelectorSubPart.prototype.constructor = SelectorSubPart;
  4047. },{"../util/SyntaxUnit":26,"./Parser":6}],16:[function(require,module,exports){
  4048. "use strict";
  4049. module.exports = Specificity;
  4050. var Pseudos = require("./Pseudos");
  4051. var SelectorPart = require("./SelectorPart");
  4052. function Specificity(a, b, c, d) {
  4053. this.a = a;
  4054. this.b = b;
  4055. this.c = c;
  4056. this.d = d;
  4057. }
  4058. Specificity.prototype = {
  4059. constructor: Specificity,
  4060. compare: function(other) {
  4061. var comps = ["a", "b", "c", "d"],
  4062. i, len;
  4063. for (i = 0, len = comps.length; i < len; i++) {
  4064. if (this[comps[i]] < other[comps[i]]) {
  4065. return -1;
  4066. } else if (this[comps[i]] > other[comps[i]]) {
  4067. return 1;
  4068. }
  4069. }
  4070. return 0;
  4071. },
  4072. valueOf: function() {
  4073. return (this.a * 1000) + (this.b * 100) + (this.c * 10) + this.d;
  4074. },
  4075. toString: function() {
  4076. return this.a + "," + this.b + "," + this.c + "," + this.d;
  4077. }
  4078. };
  4079. Specificity.calculate = function(selector) {
  4080. var i,
  4081. len,
  4082. part,
  4083. b = 0,
  4084. c = 0,
  4085. d = 0;
  4086. function updateValues(part) {
  4087. var i, j, len, num,
  4088. elementName = part.elementName ? part.elementName.text : "",
  4089. modifier;
  4090. if (elementName && elementName.charAt(elementName.length - 1) !== "*") {
  4091. d++;
  4092. }
  4093. for (i = 0, len = part.modifiers.length; i < len; i++) {
  4094. modifier = part.modifiers[i];
  4095. switch (modifier.type) {
  4096. case "class":
  4097. case "attribute":
  4098. c++;
  4099. break;
  4100. case "id":
  4101. b++;
  4102. break;
  4103. case "pseudo":
  4104. if (Pseudos.isElement(modifier.text)) {
  4105. d++;
  4106. } else {
  4107. c++;
  4108. }
  4109. break;
  4110. case "not":
  4111. for (j = 0, num = modifier.args.length; j < num; j++) {
  4112. updateValues(modifier.args[j]);
  4113. }
  4114. }
  4115. }
  4116. }
  4117. for (i = 0, len = selector.parts.length; i < len; i++) {
  4118. part = selector.parts[i];
  4119. if (part instanceof SelectorPart) {
  4120. updateValues(part);
  4121. }
  4122. }
  4123. return new Specificity(0, b, c, d);
  4124. };
  4125. },{"./Pseudos":12,"./SelectorPart":14}],17:[function(require,module,exports){
  4126. "use strict";
  4127. module.exports = TokenStream;
  4128. var TokenStreamBase = require("../util/TokenStreamBase");
  4129. var PropertyValuePart = require("./PropertyValuePart");
  4130. var Tokens = require("./Tokens");
  4131. var h = /^[0-9a-fA-F]$/,
  4132. nonascii = /^[\u00A0-\uFFFF]$/,
  4133. nl = /\n|\r\n|\r|\f/,
  4134. whitespace = /\u0009|\u000a|\u000c|\u000d|\u0020/;
  4135. function isHexDigit(c) {
  4136. return c != null && h.test(c);
  4137. }
  4138. function isDigit(c) {
  4139. return c != null && /\d/.test(c);
  4140. }
  4141. function isWhitespace(c) {
  4142. return c != null && whitespace.test(c);
  4143. }
  4144. function isNewLine(c) {
  4145. return c != null && nl.test(c);
  4146. }
  4147. function isNameStart(c) {
  4148. return c != null && /[a-z_\u00A0-\uFFFF\\]/i.test(c);
  4149. }
  4150. function isNameChar(c) {
  4151. return c != null && (isNameStart(c) || /[0-9\-\\]/.test(c));
  4152. }
  4153. function isIdentStart(c) {
  4154. return c != null && (isNameStart(c) || /-\\/.test(c));
  4155. }
  4156. function mix(receiver, supplier) {
  4157. for (var prop in supplier) {
  4158. if (Object.prototype.hasOwnProperty.call(supplier, prop)) {
  4159. receiver[prop] = supplier[prop];
  4160. }
  4161. }
  4162. return receiver;
  4163. }
  4164. function wouldStartIdent(twoCodePoints) {
  4165. return typeof twoCodePoints === "string" &&
  4166. (twoCodePoints[0] === "-" && isNameStart(twoCodePoints[1]) || isNameStart(twoCodePoints[0]));
  4167. }
  4168. function wouldStartUnsignedNumber(twoCodePoints) {
  4169. return typeof twoCodePoints === "string" &&
  4170. (isDigit(twoCodePoints[0]) || (twoCodePoints[0] === "." && isDigit(twoCodePoints[1])));
  4171. }
  4172. function TokenStream(input) {
  4173. TokenStreamBase.call(this, input, Tokens);
  4174. }
  4175. TokenStream.prototype = mix(new TokenStreamBase(), {
  4176. _getToken: function() {
  4177. var c,
  4178. reader = this._reader,
  4179. token = null,
  4180. startLine = reader.getLine(),
  4181. startCol = reader.getCol();
  4182. c = reader.read();
  4183. while (c) {
  4184. switch (c) {
  4185. case "/":
  4186. if (reader.peek() === "*") {
  4187. token = this.commentToken(c, startLine, startCol);
  4188. } else {
  4189. token = this.charToken(c, startLine, startCol);
  4190. }
  4191. break;
  4192. case "|":
  4193. case "~":
  4194. case "^":
  4195. case "$":
  4196. case "*":
  4197. if (reader.peek() === "=") {
  4198. token = this.comparisonToken(c, startLine, startCol);
  4199. } else {
  4200. token = this.charToken(c, startLine, startCol);
  4201. }
  4202. break;
  4203. case "\"":
  4204. case "'":
  4205. token = this.stringToken(c, startLine, startCol);
  4206. break;
  4207. case "#":
  4208. if (isNameChar(reader.peek())) {
  4209. token = this.hashToken(c, startLine, startCol);
  4210. } else {
  4211. token = this.charToken(c, startLine, startCol);
  4212. }
  4213. break;
  4214. case ".":
  4215. if (isDigit(reader.peek())) {
  4216. token = this.numberToken(c, startLine, startCol);
  4217. } else {
  4218. token = this.charToken(c, startLine, startCol);
  4219. }
  4220. break;
  4221. case "-":
  4222. if (wouldStartUnsignedNumber(reader.peekCount(2))) {
  4223. token = this.numberToken(c, startLine, startCol);
  4224. break;
  4225. } else if (reader.peekCount(2) === "->") {
  4226. token = this.htmlCommentEndToken(c, startLine, startCol);
  4227. } else {
  4228. token = this._getDefaultToken(c, startLine, startCol);
  4229. }
  4230. break;
  4231. case "+":
  4232. if (wouldStartUnsignedNumber(reader.peekCount(2))) {
  4233. token = this.numberToken(c, startLine, startCol);
  4234. } else {
  4235. token = this.charToken(c, startLine, startCol);
  4236. }
  4237. break;
  4238. case "!":
  4239. token = this.importantToken(c, startLine, startCol);
  4240. break;
  4241. case "@":
  4242. token = this.atRuleToken(c, startLine, startCol);
  4243. break;
  4244. case ":":
  4245. token = this.notToken(c, startLine, startCol);
  4246. break;
  4247. case "<":
  4248. token = this.htmlCommentStartToken(c, startLine, startCol);
  4249. break;
  4250. case "\\":
  4251. if (/[^\r\n\f]/.test(reader.peek())) {
  4252. token = this.identOrFunctionToken(this.readEscape(c, true), startLine, startCol);
  4253. } else {
  4254. token = this.charToken(c, startLine, startCol);
  4255. }
  4256. break;
  4257. case "U":
  4258. case "u":
  4259. if (reader.peek() === "+") {
  4260. token = this.unicodeRangeToken(c, startLine, startCol);
  4261. } else {
  4262. token = this._getDefaultToken(c, startLine, startCol);
  4263. }
  4264. break;
  4265. default:
  4266. token = this._getDefaultToken(c, startLine, startCol);
  4267. }
  4268. break;
  4269. }
  4270. if (!token && c === null) {
  4271. token = this.createToken(Tokens.EOF, null, startLine, startCol);
  4272. }
  4273. return token;
  4274. },
  4275. _getDefaultToken: function(c, startLine, startCol) {
  4276. var reader = this._reader,
  4277. token = null;
  4278. if (isDigit(c)) {
  4279. token = this.numberToken(c, startLine, startCol);
  4280. } else
  4281. if (isWhitespace(c)) {
  4282. token = this.whitespaceToken(c, startLine, startCol);
  4283. } else
  4284. if (wouldStartIdent(c + reader.peekCount(1))) {
  4285. token = this.identOrFunctionToken(c, startLine, startCol);
  4286. } else {
  4287. token = this.charToken(c, startLine, startCol);
  4288. }
  4289. return token;
  4290. },
  4291. createToken: function(tt, value, startLine, startCol, options) {
  4292. var reader = this._reader;
  4293. options = options || {};
  4294. return {
  4295. value: value,
  4296. type: tt,
  4297. channel: options.channel,
  4298. endChar: options.endChar,
  4299. hide: options.hide || false,
  4300. startLine: startLine,
  4301. startCol: startCol,
  4302. endLine: reader.getLine(),
  4303. endCol: reader.getCol()
  4304. };
  4305. },
  4306. atRuleToken: function(first, startLine, startCol) {
  4307. var rule = first,
  4308. reader = this._reader,
  4309. tt = Tokens.CHAR,
  4310. ident;
  4311. reader.mark();
  4312. ident = this.readName();
  4313. rule = first + ident;
  4314. tt = Tokens.type(rule.toLowerCase());
  4315. if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN) {
  4316. if (rule.length > 1) {
  4317. tt = Tokens.UNKNOWN_SYM;
  4318. } else {
  4319. tt = Tokens.CHAR;
  4320. rule = first;
  4321. reader.reset();
  4322. }
  4323. }
  4324. return this.createToken(tt, rule, startLine, startCol);
  4325. },
  4326. charToken: function(c, startLine, startCol) {
  4327. var tt = Tokens.type(c);
  4328. var opts = {};
  4329. if (tt === -1) {
  4330. tt = Tokens.CHAR;
  4331. } else {
  4332. opts.endChar = Tokens[tt].endChar;
  4333. }
  4334. return this.createToken(tt, c, startLine, startCol, opts);
  4335. },
  4336. commentToken: function(first, startLine, startCol) {
  4337. var comment = this.readComment(first);
  4338. return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
  4339. },
  4340. comparisonToken: function(c, startLine, startCol) {
  4341. var reader = this._reader,
  4342. comparison = c + reader.read(),
  4343. tt = Tokens.type(comparison) || Tokens.CHAR;
  4344. return this.createToken(tt, comparison, startLine, startCol);
  4345. },
  4346. hashToken: function(first, startLine, startCol) {
  4347. var name = this.readName(first);
  4348. return this.createToken(Tokens.HASH, name, startLine, startCol);
  4349. },
  4350. htmlCommentStartToken: function(first, startLine, startCol) {
  4351. var reader = this._reader,
  4352. text = first;
  4353. reader.mark();
  4354. text += reader.readCount(3);
  4355. if (text === "<!--") {
  4356. return this.createToken(Tokens.CDO, text, startLine, startCol);
  4357. } else {
  4358. reader.reset();
  4359. return this.charToken(first, startLine, startCol);
  4360. }
  4361. },
  4362. htmlCommentEndToken: function(first, startLine, startCol) {
  4363. var reader = this._reader,
  4364. text = first;
  4365. reader.mark();
  4366. text += reader.readCount(2);
  4367. if (text === "-->") {
  4368. return this.createToken(Tokens.CDC, text, startLine, startCol);
  4369. } else {
  4370. reader.reset();
  4371. return this.charToken(first, startLine, startCol);
  4372. }
  4373. },
  4374. identOrFunctionToken: function(first, startLine, startCol) {
  4375. var reader = this._reader,
  4376. ident = this.readName(first),
  4377. tt = Tokens.IDENT,
  4378. uriFns = ["url(", "url-prefix(", "domain("],
  4379. uri;
  4380. if (reader.peek() === "(") {
  4381. ident += reader.read();
  4382. if (uriFns.indexOf(ident.toLowerCase()) > -1) {
  4383. reader.mark();
  4384. uri = this.readURI(ident);
  4385. if (uri === null) {
  4386. reader.reset();
  4387. tt = Tokens.FUNCTION;
  4388. } else {
  4389. tt = Tokens.URI;
  4390. ident = uri;
  4391. }
  4392. } else {
  4393. tt = Tokens.FUNCTION;
  4394. }
  4395. } else if (reader.peek() === ":") { // might be an IE function
  4396. if (ident.toLowerCase() === "progid") {
  4397. ident += reader.readTo("(");
  4398. tt = Tokens.IE_FUNCTION;
  4399. }
  4400. }
  4401. return this.createToken(tt, ident, startLine, startCol);
  4402. },
  4403. importantToken: function(first, startLine, startCol) {
  4404. var reader = this._reader,
  4405. important = first,
  4406. tt = Tokens.CHAR,
  4407. temp,
  4408. c;
  4409. reader.mark();
  4410. c = reader.read();
  4411. while (c) {
  4412. if (c === "/") {
  4413. if (reader.peek() !== "*") {
  4414. break;
  4415. } else {
  4416. temp = this.readComment(c);
  4417. if (temp === "") { // broken!
  4418. break;
  4419. }
  4420. }
  4421. } else if (isWhitespace(c)) {
  4422. important += c + this.readWhitespace();
  4423. } else if (/i/i.test(c)) {
  4424. temp = reader.readCount(8);
  4425. if (/mportant/i.test(temp)) {
  4426. important += c + temp;
  4427. tt = Tokens.IMPORTANT_SYM;
  4428. }
  4429. break; // we're done
  4430. } else {
  4431. break;
  4432. }
  4433. c = reader.read();
  4434. }
  4435. if (tt === Tokens.CHAR) {
  4436. reader.reset();
  4437. return this.charToken(first, startLine, startCol);
  4438. } else {
  4439. return this.createToken(tt, important, startLine, startCol);
  4440. }
  4441. },
  4442. notToken: function(first, startLine, startCol) {
  4443. var reader = this._reader,
  4444. text = first;
  4445. reader.mark();
  4446. text += reader.readCount(4);
  4447. if (text.toLowerCase() === ":not(") {
  4448. return this.createToken(Tokens.NOT, text, startLine, startCol);
  4449. } else {
  4450. reader.reset();
  4451. return this.charToken(first, startLine, startCol);
  4452. }
  4453. },
  4454. numberToken: function(first, startLine, startCol) {
  4455. var reader = this._reader,
  4456. value = this.readNumber(first),
  4457. ident,
  4458. tt = Tokens.NUMBER,
  4459. c = reader.peek();
  4460. if (isIdentStart(c)) {
  4461. ident = this.readName(reader.read());
  4462. value += ident;
  4463. if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^fr$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)) {
  4464. tt = Tokens.LENGTH;
  4465. } else if (/^deg|^rad$|^grad$|^turn$/i.test(ident)) {
  4466. tt = Tokens.ANGLE;
  4467. } else if (/^ms$|^s$/i.test(ident)) {
  4468. tt = Tokens.TIME;
  4469. } else if (/^hz$|^khz$/i.test(ident)) {
  4470. tt = Tokens.FREQ;
  4471. } else if (/^dpi$|^dpcm$/i.test(ident)) {
  4472. tt = Tokens.RESOLUTION;
  4473. } else {
  4474. tt = Tokens.DIMENSION;
  4475. }
  4476. } else if (c === "%") {
  4477. value += reader.read();
  4478. tt = Tokens.PERCENTAGE;
  4479. }
  4480. return this.createToken(tt, value, startLine, startCol);
  4481. },
  4482. stringToken: function(first, startLine, startCol) {
  4483. var delim = first,
  4484. string = first,
  4485. reader = this._reader,
  4486. tt = Tokens.STRING,
  4487. c = reader.read(),
  4488. i;
  4489. while (c) {
  4490. string += c;
  4491. if (c === "\\") {
  4492. c = reader.read();
  4493. if (c === null) {
  4494. break; // premature EOF after backslash
  4495. } else if (/[^\r\n\f0-9a-f]/i.test(c)) {
  4496. string += c;
  4497. } else {
  4498. for (i = 0; isHexDigit(c) && i < 6; i++) {
  4499. string += c;
  4500. c = reader.read();
  4501. }
  4502. if (c === "\r" && reader.peek() === "\n") {
  4503. string += c;
  4504. c = reader.read();
  4505. }
  4506. if (isWhitespace(c)) {
  4507. string += c;
  4508. } else {
  4509. continue;
  4510. }
  4511. }
  4512. } else if (c === delim) {
  4513. break; // delimiter found.
  4514. } else if (isNewLine(reader.peek())) {
  4515. tt = Tokens.INVALID;
  4516. break;
  4517. }
  4518. c = reader.read();
  4519. }
  4520. if (c === null) {
  4521. tt = Tokens.INVALID;
  4522. }
  4523. return this.createToken(tt, string, startLine, startCol);
  4524. },
  4525. unicodeRangeToken: function(first, startLine, startCol) {
  4526. var reader = this._reader,
  4527. value = first,
  4528. temp,
  4529. tt = Tokens.CHAR;
  4530. if (reader.peek() === "+") {
  4531. reader.mark();
  4532. value += reader.read();
  4533. value += this.readUnicodeRangePart(true);
  4534. if (value.length === 2) {
  4535. reader.reset();
  4536. } else {
  4537. tt = Tokens.UNICODE_RANGE;
  4538. if (value.indexOf("?") === -1) {
  4539. if (reader.peek() === "-") {
  4540. reader.mark();
  4541. temp = reader.read();
  4542. temp += this.readUnicodeRangePart(false);
  4543. if (temp.length === 1) {
  4544. reader.reset();
  4545. } else {
  4546. value += temp;
  4547. }
  4548. }
  4549. }
  4550. }
  4551. }
  4552. return this.createToken(tt, value, startLine, startCol);
  4553. },
  4554. whitespaceToken: function(first, startLine, startCol) {
  4555. var value = first + this.readWhitespace();
  4556. return this.createToken(Tokens.S, value, startLine, startCol);
  4557. },
  4558. readUnicodeRangePart: function(allowQuestionMark) {
  4559. var reader = this._reader,
  4560. part = "",
  4561. c = reader.peek();
  4562. while (isHexDigit(c) && part.length < 6) {
  4563. reader.read();
  4564. part += c;
  4565. c = reader.peek();
  4566. }
  4567. if (allowQuestionMark) {
  4568. while (c === "?" && part.length < 6) {
  4569. reader.read();
  4570. part += c;
  4571. c = reader.peek();
  4572. }
  4573. }
  4574. return part;
  4575. },
  4576. readWhitespace: function() {
  4577. var reader = this._reader,
  4578. whitespace = "",
  4579. c = reader.peek();
  4580. while (isWhitespace(c)) {
  4581. reader.read();
  4582. whitespace += c;
  4583. c = reader.peek();
  4584. }
  4585. return whitespace;
  4586. },
  4587. readNumber: function(first) {
  4588. var reader = this._reader,
  4589. number = first,
  4590. hasDot = first === ".",
  4591. c = reader.peek();
  4592. while (c) {
  4593. if (isDigit(c)) {
  4594. number += reader.read();
  4595. } else if (c === ".") {
  4596. if (hasDot) {
  4597. break;
  4598. } else {
  4599. hasDot = true;
  4600. number += reader.read();
  4601. }
  4602. } else {
  4603. break;
  4604. }
  4605. c = reader.peek();
  4606. }
  4607. return number;
  4608. },
  4609. readString: function() {
  4610. var token = this.stringToken(this._reader.read(), 0, 0);
  4611. return token.type === Tokens.INVALID ? null : token.value;
  4612. },
  4613. readURI: function(first) {
  4614. var reader = this._reader,
  4615. uri = first,
  4616. inner = "",
  4617. c = reader.peek();
  4618. while (c && isWhitespace(c)) {
  4619. reader.read();
  4620. c = reader.peek();
  4621. }
  4622. if (c === "'" || c === "\"") {
  4623. inner = this.readString();
  4624. if (inner !== null) {
  4625. inner = PropertyValuePart.parseString(inner);
  4626. }
  4627. } else {
  4628. inner = this.readUnquotedURL();
  4629. }
  4630. c = reader.peek();
  4631. while (c && isWhitespace(c)) {
  4632. reader.read();
  4633. c = reader.peek();
  4634. }
  4635. if (inner === null || c !== ")") {
  4636. uri = null;
  4637. } else {
  4638. uri += PropertyValuePart.serializeString(inner) + reader.read();
  4639. }
  4640. return uri;
  4641. },
  4642. readUnquotedURL: function(first) {
  4643. var reader = this._reader,
  4644. url = first || "",
  4645. c;
  4646. for (c = reader.peek(); c; c = reader.peek()) {
  4647. if (nonascii.test(c) || /^[-!#$%&*-[\]-~]$/.test(c)) {
  4648. url += c;
  4649. reader.read();
  4650. } else if (c === "\\") {
  4651. if (/^[^\r\n\f]$/.test(reader.peek(2))) {
  4652. url += this.readEscape(reader.read(), true);
  4653. } else {
  4654. break; // bad escape sequence.
  4655. }
  4656. } else {
  4657. break; // bad character
  4658. }
  4659. }
  4660. return url;
  4661. },
  4662. readName: function(first) {
  4663. var reader = this._reader,
  4664. ident = first || "",
  4665. c;
  4666. for (c = reader.peek(); c; c = reader.peek()) {
  4667. if (c === "\\") {
  4668. if (/^[^\r\n\f]$/.test(reader.peek(2))) {
  4669. ident += this.readEscape(reader.read(), true);
  4670. } else {
  4671. break;
  4672. }
  4673. } else if (isNameChar(c)) {
  4674. ident += reader.read();
  4675. } else {
  4676. break;
  4677. }
  4678. }
  4679. return ident;
  4680. },
  4681. readEscape: function(first, unescape) {
  4682. var reader = this._reader,
  4683. cssEscape = first || "",
  4684. i = 0,
  4685. c = reader.peek();
  4686. if (isHexDigit(c)) {
  4687. do {
  4688. cssEscape += reader.read();
  4689. c = reader.peek();
  4690. } while (c && isHexDigit(c) && ++i < 6);
  4691. }
  4692. if (cssEscape.length === 1) {
  4693. if (/^[^\r\n\f0-9a-f]$/.test(c)) {
  4694. reader.read();
  4695. if (unescape) {
  4696. return c;
  4697. }
  4698. } else {
  4699. throw new Error("Bad escape sequence.");
  4700. }
  4701. } else if (c === "\r") {
  4702. reader.read();
  4703. if (reader.peek() === "\n") {
  4704. c += reader.read();
  4705. }
  4706. } else if (/^[ \t\n\f]$/.test(c)) {
  4707. reader.read();
  4708. } else {
  4709. c = "";
  4710. }
  4711. if (unescape) {
  4712. var cp = parseInt(cssEscape.slice(first.length), 16);
  4713. return String.fromCodePoint ? String.fromCodePoint(cp) :
  4714. String.fromCharCode(cp);
  4715. }
  4716. return cssEscape + c;
  4717. },
  4718. readComment: function(first) {
  4719. var reader = this._reader,
  4720. comment = first || "",
  4721. c = reader.read();
  4722. if (c === "*") {
  4723. while (c) {
  4724. comment += c;
  4725. if (comment.length > 2 && c === "*" && reader.peek() === "/") {
  4726. comment += reader.read();
  4727. break;
  4728. }
  4729. c = reader.read();
  4730. }
  4731. return comment;
  4732. } else {
  4733. return "";
  4734. }
  4735. }
  4736. });
  4737. },{"../util/TokenStreamBase":27,"./PropertyValuePart":11,"./Tokens":18}],18:[function(require,module,exports){
  4738. "use strict";
  4739. var Tokens = module.exports = [
  4740. { name: "CDO" },
  4741. { name: "CDC" },
  4742. { name: "S", whitespace: true/*, channel: "ws"*/ },
  4743. { name: "COMMENT", comment: true, hide: true, channel: "comment" },
  4744. { name: "INCLUDES", text: "~=" },
  4745. { name: "DASHMATCH", text: "|=" },
  4746. { name: "PREFIXMATCH", text: "^=" },
  4747. { name: "SUFFIXMATCH", text: "$=" },
  4748. { name: "SUBSTRINGMATCH", text: "*=" },
  4749. { name: "STRING" },
  4750. { name: "IDENT" },
  4751. { name: "HASH" },
  4752. { name: "IMPORT_SYM", text: "@import" },
  4753. { name: "PAGE_SYM", text: "@page" },
  4754. { name: "MEDIA_SYM", text: "@media" },
  4755. { name: "FONT_FACE_SYM", text: "@font-face" },
  4756. { name: "CHARSET_SYM", text: "@charset" },
  4757. { name: "NAMESPACE_SYM", text: "@namespace" },
  4758. { name: "SUPPORTS_SYM", text: "@supports" },
  4759. { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"] },
  4760. { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"] },
  4761. { name: "UNKNOWN_SYM" },
  4762. { name: "KEYFRAMES_SYM", text: [ "@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes" ] },
  4763. { name: "IMPORTANT_SYM" },
  4764. { name: "LENGTH" },
  4765. { name: "ANGLE" },
  4766. { name: "TIME" },
  4767. { name: "FREQ" },
  4768. { name: "DIMENSION" },
  4769. { name: "PERCENTAGE" },
  4770. { name: "NUMBER" },
  4771. { name: "URI" },
  4772. { name: "FUNCTION" },
  4773. { name: "UNICODE_RANGE" },
  4774. { name: "INVALID" },
  4775. { name: "PLUS", text: "+" },
  4776. { name: "GREATER", text: ">" },
  4777. { name: "COMMA", text: "," },
  4778. { name: "TILDE", text: "~" },
  4779. { name: "NOT" },
  4780. { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner" },
  4781. { name: "TOPLEFT_SYM", text: "@top-left" },
  4782. { name: "TOPCENTER_SYM", text: "@top-center" },
  4783. { name: "TOPRIGHT_SYM", text: "@top-right" },
  4784. { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner" },
  4785. { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner" },
  4786. { name: "BOTTOMLEFT_SYM", text: "@bottom-left" },
  4787. { name: "BOTTOMCENTER_SYM", text: "@bottom-center" },
  4788. { name: "BOTTOMRIGHT_SYM", text: "@bottom-right" },
  4789. { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner" },
  4790. { name: "LEFTTOP_SYM", text: "@left-top" },
  4791. { name: "LEFTMIDDLE_SYM", text: "@left-middle" },
  4792. { name: "LEFTBOTTOM_SYM", text: "@left-bottom" },
  4793. { name: "RIGHTTOP_SYM", text: "@right-top" },
  4794. { name: "RIGHTMIDDLE_SYM", text: "@right-middle" },
  4795. { name: "RIGHTBOTTOM_SYM", text: "@right-bottom" },
  4796. { name: "RESOLUTION", state: "media" },
  4797. { name: "IE_FUNCTION" },
  4798. { name: "CHAR" },
  4799. {
  4800. name: "PIPE",
  4801. text: "|"
  4802. },
  4803. {
  4804. name: "SLASH",
  4805. text: "/"
  4806. },
  4807. {
  4808. name: "MINUS",
  4809. text: "-"
  4810. },
  4811. {
  4812. name: "STAR",
  4813. text: "*"
  4814. },
  4815. {
  4816. name: "LBRACE",
  4817. endChar: "}",
  4818. text: "{"
  4819. },
  4820. {
  4821. name: "RBRACE",
  4822. text: "}"
  4823. },
  4824. {
  4825. name: "LBRACKET",
  4826. endChar: "]",
  4827. text: "["
  4828. },
  4829. {
  4830. name: "RBRACKET",
  4831. text: "]"
  4832. },
  4833. {
  4834. name: "EQUALS",
  4835. text: "="
  4836. },
  4837. {
  4838. name: "COLON",
  4839. text: ":"
  4840. },
  4841. {
  4842. name: "SEMICOLON",
  4843. text: ";"
  4844. },
  4845. {
  4846. name: "LPAREN",
  4847. endChar: ")",
  4848. text: "("
  4849. },
  4850. {
  4851. name: "RPAREN",
  4852. text: ")"
  4853. },
  4854. {
  4855. name: "DOT",
  4856. text: "."
  4857. }
  4858. ];
  4859. (function() {
  4860. var nameMap = [],
  4861. typeMap = Object.create(null);
  4862. Tokens.UNKNOWN = -1;
  4863. Tokens.unshift({ name:"EOF" });
  4864. for (var i = 0, len = Tokens.length; i < len; i++) {
  4865. nameMap.push(Tokens[i].name);
  4866. Tokens[Tokens[i].name] = i;
  4867. if (Tokens[i].text) {
  4868. if (Tokens[i].text instanceof Array) {
  4869. for (var j = 0; j < Tokens[i].text.length; j++) {
  4870. typeMap[Tokens[i].text[j]] = i;
  4871. }
  4872. } else {
  4873. typeMap[Tokens[i].text] = i;
  4874. }
  4875. }
  4876. }
  4877. Tokens.name = function(tt) {
  4878. return nameMap[tt];
  4879. };
  4880. Tokens.type = function(c) {
  4881. return typeMap[c] || -1;
  4882. };
  4883. })();
  4884. },{}],19:[function(require,module,exports){
  4885. "use strict";
  4886. var Matcher = require("./Matcher");
  4887. var Properties = require("./Properties");
  4888. var ValidationTypes = require("./ValidationTypes");
  4889. var ValidationError = require("./ValidationError");
  4890. var PropertyValueIterator = require("./PropertyValueIterator");
  4891. var Validation = module.exports = {
  4892. validate: function(property, value) {
  4893. var name = property.toString().toLowerCase(),
  4894. expression = new PropertyValueIterator(value),
  4895. spec = Properties[name],
  4896. part;
  4897. if (!spec) {
  4898. if (name.indexOf("-") !== 0) { // vendor prefixed are ok
  4899. throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
  4900. }
  4901. } else if (typeof spec !== "number") {
  4902. if (ValidationTypes.isAny(expression, "inherit | initial | unset")) {
  4903. if (expression.hasNext()) {
  4904. part = expression.next();
  4905. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4906. }
  4907. return;
  4908. }
  4909. this.singleProperty(spec, expression);
  4910. }
  4911. },
  4912. singleProperty: function(types, expression) {
  4913. var result = false,
  4914. value = expression.value,
  4915. part;
  4916. result = Matcher.parse(types).match(expression);
  4917. if (!result) {
  4918. if (expression.hasNext() && !expression.isFirst()) {
  4919. part = expression.peek();
  4920. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4921. } else {
  4922. throw new ValidationError("Expected (" + ValidationTypes.describe(types) + ") but found '" + value + "'.", value.line, value.col);
  4923. }
  4924. } else if (expression.hasNext()) {
  4925. part = expression.next();
  4926. throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
  4927. }
  4928. }
  4929. };
  4930. },{"./Matcher":3,"./Properties":7,"./PropertyValueIterator":10,"./ValidationError":20,"./ValidationTypes":21}],20:[function(require,module,exports){
  4931. "use strict";
  4932. module.exports = ValidationError;
  4933. function ValidationError(message, line, col) {
  4934. this.col = col;
  4935. this.line = line;
  4936. this.message = message;
  4937. }
  4938. ValidationError.prototype = new Error();
  4939. },{}],21:[function(require,module,exports){
  4940. "use strict";
  4941. var ValidationTypes = module.exports;
  4942. var Matcher = require("./Matcher");
  4943. function copy(to, from) {
  4944. Object.keys(from).forEach(function(prop) {
  4945. to[prop] = from[prop];
  4946. });
  4947. }
  4948. copy(ValidationTypes, {
  4949. isLiteral: function (part, literals) {
  4950. var text = part.text.toString().toLowerCase(),
  4951. args = literals.split(" | "),
  4952. i,
  4953. len,
  4954. found = false;
  4955. for (i = 0, len = args.length; i < len && !found; i++) {
  4956. if (args[i].charAt(0) === "<") {
  4957. found = this.simple[args[i]](part);
  4958. } else if (args[i].slice(-2) === "()") {
  4959. found = (part.type === "function" &&
  4960. part.name === args[i].slice(0, -2));
  4961. } else if (text === args[i].toLowerCase()) {
  4962. found = true;
  4963. }
  4964. }
  4965. return found;
  4966. },
  4967. isSimple: function(type) {
  4968. return Boolean(this.simple[type]);
  4969. },
  4970. isComplex: function(type) {
  4971. return Boolean(this.complex[type]);
  4972. },
  4973. describe: function(type) {
  4974. if (this.complex[type] instanceof Matcher) {
  4975. return this.complex[type].toString(0);
  4976. }
  4977. return type;
  4978. },
  4979. isAny: function (expression, types) {
  4980. var args = types.split(" | "),
  4981. i,
  4982. len,
  4983. found = false;
  4984. for (i = 0, len = args.length; i < len && !found && expression.hasNext(); i++) {
  4985. found = this.isType(expression, args[i]);
  4986. }
  4987. return found;
  4988. },
  4989. isAnyOfGroup: function(expression, types) {
  4990. var args = types.split(" || "),
  4991. i,
  4992. len,
  4993. found = false;
  4994. for (i = 0, len = args.length; i < len && !found; i++) {
  4995. found = this.isType(expression, args[i]);
  4996. }
  4997. return found ? args[i - 1] : false;
  4998. },
  4999. isType: function (expression, type) {
  5000. var part = expression.peek(),
  5001. result = false;
  5002. if (type.charAt(0) !== "<") {
  5003. result = this.isLiteral(part, type);
  5004. if (result) {
  5005. expression.next();
  5006. }
  5007. } else if (this.simple[type]) {
  5008. result = this.simple[type](part);
  5009. if (result) {
  5010. expression.next();
  5011. }
  5012. } else if (this.complex[type] instanceof Matcher) {
  5013. result = this.complex[type].match(expression);
  5014. } else {
  5015. result = this.complex[type](expression);
  5016. }
  5017. return result;
  5018. },
  5019. simple: {
  5020. __proto__: null,
  5021. "<absolute-size>":
  5022. "xx-small | x-small | small | medium | large | x-large | xx-large",
  5023. "<animateable-feature>":
  5024. "scroll-position | contents | <animateable-feature-name>",
  5025. "<animateable-feature-name>": function(part) {
  5026. return this["<ident>"](part) &&
  5027. !/^(unset|initial|inherit|will-change|auto|scroll-position|contents)$/i.test(part);
  5028. },
  5029. "<angle>": function(part) {
  5030. return part.type === "angle";
  5031. },
  5032. "<attachment>": "scroll | fixed | local",
  5033. "<attr>": "attr()",
  5034. "<basic-shape>": "inset() | circle() | ellipse() | polygon()",
  5035. "<bg-image>": "<image> | <gradient> | none",
  5036. "<border-style>":
  5037. "none | hidden | dotted | dashed | solid | double | groove | " +
  5038. "ridge | inset | outset",
  5039. "<border-width>": "<length> | thin | medium | thick",
  5040. "<box>": "padding-box | border-box | content-box",
  5041. "<clip-source>": "<uri>",
  5042. "<color>": function(part) {
  5043. return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
  5044. },
  5045. "<color-svg>": function(part) {
  5046. return part.type === "color";
  5047. },
  5048. "<content>": "content()",
  5049. "<content-sizing>":
  5050. "fill-available | -moz-available | -webkit-fill-available | " +
  5051. "max-content | -moz-max-content | -webkit-max-content | " +
  5052. "min-content | -moz-min-content | -webkit-min-content | " +
  5053. "fit-content | -moz-fit-content | -webkit-fit-content",
  5054. "<feature-tag-value>": function(part) {
  5055. return part.type === "function" && /^[A-Z0-9]{4}$/i.test(part);
  5056. },
  5057. "<filter-function>":
  5058. "blur() | brightness() | contrast() | custom() | " +
  5059. "drop-shadow() | grayscale() | hue-rotate() | invert() | " +
  5060. "opacity() | saturate() | sepia()",
  5061. "<flex-basis>": "<width>",
  5062. "<flex-direction>": "row | row-reverse | column | column-reverse",
  5063. "<flex-grow>": "<number>",
  5064. "<flex-shrink>": "<number>",
  5065. "<flex-wrap>": "nowrap | wrap | wrap-reverse",
  5066. "<font-size>":
  5067. "<absolute-size> | <relative-size> | <length> | <percentage>",
  5068. "<font-stretch>":
  5069. "normal | ultra-condensed | extra-condensed | condensed | " +
  5070. "semi-condensed | semi-expanded | expanded | extra-expanded | " +
  5071. "ultra-expanded",
  5072. "<font-style>": "normal | italic | oblique",
  5073. "<font-variant-caps>":
  5074. "small-caps | all-small-caps | petite-caps | all-petite-caps | " +
  5075. "unicase | titling-caps",
  5076. "<font-variant-css21>": "normal | small-caps",
  5077. "<font-weight>":
  5078. "normal | bold | bolder | lighter | " +
  5079. "100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900",
  5080. "<generic-family>":
  5081. "serif | sans-serif | cursive | fantasy | monospace",
  5082. "<geometry-box>": "<shape-box> | fill-box | stroke-box | view-box",
  5083. "<glyph-angle>": function(part) {
  5084. return part.type === "angle" && part.units === "deg";
  5085. },
  5086. "<gradient>": function(part) {
  5087. return part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?(?:repeating-)?(?:radial-|linear-)?gradient/i.test(part);
  5088. },
  5089. "<icccolor>":
  5090. "cielab() | cielch() | cielchab() | " +
  5091. "icc-color() | icc-named-color()",
  5092. "<ident>": function(part) {
  5093. return part.type === "identifier" || part.wasIdent;
  5094. },
  5095. "<ident-not-generic-family>": function(part) {
  5096. return this["<ident>"](part) && !this["<generic-family>"](part);
  5097. },
  5098. "<image>": "<uri>",
  5099. "<integer>": function(part) {
  5100. return part.type === "integer";
  5101. },
  5102. "<length>": function(part) {
  5103. if (part.type === "function" && /^(?:-(?:ms|moz|o|webkit)-)?calc/i.test(part)) {
  5104. return true;
  5105. } else {
  5106. return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
  5107. }
  5108. },
  5109. "<line>": function(part) {
  5110. return part.type === "integer";
  5111. },
  5112. "<line-height>": "<number> | <length> | <percentage> | normal",
  5113. "<margin-width>": "<length> | <percentage> | auto",
  5114. "<miterlimit>": function(part) {
  5115. return this["<number>"](part) && part.value >= 1;
  5116. },
  5117. "<nonnegative-length-or-percentage>": function(part) {
  5118. return (this["<length>"](part) || this["<percentage>"](part)) &&
  5119. (String(part) === "0" || part.type === "function" || (part.value) >= 0);
  5120. },
  5121. "<nonnegative-number-or-percentage>": function(part) {
  5122. return (this["<number>"](part) || this["<percentage>"](part)) &&
  5123. (String(part) === "0" || part.type === "function" || (part.value) >= 0);
  5124. },
  5125. "<number>": function(part) {
  5126. return part.type === "number" || this["<integer>"](part);
  5127. },
  5128. "<opacity-value>": function(part) {
  5129. return this["<number>"](part) && part.value >= 0 && part.value <= 1;
  5130. },
  5131. "<padding-width>": "<nonnegative-length-or-percentage>",
  5132. "<percentage>": function(part) {
  5133. return part.type === "percentage" || String(part) === "0";
  5134. },
  5135. "<relative-size>": "smaller | larger",
  5136. "<shape>": "rect() | inset-rect()",
  5137. "<shape-box>": "<box> | margin-box",
  5138. "<single-animation-direction>":
  5139. "normal | reverse | alternate | alternate-reverse",
  5140. "<single-animation-name>": function(part) {
  5141. return this["<ident>"](part) &&
  5142. /^-?[a-z_][-a-z0-9_]+$/i.test(part) &&
  5143. !/^(none|unset|initial|inherit)$/i.test(part);
  5144. },
  5145. "<string>": function(part) {
  5146. return part.type === "string";
  5147. },
  5148. "<time>": function(part) {
  5149. return part.type === "time";
  5150. },
  5151. "<uri>": function(part) {
  5152. return part.type === "uri";
  5153. },
  5154. "<width>": "<margin-width>"
  5155. },
  5156. complex: {
  5157. __proto__: null,
  5158. "<azimuth>":
  5159. "<angle>" +
  5160. " | " +
  5161. "[ [ left-side | far-left | left | center-left | center | " +
  5162. "center-right | right | far-right | right-side ] || behind ]" +
  5163. " | " +
  5164. "leftwards | rightwards",
  5165. "<bg-position>": "<position>#",
  5166. "<bg-size>":
  5167. "[ <length> | <percentage> | auto ]{1,2} | cover | contain",
  5168. "<blend-mode>":
  5169. "normal | multiply | screen | overlay | darken | lighten | color-dodge | " +
  5170. "color-burn | hard-light | soft-light | difference | exclusion | hue | " +
  5171. "saturation | color | luminosity",
  5172. "<border-image-slice>":
  5173. Matcher.many([true /* first element is required */],
  5174. Matcher.cast("<nonnegative-number-or-percentage>"),
  5175. Matcher.cast("<nonnegative-number-or-percentage>"),
  5176. Matcher.cast("<nonnegative-number-or-percentage>"),
  5177. Matcher.cast("<nonnegative-number-or-percentage>"),
  5178. "fill"),
  5179. "<border-radius>":
  5180. "<nonnegative-length-or-percentage>{1,4} " +
  5181. "[ / <nonnegative-length-or-percentage>{1,4} ]?",
  5182. "<box-shadow>": "none | <shadow>#",
  5183. "<clip-path>": "<basic-shape> || <geometry-box>",
  5184. "<dasharray>":
  5185. Matcher.cast("<nonnegative-length-or-percentage>")
  5186. .braces(1, Infinity, "#", Matcher.cast(",").question()),
  5187. "<family-name>":
  5188. "<string> | <ident-not-generic-family> <ident>*",
  5189. "<filter-function-list>": "[ <filter-function> | <uri> ]+",
  5190. "<flex>":
  5191. "none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]",
  5192. "<font-family>": "[ <generic-family> | <family-name> ]#",
  5193. "<font-shorthand>":
  5194. "[ <font-style> || <font-variant-css21> || " +
  5195. "<font-weight> || <font-stretch> ]? <font-size> " +
  5196. "[ / <line-height> ]? <font-family>",
  5197. "<font-variant-alternates>":
  5198. "stylistic() || " +
  5199. "historical-forms || " +
  5200. "styleset() || " +
  5201. "character-variant() || " +
  5202. "swash() || " +
  5203. "ornaments() || " +
  5204. "annotation()",
  5205. "<font-variant-ligatures>":
  5206. "[ common-ligatures | no-common-ligatures ] || " +
  5207. "[ discretionary-ligatures | no-discretionary-ligatures ] || " +
  5208. "[ historical-ligatures | no-historical-ligatures ] || " +
  5209. "[ contextual | no-contextual ]",
  5210. "<font-variant-numeric>":
  5211. "[ lining-nums | oldstyle-nums ] || " +
  5212. "[ proportional-nums | tabular-nums ] || " +
  5213. "[ diagonal-fractions | stacked-fractions ] || " +
  5214. "ordinal || slashed-zero",
  5215. "<font-variant-east-asian>":
  5216. "[ jis78 | jis83 | jis90 | jis04 | simplified | traditional ] || " +
  5217. "[ full-width | proportional-width ] || " +
  5218. "ruby",
  5219. "<paint>": "<paint-basic> | <uri> <paint-basic>?",
  5220. "<paint-basic>": "none | currentColor | <color-svg> <icccolor>?",
  5221. "<position>":
  5222. "[ center | [ left | right ] [ <percentage> | <length> ]? ] && " +
  5223. "[ center | [ top | bottom ] [ <percentage> | <length> ]? ]" +
  5224. " | " +
  5225. "[ left | center | right | <percentage> | <length> ] " +
  5226. "[ top | center | bottom | <percentage> | <length> ]" +
  5227. " | " +
  5228. "[ left | center | right | top | bottom | <percentage> | <length> ]",
  5229. "<repeat-style>":
  5230. "repeat-x | repeat-y | [ repeat | space | round | no-repeat ]{1,2}",
  5231. "<shadow>":
  5232. Matcher.many([true /* length is required */],
  5233. Matcher.cast("<length>").braces(2, 4), "inset", "<color>"),
  5234. "<text-decoration-color>":
  5235. "<color>",
  5236. "<text-decoration-line>":
  5237. "none | [ underline || overline || line-through || blink ]",
  5238. "<text-decoration-style>":
  5239. "solid | double | dotted | dashed | wavy",
  5240. "<will-change>":
  5241. "auto | <animateable-feature>#",
  5242. "<x-one-radius>":
  5243. "[ <length> | <percentage> ]{1,2}"
  5244. }
  5245. });
  5246. Object.keys(ValidationTypes.simple).forEach(function(nt) {
  5247. var rule = ValidationTypes.simple[nt];
  5248. if (typeof rule === "string") {
  5249. ValidationTypes.simple[nt] = function(part) {
  5250. return ValidationTypes.isLiteral(part, rule);
  5251. };
  5252. }
  5253. });
  5254. Object.keys(ValidationTypes.complex).forEach(function(nt) {
  5255. var rule = ValidationTypes.complex[nt];
  5256. if (typeof rule === "string") {
  5257. ValidationTypes.complex[nt] = Matcher.parse(rule);
  5258. }
  5259. });
  5260. ValidationTypes.complex["<font-variant>"] =
  5261. Matcher.oror({ expand: "<font-variant-ligatures>" },
  5262. { expand: "<font-variant-alternates>" },
  5263. "<font-variant-caps>",
  5264. { expand: "<font-variant-numeric>" },
  5265. { expand: "<font-variant-east-asian>" });
  5266. },{"./Matcher":3}],22:[function(require,module,exports){
  5267. "use strict";
  5268. module.exports = {
  5269. Colors : require("./Colors"),
  5270. Combinator : require("./Combinator"),
  5271. Parser : require("./Parser"),
  5272. PropertyName : require("./PropertyName"),
  5273. PropertyValue : require("./PropertyValue"),
  5274. PropertyValuePart : require("./PropertyValuePart"),
  5275. Matcher : require("./Matcher"),
  5276. MediaFeature : require("./MediaFeature"),
  5277. MediaQuery : require("./MediaQuery"),
  5278. Selector : require("./Selector"),
  5279. SelectorPart : require("./SelectorPart"),
  5280. SelectorSubPart : require("./SelectorSubPart"),
  5281. Specificity : require("./Specificity"),
  5282. TokenStream : require("./TokenStream"),
  5283. Tokens : require("./Tokens"),
  5284. ValidationError : require("./ValidationError")
  5285. };
  5286. },{"./Colors":1,"./Combinator":2,"./Matcher":3,"./MediaFeature":4,"./MediaQuery":5,"./Parser":6,"./PropertyName":8,"./PropertyValue":9,"./PropertyValuePart":11,"./Selector":13,"./SelectorPart":14,"./SelectorSubPart":15,"./Specificity":16,"./TokenStream":17,"./Tokens":18,"./ValidationError":20}],23:[function(require,module,exports){
  5287. "use strict";
  5288. module.exports = EventTarget;
  5289. function EventTarget() {
  5290. this._listeners = Object.create(null);
  5291. }
  5292. EventTarget.prototype = {
  5293. constructor: EventTarget,
  5294. addListener: function(type, listener) {
  5295. if (!this._listeners[type]) {
  5296. this._listeners[type] = [];
  5297. }
  5298. this._listeners[type].push(listener);
  5299. },
  5300. fire: function(event) {
  5301. if (typeof event === "string") {
  5302. event = { type: event };
  5303. }
  5304. if (typeof event.target !== "undefined") {
  5305. event.target = this;
  5306. }
  5307. if (typeof event.type === "undefined") {
  5308. throw new Error("Event object missing 'type' property.");
  5309. }
  5310. if (this._listeners[event.type]) {
  5311. var listeners = this._listeners[event.type].concat();
  5312. for (var i = 0, len = listeners.length; i < len; i++) {
  5313. listeners[i].call(this, event);
  5314. }
  5315. }
  5316. },
  5317. removeListener: function(type, listener) {
  5318. if (this._listeners[type]) {
  5319. var listeners = this._listeners[type];
  5320. for (var i = 0, len = listeners.length; i < len; i++) {
  5321. if (listeners[i] === listener) {
  5322. listeners.splice(i, 1);
  5323. break;
  5324. }
  5325. }
  5326. }
  5327. }
  5328. };
  5329. },{}],24:[function(require,module,exports){
  5330. "use strict";
  5331. module.exports = StringReader;
  5332. function StringReader(text) {
  5333. this._input = text.replace(/(\r\n?|\n)/g, "\n");
  5334. this._line = 1;
  5335. this._col = 1;
  5336. this._cursor = 0;
  5337. }
  5338. StringReader.prototype = {
  5339. constructor: StringReader,
  5340. getCol: function() {
  5341. return this._col;
  5342. },
  5343. getLine: function() {
  5344. return this._line;
  5345. },
  5346. eof: function() {
  5347. return this._cursor === this._input.length;
  5348. },
  5349. peek: function(count) {
  5350. var c = null;
  5351. count = typeof count === "undefined" ? 1 : count;
  5352. if (this._cursor < this._input.length) {
  5353. c = this._input.charAt(this._cursor + count - 1);
  5354. }
  5355. return c;
  5356. },
  5357. read: function() {
  5358. var c = null;
  5359. if (this._cursor < this._input.length) {
  5360. if (this._input.charAt(this._cursor) === "\n") {
  5361. this._line++;
  5362. this._col = 1;
  5363. } else {
  5364. this._col++;
  5365. }
  5366. c = this._input.charAt(this._cursor++);
  5367. }
  5368. return c;
  5369. },
  5370. mark: function() {
  5371. this._bookmark = {
  5372. cursor: this._cursor,
  5373. line: this._line,
  5374. col: this._col
  5375. };
  5376. },
  5377. reset: function() {
  5378. if (this._bookmark) {
  5379. this._cursor = this._bookmark.cursor;
  5380. this._line = this._bookmark.line;
  5381. this._col = this._bookmark.col;
  5382. delete this._bookmark;
  5383. }
  5384. },
  5385. peekCount: function(count) {
  5386. count = typeof count === "undefined" ? 1 : Math.max(count, 0);
  5387. return this._input.substring(this._cursor, this._cursor + count);
  5388. },
  5389. readTo: function(pattern) {
  5390. var buffer = "",
  5391. c;
  5392. while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length) {
  5393. c = this.read();
  5394. if (c) {
  5395. buffer += c;
  5396. } else {
  5397. throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + ".");
  5398. }
  5399. }
  5400. return buffer;
  5401. },
  5402. readWhile: function(filter) {
  5403. var buffer = "",
  5404. c = this.peek();
  5405. while (c !== null && filter(c)) {
  5406. buffer += this.read();
  5407. c = this.peek();
  5408. }
  5409. return buffer;
  5410. },
  5411. readMatch: function(matcher) {
  5412. var source = this._input.substring(this._cursor),
  5413. value = null;
  5414. if (typeof matcher === "string") {
  5415. if (source.slice(0, matcher.length) === matcher) {
  5416. value = this.readCount(matcher.length);
  5417. }
  5418. } else if (matcher instanceof RegExp) {
  5419. if (matcher.test(source)) {
  5420. value = this.readCount(RegExp.lastMatch.length);
  5421. }
  5422. }
  5423. return value;
  5424. },
  5425. readCount: function(count) {
  5426. var buffer = "";
  5427. while (count--) {
  5428. buffer += this.read();
  5429. }
  5430. return buffer;
  5431. }
  5432. };
  5433. },{}],25:[function(require,module,exports){
  5434. "use strict";
  5435. module.exports = SyntaxError;
  5436. function SyntaxError(message, line, col) {
  5437. Error.call(this);
  5438. this.name = this.constructor.name;
  5439. this.col = col;
  5440. this.line = line;
  5441. this.message = message;
  5442. }
  5443. SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
  5444. SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line
  5445. },{}],26:[function(require,module,exports){
  5446. "use strict";
  5447. module.exports = SyntaxUnit;
  5448. function SyntaxUnit(text, line, col, type) {
  5449. this.col = col;
  5450. this.line = line;
  5451. this.text = text;
  5452. this.type = type;
  5453. }
  5454. SyntaxUnit.fromToken = function(token) {
  5455. return new SyntaxUnit(token.value, token.startLine, token.startCol);
  5456. };
  5457. SyntaxUnit.prototype = {
  5458. constructor: SyntaxUnit,
  5459. valueOf: function() {
  5460. return this.toString();
  5461. },
  5462. toString: function() {
  5463. return this.text;
  5464. }
  5465. };
  5466. },{}],27:[function(require,module,exports){
  5467. "use strict";
  5468. module.exports = TokenStreamBase;
  5469. var StringReader = require("./StringReader");
  5470. var SyntaxError = require("./SyntaxError");
  5471. function TokenStreamBase(input, tokenData) {
  5472. this._reader = new StringReader(input ? input.toString() : "");
  5473. this._token = null;
  5474. this._tokenData = tokenData;
  5475. this._lt = [];
  5476. this._ltIndex = 0;
  5477. this._ltIndexCache = [];
  5478. }
  5479. TokenStreamBase.createTokenData = function(tokens) {
  5480. var nameMap = [],
  5481. typeMap = Object.create(null),
  5482. tokenData = tokens.concat([]),
  5483. i = 0,
  5484. len = tokenData.length + 1;
  5485. tokenData.UNKNOWN = -1;
  5486. tokenData.unshift({ name:"EOF" });
  5487. for (; i < len; i++) {
  5488. nameMap.push(tokenData[i].name);
  5489. tokenData[tokenData[i].name] = i;
  5490. if (tokenData[i].text) {
  5491. typeMap[tokenData[i].text] = i;
  5492. }
  5493. }
  5494. tokenData.name = function(tt) {
  5495. return nameMap[tt];
  5496. };
  5497. tokenData.type = function(c) {
  5498. return typeMap[c];
  5499. };
  5500. return tokenData;
  5501. };
  5502. TokenStreamBase.prototype = {
  5503. constructor: TokenStreamBase,
  5504. match: function(tokenTypes, channel) {
  5505. if (!(tokenTypes instanceof Array)) {
  5506. tokenTypes = [tokenTypes];
  5507. }
  5508. var tt = this.get(channel),
  5509. i = 0,
  5510. len = tokenTypes.length;
  5511. while (i < len) {
  5512. if (tt === tokenTypes[i++]) {
  5513. return true;
  5514. }
  5515. }
  5516. this.unget();
  5517. return false;
  5518. },
  5519. mustMatch: function(tokenTypes) {
  5520. var token;
  5521. if (!(tokenTypes instanceof Array)) {
  5522. tokenTypes = [tokenTypes];
  5523. }
  5524. if (!this.match.apply(this, arguments)) {
  5525. token = this.LT(1);
  5526. throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name +
  5527. " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
  5528. }
  5529. },
  5530. advance: function(tokenTypes, channel) {
  5531. while (this.LA(0) !== 0 && !this.match(tokenTypes, channel)) {
  5532. this.get();
  5533. }
  5534. return this.LA(0);
  5535. },
  5536. get: function(channel) {
  5537. var tokenInfo = this._tokenData,
  5538. i = 0,
  5539. token,
  5540. info;
  5541. if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length) {
  5542. i++;
  5543. this._token = this._lt[this._ltIndex++];
  5544. info = tokenInfo[this._token.type];
  5545. while ((typeof info.channel !== "undefined" && channel !== info.channel) &&
  5546. this._ltIndex < this._lt.length) {
  5547. this._token = this._lt[this._ltIndex++];
  5548. info = tokenInfo[this._token.type];
  5549. i++;
  5550. }
  5551. if ((typeof info.channel === "undefined" || channel === info.channel) &&
  5552. this._ltIndex <= this._lt.length) {
  5553. this._ltIndexCache.push(i);
  5554. return this._token.type;
  5555. }
  5556. }
  5557. token = this._getToken();
  5558. if (token.type > -1 && !tokenInfo[token.type].hide) {
  5559. token.channel = tokenInfo[token.type].channel;
  5560. this._token = token;
  5561. this._lt.push(token);
  5562. this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
  5563. if (this._lt.length > 5) {
  5564. this._lt.shift();
  5565. }
  5566. if (this._ltIndexCache.length > 5) {
  5567. this._ltIndexCache.shift();
  5568. }
  5569. this._ltIndex = this._lt.length;
  5570. }
  5571. info = tokenInfo[token.type];
  5572. if (info &&
  5573. (info.hide ||
  5574. (typeof info.channel !== "undefined" && channel !== info.channel))) {
  5575. return this.get(channel);
  5576. } else {
  5577. return token.type;
  5578. }
  5579. },
  5580. LA: function(index) {
  5581. var total = index,
  5582. tt;
  5583. if (index > 0) {
  5584. if (index > 5) {
  5585. throw new Error("Too much lookahead.");
  5586. }
  5587. while (total) {
  5588. tt = this.get();
  5589. total--;
  5590. }
  5591. while (total < index) {
  5592. this.unget();
  5593. total++;
  5594. }
  5595. } else if (index < 0) {
  5596. if (this._lt[this._ltIndex + index]) {
  5597. tt = this._lt[this._ltIndex + index].type;
  5598. } else {
  5599. throw new Error("Too much lookbehind.");
  5600. }
  5601. } else {
  5602. tt = this._token.type;
  5603. }
  5604. return tt;
  5605. },
  5606. LT: function(index) {
  5607. this.LA(index);
  5608. return this._lt[this._ltIndex + index - 1];
  5609. },
  5610. peek: function() {
  5611. return this.LA(1);
  5612. },
  5613. token: function() {
  5614. return this._token;
  5615. },
  5616. tokenName: function(tokenType) {
  5617. if (tokenType < 0 || tokenType > this._tokenData.length) {
  5618. return "UNKNOWN_TOKEN";
  5619. } else {
  5620. return this._tokenData[tokenType].name;
  5621. }
  5622. },
  5623. tokenType: function(tokenName) {
  5624. return this._tokenData[tokenName] || -1;
  5625. },
  5626. unget: function() {
  5627. if (this._ltIndexCache.length) {
  5628. this._ltIndex -= this._ltIndexCache.pop();//--;
  5629. this._token = this._lt[this._ltIndex - 1];
  5630. } else {
  5631. throw new Error("Too much lookahead.");
  5632. }
  5633. }
  5634. };
  5635. },{"./StringReader":24,"./SyntaxError":25}],28:[function(require,module,exports){
  5636. "use strict";
  5637. module.exports = {
  5638. StringReader : require("./StringReader"),
  5639. SyntaxError : require("./SyntaxError"),
  5640. SyntaxUnit : require("./SyntaxUnit"),
  5641. EventTarget : require("./EventTarget"),
  5642. TokenStreamBase : require("./TokenStreamBase")
  5643. };
  5644. },{"./EventTarget":23,"./StringReader":24,"./SyntaxError":25,"./SyntaxUnit":26,"./TokenStreamBase":27}],"parserlib":[function(require,module,exports){
  5645. "use strict";
  5646. module.exports = {
  5647. css : require("./css"),
  5648. util : require("./util")
  5649. };
  5650. },{"./css":22,"./util":28}]},{},[]);
  5651. return require('parserlib');
  5652. })();
  5653. var clone = (function() {
  5654. 'use strict';
  5655. function _instanceof(obj, type) {
  5656. return type != null && obj instanceof type;
  5657. }
  5658. var nativeMap;
  5659. try {
  5660. nativeMap = Map;
  5661. } catch(_) {
  5662. nativeMap = function() {};
  5663. }
  5664. var nativeSet;
  5665. try {
  5666. nativeSet = Set;
  5667. } catch(_) {
  5668. nativeSet = function() {};
  5669. }
  5670. var nativePromise;
  5671. try {
  5672. nativePromise = Promise;
  5673. } catch(_) {
  5674. nativePromise = function() {};
  5675. }
  5676. function clone(parent, circular, depth, prototype, includeNonEnumerable) {
  5677. if (typeof circular === 'object') {
  5678. depth = circular.depth;
  5679. prototype = circular.prototype;
  5680. includeNonEnumerable = circular.includeNonEnumerable;
  5681. circular = circular.circular;
  5682. }
  5683. var allParents = [];
  5684. var allChildren = [];
  5685. var useBuffer = typeof Buffer != 'undefined';
  5686. if (typeof circular == 'undefined')
  5687. circular = true;
  5688. if (typeof depth == 'undefined')
  5689. depth = Infinity;
  5690. function _clone(parent, depth) {
  5691. if (parent === null)
  5692. return null;
  5693. if (depth === 0)
  5694. return parent;
  5695. var child;
  5696. var proto;
  5697. if (typeof parent != 'object') {
  5698. return parent;
  5699. }
  5700. if (_instanceof(parent, nativeMap)) {
  5701. child = new nativeMap();
  5702. } else if (_instanceof(parent, nativeSet)) {
  5703. child = new nativeSet();
  5704. } else if (_instanceof(parent, nativePromise)) {
  5705. child = new nativePromise(function (resolve, reject) {
  5706. parent.then(function(value) {
  5707. resolve(_clone(value, depth - 1));
  5708. }, function(err) {
  5709. reject(_clone(err, depth - 1));
  5710. });
  5711. });
  5712. } else if (clone.__isArray(parent)) {
  5713. child = [];
  5714. } else if (clone.__isRegExp(parent)) {
  5715. child = new RegExp(parent.source, __getRegExpFlags(parent));
  5716. if (parent.lastIndex) child.lastIndex = parent.lastIndex;
  5717. } else if (clone.__isDate(parent)) {
  5718. child = new Date(parent.getTime());
  5719. } else if (useBuffer && Buffer.isBuffer(parent)) {
  5720. if (Buffer.allocUnsafe) {
  5721. child = Buffer.allocUnsafe(parent.length);
  5722. } else {
  5723. child = new Buffer(parent.length);
  5724. }
  5725. parent.copy(child);
  5726. return child;
  5727. } else if (_instanceof(parent, Error)) {
  5728. child = Object.create(parent);
  5729. } else {
  5730. if (typeof prototype == 'undefined') {
  5731. proto = Object.getPrototypeOf(parent);
  5732. child = Object.create(proto);
  5733. }
  5734. else {
  5735. child = Object.create(prototype);
  5736. proto = prototype;
  5737. }
  5738. }
  5739. if (circular) {
  5740. var index = allParents.indexOf(parent);
  5741. if (index != -1) {
  5742. return allChildren[index];
  5743. }
  5744. allParents.push(parent);
  5745. allChildren.push(child);
  5746. }
  5747. if (_instanceof(parent, nativeMap)) {
  5748. parent.forEach(function(value, key) {
  5749. var keyChild = _clone(key, depth - 1);
  5750. var valueChild = _clone(value, depth - 1);
  5751. child.set(keyChild, valueChild);
  5752. });
  5753. }
  5754. if (_instanceof(parent, nativeSet)) {
  5755. parent.forEach(function(value) {
  5756. var entryChild = _clone(value, depth - 1);
  5757. child.add(entryChild);
  5758. });
  5759. }
  5760. for (var i in parent) {
  5761. var attrs;
  5762. if (proto) {
  5763. attrs = Object.getOwnPropertyDescriptor(proto, i);
  5764. }
  5765. if (attrs && attrs.set == null) {
  5766. continue;
  5767. }
  5768. child[i] = _clone(parent[i], depth - 1);
  5769. }
  5770. if (Object.getOwnPropertySymbols) {
  5771. var symbols = Object.getOwnPropertySymbols(parent);
  5772. for (var i = 0; i < symbols.length; i++) {
  5773. var symbol = symbols[i];
  5774. var descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
  5775. if (descriptor && !descriptor.enumerable && !includeNonEnumerable) {
  5776. continue;
  5777. }
  5778. child[symbol] = _clone(parent[symbol], depth - 1);
  5779. if (!descriptor.enumerable) {
  5780. Object.defineProperty(child, symbol, {
  5781. enumerable: false
  5782. });
  5783. }
  5784. }
  5785. }
  5786. if (includeNonEnumerable) {
  5787. var allPropertyNames = Object.getOwnPropertyNames(parent);
  5788. for (var i = 0; i < allPropertyNames.length; i++) {
  5789. var propertyName = allPropertyNames[i];
  5790. var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName);
  5791. if (descriptor && descriptor.enumerable) {
  5792. continue;
  5793. }
  5794. child[propertyName] = _clone(parent[propertyName], depth - 1);
  5795. Object.defineProperty(child, propertyName, {
  5796. enumerable: false
  5797. });
  5798. }
  5799. }
  5800. return child;
  5801. }
  5802. return _clone(parent, depth);
  5803. }
  5804. clone.clonePrototype = function clonePrototype(parent) {
  5805. if (parent === null)
  5806. return null;
  5807. var c = function () {};
  5808. c.prototype = parent;
  5809. return new c();
  5810. };
  5811. function __objToStr(o) {
  5812. return Object.prototype.toString.call(o);
  5813. }
  5814. clone.__objToStr = __objToStr;
  5815. function __isDate(o) {
  5816. return typeof o === 'object' && __objToStr(o) === '[object Date]';
  5817. }
  5818. clone.__isDate = __isDate;
  5819. function __isArray(o) {
  5820. return typeof o === 'object' && __objToStr(o) === '[object Array]';
  5821. }
  5822. clone.__isArray = __isArray;
  5823. function __isRegExp(o) {
  5824. return typeof o === 'object' && __objToStr(o) === '[object RegExp]';
  5825. }
  5826. clone.__isRegExp = __isRegExp;
  5827. function __getRegExpFlags(re) {
  5828. var flags = '';
  5829. if (re.global) flags += 'g';
  5830. if (re.ignoreCase) flags += 'i';
  5831. if (re.multiline) flags += 'm';
  5832. return flags;
  5833. }
  5834. clone.__getRegExpFlags = __getRegExpFlags;
  5835. return clone;
  5836. })();
  5837. if (typeof module === 'object' && module.exports) {
  5838. module.exports = clone;
  5839. }
  5840. var CSSLint = (function() {
  5841. "use strict";
  5842. var rules = [],
  5843. formatters = [],
  5844. embeddedRuleset = /\/\*\s*csslint([^\*]*)\*\//,
  5845. api = new parserlib.util.EventTarget();
  5846. api.version = "1.0.5";
  5847. api.addRule = function(rule) {
  5848. rules.push(rule);
  5849. rules[rule.id] = rule;
  5850. };
  5851. api.clearRules = function() {
  5852. rules = [];
  5853. };
  5854. api.getRules = function() {
  5855. return [].concat(rules).sort(function(a, b) {
  5856. return a.id > b.id ? 1 : 0;
  5857. });
  5858. };
  5859. api.getRuleset = function() {
  5860. var ruleset = {},
  5861. i = 0,
  5862. len = rules.length;
  5863. while (i < len) {
  5864. ruleset[rules[i++].id] = 1; // by default, everything is a warning
  5865. }
  5866. return ruleset;
  5867. };
  5868. function applyEmbeddedRuleset(text, ruleset) {
  5869. var valueMap,
  5870. embedded = text && text.match(embeddedRuleset),
  5871. rules = embedded && embedded[1];
  5872. if (rules) {
  5873. valueMap = {
  5874. "true": 2, // true is error
  5875. "": 1, // blank is warning
  5876. "false": 0, // false is ignore
  5877. "2": 2, // explicit error
  5878. "1": 1, // explicit warning
  5879. "0": 0 // explicit ignore
  5880. };
  5881. rules.toLowerCase().split(",").forEach(function(rule) {
  5882. var pair = rule.split(":"),
  5883. property = pair[0] || "",
  5884. value = pair[1] || "";
  5885. ruleset[property.trim()] = valueMap[value.trim()];
  5886. });
  5887. }
  5888. return ruleset;
  5889. }
  5890. api.addFormatter = function(formatter) {
  5891. formatters[formatter.id] = formatter;
  5892. };
  5893. api.getFormatter = function(formatId) {
  5894. return formatters[formatId];
  5895. };
  5896. api.format = function(results, filename, formatId, options) {
  5897. var formatter = api.getFormatter(formatId),
  5898. result = null;
  5899. if (formatter) {
  5900. result = formatter.startFormat();
  5901. result += formatter.formatResults(results, filename, options || {});
  5902. result += formatter.endFormat();
  5903. }
  5904. return result;
  5905. };
  5906. api.hasFormat = function(formatId) {
  5907. return formatters.hasOwnProperty(formatId);
  5908. };
  5909. api.verify = function(text, ruleset) {
  5910. var i = 0,
  5911. reporter,
  5912. lines,
  5913. allow = {},
  5914. ignore = [],
  5915. report,
  5916. parser = new parserlib.css.Parser({
  5917. starHack: true,
  5918. ieFilters: true,
  5919. underscoreHack: true,
  5920. strict: false
  5921. });
  5922. lines = text.replace(/\n\r?/g, "$split$").split("$split$");
  5923. CSSLint.Util.forEach(lines, function (line, lineno) {
  5924. var allowLine = line && line.match(/\/\*[ \t]*csslint[ \t]+allow:[ \t]*([^\*]*)\*\//i),
  5925. allowRules = allowLine && allowLine[1],
  5926. allowRuleset = {};
  5927. if (allowRules) {
  5928. allowRules.toLowerCase().split(",").forEach(function(allowRule) {
  5929. allowRuleset[allowRule.trim()] = true;
  5930. });
  5931. if (Object.keys(allowRuleset).length > 0) {
  5932. allow[lineno + 1] = allowRuleset;
  5933. }
  5934. }
  5935. });
  5936. var ignoreStart = null,
  5937. ignoreEnd = null;
  5938. CSSLint.Util.forEach(lines, function (line, lineno) {
  5939. if (ignoreStart === null && line.match(/\/\*[ \t]*csslint[ \t]+ignore:start[ \t]*\*\//i)) {
  5940. ignoreStart = lineno;
  5941. }
  5942. if (line.match(/\/\*[ \t]*csslint[ \t]+ignore:end[ \t]*\*\//i)) {
  5943. ignoreEnd = lineno;
  5944. }
  5945. if (ignoreStart !== null && ignoreEnd !== null) {
  5946. ignore.push([ignoreStart, ignoreEnd]);
  5947. ignoreStart = ignoreEnd = null;
  5948. }
  5949. });
  5950. if (ignoreStart !== null) {
  5951. ignore.push([ignoreStart, lines.length]);
  5952. }
  5953. if (!ruleset) {
  5954. ruleset = api.getRuleset();
  5955. }
  5956. if (embeddedRuleset.test(text)) {
  5957. ruleset = clone(ruleset);
  5958. ruleset = applyEmbeddedRuleset(text, ruleset);
  5959. }
  5960. reporter = new Reporter(lines, ruleset, allow, ignore);
  5961. ruleset.errors = 2; // always report parsing errors as errors
  5962. for (i in ruleset) {
  5963. if (ruleset.hasOwnProperty(i) && ruleset[i]) {
  5964. if (rules[i]) {
  5965. rules[i].init(parser, reporter);
  5966. }
  5967. }
  5968. }
  5969. try {
  5970. parser.parse(text);
  5971. } catch (ex) {
  5972. reporter.error("Fatal error, cannot continue: " + ex.message, ex.line, ex.col, {});
  5973. }
  5974. report = {
  5975. messages : reporter.messages,
  5976. stats : reporter.stats,
  5977. ruleset : reporter.ruleset,
  5978. allow : reporter.allow,
  5979. ignore : reporter.ignore
  5980. };
  5981. report.messages.sort(function (a, b) {
  5982. if (a.rollup && !b.rollup) {
  5983. return 1;
  5984. } else if (!a.rollup && b.rollup) {
  5985. return -1;
  5986. } else {
  5987. return a.line - b.line;
  5988. }
  5989. });
  5990. return report;
  5991. };
  5992. return api;
  5993. })();
  5994. function Reporter(lines, ruleset, allow, ignore) {
  5995. "use strict";
  5996. this.messages = [];
  5997. this.stats = [];
  5998. this.lines = lines;
  5999. this.ruleset = ruleset;
  6000. this.allow = allow;
  6001. if (!this.allow) {
  6002. this.allow = {};
  6003. }
  6004. this.ignore = ignore;
  6005. if (!this.ignore) {
  6006. this.ignore = [];
  6007. }
  6008. }
  6009. Reporter.prototype = {
  6010. constructor: Reporter,
  6011. error: function(message, line, col, rule) {
  6012. "use strict";
  6013. this.messages.push({
  6014. type : "error",
  6015. line : line,
  6016. col : col,
  6017. message : message,
  6018. evidence: this.lines[line-1],
  6019. rule : rule || {}
  6020. });
  6021. },
  6022. warn: function(message, line, col, rule) {
  6023. "use strict";
  6024. this.report(message, line, col, rule);
  6025. },
  6026. report: function(message, line, col, rule) {
  6027. "use strict";
  6028. if (this.allow.hasOwnProperty(line) && this.allow[line].hasOwnProperty(rule.id)) {
  6029. return;
  6030. }
  6031. if (this.isIgnored(line)) {
  6032. return;
  6033. }
  6034. this.messages.push({
  6035. type : this.ruleset[rule.id] === 2 ? "error" : "warning",
  6036. line : line,
  6037. col : col,
  6038. message : message,
  6039. evidence: this.lines[line-1],
  6040. rule : rule
  6041. });
  6042. },
  6043. info: function(message, line, col, rule) {
  6044. "use strict";
  6045. this.messages.push({
  6046. type : "info",
  6047. line : line,
  6048. col : col,
  6049. message : message,
  6050. evidence: this.lines[line-1],
  6051. rule : rule
  6052. });
  6053. },
  6054. rollupError: function(message, rule) {
  6055. "use strict";
  6056. this.messages.push({
  6057. type : "error",
  6058. rollup : true,
  6059. message : message,
  6060. rule : rule
  6061. });
  6062. },
  6063. rollupWarn: function(message, rule) {
  6064. "use strict";
  6065. this.messages.push({
  6066. type : "warning",
  6067. rollup : true,
  6068. message : message,
  6069. rule : rule
  6070. });
  6071. },
  6072. stat: function(name, value) {
  6073. "use strict";
  6074. this.stats[name] = value;
  6075. },
  6076. isIgnored: function(line) {
  6077. "use strict";
  6078. var ignore = false;
  6079. CSSLint.Util.forEach(this.ignore, function (range) {
  6080. if (range[0] <= line && line <= range[1]) {
  6081. ignore = true;
  6082. }
  6083. });
  6084. return ignore;
  6085. }
  6086. };
  6087. CSSLint._Reporter = Reporter;
  6088. CSSLint.Util = {
  6089. mix: function(receiver, supplier) {
  6090. "use strict";
  6091. var prop;
  6092. for (prop in supplier) {
  6093. if (supplier.hasOwnProperty(prop)) {
  6094. receiver[prop] = supplier[prop];
  6095. }
  6096. }
  6097. return prop;
  6098. },
  6099. indexOf: function(values, value) {
  6100. "use strict";
  6101. if (values.indexOf) {
  6102. return values.indexOf(value);
  6103. } else {
  6104. for (var i=0, len=values.length; i < len; i++) {
  6105. if (values[i] === value) {
  6106. return i;
  6107. }
  6108. }
  6109. return -1;
  6110. }
  6111. },
  6112. forEach: function(values, func) {
  6113. "use strict";
  6114. if (values.forEach) {
  6115. return values.forEach(func);
  6116. } else {
  6117. for (var i=0, len=values.length; i < len; i++) {
  6118. func(values[i], i, values);
  6119. }
  6120. }
  6121. }
  6122. };
  6123. CSSLint.addRule({
  6124. id: "box-model",
  6125. name: "Beware of broken box size",
  6126. desc: "Don't use width or height when using padding or border.",
  6127. url: "https://github.com/CSSLint/csslint/wiki/Beware-of-box-model-size",
  6128. browsers: "All",
  6129. init: function(parser, reporter) {
  6130. "use strict";
  6131. var rule = this,
  6132. widthProperties = {
  6133. border: 1,
  6134. "border-left": 1,
  6135. "border-right": 1,
  6136. padding: 1,
  6137. "padding-left": 1,
  6138. "padding-right": 1
  6139. },
  6140. heightProperties = {
  6141. border: 1,
  6142. "border-bottom": 1,
  6143. "border-top": 1,
  6144. padding: 1,
  6145. "padding-bottom": 1,
  6146. "padding-top": 1
  6147. },
  6148. properties,
  6149. boxSizing = false;
  6150. function startRule() {
  6151. properties = {};
  6152. boxSizing = false;
  6153. }
  6154. function endRule() {
  6155. var prop, value;
  6156. if (!boxSizing) {
  6157. if (properties.height) {
  6158. for (prop in heightProperties) {
  6159. if (heightProperties.hasOwnProperty(prop) && properties[prop]) {
  6160. value = properties[prop].value;
  6161. if (!(prop === "padding" && value.parts.length === 2 && value.parts[0].value === 0)) {
  6162. reporter.report("Using height with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
  6163. }
  6164. }
  6165. }
  6166. }
  6167. if (properties.width) {
  6168. for (prop in widthProperties) {
  6169. if (widthProperties.hasOwnProperty(prop) && properties[prop]) {
  6170. value = properties[prop].value;
  6171. if (!(prop === "padding" && value.parts.length === 2 && value.parts[1].value === 0)) {
  6172. reporter.report("Using width with " + prop + " can sometimes make elements larger than you expect.", properties[prop].line, properties[prop].col, rule);
  6173. }
  6174. }
  6175. }
  6176. }
  6177. }
  6178. }
  6179. parser.addListener("startrule", startRule);
  6180. parser.addListener("startfontface", startRule);
  6181. parser.addListener("startpage", startRule);
  6182. parser.addListener("startpagemargin", startRule);
  6183. parser.addListener("startkeyframerule", startRule);
  6184. parser.addListener("startviewport", startRule);
  6185. parser.addListener("property", function(event) {
  6186. var name = event.property.text.toLowerCase();
  6187. if (heightProperties[name] || widthProperties[name]) {
  6188. if (!/^0\S*$/.test(event.value) && !(name === "border" && event.value.toString() === "none")) {
  6189. properties[name] = {
  6190. line: event.property.line,
  6191. col: event.property.col,
  6192. value: event.value
  6193. };
  6194. }
  6195. } else {
  6196. if (/^(width|height)/i.test(name) && /^(length|percentage)/.test(event.value.parts[0].type)) {
  6197. properties[name] = 1;
  6198. } else if (name === "box-sizing") {
  6199. boxSizing = true;
  6200. }
  6201. }
  6202. });
  6203. parser.addListener("endrule", endRule);
  6204. parser.addListener("endfontface", endRule);
  6205. parser.addListener("endpage", endRule);
  6206. parser.addListener("endpagemargin", endRule);
  6207. parser.addListener("endkeyframerule", endRule);
  6208. parser.addListener("endviewport", endRule);
  6209. }
  6210. });
  6211. CSSLint.addRule({
  6212. id: "bulletproof-font-face",
  6213. name: "Use the bulletproof @font-face syntax",
  6214. desc: "Use the bulletproof @font-face syntax to avoid 404's in old IE (http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax).",
  6215. url: "https://github.com/CSSLint/csslint/wiki/Bulletproof-font-face",
  6216. browsers: "All",
  6217. init: function(parser, reporter) {
  6218. "use strict";
  6219. var rule = this,
  6220. fontFaceRule = false,
  6221. firstSrc = true,
  6222. ruleFailed = false,
  6223. line, col;
  6224. parser.addListener("startfontface", function() {
  6225. fontFaceRule = true;
  6226. });
  6227. parser.addListener("property", function(event) {
  6228. if (!fontFaceRule) {
  6229. return;
  6230. }
  6231. var propertyName = event.property.toString().toLowerCase(),
  6232. value = event.value.toString();
  6233. line = event.line;
  6234. col = event.col;
  6235. if (propertyName === "src") {
  6236. var regex = /^\s?url\(['"].+\.eot\?.*['"]\)\s*format\(['"]embedded-opentype['"]\).*$/i;
  6237. if (!value.match(regex) && firstSrc) {
  6238. ruleFailed = true;
  6239. firstSrc = false;
  6240. } else if (value.match(regex) && !firstSrc) {
  6241. ruleFailed = false;
  6242. }
  6243. }
  6244. });
  6245. parser.addListener("endfontface", function() {
  6246. fontFaceRule = false;
  6247. if (ruleFailed) {
  6248. reporter.report("@font-face declaration doesn't follow the fontspring bulletproof syntax.", line, col, rule);
  6249. }
  6250. });
  6251. }
  6252. });
  6253. CSSLint.addRule({
  6254. id: "compatible-vendor-prefixes",
  6255. name: "Require compatible vendor prefixes",
  6256. desc: "Include all compatible vendor prefixes to reach a wider range of users.",
  6257. url: "https://github.com/CSSLint/csslint/wiki/Require-compatible-vendor-prefixes",
  6258. browsers: "All",
  6259. init: function (parser, reporter) {
  6260. "use strict";
  6261. var rule = this,
  6262. compatiblePrefixes,
  6263. properties,
  6264. prop,
  6265. variations,
  6266. prefixed,
  6267. i,
  6268. len,
  6269. inKeyFrame = false,
  6270. arrayPush = Array.prototype.push,
  6271. applyTo = [];
  6272. compatiblePrefixes = {
  6273. "animation" : "webkit",
  6274. "animation-delay" : "webkit",
  6275. "animation-direction" : "webkit",
  6276. "animation-duration" : "webkit",
  6277. "animation-fill-mode" : "webkit",
  6278. "animation-iteration-count" : "webkit",
  6279. "animation-name" : "webkit",
  6280. "animation-play-state" : "webkit",
  6281. "animation-timing-function" : "webkit",
  6282. "appearance" : "webkit moz",
  6283. "border-end" : "webkit moz",
  6284. "border-end-color" : "webkit moz",
  6285. "border-end-style" : "webkit moz",
  6286. "border-end-width" : "webkit moz",
  6287. "border-image" : "webkit moz o",
  6288. "border-radius" : "webkit",
  6289. "border-start" : "webkit moz",
  6290. "border-start-color" : "webkit moz",
  6291. "border-start-style" : "webkit moz",
  6292. "border-start-width" : "webkit moz",
  6293. "box-align" : "webkit moz",
  6294. "box-direction" : "webkit moz",
  6295. "box-flex" : "webkit moz",
  6296. "box-lines" : "webkit",
  6297. "box-ordinal-group" : "webkit moz",
  6298. "box-orient" : "webkit moz",
  6299. "box-pack" : "webkit moz",
  6300. "box-sizing" : "",
  6301. "box-shadow" : "",
  6302. "column-count" : "webkit moz ms",
  6303. "column-gap" : "webkit moz ms",
  6304. "column-rule" : "webkit moz ms",
  6305. "column-rule-color" : "webkit moz ms",
  6306. "column-rule-style" : "webkit moz ms",
  6307. "column-rule-width" : "webkit moz ms",
  6308. "column-width" : "webkit moz ms",
  6309. "flex" : "webkit ms",
  6310. "flex-basis" : "webkit",
  6311. "flex-direction" : "webkit ms",
  6312. "flex-flow" : "webkit",
  6313. "flex-grow" : "webkit",
  6314. "flex-shrink" : "webkit",
  6315. "hyphens" : "epub moz",
  6316. "line-break" : "webkit ms",
  6317. "margin-end" : "webkit moz",
  6318. "margin-start" : "webkit moz",
  6319. "marquee-speed" : "webkit wap",
  6320. "marquee-style" : "webkit wap",
  6321. "padding-end" : "webkit moz",
  6322. "padding-start" : "webkit moz",
  6323. "tab-size" : "moz o",
  6324. "text-size-adjust" : "webkit ms",
  6325. "transform" : "webkit ms",
  6326. "transform-origin" : "webkit ms",
  6327. "transition" : "",
  6328. "transition-delay" : "",
  6329. "transition-duration" : "",
  6330. "transition-property" : "",
  6331. "transition-timing-function" : "",
  6332. "user-modify" : "webkit moz",
  6333. "user-select" : "webkit moz ms",
  6334. "word-break" : "epub ms",
  6335. "writing-mode" : "epub ms"
  6336. };
  6337. for (prop in compatiblePrefixes) {
  6338. if (compatiblePrefixes.hasOwnProperty(prop)) {
  6339. variations = [];
  6340. prefixed = compatiblePrefixes[prop].split(" ");
  6341. for (i = 0, len = prefixed.length; i < len; i++) {
  6342. variations.push("-" + prefixed[i] + "-" + prop);
  6343. }
  6344. compatiblePrefixes[prop] = variations;
  6345. arrayPush.apply(applyTo, variations);
  6346. }
  6347. }
  6348. parser.addListener("startrule", function () {
  6349. properties = [];
  6350. });
  6351. parser.addListener("startkeyframes", function (event) {
  6352. inKeyFrame = event.prefix || true;
  6353. });
  6354. parser.addListener("endkeyframes", function () {
  6355. inKeyFrame = false;
  6356. });
  6357. parser.addListener("property", function (event) {
  6358. var name = event.property;
  6359. if (CSSLint.Util.indexOf(applyTo, name.text) > -1) {
  6360. if (!inKeyFrame || typeof inKeyFrame !== "string" ||
  6361. name.text.indexOf("-" + inKeyFrame + "-") !== 0) {
  6362. properties.push(name);
  6363. }
  6364. }
  6365. });
  6366. parser.addListener("endrule", function () {
  6367. if (!properties.length) {
  6368. return;
  6369. }
  6370. var propertyGroups = {},
  6371. i,
  6372. len,
  6373. name,
  6374. prop,
  6375. variations,
  6376. value,
  6377. full,
  6378. actual,
  6379. item,
  6380. propertiesSpecified;
  6381. for (i = 0, len = properties.length; i < len; i++) {
  6382. name = properties[i];
  6383. for (prop in compatiblePrefixes) {
  6384. if (compatiblePrefixes.hasOwnProperty(prop)) {
  6385. variations = compatiblePrefixes[prop];
  6386. if (CSSLint.Util.indexOf(variations, name.text) > -1) {
  6387. if (!propertyGroups[prop]) {
  6388. propertyGroups[prop] = {
  6389. full: variations.slice(0),
  6390. actual: [],
  6391. actualNodes: []
  6392. };
  6393. }
  6394. if (CSSLint.Util.indexOf(propertyGroups[prop].actual, name.text) === -1) {
  6395. propertyGroups[prop].actual.push(name.text);
  6396. propertyGroups[prop].actualNodes.push(name);
  6397. }
  6398. }
  6399. }
  6400. }
  6401. }
  6402. for (prop in propertyGroups) {
  6403. if (propertyGroups.hasOwnProperty(prop)) {
  6404. value = propertyGroups[prop];
  6405. full = value.full;
  6406. actual = value.actual;
  6407. if (full.length > actual.length) {
  6408. for (i = 0, len = full.length; i < len; i++) {
  6409. item = full[i];
  6410. if (CSSLint.Util.indexOf(actual, item) === -1) {
  6411. propertiesSpecified = (actual.length === 1) ? actual[0] : (actual.length === 2) ? actual.join(" and ") : actual.join(", ");
  6412. reporter.report("The property " + item + " is compatible with " + propertiesSpecified + " and should be included as well.", value.actualNodes[0].line, value.actualNodes[0].col, rule);
  6413. }
  6414. }
  6415. }
  6416. }
  6417. }
  6418. });
  6419. }
  6420. });
  6421. CSSLint.addRule({
  6422. id: "display-property-grouping",
  6423. name: "Require properties appropriate for display",
  6424. desc: "Certain properties shouldn't be used with certain display property values.",
  6425. url: "https://github.com/CSSLint/csslint/wiki/Require-properties-appropriate-for-display",
  6426. browsers: "All",
  6427. init: function(parser, reporter) {
  6428. "use strict";
  6429. var rule = this;
  6430. var propertiesToCheck = {
  6431. display: 1,
  6432. "float": "none",
  6433. height: 1,
  6434. width: 1,
  6435. margin: 1,
  6436. "margin-left": 1,
  6437. "margin-right": 1,
  6438. "margin-bottom": 1,
  6439. "margin-top": 1,
  6440. padding: 1,
  6441. "padding-left": 1,
  6442. "padding-right": 1,
  6443. "padding-bottom": 1,
  6444. "padding-top": 1,
  6445. "vertical-align": 1
  6446. },
  6447. properties;
  6448. function reportProperty(name, display, msg) {
  6449. if (properties[name]) {
  6450. if (typeof propertiesToCheck[name] !== "string" || properties[name].value.toLowerCase() !== propertiesToCheck[name]) {
  6451. reporter.report(msg || name + " can't be used with display: " + display + ".", properties[name].line, properties[name].col, rule);
  6452. }
  6453. }
  6454. }
  6455. function startRule() {
  6456. properties = {};
  6457. }
  6458. function endRule() {
  6459. var display = properties.display ? properties.display.value : null;
  6460. if (display) {
  6461. switch (display) {
  6462. case "inline":
  6463. reportProperty("height", display);
  6464. reportProperty("width", display);
  6465. reportProperty("margin", display);
  6466. reportProperty("margin-top", display);
  6467. reportProperty("margin-bottom", display);
  6468. reportProperty("float", display, "display:inline has no effect on floated elements (but may be used to fix the IE6 double-margin bug).");
  6469. break;
  6470. case "block":
  6471. reportProperty("vertical-align", display);
  6472. break;
  6473. case "inline-block":
  6474. reportProperty("float", display);
  6475. break;
  6476. default:
  6477. if (display.indexOf("table-") === 0) {
  6478. reportProperty("margin", display);
  6479. reportProperty("margin-left", display);
  6480. reportProperty("margin-right", display);
  6481. reportProperty("margin-top", display);
  6482. reportProperty("margin-bottom", display);
  6483. reportProperty("float", display);
  6484. }
  6485. }
  6486. }
  6487. }
  6488. parser.addListener("startrule", startRule);
  6489. parser.addListener("startfontface", startRule);
  6490. parser.addListener("startkeyframerule", startRule);
  6491. parser.addListener("startpagemargin", startRule);
  6492. parser.addListener("startpage", startRule);
  6493. parser.addListener("startviewport", startRule);
  6494. parser.addListener("property", function(event) {
  6495. var name = event.property.text.toLowerCase();
  6496. if (propertiesToCheck[name]) {
  6497. properties[name] = {
  6498. value: event.value.text,
  6499. line: event.property.line,
  6500. col: event.property.col
  6501. };
  6502. }
  6503. });
  6504. parser.addListener("endrule", endRule);
  6505. parser.addListener("endfontface", endRule);
  6506. parser.addListener("endkeyframerule", endRule);
  6507. parser.addListener("endpagemargin", endRule);
  6508. parser.addListener("endpage", endRule);
  6509. parser.addListener("endviewport", endRule);
  6510. }
  6511. });
  6512. CSSLint.addRule({
  6513. id: "duplicate-background-images",
  6514. name: "Disallow duplicate background images",
  6515. desc: "Every background-image should be unique. Use a common class for e.g. sprites.",
  6516. url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-background-images",
  6517. browsers: "All",
  6518. init: function(parser, reporter) {
  6519. "use strict";
  6520. var rule = this,
  6521. stack = {};
  6522. parser.addListener("property", function(event) {
  6523. var name = event.property.text,
  6524. value = event.value,
  6525. i, len;
  6526. if (name.match(/background/i)) {
  6527. for (i=0, len=value.parts.length; i < len; i++) {
  6528. if (value.parts[i].type === "uri") {
  6529. if (typeof stack[value.parts[i].uri] === "undefined") {
  6530. stack[value.parts[i].uri] = event;
  6531. } else {
  6532. reporter.report("Background image '" + value.parts[i].uri + "' was used multiple times, first declared at line " + stack[value.parts[i].uri].line + ", col " + stack[value.parts[i].uri].col + ".", event.line, event.col, rule);
  6533. }
  6534. }
  6535. }
  6536. }
  6537. });
  6538. }
  6539. });
  6540. CSSLint.addRule({
  6541. id: "duplicate-properties",
  6542. name: "Disallow duplicate properties",
  6543. desc: "Duplicate properties must appear one after the other.",
  6544. url: "https://github.com/CSSLint/csslint/wiki/Disallow-duplicate-properties",
  6545. browsers: "All",
  6546. init: function(parser, reporter) {
  6547. "use strict";
  6548. var rule = this,
  6549. properties,
  6550. lastProperty;
  6551. function startRule() {
  6552. properties = {};
  6553. }
  6554. parser.addListener("startrule", startRule);
  6555. parser.addListener("startfontface", startRule);
  6556. parser.addListener("startpage", startRule);
  6557. parser.addListener("startpagemargin", startRule);
  6558. parser.addListener("startkeyframerule", startRule);
  6559. parser.addListener("startviewport", startRule);
  6560. parser.addListener("property", function(event) {
  6561. var property = event.property,
  6562. name = property.text.toLowerCase();
  6563. if (properties[name] && (lastProperty !== name || properties[name] === event.value.text)) {
  6564. reporter.report("Duplicate property '" + event.property + "' found.", event.line, event.col, rule);
  6565. }
  6566. properties[name] = event.value.text;
  6567. lastProperty = name;
  6568. });
  6569. }
  6570. });
  6571. CSSLint.addRule({
  6572. id: "empty-rules",
  6573. name: "Disallow empty rules",
  6574. desc: "Rules without any properties specified should be removed.",
  6575. url: "https://github.com/CSSLint/csslint/wiki/Disallow-empty-rules",
  6576. browsers: "All",
  6577. init: function(parser, reporter) {
  6578. "use strict";
  6579. var rule = this,
  6580. count = 0;
  6581. parser.addListener("startrule", function() {
  6582. count=0;
  6583. });
  6584. parser.addListener("property", function() {
  6585. count++;
  6586. });
  6587. parser.addListener("endrule", function(event) {
  6588. var selectors = event.selectors;
  6589. if (count === 0) {
  6590. reporter.report("Rule is empty.", selectors[0].line, selectors[0].col, rule);
  6591. }
  6592. });
  6593. }
  6594. });
  6595. CSSLint.addRule({
  6596. id: "errors",
  6597. name: "Parsing Errors",
  6598. desc: "This rule looks for recoverable syntax errors.",
  6599. browsers: "All",
  6600. init: function(parser, reporter) {
  6601. "use strict";
  6602. var rule = this;
  6603. parser.addListener("error", function(event) {
  6604. reporter.error(event.message, event.line, event.col, rule);
  6605. });
  6606. }
  6607. });
  6608. CSSLint.addRule({
  6609. id: "floats",
  6610. name: "Disallow too many floats",
  6611. desc: "This rule tests if the float property is used too many times",
  6612. url: "https://github.com/CSSLint/csslint/wiki/Disallow-too-many-floats",
  6613. browsers: "All",
  6614. init: function(parser, reporter) {
  6615. "use strict";
  6616. var rule = this;
  6617. var count = 0;
  6618. parser.addListener("property", function(event) {
  6619. if (!reporter.isIgnored(event.property.line)) {
  6620. if (event.property.text.toLowerCase() === "float" &&
  6621. event.value.text.toLowerCase() !== "none") {
  6622. count++;
  6623. }
  6624. }
  6625. });
  6626. parser.addListener("endstylesheet", function() {
  6627. reporter.stat("floats", count);
  6628. if (count >= 10) {
  6629. reporter.rollupWarn("Too many floats (" + count + "), you're probably using them for layout. Consider using a grid system instead.", rule);
  6630. }
  6631. });
  6632. }
  6633. });
  6634. CSSLint.addRule({
  6635. id: "font-faces",
  6636. name: "Don't use too many web fonts",
  6637. desc: "Too many different web fonts in the same stylesheet.",
  6638. url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-web-fonts",
  6639. browsers: "All",
  6640. init: function(parser, reporter) {
  6641. "use strict";
  6642. var rule = this,
  6643. count = 0;
  6644. parser.addListener("startfontface", function(event) {
  6645. if (!reporter.isIgnored(event.line)) {
  6646. count++;
  6647. }
  6648. });
  6649. parser.addListener("endstylesheet", function() {
  6650. if (count > 5) {
  6651. reporter.rollupWarn("Too many @font-face declarations (" + count + ").", rule);
  6652. }
  6653. });
  6654. }
  6655. });
  6656. CSSLint.addRule({
  6657. id: "font-sizes",
  6658. name: "Disallow too many font sizes",
  6659. desc: "Checks the number of font-size declarations.",
  6660. url: "https://github.com/CSSLint/csslint/wiki/Don%27t-use-too-many-font-size-declarations",
  6661. browsers: "All",
  6662. init: function(parser, reporter) {
  6663. "use strict";
  6664. var rule = this,
  6665. count = 0;
  6666. parser.addListener("property", function(event) {
  6667. if (!reporter.isIgnored(event.property.line)) {
  6668. if (event.property.toString() === "font-size") {
  6669. count++;
  6670. }
  6671. }
  6672. });
  6673. parser.addListener("endstylesheet", function() {
  6674. reporter.stat("font-sizes", count);
  6675. if (count >= 10) {
  6676. reporter.rollupWarn("Too many font-size declarations (" + count + "), abstraction needed.", rule);
  6677. }
  6678. });
  6679. }
  6680. });
  6681. CSSLint.addRule({
  6682. id: "gradients",
  6683. name: "Require all gradient definitions",
  6684. desc: "When using a vendor-prefixed gradient, make sure to use them all.",
  6685. url: "https://github.com/CSSLint/csslint/wiki/Require-all-gradient-definitions",
  6686. browsers: "All",
  6687. init: function(parser, reporter) {
  6688. "use strict";
  6689. var rule = this,
  6690. gradients;
  6691. parser.addListener("startrule", function() {
  6692. gradients = {
  6693. moz: 0,
  6694. webkit: 0,
  6695. oldWebkit: 0,
  6696. o: 0
  6697. };
  6698. });
  6699. parser.addListener("property", function(event) {
  6700. if (/\-(moz|o|webkit)(?:\-(?:linear|radial))\-gradient/i.test(event.value)) {
  6701. gradients[RegExp.$1] = 1;
  6702. } else if (/\-webkit\-gradient/i.test(event.value)) {
  6703. gradients.oldWebkit = 1;
  6704. }
  6705. });
  6706. parser.addListener("endrule", function(event) {
  6707. var missing = [];
  6708. if (!gradients.moz) {
  6709. missing.push("Firefox 3.6+");
  6710. }
  6711. if (!gradients.webkit) {
  6712. missing.push("Webkit (Safari 5+, Chrome)");
  6713. }
  6714. if (!gradients.oldWebkit) {
  6715. missing.push("Old Webkit (Safari 4+, Chrome)");
  6716. }
  6717. if (!gradients.o) {
  6718. missing.push("Opera 11.1+");
  6719. }
  6720. if (missing.length && missing.length < 4) {
  6721. reporter.report("Missing vendor-prefixed CSS gradients for " + missing.join(", ") + ".", event.selectors[0].line, event.selectors[0].col, rule);
  6722. }
  6723. });
  6724. }
  6725. });
  6726. CSSLint.addRule({
  6727. id: "ids",
  6728. name: "Disallow IDs in selectors",
  6729. desc: "Selectors should not contain IDs.",
  6730. url: "https://github.com/CSSLint/csslint/wiki/Disallow-IDs-in-selectors",
  6731. browsers: "All",
  6732. init: function(parser, reporter) {
  6733. "use strict";
  6734. var rule = this;
  6735. parser.addListener("startrule", function(event) {
  6736. var selectors = event.selectors,
  6737. selector,
  6738. part,
  6739. modifier,
  6740. idCount,
  6741. i, j, k;
  6742. for (i=0; i < selectors.length; i++) {
  6743. selector = selectors[i];
  6744. idCount = 0;
  6745. for (j=0; j < selector.parts.length; j++) {
  6746. part = selector.parts[j];
  6747. if (part.type === parser.SELECTOR_PART_TYPE) {
  6748. for (k=0; k < part.modifiers.length; k++) {
  6749. modifier = part.modifiers[k];
  6750. if (modifier.type === "id") {
  6751. idCount++;
  6752. }
  6753. }
  6754. }
  6755. }
  6756. if (idCount === 1) {
  6757. reporter.report("Don't use IDs in selectors.", selector.line, selector.col, rule);
  6758. } else if (idCount > 1) {
  6759. reporter.report(idCount + " IDs in the selector, really?", selector.line, selector.col, rule);
  6760. }
  6761. }
  6762. });
  6763. }
  6764. });
  6765. CSSLint.addRule({
  6766. id: "import-ie-limit",
  6767. name: "@import limit on IE6-IE9",
  6768. desc: "IE6-9 supports up to 31 @import per stylesheet",
  6769. browsers: "IE6, IE7, IE8, IE9",
  6770. init: function(parser, reporter) {
  6771. "use strict";
  6772. var rule = this,
  6773. MAX_IMPORT_COUNT = 31,
  6774. count = 0;
  6775. function startPage() {
  6776. count = 0;
  6777. }
  6778. parser.addListener("startpage", startPage);
  6779. parser.addListener("import", function() {
  6780. count++;
  6781. });
  6782. parser.addListener("endstylesheet", function() {
  6783. if (count > MAX_IMPORT_COUNT) {
  6784. reporter.rollupError(
  6785. "Too many @import rules (" + count + "). IE6-9 supports up to 31 import per stylesheet.",
  6786. rule
  6787. );
  6788. }
  6789. });
  6790. }
  6791. });
  6792. CSSLint.addRule({
  6793. id: "import",
  6794. name: "Disallow @import",
  6795. desc: "Don't use @import, use <link> instead.",
  6796. url: "https://github.com/CSSLint/csslint/wiki/Disallow-%40import",
  6797. browsers: "All",
  6798. init: function(parser, reporter) {
  6799. "use strict";
  6800. var rule = this;
  6801. parser.addListener("import", function(event) {
  6802. reporter.report("@import prevents parallel downloads, use <link> instead.", event.line, event.col, rule);
  6803. });
  6804. }
  6805. });
  6806. CSSLint.addRule({
  6807. id: "important",
  6808. name: "Disallow !important",
  6809. desc: "Be careful when using !important declaration",
  6810. url: "https://github.com/CSSLint/csslint/wiki/Disallow-%21important",
  6811. browsers: "All",
  6812. init: function(parser, reporter) {
  6813. "use strict";
  6814. var rule = this,
  6815. count = 0;
  6816. parser.addListener("property", function(event) {
  6817. if (!reporter.isIgnored(event.line)) {
  6818. if (event.important === true) {
  6819. count++;
  6820. reporter.report("Use of !important", event.line, event.col, rule);
  6821. }
  6822. }
  6823. });
  6824. parser.addListener("endstylesheet", function() {
  6825. reporter.stat("important", count);
  6826. if (count >= 10) {
  6827. reporter.rollupWarn("Too many !important declarations (" + count + "), try to use less than 10 to avoid specificity issues.", rule);
  6828. }
  6829. });
  6830. }
  6831. });
  6832. CSSLint.addRule({
  6833. id: "known-properties",
  6834. name: "Require use of known properties",
  6835. desc: "Properties should be known (listed in CSS3 specification) or be a vendor-prefixed property.",
  6836. url: "https://github.com/CSSLint/csslint/wiki/Require-use-of-known-properties",
  6837. browsers: "All",
  6838. init: function(parser, reporter) {
  6839. "use strict";
  6840. var rule = this;
  6841. parser.addListener("property", function(event) {
  6842. if (event.invalid) {
  6843. reporter.report(event.invalid.message, event.line, event.col, rule);
  6844. }
  6845. });
  6846. }
  6847. });
  6848. CSSLint.addRule({
  6849. id: "order-alphabetical",
  6850. name: "Alphabetical order",
  6851. desc: "Assure properties are in alphabetical order",
  6852. browsers: "All",
  6853. init: function(parser, reporter) {
  6854. "use strict";
  6855. var rule = this,
  6856. properties;
  6857. var startRule = function () {
  6858. properties = [];
  6859. };
  6860. var endRule = function(event) {
  6861. var currentProperties = properties.join(","),
  6862. expectedProperties = properties.sort().join(",");
  6863. if (currentProperties !== expectedProperties) {
  6864. reporter.report("Rule doesn't have all its properties in alphabetical order.", event.line, event.col, rule);
  6865. }
  6866. };
  6867. parser.addListener("startrule", startRule);
  6868. parser.addListener("startfontface", startRule);
  6869. parser.addListener("startpage", startRule);
  6870. parser.addListener("startpagemargin", startRule);
  6871. parser.addListener("startkeyframerule", startRule);
  6872. parser.addListener("startviewport", startRule);
  6873. parser.addListener("property", function(event) {
  6874. var name = event.property.text,
  6875. lowerCasePrefixLessName = name.toLowerCase().replace(/^-.*?-/, "");
  6876. properties.push(lowerCasePrefixLessName);
  6877. });
  6878. parser.addListener("endrule", endRule);
  6879. parser.addListener("endfontface", endRule);
  6880. parser.addListener("endpage", endRule);
  6881. parser.addListener("endpagemargin", endRule);
  6882. parser.addListener("endkeyframerule", endRule);
  6883. parser.addListener("endviewport", endRule);
  6884. }
  6885. });
  6886. CSSLint.addRule({
  6887. id: "outline-none",
  6888. name: "Disallow outline: none",
  6889. desc: "Use of outline: none or outline: 0 should be limited to :focus rules.",
  6890. url: "https://github.com/CSSLint/csslint/wiki/Disallow-outline%3Anone",
  6891. browsers: "All",
  6892. tags: ["Accessibility"],
  6893. init: function(parser, reporter) {
  6894. "use strict";
  6895. var rule = this,
  6896. lastRule;
  6897. function startRule(event) {
  6898. if (event.selectors) {
  6899. lastRule = {
  6900. line: event.line,
  6901. col: event.col,
  6902. selectors: event.selectors,
  6903. propCount: 0,
  6904. outline: false
  6905. };
  6906. } else {
  6907. lastRule = null;
  6908. }
  6909. }
  6910. function endRule() {
  6911. if (lastRule) {
  6912. if (lastRule.outline) {
  6913. if (lastRule.selectors.toString().toLowerCase().indexOf(":focus") === -1) {
  6914. reporter.report("Outlines should only be modified using :focus.", lastRule.line, lastRule.col, rule);
  6915. } else if (lastRule.propCount === 1) {
  6916. reporter.report("Outlines shouldn't be hidden unless other visual changes are made.", lastRule.line, lastRule.col, rule);
  6917. }
  6918. }
  6919. }
  6920. }
  6921. parser.addListener("startrule", startRule);
  6922. parser.addListener("startfontface", startRule);
  6923. parser.addListener("startpage", startRule);
  6924. parser.addListener("startpagemargin", startRule);
  6925. parser.addListener("startkeyframerule", startRule);
  6926. parser.addListener("startviewport", startRule);
  6927. parser.addListener("property", function(event) {
  6928. var name = event.property.text.toLowerCase(),
  6929. value = event.value;
  6930. if (lastRule) {
  6931. lastRule.propCount++;
  6932. if (name === "outline" && (value.toString() === "none" || value.toString() === "0")) {
  6933. lastRule.outline = true;
  6934. }
  6935. }
  6936. });
  6937. parser.addListener("endrule", endRule);
  6938. parser.addListener("endfontface", endRule);
  6939. parser.addListener("endpage", endRule);
  6940. parser.addListener("endpagemargin", endRule);
  6941. parser.addListener("endkeyframerule", endRule);
  6942. parser.addListener("endviewport", endRule);
  6943. }
  6944. });
  6945. CSSLint.addRule({
  6946. id: "overqualified-elements",
  6947. name: "Disallow overqualified elements",
  6948. desc: "Don't use classes or IDs with elements (a.foo or a#foo).",
  6949. url: "https://github.com/CSSLint/csslint/wiki/Disallow-overqualified-elements",
  6950. browsers: "All",
  6951. init: function(parser, reporter) {
  6952. "use strict";
  6953. var rule = this,
  6954. classes = {};
  6955. parser.addListener("startrule", function(event) {
  6956. var selectors = event.selectors,
  6957. selector,
  6958. part,
  6959. modifier,
  6960. i, j, k;
  6961. for (i=0; i < selectors.length; i++) {
  6962. selector = selectors[i];
  6963. for (j=0; j < selector.parts.length; j++) {
  6964. part = selector.parts[j];
  6965. if (part.type === parser.SELECTOR_PART_TYPE) {
  6966. for (k=0; k < part.modifiers.length; k++) {
  6967. modifier = part.modifiers[k];
  6968. if (part.elementName && modifier.type === "id") {
  6969. reporter.report("Element (" + part + ") is overqualified, just use " + modifier + " without element name.", part.line, part.col, rule);
  6970. } else if (modifier.type === "class") {
  6971. if (!classes[modifier]) {
  6972. classes[modifier] = [];
  6973. }
  6974. classes[modifier].push({
  6975. modifier: modifier,
  6976. part: part
  6977. });
  6978. }
  6979. }
  6980. }
  6981. }
  6982. }
  6983. });
  6984. parser.addListener("endstylesheet", function() {
  6985. var prop;
  6986. for (prop in classes) {
  6987. if (classes.hasOwnProperty(prop)) {
  6988. if (classes[prop].length === 1 && classes[prop][0].part.elementName) {
  6989. reporter.report("Element (" + classes[prop][0].part + ") is overqualified, just use " + classes[prop][0].modifier + " without element name.", classes[prop][0].part.line, classes[prop][0].part.col, rule);
  6990. }
  6991. }
  6992. }
  6993. });
  6994. }
  6995. });
  6996. CSSLint.addRule({
  6997. id: "regex-selectors",
  6998. name: "Disallow selectors that look like regexs",
  6999. desc: "Selectors that look like regular expressions are slow and should be avoided.",
  7000. url: "https://github.com/CSSLint/csslint/wiki/Disallow-selectors-that-look-like-regular-expressions",
  7001. browsers: "All",
  7002. init: function(parser, reporter) {
  7003. "use strict";
  7004. var rule = this;
  7005. parser.addListener("startrule", function(event) {
  7006. var selectors = event.selectors,
  7007. selector,
  7008. part,
  7009. modifier,
  7010. i, j, k;
  7011. for (i=0; i < selectors.length; i++) {
  7012. selector = selectors[i];
  7013. for (j=0; j < selector.parts.length; j++) {
  7014. part = selector.parts[j];
  7015. if (part.type === parser.SELECTOR_PART_TYPE) {
  7016. for (k=0; k < part.modifiers.length; k++) {
  7017. modifier = part.modifiers[k];
  7018. if (modifier.type === "attribute") {
  7019. if (/([~\|\^\$\*]=)/.test(modifier)) {
  7020. reporter.report("Attribute selectors with " + RegExp.$1 + " are slow!", modifier.line, modifier.col, rule);
  7021. }
  7022. }
  7023. }
  7024. }
  7025. }
  7026. }
  7027. });
  7028. }
  7029. });
  7030. CSSLint.addRule({
  7031. id: "rules-count",
  7032. name: "Rules Count",
  7033. desc: "Track how many rules there are.",
  7034. browsers: "All",
  7035. init: function(parser, reporter) {
  7036. "use strict";
  7037. var count = 0;
  7038. parser.addListener("startrule", function() {
  7039. count++;
  7040. });
  7041. parser.addListener("endstylesheet", function() {
  7042. reporter.stat("rule-count", count);
  7043. });
  7044. }
  7045. });
  7046. CSSLint.addRule({
  7047. id: "selector-max-approaching",
  7048. name: "Warn when approaching the 4095 selector limit for IE",
  7049. desc: "Will warn when selector count is >= 3800 selectors.",
  7050. browsers: "IE",
  7051. init: function(parser, reporter) {
  7052. "use strict";
  7053. var rule = this, count = 0;
  7054. parser.addListener("startrule", function(event) {
  7055. count += event.selectors.length;
  7056. });
  7057. parser.addListener("endstylesheet", function() {
  7058. if (count >= 3800) {
  7059. reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
  7060. }
  7061. });
  7062. }
  7063. });
  7064. CSSLint.addRule({
  7065. id: "selector-max",
  7066. name: "Error when past the 4095 selector limit for IE",
  7067. desc: "Will error when selector count is > 4095.",
  7068. browsers: "IE",
  7069. init: function(parser, reporter) {
  7070. "use strict";
  7071. var rule = this, count = 0;
  7072. parser.addListener("startrule", function(event) {
  7073. count += event.selectors.length;
  7074. });
  7075. parser.addListener("endstylesheet", function() {
  7076. if (count > 4095) {
  7077. reporter.report("You have " + count + " selectors. Internet Explorer supports a maximum of 4095 selectors per stylesheet. Consider refactoring.", 0, 0, rule);
  7078. }
  7079. });
  7080. }
  7081. });
  7082. CSSLint.addRule({
  7083. id: "selector-newline",
  7084. name: "Disallow new-line characters in selectors",
  7085. desc: "New-line characters in selectors are usually a forgotten comma and not a descendant combinator.",
  7086. browsers: "All",
  7087. init: function(parser, reporter) {
  7088. "use strict";
  7089. var rule = this;
  7090. function startRule(event) {
  7091. var i, len, selector, p, n, pLen, part, part2, type, currentLine, nextLine,
  7092. selectors = event.selectors;
  7093. for (i = 0, len = selectors.length; i < len; i++) {
  7094. selector = selectors[i];
  7095. for (p = 0, pLen = selector.parts.length; p < pLen; p++) {
  7096. for (n = p + 1; n < pLen; n++) {
  7097. part = selector.parts[p];
  7098. part2 = selector.parts[n];
  7099. type = part.type;
  7100. currentLine = part.line;
  7101. nextLine = part2.line;
  7102. if (type === "descendant" && nextLine > currentLine) {
  7103. reporter.report("newline character found in selector (forgot a comma?)", currentLine, selectors[i].parts[0].col, rule);
  7104. }
  7105. }
  7106. }
  7107. }
  7108. }
  7109. parser.addListener("startrule", startRule);
  7110. }
  7111. });
  7112. CSSLint.addRule({
  7113. id: "shorthand",
  7114. name: "Require shorthand properties",
  7115. desc: "Use shorthand properties where possible.",
  7116. url: "https://github.com/CSSLint/csslint/wiki/Require-shorthand-properties",
  7117. browsers: "All",
  7118. init: function(parser, reporter) {
  7119. "use strict";
  7120. var rule = this,
  7121. prop, i, len,
  7122. propertiesToCheck = {},
  7123. properties,
  7124. mapping = {
  7125. "margin": [
  7126. "margin-top",
  7127. "margin-bottom",
  7128. "margin-left",
  7129. "margin-right"
  7130. ],
  7131. "padding": [
  7132. "padding-top",
  7133. "padding-bottom",
  7134. "padding-left",
  7135. "padding-right"
  7136. ]
  7137. };
  7138. for (prop in mapping) {
  7139. if (mapping.hasOwnProperty(prop)) {
  7140. for (i=0, len=mapping[prop].length; i < len; i++) {
  7141. propertiesToCheck[mapping[prop][i]] = prop;
  7142. }
  7143. }
  7144. }
  7145. function startRule() {
  7146. properties = {};
  7147. }
  7148. function endRule(event) {
  7149. var prop, i, len, total;
  7150. for (prop in mapping) {
  7151. if (mapping.hasOwnProperty(prop)) {
  7152. total=0;
  7153. for (i=0, len=mapping[prop].length; i < len; i++) {
  7154. total += properties[mapping[prop][i]] ? 1 : 0;
  7155. }
  7156. if (total === mapping[prop].length) {
  7157. reporter.report("The properties " + mapping[prop].join(", ") + " can be replaced by " + prop + ".", event.line, event.col, rule);
  7158. }
  7159. }
  7160. }
  7161. }
  7162. parser.addListener("startrule", startRule);
  7163. parser.addListener("startfontface", startRule);
  7164. parser.addListener("property", function(event) {
  7165. var name = event.property.toString().toLowerCase();
  7166. if (propertiesToCheck[name]) {
  7167. properties[name] = 1;
  7168. }
  7169. });
  7170. parser.addListener("endrule", endRule);
  7171. parser.addListener("endfontface", endRule);
  7172. }
  7173. });
  7174. CSSLint.addRule({
  7175. id: "star-property-hack",
  7176. name: "Disallow properties with a star prefix",
  7177. desc: "Checks for the star property hack (targets IE6/7)",
  7178. url: "https://github.com/CSSLint/csslint/wiki/Disallow-star-hack",
  7179. browsers: "All",
  7180. init: function(parser, reporter) {
  7181. "use strict";
  7182. var rule = this;
  7183. parser.addListener("property", function(event) {
  7184. var property = event.property;
  7185. if (property.hack === "*") {
  7186. reporter.report("Property with star prefix found.", event.property.line, event.property.col, rule);
  7187. }
  7188. });
  7189. }
  7190. });
  7191. CSSLint.addRule({
  7192. id: "text-indent",
  7193. name: "Disallow negative text-indent",
  7194. desc: "Checks for text indent less than -99px",
  7195. url: "https://github.com/CSSLint/csslint/wiki/Disallow-negative-text-indent",
  7196. browsers: "All",
  7197. init: function(parser, reporter) {
  7198. "use strict";
  7199. var rule = this,
  7200. textIndent,
  7201. direction;
  7202. function startRule() {
  7203. textIndent = false;
  7204. direction = "inherit";
  7205. }
  7206. function endRule() {
  7207. if (textIndent && direction !== "ltr") {
  7208. reporter.report("Negative text-indent doesn't work well with RTL. If you use text-indent for image replacement explicitly set direction for that item to ltr.", textIndent.line, textIndent.col, rule);
  7209. }
  7210. }
  7211. parser.addListener("startrule", startRule);
  7212. parser.addListener("startfontface", startRule);
  7213. parser.addListener("property", function(event) {
  7214. var name = event.property.toString().toLowerCase(),
  7215. value = event.value;
  7216. if (name === "text-indent" && value.parts[0].value < -99) {
  7217. textIndent = event.property;
  7218. } else if (name === "direction" && value.toString() === "ltr") {
  7219. direction = "ltr";
  7220. }
  7221. });
  7222. parser.addListener("endrule", endRule);
  7223. parser.addListener("endfontface", endRule);
  7224. }
  7225. });
  7226. CSSLint.addRule({
  7227. id: "underscore-property-hack",
  7228. name: "Disallow properties with an underscore prefix",
  7229. desc: "Checks for the underscore property hack (targets IE6)",
  7230. url: "https://github.com/CSSLint/csslint/wiki/Disallow-underscore-hack",
  7231. browsers: "All",
  7232. init: function(parser, reporter) {
  7233. "use strict";
  7234. var rule = this;
  7235. parser.addListener("property", function(event) {
  7236. var property = event.property;
  7237. if (property.hack === "_") {
  7238. reporter.report("Property with underscore prefix found.", event.property.line, event.property.col, rule);
  7239. }
  7240. });
  7241. }
  7242. });
  7243. CSSLint.addRule({
  7244. id: "universal-selector",
  7245. name: "Disallow universal selector",
  7246. desc: "The universal selector (*) is known to be slow.",
  7247. url: "https://github.com/CSSLint/csslint/wiki/Disallow-universal-selector",
  7248. browsers: "All",
  7249. init: function(parser, reporter) {
  7250. "use strict";
  7251. var rule = this;
  7252. parser.addListener("startrule", function(event) {
  7253. var selectors = event.selectors,
  7254. selector,
  7255. part,
  7256. i;
  7257. for (i=0; i < selectors.length; i++) {
  7258. selector = selectors[i];
  7259. part = selector.parts[selector.parts.length-1];
  7260. if (part.elementName === "*") {
  7261. reporter.report(rule.desc, part.line, part.col, rule);
  7262. }
  7263. }
  7264. });
  7265. }
  7266. });
  7267. CSSLint.addRule({
  7268. id: "unqualified-attributes",
  7269. name: "Disallow unqualified attribute selectors",
  7270. desc: "Unqualified attribute selectors are known to be slow.",
  7271. url: "https://github.com/CSSLint/csslint/wiki/Disallow-unqualified-attribute-selectors",
  7272. browsers: "All",
  7273. init: function(parser, reporter) {
  7274. "use strict";
  7275. var rule = this;
  7276. parser.addListener("startrule", function(event) {
  7277. var selectors = event.selectors,
  7278. selectorContainsClassOrId = false,
  7279. selector,
  7280. part,
  7281. modifier,
  7282. i, k;
  7283. for (i=0; i < selectors.length; i++) {
  7284. selector = selectors[i];
  7285. part = selector.parts[selector.parts.length-1];
  7286. if (part.type === parser.SELECTOR_PART_TYPE) {
  7287. for (k=0; k < part.modifiers.length; k++) {
  7288. modifier = part.modifiers[k];
  7289. if (modifier.type === "class" || modifier.type === "id") {
  7290. selectorContainsClassOrId = true;
  7291. break;
  7292. }
  7293. }
  7294. if (!selectorContainsClassOrId) {
  7295. for (k=0; k < part.modifiers.length; k++) {
  7296. modifier = part.modifiers[k];
  7297. if (modifier.type === "attribute" && (!part.elementName || part.elementName === "*")) {
  7298. reporter.report(rule.desc, part.line, part.col, rule);
  7299. }
  7300. }
  7301. }
  7302. }
  7303. }
  7304. });
  7305. }
  7306. });
  7307. CSSLint.addRule({
  7308. id: "vendor-prefix",
  7309. name: "Require standard property with vendor prefix",
  7310. desc: "When using a vendor-prefixed property, make sure to include the standard one.",
  7311. url: "https://github.com/CSSLint/csslint/wiki/Require-standard-property-with-vendor-prefix",
  7312. browsers: "All",
  7313. init: function(parser, reporter) {
  7314. "use strict";
  7315. var rule = this,
  7316. properties,
  7317. num,
  7318. propertiesToCheck = {
  7319. "-webkit-border-radius": "border-radius",
  7320. "-webkit-border-top-left-radius": "border-top-left-radius",
  7321. "-webkit-border-top-right-radius": "border-top-right-radius",
  7322. "-webkit-border-bottom-left-radius": "border-bottom-left-radius",
  7323. "-webkit-border-bottom-right-radius": "border-bottom-right-radius",
  7324. "-o-border-radius": "border-radius",
  7325. "-o-border-top-left-radius": "border-top-left-radius",
  7326. "-o-border-top-right-radius": "border-top-right-radius",
  7327. "-o-border-bottom-left-radius": "border-bottom-left-radius",
  7328. "-o-border-bottom-right-radius": "border-bottom-right-radius",
  7329. "-moz-border-radius": "border-radius",
  7330. "-moz-border-radius-topleft": "border-top-left-radius",
  7331. "-moz-border-radius-topright": "border-top-right-radius",
  7332. "-moz-border-radius-bottomleft": "border-bottom-left-radius",
  7333. "-moz-border-radius-bottomright": "border-bottom-right-radius",
  7334. "-moz-column-count": "column-count",
  7335. "-webkit-column-count": "column-count",
  7336. "-moz-column-gap": "column-gap",
  7337. "-webkit-column-gap": "column-gap",
  7338. "-moz-column-rule": "column-rule",
  7339. "-webkit-column-rule": "column-rule",
  7340. "-moz-column-rule-style": "column-rule-style",
  7341. "-webkit-column-rule-style": "column-rule-style",
  7342. "-moz-column-rule-color": "column-rule-color",
  7343. "-webkit-column-rule-color": "column-rule-color",
  7344. "-moz-column-rule-width": "column-rule-width",
  7345. "-webkit-column-rule-width": "column-rule-width",
  7346. "-moz-column-width": "column-width",
  7347. "-webkit-column-width": "column-width",
  7348. "-webkit-column-span": "column-span",
  7349. "-webkit-columns": "columns",
  7350. "-moz-box-shadow": "box-shadow",
  7351. "-webkit-box-shadow": "box-shadow",
  7352. "-moz-transform": "transform",
  7353. "-webkit-transform": "transform",
  7354. "-o-transform": "transform",
  7355. "-ms-transform": "transform",
  7356. "-moz-transform-origin": "transform-origin",
  7357. "-webkit-transform-origin": "transform-origin",
  7358. "-o-transform-origin": "transform-origin",
  7359. "-ms-transform-origin": "transform-origin",
  7360. "-moz-box-sizing": "box-sizing",
  7361. "-webkit-box-sizing": "box-sizing"
  7362. };
  7363. function startRule() {
  7364. properties = {};
  7365. num = 1;
  7366. }
  7367. function endRule() {
  7368. var prop,
  7369. i,
  7370. len,
  7371. needed,
  7372. actual,
  7373. needsStandard = [];
  7374. for (prop in properties) {
  7375. if (propertiesToCheck[prop]) {
  7376. needsStandard.push({
  7377. actual: prop,
  7378. needed: propertiesToCheck[prop]
  7379. });
  7380. }
  7381. }
  7382. for (i=0, len=needsStandard.length; i < len; i++) {
  7383. needed = needsStandard[i].needed;
  7384. actual = needsStandard[i].actual;
  7385. if (!properties[needed]) {
  7386. reporter.report("Missing standard property '" + needed + "' to go along with '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
  7387. } else {
  7388. if (properties[needed][0].pos < properties[actual][0].pos) {
  7389. reporter.report("Standard property '" + needed + "' should come after vendor-prefixed property '" + actual + "'.", properties[actual][0].name.line, properties[actual][0].name.col, rule);
  7390. }
  7391. }
  7392. }
  7393. }
  7394. parser.addListener("startrule", startRule);
  7395. parser.addListener("startfontface", startRule);
  7396. parser.addListener("startpage", startRule);
  7397. parser.addListener("startpagemargin", startRule);
  7398. parser.addListener("startkeyframerule", startRule);
  7399. parser.addListener("startviewport", startRule);
  7400. parser.addListener("property", function(event) {
  7401. var name = event.property.text.toLowerCase();
  7402. if (!properties[name]) {
  7403. properties[name] = [];
  7404. }
  7405. properties[name].push({
  7406. name: event.property,
  7407. value: event.value,
  7408. pos: num++
  7409. });
  7410. });
  7411. parser.addListener("endrule", endRule);
  7412. parser.addListener("endfontface", endRule);
  7413. parser.addListener("endpage", endRule);
  7414. parser.addListener("endpagemargin", endRule);
  7415. parser.addListener("endkeyframerule", endRule);
  7416. parser.addListener("endviewport", endRule);
  7417. }
  7418. });
  7419. CSSLint.addRule({
  7420. id: "zero-units",
  7421. name: "Disallow units for 0 values",
  7422. desc: "You don't need to specify units when a value is 0.",
  7423. url: "https://github.com/CSSLint/csslint/wiki/Disallow-units-for-zero-values",
  7424. browsers: "All",
  7425. init: function(parser, reporter) {
  7426. "use strict";
  7427. var rule = this;
  7428. parser.addListener("property", function(event) {
  7429. var parts = event.value.parts,
  7430. i = 0,
  7431. len = parts.length;
  7432. while (i < len) {
  7433. if ((parts[i].units || parts[i].type === "percentage") && parts[i].value === 0 && parts[i].type !== "time") {
  7434. reporter.report("Values of 0 shouldn't have units specified.", parts[i].line, parts[i].col, rule);
  7435. }
  7436. i++;
  7437. }
  7438. });
  7439. }
  7440. });
  7441. (function() {
  7442. "use strict";
  7443. var xmlEscape = function(str) {
  7444. if (!str || str.constructor !== String) {
  7445. return "";
  7446. }
  7447. return str.replace(/["&><]/g, function(match) {
  7448. switch (match) {
  7449. case "\"":
  7450. return "&quot;";
  7451. case "&":
  7452. return "&amp;";
  7453. case "<":
  7454. return "&lt;";
  7455. case ">":
  7456. return "&gt;";
  7457. }
  7458. });
  7459. };
  7460. CSSLint.addFormatter({
  7461. id: "checkstyle-xml",
  7462. name: "Checkstyle XML format",
  7463. startFormat: function() {
  7464. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><checkstyle>";
  7465. },
  7466. endFormat: function() {
  7467. return "</checkstyle>";
  7468. },
  7469. readError: function(filename, message) {
  7470. return "<file name=\"" + xmlEscape(filename) + "\"><error line=\"0\" column=\"0\" severty=\"error\" message=\"" + xmlEscape(message) + "\"></error></file>";
  7471. },
  7472. formatResults: function(results, filename/*, options*/) {
  7473. var messages = results.messages,
  7474. output = [];
  7475. var generateSource = function(rule) {
  7476. if (!rule || !("name" in rule)) {
  7477. return "";
  7478. }
  7479. return "net.csslint." + rule.name.replace(/\s/g, "");
  7480. };
  7481. if (messages.length > 0) {
  7482. output.push("<file name=\""+filename+"\">");
  7483. CSSLint.Util.forEach(messages, function (message) {
  7484. if (!message.rollup) {
  7485. output.push("<error line=\"" + message.line + "\" column=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7486. " message=\"" + xmlEscape(message.message) + "\" source=\"" + generateSource(message.rule) +"\"/>");
  7487. }
  7488. });
  7489. output.push("</file>");
  7490. }
  7491. return output.join("");
  7492. }
  7493. });
  7494. }());
  7495. CSSLint.addFormatter({
  7496. id: "compact",
  7497. name: "Compact, 'porcelain' format",
  7498. startFormat: function() {
  7499. "use strict";
  7500. return "";
  7501. },
  7502. endFormat: function() {
  7503. "use strict";
  7504. return "";
  7505. },
  7506. formatResults: function(results, filename, options) {
  7507. "use strict";
  7508. var messages = results.messages,
  7509. output = "";
  7510. options = options || {};
  7511. var capitalize = function(str) {
  7512. return str.charAt(0).toUpperCase() + str.slice(1);
  7513. };
  7514. if (messages.length === 0) {
  7515. return options.quiet ? "" : filename + ": Lint Free!";
  7516. }
  7517. CSSLint.Util.forEach(messages, function(message) {
  7518. if (message.rollup) {
  7519. output += filename + ": " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
  7520. } else {
  7521. output += filename + ": line " + message.line +
  7522. ", col " + message.col + ", " + capitalize(message.type) + " - " + message.message + " (" + message.rule.id + ")\n";
  7523. }
  7524. });
  7525. return output;
  7526. }
  7527. });
  7528. CSSLint.addFormatter({
  7529. id: "csslint-xml",
  7530. name: "CSSLint XML format",
  7531. startFormat: function() {
  7532. "use strict";
  7533. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><csslint>";
  7534. },
  7535. endFormat: function() {
  7536. "use strict";
  7537. return "</csslint>";
  7538. },
  7539. formatResults: function(results, filename/*, options*/) {
  7540. "use strict";
  7541. var messages = results.messages,
  7542. output = [];
  7543. var escapeSpecialCharacters = function(str) {
  7544. if (!str || str.constructor !== String) {
  7545. return "";
  7546. }
  7547. return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7548. };
  7549. if (messages.length > 0) {
  7550. output.push("<file name=\""+filename+"\">");
  7551. CSSLint.Util.forEach(messages, function (message) {
  7552. if (message.rollup) {
  7553. output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7554. } else {
  7555. output.push("<issue line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7556. " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7557. }
  7558. });
  7559. output.push("</file>");
  7560. }
  7561. return output.join("");
  7562. }
  7563. });
  7564. CSSLint.addFormatter({
  7565. id: "json",
  7566. name: "JSON",
  7567. startFormat: function() {
  7568. "use strict";
  7569. this.json = [];
  7570. return "";
  7571. },
  7572. endFormat: function() {
  7573. "use strict";
  7574. var ret = "";
  7575. if (this.json.length > 0) {
  7576. if (this.json.length === 1) {
  7577. ret = JSON.stringify(this.json[0]);
  7578. } else {
  7579. ret = JSON.stringify(this.json);
  7580. }
  7581. }
  7582. return ret;
  7583. },
  7584. formatResults: function(results, filename, options) {
  7585. "use strict";
  7586. if (results.messages.length > 0 || !options.quiet) {
  7587. this.json.push({
  7588. filename: filename,
  7589. messages: results.messages,
  7590. stats: results.stats
  7591. });
  7592. }
  7593. return "";
  7594. }
  7595. });
  7596. CSSLint.addFormatter({
  7597. id: "junit-xml",
  7598. name: "JUNIT XML format",
  7599. startFormat: function() {
  7600. "use strict";
  7601. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><testsuites>";
  7602. },
  7603. endFormat: function() {
  7604. "use strict";
  7605. return "</testsuites>";
  7606. },
  7607. formatResults: function(results, filename/*, options*/) {
  7608. "use strict";
  7609. var messages = results.messages,
  7610. output = [],
  7611. tests = {
  7612. "error": 0,
  7613. "failure": 0
  7614. };
  7615. var generateSource = function(rule) {
  7616. if (!rule || !("name" in rule)) {
  7617. return "";
  7618. }
  7619. return "net.csslint." + rule.name.replace(/\s/g, "");
  7620. };
  7621. var escapeSpecialCharacters = function(str) {
  7622. if (!str || str.constructor !== String) {
  7623. return "";
  7624. }
  7625. return str.replace(/"/g, "'").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7626. };
  7627. if (messages.length > 0) {
  7628. messages.forEach(function (message) {
  7629. var type = message.type === "warning" ? "error" : message.type;
  7630. if (!message.rollup) {
  7631. output.push("<testcase time=\"0\" name=\"" + generateSource(message.rule) + "\">");
  7632. output.push("<" + type + " message=\"" + escapeSpecialCharacters(message.message) + "\"><![CDATA[" + message.line + ":" + message.col + ":" + escapeSpecialCharacters(message.evidence) + "]]></" + type + ">");
  7633. output.push("</testcase>");
  7634. tests[type] += 1;
  7635. }
  7636. });
  7637. output.unshift("<testsuite time=\"0\" tests=\"" + messages.length + "\" skipped=\"0\" errors=\"" + tests.error + "\" failures=\"" + tests.failure + "\" package=\"net.csslint\" name=\"" + filename + "\">");
  7638. output.push("</testsuite>");
  7639. }
  7640. return output.join("");
  7641. }
  7642. });
  7643. CSSLint.addFormatter({
  7644. id: "lint-xml",
  7645. name: "Lint XML format",
  7646. startFormat: function() {
  7647. "use strict";
  7648. return "<?xml version=\"1.0\" encoding=\"utf-8\"?><lint>";
  7649. },
  7650. endFormat: function() {
  7651. "use strict";
  7652. return "</lint>";
  7653. },
  7654. formatResults: function(results, filename/*, options*/) {
  7655. "use strict";
  7656. var messages = results.messages,
  7657. output = [];
  7658. var escapeSpecialCharacters = function(str) {
  7659. if (!str || str.constructor !== String) {
  7660. return "";
  7661. }
  7662. return str.replace(/"/g, "'").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
  7663. };
  7664. if (messages.length > 0) {
  7665. output.push("<file name=\""+filename+"\">");
  7666. CSSLint.Util.forEach(messages, function (message) {
  7667. if (message.rollup) {
  7668. output.push("<issue severity=\"" + message.type + "\" reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7669. } else {
  7670. var rule = "";
  7671. if (message.rule && message.rule.id) {
  7672. rule = "rule=\"" + escapeSpecialCharacters(message.rule.id) + "\" ";
  7673. }
  7674. output.push("<issue " + rule + "line=\"" + message.line + "\" char=\"" + message.col + "\" severity=\"" + message.type + "\"" +
  7675. " reason=\"" + escapeSpecialCharacters(message.message) + "\" evidence=\"" + escapeSpecialCharacters(message.evidence) + "\"/>");
  7676. }
  7677. });
  7678. output.push("</file>");
  7679. }
  7680. return output.join("");
  7681. }
  7682. });
  7683. CSSLint.addFormatter({
  7684. id: "text",
  7685. name: "Plain Text",
  7686. startFormat: function() {
  7687. "use strict";
  7688. return "";
  7689. },
  7690. endFormat: function() {
  7691. "use strict";
  7692. return "";
  7693. },
  7694. formatResults: function(results, filename, options) {
  7695. "use strict";
  7696. var messages = results.messages,
  7697. output = "";
  7698. options = options || {};
  7699. if (messages.length === 0) {
  7700. return options.quiet ? "" : "\n\ncsslint: No errors in " + filename + ".";
  7701. }
  7702. output = "\n\ncsslint: There ";
  7703. if (messages.length === 1) {
  7704. output += "is 1 problem";
  7705. } else {
  7706. output += "are " + messages.length + " problems";
  7707. }
  7708. output += " in " + filename + ".";
  7709. var pos = filename.lastIndexOf("/"),
  7710. shortFilename = filename;
  7711. if (pos === -1) {
  7712. pos = filename.lastIndexOf("\\");
  7713. }
  7714. if (pos > -1) {
  7715. shortFilename = filename.substring(pos+1);
  7716. }
  7717. CSSLint.Util.forEach(messages, function (message, i) {
  7718. output = output + "\n\n" + shortFilename;
  7719. if (message.rollup) {
  7720. output += "\n" + (i+1) + ": " + message.type;
  7721. output += "\n" + message.message;
  7722. } else {
  7723. output += "\n" + (i+1) + ": " + message.type + " at line " + message.line + ", col " + message.col;
  7724. output += "\n" + message.message;
  7725. output += "\n" + message.evidence;
  7726. }
  7727. });
  7728. return output;
  7729. }
  7730. });
  7731. return CSSLint;
  7732. })();
  7733. module.exports.CSSLint = CSSLint;
  7734. });
  7735. ace.define("ace/mode/css_worker",[], function(require, exports, module) {
  7736. "use strict";
  7737. var oop = require("../lib/oop");
  7738. var lang = require("../lib/lang");
  7739. var Mirror = require("../worker/mirror").Mirror;
  7740. var CSSLint = require("./css/csslint").CSSLint;
  7741. var Worker = exports.Worker = function(sender) {
  7742. Mirror.call(this, sender);
  7743. this.setTimeout(400);
  7744. this.ruleset = null;
  7745. this.setDisabledRules("ids|order-alphabetical");
  7746. this.setInfoRules(
  7747. "adjoining-classes|zero-units|gradients|box-model|" +
  7748. "import|outline-none|vendor-prefix"
  7749. );
  7750. };
  7751. oop.inherits(Worker, Mirror);
  7752. (function() {
  7753. this.setInfoRules = function(ruleNames) {
  7754. if (typeof ruleNames == "string")
  7755. ruleNames = ruleNames.split("|");
  7756. this.infoRules = lang.arrayToMap(ruleNames);
  7757. this.doc.getValue() && this.deferredUpdate.schedule(100);
  7758. };
  7759. this.setDisabledRules = function(ruleNames) {
  7760. if (!ruleNames) {
  7761. this.ruleset = null;
  7762. } else {
  7763. if (typeof ruleNames == "string")
  7764. ruleNames = ruleNames.split("|");
  7765. var all = {};
  7766. CSSLint.getRules().forEach(function(x){
  7767. all[x.id] = true;
  7768. });
  7769. ruleNames.forEach(function(x) {
  7770. delete all[x];
  7771. });
  7772. this.ruleset = all;
  7773. }
  7774. this.doc.getValue() && this.deferredUpdate.schedule(100);
  7775. };
  7776. this.onUpdate = function() {
  7777. var value = this.doc.getValue();
  7778. if (!value)
  7779. return this.sender.emit("annotate", []);
  7780. var infoRules = this.infoRules;
  7781. var result = CSSLint.verify(value, this.ruleset);
  7782. this.sender.emit("annotate", result.messages.map(function(msg) {
  7783. return {
  7784. row: msg.line - 1,
  7785. column: msg.col - 1,
  7786. text: msg.message,
  7787. type: infoRules[msg.rule.id] ? "info" : msg.type,
  7788. rule: msg.rule.name
  7789. };
  7790. }));
  7791. };
  7792. }).call(Worker.prototype);
  7793. });