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