build.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var he = require('he');
  4. /* */
  5. /**
  6. * Convert a value to a string that is actually rendered.
  7. */
  8. /**
  9. * Convert a input value to a number for persistence.
  10. * If the conversion fails, return original string.
  11. */
  12. /**
  13. * Make a map and return a function for checking if a key
  14. * is in that map.
  15. */
  16. function makeMap (
  17. str,
  18. expectsLowerCase
  19. ) {
  20. var map = Object.create(null);
  21. var list = str.split(',');
  22. for (var i = 0; i < list.length; i++) {
  23. map[list[i]] = true;
  24. }
  25. return expectsLowerCase
  26. ? function (val) { return map[val.toLowerCase()]; }
  27. : function (val) { return map[val]; }
  28. }
  29. /**
  30. * Check if a tag is a built-in tag.
  31. */
  32. var isBuiltInTag = makeMap('slot,component', true);
  33. /**
  34. * Remove an item from an array
  35. */
  36. /**
  37. * Check if value is primitive
  38. */
  39. /**
  40. * Create a cached version of a pure function.
  41. */
  42. function cached (fn) {
  43. var cache = Object.create(null);
  44. return (function cachedFn (str) {
  45. var hit = cache[str];
  46. return hit || (cache[str] = fn(str))
  47. })
  48. }
  49. /**
  50. * Camelize a hyphen-delimited string.
  51. */
  52. var camelizeRE = /-(\w)/g;
  53. var camelize = cached(function (str) {
  54. return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
  55. });
  56. /**
  57. * Capitalize a string.
  58. */
  59. /**
  60. * Simple bind, faster than native
  61. */
  62. /**
  63. * Convert an Array-like object to a real Array.
  64. */
  65. /**
  66. * Mix properties into target object.
  67. */
  68. function extend (to, _from) {
  69. for (var key in _from) {
  70. to[key] = _from[key];
  71. }
  72. return to
  73. }
  74. /**
  75. * Quick object check - this is primarily used to tell
  76. * Objects from primitive values when we know the value
  77. * is a JSON-compliant type.
  78. */
  79. /**
  80. * Merge an Array of Objects into a single Object.
  81. */
  82. /**
  83. * Perform no operation.
  84. */
  85. function noop () {}
  86. /**
  87. * Always return false.
  88. */
  89. var no = function () { return false; };
  90. /**
  91. * Return same value
  92. */
  93. var identity = function (_) { return _; };
  94. /**
  95. * Generate a static keys string from compiler modules.
  96. */
  97. function genStaticKeys (modules) {
  98. return modules.reduce(function (keys, m) {
  99. return keys.concat(m.staticKeys || [])
  100. }, []).join(',')
  101. }
  102. /**
  103. * Check if two values are loosely equal - that is,
  104. * if they are plain objects, do they have the same shape?
  105. */
  106. /* */
  107. var config = {
  108. /**
  109. * Option merge strategies (used in core/util/options)
  110. */
  111. optionMergeStrategies: Object.create(null),
  112. /**
  113. * Whether to suppress warnings.
  114. */
  115. silent: false,
  116. /**
  117. * Whether to enable devtools
  118. */
  119. devtools: process.env.NODE_ENV !== 'production',
  120. /**
  121. * Error handler for watcher errors
  122. */
  123. errorHandler: null,
  124. /**
  125. * Ignore certain custom elements
  126. */
  127. ignoredElements: [],
  128. /**
  129. * Custom user key aliases for v-on
  130. */
  131. keyCodes: Object.create(null),
  132. /**
  133. * Check if a tag is reserved so that it cannot be registered as a
  134. * component. This is platform-dependent and may be overwritten.
  135. */
  136. isReservedTag: no,
  137. /**
  138. * Check if a tag is an unknown element.
  139. * Platform-dependent.
  140. */
  141. isUnknownElement: no,
  142. /**
  143. * Get the namespace of an element
  144. */
  145. getTagNamespace: noop,
  146. /**
  147. * Parse the real tag name for the specific platform.
  148. */
  149. parsePlatformTagName: identity,
  150. /**
  151. * Check if an attribute must be bound using property, e.g. value
  152. * Platform-dependent.
  153. */
  154. mustUseProp: no,
  155. /**
  156. * List of asset types that a component can own.
  157. */
  158. _assetTypes: [
  159. 'component',
  160. 'directive',
  161. 'filter'
  162. ],
  163. /**
  164. * List of lifecycle hooks.
  165. */
  166. _lifecycleHooks: [
  167. 'beforeCreate',
  168. 'created',
  169. 'beforeMount',
  170. 'mounted',
  171. 'beforeUpdate',
  172. 'updated',
  173. 'beforeDestroy',
  174. 'destroyed',
  175. 'activated',
  176. 'deactivated'
  177. ],
  178. /**
  179. * Max circular updates allowed in a scheduler flush cycle.
  180. */
  181. _maxUpdateCount: 100
  182. };
  183. var warn = noop;
  184. var formatComponentName;
  185. if (process.env.NODE_ENV !== 'production') {
  186. var hasConsole = typeof console !== 'undefined';
  187. warn = function (msg, vm) {
  188. if (hasConsole && (!config.silent)) {
  189. console.error("[Vue warn]: " + msg + " " + (
  190. vm ? formatLocation(formatComponentName(vm)) : ''
  191. ));
  192. }
  193. };
  194. formatComponentName = function (vm) {
  195. if (vm.$root === vm) {
  196. return 'root instance'
  197. }
  198. var name = vm._isVue
  199. ? vm.$options.name || vm.$options._componentTag
  200. : vm.name;
  201. return (
  202. (name ? ("component <" + name + ">") : "anonymous component") +
  203. (vm._isVue && vm.$options.__file ? (" at " + (vm.$options.__file)) : '')
  204. )
  205. };
  206. var formatLocation = function (str) {
  207. if (str === 'anonymous component') {
  208. str += " - use the \"name\" option for better debugging messages.";
  209. }
  210. return ("\n(found in " + str + ")")
  211. };
  212. }
  213. /* */
  214. var isUnaryTag = makeMap(
  215. 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
  216. 'link,meta,param,source,track,wbr',
  217. true
  218. );
  219. // Elements that you can, intentionally, leave open
  220. // (and which close themselves)
  221. var canBeLeftOpenTag = makeMap(
  222. 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source',
  223. true
  224. );
  225. // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
  226. // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
  227. var isNonPhrasingTag = makeMap(
  228. 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
  229. 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
  230. 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
  231. 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
  232. 'title,tr,track',
  233. true
  234. );
  235. /**
  236. * Not type-checking this file because it's mostly vendor code.
  237. */
  238. /*!
  239. * HTML Parser By John Resig (ejohn.org)
  240. * Modified by Juriy "kangax" Zaytsev
  241. * Original code by Erik Arvidsson, Mozilla Public License
  242. * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
  243. */
  244. // Regular Expressions for parsing tags and attributes
  245. var singleAttrIdentifier = /([^\s"'<>/=]+)/;
  246. var singleAttrAssign = /(?:=)/;
  247. var singleAttrValues = [
  248. // attr value double quotes
  249. /"([^"]*)"+/.source,
  250. // attr value, single quotes
  251. /'([^']*)'+/.source,
  252. // attr value, no quotes
  253. /([^\s"'=<>`]+)/.source
  254. ];
  255. var attribute = new RegExp(
  256. '^\\s*' + singleAttrIdentifier.source +
  257. '(?:\\s*(' + singleAttrAssign.source + ')' +
  258. '\\s*(?:' + singleAttrValues.join('|') + '))?'
  259. );
  260. // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
  261. // but for Vue templates we can enforce a simple charset
  262. var ncname = '[a-zA-Z_][\\w\\-\\.]*';
  263. var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')';
  264. var startTagOpen = new RegExp('^<' + qnameCapture);
  265. var startTagClose = /^\s*(\/?)>/;
  266. var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>');
  267. var doctype = /^<!DOCTYPE [^>]+>/i;
  268. var comment = /^<!--/;
  269. var conditionalComment = /^<!\[/;
  270. var IS_REGEX_CAPTURING_BROKEN = false;
  271. 'x'.replace(/x(.)?/g, function (m, g) {
  272. IS_REGEX_CAPTURING_BROKEN = g === '';
  273. });
  274. // Special Elements (can contain anything)
  275. var isScriptOrStyle = makeMap('script,style', true);
  276. var reCache = {};
  277. var ltRE = /&lt;/g;
  278. var gtRE = /&gt;/g;
  279. var nlRE = /&#10;/g;
  280. var ampRE = /&amp;/g;
  281. var quoteRE = /&quot;/g;
  282. function decodeAttr (value, shouldDecodeNewlines) {
  283. if (shouldDecodeNewlines) {
  284. value = value.replace(nlRE, '\n');
  285. }
  286. return value
  287. .replace(ltRE, '<')
  288. .replace(gtRE, '>')
  289. .replace(ampRE, '&')
  290. .replace(quoteRE, '"')
  291. }
  292. function parseHTML (html, options) {
  293. var stack = [];
  294. var expectHTML = options.expectHTML;
  295. var isUnaryTag$$1 = options.isUnaryTag || no;
  296. var index = 0;
  297. var last, lastTag;
  298. while (html) {
  299. last = html;
  300. // Make sure we're not in a script or style element
  301. if (!lastTag || !isScriptOrStyle(lastTag)) {
  302. var textEnd = html.indexOf('<');
  303. if (textEnd === 0) {
  304. // Comment:
  305. if (comment.test(html)) {
  306. var commentEnd = html.indexOf('-->');
  307. if (commentEnd >= 0) {
  308. advance(commentEnd + 3);
  309. continue
  310. }
  311. }
  312. // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
  313. if (conditionalComment.test(html)) {
  314. var conditionalEnd = html.indexOf(']>');
  315. if (conditionalEnd >= 0) {
  316. advance(conditionalEnd + 2);
  317. continue
  318. }
  319. }
  320. // Doctype:
  321. var doctypeMatch = html.match(doctype);
  322. if (doctypeMatch) {
  323. advance(doctypeMatch[0].length);
  324. continue
  325. }
  326. // End tag:
  327. var endTagMatch = html.match(endTag);
  328. if (endTagMatch) {
  329. var curIndex = index;
  330. advance(endTagMatch[0].length);
  331. parseEndTag(endTagMatch[1], curIndex, index);
  332. continue
  333. }
  334. // Start tag:
  335. var startTagMatch = parseStartTag();
  336. if (startTagMatch) {
  337. handleStartTag(startTagMatch);
  338. continue
  339. }
  340. }
  341. var text = (void 0), rest$1 = (void 0), next = (void 0);
  342. if (textEnd > 0) {
  343. rest$1 = html.slice(textEnd);
  344. while (
  345. !endTag.test(rest$1) &&
  346. !startTagOpen.test(rest$1) &&
  347. !comment.test(rest$1) &&
  348. !conditionalComment.test(rest$1)
  349. ) {
  350. // < in plain text, be forgiving and treat it as text
  351. next = rest$1.indexOf('<', 1);
  352. if (next < 0) { break }
  353. textEnd += next;
  354. rest$1 = html.slice(textEnd);
  355. }
  356. text = html.substring(0, textEnd);
  357. advance(textEnd);
  358. }
  359. if (textEnd < 0) {
  360. text = html;
  361. html = '';
  362. }
  363. if (options.chars && text) {
  364. options.chars(text);
  365. }
  366. } else {
  367. var stackedTag = lastTag.toLowerCase();
  368. var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
  369. var endTagLength = 0;
  370. var rest = html.replace(reStackedTag, function (all, text, endTag) {
  371. endTagLength = endTag.length;
  372. if (stackedTag !== 'script' && stackedTag !== 'style' && stackedTag !== 'noscript') {
  373. text = text
  374. .replace(/<!--([\s\S]*?)-->/g, '$1')
  375. .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
  376. }
  377. if (options.chars) {
  378. options.chars(text);
  379. }
  380. return ''
  381. });
  382. index += html.length - rest.length;
  383. html = rest;
  384. parseEndTag(stackedTag, index - endTagLength, index);
  385. }
  386. if (html === last && options.chars) {
  387. options.chars(html);
  388. break
  389. }
  390. }
  391. // Clean up any remaining tags
  392. parseEndTag();
  393. function advance (n) {
  394. index += n;
  395. html = html.substring(n);
  396. }
  397. function parseStartTag () {
  398. var start = html.match(startTagOpen);
  399. if (start) {
  400. var match = {
  401. tagName: start[1],
  402. attrs: [],
  403. start: index
  404. };
  405. advance(start[0].length);
  406. var end, attr;
  407. while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
  408. advance(attr[0].length);
  409. match.attrs.push(attr);
  410. }
  411. if (end) {
  412. match.unarySlash = end[1];
  413. advance(end[0].length);
  414. match.end = index;
  415. return match
  416. }
  417. }
  418. }
  419. function handleStartTag (match) {
  420. var tagName = match.tagName;
  421. var unarySlash = match.unarySlash;
  422. if (expectHTML) {
  423. if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
  424. parseEndTag(lastTag);
  425. }
  426. if (canBeLeftOpenTag(tagName) && lastTag === tagName) {
  427. parseEndTag(tagName);
  428. }
  429. }
  430. var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash;
  431. var l = match.attrs.length;
  432. var attrs = new Array(l);
  433. for (var i = 0; i < l; i++) {
  434. var args = match.attrs[i];
  435. // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
  436. if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
  437. if (args[3] === '') { delete args[3]; }
  438. if (args[4] === '') { delete args[4]; }
  439. if (args[5] === '') { delete args[5]; }
  440. }
  441. var value = args[3] || args[4] || args[5] || '';
  442. attrs[i] = {
  443. name: args[1],
  444. value: decodeAttr(
  445. value,
  446. options.shouldDecodeNewlines
  447. )
  448. };
  449. }
  450. if (!unary) {
  451. stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
  452. lastTag = tagName;
  453. unarySlash = '';
  454. }
  455. if (options.start) {
  456. options.start(tagName, attrs, unary, match.start, match.end);
  457. }
  458. }
  459. function parseEndTag (tagName, start, end) {
  460. var pos, lowerCasedTagName;
  461. if (start == null) { start = index; }
  462. if (end == null) { end = index; }
  463. if (tagName) {
  464. lowerCasedTagName = tagName.toLowerCase();
  465. }
  466. // Find the closest opened tag of the same type
  467. if (tagName) {
  468. for (pos = stack.length - 1; pos >= 0; pos--) {
  469. if (stack[pos].lowerCasedTag === lowerCasedTagName) {
  470. break
  471. }
  472. }
  473. } else {
  474. // If no tag name is provided, clean shop
  475. pos = 0;
  476. }
  477. if (pos >= 0) {
  478. // Close all the open elements, up the stack
  479. for (var i = stack.length - 1; i >= pos; i--) {
  480. if (options.end) {
  481. options.end(stack[i].tag, start, end);
  482. }
  483. }
  484. // Remove the open elements from the stack
  485. stack.length = pos;
  486. lastTag = pos && stack[pos - 1].tag;
  487. } else if (lowerCasedTagName === 'br') {
  488. if (options.start) {
  489. options.start(tagName, [], true, start, end);
  490. }
  491. } else if (lowerCasedTagName === 'p') {
  492. if (options.start) {
  493. options.start(tagName, [], false, start, end);
  494. }
  495. if (options.end) {
  496. options.end(tagName, start, end);
  497. }
  498. }
  499. }
  500. }
  501. /* */
  502. function parseFilters (exp) {
  503. var inSingle = false;
  504. var inDouble = false;
  505. var inTemplateString = false;
  506. var inRegex = false;
  507. var curly = 0;
  508. var square = 0;
  509. var paren = 0;
  510. var lastFilterIndex = 0;
  511. var c, prev, i, expression, filters;
  512. for (i = 0; i < exp.length; i++) {
  513. prev = c;
  514. c = exp.charCodeAt(i);
  515. if (inSingle) {
  516. if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
  517. } else if (inDouble) {
  518. if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
  519. } else if (inTemplateString) {
  520. if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
  521. } else if (inRegex) {
  522. if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
  523. } else if (
  524. c === 0x7C && // pipe
  525. exp.charCodeAt(i + 1) !== 0x7C &&
  526. exp.charCodeAt(i - 1) !== 0x7C &&
  527. !curly && !square && !paren
  528. ) {
  529. if (expression === undefined) {
  530. // first filter, end of expression
  531. lastFilterIndex = i + 1;
  532. expression = exp.slice(0, i).trim();
  533. } else {
  534. pushFilter();
  535. }
  536. } else {
  537. switch (c) {
  538. case 0x22: inDouble = true; break // "
  539. case 0x27: inSingle = true; break // '
  540. case 0x60: inTemplateString = true; break // `
  541. case 0x28: paren++; break // (
  542. case 0x29: paren--; break // )
  543. case 0x5B: square++; break // [
  544. case 0x5D: square--; break // ]
  545. case 0x7B: curly++; break // {
  546. case 0x7D: curly--; break // }
  547. }
  548. if (c === 0x2f) { // /
  549. var j = i - 1;
  550. var p = (void 0);
  551. // find first non-whitespace prev char
  552. for (; j >= 0; j--) {
  553. p = exp.charAt(j);
  554. if (p !== ' ') { break }
  555. }
  556. if (!p || !/[\w$]/.test(p)) {
  557. inRegex = true;
  558. }
  559. }
  560. }
  561. }
  562. if (expression === undefined) {
  563. expression = exp.slice(0, i).trim();
  564. } else if (lastFilterIndex !== 0) {
  565. pushFilter();
  566. }
  567. function pushFilter () {
  568. (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
  569. lastFilterIndex = i + 1;
  570. }
  571. if (filters) {
  572. for (i = 0; i < filters.length; i++) {
  573. expression = wrapFilter(expression, filters[i]);
  574. }
  575. }
  576. return expression
  577. }
  578. function wrapFilter (exp, filter) {
  579. var i = filter.indexOf('(');
  580. if (i < 0) {
  581. // _f: resolveFilter
  582. return ("_f(\"" + filter + "\")(" + exp + ")")
  583. } else {
  584. var name = filter.slice(0, i);
  585. var args = filter.slice(i + 1);
  586. return ("_f(\"" + name + "\")(" + exp + "," + args)
  587. }
  588. }
  589. /* */
  590. var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
  591. var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
  592. var buildRegex = cached(function (delimiters) {
  593. var open = delimiters[0].replace(regexEscapeRE, '\\$&');
  594. var close = delimiters[1].replace(regexEscapeRE, '\\$&');
  595. return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
  596. });
  597. function parseText (
  598. text,
  599. delimiters
  600. ) {
  601. var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
  602. if (!tagRE.test(text)) {
  603. return
  604. }
  605. var tokens = [];
  606. var lastIndex = tagRE.lastIndex = 0;
  607. var match, index;
  608. while ((match = tagRE.exec(text))) {
  609. index = match.index;
  610. // push text token
  611. if (index > lastIndex) {
  612. tokens.push(JSON.stringify(text.slice(lastIndex, index)));
  613. }
  614. // tag token
  615. var exp = parseFilters(match[1].trim());
  616. tokens.push(("_s(" + exp + ")"));
  617. lastIndex = index + match[0].length;
  618. }
  619. if (lastIndex < text.length) {
  620. tokens.push(JSON.stringify(text.slice(lastIndex)));
  621. }
  622. return tokens.join('+')
  623. }
  624. /* */
  625. /* globals MutationObserver */
  626. // can we use __proto__?
  627. // Browser environment sniffing
  628. var inBrowser = typeof window !== 'undefined';
  629. var UA = inBrowser && window.navigator.userAgent.toLowerCase();
  630. var isIE = UA && /msie|trident/.test(UA);
  631. var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
  632. var isEdge = UA && UA.indexOf('edge/') > 0;
  633. var isAndroid = UA && UA.indexOf('android') > 0;
  634. var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
  635. // this needs to be lazy-evaled because vue may be required before
  636. // vue-server-renderer can set VUE_ENV
  637. var _isServer;
  638. var isServerRendering = function () {
  639. if (_isServer === undefined) {
  640. /* istanbul ignore if */
  641. if (!inBrowser && typeof global !== 'undefined') {
  642. // detect presence of vue-server-renderer and avoid
  643. // Webpack shimming the process
  644. _isServer = global['process'].env.VUE_ENV === 'server';
  645. } else {
  646. _isServer = false;
  647. }
  648. }
  649. return _isServer
  650. };
  651. // detect devtools
  652. /* istanbul ignore next */
  653. function isNative (Ctor) {
  654. return /native code/.test(Ctor.toString())
  655. }
  656. /**
  657. * Defer a task to execute it asynchronously.
  658. */
  659. var nextTick = (function () {
  660. var callbacks = [];
  661. var pending = false;
  662. var timerFunc;
  663. function nextTickHandler () {
  664. pending = false;
  665. var copies = callbacks.slice(0);
  666. callbacks.length = 0;
  667. for (var i = 0; i < copies.length; i++) {
  668. copies[i]();
  669. }
  670. }
  671. // the nextTick behavior leverages the microtask queue, which can be accessed
  672. // via either native Promise.then or MutationObserver.
  673. // MutationObserver has wider support, however it is seriously bugged in
  674. // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
  675. // completely stops working after triggering a few times... so, if native
  676. // Promise is available, we will use it:
  677. /* istanbul ignore if */
  678. if (typeof Promise !== 'undefined' && isNative(Promise)) {
  679. var p = Promise.resolve();
  680. var logError = function (err) { console.error(err); };
  681. timerFunc = function () {
  682. p.then(nextTickHandler).catch(logError);
  683. // in problematic UIWebViews, Promise.then doesn't completely break, but
  684. // it can get stuck in a weird state where callbacks are pushed into the
  685. // microtask queue but the queue isn't being flushed, until the browser
  686. // needs to do some other work, e.g. handle a timer. Therefore we can
  687. // "force" the microtask queue to be flushed by adding an empty timer.
  688. if (isIOS) { setTimeout(noop); }
  689. };
  690. } else if (typeof MutationObserver !== 'undefined' && (
  691. isNative(MutationObserver) ||
  692. // PhantomJS and iOS 7.x
  693. MutationObserver.toString() === '[object MutationObserverConstructor]'
  694. )) {
  695. // use MutationObserver where native Promise is not available,
  696. // e.g. PhantomJS IE11, iOS7, Android 4.4
  697. var counter = 1;
  698. var observer = new MutationObserver(nextTickHandler);
  699. var textNode = document.createTextNode(String(counter));
  700. observer.observe(textNode, {
  701. characterData: true
  702. });
  703. timerFunc = function () {
  704. counter = (counter + 1) % 2;
  705. textNode.data = String(counter);
  706. };
  707. } else {
  708. // fallback to setTimeout
  709. /* istanbul ignore next */
  710. timerFunc = function () {
  711. setTimeout(nextTickHandler, 0);
  712. };
  713. }
  714. return function queueNextTick (cb, ctx) {
  715. var _resolve;
  716. callbacks.push(function () {
  717. if (cb) { cb.call(ctx); }
  718. if (_resolve) { _resolve(ctx); }
  719. });
  720. if (!pending) {
  721. pending = true;
  722. timerFunc();
  723. }
  724. if (!cb && typeof Promise !== 'undefined') {
  725. return new Promise(function (resolve) {
  726. _resolve = resolve;
  727. })
  728. }
  729. }
  730. })();
  731. var _Set;
  732. /* istanbul ignore if */
  733. if (typeof Set !== 'undefined' && isNative(Set)) {
  734. // use native Set when available.
  735. _Set = Set;
  736. } else {
  737. // a non-standard Set polyfill that only works with primitive keys.
  738. _Set = (function () {
  739. function Set () {
  740. this.set = Object.create(null);
  741. }
  742. Set.prototype.has = function has (key) {
  743. return this.set[key] === true
  744. };
  745. Set.prototype.add = function add (key) {
  746. this.set[key] = true;
  747. };
  748. Set.prototype.clear = function clear () {
  749. this.set = Object.create(null);
  750. };
  751. return Set;
  752. }());
  753. }
  754. /* */
  755. function baseWarn (msg) {
  756. console.error(("[Vue parser]: " + msg));
  757. }
  758. function pluckModuleFunction (
  759. modules,
  760. key
  761. ) {
  762. return modules
  763. ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
  764. : []
  765. }
  766. function addProp (el, name, value) {
  767. (el.props || (el.props = [])).push({ name: name, value: value });
  768. }
  769. function addAttr (el, name, value) {
  770. (el.attrs || (el.attrs = [])).push({ name: name, value: value });
  771. }
  772. function addDirective (
  773. el,
  774. name,
  775. rawName,
  776. value,
  777. arg,
  778. modifiers
  779. ) {
  780. (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
  781. }
  782. function addHandler (
  783. el,
  784. name,
  785. value,
  786. modifiers,
  787. important
  788. ) {
  789. // check capture modifier
  790. if (modifiers && modifiers.capture) {
  791. delete modifiers.capture;
  792. name = '!' + name; // mark the event as captured
  793. }
  794. if (modifiers && modifiers.once) {
  795. delete modifiers.once;
  796. name = '~' + name; // mark the event as once
  797. }
  798. var events;
  799. if (modifiers && modifiers.native) {
  800. delete modifiers.native;
  801. events = el.nativeEvents || (el.nativeEvents = {});
  802. } else {
  803. events = el.events || (el.events = {});
  804. }
  805. var newHandler = { value: value, modifiers: modifiers };
  806. var handlers = events[name];
  807. /* istanbul ignore if */
  808. if (Array.isArray(handlers)) {
  809. important ? handlers.unshift(newHandler) : handlers.push(newHandler);
  810. } else if (handlers) {
  811. events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
  812. } else {
  813. events[name] = newHandler;
  814. }
  815. }
  816. function getBindingAttr (
  817. el,
  818. name,
  819. getStatic
  820. ) {
  821. var dynamicValue =
  822. getAndRemoveAttr(el, ':' + name) ||
  823. getAndRemoveAttr(el, 'v-bind:' + name);
  824. if (dynamicValue != null) {
  825. return parseFilters(dynamicValue)
  826. } else if (getStatic !== false) {
  827. var staticValue = getAndRemoveAttr(el, name);
  828. if (staticValue != null) {
  829. return JSON.stringify(staticValue)
  830. }
  831. }
  832. }
  833. function getAndRemoveAttr (el, name) {
  834. var val;
  835. if ((val = el.attrsMap[name]) != null) {
  836. var list = el.attrsList;
  837. for (var i = 0, l = list.length; i < l; i++) {
  838. if (list[i].name === name) {
  839. list.splice(i, 1);
  840. break
  841. }
  842. }
  843. }
  844. return val
  845. }
  846. var len;
  847. var str;
  848. var chr;
  849. var index;
  850. var expressionPos;
  851. var expressionEndPos;
  852. /**
  853. * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val)
  854. *
  855. * for loop possible cases:
  856. *
  857. * - test
  858. * - test[idx]
  859. * - test[test1[idx]]
  860. * - test["a"][idx]
  861. * - xxx.test[a[a].test1[idx]]
  862. * - test.xxx.a["asa"][test1[idx]]
  863. *
  864. */
  865. function parseModel (val) {
  866. str = val;
  867. len = str.length;
  868. index = expressionPos = expressionEndPos = 0;
  869. if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
  870. return {
  871. exp: val,
  872. idx: null
  873. }
  874. }
  875. while (!eof()) {
  876. chr = next();
  877. /* istanbul ignore if */
  878. if (isStringStart(chr)) {
  879. parseString(chr);
  880. } else if (chr === 0x5B) {
  881. parseBracket(chr);
  882. }
  883. }
  884. return {
  885. exp: val.substring(0, expressionPos),
  886. idx: val.substring(expressionPos + 1, expressionEndPos)
  887. }
  888. }
  889. function next () {
  890. return str.charCodeAt(++index)
  891. }
  892. function eof () {
  893. return index >= len
  894. }
  895. function isStringStart (chr) {
  896. return chr === 0x22 || chr === 0x27
  897. }
  898. function parseBracket (chr) {
  899. var inBracket = 1;
  900. expressionPos = index;
  901. while (!eof()) {
  902. chr = next();
  903. if (isStringStart(chr)) {
  904. parseString(chr);
  905. continue
  906. }
  907. if (chr === 0x5B) { inBracket++; }
  908. if (chr === 0x5D) { inBracket--; }
  909. if (inBracket === 0) {
  910. expressionEndPos = index;
  911. break
  912. }
  913. }
  914. }
  915. function parseString (chr) {
  916. var stringQuote = chr;
  917. while (!eof()) {
  918. chr = next();
  919. if (chr === stringQuote) {
  920. break
  921. }
  922. }
  923. }
  924. /* */
  925. var dirRE = /^v-|^@|^:/;
  926. var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/;
  927. var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/;
  928. var bindRE = /^:|^v-bind:/;
  929. var onRE = /^@|^v-on:/;
  930. var argRE = /:(.*)$/;
  931. var modifierRE = /\.[^.]+/g;
  932. var decodeHTMLCached = cached(he.decode);
  933. // configurable state
  934. var warn$1;
  935. var platformGetTagNamespace;
  936. var platformMustUseProp;
  937. var platformIsPreTag;
  938. var preTransforms;
  939. var transforms;
  940. var postTransforms;
  941. var delimiters;
  942. /**
  943. * Convert HTML string to AST.
  944. */
  945. function parse (
  946. template,
  947. options
  948. ) {
  949. warn$1 = options.warn || baseWarn;
  950. platformGetTagNamespace = options.getTagNamespace || no;
  951. platformMustUseProp = options.mustUseProp || no;
  952. platformIsPreTag = options.isPreTag || no;
  953. preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
  954. transforms = pluckModuleFunction(options.modules, 'transformNode');
  955. postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
  956. delimiters = options.delimiters;
  957. var stack = [];
  958. var preserveWhitespace = options.preserveWhitespace !== false;
  959. var root;
  960. var currentParent;
  961. var inVPre = false;
  962. var inPre = false;
  963. var warned = false;
  964. parseHTML(template, {
  965. expectHTML: options.expectHTML,
  966. isUnaryTag: options.isUnaryTag,
  967. shouldDecodeNewlines: options.shouldDecodeNewlines,
  968. start: function start (tag, attrs, unary) {
  969. // check namespace.
  970. // inherit parent ns if there is one
  971. var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
  972. // handle IE svg bug
  973. /* istanbul ignore if */
  974. if (isIE && ns === 'svg') {
  975. attrs = guardIESVGBug(attrs);
  976. }
  977. var element = {
  978. type: 1,
  979. tag: tag,
  980. attrsList: attrs,
  981. attrsMap: makeAttrsMap(attrs),
  982. parent: currentParent,
  983. children: []
  984. };
  985. if (ns) {
  986. element.ns = ns;
  987. }
  988. if (isForbiddenTag(element) && !isServerRendering()) {
  989. element.forbidden = true;
  990. process.env.NODE_ENV !== 'production' && warn$1(
  991. 'Templates should only be responsible for mapping the state to the ' +
  992. 'UI. Avoid placing tags with side-effects in your templates, such as ' +
  993. "<" + tag + ">" + ', as they will not be parsed.'
  994. );
  995. }
  996. // apply pre-transforms
  997. for (var i = 0; i < preTransforms.length; i++) {
  998. preTransforms[i](element, options);
  999. }
  1000. if (!inVPre) {
  1001. processPre(element);
  1002. if (element.pre) {
  1003. inVPre = true;
  1004. }
  1005. }
  1006. if (platformIsPreTag(element.tag)) {
  1007. inPre = true;
  1008. }
  1009. if (inVPre) {
  1010. processRawAttrs(element);
  1011. } else {
  1012. processFor(element);
  1013. processIf(element);
  1014. processOnce(element);
  1015. processKey(element);
  1016. // determine whether this is a plain element after
  1017. // removing structural attributes
  1018. element.plain = !element.key && !attrs.length;
  1019. processRef(element);
  1020. processSlot(element);
  1021. processComponent(element);
  1022. for (var i$1 = 0; i$1 < transforms.length; i$1++) {
  1023. transforms[i$1](element, options);
  1024. }
  1025. processAttrs(element);
  1026. }
  1027. function checkRootConstraints (el) {
  1028. if (process.env.NODE_ENV !== 'production' && !warned) {
  1029. if (el.tag === 'slot' || el.tag === 'template') {
  1030. warned = true;
  1031. warn$1(
  1032. "Cannot use <" + (el.tag) + "> as component root element because it may " +
  1033. 'contain multiple nodes:\n' + template
  1034. );
  1035. }
  1036. if (el.attrsMap.hasOwnProperty('v-for')) {
  1037. warned = true;
  1038. warn$1(
  1039. 'Cannot use v-for on stateful component root element because ' +
  1040. 'it renders multiple elements:\n' + template
  1041. );
  1042. }
  1043. }
  1044. }
  1045. // tree management
  1046. if (!root) {
  1047. root = element;
  1048. checkRootConstraints(root);
  1049. } else if (!stack.length) {
  1050. // allow root elements with v-if, v-else-if and v-else
  1051. if (root.if && (element.elseif || element.else)) {
  1052. checkRootConstraints(element);
  1053. addIfCondition(root, {
  1054. exp: element.elseif,
  1055. block: element
  1056. });
  1057. } else if (process.env.NODE_ENV !== 'production' && !warned) {
  1058. warned = true;
  1059. warn$1(
  1060. "Component template should contain exactly one root element:" +
  1061. "\n\n" + template + "\n\n" +
  1062. "If you are using v-if on multiple elements, " +
  1063. "use v-else-if to chain them instead."
  1064. );
  1065. }
  1066. }
  1067. if (currentParent && !element.forbidden) {
  1068. if (element.elseif || element.else) {
  1069. processIfConditions(element, currentParent);
  1070. } else if (element.slotScope) { // scoped slot
  1071. currentParent.plain = false;
  1072. var name = element.slotTarget || 'default';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
  1073. } else {
  1074. currentParent.children.push(element);
  1075. element.parent = currentParent;
  1076. }
  1077. }
  1078. if (!unary) {
  1079. currentParent = element;
  1080. stack.push(element);
  1081. }
  1082. // apply post-transforms
  1083. for (var i$2 = 0; i$2 < postTransforms.length; i$2++) {
  1084. postTransforms[i$2](element, options);
  1085. }
  1086. },
  1087. end: function end () {
  1088. // remove trailing whitespace
  1089. var element = stack[stack.length - 1];
  1090. var lastNode = element.children[element.children.length - 1];
  1091. if (lastNode && lastNode.type === 3 && lastNode.text === ' ') {
  1092. element.children.pop();
  1093. }
  1094. // pop stack
  1095. stack.length -= 1;
  1096. currentParent = stack[stack.length - 1];
  1097. // check pre state
  1098. if (element.pre) {
  1099. inVPre = false;
  1100. }
  1101. if (platformIsPreTag(element.tag)) {
  1102. inPre = false;
  1103. }
  1104. },
  1105. chars: function chars (text) {
  1106. if (!currentParent) {
  1107. if (process.env.NODE_ENV !== 'production' && !warned && text === template) {
  1108. warned = true;
  1109. warn$1(
  1110. 'Component template requires a root element, rather than just text:\n\n' + template
  1111. );
  1112. }
  1113. return
  1114. }
  1115. // IE textarea placeholder bug
  1116. /* istanbul ignore if */
  1117. if (isIE &&
  1118. currentParent.tag === 'textarea' &&
  1119. currentParent.attrsMap.placeholder === text) {
  1120. return
  1121. }
  1122. var children = currentParent.children;
  1123. text = inPre || text.trim()
  1124. ? decodeHTMLCached(text)
  1125. // only preserve whitespace if its not right after a starting tag
  1126. : preserveWhitespace && children.length ? ' ' : '';
  1127. if (text) {
  1128. var expression;
  1129. if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) {
  1130. children.push({
  1131. type: 2,
  1132. expression: expression,
  1133. text: text
  1134. });
  1135. } else if (text !== ' ' || children[children.length - 1].text !== ' ') {
  1136. currentParent.children.push({
  1137. type: 3,
  1138. text: text
  1139. });
  1140. }
  1141. }
  1142. }
  1143. });
  1144. return root
  1145. }
  1146. function processPre (el) {
  1147. if (getAndRemoveAttr(el, 'v-pre') != null) {
  1148. el.pre = true;
  1149. }
  1150. }
  1151. function processRawAttrs (el) {
  1152. var l = el.attrsList.length;
  1153. if (l) {
  1154. var attrs = el.attrs = new Array(l);
  1155. for (var i = 0; i < l; i++) {
  1156. attrs[i] = {
  1157. name: el.attrsList[i].name,
  1158. value: JSON.stringify(el.attrsList[i].value)
  1159. };
  1160. }
  1161. } else if (!el.pre) {
  1162. // non root node in pre blocks with no attributes
  1163. el.plain = true;
  1164. }
  1165. }
  1166. function processKey (el) {
  1167. var exp = getBindingAttr(el, 'key');
  1168. if (exp) {
  1169. if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
  1170. warn$1("<template> cannot be keyed. Place the key on real elements instead.");
  1171. }
  1172. el.key = exp;
  1173. }
  1174. }
  1175. function processRef (el) {
  1176. var ref = getBindingAttr(el, 'ref');
  1177. if (ref) {
  1178. el.ref = ref;
  1179. el.refInFor = checkInFor(el);
  1180. }
  1181. }
  1182. function processFor (el) {
  1183. var exp;
  1184. if ((exp = getAndRemoveAttr(el, 'v-for'))) {
  1185. var inMatch = exp.match(forAliasRE);
  1186. if (!inMatch) {
  1187. process.env.NODE_ENV !== 'production' && warn$1(
  1188. ("Invalid v-for expression: " + exp)
  1189. );
  1190. return
  1191. }
  1192. el.for = inMatch[2].trim();
  1193. var alias = inMatch[1].trim();
  1194. var iteratorMatch = alias.match(forIteratorRE);
  1195. if (iteratorMatch) {
  1196. el.alias = iteratorMatch[1].trim();
  1197. el.iterator1 = iteratorMatch[2].trim();
  1198. if (iteratorMatch[3]) {
  1199. el.iterator2 = iteratorMatch[3].trim();
  1200. }
  1201. } else {
  1202. el.alias = alias;
  1203. }
  1204. }
  1205. }
  1206. function processIf (el) {
  1207. var exp = getAndRemoveAttr(el, 'v-if');
  1208. if (exp) {
  1209. el.if = exp;
  1210. addIfCondition(el, {
  1211. exp: exp,
  1212. block: el
  1213. });
  1214. } else {
  1215. if (getAndRemoveAttr(el, 'v-else') != null) {
  1216. el.else = true;
  1217. }
  1218. var elseif = getAndRemoveAttr(el, 'v-else-if');
  1219. if (elseif) {
  1220. el.elseif = elseif;
  1221. }
  1222. }
  1223. }
  1224. function processIfConditions (el, parent) {
  1225. var prev = findPrevElement(parent.children);
  1226. if (prev && prev.if) {
  1227. addIfCondition(prev, {
  1228. exp: el.elseif,
  1229. block: el
  1230. });
  1231. } else if (process.env.NODE_ENV !== 'production') {
  1232. warn$1(
  1233. "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
  1234. "used on element <" + (el.tag) + "> without corresponding v-if."
  1235. );
  1236. }
  1237. }
  1238. function findPrevElement (children) {
  1239. var i = children.length;
  1240. while (i--) {
  1241. if (children[i].type === 1) {
  1242. return children[i]
  1243. } else {
  1244. if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
  1245. warn$1(
  1246. "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
  1247. "will be ignored."
  1248. );
  1249. }
  1250. children.pop();
  1251. }
  1252. }
  1253. }
  1254. function addIfCondition (el, condition) {
  1255. if (!el.ifConditions) {
  1256. el.ifConditions = [];
  1257. }
  1258. el.ifConditions.push(condition);
  1259. }
  1260. function processOnce (el) {
  1261. var once = getAndRemoveAttr(el, 'v-once');
  1262. if (once != null) {
  1263. el.once = true;
  1264. }
  1265. }
  1266. function processSlot (el) {
  1267. if (el.tag === 'slot') {
  1268. el.slotName = getBindingAttr(el, 'name');
  1269. if (process.env.NODE_ENV !== 'production' && el.key) {
  1270. warn$1(
  1271. "`key` does not work on <slot> because slots are abstract outlets " +
  1272. "and can possibly expand into multiple elements. " +
  1273. "Use the key on a wrapping element instead."
  1274. );
  1275. }
  1276. } else {
  1277. var slotTarget = getBindingAttr(el, 'slot');
  1278. if (slotTarget) {
  1279. el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
  1280. }
  1281. if (el.tag === 'template') {
  1282. el.slotScope = getAndRemoveAttr(el, 'scope');
  1283. }
  1284. }
  1285. }
  1286. function processComponent (el) {
  1287. var binding;
  1288. if ((binding = getBindingAttr(el, 'is'))) {
  1289. el.component = binding;
  1290. }
  1291. if (getAndRemoveAttr(el, 'inline-template') != null) {
  1292. el.inlineTemplate = true;
  1293. }
  1294. }
  1295. function processAttrs (el) {
  1296. var list = el.attrsList;
  1297. var i, l, name, rawName, value, arg, modifiers, isProp;
  1298. for (i = 0, l = list.length; i < l; i++) {
  1299. name = rawName = list[i].name;
  1300. value = list[i].value;
  1301. if (dirRE.test(name)) {
  1302. // mark element as dynamic
  1303. el.hasBindings = true;
  1304. // modifiers
  1305. modifiers = parseModifiers(name);
  1306. if (modifiers) {
  1307. name = name.replace(modifierRE, '');
  1308. }
  1309. if (bindRE.test(name)) { // v-bind
  1310. name = name.replace(bindRE, '');
  1311. value = parseFilters(value);
  1312. isProp = false;
  1313. if (modifiers) {
  1314. if (modifiers.prop) {
  1315. isProp = true;
  1316. name = camelize(name);
  1317. if (name === 'innerHtml') { name = 'innerHTML'; }
  1318. }
  1319. if (modifiers.camel) {
  1320. name = camelize(name);
  1321. }
  1322. }
  1323. if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) {
  1324. addProp(el, name, value);
  1325. } else {
  1326. addAttr(el, name, value);
  1327. }
  1328. } else if (onRE.test(name)) { // v-on
  1329. name = name.replace(onRE, '');
  1330. addHandler(el, name, value, modifiers);
  1331. } else { // normal directives
  1332. name = name.replace(dirRE, '');
  1333. // parse arg
  1334. var argMatch = name.match(argRE);
  1335. if (argMatch && (arg = argMatch[1])) {
  1336. name = name.slice(0, -(arg.length + 1));
  1337. }
  1338. addDirective(el, name, rawName, value, arg, modifiers);
  1339. if (process.env.NODE_ENV !== 'production' && name === 'model') {
  1340. checkForAliasModel(el, value);
  1341. }
  1342. }
  1343. } else {
  1344. // literal attribute
  1345. if (process.env.NODE_ENV !== 'production') {
  1346. var expression = parseText(value, delimiters);
  1347. if (expression) {
  1348. warn$1(
  1349. name + "=\"" + value + "\": " +
  1350. 'Interpolation inside attributes has been removed. ' +
  1351. 'Use v-bind or the colon shorthand instead. For example, ' +
  1352. 'instead of <div id="{{ val }}">, use <div :id="val">.'
  1353. );
  1354. }
  1355. }
  1356. addAttr(el, name, JSON.stringify(value));
  1357. }
  1358. }
  1359. }
  1360. function checkInFor (el) {
  1361. var parent = el;
  1362. while (parent) {
  1363. if (parent.for !== undefined) {
  1364. return true
  1365. }
  1366. parent = parent.parent;
  1367. }
  1368. return false
  1369. }
  1370. function parseModifiers (name) {
  1371. var match = name.match(modifierRE);
  1372. if (match) {
  1373. var ret = {};
  1374. match.forEach(function (m) { ret[m.slice(1)] = true; });
  1375. return ret
  1376. }
  1377. }
  1378. function makeAttrsMap (attrs) {
  1379. var map = {};
  1380. for (var i = 0, l = attrs.length; i < l; i++) {
  1381. if (process.env.NODE_ENV !== 'production' && map[attrs[i].name] && !isIE) {
  1382. warn$1('duplicate attribute: ' + attrs[i].name);
  1383. }
  1384. map[attrs[i].name] = attrs[i].value;
  1385. }
  1386. return map
  1387. }
  1388. function isForbiddenTag (el) {
  1389. return (
  1390. el.tag === 'style' ||
  1391. (el.tag === 'script' && (
  1392. !el.attrsMap.type ||
  1393. el.attrsMap.type === 'text/javascript'
  1394. ))
  1395. )
  1396. }
  1397. var ieNSBug = /^xmlns:NS\d+/;
  1398. var ieNSPrefix = /^NS\d+:/;
  1399. /* istanbul ignore next */
  1400. function guardIESVGBug (attrs) {
  1401. var res = [];
  1402. for (var i = 0; i < attrs.length; i++) {
  1403. var attr = attrs[i];
  1404. if (!ieNSBug.test(attr.name)) {
  1405. attr.name = attr.name.replace(ieNSPrefix, '');
  1406. res.push(attr);
  1407. }
  1408. }
  1409. return res
  1410. }
  1411. function checkForAliasModel (el, value) {
  1412. var _el = el;
  1413. while (_el) {
  1414. if (_el.for && _el.alias === value) {
  1415. warn$1(
  1416. "<" + (el.tag) + " v-model=\"" + value + "\">: " +
  1417. "You are binding v-model directly to a v-for iteration alias. " +
  1418. "This will not be able to modify the v-for source array because " +
  1419. "writing to the alias is like modifying a function local variable. " +
  1420. "Consider using an array of objects and use v-model on an object property instead."
  1421. );
  1422. }
  1423. _el = _el.parent;
  1424. }
  1425. }
  1426. /* */
  1427. var isStaticKey;
  1428. var isPlatformReservedTag;
  1429. var genStaticKeysCached = cached(genStaticKeys$1);
  1430. /**
  1431. * Goal of the optimizer: walk the generated template AST tree
  1432. * and detect sub-trees that are purely static, i.e. parts of
  1433. * the DOM that never needs to change.
  1434. *
  1435. * Once we detect these sub-trees, we can:
  1436. *
  1437. * 1. Hoist them into constants, so that we no longer need to
  1438. * create fresh nodes for them on each re-render;
  1439. * 2. Completely skip them in the patching process.
  1440. */
  1441. function optimize (root, options) {
  1442. if (!root) { return }
  1443. isStaticKey = genStaticKeysCached(options.staticKeys || '');
  1444. isPlatformReservedTag = options.isReservedTag || no;
  1445. // first pass: mark all non-static nodes.
  1446. markStatic(root);
  1447. // second pass: mark static roots.
  1448. markStaticRoots(root, false);
  1449. }
  1450. function genStaticKeys$1 (keys) {
  1451. return makeMap(
  1452. 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
  1453. (keys ? ',' + keys : '')
  1454. )
  1455. }
  1456. function markStatic (node) {
  1457. node.static = isStatic(node);
  1458. if (node.type === 1) {
  1459. // do not make component slot content static. this avoids
  1460. // 1. components not able to mutate slot nodes
  1461. // 2. static slot content fails for hot-reloading
  1462. if (
  1463. !isPlatformReservedTag(node.tag) &&
  1464. node.tag !== 'slot' &&
  1465. node.attrsMap['inline-template'] == null
  1466. ) {
  1467. return
  1468. }
  1469. for (var i = 0, l = node.children.length; i < l; i++) {
  1470. var child = node.children[i];
  1471. markStatic(child);
  1472. if (!child.static) {
  1473. node.static = false;
  1474. }
  1475. }
  1476. }
  1477. }
  1478. function markStaticRoots (node, isInFor) {
  1479. if (node.type === 1) {
  1480. if (node.static || node.once) {
  1481. node.staticInFor = isInFor;
  1482. }
  1483. // For a node to qualify as a static root, it should have children that
  1484. // are not just static text. Otherwise the cost of hoisting out will
  1485. // outweigh the benefits and it's better off to just always render it fresh.
  1486. if (node.static && node.children.length && !(
  1487. node.children.length === 1 &&
  1488. node.children[0].type === 3
  1489. )) {
  1490. node.staticRoot = true;
  1491. return
  1492. } else {
  1493. node.staticRoot = false;
  1494. }
  1495. if (node.children) {
  1496. for (var i = 0, l = node.children.length; i < l; i++) {
  1497. markStaticRoots(node.children[i], isInFor || !!node.for);
  1498. }
  1499. }
  1500. if (node.ifConditions) {
  1501. walkThroughConditionsBlocks(node.ifConditions, isInFor);
  1502. }
  1503. }
  1504. }
  1505. function walkThroughConditionsBlocks (conditionBlocks, isInFor) {
  1506. for (var i = 1, len = conditionBlocks.length; i < len; i++) {
  1507. markStaticRoots(conditionBlocks[i].block, isInFor);
  1508. }
  1509. }
  1510. function isStatic (node) {
  1511. if (node.type === 2) { // expression
  1512. return false
  1513. }
  1514. if (node.type === 3) { // text
  1515. return true
  1516. }
  1517. return !!(node.pre || (
  1518. !node.hasBindings && // no dynamic bindings
  1519. !node.if && !node.for && // not v-if or v-for or v-else
  1520. !isBuiltInTag(node.tag) && // not a built-in
  1521. isPlatformReservedTag(node.tag) && // not a component
  1522. !isDirectChildOfTemplateFor(node) &&
  1523. Object.keys(node).every(isStaticKey)
  1524. ))
  1525. }
  1526. function isDirectChildOfTemplateFor (node) {
  1527. while (node.parent) {
  1528. node = node.parent;
  1529. if (node.tag !== 'template') {
  1530. return false
  1531. }
  1532. if (node.for) {
  1533. return true
  1534. }
  1535. }
  1536. return false
  1537. }
  1538. /* */
  1539. var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
  1540. var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/;
  1541. // keyCode aliases
  1542. var keyCodes = {
  1543. esc: 27,
  1544. tab: 9,
  1545. enter: 13,
  1546. space: 32,
  1547. up: 38,
  1548. left: 37,
  1549. right: 39,
  1550. down: 40,
  1551. 'delete': [8, 46]
  1552. };
  1553. var modifierCode = {
  1554. stop: '$event.stopPropagation();',
  1555. prevent: '$event.preventDefault();',
  1556. self: 'if($event.target !== $event.currentTarget)return;',
  1557. ctrl: 'if(!$event.ctrlKey)return;',
  1558. shift: 'if(!$event.shiftKey)return;',
  1559. alt: 'if(!$event.altKey)return;',
  1560. meta: 'if(!$event.metaKey)return;'
  1561. };
  1562. function genHandlers (events, native) {
  1563. var res = native ? 'nativeOn:{' : 'on:{';
  1564. for (var name in events) {
  1565. res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
  1566. }
  1567. return res.slice(0, -1) + '}'
  1568. }
  1569. function genHandler (
  1570. name,
  1571. handler
  1572. ) {
  1573. if (!handler) {
  1574. return 'function(){}'
  1575. } else if (Array.isArray(handler)) {
  1576. return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
  1577. } else if (!handler.modifiers) {
  1578. return fnExpRE.test(handler.value) || simplePathRE.test(handler.value)
  1579. ? handler.value
  1580. : ("function($event){" + (handler.value) + "}")
  1581. } else {
  1582. var code = '';
  1583. var keys = [];
  1584. for (var key in handler.modifiers) {
  1585. if (modifierCode[key]) {
  1586. code += modifierCode[key];
  1587. } else {
  1588. keys.push(key);
  1589. }
  1590. }
  1591. if (keys.length) {
  1592. code = genKeyFilter(keys) + code;
  1593. }
  1594. var handlerCode = simplePathRE.test(handler.value)
  1595. ? handler.value + '($event)'
  1596. : handler.value;
  1597. return 'function($event){' + code + handlerCode + '}'
  1598. }
  1599. }
  1600. function genKeyFilter (keys) {
  1601. return ("if(" + (keys.map(genFilterCode).join('&&')) + ")return;")
  1602. }
  1603. function genFilterCode (key) {
  1604. var keyVal = parseInt(key, 10);
  1605. if (keyVal) {
  1606. return ("$event.keyCode!==" + keyVal)
  1607. }
  1608. var alias = keyCodes[key];
  1609. return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")")
  1610. }
  1611. /* */
  1612. function bind$1 (el, dir) {
  1613. el.wrapData = function (code) {
  1614. return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")")
  1615. };
  1616. }
  1617. /* */
  1618. var baseDirectives = {
  1619. bind: bind$1,
  1620. cloak: noop
  1621. };
  1622. /* */
  1623. // configurable state
  1624. var warn$2;
  1625. var transforms$1;
  1626. var dataGenFns;
  1627. var platformDirectives;
  1628. var isPlatformReservedTag$1;
  1629. var staticRenderFns;
  1630. var onceCount;
  1631. var currentOptions;
  1632. function generate (
  1633. ast,
  1634. options
  1635. ) {
  1636. // save previous staticRenderFns so generate calls can be nested
  1637. var prevStaticRenderFns = staticRenderFns;
  1638. var currentStaticRenderFns = staticRenderFns = [];
  1639. var prevOnceCount = onceCount;
  1640. onceCount = 0;
  1641. currentOptions = options;
  1642. warn$2 = options.warn || baseWarn;
  1643. transforms$1 = pluckModuleFunction(options.modules, 'transformCode');
  1644. dataGenFns = pluckModuleFunction(options.modules, 'genData');
  1645. platformDirectives = options.directives || {};
  1646. isPlatformReservedTag$1 = options.isReservedTag || no;
  1647. var code = ast ? genElement(ast) : '_c("div")';
  1648. staticRenderFns = prevStaticRenderFns;
  1649. onceCount = prevOnceCount;
  1650. return {
  1651. render: ("with(this){return " + code + "}"),
  1652. staticRenderFns: currentStaticRenderFns
  1653. }
  1654. }
  1655. function genElement (el) {
  1656. if (el.staticRoot && !el.staticProcessed) {
  1657. return genStatic(el)
  1658. } else if (el.once && !el.onceProcessed) {
  1659. return genOnce(el)
  1660. } else if (el.for && !el.forProcessed) {
  1661. return genFor(el)
  1662. } else if (el.if && !el.ifProcessed) {
  1663. return genIf(el)
  1664. } else if (el.tag === 'template' && !el.slotTarget) {
  1665. return genChildren(el) || 'void 0'
  1666. } else if (el.tag === 'slot') {
  1667. return genSlot(el)
  1668. } else {
  1669. // component or element
  1670. var code;
  1671. if (el.component) {
  1672. code = genComponent(el.component, el);
  1673. } else {
  1674. var data = el.plain ? undefined : genData(el);
  1675. var children = el.inlineTemplate ? null : genChildren(el, true);
  1676. code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
  1677. }
  1678. // module transforms
  1679. for (var i = 0; i < transforms$1.length; i++) {
  1680. code = transforms$1[i](el, code);
  1681. }
  1682. return code
  1683. }
  1684. }
  1685. // hoist static sub-trees out
  1686. function genStatic (el) {
  1687. el.staticProcessed = true;
  1688. staticRenderFns.push(("with(this){return " + (genElement(el)) + "}"));
  1689. return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
  1690. }
  1691. // v-once
  1692. function genOnce (el) {
  1693. el.onceProcessed = true;
  1694. if (el.if && !el.ifProcessed) {
  1695. return genIf(el)
  1696. } else if (el.staticInFor) {
  1697. var key = '';
  1698. var parent = el.parent;
  1699. while (parent) {
  1700. if (parent.for) {
  1701. key = parent.key;
  1702. break
  1703. }
  1704. parent = parent.parent;
  1705. }
  1706. if (!key) {
  1707. process.env.NODE_ENV !== 'production' && warn$2(
  1708. "v-once can only be used inside v-for that is keyed. "
  1709. );
  1710. return genElement(el)
  1711. }
  1712. return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")")
  1713. } else {
  1714. return genStatic(el)
  1715. }
  1716. }
  1717. function genIf (el) {
  1718. el.ifProcessed = true; // avoid recursion
  1719. return genIfConditions(el.ifConditions.slice())
  1720. }
  1721. function genIfConditions (conditions) {
  1722. if (!conditions.length) {
  1723. return '_e()'
  1724. }
  1725. var condition = conditions.shift();
  1726. if (condition.exp) {
  1727. return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions)))
  1728. } else {
  1729. return ("" + (genTernaryExp(condition.block)))
  1730. }
  1731. // v-if with v-once should generate code like (a)?_m(0):_m(1)
  1732. function genTernaryExp (el) {
  1733. return el.once ? genOnce(el) : genElement(el)
  1734. }
  1735. }
  1736. function genFor (el) {
  1737. var exp = el.for;
  1738. var alias = el.alias;
  1739. var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
  1740. var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
  1741. el.forProcessed = true; // avoid recursion
  1742. return "_l((" + exp + ")," +
  1743. "function(" + alias + iterator1 + iterator2 + "){" +
  1744. "return " + (genElement(el)) +
  1745. '})'
  1746. }
  1747. function genData (el) {
  1748. var data = '{';
  1749. // directives first.
  1750. // directives may mutate the el's other properties before they are generated.
  1751. var dirs = genDirectives(el);
  1752. if (dirs) { data += dirs + ','; }
  1753. // key
  1754. if (el.key) {
  1755. data += "key:" + (el.key) + ",";
  1756. }
  1757. // ref
  1758. if (el.ref) {
  1759. data += "ref:" + (el.ref) + ",";
  1760. }
  1761. if (el.refInFor) {
  1762. data += "refInFor:true,";
  1763. }
  1764. // pre
  1765. if (el.pre) {
  1766. data += "pre:true,";
  1767. }
  1768. // record original tag name for components using "is" attribute
  1769. if (el.component) {
  1770. data += "tag:\"" + (el.tag) + "\",";
  1771. }
  1772. // module data generation functions
  1773. for (var i = 0; i < dataGenFns.length; i++) {
  1774. data += dataGenFns[i](el);
  1775. }
  1776. // attributes
  1777. if (el.attrs) {
  1778. data += "attrs:{" + (genProps(el.attrs)) + "},";
  1779. }
  1780. // DOM props
  1781. if (el.props) {
  1782. data += "domProps:{" + (genProps(el.props)) + "},";
  1783. }
  1784. // event handlers
  1785. if (el.events) {
  1786. data += (genHandlers(el.events)) + ",";
  1787. }
  1788. if (el.nativeEvents) {
  1789. data += (genHandlers(el.nativeEvents, true)) + ",";
  1790. }
  1791. // slot target
  1792. if (el.slotTarget) {
  1793. data += "slot:" + (el.slotTarget) + ",";
  1794. }
  1795. // scoped slots
  1796. if (el.scopedSlots) {
  1797. data += (genScopedSlots(el.scopedSlots)) + ",";
  1798. }
  1799. // inline-template
  1800. if (el.inlineTemplate) {
  1801. var inlineTemplate = genInlineTemplate(el);
  1802. if (inlineTemplate) {
  1803. data += inlineTemplate + ",";
  1804. }
  1805. }
  1806. data = data.replace(/,$/, '') + '}';
  1807. // v-bind data wrap
  1808. if (el.wrapData) {
  1809. data = el.wrapData(data);
  1810. }
  1811. return data
  1812. }
  1813. function genDirectives (el) {
  1814. var dirs = el.directives;
  1815. if (!dirs) { return }
  1816. var res = 'directives:[';
  1817. var hasRuntime = false;
  1818. var i, l, dir, needRuntime;
  1819. for (i = 0, l = dirs.length; i < l; i++) {
  1820. dir = dirs[i];
  1821. needRuntime = true;
  1822. var gen = platformDirectives[dir.name] || baseDirectives[dir.name];
  1823. if (gen) {
  1824. // compile-time directive that manipulates AST.
  1825. // returns true if it also needs a runtime counterpart.
  1826. needRuntime = !!gen(el, dir, warn$2);
  1827. }
  1828. if (needRuntime) {
  1829. hasRuntime = true;
  1830. 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))) : '') + "},";
  1831. }
  1832. }
  1833. if (hasRuntime) {
  1834. return res.slice(0, -1) + ']'
  1835. }
  1836. }
  1837. function genInlineTemplate (el) {
  1838. var ast = el.children[0];
  1839. if (process.env.NODE_ENV !== 'production' && (
  1840. el.children.length > 1 || ast.type !== 1
  1841. )) {
  1842. warn$2('Inline-template components must have exactly one child element.');
  1843. }
  1844. if (ast.type === 1) {
  1845. var inlineRenderFns = generate(ast, currentOptions);
  1846. return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
  1847. }
  1848. }
  1849. function genScopedSlots (slots) {
  1850. return ("scopedSlots:{" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "}")
  1851. }
  1852. function genScopedSlot (key, el) {
  1853. return key + ":function(" + (String(el.attrsMap.scope)) + "){" +
  1854. "return " + (el.tag === 'template'
  1855. ? genChildren(el) || 'void 0'
  1856. : genElement(el)) + "}"
  1857. }
  1858. function genChildren (el, checkSkip) {
  1859. var children = el.children;
  1860. if (children.length) {
  1861. var el$1 = children[0];
  1862. // optimize single v-for
  1863. if (children.length === 1 &&
  1864. el$1.for &&
  1865. el$1.tag !== 'template' &&
  1866. el$1.tag !== 'slot') {
  1867. return genElement(el$1)
  1868. }
  1869. var normalizationType = getNormalizationType(children);
  1870. return ("[" + (children.map(genNode).join(',')) + "]" + (checkSkip
  1871. ? normalizationType ? ("," + normalizationType) : ''
  1872. : ''))
  1873. }
  1874. }
  1875. // determine the normalization needed for the children array.
  1876. // 0: no normalization needed
  1877. // 1: simple normalization needed (possible 1-level deep nested array)
  1878. // 2: full normalization needed
  1879. function getNormalizationType (children) {
  1880. var res = 0;
  1881. for (var i = 0; i < children.length; i++) {
  1882. var el = children[i];
  1883. if (el.type !== 1) {
  1884. continue
  1885. }
  1886. if (needsNormalization(el) ||
  1887. (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
  1888. res = 2;
  1889. break
  1890. }
  1891. if (maybeComponent(el) ||
  1892. (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
  1893. res = 1;
  1894. }
  1895. }
  1896. return res
  1897. }
  1898. function needsNormalization (el) {
  1899. return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
  1900. }
  1901. function maybeComponent (el) {
  1902. return !isPlatformReservedTag$1(el.tag)
  1903. }
  1904. function genNode (node) {
  1905. if (node.type === 1) {
  1906. return genElement(node)
  1907. } else {
  1908. return genText(node)
  1909. }
  1910. }
  1911. function genText (text) {
  1912. return ("_v(" + (text.type === 2
  1913. ? text.expression // no need for () because already wrapped in _s()
  1914. : transformSpecialNewlines(JSON.stringify(text.text))) + ")")
  1915. }
  1916. function genSlot (el) {
  1917. var slotName = el.slotName || '"default"';
  1918. var children = genChildren(el);
  1919. var res = "_t(" + slotName + (children ? ("," + children) : '');
  1920. var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
  1921. var bind$$1 = el.attrsMap['v-bind'];
  1922. if ((attrs || bind$$1) && !children) {
  1923. res += ",null";
  1924. }
  1925. if (attrs) {
  1926. res += "," + attrs;
  1927. }
  1928. if (bind$$1) {
  1929. res += (attrs ? '' : ',null') + "," + bind$$1;
  1930. }
  1931. return res + ')'
  1932. }
  1933. // componentName is el.component, take it as argument to shun flow's pessimistic refinement
  1934. function genComponent (componentName, el) {
  1935. var children = el.inlineTemplate ? null : genChildren(el, true);
  1936. return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")")
  1937. }
  1938. function genProps (props) {
  1939. var res = '';
  1940. for (var i = 0; i < props.length; i++) {
  1941. var prop = props[i];
  1942. res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
  1943. }
  1944. return res.slice(0, -1)
  1945. }
  1946. // #3895, #4268
  1947. function transformSpecialNewlines (text) {
  1948. return text
  1949. .replace(/\u2028/g, '\\u2028')
  1950. .replace(/\u2029/g, '\\u2029')
  1951. }
  1952. /* */
  1953. /**
  1954. * Compile a template.
  1955. */
  1956. function compile$2 (
  1957. template,
  1958. options
  1959. ) {
  1960. var ast = parse(template.trim(), options);
  1961. optimize(ast, options);
  1962. var code = generate(ast, options);
  1963. return {
  1964. ast: ast,
  1965. render: code.render,
  1966. staticRenderFns: code.staticRenderFns
  1967. }
  1968. }
  1969. /* */
  1970. // operators like typeof, instanceof and in are allowed
  1971. var prohibitedKeywordRE = new RegExp('\\b' + (
  1972. 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
  1973. 'super,throw,while,yield,delete,export,import,return,switch,default,' +
  1974. 'extends,finally,continue,debugger,function,arguments'
  1975. ).split(',').join('\\b|\\b') + '\\b');
  1976. // check valid identifier for v-for
  1977. var identRE = /[A-Za-z_$][\w$]*/;
  1978. // strip strings in expressions
  1979. var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
  1980. // detect problematic expressions in a template
  1981. function detectErrors (ast) {
  1982. var errors = [];
  1983. if (ast) {
  1984. checkNode(ast, errors);
  1985. }
  1986. return errors
  1987. }
  1988. function checkNode (node, errors) {
  1989. if (node.type === 1) {
  1990. for (var name in node.attrsMap) {
  1991. if (dirRE.test(name)) {
  1992. var value = node.attrsMap[name];
  1993. if (value) {
  1994. if (name === 'v-for') {
  1995. checkFor(node, ("v-for=\"" + value + "\""), errors);
  1996. } else {
  1997. checkExpression(value, (name + "=\"" + value + "\""), errors);
  1998. }
  1999. }
  2000. }
  2001. }
  2002. if (node.children) {
  2003. for (var i = 0; i < node.children.length; i++) {
  2004. checkNode(node.children[i], errors);
  2005. }
  2006. }
  2007. } else if (node.type === 2) {
  2008. checkExpression(node.expression, node.text, errors);
  2009. }
  2010. }
  2011. function checkFor (node, text, errors) {
  2012. checkExpression(node.for || '', text, errors);
  2013. checkIdentifier(node.alias, 'v-for alias', text, errors);
  2014. checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
  2015. checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
  2016. }
  2017. function checkIdentifier (ident, type, text, errors) {
  2018. if (typeof ident === 'string' && !identRE.test(ident)) {
  2019. errors.push(("- invalid " + type + " \"" + ident + "\" in expression: " + text));
  2020. }
  2021. }
  2022. function checkExpression (exp, text, errors) {
  2023. try {
  2024. new Function(("return " + exp));
  2025. } catch (e) {
  2026. var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
  2027. if (keywordMatch) {
  2028. errors.push(
  2029. "- avoid using JavaScript keyword as property name: " +
  2030. "\"" + (keywordMatch[0]) + "\" in expression " + text
  2031. );
  2032. } else {
  2033. errors.push(("- invalid expression: " + text));
  2034. }
  2035. }
  2036. }
  2037. /* */
  2038. function transformNode (el, options) {
  2039. var warn = options.warn || baseWarn;
  2040. var staticClass = getAndRemoveAttr(el, 'class');
  2041. var ref = parseStaticClass(staticClass, options);
  2042. var dynamic = ref.dynamic;
  2043. var classResult = ref.classResult;
  2044. if (process.env.NODE_ENV !== 'production' && dynamic && staticClass) {
  2045. warn(
  2046. "class=\"" + staticClass + "\": " +
  2047. 'Interpolation inside attributes has been deprecated. ' +
  2048. 'Use v-bind or the colon shorthand instead.'
  2049. );
  2050. }
  2051. if (!dynamic && classResult) {
  2052. el.staticClass = classResult;
  2053. }
  2054. var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
  2055. if (classBinding) {
  2056. el.classBinding = classBinding;
  2057. } else if (dynamic) {
  2058. el.classBinding = classResult;
  2059. }
  2060. }
  2061. function genData$1 (el) {
  2062. var data = '';
  2063. if (el.staticClass) {
  2064. data += "staticClass:" + (el.staticClass) + ",";
  2065. }
  2066. if (el.classBinding) {
  2067. data += "class:" + (el.classBinding) + ",";
  2068. }
  2069. return data
  2070. }
  2071. function parseStaticClass (staticClass, options) {
  2072. // "a b c" -> ["a", "b", "c"] => staticClass: ["a", "b", "c"]
  2073. // "a {{x}} c" -> ["a", x, "c"] => classBinding: '["a", x, "c"]'
  2074. var dynamic = false;
  2075. var classResult = '';
  2076. if (staticClass) {
  2077. var classList = staticClass.trim().split(' ').map(function (name) {
  2078. var result = parseText(name, options.delimiters);
  2079. if (result) {
  2080. dynamic = true;
  2081. return result
  2082. }
  2083. return JSON.stringify(name)
  2084. });
  2085. if (classList.length) {
  2086. classResult = '[' + classList.join(',') + ']';
  2087. }
  2088. }
  2089. return { dynamic: dynamic, classResult: classResult }
  2090. }
  2091. var klass = {
  2092. staticKeys: ['staticClass'],
  2093. transformNode: transformNode,
  2094. genData: genData$1
  2095. };
  2096. /* */
  2097. var normalize = cached(camelize);
  2098. function transformNode$1 (el, options) {
  2099. var warn = options.warn || baseWarn;
  2100. var staticStyle = getAndRemoveAttr(el, 'style');
  2101. var ref = parseStaticStyle(staticStyle, options);
  2102. var dynamic = ref.dynamic;
  2103. var styleResult = ref.styleResult;
  2104. if (process.env.NODE_ENV !== 'production' && dynamic) {
  2105. warn(
  2106. "style=\"" + (String(staticStyle)) + "\": " +
  2107. 'Interpolation inside attributes has been deprecated. ' +
  2108. 'Use v-bind or the colon shorthand instead.'
  2109. );
  2110. }
  2111. if (!dynamic && styleResult) {
  2112. el.staticStyle = styleResult;
  2113. }
  2114. var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
  2115. if (styleBinding) {
  2116. el.styleBinding = styleBinding;
  2117. } else if (dynamic) {
  2118. el.styleBinding = styleResult;
  2119. }
  2120. }
  2121. function genData$2 (el) {
  2122. var data = '';
  2123. if (el.staticStyle) {
  2124. data += "staticStyle:" + (el.staticStyle) + ",";
  2125. }
  2126. if (el.styleBinding) {
  2127. data += "style:" + (el.styleBinding) + ",";
  2128. }
  2129. return data
  2130. }
  2131. function parseStaticStyle (staticStyle, options) {
  2132. // "width: 200px; height: 200px;" -> {width: 200, height: 200}
  2133. // "width: 200px; height: {{y}}" -> {width: 200, height: y}
  2134. var dynamic = false;
  2135. var styleResult = '';
  2136. if (staticStyle) {
  2137. var styleList = staticStyle.trim().split(';').map(function (style) {
  2138. var result = style.trim().split(':');
  2139. if (result.length !== 2) {
  2140. return
  2141. }
  2142. var key = normalize(result[0].trim());
  2143. var value = result[1].trim();
  2144. var dynamicValue = parseText(value, options.delimiters);
  2145. if (dynamicValue) {
  2146. dynamic = true;
  2147. return key + ':' + dynamicValue
  2148. }
  2149. return key + ':' + JSON.stringify(value)
  2150. }).filter(function (result) { return result; });
  2151. if (styleList.length) {
  2152. styleResult = '{' + styleList.join(',') + '}';
  2153. }
  2154. }
  2155. return { dynamic: dynamic, styleResult: styleResult }
  2156. }
  2157. var style = {
  2158. staticKeys: ['staticStyle'],
  2159. transformNode: transformNode$1,
  2160. genData: genData$2
  2161. };
  2162. /* */
  2163. function transformNode$2 (el, options) {
  2164. if (el.tag === 'cell' && !el.attrsList.some(function (item) { return item.name === 'append'; })) {
  2165. el.attrsMap.append = 'tree';
  2166. el.attrsList.push({ name: 'append', value: 'tree' });
  2167. }
  2168. if (el.attrsMap.append === 'tree') {
  2169. el.appendAsTree = true;
  2170. }
  2171. }
  2172. function genData$3 (el) {
  2173. return el.appendAsTree ? "appendAsTree:true," : ''
  2174. }
  2175. var append = {
  2176. staticKeys: ['appendAsTree'],
  2177. transformNode: transformNode$2,
  2178. genData: genData$3
  2179. };
  2180. var modules = [
  2181. klass,
  2182. style,
  2183. append
  2184. ];
  2185. /* */
  2186. function model (
  2187. el,
  2188. dir,
  2189. _warn
  2190. ) {
  2191. genDefaultModel(el, dir.value, dir.modifiers);
  2192. }
  2193. function genDefaultModel (
  2194. el,
  2195. value,
  2196. modifiers
  2197. ) {
  2198. var ref = modifiers || {};
  2199. var lazy = ref.lazy;
  2200. var trim = ref.trim;
  2201. var event = lazy ? 'change' : 'input';
  2202. var isNative = el.tag === 'input' || el.tag === 'textarea';
  2203. var valueExpression = isNative
  2204. ? ("$event.target.attr.value" + (trim ? '.trim()' : ''))
  2205. : "$event";
  2206. var code = genAssignmentCode(value, valueExpression);
  2207. addAttr(el, 'value', ("(" + value + ")"));
  2208. addHandler(el, event, code, null, true);
  2209. }
  2210. function genAssignmentCode (value, assignment) {
  2211. var modelRs = parseModel(value);
  2212. if (modelRs.idx === null) {
  2213. return (value + "=" + assignment)
  2214. } else {
  2215. return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" +
  2216. "if (!Array.isArray($$exp)){" +
  2217. value + "=" + assignment + "}" +
  2218. "else{$$exp.splice($$idx, 1, " + assignment + ")}"
  2219. }
  2220. }
  2221. var directives = {
  2222. model: model
  2223. };
  2224. var latestNodeId = 1;
  2225. function TextNode (text) {
  2226. this.instanceId = '';
  2227. this.nodeId = latestNodeId++;
  2228. this.parentNode = null;
  2229. this.nodeType = 3;
  2230. this.text = text;
  2231. }
  2232. var renderer = {
  2233. TextNode: TextNode,
  2234. instances: {},
  2235. modules: {},
  2236. components: {}
  2237. };
  2238. var isReservedTag = makeMap(
  2239. 'div,img,image,input,switch,indicator,list,scroller,cell,template,text,slider,image'
  2240. );
  2241. function isUnaryTag$1 () { /* console.log('isUnaryTag') */ }
  2242. function mustUseProp () { /* console.log('mustUseProp') */ }
  2243. function getTagNamespace () { /* console.log('getTagNamespace') */ }
  2244. /* */
  2245. var cache = Object.create(null);
  2246. var baseOptions = {
  2247. preserveWhitespace: false,
  2248. modules: modules,
  2249. staticKeys: genStaticKeys(modules),
  2250. directives: directives,
  2251. isReservedTag: isReservedTag,
  2252. isUnaryTag: isUnaryTag$1,
  2253. mustUseProp: mustUseProp,
  2254. getTagNamespace: getTagNamespace
  2255. };
  2256. function compile$1 (
  2257. template,
  2258. options
  2259. ) {
  2260. options = options
  2261. ? extend(extend({}, baseOptions), options)
  2262. : baseOptions;
  2263. return compile$2(template, options)
  2264. }
  2265. function makeFunction (code) {
  2266. try {
  2267. return new Function(code)
  2268. } catch (e) {
  2269. return noop
  2270. }
  2271. }
  2272. /* */
  2273. function compile$$1 (
  2274. template,
  2275. options
  2276. ) {
  2277. options = options || {};
  2278. var errors = [];
  2279. // allow injecting modules/directives
  2280. var baseModules = baseOptions.modules || [];
  2281. var modules = options.modules
  2282. ? baseModules.concat(options.modules)
  2283. : baseModules;
  2284. var directives = options.directives
  2285. ? extend(extend({}, baseOptions.directives), options.directives)
  2286. : baseOptions.directives;
  2287. var compiled = compile$1(template, {
  2288. modules: modules,
  2289. directives: directives,
  2290. warn: function (msg) {
  2291. errors.push(msg);
  2292. }
  2293. });
  2294. compiled.errors = errors.concat(detectErrors(compiled.ast));
  2295. return compiled
  2296. }
  2297. exports.compile = compile$$1;