DOMParser.js 238 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284
  1. /**
  2. * DOMParser
  3. * @description 使用Env、OpenAPI等兼容方法进行网络请求, 这里使用Env举例
  4. * @example
  5. *
  6. const $ = new Env("ModuleName")
  7. async function loadDOMParser() {
  8. return new Promise(async (resolve) => {
  9. $.getScript(
  10. 'https://cdn.jsdelivr.net/gh/Yuheng0101/X@main/Utils/DOMParser.js'
  11. ).then((fn) => {
  12. eval(fn)
  13. const DOMParser = createDOMParser()
  14. console.log(`✅ DOMParser加载成功, 请继续`)
  15. resolve(DOMParser)
  16. })
  17. })
  18. }
  19. */
  20. function createDOMParser() {
  21. function r(e, n, t) {
  22. let result = {}
  23. function o(i, f) {
  24. if (!n[i]) {
  25. if (!e[i]) {
  26. var c = 'function' == typeof require && require
  27. if (!f && c) return c(i, !0)
  28. if (u) return u(i, !0)
  29. var a = new Error("Cannot find module '" + i + "'")
  30. throw ((a.code = 'MODULE_NOT_FOUND'), a)
  31. }
  32. var p = (n[i] = { exports: {} })
  33. e[i][0].call(
  34. p.exports,
  35. function (r) {
  36. var n = e[i][1][r]
  37. return o(n || r)
  38. },
  39. p,
  40. p.exports,
  41. r,
  42. e,
  43. n,
  44. t
  45. )
  46. }
  47. // console.log(n[i].exports)
  48. return n[i].exports
  49. }
  50. for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++) {
  51. Object.assign(result, o(t[i]))
  52. }
  53. return result
  54. }
  55. const utils = {
  56. 5: [
  57. function (require, module, exports) {
  58. 'use strict'
  59. /**
  60. * Ponyfill for `Array.prototype.find` which is only available in ES6 runtimes.
  61. *
  62. * Works with anything that has a `length` property and index access properties, including NodeList.
  63. *
  64. * @template {unknown} T
  65. * @param {Array<T> | ({length:number, [number]: T})} list
  66. * @param {function (item: T, index: number, list:Array<T> | ({length:number, [number]: T})):boolean} predicate
  67. * @param {Partial<Pick<ArrayConstructor['prototype'], 'find'>>?} ac `Array.prototype` by default,
  68. * allows injecting a custom implementation in tests
  69. * @returns {T | undefined}
  70. *
  71. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find
  72. * @see https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.find
  73. */
  74. function find(list, predicate, ac) {
  75. if (ac === undefined) {
  76. ac = Array.prototype
  77. }
  78. if (list && typeof ac.find === 'function') {
  79. return ac.find.call(list, predicate)
  80. }
  81. for (var i = 0; i < list.length; i++) {
  82. if (Object.prototype.hasOwnProperty.call(list, i)) {
  83. var item = list[i]
  84. if (predicate.call(undefined, item, i, list)) {
  85. return item
  86. }
  87. }
  88. }
  89. }
  90. /**
  91. * "Shallow freezes" an object to render it immutable.
  92. * Uses `Object.freeze` if available,
  93. * otherwise the immutability is only in the type.
  94. *
  95. * Is used to create "enum like" objects.
  96. *
  97. * @template T
  98. * @param {T} object the object to freeze
  99. * @param {Pick<ObjectConstructor, 'freeze'> = Object} oc `Object` by default,
  100. * allows to inject custom object constructor for tests
  101. * @returns {Readonly<T>}
  102. *
  103. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
  104. */
  105. function freeze(object, oc) {
  106. if (oc === undefined) {
  107. oc = Object
  108. }
  109. return oc && typeof oc.freeze === 'function' ? oc.freeze(object) : object
  110. }
  111. /**
  112. * Since we can not rely on `Object.assign` we provide a simplified version
  113. * that is sufficient for our needs.
  114. *
  115. * @param {Object} target
  116. * @param {Object | null | undefined} source
  117. *
  118. * @returns {Object} target
  119. * @throws TypeError if target is not an object
  120. *
  121. * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
  122. * @see https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.assign
  123. */
  124. function assign(target, source) {
  125. if (target === null || typeof target !== 'object') {
  126. throw new TypeError('target is not an object')
  127. }
  128. for (var key in source) {
  129. if (Object.prototype.hasOwnProperty.call(source, key)) {
  130. target[key] = source[key]
  131. }
  132. }
  133. return target
  134. }
  135. /**
  136. * All mime types that are allowed as input to `DOMParser.parseFromString`
  137. *
  138. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString#Argument02 MDN
  139. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#domparsersupportedtype WHATWG HTML Spec
  140. * @see DOMParser.prototype.parseFromString
  141. */
  142. var MIME_TYPE = freeze({
  143. /**
  144. * `text/html`, the only mime type that triggers treating an XML document as HTML.
  145. *
  146. * @see DOMParser.SupportedType.isHTML
  147. * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
  148. * @see https://en.wikipedia.org/wiki/HTML Wikipedia
  149. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
  150. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring WHATWG HTML Spec
  151. */
  152. HTML: 'text/html',
  153. /**
  154. * Helper method to check a mime type if it indicates an HTML document
  155. *
  156. * @param {string} [value]
  157. * @returns {boolean}
  158. *
  159. * @see https://www.iana.org/assignments/media-types/text/html IANA MimeType registration
  160. * @see https://en.wikipedia.org/wiki/HTML Wikipedia
  161. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString MDN
  162. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-domparser-parsefromstring */
  163. isHTML: function (value) {
  164. return value === MIME_TYPE.HTML
  165. },
  166. /**
  167. * `application/xml`, the standard mime type for XML documents.
  168. *
  169. * @see https://www.iana.org/assignments/media-types/application/xml IANA MimeType registration
  170. * @see https://tools.ietf.org/html/rfc7303#section-9.1 RFC 7303
  171. * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
  172. */
  173. XML_APPLICATION: 'application/xml',
  174. /**
  175. * `text/html`, an alias for `application/xml`.
  176. *
  177. * @see https://tools.ietf.org/html/rfc7303#section-9.2 RFC 7303
  178. * @see https://www.iana.org/assignments/media-types/text/xml IANA MimeType registration
  179. * @see https://en.wikipedia.org/wiki/XML_and_MIME Wikipedia
  180. */
  181. XML_TEXT: 'text/xml',
  182. /**
  183. * `application/xhtml+xml`, indicates an XML document that has the default HTML namespace,
  184. * but is parsed as an XML document.
  185. *
  186. * @see https://www.iana.org/assignments/media-types/application/xhtml+xml IANA MimeType registration
  187. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument WHATWG DOM Spec
  188. * @see https://en.wikipedia.org/wiki/XHTML Wikipedia
  189. */
  190. XML_XHTML_APPLICATION: 'application/xhtml+xml',
  191. /**
  192. * `image/svg+xml`,
  193. *
  194. * @see https://www.iana.org/assignments/media-types/image/svg+xml IANA MimeType registration
  195. * @see https://www.w3.org/TR/SVG11/ W3C SVG 1.1
  196. * @see https://en.wikipedia.org/wiki/Scalable_Vector_Graphics Wikipedia
  197. */
  198. XML_SVG_IMAGE: 'image/svg+xml'
  199. })
  200. /**
  201. * Namespaces that are used in this code base.
  202. *
  203. * @see http://www.w3.org/TR/REC-xml-names
  204. */
  205. var NAMESPACE = freeze({
  206. /**
  207. * The XHTML namespace.
  208. *
  209. * @see http://www.w3.org/1999/xhtml
  210. */
  211. HTML: 'http://www.w3.org/1999/xhtml',
  212. /**
  213. * Checks if `uri` equals `NAMESPACE.HTML`.
  214. *
  215. * @param {string} [uri]
  216. *
  217. * @see NAMESPACE.HTML
  218. */
  219. isHTML: function (uri) {
  220. return uri === NAMESPACE.HTML
  221. },
  222. /**
  223. * The SVG namespace.
  224. *
  225. * @see http://www.w3.org/2000/svg
  226. */
  227. SVG: 'http://www.w3.org/2000/svg',
  228. /**
  229. * The `xml:` namespace.
  230. *
  231. * @see http://www.w3.org/XML/1998/namespace
  232. */
  233. XML: 'http://www.w3.org/XML/1998/namespace',
  234. /**
  235. * The `xmlns:` namespace
  236. *
  237. * @see https://www.w3.org/2000/xmlns/
  238. */
  239. XMLNS: 'http://www.w3.org/2000/xmlns/'
  240. })
  241. exports.assign = assign
  242. exports.find = find
  243. exports.freeze = freeze
  244. exports.MIME_TYPE = MIME_TYPE
  245. exports.NAMESPACE = NAMESPACE
  246. },
  247. {}
  248. ],
  249. 6: [
  250. function (require, module, exports) {
  251. var conventions = require('./conventions')
  252. var dom = require('./dom')
  253. var entities = require('./entities')
  254. var sax = require('./sax')
  255. var DOMImplementation = dom.DOMImplementation
  256. var NAMESPACE = conventions.NAMESPACE
  257. var ParseError = sax.ParseError
  258. var XMLReader = sax.XMLReader
  259. /**
  260. * Normalizes line ending according to https://www.w3.org/TR/xml11/#sec-line-ends:
  261. *
  262. * > XML parsed entities are often stored in computer files which,
  263. * > for editing convenience, are organized into lines.
  264. * > These lines are typically separated by some combination
  265. * > of the characters CARRIAGE RETURN (#xD) and LINE FEED (#xA).
  266. * >
  267. * > To simplify the tasks of applications, the XML processor must behave
  268. * > as if it normalized all line breaks in external parsed entities (including the document entity)
  269. * > on input, before parsing, by translating all of the following to a single #xA character:
  270. * >
  271. * > 1. the two-character sequence #xD #xA
  272. * > 2. the two-character sequence #xD #x85
  273. * > 3. the single character #x85
  274. * > 4. the single character #x2028
  275. * > 5. any #xD character that is not immediately followed by #xA or #x85.
  276. *
  277. * @param {string} input
  278. * @returns {string}
  279. */
  280. function normalizeLineEndings(input) {
  281. return input.replace(/\r[\n\u0085]/g, '\n').replace(/[\r\u0085\u2028]/g, '\n')
  282. }
  283. /**
  284. * @typedef Locator
  285. * @property {number} [columnNumber]
  286. * @property {number} [lineNumber]
  287. */
  288. /**
  289. * @typedef DOMParserOptions
  290. * @property {DOMHandler} [domBuilder]
  291. * @property {Function} [errorHandler]
  292. * @property {(string) => string} [normalizeLineEndings] used to replace line endings before parsing
  293. * defaults to `normalizeLineEndings`
  294. * @property {Locator} [locator]
  295. * @property {Record<string, string>} [xmlns]
  296. *
  297. * @see normalizeLineEndings
  298. */
  299. /**
  300. * The DOMParser interface provides the ability to parse XML or HTML source code
  301. * from a string into a DOM `Document`.
  302. *
  303. * _xmldom is different from the spec in that it allows an `options` parameter,
  304. * to override the default behavior._
  305. *
  306. * @param {DOMParserOptions} [options]
  307. * @constructor
  308. *
  309. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
  310. * @see https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-parsing-and-serialization
  311. */
  312. function DOMParser(options) {
  313. this.options = options || { locator: {} }
  314. }
  315. DOMParser.prototype.parseFromString = function (source, mimeType) {
  316. var options = this.options
  317. var sax = new XMLReader()
  318. var domBuilder = options.domBuilder || new DOMHandler() //contentHandler and LexicalHandler
  319. var errorHandler = options.errorHandler
  320. var locator = options.locator
  321. var defaultNSMap = options.xmlns || {}
  322. var isHTML = /\/x?html?$/.test(mimeType) //mimeType.toLowerCase().indexOf('html') > -1;
  323. var entityMap = isHTML ? entities.HTML_ENTITIES : entities.XML_ENTITIES
  324. if (locator) {
  325. domBuilder.setDocumentLocator(locator)
  326. }
  327. sax.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator)
  328. sax.domBuilder = options.domBuilder || domBuilder
  329. if (isHTML) {
  330. defaultNSMap[''] = NAMESPACE.HTML
  331. }
  332. defaultNSMap.xml = defaultNSMap.xml || NAMESPACE.XML
  333. var normalize = options.normalizeLineEndings || normalizeLineEndings
  334. if (source && typeof source === 'string') {
  335. sax.parse(normalize(source), defaultNSMap, entityMap)
  336. } else {
  337. sax.errorHandler.error('invalid doc source')
  338. }
  339. return domBuilder.doc
  340. }
  341. function buildErrorHandler(errorImpl, domBuilder, locator) {
  342. if (!errorImpl) {
  343. if (domBuilder instanceof DOMHandler) {
  344. return domBuilder
  345. }
  346. errorImpl = domBuilder
  347. }
  348. var errorHandler = {}
  349. var isCallback = errorImpl instanceof Function
  350. locator = locator || {}
  351. function build(key) {
  352. var fn = errorImpl[key]
  353. if (!fn && isCallback) {
  354. fn =
  355. errorImpl.length == 2
  356. ? function (msg) {
  357. errorImpl(key, msg)
  358. }
  359. : errorImpl
  360. }
  361. errorHandler[key] =
  362. (fn &&
  363. function (msg) {
  364. fn('[xmldom ' + key + ']\t' + msg + _locator(locator))
  365. }) ||
  366. function () {}
  367. }
  368. build('warning')
  369. build('error')
  370. build('fatalError')
  371. return errorHandler
  372. }
  373. //console.log('#\n\n\n\n\n\n\n####')
  374. /**
  375. * +ContentHandler+ErrorHandler
  376. * +LexicalHandler+EntityResolver2
  377. * -DeclHandler-DTDHandler
  378. *
  379. * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
  380. * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
  381. * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
  382. */
  383. function DOMHandler() {
  384. this.cdata = false
  385. }
  386. function position(locator, node) {
  387. node.lineNumber = locator.lineNumber
  388. node.columnNumber = locator.columnNumber
  389. }
  390. /**
  391. * @see org.xml.sax.ContentHandler#startDocument
  392. * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
  393. */
  394. DOMHandler.prototype = {
  395. startDocument: function () {
  396. this.doc = new DOMImplementation().createDocument(null, null, null)
  397. if (this.locator) {
  398. this.doc.documentURI = this.locator.systemId
  399. }
  400. },
  401. startElement: function (namespaceURI, localName, qName, attrs) {
  402. var doc = this.doc
  403. var el = doc.createElementNS(namespaceURI, qName || localName)
  404. var len = attrs.length
  405. appendElement(this, el)
  406. this.currentElement = el
  407. this.locator && position(this.locator, el)
  408. for (var i = 0; i < len; i++) {
  409. var namespaceURI = attrs.getURI(i)
  410. var value = attrs.getValue(i)
  411. var qName = attrs.getQName(i)
  412. var attr = doc.createAttributeNS(namespaceURI, qName)
  413. this.locator && position(attrs.getLocator(i), attr)
  414. attr.value = attr.nodeValue = value
  415. el.setAttributeNode(attr)
  416. }
  417. },
  418. endElement: function (namespaceURI, localName, qName) {
  419. var current = this.currentElement
  420. var tagName = current.tagName
  421. this.currentElement = current.parentNode
  422. },
  423. startPrefixMapping: function (prefix, uri) {},
  424. endPrefixMapping: function (prefix) {},
  425. processingInstruction: function (target, data) {
  426. var ins = this.doc.createProcessingInstruction(target, data)
  427. this.locator && position(this.locator, ins)
  428. appendElement(this, ins)
  429. },
  430. ignorableWhitespace: function (ch, start, length) {},
  431. characters: function (chars, start, length) {
  432. chars = _toString.apply(this, arguments)
  433. //console.log(chars)
  434. if (chars) {
  435. if (this.cdata) {
  436. var charNode = this.doc.createCDATASection(chars)
  437. } else {
  438. var charNode = this.doc.createTextNode(chars)
  439. }
  440. if (this.currentElement) {
  441. this.currentElement.appendChild(charNode)
  442. } else if (/^\s*$/.test(chars)) {
  443. this.doc.appendChild(charNode)
  444. //process xml
  445. }
  446. this.locator && position(this.locator, charNode)
  447. }
  448. },
  449. skippedEntity: function (name) {},
  450. endDocument: function () {
  451. this.doc.normalize()
  452. },
  453. setDocumentLocator: function (locator) {
  454. if ((this.locator = locator)) {
  455. // && !('lineNumber' in locator)){
  456. locator.lineNumber = 0
  457. }
  458. },
  459. //LexicalHandler
  460. comment: function (chars, start, length) {
  461. chars = _toString.apply(this, arguments)
  462. var comm = this.doc.createComment(chars)
  463. this.locator && position(this.locator, comm)
  464. appendElement(this, comm)
  465. },
  466. startCDATA: function () {
  467. //used in characters() methods
  468. this.cdata = true
  469. },
  470. endCDATA: function () {
  471. this.cdata = false
  472. },
  473. startDTD: function (name, publicId, systemId) {
  474. var impl = this.doc.implementation
  475. if (impl && impl.createDocumentType) {
  476. var dt = impl.createDocumentType(name, publicId, systemId)
  477. this.locator && position(this.locator, dt)
  478. appendElement(this, dt)
  479. this.doc.doctype = dt
  480. }
  481. },
  482. /**
  483. * @see org.xml.sax.ErrorHandler
  484. * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
  485. */
  486. warning: function (error) {
  487. console.warn('[xmldom warning]\t' + error, _locator(this.locator))
  488. },
  489. error: function (error) {
  490. console.error('[xmldom error]\t' + error, _locator(this.locator))
  491. },
  492. fatalError: function (error) {
  493. throw new ParseError(error, this.locator)
  494. }
  495. }
  496. function _locator(l) {
  497. if (l) {
  498. return '\n@' + (l.systemId || '') + '#[line:' + l.lineNumber + ',col:' + l.columnNumber + ']'
  499. }
  500. }
  501. function _toString(chars, start, length) {
  502. if (typeof chars == 'string') {
  503. return chars.substr(start, length)
  504. } else {
  505. //java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
  506. if (chars.length >= start + length || start) {
  507. return new java.lang.String(chars, start, length) + ''
  508. }
  509. return chars
  510. }
  511. }
  512. /*
  513. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
  514. * used method of org.xml.sax.ext.LexicalHandler:
  515. * #comment(chars, start, length)
  516. * #startCDATA()
  517. * #endCDATA()
  518. * #startDTD(name, publicId, systemId)
  519. *
  520. *
  521. * IGNORED method of org.xml.sax.ext.LexicalHandler:
  522. * #endDTD()
  523. * #startEntity(name)
  524. * #endEntity(name)
  525. *
  526. *
  527. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
  528. * IGNORED method of org.xml.sax.ext.DeclHandler
  529. * #attributeDecl(eName, aName, type, mode, value)
  530. * #elementDecl(name, model)
  531. * #externalEntityDecl(name, publicId, systemId)
  532. * #internalEntityDecl(name, value)
  533. * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
  534. * IGNORED method of org.xml.sax.EntityResolver2
  535. * #resolveEntity(String name,String publicId,String baseURI,String systemId)
  536. * #resolveEntity(publicId, systemId)
  537. * #getExternalSubset(name, baseURI)
  538. * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
  539. * IGNORED method of org.xml.sax.DTDHandler
  540. * #notationDecl(name, publicId, systemId) {};
  541. * #unparsedEntityDecl(name, publicId, systemId, notationName) {};
  542. */
  543. 'endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl'.replace(
  544. /\w+/g,
  545. function (key) {
  546. DOMHandler.prototype[key] = function () {
  547. return null
  548. }
  549. }
  550. )
  551. /* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
  552. function appendElement(hander, node) {
  553. if (!hander.currentElement) {
  554. hander.doc.appendChild(node)
  555. } else {
  556. hander.currentElement.appendChild(node)
  557. }
  558. } //appendChild and setAttributeNS are preformance key
  559. exports.__DOMHandler = DOMHandler
  560. exports.normalizeLineEndings = normalizeLineEndings
  561. exports.DOMParser = DOMParser
  562. },
  563. { './conventions': 5, './dom': 7, './entities': 8, './sax': 10 }
  564. ],
  565. 7: [
  566. function (require, module, exports) {
  567. var conventions = require('./conventions')
  568. var find = conventions.find
  569. var NAMESPACE = conventions.NAMESPACE
  570. /**
  571. * A prerequisite for `[].filter`, to drop elements that are empty
  572. * @param {string} input
  573. * @returns {boolean}
  574. */
  575. function notEmptyString(input) {
  576. return input !== ''
  577. }
  578. /**
  579. * @see https://infra.spec.whatwg.org/#split-on-ascii-whitespace
  580. * @see https://infra.spec.whatwg.org/#ascii-whitespace
  581. *
  582. * @param {string} input
  583. * @returns {string[]} (can be empty)
  584. */
  585. function splitOnASCIIWhitespace(input) {
  586. // U+0009 TAB, U+000A LF, U+000C FF, U+000D CR, U+0020 SPACE
  587. return input ? input.split(/[\t\n\f\r ]+/).filter(notEmptyString) : []
  588. }
  589. /**
  590. * Adds element as a key to current if it is not already present.
  591. *
  592. * @param {Record<string, boolean | undefined>} current
  593. * @param {string} element
  594. * @returns {Record<string, boolean | undefined>}
  595. */
  596. function orderedSetReducer(current, element) {
  597. if (!current.hasOwnProperty(element)) {
  598. current[element] = true
  599. }
  600. return current
  601. }
  602. /**
  603. * @see https://infra.spec.whatwg.org/#ordered-set
  604. * @param {string} input
  605. * @returns {string[]}
  606. */
  607. function toOrderedSet(input) {
  608. if (!input) return []
  609. var list = splitOnASCIIWhitespace(input)
  610. return Object.keys(list.reduce(orderedSetReducer, {}))
  611. }
  612. /**
  613. * Uses `list.indexOf` to implement something like `Array.prototype.includes`,
  614. * which we can not rely on being available.
  615. *
  616. * @param {any[]} list
  617. * @returns {function(any): boolean}
  618. */
  619. function arrayIncludes(list) {
  620. return function (element) {
  621. return list && list.indexOf(element) !== -1
  622. }
  623. }
  624. function copy(src, dest) {
  625. for (var p in src) {
  626. if (Object.prototype.hasOwnProperty.call(src, p)) {
  627. dest[p] = src[p]
  628. }
  629. }
  630. }
  631. /**
  632. ^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
  633. ^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
  634. */
  635. function _extends(Class, Super) {
  636. var pt = Class.prototype
  637. if (!(pt instanceof Super)) {
  638. function t() {}
  639. t.prototype = Super.prototype
  640. t = new t()
  641. copy(pt, t)
  642. Class.prototype = pt = t
  643. }
  644. if (pt.constructor != Class) {
  645. if (typeof Class != 'function') {
  646. console.error('unknown Class:' + Class)
  647. }
  648. pt.constructor = Class
  649. }
  650. }
  651. // Node Types
  652. var NodeType = {}
  653. var ELEMENT_NODE = (NodeType.ELEMENT_NODE = 1)
  654. var ATTRIBUTE_NODE = (NodeType.ATTRIBUTE_NODE = 2)
  655. var TEXT_NODE = (NodeType.TEXT_NODE = 3)
  656. var CDATA_SECTION_NODE = (NodeType.CDATA_SECTION_NODE = 4)
  657. var ENTITY_REFERENCE_NODE = (NodeType.ENTITY_REFERENCE_NODE = 5)
  658. var ENTITY_NODE = (NodeType.ENTITY_NODE = 6)
  659. var PROCESSING_INSTRUCTION_NODE = (NodeType.PROCESSING_INSTRUCTION_NODE = 7)
  660. var COMMENT_NODE = (NodeType.COMMENT_NODE = 8)
  661. var DOCUMENT_NODE = (NodeType.DOCUMENT_NODE = 9)
  662. var DOCUMENT_TYPE_NODE = (NodeType.DOCUMENT_TYPE_NODE = 10)
  663. var DOCUMENT_FRAGMENT_NODE = (NodeType.DOCUMENT_FRAGMENT_NODE = 11)
  664. var NOTATION_NODE = (NodeType.NOTATION_NODE = 12)
  665. // ExceptionCode
  666. var ExceptionCode = {}
  667. var ExceptionMessage = {}
  668. var INDEX_SIZE_ERR = (ExceptionCode.INDEX_SIZE_ERR = ((ExceptionMessage[1] = 'Index size error'), 1))
  669. var DOMSTRING_SIZE_ERR = (ExceptionCode.DOMSTRING_SIZE_ERR = ((ExceptionMessage[2] = 'DOMString size error'), 2))
  670. var HIERARCHY_REQUEST_ERR = (ExceptionCode.HIERARCHY_REQUEST_ERR = ((ExceptionMessage[3] = 'Hierarchy request error'), 3))
  671. var WRONG_DOCUMENT_ERR = (ExceptionCode.WRONG_DOCUMENT_ERR = ((ExceptionMessage[4] = 'Wrong document'), 4))
  672. var INVALID_CHARACTER_ERR = (ExceptionCode.INVALID_CHARACTER_ERR = ((ExceptionMessage[5] = 'Invalid character'), 5))
  673. var NO_DATA_ALLOWED_ERR = (ExceptionCode.NO_DATA_ALLOWED_ERR = ((ExceptionMessage[6] = 'No data allowed'), 6))
  674. var NO_MODIFICATION_ALLOWED_ERR = (ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7] = 'No modification allowed'), 7))
  675. var NOT_FOUND_ERR = (ExceptionCode.NOT_FOUND_ERR = ((ExceptionMessage[8] = 'Not found'), 8))
  676. var NOT_SUPPORTED_ERR = (ExceptionCode.NOT_SUPPORTED_ERR = ((ExceptionMessage[9] = 'Not supported'), 9))
  677. var INUSE_ATTRIBUTE_ERR = (ExceptionCode.INUSE_ATTRIBUTE_ERR = ((ExceptionMessage[10] = 'Attribute in use'), 10))
  678. //level2
  679. var INVALID_STATE_ERR = (ExceptionCode.INVALID_STATE_ERR = ((ExceptionMessage[11] = 'Invalid state'), 11))
  680. var SYNTAX_ERR = (ExceptionCode.SYNTAX_ERR = ((ExceptionMessage[12] = 'Syntax error'), 12))
  681. var INVALID_MODIFICATION_ERR = (ExceptionCode.INVALID_MODIFICATION_ERR = ((ExceptionMessage[13] = 'Invalid modification'), 13))
  682. var NAMESPACE_ERR = (ExceptionCode.NAMESPACE_ERR = ((ExceptionMessage[14] = 'Invalid namespace'), 14))
  683. var INVALID_ACCESS_ERR = (ExceptionCode.INVALID_ACCESS_ERR = ((ExceptionMessage[15] = 'Invalid access'), 15))
  684. /**
  685. * DOM Level 2
  686. * Object DOMException
  687. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
  688. * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
  689. */
  690. function DOMException(code, message) {
  691. if (message instanceof Error) {
  692. var error = message
  693. } else {
  694. error = this
  695. Error.call(this, ExceptionMessage[code])
  696. this.message = ExceptionMessage[code]
  697. if (Error.captureStackTrace) Error.captureStackTrace(this, DOMException)
  698. }
  699. error.code = code
  700. if (message) this.message = this.message + ': ' + message
  701. return error
  702. }
  703. DOMException.prototype = Error.prototype
  704. copy(ExceptionCode, DOMException)
  705. /**
  706. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
  707. * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
  708. * The items in the NodeList are accessible via an integral index, starting from 0.
  709. */
  710. function NodeList() {}
  711. NodeList.prototype = {
  712. /**
  713. * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
  714. * @standard level1
  715. */
  716. length: 0,
  717. /**
  718. * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
  719. * @standard level1
  720. * @param index unsigned long
  721. * Index into the collection.
  722. * @return Node
  723. * The node at the indexth position in the NodeList, or null if that is not a valid index.
  724. */
  725. item: function (index) {
  726. return index >= 0 && index < this.length ? this[index] : null
  727. },
  728. toString: function (isHTML, nodeFilter) {
  729. for (var buf = [], i = 0; i < this.length; i++) {
  730. serializeToString(this[i], buf, isHTML, nodeFilter)
  731. }
  732. return buf.join('')
  733. },
  734. /**
  735. * @private
  736. * @param {function (Node):boolean} predicate
  737. * @returns {Node[]}
  738. */
  739. filter: function (predicate) {
  740. return Array.prototype.filter.call(this, predicate)
  741. },
  742. /**
  743. * @private
  744. * @param {Node} item
  745. * @returns {number}
  746. */
  747. indexOf: function (item) {
  748. return Array.prototype.indexOf.call(this, item)
  749. }
  750. }
  751. function LiveNodeList(node, refresh) {
  752. this._node = node
  753. this._refresh = refresh
  754. _updateLiveList(this)
  755. }
  756. function _updateLiveList(list) {
  757. var inc = list._node._inc || list._node.ownerDocument._inc
  758. if (list._inc !== inc) {
  759. var ls = list._refresh(list._node)
  760. __set__(list, 'length', ls.length)
  761. if (!list.$$length || ls.length < list.$$length) {
  762. for (var i = ls.length; i in list; i++) {
  763. if (Object.prototype.hasOwnProperty.call(list, i)) {
  764. delete list[i]
  765. }
  766. }
  767. }
  768. copy(ls, list)
  769. list._inc = inc
  770. }
  771. }
  772. LiveNodeList.prototype.item = function (i) {
  773. _updateLiveList(this)
  774. return this[i] || null
  775. }
  776. _extends(LiveNodeList, NodeList)
  777. /**
  778. * Objects implementing the NamedNodeMap interface are used
  779. * to represent collections of nodes that can be accessed by name.
  780. * Note that NamedNodeMap does not inherit from NodeList;
  781. * NamedNodeMaps are not maintained in any particular order.
  782. * Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index,
  783. * but this is simply to allow convenient enumeration of the contents of a NamedNodeMap,
  784. * and does not imply that the DOM specifies an order to these Nodes.
  785. * NamedNodeMap objects in the DOM are live.
  786. * used for attributes or DocumentType entities
  787. */
  788. function NamedNodeMap() {}
  789. function _findNodeIndex(list, node) {
  790. var i = list.length
  791. while (i--) {
  792. if (list[i] === node) {
  793. return i
  794. }
  795. }
  796. }
  797. function _addNamedNode(el, list, newAttr, oldAttr) {
  798. if (oldAttr) {
  799. list[_findNodeIndex(list, oldAttr)] = newAttr
  800. } else {
  801. list[list.length++] = newAttr
  802. }
  803. if (el) {
  804. newAttr.ownerElement = el
  805. var doc = el.ownerDocument
  806. if (doc) {
  807. oldAttr && _onRemoveAttribute(doc, el, oldAttr)
  808. _onAddAttribute(doc, el, newAttr)
  809. }
  810. }
  811. }
  812. function _removeNamedNode(el, list, attr) {
  813. //console.log('remove attr:'+attr)
  814. var i = _findNodeIndex(list, attr)
  815. if (i >= 0) {
  816. var lastIndex = list.length - 1
  817. while (i < lastIndex) {
  818. list[i] = list[++i]
  819. }
  820. list.length = lastIndex
  821. if (el) {
  822. var doc = el.ownerDocument
  823. if (doc) {
  824. _onRemoveAttribute(doc, el, attr)
  825. attr.ownerElement = null
  826. }
  827. }
  828. } else {
  829. throw new DOMException(NOT_FOUND_ERR, new Error(el.tagName + '@' + attr))
  830. }
  831. }
  832. NamedNodeMap.prototype = {
  833. length: 0,
  834. item: NodeList.prototype.item,
  835. getNamedItem: function (key) {
  836. // if(key.indexOf(':')>0 || key == 'xmlns'){
  837. // return null;
  838. // }
  839. //console.log()
  840. var i = this.length
  841. while (i--) {
  842. var attr = this[i]
  843. //console.log(attr.nodeName,key)
  844. if (attr.nodeName == key) {
  845. return attr
  846. }
  847. }
  848. },
  849. setNamedItem: function (attr) {
  850. var el = attr.ownerElement
  851. if (el && el != this._ownerElement) {
  852. throw new DOMException(INUSE_ATTRIBUTE_ERR)
  853. }
  854. var oldAttr = this.getNamedItem(attr.nodeName)
  855. _addNamedNode(this._ownerElement, this, attr, oldAttr)
  856. return oldAttr
  857. },
  858. /* returns Node */
  859. setNamedItemNS: function (attr) {
  860. // raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
  861. var el = attr.ownerElement,
  862. oldAttr
  863. if (el && el != this._ownerElement) {
  864. throw new DOMException(INUSE_ATTRIBUTE_ERR)
  865. }
  866. oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName)
  867. _addNamedNode(this._ownerElement, this, attr, oldAttr)
  868. return oldAttr
  869. },
  870. /* returns Node */
  871. removeNamedItem: function (key) {
  872. var attr = this.getNamedItem(key)
  873. _removeNamedNode(this._ownerElement, this, attr)
  874. return attr
  875. }, // raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
  876. //for level2
  877. removeNamedItemNS: function (namespaceURI, localName) {
  878. var attr = this.getNamedItemNS(namespaceURI, localName)
  879. _removeNamedNode(this._ownerElement, this, attr)
  880. return attr
  881. },
  882. getNamedItemNS: function (namespaceURI, localName) {
  883. var i = this.length
  884. while (i--) {
  885. var node = this[i]
  886. if (node.localName == localName && node.namespaceURI == namespaceURI) {
  887. return node
  888. }
  889. }
  890. return null
  891. }
  892. }
  893. /**
  894. * The DOMImplementation interface represents an object providing methods
  895. * which are not dependent on any particular document.
  896. * Such an object is returned by the `Document.implementation` property.
  897. *
  898. * __The individual methods describe the differences compared to the specs.__
  899. *
  900. * @constructor
  901. *
  902. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation MDN
  903. * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490 DOM Level 1 Core (Initial)
  904. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-102161490 DOM Level 2 Core
  905. * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-102161490 DOM Level 3 Core
  906. * @see https://dom.spec.whatwg.org/#domimplementation DOM Living Standard
  907. */
  908. function DOMImplementation() {}
  909. DOMImplementation.prototype = {
  910. /**
  911. * The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported.
  912. * The different implementations fairly diverged in what kind of features were reported.
  913. * The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.
  914. *
  915. * @deprecated It is deprecated and modern browsers return true in all cases.
  916. *
  917. * @param {string} feature
  918. * @param {string} [version]
  919. * @returns {boolean} always true
  920. *
  921. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/hasFeature MDN
  922. * @see https://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-5CED94D7 DOM Level 1 Core
  923. * @see https://dom.spec.whatwg.org/#dom-domimplementation-hasfeature DOM Living Standard
  924. */
  925. hasFeature: function (feature, version) {
  926. return true
  927. },
  928. /**
  929. * Creates an XML Document object of the specified type with its document element.
  930. *
  931. * __It behaves slightly different from the description in the living standard__:
  932. * - There is no interface/class `XMLDocument`, it returns a `Document` instance.
  933. * - `contentType`, `encoding`, `mode`, `origin`, `url` fields are currently not declared.
  934. * - this implementation is not validating names or qualified names
  935. * (when parsing XML strings, the SAX parser takes care of that)
  936. *
  937. * @param {string|null} namespaceURI
  938. * @param {string} qualifiedName
  939. * @param {DocumentType=null} doctype
  940. * @returns {Document}
  941. *
  942. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocument MDN
  943. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocument DOM Level 2 Core (initial)
  944. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocument DOM Level 2 Core
  945. *
  946. * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
  947. * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
  948. * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
  949. */
  950. createDocument: function (namespaceURI, qualifiedName, doctype) {
  951. var doc = new Document()
  952. doc.implementation = this
  953. doc.childNodes = new NodeList()
  954. doc.doctype = doctype || null
  955. if (doctype) {
  956. doc.appendChild(doctype)
  957. }
  958. if (qualifiedName) {
  959. var root = doc.createElementNS(namespaceURI, qualifiedName)
  960. doc.appendChild(root)
  961. }
  962. return doc
  963. },
  964. /**
  965. * Returns a doctype, with the given `qualifiedName`, `publicId`, and `systemId`.
  966. *
  967. * __This behavior is slightly different from the in the specs__:
  968. * - this implementation is not validating names or qualified names
  969. * (when parsing XML strings, the SAX parser takes care of that)
  970. *
  971. * @param {string} qualifiedName
  972. * @param {string} [publicId]
  973. * @param {string} [systemId]
  974. * @returns {DocumentType} which can either be used with `DOMImplementation.createDocument` upon document creation
  975. * or can be put into the document via methods like `Node.insertBefore()` or `Node.replaceChild()`
  976. *
  977. * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createDocumentType MDN
  978. * @see https://www.w3.org/TR/DOM-Level-2-Core/core.html#Level-2-Core-DOM-createDocType DOM Level 2 Core
  979. * @see https://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype DOM Living Standard
  980. *
  981. * @see https://dom.spec.whatwg.org/#validate-and-extract DOM: Validate and extract
  982. * @see https://www.w3.org/TR/xml/#NT-NameStartChar XML Spec: Names
  983. * @see https://www.w3.org/TR/xml-names/#ns-qualnames XML Namespaces: Qualified names
  984. */
  985. createDocumentType: function (qualifiedName, publicId, systemId) {
  986. var node = new DocumentType()
  987. node.name = qualifiedName
  988. node.nodeName = qualifiedName
  989. node.publicId = publicId || ''
  990. node.systemId = systemId || ''
  991. return node
  992. }
  993. }
  994. /**
  995. * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
  996. */
  997. function Node() {}
  998. Node.prototype = {
  999. firstChild: null,
  1000. lastChild: null,
  1001. previousSibling: null,
  1002. nextSibling: null,
  1003. attributes: null,
  1004. parentNode: null,
  1005. childNodes: null,
  1006. ownerDocument: null,
  1007. nodeValue: null,
  1008. namespaceURI: null,
  1009. prefix: null,
  1010. localName: null,
  1011. // Modified in DOM Level 2:
  1012. insertBefore: function (newChild, refChild) {
  1013. //raises
  1014. return _insertBefore(this, newChild, refChild)
  1015. },
  1016. replaceChild: function (newChild, oldChild) {
  1017. //raises
  1018. _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument)
  1019. if (oldChild) {
  1020. this.removeChild(oldChild)
  1021. }
  1022. },
  1023. removeChild: function (oldChild) {
  1024. return _removeChild(this, oldChild)
  1025. },
  1026. appendChild: function (newChild) {
  1027. return this.insertBefore(newChild, null)
  1028. },
  1029. hasChildNodes: function () {
  1030. return this.firstChild != null
  1031. },
  1032. cloneNode: function (deep) {
  1033. return cloneNode(this.ownerDocument || this, this, deep)
  1034. },
  1035. // Modified in DOM Level 2:
  1036. normalize: function () {
  1037. var child = this.firstChild
  1038. while (child) {
  1039. var next = child.nextSibling
  1040. if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
  1041. this.removeChild(next)
  1042. child.appendData(next.data)
  1043. } else {
  1044. child.normalize()
  1045. child = next
  1046. }
  1047. }
  1048. },
  1049. // Introduced in DOM Level 2:
  1050. isSupported: function (feature, version) {
  1051. return this.ownerDocument.implementation.hasFeature(feature, version)
  1052. },
  1053. // Introduced in DOM Level 2:
  1054. hasAttributes: function () {
  1055. return this.attributes.length > 0
  1056. },
  1057. /**
  1058. * Look up the prefix associated to the given namespace URI, starting from this node.
  1059. * **The default namespace declarations are ignored by this method.**
  1060. * See Namespace Prefix Lookup for details on the algorithm used by this method.
  1061. *
  1062. * _Note: The implementation seems to be incomplete when compared to the algorithm described in the specs._
  1063. *
  1064. * @param {string | null} namespaceURI
  1065. * @returns {string | null}
  1066. * @see https://www.w3.org/TR/DOM-Level-3-Core/core.html#Node3-lookupNamespacePrefix
  1067. * @see https://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#lookupNamespacePrefixAlgo
  1068. * @see https://dom.spec.whatwg.org/#dom-node-lookupprefix
  1069. * @see https://github.com/xmldom/xmldom/issues/322
  1070. */
  1071. lookupPrefix: function (namespaceURI) {
  1072. var el = this
  1073. while (el) {
  1074. var map = el._nsMap
  1075. //console.dir(map)
  1076. if (map) {
  1077. for (var n in map) {
  1078. if (Object.prototype.hasOwnProperty.call(map, n) && map[n] === namespaceURI) {
  1079. return n
  1080. }
  1081. }
  1082. }
  1083. el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode
  1084. }
  1085. return null
  1086. },
  1087. // Introduced in DOM Level 3:
  1088. lookupNamespaceURI: function (prefix) {
  1089. var el = this
  1090. while (el) {
  1091. var map = el._nsMap
  1092. //console.dir(map)
  1093. if (map) {
  1094. if (Object.prototype.hasOwnProperty.call(map, prefix)) {
  1095. return map[prefix]
  1096. }
  1097. }
  1098. el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode
  1099. }
  1100. return null
  1101. },
  1102. // Introduced in DOM Level 3:
  1103. isDefaultNamespace: function (namespaceURI) {
  1104. var prefix = this.lookupPrefix(namespaceURI)
  1105. return prefix == null
  1106. }
  1107. }
  1108. function _xmlEncoder(c) {
  1109. return (c == '<' && '&lt;') || (c == '>' && '&gt;') || (c == '&' && '&amp;') || (c == '"' && '&quot;') || '&#' + c.charCodeAt() + ';'
  1110. }
  1111. copy(NodeType, Node)
  1112. copy(NodeType, Node.prototype)
  1113. /**
  1114. * @param callback return true for continue,false for break
  1115. * @return boolean true: break visit;
  1116. */
  1117. function _visitNode(node, callback) {
  1118. if (callback(node)) {
  1119. return true
  1120. }
  1121. if ((node = node.firstChild)) {
  1122. do {
  1123. if (_visitNode(node, callback)) {
  1124. return true
  1125. }
  1126. } while ((node = node.nextSibling))
  1127. }
  1128. }
  1129. function Document() {
  1130. this.ownerDocument = this
  1131. }
  1132. function _onAddAttribute(doc, el, newAttr) {
  1133. doc && doc._inc++
  1134. var ns = newAttr.namespaceURI
  1135. if (ns === NAMESPACE.XMLNS) {
  1136. //update namespace
  1137. el._nsMap[newAttr.prefix ? newAttr.localName : ''] = newAttr.value
  1138. }
  1139. }
  1140. function _onRemoveAttribute(doc, el, newAttr, remove) {
  1141. doc && doc._inc++
  1142. var ns = newAttr.namespaceURI
  1143. if (ns === NAMESPACE.XMLNS) {
  1144. //update namespace
  1145. delete el._nsMap[newAttr.prefix ? newAttr.localName : '']
  1146. }
  1147. }
  1148. /**
  1149. * Updates `el.childNodes`, updating the indexed items and it's `length`.
  1150. * Passing `newChild` means it will be appended.
  1151. * Otherwise it's assumed that an item has been removed,
  1152. * and `el.firstNode` and it's `.nextSibling` are used
  1153. * to walk the current list of child nodes.
  1154. *
  1155. * @param {Document} doc
  1156. * @param {Node} el
  1157. * @param {Node} [newChild]
  1158. * @private
  1159. */
  1160. function _onUpdateChild(doc, el, newChild) {
  1161. if (doc && doc._inc) {
  1162. doc._inc++
  1163. //update childNodes
  1164. var cs = el.childNodes
  1165. if (newChild) {
  1166. cs[cs.length++] = newChild
  1167. } else {
  1168. var child = el.firstChild
  1169. var i = 0
  1170. while (child) {
  1171. cs[i++] = child
  1172. child = child.nextSibling
  1173. }
  1174. cs.length = i
  1175. delete cs[cs.length]
  1176. }
  1177. }
  1178. }
  1179. /**
  1180. * Removes the connections between `parentNode` and `child`
  1181. * and any existing `child.previousSibling` or `child.nextSibling`.
  1182. *
  1183. * @see https://github.com/xmldom/xmldom/issues/135
  1184. * @see https://github.com/xmldom/xmldom/issues/145
  1185. *
  1186. * @param {Node} parentNode
  1187. * @param {Node} child
  1188. * @returns {Node} the child that was removed.
  1189. * @private
  1190. */
  1191. function _removeChild(parentNode, child) {
  1192. var previous = child.previousSibling
  1193. var next = child.nextSibling
  1194. if (previous) {
  1195. previous.nextSibling = next
  1196. } else {
  1197. parentNode.firstChild = next
  1198. }
  1199. if (next) {
  1200. next.previousSibling = previous
  1201. } else {
  1202. parentNode.lastChild = previous
  1203. }
  1204. child.parentNode = null
  1205. child.previousSibling = null
  1206. child.nextSibling = null
  1207. _onUpdateChild(parentNode.ownerDocument, parentNode)
  1208. return child
  1209. }
  1210. /**
  1211. * Returns `true` if `node` can be a parent for insertion.
  1212. * @param {Node} node
  1213. * @returns {boolean}
  1214. */
  1215. function hasValidParentNodeType(node) {
  1216. return (
  1217. node && (node.nodeType === Node.DOCUMENT_NODE || node.nodeType === Node.DOCUMENT_FRAGMENT_NODE || node.nodeType === Node.ELEMENT_NODE)
  1218. )
  1219. }
  1220. /**
  1221. * Returns `true` if `node` can be inserted according to it's `nodeType`.
  1222. * @param {Node} node
  1223. * @returns {boolean}
  1224. */
  1225. function hasInsertableNodeType(node) {
  1226. return (
  1227. node &&
  1228. (isElementNode(node) ||
  1229. isTextNode(node) ||
  1230. isDocTypeNode(node) ||
  1231. node.nodeType === Node.DOCUMENT_FRAGMENT_NODE ||
  1232. node.nodeType === Node.COMMENT_NODE ||
  1233. node.nodeType === Node.PROCESSING_INSTRUCTION_NODE)
  1234. )
  1235. }
  1236. /**
  1237. * Returns true if `node` is a DOCTYPE node
  1238. * @param {Node} node
  1239. * @returns {boolean}
  1240. */
  1241. function isDocTypeNode(node) {
  1242. return node && node.nodeType === Node.DOCUMENT_TYPE_NODE
  1243. }
  1244. /**
  1245. * Returns true if the node is an element
  1246. * @param {Node} node
  1247. * @returns {boolean}
  1248. */
  1249. function isElementNode(node) {
  1250. return node && node.nodeType === Node.ELEMENT_NODE
  1251. }
  1252. /**
  1253. * Returns true if `node` is a text node
  1254. * @param {Node} node
  1255. * @returns {boolean}
  1256. */
  1257. function isTextNode(node) {
  1258. return node && node.nodeType === Node.TEXT_NODE
  1259. }
  1260. /**
  1261. * Check if en element node can be inserted before `child`, or at the end if child is falsy,
  1262. * according to the presence and position of a doctype node on the same level.
  1263. *
  1264. * @param {Document} doc The document node
  1265. * @param {Node} child the node that would become the nextSibling if the element would be inserted
  1266. * @returns {boolean} `true` if an element can be inserted before child
  1267. * @private
  1268. * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1269. */
  1270. function isElementInsertionPossible(doc, child) {
  1271. var parentChildNodes = doc.childNodes || []
  1272. if (find(parentChildNodes, isElementNode) || isDocTypeNode(child)) {
  1273. return false
  1274. }
  1275. var docTypeNode = find(parentChildNodes, isDocTypeNode)
  1276. return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child))
  1277. }
  1278. /**
  1279. * Check if en element node can be inserted before `child`, or at the end if child is falsy,
  1280. * according to the presence and position of a doctype node on the same level.
  1281. *
  1282. * @param {Node} doc The document node
  1283. * @param {Node} child the node that would become the nextSibling if the element would be inserted
  1284. * @returns {boolean} `true` if an element can be inserted before child
  1285. * @private
  1286. * https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1287. */
  1288. function isElementReplacementPossible(doc, child) {
  1289. var parentChildNodes = doc.childNodes || []
  1290. function hasElementChildThatIsNotChild(node) {
  1291. return isElementNode(node) && node !== child
  1292. }
  1293. if (find(parentChildNodes, hasElementChildThatIsNotChild)) {
  1294. return false
  1295. }
  1296. var docTypeNode = find(parentChildNodes, isDocTypeNode)
  1297. return !(child && docTypeNode && parentChildNodes.indexOf(docTypeNode) > parentChildNodes.indexOf(child))
  1298. }
  1299. /**
  1300. * @private
  1301. * Steps 1-5 of the checks before inserting and before replacing a child are the same.
  1302. *
  1303. * @param {Node} parent the parent node to insert `node` into
  1304. * @param {Node} node the node to insert
  1305. * @param {Node=} child the node that should become the `nextSibling` of `node`
  1306. * @returns {Node}
  1307. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1308. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1309. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1310. * @see https://dom.spec.whatwg.org/#concept-node-replace
  1311. */
  1312. function assertPreInsertionValidity1to5(parent, node, child) {
  1313. // 1. If `parent` is not a Document, DocumentFragment, or Element node, then throw a "HierarchyRequestError" DOMException.
  1314. if (!hasValidParentNodeType(parent)) {
  1315. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected parent node type ' + parent.nodeType)
  1316. }
  1317. // 2. If `node` is a host-including inclusive ancestor of `parent`, then throw a "HierarchyRequestError" DOMException.
  1318. // not implemented!
  1319. // 3. If `child` is non-null and its parent is not `parent`, then throw a "NotFoundError" DOMException.
  1320. if (child && child.parentNode !== parent) {
  1321. throw new DOMException(NOT_FOUND_ERR, 'child not in parent')
  1322. }
  1323. if (
  1324. // 4. If `node` is not a DocumentFragment, DocumentType, Element, or CharacterData node, then throw a "HierarchyRequestError" DOMException.
  1325. !hasInsertableNodeType(node) ||
  1326. // 5. If either `node` is a Text node and `parent` is a document,
  1327. // the sax parser currently adds top level text nodes, this will be fixed in 0.9.0
  1328. // || (node.nodeType === Node.TEXT_NODE && parent.nodeType === Node.DOCUMENT_NODE)
  1329. // or `node` is a doctype and `parent` is not a document, then throw a "HierarchyRequestError" DOMException.
  1330. (isDocTypeNode(node) && parent.nodeType !== Node.DOCUMENT_NODE)
  1331. ) {
  1332. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Unexpected node type ' + node.nodeType + ' for parent node type ' + parent.nodeType)
  1333. }
  1334. }
  1335. /**
  1336. * @private
  1337. * Step 6 of the checks before inserting and before replacing a child are different.
  1338. *
  1339. * @param {Document} parent the parent node to insert `node` into
  1340. * @param {Node} node the node to insert
  1341. * @param {Node | undefined} child the node that should become the `nextSibling` of `node`
  1342. * @returns {Node}
  1343. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1344. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1345. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1346. * @see https://dom.spec.whatwg.org/#concept-node-replace
  1347. */
  1348. function assertPreInsertionValidityInDocument(parent, node, child) {
  1349. var parentChildNodes = parent.childNodes || []
  1350. var nodeChildNodes = node.childNodes || []
  1351. // DocumentFragment
  1352. if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  1353. var nodeChildElements = nodeChildNodes.filter(isElementNode)
  1354. // If node has more than one element child or has a Text node child.
  1355. if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
  1356. throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment')
  1357. }
  1358. // Otherwise, if `node` has one element child and either `parent` has an element child,
  1359. // `child` is a doctype, or `child` is non-null and a doctype is following `child`.
  1360. if (nodeChildElements.length === 1 && !isElementInsertionPossible(parent, child)) {
  1361. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype')
  1362. }
  1363. }
  1364. // Element
  1365. if (isElementNode(node)) {
  1366. // `parent` has an element child, `child` is a doctype,
  1367. // or `child` is non-null and a doctype is following `child`.
  1368. if (!isElementInsertionPossible(parent, child)) {
  1369. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype')
  1370. }
  1371. }
  1372. // DocumentType
  1373. if (isDocTypeNode(node)) {
  1374. // `parent` has a doctype child,
  1375. if (find(parentChildNodes, isDocTypeNode)) {
  1376. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed')
  1377. }
  1378. var parentElementChild = find(parentChildNodes, isElementNode)
  1379. // `child` is non-null and an element is preceding `child`,
  1380. if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
  1381. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element')
  1382. }
  1383. // or `child` is null and `parent` has an element child.
  1384. if (!child && parentElementChild) {
  1385. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can not be appended since element is present')
  1386. }
  1387. }
  1388. }
  1389. /**
  1390. * @private
  1391. * Step 6 of the checks before inserting and before replacing a child are different.
  1392. *
  1393. * @param {Document} parent the parent node to insert `node` into
  1394. * @param {Node} node the node to insert
  1395. * @param {Node | undefined} child the node that should become the `nextSibling` of `node`
  1396. * @returns {Node}
  1397. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1398. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1399. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1400. * @see https://dom.spec.whatwg.org/#concept-node-replace
  1401. */
  1402. function assertPreReplacementValidityInDocument(parent, node, child) {
  1403. var parentChildNodes = parent.childNodes || []
  1404. var nodeChildNodes = node.childNodes || []
  1405. // DocumentFragment
  1406. if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
  1407. var nodeChildElements = nodeChildNodes.filter(isElementNode)
  1408. // If `node` has more than one element child or has a Text node child.
  1409. if (nodeChildElements.length > 1 || find(nodeChildNodes, isTextNode)) {
  1410. throw new DOMException(HIERARCHY_REQUEST_ERR, 'More than one element or text in fragment')
  1411. }
  1412. // Otherwise, if `node` has one element child and either `parent` has an element child that is not `child` or a doctype is following `child`.
  1413. if (nodeChildElements.length === 1 && !isElementReplacementPossible(parent, child)) {
  1414. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Element in fragment can not be inserted before doctype')
  1415. }
  1416. }
  1417. // Element
  1418. if (isElementNode(node)) {
  1419. // `parent` has an element child that is not `child` or a doctype is following `child`.
  1420. if (!isElementReplacementPossible(parent, child)) {
  1421. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one element can be added and only after doctype')
  1422. }
  1423. }
  1424. // DocumentType
  1425. if (isDocTypeNode(node)) {
  1426. function hasDoctypeChildThatIsNotChild(node) {
  1427. return isDocTypeNode(node) && node !== child
  1428. }
  1429. // `parent` has a doctype child that is not `child`,
  1430. if (find(parentChildNodes, hasDoctypeChildThatIsNotChild)) {
  1431. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Only one doctype is allowed')
  1432. }
  1433. var parentElementChild = find(parentChildNodes, isElementNode)
  1434. // or an element is preceding `child`.
  1435. if (child && parentChildNodes.indexOf(parentElementChild) < parentChildNodes.indexOf(child)) {
  1436. throw new DOMException(HIERARCHY_REQUEST_ERR, 'Doctype can only be inserted before an element')
  1437. }
  1438. }
  1439. }
  1440. /**
  1441. * @private
  1442. * @param {Node} parent the parent node to insert `node` into
  1443. * @param {Node} node the node to insert
  1444. * @param {Node=} child the node that should become the `nextSibling` of `node`
  1445. * @returns {Node}
  1446. * @throws DOMException for several node combinations that would create a DOM that is not well-formed.
  1447. * @throws DOMException if `child` is provided but is not a child of `parent`.
  1448. * @see https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity
  1449. */
  1450. function _insertBefore(parent, node, child, _inDocumentAssertion) {
  1451. // To ensure pre-insertion validity of a node into a parent before a child, run these steps:
  1452. assertPreInsertionValidity1to5(parent, node, child)
  1453. // If parent is a document, and any of the statements below, switched on the interface node implements,
  1454. // are true, then throw a "HierarchyRequestError" DOMException.
  1455. if (parent.nodeType === Node.DOCUMENT_NODE) {
  1456. ;(_inDocumentAssertion || assertPreInsertionValidityInDocument)(parent, node, child)
  1457. }
  1458. var cp = node.parentNode
  1459. if (cp) {
  1460. cp.removeChild(node) //remove and update
  1461. }
  1462. if (node.nodeType === DOCUMENT_FRAGMENT_NODE) {
  1463. var newFirst = node.firstChild
  1464. if (newFirst == null) {
  1465. return node
  1466. }
  1467. var newLast = node.lastChild
  1468. } else {
  1469. newFirst = newLast = node
  1470. }
  1471. var pre = child ? child.previousSibling : parent.lastChild
  1472. newFirst.previousSibling = pre
  1473. newLast.nextSibling = child
  1474. if (pre) {
  1475. pre.nextSibling = newFirst
  1476. } else {
  1477. parent.firstChild = newFirst
  1478. }
  1479. if (child == null) {
  1480. parent.lastChild = newLast
  1481. } else {
  1482. child.previousSibling = newLast
  1483. }
  1484. do {
  1485. newFirst.parentNode = parent
  1486. } while (newFirst !== newLast && (newFirst = newFirst.nextSibling))
  1487. _onUpdateChild(parent.ownerDocument || parent, parent)
  1488. //console.log(parent.lastChild.nextSibling == null)
  1489. if (node.nodeType == DOCUMENT_FRAGMENT_NODE) {
  1490. node.firstChild = node.lastChild = null
  1491. }
  1492. return node
  1493. }
  1494. /**
  1495. * Appends `newChild` to `parentNode`.
  1496. * If `newChild` is already connected to a `parentNode` it is first removed from it.
  1497. *
  1498. * @see https://github.com/xmldom/xmldom/issues/135
  1499. * @see https://github.com/xmldom/xmldom/issues/145
  1500. * @param {Node} parentNode
  1501. * @param {Node} newChild
  1502. * @returns {Node}
  1503. * @private
  1504. */
  1505. function _appendSingleChild(parentNode, newChild) {
  1506. if (newChild.parentNode) {
  1507. newChild.parentNode.removeChild(newChild)
  1508. }
  1509. newChild.parentNode = parentNode
  1510. newChild.previousSibling = parentNode.lastChild
  1511. newChild.nextSibling = null
  1512. if (newChild.previousSibling) {
  1513. newChild.previousSibling.nextSibling = newChild
  1514. } else {
  1515. parentNode.firstChild = newChild
  1516. }
  1517. parentNode.lastChild = newChild
  1518. _onUpdateChild(parentNode.ownerDocument, parentNode, newChild)
  1519. return newChild
  1520. }
  1521. Document.prototype = {
  1522. //implementation : null,
  1523. nodeName: '#document',
  1524. nodeType: DOCUMENT_NODE,
  1525. /**
  1526. * The DocumentType node of the document.
  1527. *
  1528. * @readonly
  1529. * @type DocumentType
  1530. */
  1531. doctype: null,
  1532. documentElement: null,
  1533. _inc: 1,
  1534. insertBefore: function (newChild, refChild) {
  1535. //raises
  1536. if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
  1537. var child = newChild.firstChild
  1538. while (child) {
  1539. var next = child.nextSibling
  1540. this.insertBefore(child, refChild)
  1541. child = next
  1542. }
  1543. return newChild
  1544. }
  1545. _insertBefore(this, newChild, refChild)
  1546. newChild.ownerDocument = this
  1547. if (this.documentElement === null && newChild.nodeType === ELEMENT_NODE) {
  1548. this.documentElement = newChild
  1549. }
  1550. return newChild
  1551. },
  1552. removeChild: function (oldChild) {
  1553. if (this.documentElement == oldChild) {
  1554. this.documentElement = null
  1555. }
  1556. return _removeChild(this, oldChild)
  1557. },
  1558. replaceChild: function (newChild, oldChild) {
  1559. //raises
  1560. _insertBefore(this, newChild, oldChild, assertPreReplacementValidityInDocument)
  1561. newChild.ownerDocument = this
  1562. if (oldChild) {
  1563. this.removeChild(oldChild)
  1564. }
  1565. if (isElementNode(newChild)) {
  1566. this.documentElement = newChild
  1567. }
  1568. },
  1569. // Introduced in DOM Level 2:
  1570. importNode: function (importedNode, deep) {
  1571. return importNode(this, importedNode, deep)
  1572. },
  1573. // Introduced in DOM Level 2:
  1574. getElementById: function (id) {
  1575. var rtv = null
  1576. _visitNode(this.documentElement, function (node) {
  1577. if (node.nodeType == ELEMENT_NODE) {
  1578. if (node.getAttribute('id') == id) {
  1579. rtv = node
  1580. return true
  1581. }
  1582. }
  1583. })
  1584. return rtv
  1585. },
  1586. /**
  1587. * The `getElementsByClassName` method of `Document` interface returns an array-like object
  1588. * of all child elements which have **all** of the given class name(s).
  1589. *
  1590. * Returns an empty list if `classeNames` is an empty string or only contains HTML white space characters.
  1591. *
  1592. *
  1593. * Warning: This is a live LiveNodeList.
  1594. * Changes in the DOM will reflect in the array as the changes occur.
  1595. * If an element selected by this array no longer qualifies for the selector,
  1596. * it will automatically be removed. Be aware of this for iteration purposes.
  1597. *
  1598. * @param {string} classNames is a string representing the class name(s) to match; multiple class names are separated by (ASCII-)whitespace
  1599. *
  1600. * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
  1601. * @see https://dom.spec.whatwg.org/#concept-getelementsbyclassname
  1602. */
  1603. getElementsByClassName: function (classNames) {
  1604. var classNamesSet = toOrderedSet(classNames)
  1605. return new LiveNodeList(this, function (base) {
  1606. var ls = []
  1607. if (classNamesSet.length > 0) {
  1608. _visitNode(base.documentElement, function (node) {
  1609. if (node !== base && node.nodeType === ELEMENT_NODE) {
  1610. var nodeClassNames = node.getAttribute('class')
  1611. // can be null if the attribute does not exist
  1612. if (nodeClassNames) {
  1613. // before splitting and iterating just compare them for the most common case
  1614. var matches = classNames === nodeClassNames
  1615. if (!matches) {
  1616. var nodeClassNamesSet = toOrderedSet(nodeClassNames)
  1617. matches = classNamesSet.every(arrayIncludes(nodeClassNamesSet))
  1618. }
  1619. if (matches) {
  1620. ls.push(node)
  1621. }
  1622. }
  1623. }
  1624. })
  1625. }
  1626. return ls
  1627. })
  1628. },
  1629. //document factory method:
  1630. createElement: function (tagName) {
  1631. var node = new Element()
  1632. node.ownerDocument = this
  1633. node.nodeName = tagName
  1634. node.tagName = tagName
  1635. node.localName = tagName
  1636. node.childNodes = new NodeList()
  1637. var attrs = (node.attributes = new NamedNodeMap())
  1638. attrs._ownerElement = node
  1639. return node
  1640. },
  1641. createDocumentFragment: function () {
  1642. var node = new DocumentFragment()
  1643. node.ownerDocument = this
  1644. node.childNodes = new NodeList()
  1645. return node
  1646. },
  1647. createTextNode: function (data) {
  1648. var node = new Text()
  1649. node.ownerDocument = this
  1650. node.appendData(data)
  1651. return node
  1652. },
  1653. createComment: function (data) {
  1654. var node = new Comment()
  1655. node.ownerDocument = this
  1656. node.appendData(data)
  1657. return node
  1658. },
  1659. createCDATASection: function (data) {
  1660. var node = new CDATASection()
  1661. node.ownerDocument = this
  1662. node.appendData(data)
  1663. return node
  1664. },
  1665. createProcessingInstruction: function (target, data) {
  1666. var node = new ProcessingInstruction()
  1667. node.ownerDocument = this
  1668. node.tagName = node.nodeName = node.target = target
  1669. node.nodeValue = node.data = data
  1670. return node
  1671. },
  1672. createAttribute: function (name) {
  1673. var node = new Attr()
  1674. node.ownerDocument = this
  1675. node.name = name
  1676. node.nodeName = name
  1677. node.localName = name
  1678. node.specified = true
  1679. return node
  1680. },
  1681. createEntityReference: function (name) {
  1682. var node = new EntityReference()
  1683. node.ownerDocument = this
  1684. node.nodeName = name
  1685. return node
  1686. },
  1687. // Introduced in DOM Level 2:
  1688. createElementNS: function (namespaceURI, qualifiedName) {
  1689. var node = new Element()
  1690. var pl = qualifiedName.split(':')
  1691. var attrs = (node.attributes = new NamedNodeMap())
  1692. node.childNodes = new NodeList()
  1693. node.ownerDocument = this
  1694. node.nodeName = qualifiedName
  1695. node.tagName = qualifiedName
  1696. node.namespaceURI = namespaceURI
  1697. if (pl.length == 2) {
  1698. node.prefix = pl[0]
  1699. node.localName = pl[1]
  1700. } else {
  1701. //el.prefix = null;
  1702. node.localName = qualifiedName
  1703. }
  1704. attrs._ownerElement = node
  1705. return node
  1706. },
  1707. // Introduced in DOM Level 2:
  1708. createAttributeNS: function (namespaceURI, qualifiedName) {
  1709. var node = new Attr()
  1710. var pl = qualifiedName.split(':')
  1711. node.ownerDocument = this
  1712. node.nodeName = qualifiedName
  1713. node.name = qualifiedName
  1714. node.namespaceURI = namespaceURI
  1715. node.specified = true
  1716. if (pl.length == 2) {
  1717. node.prefix = pl[0]
  1718. node.localName = pl[1]
  1719. } else {
  1720. //el.prefix = null;
  1721. node.localName = qualifiedName
  1722. }
  1723. return node
  1724. }
  1725. }
  1726. _extends(Document, Node)
  1727. function Element() {
  1728. this._nsMap = {}
  1729. }
  1730. Element.prototype = {
  1731. nodeType: ELEMENT_NODE,
  1732. hasAttribute: function (name) {
  1733. return this.getAttributeNode(name) != null
  1734. },
  1735. getAttribute: function (name) {
  1736. var attr = this.getAttributeNode(name)
  1737. return (attr && attr.value) || ''
  1738. },
  1739. getAttributeNode: function (name) {
  1740. return this.attributes.getNamedItem(name)
  1741. },
  1742. setAttribute: function (name, value) {
  1743. var attr = this.ownerDocument.createAttribute(name)
  1744. attr.value = attr.nodeValue = '' + value
  1745. this.setAttributeNode(attr)
  1746. },
  1747. removeAttribute: function (name) {
  1748. var attr = this.getAttributeNode(name)
  1749. attr && this.removeAttributeNode(attr)
  1750. },
  1751. //four real opeartion method
  1752. appendChild: function (newChild) {
  1753. if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
  1754. return this.insertBefore(newChild, null)
  1755. } else {
  1756. return _appendSingleChild(this, newChild)
  1757. }
  1758. },
  1759. setAttributeNode: function (newAttr) {
  1760. return this.attributes.setNamedItem(newAttr)
  1761. },
  1762. setAttributeNodeNS: function (newAttr) {
  1763. return this.attributes.setNamedItemNS(newAttr)
  1764. },
  1765. removeAttributeNode: function (oldAttr) {
  1766. //console.log(this == oldAttr.ownerElement)
  1767. return this.attributes.removeNamedItem(oldAttr.nodeName)
  1768. },
  1769. //get real attribute name,and remove it by removeAttributeNode
  1770. removeAttributeNS: function (namespaceURI, localName) {
  1771. var old = this.getAttributeNodeNS(namespaceURI, localName)
  1772. old && this.removeAttributeNode(old)
  1773. },
  1774. hasAttributeNS: function (namespaceURI, localName) {
  1775. return this.getAttributeNodeNS(namespaceURI, localName) != null
  1776. },
  1777. getAttributeNS: function (namespaceURI, localName) {
  1778. var attr = this.getAttributeNodeNS(namespaceURI, localName)
  1779. return (attr && attr.value) || ''
  1780. },
  1781. setAttributeNS: function (namespaceURI, qualifiedName, value) {
  1782. var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName)
  1783. attr.value = attr.nodeValue = '' + value
  1784. this.setAttributeNode(attr)
  1785. },
  1786. getAttributeNodeNS: function (namespaceURI, localName) {
  1787. return this.attributes.getNamedItemNS(namespaceURI, localName)
  1788. },
  1789. getElementsByTagName: function (tagName) {
  1790. return new LiveNodeList(this, function (base) {
  1791. var ls = []
  1792. _visitNode(base, function (node) {
  1793. if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)) {
  1794. ls.push(node)
  1795. }
  1796. })
  1797. return ls
  1798. })
  1799. },
  1800. getElementsByTagNameNS: function (namespaceURI, localName) {
  1801. return new LiveNodeList(this, function (base) {
  1802. var ls = []
  1803. _visitNode(base, function (node) {
  1804. if (
  1805. node !== base &&
  1806. node.nodeType === ELEMENT_NODE &&
  1807. (namespaceURI === '*' || node.namespaceURI === namespaceURI) &&
  1808. (localName === '*' || node.localName == localName)
  1809. ) {
  1810. ls.push(node)
  1811. }
  1812. })
  1813. return ls
  1814. })
  1815. }
  1816. }
  1817. Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName
  1818. Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS
  1819. _extends(Element, Node)
  1820. function Attr() {}
  1821. Attr.prototype.nodeType = ATTRIBUTE_NODE
  1822. _extends(Attr, Node)
  1823. function CharacterData() {}
  1824. CharacterData.prototype = {
  1825. data: '',
  1826. substringData: function (offset, count) {
  1827. return this.data.substring(offset, offset + count)
  1828. },
  1829. appendData: function (text) {
  1830. text = this.data + text
  1831. this.nodeValue = this.data = text
  1832. this.length = text.length
  1833. },
  1834. insertData: function (offset, text) {
  1835. this.replaceData(offset, 0, text)
  1836. },
  1837. appendChild: function (newChild) {
  1838. throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
  1839. },
  1840. deleteData: function (offset, count) {
  1841. this.replaceData(offset, count, '')
  1842. },
  1843. replaceData: function (offset, count, text) {
  1844. var start = this.data.substring(0, offset)
  1845. var end = this.data.substring(offset + count)
  1846. text = start + text + end
  1847. this.nodeValue = this.data = text
  1848. this.length = text.length
  1849. }
  1850. }
  1851. _extends(CharacterData, Node)
  1852. function Text() {}
  1853. Text.prototype = {
  1854. nodeName: '#text',
  1855. nodeType: TEXT_NODE,
  1856. splitText: function (offset) {
  1857. var text = this.data
  1858. var newText = text.substring(offset)
  1859. text = text.substring(0, offset)
  1860. this.data = this.nodeValue = text
  1861. this.length = text.length
  1862. var newNode = this.ownerDocument.createTextNode(newText)
  1863. if (this.parentNode) {
  1864. this.parentNode.insertBefore(newNode, this.nextSibling)
  1865. }
  1866. return newNode
  1867. }
  1868. }
  1869. _extends(Text, CharacterData)
  1870. function Comment() {}
  1871. Comment.prototype = {
  1872. nodeName: '#comment',
  1873. nodeType: COMMENT_NODE
  1874. }
  1875. _extends(Comment, CharacterData)
  1876. function CDATASection() {}
  1877. CDATASection.prototype = {
  1878. nodeName: '#cdata-section',
  1879. nodeType: CDATA_SECTION_NODE
  1880. }
  1881. _extends(CDATASection, CharacterData)
  1882. function DocumentType() {}
  1883. DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE
  1884. _extends(DocumentType, Node)
  1885. function Notation() {}
  1886. Notation.prototype.nodeType = NOTATION_NODE
  1887. _extends(Notation, Node)
  1888. function Entity() {}
  1889. Entity.prototype.nodeType = ENTITY_NODE
  1890. _extends(Entity, Node)
  1891. function EntityReference() {}
  1892. EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE
  1893. _extends(EntityReference, Node)
  1894. function DocumentFragment() {}
  1895. DocumentFragment.prototype.nodeName = '#document-fragment'
  1896. DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE
  1897. _extends(DocumentFragment, Node)
  1898. function ProcessingInstruction() {}
  1899. ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE
  1900. _extends(ProcessingInstruction, Node)
  1901. function XMLSerializer() {}
  1902. XMLSerializer.prototype.serializeToString = function (node, isHtml, nodeFilter) {
  1903. return nodeSerializeToString.call(node, isHtml, nodeFilter)
  1904. }
  1905. Node.prototype.toString = nodeSerializeToString
  1906. function nodeSerializeToString(isHtml, nodeFilter) {
  1907. var buf = []
  1908. var refNode = (this.nodeType == 9 && this.documentElement) || this
  1909. var prefix = refNode.prefix
  1910. var uri = refNode.namespaceURI
  1911. if (uri && prefix == null) {
  1912. //console.log(prefix)
  1913. var prefix = refNode.lookupPrefix(uri)
  1914. if (prefix == null) {
  1915. //isHTML = true;
  1916. var visibleNamespaces = [
  1917. { namespace: uri, prefix: null }
  1918. //{namespace:uri,prefix:''}
  1919. ]
  1920. }
  1921. }
  1922. serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces)
  1923. //console.log('###',this.nodeType,uri,prefix,buf.join(''))
  1924. return buf.join('')
  1925. }
  1926. function needNamespaceDefine(node, isHTML, visibleNamespaces) {
  1927. var prefix = node.prefix || ''
  1928. var uri = node.namespaceURI
  1929. // According to [Namespaces in XML 1.0](https://www.w3.org/TR/REC-xml-names/#ns-using) ,
  1930. // and more specifically https://www.w3.org/TR/REC-xml-names/#nsc-NoPrefixUndecl :
  1931. // > In a namespace declaration for a prefix [...], the attribute value MUST NOT be empty.
  1932. // in a similar manner [Namespaces in XML 1.1](https://www.w3.org/TR/xml-names11/#ns-using)
  1933. // and more specifically https://www.w3.org/TR/xml-names11/#nsc-NSDeclared :
  1934. // > [...] Furthermore, the attribute value [...] must not be an empty string.
  1935. // so serializing empty namespace value like xmlns:ds="" would produce an invalid XML document.
  1936. if (!uri) {
  1937. return false
  1938. }
  1939. if ((prefix === 'xml' && uri === NAMESPACE.XML) || uri === NAMESPACE.XMLNS) {
  1940. return false
  1941. }
  1942. var i = visibleNamespaces.length
  1943. while (i--) {
  1944. var ns = visibleNamespaces[i]
  1945. // get namespace prefix
  1946. if (ns.prefix === prefix) {
  1947. return ns.namespace !== uri
  1948. }
  1949. }
  1950. return true
  1951. }
  1952. /**
  1953. * Well-formed constraint: No < in Attribute Values
  1954. * > The replacement text of any entity referred to directly or indirectly
  1955. * > in an attribute value must not contain a <.
  1956. * @see https://www.w3.org/TR/xml11/#CleanAttrVals
  1957. * @see https://www.w3.org/TR/xml11/#NT-AttValue
  1958. *
  1959. * Literal whitespace other than space that appear in attribute values
  1960. * are serialized as their entity references, so they will be preserved.
  1961. * (In contrast to whitespace literals in the input which are normalized to spaces)
  1962. * @see https://www.w3.org/TR/xml11/#AVNormalize
  1963. * @see https://w3c.github.io/DOM-Parsing/#serializing-an-element-s-attributes
  1964. */
  1965. function addSerializedAttribute(buf, qualifiedName, value) {
  1966. buf.push(' ', qualifiedName, '="', value.replace(/[<>&"\t\n\r]/g, _xmlEncoder), '"')
  1967. }
  1968. function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
  1969. if (!visibleNamespaces) {
  1970. visibleNamespaces = []
  1971. }
  1972. if (nodeFilter) {
  1973. node = nodeFilter(node)
  1974. if (node) {
  1975. if (typeof node == 'string') {
  1976. buf.push(node)
  1977. return
  1978. }
  1979. } else {
  1980. return
  1981. }
  1982. //buf.sort.apply(attrs, attributeSorter);
  1983. }
  1984. switch (node.nodeType) {
  1985. case ELEMENT_NODE:
  1986. var attrs = node.attributes
  1987. var len = attrs.length
  1988. var child = node.firstChild
  1989. var nodeName = node.tagName
  1990. isHTML = NAMESPACE.isHTML(node.namespaceURI) || isHTML
  1991. var prefixedNodeName = nodeName
  1992. if (!isHTML && !node.prefix && node.namespaceURI) {
  1993. var defaultNS
  1994. // lookup current default ns from `xmlns` attribute
  1995. for (var ai = 0; ai < attrs.length; ai++) {
  1996. if (attrs.item(ai).name === 'xmlns') {
  1997. defaultNS = attrs.item(ai).value
  1998. break
  1999. }
  2000. }
  2001. if (!defaultNS) {
  2002. // lookup current default ns in visibleNamespaces
  2003. for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
  2004. var namespace = visibleNamespaces[nsi]
  2005. if (namespace.prefix === '' && namespace.namespace === node.namespaceURI) {
  2006. defaultNS = namespace.namespace
  2007. break
  2008. }
  2009. }
  2010. }
  2011. if (defaultNS !== node.namespaceURI) {
  2012. for (var nsi = visibleNamespaces.length - 1; nsi >= 0; nsi--) {
  2013. var namespace = visibleNamespaces[nsi]
  2014. if (namespace.namespace === node.namespaceURI) {
  2015. if (namespace.prefix) {
  2016. prefixedNodeName = namespace.prefix + ':' + nodeName
  2017. }
  2018. break
  2019. }
  2020. }
  2021. }
  2022. }
  2023. buf.push('<', prefixedNodeName)
  2024. for (var i = 0; i < len; i++) {
  2025. // add namespaces for attributes
  2026. var attr = attrs.item(i)
  2027. if (attr.prefix == 'xmlns') {
  2028. visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value })
  2029. } else if (attr.nodeName == 'xmlns') {
  2030. visibleNamespaces.push({ prefix: '', namespace: attr.value })
  2031. }
  2032. }
  2033. for (var i = 0; i < len; i++) {
  2034. var attr = attrs.item(i)
  2035. if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
  2036. var prefix = attr.prefix || ''
  2037. var uri = attr.namespaceURI
  2038. addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri)
  2039. visibleNamespaces.push({ prefix: prefix, namespace: uri })
  2040. }
  2041. serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces)
  2042. }
  2043. // add namespace for current node
  2044. if (nodeName === prefixedNodeName && needNamespaceDefine(node, isHTML, visibleNamespaces)) {
  2045. var prefix = node.prefix || ''
  2046. var uri = node.namespaceURI
  2047. addSerializedAttribute(buf, prefix ? 'xmlns:' + prefix : 'xmlns', uri)
  2048. visibleNamespaces.push({ prefix: prefix, namespace: uri })
  2049. }
  2050. if (child || (isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName))) {
  2051. buf.push('>')
  2052. //if is cdata child node
  2053. if (isHTML && /^script$/i.test(nodeName)) {
  2054. while (child) {
  2055. if (child.data) {
  2056. buf.push(child.data)
  2057. } else {
  2058. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice())
  2059. }
  2060. child = child.nextSibling
  2061. }
  2062. } else {
  2063. while (child) {
  2064. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice())
  2065. child = child.nextSibling
  2066. }
  2067. }
  2068. buf.push('</', prefixedNodeName, '>')
  2069. } else {
  2070. buf.push('/>')
  2071. }
  2072. // remove added visible namespaces
  2073. //visibleNamespaces.length = startVisibleNamespaces;
  2074. return
  2075. case DOCUMENT_NODE:
  2076. case DOCUMENT_FRAGMENT_NODE:
  2077. var child = node.firstChild
  2078. while (child) {
  2079. serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces.slice())
  2080. child = child.nextSibling
  2081. }
  2082. return
  2083. case ATTRIBUTE_NODE:
  2084. return addSerializedAttribute(buf, node.name, node.value)
  2085. case TEXT_NODE:
  2086. /**
  2087. * The ampersand character (&) and the left angle bracket (<) must not appear in their literal form,
  2088. * except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section.
  2089. * If they are needed elsewhere, they must be escaped using either numeric character references or the strings
  2090. * `&amp;` and `&lt;` respectively.
  2091. * The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility,
  2092. * be escaped using either `&gt;` or a character reference when it appears in the string `]]>` in content,
  2093. * when that string is not marking the end of a CDATA section.
  2094. *
  2095. * In the content of elements, character data is any string of characters
  2096. * which does not contain the start-delimiter of any markup
  2097. * and does not include the CDATA-section-close delimiter, `]]>`.
  2098. *
  2099. * @see https://www.w3.org/TR/xml/#NT-CharData
  2100. * @see https://w3c.github.io/DOM-Parsing/#xml-serializing-a-text-node
  2101. */
  2102. return buf.push(node.data.replace(/[<&>]/g, _xmlEncoder))
  2103. case CDATA_SECTION_NODE:
  2104. return buf.push('<![CDATA[', node.data, ']]>')
  2105. case COMMENT_NODE:
  2106. return buf.push('<!--', node.data, '-->')
  2107. case DOCUMENT_TYPE_NODE:
  2108. var pubid = node.publicId
  2109. var sysid = node.systemId
  2110. buf.push('<!DOCTYPE ', node.name)
  2111. if (pubid) {
  2112. buf.push(' PUBLIC ', pubid)
  2113. if (sysid && sysid != '.') {
  2114. buf.push(' ', sysid)
  2115. }
  2116. buf.push('>')
  2117. } else if (sysid && sysid != '.') {
  2118. buf.push(' SYSTEM ', sysid, '>')
  2119. } else {
  2120. var sub = node.internalSubset
  2121. if (sub) {
  2122. buf.push(' [', sub, ']')
  2123. }
  2124. buf.push('>')
  2125. }
  2126. return
  2127. case PROCESSING_INSTRUCTION_NODE:
  2128. return buf.push('<?', node.target, ' ', node.data, '?>')
  2129. case ENTITY_REFERENCE_NODE:
  2130. return buf.push('&', node.nodeName, ';')
  2131. //case ENTITY_NODE:
  2132. //case NOTATION_NODE:
  2133. default:
  2134. buf.push('??', node.nodeName)
  2135. }
  2136. }
  2137. function importNode(doc, node, deep) {
  2138. var node2
  2139. switch (node.nodeType) {
  2140. case ELEMENT_NODE:
  2141. node2 = node.cloneNode(false)
  2142. node2.ownerDocument = doc
  2143. //var attrs = node2.attributes;
  2144. //var len = attrs.length;
  2145. //for(var i=0;i<len;i++){
  2146. //node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
  2147. //}
  2148. case DOCUMENT_FRAGMENT_NODE:
  2149. break
  2150. case ATTRIBUTE_NODE:
  2151. deep = true
  2152. break
  2153. //case ENTITY_REFERENCE_NODE:
  2154. //case PROCESSING_INSTRUCTION_NODE:
  2155. ////case TEXT_NODE:
  2156. //case CDATA_SECTION_NODE:
  2157. //case COMMENT_NODE:
  2158. // deep = false;
  2159. // break;
  2160. //case DOCUMENT_NODE:
  2161. //case DOCUMENT_TYPE_NODE:
  2162. //cannot be imported.
  2163. //case ENTITY_NODE:
  2164. //case NOTATION_NODE:
  2165. //can not hit in level3
  2166. //default:throw e;
  2167. }
  2168. if (!node2) {
  2169. node2 = node.cloneNode(false) //false
  2170. }
  2171. node2.ownerDocument = doc
  2172. node2.parentNode = null
  2173. if (deep) {
  2174. var child = node.firstChild
  2175. while (child) {
  2176. node2.appendChild(importNode(doc, child, deep))
  2177. child = child.nextSibling
  2178. }
  2179. }
  2180. return node2
  2181. }
  2182. //
  2183. //var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
  2184. // attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
  2185. function cloneNode(doc, node, deep) {
  2186. var node2 = new node.constructor()
  2187. for (var n in node) {
  2188. if (Object.prototype.hasOwnProperty.call(node, n)) {
  2189. var v = node[n]
  2190. if (typeof v != 'object') {
  2191. if (v != node2[n]) {
  2192. node2[n] = v
  2193. }
  2194. }
  2195. }
  2196. }
  2197. if (node.childNodes) {
  2198. node2.childNodes = new NodeList()
  2199. }
  2200. node2.ownerDocument = doc
  2201. switch (node2.nodeType) {
  2202. case ELEMENT_NODE:
  2203. var attrs = node.attributes
  2204. var attrs2 = (node2.attributes = new NamedNodeMap())
  2205. var len = attrs.length
  2206. attrs2._ownerElement = node2
  2207. for (var i = 0; i < len; i++) {
  2208. node2.setAttributeNode(cloneNode(doc, attrs.item(i), true))
  2209. }
  2210. break
  2211. case ATTRIBUTE_NODE:
  2212. deep = true
  2213. }
  2214. if (deep) {
  2215. var child = node.firstChild
  2216. while (child) {
  2217. node2.appendChild(cloneNode(doc, child, deep))
  2218. child = child.nextSibling
  2219. }
  2220. }
  2221. return node2
  2222. }
  2223. function __set__(object, key, value) {
  2224. object[key] = value
  2225. }
  2226. //do dynamic
  2227. try {
  2228. if (Object.defineProperty) {
  2229. Object.defineProperty(LiveNodeList.prototype, 'length', {
  2230. get: function () {
  2231. _updateLiveList(this)
  2232. return this.$$length
  2233. }
  2234. })
  2235. Object.defineProperty(Node.prototype, 'textContent', {
  2236. get: function () {
  2237. return getTextContent(this)
  2238. },
  2239. set: function (data) {
  2240. switch (this.nodeType) {
  2241. case ELEMENT_NODE:
  2242. case DOCUMENT_FRAGMENT_NODE:
  2243. while (this.firstChild) {
  2244. this.removeChild(this.firstChild)
  2245. }
  2246. if (data || String(data)) {
  2247. this.appendChild(this.ownerDocument.createTextNode(data))
  2248. }
  2249. break
  2250. default:
  2251. this.data = data
  2252. this.value = data
  2253. this.nodeValue = data
  2254. }
  2255. }
  2256. })
  2257. function getTextContent(node) {
  2258. switch (node.nodeType) {
  2259. case ELEMENT_NODE:
  2260. case DOCUMENT_FRAGMENT_NODE:
  2261. var buf = []
  2262. node = node.firstChild
  2263. while (node) {
  2264. if (node.nodeType !== 7 && node.nodeType !== 8) {
  2265. buf.push(getTextContent(node))
  2266. }
  2267. node = node.nextSibling
  2268. }
  2269. return buf.join('')
  2270. default:
  2271. return node.nodeValue
  2272. }
  2273. }
  2274. __set__ = function (object, key, value) {
  2275. //console.log(value)
  2276. object['$$' + key] = value
  2277. }
  2278. }
  2279. } catch (e) {
  2280. //ie8
  2281. }
  2282. //if(typeof require == 'function'){
  2283. exports.DocumentType = DocumentType
  2284. exports.DOMException = DOMException
  2285. exports.DOMImplementation = DOMImplementation
  2286. exports.Element = Element
  2287. exports.Node = Node
  2288. exports.NodeList = NodeList
  2289. exports.XMLSerializer = XMLSerializer
  2290. //}
  2291. },
  2292. { './conventions': 5 }
  2293. ],
  2294. 8: [
  2295. function (require, module, exports) {
  2296. 'use strict'
  2297. var freeze = require('./conventions').freeze
  2298. /**
  2299. * The entities that are predefined in every XML document.
  2300. *
  2301. * @see https://www.w3.org/TR/2006/REC-xml11-20060816/#sec-predefined-ent W3C XML 1.1
  2302. * @see https://www.w3.org/TR/2008/REC-xml-20081126/#sec-predefined-ent W3C XML 1.0
  2303. * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML Wikipedia
  2304. */
  2305. exports.XML_ENTITIES = freeze({
  2306. amp: '&',
  2307. apos: "'",
  2308. gt: '>',
  2309. lt: '<',
  2310. quot: '"'
  2311. })
  2312. /**
  2313. * A map of all entities that are detected in an HTML document.
  2314. * They contain all entries from `XML_ENTITIES`.
  2315. *
  2316. * @see XML_ENTITIES
  2317. * @see DOMParser.parseFromString
  2318. * @see DOMImplementation.prototype.createHTMLDocument
  2319. * @see https://html.spec.whatwg.org/#named-character-references WHATWG HTML(5) Spec
  2320. * @see https://html.spec.whatwg.org/entities.json JSON
  2321. * @see https://www.w3.org/TR/xml-entity-names/ W3C XML Entity Names
  2322. * @see https://www.w3.org/TR/html4/sgml/entities.html W3C HTML4/SGML
  2323. * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Character_entity_references_in_HTML Wikipedia (HTML)
  2324. * @see https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML Wikpedia (XHTML)
  2325. */
  2326. exports.HTML_ENTITIES = freeze({
  2327. Aacute: '\u00C1',
  2328. aacute: '\u00E1',
  2329. Abreve: '\u0102',
  2330. abreve: '\u0103',
  2331. ac: '\u223E',
  2332. acd: '\u223F',
  2333. acE: '\u223E\u0333',
  2334. Acirc: '\u00C2',
  2335. acirc: '\u00E2',
  2336. acute: '\u00B4',
  2337. Acy: '\u0410',
  2338. acy: '\u0430',
  2339. AElig: '\u00C6',
  2340. aelig: '\u00E6',
  2341. af: '\u2061',
  2342. Afr: '\uD835\uDD04',
  2343. afr: '\uD835\uDD1E',
  2344. Agrave: '\u00C0',
  2345. agrave: '\u00E0',
  2346. alefsym: '\u2135',
  2347. aleph: '\u2135',
  2348. Alpha: '\u0391',
  2349. alpha: '\u03B1',
  2350. Amacr: '\u0100',
  2351. amacr: '\u0101',
  2352. amalg: '\u2A3F',
  2353. AMP: '\u0026',
  2354. amp: '\u0026',
  2355. And: '\u2A53',
  2356. and: '\u2227',
  2357. andand: '\u2A55',
  2358. andd: '\u2A5C',
  2359. andslope: '\u2A58',
  2360. andv: '\u2A5A',
  2361. ang: '\u2220',
  2362. ange: '\u29A4',
  2363. angle: '\u2220',
  2364. angmsd: '\u2221',
  2365. angmsdaa: '\u29A8',
  2366. angmsdab: '\u29A9',
  2367. angmsdac: '\u29AA',
  2368. angmsdad: '\u29AB',
  2369. angmsdae: '\u29AC',
  2370. angmsdaf: '\u29AD',
  2371. angmsdag: '\u29AE',
  2372. angmsdah: '\u29AF',
  2373. angrt: '\u221F',
  2374. angrtvb: '\u22BE',
  2375. angrtvbd: '\u299D',
  2376. angsph: '\u2222',
  2377. angst: '\u00C5',
  2378. angzarr: '\u237C',
  2379. Aogon: '\u0104',
  2380. aogon: '\u0105',
  2381. Aopf: '\uD835\uDD38',
  2382. aopf: '\uD835\uDD52',
  2383. ap: '\u2248',
  2384. apacir: '\u2A6F',
  2385. apE: '\u2A70',
  2386. ape: '\u224A',
  2387. apid: '\u224B',
  2388. apos: '\u0027',
  2389. ApplyFunction: '\u2061',
  2390. approx: '\u2248',
  2391. approxeq: '\u224A',
  2392. Aring: '\u00C5',
  2393. aring: '\u00E5',
  2394. Ascr: '\uD835\uDC9C',
  2395. ascr: '\uD835\uDCB6',
  2396. Assign: '\u2254',
  2397. ast: '\u002A',
  2398. asymp: '\u2248',
  2399. asympeq: '\u224D',
  2400. Atilde: '\u00C3',
  2401. atilde: '\u00E3',
  2402. Auml: '\u00C4',
  2403. auml: '\u00E4',
  2404. awconint: '\u2233',
  2405. awint: '\u2A11',
  2406. backcong: '\u224C',
  2407. backepsilon: '\u03F6',
  2408. backprime: '\u2035',
  2409. backsim: '\u223D',
  2410. backsimeq: '\u22CD',
  2411. Backslash: '\u2216',
  2412. Barv: '\u2AE7',
  2413. barvee: '\u22BD',
  2414. Barwed: '\u2306',
  2415. barwed: '\u2305',
  2416. barwedge: '\u2305',
  2417. bbrk: '\u23B5',
  2418. bbrktbrk: '\u23B6',
  2419. bcong: '\u224C',
  2420. Bcy: '\u0411',
  2421. bcy: '\u0431',
  2422. bdquo: '\u201E',
  2423. becaus: '\u2235',
  2424. Because: '\u2235',
  2425. because: '\u2235',
  2426. bemptyv: '\u29B0',
  2427. bepsi: '\u03F6',
  2428. bernou: '\u212C',
  2429. Bernoullis: '\u212C',
  2430. Beta: '\u0392',
  2431. beta: '\u03B2',
  2432. beth: '\u2136',
  2433. between: '\u226C',
  2434. Bfr: '\uD835\uDD05',
  2435. bfr: '\uD835\uDD1F',
  2436. bigcap: '\u22C2',
  2437. bigcirc: '\u25EF',
  2438. bigcup: '\u22C3',
  2439. bigodot: '\u2A00',
  2440. bigoplus: '\u2A01',
  2441. bigotimes: '\u2A02',
  2442. bigsqcup: '\u2A06',
  2443. bigstar: '\u2605',
  2444. bigtriangledown: '\u25BD',
  2445. bigtriangleup: '\u25B3',
  2446. biguplus: '\u2A04',
  2447. bigvee: '\u22C1',
  2448. bigwedge: '\u22C0',
  2449. bkarow: '\u290D',
  2450. blacklozenge: '\u29EB',
  2451. blacksquare: '\u25AA',
  2452. blacktriangle: '\u25B4',
  2453. blacktriangledown: '\u25BE',
  2454. blacktriangleleft: '\u25C2',
  2455. blacktriangleright: '\u25B8',
  2456. blank: '\u2423',
  2457. blk12: '\u2592',
  2458. blk14: '\u2591',
  2459. blk34: '\u2593',
  2460. block: '\u2588',
  2461. bne: '\u003D\u20E5',
  2462. bnequiv: '\u2261\u20E5',
  2463. bNot: '\u2AED',
  2464. bnot: '\u2310',
  2465. Bopf: '\uD835\uDD39',
  2466. bopf: '\uD835\uDD53',
  2467. bot: '\u22A5',
  2468. bottom: '\u22A5',
  2469. bowtie: '\u22C8',
  2470. boxbox: '\u29C9',
  2471. boxDL: '\u2557',
  2472. boxDl: '\u2556',
  2473. boxdL: '\u2555',
  2474. boxdl: '\u2510',
  2475. boxDR: '\u2554',
  2476. boxDr: '\u2553',
  2477. boxdR: '\u2552',
  2478. boxdr: '\u250C',
  2479. boxH: '\u2550',
  2480. boxh: '\u2500',
  2481. boxHD: '\u2566',
  2482. boxHd: '\u2564',
  2483. boxhD: '\u2565',
  2484. boxhd: '\u252C',
  2485. boxHU: '\u2569',
  2486. boxHu: '\u2567',
  2487. boxhU: '\u2568',
  2488. boxhu: '\u2534',
  2489. boxminus: '\u229F',
  2490. boxplus: '\u229E',
  2491. boxtimes: '\u22A0',
  2492. boxUL: '\u255D',
  2493. boxUl: '\u255C',
  2494. boxuL: '\u255B',
  2495. boxul: '\u2518',
  2496. boxUR: '\u255A',
  2497. boxUr: '\u2559',
  2498. boxuR: '\u2558',
  2499. boxur: '\u2514',
  2500. boxV: '\u2551',
  2501. boxv: '\u2502',
  2502. boxVH: '\u256C',
  2503. boxVh: '\u256B',
  2504. boxvH: '\u256A',
  2505. boxvh: '\u253C',
  2506. boxVL: '\u2563',
  2507. boxVl: '\u2562',
  2508. boxvL: '\u2561',
  2509. boxvl: '\u2524',
  2510. boxVR: '\u2560',
  2511. boxVr: '\u255F',
  2512. boxvR: '\u255E',
  2513. boxvr: '\u251C',
  2514. bprime: '\u2035',
  2515. Breve: '\u02D8',
  2516. breve: '\u02D8',
  2517. brvbar: '\u00A6',
  2518. Bscr: '\u212C',
  2519. bscr: '\uD835\uDCB7',
  2520. bsemi: '\u204F',
  2521. bsim: '\u223D',
  2522. bsime: '\u22CD',
  2523. bsol: '\u005C',
  2524. bsolb: '\u29C5',
  2525. bsolhsub: '\u27C8',
  2526. bull: '\u2022',
  2527. bullet: '\u2022',
  2528. bump: '\u224E',
  2529. bumpE: '\u2AAE',
  2530. bumpe: '\u224F',
  2531. Bumpeq: '\u224E',
  2532. bumpeq: '\u224F',
  2533. Cacute: '\u0106',
  2534. cacute: '\u0107',
  2535. Cap: '\u22D2',
  2536. cap: '\u2229',
  2537. capand: '\u2A44',
  2538. capbrcup: '\u2A49',
  2539. capcap: '\u2A4B',
  2540. capcup: '\u2A47',
  2541. capdot: '\u2A40',
  2542. CapitalDifferentialD: '\u2145',
  2543. caps: '\u2229\uFE00',
  2544. caret: '\u2041',
  2545. caron: '\u02C7',
  2546. Cayleys: '\u212D',
  2547. ccaps: '\u2A4D',
  2548. Ccaron: '\u010C',
  2549. ccaron: '\u010D',
  2550. Ccedil: '\u00C7',
  2551. ccedil: '\u00E7',
  2552. Ccirc: '\u0108',
  2553. ccirc: '\u0109',
  2554. Cconint: '\u2230',
  2555. ccups: '\u2A4C',
  2556. ccupssm: '\u2A50',
  2557. Cdot: '\u010A',
  2558. cdot: '\u010B',
  2559. cedil: '\u00B8',
  2560. Cedilla: '\u00B8',
  2561. cemptyv: '\u29B2',
  2562. cent: '\u00A2',
  2563. CenterDot: '\u00B7',
  2564. centerdot: '\u00B7',
  2565. Cfr: '\u212D',
  2566. cfr: '\uD835\uDD20',
  2567. CHcy: '\u0427',
  2568. chcy: '\u0447',
  2569. check: '\u2713',
  2570. checkmark: '\u2713',
  2571. Chi: '\u03A7',
  2572. chi: '\u03C7',
  2573. cir: '\u25CB',
  2574. circ: '\u02C6',
  2575. circeq: '\u2257',
  2576. circlearrowleft: '\u21BA',
  2577. circlearrowright: '\u21BB',
  2578. circledast: '\u229B',
  2579. circledcirc: '\u229A',
  2580. circleddash: '\u229D',
  2581. CircleDot: '\u2299',
  2582. circledR: '\u00AE',
  2583. circledS: '\u24C8',
  2584. CircleMinus: '\u2296',
  2585. CirclePlus: '\u2295',
  2586. CircleTimes: '\u2297',
  2587. cirE: '\u29C3',
  2588. cire: '\u2257',
  2589. cirfnint: '\u2A10',
  2590. cirmid: '\u2AEF',
  2591. cirscir: '\u29C2',
  2592. ClockwiseContourIntegral: '\u2232',
  2593. CloseCurlyDoubleQuote: '\u201D',
  2594. CloseCurlyQuote: '\u2019',
  2595. clubs: '\u2663',
  2596. clubsuit: '\u2663',
  2597. Colon: '\u2237',
  2598. colon: '\u003A',
  2599. Colone: '\u2A74',
  2600. colone: '\u2254',
  2601. coloneq: '\u2254',
  2602. comma: '\u002C',
  2603. commat: '\u0040',
  2604. comp: '\u2201',
  2605. compfn: '\u2218',
  2606. complement: '\u2201',
  2607. complexes: '\u2102',
  2608. cong: '\u2245',
  2609. congdot: '\u2A6D',
  2610. Congruent: '\u2261',
  2611. Conint: '\u222F',
  2612. conint: '\u222E',
  2613. ContourIntegral: '\u222E',
  2614. Copf: '\u2102',
  2615. copf: '\uD835\uDD54',
  2616. coprod: '\u2210',
  2617. Coproduct: '\u2210',
  2618. COPY: '\u00A9',
  2619. copy: '\u00A9',
  2620. copysr: '\u2117',
  2621. CounterClockwiseContourIntegral: '\u2233',
  2622. crarr: '\u21B5',
  2623. Cross: '\u2A2F',
  2624. cross: '\u2717',
  2625. Cscr: '\uD835\uDC9E',
  2626. cscr: '\uD835\uDCB8',
  2627. csub: '\u2ACF',
  2628. csube: '\u2AD1',
  2629. csup: '\u2AD0',
  2630. csupe: '\u2AD2',
  2631. ctdot: '\u22EF',
  2632. cudarrl: '\u2938',
  2633. cudarrr: '\u2935',
  2634. cuepr: '\u22DE',
  2635. cuesc: '\u22DF',
  2636. cularr: '\u21B6',
  2637. cularrp: '\u293D',
  2638. Cup: '\u22D3',
  2639. cup: '\u222A',
  2640. cupbrcap: '\u2A48',
  2641. CupCap: '\u224D',
  2642. cupcap: '\u2A46',
  2643. cupcup: '\u2A4A',
  2644. cupdot: '\u228D',
  2645. cupor: '\u2A45',
  2646. cups: '\u222A\uFE00',
  2647. curarr: '\u21B7',
  2648. curarrm: '\u293C',
  2649. curlyeqprec: '\u22DE',
  2650. curlyeqsucc: '\u22DF',
  2651. curlyvee: '\u22CE',
  2652. curlywedge: '\u22CF',
  2653. curren: '\u00A4',
  2654. curvearrowleft: '\u21B6',
  2655. curvearrowright: '\u21B7',
  2656. cuvee: '\u22CE',
  2657. cuwed: '\u22CF',
  2658. cwconint: '\u2232',
  2659. cwint: '\u2231',
  2660. cylcty: '\u232D',
  2661. Dagger: '\u2021',
  2662. dagger: '\u2020',
  2663. daleth: '\u2138',
  2664. Darr: '\u21A1',
  2665. dArr: '\u21D3',
  2666. darr: '\u2193',
  2667. dash: '\u2010',
  2668. Dashv: '\u2AE4',
  2669. dashv: '\u22A3',
  2670. dbkarow: '\u290F',
  2671. dblac: '\u02DD',
  2672. Dcaron: '\u010E',
  2673. dcaron: '\u010F',
  2674. Dcy: '\u0414',
  2675. dcy: '\u0434',
  2676. DD: '\u2145',
  2677. dd: '\u2146',
  2678. ddagger: '\u2021',
  2679. ddarr: '\u21CA',
  2680. DDotrahd: '\u2911',
  2681. ddotseq: '\u2A77',
  2682. deg: '\u00B0',
  2683. Del: '\u2207',
  2684. Delta: '\u0394',
  2685. delta: '\u03B4',
  2686. demptyv: '\u29B1',
  2687. dfisht: '\u297F',
  2688. Dfr: '\uD835\uDD07',
  2689. dfr: '\uD835\uDD21',
  2690. dHar: '\u2965',
  2691. dharl: '\u21C3',
  2692. dharr: '\u21C2',
  2693. DiacriticalAcute: '\u00B4',
  2694. DiacriticalDot: '\u02D9',
  2695. DiacriticalDoubleAcute: '\u02DD',
  2696. DiacriticalGrave: '\u0060',
  2697. DiacriticalTilde: '\u02DC',
  2698. diam: '\u22C4',
  2699. Diamond: '\u22C4',
  2700. diamond: '\u22C4',
  2701. diamondsuit: '\u2666',
  2702. diams: '\u2666',
  2703. die: '\u00A8',
  2704. DifferentialD: '\u2146',
  2705. digamma: '\u03DD',
  2706. disin: '\u22F2',
  2707. div: '\u00F7',
  2708. divide: '\u00F7',
  2709. divideontimes: '\u22C7',
  2710. divonx: '\u22C7',
  2711. DJcy: '\u0402',
  2712. djcy: '\u0452',
  2713. dlcorn: '\u231E',
  2714. dlcrop: '\u230D',
  2715. dollar: '\u0024',
  2716. Dopf: '\uD835\uDD3B',
  2717. dopf: '\uD835\uDD55',
  2718. Dot: '\u00A8',
  2719. dot: '\u02D9',
  2720. DotDot: '\u20DC',
  2721. doteq: '\u2250',
  2722. doteqdot: '\u2251',
  2723. DotEqual: '\u2250',
  2724. dotminus: '\u2238',
  2725. dotplus: '\u2214',
  2726. dotsquare: '\u22A1',
  2727. doublebarwedge: '\u2306',
  2728. DoubleContourIntegral: '\u222F',
  2729. DoubleDot: '\u00A8',
  2730. DoubleDownArrow: '\u21D3',
  2731. DoubleLeftArrow: '\u21D0',
  2732. DoubleLeftRightArrow: '\u21D4',
  2733. DoubleLeftTee: '\u2AE4',
  2734. DoubleLongLeftArrow: '\u27F8',
  2735. DoubleLongLeftRightArrow: '\u27FA',
  2736. DoubleLongRightArrow: '\u27F9',
  2737. DoubleRightArrow: '\u21D2',
  2738. DoubleRightTee: '\u22A8',
  2739. DoubleUpArrow: '\u21D1',
  2740. DoubleUpDownArrow: '\u21D5',
  2741. DoubleVerticalBar: '\u2225',
  2742. DownArrow: '\u2193',
  2743. Downarrow: '\u21D3',
  2744. downarrow: '\u2193',
  2745. DownArrowBar: '\u2913',
  2746. DownArrowUpArrow: '\u21F5',
  2747. DownBreve: '\u0311',
  2748. downdownarrows: '\u21CA',
  2749. downharpoonleft: '\u21C3',
  2750. downharpoonright: '\u21C2',
  2751. DownLeftRightVector: '\u2950',
  2752. DownLeftTeeVector: '\u295E',
  2753. DownLeftVector: '\u21BD',
  2754. DownLeftVectorBar: '\u2956',
  2755. DownRightTeeVector: '\u295F',
  2756. DownRightVector: '\u21C1',
  2757. DownRightVectorBar: '\u2957',
  2758. DownTee: '\u22A4',
  2759. DownTeeArrow: '\u21A7',
  2760. drbkarow: '\u2910',
  2761. drcorn: '\u231F',
  2762. drcrop: '\u230C',
  2763. Dscr: '\uD835\uDC9F',
  2764. dscr: '\uD835\uDCB9',
  2765. DScy: '\u0405',
  2766. dscy: '\u0455',
  2767. dsol: '\u29F6',
  2768. Dstrok: '\u0110',
  2769. dstrok: '\u0111',
  2770. dtdot: '\u22F1',
  2771. dtri: '\u25BF',
  2772. dtrif: '\u25BE',
  2773. duarr: '\u21F5',
  2774. duhar: '\u296F',
  2775. dwangle: '\u29A6',
  2776. DZcy: '\u040F',
  2777. dzcy: '\u045F',
  2778. dzigrarr: '\u27FF',
  2779. Eacute: '\u00C9',
  2780. eacute: '\u00E9',
  2781. easter: '\u2A6E',
  2782. Ecaron: '\u011A',
  2783. ecaron: '\u011B',
  2784. ecir: '\u2256',
  2785. Ecirc: '\u00CA',
  2786. ecirc: '\u00EA',
  2787. ecolon: '\u2255',
  2788. Ecy: '\u042D',
  2789. ecy: '\u044D',
  2790. eDDot: '\u2A77',
  2791. Edot: '\u0116',
  2792. eDot: '\u2251',
  2793. edot: '\u0117',
  2794. ee: '\u2147',
  2795. efDot: '\u2252',
  2796. Efr: '\uD835\uDD08',
  2797. efr: '\uD835\uDD22',
  2798. eg: '\u2A9A',
  2799. Egrave: '\u00C8',
  2800. egrave: '\u00E8',
  2801. egs: '\u2A96',
  2802. egsdot: '\u2A98',
  2803. el: '\u2A99',
  2804. Element: '\u2208',
  2805. elinters: '\u23E7',
  2806. ell: '\u2113',
  2807. els: '\u2A95',
  2808. elsdot: '\u2A97',
  2809. Emacr: '\u0112',
  2810. emacr: '\u0113',
  2811. empty: '\u2205',
  2812. emptyset: '\u2205',
  2813. EmptySmallSquare: '\u25FB',
  2814. emptyv: '\u2205',
  2815. EmptyVerySmallSquare: '\u25AB',
  2816. emsp: '\u2003',
  2817. emsp13: '\u2004',
  2818. emsp14: '\u2005',
  2819. ENG: '\u014A',
  2820. eng: '\u014B',
  2821. ensp: '\u2002',
  2822. Eogon: '\u0118',
  2823. eogon: '\u0119',
  2824. Eopf: '\uD835\uDD3C',
  2825. eopf: '\uD835\uDD56',
  2826. epar: '\u22D5',
  2827. eparsl: '\u29E3',
  2828. eplus: '\u2A71',
  2829. epsi: '\u03B5',
  2830. Epsilon: '\u0395',
  2831. epsilon: '\u03B5',
  2832. epsiv: '\u03F5',
  2833. eqcirc: '\u2256',
  2834. eqcolon: '\u2255',
  2835. eqsim: '\u2242',
  2836. eqslantgtr: '\u2A96',
  2837. eqslantless: '\u2A95',
  2838. Equal: '\u2A75',
  2839. equals: '\u003D',
  2840. EqualTilde: '\u2242',
  2841. equest: '\u225F',
  2842. Equilibrium: '\u21CC',
  2843. equiv: '\u2261',
  2844. equivDD: '\u2A78',
  2845. eqvparsl: '\u29E5',
  2846. erarr: '\u2971',
  2847. erDot: '\u2253',
  2848. Escr: '\u2130',
  2849. escr: '\u212F',
  2850. esdot: '\u2250',
  2851. Esim: '\u2A73',
  2852. esim: '\u2242',
  2853. Eta: '\u0397',
  2854. eta: '\u03B7',
  2855. ETH: '\u00D0',
  2856. eth: '\u00F0',
  2857. Euml: '\u00CB',
  2858. euml: '\u00EB',
  2859. euro: '\u20AC',
  2860. excl: '\u0021',
  2861. exist: '\u2203',
  2862. Exists: '\u2203',
  2863. expectation: '\u2130',
  2864. ExponentialE: '\u2147',
  2865. exponentiale: '\u2147',
  2866. fallingdotseq: '\u2252',
  2867. Fcy: '\u0424',
  2868. fcy: '\u0444',
  2869. female: '\u2640',
  2870. ffilig: '\uFB03',
  2871. fflig: '\uFB00',
  2872. ffllig: '\uFB04',
  2873. Ffr: '\uD835\uDD09',
  2874. ffr: '\uD835\uDD23',
  2875. filig: '\uFB01',
  2876. FilledSmallSquare: '\u25FC',
  2877. FilledVerySmallSquare: '\u25AA',
  2878. fjlig: '\u0066\u006A',
  2879. flat: '\u266D',
  2880. fllig: '\uFB02',
  2881. fltns: '\u25B1',
  2882. fnof: '\u0192',
  2883. Fopf: '\uD835\uDD3D',
  2884. fopf: '\uD835\uDD57',
  2885. ForAll: '\u2200',
  2886. forall: '\u2200',
  2887. fork: '\u22D4',
  2888. forkv: '\u2AD9',
  2889. Fouriertrf: '\u2131',
  2890. fpartint: '\u2A0D',
  2891. frac12: '\u00BD',
  2892. frac13: '\u2153',
  2893. frac14: '\u00BC',
  2894. frac15: '\u2155',
  2895. frac16: '\u2159',
  2896. frac18: '\u215B',
  2897. frac23: '\u2154',
  2898. frac25: '\u2156',
  2899. frac34: '\u00BE',
  2900. frac35: '\u2157',
  2901. frac38: '\u215C',
  2902. frac45: '\u2158',
  2903. frac56: '\u215A',
  2904. frac58: '\u215D',
  2905. frac78: '\u215E',
  2906. frasl: '\u2044',
  2907. frown: '\u2322',
  2908. Fscr: '\u2131',
  2909. fscr: '\uD835\uDCBB',
  2910. gacute: '\u01F5',
  2911. Gamma: '\u0393',
  2912. gamma: '\u03B3',
  2913. Gammad: '\u03DC',
  2914. gammad: '\u03DD',
  2915. gap: '\u2A86',
  2916. Gbreve: '\u011E',
  2917. gbreve: '\u011F',
  2918. Gcedil: '\u0122',
  2919. Gcirc: '\u011C',
  2920. gcirc: '\u011D',
  2921. Gcy: '\u0413',
  2922. gcy: '\u0433',
  2923. Gdot: '\u0120',
  2924. gdot: '\u0121',
  2925. gE: '\u2267',
  2926. ge: '\u2265',
  2927. gEl: '\u2A8C',
  2928. gel: '\u22DB',
  2929. geq: '\u2265',
  2930. geqq: '\u2267',
  2931. geqslant: '\u2A7E',
  2932. ges: '\u2A7E',
  2933. gescc: '\u2AA9',
  2934. gesdot: '\u2A80',
  2935. gesdoto: '\u2A82',
  2936. gesdotol: '\u2A84',
  2937. gesl: '\u22DB\uFE00',
  2938. gesles: '\u2A94',
  2939. Gfr: '\uD835\uDD0A',
  2940. gfr: '\uD835\uDD24',
  2941. Gg: '\u22D9',
  2942. gg: '\u226B',
  2943. ggg: '\u22D9',
  2944. gimel: '\u2137',
  2945. GJcy: '\u0403',
  2946. gjcy: '\u0453',
  2947. gl: '\u2277',
  2948. gla: '\u2AA5',
  2949. glE: '\u2A92',
  2950. glj: '\u2AA4',
  2951. gnap: '\u2A8A',
  2952. gnapprox: '\u2A8A',
  2953. gnE: '\u2269',
  2954. gne: '\u2A88',
  2955. gneq: '\u2A88',
  2956. gneqq: '\u2269',
  2957. gnsim: '\u22E7',
  2958. Gopf: '\uD835\uDD3E',
  2959. gopf: '\uD835\uDD58',
  2960. grave: '\u0060',
  2961. GreaterEqual: '\u2265',
  2962. GreaterEqualLess: '\u22DB',
  2963. GreaterFullEqual: '\u2267',
  2964. GreaterGreater: '\u2AA2',
  2965. GreaterLess: '\u2277',
  2966. GreaterSlantEqual: '\u2A7E',
  2967. GreaterTilde: '\u2273',
  2968. Gscr: '\uD835\uDCA2',
  2969. gscr: '\u210A',
  2970. gsim: '\u2273',
  2971. gsime: '\u2A8E',
  2972. gsiml: '\u2A90',
  2973. Gt: '\u226B',
  2974. GT: '\u003E',
  2975. gt: '\u003E',
  2976. gtcc: '\u2AA7',
  2977. gtcir: '\u2A7A',
  2978. gtdot: '\u22D7',
  2979. gtlPar: '\u2995',
  2980. gtquest: '\u2A7C',
  2981. gtrapprox: '\u2A86',
  2982. gtrarr: '\u2978',
  2983. gtrdot: '\u22D7',
  2984. gtreqless: '\u22DB',
  2985. gtreqqless: '\u2A8C',
  2986. gtrless: '\u2277',
  2987. gtrsim: '\u2273',
  2988. gvertneqq: '\u2269\uFE00',
  2989. gvnE: '\u2269\uFE00',
  2990. Hacek: '\u02C7',
  2991. hairsp: '\u200A',
  2992. half: '\u00BD',
  2993. hamilt: '\u210B',
  2994. HARDcy: '\u042A',
  2995. hardcy: '\u044A',
  2996. hArr: '\u21D4',
  2997. harr: '\u2194',
  2998. harrcir: '\u2948',
  2999. harrw: '\u21AD',
  3000. Hat: '\u005E',
  3001. hbar: '\u210F',
  3002. Hcirc: '\u0124',
  3003. hcirc: '\u0125',
  3004. hearts: '\u2665',
  3005. heartsuit: '\u2665',
  3006. hellip: '\u2026',
  3007. hercon: '\u22B9',
  3008. Hfr: '\u210C',
  3009. hfr: '\uD835\uDD25',
  3010. HilbertSpace: '\u210B',
  3011. hksearow: '\u2925',
  3012. hkswarow: '\u2926',
  3013. hoarr: '\u21FF',
  3014. homtht: '\u223B',
  3015. hookleftarrow: '\u21A9',
  3016. hookrightarrow: '\u21AA',
  3017. Hopf: '\u210D',
  3018. hopf: '\uD835\uDD59',
  3019. horbar: '\u2015',
  3020. HorizontalLine: '\u2500',
  3021. Hscr: '\u210B',
  3022. hscr: '\uD835\uDCBD',
  3023. hslash: '\u210F',
  3024. Hstrok: '\u0126',
  3025. hstrok: '\u0127',
  3026. HumpDownHump: '\u224E',
  3027. HumpEqual: '\u224F',
  3028. hybull: '\u2043',
  3029. hyphen: '\u2010',
  3030. Iacute: '\u00CD',
  3031. iacute: '\u00ED',
  3032. ic: '\u2063',
  3033. Icirc: '\u00CE',
  3034. icirc: '\u00EE',
  3035. Icy: '\u0418',
  3036. icy: '\u0438',
  3037. Idot: '\u0130',
  3038. IEcy: '\u0415',
  3039. iecy: '\u0435',
  3040. iexcl: '\u00A1',
  3041. iff: '\u21D4',
  3042. Ifr: '\u2111',
  3043. ifr: '\uD835\uDD26',
  3044. Igrave: '\u00CC',
  3045. igrave: '\u00EC',
  3046. ii: '\u2148',
  3047. iiiint: '\u2A0C',
  3048. iiint: '\u222D',
  3049. iinfin: '\u29DC',
  3050. iiota: '\u2129',
  3051. IJlig: '\u0132',
  3052. ijlig: '\u0133',
  3053. Im: '\u2111',
  3054. Imacr: '\u012A',
  3055. imacr: '\u012B',
  3056. image: '\u2111',
  3057. ImaginaryI: '\u2148',
  3058. imagline: '\u2110',
  3059. imagpart: '\u2111',
  3060. imath: '\u0131',
  3061. imof: '\u22B7',
  3062. imped: '\u01B5',
  3063. Implies: '\u21D2',
  3064. in: '\u2208',
  3065. incare: '\u2105',
  3066. infin: '\u221E',
  3067. infintie: '\u29DD',
  3068. inodot: '\u0131',
  3069. Int: '\u222C',
  3070. int: '\u222B',
  3071. intcal: '\u22BA',
  3072. integers: '\u2124',
  3073. Integral: '\u222B',
  3074. intercal: '\u22BA',
  3075. Intersection: '\u22C2',
  3076. intlarhk: '\u2A17',
  3077. intprod: '\u2A3C',
  3078. InvisibleComma: '\u2063',
  3079. InvisibleTimes: '\u2062',
  3080. IOcy: '\u0401',
  3081. iocy: '\u0451',
  3082. Iogon: '\u012E',
  3083. iogon: '\u012F',
  3084. Iopf: '\uD835\uDD40',
  3085. iopf: '\uD835\uDD5A',
  3086. Iota: '\u0399',
  3087. iota: '\u03B9',
  3088. iprod: '\u2A3C',
  3089. iquest: '\u00BF',
  3090. Iscr: '\u2110',
  3091. iscr: '\uD835\uDCBE',
  3092. isin: '\u2208',
  3093. isindot: '\u22F5',
  3094. isinE: '\u22F9',
  3095. isins: '\u22F4',
  3096. isinsv: '\u22F3',
  3097. isinv: '\u2208',
  3098. it: '\u2062',
  3099. Itilde: '\u0128',
  3100. itilde: '\u0129',
  3101. Iukcy: '\u0406',
  3102. iukcy: '\u0456',
  3103. Iuml: '\u00CF',
  3104. iuml: '\u00EF',
  3105. Jcirc: '\u0134',
  3106. jcirc: '\u0135',
  3107. Jcy: '\u0419',
  3108. jcy: '\u0439',
  3109. Jfr: '\uD835\uDD0D',
  3110. jfr: '\uD835\uDD27',
  3111. jmath: '\u0237',
  3112. Jopf: '\uD835\uDD41',
  3113. jopf: '\uD835\uDD5B',
  3114. Jscr: '\uD835\uDCA5',
  3115. jscr: '\uD835\uDCBF',
  3116. Jsercy: '\u0408',
  3117. jsercy: '\u0458',
  3118. Jukcy: '\u0404',
  3119. jukcy: '\u0454',
  3120. Kappa: '\u039A',
  3121. kappa: '\u03BA',
  3122. kappav: '\u03F0',
  3123. Kcedil: '\u0136',
  3124. kcedil: '\u0137',
  3125. Kcy: '\u041A',
  3126. kcy: '\u043A',
  3127. Kfr: '\uD835\uDD0E',
  3128. kfr: '\uD835\uDD28',
  3129. kgreen: '\u0138',
  3130. KHcy: '\u0425',
  3131. khcy: '\u0445',
  3132. KJcy: '\u040C',
  3133. kjcy: '\u045C',
  3134. Kopf: '\uD835\uDD42',
  3135. kopf: '\uD835\uDD5C',
  3136. Kscr: '\uD835\uDCA6',
  3137. kscr: '\uD835\uDCC0',
  3138. lAarr: '\u21DA',
  3139. Lacute: '\u0139',
  3140. lacute: '\u013A',
  3141. laemptyv: '\u29B4',
  3142. lagran: '\u2112',
  3143. Lambda: '\u039B',
  3144. lambda: '\u03BB',
  3145. Lang: '\u27EA',
  3146. lang: '\u27E8',
  3147. langd: '\u2991',
  3148. langle: '\u27E8',
  3149. lap: '\u2A85',
  3150. Laplacetrf: '\u2112',
  3151. laquo: '\u00AB',
  3152. Larr: '\u219E',
  3153. lArr: '\u21D0',
  3154. larr: '\u2190',
  3155. larrb: '\u21E4',
  3156. larrbfs: '\u291F',
  3157. larrfs: '\u291D',
  3158. larrhk: '\u21A9',
  3159. larrlp: '\u21AB',
  3160. larrpl: '\u2939',
  3161. larrsim: '\u2973',
  3162. larrtl: '\u21A2',
  3163. lat: '\u2AAB',
  3164. lAtail: '\u291B',
  3165. latail: '\u2919',
  3166. late: '\u2AAD',
  3167. lates: '\u2AAD\uFE00',
  3168. lBarr: '\u290E',
  3169. lbarr: '\u290C',
  3170. lbbrk: '\u2772',
  3171. lbrace: '\u007B',
  3172. lbrack: '\u005B',
  3173. lbrke: '\u298B',
  3174. lbrksld: '\u298F',
  3175. lbrkslu: '\u298D',
  3176. Lcaron: '\u013D',
  3177. lcaron: '\u013E',
  3178. Lcedil: '\u013B',
  3179. lcedil: '\u013C',
  3180. lceil: '\u2308',
  3181. lcub: '\u007B',
  3182. Lcy: '\u041B',
  3183. lcy: '\u043B',
  3184. ldca: '\u2936',
  3185. ldquo: '\u201C',
  3186. ldquor: '\u201E',
  3187. ldrdhar: '\u2967',
  3188. ldrushar: '\u294B',
  3189. ldsh: '\u21B2',
  3190. lE: '\u2266',
  3191. le: '\u2264',
  3192. LeftAngleBracket: '\u27E8',
  3193. LeftArrow: '\u2190',
  3194. Leftarrow: '\u21D0',
  3195. leftarrow: '\u2190',
  3196. LeftArrowBar: '\u21E4',
  3197. LeftArrowRightArrow: '\u21C6',
  3198. leftarrowtail: '\u21A2',
  3199. LeftCeiling: '\u2308',
  3200. LeftDoubleBracket: '\u27E6',
  3201. LeftDownTeeVector: '\u2961',
  3202. LeftDownVector: '\u21C3',
  3203. LeftDownVectorBar: '\u2959',
  3204. LeftFloor: '\u230A',
  3205. leftharpoondown: '\u21BD',
  3206. leftharpoonup: '\u21BC',
  3207. leftleftarrows: '\u21C7',
  3208. LeftRightArrow: '\u2194',
  3209. Leftrightarrow: '\u21D4',
  3210. leftrightarrow: '\u2194',
  3211. leftrightarrows: '\u21C6',
  3212. leftrightharpoons: '\u21CB',
  3213. leftrightsquigarrow: '\u21AD',
  3214. LeftRightVector: '\u294E',
  3215. LeftTee: '\u22A3',
  3216. LeftTeeArrow: '\u21A4',
  3217. LeftTeeVector: '\u295A',
  3218. leftthreetimes: '\u22CB',
  3219. LeftTriangle: '\u22B2',
  3220. LeftTriangleBar: '\u29CF',
  3221. LeftTriangleEqual: '\u22B4',
  3222. LeftUpDownVector: '\u2951',
  3223. LeftUpTeeVector: '\u2960',
  3224. LeftUpVector: '\u21BF',
  3225. LeftUpVectorBar: '\u2958',
  3226. LeftVector: '\u21BC',
  3227. LeftVectorBar: '\u2952',
  3228. lEg: '\u2A8B',
  3229. leg: '\u22DA',
  3230. leq: '\u2264',
  3231. leqq: '\u2266',
  3232. leqslant: '\u2A7D',
  3233. les: '\u2A7D',
  3234. lescc: '\u2AA8',
  3235. lesdot: '\u2A7F',
  3236. lesdoto: '\u2A81',
  3237. lesdotor: '\u2A83',
  3238. lesg: '\u22DA\uFE00',
  3239. lesges: '\u2A93',
  3240. lessapprox: '\u2A85',
  3241. lessdot: '\u22D6',
  3242. lesseqgtr: '\u22DA',
  3243. lesseqqgtr: '\u2A8B',
  3244. LessEqualGreater: '\u22DA',
  3245. LessFullEqual: '\u2266',
  3246. LessGreater: '\u2276',
  3247. lessgtr: '\u2276',
  3248. LessLess: '\u2AA1',
  3249. lesssim: '\u2272',
  3250. LessSlantEqual: '\u2A7D',
  3251. LessTilde: '\u2272',
  3252. lfisht: '\u297C',
  3253. lfloor: '\u230A',
  3254. Lfr: '\uD835\uDD0F',
  3255. lfr: '\uD835\uDD29',
  3256. lg: '\u2276',
  3257. lgE: '\u2A91',
  3258. lHar: '\u2962',
  3259. lhard: '\u21BD',
  3260. lharu: '\u21BC',
  3261. lharul: '\u296A',
  3262. lhblk: '\u2584',
  3263. LJcy: '\u0409',
  3264. ljcy: '\u0459',
  3265. Ll: '\u22D8',
  3266. ll: '\u226A',
  3267. llarr: '\u21C7',
  3268. llcorner: '\u231E',
  3269. Lleftarrow: '\u21DA',
  3270. llhard: '\u296B',
  3271. lltri: '\u25FA',
  3272. Lmidot: '\u013F',
  3273. lmidot: '\u0140',
  3274. lmoust: '\u23B0',
  3275. lmoustache: '\u23B0',
  3276. lnap: '\u2A89',
  3277. lnapprox: '\u2A89',
  3278. lnE: '\u2268',
  3279. lne: '\u2A87',
  3280. lneq: '\u2A87',
  3281. lneqq: '\u2268',
  3282. lnsim: '\u22E6',
  3283. loang: '\u27EC',
  3284. loarr: '\u21FD',
  3285. lobrk: '\u27E6',
  3286. LongLeftArrow: '\u27F5',
  3287. Longleftarrow: '\u27F8',
  3288. longleftarrow: '\u27F5',
  3289. LongLeftRightArrow: '\u27F7',
  3290. Longleftrightarrow: '\u27FA',
  3291. longleftrightarrow: '\u27F7',
  3292. longmapsto: '\u27FC',
  3293. LongRightArrow: '\u27F6',
  3294. Longrightarrow: '\u27F9',
  3295. longrightarrow: '\u27F6',
  3296. looparrowleft: '\u21AB',
  3297. looparrowright: '\u21AC',
  3298. lopar: '\u2985',
  3299. Lopf: '\uD835\uDD43',
  3300. lopf: '\uD835\uDD5D',
  3301. loplus: '\u2A2D',
  3302. lotimes: '\u2A34',
  3303. lowast: '\u2217',
  3304. lowbar: '\u005F',
  3305. LowerLeftArrow: '\u2199',
  3306. LowerRightArrow: '\u2198',
  3307. loz: '\u25CA',
  3308. lozenge: '\u25CA',
  3309. lozf: '\u29EB',
  3310. lpar: '\u0028',
  3311. lparlt: '\u2993',
  3312. lrarr: '\u21C6',
  3313. lrcorner: '\u231F',
  3314. lrhar: '\u21CB',
  3315. lrhard: '\u296D',
  3316. lrm: '\u200E',
  3317. lrtri: '\u22BF',
  3318. lsaquo: '\u2039',
  3319. Lscr: '\u2112',
  3320. lscr: '\uD835\uDCC1',
  3321. Lsh: '\u21B0',
  3322. lsh: '\u21B0',
  3323. lsim: '\u2272',
  3324. lsime: '\u2A8D',
  3325. lsimg: '\u2A8F',
  3326. lsqb: '\u005B',
  3327. lsquo: '\u2018',
  3328. lsquor: '\u201A',
  3329. Lstrok: '\u0141',
  3330. lstrok: '\u0142',
  3331. Lt: '\u226A',
  3332. LT: '\u003C',
  3333. lt: '\u003C',
  3334. ltcc: '\u2AA6',
  3335. ltcir: '\u2A79',
  3336. ltdot: '\u22D6',
  3337. lthree: '\u22CB',
  3338. ltimes: '\u22C9',
  3339. ltlarr: '\u2976',
  3340. ltquest: '\u2A7B',
  3341. ltri: '\u25C3',
  3342. ltrie: '\u22B4',
  3343. ltrif: '\u25C2',
  3344. ltrPar: '\u2996',
  3345. lurdshar: '\u294A',
  3346. luruhar: '\u2966',
  3347. lvertneqq: '\u2268\uFE00',
  3348. lvnE: '\u2268\uFE00',
  3349. macr: '\u00AF',
  3350. male: '\u2642',
  3351. malt: '\u2720',
  3352. maltese: '\u2720',
  3353. Map: '\u2905',
  3354. map: '\u21A6',
  3355. mapsto: '\u21A6',
  3356. mapstodown: '\u21A7',
  3357. mapstoleft: '\u21A4',
  3358. mapstoup: '\u21A5',
  3359. marker: '\u25AE',
  3360. mcomma: '\u2A29',
  3361. Mcy: '\u041C',
  3362. mcy: '\u043C',
  3363. mdash: '\u2014',
  3364. mDDot: '\u223A',
  3365. measuredangle: '\u2221',
  3366. MediumSpace: '\u205F',
  3367. Mellintrf: '\u2133',
  3368. Mfr: '\uD835\uDD10',
  3369. mfr: '\uD835\uDD2A',
  3370. mho: '\u2127',
  3371. micro: '\u00B5',
  3372. mid: '\u2223',
  3373. midast: '\u002A',
  3374. midcir: '\u2AF0',
  3375. middot: '\u00B7',
  3376. minus: '\u2212',
  3377. minusb: '\u229F',
  3378. minusd: '\u2238',
  3379. minusdu: '\u2A2A',
  3380. MinusPlus: '\u2213',
  3381. mlcp: '\u2ADB',
  3382. mldr: '\u2026',
  3383. mnplus: '\u2213',
  3384. models: '\u22A7',
  3385. Mopf: '\uD835\uDD44',
  3386. mopf: '\uD835\uDD5E',
  3387. mp: '\u2213',
  3388. Mscr: '\u2133',
  3389. mscr: '\uD835\uDCC2',
  3390. mstpos: '\u223E',
  3391. Mu: '\u039C',
  3392. mu: '\u03BC',
  3393. multimap: '\u22B8',
  3394. mumap: '\u22B8',
  3395. nabla: '\u2207',
  3396. Nacute: '\u0143',
  3397. nacute: '\u0144',
  3398. nang: '\u2220\u20D2',
  3399. nap: '\u2249',
  3400. napE: '\u2A70\u0338',
  3401. napid: '\u224B\u0338',
  3402. napos: '\u0149',
  3403. napprox: '\u2249',
  3404. natur: '\u266E',
  3405. natural: '\u266E',
  3406. naturals: '\u2115',
  3407. nbsp: '\u00A0',
  3408. nbump: '\u224E\u0338',
  3409. nbumpe: '\u224F\u0338',
  3410. ncap: '\u2A43',
  3411. Ncaron: '\u0147',
  3412. ncaron: '\u0148',
  3413. Ncedil: '\u0145',
  3414. ncedil: '\u0146',
  3415. ncong: '\u2247',
  3416. ncongdot: '\u2A6D\u0338',
  3417. ncup: '\u2A42',
  3418. Ncy: '\u041D',
  3419. ncy: '\u043D',
  3420. ndash: '\u2013',
  3421. ne: '\u2260',
  3422. nearhk: '\u2924',
  3423. neArr: '\u21D7',
  3424. nearr: '\u2197',
  3425. nearrow: '\u2197',
  3426. nedot: '\u2250\u0338',
  3427. NegativeMediumSpace: '\u200B',
  3428. NegativeThickSpace: '\u200B',
  3429. NegativeThinSpace: '\u200B',
  3430. NegativeVeryThinSpace: '\u200B',
  3431. nequiv: '\u2262',
  3432. nesear: '\u2928',
  3433. nesim: '\u2242\u0338',
  3434. NestedGreaterGreater: '\u226B',
  3435. NestedLessLess: '\u226A',
  3436. NewLine: '\u000A',
  3437. nexist: '\u2204',
  3438. nexists: '\u2204',
  3439. Nfr: '\uD835\uDD11',
  3440. nfr: '\uD835\uDD2B',
  3441. ngE: '\u2267\u0338',
  3442. nge: '\u2271',
  3443. ngeq: '\u2271',
  3444. ngeqq: '\u2267\u0338',
  3445. ngeqslant: '\u2A7E\u0338',
  3446. nges: '\u2A7E\u0338',
  3447. nGg: '\u22D9\u0338',
  3448. ngsim: '\u2275',
  3449. nGt: '\u226B\u20D2',
  3450. ngt: '\u226F',
  3451. ngtr: '\u226F',
  3452. nGtv: '\u226B\u0338',
  3453. nhArr: '\u21CE',
  3454. nharr: '\u21AE',
  3455. nhpar: '\u2AF2',
  3456. ni: '\u220B',
  3457. nis: '\u22FC',
  3458. nisd: '\u22FA',
  3459. niv: '\u220B',
  3460. NJcy: '\u040A',
  3461. njcy: '\u045A',
  3462. nlArr: '\u21CD',
  3463. nlarr: '\u219A',
  3464. nldr: '\u2025',
  3465. nlE: '\u2266\u0338',
  3466. nle: '\u2270',
  3467. nLeftarrow: '\u21CD',
  3468. nleftarrow: '\u219A',
  3469. nLeftrightarrow: '\u21CE',
  3470. nleftrightarrow: '\u21AE',
  3471. nleq: '\u2270',
  3472. nleqq: '\u2266\u0338',
  3473. nleqslant: '\u2A7D\u0338',
  3474. nles: '\u2A7D\u0338',
  3475. nless: '\u226E',
  3476. nLl: '\u22D8\u0338',
  3477. nlsim: '\u2274',
  3478. nLt: '\u226A\u20D2',
  3479. nlt: '\u226E',
  3480. nltri: '\u22EA',
  3481. nltrie: '\u22EC',
  3482. nLtv: '\u226A\u0338',
  3483. nmid: '\u2224',
  3484. NoBreak: '\u2060',
  3485. NonBreakingSpace: '\u00A0',
  3486. Nopf: '\u2115',
  3487. nopf: '\uD835\uDD5F',
  3488. Not: '\u2AEC',
  3489. not: '\u00AC',
  3490. NotCongruent: '\u2262',
  3491. NotCupCap: '\u226D',
  3492. NotDoubleVerticalBar: '\u2226',
  3493. NotElement: '\u2209',
  3494. NotEqual: '\u2260',
  3495. NotEqualTilde: '\u2242\u0338',
  3496. NotExists: '\u2204',
  3497. NotGreater: '\u226F',
  3498. NotGreaterEqual: '\u2271',
  3499. NotGreaterFullEqual: '\u2267\u0338',
  3500. NotGreaterGreater: '\u226B\u0338',
  3501. NotGreaterLess: '\u2279',
  3502. NotGreaterSlantEqual: '\u2A7E\u0338',
  3503. NotGreaterTilde: '\u2275',
  3504. NotHumpDownHump: '\u224E\u0338',
  3505. NotHumpEqual: '\u224F\u0338',
  3506. notin: '\u2209',
  3507. notindot: '\u22F5\u0338',
  3508. notinE: '\u22F9\u0338',
  3509. notinva: '\u2209',
  3510. notinvb: '\u22F7',
  3511. notinvc: '\u22F6',
  3512. NotLeftTriangle: '\u22EA',
  3513. NotLeftTriangleBar: '\u29CF\u0338',
  3514. NotLeftTriangleEqual: '\u22EC',
  3515. NotLess: '\u226E',
  3516. NotLessEqual: '\u2270',
  3517. NotLessGreater: '\u2278',
  3518. NotLessLess: '\u226A\u0338',
  3519. NotLessSlantEqual: '\u2A7D\u0338',
  3520. NotLessTilde: '\u2274',
  3521. NotNestedGreaterGreater: '\u2AA2\u0338',
  3522. NotNestedLessLess: '\u2AA1\u0338',
  3523. notni: '\u220C',
  3524. notniva: '\u220C',
  3525. notnivb: '\u22FE',
  3526. notnivc: '\u22FD',
  3527. NotPrecedes: '\u2280',
  3528. NotPrecedesEqual: '\u2AAF\u0338',
  3529. NotPrecedesSlantEqual: '\u22E0',
  3530. NotReverseElement: '\u220C',
  3531. NotRightTriangle: '\u22EB',
  3532. NotRightTriangleBar: '\u29D0\u0338',
  3533. NotRightTriangleEqual: '\u22ED',
  3534. NotSquareSubset: '\u228F\u0338',
  3535. NotSquareSubsetEqual: '\u22E2',
  3536. NotSquareSuperset: '\u2290\u0338',
  3537. NotSquareSupersetEqual: '\u22E3',
  3538. NotSubset: '\u2282\u20D2',
  3539. NotSubsetEqual: '\u2288',
  3540. NotSucceeds: '\u2281',
  3541. NotSucceedsEqual: '\u2AB0\u0338',
  3542. NotSucceedsSlantEqual: '\u22E1',
  3543. NotSucceedsTilde: '\u227F\u0338',
  3544. NotSuperset: '\u2283\u20D2',
  3545. NotSupersetEqual: '\u2289',
  3546. NotTilde: '\u2241',
  3547. NotTildeEqual: '\u2244',
  3548. NotTildeFullEqual: '\u2247',
  3549. NotTildeTilde: '\u2249',
  3550. NotVerticalBar: '\u2224',
  3551. npar: '\u2226',
  3552. nparallel: '\u2226',
  3553. nparsl: '\u2AFD\u20E5',
  3554. npart: '\u2202\u0338',
  3555. npolint: '\u2A14',
  3556. npr: '\u2280',
  3557. nprcue: '\u22E0',
  3558. npre: '\u2AAF\u0338',
  3559. nprec: '\u2280',
  3560. npreceq: '\u2AAF\u0338',
  3561. nrArr: '\u21CF',
  3562. nrarr: '\u219B',
  3563. nrarrc: '\u2933\u0338',
  3564. nrarrw: '\u219D\u0338',
  3565. nRightarrow: '\u21CF',
  3566. nrightarrow: '\u219B',
  3567. nrtri: '\u22EB',
  3568. nrtrie: '\u22ED',
  3569. nsc: '\u2281',
  3570. nsccue: '\u22E1',
  3571. nsce: '\u2AB0\u0338',
  3572. Nscr: '\uD835\uDCA9',
  3573. nscr: '\uD835\uDCC3',
  3574. nshortmid: '\u2224',
  3575. nshortparallel: '\u2226',
  3576. nsim: '\u2241',
  3577. nsime: '\u2244',
  3578. nsimeq: '\u2244',
  3579. nsmid: '\u2224',
  3580. nspar: '\u2226',
  3581. nsqsube: '\u22E2',
  3582. nsqsupe: '\u22E3',
  3583. nsub: '\u2284',
  3584. nsubE: '\u2AC5\u0338',
  3585. nsube: '\u2288',
  3586. nsubset: '\u2282\u20D2',
  3587. nsubseteq: '\u2288',
  3588. nsubseteqq: '\u2AC5\u0338',
  3589. nsucc: '\u2281',
  3590. nsucceq: '\u2AB0\u0338',
  3591. nsup: '\u2285',
  3592. nsupE: '\u2AC6\u0338',
  3593. nsupe: '\u2289',
  3594. nsupset: '\u2283\u20D2',
  3595. nsupseteq: '\u2289',
  3596. nsupseteqq: '\u2AC6\u0338',
  3597. ntgl: '\u2279',
  3598. Ntilde: '\u00D1',
  3599. ntilde: '\u00F1',
  3600. ntlg: '\u2278',
  3601. ntriangleleft: '\u22EA',
  3602. ntrianglelefteq: '\u22EC',
  3603. ntriangleright: '\u22EB',
  3604. ntrianglerighteq: '\u22ED',
  3605. Nu: '\u039D',
  3606. nu: '\u03BD',
  3607. num: '\u0023',
  3608. numero: '\u2116',
  3609. numsp: '\u2007',
  3610. nvap: '\u224D\u20D2',
  3611. nVDash: '\u22AF',
  3612. nVdash: '\u22AE',
  3613. nvDash: '\u22AD',
  3614. nvdash: '\u22AC',
  3615. nvge: '\u2265\u20D2',
  3616. nvgt: '\u003E\u20D2',
  3617. nvHarr: '\u2904',
  3618. nvinfin: '\u29DE',
  3619. nvlArr: '\u2902',
  3620. nvle: '\u2264\u20D2',
  3621. nvlt: '\u003C\u20D2',
  3622. nvltrie: '\u22B4\u20D2',
  3623. nvrArr: '\u2903',
  3624. nvrtrie: '\u22B5\u20D2',
  3625. nvsim: '\u223C\u20D2',
  3626. nwarhk: '\u2923',
  3627. nwArr: '\u21D6',
  3628. nwarr: '\u2196',
  3629. nwarrow: '\u2196',
  3630. nwnear: '\u2927',
  3631. Oacute: '\u00D3',
  3632. oacute: '\u00F3',
  3633. oast: '\u229B',
  3634. ocir: '\u229A',
  3635. Ocirc: '\u00D4',
  3636. ocirc: '\u00F4',
  3637. Ocy: '\u041E',
  3638. ocy: '\u043E',
  3639. odash: '\u229D',
  3640. Odblac: '\u0150',
  3641. odblac: '\u0151',
  3642. odiv: '\u2A38',
  3643. odot: '\u2299',
  3644. odsold: '\u29BC',
  3645. OElig: '\u0152',
  3646. oelig: '\u0153',
  3647. ofcir: '\u29BF',
  3648. Ofr: '\uD835\uDD12',
  3649. ofr: '\uD835\uDD2C',
  3650. ogon: '\u02DB',
  3651. Ograve: '\u00D2',
  3652. ograve: '\u00F2',
  3653. ogt: '\u29C1',
  3654. ohbar: '\u29B5',
  3655. ohm: '\u03A9',
  3656. oint: '\u222E',
  3657. olarr: '\u21BA',
  3658. olcir: '\u29BE',
  3659. olcross: '\u29BB',
  3660. oline: '\u203E',
  3661. olt: '\u29C0',
  3662. Omacr: '\u014C',
  3663. omacr: '\u014D',
  3664. Omega: '\u03A9',
  3665. omega: '\u03C9',
  3666. Omicron: '\u039F',
  3667. omicron: '\u03BF',
  3668. omid: '\u29B6',
  3669. ominus: '\u2296',
  3670. Oopf: '\uD835\uDD46',
  3671. oopf: '\uD835\uDD60',
  3672. opar: '\u29B7',
  3673. OpenCurlyDoubleQuote: '\u201C',
  3674. OpenCurlyQuote: '\u2018',
  3675. operp: '\u29B9',
  3676. oplus: '\u2295',
  3677. Or: '\u2A54',
  3678. or: '\u2228',
  3679. orarr: '\u21BB',
  3680. ord: '\u2A5D',
  3681. order: '\u2134',
  3682. orderof: '\u2134',
  3683. ordf: '\u00AA',
  3684. ordm: '\u00BA',
  3685. origof: '\u22B6',
  3686. oror: '\u2A56',
  3687. orslope: '\u2A57',
  3688. orv: '\u2A5B',
  3689. oS: '\u24C8',
  3690. Oscr: '\uD835\uDCAA',
  3691. oscr: '\u2134',
  3692. Oslash: '\u00D8',
  3693. oslash: '\u00F8',
  3694. osol: '\u2298',
  3695. Otilde: '\u00D5',
  3696. otilde: '\u00F5',
  3697. Otimes: '\u2A37',
  3698. otimes: '\u2297',
  3699. otimesas: '\u2A36',
  3700. Ouml: '\u00D6',
  3701. ouml: '\u00F6',
  3702. ovbar: '\u233D',
  3703. OverBar: '\u203E',
  3704. OverBrace: '\u23DE',
  3705. OverBracket: '\u23B4',
  3706. OverParenthesis: '\u23DC',
  3707. par: '\u2225',
  3708. para: '\u00B6',
  3709. parallel: '\u2225',
  3710. parsim: '\u2AF3',
  3711. parsl: '\u2AFD',
  3712. part: '\u2202',
  3713. PartialD: '\u2202',
  3714. Pcy: '\u041F',
  3715. pcy: '\u043F',
  3716. percnt: '\u0025',
  3717. period: '\u002E',
  3718. permil: '\u2030',
  3719. perp: '\u22A5',
  3720. pertenk: '\u2031',
  3721. Pfr: '\uD835\uDD13',
  3722. pfr: '\uD835\uDD2D',
  3723. Phi: '\u03A6',
  3724. phi: '\u03C6',
  3725. phiv: '\u03D5',
  3726. phmmat: '\u2133',
  3727. phone: '\u260E',
  3728. Pi: '\u03A0',
  3729. pi: '\u03C0',
  3730. pitchfork: '\u22D4',
  3731. piv: '\u03D6',
  3732. planck: '\u210F',
  3733. planckh: '\u210E',
  3734. plankv: '\u210F',
  3735. plus: '\u002B',
  3736. plusacir: '\u2A23',
  3737. plusb: '\u229E',
  3738. pluscir: '\u2A22',
  3739. plusdo: '\u2214',
  3740. plusdu: '\u2A25',
  3741. pluse: '\u2A72',
  3742. PlusMinus: '\u00B1',
  3743. plusmn: '\u00B1',
  3744. plussim: '\u2A26',
  3745. plustwo: '\u2A27',
  3746. pm: '\u00B1',
  3747. Poincareplane: '\u210C',
  3748. pointint: '\u2A15',
  3749. Popf: '\u2119',
  3750. popf: '\uD835\uDD61',
  3751. pound: '\u00A3',
  3752. Pr: '\u2ABB',
  3753. pr: '\u227A',
  3754. prap: '\u2AB7',
  3755. prcue: '\u227C',
  3756. prE: '\u2AB3',
  3757. pre: '\u2AAF',
  3758. prec: '\u227A',
  3759. precapprox: '\u2AB7',
  3760. preccurlyeq: '\u227C',
  3761. Precedes: '\u227A',
  3762. PrecedesEqual: '\u2AAF',
  3763. PrecedesSlantEqual: '\u227C',
  3764. PrecedesTilde: '\u227E',
  3765. preceq: '\u2AAF',
  3766. precnapprox: '\u2AB9',
  3767. precneqq: '\u2AB5',
  3768. precnsim: '\u22E8',
  3769. precsim: '\u227E',
  3770. Prime: '\u2033',
  3771. prime: '\u2032',
  3772. primes: '\u2119',
  3773. prnap: '\u2AB9',
  3774. prnE: '\u2AB5',
  3775. prnsim: '\u22E8',
  3776. prod: '\u220F',
  3777. Product: '\u220F',
  3778. profalar: '\u232E',
  3779. profline: '\u2312',
  3780. profsurf: '\u2313',
  3781. prop: '\u221D',
  3782. Proportion: '\u2237',
  3783. Proportional: '\u221D',
  3784. propto: '\u221D',
  3785. prsim: '\u227E',
  3786. prurel: '\u22B0',
  3787. Pscr: '\uD835\uDCAB',
  3788. pscr: '\uD835\uDCC5',
  3789. Psi: '\u03A8',
  3790. psi: '\u03C8',
  3791. puncsp: '\u2008',
  3792. Qfr: '\uD835\uDD14',
  3793. qfr: '\uD835\uDD2E',
  3794. qint: '\u2A0C',
  3795. Qopf: '\u211A',
  3796. qopf: '\uD835\uDD62',
  3797. qprime: '\u2057',
  3798. Qscr: '\uD835\uDCAC',
  3799. qscr: '\uD835\uDCC6',
  3800. quaternions: '\u210D',
  3801. quatint: '\u2A16',
  3802. quest: '\u003F',
  3803. questeq: '\u225F',
  3804. QUOT: '\u0022',
  3805. quot: '\u0022',
  3806. rAarr: '\u21DB',
  3807. race: '\u223D\u0331',
  3808. Racute: '\u0154',
  3809. racute: '\u0155',
  3810. radic: '\u221A',
  3811. raemptyv: '\u29B3',
  3812. Rang: '\u27EB',
  3813. rang: '\u27E9',
  3814. rangd: '\u2992',
  3815. range: '\u29A5',
  3816. rangle: '\u27E9',
  3817. raquo: '\u00BB',
  3818. Rarr: '\u21A0',
  3819. rArr: '\u21D2',
  3820. rarr: '\u2192',
  3821. rarrap: '\u2975',
  3822. rarrb: '\u21E5',
  3823. rarrbfs: '\u2920',
  3824. rarrc: '\u2933',
  3825. rarrfs: '\u291E',
  3826. rarrhk: '\u21AA',
  3827. rarrlp: '\u21AC',
  3828. rarrpl: '\u2945',
  3829. rarrsim: '\u2974',
  3830. Rarrtl: '\u2916',
  3831. rarrtl: '\u21A3',
  3832. rarrw: '\u219D',
  3833. rAtail: '\u291C',
  3834. ratail: '\u291A',
  3835. ratio: '\u2236',
  3836. rationals: '\u211A',
  3837. RBarr: '\u2910',
  3838. rBarr: '\u290F',
  3839. rbarr: '\u290D',
  3840. rbbrk: '\u2773',
  3841. rbrace: '\u007D',
  3842. rbrack: '\u005D',
  3843. rbrke: '\u298C',
  3844. rbrksld: '\u298E',
  3845. rbrkslu: '\u2990',
  3846. Rcaron: '\u0158',
  3847. rcaron: '\u0159',
  3848. Rcedil: '\u0156',
  3849. rcedil: '\u0157',
  3850. rceil: '\u2309',
  3851. rcub: '\u007D',
  3852. Rcy: '\u0420',
  3853. rcy: '\u0440',
  3854. rdca: '\u2937',
  3855. rdldhar: '\u2969',
  3856. rdquo: '\u201D',
  3857. rdquor: '\u201D',
  3858. rdsh: '\u21B3',
  3859. Re: '\u211C',
  3860. real: '\u211C',
  3861. realine: '\u211B',
  3862. realpart: '\u211C',
  3863. reals: '\u211D',
  3864. rect: '\u25AD',
  3865. REG: '\u00AE',
  3866. reg: '\u00AE',
  3867. ReverseElement: '\u220B',
  3868. ReverseEquilibrium: '\u21CB',
  3869. ReverseUpEquilibrium: '\u296F',
  3870. rfisht: '\u297D',
  3871. rfloor: '\u230B',
  3872. Rfr: '\u211C',
  3873. rfr: '\uD835\uDD2F',
  3874. rHar: '\u2964',
  3875. rhard: '\u21C1',
  3876. rharu: '\u21C0',
  3877. rharul: '\u296C',
  3878. Rho: '\u03A1',
  3879. rho: '\u03C1',
  3880. rhov: '\u03F1',
  3881. RightAngleBracket: '\u27E9',
  3882. RightArrow: '\u2192',
  3883. Rightarrow: '\u21D2',
  3884. rightarrow: '\u2192',
  3885. RightArrowBar: '\u21E5',
  3886. RightArrowLeftArrow: '\u21C4',
  3887. rightarrowtail: '\u21A3',
  3888. RightCeiling: '\u2309',
  3889. RightDoubleBracket: '\u27E7',
  3890. RightDownTeeVector: '\u295D',
  3891. RightDownVector: '\u21C2',
  3892. RightDownVectorBar: '\u2955',
  3893. RightFloor: '\u230B',
  3894. rightharpoondown: '\u21C1',
  3895. rightharpoonup: '\u21C0',
  3896. rightleftarrows: '\u21C4',
  3897. rightleftharpoons: '\u21CC',
  3898. rightrightarrows: '\u21C9',
  3899. rightsquigarrow: '\u219D',
  3900. RightTee: '\u22A2',
  3901. RightTeeArrow: '\u21A6',
  3902. RightTeeVector: '\u295B',
  3903. rightthreetimes: '\u22CC',
  3904. RightTriangle: '\u22B3',
  3905. RightTriangleBar: '\u29D0',
  3906. RightTriangleEqual: '\u22B5',
  3907. RightUpDownVector: '\u294F',
  3908. RightUpTeeVector: '\u295C',
  3909. RightUpVector: '\u21BE',
  3910. RightUpVectorBar: '\u2954',
  3911. RightVector: '\u21C0',
  3912. RightVectorBar: '\u2953',
  3913. ring: '\u02DA',
  3914. risingdotseq: '\u2253',
  3915. rlarr: '\u21C4',
  3916. rlhar: '\u21CC',
  3917. rlm: '\u200F',
  3918. rmoust: '\u23B1',
  3919. rmoustache: '\u23B1',
  3920. rnmid: '\u2AEE',
  3921. roang: '\u27ED',
  3922. roarr: '\u21FE',
  3923. robrk: '\u27E7',
  3924. ropar: '\u2986',
  3925. Ropf: '\u211D',
  3926. ropf: '\uD835\uDD63',
  3927. roplus: '\u2A2E',
  3928. rotimes: '\u2A35',
  3929. RoundImplies: '\u2970',
  3930. rpar: '\u0029',
  3931. rpargt: '\u2994',
  3932. rppolint: '\u2A12',
  3933. rrarr: '\u21C9',
  3934. Rrightarrow: '\u21DB',
  3935. rsaquo: '\u203A',
  3936. Rscr: '\u211B',
  3937. rscr: '\uD835\uDCC7',
  3938. Rsh: '\u21B1',
  3939. rsh: '\u21B1',
  3940. rsqb: '\u005D',
  3941. rsquo: '\u2019',
  3942. rsquor: '\u2019',
  3943. rthree: '\u22CC',
  3944. rtimes: '\u22CA',
  3945. rtri: '\u25B9',
  3946. rtrie: '\u22B5',
  3947. rtrif: '\u25B8',
  3948. rtriltri: '\u29CE',
  3949. RuleDelayed: '\u29F4',
  3950. ruluhar: '\u2968',
  3951. rx: '\u211E',
  3952. Sacute: '\u015A',
  3953. sacute: '\u015B',
  3954. sbquo: '\u201A',
  3955. Sc: '\u2ABC',
  3956. sc: '\u227B',
  3957. scap: '\u2AB8',
  3958. Scaron: '\u0160',
  3959. scaron: '\u0161',
  3960. sccue: '\u227D',
  3961. scE: '\u2AB4',
  3962. sce: '\u2AB0',
  3963. Scedil: '\u015E',
  3964. scedil: '\u015F',
  3965. Scirc: '\u015C',
  3966. scirc: '\u015D',
  3967. scnap: '\u2ABA',
  3968. scnE: '\u2AB6',
  3969. scnsim: '\u22E9',
  3970. scpolint: '\u2A13',
  3971. scsim: '\u227F',
  3972. Scy: '\u0421',
  3973. scy: '\u0441',
  3974. sdot: '\u22C5',
  3975. sdotb: '\u22A1',
  3976. sdote: '\u2A66',
  3977. searhk: '\u2925',
  3978. seArr: '\u21D8',
  3979. searr: '\u2198',
  3980. searrow: '\u2198',
  3981. sect: '\u00A7',
  3982. semi: '\u003B',
  3983. seswar: '\u2929',
  3984. setminus: '\u2216',
  3985. setmn: '\u2216',
  3986. sext: '\u2736',
  3987. Sfr: '\uD835\uDD16',
  3988. sfr: '\uD835\uDD30',
  3989. sfrown: '\u2322',
  3990. sharp: '\u266F',
  3991. SHCHcy: '\u0429',
  3992. shchcy: '\u0449',
  3993. SHcy: '\u0428',
  3994. shcy: '\u0448',
  3995. ShortDownArrow: '\u2193',
  3996. ShortLeftArrow: '\u2190',
  3997. shortmid: '\u2223',
  3998. shortparallel: '\u2225',
  3999. ShortRightArrow: '\u2192',
  4000. ShortUpArrow: '\u2191',
  4001. shy: '\u00AD',
  4002. Sigma: '\u03A3',
  4003. sigma: '\u03C3',
  4004. sigmaf: '\u03C2',
  4005. sigmav: '\u03C2',
  4006. sim: '\u223C',
  4007. simdot: '\u2A6A',
  4008. sime: '\u2243',
  4009. simeq: '\u2243',
  4010. simg: '\u2A9E',
  4011. simgE: '\u2AA0',
  4012. siml: '\u2A9D',
  4013. simlE: '\u2A9F',
  4014. simne: '\u2246',
  4015. simplus: '\u2A24',
  4016. simrarr: '\u2972',
  4017. slarr: '\u2190',
  4018. SmallCircle: '\u2218',
  4019. smallsetminus: '\u2216',
  4020. smashp: '\u2A33',
  4021. smeparsl: '\u29E4',
  4022. smid: '\u2223',
  4023. smile: '\u2323',
  4024. smt: '\u2AAA',
  4025. smte: '\u2AAC',
  4026. smtes: '\u2AAC\uFE00',
  4027. SOFTcy: '\u042C',
  4028. softcy: '\u044C',
  4029. sol: '\u002F',
  4030. solb: '\u29C4',
  4031. solbar: '\u233F',
  4032. Sopf: '\uD835\uDD4A',
  4033. sopf: '\uD835\uDD64',
  4034. spades: '\u2660',
  4035. spadesuit: '\u2660',
  4036. spar: '\u2225',
  4037. sqcap: '\u2293',
  4038. sqcaps: '\u2293\uFE00',
  4039. sqcup: '\u2294',
  4040. sqcups: '\u2294\uFE00',
  4041. Sqrt: '\u221A',
  4042. sqsub: '\u228F',
  4043. sqsube: '\u2291',
  4044. sqsubset: '\u228F',
  4045. sqsubseteq: '\u2291',
  4046. sqsup: '\u2290',
  4047. sqsupe: '\u2292',
  4048. sqsupset: '\u2290',
  4049. sqsupseteq: '\u2292',
  4050. squ: '\u25A1',
  4051. Square: '\u25A1',
  4052. square: '\u25A1',
  4053. SquareIntersection: '\u2293',
  4054. SquareSubset: '\u228F',
  4055. SquareSubsetEqual: '\u2291',
  4056. SquareSuperset: '\u2290',
  4057. SquareSupersetEqual: '\u2292',
  4058. SquareUnion: '\u2294',
  4059. squarf: '\u25AA',
  4060. squf: '\u25AA',
  4061. srarr: '\u2192',
  4062. Sscr: '\uD835\uDCAE',
  4063. sscr: '\uD835\uDCC8',
  4064. ssetmn: '\u2216',
  4065. ssmile: '\u2323',
  4066. sstarf: '\u22C6',
  4067. Star: '\u22C6',
  4068. star: '\u2606',
  4069. starf: '\u2605',
  4070. straightepsilon: '\u03F5',
  4071. straightphi: '\u03D5',
  4072. strns: '\u00AF',
  4073. Sub: '\u22D0',
  4074. sub: '\u2282',
  4075. subdot: '\u2ABD',
  4076. subE: '\u2AC5',
  4077. sube: '\u2286',
  4078. subedot: '\u2AC3',
  4079. submult: '\u2AC1',
  4080. subnE: '\u2ACB',
  4081. subne: '\u228A',
  4082. subplus: '\u2ABF',
  4083. subrarr: '\u2979',
  4084. Subset: '\u22D0',
  4085. subset: '\u2282',
  4086. subseteq: '\u2286',
  4087. subseteqq: '\u2AC5',
  4088. SubsetEqual: '\u2286',
  4089. subsetneq: '\u228A',
  4090. subsetneqq: '\u2ACB',
  4091. subsim: '\u2AC7',
  4092. subsub: '\u2AD5',
  4093. subsup: '\u2AD3',
  4094. succ: '\u227B',
  4095. succapprox: '\u2AB8',
  4096. succcurlyeq: '\u227D',
  4097. Succeeds: '\u227B',
  4098. SucceedsEqual: '\u2AB0',
  4099. SucceedsSlantEqual: '\u227D',
  4100. SucceedsTilde: '\u227F',
  4101. succeq: '\u2AB0',
  4102. succnapprox: '\u2ABA',
  4103. succneqq: '\u2AB6',
  4104. succnsim: '\u22E9',
  4105. succsim: '\u227F',
  4106. SuchThat: '\u220B',
  4107. Sum: '\u2211',
  4108. sum: '\u2211',
  4109. sung: '\u266A',
  4110. Sup: '\u22D1',
  4111. sup: '\u2283',
  4112. sup1: '\u00B9',
  4113. sup2: '\u00B2',
  4114. sup3: '\u00B3',
  4115. supdot: '\u2ABE',
  4116. supdsub: '\u2AD8',
  4117. supE: '\u2AC6',
  4118. supe: '\u2287',
  4119. supedot: '\u2AC4',
  4120. Superset: '\u2283',
  4121. SupersetEqual: '\u2287',
  4122. suphsol: '\u27C9',
  4123. suphsub: '\u2AD7',
  4124. suplarr: '\u297B',
  4125. supmult: '\u2AC2',
  4126. supnE: '\u2ACC',
  4127. supne: '\u228B',
  4128. supplus: '\u2AC0',
  4129. Supset: '\u22D1',
  4130. supset: '\u2283',
  4131. supseteq: '\u2287',
  4132. supseteqq: '\u2AC6',
  4133. supsetneq: '\u228B',
  4134. supsetneqq: '\u2ACC',
  4135. supsim: '\u2AC8',
  4136. supsub: '\u2AD4',
  4137. supsup: '\u2AD6',
  4138. swarhk: '\u2926',
  4139. swArr: '\u21D9',
  4140. swarr: '\u2199',
  4141. swarrow: '\u2199',
  4142. swnwar: '\u292A',
  4143. szlig: '\u00DF',
  4144. Tab: '\u0009',
  4145. target: '\u2316',
  4146. Tau: '\u03A4',
  4147. tau: '\u03C4',
  4148. tbrk: '\u23B4',
  4149. Tcaron: '\u0164',
  4150. tcaron: '\u0165',
  4151. Tcedil: '\u0162',
  4152. tcedil: '\u0163',
  4153. Tcy: '\u0422',
  4154. tcy: '\u0442',
  4155. tdot: '\u20DB',
  4156. telrec: '\u2315',
  4157. Tfr: '\uD835\uDD17',
  4158. tfr: '\uD835\uDD31',
  4159. there4: '\u2234',
  4160. Therefore: '\u2234',
  4161. therefore: '\u2234',
  4162. Theta: '\u0398',
  4163. theta: '\u03B8',
  4164. thetasym: '\u03D1',
  4165. thetav: '\u03D1',
  4166. thickapprox: '\u2248',
  4167. thicksim: '\u223C',
  4168. ThickSpace: '\u205F\u200A',
  4169. thinsp: '\u2009',
  4170. ThinSpace: '\u2009',
  4171. thkap: '\u2248',
  4172. thksim: '\u223C',
  4173. THORN: '\u00DE',
  4174. thorn: '\u00FE',
  4175. Tilde: '\u223C',
  4176. tilde: '\u02DC',
  4177. TildeEqual: '\u2243',
  4178. TildeFullEqual: '\u2245',
  4179. TildeTilde: '\u2248',
  4180. times: '\u00D7',
  4181. timesb: '\u22A0',
  4182. timesbar: '\u2A31',
  4183. timesd: '\u2A30',
  4184. tint: '\u222D',
  4185. toea: '\u2928',
  4186. top: '\u22A4',
  4187. topbot: '\u2336',
  4188. topcir: '\u2AF1',
  4189. Topf: '\uD835\uDD4B',
  4190. topf: '\uD835\uDD65',
  4191. topfork: '\u2ADA',
  4192. tosa: '\u2929',
  4193. tprime: '\u2034',
  4194. TRADE: '\u2122',
  4195. trade: '\u2122',
  4196. triangle: '\u25B5',
  4197. triangledown: '\u25BF',
  4198. triangleleft: '\u25C3',
  4199. trianglelefteq: '\u22B4',
  4200. triangleq: '\u225C',
  4201. triangleright: '\u25B9',
  4202. trianglerighteq: '\u22B5',
  4203. tridot: '\u25EC',
  4204. trie: '\u225C',
  4205. triminus: '\u2A3A',
  4206. TripleDot: '\u20DB',
  4207. triplus: '\u2A39',
  4208. trisb: '\u29CD',
  4209. tritime: '\u2A3B',
  4210. trpezium: '\u23E2',
  4211. Tscr: '\uD835\uDCAF',
  4212. tscr: '\uD835\uDCC9',
  4213. TScy: '\u0426',
  4214. tscy: '\u0446',
  4215. TSHcy: '\u040B',
  4216. tshcy: '\u045B',
  4217. Tstrok: '\u0166',
  4218. tstrok: '\u0167',
  4219. twixt: '\u226C',
  4220. twoheadleftarrow: '\u219E',
  4221. twoheadrightarrow: '\u21A0',
  4222. Uacute: '\u00DA',
  4223. uacute: '\u00FA',
  4224. Uarr: '\u219F',
  4225. uArr: '\u21D1',
  4226. uarr: '\u2191',
  4227. Uarrocir: '\u2949',
  4228. Ubrcy: '\u040E',
  4229. ubrcy: '\u045E',
  4230. Ubreve: '\u016C',
  4231. ubreve: '\u016D',
  4232. Ucirc: '\u00DB',
  4233. ucirc: '\u00FB',
  4234. Ucy: '\u0423',
  4235. ucy: '\u0443',
  4236. udarr: '\u21C5',
  4237. Udblac: '\u0170',
  4238. udblac: '\u0171',
  4239. udhar: '\u296E',
  4240. ufisht: '\u297E',
  4241. Ufr: '\uD835\uDD18',
  4242. ufr: '\uD835\uDD32',
  4243. Ugrave: '\u00D9',
  4244. ugrave: '\u00F9',
  4245. uHar: '\u2963',
  4246. uharl: '\u21BF',
  4247. uharr: '\u21BE',
  4248. uhblk: '\u2580',
  4249. ulcorn: '\u231C',
  4250. ulcorner: '\u231C',
  4251. ulcrop: '\u230F',
  4252. ultri: '\u25F8',
  4253. Umacr: '\u016A',
  4254. umacr: '\u016B',
  4255. uml: '\u00A8',
  4256. UnderBar: '\u005F',
  4257. UnderBrace: '\u23DF',
  4258. UnderBracket: '\u23B5',
  4259. UnderParenthesis: '\u23DD',
  4260. Union: '\u22C3',
  4261. UnionPlus: '\u228E',
  4262. Uogon: '\u0172',
  4263. uogon: '\u0173',
  4264. Uopf: '\uD835\uDD4C',
  4265. uopf: '\uD835\uDD66',
  4266. UpArrow: '\u2191',
  4267. Uparrow: '\u21D1',
  4268. uparrow: '\u2191',
  4269. UpArrowBar: '\u2912',
  4270. UpArrowDownArrow: '\u21C5',
  4271. UpDownArrow: '\u2195',
  4272. Updownarrow: '\u21D5',
  4273. updownarrow: '\u2195',
  4274. UpEquilibrium: '\u296E',
  4275. upharpoonleft: '\u21BF',
  4276. upharpoonright: '\u21BE',
  4277. uplus: '\u228E',
  4278. UpperLeftArrow: '\u2196',
  4279. UpperRightArrow: '\u2197',
  4280. Upsi: '\u03D2',
  4281. upsi: '\u03C5',
  4282. upsih: '\u03D2',
  4283. Upsilon: '\u03A5',
  4284. upsilon: '\u03C5',
  4285. UpTee: '\u22A5',
  4286. UpTeeArrow: '\u21A5',
  4287. upuparrows: '\u21C8',
  4288. urcorn: '\u231D',
  4289. urcorner: '\u231D',
  4290. urcrop: '\u230E',
  4291. Uring: '\u016E',
  4292. uring: '\u016F',
  4293. urtri: '\u25F9',
  4294. Uscr: '\uD835\uDCB0',
  4295. uscr: '\uD835\uDCCA',
  4296. utdot: '\u22F0',
  4297. Utilde: '\u0168',
  4298. utilde: '\u0169',
  4299. utri: '\u25B5',
  4300. utrif: '\u25B4',
  4301. uuarr: '\u21C8',
  4302. Uuml: '\u00DC',
  4303. uuml: '\u00FC',
  4304. uwangle: '\u29A7',
  4305. vangrt: '\u299C',
  4306. varepsilon: '\u03F5',
  4307. varkappa: '\u03F0',
  4308. varnothing: '\u2205',
  4309. varphi: '\u03D5',
  4310. varpi: '\u03D6',
  4311. varpropto: '\u221D',
  4312. vArr: '\u21D5',
  4313. varr: '\u2195',
  4314. varrho: '\u03F1',
  4315. varsigma: '\u03C2',
  4316. varsubsetneq: '\u228A\uFE00',
  4317. varsubsetneqq: '\u2ACB\uFE00',
  4318. varsupsetneq: '\u228B\uFE00',
  4319. varsupsetneqq: '\u2ACC\uFE00',
  4320. vartheta: '\u03D1',
  4321. vartriangleleft: '\u22B2',
  4322. vartriangleright: '\u22B3',
  4323. Vbar: '\u2AEB',
  4324. vBar: '\u2AE8',
  4325. vBarv: '\u2AE9',
  4326. Vcy: '\u0412',
  4327. vcy: '\u0432',
  4328. VDash: '\u22AB',
  4329. Vdash: '\u22A9',
  4330. vDash: '\u22A8',
  4331. vdash: '\u22A2',
  4332. Vdashl: '\u2AE6',
  4333. Vee: '\u22C1',
  4334. vee: '\u2228',
  4335. veebar: '\u22BB',
  4336. veeeq: '\u225A',
  4337. vellip: '\u22EE',
  4338. Verbar: '\u2016',
  4339. verbar: '\u007C',
  4340. Vert: '\u2016',
  4341. vert: '\u007C',
  4342. VerticalBar: '\u2223',
  4343. VerticalLine: '\u007C',
  4344. VerticalSeparator: '\u2758',
  4345. VerticalTilde: '\u2240',
  4346. VeryThinSpace: '\u200A',
  4347. Vfr: '\uD835\uDD19',
  4348. vfr: '\uD835\uDD33',
  4349. vltri: '\u22B2',
  4350. vnsub: '\u2282\u20D2',
  4351. vnsup: '\u2283\u20D2',
  4352. Vopf: '\uD835\uDD4D',
  4353. vopf: '\uD835\uDD67',
  4354. vprop: '\u221D',
  4355. vrtri: '\u22B3',
  4356. Vscr: '\uD835\uDCB1',
  4357. vscr: '\uD835\uDCCB',
  4358. vsubnE: '\u2ACB\uFE00',
  4359. vsubne: '\u228A\uFE00',
  4360. vsupnE: '\u2ACC\uFE00',
  4361. vsupne: '\u228B\uFE00',
  4362. Vvdash: '\u22AA',
  4363. vzigzag: '\u299A',
  4364. Wcirc: '\u0174',
  4365. wcirc: '\u0175',
  4366. wedbar: '\u2A5F',
  4367. Wedge: '\u22C0',
  4368. wedge: '\u2227',
  4369. wedgeq: '\u2259',
  4370. weierp: '\u2118',
  4371. Wfr: '\uD835\uDD1A',
  4372. wfr: '\uD835\uDD34',
  4373. Wopf: '\uD835\uDD4E',
  4374. wopf: '\uD835\uDD68',
  4375. wp: '\u2118',
  4376. wr: '\u2240',
  4377. wreath: '\u2240',
  4378. Wscr: '\uD835\uDCB2',
  4379. wscr: '\uD835\uDCCC',
  4380. xcap: '\u22C2',
  4381. xcirc: '\u25EF',
  4382. xcup: '\u22C3',
  4383. xdtri: '\u25BD',
  4384. Xfr: '\uD835\uDD1B',
  4385. xfr: '\uD835\uDD35',
  4386. xhArr: '\u27FA',
  4387. xharr: '\u27F7',
  4388. Xi: '\u039E',
  4389. xi: '\u03BE',
  4390. xlArr: '\u27F8',
  4391. xlarr: '\u27F5',
  4392. xmap: '\u27FC',
  4393. xnis: '\u22FB',
  4394. xodot: '\u2A00',
  4395. Xopf: '\uD835\uDD4F',
  4396. xopf: '\uD835\uDD69',
  4397. xoplus: '\u2A01',
  4398. xotime: '\u2A02',
  4399. xrArr: '\u27F9',
  4400. xrarr: '\u27F6',
  4401. Xscr: '\uD835\uDCB3',
  4402. xscr: '\uD835\uDCCD',
  4403. xsqcup: '\u2A06',
  4404. xuplus: '\u2A04',
  4405. xutri: '\u25B3',
  4406. xvee: '\u22C1',
  4407. xwedge: '\u22C0',
  4408. Yacute: '\u00DD',
  4409. yacute: '\u00FD',
  4410. YAcy: '\u042F',
  4411. yacy: '\u044F',
  4412. Ycirc: '\u0176',
  4413. ycirc: '\u0177',
  4414. Ycy: '\u042B',
  4415. ycy: '\u044B',
  4416. yen: '\u00A5',
  4417. Yfr: '\uD835\uDD1C',
  4418. yfr: '\uD835\uDD36',
  4419. YIcy: '\u0407',
  4420. yicy: '\u0457',
  4421. Yopf: '\uD835\uDD50',
  4422. yopf: '\uD835\uDD6A',
  4423. Yscr: '\uD835\uDCB4',
  4424. yscr: '\uD835\uDCCE',
  4425. YUcy: '\u042E',
  4426. yucy: '\u044E',
  4427. Yuml: '\u0178',
  4428. yuml: '\u00FF',
  4429. Zacute: '\u0179',
  4430. zacute: '\u017A',
  4431. Zcaron: '\u017D',
  4432. zcaron: '\u017E',
  4433. Zcy: '\u0417',
  4434. zcy: '\u0437',
  4435. Zdot: '\u017B',
  4436. zdot: '\u017C',
  4437. zeetrf: '\u2128',
  4438. ZeroWidthSpace: '\u200B',
  4439. Zeta: '\u0396',
  4440. zeta: '\u03B6',
  4441. Zfr: '\u2128',
  4442. zfr: '\uD835\uDD37',
  4443. ZHcy: '\u0416',
  4444. zhcy: '\u0436',
  4445. zigrarr: '\u21DD',
  4446. Zopf: '\u2124',
  4447. zopf: '\uD835\uDD6B',
  4448. Zscr: '\uD835\uDCB5',
  4449. zscr: '\uD835\uDCCF',
  4450. zwj: '\u200D',
  4451. zwnj: '\u200C'
  4452. })
  4453. /**
  4454. * @deprecated use `HTML_ENTITIES` instead
  4455. * @see HTML_ENTITIES
  4456. */
  4457. exports.entityMap = exports.HTML_ENTITIES
  4458. },
  4459. { './conventions': 5 }
  4460. ],
  4461. 9: [
  4462. function (require, module, exports) {
  4463. var dom = require('./dom')
  4464. exports.DOMImplementation = dom.DOMImplementation
  4465. exports.XMLSerializer = dom.XMLSerializer
  4466. exports.DOMParser = require('./dom-parser').DOMParser
  4467. },
  4468. { './dom': 7, './dom-parser': 6 }
  4469. ],
  4470. 10: [
  4471. function (require, module, exports) {
  4472. var NAMESPACE = require('./conventions').NAMESPACE
  4473. var nameStartChar =
  4474. /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/ //\u10000-\uEFFFF
  4475. var nameChar = new RegExp('[\\-\\.0-9' + nameStartChar.source.slice(1, -1) + '\\u00B7\\u0300-\\u036F\\u203F-\\u2040]')
  4476. var tagNamePattern = new RegExp('^' + nameStartChar.source + nameChar.source + '*(?::' + nameStartChar.source + nameChar.source + '*)?$')
  4477. var S_TAG = 0 //tag name offerring
  4478. var S_ATTR = 1 //attr name offerring
  4479. var S_ATTR_SPACE = 2 //attr name end and space offer
  4480. var S_EQ = 3 //=space?
  4481. var S_ATTR_NOQUOT_VALUE = 4 //attr value(no quot value only)
  4482. var S_ATTR_END = 5 //attr value end and no space(quot end)
  4483. var S_TAG_SPACE = 6 //(attr value end || tag end ) && (space offer)
  4484. var S_TAG_CLOSE = 7 //closed el<el />
  4485. function ParseError(message, locator) {
  4486. this.message = message
  4487. this.locator = locator
  4488. if (Error.captureStackTrace) Error.captureStackTrace(this, ParseError)
  4489. }
  4490. ParseError.prototype = new Error()
  4491. ParseError.prototype.name = ParseError.name
  4492. function XMLReader() {}
  4493. XMLReader.prototype = {
  4494. parse: function (source, defaultNSMap, entityMap) {
  4495. var domBuilder = this.domBuilder
  4496. domBuilder.startDocument()
  4497. _copy(defaultNSMap, (defaultNSMap = {}))
  4498. parse(source, defaultNSMap, entityMap, domBuilder, this.errorHandler)
  4499. domBuilder.endDocument()
  4500. }
  4501. }
  4502. function parse(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
  4503. function fixedFromCharCode(code) {
  4504. if (code > 0xffff) {
  4505. code -= 0x10000
  4506. var surrogate1 = 0xd800 + (code >> 10),
  4507. surrogate2 = 0xdc00 + (code & 0x3ff)
  4508. return String.fromCharCode(surrogate1, surrogate2)
  4509. } else {
  4510. return String.fromCharCode(code)
  4511. }
  4512. }
  4513. function entityReplacer(a) {
  4514. var k = a.slice(1, -1)
  4515. if (Object.hasOwnProperty.call(entityMap, k)) {
  4516. return entityMap[k]
  4517. } else if (k.charAt(0) === '#') {
  4518. return fixedFromCharCode(parseInt(k.substr(1).replace('x', '0x')))
  4519. } else {
  4520. errorHandler.error('entity not found:' + a)
  4521. return a
  4522. }
  4523. }
  4524. function appendText(end) {
  4525. //has some bugs
  4526. if (end > start) {
  4527. var xt = source.substring(start, end).replace(/&#?\w+;/g, entityReplacer)
  4528. locator && position(start)
  4529. domBuilder.characters(xt, 0, end - start)
  4530. start = end
  4531. }
  4532. }
  4533. function position(p, m) {
  4534. while (p >= lineEnd && (m = linePattern.exec(source))) {
  4535. lineStart = m.index
  4536. lineEnd = lineStart + m[0].length
  4537. locator.lineNumber++
  4538. //console.log('line++:',locator,startPos,endPos)
  4539. }
  4540. locator.columnNumber = p - lineStart + 1
  4541. }
  4542. var lineStart = 0
  4543. var lineEnd = 0
  4544. var linePattern = /.*(?:\r\n?|\n)|.*$/g
  4545. var locator = domBuilder.locator
  4546. var parseStack = [{ currentNSMap: defaultNSMapCopy }]
  4547. var closeMap = {}
  4548. var start = 0
  4549. while (true) {
  4550. try {
  4551. var tagStart = source.indexOf('<', start)
  4552. if (tagStart < 0) {
  4553. if (!source.substr(start).match(/^\s*$/)) {
  4554. var doc = domBuilder.doc
  4555. var text = doc.createTextNode(source.substr(start))
  4556. doc.appendChild(text)
  4557. domBuilder.currentElement = text
  4558. }
  4559. return
  4560. }
  4561. if (tagStart > start) {
  4562. appendText(tagStart)
  4563. }
  4564. switch (source.charAt(tagStart + 1)) {
  4565. case '/':
  4566. var end = source.indexOf('>', tagStart + 3)
  4567. var tagName = source.substring(tagStart + 2, end).replace(/[ \t\n\r]+$/g, '')
  4568. var config = parseStack.pop()
  4569. if (end < 0) {
  4570. tagName = source.substring(tagStart + 2).replace(/[\s<].*/, '')
  4571. errorHandler.error('end tag name: ' + tagName + ' is not complete:' + config.tagName)
  4572. end = tagStart + 1 + tagName.length
  4573. } else if (tagName.match(/\s</)) {
  4574. tagName = tagName.replace(/[\s<].*/, '')
  4575. errorHandler.error('end tag name: ' + tagName + ' maybe not complete')
  4576. end = tagStart + 1 + tagName.length
  4577. }
  4578. var localNSMap = config.localNSMap
  4579. var endMatch = config.tagName == tagName
  4580. var endIgnoreCaseMach = endMatch || (config.tagName && config.tagName.toLowerCase() == tagName.toLowerCase())
  4581. if (endIgnoreCaseMach) {
  4582. domBuilder.endElement(config.uri, config.localName, tagName)
  4583. if (localNSMap) {
  4584. for (var prefix in localNSMap) {
  4585. if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
  4586. domBuilder.endPrefixMapping(prefix)
  4587. }
  4588. }
  4589. }
  4590. if (!endMatch) {
  4591. errorHandler.fatalError('end tag name: ' + tagName + ' is not match the current start tagName:' + config.tagName) // No known test case
  4592. }
  4593. } else {
  4594. parseStack.push(config)
  4595. }
  4596. end++
  4597. break
  4598. // end elment
  4599. case '?': // <?...?>
  4600. locator && position(tagStart)
  4601. end = parseInstruction(source, tagStart, domBuilder)
  4602. break
  4603. case '!': // <!doctype,<![CDATA,<!--
  4604. locator && position(tagStart)
  4605. end = parseDCC(source, tagStart, domBuilder, errorHandler)
  4606. break
  4607. default:
  4608. locator && position(tagStart)
  4609. var el = new ElementAttributes()
  4610. var currentNSMap = parseStack[parseStack.length - 1].currentNSMap
  4611. //elStartEnd
  4612. var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler)
  4613. var len = el.length
  4614. if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
  4615. el.closed = true
  4616. if (!entityMap.nbsp) {
  4617. errorHandler.warning('unclosed xml attribute')
  4618. }
  4619. }
  4620. if (locator && len) {
  4621. var locator2 = copyLocator(locator, {})
  4622. //try{//attribute position fixed
  4623. for (var i = 0; i < len; i++) {
  4624. var a = el[i]
  4625. position(a.offset)
  4626. a.locator = copyLocator(locator, {})
  4627. }
  4628. domBuilder.locator = locator2
  4629. if (appendElement(el, domBuilder, currentNSMap)) {
  4630. parseStack.push(el)
  4631. }
  4632. domBuilder.locator = locator
  4633. } else {
  4634. if (appendElement(el, domBuilder, currentNSMap)) {
  4635. parseStack.push(el)
  4636. }
  4637. }
  4638. if (NAMESPACE.isHTML(el.uri) && !el.closed) {
  4639. end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder)
  4640. } else {
  4641. end++
  4642. }
  4643. }
  4644. } catch (e) {
  4645. if (e instanceof ParseError) {
  4646. throw e
  4647. }
  4648. errorHandler.error('element parse error: ' + e)
  4649. end = -1
  4650. }
  4651. if (end > start) {
  4652. start = end
  4653. } else {
  4654. //TODO: 这里有可能sax回退,有位置错误风险
  4655. appendText(Math.max(tagStart, start) + 1)
  4656. }
  4657. }
  4658. }
  4659. function copyLocator(f, t) {
  4660. t.lineNumber = f.lineNumber
  4661. t.columnNumber = f.columnNumber
  4662. return t
  4663. }
  4664. /**
  4665. * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
  4666. * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
  4667. */
  4668. function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
  4669. /**
  4670. * @param {string} qname
  4671. * @param {string} value
  4672. * @param {number} startIndex
  4673. */
  4674. function addAttribute(qname, value, startIndex) {
  4675. if (el.attributeNames.hasOwnProperty(qname)) {
  4676. errorHandler.fatalError('Attribute ' + qname + ' redefined')
  4677. }
  4678. el.addValue(
  4679. qname,
  4680. // @see https://www.w3.org/TR/xml/#AVNormalize
  4681. // since the xmldom sax parser does not "interpret" DTD the following is not implemented:
  4682. // - recursive replacement of (DTD) entity references
  4683. // - trimming and collapsing multiple spaces into a single one for attributes that are not of type CDATA
  4684. value.replace(/[\t\n\r]/g, ' ').replace(/&#?\w+;/g, entityReplacer),
  4685. startIndex
  4686. )
  4687. }
  4688. var attrName
  4689. var value
  4690. var p = ++start
  4691. var s = S_TAG //status
  4692. while (true) {
  4693. var c = source.charAt(p)
  4694. switch (c) {
  4695. case '=':
  4696. if (s === S_ATTR) {
  4697. //attrName
  4698. attrName = source.slice(start, p)
  4699. s = S_EQ
  4700. } else if (s === S_ATTR_SPACE) {
  4701. s = S_EQ
  4702. } else {
  4703. //fatalError: equal must after attrName or space after attrName
  4704. throw new Error('attribute equal must after attrName') // No known test case
  4705. }
  4706. break
  4707. case "'":
  4708. case '"':
  4709. if (
  4710. s === S_EQ ||
  4711. s === S_ATTR //|| s == S_ATTR_SPACE
  4712. ) {
  4713. //equal
  4714. if (s === S_ATTR) {
  4715. errorHandler.warning('attribute value must after "="')
  4716. attrName = source.slice(start, p)
  4717. }
  4718. start = p + 1
  4719. p = source.indexOf(c, start)
  4720. if (p > 0) {
  4721. value = source.slice(start, p)
  4722. addAttribute(attrName, value, start - 1)
  4723. s = S_ATTR_END
  4724. } else {
  4725. //fatalError: no end quot match
  4726. throw new Error("attribute value no end '" + c + "' match")
  4727. }
  4728. } else if (s == S_ATTR_NOQUOT_VALUE) {
  4729. value = source.slice(start, p)
  4730. addAttribute(attrName, value, start)
  4731. errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c + ')!!')
  4732. start = p + 1
  4733. s = S_ATTR_END
  4734. } else {
  4735. //fatalError: no equal before
  4736. throw new Error('attribute value must after "="') // No known test case
  4737. }
  4738. break
  4739. case '/':
  4740. switch (s) {
  4741. case S_TAG:
  4742. el.setTagName(source.slice(start, p))
  4743. case S_ATTR_END:
  4744. case S_TAG_SPACE:
  4745. case S_TAG_CLOSE:
  4746. s = S_TAG_CLOSE
  4747. el.closed = true
  4748. case S_ATTR_NOQUOT_VALUE:
  4749. case S_ATTR:
  4750. break
  4751. case S_ATTR_SPACE:
  4752. el.closed = true
  4753. break
  4754. //case S_EQ:
  4755. default:
  4756. throw new Error("attribute invalid close char('/')") // No known test case
  4757. }
  4758. break
  4759. case '': //end document
  4760. errorHandler.error('unexpected end of input')
  4761. if (s == S_TAG) {
  4762. el.setTagName(source.slice(start, p))
  4763. }
  4764. return p
  4765. case '>':
  4766. switch (s) {
  4767. case S_TAG:
  4768. el.setTagName(source.slice(start, p))
  4769. case S_ATTR_END:
  4770. case S_TAG_SPACE:
  4771. case S_TAG_CLOSE:
  4772. break //normal
  4773. case S_ATTR_NOQUOT_VALUE: //Compatible state
  4774. case S_ATTR:
  4775. value = source.slice(start, p)
  4776. if (value.slice(-1) === '/') {
  4777. el.closed = true
  4778. value = value.slice(0, -1)
  4779. }
  4780. case S_ATTR_SPACE:
  4781. if (s === S_ATTR_SPACE) {
  4782. value = attrName
  4783. }
  4784. if (s == S_ATTR_NOQUOT_VALUE) {
  4785. errorHandler.warning('attribute "' + value + '" missed quot(")!')
  4786. addAttribute(attrName, value, start)
  4787. } else {
  4788. if (!NAMESPACE.isHTML(currentNSMap['']) || !value.match(/^(?:disabled|checked|selected)$/i)) {
  4789. errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!')
  4790. }
  4791. addAttribute(value, value, start)
  4792. }
  4793. break
  4794. case S_EQ:
  4795. throw new Error('attribute value missed!!')
  4796. }
  4797. // console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
  4798. return p
  4799. /*xml space '\x20' | #x9 | #xD | #xA; */
  4800. case '\u0080':
  4801. c = ' '
  4802. default:
  4803. if (c <= ' ') {
  4804. //space
  4805. switch (s) {
  4806. case S_TAG:
  4807. el.setTagName(source.slice(start, p)) //tagName
  4808. s = S_TAG_SPACE
  4809. break
  4810. case S_ATTR:
  4811. attrName = source.slice(start, p)
  4812. s = S_ATTR_SPACE
  4813. break
  4814. case S_ATTR_NOQUOT_VALUE:
  4815. var value = source.slice(start, p)
  4816. errorHandler.warning('attribute "' + value + '" missed quot(")!!')
  4817. addAttribute(attrName, value, start)
  4818. case S_ATTR_END:
  4819. s = S_TAG_SPACE
  4820. break
  4821. //case S_TAG_SPACE:
  4822. //case S_EQ:
  4823. //case S_ATTR_SPACE:
  4824. // void();break;
  4825. //case S_TAG_CLOSE:
  4826. //ignore warning
  4827. }
  4828. } else {
  4829. //not space
  4830. //S_TAG, S_ATTR, S_EQ, S_ATTR_NOQUOT_VALUE
  4831. //S_ATTR_SPACE, S_ATTR_END, S_TAG_SPACE, S_TAG_CLOSE
  4832. switch (s) {
  4833. //case S_TAG:void();break;
  4834. //case S_ATTR:void();break;
  4835. //case S_ATTR_NOQUOT_VALUE:void();break;
  4836. case S_ATTR_SPACE:
  4837. var tagName = el.tagName
  4838. if (!NAMESPACE.isHTML(currentNSMap['']) || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
  4839. errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!')
  4840. }
  4841. addAttribute(attrName, attrName, start)
  4842. start = p
  4843. s = S_ATTR
  4844. break
  4845. case S_ATTR_END:
  4846. errorHandler.warning('attribute space is required"' + attrName + '"!!')
  4847. case S_TAG_SPACE:
  4848. s = S_ATTR
  4849. start = p
  4850. break
  4851. case S_EQ:
  4852. s = S_ATTR_NOQUOT_VALUE
  4853. start = p
  4854. break
  4855. case S_TAG_CLOSE:
  4856. throw new Error("elements closed character '/' and '>' must be connected to")
  4857. }
  4858. }
  4859. } //end outer switch
  4860. //console.log('p++',p)
  4861. p++
  4862. }
  4863. }
  4864. /**
  4865. * @return true if has new namespace define
  4866. */
  4867. function appendElement(el, domBuilder, currentNSMap) {
  4868. var tagName = el.tagName
  4869. var localNSMap = null
  4870. //var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
  4871. var i = el.length
  4872. while (i--) {
  4873. var a = el[i]
  4874. var qName = a.qName
  4875. var value = a.value
  4876. var nsp = qName.indexOf(':')
  4877. if (nsp > 0) {
  4878. var prefix = (a.prefix = qName.slice(0, nsp))
  4879. var localName = qName.slice(nsp + 1)
  4880. var nsPrefix = prefix === 'xmlns' && localName
  4881. } else {
  4882. localName = qName
  4883. prefix = null
  4884. nsPrefix = qName === 'xmlns' && ''
  4885. }
  4886. //can not set prefix,because prefix !== ''
  4887. a.localName = localName
  4888. //prefix == null for no ns prefix attribute
  4889. if (nsPrefix !== false) {
  4890. //hack!!
  4891. if (localNSMap == null) {
  4892. localNSMap = {}
  4893. //console.log(currentNSMap,0)
  4894. _copy(currentNSMap, (currentNSMap = {}))
  4895. //console.log(currentNSMap,1)
  4896. }
  4897. currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value
  4898. a.uri = NAMESPACE.XMLNS
  4899. domBuilder.startPrefixMapping(nsPrefix, value)
  4900. }
  4901. }
  4902. var i = el.length
  4903. while (i--) {
  4904. a = el[i]
  4905. var prefix = a.prefix
  4906. if (prefix) {
  4907. //no prefix attribute has no namespace
  4908. if (prefix === 'xml') {
  4909. a.uri = NAMESPACE.XML
  4910. }
  4911. if (prefix !== 'xmlns') {
  4912. a.uri = currentNSMap[prefix || '']
  4913. //{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
  4914. }
  4915. }
  4916. }
  4917. var nsp = tagName.indexOf(':')
  4918. if (nsp > 0) {
  4919. prefix = el.prefix = tagName.slice(0, nsp)
  4920. localName = el.localName = tagName.slice(nsp + 1)
  4921. } else {
  4922. prefix = null //important!!
  4923. localName = el.localName = tagName
  4924. }
  4925. //no prefix element has default namespace
  4926. var ns = (el.uri = currentNSMap[prefix || ''])
  4927. domBuilder.startElement(ns, localName, tagName, el)
  4928. //endPrefixMapping and startPrefixMapping have not any help for dom builder
  4929. //localNSMap = null
  4930. if (el.closed) {
  4931. domBuilder.endElement(ns, localName, tagName)
  4932. if (localNSMap) {
  4933. for (prefix in localNSMap) {
  4934. if (Object.prototype.hasOwnProperty.call(localNSMap, prefix)) {
  4935. domBuilder.endPrefixMapping(prefix)
  4936. }
  4937. }
  4938. }
  4939. } else {
  4940. el.currentNSMap = currentNSMap
  4941. el.localNSMap = localNSMap
  4942. //parseStack.push(el);
  4943. return true
  4944. }
  4945. }
  4946. function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
  4947. if (/^(?:script|textarea)$/i.test(tagName)) {
  4948. var elEndStart = source.indexOf('</' + tagName + '>', elStartEnd)
  4949. var text = source.substring(elStartEnd + 1, elEndStart)
  4950. if (/[&<]/.test(text)) {
  4951. if (/^script$/i.test(tagName)) {
  4952. //if(!/\]\]>/.test(text)){
  4953. //lexHandler.startCDATA();
  4954. domBuilder.characters(text, 0, text.length)
  4955. //lexHandler.endCDATA();
  4956. return elEndStart
  4957. //}
  4958. } //}else{//text area
  4959. text = text.replace(/&#?\w+;/g, entityReplacer)
  4960. domBuilder.characters(text, 0, text.length)
  4961. return elEndStart
  4962. //}
  4963. }
  4964. }
  4965. return elStartEnd + 1
  4966. }
  4967. function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
  4968. //if(tagName in closeMap){
  4969. var pos = closeMap[tagName]
  4970. if (pos == null) {
  4971. //console.log(tagName)
  4972. pos = source.lastIndexOf('</' + tagName + '>')
  4973. if (pos < elStartEnd) {
  4974. //忘记闭合
  4975. pos = source.lastIndexOf('</' + tagName)
  4976. }
  4977. closeMap[tagName] = pos
  4978. }
  4979. return pos < elStartEnd
  4980. //}
  4981. }
  4982. function _copy(source, target) {
  4983. for (var n in source) {
  4984. if (Object.prototype.hasOwnProperty.call(source, n)) {
  4985. target[n] = source[n]
  4986. }
  4987. }
  4988. }
  4989. function parseDCC(source, start, domBuilder, errorHandler) {
  4990. //sure start with '<!'
  4991. var next = source.charAt(start + 2)
  4992. switch (next) {
  4993. case '-':
  4994. if (source.charAt(start + 3) === '-') {
  4995. var end = source.indexOf('-->', start + 4)
  4996. //append comment source.substring(4,end)//<!--
  4997. if (end > start) {
  4998. domBuilder.comment(source, start + 4, end - start - 4)
  4999. return end + 3
  5000. } else {
  5001. errorHandler.error('Unclosed comment')
  5002. return -1
  5003. }
  5004. } else {
  5005. //error
  5006. return -1
  5007. }
  5008. default:
  5009. if (source.substr(start + 3, 6) == 'CDATA[') {
  5010. var end = source.indexOf(']]>', start + 9)
  5011. domBuilder.startCDATA()
  5012. domBuilder.characters(source, start + 9, end - start - 9)
  5013. domBuilder.endCDATA()
  5014. return end + 3
  5015. }
  5016. //<!DOCTYPE
  5017. //startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
  5018. var matchs = split(source, start)
  5019. var len = matchs.length
  5020. if (len > 1 && /!doctype/i.test(matchs[0][0])) {
  5021. var name = matchs[1][0]
  5022. var pubid = false
  5023. var sysid = false
  5024. if (len > 3) {
  5025. if (/^public$/i.test(matchs[2][0])) {
  5026. pubid = matchs[3][0]
  5027. sysid = len > 4 && matchs[4][0]
  5028. } else if (/^system$/i.test(matchs[2][0])) {
  5029. sysid = matchs[3][0]
  5030. }
  5031. }
  5032. var lastMatch = matchs[len - 1]
  5033. domBuilder.startDTD(name, pubid, sysid)
  5034. domBuilder.endDTD()
  5035. return lastMatch.index + lastMatch[0].length
  5036. }
  5037. }
  5038. return -1
  5039. }
  5040. function parseInstruction(source, start, domBuilder) {
  5041. var end = source.indexOf('?>', start)
  5042. if (end) {
  5043. var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/)
  5044. if (match) {
  5045. var len = match[0].length
  5046. domBuilder.processingInstruction(match[1], match[2])
  5047. return end + 2
  5048. } else {
  5049. //error
  5050. return -1
  5051. }
  5052. }
  5053. return -1
  5054. }
  5055. function ElementAttributes() {
  5056. this.attributeNames = {}
  5057. }
  5058. ElementAttributes.prototype = {
  5059. setTagName: function (tagName) {
  5060. if (!tagNamePattern.test(tagName)) {
  5061. throw new Error('invalid tagName:' + tagName)
  5062. }
  5063. this.tagName = tagName
  5064. },
  5065. addValue: function (qName, value, offset) {
  5066. if (!tagNamePattern.test(qName)) {
  5067. throw new Error('invalid attribute:' + qName)
  5068. }
  5069. this.attributeNames[qName] = this.length
  5070. this[this.length++] = { qName: qName, value: value, offset: offset }
  5071. },
  5072. length: 0,
  5073. getLocalName: function (i) {
  5074. return this[i].localName
  5075. },
  5076. getLocator: function (i) {
  5077. return this[i].locator
  5078. },
  5079. getQName: function (i) {
  5080. return this[i].qName
  5081. },
  5082. getURI: function (i) {
  5083. return this[i].uri
  5084. },
  5085. getValue: function (i) {
  5086. return this[i].value
  5087. }
  5088. // ,getIndex:function(uri, localName)){
  5089. // if(localName){
  5090. //
  5091. // }else{
  5092. // var qName = uri
  5093. // }
  5094. // },
  5095. // getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
  5096. // getType:function(uri,localName){}
  5097. // getType:function(i){},
  5098. }
  5099. function split(source, start) {
  5100. var match
  5101. var buf = []
  5102. var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g
  5103. reg.lastIndex = start
  5104. reg.exec(source) //skip <
  5105. while ((match = reg.exec(source))) {
  5106. buf.push(match)
  5107. if (match[1]) return buf
  5108. }
  5109. }
  5110. exports.XMLReader = XMLReader
  5111. exports.ParseError = ParseError
  5112. },
  5113. { './conventions': 5 }
  5114. ]
  5115. }
  5116. return r(utils, {}, [9])
  5117. }