build.js 77 KB

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