build.js 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var he = _interopDefault(require('he'));
  5. /* */
  6. // these helpers produces better vm code in JS engines due to their
  7. // explicitness and function inlining
  8. /**
  9. * Check if value is primitive
  10. */
  11. /**
  12. * Quick object check - this is primarily used to tell
  13. * Objects from primitive values when we know the value
  14. * is a JSON-compliant type.
  15. */
  16. function isObject (obj) {
  17. return obj !== null && typeof obj === 'object'
  18. }
  19. /**
  20. * Get the raw type string of a value e.g. [object Object]
  21. */
  22. var _toString = Object.prototype.toString;
  23. function toRawType (value) {
  24. return _toString.call(value).slice(8, -1)
  25. }
  26. /**
  27. * Strict object type check. Only returns true
  28. * for plain JavaScript objects.
  29. */
  30. function isPlainObject (obj) {
  31. return _toString.call(obj) === '[object Object]'
  32. }
  33. /**
  34. * Check if val is a valid array index.
  35. */
  36. function isValidArrayIndex (val) {
  37. var n = parseFloat(String(val));
  38. return n >= 0 && Math.floor(n) === n && isFinite(val)
  39. }
  40. /**
  41. * Convert a value to a string that is actually rendered.
  42. */
  43. /**
  44. * Convert a input value to a number for persistence.
  45. * If the conversion fails, return original string.
  46. */
  47. /**
  48. * Make a map and return a function for checking if a key
  49. * is in that map.
  50. */
  51. function makeMap (
  52. str,
  53. expectsLowerCase
  54. ) {
  55. var map = Object.create(null);
  56. var list = str.split(',');
  57. for (var i = 0; i < list.length; i++) {
  58. map[list[i]] = true;
  59. }
  60. return expectsLowerCase
  61. ? function (val) { return map[val.toLowerCase()]; }
  62. : function (val) { return map[val]; }
  63. }
  64. /**
  65. * Check if a tag is a built-in tag.
  66. */
  67. var isBuiltInTag = makeMap('slot,component', true);
  68. /**
  69. * Check if a attribute is a reserved attribute.
  70. */
  71. var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
  72. /**
  73. * Remove an item from an array
  74. */
  75. function remove (arr, item) {
  76. if (arr.length) {
  77. var index = arr.indexOf(item);
  78. if (index > -1) {
  79. return arr.splice(index, 1)
  80. }
  81. }
  82. }
  83. /**
  84. * Check whether the object has the property.
  85. */
  86. var hasOwnProperty = Object.prototype.hasOwnProperty;
  87. function hasOwn (obj, key) {
  88. return hasOwnProperty.call(obj, key)
  89. }
  90. /**
  91. * Create a cached version of a pure function.
  92. */
  93. function cached (fn) {
  94. var cache = Object.create(null);
  95. return (function cachedFn (str) {
  96. var hit = cache[str];
  97. return hit || (cache[str] = fn(str))
  98. })
  99. }
  100. /**
  101. * Camelize a hyphen-delimited string.
  102. */
  103. var camelizeRE = /-(\w)/g;
  104. var camelize = cached(function (str) {
  105. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  106. });
  107. /**
  108. * Capitalize a string.
  109. */
  110. var capitalize = cached(function (str) {
  111. return str.charAt(0).toUpperCase() + str.slice(1)
  112. });
  113. /**
  114. * Hyphenate a camelCase string.
  115. */
  116. var hyphenateRE = /\B([A-Z])/g;
  117. var hyphenate = cached(function (str) {
  118. return str.replace(hyphenateRE, '-$1').toLowerCase()
  119. });
  120. /**
  121. * Simple bind, faster than native
  122. */
  123. /**
  124. * Convert an Array-like object to a real Array.
  125. */
  126. /**
  127. * Mix properties into target object.
  128. */
  129. function extend (to, _from) {
  130. for (var key in _from) {
  131. to[key] = _from[key];
  132. }
  133. return to
  134. }
  135. /**
  136. * Merge an Array of Objects into a single Object.
  137. */
  138. /**
  139. * Perform no operation.
  140. * Stubbing args to make Flow happy without leaving useless transpiled code
  141. * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
  142. */
  143. function noop (a, b, c) {}
  144. /**
  145. * Always return false.
  146. */
  147. var no = function (a, b, c) { return false; };
  148. /**
  149. * Return same value
  150. */
  151. var identity = function (_) { return _; };
  152. /**
  153. * Generate a static keys string from compiler modules.
  154. */
  155. function genStaticKeys (modules) {
  156. return modules.reduce(function (keys, m) {
  157. return keys.concat(m.staticKeys || [])
  158. }, []).join(',')
  159. }
  160. /**
  161. * Check if two values are loosely equal - that is,
  162. * if they are plain objects, do they have the same shape?
  163. */
  164. /**
  165. * Ensure a function is called only once.
  166. */
  167. /* */
  168. var isUnaryTag = makeMap(
  169. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  170. 'link,meta,param,source,track,wbr'
  171. );
  172. // Elements that you can, intentionally, leave open
  173. // (and which close themselves)
  174. var canBeLeftOpenTag = makeMap(
  175. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
  176. );
  177. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  178. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  179. var isNonPhrasingTag = makeMap(
  180. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  181. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  182. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  183. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  184. 'title,tr,track'
  185. );
  186. /**
  187. * Not type-checking this file because it's mostly vendor code.
  188. */
  189. /*!
  190. * HTML Parser By John Resig (ejohn.org)
  191. * Modified by Juriy "kangax" Zaytsev
  192. * Original code by Erik Arvidsson, Mozilla Public License
  193. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  194. */
  195. // Regular Expressions for parsing tags and attributes
  196. var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
  197. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  198. // but for Vue templates we can enforce a simple charset
  199. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  200. var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
  201. var startTagOpen = new RegExp(("^<" + qnameCapture));
  202. var startTagClose = /^\s*(\/?)>/;
  203. var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
  204. var doctype = /^<!DOCTYPE [^>]+>/i;
  205. var comment = /^<!--/;
  206. var conditionalComment = /^<!\[/;
  207. var IS_REGEX_CAPTURING_BROKEN = false;
  208. 'x'.replace(/x(.)?/g, function (m, g) {
  209. IS_REGEX_CAPTURING_BROKEN = g === '';
  210. });
  211. // Special Elements (can contain anything)
  212. var isPlainTextElement = makeMap('script,style,textarea', true);
  213. var reCache = {};
  214. var decodingMap = {
  215. '&lt;': '<',
  216. '&gt;': '>',
  217. '&quot;': '"',
  218. '&amp;': '&',
  219. '&#10;': '\n'
  220. };
  221. var encodedAttr = /&(?:lt|gt|quot|amp);/g;
  222. var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g;
  223. // #5992
  224. var isIgnoreNewlineTag = makeMap('pre,textarea', true);
  225. var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
  226. function decodeAttr (value, shouldDecodeNewlines) {
  227. var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
  228. return value.replace(re, function (match) { return decodingMap[match]; })
  229. }
  230. function parseHTML (html, options) {
  231. var stack = [];
  232. var expectHTML = options.expectHTML;
  233. var isUnaryTag$$1 = options.isUnaryTag || no;
  234. var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
  235. var index = 0;
  236. var last, lastTag;
  237. while (html) {
  238. last = html;
  239. // Make sure we're not in a plaintext content element like script/style
  240. if (!lastTag || !isPlainTextElement(lastTag)) {
  241. var textEnd = html.indexOf('<');
  242. if (textEnd === 0) {
  243. // Comment:
  244. if (comment.test(html)) {
  245. var commentEnd = html.indexOf('-->');
  246. if (commentEnd >= 0) {
  247. if (options.shouldKeepComment) {
  248. options.comment(html.substring(4, commentEnd));
  249. }
  250. advance(commentEnd + 3);
  251. continue
  252. }
  253. }
  254. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  255. if (conditionalComment.test(html)) {
  256. var conditionalEnd = html.indexOf(']>');
  257. if (conditionalEnd >= 0) {
  258. advance(conditionalEnd + 2);
  259. continue
  260. }
  261. }
  262. // Doctype:
  263. var doctypeMatch = html.match(doctype);
  264. if (doctypeMatch) {
  265. advance(doctypeMatch[0].length);
  266. continue
  267. }
  268. // End tag:
  269. var endTagMatch = html.match(endTag);
  270. if (endTagMatch) {
  271. var curIndex = index;
  272. advance(endTagMatch[0].length);
  273. parseEndTag(endTagMatch[1], curIndex, index);
  274. continue
  275. }
  276. // Start tag:
  277. var startTagMatch = parseStartTag();
  278. if (startTagMatch) {
  279. handleStartTag(startTagMatch);
  280. if (shouldIgnoreFirstNewline(lastTag, html)) {
  281. advance(1);
  282. }
  283. continue
  284. }
  285. }
  286. var text = (void 0), rest = (void 0), next = (void 0);
  287. if (textEnd >= 0) {
  288. rest = html.slice(textEnd);
  289. while (
  290. !endTag.test(rest) &&
  291. !startTagOpen.test(rest) &&
  292. !comment.test(rest) &&
  293. !conditionalComment.test(rest)
  294. ) {
  295. // < in plain text, be forgiving and treat it as text
  296. next = rest.indexOf('<', 1);
  297. if (next < 0) { break }
  298. textEnd += next;
  299. rest = html.slice(textEnd);
  300. }
  301. text = html.substring(0, textEnd);
  302. advance(textEnd);
  303. }
  304. if (textEnd < 0) {
  305. text = html;
  306. html = '';
  307. }
  308. if (options.chars && text) {
  309. options.chars(text);
  310. }
  311. } else {
  312. var endTagLength = 0;
  313. var stackedTag = lastTag.toLowerCase();
  314. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  315. var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
  316. endTagLength = endTag.length;
  317. if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
  318. text = text
  319. .replace(/<!--([\s\S]*?)-->/g, '$1')
  320. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  321. }
  322. if (shouldIgnoreFirstNewline(stackedTag, text)) {
  323. text = text.slice(1);
  324. }
  325. if (options.chars) {
  326. options.chars(text);
  327. }
  328. return ''
  329. });
  330. index += html.length - rest$1.length;
  331. html = rest$1;
  332. parseEndTag(stackedTag, index - endTagLength, index);
  333. }
  334. if (html === last) {
  335. options.chars && options.chars(html);
  336. if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
  337. options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
  338. }
  339. break
  340. }
  341. }
  342. // Clean up any remaining tags
  343. parseEndTag();
  344. function advance (n) {
  345. index += n;
  346. html = html.substring(n);
  347. }
  348. function parseStartTag () {
  349. var start = html.match(startTagOpen);
  350. if (start) {
  351. var match = {
  352. tagName: start[1],
  353. attrs: [],
  354. start: index
  355. };
  356. advance(start[0].length);
  357. var end, attr;
  358. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  359. advance(attr[0].length);
  360. match.attrs.push(attr);
  361. }
  362. if (end) {
  363. match.unarySlash = end[1];
  364. advance(end[0].length);
  365. match.end = index;
  366. return match
  367. }
  368. }
  369. }
  370. function handleStartTag (match) {
  371. var tagName = match.tagName;
  372. var unarySlash = match.unarySlash;
  373. if (expectHTML) {
  374. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  375. parseEndTag(lastTag);
  376. }
  377. if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
  378. parseEndTag(tagName);
  379. }
  380. }
  381. var unary = isUnaryTag$$1(tagName) || !!unarySlash;
  382. var l = match.attrs.length;
  383. var attrs = new Array(l);
  384. for (var i = 0; i < l; i++) {
  385. var args = match.attrs[i];
  386. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  387. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  388. if (args[3] === '') { delete args[3]; }
  389. if (args[4] === '') { delete args[4]; }
  390. if (args[5] === '') { delete args[5]; }
  391. }
  392. var value = args[3] || args[4] || args[5] || '';
  393. attrs[i] = {
  394. name: args[1],
  395. value: decodeAttr(
  396. value,
  397. options.shouldDecodeNewlines
  398. )
  399. };
  400. }
  401. if (!unary) {
  402. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  403. lastTag = tagName;
  404. }
  405. if (options.start) {
  406. options.start(tagName, attrs, unary, match.start, match.end);
  407. }
  408. }
  409. function parseEndTag (tagName, start, end) {
  410. var pos, lowerCasedTagName;
  411. if (start == null) { start = index; }
  412. if (end == null) { end = index; }
  413. if (tagName) {
  414. lowerCasedTagName = tagName.toLowerCase();
  415. }
  416. // Find the closest opened tag of the same type
  417. if (tagName) {
  418. for (pos = stack.length - 1; pos >= 0; pos--) {
  419. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  420. break
  421. }
  422. }
  423. } else {
  424. // If no tag name is provided, clean shop
  425. pos = 0;
  426. }
  427. if (pos >= 0) {
  428. // Close all the open elements, up the stack
  429. for (var i = stack.length - 1; i >= pos; i--) {
  430. if (process.env.NODE_ENV !== 'production' &&
  431. (i > pos || !tagName) &&
  432. options.warn
  433. ) {
  434. options.warn(
  435. ("tag <" + (stack[i].tag) + "> has no matching end tag.")
  436. );
  437. }
  438. if (options.end) {
  439. options.end(stack[i].tag, start, end);
  440. }
  441. }
  442. // Remove the open elements from the stack
  443. stack.length = pos;
  444. lastTag = pos && stack[pos - 1].tag;
  445. } else if (lowerCasedTagName === 'br') {
  446. if (options.start) {
  447. options.start(tagName, [], true, start, end);
  448. }
  449. } else if (lowerCasedTagName === 'p') {
  450. if (options.start) {
  451. options.start(tagName, [], false, start, end);
  452. }
  453. if (options.end) {
  454. options.end(tagName, start, end);
  455. }
  456. }
  457. }
  458. }
  459. /* */
  460. var validDivisionCharRE = /[\w).+\-_$\]]/;
  461. function parseFilters (exp) {
  462. var inSingle = false;
  463. var inDouble = false;
  464. var inTemplateString = false;
  465. var inRegex = false;
  466. var curly = 0;
  467. var square = 0;
  468. var paren = 0;
  469. var lastFilterIndex = 0;
  470. var c, prev, i, expression, filters;
  471. for (i = 0; i < exp.length; i++) {
  472. prev = c;
  473. c = exp.charCodeAt(i);
  474. if (inSingle) {
  475. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  476. } else if (inDouble) {
  477. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  478. } else if (inTemplateString) {
  479. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  480. } else if (inRegex) {
  481. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  482. } else if (
  483. c === 0x7C && // pipe
  484. exp.charCodeAt(i + 1) !== 0x7C &&
  485. exp.charCodeAt(i - 1) !== 0x7C &&
  486. !curly && !square && !paren
  487. ) {
  488. if (expression === undefined) {
  489. // first filter, end of expression
  490. lastFilterIndex = i + 1;
  491. expression = exp.slice(0, i).trim();
  492. } else {
  493. pushFilter();
  494. }
  495. } else {
  496. switch (c) {
  497. case 0x22: inDouble = true; break // "
  498. case 0x27: inSingle = true; break // '
  499. case 0x60: inTemplateString = true; break // `
  500. case 0x28: paren++; break // (
  501. case 0x29: paren--; break // )
  502. case 0x5B: square++; break // [
  503. case 0x5D: square--; break // ]
  504. case 0x7B: curly++; break // {
  505. case 0x7D: curly--; break // }
  506. }
  507. if (c === 0x2f) { // /
  508. var j = i - 1;
  509. var p = (void 0);
  510. // find first non-whitespace prev char
  511. for (; j >= 0; j--) {
  512. p = exp.charAt(j);
  513. if (p !== ' ') { break }
  514. }
  515. if (!p || !validDivisionCharRE.test(p)) {
  516. inRegex = true;
  517. }
  518. }
  519. }
  520. }
  521. if (expression === undefined) {
  522. expression = exp.slice(0, i).trim();
  523. } else if (lastFilterIndex !== 0) {
  524. pushFilter();
  525. }
  526. function pushFilter () {
  527. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  528. lastFilterIndex = i + 1;
  529. }
  530. if (filters) {
  531. for (i = 0; i < filters.length; i++) {
  532. expression = wrapFilter(expression, filters[i]);
  533. }
  534. }
  535. return expression
  536. }
  537. function wrapFilter (exp, filter) {
  538. var i = filter.indexOf('(');
  539. if (i < 0) {
  540. // _f: resolveFilter
  541. return ("_f(\"" + filter + "\")(" + exp + ")")
  542. } else {
  543. var name = filter.slice(0, i);
  544. var args = filter.slice(i + 1);
  545. return ("_f(\"" + name + "\")(" + exp + "," + args)
  546. }
  547. }
  548. /* */
  549. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  550. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  551. var buildRegex = cached(function (delimiters) {
  552. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  553. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  554. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  555. });
  556. function parseText (
  557. text,
  558. delimiters
  559. ) {
  560. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  561. if (!tagRE.test(text)) {
  562. return
  563. }
  564. var tokens = [];
  565. var lastIndex = tagRE.lastIndex = 0;
  566. var match, index;
  567. while ((match = tagRE.exec(text))) {
  568. index = match.index;
  569. // push text token
  570. if (index > lastIndex) {
  571. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  572. }
  573. // tag token
  574. var exp = parseFilters(match[1].trim());
  575. tokens.push(("_s(" + exp + ")"));
  576. lastIndex = index + match[0].length;
  577. }
  578. if (lastIndex < text.length) {
  579. tokens.push(JSON.stringify(text.slice(lastIndex)));
  580. }
  581. return tokens.join('+')
  582. }
  583. /* */
  584. /**
  585. * Cross-platform code generation for component v-model
  586. */
  587. function genComponentModel (
  588. el,
  589. value,
  590. modifiers
  591. ) {
  592. var ref = modifiers || {};
  593. var number = ref.number;
  594. var trim = ref.trim;
  595. var baseValueExpression = '$$v';
  596. var valueExpression = baseValueExpression;
  597. if (trim) {
  598. valueExpression =
  599. "(typeof " + baseValueExpression + " === 'string'" +
  600. "? " + baseValueExpression + ".trim()" +
  601. ": " + baseValueExpression + ")";
  602. }
  603. if (number) {
  604. valueExpression = "_n(" + valueExpression + ")";
  605. }
  606. var assignment = genAssignmentCode(value, valueExpression);
  607. el.model = {
  608. value: ("(" + value + ")"),
  609. expression: ("\"" + value + "\""),
  610. callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
  611. };
  612. }
  613. /**
  614. * Cross-platform codegen helper for generating v-model value assignment code.
  615. */
  616. function genAssignmentCode (
  617. value,
  618. assignment
  619. ) {
  620. var res = parseModel(value);
  621. if (res.key === null) {
  622. return (value + "=" + assignment)
  623. } else {
  624. return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
  625. }
  626. }
  627. /**
  628. * Parse a v-model expression into a base path and a final key segment.
  629. * Handles both dot-path and possible square brackets.
  630. *
  631. * Possible cases:
  632. *
  633. * - test
  634. * - test[key]
  635. * - test[test1[key]]
  636. * - test["a"][key]
  637. * - xxx.test[a[a].test1[key]]
  638. * - test.xxx.a["asa"][test1[key]]
  639. *
  640. */
  641. var len;
  642. var str;
  643. var chr;
  644. var index;
  645. var expressionPos;
  646. var expressionEndPos;
  647. function parseModel (val) {
  648. len = val.length;
  649. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  650. index = val.lastIndexOf('.');
  651. if (index > -1) {
  652. return {
  653. exp: val.slice(0, index),
  654. key: '"' + val.slice(index + 1) + '"'
  655. }
  656. } else {
  657. return {
  658. exp: val,
  659. key: null
  660. }
  661. }
  662. }
  663. str = val;
  664. index = expressionPos = expressionEndPos = 0;
  665. while (!eof()) {
  666. chr = next();
  667. /* istanbul ignore if */
  668. if (isStringStart(chr)) {
  669. parseString(chr);
  670. } else if (chr === 0x5B) {
  671. parseBracket(chr);
  672. }
  673. }
  674. return {
  675. exp: val.slice(0, expressionPos),
  676. key: val.slice(expressionPos + 1, expressionEndPos)
  677. }
  678. }
  679. function next () {
  680. return str.charCodeAt(++index)
  681. }
  682. function eof () {
  683. return index >= len
  684. }
  685. function isStringStart (chr) {
  686. return chr === 0x22 || chr === 0x27
  687. }
  688. function parseBracket (chr) {
  689. var inBracket = 1;
  690. expressionPos = index;
  691. while (!eof()) {
  692. chr = next();
  693. if (isStringStart(chr)) {
  694. parseString(chr);
  695. continue
  696. }
  697. if (chr === 0x5B) { inBracket++; }
  698. if (chr === 0x5D) { inBracket--; }
  699. if (inBracket === 0) {
  700. expressionEndPos = index;
  701. break
  702. }
  703. }
  704. }
  705. function parseString (chr) {
  706. var stringQuote = chr;
  707. while (!eof()) {
  708. chr = next();
  709. if (chr === stringQuote) {
  710. break
  711. }
  712. }
  713. }
  714. var ASSET_TYPES = [
  715. 'component',
  716. 'directive',
  717. 'filter'
  718. ];
  719. var LIFECYCLE_HOOKS = [
  720. 'beforeCreate',
  721. 'created',
  722. 'beforeMount',
  723. 'mounted',
  724. 'beforeUpdate',
  725. 'updated',
  726. 'beforeDestroy',
  727. 'destroyed',
  728. 'activated',
  729. 'deactivated',
  730. 'errorCaptured'
  731. ];
  732. /* */
  733. var config = ({
  734. /**
  735. * Option merge strategies (used in core/util/options)
  736. */
  737. optionMergeStrategies: Object.create(null),
  738. /**
  739. * Whether to suppress warnings.
  740. */
  741. silent: false,
  742. /**
  743. * Show production mode tip message on boot?
  744. */
  745. productionTip: process.env.NODE_ENV !== 'production',
  746. /**
  747. * Whether to enable devtools
  748. */
  749. devtools: process.env.NODE_ENV !== 'production',
  750. /**
  751. * Whether to record perf
  752. */
  753. performance: false,
  754. /**
  755. * Error handler for watcher errors
  756. */
  757. errorHandler: null,
  758. /**
  759. * Warn handler for watcher warns
  760. */
  761. warnHandler: null,
  762. /**
  763. * Ignore certain custom elements
  764. */
  765. ignoredElements: [],
  766. /**
  767. * Custom user key aliases for v-on
  768. */
  769. keyCodes: Object.create(null),
  770. /**
  771. * Check if a tag is reserved so that it cannot be registered as a
  772. * component. This is platform-dependent and may be overwritten.
  773. */
  774. isReservedTag: no,
  775. /**
  776. * Check if an attribute is reserved so that it cannot be used as a component
  777. * prop. This is platform-dependent and may be overwritten.
  778. */
  779. isReservedAttr: no,
  780. /**
  781. * Check if a tag is an unknown element.
  782. * Platform-dependent.
  783. */
  784. isUnknownElement: no,
  785. /**
  786. * Get the namespace of an element
  787. */
  788. getTagNamespace: noop,
  789. /**
  790. * Parse the real tag name for the specific platform.
  791. */
  792. parsePlatformTagName: identity,
  793. /**
  794. * Check if an attribute must be bound using property, e.g. value
  795. * Platform-dependent.
  796. */
  797. mustUseProp: no,
  798. /**
  799. * Exposed for legacy reasons
  800. */
  801. _lifecycleHooks: LIFECYCLE_HOOKS
  802. });
  803. /* */
  804. var warn$1 = noop;
  805. var tip = noop;
  806. var generateComponentTrace = (noop); // work around flow check
  807. var formatComponentName = (noop);
  808. if (process.env.NODE_ENV !== 'production') {
  809. var hasConsole = typeof console !== 'undefined';
  810. var classifyRE = /(?:^|[-_])(\w)/g;
  811. var classify = function (str) { return str
  812. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  813. .replace(/[-_]/g, ''); };
  814. warn$1 = function (msg, vm) {
  815. var trace = vm ? generateComponentTrace(vm) : '';
  816. if (config.warnHandler) {
  817. config.warnHandler.call(null, msg, vm, trace);
  818. } else if (hasConsole && (!config.silent)) {
  819. console.error(("[Vue warn]: " + msg + trace));
  820. }
  821. };
  822. tip = function (msg, vm) {
  823. if (hasConsole && (!config.silent)) {
  824. console.warn("[Vue tip]: " + msg + (
  825. vm ? generateComponentTrace(vm) : ''
  826. ));
  827. }
  828. };
  829. formatComponentName = function (vm, includeFile) {
  830. if (vm.$root === vm) {
  831. return '<Root>'
  832. }
  833. var options = typeof vm === 'function' && vm.cid != null
  834. ? vm.options
  835. : vm._isVue
  836. ? vm.$options || vm.constructor.options
  837. : vm || {};
  838. var name = options.name || options._componentTag;
  839. var file = options.__file;
  840. if (!name && file) {
  841. var match = file.match(/([^/\\]+)\.vue$/);
  842. name = match && match[1];
  843. }
  844. return (
  845. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  846. (file && includeFile !== false ? (" at " + file) : '')
  847. )
  848. };
  849. var repeat = function (str, n) {
  850. var res = '';
  851. while (n) {
  852. if (n % 2 === 1) { res += str; }
  853. if (n > 1) { str += str; }
  854. n >>= 1;
  855. }
  856. return res
  857. };
  858. generateComponentTrace = function (vm) {
  859. if (vm._isVue && vm.$parent) {
  860. var tree = [];
  861. var currentRecursiveSequence = 0;
  862. while (vm) {
  863. if (tree.length > 0) {
  864. var last = tree[tree.length - 1];
  865. if (last.constructor === vm.constructor) {
  866. currentRecursiveSequence++;
  867. vm = vm.$parent;
  868. continue
  869. } else if (currentRecursiveSequence > 0) {
  870. tree[tree.length - 1] = [last, currentRecursiveSequence];
  871. currentRecursiveSequence = 0;
  872. }
  873. }
  874. tree.push(vm);
  875. vm = vm.$parent;
  876. }
  877. return '\n\nfound in\n\n' + tree
  878. .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
  879. ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
  880. : formatComponentName(vm))); })
  881. .join('\n')
  882. } else {
  883. return ("\n\n(found in " + (formatComponentName(vm)) + ")")
  884. }
  885. };
  886. }
  887. /* */
  888. function handleError (err, vm, info) {
  889. if (vm) {
  890. var cur = vm;
  891. while ((cur = cur.$parent)) {
  892. var hooks = cur.$options.errorCaptured;
  893. if (hooks) {
  894. for (var i = 0; i < hooks.length; i++) {
  895. try {
  896. var capture = hooks[i].call(cur, err, vm, info) === false;
  897. if (capture) { return }
  898. } catch (e) {
  899. globalHandleError(e, cur, 'errorCaptured hook');
  900. }
  901. }
  902. }
  903. }
  904. }
  905. globalHandleError(err, vm, info);
  906. }
  907. function globalHandleError (err, vm, info) {
  908. if (config.errorHandler) {
  909. try {
  910. return config.errorHandler.call(null, err, vm, info)
  911. } catch (e) {
  912. logError(e, null, 'config.errorHandler');
  913. }
  914. }
  915. logError(err, vm, info);
  916. }
  917. function logError (err, vm, info) {
  918. if (process.env.NODE_ENV !== 'production') {
  919. warn$1(("Error in " + info + ": \"" + (err.toString()) + "\""), vm);
  920. }
  921. /* istanbul ignore else */
  922. if (inBrowser && typeof console !== 'undefined') {
  923. console.error(err);
  924. } else {
  925. throw err
  926. }
  927. }
  928. /* */
  929. /* globals MessageChannel */
  930. // can we use __proto__?
  931. var hasProto = '__proto__' in {};
  932. // Browser environment sniffing
  933. var inBrowser = typeof window !== 'undefined';
  934. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  935. var isIE = UA && /msie|trident/.test(UA);
  936. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  937. var isEdge = UA && UA.indexOf('edge/') > 0;
  938. var isAndroid = UA && UA.indexOf('android') > 0;
  939. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  940. var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
  941. // Firefox has a "watch" function on Object.prototype...
  942. var nativeWatch = ({}).watch;
  943. if (inBrowser) {
  944. try {
  945. var opts = {};
  946. Object.defineProperty(opts, 'passive', ({
  947. get: function get () {
  948. /* istanbul ignore next */
  949. }
  950. })); // https://github.com/facebook/flow/issues/285
  951. window.addEventListener('test-passive', null, opts);
  952. } catch (e) {}
  953. }
  954. // this needs to be lazy-evaled because vue may be required before
  955. // vue-server-renderer can set VUE_ENV
  956. var _isServer;
  957. var isServerRendering = function () {
  958. if (_isServer === undefined) {
  959. /* istanbul ignore if */
  960. if (!inBrowser && typeof global !== 'undefined') {
  961. // detect presence of vue-server-renderer and avoid
  962. // Webpack shimming the process
  963. _isServer = global['process'].env.VUE_ENV === 'server';
  964. } else {
  965. _isServer = false;
  966. }
  967. }
  968. return _isServer
  969. };
  970. // detect devtools
  971. /* istanbul ignore next */
  972. function isNative (Ctor) {
  973. return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
  974. }
  975. var hasSymbol =
  976. typeof Symbol !== 'undefined' && isNative(Symbol) &&
  977. typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
  978. /**
  979. * Defer a task to execute it asynchronously.
  980. */
  981. var nextTick = (function () {
  982. var callbacks = [];
  983. var pending = false;
  984. var timerFunc;
  985. function nextTickHandler () {
  986. pending = false;
  987. var copies = callbacks.slice(0);
  988. callbacks.length = 0;
  989. for (var i = 0; i < copies.length; i++) {
  990. copies[i]();
  991. }
  992. }
  993. // An asynchronous deferring mechanism.
  994. // In pre 2.4, we used to use microtasks (Promise/MutationObserver)
  995. // but microtasks actually has too high a priority and fires in between
  996. // supposedly sequential events (e.g. #4521, #6690) or even between
  997. // bubbling of the same event (#6566). Technically setImmediate should be
  998. // the ideal choice, but it's not available everywhere; and the only polyfill
  999. // that consistently queues the callback after all DOM events triggered in the
  1000. // same loop is by using MessageChannel.
  1001. /* istanbul ignore if */
  1002. if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
  1003. timerFunc = function () {
  1004. setImmediate(nextTickHandler);
  1005. };
  1006. } else if (typeof MessageChannel !== 'undefined' && (
  1007. isNative(MessageChannel) ||
  1008. // PhantomJS
  1009. MessageChannel.toString() === '[object MessageChannelConstructor]'
  1010. )) {
  1011. var channel = new MessageChannel();
  1012. var port = channel.port2;
  1013. channel.port1.onmessage = nextTickHandler;
  1014. timerFunc = function () {
  1015. port.postMessage(1);
  1016. };
  1017. } else
  1018. /* istanbul ignore next */
  1019. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  1020. // use microtask in non-DOM environments, e.g. Weex
  1021. var p = Promise.resolve();
  1022. timerFunc = function () {
  1023. p.then(nextTickHandler);
  1024. };
  1025. } else {
  1026. // fallback to setTimeout
  1027. timerFunc = function () {
  1028. setTimeout(nextTickHandler, 0);
  1029. };
  1030. }
  1031. return function queueNextTick (cb, ctx) {
  1032. var _resolve;
  1033. callbacks.push(function () {
  1034. if (cb) {
  1035. try {
  1036. cb.call(ctx);
  1037. } catch (e) {
  1038. handleError(e, ctx, 'nextTick');
  1039. }
  1040. } else if (_resolve) {
  1041. _resolve(ctx);
  1042. }
  1043. });
  1044. if (!pending) {
  1045. pending = true;
  1046. timerFunc();
  1047. }
  1048. // $flow-disable-line
  1049. if (!cb && typeof Promise !== 'undefined') {
  1050. return new Promise(function (resolve, reject) {
  1051. _resolve = resolve;
  1052. })
  1053. }
  1054. }
  1055. })();
  1056. var _Set;
  1057. /* istanbul ignore if */ // $flow-disable-line
  1058. if (typeof Set !== 'undefined' && isNative(Set)) {
  1059. // use native Set when available.
  1060. _Set = Set;
  1061. } else {
  1062. // a non-standard Set polyfill that only works with primitive keys.
  1063. _Set = (function () {
  1064. function Set () {
  1065. this.set = Object.create(null);
  1066. }
  1067. Set.prototype.has = function has (key) {
  1068. return this.set[key] === true
  1069. };
  1070. Set.prototype.add = function add (key) {
  1071. this.set[key] = true;
  1072. };
  1073. Set.prototype.clear = function clear () {
  1074. this.set = Object.create(null);
  1075. };
  1076. return Set;
  1077. }());
  1078. }
  1079. /* */
  1080. function baseWarn (msg) {
  1081. console.error(("[Vue compiler]: " + msg));
  1082. }
  1083. function pluckModuleFunction (
  1084. modules,
  1085. key
  1086. ) {
  1087. return modules
  1088. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  1089. : []
  1090. }
  1091. function addProp (el, name, value) {
  1092. (el.props || (el.props = [])).push({ name: name, value: value });
  1093. }
  1094. function addAttr (el, name, value) {
  1095. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  1096. }
  1097. function addDirective (
  1098. el,
  1099. name,
  1100. rawName,
  1101. value,
  1102. arg,
  1103. modifiers
  1104. ) {
  1105. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  1106. }
  1107. function addHandler (
  1108. el,
  1109. name,
  1110. value,
  1111. modifiers,
  1112. important,
  1113. warn
  1114. ) {
  1115. // warn prevent and passive modifier
  1116. /* istanbul ignore if */
  1117. if (
  1118. process.env.NODE_ENV !== 'production' && warn &&
  1119. modifiers && modifiers.prevent && modifiers.passive
  1120. ) {
  1121. warn(
  1122. 'passive and prevent can\'t be used together. ' +
  1123. 'Passive handler can\'t prevent default event.'
  1124. );
  1125. }
  1126. // check capture modifier
  1127. if (modifiers && modifiers.capture) {
  1128. delete modifiers.capture;
  1129. name = '!' + name; // mark the event as captured
  1130. }
  1131. if (modifiers && modifiers.once) {
  1132. delete modifiers.once;
  1133. name = '~' + name; // mark the event as once
  1134. }
  1135. /* istanbul ignore if */
  1136. if (modifiers && modifiers.passive) {
  1137. delete modifiers.passive;
  1138. name = '&' + name; // mark the event as passive
  1139. }
  1140. var events;
  1141. if (modifiers && modifiers.native) {
  1142. delete modifiers.native;
  1143. events = el.nativeEvents || (el.nativeEvents = {});
  1144. } else {
  1145. events = el.events || (el.events = {});
  1146. }
  1147. var newHandler = { value: value, modifiers: modifiers };
  1148. var handlers = events[name];
  1149. /* istanbul ignore if */
  1150. if (Array.isArray(handlers)) {
  1151. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  1152. } else if (handlers) {
  1153. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  1154. } else {
  1155. events[name] = newHandler;
  1156. }
  1157. }
  1158. function getBindingAttr (
  1159. el,
  1160. name,
  1161. getStatic
  1162. ) {
  1163. var dynamicValue =
  1164. getAndRemoveAttr(el, ':' + name) ||
  1165. getAndRemoveAttr(el, 'v-bind:' + name);
  1166. if (dynamicValue != null) {
  1167. return parseFilters(dynamicValue)
  1168. } else if (getStatic !== false) {
  1169. var staticValue = getAndRemoveAttr(el, name);
  1170. if (staticValue != null) {
  1171. return JSON.stringify(staticValue)
  1172. }
  1173. }
  1174. }
  1175. // note: this only removes the attr from the Array (attrsList) so that it
  1176. // doesn't get processed by processAttrs.
  1177. // By default it does NOT remove it from the map (attrsMap) because the map is
  1178. // needed during codegen.
  1179. function getAndRemoveAttr (
  1180. el,
  1181. name,
  1182. removeFromMap
  1183. ) {
  1184. var val;
  1185. if ((val = el.attrsMap[name]) != null) {
  1186. var list = el.attrsList;
  1187. for (var i = 0, l = list.length; i < l; i++) {
  1188. if (list[i].name === name) {
  1189. list.splice(i, 1);
  1190. break
  1191. }
  1192. }
  1193. }
  1194. if (removeFromMap) {
  1195. delete el.attrsMap[name];
  1196. }
  1197. return val
  1198. }
  1199. /* */
  1200. var onRE = /^@|^v-on:/;
  1201. var dirRE = /^v-|^@|^:/;
  1202. var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
  1203. var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
  1204. var argRE = /:(.*)$/;
  1205. var bindRE = /^:|^v-bind:/;
  1206. var modifierRE = /\.[^.]+/g;
  1207. var decodeHTMLCached = cached(he.decode);
  1208. // configurable state
  1209. var warn;
  1210. var delimiters;
  1211. var transforms;
  1212. var preTransforms;
  1213. var postTransforms;
  1214. var platformIsPreTag;
  1215. var platformMustUseProp;
  1216. var platformGetTagNamespace;
  1217. function createASTElement (
  1218. tag,
  1219. attrs,
  1220. parent
  1221. ) {
  1222. return {
  1223. type: 1,
  1224. tag: tag,
  1225. attrsList: attrs,
  1226. attrsMap: makeAttrsMap(attrs),
  1227. parent: parent,
  1228. children: []
  1229. }
  1230. }
  1231. /**
  1232. * Convert HTML string to AST.
  1233. */
  1234. function parse (
  1235. template,
  1236. options
  1237. ) {
  1238. warn = options.warn || baseWarn;
  1239. platformIsPreTag = options.isPreTag || no;
  1240. platformMustUseProp = options.mustUseProp || no;
  1241. platformGetTagNamespace = options.getTagNamespace || no;
  1242. transforms = pluckModuleFunction(options.modules, 'transformNode');
  1243. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  1244. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  1245. delimiters = options.delimiters;
  1246. var stack = [];
  1247. var preserveWhitespace = options.preserveWhitespace !== false;
  1248. var root;
  1249. var currentParent;
  1250. var inVPre = false;
  1251. var inPre = false;
  1252. var warned = false;
  1253. function warnOnce (msg) {
  1254. if (!warned) {
  1255. warned = true;
  1256. warn(msg);
  1257. }
  1258. }
  1259. function endPre (element) {
  1260. // check pre state
  1261. if (element.pre) {
  1262. inVPre = false;
  1263. }
  1264. if (platformIsPreTag(element.tag)) {
  1265. inPre = false;
  1266. }
  1267. }
  1268. parseHTML(template, {
  1269. warn: warn,
  1270. expectHTML: options.expectHTML,
  1271. isUnaryTag: options.isUnaryTag,
  1272. canBeLeftOpenTag: options.canBeLeftOpenTag,
  1273. shouldDecodeNewlines: options.shouldDecodeNewlines,
  1274. shouldKeepComment: options.comments,
  1275. start: function start (tag, attrs, unary) {
  1276. // check namespace.
  1277. // inherit parent ns if there is one
  1278. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  1279. // handle IE svg bug
  1280. /* istanbul ignore if */
  1281. if (isIE && ns === 'svg') {
  1282. attrs = guardIESVGBug(attrs);
  1283. }
  1284. var element = createASTElement(tag, attrs, currentParent);
  1285. if (ns) {
  1286. element.ns = ns;
  1287. }
  1288. if (isForbiddenTag(element) && !isServerRendering()) {
  1289. element.forbidden = true;
  1290. process.env.NODE_ENV !== 'production' && warn(
  1291. 'Templates should only be responsible for mapping the state to the ' +
  1292. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  1293. "<" + tag + ">" + ', as they will not be parsed.'
  1294. );
  1295. }
  1296. // apply pre-transforms
  1297. for (var i = 0; i < preTransforms.length; i++) {
  1298. element = preTransforms[i](element, options) || element;
  1299. }
  1300. if (!inVPre) {
  1301. processPre(element);
  1302. if (element.pre) {
  1303. inVPre = true;
  1304. }
  1305. }
  1306. if (platformIsPreTag(element.tag)) {
  1307. inPre = true;
  1308. }
  1309. if (inVPre) {
  1310. processRawAttrs(element);
  1311. } else if (!element.processed) {
  1312. // structural directives
  1313. processFor(element);
  1314. processIf(element);
  1315. processOnce(element);
  1316. // element-scope stuff
  1317. processElement(element, options);
  1318. }
  1319. function checkRootConstraints (el) {
  1320. if (process.env.NODE_ENV !== 'production') {
  1321. if (el.tag === 'slot' || el.tag === 'template') {
  1322. warnOnce(
  1323. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  1324. 'contain multiple nodes.'
  1325. );
  1326. }
  1327. if (el.attrsMap.hasOwnProperty('v-for')) {
  1328. warnOnce(
  1329. 'Cannot use v-for on stateful component root element because ' +
  1330. 'it renders multiple elements.'
  1331. );
  1332. }
  1333. }
  1334. }
  1335. // tree management
  1336. if (!root) {
  1337. root = element;
  1338. checkRootConstraints(root);
  1339. } else if (!stack.length) {
  1340. // allow root elements with v-if, v-else-if and v-else
  1341. if (root.if && (element.elseif || element.else)) {
  1342. checkRootConstraints(element);
  1343. addIfCondition(root, {
  1344. exp: element.elseif,
  1345. block: element
  1346. });
  1347. } else if (process.env.NODE_ENV !== 'production') {
  1348. warnOnce(
  1349. "Component template should contain exactly one root element. " +
  1350. "If you are using v-if on multiple elements, " +
  1351. "use v-else-if to chain them instead."
  1352. );
  1353. }
  1354. }
  1355. if (currentParent && !element.forbidden) {
  1356. if (element.elseif || element.else) {
  1357. processIfConditions(element, currentParent);
  1358. } else if (element.slotScope) { // scoped slot
  1359. currentParent.plain = false;
  1360. var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  1361. } else {
  1362. currentParent.children.push(element);
  1363. element.parent = currentParent;
  1364. }
  1365. }
  1366. if (!unary) {
  1367. currentParent = element;
  1368. stack.push(element);
  1369. } else {
  1370. endPre(element);
  1371. }
  1372. // apply post-transforms
  1373. for (var i$1 = 0; i$1 < postTransforms.length; i$1++) {
  1374. postTransforms[i$1](element, options);
  1375. }
  1376. },
  1377. end: function end () {
  1378. // remove trailing whitespace
  1379. var element = stack[stack.length - 1];
  1380. var lastNode = element.children[element.children.length - 1];
  1381. if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
  1382. element.children.pop();
  1383. }
  1384. // pop stack
  1385. stack.length -= 1;
  1386. currentParent = stack[stack.length - 1];
  1387. endPre(element);
  1388. },
  1389. chars: function chars (text) {
  1390. if (!currentParent) {
  1391. if (process.env.NODE_ENV !== 'production') {
  1392. if (text === template) {
  1393. warnOnce(
  1394. 'Component template requires a root element, rather than just text.'
  1395. );
  1396. } else if ((text = text.trim())) {
  1397. warnOnce(
  1398. ("text \"" + text + "\" outside root element will be ignored.")
  1399. );
  1400. }
  1401. }
  1402. return
  1403. }
  1404. // IE textarea placeholder bug
  1405. /* istanbul ignore if */
  1406. if (isIE &&
  1407. currentParent.tag === 'textarea' &&
  1408. currentParent.attrsMap.placeholder === text
  1409. ) {
  1410. return
  1411. }
  1412. var children = currentParent.children;
  1413. text = inPre || text.trim()
  1414. ? isTextTag(currentParent) ? text : decodeHTMLCached(text)
  1415. // only preserve whitespace if its not right after a starting tag
  1416. : preserveWhitespace && children.length ? ' ' : '';
  1417. if (text) {
  1418. var expression;
  1419. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  1420. children.push({
  1421. type: 2,
  1422. expression: expression,
  1423. text: text
  1424. });
  1425. } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
  1426. children.push({
  1427. type: 3,
  1428. text: text
  1429. });
  1430. }
  1431. }
  1432. },
  1433. comment: function comment (text) {
  1434. currentParent.children.push({
  1435. type: 3,
  1436. text: text,
  1437. isComment: true
  1438. });
  1439. }
  1440. });
  1441. return root
  1442. }
  1443. function processPre (el) {
  1444. if (getAndRemoveAttr(el, 'v-pre') != null) {
  1445. el.pre = true;
  1446. }
  1447. }
  1448. function processRawAttrs (el) {
  1449. var l = el.attrsList.length;
  1450. if (l) {
  1451. var attrs = el.attrs = new Array(l);
  1452. for (var i = 0; i < l; i++) {
  1453. attrs[i] = {
  1454. name: el.attrsList[i].name,
  1455. value: JSON.stringify(el.attrsList[i].value)
  1456. };
  1457. }
  1458. } else if (!el.pre) {
  1459. // non root node in pre blocks with no attributes
  1460. el.plain = true;
  1461. }
  1462. }
  1463. function processElement (element, options) {
  1464. processKey(element);
  1465. // determine whether this is a plain element after
  1466. // removing structural attributes
  1467. element.plain = !element.key && !element.attrsList.length;
  1468. processRef(element);
  1469. processSlot(element);
  1470. processComponent(element);
  1471. for (var i = 0; i < transforms.length; i++) {
  1472. element = transforms[i](element, options) || element;
  1473. }
  1474. processAttrs(element);
  1475. }
  1476. function processKey (el) {
  1477. var exp = getBindingAttr(el, 'key');
  1478. if (exp) {
  1479. if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
  1480. warn("<template> cannot be keyed. Place the key on real elements instead.");
  1481. }
  1482. el.key = exp;
  1483. }
  1484. }
  1485. function processRef (el) {
  1486. var ref = getBindingAttr(el, 'ref');
  1487. if (ref) {
  1488. el.ref = ref;
  1489. el.refInFor = checkInFor(el);
  1490. }
  1491. }
  1492. function processFor (el) {
  1493. var exp;
  1494. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  1495. var inMatch = exp.match(forAliasRE);
  1496. if (!inMatch) {
  1497. process.env.NODE_ENV !== 'production' && warn(
  1498. ("Invalid v-for expression: " + exp)
  1499. );
  1500. return
  1501. }
  1502. el.for = inMatch[2].trim();
  1503. var alias = inMatch[1].trim();
  1504. var iteratorMatch = alias.match(forIteratorRE);
  1505. if (iteratorMatch) {
  1506. el.alias = iteratorMatch[1].trim();
  1507. el.iterator1 = iteratorMatch[2].trim();
  1508. if (iteratorMatch[3]) {
  1509. el.iterator2 = iteratorMatch[3].trim();
  1510. }
  1511. } else {
  1512. el.alias = alias;
  1513. }
  1514. }
  1515. }
  1516. function processIf (el) {
  1517. var exp = getAndRemoveAttr(el, 'v-if');
  1518. if (exp) {
  1519. el.if = exp;
  1520. addIfCondition(el, {
  1521. exp: exp,
  1522. block: el
  1523. });
  1524. } else {
  1525. if (getAndRemoveAttr(el, 'v-else') != null) {
  1526. el.else = true;
  1527. }
  1528. var elseif = getAndRemoveAttr(el, 'v-else-if');
  1529. if (elseif) {
  1530. el.elseif = elseif;
  1531. }
  1532. }
  1533. }
  1534. function processIfConditions (el, parent) {
  1535. var prev = findPrevElement(parent.children);
  1536. if (prev && prev.if) {
  1537. addIfCondition(prev, {
  1538. exp: el.elseif,
  1539. block: el
  1540. });
  1541. } else if (process.env.NODE_ENV !== 'production') {
  1542. warn(
  1543. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  1544. "used on element <" + (el.tag) + "> without corresponding v-if."
  1545. );
  1546. }
  1547. }
  1548. function findPrevElement (children) {
  1549. var i = children.length;
  1550. while (i--) {
  1551. if (children[i].type === 1) {
  1552. return children[i]
  1553. } else {
  1554. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  1555. warn(
  1556. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  1557. "will be ignored."
  1558. );
  1559. }
  1560. children.pop();
  1561. }
  1562. }
  1563. }
  1564. function addIfCondition (el, condition) {
  1565. if (!el.ifConditions) {
  1566. el.ifConditions = [];
  1567. }
  1568. el.ifConditions.push(condition);
  1569. }
  1570. function processOnce (el) {
  1571. var once$$1 = getAndRemoveAttr(el, 'v-once');
  1572. if (once$$1 != null) {
  1573. el.once = true;
  1574. }
  1575. }
  1576. function processSlot (el) {
  1577. if (el.tag === 'slot') {
  1578. el.slotName = getBindingAttr(el, 'name');
  1579. if (process.env.NODE_ENV !== 'production' && el.key) {
  1580. warn(
  1581. "`key` does not work on <slot> because slots are abstract outlets " +
  1582. "and can possibly expand into multiple elements. " +
  1583. "Use the key on a wrapping element instead."
  1584. );
  1585. }
  1586. } else {
  1587. var slotScope;
  1588. if (el.tag === 'template') {
  1589. slotScope = getAndRemoveAttr(el, 'scope');
  1590. /* istanbul ignore if */
  1591. if (process.env.NODE_ENV !== 'production' && slotScope) {
  1592. warn(
  1593. "the \"scope\" attribute for scoped slots have been deprecated and " +
  1594. "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
  1595. "can also be used on plain elements in addition to <template> to " +
  1596. "denote scoped slots.",
  1597. true
  1598. );
  1599. }
  1600. el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
  1601. } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
  1602. el.slotScope = slotScope;
  1603. }
  1604. var slotTarget = getBindingAttr(el, 'slot');
  1605. if (slotTarget) {
  1606. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  1607. // preserve slot as an attribute for native shadow DOM compat
  1608. // only for non-scoped slots.
  1609. if (!el.slotScope) {
  1610. addAttr(el, 'slot', slotTarget);
  1611. }
  1612. }
  1613. }
  1614. }
  1615. function processComponent (el) {
  1616. var binding;
  1617. if ((binding = getBindingAttr(el, 'is'))) {
  1618. el.component = binding;
  1619. }
  1620. if (getAndRemoveAttr(el, 'inline-template') != null) {
  1621. el.inlineTemplate = true;
  1622. }
  1623. }
  1624. function processAttrs (el) {
  1625. var list = el.attrsList;
  1626. var i, l, name, rawName, value, modifiers, isProp;
  1627. for (i = 0, l = list.length; i < l; i++) {
  1628. name = rawName = list[i].name;
  1629. value = list[i].value;
  1630. if (dirRE.test(name)) {
  1631. // mark element as dynamic
  1632. el.hasBindings = true;
  1633. // modifiers
  1634. modifiers = parseModifiers(name);
  1635. if (modifiers) {
  1636. name = name.replace(modifierRE, '');
  1637. }
  1638. if (bindRE.test(name)) { // v-bind
  1639. name = name.replace(bindRE, '');
  1640. value = parseFilters(value);
  1641. isProp = false;
  1642. if (modifiers) {
  1643. if (modifiers.prop) {
  1644. isProp = true;
  1645. name = camelize(name);
  1646. if (name === 'innerHtml') { name = 'innerHTML'; }
  1647. }
  1648. if (modifiers.camel) {
  1649. name = camelize(name);
  1650. }
  1651. if (modifiers.sync) {
  1652. addHandler(
  1653. el,
  1654. ("update:" + (camelize(name))),
  1655. genAssignmentCode(value, "$event")
  1656. );
  1657. }
  1658. }
  1659. if (isProp || (
  1660. !el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
  1661. )) {
  1662. addProp(el, name, value);
  1663. } else {
  1664. addAttr(el, name, value);
  1665. }
  1666. } else if (onRE.test(name)) { // v-on
  1667. name = name.replace(onRE, '');
  1668. addHandler(el, name, value, modifiers, false, warn);
  1669. } else { // normal directives
  1670. name = name.replace(dirRE, '');
  1671. // parse arg
  1672. var argMatch = name.match(argRE);
  1673. var arg = argMatch && argMatch[1];
  1674. if (arg) {
  1675. name = name.slice(0, -(arg.length + 1));
  1676. }
  1677. addDirective(el, name, rawName, value, arg, modifiers);
  1678. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  1679. checkForAliasModel(el, value);
  1680. }
  1681. }
  1682. } else {
  1683. // literal attribute
  1684. if (process.env.NODE_ENV !== 'production') {
  1685. var expression = parseText(value, delimiters);
  1686. if (expression) {
  1687. warn(
  1688. name + "=\"" + value + "\": " +
  1689. 'Interpolation inside attributes has been removed. ' +
  1690. 'Use v-bind or the colon shorthand instead. For example, ' +
  1691. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  1692. );
  1693. }
  1694. }
  1695. addAttr(el, name, JSON.stringify(value));
  1696. }
  1697. }
  1698. }
  1699. function checkInFor (el) {
  1700. var parent = el;
  1701. while (parent) {
  1702. if (parent.for !== undefined) {
  1703. return true
  1704. }
  1705. parent = parent.parent;
  1706. }
  1707. return false
  1708. }
  1709. function parseModifiers (name) {
  1710. var match = name.match(modifierRE);
  1711. if (match) {
  1712. var ret = {};
  1713. match.forEach(function (m) { ret[m.slice(1)] = true; });
  1714. return ret
  1715. }
  1716. }
  1717. function makeAttrsMap (attrs) {
  1718. var map = {};
  1719. for (var i = 0, l = attrs.length; i < l; i++) {
  1720. if (
  1721. process.env.NODE_ENV !== 'production' &&
  1722. map[attrs[i].name] && !isIE && !isEdge
  1723. ) {
  1724. warn('duplicate attribute: ' + attrs[i].name);
  1725. }
  1726. map[attrs[i].name] = attrs[i].value;
  1727. }
  1728. return map
  1729. }
  1730. // for script (e.g. type="x/template") or style, do not decode content
  1731. function isTextTag (el) {
  1732. return el.tag === 'script' || el.tag === 'style'
  1733. }
  1734. function isForbiddenTag (el) {
  1735. return (
  1736. el.tag === 'style' ||
  1737. (el.tag === 'script' && (
  1738. !el.attrsMap.type ||
  1739. el.attrsMap.type === 'text/javascript'
  1740. ))
  1741. )
  1742. }
  1743. var ieNSBug = /^xmlns:NS\d+/;
  1744. var ieNSPrefix = /^NS\d+:/;
  1745. /* istanbul ignore next */
  1746. function guardIESVGBug (attrs) {
  1747. var res = [];
  1748. for (var i = 0; i < attrs.length; i++) {
  1749. var attr = attrs[i];
  1750. if (!ieNSBug.test(attr.name)) {
  1751. attr.name = attr.name.replace(ieNSPrefix, '');
  1752. res.push(attr);
  1753. }
  1754. }
  1755. return res
  1756. }
  1757. function checkForAliasModel (el, value) {
  1758. var _el = el;
  1759. while (_el) {
  1760. if (_el.for && _el.alias === value) {
  1761. warn(
  1762. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  1763. "You are binding v-model directly to a v-for iteration alias. " +
  1764. "This will not be able to modify the v-for source array because " +
  1765. "writing to the alias is like modifying a function local variable. " +
  1766. "Consider using an array of objects and use v-model on an object property instead."
  1767. );
  1768. }
  1769. _el = _el.parent;
  1770. }
  1771. }
  1772. /* */
  1773. var isStaticKey;
  1774. var isPlatformReservedTag;
  1775. var genStaticKeysCached = cached(genStaticKeys$1);
  1776. /**
  1777. * Goal of the optimizer: walk the generated template AST tree
  1778. * and detect sub-trees that are purely static, i.e. parts of
  1779. * the DOM that never needs to change.
  1780. *
  1781. * Once we detect these sub-trees, we can:
  1782. *
  1783. * 1. Hoist them into constants, so that we no longer need to
  1784. * create fresh nodes for them on each re-render;
  1785. * 2. Completely skip them in the patching process.
  1786. */
  1787. function optimize (root, options) {
  1788. if (!root) { return }
  1789. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  1790. isPlatformReservedTag = options.isReservedTag || no;
  1791. // first pass: mark all non-static nodes.
  1792. markStatic(root);
  1793. // second pass: mark static roots.
  1794. markStaticRoots(root, false);
  1795. }
  1796. function genStaticKeys$1 (keys) {
  1797. return makeMap(
  1798. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  1799. (keys ? ',' + keys : '')
  1800. )
  1801. }
  1802. function markStatic (node) {
  1803. node.static = isStatic(node);
  1804. if (node.type === 1) {
  1805. // do not make component slot content static. this avoids
  1806. // 1. components not able to mutate slot nodes
  1807. // 2. static slot content fails for hot-reloading
  1808. if (
  1809. !isPlatformReservedTag(node.tag) &&
  1810. node.tag !== 'slot' &&
  1811. node.attrsMap['inline-template'] == null
  1812. ) {
  1813. return
  1814. }
  1815. for (var i = 0, l = node.children.length; i < l; i++) {
  1816. var child = node.children[i];
  1817. markStatic(child);
  1818. if (!child.static) {
  1819. node.static = false;
  1820. }
  1821. }
  1822. if (node.ifConditions) {
  1823. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  1824. var block = node.ifConditions[i$1].block;
  1825. markStatic(block);
  1826. if (!block.static) {
  1827. node.static = false;
  1828. }
  1829. }
  1830. }
  1831. }
  1832. }
  1833. function markStaticRoots (node, isInFor) {
  1834. if (node.type === 1) {
  1835. if (node.static || node.once) {
  1836. node.staticInFor = isInFor;
  1837. }
  1838. // For a node to qualify as a static root, it should have children that
  1839. // are not just static text. Otherwise the cost of hoisting out will
  1840. // outweigh the benefits and it's better off to just always render it fresh.
  1841. if (node.static && node.children.length && !(
  1842. node.children.length === 1 &&
  1843. node.children[0].type === 3
  1844. )) {
  1845. node.staticRoot = true;
  1846. return
  1847. } else {
  1848. node.staticRoot = false;
  1849. }
  1850. if (node.children) {
  1851. for (var i = 0, l = node.children.length; i < l; i++) {
  1852. markStaticRoots(node.children[i], isInFor || !!node.for);
  1853. }
  1854. }
  1855. if (node.ifConditions) {
  1856. for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
  1857. markStaticRoots(node.ifConditions[i$1].block, isInFor);
  1858. }
  1859. }
  1860. }
  1861. }
  1862. function isStatic (node) {
  1863. if (node.type === 2) { // expression
  1864. return false
  1865. }
  1866. if (node.type === 3) { // text
  1867. return true
  1868. }
  1869. return !!(node.pre || (
  1870. !node.hasBindings && // no dynamic bindings
  1871. !node.if && !node.for && // not v-if or v-for or v-else
  1872. !isBuiltInTag(node.tag) && // not a built-in
  1873. isPlatformReservedTag(node.tag) && // not a component
  1874. !isDirectChildOfTemplateFor(node) &&
  1875. Object.keys(node).every(isStaticKey)
  1876. ))
  1877. }
  1878. function isDirectChildOfTemplateFor (node) {
  1879. while (node.parent) {
  1880. node = node.parent;
  1881. if (node.tag !== 'template') {
  1882. return false
  1883. }
  1884. if (node.for) {
  1885. return true
  1886. }
  1887. }
  1888. return false
  1889. }
  1890. /* */
  1891. var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  1892. var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
  1893. // keyCode aliases
  1894. var keyCodes = {
  1895. esc: 27,
  1896. tab: 9,
  1897. enter: 13,
  1898. space: 32,
  1899. up: 38,
  1900. left: 37,
  1901. right: 39,
  1902. down: 40,
  1903. 'delete': [8, 46]
  1904. };
  1905. // #4868: modifiers that prevent the execution of the listener
  1906. // need to explicitly return null so that we can determine whether to remove
  1907. // the listener for .once
  1908. var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
  1909. var modifierCode = {
  1910. stop: '$event.stopPropagation();',
  1911. prevent: '$event.preventDefault();',
  1912. self: genGuard("$event.target !== $event.currentTarget"),
  1913. ctrl: genGuard("!$event.ctrlKey"),
  1914. shift: genGuard("!$event.shiftKey"),
  1915. alt: genGuard("!$event.altKey"),
  1916. meta: genGuard("!$event.metaKey"),
  1917. left: genGuard("'button' in $event && $event.button !== 0"),
  1918. middle: genGuard("'button' in $event && $event.button !== 1"),
  1919. right: genGuard("'button' in $event && $event.button !== 2")
  1920. };
  1921. function genHandlers (
  1922. events,
  1923. isNative,
  1924. warn
  1925. ) {
  1926. var res = isNative ? 'nativeOn:{' : 'on:{';
  1927. for (var name in events) {
  1928. var handler = events[name];
  1929. // #5330: warn click.right, since right clicks do not actually fire click events.
  1930. if (process.env.NODE_ENV !== 'production' &&
  1931. name === 'click' &&
  1932. handler && handler.modifiers && handler.modifiers.right
  1933. ) {
  1934. warn(
  1935. "Use \"contextmenu\" instead of \"click.right\" since right clicks " +
  1936. "do not actually fire \"click\" events."
  1937. );
  1938. }
  1939. res += "\"" + name + "\":" + (genHandler(name, handler)) + ",";
  1940. }
  1941. return res.slice(0, -1) + '}'
  1942. }
  1943. function genHandler (
  1944. name,
  1945. handler
  1946. ) {
  1947. if (!handler) {
  1948. return 'function(){}'
  1949. }
  1950. if (Array.isArray(handler)) {
  1951. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  1952. }
  1953. var isMethodPath = simplePathRE.test(handler.value);
  1954. var isFunctionExpression = fnExpRE.test(handler.value);
  1955. if (!handler.modifiers) {
  1956. return isMethodPath || isFunctionExpression
  1957. ? handler.value
  1958. : ("function($event){" + (handler.value) + "}") // inline statement
  1959. } else {
  1960. var code = '';
  1961. var genModifierCode = '';
  1962. var keys = [];
  1963. for (var key in handler.modifiers) {
  1964. if (modifierCode[key]) {
  1965. genModifierCode += modifierCode[key];
  1966. // left/right
  1967. if (keyCodes[key]) {
  1968. keys.push(key);
  1969. }
  1970. } else if (key === 'exact') {
  1971. var modifiers = (handler.modifiers);
  1972. genModifierCode += genGuard(
  1973. ['ctrl', 'shift', 'alt', 'meta']
  1974. .filter(function (keyModifier) { return !modifiers[keyModifier]; })
  1975. .map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
  1976. .join('||')
  1977. );
  1978. } else {
  1979. keys.push(key);
  1980. }
  1981. }
  1982. if (keys.length) {
  1983. code += genKeyFilter(keys);
  1984. }
  1985. // Make sure modifiers like prevent and stop get executed after key filtering
  1986. if (genModifierCode) {
  1987. code += genModifierCode;
  1988. }
  1989. var handlerCode = isMethodPath
  1990. ? handler.value + '($event)'
  1991. : isFunctionExpression
  1992. ? ("(" + (handler.value) + ")($event)")
  1993. : handler.value;
  1994. return ("function($event){" + code + handlerCode + "}")
  1995. }
  1996. }
  1997. function genKeyFilter (keys) {
  1998. return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
  1999. }
  2000. function genFilterCode (key) {
  2001. var keyVal = parseInt(key, 10);
  2002. if (keyVal) {
  2003. return ("$event.keyCode!==" + keyVal)
  2004. }
  2005. var code = keyCodes[key];
  2006. return (
  2007. "_k($event.keyCode," +
  2008. (JSON.stringify(key)) + "," +
  2009. (JSON.stringify(code)) + "," +
  2010. "$event.key)"
  2011. )
  2012. }
  2013. /* */
  2014. var emptyObject = Object.freeze({});
  2015. /**
  2016. * Check if a string starts with $ or _
  2017. */
  2018. /**
  2019. * Define a property.
  2020. */
  2021. function def (obj, key, val, enumerable) {
  2022. Object.defineProperty(obj, key, {
  2023. value: val,
  2024. enumerable: !!enumerable,
  2025. writable: true,
  2026. configurable: true
  2027. });
  2028. }
  2029. /* */
  2030. var uid = 0;
  2031. /**
  2032. * A dep is an observable that can have multiple
  2033. * directives subscribing to it.
  2034. */
  2035. var Dep = function Dep () {
  2036. this.id = uid++;
  2037. this.subs = [];
  2038. };
  2039. Dep.prototype.addSub = function addSub (sub) {
  2040. this.subs.push(sub);
  2041. };
  2042. Dep.prototype.removeSub = function removeSub (sub) {
  2043. remove(this.subs, sub);
  2044. };
  2045. Dep.prototype.depend = function depend () {
  2046. if (Dep.target) {
  2047. Dep.target.addDep(this);
  2048. }
  2049. };
  2050. Dep.prototype.notify = function notify () {
  2051. // stabilize the subscriber list first
  2052. var subs = this.subs.slice();
  2053. for (var i = 0, l = subs.length; i < l; i++) {
  2054. subs[i].update();
  2055. }
  2056. };
  2057. // the current target watcher being evaluated.
  2058. // this is globally unique because there could be only one
  2059. // watcher being evaluated at any time.
  2060. Dep.target = null;
  2061. /* */
  2062. var VNode = function VNode (
  2063. tag,
  2064. data,
  2065. children,
  2066. text,
  2067. elm,
  2068. context,
  2069. componentOptions,
  2070. asyncFactory
  2071. ) {
  2072. this.tag = tag;
  2073. this.data = data;
  2074. this.children = children;
  2075. this.text = text;
  2076. this.elm = elm;
  2077. this.ns = undefined;
  2078. this.context = context;
  2079. this.functionalContext = undefined;
  2080. this.functionalOptions = undefined;
  2081. this.functionalScopeId = undefined;
  2082. this.key = data && data.key;
  2083. this.componentOptions = componentOptions;
  2084. this.componentInstance = undefined;
  2085. this.parent = undefined;
  2086. this.raw = false;
  2087. this.isStatic = false;
  2088. this.isRootInsert = true;
  2089. this.isComment = false;
  2090. this.isCloned = false;
  2091. this.isOnce = false;
  2092. this.asyncFactory = asyncFactory;
  2093. this.asyncMeta = undefined;
  2094. this.isAsyncPlaceholder = false;
  2095. };
  2096. var prototypeAccessors = { child: { configurable: true } };
  2097. // DEPRECATED: alias for componentInstance for backwards compat.
  2098. /* istanbul ignore next */
  2099. prototypeAccessors.child.get = function () {
  2100. return this.componentInstance
  2101. };
  2102. Object.defineProperties( VNode.prototype, prototypeAccessors );
  2103. // optimized shallow clone
  2104. // used for static nodes and slot nodes because they may be reused across
  2105. // multiple renders, cloning them avoids errors when DOM manipulations rely
  2106. // on their elm reference.
  2107. /*
  2108. * not type checking this file because flow doesn't play well with
  2109. * dynamically accessing methods on Array prototype
  2110. */
  2111. var arrayProto = Array.prototype;
  2112. var arrayMethods = Object.create(arrayProto);[
  2113. 'push',
  2114. 'pop',
  2115. 'shift',
  2116. 'unshift',
  2117. 'splice',
  2118. 'sort',
  2119. 'reverse'
  2120. ]
  2121. .forEach(function (method) {
  2122. // cache original method
  2123. var original = arrayProto[method];
  2124. def(arrayMethods, method, function mutator () {
  2125. var args = [], len = arguments.length;
  2126. while ( len-- ) args[ len ] = arguments[ len ];
  2127. var result = original.apply(this, args);
  2128. var ob = this.__ob__;
  2129. var inserted;
  2130. switch (method) {
  2131. case 'push':
  2132. case 'unshift':
  2133. inserted = args;
  2134. break
  2135. case 'splice':
  2136. inserted = args.slice(2);
  2137. break
  2138. }
  2139. if (inserted) { ob.observeArray(inserted); }
  2140. // notify change
  2141. ob.dep.notify();
  2142. return result
  2143. });
  2144. });
  2145. /* */
  2146. var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
  2147. /**
  2148. * By default, when a reactive property is set, the new value is
  2149. * also converted to become reactive. However when passing down props,
  2150. * we don't want to force conversion because the value may be a nested value
  2151. * under a frozen data structure. Converting it would defeat the optimization.
  2152. */
  2153. var observerState = {
  2154. shouldConvert: true
  2155. };
  2156. /**
  2157. * Observer class that are attached to each observed
  2158. * object. Once attached, the observer converts target
  2159. * object's property keys into getter/setters that
  2160. * collect dependencies and dispatches updates.
  2161. */
  2162. var Observer = function Observer (value) {
  2163. this.value = value;
  2164. this.dep = new Dep();
  2165. this.vmCount = 0;
  2166. def(value, '__ob__', this);
  2167. if (Array.isArray(value)) {
  2168. var augment = hasProto
  2169. ? protoAugment
  2170. : copyAugment;
  2171. augment(value, arrayMethods, arrayKeys);
  2172. this.observeArray(value);
  2173. } else {
  2174. this.walk(value);
  2175. }
  2176. };
  2177. /**
  2178. * Walk through each property and convert them into
  2179. * getter/setters. This method should only be called when
  2180. * value type is Object.
  2181. */
  2182. Observer.prototype.walk = function walk (obj) {
  2183. var keys = Object.keys(obj);
  2184. for (var i = 0; i < keys.length; i++) {
  2185. defineReactive(obj, keys[i], obj[keys[i]]);
  2186. }
  2187. };
  2188. /**
  2189. * Observe a list of Array items.
  2190. */
  2191. Observer.prototype.observeArray = function observeArray (items) {
  2192. for (var i = 0, l = items.length; i < l; i++) {
  2193. observe(items[i]);
  2194. }
  2195. };
  2196. // helpers
  2197. /**
  2198. * Augment an target Object or Array by intercepting
  2199. * the prototype chain using __proto__
  2200. */
  2201. function protoAugment (target, src, keys) {
  2202. /* eslint-disable no-proto */
  2203. target.__proto__ = src;
  2204. /* eslint-enable no-proto */
  2205. }
  2206. /**
  2207. * Augment an target Object or Array by defining
  2208. * hidden properties.
  2209. */
  2210. /* istanbul ignore next */
  2211. function copyAugment (target, src, keys) {
  2212. for (var i = 0, l = keys.length; i < l; i++) {
  2213. var key = keys[i];
  2214. def(target, key, src[key]);
  2215. }
  2216. }
  2217. /**
  2218. * Attempt to create an observer instance for a value,
  2219. * returns the new observer if successfully observed,
  2220. * or the existing observer if the value already has one.
  2221. */
  2222. function observe (value, asRootData) {
  2223. if (!isObject(value) || value instanceof VNode) {
  2224. return
  2225. }
  2226. var ob;
  2227. if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
  2228. ob = value.__ob__;
  2229. } else if (
  2230. observerState.shouldConvert &&
  2231. !isServerRendering() &&
  2232. (Array.isArray(value) || isPlainObject(value)) &&
  2233. Object.isExtensible(value) &&
  2234. !value._isVue
  2235. ) {
  2236. ob = new Observer(value);
  2237. }
  2238. if (asRootData && ob) {
  2239. ob.vmCount++;
  2240. }
  2241. return ob
  2242. }
  2243. /**
  2244. * Define a reactive property on an Object.
  2245. */
  2246. function defineReactive (
  2247. obj,
  2248. key,
  2249. val,
  2250. customSetter,
  2251. shallow
  2252. ) {
  2253. var dep = new Dep();
  2254. var property = Object.getOwnPropertyDescriptor(obj, key);
  2255. if (property && property.configurable === false) {
  2256. return
  2257. }
  2258. // cater for pre-defined getter/setters
  2259. var getter = property && property.get;
  2260. var setter = property && property.set;
  2261. var childOb = !shallow && observe(val);
  2262. Object.defineProperty(obj, key, {
  2263. enumerable: true,
  2264. configurable: true,
  2265. get: function reactiveGetter () {
  2266. var value = getter ? getter.call(obj) : val;
  2267. if (Dep.target) {
  2268. dep.depend();
  2269. if (childOb) {
  2270. childOb.dep.depend();
  2271. if (Array.isArray(value)) {
  2272. dependArray(value);
  2273. }
  2274. }
  2275. }
  2276. return value
  2277. },
  2278. set: function reactiveSetter (newVal) {
  2279. var value = getter ? getter.call(obj) : val;
  2280. /* eslint-disable no-self-compare */
  2281. if (newVal === value || (newVal !== newVal && value !== value)) {
  2282. return
  2283. }
  2284. /* eslint-enable no-self-compare */
  2285. if (process.env.NODE_ENV !== 'production' && customSetter) {
  2286. customSetter();
  2287. }
  2288. if (setter) {
  2289. setter.call(obj, newVal);
  2290. } else {
  2291. val = newVal;
  2292. }
  2293. childOb = !shallow && observe(newVal);
  2294. dep.notify();
  2295. }
  2296. });
  2297. }
  2298. /**
  2299. * Set a property on an object. Adds the new property and
  2300. * triggers change notification if the property doesn't
  2301. * already exist.
  2302. */
  2303. function set (target, key, val) {
  2304. if (Array.isArray(target) && isValidArrayIndex(key)) {
  2305. target.length = Math.max(target.length, key);
  2306. target.splice(key, 1, val);
  2307. return val
  2308. }
  2309. if (hasOwn(target, key)) {
  2310. target[key] = val;
  2311. return val
  2312. }
  2313. var ob = (target).__ob__;
  2314. if (target._isVue || (ob && ob.vmCount)) {
  2315. process.env.NODE_ENV !== 'production' && warn$1(
  2316. 'Avoid adding reactive properties to a Vue instance or its root $data ' +
  2317. 'at runtime - declare it upfront in the data option.'
  2318. );
  2319. return val
  2320. }
  2321. if (!ob) {
  2322. target[key] = val;
  2323. return val
  2324. }
  2325. defineReactive(ob.value, key, val);
  2326. ob.dep.notify();
  2327. return val
  2328. }
  2329. /**
  2330. * Delete a property and trigger change if necessary.
  2331. */
  2332. /**
  2333. * Collect dependencies on array elements when the array is touched, since
  2334. * we cannot intercept array element access like property getters.
  2335. */
  2336. function dependArray (value) {
  2337. for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
  2338. e = value[i];
  2339. e && e.__ob__ && e.__ob__.dep.depend();
  2340. if (Array.isArray(e)) {
  2341. dependArray(e);
  2342. }
  2343. }
  2344. }
  2345. /* */
  2346. /**
  2347. * Option overwriting strategies are functions that handle
  2348. * how to merge a parent option value and a child option
  2349. * value into the final value.
  2350. */
  2351. var strats = config.optionMergeStrategies;
  2352. /**
  2353. * Options with restrictions
  2354. */
  2355. if (process.env.NODE_ENV !== 'production') {
  2356. strats.el = strats.propsData = function (parent, child, vm, key) {
  2357. if (!vm) {
  2358. warn$1(
  2359. "option \"" + key + "\" can only be used during instance " +
  2360. 'creation with the `new` keyword.'
  2361. );
  2362. }
  2363. return defaultStrat(parent, child)
  2364. };
  2365. }
  2366. /**
  2367. * Helper that recursively merges two data objects together.
  2368. */
  2369. function mergeData (to, from) {
  2370. if (!from) { return to }
  2371. var key, toVal, fromVal;
  2372. var keys = Object.keys(from);
  2373. for (var i = 0; i < keys.length; i++) {
  2374. key = keys[i];
  2375. toVal = to[key];
  2376. fromVal = from[key];
  2377. if (!hasOwn(to, key)) {
  2378. set(to, key, fromVal);
  2379. } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
  2380. mergeData(toVal, fromVal);
  2381. }
  2382. }
  2383. return to
  2384. }
  2385. /**
  2386. * Data
  2387. */
  2388. function mergeDataOrFn (
  2389. parentVal,
  2390. childVal,
  2391. vm
  2392. ) {
  2393. if (!vm) {
  2394. // in a Vue.extend merge, both should be functions
  2395. if (!childVal) {
  2396. return parentVal
  2397. }
  2398. if (!parentVal) {
  2399. return childVal
  2400. }
  2401. // when parentVal & childVal are both present,
  2402. // we need to return a function that returns the
  2403. // merged result of both functions... no need to
  2404. // check if parentVal is a function here because
  2405. // it has to be a function to pass previous merges.
  2406. return function mergedDataFn () {
  2407. return mergeData(
  2408. typeof childVal === 'function' ? childVal.call(this) : childVal,
  2409. typeof parentVal === 'function' ? parentVal.call(this) : parentVal
  2410. )
  2411. }
  2412. } else if (parentVal || childVal) {
  2413. return function mergedInstanceDataFn () {
  2414. // instance merge
  2415. var instanceData = typeof childVal === 'function'
  2416. ? childVal.call(vm)
  2417. : childVal;
  2418. var defaultData = typeof parentVal === 'function'
  2419. ? parentVal.call(vm)
  2420. : parentVal;
  2421. if (instanceData) {
  2422. return mergeData(instanceData, defaultData)
  2423. } else {
  2424. return defaultData
  2425. }
  2426. }
  2427. }
  2428. }
  2429. strats.data = function (
  2430. parentVal,
  2431. childVal,
  2432. vm
  2433. ) {
  2434. if (!vm) {
  2435. if (childVal && typeof childVal !== 'function') {
  2436. process.env.NODE_ENV !== 'production' && warn$1(
  2437. 'The "data" option should be a function ' +
  2438. 'that returns a per-instance value in component ' +
  2439. 'definitions.',
  2440. vm
  2441. );
  2442. return parentVal
  2443. }
  2444. return mergeDataOrFn.call(this, parentVal, childVal)
  2445. }
  2446. return mergeDataOrFn(parentVal, childVal, vm)
  2447. };
  2448. /**
  2449. * Hooks and props are merged as arrays.
  2450. */
  2451. function mergeHook (
  2452. parentVal,
  2453. childVal
  2454. ) {
  2455. return childVal
  2456. ? parentVal
  2457. ? parentVal.concat(childVal)
  2458. : Array.isArray(childVal)
  2459. ? childVal
  2460. : [childVal]
  2461. : parentVal
  2462. }
  2463. LIFECYCLE_HOOKS.forEach(function (hook) {
  2464. strats[hook] = mergeHook;
  2465. });
  2466. /**
  2467. * Assets
  2468. *
  2469. * When a vm is present (instance creation), we need to do
  2470. * a three-way merge between constructor options, instance
  2471. * options and parent options.
  2472. */
  2473. function mergeAssets (
  2474. parentVal,
  2475. childVal,
  2476. vm,
  2477. key
  2478. ) {
  2479. var res = Object.create(parentVal || null);
  2480. if (childVal) {
  2481. process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
  2482. return extend(res, childVal)
  2483. } else {
  2484. return res
  2485. }
  2486. }
  2487. ASSET_TYPES.forEach(function (type) {
  2488. strats[type + 's'] = mergeAssets;
  2489. });
  2490. /**
  2491. * Watchers.
  2492. *
  2493. * Watchers hashes should not overwrite one
  2494. * another, so we merge them as arrays.
  2495. */
  2496. strats.watch = function (
  2497. parentVal,
  2498. childVal,
  2499. vm,
  2500. key
  2501. ) {
  2502. // work around Firefox's Object.prototype.watch...
  2503. if (parentVal === nativeWatch) { parentVal = undefined; }
  2504. if (childVal === nativeWatch) { childVal = undefined; }
  2505. /* istanbul ignore if */
  2506. if (!childVal) { return Object.create(parentVal || null) }
  2507. if (process.env.NODE_ENV !== 'production') {
  2508. assertObjectType(key, childVal, vm);
  2509. }
  2510. if (!parentVal) { return childVal }
  2511. var ret = {};
  2512. extend(ret, parentVal);
  2513. for (var key$1 in childVal) {
  2514. var parent = ret[key$1];
  2515. var child = childVal[key$1];
  2516. if (parent && !Array.isArray(parent)) {
  2517. parent = [parent];
  2518. }
  2519. ret[key$1] = parent
  2520. ? parent.concat(child)
  2521. : Array.isArray(child) ? child : [child];
  2522. }
  2523. return ret
  2524. };
  2525. /**
  2526. * Other object hashes.
  2527. */
  2528. strats.props =
  2529. strats.methods =
  2530. strats.inject =
  2531. strats.computed = function (
  2532. parentVal,
  2533. childVal,
  2534. vm,
  2535. key
  2536. ) {
  2537. if (childVal && process.env.NODE_ENV !== 'production') {
  2538. assertObjectType(key, childVal, vm);
  2539. }
  2540. if (!parentVal) { return childVal }
  2541. var ret = Object.create(null);
  2542. extend(ret, parentVal);
  2543. if (childVal) { extend(ret, childVal); }
  2544. return ret
  2545. };
  2546. strats.provide = mergeDataOrFn;
  2547. /**
  2548. * Default strategy.
  2549. */
  2550. var defaultStrat = function (parentVal, childVal) {
  2551. return childVal === undefined
  2552. ? parentVal
  2553. : childVal
  2554. };
  2555. function assertObjectType (name, value, vm) {
  2556. if (!isPlainObject(value)) {
  2557. warn$1(
  2558. "Invalid value for option \"" + name + "\": expected an Object, " +
  2559. "but got " + (toRawType(value)) + ".",
  2560. vm
  2561. );
  2562. }
  2563. }
  2564. /**
  2565. * Merge two option objects into a new one.
  2566. * Core utility used in both instantiation and inheritance.
  2567. */
  2568. /**
  2569. * Resolve an asset.
  2570. * This function is used because child instances need access
  2571. * to assets defined in its ancestor chain.
  2572. */
  2573. /* */
  2574. /* */
  2575. /* */
  2576. function on (el, dir) {
  2577. if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
  2578. warn$1("v-on without argument does not support modifiers.");
  2579. }
  2580. el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
  2581. }
  2582. /* */
  2583. function bind$1 (el, dir) {
  2584. el.wrapData = function (code) {
  2585. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
  2586. };
  2587. }
  2588. /* */
  2589. var baseDirectives = {
  2590. on: on,
  2591. bind: bind$1,
  2592. cloak: noop
  2593. };
  2594. /* */
  2595. var CodegenState = function CodegenState (options) {
  2596. this.options = options;
  2597. this.warn = options.warn || baseWarn;
  2598. this.transforms = pluckModuleFunction(options.modules, 'transformCode');
  2599. this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
  2600. this.directives = extend(extend({}, baseDirectives), options.directives);
  2601. var isReservedTag = options.isReservedTag || no;
  2602. this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
  2603. this.onceId = 0;
  2604. this.staticRenderFns = [];
  2605. };
  2606. function generate (
  2607. ast,
  2608. options
  2609. ) {
  2610. var state = new CodegenState(options);
  2611. var code = ast ? genElement(ast, state) : '_c("div")';
  2612. return {
  2613. render: ("with(this){return " + code + "}"),
  2614. staticRenderFns: state.staticRenderFns
  2615. }
  2616. }
  2617. function genElement (el, state) {
  2618. if (el.staticRoot && !el.staticProcessed) {
  2619. return genStatic(el, state)
  2620. } else if (el.once && !el.onceProcessed) {
  2621. return genOnce(el, state)
  2622. } else if (el.for && !el.forProcessed) {
  2623. return genFor(el, state)
  2624. } else if (el.if && !el.ifProcessed) {
  2625. return genIf(el, state)
  2626. } else if (el.tag === 'template' && !el.slotTarget) {
  2627. return genChildren(el, state) || 'void 0'
  2628. } else if (el.tag === 'slot') {
  2629. return genSlot(el, state)
  2630. } else {
  2631. // component or element
  2632. var code;
  2633. if (el.component) {
  2634. code = genComponent(el.component, el, state);
  2635. } else {
  2636. var data = el.plain ? undefined : genData(el, state);
  2637. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  2638. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  2639. }
  2640. // module transforms
  2641. for (var i = 0; i < state.transforms.length; i++) {
  2642. code = state.transforms[i](el, code);
  2643. }
  2644. return code
  2645. }
  2646. }
  2647. // hoist static sub-trees out
  2648. function genStatic (el, state) {
  2649. el.staticProcessed = true;
  2650. state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
  2651. return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  2652. }
  2653. // v-once
  2654. function genOnce (el, state) {
  2655. el.onceProcessed = true;
  2656. if (el.if && !el.ifProcessed) {
  2657. return genIf(el, state)
  2658. } else if (el.staticInFor) {
  2659. var key = '';
  2660. var parent = el.parent;
  2661. while (parent) {
  2662. if (parent.for) {
  2663. key = parent.key;
  2664. break
  2665. }
  2666. parent = parent.parent;
  2667. }
  2668. if (!key) {
  2669. process.env.NODE_ENV !== 'production' && state.warn(
  2670. "v-once can only be used inside v-for that is keyed. "
  2671. );
  2672. return genElement(el, state)
  2673. }
  2674. return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
  2675. } else {
  2676. return genStatic(el, state)
  2677. }
  2678. }
  2679. function genIf (
  2680. el,
  2681. state,
  2682. altGen,
  2683. altEmpty
  2684. ) {
  2685. el.ifProcessed = true; // avoid recursion
  2686. return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
  2687. }
  2688. function genIfConditions (
  2689. conditions,
  2690. state,
  2691. altGen,
  2692. altEmpty
  2693. ) {
  2694. if (!conditions.length) {
  2695. return altEmpty || '_e()'
  2696. }
  2697. var condition = conditions.shift();
  2698. if (condition.exp) {
  2699. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
  2700. } else {
  2701. return ("" + (genTernaryExp(condition.block)))
  2702. }
  2703. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  2704. function genTernaryExp (el) {
  2705. return altGen
  2706. ? altGen(el, state)
  2707. : el.once
  2708. ? genOnce(el, state)
  2709. : genElement(el, state)
  2710. }
  2711. }
  2712. function genFor (
  2713. el,
  2714. state,
  2715. altGen,
  2716. altHelper
  2717. ) {
  2718. var exp = el.for;
  2719. var alias = el.alias;
  2720. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  2721. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  2722. if (process.env.NODE_ENV !== 'production' &&
  2723. state.maybeComponent(el) &&
  2724. el.tag !== 'slot' &&
  2725. el.tag !== 'template' &&
  2726. !el.key
  2727. ) {
  2728. state.warn(
  2729. "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
  2730. "v-for should have explicit keys. " +
  2731. "See https://vuejs.org/guide/list.html#key for more info.",
  2732. true /* tip */
  2733. );
  2734. }
  2735. el.forProcessed = true; // avoid recursion
  2736. return (altHelper || '_l') + "((" + exp + ")," +
  2737. "function(" + alias + iterator1 + iterator2 + "){" +
  2738. "return " + ((altGen || genElement)(el, state)) +
  2739. '})'
  2740. }
  2741. function genData (el, state) {
  2742. var data = '{';
  2743. // directives first.
  2744. // directives may mutate the el's other properties before they are generated.
  2745. var dirs = genDirectives(el, state);
  2746. if (dirs) { data += dirs + ','; }
  2747. // key
  2748. if (el.key) {
  2749. data += "key:" + (el.key) + ",";
  2750. }
  2751. // ref
  2752. if (el.ref) {
  2753. data += "ref:" + (el.ref) + ",";
  2754. }
  2755. if (el.refInFor) {
  2756. data += "refInFor:true,";
  2757. }
  2758. // pre
  2759. if (el.pre) {
  2760. data += "pre:true,";
  2761. }
  2762. // record original tag name for components using "is" attribute
  2763. if (el.component) {
  2764. data += "tag:\"" + (el.tag) + "\",";
  2765. }
  2766. // module data generation functions
  2767. for (var i = 0; i < state.dataGenFns.length; i++) {
  2768. data += state.dataGenFns[i](el);
  2769. }
  2770. // attributes
  2771. if (el.attrs) {
  2772. data += "attrs:{" + (genProps(el.attrs)) + "},";
  2773. }
  2774. // DOM props
  2775. if (el.props) {
  2776. data += "domProps:{" + (genProps(el.props)) + "},";
  2777. }
  2778. // event handlers
  2779. if (el.events) {
  2780. data += (genHandlers(el.events, false, state.warn)) + ",";
  2781. }
  2782. if (el.nativeEvents) {
  2783. data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
  2784. }
  2785. // slot target
  2786. // only for non-scoped slots
  2787. if (el.slotTarget && !el.slotScope) {
  2788. data += "slot:" + (el.slotTarget) + ",";
  2789. }
  2790. // scoped slots
  2791. if (el.scopedSlots) {
  2792. data += (genScopedSlots(el.scopedSlots, state)) + ",";
  2793. }
  2794. // component v-model
  2795. if (el.model) {
  2796. data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
  2797. }
  2798. // inline-template
  2799. if (el.inlineTemplate) {
  2800. var inlineTemplate = genInlineTemplate(el, state);
  2801. if (inlineTemplate) {
  2802. data += inlineTemplate + ",";
  2803. }
  2804. }
  2805. data = data.replace(/,$/, '') + '}';
  2806. // v-bind data wrap
  2807. if (el.wrapData) {
  2808. data = el.wrapData(data);
  2809. }
  2810. // v-on data wrap
  2811. if (el.wrapListeners) {
  2812. data = el.wrapListeners(data);
  2813. }
  2814. return data
  2815. }
  2816. function genDirectives (el, state) {
  2817. var dirs = el.directives;
  2818. if (!dirs) { return }
  2819. var res = 'directives:[';
  2820. var hasRuntime = false;
  2821. var i, l, dir, needRuntime;
  2822. for (i = 0, l = dirs.length; i < l; i++) {
  2823. dir = dirs[i];
  2824. needRuntime = true;
  2825. var gen = state.directives[dir.name];
  2826. if (gen) {
  2827. // compile-time directive that manipulates AST.
  2828. // returns true if it also needs a runtime counterpart.
  2829. needRuntime = !!gen(el, dir, state.warn);
  2830. }
  2831. if (needRuntime) {
  2832. hasRuntime = true;
  2833. res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},";
  2834. }
  2835. }
  2836. if (hasRuntime) {
  2837. return res.slice(0, -1) + ']'
  2838. }
  2839. }
  2840. function genInlineTemplate (el, state) {
  2841. var ast = el.children[0];
  2842. if (process.env.NODE_ENV !== 'production' && (
  2843. el.children.length !== 1 || ast.type !== 1
  2844. )) {
  2845. state.warn('Inline-template components must have exactly one child element.');
  2846. }
  2847. if (ast.type === 1) {
  2848. var inlineRenderFns = generate(ast, state.options);
  2849. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  2850. }
  2851. }
  2852. function genScopedSlots (
  2853. slots,
  2854. state
  2855. ) {
  2856. return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
  2857. return genScopedSlot(key, slots[key], state)
  2858. }).join(',')) + "])")
  2859. }
  2860. function genScopedSlot (
  2861. key,
  2862. el,
  2863. state
  2864. ) {
  2865. if (el.for && !el.forProcessed) {
  2866. return genForScopedSlot(key, el, state)
  2867. }
  2868. var fn = "function(" + (String(el.slotScope)) + "){" +
  2869. "return " + (el.tag === 'template'
  2870. ? el.if
  2871. ? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined")
  2872. : genChildren(el, state) || 'undefined'
  2873. : genElement(el, state)) + "}";
  2874. return ("{key:" + key + ",fn:" + fn + "}")
  2875. }
  2876. function genForScopedSlot (
  2877. key,
  2878. el,
  2879. state
  2880. ) {
  2881. var exp = el.for;
  2882. var alias = el.alias;
  2883. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  2884. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  2885. el.forProcessed = true; // avoid recursion
  2886. return "_l((" + exp + ")," +
  2887. "function(" + alias + iterator1 + iterator2 + "){" +
  2888. "return " + (genScopedSlot(key, el, state)) +
  2889. '})'
  2890. }
  2891. function genChildren (
  2892. el,
  2893. state,
  2894. checkSkip,
  2895. altGenElement,
  2896. altGenNode
  2897. ) {
  2898. var children = el.children;
  2899. if (children.length) {
  2900. var el$1 = children[0];
  2901. // optimize single v-for
  2902. if (children.length === 1 &&
  2903. el$1.for &&
  2904. el$1.tag !== 'template' &&
  2905. el$1.tag !== 'slot'
  2906. ) {
  2907. return (altGenElement || genElement)(el$1, state)
  2908. }
  2909. var normalizationType = checkSkip
  2910. ? getNormalizationType(children, state.maybeComponent)
  2911. : 0;
  2912. var gen = altGenNode || genNode;
  2913. return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
  2914. }
  2915. }
  2916. // determine the normalization needed for the children array.
  2917. // 0: no normalization needed
  2918. // 1: simple normalization needed (possible 1-level deep nested array)
  2919. // 2: full normalization needed
  2920. function getNormalizationType (
  2921. children,
  2922. maybeComponent
  2923. ) {
  2924. var res = 0;
  2925. for (var i = 0; i < children.length; i++) {
  2926. var el = children[i];
  2927. if (el.type !== 1) {
  2928. continue
  2929. }
  2930. if (needsNormalization(el) ||
  2931. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  2932. res = 2;
  2933. break
  2934. }
  2935. if (maybeComponent(el) ||
  2936. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  2937. res = 1;
  2938. }
  2939. }
  2940. return res
  2941. }
  2942. function needsNormalization (el) {
  2943. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  2944. }
  2945. function genNode (node, state) {
  2946. if (node.type === 1) {
  2947. return genElement(node, state)
  2948. } if (node.type === 3 && node.isComment) {
  2949. return genComment(node)
  2950. } else {
  2951. return genText(node)
  2952. }
  2953. }
  2954. function genText (text) {
  2955. return ("_v(" + (text.type === 2
  2956. ? text.expression // no need for () because already wrapped in _s()
  2957. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  2958. }
  2959. function genComment (comment) {
  2960. return ("_e(" + (JSON.stringify(comment.text)) + ")")
  2961. }
  2962. function genSlot (el, state) {
  2963. var slotName = el.slotName || '"default"';
  2964. var children = genChildren(el, state);
  2965. var res = "_t(" + slotName + (children ? ("," + children) : '');
  2966. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  2967. var bind$$1 = el.attrsMap['v-bind'];
  2968. if ((attrs || bind$$1) && !children) {
  2969. res += ",null";
  2970. }
  2971. if (attrs) {
  2972. res += "," + attrs;
  2973. }
  2974. if (bind$$1) {
  2975. res += (attrs ? '' : ',null') + "," + bind$$1;
  2976. }
  2977. return res + ')'
  2978. }
  2979. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  2980. function genComponent (
  2981. componentName,
  2982. el,
  2983. state
  2984. ) {
  2985. var children = el.inlineTemplate ? null : genChildren(el, state, true);
  2986. return ("_c(" + componentName + "," + (genData(el, state)) + (children ? ("," + children) : '') + ")")
  2987. }
  2988. function genProps (props) {
  2989. var res = '';
  2990. for (var i = 0; i < props.length; i++) {
  2991. var prop = props[i];
  2992. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  2993. }
  2994. return res.slice(0, -1)
  2995. }
  2996. // #3895, #4268
  2997. function transformSpecialNewlines (text) {
  2998. return text
  2999. .replace(/\u2028/g, '\\u2028')
  3000. .replace(/\u2029/g, '\\u2029')
  3001. }
  3002. /* */
  3003. // these keywords should not appear inside expressions, but operators like
  3004. // typeof, instanceof and in are allowed
  3005. var prohibitedKeywordRE = new RegExp('\\b' + (
  3006. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  3007. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  3008. 'extends,finally,continue,debugger,function,arguments'
  3009. ).split(',').join('\\b|\\b') + '\\b');
  3010. // these unary operators should not be used as property/method names
  3011. var unaryOperatorsRE = new RegExp('\\b' + (
  3012. 'delete,typeof,void'
  3013. ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
  3014. // check valid identifier for v-for
  3015. var identRE = /[A-Za-z_$][\w$]*/;
  3016. // strip strings in expressions
  3017. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  3018. // detect problematic expressions in a template
  3019. function detectErrors (ast) {
  3020. var errors = [];
  3021. if (ast) {
  3022. checkNode(ast, errors);
  3023. }
  3024. return errors
  3025. }
  3026. function checkNode (node, errors) {
  3027. if (node.type === 1) {
  3028. for (var name in node.attrsMap) {
  3029. if (dirRE.test(name)) {
  3030. var value = node.attrsMap[name];
  3031. if (value) {
  3032. if (name === 'v-for') {
  3033. checkFor(node, ("v-for=\"" + value + "\""), errors);
  3034. } else if (onRE.test(name)) {
  3035. checkEvent(value, (name + "=\"" + value + "\""), errors);
  3036. } else {
  3037. checkExpression(value, (name + "=\"" + value + "\""), errors);
  3038. }
  3039. }
  3040. }
  3041. }
  3042. if (node.children) {
  3043. for (var i = 0; i < node.children.length; i++) {
  3044. checkNode(node.children[i], errors);
  3045. }
  3046. }
  3047. } else if (node.type === 2) {
  3048. checkExpression(node.expression, node.text, errors);
  3049. }
  3050. }
  3051. function checkEvent (exp, text, errors) {
  3052. var stipped = exp.replace(stripStringRE, '');
  3053. var keywordMatch = stipped.match(unaryOperatorsRE);
  3054. if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
  3055. errors.push(
  3056. "avoid using JavaScript unary operator as property name: " +
  3057. "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
  3058. );
  3059. }
  3060. checkExpression(exp, text, errors);
  3061. }
  3062. function checkFor (node, text, errors) {
  3063. checkExpression(node.for || '', text, errors);
  3064. checkIdentifier(node.alias, 'v-for alias', text, errors);
  3065. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  3066. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  3067. }
  3068. function checkIdentifier (ident, type, text, errors) {
  3069. if (typeof ident === 'string' && !identRE.test(ident)) {
  3070. errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
  3071. }
  3072. }
  3073. function checkExpression (exp, text, errors) {
  3074. try {
  3075. new Function(("return " + exp));
  3076. } catch (e) {
  3077. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  3078. if (keywordMatch) {
  3079. errors.push(
  3080. "avoid using JavaScript keyword as property name: " +
  3081. "\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim())
  3082. );
  3083. } else {
  3084. errors.push(
  3085. "invalid expression: " + (e.message) + " in\n\n" +
  3086. " " + exp + "\n\n" +
  3087. " Raw expression: " + (text.trim()) + "\n"
  3088. );
  3089. }
  3090. }
  3091. }
  3092. /* */
  3093. function createFunction (code, errors) {
  3094. try {
  3095. return new Function(code)
  3096. } catch (err) {
  3097. errors.push({ err: err, code: code });
  3098. return noop
  3099. }
  3100. }
  3101. function createCompileToFunctionFn (compile) {
  3102. var cache = Object.create(null);
  3103. return function compileToFunctions (
  3104. template,
  3105. options,
  3106. vm
  3107. ) {
  3108. options = extend({}, options);
  3109. var warn$$1 = options.warn || warn$1;
  3110. delete options.warn;
  3111. /* istanbul ignore if */
  3112. if (process.env.NODE_ENV !== 'production') {
  3113. // detect possible CSP restriction
  3114. try {
  3115. new Function('return 1');
  3116. } catch (e) {
  3117. if (e.toString().match(/unsafe-eval|CSP/)) {
  3118. warn$$1(
  3119. 'It seems you are using the standalone build of Vue.js in an ' +
  3120. 'environment with Content Security Policy that prohibits unsafe-eval. ' +
  3121. 'The template compiler cannot work in this environment. Consider ' +
  3122. 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
  3123. 'templates into render functions.'
  3124. );
  3125. }
  3126. }
  3127. }
  3128. // check cache
  3129. var key = options.delimiters
  3130. ? String(options.delimiters) + template
  3131. : template;
  3132. if (cache[key]) {
  3133. return cache[key]
  3134. }
  3135. // compile
  3136. var compiled = compile(template, options);
  3137. // check compilation errors/tips
  3138. if (process.env.NODE_ENV !== 'production') {
  3139. if (compiled.errors && compiled.errors.length) {
  3140. warn$$1(
  3141. "Error compiling template:\n\n" + template + "\n\n" +
  3142. compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
  3143. vm
  3144. );
  3145. }
  3146. if (compiled.tips && compiled.tips.length) {
  3147. compiled.tips.forEach(function (msg) { return tip(msg, vm); });
  3148. }
  3149. }
  3150. // turn code into functions
  3151. var res = {};
  3152. var fnGenErrors = [];
  3153. res.render = createFunction(compiled.render, fnGenErrors);
  3154. res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
  3155. return createFunction(code, fnGenErrors)
  3156. });
  3157. // check function generation errors.
  3158. // this should only happen if there is a bug in the compiler itself.
  3159. // mostly for codegen development use
  3160. /* istanbul ignore if */
  3161. if (process.env.NODE_ENV !== 'production') {
  3162. if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
  3163. warn$$1(
  3164. "Failed to generate render function:\n\n" +
  3165. fnGenErrors.map(function (ref) {
  3166. var err = ref.err;
  3167. var code = ref.code;
  3168. return ((err.toString()) + " in\n\n" + code + "\n");
  3169. }).join('\n'),
  3170. vm
  3171. );
  3172. }
  3173. }
  3174. return (cache[key] = res)
  3175. }
  3176. }
  3177. /* */
  3178. function createCompilerCreator (baseCompile) {
  3179. return function createCompiler (baseOptions) {
  3180. function compile (
  3181. template,
  3182. options
  3183. ) {
  3184. var finalOptions = Object.create(baseOptions);
  3185. var errors = [];
  3186. var tips = [];
  3187. finalOptions.warn = function (msg, tip) {
  3188. (tip ? tips : errors).push(msg);
  3189. };
  3190. if (options) {
  3191. // merge custom modules
  3192. if (options.modules) {
  3193. finalOptions.modules =
  3194. (baseOptions.modules || []).concat(options.modules);
  3195. }
  3196. // merge custom directives
  3197. if (options.directives) {
  3198. finalOptions.directives = extend(
  3199. Object.create(baseOptions.directives),
  3200. options.directives
  3201. );
  3202. }
  3203. // copy other options
  3204. for (var key in options) {
  3205. if (key !== 'modules' && key !== 'directives') {
  3206. finalOptions[key] = options[key];
  3207. }
  3208. }
  3209. }
  3210. var compiled = baseCompile(template, finalOptions);
  3211. if (process.env.NODE_ENV !== 'production') {
  3212. errors.push.apply(errors, detectErrors(compiled.ast));
  3213. }
  3214. compiled.errors = errors;
  3215. compiled.tips = tips;
  3216. return compiled
  3217. }
  3218. return {
  3219. compile: compile,
  3220. compileToFunctions: createCompileToFunctionFn(compile)
  3221. }
  3222. }
  3223. }
  3224. /* */
  3225. // `createCompilerCreator` allows creating compilers that use alternative
  3226. // parser/optimizer/codegen, e.g the SSR optimizing compiler.
  3227. // Here we just export a default compiler using the default parts.
  3228. var createCompiler = createCompilerCreator(function baseCompile (
  3229. template,
  3230. options
  3231. ) {
  3232. var ast = parse(template.trim(), options);
  3233. optimize(ast, options);
  3234. var code = generate(ast, options);
  3235. return {
  3236. ast: ast,
  3237. render: code.render,
  3238. staticRenderFns: code.staticRenderFns
  3239. }
  3240. });
  3241. /* */
  3242. function transformNode (el, options) {
  3243. var warn = options.warn || baseWarn;
  3244. var staticClass = getAndRemoveAttr(el, 'class');
  3245. var ref = parseStaticClass(staticClass, options);
  3246. var dynamic = ref.dynamic;
  3247. var classResult = ref.classResult;
  3248. if (process.env.NODE_ENV !== 'production' && dynamic && staticClass) {
  3249. warn(
  3250. "class=\"" + staticClass + "\": " +
  3251. 'Interpolation inside attributes has been deprecated. ' +
  3252. 'Use v-bind or the colon shorthand instead.'
  3253. );
  3254. }
  3255. if (!dynamic && classResult) {
  3256. el.staticClass = classResult;
  3257. }
  3258. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  3259. if (classBinding) {
  3260. el.classBinding = classBinding;
  3261. } else if (dynamic) {
  3262. el.classBinding = classResult;
  3263. }
  3264. }
  3265. function genData$1 (el) {
  3266. var data = '';
  3267. if (el.staticClass) {
  3268. data += "staticClass:" + (el.staticClass) + ",";
  3269. }
  3270. if (el.classBinding) {
  3271. data += "class:" + (el.classBinding) + ",";
  3272. }
  3273. return data
  3274. }
  3275. function parseStaticClass (staticClass, options) {
  3276. // "a b c" -> ["a", "b", "c"] => staticClass: ["a", "b", "c"]
  3277. // "a {{x}} c" -> ["a", x, "c"] => classBinding: '["a", x, "c"]'
  3278. var dynamic = false;
  3279. var classResult = '';
  3280. if (staticClass) {
  3281. var classList = staticClass.trim().split(' ').map(function (name) {
  3282. var result = parseText(name, options.delimiters);
  3283. if (result) {
  3284. dynamic = true;
  3285. return result
  3286. }
  3287. return JSON.stringify(name)
  3288. });
  3289. if (classList.length) {
  3290. classResult = '[' + classList.join(',') + ']';
  3291. }
  3292. }
  3293. return { dynamic: dynamic, classResult: classResult }
  3294. }
  3295. var klass = {
  3296. staticKeys: ['staticClass'],
  3297. transformNode: transformNode,
  3298. genData: genData$1
  3299. };
  3300. /* */
  3301. var normalize = cached(camelize);
  3302. function transformNode$1 (el, options) {
  3303. var warn = options.warn || baseWarn;
  3304. var staticStyle = getAndRemoveAttr(el, 'style');
  3305. var ref = parseStaticStyle(staticStyle, options);
  3306. var dynamic = ref.dynamic;
  3307. var styleResult = ref.styleResult;
  3308. if (process.env.NODE_ENV !== 'production' && dynamic) {
  3309. warn(
  3310. "style=\"" + (String(staticStyle)) + "\": " +
  3311. 'Interpolation inside attributes has been deprecated. ' +
  3312. 'Use v-bind or the colon shorthand instead.'
  3313. );
  3314. }
  3315. if (!dynamic && styleResult) {
  3316. el.staticStyle = styleResult;
  3317. }
  3318. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  3319. if (styleBinding) {
  3320. el.styleBinding = styleBinding;
  3321. } else if (dynamic) {
  3322. el.styleBinding = styleResult;
  3323. }
  3324. }
  3325. function genData$2 (el) {
  3326. var data = '';
  3327. if (el.staticStyle) {
  3328. data += "staticStyle:" + (el.staticStyle) + ",";
  3329. }
  3330. if (el.styleBinding) {
  3331. data += "style:" + (el.styleBinding) + ",";
  3332. }
  3333. return data
  3334. }
  3335. function parseStaticStyle (staticStyle, options) {
  3336. // "width: 200px; height: 200px;" -> {width: 200, height: 200}
  3337. // "width: 200px; height: {{y}}" -> {width: 200, height: y}
  3338. var dynamic = false;
  3339. var styleResult = '';
  3340. if (staticStyle) {
  3341. var styleList = staticStyle.trim().split(';').map(function (style) {
  3342. var result = style.trim().split(':');
  3343. if (result.length !== 2) {
  3344. return
  3345. }
  3346. var key = normalize(result[0].trim());
  3347. var value = result[1].trim();
  3348. var dynamicValue = parseText(value, options.delimiters);
  3349. if (dynamicValue) {
  3350. dynamic = true;
  3351. return key + ':' + dynamicValue
  3352. }
  3353. return key + ':' + JSON.stringify(value)
  3354. }).filter(function (result) { return result; });
  3355. if (styleList.length) {
  3356. styleResult = '{' + styleList.join(',') + '}';
  3357. }
  3358. }
  3359. return { dynamic: dynamic, styleResult: styleResult }
  3360. }
  3361. var style = {
  3362. staticKeys: ['staticStyle'],
  3363. transformNode: transformNode$1,
  3364. genData: genData$2
  3365. };
  3366. /* */
  3367. var normalize$1 = cached(camelize);
  3368. function normalizeKeyName (str) {
  3369. if (str.match(/^v\-/)) {
  3370. return str.replace(/(v-[a-z\-]+\:)([a-z\-]+)$/i, function ($, directive, prop) {
  3371. return directive + normalize$1(prop)
  3372. })
  3373. }
  3374. return normalize$1(str)
  3375. }
  3376. function transformNode$2 (el, options) {
  3377. if (Array.isArray(el.attrsList)) {
  3378. el.attrsList.forEach(function (attr) {
  3379. if (attr.name && attr.name.match(/\-/)) {
  3380. var realName = normalizeKeyName(attr.name);
  3381. if (el.attrsMap) {
  3382. el.attrsMap[realName] = el.attrsMap[attr.name];
  3383. delete el.attrsMap[attr.name];
  3384. }
  3385. attr.name = realName;
  3386. }
  3387. });
  3388. }
  3389. }
  3390. var props = {
  3391. transformNode: transformNode$2
  3392. };
  3393. /* */
  3394. function preTransformNode (el, options) {
  3395. if (el.tag === 'cell' && !el.attrsList.some(function (item) { return item.name === 'append'; })) {
  3396. el.attrsMap.append = 'tree';
  3397. el.attrsList.push({ name: 'append', value: 'tree' });
  3398. }
  3399. if (el.attrsMap.append === 'tree') {
  3400. el.appendAsTree = true;
  3401. }
  3402. }
  3403. function genData$3 (el) {
  3404. return el.appendAsTree ? "appendAsTree:true," : ''
  3405. }
  3406. var append = {
  3407. staticKeys: ['appendAsTree'],
  3408. preTransformNode: preTransformNode,
  3409. genData: genData$3
  3410. };
  3411. var modules = [
  3412. klass,
  3413. style,
  3414. props,
  3415. append
  3416. ];
  3417. /* */
  3418. function model (
  3419. el,
  3420. dir,
  3421. _warn
  3422. ) {
  3423. if (el.tag === 'input' || el.tag === 'textarea') {
  3424. genDefaultModel(el, dir.value, dir.modifiers);
  3425. } else {
  3426. genComponentModel(el, dir.value, dir.modifiers);
  3427. }
  3428. }
  3429. function genDefaultModel (
  3430. el,
  3431. value,
  3432. modifiers
  3433. ) {
  3434. var ref = modifiers || {};
  3435. var lazy = ref.lazy;
  3436. var trim = ref.trim;
  3437. var number = ref.number;
  3438. var event = lazy ? 'change' : 'input';
  3439. var valueExpression = "$event.target.attr.value" + (trim ? '.trim()' : '');
  3440. if (number) {
  3441. valueExpression = "_n(" + valueExpression + ")";
  3442. }
  3443. var code = genAssignmentCode(value, valueExpression);
  3444. addAttr(el, 'value', ("(" + value + ")"));
  3445. addHandler(el, event, code, null, true);
  3446. }
  3447. var directives = {
  3448. model: model
  3449. };
  3450. /* globals document */
  3451. var isReservedTag = makeMap(
  3452. 'template,script,style,element,content,slot,link,meta,svg,view,' +
  3453. 'a,div,img,image,text,span,input,switch,textarea,spinner,select,' +
  3454. 'slider,slider-neighbor,indicator,canvas,' +
  3455. 'list,cell,header,loading,loading-indicator,refresh,scrollable,scroller,' +
  3456. 'video,web,embed,tabbar,tabheader,datepicker,timepicker,marquee,countdown',
  3457. true
  3458. );
  3459. // Elements that you can, intentionally, leave open (and which close themselves)
  3460. // more flexible than web
  3461. var canBeLeftOpenTag$1 = makeMap(
  3462. 'web,spinner,switch,video,textarea,canvas,' +
  3463. 'indicator,marquee,countdown',
  3464. true
  3465. );
  3466. var isRuntimeComponent = makeMap(
  3467. 'richtext,trisition,trisition-group',
  3468. true
  3469. );
  3470. var isUnaryTag$1 = makeMap(
  3471. 'embed,img,image,input,link,meta',
  3472. true
  3473. );
  3474. function mustUseProp () { /* console.log('mustUseProp') */ }
  3475. function getTagNamespace () { /* console.log('getTagNamespace') */ }
  3476. /* */
  3477. var baseOptions = {
  3478. modules: modules,
  3479. directives: directives,
  3480. isUnaryTag: isUnaryTag$1,
  3481. mustUseProp: mustUseProp,
  3482. canBeLeftOpenTag: canBeLeftOpenTag$1,
  3483. isReservedTag: isReservedTag,
  3484. getTagNamespace: getTagNamespace,
  3485. preserveWhitespace: false,
  3486. staticKeys: genStaticKeys(modules)
  3487. };
  3488. var ref = createCompiler(baseOptions);
  3489. var compile = ref.compile;
  3490. exports.compile = compile;