6054c8238a6ead764130056d8c69d30e.js 307 KB

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