jass-vue 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +43 -0
- data/lib/jass/vue.rb +12 -0
- data/lib/jass/vue/version.rb +5 -0
- data/vendor/node_modules/arr-diff/index.js +58 -0
- data/vendor/node_modules/arr-diff/package.json +49 -0
- data/vendor/node_modules/arr-flatten/index.js +22 -0
- data/vendor/node_modules/arr-flatten/package.json +76 -0
- data/vendor/node_modules/array-unique/index.js +28 -0
- data/vendor/node_modules/array-unique/package.json +37 -0
- data/vendor/node_modules/braces/index.js +399 -0
- data/vendor/node_modules/braces/package.json +83 -0
- data/vendor/node_modules/de-indent/index.js +45 -0
- data/vendor/node_modules/de-indent/package.json +25 -0
- data/vendor/node_modules/de-indent/test.js +30 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.es.js +55 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.es6.js +59 -0
- data/vendor/node_modules/estree-walker/dist/estree-walker.umd.js +65 -0
- data/vendor/node_modules/estree-walker/package.json +33 -0
- data/vendor/node_modules/estree-walker/src/estree-walker.js +49 -0
- data/vendor/node_modules/expand-brackets/index.js +163 -0
- data/vendor/node_modules/expand-brackets/package.json +62 -0
- data/vendor/node_modules/expand-range/index.js +43 -0
- data/vendor/node_modules/expand-range/package.json +73 -0
- data/vendor/node_modules/extglob/index.js +178 -0
- data/vendor/node_modules/extglob/package.json +60 -0
- data/vendor/node_modules/filename-regex/index.js +10 -0
- data/vendor/node_modules/filename-regex/package.json +50 -0
- data/vendor/node_modules/fill-range/index.js +408 -0
- data/vendor/node_modules/fill-range/package.json +61 -0
- data/vendor/node_modules/for-in/index.js +16 -0
- data/vendor/node_modules/for-in/package.json +68 -0
- data/vendor/node_modules/for-own/index.js +19 -0
- data/vendor/node_modules/for-own/package.json +70 -0
- data/vendor/node_modules/glob-base/index.js +51 -0
- data/vendor/node_modules/glob-base/package.json +52 -0
- data/vendor/node_modules/glob-parent/index.js +10 -0
- data/vendor/node_modules/glob-parent/package.json +35 -0
- data/vendor/node_modules/glob-parent/test.js +28 -0
- data/vendor/node_modules/he/bin/he +148 -0
- data/vendor/node_modules/he/he.js +342 -0
- data/vendor/node_modules/he/man/he.1 +78 -0
- data/vendor/node_modules/he/package.json +56 -0
- data/vendor/node_modules/is-buffer/index.js +21 -0
- data/vendor/node_modules/is-buffer/package.json +51 -0
- data/vendor/node_modules/is-dotfile/index.js +14 -0
- data/vendor/node_modules/is-dotfile/package.json +69 -0
- data/vendor/node_modules/is-equal-shallow/index.js +27 -0
- data/vendor/node_modules/is-equal-shallow/package.json +54 -0
- data/vendor/node_modules/is-extendable/index.js +13 -0
- data/vendor/node_modules/is-extendable/package.json +51 -0
- data/vendor/node_modules/is-extglob/index.js +11 -0
- data/vendor/node_modules/is-extglob/package.json +48 -0
- data/vendor/node_modules/is-glob/index.js +14 -0
- data/vendor/node_modules/is-glob/package.json +60 -0
- data/vendor/node_modules/is-number/index.js +19 -0
- data/vendor/node_modules/is-number/package.json +59 -0
- data/vendor/node_modules/is-posix-bracket/index.js +10 -0
- data/vendor/node_modules/is-posix-bracket/package.json +64 -0
- data/vendor/node_modules/is-primitive/index.js +13 -0
- data/vendor/node_modules/is-primitive/package.json +46 -0
- data/vendor/node_modules/isarray/index.js +5 -0
- data/vendor/node_modules/isarray/package.json +45 -0
- data/vendor/node_modules/isarray/test.js +20 -0
- data/vendor/node_modules/isobject/index.js +14 -0
- data/vendor/node_modules/isobject/package.json +67 -0
- data/vendor/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/magic-string/dist/magic-string.cjs.js +1287 -0
- data/vendor/node_modules/magic-string/dist/magic-string.es.js +1283 -0
- data/vendor/node_modules/magic-string/dist/magic-string.umd.js +1339 -0
- data/vendor/node_modules/magic-string/package.json +60 -0
- data/vendor/node_modules/magic-string/src/Bundle.js +263 -0
- data/vendor/node_modules/magic-string/src/Chunk.js +154 -0
- data/vendor/node_modules/magic-string/src/MagicString.js +618 -0
- data/vendor/node_modules/magic-string/src/index-legacy.js +6 -0
- data/vendor/node_modules/magic-string/src/index.js +4 -0
- data/vendor/node_modules/magic-string/src/utils/Mappings.js +117 -0
- data/vendor/node_modules/magic-string/src/utils/SourceMap.js +21 -0
- data/vendor/node_modules/magic-string/src/utils/Stats.js +18 -0
- data/vendor/node_modules/magic-string/src/utils/btoa.js +13 -0
- data/vendor/node_modules/magic-string/src/utils/getLocator.js +35 -0
- data/vendor/node_modules/magic-string/src/utils/getRelativePath.js +18 -0
- data/vendor/node_modules/magic-string/src/utils/guessIndent.js +25 -0
- data/vendor/node_modules/magic-string/src/utils/hasOwnProp.js +1 -0
- data/vendor/node_modules/magic-string/src/utils/isObject.js +5 -0
- data/vendor/node_modules/micromatch/index.js +431 -0
- data/vendor/node_modules/micromatch/lib/chars.js +67 -0
- data/vendor/node_modules/micromatch/lib/expand.js +304 -0
- data/vendor/node_modules/micromatch/lib/glob.js +193 -0
- data/vendor/node_modules/micromatch/lib/utils.js +149 -0
- data/vendor/node_modules/micromatch/package.json +114 -0
- data/vendor/node_modules/normalize-path/index.js +19 -0
- data/vendor/node_modules/normalize-path/package.json +78 -0
- data/vendor/node_modules/object.omit/index.js +40 -0
- data/vendor/node_modules/object.omit/package.json +67 -0
- data/vendor/node_modules/parse-glob/index.js +156 -0
- data/vendor/node_modules/parse-glob/package.json +62 -0
- data/vendor/node_modules/preserve/index.js +54 -0
- data/vendor/node_modules/preserve/package.json +48 -0
- data/vendor/node_modules/preserve/test.js +48 -0
- data/vendor/node_modules/randomatic/index.js +82 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/index.js +22 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/index.js +116 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/node_modules/is-number/package.json +83 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/index.js +119 -0
- data/vendor/node_modules/randomatic/node_modules/kind-of/package.json +90 -0
- data/vendor/node_modules/randomatic/package.json +78 -0
- data/vendor/node_modules/regex-cache/index.js +68 -0
- data/vendor/node_modules/regex-cache/package.json +64 -0
- data/vendor/node_modules/remove-trailing-separator/index.js +17 -0
- data/vendor/node_modules/remove-trailing-separator/package.json +37 -0
- data/vendor/node_modules/repeat-element/index.js +18 -0
- data/vendor/node_modules/repeat-element/package.json +44 -0
- data/vendor/node_modules/repeat-string/index.js +70 -0
- data/vendor/node_modules/repeat-string/package.json +77 -0
- data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.common.js +164 -0
- data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.es.js +160 -0
- data/vendor/node_modules/rollup-plugin-vue2/package.json +50 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +223 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es.js +214 -0
- data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es6.js +217 -0
- data/vendor/node_modules/rollup-pluginutils/package.json +40 -0
- data/vendor/node_modules/rollup-pluginutils/src/addExtension.js +6 -0
- data/vendor/node_modules/rollup-pluginutils/src/attachScopes.js +147 -0
- data/vendor/node_modules/rollup-pluginutils/src/createFilter.js +33 -0
- data/vendor/node_modules/rollup-pluginutils/src/index.js +4 -0
- data/vendor/node_modules/rollup-pluginutils/src/makeLegalIdentifier.js +15 -0
- data/vendor/node_modules/rollup-pluginutils/src/utils/ensureArray.js +5 -0
- data/vendor/node_modules/vlq/dist/vlq.js +91 -0
- data/vendor/node_modules/vlq/package.json +27 -0
- data/vendor/node_modules/vlq/src/vlq.js +78 -0
- data/vendor/node_modules/vue-template-compiler/browser.js +5237 -0
- data/vendor/node_modules/vue-template-compiler/build.js +4835 -0
- data/vendor/node_modules/vue-template-compiler/index.js +18 -0
- data/vendor/node_modules/vue-template-compiler/package.json +27 -0
- data/vendor/node_modules/vue-template-es2015-compiler/buble.js +14112 -0
- data/vendor/node_modules/vue-template-es2015-compiler/index.js +24 -0
- data/vendor/node_modules/vue-template-es2015-compiler/package.json +28 -0
- data/vendor/package.json +9 -0
- data/vendor/yarn.lock +268 -0
- metadata +242 -0
@@ -0,0 +1,4835 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
6
|
+
|
7
|
+
var deindent = _interopDefault(require('de-indent'));
|
8
|
+
var he = _interopDefault(require('he'));
|
9
|
+
|
10
|
+
/* */
|
11
|
+
|
12
|
+
var emptyObject = Object.freeze({});
|
13
|
+
|
14
|
+
// these helpers produces better vm code in JS engines due to their
|
15
|
+
// explicitness and function inlining
|
16
|
+
function isUndef (v) {
|
17
|
+
return v === undefined || v === null
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Check if value is primitive
|
28
|
+
*/
|
29
|
+
function isPrimitive (value) {
|
30
|
+
return (
|
31
|
+
typeof value === 'string' ||
|
32
|
+
typeof value === 'number' ||
|
33
|
+
// $flow-disable-line
|
34
|
+
typeof value === 'symbol' ||
|
35
|
+
typeof value === 'boolean'
|
36
|
+
)
|
37
|
+
}
|
38
|
+
|
39
|
+
/**
|
40
|
+
* Quick object check - this is primarily used to tell
|
41
|
+
* Objects from primitive values when we know the value
|
42
|
+
* is a JSON-compliant type.
|
43
|
+
*/
|
44
|
+
function isObject (obj) {
|
45
|
+
return obj !== null && typeof obj === 'object'
|
46
|
+
}
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Get the raw type string of a value e.g. [object Object]
|
50
|
+
*/
|
51
|
+
var _toString = Object.prototype.toString;
|
52
|
+
|
53
|
+
function toRawType (value) {
|
54
|
+
return _toString.call(value).slice(8, -1)
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Strict object type check. Only returns true
|
59
|
+
* for plain JavaScript objects.
|
60
|
+
*/
|
61
|
+
function isPlainObject (obj) {
|
62
|
+
return _toString.call(obj) === '[object Object]'
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Check if val is a valid array index.
|
69
|
+
*/
|
70
|
+
function isValidArrayIndex (val) {
|
71
|
+
var n = parseFloat(String(val));
|
72
|
+
return n >= 0 && Math.floor(n) === n && isFinite(val)
|
73
|
+
}
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Convert a value to a string that is actually rendered.
|
77
|
+
*/
|
78
|
+
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Convert a input value to a number for persistence.
|
82
|
+
* If the conversion fails, return original string.
|
83
|
+
*/
|
84
|
+
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Make a map and return a function for checking if a key
|
88
|
+
* is in that map.
|
89
|
+
*/
|
90
|
+
function makeMap (
|
91
|
+
str,
|
92
|
+
expectsLowerCase
|
93
|
+
) {
|
94
|
+
var map = Object.create(null);
|
95
|
+
var list = str.split(',');
|
96
|
+
for (var i = 0; i < list.length; i++) {
|
97
|
+
map[list[i]] = true;
|
98
|
+
}
|
99
|
+
return expectsLowerCase
|
100
|
+
? function (val) { return map[val.toLowerCase()]; }
|
101
|
+
: function (val) { return map[val]; }
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* Check if a tag is a built-in tag.
|
106
|
+
*/
|
107
|
+
var isBuiltInTag = makeMap('slot,component', true);
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Check if a attribute is a reserved attribute.
|
111
|
+
*/
|
112
|
+
var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Remove an item from an array
|
116
|
+
*/
|
117
|
+
function remove (arr, item) {
|
118
|
+
if (arr.length) {
|
119
|
+
var index = arr.indexOf(item);
|
120
|
+
if (index > -1) {
|
121
|
+
return arr.splice(index, 1)
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Check whether the object has the property.
|
128
|
+
*/
|
129
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
130
|
+
function hasOwn (obj, key) {
|
131
|
+
return hasOwnProperty.call(obj, key)
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* Create a cached version of a pure function.
|
136
|
+
*/
|
137
|
+
function cached (fn) {
|
138
|
+
var cache = Object.create(null);
|
139
|
+
return (function cachedFn (str) {
|
140
|
+
var hit = cache[str];
|
141
|
+
return hit || (cache[str] = fn(str))
|
142
|
+
})
|
143
|
+
}
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Camelize a hyphen-delimited string.
|
147
|
+
*/
|
148
|
+
var camelizeRE = /-(\w)/g;
|
149
|
+
var camelize = cached(function (str) {
|
150
|
+
return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
|
151
|
+
});
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Capitalize a string.
|
155
|
+
*/
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
/**
|
161
|
+
* Simple bind polyfill for environments that do not support it... e.g.
|
162
|
+
* PhantomJS 1.x. Technically we don't need this anymore since native bind is
|
163
|
+
* now more performant in most browsers, but removing it would be breaking for
|
164
|
+
* code that was able to run in PhantomJS 1.x, so this must be kept for
|
165
|
+
* backwards compatibility.
|
166
|
+
*/
|
167
|
+
|
168
|
+
/* istanbul ignore next */
|
169
|
+
function polyfillBind (fn, ctx) {
|
170
|
+
function boundFn (a) {
|
171
|
+
var l = arguments.length;
|
172
|
+
return l
|
173
|
+
? l > 1
|
174
|
+
? fn.apply(ctx, arguments)
|
175
|
+
: fn.call(ctx, a)
|
176
|
+
: fn.call(ctx)
|
177
|
+
}
|
178
|
+
|
179
|
+
boundFn._length = fn.length;
|
180
|
+
return boundFn
|
181
|
+
}
|
182
|
+
|
183
|
+
function nativeBind (fn, ctx) {
|
184
|
+
return fn.bind(ctx)
|
185
|
+
}
|
186
|
+
|
187
|
+
var bind = Function.prototype.bind
|
188
|
+
? nativeBind
|
189
|
+
: polyfillBind;
|
190
|
+
|
191
|
+
/**
|
192
|
+
* Convert an Array-like object to a real Array.
|
193
|
+
*/
|
194
|
+
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Mix properties into target object.
|
198
|
+
*/
|
199
|
+
function extend (to, _from) {
|
200
|
+
for (var key in _from) {
|
201
|
+
to[key] = _from[key];
|
202
|
+
}
|
203
|
+
return to
|
204
|
+
}
|
205
|
+
|
206
|
+
/**
|
207
|
+
* Merge an Array of Objects into a single Object.
|
208
|
+
*/
|
209
|
+
|
210
|
+
|
211
|
+
/**
|
212
|
+
* Perform no operation.
|
213
|
+
* Stubbing args to make Flow happy without leaving useless transpiled code
|
214
|
+
* with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
|
215
|
+
*/
|
216
|
+
function noop (a, b, c) {}
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Always return false.
|
220
|
+
*/
|
221
|
+
var no = function (a, b, c) { return false; };
|
222
|
+
|
223
|
+
/**
|
224
|
+
* Return same value
|
225
|
+
*/
|
226
|
+
var identity = function (_) { return _; };
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Generate a static keys string from compiler modules.
|
230
|
+
*/
|
231
|
+
function genStaticKeys (modules) {
|
232
|
+
return modules.reduce(function (keys, m) {
|
233
|
+
return keys.concat(m.staticKeys || [])
|
234
|
+
}, []).join(',')
|
235
|
+
}
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Check if two values are loosely equal - that is,
|
239
|
+
* if they are plain objects, do they have the same shape?
|
240
|
+
*/
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Ensure a function is called only once.
|
247
|
+
*/
|
248
|
+
|
249
|
+
/* */
|
250
|
+
|
251
|
+
var isUnaryTag = makeMap(
|
252
|
+
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
|
253
|
+
'link,meta,param,source,track,wbr'
|
254
|
+
);
|
255
|
+
|
256
|
+
// Elements that you can, intentionally, leave open
|
257
|
+
// (and which close themselves)
|
258
|
+
var canBeLeftOpenTag = makeMap(
|
259
|
+
'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
|
260
|
+
);
|
261
|
+
|
262
|
+
// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
|
263
|
+
// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
|
264
|
+
var isNonPhrasingTag = makeMap(
|
265
|
+
'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
|
266
|
+
'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
|
267
|
+
'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
|
268
|
+
'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
|
269
|
+
'title,tr,track'
|
270
|
+
);
|
271
|
+
|
272
|
+
/**
|
273
|
+
* Not type-checking this file because it's mostly vendor code.
|
274
|
+
*/
|
275
|
+
|
276
|
+
/*!
|
277
|
+
* HTML Parser By John Resig (ejohn.org)
|
278
|
+
* Modified by Juriy "kangax" Zaytsev
|
279
|
+
* Original code by Erik Arvidsson, Mozilla Public License
|
280
|
+
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
|
281
|
+
*/
|
282
|
+
|
283
|
+
// Regular Expressions for parsing tags and attributes
|
284
|
+
var attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
|
285
|
+
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
|
286
|
+
// but for Vue templates we can enforce a simple charset
|
287
|
+
var ncname = '[a-zA-Z_][\\w\\-\\.]*';
|
288
|
+
var qnameCapture = "((?:" + ncname + "\\:)?" + ncname + ")";
|
289
|
+
var startTagOpen = new RegExp(("^<" + qnameCapture));
|
290
|
+
var startTagClose = /^\s*(\/?)>/;
|
291
|
+
var endTag = new RegExp(("^<\\/" + qnameCapture + "[^>]*>"));
|
292
|
+
var doctype = /^<!DOCTYPE [^>]+>/i;
|
293
|
+
// #7298: escape - to avoid being pased as HTML comment when inlined in page
|
294
|
+
var comment = /^<!\--/;
|
295
|
+
var conditionalComment = /^<!\[/;
|
296
|
+
|
297
|
+
var IS_REGEX_CAPTURING_BROKEN = false;
|
298
|
+
'x'.replace(/x(.)?/g, function (m, g) {
|
299
|
+
IS_REGEX_CAPTURING_BROKEN = g === '';
|
300
|
+
});
|
301
|
+
|
302
|
+
// Special Elements (can contain anything)
|
303
|
+
var isPlainTextElement = makeMap('script,style,textarea', true);
|
304
|
+
var reCache = {};
|
305
|
+
|
306
|
+
var decodingMap = {
|
307
|
+
'<': '<',
|
308
|
+
'>': '>',
|
309
|
+
'"': '"',
|
310
|
+
'&': '&',
|
311
|
+
' ': '\n',
|
312
|
+
'	': '\t'
|
313
|
+
};
|
314
|
+
var encodedAttr = /&(?:lt|gt|quot|amp);/g;
|
315
|
+
var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10|#9);/g;
|
316
|
+
|
317
|
+
// #5992
|
318
|
+
var isIgnoreNewlineTag = makeMap('pre,textarea', true);
|
319
|
+
var shouldIgnoreFirstNewline = function (tag, html) { return tag && isIgnoreNewlineTag(tag) && html[0] === '\n'; };
|
320
|
+
|
321
|
+
function decodeAttr (value, shouldDecodeNewlines) {
|
322
|
+
var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr;
|
323
|
+
return value.replace(re, function (match) { return decodingMap[match]; })
|
324
|
+
}
|
325
|
+
|
326
|
+
function parseHTML (html, options) {
|
327
|
+
var stack = [];
|
328
|
+
var expectHTML = options.expectHTML;
|
329
|
+
var isUnaryTag$$1 = options.isUnaryTag || no;
|
330
|
+
var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no;
|
331
|
+
var index = 0;
|
332
|
+
var last, lastTag;
|
333
|
+
while (html) {
|
334
|
+
last = html;
|
335
|
+
// Make sure we're not in a plaintext content element like script/style
|
336
|
+
if (!lastTag || !isPlainTextElement(lastTag)) {
|
337
|
+
var textEnd = html.indexOf('<');
|
338
|
+
if (textEnd === 0) {
|
339
|
+
// Comment:
|
340
|
+
if (comment.test(html)) {
|
341
|
+
var commentEnd = html.indexOf('-->');
|
342
|
+
|
343
|
+
if (commentEnd >= 0) {
|
344
|
+
if (options.shouldKeepComment) {
|
345
|
+
options.comment(html.substring(4, commentEnd));
|
346
|
+
}
|
347
|
+
advance(commentEnd + 3);
|
348
|
+
continue
|
349
|
+
}
|
350
|
+
}
|
351
|
+
|
352
|
+
// http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
|
353
|
+
if (conditionalComment.test(html)) {
|
354
|
+
var conditionalEnd = html.indexOf(']>');
|
355
|
+
|
356
|
+
if (conditionalEnd >= 0) {
|
357
|
+
advance(conditionalEnd + 2);
|
358
|
+
continue
|
359
|
+
}
|
360
|
+
}
|
361
|
+
|
362
|
+
// Doctype:
|
363
|
+
var doctypeMatch = html.match(doctype);
|
364
|
+
if (doctypeMatch) {
|
365
|
+
advance(doctypeMatch[0].length);
|
366
|
+
continue
|
367
|
+
}
|
368
|
+
|
369
|
+
// End tag:
|
370
|
+
var endTagMatch = html.match(endTag);
|
371
|
+
if (endTagMatch) {
|
372
|
+
var curIndex = index;
|
373
|
+
advance(endTagMatch[0].length);
|
374
|
+
parseEndTag(endTagMatch[1], curIndex, index);
|
375
|
+
continue
|
376
|
+
}
|
377
|
+
|
378
|
+
// Start tag:
|
379
|
+
var startTagMatch = parseStartTag();
|
380
|
+
if (startTagMatch) {
|
381
|
+
handleStartTag(startTagMatch);
|
382
|
+
if (shouldIgnoreFirstNewline(lastTag, html)) {
|
383
|
+
advance(1);
|
384
|
+
}
|
385
|
+
continue
|
386
|
+
}
|
387
|
+
}
|
388
|
+
|
389
|
+
var text = (void 0), rest = (void 0), next = (void 0);
|
390
|
+
if (textEnd >= 0) {
|
391
|
+
rest = html.slice(textEnd);
|
392
|
+
while (
|
393
|
+
!endTag.test(rest) &&
|
394
|
+
!startTagOpen.test(rest) &&
|
395
|
+
!comment.test(rest) &&
|
396
|
+
!conditionalComment.test(rest)
|
397
|
+
) {
|
398
|
+
// < in plain text, be forgiving and treat it as text
|
399
|
+
next = rest.indexOf('<', 1);
|
400
|
+
if (next < 0) { break }
|
401
|
+
textEnd += next;
|
402
|
+
rest = html.slice(textEnd);
|
403
|
+
}
|
404
|
+
text = html.substring(0, textEnd);
|
405
|
+
advance(textEnd);
|
406
|
+
}
|
407
|
+
|
408
|
+
if (textEnd < 0) {
|
409
|
+
text = html;
|
410
|
+
html = '';
|
411
|
+
}
|
412
|
+
|
413
|
+
if (options.chars && text) {
|
414
|
+
options.chars(text);
|
415
|
+
}
|
416
|
+
} else {
|
417
|
+
var endTagLength = 0;
|
418
|
+
var stackedTag = lastTag.toLowerCase();
|
419
|
+
var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i'));
|
420
|
+
var rest$1 = html.replace(reStackedTag, function (all, text, endTag) {
|
421
|
+
endTagLength = endTag.length;
|
422
|
+
if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') {
|
423
|
+
text = text
|
424
|
+
.replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
|
425
|
+
.replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
|
426
|
+
}
|
427
|
+
if (shouldIgnoreFirstNewline(stackedTag, text)) {
|
428
|
+
text = text.slice(1);
|
429
|
+
}
|
430
|
+
if (options.chars) {
|
431
|
+
options.chars(text);
|
432
|
+
}
|
433
|
+
return ''
|
434
|
+
});
|
435
|
+
index += html.length - rest$1.length;
|
436
|
+
html = rest$1;
|
437
|
+
parseEndTag(stackedTag, index - endTagLength, index);
|
438
|
+
}
|
439
|
+
|
440
|
+
if (html === last) {
|
441
|
+
options.chars && options.chars(html);
|
442
|
+
if (process.env.NODE_ENV !== 'production' && !stack.length && options.warn) {
|
443
|
+
options.warn(("Mal-formatted tag at end of template: \"" + html + "\""));
|
444
|
+
}
|
445
|
+
break
|
446
|
+
}
|
447
|
+
}
|
448
|
+
|
449
|
+
// Clean up any remaining tags
|
450
|
+
parseEndTag();
|
451
|
+
|
452
|
+
function advance (n) {
|
453
|
+
index += n;
|
454
|
+
html = html.substring(n);
|
455
|
+
}
|
456
|
+
|
457
|
+
function parseStartTag () {
|
458
|
+
var start = html.match(startTagOpen);
|
459
|
+
if (start) {
|
460
|
+
var match = {
|
461
|
+
tagName: start[1],
|
462
|
+
attrs: [],
|
463
|
+
start: index
|
464
|
+
};
|
465
|
+
advance(start[0].length);
|
466
|
+
var end, attr;
|
467
|
+
while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) {
|
468
|
+
advance(attr[0].length);
|
469
|
+
match.attrs.push(attr);
|
470
|
+
}
|
471
|
+
if (end) {
|
472
|
+
match.unarySlash = end[1];
|
473
|
+
advance(end[0].length);
|
474
|
+
match.end = index;
|
475
|
+
return match
|
476
|
+
}
|
477
|
+
}
|
478
|
+
}
|
479
|
+
|
480
|
+
function handleStartTag (match) {
|
481
|
+
var tagName = match.tagName;
|
482
|
+
var unarySlash = match.unarySlash;
|
483
|
+
|
484
|
+
if (expectHTML) {
|
485
|
+
if (lastTag === 'p' && isNonPhrasingTag(tagName)) {
|
486
|
+
parseEndTag(lastTag);
|
487
|
+
}
|
488
|
+
if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) {
|
489
|
+
parseEndTag(tagName);
|
490
|
+
}
|
491
|
+
}
|
492
|
+
|
493
|
+
var unary = isUnaryTag$$1(tagName) || !!unarySlash;
|
494
|
+
|
495
|
+
var l = match.attrs.length;
|
496
|
+
var attrs = new Array(l);
|
497
|
+
for (var i = 0; i < l; i++) {
|
498
|
+
var args = match.attrs[i];
|
499
|
+
// hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
|
500
|
+
if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) {
|
501
|
+
if (args[3] === '') { delete args[3]; }
|
502
|
+
if (args[4] === '') { delete args[4]; }
|
503
|
+
if (args[5] === '') { delete args[5]; }
|
504
|
+
}
|
505
|
+
var value = args[3] || args[4] || args[5] || '';
|
506
|
+
var shouldDecodeNewlines = tagName === 'a' && args[1] === 'href'
|
507
|
+
? options.shouldDecodeNewlinesForHref
|
508
|
+
: options.shouldDecodeNewlines;
|
509
|
+
attrs[i] = {
|
510
|
+
name: args[1],
|
511
|
+
value: decodeAttr(value, shouldDecodeNewlines)
|
512
|
+
};
|
513
|
+
}
|
514
|
+
|
515
|
+
if (!unary) {
|
516
|
+
stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs });
|
517
|
+
lastTag = tagName;
|
518
|
+
}
|
519
|
+
|
520
|
+
if (options.start) {
|
521
|
+
options.start(tagName, attrs, unary, match.start, match.end);
|
522
|
+
}
|
523
|
+
}
|
524
|
+
|
525
|
+
function parseEndTag (tagName, start, end) {
|
526
|
+
var pos, lowerCasedTagName;
|
527
|
+
if (start == null) { start = index; }
|
528
|
+
if (end == null) { end = index; }
|
529
|
+
|
530
|
+
if (tagName) {
|
531
|
+
lowerCasedTagName = tagName.toLowerCase();
|
532
|
+
}
|
533
|
+
|
534
|
+
// Find the closest opened tag of the same type
|
535
|
+
if (tagName) {
|
536
|
+
for (pos = stack.length - 1; pos >= 0; pos--) {
|
537
|
+
if (stack[pos].lowerCasedTag === lowerCasedTagName) {
|
538
|
+
break
|
539
|
+
}
|
540
|
+
}
|
541
|
+
} else {
|
542
|
+
// If no tag name is provided, clean shop
|
543
|
+
pos = 0;
|
544
|
+
}
|
545
|
+
|
546
|
+
if (pos >= 0) {
|
547
|
+
// Close all the open elements, up the stack
|
548
|
+
for (var i = stack.length - 1; i >= pos; i--) {
|
549
|
+
if (process.env.NODE_ENV !== 'production' &&
|
550
|
+
(i > pos || !tagName) &&
|
551
|
+
options.warn
|
552
|
+
) {
|
553
|
+
options.warn(
|
554
|
+
("tag <" + (stack[i].tag) + "> has no matching end tag.")
|
555
|
+
);
|
556
|
+
}
|
557
|
+
if (options.end) {
|
558
|
+
options.end(stack[i].tag, start, end);
|
559
|
+
}
|
560
|
+
}
|
561
|
+
|
562
|
+
// Remove the open elements from the stack
|
563
|
+
stack.length = pos;
|
564
|
+
lastTag = pos && stack[pos - 1].tag;
|
565
|
+
} else if (lowerCasedTagName === 'br') {
|
566
|
+
if (options.start) {
|
567
|
+
options.start(tagName, [], true, start, end);
|
568
|
+
}
|
569
|
+
} else if (lowerCasedTagName === 'p') {
|
570
|
+
if (options.start) {
|
571
|
+
options.start(tagName, [], false, start, end);
|
572
|
+
}
|
573
|
+
if (options.end) {
|
574
|
+
options.end(tagName, start, end);
|
575
|
+
}
|
576
|
+
}
|
577
|
+
}
|
578
|
+
}
|
579
|
+
|
580
|
+
/* */
|
581
|
+
|
582
|
+
var splitRE = /\r?\n/g;
|
583
|
+
var replaceRE = /./g;
|
584
|
+
var isSpecialTag = makeMap('script,style,template', true);
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
/**
|
589
|
+
* Parse a single-file component (*.vue) file into an SFC Descriptor Object.
|
590
|
+
*/
|
591
|
+
function parseComponent (
|
592
|
+
content,
|
593
|
+
options
|
594
|
+
) {
|
595
|
+
if ( options === void 0 ) options = {};
|
596
|
+
|
597
|
+
var sfc = {
|
598
|
+
template: null,
|
599
|
+
script: null,
|
600
|
+
styles: [],
|
601
|
+
customBlocks: []
|
602
|
+
};
|
603
|
+
var depth = 0;
|
604
|
+
var currentBlock = null;
|
605
|
+
|
606
|
+
function start (
|
607
|
+
tag,
|
608
|
+
attrs,
|
609
|
+
unary,
|
610
|
+
start,
|
611
|
+
end
|
612
|
+
) {
|
613
|
+
if (depth === 0) {
|
614
|
+
currentBlock = {
|
615
|
+
type: tag,
|
616
|
+
content: '',
|
617
|
+
start: end,
|
618
|
+
attrs: attrs.reduce(function (cumulated, ref) {
|
619
|
+
var name = ref.name;
|
620
|
+
var value = ref.value;
|
621
|
+
|
622
|
+
cumulated[name] = value || true;
|
623
|
+
return cumulated
|
624
|
+
}, {})
|
625
|
+
};
|
626
|
+
if (isSpecialTag(tag)) {
|
627
|
+
checkAttrs(currentBlock, attrs);
|
628
|
+
if (tag === 'style') {
|
629
|
+
sfc.styles.push(currentBlock);
|
630
|
+
} else {
|
631
|
+
sfc[tag] = currentBlock;
|
632
|
+
}
|
633
|
+
} else { // custom blocks
|
634
|
+
sfc.customBlocks.push(currentBlock);
|
635
|
+
}
|
636
|
+
}
|
637
|
+
if (!unary) {
|
638
|
+
depth++;
|
639
|
+
}
|
640
|
+
}
|
641
|
+
|
642
|
+
function checkAttrs (block, attrs) {
|
643
|
+
for (var i = 0; i < attrs.length; i++) {
|
644
|
+
var attr = attrs[i];
|
645
|
+
if (attr.name === 'lang') {
|
646
|
+
block.lang = attr.value;
|
647
|
+
}
|
648
|
+
if (attr.name === 'scoped') {
|
649
|
+
block.scoped = true;
|
650
|
+
}
|
651
|
+
if (attr.name === 'module') {
|
652
|
+
block.module = attr.value || true;
|
653
|
+
}
|
654
|
+
if (attr.name === 'src') {
|
655
|
+
block.src = attr.value;
|
656
|
+
}
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
function end (tag, start, end) {
|
661
|
+
if (depth === 1 && currentBlock) {
|
662
|
+
currentBlock.end = start;
|
663
|
+
var text = deindent(content.slice(currentBlock.start, currentBlock.end));
|
664
|
+
// pad content so that linters and pre-processors can output correct
|
665
|
+
// line numbers in errors and warnings
|
666
|
+
if (currentBlock.type !== 'template' && options.pad) {
|
667
|
+
text = padContent(currentBlock, options.pad) + text;
|
668
|
+
}
|
669
|
+
currentBlock.content = text;
|
670
|
+
currentBlock = null;
|
671
|
+
}
|
672
|
+
depth--;
|
673
|
+
}
|
674
|
+
|
675
|
+
function padContent (block, pad) {
|
676
|
+
if (pad === 'space') {
|
677
|
+
return content.slice(0, block.start).replace(replaceRE, ' ')
|
678
|
+
} else {
|
679
|
+
var offset = content.slice(0, block.start).split(splitRE).length;
|
680
|
+
var padChar = block.type === 'script' && !block.lang
|
681
|
+
? '//\n'
|
682
|
+
: '\n';
|
683
|
+
return Array(offset).join(padChar)
|
684
|
+
}
|
685
|
+
}
|
686
|
+
|
687
|
+
parseHTML(content, {
|
688
|
+
start: start,
|
689
|
+
end: end
|
690
|
+
});
|
691
|
+
|
692
|
+
return sfc
|
693
|
+
}
|
694
|
+
|
695
|
+
/* */
|
696
|
+
|
697
|
+
/**
|
698
|
+
* Check if a string starts with $ or _
|
699
|
+
*/
|
700
|
+
|
701
|
+
|
702
|
+
/**
|
703
|
+
* Define a property.
|
704
|
+
*/
|
705
|
+
function def (obj, key, val, enumerable) {
|
706
|
+
Object.defineProperty(obj, key, {
|
707
|
+
value: val,
|
708
|
+
enumerable: !!enumerable,
|
709
|
+
writable: true,
|
710
|
+
configurable: true
|
711
|
+
});
|
712
|
+
}
|
713
|
+
|
714
|
+
/* */
|
715
|
+
|
716
|
+
// can we use __proto__?
|
717
|
+
var hasProto = '__proto__' in {};
|
718
|
+
|
719
|
+
// Browser environment sniffing
|
720
|
+
var inBrowser = typeof window !== 'undefined';
|
721
|
+
var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
|
722
|
+
var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
|
723
|
+
var UA = inBrowser && window.navigator.userAgent.toLowerCase();
|
724
|
+
var isIE = UA && /msie|trident/.test(UA);
|
725
|
+
var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
|
726
|
+
var isEdge = UA && UA.indexOf('edge/') > 0;
|
727
|
+
var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
|
728
|
+
var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
|
729
|
+
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
|
730
|
+
|
731
|
+
// Firefox has a "watch" function on Object.prototype...
|
732
|
+
var nativeWatch = ({}).watch;
|
733
|
+
|
734
|
+
|
735
|
+
if (inBrowser) {
|
736
|
+
try {
|
737
|
+
var opts = {};
|
738
|
+
Object.defineProperty(opts, 'passive', ({
|
739
|
+
get: function get () {
|
740
|
+
/* istanbul ignore next */
|
741
|
+
|
742
|
+
}
|
743
|
+
})); // https://github.com/facebook/flow/issues/285
|
744
|
+
window.addEventListener('test-passive', null, opts);
|
745
|
+
} catch (e) {}
|
746
|
+
}
|
747
|
+
|
748
|
+
// this needs to be lazy-evaled because vue may be required before
|
749
|
+
// vue-server-renderer can set VUE_ENV
|
750
|
+
var _isServer;
|
751
|
+
var isServerRendering = function () {
|
752
|
+
if (_isServer === undefined) {
|
753
|
+
/* istanbul ignore if */
|
754
|
+
if (!inBrowser && !inWeex && typeof global !== 'undefined') {
|
755
|
+
// detect presence of vue-server-renderer and avoid
|
756
|
+
// Webpack shimming the process
|
757
|
+
_isServer = global['process'].env.VUE_ENV === 'server';
|
758
|
+
} else {
|
759
|
+
_isServer = false;
|
760
|
+
}
|
761
|
+
}
|
762
|
+
return _isServer
|
763
|
+
};
|
764
|
+
|
765
|
+
// detect devtools
|
766
|
+
var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
767
|
+
|
768
|
+
/* istanbul ignore next */
|
769
|
+
function isNative (Ctor) {
|
770
|
+
return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
|
771
|
+
}
|
772
|
+
|
773
|
+
var hasSymbol =
|
774
|
+
typeof Symbol !== 'undefined' && isNative(Symbol) &&
|
775
|
+
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
|
776
|
+
|
777
|
+
/* istanbul ignore if */ // $flow-disable-line
|
778
|
+
if (typeof Set !== 'undefined' && isNative(Set)) {
|
779
|
+
// use native Set when available.
|
780
|
+
|
781
|
+
} else {
|
782
|
+
// a non-standard Set polyfill that only works with primitive keys.
|
783
|
+
|
784
|
+
}
|
785
|
+
|
786
|
+
var ASSET_TYPES = [
|
787
|
+
'component',
|
788
|
+
'directive',
|
789
|
+
'filter'
|
790
|
+
];
|
791
|
+
|
792
|
+
var LIFECYCLE_HOOKS = [
|
793
|
+
'beforeCreate',
|
794
|
+
'created',
|
795
|
+
'beforeMount',
|
796
|
+
'mounted',
|
797
|
+
'beforeUpdate',
|
798
|
+
'updated',
|
799
|
+
'beforeDestroy',
|
800
|
+
'destroyed',
|
801
|
+
'activated',
|
802
|
+
'deactivated',
|
803
|
+
'errorCaptured'
|
804
|
+
];
|
805
|
+
|
806
|
+
/* */
|
807
|
+
|
808
|
+
var config = ({
|
809
|
+
/**
|
810
|
+
* Option merge strategies (used in core/util/options)
|
811
|
+
*/
|
812
|
+
// $flow-disable-line
|
813
|
+
optionMergeStrategies: Object.create(null),
|
814
|
+
|
815
|
+
/**
|
816
|
+
* Whether to suppress warnings.
|
817
|
+
*/
|
818
|
+
silent: false,
|
819
|
+
|
820
|
+
/**
|
821
|
+
* Show production mode tip message on boot?
|
822
|
+
*/
|
823
|
+
productionTip: process.env.NODE_ENV !== 'production',
|
824
|
+
|
825
|
+
/**
|
826
|
+
* Whether to enable devtools
|
827
|
+
*/
|
828
|
+
devtools: process.env.NODE_ENV !== 'production',
|
829
|
+
|
830
|
+
/**
|
831
|
+
* Whether to record perf
|
832
|
+
*/
|
833
|
+
performance: false,
|
834
|
+
|
835
|
+
/**
|
836
|
+
* Error handler for watcher errors
|
837
|
+
*/
|
838
|
+
errorHandler: null,
|
839
|
+
|
840
|
+
/**
|
841
|
+
* Warn handler for watcher warns
|
842
|
+
*/
|
843
|
+
warnHandler: null,
|
844
|
+
|
845
|
+
/**
|
846
|
+
* Ignore certain custom elements
|
847
|
+
*/
|
848
|
+
ignoredElements: [],
|
849
|
+
|
850
|
+
/**
|
851
|
+
* Custom user key aliases for v-on
|
852
|
+
*/
|
853
|
+
// $flow-disable-line
|
854
|
+
keyCodes: Object.create(null),
|
855
|
+
|
856
|
+
/**
|
857
|
+
* Check if a tag is reserved so that it cannot be registered as a
|
858
|
+
* component. This is platform-dependent and may be overwritten.
|
859
|
+
*/
|
860
|
+
isReservedTag: no,
|
861
|
+
|
862
|
+
/**
|
863
|
+
* Check if an attribute is reserved so that it cannot be used as a component
|
864
|
+
* prop. This is platform-dependent and may be overwritten.
|
865
|
+
*/
|
866
|
+
isReservedAttr: no,
|
867
|
+
|
868
|
+
/**
|
869
|
+
* Check if a tag is an unknown element.
|
870
|
+
* Platform-dependent.
|
871
|
+
*/
|
872
|
+
isUnknownElement: no,
|
873
|
+
|
874
|
+
/**
|
875
|
+
* Get the namespace of an element
|
876
|
+
*/
|
877
|
+
getTagNamespace: noop,
|
878
|
+
|
879
|
+
/**
|
880
|
+
* Parse the real tag name for the specific platform.
|
881
|
+
*/
|
882
|
+
parsePlatformTagName: identity,
|
883
|
+
|
884
|
+
/**
|
885
|
+
* Check if an attribute must be bound using property, e.g. value
|
886
|
+
* Platform-dependent.
|
887
|
+
*/
|
888
|
+
mustUseProp: no,
|
889
|
+
|
890
|
+
/**
|
891
|
+
* Exposed for legacy reasons
|
892
|
+
*/
|
893
|
+
_lifecycleHooks: LIFECYCLE_HOOKS
|
894
|
+
})
|
895
|
+
|
896
|
+
/* */
|
897
|
+
|
898
|
+
var warn = noop;
|
899
|
+
var tip = noop;
|
900
|
+
var generateComponentTrace = (noop); // work around flow check
|
901
|
+
var formatComponentName = (noop);
|
902
|
+
|
903
|
+
if (process.env.NODE_ENV !== 'production') {
|
904
|
+
var hasConsole = typeof console !== 'undefined';
|
905
|
+
var classifyRE = /(?:^|[-_])(\w)/g;
|
906
|
+
var classify = function (str) { return str
|
907
|
+
.replace(classifyRE, function (c) { return c.toUpperCase(); })
|
908
|
+
.replace(/[-_]/g, ''); };
|
909
|
+
|
910
|
+
warn = function (msg, vm) {
|
911
|
+
var trace = vm ? generateComponentTrace(vm) : '';
|
912
|
+
|
913
|
+
if (config.warnHandler) {
|
914
|
+
config.warnHandler.call(null, msg, vm, trace);
|
915
|
+
} else if (hasConsole && (!config.silent)) {
|
916
|
+
console.error(("[Vue warn]: " + msg + trace));
|
917
|
+
}
|
918
|
+
};
|
919
|
+
|
920
|
+
tip = function (msg, vm) {
|
921
|
+
if (hasConsole && (!config.silent)) {
|
922
|
+
console.warn("[Vue tip]: " + msg + (
|
923
|
+
vm ? generateComponentTrace(vm) : ''
|
924
|
+
));
|
925
|
+
}
|
926
|
+
};
|
927
|
+
|
928
|
+
formatComponentName = function (vm, includeFile) {
|
929
|
+
if (vm.$root === vm) {
|
930
|
+
return '<Root>'
|
931
|
+
}
|
932
|
+
var options = typeof vm === 'function' && vm.cid != null
|
933
|
+
? vm.options
|
934
|
+
: vm._isVue
|
935
|
+
? vm.$options || vm.constructor.options
|
936
|
+
: vm || {};
|
937
|
+
var name = options.name || options._componentTag;
|
938
|
+
var file = options.__file;
|
939
|
+
if (!name && file) {
|
940
|
+
var match = file.match(/([^/\\]+)\.vue$/);
|
941
|
+
name = match && match[1];
|
942
|
+
}
|
943
|
+
|
944
|
+
return (
|
945
|
+
(name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
|
946
|
+
(file && includeFile !== false ? (" at " + file) : '')
|
947
|
+
)
|
948
|
+
};
|
949
|
+
|
950
|
+
var repeat = function (str, n) {
|
951
|
+
var res = '';
|
952
|
+
while (n) {
|
953
|
+
if (n % 2 === 1) { res += str; }
|
954
|
+
if (n > 1) { str += str; }
|
955
|
+
n >>= 1;
|
956
|
+
}
|
957
|
+
return res
|
958
|
+
};
|
959
|
+
|
960
|
+
generateComponentTrace = function (vm) {
|
961
|
+
if (vm._isVue && vm.$parent) {
|
962
|
+
var tree = [];
|
963
|
+
var currentRecursiveSequence = 0;
|
964
|
+
while (vm) {
|
965
|
+
if (tree.length > 0) {
|
966
|
+
var last = tree[tree.length - 1];
|
967
|
+
if (last.constructor === vm.constructor) {
|
968
|
+
currentRecursiveSequence++;
|
969
|
+
vm = vm.$parent;
|
970
|
+
continue
|
971
|
+
} else if (currentRecursiveSequence > 0) {
|
972
|
+
tree[tree.length - 1] = [last, currentRecursiveSequence];
|
973
|
+
currentRecursiveSequence = 0;
|
974
|
+
}
|
975
|
+
}
|
976
|
+
tree.push(vm);
|
977
|
+
vm = vm.$parent;
|
978
|
+
}
|
979
|
+
return '\n\nfound in\n\n' + tree
|
980
|
+
.map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
|
981
|
+
? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
|
982
|
+
: formatComponentName(vm))); })
|
983
|
+
.join('\n')
|
984
|
+
} else {
|
985
|
+
return ("\n\n(found in " + (formatComponentName(vm)) + ")")
|
986
|
+
}
|
987
|
+
};
|
988
|
+
}
|
989
|
+
|
990
|
+
/* */
|
991
|
+
|
992
|
+
|
993
|
+
var uid = 0;
|
994
|
+
|
995
|
+
/**
|
996
|
+
* A dep is an observable that can have multiple
|
997
|
+
* directives subscribing to it.
|
998
|
+
*/
|
999
|
+
var Dep = function Dep () {
|
1000
|
+
this.id = uid++;
|
1001
|
+
this.subs = [];
|
1002
|
+
};
|
1003
|
+
|
1004
|
+
Dep.prototype.addSub = function addSub (sub) {
|
1005
|
+
this.subs.push(sub);
|
1006
|
+
};
|
1007
|
+
|
1008
|
+
Dep.prototype.removeSub = function removeSub (sub) {
|
1009
|
+
remove(this.subs, sub);
|
1010
|
+
};
|
1011
|
+
|
1012
|
+
Dep.prototype.depend = function depend () {
|
1013
|
+
if (Dep.target) {
|
1014
|
+
Dep.target.addDep(this);
|
1015
|
+
}
|
1016
|
+
};
|
1017
|
+
|
1018
|
+
Dep.prototype.notify = function notify () {
|
1019
|
+
// stabilize the subscriber list first
|
1020
|
+
var subs = this.subs.slice();
|
1021
|
+
for (var i = 0, l = subs.length; i < l; i++) {
|
1022
|
+
subs[i].update();
|
1023
|
+
}
|
1024
|
+
};
|
1025
|
+
|
1026
|
+
// the current target watcher being evaluated.
|
1027
|
+
// this is globally unique because there could be only one
|
1028
|
+
// watcher being evaluated at any time.
|
1029
|
+
Dep.target = null;
|
1030
|
+
|
1031
|
+
/* */
|
1032
|
+
|
1033
|
+
var VNode = function VNode (
|
1034
|
+
tag,
|
1035
|
+
data,
|
1036
|
+
children,
|
1037
|
+
text,
|
1038
|
+
elm,
|
1039
|
+
context,
|
1040
|
+
componentOptions,
|
1041
|
+
asyncFactory
|
1042
|
+
) {
|
1043
|
+
this.tag = tag;
|
1044
|
+
this.data = data;
|
1045
|
+
this.children = children;
|
1046
|
+
this.text = text;
|
1047
|
+
this.elm = elm;
|
1048
|
+
this.ns = undefined;
|
1049
|
+
this.context = context;
|
1050
|
+
this.fnContext = undefined;
|
1051
|
+
this.fnOptions = undefined;
|
1052
|
+
this.fnScopeId = undefined;
|
1053
|
+
this.key = data && data.key;
|
1054
|
+
this.componentOptions = componentOptions;
|
1055
|
+
this.componentInstance = undefined;
|
1056
|
+
this.parent = undefined;
|
1057
|
+
this.raw = false;
|
1058
|
+
this.isStatic = false;
|
1059
|
+
this.isRootInsert = true;
|
1060
|
+
this.isComment = false;
|
1061
|
+
this.isCloned = false;
|
1062
|
+
this.isOnce = false;
|
1063
|
+
this.asyncFactory = asyncFactory;
|
1064
|
+
this.asyncMeta = undefined;
|
1065
|
+
this.isAsyncPlaceholder = false;
|
1066
|
+
};
|
1067
|
+
|
1068
|
+
var prototypeAccessors = { child: { configurable: true } };
|
1069
|
+
|
1070
|
+
// DEPRECATED: alias for componentInstance for backwards compat.
|
1071
|
+
/* istanbul ignore next */
|
1072
|
+
prototypeAccessors.child.get = function () {
|
1073
|
+
return this.componentInstance
|
1074
|
+
};
|
1075
|
+
|
1076
|
+
Object.defineProperties( VNode.prototype, prototypeAccessors );
|
1077
|
+
|
1078
|
+
|
1079
|
+
|
1080
|
+
|
1081
|
+
|
1082
|
+
// optimized shallow clone
|
1083
|
+
// used for static nodes and slot nodes because they may be reused across
|
1084
|
+
// multiple renders, cloning them avoids errors when DOM manipulations rely
|
1085
|
+
// on their elm reference.
|
1086
|
+
|
1087
|
+
/*
|
1088
|
+
* not type checking this file because flow doesn't play well with
|
1089
|
+
* dynamically accessing methods on Array prototype
|
1090
|
+
*/
|
1091
|
+
|
1092
|
+
var arrayProto = Array.prototype;
|
1093
|
+
var arrayMethods = Object.create(arrayProto);
|
1094
|
+
|
1095
|
+
var methodsToPatch = [
|
1096
|
+
'push',
|
1097
|
+
'pop',
|
1098
|
+
'shift',
|
1099
|
+
'unshift',
|
1100
|
+
'splice',
|
1101
|
+
'sort',
|
1102
|
+
'reverse'
|
1103
|
+
];
|
1104
|
+
|
1105
|
+
/**
|
1106
|
+
* Intercept mutating methods and emit events
|
1107
|
+
*/
|
1108
|
+
methodsToPatch.forEach(function (method) {
|
1109
|
+
// cache original method
|
1110
|
+
var original = arrayProto[method];
|
1111
|
+
def(arrayMethods, method, function mutator () {
|
1112
|
+
var args = [], len = arguments.length;
|
1113
|
+
while ( len-- ) args[ len ] = arguments[ len ];
|
1114
|
+
|
1115
|
+
var result = original.apply(this, args);
|
1116
|
+
var ob = this.__ob__;
|
1117
|
+
var inserted;
|
1118
|
+
switch (method) {
|
1119
|
+
case 'push':
|
1120
|
+
case 'unshift':
|
1121
|
+
inserted = args;
|
1122
|
+
break
|
1123
|
+
case 'splice':
|
1124
|
+
inserted = args.slice(2);
|
1125
|
+
break
|
1126
|
+
}
|
1127
|
+
if (inserted) { ob.observeArray(inserted); }
|
1128
|
+
// notify change
|
1129
|
+
ob.dep.notify();
|
1130
|
+
return result
|
1131
|
+
});
|
1132
|
+
});
|
1133
|
+
|
1134
|
+
/* */
|
1135
|
+
|
1136
|
+
var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
1137
|
+
|
1138
|
+
/**
|
1139
|
+
* In some cases we may want to disable observation inside a component's
|
1140
|
+
* update computation.
|
1141
|
+
*/
|
1142
|
+
var shouldObserve = true;
|
1143
|
+
|
1144
|
+
|
1145
|
+
|
1146
|
+
/**
|
1147
|
+
* Observer class that is attached to each observed
|
1148
|
+
* object. Once attached, the observer converts the target
|
1149
|
+
* object's property keys into getter/setters that
|
1150
|
+
* collect dependencies and dispatch updates.
|
1151
|
+
*/
|
1152
|
+
var Observer = function Observer (value) {
|
1153
|
+
this.value = value;
|
1154
|
+
this.dep = new Dep();
|
1155
|
+
this.vmCount = 0;
|
1156
|
+
def(value, '__ob__', this);
|
1157
|
+
if (Array.isArray(value)) {
|
1158
|
+
var augment = hasProto
|
1159
|
+
? protoAugment
|
1160
|
+
: copyAugment;
|
1161
|
+
augment(value, arrayMethods, arrayKeys);
|
1162
|
+
this.observeArray(value);
|
1163
|
+
} else {
|
1164
|
+
this.walk(value);
|
1165
|
+
}
|
1166
|
+
};
|
1167
|
+
|
1168
|
+
/**
|
1169
|
+
* Walk through each property and convert them into
|
1170
|
+
* getter/setters. This method should only be called when
|
1171
|
+
* value type is Object.
|
1172
|
+
*/
|
1173
|
+
Observer.prototype.walk = function walk (obj) {
|
1174
|
+
var keys = Object.keys(obj);
|
1175
|
+
for (var i = 0; i < keys.length; i++) {
|
1176
|
+
defineReactive(obj, keys[i]);
|
1177
|
+
}
|
1178
|
+
};
|
1179
|
+
|
1180
|
+
/**
|
1181
|
+
* Observe a list of Array items.
|
1182
|
+
*/
|
1183
|
+
Observer.prototype.observeArray = function observeArray (items) {
|
1184
|
+
for (var i = 0, l = items.length; i < l; i++) {
|
1185
|
+
observe(items[i]);
|
1186
|
+
}
|
1187
|
+
};
|
1188
|
+
|
1189
|
+
// helpers
|
1190
|
+
|
1191
|
+
/**
|
1192
|
+
* Augment an target Object or Array by intercepting
|
1193
|
+
* the prototype chain using __proto__
|
1194
|
+
*/
|
1195
|
+
function protoAugment (target, src, keys) {
|
1196
|
+
/* eslint-disable no-proto */
|
1197
|
+
target.__proto__ = src;
|
1198
|
+
/* eslint-enable no-proto */
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
/**
|
1202
|
+
* Augment an target Object or Array by defining
|
1203
|
+
* hidden properties.
|
1204
|
+
*/
|
1205
|
+
/* istanbul ignore next */
|
1206
|
+
function copyAugment (target, src, keys) {
|
1207
|
+
for (var i = 0, l = keys.length; i < l; i++) {
|
1208
|
+
var key = keys[i];
|
1209
|
+
def(target, key, src[key]);
|
1210
|
+
}
|
1211
|
+
}
|
1212
|
+
|
1213
|
+
/**
|
1214
|
+
* Attempt to create an observer instance for a value,
|
1215
|
+
* returns the new observer if successfully observed,
|
1216
|
+
* or the existing observer if the value already has one.
|
1217
|
+
*/
|
1218
|
+
function observe (value, asRootData) {
|
1219
|
+
if (!isObject(value) || value instanceof VNode) {
|
1220
|
+
return
|
1221
|
+
}
|
1222
|
+
var ob;
|
1223
|
+
if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
|
1224
|
+
ob = value.__ob__;
|
1225
|
+
} else if (
|
1226
|
+
shouldObserve &&
|
1227
|
+
!isServerRendering() &&
|
1228
|
+
(Array.isArray(value) || isPlainObject(value)) &&
|
1229
|
+
Object.isExtensible(value) &&
|
1230
|
+
!value._isVue
|
1231
|
+
) {
|
1232
|
+
ob = new Observer(value);
|
1233
|
+
}
|
1234
|
+
if (asRootData && ob) {
|
1235
|
+
ob.vmCount++;
|
1236
|
+
}
|
1237
|
+
return ob
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
/**
|
1241
|
+
* Define a reactive property on an Object.
|
1242
|
+
*/
|
1243
|
+
function defineReactive (
|
1244
|
+
obj,
|
1245
|
+
key,
|
1246
|
+
val,
|
1247
|
+
customSetter,
|
1248
|
+
shallow
|
1249
|
+
) {
|
1250
|
+
var dep = new Dep();
|
1251
|
+
|
1252
|
+
var property = Object.getOwnPropertyDescriptor(obj, key);
|
1253
|
+
if (property && property.configurable === false) {
|
1254
|
+
return
|
1255
|
+
}
|
1256
|
+
|
1257
|
+
// cater for pre-defined getter/setters
|
1258
|
+
var getter = property && property.get;
|
1259
|
+
if (!getter && arguments.length === 2) {
|
1260
|
+
val = obj[key];
|
1261
|
+
}
|
1262
|
+
var setter = property && property.set;
|
1263
|
+
|
1264
|
+
var childOb = !shallow && observe(val);
|
1265
|
+
Object.defineProperty(obj, key, {
|
1266
|
+
enumerable: true,
|
1267
|
+
configurable: true,
|
1268
|
+
get: function reactiveGetter () {
|
1269
|
+
var value = getter ? getter.call(obj) : val;
|
1270
|
+
if (Dep.target) {
|
1271
|
+
dep.depend();
|
1272
|
+
if (childOb) {
|
1273
|
+
childOb.dep.depend();
|
1274
|
+
if (Array.isArray(value)) {
|
1275
|
+
dependArray(value);
|
1276
|
+
}
|
1277
|
+
}
|
1278
|
+
}
|
1279
|
+
return value
|
1280
|
+
},
|
1281
|
+
set: function reactiveSetter (newVal) {
|
1282
|
+
var value = getter ? getter.call(obj) : val;
|
1283
|
+
/* eslint-disable no-self-compare */
|
1284
|
+
if (newVal === value || (newVal !== newVal && value !== value)) {
|
1285
|
+
return
|
1286
|
+
}
|
1287
|
+
/* eslint-enable no-self-compare */
|
1288
|
+
if (process.env.NODE_ENV !== 'production' && customSetter) {
|
1289
|
+
customSetter();
|
1290
|
+
}
|
1291
|
+
if (setter) {
|
1292
|
+
setter.call(obj, newVal);
|
1293
|
+
} else {
|
1294
|
+
val = newVal;
|
1295
|
+
}
|
1296
|
+
childOb = !shallow && observe(newVal);
|
1297
|
+
dep.notify();
|
1298
|
+
}
|
1299
|
+
});
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
/**
|
1303
|
+
* Set a property on an object. Adds the new property and
|
1304
|
+
* triggers change notification if the property doesn't
|
1305
|
+
* already exist.
|
1306
|
+
*/
|
1307
|
+
function set (target, key, val) {
|
1308
|
+
if (process.env.NODE_ENV !== 'production' &&
|
1309
|
+
(isUndef(target) || isPrimitive(target))
|
1310
|
+
) {
|
1311
|
+
warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
|
1312
|
+
}
|
1313
|
+
if (Array.isArray(target) && isValidArrayIndex(key)) {
|
1314
|
+
target.length = Math.max(target.length, key);
|
1315
|
+
target.splice(key, 1, val);
|
1316
|
+
return val
|
1317
|
+
}
|
1318
|
+
if (key in target && !(key in Object.prototype)) {
|
1319
|
+
target[key] = val;
|
1320
|
+
return val
|
1321
|
+
}
|
1322
|
+
var ob = (target).__ob__;
|
1323
|
+
if (target._isVue || (ob && ob.vmCount)) {
|
1324
|
+
process.env.NODE_ENV !== 'production' && warn(
|
1325
|
+
'Avoid adding reactive properties to a Vue instance or its root $data ' +
|
1326
|
+
'at runtime - declare it upfront in the data option.'
|
1327
|
+
);
|
1328
|
+
return val
|
1329
|
+
}
|
1330
|
+
if (!ob) {
|
1331
|
+
target[key] = val;
|
1332
|
+
return val
|
1333
|
+
}
|
1334
|
+
defineReactive(ob.value, key, val);
|
1335
|
+
ob.dep.notify();
|
1336
|
+
return val
|
1337
|
+
}
|
1338
|
+
|
1339
|
+
/**
|
1340
|
+
* Delete a property and trigger change if necessary.
|
1341
|
+
*/
|
1342
|
+
|
1343
|
+
|
1344
|
+
/**
|
1345
|
+
* Collect dependencies on array elements when the array is touched, since
|
1346
|
+
* we cannot intercept array element access like property getters.
|
1347
|
+
*/
|
1348
|
+
function dependArray (value) {
|
1349
|
+
for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
|
1350
|
+
e = value[i];
|
1351
|
+
e && e.__ob__ && e.__ob__.dep.depend();
|
1352
|
+
if (Array.isArray(e)) {
|
1353
|
+
dependArray(e);
|
1354
|
+
}
|
1355
|
+
}
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
/* */
|
1359
|
+
|
1360
|
+
/**
|
1361
|
+
* Option overwriting strategies are functions that handle
|
1362
|
+
* how to merge a parent option value and a child option
|
1363
|
+
* value into the final value.
|
1364
|
+
*/
|
1365
|
+
var strats = config.optionMergeStrategies;
|
1366
|
+
|
1367
|
+
/**
|
1368
|
+
* Options with restrictions
|
1369
|
+
*/
|
1370
|
+
if (process.env.NODE_ENV !== 'production') {
|
1371
|
+
strats.el = strats.propsData = function (parent, child, vm, key) {
|
1372
|
+
if (!vm) {
|
1373
|
+
warn(
|
1374
|
+
"option \"" + key + "\" can only be used during instance " +
|
1375
|
+
'creation with the `new` keyword.'
|
1376
|
+
);
|
1377
|
+
}
|
1378
|
+
return defaultStrat(parent, child)
|
1379
|
+
};
|
1380
|
+
}
|
1381
|
+
|
1382
|
+
/**
|
1383
|
+
* Helper that recursively merges two data objects together.
|
1384
|
+
*/
|
1385
|
+
function mergeData (to, from) {
|
1386
|
+
if (!from) { return to }
|
1387
|
+
var key, toVal, fromVal;
|
1388
|
+
var keys = Object.keys(from);
|
1389
|
+
for (var i = 0; i < keys.length; i++) {
|
1390
|
+
key = keys[i];
|
1391
|
+
toVal = to[key];
|
1392
|
+
fromVal = from[key];
|
1393
|
+
if (!hasOwn(to, key)) {
|
1394
|
+
set(to, key, fromVal);
|
1395
|
+
} else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
|
1396
|
+
mergeData(toVal, fromVal);
|
1397
|
+
}
|
1398
|
+
}
|
1399
|
+
return to
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
/**
|
1403
|
+
* Data
|
1404
|
+
*/
|
1405
|
+
function mergeDataOrFn (
|
1406
|
+
parentVal,
|
1407
|
+
childVal,
|
1408
|
+
vm
|
1409
|
+
) {
|
1410
|
+
if (!vm) {
|
1411
|
+
// in a Vue.extend merge, both should be functions
|
1412
|
+
if (!childVal) {
|
1413
|
+
return parentVal
|
1414
|
+
}
|
1415
|
+
if (!parentVal) {
|
1416
|
+
return childVal
|
1417
|
+
}
|
1418
|
+
// when parentVal & childVal are both present,
|
1419
|
+
// we need to return a function that returns the
|
1420
|
+
// merged result of both functions... no need to
|
1421
|
+
// check if parentVal is a function here because
|
1422
|
+
// it has to be a function to pass previous merges.
|
1423
|
+
return function mergedDataFn () {
|
1424
|
+
return mergeData(
|
1425
|
+
typeof childVal === 'function' ? childVal.call(this, this) : childVal,
|
1426
|
+
typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
|
1427
|
+
)
|
1428
|
+
}
|
1429
|
+
} else {
|
1430
|
+
return function mergedInstanceDataFn () {
|
1431
|
+
// instance merge
|
1432
|
+
var instanceData = typeof childVal === 'function'
|
1433
|
+
? childVal.call(vm, vm)
|
1434
|
+
: childVal;
|
1435
|
+
var defaultData = typeof parentVal === 'function'
|
1436
|
+
? parentVal.call(vm, vm)
|
1437
|
+
: parentVal;
|
1438
|
+
if (instanceData) {
|
1439
|
+
return mergeData(instanceData, defaultData)
|
1440
|
+
} else {
|
1441
|
+
return defaultData
|
1442
|
+
}
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
strats.data = function (
|
1448
|
+
parentVal,
|
1449
|
+
childVal,
|
1450
|
+
vm
|
1451
|
+
) {
|
1452
|
+
if (!vm) {
|
1453
|
+
if (childVal && typeof childVal !== 'function') {
|
1454
|
+
process.env.NODE_ENV !== 'production' && warn(
|
1455
|
+
'The "data" option should be a function ' +
|
1456
|
+
'that returns a per-instance value in component ' +
|
1457
|
+
'definitions.',
|
1458
|
+
vm
|
1459
|
+
);
|
1460
|
+
|
1461
|
+
return parentVal
|
1462
|
+
}
|
1463
|
+
return mergeDataOrFn(parentVal, childVal)
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
return mergeDataOrFn(parentVal, childVal, vm)
|
1467
|
+
};
|
1468
|
+
|
1469
|
+
/**
|
1470
|
+
* Hooks and props are merged as arrays.
|
1471
|
+
*/
|
1472
|
+
function mergeHook (
|
1473
|
+
parentVal,
|
1474
|
+
childVal
|
1475
|
+
) {
|
1476
|
+
return childVal
|
1477
|
+
? parentVal
|
1478
|
+
? parentVal.concat(childVal)
|
1479
|
+
: Array.isArray(childVal)
|
1480
|
+
? childVal
|
1481
|
+
: [childVal]
|
1482
|
+
: parentVal
|
1483
|
+
}
|
1484
|
+
|
1485
|
+
LIFECYCLE_HOOKS.forEach(function (hook) {
|
1486
|
+
strats[hook] = mergeHook;
|
1487
|
+
});
|
1488
|
+
|
1489
|
+
/**
|
1490
|
+
* Assets
|
1491
|
+
*
|
1492
|
+
* When a vm is present (instance creation), we need to do
|
1493
|
+
* a three-way merge between constructor options, instance
|
1494
|
+
* options and parent options.
|
1495
|
+
*/
|
1496
|
+
function mergeAssets (
|
1497
|
+
parentVal,
|
1498
|
+
childVal,
|
1499
|
+
vm,
|
1500
|
+
key
|
1501
|
+
) {
|
1502
|
+
var res = Object.create(parentVal || null);
|
1503
|
+
if (childVal) {
|
1504
|
+
process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
|
1505
|
+
return extend(res, childVal)
|
1506
|
+
} else {
|
1507
|
+
return res
|
1508
|
+
}
|
1509
|
+
}
|
1510
|
+
|
1511
|
+
ASSET_TYPES.forEach(function (type) {
|
1512
|
+
strats[type + 's'] = mergeAssets;
|
1513
|
+
});
|
1514
|
+
|
1515
|
+
/**
|
1516
|
+
* Watchers.
|
1517
|
+
*
|
1518
|
+
* Watchers hashes should not overwrite one
|
1519
|
+
* another, so we merge them as arrays.
|
1520
|
+
*/
|
1521
|
+
strats.watch = function (
|
1522
|
+
parentVal,
|
1523
|
+
childVal,
|
1524
|
+
vm,
|
1525
|
+
key
|
1526
|
+
) {
|
1527
|
+
// work around Firefox's Object.prototype.watch...
|
1528
|
+
if (parentVal === nativeWatch) { parentVal = undefined; }
|
1529
|
+
if (childVal === nativeWatch) { childVal = undefined; }
|
1530
|
+
/* istanbul ignore if */
|
1531
|
+
if (!childVal) { return Object.create(parentVal || null) }
|
1532
|
+
if (process.env.NODE_ENV !== 'production') {
|
1533
|
+
assertObjectType(key, childVal, vm);
|
1534
|
+
}
|
1535
|
+
if (!parentVal) { return childVal }
|
1536
|
+
var ret = {};
|
1537
|
+
extend(ret, parentVal);
|
1538
|
+
for (var key$1 in childVal) {
|
1539
|
+
var parent = ret[key$1];
|
1540
|
+
var child = childVal[key$1];
|
1541
|
+
if (parent && !Array.isArray(parent)) {
|
1542
|
+
parent = [parent];
|
1543
|
+
}
|
1544
|
+
ret[key$1] = parent
|
1545
|
+
? parent.concat(child)
|
1546
|
+
: Array.isArray(child) ? child : [child];
|
1547
|
+
}
|
1548
|
+
return ret
|
1549
|
+
};
|
1550
|
+
|
1551
|
+
/**
|
1552
|
+
* Other object hashes.
|
1553
|
+
*/
|
1554
|
+
strats.props =
|
1555
|
+
strats.methods =
|
1556
|
+
strats.inject =
|
1557
|
+
strats.computed = function (
|
1558
|
+
parentVal,
|
1559
|
+
childVal,
|
1560
|
+
vm,
|
1561
|
+
key
|
1562
|
+
) {
|
1563
|
+
if (childVal && process.env.NODE_ENV !== 'production') {
|
1564
|
+
assertObjectType(key, childVal, vm);
|
1565
|
+
}
|
1566
|
+
if (!parentVal) { return childVal }
|
1567
|
+
var ret = Object.create(null);
|
1568
|
+
extend(ret, parentVal);
|
1569
|
+
if (childVal) { extend(ret, childVal); }
|
1570
|
+
return ret
|
1571
|
+
};
|
1572
|
+
strats.provide = mergeDataOrFn;
|
1573
|
+
|
1574
|
+
/**
|
1575
|
+
* Default strategy.
|
1576
|
+
*/
|
1577
|
+
var defaultStrat = function (parentVal, childVal) {
|
1578
|
+
return childVal === undefined
|
1579
|
+
? parentVal
|
1580
|
+
: childVal
|
1581
|
+
};
|
1582
|
+
|
1583
|
+
|
1584
|
+
|
1585
|
+
function assertObjectType (name, value, vm) {
|
1586
|
+
if (!isPlainObject(value)) {
|
1587
|
+
warn(
|
1588
|
+
"Invalid value for option \"" + name + "\": expected an Object, " +
|
1589
|
+
"but got " + (toRawType(value)) + ".",
|
1590
|
+
vm
|
1591
|
+
);
|
1592
|
+
}
|
1593
|
+
}
|
1594
|
+
|
1595
|
+
/**
|
1596
|
+
* Merge two option objects into a new one.
|
1597
|
+
* Core utility used in both instantiation and inheritance.
|
1598
|
+
*/
|
1599
|
+
|
1600
|
+
|
1601
|
+
/**
|
1602
|
+
* Resolve an asset.
|
1603
|
+
* This function is used because child instances need access
|
1604
|
+
* to assets defined in its ancestor chain.
|
1605
|
+
*/
|
1606
|
+
|
1607
|
+
/* */
|
1608
|
+
|
1609
|
+
/* */
|
1610
|
+
|
1611
|
+
/* */
|
1612
|
+
/* globals MessageChannel */
|
1613
|
+
|
1614
|
+
var callbacks = [];
|
1615
|
+
function flushCallbacks () {
|
1616
|
+
var copies = callbacks.slice(0);
|
1617
|
+
callbacks.length = 0;
|
1618
|
+
for (var i = 0; i < copies.length; i++) {
|
1619
|
+
copies[i]();
|
1620
|
+
}
|
1621
|
+
}
|
1622
|
+
|
1623
|
+
// Determine (macro) task defer implementation.
|
1624
|
+
// Technically setImmediate should be the ideal choice, but it's only available
|
1625
|
+
// in IE. The only polyfill that consistently queues the callback after all DOM
|
1626
|
+
// events triggered in the same loop is by using MessageChannel.
|
1627
|
+
/* istanbul ignore if */
|
1628
|
+
if (typeof setImmediate !== 'undefined' && isNative(setImmediate)) {
|
1629
|
+
|
1630
|
+
} else if (typeof MessageChannel !== 'undefined' && (
|
1631
|
+
isNative(MessageChannel) ||
|
1632
|
+
// PhantomJS
|
1633
|
+
MessageChannel.toString() === '[object MessageChannelConstructor]'
|
1634
|
+
)) {
|
1635
|
+
var channel = new MessageChannel();
|
1636
|
+
channel.port1.onmessage = flushCallbacks;
|
1637
|
+
|
1638
|
+
} else {
|
1639
|
+
/* istanbul ignore next */
|
1640
|
+
|
1641
|
+
}
|
1642
|
+
|
1643
|
+
// Determine microtask defer implementation.
|
1644
|
+
/* istanbul ignore next, $flow-disable-line */
|
1645
|
+
if (typeof Promise !== 'undefined' && isNative(Promise)) {
|
1646
|
+
|
1647
|
+
} else {
|
1648
|
+
// fallback to macro
|
1649
|
+
|
1650
|
+
}
|
1651
|
+
|
1652
|
+
/**
|
1653
|
+
* Wrap a function so that if any code inside triggers state change,
|
1654
|
+
* the changes are queued using a (macro) task instead of a microtask.
|
1655
|
+
*/
|
1656
|
+
|
1657
|
+
/* */
|
1658
|
+
|
1659
|
+
/* */
|
1660
|
+
|
1661
|
+
// these are reserved for web because they are directly compiled away
|
1662
|
+
// during template compilation
|
1663
|
+
var isReservedAttr = makeMap('style,class');
|
1664
|
+
|
1665
|
+
// attributes that should be using props for binding
|
1666
|
+
var acceptValue = makeMap('input,textarea,option,select,progress');
|
1667
|
+
var mustUseProp = function (tag, type, attr) {
|
1668
|
+
return (
|
1669
|
+
(attr === 'value' && acceptValue(tag)) && type !== 'button' ||
|
1670
|
+
(attr === 'selected' && tag === 'option') ||
|
1671
|
+
(attr === 'checked' && tag === 'input') ||
|
1672
|
+
(attr === 'muted' && tag === 'video')
|
1673
|
+
)
|
1674
|
+
};
|
1675
|
+
|
1676
|
+
var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
|
1677
|
+
|
1678
|
+
var isBooleanAttr = makeMap(
|
1679
|
+
'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
|
1680
|
+
'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
|
1681
|
+
'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
|
1682
|
+
'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
|
1683
|
+
'required,reversed,scoped,seamless,selected,sortable,translate,' +
|
1684
|
+
'truespeed,typemustmatch,visible'
|
1685
|
+
);
|
1686
|
+
|
1687
|
+
/* */
|
1688
|
+
|
1689
|
+
/* */
|
1690
|
+
|
1691
|
+
|
1692
|
+
|
1693
|
+
var isHTMLTag = makeMap(
|
1694
|
+
'html,body,base,head,link,meta,style,title,' +
|
1695
|
+
'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
|
1696
|
+
'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
|
1697
|
+
'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
|
1698
|
+
's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
|
1699
|
+
'embed,object,param,source,canvas,script,noscript,del,ins,' +
|
1700
|
+
'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
|
1701
|
+
'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
|
1702
|
+
'output,progress,select,textarea,' +
|
1703
|
+
'details,dialog,menu,menuitem,summary,' +
|
1704
|
+
'content,element,shadow,template,blockquote,iframe,tfoot'
|
1705
|
+
);
|
1706
|
+
|
1707
|
+
// this map is intentionally selective, only covering SVG elements that may
|
1708
|
+
// contain child elements.
|
1709
|
+
var isSVG = makeMap(
|
1710
|
+
'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
|
1711
|
+
'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
|
1712
|
+
'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
|
1713
|
+
true
|
1714
|
+
);
|
1715
|
+
|
1716
|
+
var isPreTag = function (tag) { return tag === 'pre'; };
|
1717
|
+
|
1718
|
+
var isReservedTag = function (tag) {
|
1719
|
+
return isHTMLTag(tag) || isSVG(tag)
|
1720
|
+
};
|
1721
|
+
|
1722
|
+
function getTagNamespace (tag) {
|
1723
|
+
if (isSVG(tag)) {
|
1724
|
+
return 'svg'
|
1725
|
+
}
|
1726
|
+
// basic support for MathML
|
1727
|
+
// note it doesn't support other MathML elements being component roots
|
1728
|
+
if (tag === 'math') {
|
1729
|
+
return 'math'
|
1730
|
+
}
|
1731
|
+
}
|
1732
|
+
|
1733
|
+
|
1734
|
+
|
1735
|
+
var isTextInputType = makeMap('text,number,password,search,email,tel,url');
|
1736
|
+
|
1737
|
+
/* */
|
1738
|
+
|
1739
|
+
/**
|
1740
|
+
* Query an element selector if it's not an element already.
|
1741
|
+
*/
|
1742
|
+
|
1743
|
+
/* */
|
1744
|
+
|
1745
|
+
var validDivisionCharRE = /[\w).+\-_$\]]/;
|
1746
|
+
|
1747
|
+
function parseFilters (exp) {
|
1748
|
+
var inSingle = false;
|
1749
|
+
var inDouble = false;
|
1750
|
+
var inTemplateString = false;
|
1751
|
+
var inRegex = false;
|
1752
|
+
var curly = 0;
|
1753
|
+
var square = 0;
|
1754
|
+
var paren = 0;
|
1755
|
+
var lastFilterIndex = 0;
|
1756
|
+
var c, prev, i, expression, filters;
|
1757
|
+
|
1758
|
+
for (i = 0; i < exp.length; i++) {
|
1759
|
+
prev = c;
|
1760
|
+
c = exp.charCodeAt(i);
|
1761
|
+
if (inSingle) {
|
1762
|
+
if (c === 0x27 && prev !== 0x5C) { inSingle = false; }
|
1763
|
+
} else if (inDouble) {
|
1764
|
+
if (c === 0x22 && prev !== 0x5C) { inDouble = false; }
|
1765
|
+
} else if (inTemplateString) {
|
1766
|
+
if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; }
|
1767
|
+
} else if (inRegex) {
|
1768
|
+
if (c === 0x2f && prev !== 0x5C) { inRegex = false; }
|
1769
|
+
} else if (
|
1770
|
+
c === 0x7C && // pipe
|
1771
|
+
exp.charCodeAt(i + 1) !== 0x7C &&
|
1772
|
+
exp.charCodeAt(i - 1) !== 0x7C &&
|
1773
|
+
!curly && !square && !paren
|
1774
|
+
) {
|
1775
|
+
if (expression === undefined) {
|
1776
|
+
// first filter, end of expression
|
1777
|
+
lastFilterIndex = i + 1;
|
1778
|
+
expression = exp.slice(0, i).trim();
|
1779
|
+
} else {
|
1780
|
+
pushFilter();
|
1781
|
+
}
|
1782
|
+
} else {
|
1783
|
+
switch (c) {
|
1784
|
+
case 0x22: inDouble = true; break // "
|
1785
|
+
case 0x27: inSingle = true; break // '
|
1786
|
+
case 0x60: inTemplateString = true; break // `
|
1787
|
+
case 0x28: paren++; break // (
|
1788
|
+
case 0x29: paren--; break // )
|
1789
|
+
case 0x5B: square++; break // [
|
1790
|
+
case 0x5D: square--; break // ]
|
1791
|
+
case 0x7B: curly++; break // {
|
1792
|
+
case 0x7D: curly--; break // }
|
1793
|
+
}
|
1794
|
+
if (c === 0x2f) { // /
|
1795
|
+
var j = i - 1;
|
1796
|
+
var p = (void 0);
|
1797
|
+
// find first non-whitespace prev char
|
1798
|
+
for (; j >= 0; j--) {
|
1799
|
+
p = exp.charAt(j);
|
1800
|
+
if (p !== ' ') { break }
|
1801
|
+
}
|
1802
|
+
if (!p || !validDivisionCharRE.test(p)) {
|
1803
|
+
inRegex = true;
|
1804
|
+
}
|
1805
|
+
}
|
1806
|
+
}
|
1807
|
+
}
|
1808
|
+
|
1809
|
+
if (expression === undefined) {
|
1810
|
+
expression = exp.slice(0, i).trim();
|
1811
|
+
} else if (lastFilterIndex !== 0) {
|
1812
|
+
pushFilter();
|
1813
|
+
}
|
1814
|
+
|
1815
|
+
function pushFilter () {
|
1816
|
+
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim());
|
1817
|
+
lastFilterIndex = i + 1;
|
1818
|
+
}
|
1819
|
+
|
1820
|
+
if (filters) {
|
1821
|
+
for (i = 0; i < filters.length; i++) {
|
1822
|
+
expression = wrapFilter(expression, filters[i]);
|
1823
|
+
}
|
1824
|
+
}
|
1825
|
+
|
1826
|
+
return expression
|
1827
|
+
}
|
1828
|
+
|
1829
|
+
function wrapFilter (exp, filter) {
|
1830
|
+
var i = filter.indexOf('(');
|
1831
|
+
if (i < 0) {
|
1832
|
+
// _f: resolveFilter
|
1833
|
+
return ("_f(\"" + filter + "\")(" + exp + ")")
|
1834
|
+
} else {
|
1835
|
+
var name = filter.slice(0, i);
|
1836
|
+
var args = filter.slice(i + 1);
|
1837
|
+
return ("_f(\"" + name + "\")(" + exp + (args !== ')' ? ',' + args : args))
|
1838
|
+
}
|
1839
|
+
}
|
1840
|
+
|
1841
|
+
/* */
|
1842
|
+
|
1843
|
+
var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g;
|
1844
|
+
var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g;
|
1845
|
+
|
1846
|
+
var buildRegex = cached(function (delimiters) {
|
1847
|
+
var open = delimiters[0].replace(regexEscapeRE, '\\$&');
|
1848
|
+
var close = delimiters[1].replace(regexEscapeRE, '\\$&');
|
1849
|
+
return new RegExp(open + '((?:.|\\n)+?)' + close, 'g')
|
1850
|
+
});
|
1851
|
+
|
1852
|
+
|
1853
|
+
|
1854
|
+
function parseText (
|
1855
|
+
text,
|
1856
|
+
delimiters
|
1857
|
+
) {
|
1858
|
+
var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE;
|
1859
|
+
if (!tagRE.test(text)) {
|
1860
|
+
return
|
1861
|
+
}
|
1862
|
+
var tokens = [];
|
1863
|
+
var rawTokens = [];
|
1864
|
+
var lastIndex = tagRE.lastIndex = 0;
|
1865
|
+
var match, index, tokenValue;
|
1866
|
+
while ((match = tagRE.exec(text))) {
|
1867
|
+
index = match.index;
|
1868
|
+
// push text token
|
1869
|
+
if (index > lastIndex) {
|
1870
|
+
rawTokens.push(tokenValue = text.slice(lastIndex, index));
|
1871
|
+
tokens.push(JSON.stringify(tokenValue));
|
1872
|
+
}
|
1873
|
+
// tag token
|
1874
|
+
var exp = parseFilters(match[1].trim());
|
1875
|
+
tokens.push(("_s(" + exp + ")"));
|
1876
|
+
rawTokens.push({ '@binding': exp });
|
1877
|
+
lastIndex = index + match[0].length;
|
1878
|
+
}
|
1879
|
+
if (lastIndex < text.length) {
|
1880
|
+
rawTokens.push(tokenValue = text.slice(lastIndex));
|
1881
|
+
tokens.push(JSON.stringify(tokenValue));
|
1882
|
+
}
|
1883
|
+
return {
|
1884
|
+
expression: tokens.join('+'),
|
1885
|
+
tokens: rawTokens
|
1886
|
+
}
|
1887
|
+
}
|
1888
|
+
|
1889
|
+
/* */
|
1890
|
+
|
1891
|
+
function baseWarn (msg) {
|
1892
|
+
console.error(("[Vue compiler]: " + msg));
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
function pluckModuleFunction (
|
1896
|
+
modules,
|
1897
|
+
key
|
1898
|
+
) {
|
1899
|
+
return modules
|
1900
|
+
? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; })
|
1901
|
+
: []
|
1902
|
+
}
|
1903
|
+
|
1904
|
+
function addProp (el, name, value) {
|
1905
|
+
(el.props || (el.props = [])).push({ name: name, value: value });
|
1906
|
+
el.plain = false;
|
1907
|
+
}
|
1908
|
+
|
1909
|
+
function addAttr (el, name, value) {
|
1910
|
+
(el.attrs || (el.attrs = [])).push({ name: name, value: value });
|
1911
|
+
el.plain = false;
|
1912
|
+
}
|
1913
|
+
|
1914
|
+
// add a raw attr (use this in preTransforms)
|
1915
|
+
function addRawAttr (el, name, value) {
|
1916
|
+
el.attrsMap[name] = value;
|
1917
|
+
el.attrsList.push({ name: name, value: value });
|
1918
|
+
}
|
1919
|
+
|
1920
|
+
function addDirective (
|
1921
|
+
el,
|
1922
|
+
name,
|
1923
|
+
rawName,
|
1924
|
+
value,
|
1925
|
+
arg,
|
1926
|
+
modifiers
|
1927
|
+
) {
|
1928
|
+
(el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers });
|
1929
|
+
el.plain = false;
|
1930
|
+
}
|
1931
|
+
|
1932
|
+
function addHandler (
|
1933
|
+
el,
|
1934
|
+
name,
|
1935
|
+
value,
|
1936
|
+
modifiers,
|
1937
|
+
important,
|
1938
|
+
warn
|
1939
|
+
) {
|
1940
|
+
modifiers = modifiers || emptyObject;
|
1941
|
+
// warn prevent and passive modifier
|
1942
|
+
/* istanbul ignore if */
|
1943
|
+
if (
|
1944
|
+
process.env.NODE_ENV !== 'production' && warn &&
|
1945
|
+
modifiers.prevent && modifiers.passive
|
1946
|
+
) {
|
1947
|
+
warn(
|
1948
|
+
'passive and prevent can\'t be used together. ' +
|
1949
|
+
'Passive handler can\'t prevent default event.'
|
1950
|
+
);
|
1951
|
+
}
|
1952
|
+
|
1953
|
+
// check capture modifier
|
1954
|
+
if (modifiers.capture) {
|
1955
|
+
delete modifiers.capture;
|
1956
|
+
name = '!' + name; // mark the event as captured
|
1957
|
+
}
|
1958
|
+
if (modifiers.once) {
|
1959
|
+
delete modifiers.once;
|
1960
|
+
name = '~' + name; // mark the event as once
|
1961
|
+
}
|
1962
|
+
/* istanbul ignore if */
|
1963
|
+
if (modifiers.passive) {
|
1964
|
+
delete modifiers.passive;
|
1965
|
+
name = '&' + name; // mark the event as passive
|
1966
|
+
}
|
1967
|
+
|
1968
|
+
// normalize click.right and click.middle since they don't actually fire
|
1969
|
+
// this is technically browser-specific, but at least for now browsers are
|
1970
|
+
// the only target envs that have right/middle clicks.
|
1971
|
+
if (name === 'click') {
|
1972
|
+
if (modifiers.right) {
|
1973
|
+
name = 'contextmenu';
|
1974
|
+
delete modifiers.right;
|
1975
|
+
} else if (modifiers.middle) {
|
1976
|
+
name = 'mouseup';
|
1977
|
+
}
|
1978
|
+
}
|
1979
|
+
|
1980
|
+
var events;
|
1981
|
+
if (modifiers.native) {
|
1982
|
+
delete modifiers.native;
|
1983
|
+
events = el.nativeEvents || (el.nativeEvents = {});
|
1984
|
+
} else {
|
1985
|
+
events = el.events || (el.events = {});
|
1986
|
+
}
|
1987
|
+
|
1988
|
+
var newHandler = {
|
1989
|
+
value: value.trim()
|
1990
|
+
};
|
1991
|
+
if (modifiers !== emptyObject) {
|
1992
|
+
newHandler.modifiers = modifiers;
|
1993
|
+
}
|
1994
|
+
|
1995
|
+
var handlers = events[name];
|
1996
|
+
/* istanbul ignore if */
|
1997
|
+
if (Array.isArray(handlers)) {
|
1998
|
+
important ? handlers.unshift(newHandler) : handlers.push(newHandler);
|
1999
|
+
} else if (handlers) {
|
2000
|
+
events[name] = important ? [newHandler, handlers] : [handlers, newHandler];
|
2001
|
+
} else {
|
2002
|
+
events[name] = newHandler;
|
2003
|
+
}
|
2004
|
+
|
2005
|
+
el.plain = false;
|
2006
|
+
}
|
2007
|
+
|
2008
|
+
function getBindingAttr (
|
2009
|
+
el,
|
2010
|
+
name,
|
2011
|
+
getStatic
|
2012
|
+
) {
|
2013
|
+
var dynamicValue =
|
2014
|
+
getAndRemoveAttr(el, ':' + name) ||
|
2015
|
+
getAndRemoveAttr(el, 'v-bind:' + name);
|
2016
|
+
if (dynamicValue != null) {
|
2017
|
+
return parseFilters(dynamicValue)
|
2018
|
+
} else if (getStatic !== false) {
|
2019
|
+
var staticValue = getAndRemoveAttr(el, name);
|
2020
|
+
if (staticValue != null) {
|
2021
|
+
return JSON.stringify(staticValue)
|
2022
|
+
}
|
2023
|
+
}
|
2024
|
+
}
|
2025
|
+
|
2026
|
+
// note: this only removes the attr from the Array (attrsList) so that it
|
2027
|
+
// doesn't get processed by processAttrs.
|
2028
|
+
// By default it does NOT remove it from the map (attrsMap) because the map is
|
2029
|
+
// needed during codegen.
|
2030
|
+
function getAndRemoveAttr (
|
2031
|
+
el,
|
2032
|
+
name,
|
2033
|
+
removeFromMap
|
2034
|
+
) {
|
2035
|
+
var val;
|
2036
|
+
if ((val = el.attrsMap[name]) != null) {
|
2037
|
+
var list = el.attrsList;
|
2038
|
+
for (var i = 0, l = list.length; i < l; i++) {
|
2039
|
+
if (list[i].name === name) {
|
2040
|
+
list.splice(i, 1);
|
2041
|
+
break
|
2042
|
+
}
|
2043
|
+
}
|
2044
|
+
}
|
2045
|
+
if (removeFromMap) {
|
2046
|
+
delete el.attrsMap[name];
|
2047
|
+
}
|
2048
|
+
return val
|
2049
|
+
}
|
2050
|
+
|
2051
|
+
/* */
|
2052
|
+
|
2053
|
+
function transformNode (el, options) {
|
2054
|
+
var warn = options.warn || baseWarn;
|
2055
|
+
var staticClass = getAndRemoveAttr(el, 'class');
|
2056
|
+
if (process.env.NODE_ENV !== 'production' && staticClass) {
|
2057
|
+
var res = parseText(staticClass, options.delimiters);
|
2058
|
+
if (res) {
|
2059
|
+
warn(
|
2060
|
+
"class=\"" + staticClass + "\": " +
|
2061
|
+
'Interpolation inside attributes has been removed. ' +
|
2062
|
+
'Use v-bind or the colon shorthand instead. For example, ' +
|
2063
|
+
'instead of <div class="{{ val }}">, use <div :class="val">.'
|
2064
|
+
);
|
2065
|
+
}
|
2066
|
+
}
|
2067
|
+
if (staticClass) {
|
2068
|
+
el.staticClass = JSON.stringify(staticClass);
|
2069
|
+
}
|
2070
|
+
var classBinding = getBindingAttr(el, 'class', false /* getStatic */);
|
2071
|
+
if (classBinding) {
|
2072
|
+
el.classBinding = classBinding;
|
2073
|
+
}
|
2074
|
+
}
|
2075
|
+
|
2076
|
+
function genData (el) {
|
2077
|
+
var data = '';
|
2078
|
+
if (el.staticClass) {
|
2079
|
+
data += "staticClass:" + (el.staticClass) + ",";
|
2080
|
+
}
|
2081
|
+
if (el.classBinding) {
|
2082
|
+
data += "class:" + (el.classBinding) + ",";
|
2083
|
+
}
|
2084
|
+
return data
|
2085
|
+
}
|
2086
|
+
|
2087
|
+
var klass = {
|
2088
|
+
staticKeys: ['staticClass'],
|
2089
|
+
transformNode: transformNode,
|
2090
|
+
genData: genData
|
2091
|
+
}
|
2092
|
+
|
2093
|
+
/* */
|
2094
|
+
|
2095
|
+
var parseStyleText = cached(function (cssText) {
|
2096
|
+
var res = {};
|
2097
|
+
var listDelimiter = /;(?![^(]*\))/g;
|
2098
|
+
var propertyDelimiter = /:(.+)/;
|
2099
|
+
cssText.split(listDelimiter).forEach(function (item) {
|
2100
|
+
if (item) {
|
2101
|
+
var tmp = item.split(propertyDelimiter);
|
2102
|
+
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
|
2103
|
+
}
|
2104
|
+
});
|
2105
|
+
return res
|
2106
|
+
});
|
2107
|
+
|
2108
|
+
// normalize possible array / string values into Object
|
2109
|
+
|
2110
|
+
|
2111
|
+
/**
|
2112
|
+
* parent component style should be after child's
|
2113
|
+
* so that parent component's style could override it
|
2114
|
+
*/
|
2115
|
+
|
2116
|
+
/* */
|
2117
|
+
|
2118
|
+
function transformNode$1 (el, options) {
|
2119
|
+
var warn = options.warn || baseWarn;
|
2120
|
+
var staticStyle = getAndRemoveAttr(el, 'style');
|
2121
|
+
if (staticStyle) {
|
2122
|
+
/* istanbul ignore if */
|
2123
|
+
if (process.env.NODE_ENV !== 'production') {
|
2124
|
+
var res = parseText(staticStyle, options.delimiters);
|
2125
|
+
if (res) {
|
2126
|
+
warn(
|
2127
|
+
"style=\"" + staticStyle + "\": " +
|
2128
|
+
'Interpolation inside attributes has been removed. ' +
|
2129
|
+
'Use v-bind or the colon shorthand instead. For example, ' +
|
2130
|
+
'instead of <div style="{{ val }}">, use <div :style="val">.'
|
2131
|
+
);
|
2132
|
+
}
|
2133
|
+
}
|
2134
|
+
el.staticStyle = JSON.stringify(parseStyleText(staticStyle));
|
2135
|
+
}
|
2136
|
+
|
2137
|
+
var styleBinding = getBindingAttr(el, 'style', false /* getStatic */);
|
2138
|
+
if (styleBinding) {
|
2139
|
+
el.styleBinding = styleBinding;
|
2140
|
+
}
|
2141
|
+
}
|
2142
|
+
|
2143
|
+
function genData$1 (el) {
|
2144
|
+
var data = '';
|
2145
|
+
if (el.staticStyle) {
|
2146
|
+
data += "staticStyle:" + (el.staticStyle) + ",";
|
2147
|
+
}
|
2148
|
+
if (el.styleBinding) {
|
2149
|
+
data += "style:(" + (el.styleBinding) + "),";
|
2150
|
+
}
|
2151
|
+
return data
|
2152
|
+
}
|
2153
|
+
|
2154
|
+
var style = {
|
2155
|
+
staticKeys: ['staticStyle'],
|
2156
|
+
transformNode: transformNode$1,
|
2157
|
+
genData: genData$1
|
2158
|
+
}
|
2159
|
+
|
2160
|
+
/* */
|
2161
|
+
|
2162
|
+
/**
|
2163
|
+
* Cross-platform code generation for component v-model
|
2164
|
+
*/
|
2165
|
+
function genComponentModel (
|
2166
|
+
el,
|
2167
|
+
value,
|
2168
|
+
modifiers
|
2169
|
+
) {
|
2170
|
+
var ref = modifiers || {};
|
2171
|
+
var number = ref.number;
|
2172
|
+
var trim = ref.trim;
|
2173
|
+
|
2174
|
+
var baseValueExpression = '$$v';
|
2175
|
+
var valueExpression = baseValueExpression;
|
2176
|
+
if (trim) {
|
2177
|
+
valueExpression =
|
2178
|
+
"(typeof " + baseValueExpression + " === 'string'" +
|
2179
|
+
"? " + baseValueExpression + ".trim()" +
|
2180
|
+
": " + baseValueExpression + ")";
|
2181
|
+
}
|
2182
|
+
if (number) {
|
2183
|
+
valueExpression = "_n(" + valueExpression + ")";
|
2184
|
+
}
|
2185
|
+
var assignment = genAssignmentCode(value, valueExpression);
|
2186
|
+
|
2187
|
+
el.model = {
|
2188
|
+
value: ("(" + value + ")"),
|
2189
|
+
expression: ("\"" + value + "\""),
|
2190
|
+
callback: ("function (" + baseValueExpression + ") {" + assignment + "}")
|
2191
|
+
};
|
2192
|
+
}
|
2193
|
+
|
2194
|
+
/**
|
2195
|
+
* Cross-platform codegen helper for generating v-model value assignment code.
|
2196
|
+
*/
|
2197
|
+
function genAssignmentCode (
|
2198
|
+
value,
|
2199
|
+
assignment
|
2200
|
+
) {
|
2201
|
+
var res = parseModel(value);
|
2202
|
+
if (res.key === null) {
|
2203
|
+
return (value + "=" + assignment)
|
2204
|
+
} else {
|
2205
|
+
return ("$set(" + (res.exp) + ", " + (res.key) + ", " + assignment + ")")
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
|
2209
|
+
/**
|
2210
|
+
* Parse a v-model expression into a base path and a final key segment.
|
2211
|
+
* Handles both dot-path and possible square brackets.
|
2212
|
+
*
|
2213
|
+
* Possible cases:
|
2214
|
+
*
|
2215
|
+
* - test
|
2216
|
+
* - test[key]
|
2217
|
+
* - test[test1[key]]
|
2218
|
+
* - test["a"][key]
|
2219
|
+
* - xxx.test[a[a].test1[key]]
|
2220
|
+
* - test.xxx.a["asa"][test1[key]]
|
2221
|
+
*
|
2222
|
+
*/
|
2223
|
+
|
2224
|
+
var len;
|
2225
|
+
var str;
|
2226
|
+
var chr;
|
2227
|
+
var index;
|
2228
|
+
var expressionPos;
|
2229
|
+
var expressionEndPos;
|
2230
|
+
|
2231
|
+
|
2232
|
+
|
2233
|
+
function parseModel (val) {
|
2234
|
+
// Fix https://github.com/vuejs/vue/pull/7730
|
2235
|
+
// allow v-model="obj.val " (trailing whitespace)
|
2236
|
+
val = val.trim();
|
2237
|
+
len = val.length;
|
2238
|
+
|
2239
|
+
if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) {
|
2240
|
+
index = val.lastIndexOf('.');
|
2241
|
+
if (index > -1) {
|
2242
|
+
return {
|
2243
|
+
exp: val.slice(0, index),
|
2244
|
+
key: '"' + val.slice(index + 1) + '"'
|
2245
|
+
}
|
2246
|
+
} else {
|
2247
|
+
return {
|
2248
|
+
exp: val,
|
2249
|
+
key: null
|
2250
|
+
}
|
2251
|
+
}
|
2252
|
+
}
|
2253
|
+
|
2254
|
+
str = val;
|
2255
|
+
index = expressionPos = expressionEndPos = 0;
|
2256
|
+
|
2257
|
+
while (!eof()) {
|
2258
|
+
chr = next();
|
2259
|
+
/* istanbul ignore if */
|
2260
|
+
if (isStringStart(chr)) {
|
2261
|
+
parseString(chr);
|
2262
|
+
} else if (chr === 0x5B) {
|
2263
|
+
parseBracket(chr);
|
2264
|
+
}
|
2265
|
+
}
|
2266
|
+
|
2267
|
+
return {
|
2268
|
+
exp: val.slice(0, expressionPos),
|
2269
|
+
key: val.slice(expressionPos + 1, expressionEndPos)
|
2270
|
+
}
|
2271
|
+
}
|
2272
|
+
|
2273
|
+
function next () {
|
2274
|
+
return str.charCodeAt(++index)
|
2275
|
+
}
|
2276
|
+
|
2277
|
+
function eof () {
|
2278
|
+
return index >= len
|
2279
|
+
}
|
2280
|
+
|
2281
|
+
function isStringStart (chr) {
|
2282
|
+
return chr === 0x22 || chr === 0x27
|
2283
|
+
}
|
2284
|
+
|
2285
|
+
function parseBracket (chr) {
|
2286
|
+
var inBracket = 1;
|
2287
|
+
expressionPos = index;
|
2288
|
+
while (!eof()) {
|
2289
|
+
chr = next();
|
2290
|
+
if (isStringStart(chr)) {
|
2291
|
+
parseString(chr);
|
2292
|
+
continue
|
2293
|
+
}
|
2294
|
+
if (chr === 0x5B) { inBracket++; }
|
2295
|
+
if (chr === 0x5D) { inBracket--; }
|
2296
|
+
if (inBracket === 0) {
|
2297
|
+
expressionEndPos = index;
|
2298
|
+
break
|
2299
|
+
}
|
2300
|
+
}
|
2301
|
+
}
|
2302
|
+
|
2303
|
+
function parseString (chr) {
|
2304
|
+
var stringQuote = chr;
|
2305
|
+
while (!eof()) {
|
2306
|
+
chr = next();
|
2307
|
+
if (chr === stringQuote) {
|
2308
|
+
break
|
2309
|
+
}
|
2310
|
+
}
|
2311
|
+
}
|
2312
|
+
|
2313
|
+
/* */
|
2314
|
+
|
2315
|
+
var onRE = /^@|^v-on:/;
|
2316
|
+
var dirRE = /^v-|^@|^:/;
|
2317
|
+
var forAliasRE = /([^]*?)\s+(?:in|of)\s+([^]*)/;
|
2318
|
+
var forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
|
2319
|
+
var stripParensRE = /^\(|\)$/g;
|
2320
|
+
|
2321
|
+
var argRE = /:(.*)$/;
|
2322
|
+
var bindRE = /^:|^v-bind:/;
|
2323
|
+
var modifierRE = /\.[^.]+/g;
|
2324
|
+
|
2325
|
+
var decodeHTMLCached = cached(he.decode);
|
2326
|
+
|
2327
|
+
// configurable state
|
2328
|
+
var warn$1;
|
2329
|
+
var delimiters;
|
2330
|
+
var transforms;
|
2331
|
+
var preTransforms;
|
2332
|
+
var postTransforms;
|
2333
|
+
var platformIsPreTag;
|
2334
|
+
var platformMustUseProp;
|
2335
|
+
var platformGetTagNamespace;
|
2336
|
+
|
2337
|
+
|
2338
|
+
|
2339
|
+
function createASTElement (
|
2340
|
+
tag,
|
2341
|
+
attrs,
|
2342
|
+
parent
|
2343
|
+
) {
|
2344
|
+
return {
|
2345
|
+
type: 1,
|
2346
|
+
tag: tag,
|
2347
|
+
attrsList: attrs,
|
2348
|
+
attrsMap: makeAttrsMap(attrs),
|
2349
|
+
parent: parent,
|
2350
|
+
children: []
|
2351
|
+
}
|
2352
|
+
}
|
2353
|
+
|
2354
|
+
/**
|
2355
|
+
* Convert HTML string to AST.
|
2356
|
+
*/
|
2357
|
+
function parse (
|
2358
|
+
template,
|
2359
|
+
options
|
2360
|
+
) {
|
2361
|
+
warn$1 = options.warn || baseWarn;
|
2362
|
+
|
2363
|
+
platformIsPreTag = options.isPreTag || no;
|
2364
|
+
platformMustUseProp = options.mustUseProp || no;
|
2365
|
+
platformGetTagNamespace = options.getTagNamespace || no;
|
2366
|
+
|
2367
|
+
transforms = pluckModuleFunction(options.modules, 'transformNode');
|
2368
|
+
preTransforms = pluckModuleFunction(options.modules, 'preTransformNode');
|
2369
|
+
postTransforms = pluckModuleFunction(options.modules, 'postTransformNode');
|
2370
|
+
|
2371
|
+
delimiters = options.delimiters;
|
2372
|
+
|
2373
|
+
var stack = [];
|
2374
|
+
var preserveWhitespace = options.preserveWhitespace !== false;
|
2375
|
+
var root;
|
2376
|
+
var currentParent;
|
2377
|
+
var inVPre = false;
|
2378
|
+
var inPre = false;
|
2379
|
+
var warned = false;
|
2380
|
+
|
2381
|
+
function warnOnce (msg) {
|
2382
|
+
if (!warned) {
|
2383
|
+
warned = true;
|
2384
|
+
warn$1(msg);
|
2385
|
+
}
|
2386
|
+
}
|
2387
|
+
|
2388
|
+
function closeElement (element) {
|
2389
|
+
// check pre state
|
2390
|
+
if (element.pre) {
|
2391
|
+
inVPre = false;
|
2392
|
+
}
|
2393
|
+
if (platformIsPreTag(element.tag)) {
|
2394
|
+
inPre = false;
|
2395
|
+
}
|
2396
|
+
// apply post-transforms
|
2397
|
+
for (var i = 0; i < postTransforms.length; i++) {
|
2398
|
+
postTransforms[i](element, options);
|
2399
|
+
}
|
2400
|
+
}
|
2401
|
+
|
2402
|
+
parseHTML(template, {
|
2403
|
+
warn: warn$1,
|
2404
|
+
expectHTML: options.expectHTML,
|
2405
|
+
isUnaryTag: options.isUnaryTag,
|
2406
|
+
canBeLeftOpenTag: options.canBeLeftOpenTag,
|
2407
|
+
shouldDecodeNewlines: options.shouldDecodeNewlines,
|
2408
|
+
shouldDecodeNewlinesForHref: options.shouldDecodeNewlinesForHref,
|
2409
|
+
shouldKeepComment: options.comments,
|
2410
|
+
start: function start (tag, attrs, unary) {
|
2411
|
+
// check namespace.
|
2412
|
+
// inherit parent ns if there is one
|
2413
|
+
var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag);
|
2414
|
+
|
2415
|
+
// handle IE svg bug
|
2416
|
+
/* istanbul ignore if */
|
2417
|
+
if (isIE && ns === 'svg') {
|
2418
|
+
attrs = guardIESVGBug(attrs);
|
2419
|
+
}
|
2420
|
+
|
2421
|
+
var element = createASTElement(tag, attrs, currentParent);
|
2422
|
+
if (ns) {
|
2423
|
+
element.ns = ns;
|
2424
|
+
}
|
2425
|
+
|
2426
|
+
if (isForbiddenTag(element) && !isServerRendering()) {
|
2427
|
+
element.forbidden = true;
|
2428
|
+
process.env.NODE_ENV !== 'production' && warn$1(
|
2429
|
+
'Templates should only be responsible for mapping the state to the ' +
|
2430
|
+
'UI. Avoid placing tags with side-effects in your templates, such as ' +
|
2431
|
+
"<" + tag + ">" + ', as they will not be parsed.'
|
2432
|
+
);
|
2433
|
+
}
|
2434
|
+
|
2435
|
+
// apply pre-transforms
|
2436
|
+
for (var i = 0; i < preTransforms.length; i++) {
|
2437
|
+
element = preTransforms[i](element, options) || element;
|
2438
|
+
}
|
2439
|
+
|
2440
|
+
if (!inVPre) {
|
2441
|
+
processPre(element);
|
2442
|
+
if (element.pre) {
|
2443
|
+
inVPre = true;
|
2444
|
+
}
|
2445
|
+
}
|
2446
|
+
if (platformIsPreTag(element.tag)) {
|
2447
|
+
inPre = true;
|
2448
|
+
}
|
2449
|
+
if (inVPre) {
|
2450
|
+
processRawAttrs(element);
|
2451
|
+
} else if (!element.processed) {
|
2452
|
+
// structural directives
|
2453
|
+
processFor(element);
|
2454
|
+
processIf(element);
|
2455
|
+
processOnce(element);
|
2456
|
+
// element-scope stuff
|
2457
|
+
processElement(element, options);
|
2458
|
+
}
|
2459
|
+
|
2460
|
+
function checkRootConstraints (el) {
|
2461
|
+
if (process.env.NODE_ENV !== 'production') {
|
2462
|
+
if (el.tag === 'slot' || el.tag === 'template') {
|
2463
|
+
warnOnce(
|
2464
|
+
"Cannot use <" + (el.tag) + "> as component root element because it may " +
|
2465
|
+
'contain multiple nodes.'
|
2466
|
+
);
|
2467
|
+
}
|
2468
|
+
if (el.attrsMap.hasOwnProperty('v-for')) {
|
2469
|
+
warnOnce(
|
2470
|
+
'Cannot use v-for on stateful component root element because ' +
|
2471
|
+
'it renders multiple elements.'
|
2472
|
+
);
|
2473
|
+
}
|
2474
|
+
}
|
2475
|
+
}
|
2476
|
+
|
2477
|
+
// tree management
|
2478
|
+
if (!root) {
|
2479
|
+
root = element;
|
2480
|
+
checkRootConstraints(root);
|
2481
|
+
} else if (!stack.length) {
|
2482
|
+
// allow root elements with v-if, v-else-if and v-else
|
2483
|
+
if (root.if && (element.elseif || element.else)) {
|
2484
|
+
checkRootConstraints(element);
|
2485
|
+
addIfCondition(root, {
|
2486
|
+
exp: element.elseif,
|
2487
|
+
block: element
|
2488
|
+
});
|
2489
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
2490
|
+
warnOnce(
|
2491
|
+
"Component template should contain exactly one root element. " +
|
2492
|
+
"If you are using v-if on multiple elements, " +
|
2493
|
+
"use v-else-if to chain them instead."
|
2494
|
+
);
|
2495
|
+
}
|
2496
|
+
}
|
2497
|
+
if (currentParent && !element.forbidden) {
|
2498
|
+
if (element.elseif || element.else) {
|
2499
|
+
processIfConditions(element, currentParent);
|
2500
|
+
} else if (element.slotScope) { // scoped slot
|
2501
|
+
currentParent.plain = false;
|
2502
|
+
var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element;
|
2503
|
+
} else {
|
2504
|
+
currentParent.children.push(element);
|
2505
|
+
element.parent = currentParent;
|
2506
|
+
}
|
2507
|
+
}
|
2508
|
+
if (!unary) {
|
2509
|
+
currentParent = element;
|
2510
|
+
stack.push(element);
|
2511
|
+
} else {
|
2512
|
+
closeElement(element);
|
2513
|
+
}
|
2514
|
+
},
|
2515
|
+
|
2516
|
+
end: function end () {
|
2517
|
+
// remove trailing whitespace
|
2518
|
+
var element = stack[stack.length - 1];
|
2519
|
+
var lastNode = element.children[element.children.length - 1];
|
2520
|
+
if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) {
|
2521
|
+
element.children.pop();
|
2522
|
+
}
|
2523
|
+
// pop stack
|
2524
|
+
stack.length -= 1;
|
2525
|
+
currentParent = stack[stack.length - 1];
|
2526
|
+
closeElement(element);
|
2527
|
+
},
|
2528
|
+
|
2529
|
+
chars: function chars (text) {
|
2530
|
+
if (!currentParent) {
|
2531
|
+
if (process.env.NODE_ENV !== 'production') {
|
2532
|
+
if (text === template) {
|
2533
|
+
warnOnce(
|
2534
|
+
'Component template requires a root element, rather than just text.'
|
2535
|
+
);
|
2536
|
+
} else if ((text = text.trim())) {
|
2537
|
+
warnOnce(
|
2538
|
+
("text \"" + text + "\" outside root element will be ignored.")
|
2539
|
+
);
|
2540
|
+
}
|
2541
|
+
}
|
2542
|
+
return
|
2543
|
+
}
|
2544
|
+
// IE textarea placeholder bug
|
2545
|
+
/* istanbul ignore if */
|
2546
|
+
if (isIE &&
|
2547
|
+
currentParent.tag === 'textarea' &&
|
2548
|
+
currentParent.attrsMap.placeholder === text
|
2549
|
+
) {
|
2550
|
+
return
|
2551
|
+
}
|
2552
|
+
var children = currentParent.children;
|
2553
|
+
text = inPre || text.trim()
|
2554
|
+
? isTextTag(currentParent) ? text : decodeHTMLCached(text)
|
2555
|
+
// only preserve whitespace if its not right after a starting tag
|
2556
|
+
: preserveWhitespace && children.length ? ' ' : '';
|
2557
|
+
if (text) {
|
2558
|
+
var res;
|
2559
|
+
if (!inVPre && text !== ' ' && (res = parseText(text, delimiters))) {
|
2560
|
+
children.push({
|
2561
|
+
type: 2,
|
2562
|
+
expression: res.expression,
|
2563
|
+
tokens: res.tokens,
|
2564
|
+
text: text
|
2565
|
+
});
|
2566
|
+
} else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') {
|
2567
|
+
children.push({
|
2568
|
+
type: 3,
|
2569
|
+
text: text
|
2570
|
+
});
|
2571
|
+
}
|
2572
|
+
}
|
2573
|
+
},
|
2574
|
+
comment: function comment (text) {
|
2575
|
+
currentParent.children.push({
|
2576
|
+
type: 3,
|
2577
|
+
text: text,
|
2578
|
+
isComment: true
|
2579
|
+
});
|
2580
|
+
}
|
2581
|
+
});
|
2582
|
+
return root
|
2583
|
+
}
|
2584
|
+
|
2585
|
+
function processPre (el) {
|
2586
|
+
if (getAndRemoveAttr(el, 'v-pre') != null) {
|
2587
|
+
el.pre = true;
|
2588
|
+
}
|
2589
|
+
}
|
2590
|
+
|
2591
|
+
function processRawAttrs (el) {
|
2592
|
+
var l = el.attrsList.length;
|
2593
|
+
if (l) {
|
2594
|
+
var attrs = el.attrs = new Array(l);
|
2595
|
+
for (var i = 0; i < l; i++) {
|
2596
|
+
attrs[i] = {
|
2597
|
+
name: el.attrsList[i].name,
|
2598
|
+
value: JSON.stringify(el.attrsList[i].value)
|
2599
|
+
};
|
2600
|
+
}
|
2601
|
+
} else if (!el.pre) {
|
2602
|
+
// non root node in pre blocks with no attributes
|
2603
|
+
el.plain = true;
|
2604
|
+
}
|
2605
|
+
}
|
2606
|
+
|
2607
|
+
function processElement (element, options) {
|
2608
|
+
processKey(element);
|
2609
|
+
|
2610
|
+
// determine whether this is a plain element after
|
2611
|
+
// removing structural attributes
|
2612
|
+
element.plain = !element.key && !element.attrsList.length;
|
2613
|
+
|
2614
|
+
processRef(element);
|
2615
|
+
processSlot(element);
|
2616
|
+
processComponent(element);
|
2617
|
+
for (var i = 0; i < transforms.length; i++) {
|
2618
|
+
element = transforms[i](element, options) || element;
|
2619
|
+
}
|
2620
|
+
processAttrs(element);
|
2621
|
+
}
|
2622
|
+
|
2623
|
+
function processKey (el) {
|
2624
|
+
var exp = getBindingAttr(el, 'key');
|
2625
|
+
if (exp) {
|
2626
|
+
if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
|
2627
|
+
warn$1("<template> cannot be keyed. Place the key on real elements instead.");
|
2628
|
+
}
|
2629
|
+
el.key = exp;
|
2630
|
+
}
|
2631
|
+
}
|
2632
|
+
|
2633
|
+
function processRef (el) {
|
2634
|
+
var ref = getBindingAttr(el, 'ref');
|
2635
|
+
if (ref) {
|
2636
|
+
el.ref = ref;
|
2637
|
+
el.refInFor = checkInFor(el);
|
2638
|
+
}
|
2639
|
+
}
|
2640
|
+
|
2641
|
+
function processFor (el) {
|
2642
|
+
var exp;
|
2643
|
+
if ((exp = getAndRemoveAttr(el, 'v-for'))) {
|
2644
|
+
var res = parseFor(exp);
|
2645
|
+
if (res) {
|
2646
|
+
extend(el, res);
|
2647
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
2648
|
+
warn$1(
|
2649
|
+
("Invalid v-for expression: " + exp)
|
2650
|
+
);
|
2651
|
+
}
|
2652
|
+
}
|
2653
|
+
}
|
2654
|
+
|
2655
|
+
|
2656
|
+
|
2657
|
+
function parseFor (exp) {
|
2658
|
+
var inMatch = exp.match(forAliasRE);
|
2659
|
+
if (!inMatch) { return }
|
2660
|
+
var res = {};
|
2661
|
+
res.for = inMatch[2].trim();
|
2662
|
+
var alias = inMatch[1].trim().replace(stripParensRE, '');
|
2663
|
+
var iteratorMatch = alias.match(forIteratorRE);
|
2664
|
+
if (iteratorMatch) {
|
2665
|
+
res.alias = alias.replace(forIteratorRE, '');
|
2666
|
+
res.iterator1 = iteratorMatch[1].trim();
|
2667
|
+
if (iteratorMatch[2]) {
|
2668
|
+
res.iterator2 = iteratorMatch[2].trim();
|
2669
|
+
}
|
2670
|
+
} else {
|
2671
|
+
res.alias = alias;
|
2672
|
+
}
|
2673
|
+
return res
|
2674
|
+
}
|
2675
|
+
|
2676
|
+
function processIf (el) {
|
2677
|
+
var exp = getAndRemoveAttr(el, 'v-if');
|
2678
|
+
if (exp) {
|
2679
|
+
el.if = exp;
|
2680
|
+
addIfCondition(el, {
|
2681
|
+
exp: exp,
|
2682
|
+
block: el
|
2683
|
+
});
|
2684
|
+
} else {
|
2685
|
+
if (getAndRemoveAttr(el, 'v-else') != null) {
|
2686
|
+
el.else = true;
|
2687
|
+
}
|
2688
|
+
var elseif = getAndRemoveAttr(el, 'v-else-if');
|
2689
|
+
if (elseif) {
|
2690
|
+
el.elseif = elseif;
|
2691
|
+
}
|
2692
|
+
}
|
2693
|
+
}
|
2694
|
+
|
2695
|
+
function processIfConditions (el, parent) {
|
2696
|
+
var prev = findPrevElement(parent.children);
|
2697
|
+
if (prev && prev.if) {
|
2698
|
+
addIfCondition(prev, {
|
2699
|
+
exp: el.elseif,
|
2700
|
+
block: el
|
2701
|
+
});
|
2702
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
2703
|
+
warn$1(
|
2704
|
+
"v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " +
|
2705
|
+
"used on element <" + (el.tag) + "> without corresponding v-if."
|
2706
|
+
);
|
2707
|
+
}
|
2708
|
+
}
|
2709
|
+
|
2710
|
+
function findPrevElement (children) {
|
2711
|
+
var i = children.length;
|
2712
|
+
while (i--) {
|
2713
|
+
if (children[i].type === 1) {
|
2714
|
+
return children[i]
|
2715
|
+
} else {
|
2716
|
+
if (process.env.NODE_ENV !== 'production' && children[i].text !== ' ') {
|
2717
|
+
warn$1(
|
2718
|
+
"text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " +
|
2719
|
+
"will be ignored."
|
2720
|
+
);
|
2721
|
+
}
|
2722
|
+
children.pop();
|
2723
|
+
}
|
2724
|
+
}
|
2725
|
+
}
|
2726
|
+
|
2727
|
+
function addIfCondition (el, condition) {
|
2728
|
+
if (!el.ifConditions) {
|
2729
|
+
el.ifConditions = [];
|
2730
|
+
}
|
2731
|
+
el.ifConditions.push(condition);
|
2732
|
+
}
|
2733
|
+
|
2734
|
+
function processOnce (el) {
|
2735
|
+
var once$$1 = getAndRemoveAttr(el, 'v-once');
|
2736
|
+
if (once$$1 != null) {
|
2737
|
+
el.once = true;
|
2738
|
+
}
|
2739
|
+
}
|
2740
|
+
|
2741
|
+
function processSlot (el) {
|
2742
|
+
if (el.tag === 'slot') {
|
2743
|
+
el.slotName = getBindingAttr(el, 'name');
|
2744
|
+
if (process.env.NODE_ENV !== 'production' && el.key) {
|
2745
|
+
warn$1(
|
2746
|
+
"`key` does not work on <slot> because slots are abstract outlets " +
|
2747
|
+
"and can possibly expand into multiple elements. " +
|
2748
|
+
"Use the key on a wrapping element instead."
|
2749
|
+
);
|
2750
|
+
}
|
2751
|
+
} else {
|
2752
|
+
var slotScope;
|
2753
|
+
if (el.tag === 'template') {
|
2754
|
+
slotScope = getAndRemoveAttr(el, 'scope');
|
2755
|
+
/* istanbul ignore if */
|
2756
|
+
if (process.env.NODE_ENV !== 'production' && slotScope) {
|
2757
|
+
warn$1(
|
2758
|
+
"the \"scope\" attribute for scoped slots have been deprecated and " +
|
2759
|
+
"replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
|
2760
|
+
"can also be used on plain elements in addition to <template> to " +
|
2761
|
+
"denote scoped slots.",
|
2762
|
+
true
|
2763
|
+
);
|
2764
|
+
}
|
2765
|
+
el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope');
|
2766
|
+
} else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
|
2767
|
+
/* istanbul ignore if */
|
2768
|
+
if (process.env.NODE_ENV !== 'production' && el.attrsMap['v-for']) {
|
2769
|
+
warn$1(
|
2770
|
+
"Ambiguous combined usage of slot-scope and v-for on <" + (el.tag) + "> " +
|
2771
|
+
"(v-for takes higher priority). Use a wrapper <template> for the " +
|
2772
|
+
"scoped slot to make it clearer.",
|
2773
|
+
true
|
2774
|
+
);
|
2775
|
+
}
|
2776
|
+
el.slotScope = slotScope;
|
2777
|
+
}
|
2778
|
+
var slotTarget = getBindingAttr(el, 'slot');
|
2779
|
+
if (slotTarget) {
|
2780
|
+
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget;
|
2781
|
+
// preserve slot as an attribute for native shadow DOM compat
|
2782
|
+
// only for non-scoped slots.
|
2783
|
+
if (el.tag !== 'template' && !el.slotScope) {
|
2784
|
+
addAttr(el, 'slot', slotTarget);
|
2785
|
+
}
|
2786
|
+
}
|
2787
|
+
}
|
2788
|
+
}
|
2789
|
+
|
2790
|
+
function processComponent (el) {
|
2791
|
+
var binding;
|
2792
|
+
if ((binding = getBindingAttr(el, 'is'))) {
|
2793
|
+
el.component = binding;
|
2794
|
+
}
|
2795
|
+
if (getAndRemoveAttr(el, 'inline-template') != null) {
|
2796
|
+
el.inlineTemplate = true;
|
2797
|
+
}
|
2798
|
+
}
|
2799
|
+
|
2800
|
+
function processAttrs (el) {
|
2801
|
+
var list = el.attrsList;
|
2802
|
+
var i, l, name, rawName, value, modifiers, isProp;
|
2803
|
+
for (i = 0, l = list.length; i < l; i++) {
|
2804
|
+
name = rawName = list[i].name;
|
2805
|
+
value = list[i].value;
|
2806
|
+
if (dirRE.test(name)) {
|
2807
|
+
// mark element as dynamic
|
2808
|
+
el.hasBindings = true;
|
2809
|
+
// modifiers
|
2810
|
+
modifiers = parseModifiers(name);
|
2811
|
+
if (modifiers) {
|
2812
|
+
name = name.replace(modifierRE, '');
|
2813
|
+
}
|
2814
|
+
if (bindRE.test(name)) { // v-bind
|
2815
|
+
name = name.replace(bindRE, '');
|
2816
|
+
value = parseFilters(value);
|
2817
|
+
isProp = false;
|
2818
|
+
if (modifiers) {
|
2819
|
+
if (modifiers.prop) {
|
2820
|
+
isProp = true;
|
2821
|
+
name = camelize(name);
|
2822
|
+
if (name === 'innerHtml') { name = 'innerHTML'; }
|
2823
|
+
}
|
2824
|
+
if (modifiers.camel) {
|
2825
|
+
name = camelize(name);
|
2826
|
+
}
|
2827
|
+
if (modifiers.sync) {
|
2828
|
+
addHandler(
|
2829
|
+
el,
|
2830
|
+
("update:" + (camelize(name))),
|
2831
|
+
genAssignmentCode(value, "$event")
|
2832
|
+
);
|
2833
|
+
}
|
2834
|
+
}
|
2835
|
+
if (isProp || (
|
2836
|
+
!el.component && platformMustUseProp(el.tag, el.attrsMap.type, name)
|
2837
|
+
)) {
|
2838
|
+
addProp(el, name, value);
|
2839
|
+
} else {
|
2840
|
+
addAttr(el, name, value);
|
2841
|
+
}
|
2842
|
+
} else if (onRE.test(name)) { // v-on
|
2843
|
+
name = name.replace(onRE, '');
|
2844
|
+
addHandler(el, name, value, modifiers, false, warn$1);
|
2845
|
+
} else { // normal directives
|
2846
|
+
name = name.replace(dirRE, '');
|
2847
|
+
// parse arg
|
2848
|
+
var argMatch = name.match(argRE);
|
2849
|
+
var arg = argMatch && argMatch[1];
|
2850
|
+
if (arg) {
|
2851
|
+
name = name.slice(0, -(arg.length + 1));
|
2852
|
+
}
|
2853
|
+
addDirective(el, name, rawName, value, arg, modifiers);
|
2854
|
+
if (process.env.NODE_ENV !== 'production' && name === 'model') {
|
2855
|
+
checkForAliasModel(el, value);
|
2856
|
+
}
|
2857
|
+
}
|
2858
|
+
} else {
|
2859
|
+
// literal attribute
|
2860
|
+
if (process.env.NODE_ENV !== 'production') {
|
2861
|
+
var res = parseText(value, delimiters);
|
2862
|
+
if (res) {
|
2863
|
+
warn$1(
|
2864
|
+
name + "=\"" + value + "\": " +
|
2865
|
+
'Interpolation inside attributes has been removed. ' +
|
2866
|
+
'Use v-bind or the colon shorthand instead. For example, ' +
|
2867
|
+
'instead of <div id="{{ val }}">, use <div :id="val">.'
|
2868
|
+
);
|
2869
|
+
}
|
2870
|
+
}
|
2871
|
+
addAttr(el, name, JSON.stringify(value));
|
2872
|
+
// #6887 firefox doesn't update muted state if set via attribute
|
2873
|
+
// even immediately after element creation
|
2874
|
+
if (!el.component &&
|
2875
|
+
name === 'muted' &&
|
2876
|
+
platformMustUseProp(el.tag, el.attrsMap.type, name)) {
|
2877
|
+
addProp(el, name, 'true');
|
2878
|
+
}
|
2879
|
+
}
|
2880
|
+
}
|
2881
|
+
}
|
2882
|
+
|
2883
|
+
function checkInFor (el) {
|
2884
|
+
var parent = el;
|
2885
|
+
while (parent) {
|
2886
|
+
if (parent.for !== undefined) {
|
2887
|
+
return true
|
2888
|
+
}
|
2889
|
+
parent = parent.parent;
|
2890
|
+
}
|
2891
|
+
return false
|
2892
|
+
}
|
2893
|
+
|
2894
|
+
function parseModifiers (name) {
|
2895
|
+
var match = name.match(modifierRE);
|
2896
|
+
if (match) {
|
2897
|
+
var ret = {};
|
2898
|
+
match.forEach(function (m) { ret[m.slice(1)] = true; });
|
2899
|
+
return ret
|
2900
|
+
}
|
2901
|
+
}
|
2902
|
+
|
2903
|
+
function makeAttrsMap (attrs) {
|
2904
|
+
var map = {};
|
2905
|
+
for (var i = 0, l = attrs.length; i < l; i++) {
|
2906
|
+
if (
|
2907
|
+
process.env.NODE_ENV !== 'production' &&
|
2908
|
+
map[attrs[i].name] && !isIE && !isEdge
|
2909
|
+
) {
|
2910
|
+
warn$1('duplicate attribute: ' + attrs[i].name);
|
2911
|
+
}
|
2912
|
+
map[attrs[i].name] = attrs[i].value;
|
2913
|
+
}
|
2914
|
+
return map
|
2915
|
+
}
|
2916
|
+
|
2917
|
+
// for script (e.g. type="x/template") or style, do not decode content
|
2918
|
+
function isTextTag (el) {
|
2919
|
+
return el.tag === 'script' || el.tag === 'style'
|
2920
|
+
}
|
2921
|
+
|
2922
|
+
function isForbiddenTag (el) {
|
2923
|
+
return (
|
2924
|
+
el.tag === 'style' ||
|
2925
|
+
(el.tag === 'script' && (
|
2926
|
+
!el.attrsMap.type ||
|
2927
|
+
el.attrsMap.type === 'text/javascript'
|
2928
|
+
))
|
2929
|
+
)
|
2930
|
+
}
|
2931
|
+
|
2932
|
+
var ieNSBug = /^xmlns:NS\d+/;
|
2933
|
+
var ieNSPrefix = /^NS\d+:/;
|
2934
|
+
|
2935
|
+
/* istanbul ignore next */
|
2936
|
+
function guardIESVGBug (attrs) {
|
2937
|
+
var res = [];
|
2938
|
+
for (var i = 0; i < attrs.length; i++) {
|
2939
|
+
var attr = attrs[i];
|
2940
|
+
if (!ieNSBug.test(attr.name)) {
|
2941
|
+
attr.name = attr.name.replace(ieNSPrefix, '');
|
2942
|
+
res.push(attr);
|
2943
|
+
}
|
2944
|
+
}
|
2945
|
+
return res
|
2946
|
+
}
|
2947
|
+
|
2948
|
+
function checkForAliasModel (el, value) {
|
2949
|
+
var _el = el;
|
2950
|
+
while (_el) {
|
2951
|
+
if (_el.for && _el.alias === value) {
|
2952
|
+
warn$1(
|
2953
|
+
"<" + (el.tag) + " v-model=\"" + value + "\">: " +
|
2954
|
+
"You are binding v-model directly to a v-for iteration alias. " +
|
2955
|
+
"This will not be able to modify the v-for source array because " +
|
2956
|
+
"writing to the alias is like modifying a function local variable. " +
|
2957
|
+
"Consider using an array of objects and use v-model on an object property instead."
|
2958
|
+
);
|
2959
|
+
}
|
2960
|
+
_el = _el.parent;
|
2961
|
+
}
|
2962
|
+
}
|
2963
|
+
|
2964
|
+
/* */
|
2965
|
+
|
2966
|
+
/**
|
2967
|
+
* Expand input[v-model] with dyanmic type bindings into v-if-else chains
|
2968
|
+
* Turn this:
|
2969
|
+
* <input v-model="data[type]" :type="type">
|
2970
|
+
* into this:
|
2971
|
+
* <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
|
2972
|
+
* <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
|
2973
|
+
* <input v-else :type="type" v-model="data[type]">
|
2974
|
+
*/
|
2975
|
+
|
2976
|
+
function preTransformNode (el, options) {
|
2977
|
+
if (el.tag === 'input') {
|
2978
|
+
var map = el.attrsMap;
|
2979
|
+
if (!map['v-model']) {
|
2980
|
+
return
|
2981
|
+
}
|
2982
|
+
|
2983
|
+
var typeBinding;
|
2984
|
+
if (map[':type'] || map['v-bind:type']) {
|
2985
|
+
typeBinding = getBindingAttr(el, 'type');
|
2986
|
+
}
|
2987
|
+
if (!map.type && !typeBinding && map['v-bind']) {
|
2988
|
+
typeBinding = "(" + (map['v-bind']) + ").type";
|
2989
|
+
}
|
2990
|
+
|
2991
|
+
if (typeBinding) {
|
2992
|
+
var ifCondition = getAndRemoveAttr(el, 'v-if', true);
|
2993
|
+
var ifConditionExtra = ifCondition ? ("&&(" + ifCondition + ")") : "";
|
2994
|
+
var hasElse = getAndRemoveAttr(el, 'v-else', true) != null;
|
2995
|
+
var elseIfCondition = getAndRemoveAttr(el, 'v-else-if', true);
|
2996
|
+
// 1. checkbox
|
2997
|
+
var branch0 = cloneASTElement(el);
|
2998
|
+
// process for on the main node
|
2999
|
+
processFor(branch0);
|
3000
|
+
addRawAttr(branch0, 'type', 'checkbox');
|
3001
|
+
processElement(branch0, options);
|
3002
|
+
branch0.processed = true; // prevent it from double-processed
|
3003
|
+
branch0.if = "(" + typeBinding + ")==='checkbox'" + ifConditionExtra;
|
3004
|
+
addIfCondition(branch0, {
|
3005
|
+
exp: branch0.if,
|
3006
|
+
block: branch0
|
3007
|
+
});
|
3008
|
+
// 2. add radio else-if condition
|
3009
|
+
var branch1 = cloneASTElement(el);
|
3010
|
+
getAndRemoveAttr(branch1, 'v-for', true);
|
3011
|
+
addRawAttr(branch1, 'type', 'radio');
|
3012
|
+
processElement(branch1, options);
|
3013
|
+
addIfCondition(branch0, {
|
3014
|
+
exp: "(" + typeBinding + ")==='radio'" + ifConditionExtra,
|
3015
|
+
block: branch1
|
3016
|
+
});
|
3017
|
+
// 3. other
|
3018
|
+
var branch2 = cloneASTElement(el);
|
3019
|
+
getAndRemoveAttr(branch2, 'v-for', true);
|
3020
|
+
addRawAttr(branch2, ':type', typeBinding);
|
3021
|
+
processElement(branch2, options);
|
3022
|
+
addIfCondition(branch0, {
|
3023
|
+
exp: ifCondition,
|
3024
|
+
block: branch2
|
3025
|
+
});
|
3026
|
+
|
3027
|
+
if (hasElse) {
|
3028
|
+
branch0.else = true;
|
3029
|
+
} else if (elseIfCondition) {
|
3030
|
+
branch0.elseif = elseIfCondition;
|
3031
|
+
}
|
3032
|
+
|
3033
|
+
return branch0
|
3034
|
+
}
|
3035
|
+
}
|
3036
|
+
}
|
3037
|
+
|
3038
|
+
function cloneASTElement (el) {
|
3039
|
+
return createASTElement(el.tag, el.attrsList.slice(), el.parent)
|
3040
|
+
}
|
3041
|
+
|
3042
|
+
var model = {
|
3043
|
+
preTransformNode: preTransformNode
|
3044
|
+
}
|
3045
|
+
|
3046
|
+
var modules = [
|
3047
|
+
klass,
|
3048
|
+
style,
|
3049
|
+
model
|
3050
|
+
]
|
3051
|
+
|
3052
|
+
/* */
|
3053
|
+
|
3054
|
+
var warn$2;
|
3055
|
+
|
3056
|
+
// in some cases, the event used has to be determined at runtime
|
3057
|
+
// so we used some reserved tokens during compile.
|
3058
|
+
var RANGE_TOKEN = '__r';
|
3059
|
+
|
3060
|
+
|
3061
|
+
function model$1 (
|
3062
|
+
el,
|
3063
|
+
dir,
|
3064
|
+
_warn
|
3065
|
+
) {
|
3066
|
+
warn$2 = _warn;
|
3067
|
+
var value = dir.value;
|
3068
|
+
var modifiers = dir.modifiers;
|
3069
|
+
var tag = el.tag;
|
3070
|
+
var type = el.attrsMap.type;
|
3071
|
+
|
3072
|
+
if (process.env.NODE_ENV !== 'production') {
|
3073
|
+
// inputs with type="file" are read only and setting the input's
|
3074
|
+
// value will throw an error.
|
3075
|
+
if (tag === 'input' && type === 'file') {
|
3076
|
+
warn$2(
|
3077
|
+
"<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" +
|
3078
|
+
"File inputs are read only. Use a v-on:change listener instead."
|
3079
|
+
);
|
3080
|
+
}
|
3081
|
+
}
|
3082
|
+
|
3083
|
+
if (el.component) {
|
3084
|
+
genComponentModel(el, value, modifiers);
|
3085
|
+
// component v-model doesn't need extra runtime
|
3086
|
+
return false
|
3087
|
+
} else if (tag === 'select') {
|
3088
|
+
genSelect(el, value, modifiers);
|
3089
|
+
} else if (tag === 'input' && type === 'checkbox') {
|
3090
|
+
genCheckboxModel(el, value, modifiers);
|
3091
|
+
} else if (tag === 'input' && type === 'radio') {
|
3092
|
+
genRadioModel(el, value, modifiers);
|
3093
|
+
} else if (tag === 'input' || tag === 'textarea') {
|
3094
|
+
genDefaultModel(el, value, modifiers);
|
3095
|
+
} else if (!config.isReservedTag(tag)) {
|
3096
|
+
genComponentModel(el, value, modifiers);
|
3097
|
+
// component v-model doesn't need extra runtime
|
3098
|
+
return false
|
3099
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
3100
|
+
warn$2(
|
3101
|
+
"<" + (el.tag) + " v-model=\"" + value + "\">: " +
|
3102
|
+
"v-model is not supported on this element type. " +
|
3103
|
+
'If you are working with contenteditable, it\'s recommended to ' +
|
3104
|
+
'wrap a library dedicated for that purpose inside a custom component.'
|
3105
|
+
);
|
3106
|
+
}
|
3107
|
+
|
3108
|
+
// ensure runtime directive metadata
|
3109
|
+
return true
|
3110
|
+
}
|
3111
|
+
|
3112
|
+
function genCheckboxModel (
|
3113
|
+
el,
|
3114
|
+
value,
|
3115
|
+
modifiers
|
3116
|
+
) {
|
3117
|
+
var number = modifiers && modifiers.number;
|
3118
|
+
var valueBinding = getBindingAttr(el, 'value') || 'null';
|
3119
|
+
var trueValueBinding = getBindingAttr(el, 'true-value') || 'true';
|
3120
|
+
var falseValueBinding = getBindingAttr(el, 'false-value') || 'false';
|
3121
|
+
addProp(el, 'checked',
|
3122
|
+
"Array.isArray(" + value + ")" +
|
3123
|
+
"?_i(" + value + "," + valueBinding + ")>-1" + (
|
3124
|
+
trueValueBinding === 'true'
|
3125
|
+
? (":(" + value + ")")
|
3126
|
+
: (":_q(" + value + "," + trueValueBinding + ")")
|
3127
|
+
)
|
3128
|
+
);
|
3129
|
+
addHandler(el, 'change',
|
3130
|
+
"var $$a=" + value + "," +
|
3131
|
+
'$$el=$event.target,' +
|
3132
|
+
"$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" +
|
3133
|
+
'if(Array.isArray($$a)){' +
|
3134
|
+
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," +
|
3135
|
+
'$$i=_i($$a,$$v);' +
|
3136
|
+
"if($$el.checked){$$i<0&&(" + (genAssignmentCode(value, '$$a.concat([$$v])')) + ")}" +
|
3137
|
+
"else{$$i>-1&&(" + (genAssignmentCode(value, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
|
3138
|
+
"}else{" + (genAssignmentCode(value, '$$c')) + "}",
|
3139
|
+
null, true
|
3140
|
+
);
|
3141
|
+
}
|
3142
|
+
|
3143
|
+
function genRadioModel (
|
3144
|
+
el,
|
3145
|
+
value,
|
3146
|
+
modifiers
|
3147
|
+
) {
|
3148
|
+
var number = modifiers && modifiers.number;
|
3149
|
+
var valueBinding = getBindingAttr(el, 'value') || 'null';
|
3150
|
+
valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding;
|
3151
|
+
addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")"));
|
3152
|
+
addHandler(el, 'change', genAssignmentCode(value, valueBinding), null, true);
|
3153
|
+
}
|
3154
|
+
|
3155
|
+
function genSelect (
|
3156
|
+
el,
|
3157
|
+
value,
|
3158
|
+
modifiers
|
3159
|
+
) {
|
3160
|
+
var number = modifiers && modifiers.number;
|
3161
|
+
var selectedVal = "Array.prototype.filter" +
|
3162
|
+
".call($event.target.options,function(o){return o.selected})" +
|
3163
|
+
".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
|
3164
|
+
"return " + (number ? '_n(val)' : 'val') + "})";
|
3165
|
+
|
3166
|
+
var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
|
3167
|
+
var code = "var $$selectedVal = " + selectedVal + ";";
|
3168
|
+
code = code + " " + (genAssignmentCode(value, assignment));
|
3169
|
+
addHandler(el, 'change', code, null, true);
|
3170
|
+
}
|
3171
|
+
|
3172
|
+
function genDefaultModel (
|
3173
|
+
el,
|
3174
|
+
value,
|
3175
|
+
modifiers
|
3176
|
+
) {
|
3177
|
+
var type = el.attrsMap.type;
|
3178
|
+
|
3179
|
+
// warn if v-bind:value conflicts with v-model
|
3180
|
+
// except for inputs with v-bind:type
|
3181
|
+
if (process.env.NODE_ENV !== 'production') {
|
3182
|
+
var value$1 = el.attrsMap['v-bind:value'] || el.attrsMap[':value'];
|
3183
|
+
var typeBinding = el.attrsMap['v-bind:type'] || el.attrsMap[':type'];
|
3184
|
+
if (value$1 && !typeBinding) {
|
3185
|
+
var binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value';
|
3186
|
+
warn$2(
|
3187
|
+
binding + "=\"" + value$1 + "\" conflicts with v-model on the same element " +
|
3188
|
+
'because the latter already expands to a value binding internally'
|
3189
|
+
);
|
3190
|
+
}
|
3191
|
+
}
|
3192
|
+
|
3193
|
+
var ref = modifiers || {};
|
3194
|
+
var lazy = ref.lazy;
|
3195
|
+
var number = ref.number;
|
3196
|
+
var trim = ref.trim;
|
3197
|
+
var needCompositionGuard = !lazy && type !== 'range';
|
3198
|
+
var event = lazy
|
3199
|
+
? 'change'
|
3200
|
+
: type === 'range'
|
3201
|
+
? RANGE_TOKEN
|
3202
|
+
: 'input';
|
3203
|
+
|
3204
|
+
var valueExpression = '$event.target.value';
|
3205
|
+
if (trim) {
|
3206
|
+
valueExpression = "$event.target.value.trim()";
|
3207
|
+
}
|
3208
|
+
if (number) {
|
3209
|
+
valueExpression = "_n(" + valueExpression + ")";
|
3210
|
+
}
|
3211
|
+
|
3212
|
+
var code = genAssignmentCode(value, valueExpression);
|
3213
|
+
if (needCompositionGuard) {
|
3214
|
+
code = "if($event.target.composing)return;" + code;
|
3215
|
+
}
|
3216
|
+
|
3217
|
+
addProp(el, 'value', ("(" + value + ")"));
|
3218
|
+
addHandler(el, event, code, null, true);
|
3219
|
+
if (trim || number) {
|
3220
|
+
addHandler(el, 'blur', '$forceUpdate()');
|
3221
|
+
}
|
3222
|
+
}
|
3223
|
+
|
3224
|
+
/* */
|
3225
|
+
|
3226
|
+
function text (el, dir) {
|
3227
|
+
if (dir.value) {
|
3228
|
+
addProp(el, 'textContent', ("_s(" + (dir.value) + ")"));
|
3229
|
+
}
|
3230
|
+
}
|
3231
|
+
|
3232
|
+
/* */
|
3233
|
+
|
3234
|
+
function html (el, dir) {
|
3235
|
+
if (dir.value) {
|
3236
|
+
addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")"));
|
3237
|
+
}
|
3238
|
+
}
|
3239
|
+
|
3240
|
+
var directives = {
|
3241
|
+
model: model$1,
|
3242
|
+
text: text,
|
3243
|
+
html: html
|
3244
|
+
}
|
3245
|
+
|
3246
|
+
/* */
|
3247
|
+
|
3248
|
+
var baseOptions = {
|
3249
|
+
expectHTML: true,
|
3250
|
+
modules: modules,
|
3251
|
+
directives: directives,
|
3252
|
+
isPreTag: isPreTag,
|
3253
|
+
isUnaryTag: isUnaryTag,
|
3254
|
+
mustUseProp: mustUseProp,
|
3255
|
+
canBeLeftOpenTag: canBeLeftOpenTag,
|
3256
|
+
isReservedTag: isReservedTag,
|
3257
|
+
getTagNamespace: getTagNamespace,
|
3258
|
+
staticKeys: genStaticKeys(modules)
|
3259
|
+
};
|
3260
|
+
|
3261
|
+
/* */
|
3262
|
+
|
3263
|
+
var isStaticKey;
|
3264
|
+
var isPlatformReservedTag;
|
3265
|
+
|
3266
|
+
var genStaticKeysCached = cached(genStaticKeys$1);
|
3267
|
+
|
3268
|
+
/**
|
3269
|
+
* Goal of the optimizer: walk the generated template AST tree
|
3270
|
+
* and detect sub-trees that are purely static, i.e. parts of
|
3271
|
+
* the DOM that never needs to change.
|
3272
|
+
*
|
3273
|
+
* Once we detect these sub-trees, we can:
|
3274
|
+
*
|
3275
|
+
* 1. Hoist them into constants, so that we no longer need to
|
3276
|
+
* create fresh nodes for them on each re-render;
|
3277
|
+
* 2. Completely skip them in the patching process.
|
3278
|
+
*/
|
3279
|
+
function optimize (root, options) {
|
3280
|
+
if (!root) { return }
|
3281
|
+
isStaticKey = genStaticKeysCached(options.staticKeys || '');
|
3282
|
+
isPlatformReservedTag = options.isReservedTag || no;
|
3283
|
+
// first pass: mark all non-static nodes.
|
3284
|
+
markStatic(root);
|
3285
|
+
// second pass: mark static roots.
|
3286
|
+
markStaticRoots(root, false);
|
3287
|
+
}
|
3288
|
+
|
3289
|
+
function genStaticKeys$1 (keys) {
|
3290
|
+
return makeMap(
|
3291
|
+
'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
|
3292
|
+
(keys ? ',' + keys : '')
|
3293
|
+
)
|
3294
|
+
}
|
3295
|
+
|
3296
|
+
function markStatic (node) {
|
3297
|
+
node.static = isStatic(node);
|
3298
|
+
if (node.type === 1) {
|
3299
|
+
// do not make component slot content static. this avoids
|
3300
|
+
// 1. components not able to mutate slot nodes
|
3301
|
+
// 2. static slot content fails for hot-reloading
|
3302
|
+
if (
|
3303
|
+
!isPlatformReservedTag(node.tag) &&
|
3304
|
+
node.tag !== 'slot' &&
|
3305
|
+
node.attrsMap['inline-template'] == null
|
3306
|
+
) {
|
3307
|
+
return
|
3308
|
+
}
|
3309
|
+
for (var i = 0, l = node.children.length; i < l; i++) {
|
3310
|
+
var child = node.children[i];
|
3311
|
+
markStatic(child);
|
3312
|
+
if (!child.static) {
|
3313
|
+
node.static = false;
|
3314
|
+
}
|
3315
|
+
}
|
3316
|
+
if (node.ifConditions) {
|
3317
|
+
for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
|
3318
|
+
var block = node.ifConditions[i$1].block;
|
3319
|
+
markStatic(block);
|
3320
|
+
if (!block.static) {
|
3321
|
+
node.static = false;
|
3322
|
+
}
|
3323
|
+
}
|
3324
|
+
}
|
3325
|
+
}
|
3326
|
+
}
|
3327
|
+
|
3328
|
+
function markStaticRoots (node, isInFor) {
|
3329
|
+
if (node.type === 1) {
|
3330
|
+
if (node.static || node.once) {
|
3331
|
+
node.staticInFor = isInFor;
|
3332
|
+
}
|
3333
|
+
// For a node to qualify as a static root, it should have children that
|
3334
|
+
// are not just static text. Otherwise the cost of hoisting out will
|
3335
|
+
// outweigh the benefits and it's better off to just always render it fresh.
|
3336
|
+
if (node.static && node.children.length && !(
|
3337
|
+
node.children.length === 1 &&
|
3338
|
+
node.children[0].type === 3
|
3339
|
+
)) {
|
3340
|
+
node.staticRoot = true;
|
3341
|
+
return
|
3342
|
+
} else {
|
3343
|
+
node.staticRoot = false;
|
3344
|
+
}
|
3345
|
+
if (node.children) {
|
3346
|
+
for (var i = 0, l = node.children.length; i < l; i++) {
|
3347
|
+
markStaticRoots(node.children[i], isInFor || !!node.for);
|
3348
|
+
}
|
3349
|
+
}
|
3350
|
+
if (node.ifConditions) {
|
3351
|
+
for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
|
3352
|
+
markStaticRoots(node.ifConditions[i$1].block, isInFor);
|
3353
|
+
}
|
3354
|
+
}
|
3355
|
+
}
|
3356
|
+
}
|
3357
|
+
|
3358
|
+
function isStatic (node) {
|
3359
|
+
if (node.type === 2) { // expression
|
3360
|
+
return false
|
3361
|
+
}
|
3362
|
+
if (node.type === 3) { // text
|
3363
|
+
return true
|
3364
|
+
}
|
3365
|
+
return !!(node.pre || (
|
3366
|
+
!node.hasBindings && // no dynamic bindings
|
3367
|
+
!node.if && !node.for && // not v-if or v-for or v-else
|
3368
|
+
!isBuiltInTag(node.tag) && // not a built-in
|
3369
|
+
isPlatformReservedTag(node.tag) && // not a component
|
3370
|
+
!isDirectChildOfTemplateFor(node) &&
|
3371
|
+
Object.keys(node).every(isStaticKey)
|
3372
|
+
))
|
3373
|
+
}
|
3374
|
+
|
3375
|
+
function isDirectChildOfTemplateFor (node) {
|
3376
|
+
while (node.parent) {
|
3377
|
+
node = node.parent;
|
3378
|
+
if (node.tag !== 'template') {
|
3379
|
+
return false
|
3380
|
+
}
|
3381
|
+
if (node.for) {
|
3382
|
+
return true
|
3383
|
+
}
|
3384
|
+
}
|
3385
|
+
return false
|
3386
|
+
}
|
3387
|
+
|
3388
|
+
/* */
|
3389
|
+
|
3390
|
+
var fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
|
3391
|
+
var simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
3392
|
+
|
3393
|
+
// KeyboardEvent.keyCode aliases
|
3394
|
+
var keyCodes = {
|
3395
|
+
esc: 27,
|
3396
|
+
tab: 9,
|
3397
|
+
enter: 13,
|
3398
|
+
space: 32,
|
3399
|
+
up: 38,
|
3400
|
+
left: 37,
|
3401
|
+
right: 39,
|
3402
|
+
down: 40,
|
3403
|
+
'delete': [8, 46]
|
3404
|
+
};
|
3405
|
+
|
3406
|
+
// KeyboardEvent.key aliases
|
3407
|
+
var keyNames = {
|
3408
|
+
esc: 'Escape',
|
3409
|
+
tab: 'Tab',
|
3410
|
+
enter: 'Enter',
|
3411
|
+
space: ' ',
|
3412
|
+
// #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
|
3413
|
+
up: ['Up', 'ArrowUp'],
|
3414
|
+
left: ['Left', 'ArrowLeft'],
|
3415
|
+
right: ['Right', 'ArrowRight'],
|
3416
|
+
down: ['Down', 'ArrowDown'],
|
3417
|
+
'delete': ['Backspace', 'Delete']
|
3418
|
+
};
|
3419
|
+
|
3420
|
+
// #4868: modifiers that prevent the execution of the listener
|
3421
|
+
// need to explicitly return null so that we can determine whether to remove
|
3422
|
+
// the listener for .once
|
3423
|
+
var genGuard = function (condition) { return ("if(" + condition + ")return null;"); };
|
3424
|
+
|
3425
|
+
var modifierCode = {
|
3426
|
+
stop: '$event.stopPropagation();',
|
3427
|
+
prevent: '$event.preventDefault();',
|
3428
|
+
self: genGuard("$event.target !== $event.currentTarget"),
|
3429
|
+
ctrl: genGuard("!$event.ctrlKey"),
|
3430
|
+
shift: genGuard("!$event.shiftKey"),
|
3431
|
+
alt: genGuard("!$event.altKey"),
|
3432
|
+
meta: genGuard("!$event.metaKey"),
|
3433
|
+
left: genGuard("'button' in $event && $event.button !== 0"),
|
3434
|
+
middle: genGuard("'button' in $event && $event.button !== 1"),
|
3435
|
+
right: genGuard("'button' in $event && $event.button !== 2")
|
3436
|
+
};
|
3437
|
+
|
3438
|
+
function genHandlers (
|
3439
|
+
events,
|
3440
|
+
isNative,
|
3441
|
+
warn
|
3442
|
+
) {
|
3443
|
+
var res = isNative ? 'nativeOn:{' : 'on:{';
|
3444
|
+
for (var name in events) {
|
3445
|
+
res += "\"" + name + "\":" + (genHandler(name, events[name])) + ",";
|
3446
|
+
}
|
3447
|
+
return res.slice(0, -1) + '}'
|
3448
|
+
}
|
3449
|
+
|
3450
|
+
function genHandler (
|
3451
|
+
name,
|
3452
|
+
handler
|
3453
|
+
) {
|
3454
|
+
if (!handler) {
|
3455
|
+
return 'function(){}'
|
3456
|
+
}
|
3457
|
+
|
3458
|
+
if (Array.isArray(handler)) {
|
3459
|
+
return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]")
|
3460
|
+
}
|
3461
|
+
|
3462
|
+
var isMethodPath = simplePathRE.test(handler.value);
|
3463
|
+
var isFunctionExpression = fnExpRE.test(handler.value);
|
3464
|
+
|
3465
|
+
if (!handler.modifiers) {
|
3466
|
+
if (isMethodPath || isFunctionExpression) {
|
3467
|
+
return handler.value
|
3468
|
+
}
|
3469
|
+
/* istanbul ignore if */
|
3470
|
+
return ("function($event){" + (handler.value) + "}") // inline statement
|
3471
|
+
} else {
|
3472
|
+
var code = '';
|
3473
|
+
var genModifierCode = '';
|
3474
|
+
var keys = [];
|
3475
|
+
for (var key in handler.modifiers) {
|
3476
|
+
if (modifierCode[key]) {
|
3477
|
+
genModifierCode += modifierCode[key];
|
3478
|
+
// left/right
|
3479
|
+
if (keyCodes[key]) {
|
3480
|
+
keys.push(key);
|
3481
|
+
}
|
3482
|
+
} else if (key === 'exact') {
|
3483
|
+
var modifiers = (handler.modifiers);
|
3484
|
+
genModifierCode += genGuard(
|
3485
|
+
['ctrl', 'shift', 'alt', 'meta']
|
3486
|
+
.filter(function (keyModifier) { return !modifiers[keyModifier]; })
|
3487
|
+
.map(function (keyModifier) { return ("$event." + keyModifier + "Key"); })
|
3488
|
+
.join('||')
|
3489
|
+
);
|
3490
|
+
} else {
|
3491
|
+
keys.push(key);
|
3492
|
+
}
|
3493
|
+
}
|
3494
|
+
if (keys.length) {
|
3495
|
+
code += genKeyFilter(keys);
|
3496
|
+
}
|
3497
|
+
// Make sure modifiers like prevent and stop get executed after key filtering
|
3498
|
+
if (genModifierCode) {
|
3499
|
+
code += genModifierCode;
|
3500
|
+
}
|
3501
|
+
var handlerCode = isMethodPath
|
3502
|
+
? ("return " + (handler.value) + "($event)")
|
3503
|
+
: isFunctionExpression
|
3504
|
+
? ("return (" + (handler.value) + ")($event)")
|
3505
|
+
: handler.value;
|
3506
|
+
/* istanbul ignore if */
|
3507
|
+
return ("function($event){" + code + handlerCode + "}")
|
3508
|
+
}
|
3509
|
+
}
|
3510
|
+
|
3511
|
+
function genKeyFilter (keys) {
|
3512
|
+
return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;")
|
3513
|
+
}
|
3514
|
+
|
3515
|
+
function genFilterCode (key) {
|
3516
|
+
var keyVal = parseInt(key, 10);
|
3517
|
+
if (keyVal) {
|
3518
|
+
return ("$event.keyCode!==" + keyVal)
|
3519
|
+
}
|
3520
|
+
var keyCode = keyCodes[key];
|
3521
|
+
var keyName = keyNames[key];
|
3522
|
+
return (
|
3523
|
+
"_k($event.keyCode," +
|
3524
|
+
(JSON.stringify(key)) + "," +
|
3525
|
+
(JSON.stringify(keyCode)) + "," +
|
3526
|
+
"$event.key," +
|
3527
|
+
"" + (JSON.stringify(keyName)) +
|
3528
|
+
")"
|
3529
|
+
)
|
3530
|
+
}
|
3531
|
+
|
3532
|
+
/* */
|
3533
|
+
|
3534
|
+
function on (el, dir) {
|
3535
|
+
if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
|
3536
|
+
warn("v-on without argument does not support modifiers.");
|
3537
|
+
}
|
3538
|
+
el.wrapListeners = function (code) { return ("_g(" + code + "," + (dir.value) + ")"); };
|
3539
|
+
}
|
3540
|
+
|
3541
|
+
/* */
|
3542
|
+
|
3543
|
+
function bind$1 (el, dir) {
|
3544
|
+
el.wrapData = function (code) {
|
3545
|
+
return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + "," + (dir.modifiers && dir.modifiers.prop ? 'true' : 'false') + (dir.modifiers && dir.modifiers.sync ? ',true' : '') + ")")
|
3546
|
+
};
|
3547
|
+
}
|
3548
|
+
|
3549
|
+
/* */
|
3550
|
+
|
3551
|
+
var baseDirectives = {
|
3552
|
+
on: on,
|
3553
|
+
bind: bind$1,
|
3554
|
+
cloak: noop
|
3555
|
+
}
|
3556
|
+
|
3557
|
+
/* */
|
3558
|
+
|
3559
|
+
var CodegenState = function CodegenState (options) {
|
3560
|
+
this.options = options;
|
3561
|
+
this.warn = options.warn || baseWarn;
|
3562
|
+
this.transforms = pluckModuleFunction(options.modules, 'transformCode');
|
3563
|
+
this.dataGenFns = pluckModuleFunction(options.modules, 'genData');
|
3564
|
+
this.directives = extend(extend({}, baseDirectives), options.directives);
|
3565
|
+
var isReservedTag = options.isReservedTag || no;
|
3566
|
+
this.maybeComponent = function (el) { return !isReservedTag(el.tag); };
|
3567
|
+
this.onceId = 0;
|
3568
|
+
this.staticRenderFns = [];
|
3569
|
+
};
|
3570
|
+
|
3571
|
+
|
3572
|
+
|
3573
|
+
function generate (
|
3574
|
+
ast,
|
3575
|
+
options
|
3576
|
+
) {
|
3577
|
+
var state = new CodegenState(options);
|
3578
|
+
var code = ast ? genElement(ast, state) : '_c("div")';
|
3579
|
+
return {
|
3580
|
+
render: ("with(this){return " + code + "}"),
|
3581
|
+
staticRenderFns: state.staticRenderFns
|
3582
|
+
}
|
3583
|
+
}
|
3584
|
+
|
3585
|
+
function genElement (el, state) {
|
3586
|
+
if (el.staticRoot && !el.staticProcessed) {
|
3587
|
+
return genStatic(el, state)
|
3588
|
+
} else if (el.once && !el.onceProcessed) {
|
3589
|
+
return genOnce(el, state)
|
3590
|
+
} else if (el.for && !el.forProcessed) {
|
3591
|
+
return genFor(el, state)
|
3592
|
+
} else if (el.if && !el.ifProcessed) {
|
3593
|
+
return genIf(el, state)
|
3594
|
+
} else if (el.tag === 'template' && !el.slotTarget) {
|
3595
|
+
return genChildren(el, state) || 'void 0'
|
3596
|
+
} else if (el.tag === 'slot') {
|
3597
|
+
return genSlot(el, state)
|
3598
|
+
} else {
|
3599
|
+
// component or element
|
3600
|
+
var code;
|
3601
|
+
if (el.component) {
|
3602
|
+
code = genComponent(el.component, el, state);
|
3603
|
+
} else {
|
3604
|
+
var data = el.plain ? undefined : genData$2(el, state);
|
3605
|
+
|
3606
|
+
var children = el.inlineTemplate ? null : genChildren(el, state, true);
|
3607
|
+
code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")";
|
3608
|
+
}
|
3609
|
+
// module transforms
|
3610
|
+
for (var i = 0; i < state.transforms.length; i++) {
|
3611
|
+
code = state.transforms[i](el, code);
|
3612
|
+
}
|
3613
|
+
return code
|
3614
|
+
}
|
3615
|
+
}
|
3616
|
+
|
3617
|
+
// hoist static sub-trees out
|
3618
|
+
function genStatic (el, state) {
|
3619
|
+
el.staticProcessed = true;
|
3620
|
+
state.staticRenderFns.push(("with(this){return " + (genElement(el, state)) + "}"));
|
3621
|
+
return ("_m(" + (state.staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")")
|
3622
|
+
}
|
3623
|
+
|
3624
|
+
// v-once
|
3625
|
+
function genOnce (el, state) {
|
3626
|
+
el.onceProcessed = true;
|
3627
|
+
if (el.if && !el.ifProcessed) {
|
3628
|
+
return genIf(el, state)
|
3629
|
+
} else if (el.staticInFor) {
|
3630
|
+
var key = '';
|
3631
|
+
var parent = el.parent;
|
3632
|
+
while (parent) {
|
3633
|
+
if (parent.for) {
|
3634
|
+
key = parent.key;
|
3635
|
+
break
|
3636
|
+
}
|
3637
|
+
parent = parent.parent;
|
3638
|
+
}
|
3639
|
+
if (!key) {
|
3640
|
+
process.env.NODE_ENV !== 'production' && state.warn(
|
3641
|
+
"v-once can only be used inside v-for that is keyed. "
|
3642
|
+
);
|
3643
|
+
return genElement(el, state)
|
3644
|
+
}
|
3645
|
+
return ("_o(" + (genElement(el, state)) + "," + (state.onceId++) + "," + key + ")")
|
3646
|
+
} else {
|
3647
|
+
return genStatic(el, state)
|
3648
|
+
}
|
3649
|
+
}
|
3650
|
+
|
3651
|
+
function genIf (
|
3652
|
+
el,
|
3653
|
+
state,
|
3654
|
+
altGen,
|
3655
|
+
altEmpty
|
3656
|
+
) {
|
3657
|
+
el.ifProcessed = true; // avoid recursion
|
3658
|
+
return genIfConditions(el.ifConditions.slice(), state, altGen, altEmpty)
|
3659
|
+
}
|
3660
|
+
|
3661
|
+
function genIfConditions (
|
3662
|
+
conditions,
|
3663
|
+
state,
|
3664
|
+
altGen,
|
3665
|
+
altEmpty
|
3666
|
+
) {
|
3667
|
+
if (!conditions.length) {
|
3668
|
+
return altEmpty || '_e()'
|
3669
|
+
}
|
3670
|
+
|
3671
|
+
var condition = conditions.shift();
|
3672
|
+
if (condition.exp) {
|
3673
|
+
return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions, state, altGen, altEmpty)))
|
3674
|
+
} else {
|
3675
|
+
return ("" + (genTernaryExp(condition.block)))
|
3676
|
+
}
|
3677
|
+
|
3678
|
+
// v-if with v-once should generate code like (a)?_m(0):_m(1)
|
3679
|
+
function genTernaryExp (el) {
|
3680
|
+
return altGen
|
3681
|
+
? altGen(el, state)
|
3682
|
+
: el.once
|
3683
|
+
? genOnce(el, state)
|
3684
|
+
: genElement(el, state)
|
3685
|
+
}
|
3686
|
+
}
|
3687
|
+
|
3688
|
+
function genFor (
|
3689
|
+
el,
|
3690
|
+
state,
|
3691
|
+
altGen,
|
3692
|
+
altHelper
|
3693
|
+
) {
|
3694
|
+
var exp = el.for;
|
3695
|
+
var alias = el.alias;
|
3696
|
+
var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
|
3697
|
+
var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
|
3698
|
+
|
3699
|
+
if (process.env.NODE_ENV !== 'production' &&
|
3700
|
+
state.maybeComponent(el) &&
|
3701
|
+
el.tag !== 'slot' &&
|
3702
|
+
el.tag !== 'template' &&
|
3703
|
+
!el.key
|
3704
|
+
) {
|
3705
|
+
state.warn(
|
3706
|
+
"<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " +
|
3707
|
+
"v-for should have explicit keys. " +
|
3708
|
+
"See https://vuejs.org/guide/list.html#key for more info.",
|
3709
|
+
true /* tip */
|
3710
|
+
);
|
3711
|
+
}
|
3712
|
+
|
3713
|
+
el.forProcessed = true; // avoid recursion
|
3714
|
+
return (altHelper || '_l') + "((" + exp + ")," +
|
3715
|
+
"function(" + alias + iterator1 + iterator2 + "){" +
|
3716
|
+
"return " + ((altGen || genElement)(el, state)) +
|
3717
|
+
'})'
|
3718
|
+
}
|
3719
|
+
|
3720
|
+
function genData$2 (el, state) {
|
3721
|
+
var data = '{';
|
3722
|
+
|
3723
|
+
// directives first.
|
3724
|
+
// directives may mutate the el's other properties before they are generated.
|
3725
|
+
var dirs = genDirectives(el, state);
|
3726
|
+
if (dirs) { data += dirs + ','; }
|
3727
|
+
|
3728
|
+
// key
|
3729
|
+
if (el.key) {
|
3730
|
+
data += "key:" + (el.key) + ",";
|
3731
|
+
}
|
3732
|
+
// ref
|
3733
|
+
if (el.ref) {
|
3734
|
+
data += "ref:" + (el.ref) + ",";
|
3735
|
+
}
|
3736
|
+
if (el.refInFor) {
|
3737
|
+
data += "refInFor:true,";
|
3738
|
+
}
|
3739
|
+
// pre
|
3740
|
+
if (el.pre) {
|
3741
|
+
data += "pre:true,";
|
3742
|
+
}
|
3743
|
+
// record original tag name for components using "is" attribute
|
3744
|
+
if (el.component) {
|
3745
|
+
data += "tag:\"" + (el.tag) + "\",";
|
3746
|
+
}
|
3747
|
+
// module data generation functions
|
3748
|
+
for (var i = 0; i < state.dataGenFns.length; i++) {
|
3749
|
+
data += state.dataGenFns[i](el);
|
3750
|
+
}
|
3751
|
+
// attributes
|
3752
|
+
if (el.attrs) {
|
3753
|
+
data += "attrs:{" + (genProps(el.attrs)) + "},";
|
3754
|
+
}
|
3755
|
+
// DOM props
|
3756
|
+
if (el.props) {
|
3757
|
+
data += "domProps:{" + (genProps(el.props)) + "},";
|
3758
|
+
}
|
3759
|
+
// event handlers
|
3760
|
+
if (el.events) {
|
3761
|
+
data += (genHandlers(el.events, false, state.warn)) + ",";
|
3762
|
+
}
|
3763
|
+
if (el.nativeEvents) {
|
3764
|
+
data += (genHandlers(el.nativeEvents, true, state.warn)) + ",";
|
3765
|
+
}
|
3766
|
+
// slot target
|
3767
|
+
// only for non-scoped slots
|
3768
|
+
if (el.slotTarget && !el.slotScope) {
|
3769
|
+
data += "slot:" + (el.slotTarget) + ",";
|
3770
|
+
}
|
3771
|
+
// scoped slots
|
3772
|
+
if (el.scopedSlots) {
|
3773
|
+
data += (genScopedSlots(el.scopedSlots, state)) + ",";
|
3774
|
+
}
|
3775
|
+
// component v-model
|
3776
|
+
if (el.model) {
|
3777
|
+
data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},";
|
3778
|
+
}
|
3779
|
+
// inline-template
|
3780
|
+
if (el.inlineTemplate) {
|
3781
|
+
var inlineTemplate = genInlineTemplate(el, state);
|
3782
|
+
if (inlineTemplate) {
|
3783
|
+
data += inlineTemplate + ",";
|
3784
|
+
}
|
3785
|
+
}
|
3786
|
+
data = data.replace(/,$/, '') + '}';
|
3787
|
+
// v-bind data wrap
|
3788
|
+
if (el.wrapData) {
|
3789
|
+
data = el.wrapData(data);
|
3790
|
+
}
|
3791
|
+
// v-on data wrap
|
3792
|
+
if (el.wrapListeners) {
|
3793
|
+
data = el.wrapListeners(data);
|
3794
|
+
}
|
3795
|
+
return data
|
3796
|
+
}
|
3797
|
+
|
3798
|
+
function genDirectives (el, state) {
|
3799
|
+
var dirs = el.directives;
|
3800
|
+
if (!dirs) { return }
|
3801
|
+
var res = 'directives:[';
|
3802
|
+
var hasRuntime = false;
|
3803
|
+
var i, l, dir, needRuntime;
|
3804
|
+
for (i = 0, l = dirs.length; i < l; i++) {
|
3805
|
+
dir = dirs[i];
|
3806
|
+
needRuntime = true;
|
3807
|
+
var gen = state.directives[dir.name];
|
3808
|
+
if (gen) {
|
3809
|
+
// compile-time directive that manipulates AST.
|
3810
|
+
// returns true if it also needs a runtime counterpart.
|
3811
|
+
needRuntime = !!gen(el, dir, state.warn);
|
3812
|
+
}
|
3813
|
+
if (needRuntime) {
|
3814
|
+
hasRuntime = true;
|
3815
|
+
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))) : '') + "},";
|
3816
|
+
}
|
3817
|
+
}
|
3818
|
+
if (hasRuntime) {
|
3819
|
+
return res.slice(0, -1) + ']'
|
3820
|
+
}
|
3821
|
+
}
|
3822
|
+
|
3823
|
+
function genInlineTemplate (el, state) {
|
3824
|
+
var ast = el.children[0];
|
3825
|
+
if (process.env.NODE_ENV !== 'production' && (
|
3826
|
+
el.children.length !== 1 || ast.type !== 1
|
3827
|
+
)) {
|
3828
|
+
state.warn('Inline-template components must have exactly one child element.');
|
3829
|
+
}
|
3830
|
+
if (ast.type === 1) {
|
3831
|
+
var inlineRenderFns = generate(ast, state.options);
|
3832
|
+
return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}")
|
3833
|
+
}
|
3834
|
+
}
|
3835
|
+
|
3836
|
+
function genScopedSlots (
|
3837
|
+
slots,
|
3838
|
+
state
|
3839
|
+
) {
|
3840
|
+
return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) {
|
3841
|
+
return genScopedSlot(key, slots[key], state)
|
3842
|
+
}).join(',')) + "])")
|
3843
|
+
}
|
3844
|
+
|
3845
|
+
function genScopedSlot (
|
3846
|
+
key,
|
3847
|
+
el,
|
3848
|
+
state
|
3849
|
+
) {
|
3850
|
+
if (el.for && !el.forProcessed) {
|
3851
|
+
return genForScopedSlot(key, el, state)
|
3852
|
+
}
|
3853
|
+
var fn = "function(" + (String(el.slotScope)) + "){" +
|
3854
|
+
"return " + (el.tag === 'template'
|
3855
|
+
? el.if
|
3856
|
+
? ((el.if) + "?" + (genChildren(el, state) || 'undefined') + ":undefined")
|
3857
|
+
: genChildren(el, state) || 'undefined'
|
3858
|
+
: genElement(el, state)) + "}";
|
3859
|
+
return ("{key:" + key + ",fn:" + fn + "}")
|
3860
|
+
}
|
3861
|
+
|
3862
|
+
function genForScopedSlot (
|
3863
|
+
key,
|
3864
|
+
el,
|
3865
|
+
state
|
3866
|
+
) {
|
3867
|
+
var exp = el.for;
|
3868
|
+
var alias = el.alias;
|
3869
|
+
var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : '';
|
3870
|
+
var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : '';
|
3871
|
+
el.forProcessed = true; // avoid recursion
|
3872
|
+
return "_l((" + exp + ")," +
|
3873
|
+
"function(" + alias + iterator1 + iterator2 + "){" +
|
3874
|
+
"return " + (genScopedSlot(key, el, state)) +
|
3875
|
+
'})'
|
3876
|
+
}
|
3877
|
+
|
3878
|
+
function genChildren (
|
3879
|
+
el,
|
3880
|
+
state,
|
3881
|
+
checkSkip,
|
3882
|
+
altGenElement,
|
3883
|
+
altGenNode
|
3884
|
+
) {
|
3885
|
+
var children = el.children;
|
3886
|
+
if (children.length) {
|
3887
|
+
var el$1 = children[0];
|
3888
|
+
// optimize single v-for
|
3889
|
+
if (children.length === 1 &&
|
3890
|
+
el$1.for &&
|
3891
|
+
el$1.tag !== 'template' &&
|
3892
|
+
el$1.tag !== 'slot'
|
3893
|
+
) {
|
3894
|
+
return (altGenElement || genElement)(el$1, state)
|
3895
|
+
}
|
3896
|
+
var normalizationType = checkSkip
|
3897
|
+
? getNormalizationType(children, state.maybeComponent)
|
3898
|
+
: 0;
|
3899
|
+
var gen = altGenNode || genNode;
|
3900
|
+
return ("[" + (children.map(function (c) { return gen(c, state); }).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : ''))
|
3901
|
+
}
|
3902
|
+
}
|
3903
|
+
|
3904
|
+
// determine the normalization needed for the children array.
|
3905
|
+
// 0: no normalization needed
|
3906
|
+
// 1: simple normalization needed (possible 1-level deep nested array)
|
3907
|
+
// 2: full normalization needed
|
3908
|
+
function getNormalizationType (
|
3909
|
+
children,
|
3910
|
+
maybeComponent
|
3911
|
+
) {
|
3912
|
+
var res = 0;
|
3913
|
+
for (var i = 0; i < children.length; i++) {
|
3914
|
+
var el = children[i];
|
3915
|
+
if (el.type !== 1) {
|
3916
|
+
continue
|
3917
|
+
}
|
3918
|
+
if (needsNormalization(el) ||
|
3919
|
+
(el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) {
|
3920
|
+
res = 2;
|
3921
|
+
break
|
3922
|
+
}
|
3923
|
+
if (maybeComponent(el) ||
|
3924
|
+
(el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) {
|
3925
|
+
res = 1;
|
3926
|
+
}
|
3927
|
+
}
|
3928
|
+
return res
|
3929
|
+
}
|
3930
|
+
|
3931
|
+
function needsNormalization (el) {
|
3932
|
+
return el.for !== undefined || el.tag === 'template' || el.tag === 'slot'
|
3933
|
+
}
|
3934
|
+
|
3935
|
+
function genNode (node, state) {
|
3936
|
+
if (node.type === 1) {
|
3937
|
+
return genElement(node, state)
|
3938
|
+
} if (node.type === 3 && node.isComment) {
|
3939
|
+
return genComment(node)
|
3940
|
+
} else {
|
3941
|
+
return genText(node)
|
3942
|
+
}
|
3943
|
+
}
|
3944
|
+
|
3945
|
+
function genText (text) {
|
3946
|
+
return ("_v(" + (text.type === 2
|
3947
|
+
? text.expression // no need for () because already wrapped in _s()
|
3948
|
+
: transformSpecialNewlines(JSON.stringify(text.text))) + ")")
|
3949
|
+
}
|
3950
|
+
|
3951
|
+
function genComment (comment) {
|
3952
|
+
return ("_e(" + (JSON.stringify(comment.text)) + ")")
|
3953
|
+
}
|
3954
|
+
|
3955
|
+
function genSlot (el, state) {
|
3956
|
+
var slotName = el.slotName || '"default"';
|
3957
|
+
var children = genChildren(el, state);
|
3958
|
+
var res = "_t(" + slotName + (children ? ("," + children) : '');
|
3959
|
+
var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}");
|
3960
|
+
var bind$$1 = el.attrsMap['v-bind'];
|
3961
|
+
if ((attrs || bind$$1) && !children) {
|
3962
|
+
res += ",null";
|
3963
|
+
}
|
3964
|
+
if (attrs) {
|
3965
|
+
res += "," + attrs;
|
3966
|
+
}
|
3967
|
+
if (bind$$1) {
|
3968
|
+
res += (attrs ? '' : ',null') + "," + bind$$1;
|
3969
|
+
}
|
3970
|
+
return res + ')'
|
3971
|
+
}
|
3972
|
+
|
3973
|
+
// componentName is el.component, take it as argument to shun flow's pessimistic refinement
|
3974
|
+
function genComponent (
|
3975
|
+
componentName,
|
3976
|
+
el,
|
3977
|
+
state
|
3978
|
+
) {
|
3979
|
+
var children = el.inlineTemplate ? null : genChildren(el, state, true);
|
3980
|
+
return ("_c(" + componentName + "," + (genData$2(el, state)) + (children ? ("," + children) : '') + ")")
|
3981
|
+
}
|
3982
|
+
|
3983
|
+
function genProps (props) {
|
3984
|
+
var res = '';
|
3985
|
+
for (var i = 0; i < props.length; i++) {
|
3986
|
+
var prop = props[i];
|
3987
|
+
/* istanbul ignore if */
|
3988
|
+
{
|
3989
|
+
res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ",";
|
3990
|
+
}
|
3991
|
+
}
|
3992
|
+
return res.slice(0, -1)
|
3993
|
+
}
|
3994
|
+
|
3995
|
+
// #3895, #4268
|
3996
|
+
function transformSpecialNewlines (text) {
|
3997
|
+
return text
|
3998
|
+
.replace(/\u2028/g, '\\u2028')
|
3999
|
+
.replace(/\u2029/g, '\\u2029')
|
4000
|
+
}
|
4001
|
+
|
4002
|
+
/* */
|
4003
|
+
|
4004
|
+
// these keywords should not appear inside expressions, but operators like
|
4005
|
+
// typeof, instanceof and in are allowed
|
4006
|
+
var prohibitedKeywordRE = new RegExp('\\b' + (
|
4007
|
+
'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
|
4008
|
+
'super,throw,while,yield,delete,export,import,return,switch,default,' +
|
4009
|
+
'extends,finally,continue,debugger,function,arguments'
|
4010
|
+
).split(',').join('\\b|\\b') + '\\b');
|
4011
|
+
|
4012
|
+
// these unary operators should not be used as property/method names
|
4013
|
+
var unaryOperatorsRE = new RegExp('\\b' + (
|
4014
|
+
'delete,typeof,void'
|
4015
|
+
).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
|
4016
|
+
|
4017
|
+
// strip strings in expressions
|
4018
|
+
var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
|
4019
|
+
|
4020
|
+
// detect problematic expressions in a template
|
4021
|
+
function detectErrors (ast) {
|
4022
|
+
var errors = [];
|
4023
|
+
if (ast) {
|
4024
|
+
checkNode(ast, errors);
|
4025
|
+
}
|
4026
|
+
return errors
|
4027
|
+
}
|
4028
|
+
|
4029
|
+
function checkNode (node, errors) {
|
4030
|
+
if (node.type === 1) {
|
4031
|
+
for (var name in node.attrsMap) {
|
4032
|
+
if (dirRE.test(name)) {
|
4033
|
+
var value = node.attrsMap[name];
|
4034
|
+
if (value) {
|
4035
|
+
if (name === 'v-for') {
|
4036
|
+
checkFor(node, ("v-for=\"" + value + "\""), errors);
|
4037
|
+
} else if (onRE.test(name)) {
|
4038
|
+
checkEvent(value, (name + "=\"" + value + "\""), errors);
|
4039
|
+
} else {
|
4040
|
+
checkExpression(value, (name + "=\"" + value + "\""), errors);
|
4041
|
+
}
|
4042
|
+
}
|
4043
|
+
}
|
4044
|
+
}
|
4045
|
+
if (node.children) {
|
4046
|
+
for (var i = 0; i < node.children.length; i++) {
|
4047
|
+
checkNode(node.children[i], errors);
|
4048
|
+
}
|
4049
|
+
}
|
4050
|
+
} else if (node.type === 2) {
|
4051
|
+
checkExpression(node.expression, node.text, errors);
|
4052
|
+
}
|
4053
|
+
}
|
4054
|
+
|
4055
|
+
function checkEvent (exp, text, errors) {
|
4056
|
+
var stipped = exp.replace(stripStringRE, '');
|
4057
|
+
var keywordMatch = stipped.match(unaryOperatorsRE);
|
4058
|
+
if (keywordMatch && stipped.charAt(keywordMatch.index - 1) !== '$') {
|
4059
|
+
errors.push(
|
4060
|
+
"avoid using JavaScript unary operator as property name: " +
|
4061
|
+
"\"" + (keywordMatch[0]) + "\" in expression " + (text.trim())
|
4062
|
+
);
|
4063
|
+
}
|
4064
|
+
checkExpression(exp, text, errors);
|
4065
|
+
}
|
4066
|
+
|
4067
|
+
function checkFor (node, text, errors) {
|
4068
|
+
checkExpression(node.for || '', text, errors);
|
4069
|
+
checkIdentifier(node.alias, 'v-for alias', text, errors);
|
4070
|
+
checkIdentifier(node.iterator1, 'v-for iterator', text, errors);
|
4071
|
+
checkIdentifier(node.iterator2, 'v-for iterator', text, errors);
|
4072
|
+
}
|
4073
|
+
|
4074
|
+
function checkIdentifier (
|
4075
|
+
ident,
|
4076
|
+
type,
|
4077
|
+
text,
|
4078
|
+
errors
|
4079
|
+
) {
|
4080
|
+
if (typeof ident === 'string') {
|
4081
|
+
try {
|
4082
|
+
new Function(("var " + ident + "=_"));
|
4083
|
+
} catch (e) {
|
4084
|
+
errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim())));
|
4085
|
+
}
|
4086
|
+
}
|
4087
|
+
}
|
4088
|
+
|
4089
|
+
function checkExpression (exp, text, errors) {
|
4090
|
+
try {
|
4091
|
+
new Function(("return " + exp));
|
4092
|
+
} catch (e) {
|
4093
|
+
var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE);
|
4094
|
+
if (keywordMatch) {
|
4095
|
+
errors.push(
|
4096
|
+
"avoid using JavaScript keyword as property name: " +
|
4097
|
+
"\"" + (keywordMatch[0]) + "\"\n Raw expression: " + (text.trim())
|
4098
|
+
);
|
4099
|
+
} else {
|
4100
|
+
errors.push(
|
4101
|
+
"invalid expression: " + (e.message) + " in\n\n" +
|
4102
|
+
" " + exp + "\n\n" +
|
4103
|
+
" Raw expression: " + (text.trim()) + "\n"
|
4104
|
+
);
|
4105
|
+
}
|
4106
|
+
}
|
4107
|
+
}
|
4108
|
+
|
4109
|
+
/* */
|
4110
|
+
|
4111
|
+
function createFunction (code, errors) {
|
4112
|
+
try {
|
4113
|
+
return new Function(code)
|
4114
|
+
} catch (err) {
|
4115
|
+
errors.push({ err: err, code: code });
|
4116
|
+
return noop
|
4117
|
+
}
|
4118
|
+
}
|
4119
|
+
|
4120
|
+
function createCompileToFunctionFn (compile) {
|
4121
|
+
var cache = Object.create(null);
|
4122
|
+
|
4123
|
+
return function compileToFunctions (
|
4124
|
+
template,
|
4125
|
+
options,
|
4126
|
+
vm
|
4127
|
+
) {
|
4128
|
+
options = extend({}, options);
|
4129
|
+
var warn$$1 = options.warn || warn;
|
4130
|
+
delete options.warn;
|
4131
|
+
|
4132
|
+
/* istanbul ignore if */
|
4133
|
+
if (process.env.NODE_ENV !== 'production') {
|
4134
|
+
// detect possible CSP restriction
|
4135
|
+
try {
|
4136
|
+
new Function('return 1');
|
4137
|
+
} catch (e) {
|
4138
|
+
if (e.toString().match(/unsafe-eval|CSP/)) {
|
4139
|
+
warn$$1(
|
4140
|
+
'It seems you are using the standalone build of Vue.js in an ' +
|
4141
|
+
'environment with Content Security Policy that prohibits unsafe-eval. ' +
|
4142
|
+
'The template compiler cannot work in this environment. Consider ' +
|
4143
|
+
'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
|
4144
|
+
'templates into render functions.'
|
4145
|
+
);
|
4146
|
+
}
|
4147
|
+
}
|
4148
|
+
}
|
4149
|
+
|
4150
|
+
// check cache
|
4151
|
+
var key = options.delimiters
|
4152
|
+
? String(options.delimiters) + template
|
4153
|
+
: template;
|
4154
|
+
if (cache[key]) {
|
4155
|
+
return cache[key]
|
4156
|
+
}
|
4157
|
+
|
4158
|
+
// compile
|
4159
|
+
var compiled = compile(template, options);
|
4160
|
+
|
4161
|
+
// check compilation errors/tips
|
4162
|
+
if (process.env.NODE_ENV !== 'production') {
|
4163
|
+
if (compiled.errors && compiled.errors.length) {
|
4164
|
+
warn$$1(
|
4165
|
+
"Error compiling template:\n\n" + template + "\n\n" +
|
4166
|
+
compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n',
|
4167
|
+
vm
|
4168
|
+
);
|
4169
|
+
}
|
4170
|
+
if (compiled.tips && compiled.tips.length) {
|
4171
|
+
compiled.tips.forEach(function (msg) { return tip(msg, vm); });
|
4172
|
+
}
|
4173
|
+
}
|
4174
|
+
|
4175
|
+
// turn code into functions
|
4176
|
+
var res = {};
|
4177
|
+
var fnGenErrors = [];
|
4178
|
+
res.render = createFunction(compiled.render, fnGenErrors);
|
4179
|
+
res.staticRenderFns = compiled.staticRenderFns.map(function (code) {
|
4180
|
+
return createFunction(code, fnGenErrors)
|
4181
|
+
});
|
4182
|
+
|
4183
|
+
// check function generation errors.
|
4184
|
+
// this should only happen if there is a bug in the compiler itself.
|
4185
|
+
// mostly for codegen development use
|
4186
|
+
/* istanbul ignore if */
|
4187
|
+
if (process.env.NODE_ENV !== 'production') {
|
4188
|
+
if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) {
|
4189
|
+
warn$$1(
|
4190
|
+
"Failed to generate render function:\n\n" +
|
4191
|
+
fnGenErrors.map(function (ref) {
|
4192
|
+
var err = ref.err;
|
4193
|
+
var code = ref.code;
|
4194
|
+
|
4195
|
+
return ((err.toString()) + " in\n\n" + code + "\n");
|
4196
|
+
}).join('\n'),
|
4197
|
+
vm
|
4198
|
+
);
|
4199
|
+
}
|
4200
|
+
}
|
4201
|
+
|
4202
|
+
return (cache[key] = res)
|
4203
|
+
}
|
4204
|
+
}
|
4205
|
+
|
4206
|
+
/* */
|
4207
|
+
|
4208
|
+
function createCompilerCreator (baseCompile) {
|
4209
|
+
return function createCompiler (baseOptions) {
|
4210
|
+
function compile (
|
4211
|
+
template,
|
4212
|
+
options
|
4213
|
+
) {
|
4214
|
+
var finalOptions = Object.create(baseOptions);
|
4215
|
+
var errors = [];
|
4216
|
+
var tips = [];
|
4217
|
+
finalOptions.warn = function (msg, tip) {
|
4218
|
+
(tip ? tips : errors).push(msg);
|
4219
|
+
};
|
4220
|
+
|
4221
|
+
if (options) {
|
4222
|
+
// merge custom modules
|
4223
|
+
if (options.modules) {
|
4224
|
+
finalOptions.modules =
|
4225
|
+
(baseOptions.modules || []).concat(options.modules);
|
4226
|
+
}
|
4227
|
+
// merge custom directives
|
4228
|
+
if (options.directives) {
|
4229
|
+
finalOptions.directives = extend(
|
4230
|
+
Object.create(baseOptions.directives || null),
|
4231
|
+
options.directives
|
4232
|
+
);
|
4233
|
+
}
|
4234
|
+
// copy other options
|
4235
|
+
for (var key in options) {
|
4236
|
+
if (key !== 'modules' && key !== 'directives') {
|
4237
|
+
finalOptions[key] = options[key];
|
4238
|
+
}
|
4239
|
+
}
|
4240
|
+
}
|
4241
|
+
|
4242
|
+
var compiled = baseCompile(template, finalOptions);
|
4243
|
+
if (process.env.NODE_ENV !== 'production') {
|
4244
|
+
errors.push.apply(errors, detectErrors(compiled.ast));
|
4245
|
+
}
|
4246
|
+
compiled.errors = errors;
|
4247
|
+
compiled.tips = tips;
|
4248
|
+
return compiled
|
4249
|
+
}
|
4250
|
+
|
4251
|
+
return {
|
4252
|
+
compile: compile,
|
4253
|
+
compileToFunctions: createCompileToFunctionFn(compile)
|
4254
|
+
}
|
4255
|
+
}
|
4256
|
+
}
|
4257
|
+
|
4258
|
+
/* */
|
4259
|
+
|
4260
|
+
// `createCompilerCreator` allows creating compilers that use alternative
|
4261
|
+
// parser/optimizer/codegen, e.g the SSR optimizing compiler.
|
4262
|
+
// Here we just export a default compiler using the default parts.
|
4263
|
+
var createCompiler = createCompilerCreator(function baseCompile (
|
4264
|
+
template,
|
4265
|
+
options
|
4266
|
+
) {
|
4267
|
+
var ast = parse(template.trim(), options);
|
4268
|
+
if (options.optimize !== false) {
|
4269
|
+
optimize(ast, options);
|
4270
|
+
}
|
4271
|
+
var code = generate(ast, options);
|
4272
|
+
return {
|
4273
|
+
ast: ast,
|
4274
|
+
render: code.render,
|
4275
|
+
staticRenderFns: code.staticRenderFns
|
4276
|
+
}
|
4277
|
+
});
|
4278
|
+
|
4279
|
+
/* */
|
4280
|
+
|
4281
|
+
var ref = createCompiler(baseOptions);
|
4282
|
+
var compile = ref.compile;
|
4283
|
+
var compileToFunctions = ref.compileToFunctions;
|
4284
|
+
|
4285
|
+
/* */
|
4286
|
+
|
4287
|
+
var isAttr = makeMap(
|
4288
|
+
'accept,accept-charset,accesskey,action,align,alt,async,autocomplete,' +
|
4289
|
+
'autofocus,autoplay,autosave,bgcolor,border,buffered,challenge,charset,' +
|
4290
|
+
'checked,cite,class,code,codebase,color,cols,colspan,content,http-equiv,' +
|
4291
|
+
'name,contenteditable,contextmenu,controls,coords,data,datetime,default,' +
|
4292
|
+
'defer,dir,dirname,disabled,download,draggable,dropzone,enctype,method,for,' +
|
4293
|
+
'form,formaction,headers,height,hidden,high,href,hreflang,http-equiv,' +
|
4294
|
+
'icon,id,ismap,itemprop,keytype,kind,label,lang,language,list,loop,low,' +
|
4295
|
+
'manifest,max,maxlength,media,method,GET,POST,min,multiple,email,file,' +
|
4296
|
+
'muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,' +
|
4297
|
+
'preload,radiogroup,readonly,rel,required,reversed,rows,rowspan,sandbox,' +
|
4298
|
+
'scope,scoped,seamless,selected,shape,size,type,text,password,sizes,span,' +
|
4299
|
+
'spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,' +
|
4300
|
+
'target,title,type,usemap,value,width,wrap'
|
4301
|
+
);
|
4302
|
+
|
4303
|
+
/* istanbul ignore next */
|
4304
|
+
var isRenderableAttr = function (name) {
|
4305
|
+
return (
|
4306
|
+
isAttr(name) ||
|
4307
|
+
name.indexOf('data-') === 0 ||
|
4308
|
+
name.indexOf('aria-') === 0
|
4309
|
+
)
|
4310
|
+
};
|
4311
|
+
var propsToAttrMap = {
|
4312
|
+
acceptCharset: 'accept-charset',
|
4313
|
+
className: 'class',
|
4314
|
+
htmlFor: 'for',
|
4315
|
+
httpEquiv: 'http-equiv'
|
4316
|
+
};
|
4317
|
+
|
4318
|
+
var ESC = {
|
4319
|
+
'<': '<',
|
4320
|
+
'>': '>',
|
4321
|
+
'"': '"',
|
4322
|
+
'&': '&'
|
4323
|
+
};
|
4324
|
+
|
4325
|
+
function escape (s) {
|
4326
|
+
return s.replace(/[<>"&]/g, escapeChar)
|
4327
|
+
}
|
4328
|
+
|
4329
|
+
function escapeChar (a) {
|
4330
|
+
return ESC[a] || a
|
4331
|
+
}
|
4332
|
+
|
4333
|
+
/* */
|
4334
|
+
|
4335
|
+
var plainStringRE = /^"(?:[^"\\]|\\.)*"$|^'(?:[^'\\]|\\.)*'$/;
|
4336
|
+
|
4337
|
+
// let the model AST transform translate v-model into appropriate
|
4338
|
+
// props bindings
|
4339
|
+
function applyModelTransform (el, state) {
|
4340
|
+
if (el.directives) {
|
4341
|
+
for (var i = 0; i < el.directives.length; i++) {
|
4342
|
+
var dir = el.directives[i];
|
4343
|
+
if (dir.name === 'model') {
|
4344
|
+
state.directives.model(el, dir, state.warn);
|
4345
|
+
// remove value for textarea as its converted to text
|
4346
|
+
if (el.tag === 'textarea' && el.props) {
|
4347
|
+
el.props = el.props.filter(function (p) { return p.name !== 'value'; });
|
4348
|
+
}
|
4349
|
+
break
|
4350
|
+
}
|
4351
|
+
}
|
4352
|
+
}
|
4353
|
+
}
|
4354
|
+
|
4355
|
+
function genAttrSegments (
|
4356
|
+
attrs
|
4357
|
+
) {
|
4358
|
+
return attrs.map(function (ref) {
|
4359
|
+
var name = ref.name;
|
4360
|
+
var value = ref.value;
|
4361
|
+
|
4362
|
+
return genAttrSegment(name, value);
|
4363
|
+
})
|
4364
|
+
}
|
4365
|
+
|
4366
|
+
function genDOMPropSegments (
|
4367
|
+
props,
|
4368
|
+
attrs
|
4369
|
+
) {
|
4370
|
+
var segments = [];
|
4371
|
+
props.forEach(function (ref) {
|
4372
|
+
var name = ref.name;
|
4373
|
+
var value = ref.value;
|
4374
|
+
|
4375
|
+
name = propsToAttrMap[name] || name.toLowerCase();
|
4376
|
+
if (isRenderableAttr(name) &&
|
4377
|
+
!(attrs && attrs.some(function (a) { return a.name === name; }))
|
4378
|
+
) {
|
4379
|
+
segments.push(genAttrSegment(name, value));
|
4380
|
+
}
|
4381
|
+
});
|
4382
|
+
return segments
|
4383
|
+
}
|
4384
|
+
|
4385
|
+
function genAttrSegment (name, value) {
|
4386
|
+
if (plainStringRE.test(value)) {
|
4387
|
+
// force double quote
|
4388
|
+
value = value.replace(/^'|'$/g, '"');
|
4389
|
+
// force enumerated attr to "true"
|
4390
|
+
if (isEnumeratedAttr(name) && value !== "\"false\"") {
|
4391
|
+
value = "\"true\"";
|
4392
|
+
}
|
4393
|
+
return {
|
4394
|
+
type: RAW,
|
4395
|
+
value: isBooleanAttr(name)
|
4396
|
+
? (" " + name + "=\"" + name + "\"")
|
4397
|
+
: value === '""'
|
4398
|
+
? (" " + name)
|
4399
|
+
: (" " + name + "=\"" + (JSON.parse(value)) + "\"")
|
4400
|
+
}
|
4401
|
+
} else {
|
4402
|
+
return {
|
4403
|
+
type: EXPRESSION,
|
4404
|
+
value: ("_ssrAttr(" + (JSON.stringify(name)) + "," + value + ")")
|
4405
|
+
}
|
4406
|
+
}
|
4407
|
+
}
|
4408
|
+
|
4409
|
+
function genClassSegments (
|
4410
|
+
staticClass,
|
4411
|
+
classBinding
|
4412
|
+
) {
|
4413
|
+
if (staticClass && !classBinding) {
|
4414
|
+
return [{ type: RAW, value: (" class=" + staticClass) }]
|
4415
|
+
} else {
|
4416
|
+
return [{
|
4417
|
+
type: EXPRESSION,
|
4418
|
+
value: ("_ssrClass(" + (staticClass || 'null') + "," + (classBinding || 'null') + ")")
|
4419
|
+
}]
|
4420
|
+
}
|
4421
|
+
}
|
4422
|
+
|
4423
|
+
function genStyleSegments (
|
4424
|
+
staticStyle,
|
4425
|
+
parsedStaticStyle,
|
4426
|
+
styleBinding,
|
4427
|
+
vShowExpression
|
4428
|
+
) {
|
4429
|
+
if (staticStyle && !styleBinding && !vShowExpression) {
|
4430
|
+
return [{ type: RAW, value: (" style=" + (JSON.stringify(staticStyle))) }]
|
4431
|
+
} else {
|
4432
|
+
return [{
|
4433
|
+
type: EXPRESSION,
|
4434
|
+
value: ("_ssrStyle(" + (parsedStaticStyle || 'null') + "," + (styleBinding || 'null') + ", " + (vShowExpression
|
4435
|
+
? ("{ display: (" + vShowExpression + ") ? '' : 'none' }")
|
4436
|
+
: 'null') + ")")
|
4437
|
+
}]
|
4438
|
+
}
|
4439
|
+
}
|
4440
|
+
|
4441
|
+
/* */
|
4442
|
+
|
4443
|
+
/**
|
4444
|
+
* In SSR, the vdom tree is generated only once and never patched, so
|
4445
|
+
* we can optimize most element / trees into plain string render functions.
|
4446
|
+
* The SSR optimizer walks the AST tree to detect optimizable elements and trees.
|
4447
|
+
*
|
4448
|
+
* The criteria for SSR optimizability is quite a bit looser than static tree
|
4449
|
+
* detection (which is designed for client re-render). In SSR we bail only for
|
4450
|
+
* components/slots/custom directives.
|
4451
|
+
*/
|
4452
|
+
|
4453
|
+
// optimizability constants
|
4454
|
+
var optimizability = {
|
4455
|
+
FALSE: 0, // whole sub tree un-optimizable
|
4456
|
+
FULL: 1, // whole sub tree optimizable
|
4457
|
+
SELF: 2, // self optimizable but has some un-optimizable children
|
4458
|
+
CHILDREN: 3, // self un-optimizable but have fully optimizable children
|
4459
|
+
PARTIAL: 4 // self un-optimizable with some un-optimizable children
|
4460
|
+
};
|
4461
|
+
|
4462
|
+
var isPlatformReservedTag$1;
|
4463
|
+
|
4464
|
+
function optimize$1 (root, options) {
|
4465
|
+
if (!root) { return }
|
4466
|
+
isPlatformReservedTag$1 = options.isReservedTag || no;
|
4467
|
+
walk(root, true);
|
4468
|
+
}
|
4469
|
+
|
4470
|
+
function walk (node, isRoot) {
|
4471
|
+
if (isUnOptimizableTree(node)) {
|
4472
|
+
node.ssrOptimizability = optimizability.FALSE;
|
4473
|
+
return
|
4474
|
+
}
|
4475
|
+
// root node or nodes with custom directives should always be a VNode
|
4476
|
+
var selfUnoptimizable = isRoot || hasCustomDirective(node);
|
4477
|
+
var check = function (child) {
|
4478
|
+
if (child.ssrOptimizability !== optimizability.FULL) {
|
4479
|
+
node.ssrOptimizability = selfUnoptimizable
|
4480
|
+
? optimizability.PARTIAL
|
4481
|
+
: optimizability.SELF;
|
4482
|
+
}
|
4483
|
+
};
|
4484
|
+
if (selfUnoptimizable) {
|
4485
|
+
node.ssrOptimizability = optimizability.CHILDREN;
|
4486
|
+
}
|
4487
|
+
if (node.type === 1) {
|
4488
|
+
for (var i = 0, l = node.children.length; i < l; i++) {
|
4489
|
+
var child = node.children[i];
|
4490
|
+
walk(child);
|
4491
|
+
check(child);
|
4492
|
+
}
|
4493
|
+
if (node.ifConditions) {
|
4494
|
+
for (var i$1 = 1, l$1 = node.ifConditions.length; i$1 < l$1; i$1++) {
|
4495
|
+
var block = node.ifConditions[i$1].block;
|
4496
|
+
walk(block, isRoot);
|
4497
|
+
check(block);
|
4498
|
+
}
|
4499
|
+
}
|
4500
|
+
if (node.ssrOptimizability == null ||
|
4501
|
+
(!isRoot && (node.attrsMap['v-html'] || node.attrsMap['v-text']))
|
4502
|
+
) {
|
4503
|
+
node.ssrOptimizability = optimizability.FULL;
|
4504
|
+
} else {
|
4505
|
+
node.children = optimizeSiblings(node);
|
4506
|
+
}
|
4507
|
+
} else {
|
4508
|
+
node.ssrOptimizability = optimizability.FULL;
|
4509
|
+
}
|
4510
|
+
}
|
4511
|
+
|
4512
|
+
function optimizeSiblings (el) {
|
4513
|
+
var children = el.children;
|
4514
|
+
var optimizedChildren = [];
|
4515
|
+
|
4516
|
+
var currentOptimizableGroup = [];
|
4517
|
+
var pushGroup = function () {
|
4518
|
+
if (currentOptimizableGroup.length) {
|
4519
|
+
optimizedChildren.push({
|
4520
|
+
type: 1,
|
4521
|
+
parent: el,
|
4522
|
+
tag: 'template',
|
4523
|
+
attrsList: [],
|
4524
|
+
attrsMap: {},
|
4525
|
+
children: currentOptimizableGroup,
|
4526
|
+
ssrOptimizability: optimizability.FULL
|
4527
|
+
});
|
4528
|
+
}
|
4529
|
+
currentOptimizableGroup = [];
|
4530
|
+
};
|
4531
|
+
|
4532
|
+
for (var i = 0; i < children.length; i++) {
|
4533
|
+
var c = children[i];
|
4534
|
+
if (c.ssrOptimizability === optimizability.FULL) {
|
4535
|
+
currentOptimizableGroup.push(c);
|
4536
|
+
} else {
|
4537
|
+
// wrap fully-optimizable adjacent siblings inside a template tag
|
4538
|
+
// so that they can be optimized into a single ssrNode by codegen
|
4539
|
+
pushGroup();
|
4540
|
+
optimizedChildren.push(c);
|
4541
|
+
}
|
4542
|
+
}
|
4543
|
+
pushGroup();
|
4544
|
+
return optimizedChildren
|
4545
|
+
}
|
4546
|
+
|
4547
|
+
function isUnOptimizableTree (node) {
|
4548
|
+
if (node.type === 2 || node.type === 3) { // text or expression
|
4549
|
+
return false
|
4550
|
+
}
|
4551
|
+
return (
|
4552
|
+
isBuiltInTag(node.tag) || // built-in (slot, component)
|
4553
|
+
!isPlatformReservedTag$1(node.tag) || // custom component
|
4554
|
+
!!node.component || // "is" component
|
4555
|
+
isSelectWithModel(node) // <select v-model> requires runtime inspection
|
4556
|
+
)
|
4557
|
+
}
|
4558
|
+
|
4559
|
+
var isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once');
|
4560
|
+
|
4561
|
+
function hasCustomDirective (node) {
|
4562
|
+
return (
|
4563
|
+
node.type === 1 &&
|
4564
|
+
node.directives &&
|
4565
|
+
node.directives.some(function (d) { return !isBuiltInDir(d.name); })
|
4566
|
+
)
|
4567
|
+
}
|
4568
|
+
|
4569
|
+
// <select v-model> cannot be optimized because it requires a runtime check
|
4570
|
+
// to determine proper selected option
|
4571
|
+
function isSelectWithModel (node) {
|
4572
|
+
return (
|
4573
|
+
node.type === 1 &&
|
4574
|
+
node.tag === 'select' &&
|
4575
|
+
node.directives != null &&
|
4576
|
+
node.directives.some(function (d) { return d.name === 'model'; })
|
4577
|
+
)
|
4578
|
+
}
|
4579
|
+
|
4580
|
+
/* */
|
4581
|
+
|
4582
|
+
// The SSR codegen is essentially extending the default codegen to handle
|
4583
|
+
// SSR-optimizable nodes and turn them into string render fns. In cases where
|
4584
|
+
// a node is not optimizable it simply falls back to the default codegen.
|
4585
|
+
|
4586
|
+
// segment types
|
4587
|
+
var RAW = 0;
|
4588
|
+
var INTERPOLATION = 1;
|
4589
|
+
var EXPRESSION = 2;
|
4590
|
+
|
4591
|
+
function generate$1 (
|
4592
|
+
ast,
|
4593
|
+
options
|
4594
|
+
) {
|
4595
|
+
var state = new CodegenState(options);
|
4596
|
+
var code = ast ? genSSRElement(ast, state) : '_c("div")';
|
4597
|
+
return {
|
4598
|
+
render: ("with(this){return " + code + "}"),
|
4599
|
+
staticRenderFns: state.staticRenderFns
|
4600
|
+
}
|
4601
|
+
}
|
4602
|
+
|
4603
|
+
function genSSRElement (el, state) {
|
4604
|
+
if (el.for && !el.forProcessed) {
|
4605
|
+
return genFor(el, state, genSSRElement)
|
4606
|
+
} else if (el.if && !el.ifProcessed) {
|
4607
|
+
return genIf(el, state, genSSRElement)
|
4608
|
+
} else if (el.tag === 'template' && !el.slotTarget) {
|
4609
|
+
return el.ssrOptimizability === optimizability.FULL
|
4610
|
+
? genChildrenAsStringNode(el, state)
|
4611
|
+
: genSSRChildren(el, state) || 'void 0'
|
4612
|
+
}
|
4613
|
+
|
4614
|
+
switch (el.ssrOptimizability) {
|
4615
|
+
case optimizability.FULL:
|
4616
|
+
// stringify whole tree
|
4617
|
+
return genStringElement(el, state)
|
4618
|
+
case optimizability.SELF:
|
4619
|
+
// stringify self and check children
|
4620
|
+
return genStringElementWithChildren(el, state)
|
4621
|
+
case optimizability.CHILDREN:
|
4622
|
+
// generate self as VNode and stringify children
|
4623
|
+
return genNormalElement(el, state, true)
|
4624
|
+
case optimizability.PARTIAL:
|
4625
|
+
// generate self as VNode and check children
|
4626
|
+
return genNormalElement(el, state, false)
|
4627
|
+
default:
|
4628
|
+
// bail whole tree
|
4629
|
+
return genElement(el, state)
|
4630
|
+
}
|
4631
|
+
}
|
4632
|
+
|
4633
|
+
function genNormalElement (el, state, stringifyChildren) {
|
4634
|
+
var data = el.plain ? undefined : genData$2(el, state);
|
4635
|
+
var children = stringifyChildren
|
4636
|
+
? ("[" + (genChildrenAsStringNode(el, state)) + "]")
|
4637
|
+
: genSSRChildren(el, state, true);
|
4638
|
+
return ("_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")")
|
4639
|
+
}
|
4640
|
+
|
4641
|
+
function genSSRChildren (el, state, checkSkip) {
|
4642
|
+
return genChildren(el, state, checkSkip, genSSRElement, genSSRNode)
|
4643
|
+
}
|
4644
|
+
|
4645
|
+
function genSSRNode (el, state) {
|
4646
|
+
return el.type === 1
|
4647
|
+
? genSSRElement(el, state)
|
4648
|
+
: genText(el)
|
4649
|
+
}
|
4650
|
+
|
4651
|
+
function genChildrenAsStringNode (el, state) {
|
4652
|
+
return el.children.length
|
4653
|
+
? ("_ssrNode(" + (flattenSegments(childrenToSegments(el, state))) + ")")
|
4654
|
+
: ''
|
4655
|
+
}
|
4656
|
+
|
4657
|
+
function genStringElement (el, state) {
|
4658
|
+
return ("_ssrNode(" + (elementToString(el, state)) + ")")
|
4659
|
+
}
|
4660
|
+
|
4661
|
+
function genStringElementWithChildren (el, state) {
|
4662
|
+
var children = genSSRChildren(el, state, true);
|
4663
|
+
return ("_ssrNode(" + (flattenSegments(elementToOpenTagSegments(el, state))) + ",\"</" + (el.tag) + ">\"" + (children ? ("," + children) : '') + ")")
|
4664
|
+
}
|
4665
|
+
|
4666
|
+
function elementToString (el, state) {
|
4667
|
+
return ("(" + (flattenSegments(elementToSegments(el, state))) + ")")
|
4668
|
+
}
|
4669
|
+
|
4670
|
+
function elementToSegments (el, state) {
|
4671
|
+
// v-for / v-if
|
4672
|
+
if (el.for && !el.forProcessed) {
|
4673
|
+
el.forProcessed = true;
|
4674
|
+
return [{
|
4675
|
+
type: EXPRESSION,
|
4676
|
+
value: genFor(el, state, elementToString, '_ssrList')
|
4677
|
+
}]
|
4678
|
+
} else if (el.if && !el.ifProcessed) {
|
4679
|
+
el.ifProcessed = true;
|
4680
|
+
return [{
|
4681
|
+
type: EXPRESSION,
|
4682
|
+
value: genIf(el, state, elementToString, '"<!---->"')
|
4683
|
+
}]
|
4684
|
+
} else if (el.tag === 'template') {
|
4685
|
+
return childrenToSegments(el, state)
|
4686
|
+
}
|
4687
|
+
|
4688
|
+
var openSegments = elementToOpenTagSegments(el, state);
|
4689
|
+
var childrenSegments = childrenToSegments(el, state);
|
4690
|
+
var ref = state.options;
|
4691
|
+
var isUnaryTag = ref.isUnaryTag;
|
4692
|
+
var close = (isUnaryTag && isUnaryTag(el.tag))
|
4693
|
+
? []
|
4694
|
+
: [{ type: RAW, value: ("</" + (el.tag) + ">") }];
|
4695
|
+
return openSegments.concat(childrenSegments, close)
|
4696
|
+
}
|
4697
|
+
|
4698
|
+
function elementToOpenTagSegments (el, state) {
|
4699
|
+
applyModelTransform(el, state);
|
4700
|
+
var binding;
|
4701
|
+
var segments = [{ type: RAW, value: ("<" + (el.tag)) }];
|
4702
|
+
// attrs
|
4703
|
+
if (el.attrs) {
|
4704
|
+
segments.push.apply(segments, genAttrSegments(el.attrs));
|
4705
|
+
}
|
4706
|
+
// domProps
|
4707
|
+
if (el.props) {
|
4708
|
+
segments.push.apply(segments, genDOMPropSegments(el.props, el.attrs));
|
4709
|
+
}
|
4710
|
+
// v-bind="object"
|
4711
|
+
if ((binding = el.attrsMap['v-bind'])) {
|
4712
|
+
segments.push({ type: EXPRESSION, value: ("_ssrAttrs(" + binding + ")") });
|
4713
|
+
}
|
4714
|
+
// v-bind.prop="object"
|
4715
|
+
if ((binding = el.attrsMap['v-bind.prop'])) {
|
4716
|
+
segments.push({ type: EXPRESSION, value: ("_ssrDOMProps(" + binding + ")") });
|
4717
|
+
}
|
4718
|
+
// class
|
4719
|
+
if (el.staticClass || el.classBinding) {
|
4720
|
+
segments.push.apply(
|
4721
|
+
segments,
|
4722
|
+
genClassSegments(el.staticClass, el.classBinding)
|
4723
|
+
);
|
4724
|
+
}
|
4725
|
+
// style & v-show
|
4726
|
+
if (el.staticStyle || el.styleBinding || el.attrsMap['v-show']) {
|
4727
|
+
segments.push.apply(
|
4728
|
+
segments,
|
4729
|
+
genStyleSegments(
|
4730
|
+
el.attrsMap.style,
|
4731
|
+
el.staticStyle,
|
4732
|
+
el.styleBinding,
|
4733
|
+
el.attrsMap['v-show']
|
4734
|
+
)
|
4735
|
+
);
|
4736
|
+
}
|
4737
|
+
// _scopedId
|
4738
|
+
if (state.options.scopeId) {
|
4739
|
+
segments.push({ type: RAW, value: (" " + (state.options.scopeId)) });
|
4740
|
+
}
|
4741
|
+
segments.push({ type: RAW, value: ">" });
|
4742
|
+
return segments
|
4743
|
+
}
|
4744
|
+
|
4745
|
+
function childrenToSegments (el, state) {
|
4746
|
+
var binding;
|
4747
|
+
if ((binding = el.attrsMap['v-html'])) {
|
4748
|
+
return [{ type: EXPRESSION, value: ("_s(" + binding + ")") }]
|
4749
|
+
}
|
4750
|
+
if ((binding = el.attrsMap['v-text'])) {
|
4751
|
+
return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
|
4752
|
+
}
|
4753
|
+
if (el.tag === 'textarea' && (binding = el.attrsMap['v-model'])) {
|
4754
|
+
return [{ type: INTERPOLATION, value: ("_s(" + binding + ")") }]
|
4755
|
+
}
|
4756
|
+
return el.children
|
4757
|
+
? nodesToSegments(el.children, state)
|
4758
|
+
: []
|
4759
|
+
}
|
4760
|
+
|
4761
|
+
function nodesToSegments (
|
4762
|
+
children,
|
4763
|
+
state
|
4764
|
+
) {
|
4765
|
+
var segments = [];
|
4766
|
+
for (var i = 0; i < children.length; i++) {
|
4767
|
+
var c = children[i];
|
4768
|
+
if (c.type === 1) {
|
4769
|
+
segments.push.apply(segments, elementToSegments(c, state));
|
4770
|
+
} else if (c.type === 2) {
|
4771
|
+
segments.push({ type: INTERPOLATION, value: c.expression });
|
4772
|
+
} else if (c.type === 3) {
|
4773
|
+
segments.push({ type: RAW, value: escape(c.text) });
|
4774
|
+
}
|
4775
|
+
}
|
4776
|
+
return segments
|
4777
|
+
}
|
4778
|
+
|
4779
|
+
function flattenSegments (segments) {
|
4780
|
+
var mergedSegments = [];
|
4781
|
+
var textBuffer = '';
|
4782
|
+
|
4783
|
+
var pushBuffer = function () {
|
4784
|
+
if (textBuffer) {
|
4785
|
+
mergedSegments.push(JSON.stringify(textBuffer));
|
4786
|
+
textBuffer = '';
|
4787
|
+
}
|
4788
|
+
};
|
4789
|
+
|
4790
|
+
for (var i = 0; i < segments.length; i++) {
|
4791
|
+
var s = segments[i];
|
4792
|
+
if (s.type === RAW) {
|
4793
|
+
textBuffer += s.value;
|
4794
|
+
} else if (s.type === INTERPOLATION) {
|
4795
|
+
pushBuffer();
|
4796
|
+
mergedSegments.push(("_ssrEscape(" + (s.value) + ")"));
|
4797
|
+
} else if (s.type === EXPRESSION) {
|
4798
|
+
pushBuffer();
|
4799
|
+
mergedSegments.push(("(" + (s.value) + ")"));
|
4800
|
+
}
|
4801
|
+
}
|
4802
|
+
pushBuffer();
|
4803
|
+
|
4804
|
+
return mergedSegments.join('+')
|
4805
|
+
}
|
4806
|
+
|
4807
|
+
/* */
|
4808
|
+
|
4809
|
+
var createCompiler$1 = createCompilerCreator(function baseCompile (
|
4810
|
+
template,
|
4811
|
+
options
|
4812
|
+
) {
|
4813
|
+
var ast = parse(template.trim(), options);
|
4814
|
+
optimize$1(ast, options);
|
4815
|
+
var code = generate$1(ast, options);
|
4816
|
+
return {
|
4817
|
+
ast: ast,
|
4818
|
+
render: code.render,
|
4819
|
+
staticRenderFns: code.staticRenderFns
|
4820
|
+
}
|
4821
|
+
});
|
4822
|
+
|
4823
|
+
/* */
|
4824
|
+
|
4825
|
+
var ref$1 = createCompiler$1(baseOptions);
|
4826
|
+
var compile$1 = ref$1.compile;
|
4827
|
+
var compileToFunctions$1 = ref$1.compileToFunctions;
|
4828
|
+
|
4829
|
+
/* */
|
4830
|
+
|
4831
|
+
exports.parseComponent = parseComponent;
|
4832
|
+
exports.compile = compile;
|
4833
|
+
exports.compileToFunctions = compileToFunctions;
|
4834
|
+
exports.ssrCompile = compile$1;
|
4835
|
+
exports.ssrCompileToFunctions = compileToFunctions$1;
|