@@ -1,3 +1,19 @@ |
||
1 |
-module.exports = function(router, io, logger){ |
|
1 |
+var logger = require('winston'); |
|
2 |
+ |
|
3 |
+module.exports.start = function(channel){ |
|
2 | 4 |
logger.info("Starting External temperature module"); |
5 |
+ setInterval(function () { |
|
6 |
+ var temperature = readSensor(); |
|
7 |
+ channel.emit('temperature_external', { temperature: temperature }); |
|
8 |
+ }, 1000); |
|
9 |
+ |
|
10 |
+} |
|
11 |
+ |
|
12 |
+function readSensor() { |
|
13 |
+ // Read Sensor data |
|
14 |
+ // give random data for testing |
|
15 |
+ var high = 25; |
|
16 |
+ var low = 23; |
|
17 |
+ var temp = Math.random() * (high - low) + low |
|
18 |
+ return temp |
|
3 | 19 |
} |
@@ -24,13 +24,11 @@ router.get('/', function (req, res) { |
||
24 | 24 |
external_temperature_sensor = require('./external_temperature_sensor'); |
25 | 25 |
relay_controller = require('./relay_controller'); |
26 | 26 |
|
27 |
-external_temperature_sensor(router, io, winston); |
|
28 |
- |
|
29 |
- |
|
30 |
-var channel_relays = io |
|
27 |
+var channel = io |
|
31 | 28 |
.of('/') |
32 | 29 |
.on('connection', function (socket) { |
33 |
- relay_controller.monitor(socket, channel_relays); |
|
30 |
+ relay_controller.monitor(socket, channel); |
|
34 | 31 |
}); |
35 | 32 |
|
36 |
-relay_controller.start(router, channel_relays); |
|
33 |
+relay_controller.start(router, channel); |
|
34 |
+external_temperature_sensor.start(channel); |
@@ -44,7 +44,7 @@ |
||
44 | 44 |
.statcard .statcard-number { |
45 | 45 |
margin-top: 0; |
46 | 46 |
margin-bottom: 0; } |
47 |
- .statcard h1, .statcard h2, .statcard h3, .statcard h4, .statcard h5, .statcard h6 { |
|
47 |
+ .statcard h1, .statcard h2, .statcard h3, .statcard h4, .statcard h5, .statcard h6, .statcard dt, .statcard dd { |
|
48 | 48 |
margin-top: 0; |
49 | 49 |
font-family: inherit; |
50 | 50 |
font-weight: 300; |
@@ -60,37 +60,105 @@ |
||
60 | 60 |
float: left; |
61 | 61 |
font-size: 50px; |
62 | 62 |
margin-right: 20px; } |
63 |
+ .statcard .statcard-header { |
|
64 |
+ padding: 1.5rem 1.5rem !important; } |
|
65 |
+ .statcard .statcard-content { |
|
66 |
+ width: 100%; |
|
67 |
+ min-height: 30px; |
|
68 |
+ padding: 1.5rem 1.5rem !important; |
|
69 |
+ border-top: 1px solid rgba(0, 0, 0, 0.125); } |
|
70 |
+ .statcard .statcard-content .row { |
|
71 |
+ margin-bottom: 0px; } |
|
72 |
+ |
|
73 |
+.statcard.statcard-divided { |
|
74 |
+ padding: 0px !important; |
|
75 |
+ border-radius: 0.25rem; } |
|
63 | 76 |
|
64 |
-.statcard.statcard-primary { |
|
77 |
+.statcard.statcard-primary, .statcard-header.statcard-primary, .statcard-content.statcard-primary { |
|
65 | 78 |
color: #fff; |
66 | 79 |
background-color: #007bff; } |
67 |
- .statcard.statcard-primary .statcard-title { |
|
80 |
+ .statcard.statcard-primary .statcard-title, .statcard-header.statcard-primary .statcard-title, .statcard-content.statcard-primary .statcard-title { |
|
68 | 81 |
color: #fff; } |
69 | 82 |
|
70 |
-.statcard.statcard-success { |
|
83 |
+.statcard.statcard-success, .statcard-header.statcard-success, .statcard-content.statcard-success { |
|
71 | 84 |
color: #fff; |
72 | 85 |
background-color: #28a745; } |
73 |
- .statcard.statcard-success .statcard-title { |
|
86 |
+ .statcard.statcard-success .statcard-title, .statcard-header.statcard-success .statcard-title, .statcard-content.statcard-success .statcard-title { |
|
74 | 87 |
color: #fff; } |
75 | 88 |
|
76 |
-.statcard.statcard-info { |
|
89 |
+.statcard.statcard-info, .statcard-header.statcard-info, .statcard-content.statcard-info { |
|
77 | 90 |
color: #fff; |
78 | 91 |
background-color: #17a2b8; } |
79 |
- .statcard.statcard-info .statcard-title { |
|
92 |
+ .statcard.statcard-info .statcard-title, .statcard-header.statcard-info .statcard-title, .statcard-content.statcard-info .statcard-title { |
|
80 | 93 |
color: #fff; } |
81 | 94 |
|
82 |
-.statcard.statcard-danger { |
|
95 |
+.statcard.statcard-danger, .statcard-header.statcard-danger, .statcard-content.statcard-danger { |
|
83 | 96 |
color: #fff; |
84 | 97 |
background-color: #dc3545; } |
85 |
- .statcard.statcard-danger .statcard-title { |
|
98 |
+ .statcard.statcard-danger .statcard-title, .statcard-header.statcard-danger .statcard-title, .statcard-content.statcard-danger .statcard-title { |
|
86 | 99 |
color: #fff; } |
87 | 100 |
|
88 |
-.statcard.statcard-warning { |
|
101 |
+.statcard.statcard-warning, .statcard-header.statcard-warning, .statcard-content.statcard-warning { |
|
89 | 102 |
color: #fff; |
90 | 103 |
background-color: #ffc107; } |
91 |
- .statcard.statcard-warning .statcard-title { |
|
104 |
+ .statcard.statcard-warning .statcard-title, .statcard-header.statcard-warning .statcard-title, .statcard-content.statcard-warning .statcard-title { |
|
105 |
+ color: #fff; } |
|
106 |
+ |
|
107 |
+.statcard.statcard-secondary, .statcard-header.statcard-secondary, .statcard-content.statcard-secondary { |
|
108 |
+ color: #fff; |
|
109 |
+ background-color: #727b84; } |
|
110 |
+ .statcard.statcard-secondary .statcard-title, .statcard-header.statcard-secondary .statcard-title, .statcard-content.statcard-secondary .statcard-title { |
|
92 | 111 |
color: #fff; } |
93 | 112 |
|
113 |
+.statcard.statcard-light, .statcard-header.statcard-light, .statcard-content.statcard-light { |
|
114 |
+ color: #111; |
|
115 |
+ background-color: #f8f9fa; } |
|
116 |
+ .statcard.statcard-light .statcard-title, .statcard-header.statcard-light .statcard-title, .statcard-content.statcard-light .statcard-title { |
|
117 |
+ color: #111; } |
|
118 |
+ |
|
119 |
+.statcard.statcard-dark, .statcard-header.statcard-dark, .statcard-content.statcard-dark { |
|
120 |
+ color: #fff; |
|
121 |
+ background-color: #343a40; } |
|
122 |
+ .statcard.statcard-dark .statcard-title, .statcard-header.statcard-dark .statcard-title, .statcard-content.statcard-dark .statcard-title { |
|
123 |
+ color: #fff; } |
|
124 |
+ |
|
125 |
+.delta-indicator { |
|
126 |
+ display: inline-block; |
|
127 |
+ padding: .4em; |
|
128 |
+ font-size: 12px; |
|
129 |
+ vertical-align: middle; |
|
130 |
+ font-weight: normal; |
|
131 |
+ margin-top: -4px; } |
|
132 |
+ |
|
133 |
+.delta-indicator:after { |
|
134 |
+ content: ""; |
|
135 |
+ display: inline-block; |
|
136 |
+ width: 0; |
|
137 |
+ height: 0; |
|
138 |
+ margin-left: 2px; |
|
139 |
+ margin-left: 2px; |
|
140 |
+ vertical-align: middle; |
|
141 |
+ border-right: 4px solid transparent; |
|
142 |
+ border-left: 4px solid transparent; |
|
143 |
+ margin-top: -4px; } |
|
144 |
+ |
|
145 |
+.delta-positive { |
|
146 |
+ color: #1BC98E; } |
|
147 |
+ |
|
148 |
+.delta-positive:after { |
|
149 |
+ border-top: 0; |
|
150 |
+ border-bottom: 4px solid; } |
|
151 |
+ |
|
152 |
+.delta-negative { |
|
153 |
+ color: #E64759; } |
|
154 |
+ |
|
155 |
+.delta-negative:after { |
|
156 |
+ border-bottom: 0; |
|
157 |
+ border-top: 4px solid; } |
|
158 |
+ |
|
159 |
+.statcard-primary .delta-positive, .statcard-primary .delta-negative { |
|
160 |
+ color: #fff; } |
|
161 |
+ |
|
94 | 162 |
.spacer-sm { |
95 | 163 |
margin-top: 20px; } |
96 | 164 |
|
@@ -0,0 +1,9316 @@ |
||
1 |
+/*! |
|
2 |
+ * Vue.js v2.2.6 |
|
3 |
+ * (c) 2014-2017 Evan You |
|
4 |
+ * Released under the MIT License. |
|
5 |
+ */ |
|
6 |
+(function (global, factory) { |
|
7 |
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
|
8 |
+ typeof define === 'function' && define.amd ? define(factory) : |
|
9 |
+ (global.Vue = factory()); |
|
10 |
+}(this, (function () { 'use strict'; |
|
11 |
+ |
|
12 |
+/* */ |
|
13 |
+ |
|
14 |
+/** |
|
15 |
+ * Convert a value to a string that is actually rendered. |
|
16 |
+ */ |
|
17 |
+function _toString (val) { |
|
18 |
+ return val == null |
|
19 |
+ ? '' |
|
20 |
+ : typeof val === 'object' |
|
21 |
+ ? JSON.stringify(val, null, 2) |
|
22 |
+ : String(val) |
|
23 |
+} |
|
24 |
+ |
|
25 |
+/** |
|
26 |
+ * Convert a input value to a number for persistence. |
|
27 |
+ * If the conversion fails, return original string. |
|
28 |
+ */ |
|
29 |
+function toNumber (val) { |
|
30 |
+ var n = parseFloat(val); |
|
31 |
+ return isNaN(n) ? val : n |
|
32 |
+} |
|
33 |
+ |
|
34 |
+/** |
|
35 |
+ * Make a map and return a function for checking if a key |
|
36 |
+ * is in that map. |
|
37 |
+ */ |
|
38 |
+function makeMap ( |
|
39 |
+ str, |
|
40 |
+ expectsLowerCase |
|
41 |
+) { |
|
42 |
+ var map = Object.create(null); |
|
43 |
+ var list = str.split(','); |
|
44 |
+ for (var i = 0; i < list.length; i++) { |
|
45 |
+ map[list[i]] = true; |
|
46 |
+ } |
|
47 |
+ return expectsLowerCase |
|
48 |
+ ? function (val) { return map[val.toLowerCase()]; } |
|
49 |
+ : function (val) { return map[val]; } |
|
50 |
+} |
|
51 |
+ |
|
52 |
+/** |
|
53 |
+ * Check if a tag is a built-in tag. |
|
54 |
+ */ |
|
55 |
+var isBuiltInTag = makeMap('slot,component', true); |
|
56 |
+ |
|
57 |
+/** |
|
58 |
+ * Remove an item from an array |
|
59 |
+ */ |
|
60 |
+function remove (arr, item) { |
|
61 |
+ if (arr.length) { |
|
62 |
+ var index = arr.indexOf(item); |
|
63 |
+ if (index > -1) { |
|
64 |
+ return arr.splice(index, 1) |
|
65 |
+ } |
|
66 |
+ } |
|
67 |
+} |
|
68 |
+ |
|
69 |
+/** |
|
70 |
+ * Check whether the object has the property. |
|
71 |
+ */ |
|
72 |
+var hasOwnProperty = Object.prototype.hasOwnProperty; |
|
73 |
+function hasOwn (obj, key) { |
|
74 |
+ return hasOwnProperty.call(obj, key) |
|
75 |
+} |
|
76 |
+ |
|
77 |
+/** |
|
78 |
+ * Check if value is primitive |
|
79 |
+ */ |
|
80 |
+function isPrimitive (value) { |
|
81 |
+ return typeof value === 'string' || typeof value === 'number' |
|
82 |
+} |
|
83 |
+ |
|
84 |
+/** |
|
85 |
+ * Create a cached version of a pure function. |
|
86 |
+ */ |
|
87 |
+function cached (fn) { |
|
88 |
+ var cache = Object.create(null); |
|
89 |
+ return (function cachedFn (str) { |
|
90 |
+ var hit = cache[str]; |
|
91 |
+ return hit || (cache[str] = fn(str)) |
|
92 |
+ }) |
|
93 |
+} |
|
94 |
+ |
|
95 |
+/** |
|
96 |
+ * Camelize a hyphen-delimited string. |
|
97 |
+ */ |
|
98 |
+var camelizeRE = /-(\w)/g; |
|
99 |
+var camelize = cached(function (str) { |
|
100 |
+ return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) |
|
101 |
+}); |
|
102 |
+ |
|
103 |
+/** |
|
104 |
+ * Capitalize a string. |
|
105 |
+ */ |
|
106 |
+var capitalize = cached(function (str) { |
|
107 |
+ return str.charAt(0).toUpperCase() + str.slice(1) |
|
108 |
+}); |
|
109 |
+ |
|
110 |
+/** |
|
111 |
+ * Hyphenate a camelCase string. |
|
112 |
+ */ |
|
113 |
+var hyphenateRE = /([^-])([A-Z])/g; |
|
114 |
+var hyphenate = cached(function (str) { |
|
115 |
+ return str |
|
116 |
+ .replace(hyphenateRE, '$1-$2') |
|
117 |
+ .replace(hyphenateRE, '$1-$2') |
|
118 |
+ .toLowerCase() |
|
119 |
+}); |
|
120 |
+ |
|
121 |
+/** |
|
122 |
+ * Simple bind, faster than native |
|
123 |
+ */ |
|
124 |
+function bind (fn, ctx) { |
|
125 |
+ function boundFn (a) { |
|
126 |
+ var l = arguments.length; |
|
127 |
+ return l |
|
128 |
+ ? l > 1 |
|
129 |
+ ? fn.apply(ctx, arguments) |
|
130 |
+ : fn.call(ctx, a) |
|
131 |
+ : fn.call(ctx) |
|
132 |
+ } |
|
133 |
+ // record original fn length |
|
134 |
+ boundFn._length = fn.length; |
|
135 |
+ return boundFn |
|
136 |
+} |
|
137 |
+ |
|
138 |
+/** |
|
139 |
+ * Convert an Array-like object to a real Array. |
|
140 |
+ */ |
|
141 |
+function toArray (list, start) { |
|
142 |
+ start = start || 0; |
|
143 |
+ var i = list.length - start; |
|
144 |
+ var ret = new Array(i); |
|
145 |
+ while (i--) { |
|
146 |
+ ret[i] = list[i + start]; |
|
147 |
+ } |
|
148 |
+ return ret |
|
149 |
+} |
|
150 |
+ |
|
151 |
+/** |
|
152 |
+ * Mix properties into target object. |
|
153 |
+ */ |
|
154 |
+function extend (to, _from) { |
|
155 |
+ for (var key in _from) { |
|
156 |
+ to[key] = _from[key]; |
|
157 |
+ } |
|
158 |
+ return to |
|
159 |
+} |
|
160 |
+ |
|
161 |
+/** |
|
162 |
+ * Quick object check - this is primarily used to tell |
|
163 |
+ * Objects from primitive values when we know the value |
|
164 |
+ * is a JSON-compliant type. |
|
165 |
+ */ |
|
166 |
+function isObject (obj) { |
|
167 |
+ return obj !== null && typeof obj === 'object' |
|
168 |
+} |
|
169 |
+ |
|
170 |
+/** |
|
171 |
+ * Strict object type check. Only returns true |
|
172 |
+ * for plain JavaScript objects. |
|
173 |
+ */ |
|
174 |
+var toString = Object.prototype.toString; |
|
175 |
+var OBJECT_STRING = '[object Object]'; |
|
176 |
+function isPlainObject (obj) { |
|
177 |
+ return toString.call(obj) === OBJECT_STRING |
|
178 |
+} |
|
179 |
+ |
|
180 |
+/** |
|
181 |
+ * Merge an Array of Objects into a single Object. |
|
182 |
+ */ |
|
183 |
+function toObject (arr) { |
|
184 |
+ var res = {}; |
|
185 |
+ for (var i = 0; i < arr.length; i++) { |
|
186 |
+ if (arr[i]) { |
|
187 |
+ extend(res, arr[i]); |
|
188 |
+ } |
|
189 |
+ } |
|
190 |
+ return res |
|
191 |
+} |
|
192 |
+ |
|
193 |
+/** |
|
194 |
+ * Perform no operation. |
|
195 |
+ */ |
|
196 |
+function noop () {} |
|
197 |
+ |
|
198 |
+/** |
|
199 |
+ * Always return false. |
|
200 |
+ */ |
|
201 |
+var no = function () { return false; }; |
|
202 |
+ |
|
203 |
+/** |
|
204 |
+ * Return same value |
|
205 |
+ */ |
|
206 |
+var identity = function (_) { return _; }; |
|
207 |
+ |
|
208 |
+/** |
|
209 |
+ * Generate a static keys string from compiler modules. |
|
210 |
+ */ |
|
211 |
+function genStaticKeys (modules) { |
|
212 |
+ return modules.reduce(function (keys, m) { |
|
213 |
+ return keys.concat(m.staticKeys || []) |
|
214 |
+ }, []).join(',') |
|
215 |
+} |
|
216 |
+ |
|
217 |
+/** |
|
218 |
+ * Check if two values are loosely equal - that is, |
|
219 |
+ * if they are plain objects, do they have the same shape? |
|
220 |
+ */ |
|
221 |
+function looseEqual (a, b) { |
|
222 |
+ var isObjectA = isObject(a); |
|
223 |
+ var isObjectB = isObject(b); |
|
224 |
+ if (isObjectA && isObjectB) { |
|
225 |
+ try { |
|
226 |
+ return JSON.stringify(a) === JSON.stringify(b) |
|
227 |
+ } catch (e) { |
|
228 |
+ // possible circular reference |
|
229 |
+ return a === b |
|
230 |
+ } |
|
231 |
+ } else if (!isObjectA && !isObjectB) { |
|
232 |
+ return String(a) === String(b) |
|
233 |
+ } else { |
|
234 |
+ return false |
|
235 |
+ } |
|
236 |
+} |
|
237 |
+ |
|
238 |
+function looseIndexOf (arr, val) { |
|
239 |
+ for (var i = 0; i < arr.length; i++) { |
|
240 |
+ if (looseEqual(arr[i], val)) { return i } |
|
241 |
+ } |
|
242 |
+ return -1 |
|
243 |
+} |
|
244 |
+ |
|
245 |
+/** |
|
246 |
+ * Ensure a function is called only once. |
|
247 |
+ */ |
|
248 |
+function once (fn) { |
|
249 |
+ var called = false; |
|
250 |
+ return function () { |
|
251 |
+ if (!called) { |
|
252 |
+ called = true; |
|
253 |
+ fn(); |
|
254 |
+ } |
|
255 |
+ } |
|
256 |
+} |
|
257 |
+ |
|
258 |
+/* */ |
|
259 |
+ |
|
260 |
+var config = { |
|
261 |
+ /** |
|
262 |
+ * Option merge strategies (used in core/util/options) |
|
263 |
+ */ |
|
264 |
+ optionMergeStrategies: Object.create(null), |
|
265 |
+ |
|
266 |
+ /** |
|
267 |
+ * Whether to suppress warnings. |
|
268 |
+ */ |
|
269 |
+ silent: false, |
|
270 |
+ |
|
271 |
+ /** |
|
272 |
+ * Show production mode tip message on boot? |
|
273 |
+ */ |
|
274 |
+ productionTip: "development" !== 'production', |
|
275 |
+ |
|
276 |
+ /** |
|
277 |
+ * Whether to enable devtools |
|
278 |
+ */ |
|
279 |
+ devtools: "development" !== 'production', |
|
280 |
+ |
|
281 |
+ /** |
|
282 |
+ * Whether to record perf |
|
283 |
+ */ |
|
284 |
+ performance: false, |
|
285 |
+ |
|
286 |
+ /** |
|
287 |
+ * Error handler for watcher errors |
|
288 |
+ */ |
|
289 |
+ errorHandler: null, |
|
290 |
+ |
|
291 |
+ /** |
|
292 |
+ * Ignore certain custom elements |
|
293 |
+ */ |
|
294 |
+ ignoredElements: [], |
|
295 |
+ |
|
296 |
+ /** |
|
297 |
+ * Custom user key aliases for v-on |
|
298 |
+ */ |
|
299 |
+ keyCodes: Object.create(null), |
|
300 |
+ |
|
301 |
+ /** |
|
302 |
+ * Check if a tag is reserved so that it cannot be registered as a |
|
303 |
+ * component. This is platform-dependent and may be overwritten. |
|
304 |
+ */ |
|
305 |
+ isReservedTag: no, |
|
306 |
+ |
|
307 |
+ /** |
|
308 |
+ * Check if a tag is an unknown element. |
|
309 |
+ * Platform-dependent. |
|
310 |
+ */ |
|
311 |
+ isUnknownElement: no, |
|
312 |
+ |
|
313 |
+ /** |
|
314 |
+ * Get the namespace of an element |
|
315 |
+ */ |
|
316 |
+ getTagNamespace: noop, |
|
317 |
+ |
|
318 |
+ /** |
|
319 |
+ * Parse the real tag name for the specific platform. |
|
320 |
+ */ |
|
321 |
+ parsePlatformTagName: identity, |
|
322 |
+ |
|
323 |
+ /** |
|
324 |
+ * Check if an attribute must be bound using property, e.g. value |
|
325 |
+ * Platform-dependent. |
|
326 |
+ */ |
|
327 |
+ mustUseProp: no, |
|
328 |
+ |
|
329 |
+ /** |
|
330 |
+ * List of asset types that a component can own. |
|
331 |
+ */ |
|
332 |
+ _assetTypes: [ |
|
333 |
+ 'component', |
|
334 |
+ 'directive', |
|
335 |
+ 'filter' |
|
336 |
+ ], |
|
337 |
+ |
|
338 |
+ /** |
|
339 |
+ * List of lifecycle hooks. |
|
340 |
+ */ |
|
341 |
+ _lifecycleHooks: [ |
|
342 |
+ 'beforeCreate', |
|
343 |
+ 'created', |
|
344 |
+ 'beforeMount', |
|
345 |
+ 'mounted', |
|
346 |
+ 'beforeUpdate', |
|
347 |
+ 'updated', |
|
348 |
+ 'beforeDestroy', |
|
349 |
+ 'destroyed', |
|
350 |
+ 'activated', |
|
351 |
+ 'deactivated' |
|
352 |
+ ], |
|
353 |
+ |
|
354 |
+ /** |
|
355 |
+ * Max circular updates allowed in a scheduler flush cycle. |
|
356 |
+ */ |
|
357 |
+ _maxUpdateCount: 100 |
|
358 |
+}; |
|
359 |
+ |
|
360 |
+/* */ |
|
361 |
+ |
|
362 |
+var emptyObject = Object.freeze({}); |
|
363 |
+ |
|
364 |
+/** |
|
365 |
+ * Check if a string starts with $ or _ |
|
366 |
+ */ |
|
367 |
+function isReserved (str) { |
|
368 |
+ var c = (str + '').charCodeAt(0); |
|
369 |
+ return c === 0x24 || c === 0x5F |
|
370 |
+} |
|
371 |
+ |
|
372 |
+/** |
|
373 |
+ * Define a property. |
|
374 |
+ */ |
|
375 |
+function def (obj, key, val, enumerable) { |
|
376 |
+ Object.defineProperty(obj, key, { |
|
377 |
+ value: val, |
|
378 |
+ enumerable: !!enumerable, |
|
379 |
+ writable: true, |
|
380 |
+ configurable: true |
|
381 |
+ }); |
|
382 |
+} |
|
383 |
+ |
|
384 |
+/** |
|
385 |
+ * Parse simple path. |
|
386 |
+ */ |
|
387 |
+var bailRE = /[^\w.$]/; |
|
388 |
+function parsePath (path) { |
|
389 |
+ if (bailRE.test(path)) { |
|
390 |
+ return |
|
391 |
+ } |
|
392 |
+ var segments = path.split('.'); |
|
393 |
+ return function (obj) { |
|
394 |
+ for (var i = 0; i < segments.length; i++) { |
|
395 |
+ if (!obj) { return } |
|
396 |
+ obj = obj[segments[i]]; |
|
397 |
+ } |
|
398 |
+ return obj |
|
399 |
+ } |
|
400 |
+} |
|
401 |
+ |
|
402 |
+/* */ |
|
403 |
+/* globals MutationObserver */ |
|
404 |
+ |
|
405 |
+// can we use __proto__? |
|
406 |
+var hasProto = '__proto__' in {}; |
|
407 |
+ |
|
408 |
+// Browser environment sniffing |
|
409 |
+var inBrowser = typeof window !== 'undefined'; |
|
410 |
+var UA = inBrowser && window.navigator.userAgent.toLowerCase(); |
|
411 |
+var isIE = UA && /msie|trident/.test(UA); |
|
412 |
+var isIE9 = UA && UA.indexOf('msie 9.0') > 0; |
|
413 |
+var isEdge = UA && UA.indexOf('edge/') > 0; |
|
414 |
+var isAndroid = UA && UA.indexOf('android') > 0; |
|
415 |
+var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); |
|
416 |
+var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; |
|
417 |
+ |
|
418 |
+// this needs to be lazy-evaled because vue may be required before |
|
419 |
+// vue-server-renderer can set VUE_ENV |
|
420 |
+var _isServer; |
|
421 |
+var isServerRendering = function () { |
|
422 |
+ if (_isServer === undefined) { |
|
423 |
+ /* istanbul ignore if */ |
|
424 |
+ if (!inBrowser && typeof global !== 'undefined') { |
|
425 |
+ // detect presence of vue-server-renderer and avoid |
|
426 |
+ // Webpack shimming the process |
|
427 |
+ _isServer = global['process'].env.VUE_ENV === 'server'; |
|
428 |
+ } else { |
|
429 |
+ _isServer = false; |
|
430 |
+ } |
|
431 |
+ } |
|
432 |
+ return _isServer |
|
433 |
+}; |
|
434 |
+ |
|
435 |
+// detect devtools |
|
436 |
+var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; |
|
437 |
+ |
|
438 |
+/* istanbul ignore next */ |
|
439 |
+function isNative (Ctor) { |
|
440 |
+ return /native code/.test(Ctor.toString()) |
|
441 |
+} |
|
442 |
+ |
|
443 |
+var hasSymbol = |
|
444 |
+ typeof Symbol !== 'undefined' && isNative(Symbol) && |
|
445 |
+ typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); |
|
446 |
+ |
|
447 |
+/** |
|
448 |
+ * Defer a task to execute it asynchronously. |
|
449 |
+ */ |
|
450 |
+var nextTick = (function () { |
|
451 |
+ var callbacks = []; |
|
452 |
+ var pending = false; |
|
453 |
+ var timerFunc; |
|
454 |
+ |
|
455 |
+ function nextTickHandler () { |
|
456 |
+ pending = false; |
|
457 |
+ var copies = callbacks.slice(0); |
|
458 |
+ callbacks.length = 0; |
|
459 |
+ for (var i = 0; i < copies.length; i++) { |
|
460 |
+ copies[i](); |
|
461 |
+ } |
|
462 |
+ } |
|
463 |
+ |
|
464 |
+ // the nextTick behavior leverages the microtask queue, which can be accessed |
|
465 |
+ // via either native Promise.then or MutationObserver. |
|
466 |
+ // MutationObserver has wider support, however it is seriously bugged in |
|
467 |
+ // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It |
|
468 |
+ // completely stops working after triggering a few times... so, if native |
|
469 |
+ // Promise is available, we will use it: |
|
470 |
+ /* istanbul ignore if */ |
|
471 |
+ if (typeof Promise !== 'undefined' && isNative(Promise)) { |
|
472 |
+ var p = Promise.resolve(); |
|
473 |
+ var logError = function (err) { console.error(err); }; |
|
474 |
+ timerFunc = function () { |
|
475 |
+ p.then(nextTickHandler).catch(logError); |
|
476 |
+ // in problematic UIWebViews, Promise.then doesn't completely break, but |
|
477 |
+ // it can get stuck in a weird state where callbacks are pushed into the |
|
478 |
+ // microtask queue but the queue isn't being flushed, until the browser |
|
479 |
+ // needs to do some other work, e.g. handle a timer. Therefore we can |
|
480 |
+ // "force" the microtask queue to be flushed by adding an empty timer. |
|
481 |
+ if (isIOS) { setTimeout(noop); } |
|
482 |
+ }; |
|
483 |
+ } else if (typeof MutationObserver !== 'undefined' && ( |
|
484 |
+ isNative(MutationObserver) || |
|
485 |
+ // PhantomJS and iOS 7.x |
|
486 |
+ MutationObserver.toString() === '[object MutationObserverConstructor]' |
|
487 |
+ )) { |
|
488 |
+ // use MutationObserver where native Promise is not available, |
|
489 |
+ // e.g. PhantomJS IE11, iOS7, Android 4.4 |
|
490 |
+ var counter = 1; |
|
491 |
+ var observer = new MutationObserver(nextTickHandler); |
|
492 |
+ var textNode = document.createTextNode(String(counter)); |
|
493 |
+ observer.observe(textNode, { |
|
494 |
+ characterData: true |
|
495 |
+ }); |
|
496 |
+ timerFunc = function () { |
|
497 |
+ counter = (counter + 1) % 2; |
|
498 |
+ textNode.data = String(counter); |
|
499 |
+ }; |
|
500 |
+ } else { |
|
501 |
+ // fallback to setTimeout |
|
502 |
+ /* istanbul ignore next */ |
|
503 |
+ timerFunc = function () { |
|
504 |
+ setTimeout(nextTickHandler, 0); |
|
505 |
+ }; |
|
506 |
+ } |
|
507 |
+ |
|
508 |
+ return function queueNextTick (cb, ctx) { |
|
509 |
+ var _resolve; |
|
510 |
+ callbacks.push(function () { |
|
511 |
+ if (cb) { cb.call(ctx); } |
|
512 |
+ if (_resolve) { _resolve(ctx); } |
|
513 |
+ }); |
|
514 |
+ if (!pending) { |
|
515 |
+ pending = true; |
|
516 |
+ timerFunc(); |
|
517 |
+ } |
|
518 |
+ if (!cb && typeof Promise !== 'undefined') { |
|
519 |
+ return new Promise(function (resolve) { |
|
520 |
+ _resolve = resolve; |
|
521 |
+ }) |
|
522 |
+ } |
|
523 |
+ } |
|
524 |
+})(); |
|
525 |
+ |
|
526 |
+var _Set; |
|
527 |
+/* istanbul ignore if */ |
|
528 |
+if (typeof Set !== 'undefined' && isNative(Set)) { |
|
529 |
+ // use native Set when available. |
|
530 |
+ _Set = Set; |
|
531 |
+} else { |
|
532 |
+ // a non-standard Set polyfill that only works with primitive keys. |
|
533 |
+ _Set = (function () { |
|
534 |
+ function Set () { |
|
535 |
+ this.set = Object.create(null); |
|
536 |
+ } |
|
537 |
+ Set.prototype.has = function has (key) { |
|
538 |
+ return this.set[key] === true |
|
539 |
+ }; |
|
540 |
+ Set.prototype.add = function add (key) { |
|
541 |
+ this.set[key] = true; |
|
542 |
+ }; |
|
543 |
+ Set.prototype.clear = function clear () { |
|
544 |
+ this.set = Object.create(null); |
|
545 |
+ }; |
|
546 |
+ |
|
547 |
+ return Set; |
|
548 |
+ }()); |
|
549 |
+} |
|
550 |
+ |
|
551 |
+var warn = noop; |
|
552 |
+var tip = noop; |
|
553 |
+var formatComponentName; |
|
554 |
+ |
|
555 |
+{ |
|
556 |
+ var hasConsole = typeof console !== 'undefined'; |
|
557 |
+ var classifyRE = /(?:^|[-_])(\w)/g; |
|
558 |
+ var classify = function (str) { return str |
|
559 |
+ .replace(classifyRE, function (c) { return c.toUpperCase(); }) |
|
560 |
+ .replace(/[-_]/g, ''); }; |
|
561 |
+ |
|
562 |
+ warn = function (msg, vm) { |
|
563 |
+ if (hasConsole && (!config.silent)) { |
|
564 |
+ console.error("[Vue warn]: " + msg + " " + ( |
|
565 |
+ vm ? formatLocation(formatComponentName(vm)) : '' |
|
566 |
+ )); |
|
567 |
+ } |
|
568 |
+ }; |
|
569 |
+ |
|
570 |
+ tip = function (msg, vm) { |
|
571 |
+ if (hasConsole && (!config.silent)) { |
|
572 |
+ console.warn("[Vue tip]: " + msg + " " + ( |
|
573 |
+ vm ? formatLocation(formatComponentName(vm)) : '' |
|
574 |
+ )); |
|
575 |
+ } |
|
576 |
+ }; |
|
577 |
+ |
|
578 |
+ formatComponentName = function (vm, includeFile) { |
|
579 |
+ if (vm.$root === vm) { |
|
580 |
+ return '<Root>' |
|
581 |
+ } |
|
582 |
+ var name = typeof vm === 'string' |
|
583 |
+ ? vm |
|
584 |
+ : typeof vm === 'function' && vm.options |
|
585 |
+ ? vm.options.name |
|
586 |
+ : vm._isVue |
|
587 |
+ ? vm.$options.name || vm.$options._componentTag |
|
588 |
+ : vm.name; |
|
589 |
+ |
|
590 |
+ var file = vm._isVue && vm.$options.__file; |
|
591 |
+ if (!name && file) { |
|
592 |
+ var match = file.match(/([^/\\]+)\.vue$/); |
|
593 |
+ name = match && match[1]; |
|
594 |
+ } |
|
595 |
+ |
|
596 |
+ return ( |
|
597 |
+ (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") + |
|
598 |
+ (file && includeFile !== false ? (" at " + file) : '') |
|
599 |
+ ) |
|
600 |
+ }; |
|
601 |
+ |
|
602 |
+ var formatLocation = function (str) { |
|
603 |
+ if (str === "<Anonymous>") { |
|
604 |
+ str += " - use the \"name\" option for better debugging messages."; |
|
605 |
+ } |
|
606 |
+ return ("\n(found in " + str + ")") |
|
607 |
+ }; |
|
608 |
+} |
|
609 |
+ |
|
610 |
+/* */ |
|
611 |
+ |
|
612 |
+ |
|
613 |
+var uid$1 = 0; |
|
614 |
+ |
|
615 |
+/** |
|
616 |
+ * A dep is an observable that can have multiple |
|
617 |
+ * directives subscribing to it. |
|
618 |
+ */ |
|
619 |
+var Dep = function Dep () { |
|
620 |
+ this.id = uid$1++; |
|
621 |
+ this.subs = []; |
|
622 |
+}; |
|
623 |
+ |
|
624 |
+Dep.prototype.addSub = function addSub (sub) { |
|
625 |
+ this.subs.push(sub); |
|
626 |
+}; |
|
627 |
+ |
|
628 |
+Dep.prototype.removeSub = function removeSub (sub) { |
|
629 |
+ remove(this.subs, sub); |
|
630 |
+}; |
|
631 |
+ |
|
632 |
+Dep.prototype.depend = function depend () { |
|
633 |
+ if (Dep.target) { |
|
634 |
+ Dep.target.addDep(this); |
|
635 |
+ } |
|
636 |
+}; |
|
637 |
+ |
|
638 |
+Dep.prototype.notify = function notify () { |
|
639 |
+ // stabilize the subscriber list first |
|
640 |
+ var subs = this.subs.slice(); |
|
641 |
+ for (var i = 0, l = subs.length; i < l; i++) { |
|
642 |
+ subs[i].update(); |
|
643 |
+ } |
|
644 |
+}; |
|
645 |
+ |
|
646 |
+// the current target watcher being evaluated. |
|
647 |
+// this is globally unique because there could be only one |
|
648 |
+// watcher being evaluated at any time. |
|
649 |
+Dep.target = null; |
|
650 |
+var targetStack = []; |
|
651 |
+ |
|
652 |
+function pushTarget (_target) { |
|
653 |
+ if (Dep.target) { targetStack.push(Dep.target); } |
|
654 |
+ Dep.target = _target; |
|
655 |
+} |
|
656 |
+ |
|
657 |
+function popTarget () { |
|
658 |
+ Dep.target = targetStack.pop(); |
|
659 |
+} |
|
660 |
+ |
|
661 |
+/* |
|
662 |
+ * not type checking this file because flow doesn't play well with |
|
663 |
+ * dynamically accessing methods on Array prototype |
|
664 |
+ */ |
|
665 |
+ |
|
666 |
+var arrayProto = Array.prototype; |
|
667 |
+var arrayMethods = Object.create(arrayProto);[ |
|
668 |
+ 'push', |
|
669 |
+ 'pop', |
|
670 |
+ 'shift', |
|
671 |
+ 'unshift', |
|
672 |
+ 'splice', |
|
673 |
+ 'sort', |
|
674 |
+ 'reverse' |
|
675 |
+] |
|
676 |
+.forEach(function (method) { |
|
677 |
+ // cache original method |
|
678 |
+ var original = arrayProto[method]; |
|
679 |
+ def(arrayMethods, method, function mutator () { |
|
680 |
+ var arguments$1 = arguments; |
|
681 |
+ |
|
682 |
+ // avoid leaking arguments: |
|
683 |
+ // http://jsperf.com/closure-with-arguments |
|
684 |
+ var i = arguments.length; |
|
685 |
+ var args = new Array(i); |
|
686 |
+ while (i--) { |
|
687 |
+ args[i] = arguments$1[i]; |
|
688 |
+ } |
|
689 |
+ var result = original.apply(this, args); |
|
690 |
+ var ob = this.__ob__; |
|
691 |
+ var inserted; |
|
692 |
+ switch (method) { |
|
693 |
+ case 'push': |
|
694 |
+ inserted = args; |
|
695 |
+ break |
|
696 |
+ case 'unshift': |
|
697 |
+ inserted = args; |
|
698 |
+ break |
|
699 |
+ case 'splice': |
|
700 |
+ inserted = args.slice(2); |
|
701 |
+ break |
|
702 |
+ } |
|
703 |
+ if (inserted) { ob.observeArray(inserted); } |
|
704 |
+ // notify change |
|
705 |
+ ob.dep.notify(); |
|
706 |
+ return result |
|
707 |
+ }); |
|
708 |
+}); |
|
709 |
+ |
|
710 |
+/* */ |
|
711 |
+ |
|
712 |
+var arrayKeys = Object.getOwnPropertyNames(arrayMethods); |
|
713 |
+ |
|
714 |
+/** |
|
715 |
+ * By default, when a reactive property is set, the new value is |
|
716 |
+ * also converted to become reactive. However when passing down props, |
|
717 |
+ * we don't want to force conversion because the value may be a nested value |
|
718 |
+ * under a frozen data structure. Converting it would defeat the optimization. |
|
719 |
+ */ |
|
720 |
+var observerState = { |
|
721 |
+ shouldConvert: true, |
|
722 |
+ isSettingProps: false |
|
723 |
+}; |
|
724 |
+ |
|
725 |
+/** |
|
726 |
+ * Observer class that are attached to each observed |
|
727 |
+ * object. Once attached, the observer converts target |
|
728 |
+ * object's property keys into getter/setters that |
|
729 |
+ * collect dependencies and dispatches updates. |
|
730 |
+ */ |
|
731 |
+var Observer = function Observer (value) { |
|
732 |
+ this.value = value; |
|
733 |
+ this.dep = new Dep(); |
|
734 |
+ this.vmCount = 0; |
|
735 |
+ def(value, '__ob__', this); |
|
736 |
+ if (Array.isArray(value)) { |
|
737 |
+ var augment = hasProto |
|
738 |
+ ? protoAugment |
|
739 |
+ : copyAugment; |
|
740 |
+ augment(value, arrayMethods, arrayKeys); |
|
741 |
+ this.observeArray(value); |
|
742 |
+ } else { |
|
743 |
+ this.walk(value); |
|
744 |
+ } |
|
745 |
+}; |
|
746 |
+ |
|
747 |
+/** |
|
748 |
+ * Walk through each property and convert them into |
|
749 |
+ * getter/setters. This method should only be called when |
|
750 |
+ * value type is Object. |
|
751 |
+ */ |
|
752 |
+Observer.prototype.walk = function walk (obj) { |
|
753 |
+ var keys = Object.keys(obj); |
|
754 |
+ for (var i = 0; i < keys.length; i++) { |
|
755 |
+ defineReactive$$1(obj, keys[i], obj[keys[i]]); |
|
756 |
+ } |
|
757 |
+}; |
|
758 |
+ |
|
759 |
+/** |
|
760 |
+ * Observe a list of Array items. |
|
761 |
+ */ |
|
762 |
+Observer.prototype.observeArray = function observeArray (items) { |
|
763 |
+ for (var i = 0, l = items.length; i < l; i++) { |
|
764 |
+ observe(items[i]); |
|
765 |
+ } |
|
766 |
+}; |
|
767 |
+ |
|
768 |
+// helpers |
|
769 |
+ |
|
770 |
+/** |
|
771 |
+ * Augment an target Object or Array by intercepting |
|
772 |
+ * the prototype chain using __proto__ |
|
773 |
+ */ |
|
774 |
+function protoAugment (target, src) { |
|
775 |
+ /* eslint-disable no-proto */ |
|
776 |
+ target.__proto__ = src; |
|
777 |
+ /* eslint-enable no-proto */ |
|
778 |
+} |
|
779 |
+ |
|
780 |
+/** |
|
781 |
+ * Augment an target Object or Array by defining |
|
782 |
+ * hidden properties. |
|
783 |
+ */ |
|
784 |
+/* istanbul ignore next */ |
|
785 |
+function copyAugment (target, src, keys) { |
|
786 |
+ for (var i = 0, l = keys.length; i < l; i++) { |
|
787 |
+ var key = keys[i]; |
|
788 |
+ def(target, key, src[key]); |
|
789 |
+ } |
|
790 |
+} |
|
791 |
+ |
|
792 |
+/** |
|
793 |
+ * Attempt to create an observer instance for a value, |
|
794 |
+ * returns the new observer if successfully observed, |
|
795 |
+ * or the existing observer if the value already has one. |
|
796 |
+ */ |
|
797 |
+function observe (value, asRootData) { |
|
798 |
+ if (!isObject(value)) { |
|
799 |
+ return |
|
800 |
+ } |
|
801 |
+ var ob; |
|
802 |
+ if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { |
|
803 |
+ ob = value.__ob__; |
|
804 |
+ } else if ( |
|
805 |
+ observerState.shouldConvert && |
|
806 |
+ !isServerRendering() && |
|
807 |
+ (Array.isArray(value) || isPlainObject(value)) && |
|
808 |
+ Object.isExtensible(value) && |
|
809 |
+ !value._isVue |
|
810 |
+ ) { |
|
811 |
+ ob = new Observer(value); |
|
812 |
+ } |
|
813 |
+ if (asRootData && ob) { |
|
814 |
+ ob.vmCount++; |
|
815 |
+ } |
|
816 |
+ return ob |
|
817 |
+} |
|
818 |
+ |
|
819 |
+/** |
|
820 |
+ * Define a reactive property on an Object. |
|
821 |
+ */ |
|
822 |
+function defineReactive$$1 ( |
|
823 |
+ obj, |
|
824 |
+ key, |
|
825 |
+ val, |
|
826 |
+ customSetter |
|
827 |
+) { |
|
828 |
+ var dep = new Dep(); |
|
829 |
+ |
|
830 |
+ var property = Object.getOwnPropertyDescriptor(obj, key); |
|
831 |
+ if (property && property.configurable === false) { |
|
832 |
+ return |
|
833 |
+ } |
|
834 |
+ |
|
835 |
+ // cater for pre-defined getter/setters |
|
836 |
+ var getter = property && property.get; |
|
837 |
+ var setter = property && property.set; |
|
838 |
+ |
|
839 |
+ var childOb = observe(val); |
|
840 |
+ Object.defineProperty(obj, key, { |
|
841 |
+ enumerable: true, |
|
842 |
+ configurable: true, |
|
843 |
+ get: function reactiveGetter () { |
|
844 |
+ var value = getter ? getter.call(obj) : val; |
|
845 |
+ if (Dep.target) { |
|
846 |
+ dep.depend(); |
|
847 |
+ if (childOb) { |
|
848 |
+ childOb.dep.depend(); |
|
849 |
+ } |
|
850 |
+ if (Array.isArray(value)) { |
|
851 |
+ dependArray(value); |
|
852 |
+ } |
|
853 |
+ } |
|
854 |
+ return value |
|
855 |
+ }, |
|
856 |
+ set: function reactiveSetter (newVal) { |
|
857 |
+ var value = getter ? getter.call(obj) : val; |
|
858 |
+ /* eslint-disable no-self-compare */ |
|
859 |
+ if (newVal === value || (newVal !== newVal && value !== value)) { |
|
860 |
+ return |
|
861 |
+ } |
|
862 |
+ /* eslint-enable no-self-compare */ |
|
863 |
+ if ("development" !== 'production' && customSetter) { |
|
864 |
+ customSetter(); |
|
865 |
+ } |
|
866 |
+ if (setter) { |
|
867 |
+ setter.call(obj, newVal); |
|
868 |
+ } else { |
|
869 |
+ val = newVal; |
|
870 |
+ } |
|
871 |
+ childOb = observe(newVal); |
|
872 |
+ dep.notify(); |
|
873 |
+ } |
|
874 |
+ }); |
|
875 |
+} |
|
876 |
+ |
|
877 |
+/** |
|
878 |
+ * Set a property on an object. Adds the new property and |
|
879 |
+ * triggers change notification if the property doesn't |
|
880 |
+ * already exist. |
|
881 |
+ */ |
|
882 |
+function set (target, key, val) { |
|
883 |
+ if (Array.isArray(target) && typeof key === 'number') { |
|
884 |
+ target.length = Math.max(target.length, key); |
|
885 |
+ target.splice(key, 1, val); |
|
886 |
+ return val |
|
887 |
+ } |
|
888 |
+ if (hasOwn(target, key)) { |
|
889 |
+ target[key] = val; |
|
890 |
+ return val |
|
891 |
+ } |
|
892 |
+ var ob = (target ).__ob__; |
|
893 |
+ if (target._isVue || (ob && ob.vmCount)) { |
|
894 |
+ "development" !== 'production' && warn( |
|
895 |
+ 'Avoid adding reactive properties to a Vue instance or its root $data ' + |
|
896 |
+ 'at runtime - declare it upfront in the data option.' |
|
897 |
+ ); |
|
898 |
+ return val |
|
899 |
+ } |
|
900 |
+ if (!ob) { |
|
901 |
+ target[key] = val; |
|
902 |
+ return val |
|
903 |
+ } |
|
904 |
+ defineReactive$$1(ob.value, key, val); |
|
905 |
+ ob.dep.notify(); |
|
906 |
+ return val |
|
907 |
+} |
|
908 |
+ |
|
909 |
+/** |
|
910 |
+ * Delete a property and trigger change if necessary. |
|
911 |
+ */ |
|
912 |
+function del (target, key) { |
|
913 |
+ if (Array.isArray(target) && typeof key === 'number') { |
|
914 |
+ target.splice(key, 1); |
|
915 |
+ return |
|
916 |
+ } |
|
917 |
+ var ob = (target ).__ob__; |
|
918 |
+ if (target._isVue || (ob && ob.vmCount)) { |
|
919 |
+ "development" !== 'production' && warn( |
|
920 |
+ 'Avoid deleting properties on a Vue instance or its root $data ' + |
|
921 |
+ '- just set it to null.' |
|
922 |
+ ); |
|
923 |
+ return |
|
924 |
+ } |
|
925 |
+ if (!hasOwn(target, key)) { |
|
926 |
+ return |
|
927 |
+ } |
|
928 |
+ delete target[key]; |
|
929 |
+ if (!ob) { |
|
930 |
+ return |
|
931 |
+ } |
|
932 |
+ ob.dep.notify(); |
|
933 |
+} |
|
934 |
+ |
|
935 |
+/** |
|
936 |
+ * Collect dependencies on array elements when the array is touched, since |
|
937 |
+ * we cannot intercept array element access like property getters. |
|
938 |
+ */ |
|
939 |
+function dependArray (value) { |
|
940 |
+ for (var e = (void 0), i = 0, l = value.length; i < l; i++) { |
|
941 |
+ e = value[i]; |
|
942 |
+ e && e.__ob__ && e.__ob__.dep.depend(); |
|
943 |
+ if (Array.isArray(e)) { |
|
944 |
+ dependArray(e); |
|
945 |
+ } |
|
946 |
+ } |
|
947 |
+} |
|
948 |
+ |
|
949 |
+/* */ |
|
950 |
+ |
|
951 |
+/** |
|
952 |
+ * Option overwriting strategies are functions that handle |
|
953 |
+ * how to merge a parent option value and a child option |
|
954 |
+ * value into the final value. |
|
955 |
+ */ |
|
956 |
+var strats = config.optionMergeStrategies; |
|
957 |
+ |
|
958 |
+/** |
|
959 |
+ * Options with restrictions |
|
960 |
+ */ |
|
961 |
+{ |
|
962 |
+ strats.el = strats.propsData = function (parent, child, vm, key) { |
|
963 |
+ if (!vm) { |
|
964 |
+ warn( |
|
965 |
+ "option \"" + key + "\" can only be used during instance " + |
|
966 |
+ 'creation with the `new` keyword.' |
|
967 |
+ ); |
|
968 |
+ } |
|
969 |
+ return defaultStrat(parent, child) |
|
970 |
+ }; |
|
971 |
+} |
|
972 |
+ |
|
973 |
+/** |
|
974 |
+ * Helper that recursively merges two data objects together. |
|
975 |
+ */ |
|
976 |
+function mergeData (to, from) { |
|
977 |
+ if (!from) { return to } |
|
978 |
+ var key, toVal, fromVal; |
|
979 |
+ var keys = Object.keys(from); |
|
980 |
+ for (var i = 0; i < keys.length; i++) { |
|
981 |
+ key = keys[i]; |
|
982 |
+ toVal = to[key]; |
|
983 |
+ fromVal = from[key]; |
|
984 |
+ if (!hasOwn(to, key)) { |
|
985 |
+ set(to, key, fromVal); |
|
986 |
+ } else if (isPlainObject(toVal) && isPlainObject(fromVal)) { |
|
987 |
+ mergeData(toVal, fromVal); |
|
988 |
+ } |
|
989 |
+ } |
|
990 |
+ return to |
|
991 |
+} |
|
992 |
+ |
|
993 |
+/** |
|
994 |
+ * Data |
|
995 |
+ */ |
|
996 |
+strats.data = function ( |
|
997 |
+ parentVal, |
|
998 |
+ childVal, |
|
999 |
+ vm |
|
1000 |
+) { |
|
1001 |
+ if (!vm) { |
|
1002 |
+ // in a Vue.extend merge, both should be functions |
|
1003 |
+ if (!childVal) { |
|
1004 |
+ return parentVal |
|
1005 |
+ } |
|
1006 |
+ if (typeof childVal !== 'function') { |
|
1007 |
+ "development" !== 'production' && warn( |
|
1008 |
+ 'The "data" option should be a function ' + |
|
1009 |
+ 'that returns a per-instance value in component ' + |
|
1010 |
+ 'definitions.', |
|
1011 |
+ vm |
|
1012 |
+ ); |
|
1013 |
+ return parentVal |
|
1014 |
+ } |
|
1015 |
+ if (!parentVal) { |
|
1016 |
+ return childVal |
|
1017 |
+ } |
|
1018 |
+ // when parentVal & childVal are both present, |
|
1019 |
+ // we need to return a function that returns the |
|
1020 |
+ // merged result of both functions... no need to |
|
1021 |
+ // check if parentVal is a function here because |
|
1022 |
+ // it has to be a function to pass previous merges. |
|
1023 |
+ return function mergedDataFn () { |
|
1024 |
+ return mergeData( |
|
1025 |
+ childVal.call(this), |
|
1026 |
+ parentVal.call(this) |
|
1027 |
+ ) |
|
1028 |
+ } |
|
1029 |
+ } else if (parentVal || childVal) { |
|
1030 |
+ return function mergedInstanceDataFn () { |
|
1031 |
+ // instance merge |
|
1032 |
+ var instanceData = typeof childVal === 'function' |
|
1033 |
+ ? childVal.call(vm) |
|
1034 |
+ : childVal; |
|
1035 |
+ var defaultData = typeof parentVal === 'function' |
|
1036 |
+ ? parentVal.call(vm) |
|
1037 |
+ : undefined; |
|
1038 |
+ if (instanceData) { |
|
1039 |
+ return mergeData(instanceData, defaultData) |
|
1040 |
+ } else { |
|
1041 |
+ return defaultData |
|
1042 |
+ } |
|
1043 |
+ } |
|
1044 |
+ } |
|
1045 |
+}; |
|
1046 |
+ |
|
1047 |
+/** |
|
1048 |
+ * Hooks and props are merged as arrays. |
|
1049 |
+ */ |
|
1050 |
+function mergeHook ( |
|
1051 |
+ parentVal, |
|
1052 |
+ childVal |
|
1053 |
+) { |
|
1054 |
+ return childVal |
|
1055 |
+ ? parentVal |
|
1056 |
+ ? parentVal.concat(childVal) |
|
1057 |
+ : Array.isArray(childVal) |
|
1058 |
+ ? childVal |
|
1059 |
+ : [childVal] |
|
1060 |
+ : parentVal |
|
1061 |
+} |
|
1062 |
+ |
|
1063 |
+config._lifecycleHooks.forEach(function (hook) { |
|
1064 |
+ strats[hook] = mergeHook; |
|
1065 |
+}); |
|
1066 |
+ |
|
1067 |
+/** |
|
1068 |
+ * Assets |
|
1069 |
+ * |
|
1070 |
+ * When a vm is present (instance creation), we need to do |
|
1071 |
+ * a three-way merge between constructor options, instance |
|
1072 |
+ * options and parent options. |
|
1073 |
+ */ |
|
1074 |
+function mergeAssets (parentVal, childVal) { |
|
1075 |
+ var res = Object.create(parentVal || null); |
|
1076 |
+ return childVal |
|
1077 |
+ ? extend(res, childVal) |
|
1078 |
+ : res |
|
1079 |
+} |
|
1080 |
+ |
|
1081 |
+config._assetTypes.forEach(function (type) { |
|
1082 |
+ strats[type + 's'] = mergeAssets; |
|
1083 |
+}); |
|
1084 |
+ |
|
1085 |
+/** |
|
1086 |
+ * Watchers. |
|
1087 |
+ * |
|
1088 |
+ * Watchers hashes should not overwrite one |
|
1089 |
+ * another, so we merge them as arrays. |
|
1090 |
+ */ |
|
1091 |
+strats.watch = function (parentVal, childVal) { |
|
1092 |
+ /* istanbul ignore if */ |
|
1093 |
+ if (!childVal) { return Object.create(parentVal || null) } |
|
1094 |
+ if (!parentVal) { return childVal } |
|
1095 |
+ var ret = {}; |
|
1096 |
+ extend(ret, parentVal); |
|
1097 |
+ for (var key in childVal) { |
|
1098 |
+ var parent = ret[key]; |
|
1099 |
+ var child = childVal[key]; |
|
1100 |
+ if (parent && !Array.isArray(parent)) { |
|
1101 |
+ parent = [parent]; |
|
1102 |
+ } |
|
1103 |
+ ret[key] = parent |
|
1104 |
+ ? parent.concat(child) |
|
1105 |
+ : [child]; |
|
1106 |
+ } |
|
1107 |
+ return ret |
|
1108 |
+}; |
|
1109 |
+ |
|
1110 |
+/** |
|
1111 |
+ * Other object hashes. |
|
1112 |
+ */ |
|
1113 |
+strats.props = |
|
1114 |
+strats.methods = |
|
1115 |
+strats.computed = function (parentVal, childVal) { |
|
1116 |
+ if (!childVal) { return Object.create(parentVal || null) } |
|
1117 |
+ if (!parentVal) { return childVal } |
|
1118 |
+ var ret = Object.create(null); |
|
1119 |
+ extend(ret, parentVal); |
|
1120 |
+ extend(ret, childVal); |
|
1121 |
+ return ret |
|
1122 |
+}; |
|
1123 |
+ |
|
1124 |
+/** |
|
1125 |
+ * Default strategy. |
|
1126 |
+ */ |
|
1127 |
+var defaultStrat = function (parentVal, childVal) { |
|
1128 |
+ return childVal === undefined |
|
1129 |
+ ? parentVal |
|
1130 |
+ : childVal |
|
1131 |
+}; |
|
1132 |
+ |
|
1133 |
+/** |
|
1134 |
+ * Validate component names |
|
1135 |
+ */ |
|
1136 |
+function checkComponents (options) { |
|
1137 |
+ for (var key in options.components) { |
|
1138 |
+ var lower = key.toLowerCase(); |
|
1139 |
+ if (isBuiltInTag(lower) || config.isReservedTag(lower)) { |
|
1140 |
+ warn( |
|
1141 |
+ 'Do not use built-in or reserved HTML elements as component ' + |
|
1142 |
+ 'id: ' + key |
|
1143 |
+ ); |
|
1144 |
+ } |
|
1145 |
+ } |
|
1146 |
+} |
|
1147 |
+ |
|
1148 |
+/** |
|
1149 |
+ * Ensure all props option syntax are normalized into the |
|
1150 |
+ * Object-based format. |
|
1151 |
+ */ |
|
1152 |
+function normalizeProps (options) { |
|
1153 |
+ var props = options.props; |
|
1154 |
+ if (!props) { return } |
|
1155 |
+ var res = {}; |
|
1156 |
+ var i, val, name; |
|
1157 |
+ if (Array.isArray(props)) { |
|
1158 |
+ i = props.length; |
|
1159 |
+ while (i--) { |
|
1160 |
+ val = props[i]; |
|
1161 |
+ if (typeof val === 'string') { |
|
1162 |
+ name = camelize(val); |
|
1163 |
+ res[name] = { type: null }; |
|
1164 |
+ } else { |
|
1165 |
+ warn('props must be strings when using array syntax.'); |
|
1166 |
+ } |
|
1167 |
+ } |
|
1168 |
+ } else if (isPlainObject(props)) { |
|
1169 |
+ for (var key in props) { |
|
1170 |
+ val = props[key]; |
|
1171 |
+ name = camelize(key); |
|
1172 |
+ res[name] = isPlainObject(val) |
|
1173 |
+ ? val |
|
1174 |
+ : { type: val }; |
|
1175 |
+ } |
|
1176 |
+ } |
|
1177 |
+ options.props = res; |
|
1178 |
+} |
|
1179 |
+ |
|
1180 |
+/** |
|
1181 |
+ * Normalize raw function directives into object format. |
|
1182 |
+ */ |
|
1183 |
+function normalizeDirectives (options) { |
|
1184 |
+ var dirs = options.directives; |
|
1185 |
+ if (dirs) { |
|
1186 |
+ for (var key in dirs) { |
|
1187 |
+ var def = dirs[key]; |
|
1188 |
+ if (typeof def === 'function') { |
|
1189 |
+ dirs[key] = { bind: def, update: def }; |
|
1190 |
+ } |
|
1191 |
+ } |
|
1192 |
+ } |
|
1193 |
+} |
|
1194 |
+ |
|
1195 |
+/** |
|
1196 |
+ * Merge two option objects into a new one. |
|
1197 |
+ * Core utility used in both instantiation and inheritance. |
|
1198 |
+ */ |
|
1199 |
+function mergeOptions ( |
|
1200 |
+ parent, |
|
1201 |
+ child, |
|
1202 |
+ vm |
|
1203 |
+) { |
|
1204 |
+ { |
|
1205 |
+ checkComponents(child); |
|
1206 |
+ } |
|
1207 |
+ normalizeProps(child); |
|
1208 |
+ normalizeDirectives(child); |
|
1209 |
+ var extendsFrom = child.extends; |
|
1210 |
+ if (extendsFrom) { |
|
1211 |
+ parent = typeof extendsFrom === 'function' |
|
1212 |
+ ? mergeOptions(parent, extendsFrom.options, vm) |
|
1213 |
+ : mergeOptions(parent, extendsFrom, vm); |
|
1214 |
+ } |
|
1215 |
+ if (child.mixins) { |
|
1216 |
+ for (var i = 0, l = child.mixins.length; i < l; i++) { |
|
1217 |
+ var mixin = child.mixins[i]; |
|
1218 |
+ if (mixin.prototype instanceof Vue$3) { |
|
1219 |
+ mixin = mixin.options; |
|
1220 |
+ } |
|
1221 |
+ parent = mergeOptions(parent, mixin, vm); |
|
1222 |
+ } |
|
1223 |
+ } |
|
1224 |
+ var options = {}; |
|
1225 |
+ var key; |
|
1226 |
+ for (key in parent) { |
|
1227 |
+ mergeField(key); |
|
1228 |
+ } |
|
1229 |
+ for (key in child) { |
|
1230 |
+ if (!hasOwn(parent, key)) { |
|
1231 |
+ mergeField(key); |
|
1232 |
+ } |
|
1233 |
+ } |
|
1234 |
+ function mergeField (key) { |
|
1235 |
+ var strat = strats[key] || defaultStrat; |
|
1236 |
+ options[key] = strat(parent[key], child[key], vm, key); |
|
1237 |
+ } |
|
1238 |
+ return options |
|
1239 |
+} |
|
1240 |
+ |
|
1241 |
+/** |
|
1242 |
+ * Resolve an asset. |
|
1243 |
+ * This function is used because child instances need access |
|
1244 |
+ * to assets defined in its ancestor chain. |
|
1245 |
+ */ |
|
1246 |
+function resolveAsset ( |
|
1247 |
+ options, |
|
1248 |
+ type, |
|
1249 |
+ id, |
|
1250 |
+ warnMissing |
|
1251 |
+) { |
|
1252 |
+ /* istanbul ignore if */ |
|
1253 |
+ if (typeof id !== 'string') { |
|
1254 |
+ return |
|
1255 |
+ } |
|
1256 |
+ var assets = options[type]; |
|
1257 |
+ // check local registration variations first |
|
1258 |
+ if (hasOwn(assets, id)) { return assets[id] } |
|
1259 |
+ var camelizedId = camelize(id); |
|
1260 |
+ if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } |
|
1261 |
+ var PascalCaseId = capitalize(camelizedId); |
|
1262 |
+ if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } |
|
1263 |
+ // fallback to prototype chain |
|
1264 |
+ var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; |
|
1265 |
+ if ("development" !== 'production' && warnMissing && !res) { |
|
1266 |
+ warn( |
|
1267 |
+ 'Failed to resolve ' + type.slice(0, -1) + ': ' + id, |
|
1268 |
+ options |
|
1269 |
+ ); |
|
1270 |
+ } |
|
1271 |
+ return res |
|
1272 |
+} |
|
1273 |
+ |
|
1274 |
+/* */ |
|
1275 |
+ |
|
1276 |
+function validateProp ( |
|
1277 |
+ key, |
|
1278 |
+ propOptions, |
|
1279 |
+ propsData, |
|
1280 |
+ vm |
|
1281 |
+) { |
|
1282 |
+ var prop = propOptions[key]; |
|
1283 |
+ var absent = !hasOwn(propsData, key); |
|
1284 |
+ var value = propsData[key]; |
|
1285 |
+ // handle boolean props |
|
1286 |
+ if (isType(Boolean, prop.type)) { |
|
1287 |
+ if (absent && !hasOwn(prop, 'default')) { |
|
1288 |
+ value = false; |
|
1289 |
+ } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) { |
|
1290 |
+ value = true; |
|
1291 |
+ } |
|
1292 |
+ } |
|
1293 |
+ // check default value |
|
1294 |
+ if (value === undefined) { |
|
1295 |
+ value = getPropDefaultValue(vm, prop, key); |
|
1296 |
+ // since the default value is a fresh copy, |
|
1297 |
+ // make sure to observe it. |
|
1298 |
+ var prevShouldConvert = observerState.shouldConvert; |
|
1299 |
+ observerState.shouldConvert = true; |
|
1300 |
+ observe(value); |
|
1301 |
+ observerState.shouldConvert = prevShouldConvert; |
|
1302 |
+ } |
|
1303 |
+ { |
|
1304 |
+ assertProp(prop, key, value, vm, absent); |
|
1305 |
+ } |
|
1306 |
+ return value |
|
1307 |
+} |
|
1308 |
+ |
|
1309 |
+/** |
|
1310 |
+ * Get the default value of a prop. |
|
1311 |
+ */ |
|
1312 |
+function getPropDefaultValue (vm, prop, key) { |
|
1313 |
+ // no default, return undefined |
|
1314 |
+ if (!hasOwn(prop, 'default')) { |
|
1315 |
+ return undefined |
|
1316 |
+ } |
|
1317 |
+ var def = prop.default; |
|
1318 |
+ // warn against non-factory defaults for Object & Array |
|
1319 |
+ if ("development" !== 'production' && isObject(def)) { |
|
1320 |
+ warn( |
|
1321 |
+ 'Invalid default value for prop "' + key + '": ' + |
|
1322 |
+ 'Props with type Object/Array must use a factory function ' + |
|
1323 |
+ 'to return the default value.', |
|
1324 |
+ vm |
|
1325 |
+ ); |
|
1326 |
+ } |
|
1327 |
+ // the raw prop value was also undefined from previous render, |
|
1328 |
+ // return previous default value to avoid unnecessary watcher trigger |
|
1329 |
+ if (vm && vm.$options.propsData && |
|
1330 |
+ vm.$options.propsData[key] === undefined && |
|
1331 |
+ vm._props[key] !== undefined) { |
|
1332 |
+ return vm._props[key] |
|
1333 |
+ } |
|
1334 |
+ // call factory function for non-Function types |
|
1335 |
+ // a value is Function if its prototype is function even across different execution context |
|
1336 |
+ return typeof def === 'function' && getType(prop.type) !== 'Function' |
|
1337 |
+ ? def.call(vm) |
|
1338 |
+ : def |
|
1339 |
+} |
|
1340 |
+ |
|
1341 |
+/** |
|
1342 |
+ * Assert whether a prop is valid. |
|
1343 |
+ */ |
|
1344 |
+function assertProp ( |
|
1345 |
+ prop, |
|
1346 |
+ name, |
|
1347 |
+ value, |
|
1348 |
+ vm, |
|
1349 |
+ absent |
|
1350 |
+) { |
|
1351 |
+ if (prop.required && absent) { |
|
1352 |
+ warn( |
|
1353 |
+ 'Missing required prop: "' + name + '"', |
|
1354 |
+ vm |
|
1355 |
+ ); |
|
1356 |
+ return |
|
1357 |
+ } |
|
1358 |
+ if (value == null && !prop.required) { |
|
1359 |
+ return |
|
1360 |
+ } |
|
1361 |
+ var type = prop.type; |
|
1362 |
+ var valid = !type || type === true; |
|
1363 |
+ var expectedTypes = []; |
|
1364 |
+ if (type) { |
|
1365 |
+ if (!Array.isArray(type)) { |
|
1366 |
+ type = [type]; |
|
1367 |
+ } |
|
1368 |
+ for (var i = 0; i < type.length && !valid; i++) { |
|
1369 |
+ var assertedType = assertType(value, type[i]); |
|
1370 |
+ expectedTypes.push(assertedType.expectedType || ''); |
|
1371 |
+ valid = assertedType.valid; |
|
1372 |
+ } |
|
1373 |
+ } |
|
1374 |
+ if (!valid) { |
|
1375 |
+ warn( |
|
1376 |
+ 'Invalid prop: type check failed for prop "' + name + '".' + |
|
1377 |
+ ' Expected ' + expectedTypes.map(capitalize).join(', ') + |
|
1378 |
+ ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.', |
|
1379 |
+ vm |
|
1380 |
+ ); |
|
1381 |
+ return |
|
1382 |
+ } |
|
1383 |
+ var validator = prop.validator; |
|
1384 |
+ if (validator) { |
|
1385 |
+ if (!validator(value)) { |
|
1386 |
+ warn( |
|
1387 |
+ 'Invalid prop: custom validator check failed for prop "' + name + '".', |
|
1388 |
+ vm |
|
1389 |
+ ); |
|
1390 |
+ } |
|
1391 |
+ } |
|
1392 |
+} |
|
1393 |
+ |
|
1394 |
+/** |
|
1395 |
+ * Assert the type of a value |
|
1396 |
+ */ |
|
1397 |
+function assertType (value, type) { |
|
1398 |
+ var valid; |
|
1399 |
+ var expectedType = getType(type); |
|
1400 |
+ if (expectedType === 'String') { |
|
1401 |
+ valid = typeof value === (expectedType = 'string'); |
|
1402 |
+ } else if (expectedType === 'Number') { |
|
1403 |
+ valid = typeof value === (expectedType = 'number'); |
|
1404 |
+ } else if (expectedType === 'Boolean') { |
|
1405 |
+ valid = typeof value === (expectedType = 'boolean'); |
|
1406 |
+ } else if (expectedType === 'Function') { |
|
1407 |
+ valid = typeof value === (expectedType = 'function'); |
|
1408 |
+ } else if (expectedType === 'Object') { |
|
1409 |
+ valid = isPlainObject(value); |
|
1410 |
+ } else if (expectedType === 'Array') { |
|
1411 |
+ valid = Array.isArray(value); |
|
1412 |
+ } else { |
|
1413 |
+ valid = value instanceof type; |
|
1414 |
+ } |
|
1415 |
+ return { |
|
1416 |
+ valid: valid, |
|
1417 |
+ expectedType: expectedType |
|
1418 |
+ } |
|
1419 |
+} |
|
1420 |
+ |
|
1421 |
+/** |
|
1422 |
+ * Use function string name to check built-in types, |
|
1423 |
+ * because a simple equality check will fail when running |
|
1424 |
+ * across different vms / iframes. |
|
1425 |
+ */ |
|
1426 |
+function getType (fn) { |
|
1427 |
+ var match = fn && fn.toString().match(/^\s*function (\w+)/); |
|
1428 |
+ return match && match[1] |
|
1429 |
+} |
|
1430 |
+ |
|
1431 |
+function isType (type, fn) { |
|
1432 |
+ if (!Array.isArray(fn)) { |
|
1433 |
+ return getType(fn) === getType(type) |
|
1434 |
+ } |
|
1435 |
+ for (var i = 0, len = fn.length; i < len; i++) { |
|
1436 |
+ if (getType(fn[i]) === getType(type)) { |
|
1437 |
+ return true |
|
1438 |
+ } |
|
1439 |
+ } |
|
1440 |
+ /* istanbul ignore next */ |
|
1441 |
+ return false |
|
1442 |
+} |
|
1443 |
+ |
|
1444 |
+function handleError (err, vm, info) { |
|
1445 |
+ if (config.errorHandler) { |
|
1446 |
+ config.errorHandler.call(null, err, vm, info); |
|
1447 |
+ } else { |
|
1448 |
+ { |
|
1449 |
+ warn(("Error in " + info + ":"), vm); |
|
1450 |
+ } |
|
1451 |
+ /* istanbul ignore else */ |
|
1452 |
+ if (inBrowser && typeof console !== 'undefined') { |
|
1453 |
+ console.error(err); |
|
1454 |
+ } else { |
|
1455 |
+ throw err |
|
1456 |
+ } |
|
1457 |
+ } |
|
1458 |
+} |
|
1459 |
+ |
|
1460 |
+/* not type checking this file because flow doesn't play well with Proxy */ |
|
1461 |
+ |
|
1462 |
+var initProxy; |
|
1463 |
+ |
|
1464 |
+{ |
|
1465 |
+ var allowedGlobals = makeMap( |
|
1466 |
+ 'Infinity,undefined,NaN,isFinite,isNaN,' + |
|
1467 |
+ 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + |
|
1468 |
+ 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + |
|
1469 |
+ 'require' // for Webpack/Browserify |
|
1470 |
+ ); |
|
1471 |
+ |
|
1472 |
+ var warnNonPresent = function (target, key) { |
|
1473 |
+ warn( |
|
1474 |
+ "Property or method \"" + key + "\" is not defined on the instance but " + |
|
1475 |
+ "referenced during render. Make sure to declare reactive data " + |
|
1476 |
+ "properties in the data option.", |
|
1477 |
+ target |
|
1478 |
+ ); |
|
1479 |
+ }; |
|
1480 |
+ |
|
1481 |
+ var hasProxy = |
|
1482 |
+ typeof Proxy !== 'undefined' && |
|
1483 |
+ Proxy.toString().match(/native code/); |
|
1484 |
+ |
|
1485 |
+ if (hasProxy) { |
|
1486 |
+ var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta'); |
|
1487 |
+ config.keyCodes = new Proxy(config.keyCodes, { |
|
1488 |
+ set: function set (target, key, value) { |
|
1489 |
+ if (isBuiltInModifier(key)) { |
|
1490 |
+ warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); |
|
1491 |
+ return false |
|
1492 |
+ } else { |
|
1493 |
+ target[key] = value; |
|
1494 |
+ return true |
|
1495 |
+ } |
|
1496 |
+ } |
|
1497 |
+ }); |
|
1498 |
+ } |
|
1499 |
+ |
|
1500 |
+ var hasHandler = { |
|
1501 |
+ has: function has (target, key) { |
|
1502 |
+ var has = key in target; |
|
1503 |
+ var isAllowed = allowedGlobals(key) || key.charAt(0) === '_'; |
|
1504 |
+ if (!has && !isAllowed) { |
|
1505 |
+ warnNonPresent(target, key); |
|
1506 |
+ } |
|
1507 |
+ return has || !isAllowed |
|
1508 |
+ } |
|
1509 |
+ }; |
|
1510 |
+ |
|
1511 |
+ var getHandler = { |
|
1512 |
+ get: function get (target, key) { |
|
1513 |
+ if (typeof key === 'string' && !(key in target)) { |
|
1514 |
+ warnNonPresent(target, key); |
|
1515 |
+ } |
|
1516 |
+ return target[key] |
|
1517 |
+ } |
|
1518 |
+ }; |
|
1519 |
+ |
|
1520 |
+ initProxy = function initProxy (vm) { |
|
1521 |
+ if (hasProxy) { |
|
1522 |
+ // determine which proxy handler to use |
|
1523 |
+ var options = vm.$options; |
|
1524 |
+ var handlers = options.render && options.render._withStripped |
|
1525 |
+ ? getHandler |
|
1526 |
+ : hasHandler; |
|
1527 |
+ vm._renderProxy = new Proxy(vm, handlers); |
|
1528 |
+ } else { |
|
1529 |
+ vm._renderProxy = vm; |
|
1530 |
+ } |
|
1531 |
+ }; |
|
1532 |
+} |
|
1533 |
+ |
|
1534 |
+var mark; |
|
1535 |
+var measure; |
|
1536 |
+ |
|
1537 |
+{ |
|
1538 |
+ var perf = inBrowser && window.performance; |
|
1539 |
+ /* istanbul ignore if */ |
|
1540 |
+ if ( |
|
1541 |
+ perf && |
|
1542 |
+ perf.mark && |
|
1543 |
+ perf.measure && |
|
1544 |
+ perf.clearMarks && |
|
1545 |
+ perf.clearMeasures |
|
1546 |
+ ) { |
|
1547 |
+ mark = function (tag) { return perf.mark(tag); }; |
|
1548 |
+ measure = function (name, startTag, endTag) { |
|
1549 |
+ perf.measure(name, startTag, endTag); |
|
1550 |
+ perf.clearMarks(startTag); |
|
1551 |
+ perf.clearMarks(endTag); |
|
1552 |
+ perf.clearMeasures(name); |
|
1553 |
+ }; |
|
1554 |
+ } |
|
1555 |
+} |
|
1556 |
+ |
|
1557 |
+/* */ |
|
1558 |
+ |
|
1559 |
+var VNode = function VNode ( |
|
1560 |
+ tag, |
|
1561 |
+ data, |
|
1562 |
+ children, |
|
1563 |
+ text, |
|
1564 |
+ elm, |
|
1565 |
+ context, |
|
1566 |
+ componentOptions |
|
1567 |
+) { |
|
1568 |
+ this.tag = tag; |
|
1569 |
+ this.data = data; |
|
1570 |
+ this.children = children; |
|
1571 |
+ this.text = text; |
|
1572 |
+ this.elm = elm; |
|
1573 |
+ this.ns = undefined; |
|
1574 |
+ this.context = context; |
|
1575 |
+ this.functionalContext = undefined; |
|
1576 |
+ this.key = data && data.key; |
|
1577 |
+ this.componentOptions = componentOptions; |
|
1578 |
+ this.componentInstance = undefined; |
|
1579 |
+ this.parent = undefined; |
|
1580 |
+ this.raw = false; |
|
1581 |
+ this.isStatic = false; |
|
1582 |
+ this.isRootInsert = true; |
|
1583 |
+ this.isComment = false; |
|
1584 |
+ this.isCloned = false; |
|
1585 |
+ this.isOnce = false; |
|
1586 |
+}; |
|
1587 |
+ |
|
1588 |
+var prototypeAccessors = { child: {} }; |
|
1589 |
+ |
|
1590 |
+// DEPRECATED: alias for componentInstance for backwards compat. |
|
1591 |
+/* istanbul ignore next */ |
|
1592 |
+prototypeAccessors.child.get = function () { |
|
1593 |
+ return this.componentInstance |
|
1594 |
+}; |
|
1595 |
+ |
|
1596 |
+Object.defineProperties( VNode.prototype, prototypeAccessors ); |
|
1597 |
+ |
|
1598 |
+var createEmptyVNode = function () { |
|
1599 |
+ var node = new VNode(); |
|
1600 |
+ node.text = ''; |
|
1601 |
+ node.isComment = true; |
|
1602 |
+ return node |
|
1603 |
+}; |
|
1604 |
+ |
|
1605 |
+function createTextVNode (val) { |
|
1606 |
+ return new VNode(undefined, undefined, undefined, String(val)) |
|
1607 |
+} |
|
1608 |
+ |
|
1609 |
+// optimized shallow clone |
|
1610 |
+// used for static nodes and slot nodes because they may be reused across |
|
1611 |
+// multiple renders, cloning them avoids errors when DOM manipulations rely |
|
1612 |
+// on their elm reference. |
|
1613 |
+function cloneVNode (vnode) { |
|
1614 |
+ var cloned = new VNode( |
|
1615 |
+ vnode.tag, |
|
1616 |
+ vnode.data, |
|
1617 |
+ vnode.children, |
|
1618 |
+ vnode.text, |
|
1619 |
+ vnode.elm, |
|
1620 |
+ vnode.context, |
|
1621 |
+ vnode.componentOptions |
|
1622 |
+ ); |
|
1623 |
+ cloned.ns = vnode.ns; |
|
1624 |
+ cloned.isStatic = vnode.isStatic; |
|
1625 |
+ cloned.key = vnode.key; |
|
1626 |
+ cloned.isCloned = true; |
|
1627 |
+ return cloned |
|
1628 |
+} |
|
1629 |
+ |
|
1630 |
+function cloneVNodes (vnodes) { |
|
1631 |
+ var len = vnodes.length; |
|
1632 |
+ var res = new Array(len); |
|
1633 |
+ for (var i = 0; i < len; i++) { |
|
1634 |
+ res[i] = cloneVNode(vnodes[i]); |
|
1635 |
+ } |
|
1636 |
+ return res |
|
1637 |
+} |
|
1638 |
+ |
|
1639 |
+/* */ |
|
1640 |
+ |
|
1641 |
+var normalizeEvent = cached(function (name) { |
|
1642 |
+ var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first |
|
1643 |
+ name = once$$1 ? name.slice(1) : name; |
|
1644 |
+ var capture = name.charAt(0) === '!'; |
|
1645 |
+ name = capture ? name.slice(1) : name; |
|
1646 |
+ return { |
|
1647 |
+ name: name, |
|
1648 |
+ once: once$$1, |
|
1649 |
+ capture: capture |
|
1650 |
+ } |
|
1651 |
+}); |
|
1652 |
+ |
|
1653 |
+function createFnInvoker (fns) { |
|
1654 |
+ function invoker () { |
|
1655 |
+ var arguments$1 = arguments; |
|
1656 |
+ |
|
1657 |
+ var fns = invoker.fns; |
|
1658 |
+ if (Array.isArray(fns)) { |
|
1659 |
+ for (var i = 0; i < fns.length; i++) { |
|
1660 |
+ fns[i].apply(null, arguments$1); |
|
1661 |
+ } |
|
1662 |
+ } else { |
|
1663 |
+ // return handler return value for single handlers |
|
1664 |
+ return fns.apply(null, arguments) |
|
1665 |
+ } |
|
1666 |
+ } |
|
1667 |
+ invoker.fns = fns; |
|
1668 |
+ return invoker |
|
1669 |
+} |
|
1670 |
+ |
|
1671 |
+function updateListeners ( |
|
1672 |
+ on, |
|
1673 |
+ oldOn, |
|
1674 |
+ add, |
|
1675 |
+ remove$$1, |
|
1676 |
+ vm |
|
1677 |
+) { |
|
1678 |
+ var name, cur, old, event; |
|
1679 |
+ for (name in on) { |
|
1680 |
+ cur = on[name]; |
|
1681 |
+ old = oldOn[name]; |
|
1682 |
+ event = normalizeEvent(name); |
|
1683 |
+ if (!cur) { |
|
1684 |
+ "development" !== 'production' && warn( |
|
1685 |
+ "Invalid handler for event \"" + (event.name) + "\": got " + String(cur), |
|
1686 |
+ vm |
|
1687 |
+ ); |
|
1688 |
+ } else if (!old) { |
|
1689 |
+ if (!cur.fns) { |
|
1690 |
+ cur = on[name] = createFnInvoker(cur); |
|
1691 |
+ } |
|
1692 |
+ add(event.name, cur, event.once, event.capture); |
|
1693 |
+ } else if (cur !== old) { |
|
1694 |
+ old.fns = cur; |
|
1695 |
+ on[name] = old; |
|
1696 |
+ } |
|
1697 |
+ } |
|
1698 |
+ for (name in oldOn) { |
|
1699 |
+ if (!on[name]) { |
|
1700 |
+ event = normalizeEvent(name); |
|
1701 |
+ remove$$1(event.name, oldOn[name], event.capture); |
|
1702 |
+ } |
|
1703 |
+ } |
|
1704 |
+} |
|
1705 |
+ |
|
1706 |
+/* */ |
|
1707 |
+ |
|
1708 |
+function mergeVNodeHook (def, hookKey, hook) { |
|
1709 |
+ var invoker; |
|
1710 |
+ var oldHook = def[hookKey]; |
|
1711 |
+ |
|
1712 |
+ function wrappedHook () { |
|
1713 |
+ hook.apply(this, arguments); |
|
1714 |
+ // important: remove merged hook to ensure it's called only once |
|
1715 |
+ // and prevent memory leak |
|
1716 |
+ remove(invoker.fns, wrappedHook); |
|
1717 |
+ } |
|
1718 |
+ |
|
1719 |
+ if (!oldHook) { |
|
1720 |
+ // no existing hook |
|
1721 |
+ invoker = createFnInvoker([wrappedHook]); |
|
1722 |
+ } else { |
|
1723 |
+ /* istanbul ignore if */ |
|
1724 |
+ if (oldHook.fns && oldHook.merged) { |
|
1725 |
+ // already a merged invoker |
|
1726 |
+ invoker = oldHook; |
|
1727 |
+ invoker.fns.push(wrappedHook); |
|
1728 |
+ } else { |
|
1729 |
+ // existing plain hook |
|
1730 |
+ invoker = createFnInvoker([oldHook, wrappedHook]); |
|
1731 |
+ } |
|
1732 |
+ } |
|
1733 |
+ |
|
1734 |
+ invoker.merged = true; |
|
1735 |
+ def[hookKey] = invoker; |
|
1736 |
+} |
|
1737 |
+ |
|
1738 |
+/* */ |
|
1739 |
+ |
|
1740 |
+// The template compiler attempts to minimize the need for normalization by |
|
1741 |
+// statically analyzing the template at compile time. |
|
1742 |
+// |
|
1743 |
+// For plain HTML markup, normalization can be completely skipped because the |
|
1744 |
+// generated render function is guaranteed to return Array<VNode>. There are |
|
1745 |
+// two cases where extra normalization is needed: |
|
1746 |
+ |
|
1747 |
+// 1. When the children contains components - because a functional component |
|
1748 |
+// may return an Array instead of a single root. In this case, just a simple |
|
1749 |
+// normalization is needed - if any child is an Array, we flatten the whole |
|
1750 |
+// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep |
|
1751 |
+// because functional components already normalize their own children. |
|
1752 |
+function simpleNormalizeChildren (children) { |
|
1753 |
+ for (var i = 0; i < children.length; i++) { |
|
1754 |
+ if (Array.isArray(children[i])) { |
|
1755 |
+ return Array.prototype.concat.apply([], children) |
|
1756 |
+ } |
|
1757 |
+ } |
|
1758 |
+ return children |
|
1759 |
+} |
|
1760 |
+ |
|
1761 |
+// 2. When the children contains constructs that always generated nested Arrays, |
|
1762 |
+// e.g. <template>, <slot>, v-for, or when the children is provided by user |
|
1763 |
+// with hand-written render functions / JSX. In such cases a full normalization |
|
1764 |
+// is needed to cater to all possible types of children values. |
|
1765 |
+function normalizeChildren (children) { |
|
1766 |
+ return isPrimitive(children) |
|
1767 |
+ ? [createTextVNode(children)] |
|
1768 |
+ : Array.isArray(children) |
|
1769 |
+ ? normalizeArrayChildren(children) |
|
1770 |
+ : undefined |
|
1771 |
+} |
|
1772 |
+ |
|
1773 |
+function normalizeArrayChildren (children, nestedIndex) { |
|
1774 |
+ var res = []; |
|
1775 |
+ var i, c, last; |
|
1776 |
+ for (i = 0; i < children.length; i++) { |
|
1777 |
+ c = children[i]; |
|
1778 |
+ if (c == null || typeof c === 'boolean') { continue } |
|
1779 |
+ last = res[res.length - 1]; |
|
1780 |
+ // nested |
|
1781 |
+ if (Array.isArray(c)) { |
|
1782 |
+ res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i))); |
|
1783 |
+ } else if (isPrimitive(c)) { |
|
1784 |
+ if (last && last.text) { |
|
1785 |
+ last.text += String(c); |
|
1786 |
+ } else if (c !== '') { |
|
1787 |
+ // convert primitive to vnode |
|
1788 |
+ res.push(createTextVNode(c)); |
|
1789 |
+ } |
|
1790 |
+ } else { |
|
1791 |
+ if (c.text && last && last.text) { |
|
1792 |
+ res[res.length - 1] = createTextVNode(last.text + c.text); |
|
1793 |
+ } else { |
|
1794 |
+ // default key for nested array children (likely generated by v-for) |
|
1795 |
+ if (c.tag && c.key == null && nestedIndex != null) { |
|
1796 |
+ c.key = "__vlist" + nestedIndex + "_" + i + "__"; |
|
1797 |
+ } |
|
1798 |
+ res.push(c); |
|
1799 |
+ } |
|
1800 |
+ } |
|
1801 |
+ } |
|
1802 |
+ return res |
|
1803 |
+} |
|
1804 |
+ |
|
1805 |
+/* */ |
|
1806 |
+ |
|
1807 |
+function getFirstComponentChild (children) { |
|
1808 |
+ return children && children.filter(function (c) { return c && c.componentOptions; })[0] |
|
1809 |
+} |
|
1810 |
+ |
|
1811 |
+/* */ |
|
1812 |
+ |
|
1813 |
+function initEvents (vm) { |
|
1814 |
+ vm._events = Object.create(null); |
|
1815 |
+ vm._hasHookEvent = false; |
|
1816 |
+ // init parent attached events |
|
1817 |
+ var listeners = vm.$options._parentListeners; |
|
1818 |
+ if (listeners) { |
|
1819 |
+ updateComponentListeners(vm, listeners); |
|
1820 |
+ } |
|
1821 |
+} |
|
1822 |
+ |
|
1823 |
+var target; |
|
1824 |
+ |
|
1825 |
+function add (event, fn, once$$1) { |
|
1826 |
+ if (once$$1) { |
|
1827 |
+ target.$once(event, fn); |
|
1828 |
+ } else { |
|
1829 |
+ target.$on(event, fn); |
|
1830 |
+ } |
|
1831 |
+} |
|
1832 |
+ |
|
1833 |
+function remove$1 (event, fn) { |
|
1834 |
+ target.$off(event, fn); |
|
1835 |
+} |
|
1836 |
+ |
|
1837 |
+function updateComponentListeners ( |
|
1838 |
+ vm, |
|
1839 |
+ listeners, |
|
1840 |
+ oldListeners |
|
1841 |
+) { |
|
1842 |
+ target = vm; |
|
1843 |
+ updateListeners(listeners, oldListeners || {}, add, remove$1, vm); |
|
1844 |
+} |
|
1845 |
+ |
|
1846 |
+function eventsMixin (Vue) { |
|
1847 |
+ var hookRE = /^hook:/; |
|
1848 |
+ Vue.prototype.$on = function (event, fn) { |
|
1849 |
+ var this$1 = this; |
|
1850 |
+ |
|
1851 |
+ var vm = this; |
|
1852 |
+ if (Array.isArray(event)) { |
|
1853 |
+ for (var i = 0, l = event.length; i < l; i++) { |
|
1854 |
+ this$1.$on(event[i], fn); |
|
1855 |
+ } |
|
1856 |
+ } else { |
|
1857 |
+ (vm._events[event] || (vm._events[event] = [])).push(fn); |
|
1858 |
+ // optimize hook:event cost by using a boolean flag marked at registration |
|
1859 |
+ // instead of a hash lookup |
|
1860 |
+ if (hookRE.test(event)) { |
|
1861 |
+ vm._hasHookEvent = true; |
|
1862 |
+ } |
|
1863 |
+ } |
|
1864 |
+ return vm |
|
1865 |
+ }; |
|
1866 |
+ |
|
1867 |
+ Vue.prototype.$once = function (event, fn) { |
|
1868 |
+ var vm = this; |
|
1869 |
+ function on () { |
|
1870 |
+ vm.$off(event, on); |
|
1871 |
+ fn.apply(vm, arguments); |
|
1872 |
+ } |
|
1873 |
+ on.fn = fn; |
|
1874 |
+ vm.$on(event, on); |
|
1875 |
+ return vm |
|
1876 |
+ }; |
|
1877 |
+ |
|
1878 |
+ Vue.prototype.$off = function (event, fn) { |
|
1879 |
+ var this$1 = this; |
|
1880 |
+ |
|
1881 |
+ var vm = this; |
|
1882 |
+ // all |
|
1883 |
+ if (!arguments.length) { |
|
1884 |
+ vm._events = Object.create(null); |
|
1885 |
+ return vm |
|
1886 |
+ } |
|
1887 |
+ // array of events |
|
1888 |
+ if (Array.isArray(event)) { |
|
1889 |
+ for (var i$1 = 0, l = event.length; i$1 < l; i$1++) { |
|
1890 |
+ this$1.$off(event[i$1], fn); |
|
1891 |
+ } |
|
1892 |
+ return vm |
|
1893 |
+ } |
|
1894 |
+ // specific event |
|
1895 |
+ var cbs = vm._events[event]; |
|
1896 |
+ if (!cbs) { |
|
1897 |
+ return vm |
|
1898 |
+ } |
|
1899 |
+ if (arguments.length === 1) { |
|
1900 |
+ vm._events[event] = null; |
|
1901 |
+ return vm |
|
1902 |
+ } |
|
1903 |
+ // specific handler |
|
1904 |
+ var cb; |
|
1905 |
+ var i = cbs.length; |
|
1906 |
+ while (i--) { |
|
1907 |
+ cb = cbs[i]; |
|
1908 |
+ if (cb === fn || cb.fn === fn) { |
|
1909 |
+ cbs.splice(i, 1); |
|
1910 |
+ break |
|
1911 |
+ } |
|
1912 |
+ } |
|
1913 |
+ return vm |
|
1914 |
+ }; |
|
1915 |
+ |
|
1916 |
+ Vue.prototype.$emit = function (event) { |
|
1917 |
+ var vm = this; |
|
1918 |
+ { |
|
1919 |
+ var lowerCaseEvent = event.toLowerCase(); |
|
1920 |
+ if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) { |
|
1921 |
+ tip( |
|
1922 |
+ "Event \"" + lowerCaseEvent + "\" is emitted in component " + |
|
1923 |
+ (formatComponentName(vm)) + " but the handler is registered for \"" + event + "\". " + |
|
1924 |
+ "Note that HTML attributes are case-insensitive and you cannot use " + |
|
1925 |
+ "v-on to listen to camelCase events when using in-DOM templates. " + |
|
1926 |
+ "You should probably use \"" + (hyphenate(event)) + "\" instead of \"" + event + "\"." |
|
1927 |
+ ); |
|
1928 |
+ } |
|
1929 |
+ } |
|
1930 |
+ var cbs = vm._events[event]; |
|
1931 |
+ if (cbs) { |
|
1932 |
+ cbs = cbs.length > 1 ? toArray(cbs) : cbs; |
|
1933 |
+ var args = toArray(arguments, 1); |
|
1934 |
+ for (var i = 0, l = cbs.length; i < l; i++) { |
|
1935 |
+ cbs[i].apply(vm, args); |
|
1936 |
+ } |
|
1937 |
+ } |
|
1938 |
+ return vm |
|
1939 |
+ }; |
|
1940 |
+} |
|
1941 |
+ |
|
1942 |
+/* */ |
|
1943 |
+ |
|
1944 |
+/** |
|
1945 |
+ * Runtime helper for resolving raw children VNodes into a slot object. |
|
1946 |
+ */ |
|
1947 |
+function resolveSlots ( |
|
1948 |
+ children, |
|
1949 |
+ context |
|
1950 |
+) { |
|
1951 |
+ var slots = {}; |
|
1952 |
+ if (!children) { |
|
1953 |
+ return slots |
|
1954 |
+ } |
|
1955 |
+ var defaultSlot = []; |
|
1956 |
+ var name, child; |
|
1957 |
+ for (var i = 0, l = children.length; i < l; i++) { |
|
1958 |
+ child = children[i]; |
|
1959 |
+ // named slots should only be respected if the vnode was rendered in the |
|
1960 |
+ // same context. |
|
1961 |
+ if ((child.context === context || child.functionalContext === context) && |
|
1962 |
+ child.data && (name = child.data.slot)) { |
|
1963 |
+ var slot = (slots[name] || (slots[name] = [])); |
|
1964 |
+ if (child.tag === 'template') { |
|
1965 |
+ slot.push.apply(slot, child.children); |
|
1966 |
+ } else { |
|
1967 |
+ slot.push(child); |
|
1968 |
+ } |
|
1969 |
+ } else { |
|
1970 |
+ defaultSlot.push(child); |
|
1971 |
+ } |
|
1972 |
+ } |
|
1973 |
+ // ignore whitespace |
|
1974 |
+ if (!defaultSlot.every(isWhitespace)) { |
|
1975 |
+ slots.default = defaultSlot; |
|
1976 |
+ } |
|
1977 |
+ return slots |
|
1978 |
+} |
|
1979 |
+ |
|
1980 |
+function isWhitespace (node) { |
|
1981 |
+ return node.isComment || node.text === ' ' |
|
1982 |
+} |
|
1983 |
+ |
|
1984 |
+function resolveScopedSlots ( |
|
1985 |
+ fns |
|
1986 |
+) { |
|
1987 |
+ var res = {}; |
|
1988 |
+ for (var i = 0; i < fns.length; i++) { |
|
1989 |
+ res[fns[i][0]] = fns[i][1]; |
|
1990 |
+ } |
|
1991 |
+ return res |
|
1992 |
+} |
|
1993 |
+ |
|
1994 |
+/* */ |
|
1995 |
+ |
|
1996 |
+var activeInstance = null; |
|
1997 |
+ |
|
1998 |
+function initLifecycle (vm) { |
|
1999 |
+ var options = vm.$options; |
|
2000 |
+ |
|
2001 |
+ // locate first non-abstract parent |
|
2002 |
+ var parent = options.parent; |
|
2003 |
+ if (parent && !options.abstract) { |
|
2004 |
+ while (parent.$options.abstract && parent.$parent) { |
|
2005 |
+ parent = parent.$parent; |
|
2006 |
+ } |
|
2007 |
+ parent.$children.push(vm); |
|
2008 |
+ } |
|
2009 |
+ |
|
2010 |
+ vm.$parent = parent; |
|
2011 |
+ vm.$root = parent ? parent.$root : vm; |
|
2012 |
+ |
|
2013 |
+ vm.$children = []; |
|
2014 |
+ vm.$refs = {}; |
|
2015 |
+ |
|
2016 |
+ vm._watcher = null; |
|
2017 |
+ vm._inactive = null; |
|
2018 |
+ vm._directInactive = false; |
|
2019 |
+ vm._isMounted = false; |
|
2020 |
+ vm._isDestroyed = false; |
|
2021 |
+ vm._isBeingDestroyed = false; |
|
2022 |
+} |
|
2023 |
+ |
|
2024 |
+function lifecycleMixin (Vue) { |
|
2025 |
+ Vue.prototype._update = function (vnode, hydrating) { |
|
2026 |
+ var vm = this; |
|
2027 |
+ if (vm._isMounted) { |
|
2028 |
+ callHook(vm, 'beforeUpdate'); |
|
2029 |
+ } |
|
2030 |
+ var prevEl = vm.$el; |
|
2031 |
+ var prevVnode = vm._vnode; |
|
2032 |
+ var prevActiveInstance = activeInstance; |
|
2033 |
+ activeInstance = vm; |
|
2034 |
+ vm._vnode = vnode; |
|
2035 |
+ // Vue.prototype.__patch__ is injected in entry points |
|
2036 |
+ // based on the rendering backend used. |
|
2037 |
+ if (!prevVnode) { |
|
2038 |
+ // initial render |
|
2039 |
+ vm.$el = vm.__patch__( |
|
2040 |
+ vm.$el, vnode, hydrating, false /* removeOnly */, |
|
2041 |
+ vm.$options._parentElm, |
|
2042 |
+ vm.$options._refElm |
|
2043 |
+ ); |
|
2044 |
+ } else { |
|
2045 |
+ // updates |
|
2046 |
+ vm.$el = vm.__patch__(prevVnode, vnode); |
|
2047 |
+ } |
|
2048 |
+ activeInstance = prevActiveInstance; |
|
2049 |
+ // update __vue__ reference |
|
2050 |
+ if (prevEl) { |
|
2051 |
+ prevEl.__vue__ = null; |
|
2052 |
+ } |
|
2053 |
+ if (vm.$el) { |
|
2054 |
+ vm.$el.__vue__ = vm; |
|
2055 |
+ } |
|
2056 |
+ // if parent is an HOC, update its $el as well |
|
2057 |
+ if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { |
|
2058 |
+ vm.$parent.$el = vm.$el; |
|
2059 |
+ } |
|
2060 |
+ // updated hook is called by the scheduler to ensure that children are |
|
2061 |
+ // updated in a parent's updated hook. |
|
2062 |
+ }; |
|
2063 |
+ |
|
2064 |
+ Vue.prototype.$forceUpdate = function () { |
|
2065 |
+ var vm = this; |
|
2066 |
+ if (vm._watcher) { |
|
2067 |
+ vm._watcher.update(); |
|
2068 |
+ } |
|
2069 |
+ }; |
|
2070 |
+ |
|
2071 |
+ Vue.prototype.$destroy = function () { |
|
2072 |
+ var vm = this; |
|
2073 |
+ if (vm._isBeingDestroyed) { |
|
2074 |
+ return |
|
2075 |
+ } |
|
2076 |
+ callHook(vm, 'beforeDestroy'); |
|
2077 |
+ vm._isBeingDestroyed = true; |
|
2078 |
+ // remove self from parent |
|
2079 |
+ var parent = vm.$parent; |
|
2080 |
+ if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { |
|
2081 |
+ remove(parent.$children, vm); |
|
2082 |
+ } |
|
2083 |
+ // teardown watchers |
|
2084 |
+ if (vm._watcher) { |
|
2085 |
+ vm._watcher.teardown(); |
|
2086 |
+ } |
|
2087 |
+ var i = vm._watchers.length; |
|
2088 |
+ while (i--) { |
|
2089 |
+ vm._watchers[i].teardown(); |
|
2090 |
+ } |
|
2091 |
+ // remove reference from data ob |
|
2092 |
+ // frozen object may not have observer. |
|
2093 |
+ if (vm._data.__ob__) { |
|
2094 |
+ vm._data.__ob__.vmCount--; |
|
2095 |
+ } |
|
2096 |
+ // call the last hook... |
|
2097 |
+ vm._isDestroyed = true; |
|
2098 |
+ // invoke destroy hooks on current rendered tree |
|
2099 |
+ vm.__patch__(vm._vnode, null); |
|
2100 |
+ // fire destroyed hook |
|
2101 |
+ callHook(vm, 'destroyed'); |
|
2102 |
+ // turn off all instance listeners. |
|
2103 |
+ vm.$off(); |
|
2104 |
+ // remove __vue__ reference |
|
2105 |
+ if (vm.$el) { |
|
2106 |
+ vm.$el.__vue__ = null; |
|
2107 |
+ } |
|
2108 |
+ // remove reference to DOM nodes (prevents leak) |
|
2109 |
+ vm.$options._parentElm = vm.$options._refElm = null; |
|
2110 |
+ }; |
|
2111 |
+} |
|
2112 |
+ |
|
2113 |
+function mountComponent ( |
|
2114 |
+ vm, |
|
2115 |
+ el, |
|
2116 |
+ hydrating |
|
2117 |
+) { |
|
2118 |
+ vm.$el = el; |
|
2119 |
+ if (!vm.$options.render) { |
|
2120 |
+ vm.$options.render = createEmptyVNode; |
|
2121 |
+ { |
|
2122 |
+ /* istanbul ignore if */ |
|
2123 |
+ if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') || |
|
2124 |
+ vm.$options.el || el) { |
|
2125 |
+ warn( |
|
2126 |
+ 'You are using the runtime-only build of Vue where the template ' + |
|
2127 |
+ 'compiler is not available. Either pre-compile the templates into ' + |
|
2128 |
+ 'render functions, or use the compiler-included build.', |
|
2129 |
+ vm |
|
2130 |
+ ); |
|
2131 |
+ } else { |
|
2132 |
+ warn( |
|
2133 |
+ 'Failed to mount component: template or render function not defined.', |
|
2134 |
+ vm |
|
2135 |
+ ); |
|
2136 |
+ } |
|
2137 |
+ } |
|
2138 |
+ } |
|
2139 |
+ callHook(vm, 'beforeMount'); |
|
2140 |
+ |
|
2141 |
+ var updateComponent; |
|
2142 |
+ /* istanbul ignore if */ |
|
2143 |
+ if ("development" !== 'production' && config.performance && mark) { |
|
2144 |
+ updateComponent = function () { |
|
2145 |
+ var name = vm._name; |
|
2146 |
+ var id = vm._uid; |
|
2147 |
+ var startTag = "vue-perf-start:" + id; |
|
2148 |
+ var endTag = "vue-perf-end:" + id; |
|
2149 |
+ |
|
2150 |
+ mark(startTag); |
|
2151 |
+ var vnode = vm._render(); |
|
2152 |
+ mark(endTag); |
|
2153 |
+ measure((name + " render"), startTag, endTag); |
|
2154 |
+ |
|
2155 |
+ mark(startTag); |
|
2156 |
+ vm._update(vnode, hydrating); |
|
2157 |
+ mark(endTag); |
|
2158 |
+ measure((name + " patch"), startTag, endTag); |
|
2159 |
+ }; |
|
2160 |
+ } else { |
|
2161 |
+ updateComponent = function () { |
|
2162 |
+ vm._update(vm._render(), hydrating); |
|
2163 |
+ }; |
|
2164 |
+ } |
|
2165 |
+ |
|
2166 |
+ vm._watcher = new Watcher(vm, updateComponent, noop); |
|
2167 |
+ hydrating = false; |
|
2168 |
+ |
|
2169 |
+ // manually mounted instance, call mounted on self |
|
2170 |
+ // mounted is called for render-created child components in its inserted hook |
|
2171 |
+ if (vm.$vnode == null) { |
|
2172 |
+ vm._isMounted = true; |
|
2173 |
+ callHook(vm, 'mounted'); |
|
2174 |
+ } |
|
2175 |
+ return vm |
|
2176 |
+} |
|
2177 |
+ |
|
2178 |
+function updateChildComponent ( |
|
2179 |
+ vm, |
|
2180 |
+ propsData, |
|
2181 |
+ listeners, |
|
2182 |
+ parentVnode, |
|
2183 |
+ renderChildren |
|
2184 |
+) { |
|
2185 |
+ // determine whether component has slot children |
|
2186 |
+ // we need to do this before overwriting $options._renderChildren |
|
2187 |
+ var hasChildren = !!( |
|
2188 |
+ renderChildren || // has new static slots |
|
2189 |
+ vm.$options._renderChildren || // has old static slots |
|
2190 |
+ parentVnode.data.scopedSlots || // has new scoped slots |
|
2191 |
+ vm.$scopedSlots !== emptyObject // has old scoped slots |
|
2192 |
+ ); |
|
2193 |
+ |
|
2194 |
+ vm.$options._parentVnode = parentVnode; |
|
2195 |
+ vm.$vnode = parentVnode; // update vm's placeholder node without re-render |
|
2196 |
+ if (vm._vnode) { // update child tree's parent |
|
2197 |
+ vm._vnode.parent = parentVnode; |
|
2198 |
+ } |
|
2199 |
+ vm.$options._renderChildren = renderChildren; |
|
2200 |
+ |
|
2201 |
+ // update props |
|
2202 |
+ if (propsData && vm.$options.props) { |
|
2203 |
+ observerState.shouldConvert = false; |
|
2204 |
+ { |
|
2205 |
+ observerState.isSettingProps = true; |
|
2206 |
+ } |
|
2207 |
+ var props = vm._props; |
|
2208 |
+ var propKeys = vm.$options._propKeys || []; |
|
2209 |
+ for (var i = 0; i < propKeys.length; i++) { |
|
2210 |
+ var key = propKeys[i]; |
|
2211 |
+ props[key] = validateProp(key, vm.$options.props, propsData, vm); |
|
2212 |
+ } |
|
2213 |
+ observerState.shouldConvert = true; |
|
2214 |
+ { |
|
2215 |
+ observerState.isSettingProps = false; |
|
2216 |
+ } |
|
2217 |
+ // keep a copy of raw propsData |
|
2218 |
+ vm.$options.propsData = propsData; |
|
2219 |
+ } |
|
2220 |
+ // update listeners |
|
2221 |
+ if (listeners) { |
|
2222 |
+ var oldListeners = vm.$options._parentListeners; |
|
2223 |
+ vm.$options._parentListeners = listeners; |
|
2224 |
+ updateComponentListeners(vm, listeners, oldListeners); |
|
2225 |
+ } |
|
2226 |
+ // resolve slots + force update if has children |
|
2227 |
+ if (hasChildren) { |
|
2228 |
+ vm.$slots = resolveSlots(renderChildren, parentVnode.context); |
|
2229 |
+ vm.$forceUpdate(); |
|
2230 |
+ } |
|
2231 |
+} |
|
2232 |
+ |
|
2233 |
+function isInInactiveTree (vm) { |
|
2234 |
+ while (vm && (vm = vm.$parent)) { |
|
2235 |
+ if (vm._inactive) { return true } |
|
2236 |
+ } |
|
2237 |
+ return false |
|
2238 |
+} |
|
2239 |
+ |
|
2240 |
+function activateChildComponent (vm, direct) { |
|
2241 |
+ if (direct) { |
|
2242 |
+ vm._directInactive = false; |
|
2243 |
+ if (isInInactiveTree(vm)) { |
|
2244 |
+ return |
|
2245 |
+ } |
|
2246 |
+ } else if (vm._directInactive) { |
|
2247 |
+ return |
|
2248 |
+ } |
|
2249 |
+ if (vm._inactive || vm._inactive == null) { |
|
2250 |
+ vm._inactive = false; |
|
2251 |
+ for (var i = 0; i < vm.$children.length; i++) { |
|
2252 |
+ activateChildComponent(vm.$children[i]); |
|
2253 |
+ } |
|
2254 |
+ callHook(vm, 'activated'); |
|
2255 |
+ } |
|
2256 |
+} |
|
2257 |
+ |
|
2258 |
+function deactivateChildComponent (vm, direct) { |
|
2259 |
+ if (direct) { |
|
2260 |
+ vm._directInactive = true; |
|
2261 |
+ if (isInInactiveTree(vm)) { |
|
2262 |
+ return |
|
2263 |
+ } |
|
2264 |
+ } |
|
2265 |
+ if (!vm._inactive) { |
|
2266 |
+ vm._inactive = true; |
|
2267 |
+ for (var i = 0; i < vm.$children.length; i++) { |
|
2268 |
+ deactivateChildComponent(vm.$children[i]); |
|
2269 |
+ } |
|
2270 |
+ callHook(vm, 'deactivated'); |
|
2271 |
+ } |
|
2272 |
+} |
|
2273 |
+ |
|
2274 |
+function callHook (vm, hook) { |
|
2275 |
+ var handlers = vm.$options[hook]; |
|
2276 |
+ if (handlers) { |
|
2277 |
+ for (var i = 0, j = handlers.length; i < j; i++) { |
|
2278 |
+ try { |
|
2279 |
+ handlers[i].call(vm); |
|
2280 |
+ } catch (e) { |
|
2281 |
+ handleError(e, vm, (hook + " hook")); |
|
2282 |
+ } |
|
2283 |
+ } |
|
2284 |
+ } |
|
2285 |
+ if (vm._hasHookEvent) { |
|
2286 |
+ vm.$emit('hook:' + hook); |
|
2287 |
+ } |
|
2288 |
+} |
|
2289 |
+ |
|
2290 |
+/* */ |
|
2291 |
+ |
|
2292 |
+ |
|
2293 |
+var queue = []; |
|
2294 |
+var has = {}; |
|
2295 |
+var circular = {}; |
|
2296 |
+var waiting = false; |
|
2297 |
+var flushing = false; |
|
2298 |
+var index = 0; |
|
2299 |
+ |
|
2300 |
+/** |
|
2301 |
+ * Reset the scheduler's state. |
|
2302 |
+ */ |
|
2303 |
+function resetSchedulerState () { |
|
2304 |
+ queue.length = 0; |
|
2305 |
+ has = {}; |
|
2306 |
+ { |
|
2307 |
+ circular = {}; |
|
2308 |
+ } |
|
2309 |
+ waiting = flushing = false; |
|
2310 |
+} |
|
2311 |
+ |
|
2312 |
+/** |
|
2313 |
+ * Flush both queues and run the watchers. |
|
2314 |
+ */ |
|
2315 |
+function flushSchedulerQueue () { |
|
2316 |
+ flushing = true; |
|
2317 |
+ var watcher, id, vm; |
|
2318 |
+ |
|
2319 |
+ // Sort queue before flush. |
|
2320 |
+ // This ensures that: |
|
2321 |
+ // 1. Components are updated from parent to child. (because parent is always |
|
2322 |
+ // created before the child) |
|
2323 |
+ // 2. A component's user watchers are run before its render watcher (because |
|
2324 |
+ // user watchers are created before the render watcher) |
|
2325 |
+ // 3. If a component is destroyed during a parent component's watcher run, |
|
2326 |
+ // its watchers can be skipped. |
|
2327 |
+ queue.sort(function (a, b) { return a.id - b.id; }); |
|
2328 |
+ |
|
2329 |
+ // do not cache length because more watchers might be pushed |
|
2330 |
+ // as we run existing watchers |
|
2331 |
+ for (index = 0; index < queue.length; index++) { |
|
2332 |
+ watcher = queue[index]; |
|
2333 |
+ id = watcher.id; |
|
2334 |
+ has[id] = null; |
|
2335 |
+ watcher.run(); |
|
2336 |
+ // in dev build, check and stop circular updates. |
|
2337 |
+ if ("development" !== 'production' && has[id] != null) { |
|
2338 |
+ circular[id] = (circular[id] || 0) + 1; |
|
2339 |
+ if (circular[id] > config._maxUpdateCount) { |
|
2340 |
+ warn( |
|
2341 |
+ 'You may have an infinite update loop ' + ( |
|
2342 |
+ watcher.user |
|
2343 |
+ ? ("in watcher with expression \"" + (watcher.expression) + "\"") |
|
2344 |
+ : "in a component render function." |
|
2345 |
+ ), |
|
2346 |
+ watcher.vm |
|
2347 |
+ ); |
|
2348 |
+ break |
|
2349 |
+ } |
|
2350 |
+ } |
|
2351 |
+ } |
|
2352 |
+ |
|
2353 |
+ // reset scheduler before updated hook called |
|
2354 |
+ var oldQueue = queue.slice(); |
|
2355 |
+ resetSchedulerState(); |
|
2356 |
+ |
|
2357 |
+ // call updated hooks |
|
2358 |
+ index = oldQueue.length; |
|
2359 |
+ while (index--) { |
|
2360 |
+ watcher = oldQueue[index]; |
|
2361 |
+ vm = watcher.vm; |
|
2362 |
+ if (vm._watcher === watcher && vm._isMounted) { |
|
2363 |
+ callHook(vm, 'updated'); |
|
2364 |
+ } |
|
2365 |
+ } |
|
2366 |
+ |
|
2367 |
+ // devtool hook |
|
2368 |
+ /* istanbul ignore if */ |
|
2369 |
+ if (devtools && config.devtools) { |
|
2370 |
+ devtools.emit('flush'); |
|
2371 |
+ } |
|
2372 |
+} |
|
2373 |
+ |
|
2374 |
+/** |
|
2375 |
+ * Push a watcher into the watcher queue. |
|
2376 |
+ * Jobs with duplicate IDs will be skipped unless it's |
|
2377 |
+ * pushed when the queue is being flushed. |
|
2378 |
+ */ |
|
2379 |
+function queueWatcher (watcher) { |
|
2380 |
+ var id = watcher.id; |
|
2381 |
+ if (has[id] == null) { |
|
2382 |
+ has[id] = true; |
|
2383 |
+ if (!flushing) { |
|
2384 |
+ queue.push(watcher); |
|
2385 |
+ } else { |
|
2386 |
+ // if already flushing, splice the watcher based on its id |
|
2387 |
+ // if already past its id, it will be run next immediately. |
|
2388 |
+ var i = queue.length - 1; |
|
2389 |
+ while (i >= 0 && queue[i].id > watcher.id) { |
|
2390 |
+ i--; |
|
2391 |
+ } |
|
2392 |
+ queue.splice(Math.max(i, index) + 1, 0, watcher); |
|
2393 |
+ } |
|
2394 |
+ // queue the flush |
|
2395 |
+ if (!waiting) { |
|
2396 |
+ waiting = true; |
|
2397 |
+ nextTick(flushSchedulerQueue); |
|
2398 |
+ } |
|
2399 |
+ } |
|
2400 |
+} |
|
2401 |
+ |
|
2402 |
+/* */ |
|
2403 |
+ |
|
2404 |
+var uid$2 = 0; |
|
2405 |
+ |
|
2406 |
+/** |
|
2407 |
+ * A watcher parses an expression, collects dependencies, |
|
2408 |
+ * and fires callback when the expression value changes. |
|
2409 |
+ * This is used for both the $watch() api and directives. |
|
2410 |
+ */ |
|
2411 |
+var Watcher = function Watcher ( |
|
2412 |
+ vm, |
|
2413 |
+ expOrFn, |
|
2414 |
+ cb, |
|
2415 |
+ options |
|
2416 |
+) { |
|
2417 |
+ this.vm = vm; |
|
2418 |
+ vm._watchers.push(this); |
|
2419 |
+ // options |
|
2420 |
+ if (options) { |
|
2421 |
+ this.deep = !!options.deep; |
|
2422 |
+ this.user = !!options.user; |
|
2423 |
+ this.lazy = !!options.lazy; |
|
2424 |
+ this.sync = !!options.sync; |
|
2425 |
+ } else { |
|
2426 |
+ this.deep = this.user = this.lazy = this.sync = false; |
|
2427 |
+ } |
|
2428 |
+ this.cb = cb; |
|
2429 |
+ this.id = ++uid$2; // uid for batching |
|
2430 |
+ this.active = true; |
|
2431 |
+ this.dirty = this.lazy; // for lazy watchers |
|
2432 |
+ this.deps = []; |
|
2433 |
+ this.newDeps = []; |
|
2434 |
+ this.depIds = new _Set(); |
|
2435 |
+ this.newDepIds = new _Set(); |
|
2436 |
+ this.expression = expOrFn.toString(); |
|
2437 |
+ // parse expression for getter |
|
2438 |
+ if (typeof expOrFn === 'function') { |
|
2439 |
+ this.getter = expOrFn; |
|
2440 |
+ } else { |
|
2441 |
+ this.getter = parsePath(expOrFn); |
|
2442 |
+ if (!this.getter) { |
|
2443 |
+ this.getter = function () {}; |
|
2444 |
+ "development" !== 'production' && warn( |
|
2445 |
+ "Failed watching path: \"" + expOrFn + "\" " + |
|
2446 |
+ 'Watcher only accepts simple dot-delimited paths. ' + |
|
2447 |
+ 'For full control, use a function instead.', |
|
2448 |
+ vm |
|
2449 |
+ ); |
|
2450 |
+ } |
|
2451 |
+ } |
|
2452 |
+ this.value = this.lazy |
|
2453 |
+ ? undefined |
|
2454 |
+ : this.get(); |
|
2455 |
+}; |
|
2456 |
+ |
|
2457 |
+/** |
|
2458 |
+ * Evaluate the getter, and re-collect dependencies. |
|
2459 |
+ */ |
|
2460 |
+Watcher.prototype.get = function get () { |
|
2461 |
+ pushTarget(this); |
|
2462 |
+ var value; |
|
2463 |
+ var vm = this.vm; |
|
2464 |
+ if (this.user) { |
|
2465 |
+ try { |
|
2466 |
+ value = this.getter.call(vm, vm); |
|
2467 |
+ } catch (e) { |
|
2468 |
+ handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\"")); |
|
2469 |
+ } |
|
2470 |
+ } else { |
|
2471 |
+ value = this.getter.call(vm, vm); |
|
2472 |
+ } |
|
2473 |
+ // "touch" every property so they are all tracked as |
|
2474 |
+ // dependencies for deep watching |
|
2475 |
+ if (this.deep) { |
|
2476 |
+ traverse(value); |
|
2477 |
+ } |
|
2478 |
+ popTarget(); |
|
2479 |
+ this.cleanupDeps(); |
|
2480 |
+ return value |
|
2481 |
+}; |
|
2482 |
+ |
|
2483 |
+/** |
|
2484 |
+ * Add a dependency to this directive. |
|
2485 |
+ */ |
|
2486 |
+Watcher.prototype.addDep = function addDep (dep) { |
|
2487 |
+ var id = dep.id; |
|
2488 |
+ if (!this.newDepIds.has(id)) { |
|
2489 |
+ this.newDepIds.add(id); |
|
2490 |
+ this.newDeps.push(dep); |
|
2491 |
+ if (!this.depIds.has(id)) { |
|
2492 |
+ dep.addSub(this); |
|
2493 |
+ } |
|
2494 |
+ } |
|
2495 |
+}; |
|
2496 |
+ |
|
2497 |
+/** |
|
2498 |
+ * Clean up for dependency collection. |
|
2499 |
+ */ |
|
2500 |
+Watcher.prototype.cleanupDeps = function cleanupDeps () { |
|
2501 |
+ var this$1 = this; |
|
2502 |
+ |
|
2503 |
+ var i = this.deps.length; |
|
2504 |
+ while (i--) { |
|
2505 |
+ var dep = this$1.deps[i]; |
|
2506 |
+ if (!this$1.newDepIds.has(dep.id)) { |
|
2507 |
+ dep.removeSub(this$1); |
|
2508 |
+ } |
|
2509 |
+ } |
|
2510 |
+ var tmp = this.depIds; |
|
2511 |
+ this.depIds = this.newDepIds; |
|
2512 |
+ this.newDepIds = tmp; |
|
2513 |
+ this.newDepIds.clear(); |
|
2514 |
+ tmp = this.deps; |
|
2515 |
+ this.deps = this.newDeps; |
|
2516 |
+ this.newDeps = tmp; |
|
2517 |
+ this.newDeps.length = 0; |
|
2518 |
+}; |
|
2519 |
+ |
|
2520 |
+/** |
|
2521 |
+ * Subscriber interface. |
|
2522 |
+ * Will be called when a dependency changes. |
|
2523 |
+ */ |
|
2524 |
+Watcher.prototype.update = function update () { |
|
2525 |
+ /* istanbul ignore else */ |
|
2526 |
+ if (this.lazy) { |
|
2527 |
+ this.dirty = true; |
|
2528 |
+ } else if (this.sync) { |
|
2529 |
+ this.run(); |
|
2530 |
+ } else { |
|
2531 |
+ queueWatcher(this); |
|
2532 |
+ } |
|
2533 |
+}; |
|
2534 |
+ |
|
2535 |
+/** |
|
2536 |
+ * Scheduler job interface. |
|
2537 |
+ * Will be called by the scheduler. |
|
2538 |
+ */ |
|
2539 |
+Watcher.prototype.run = function run () { |
|
2540 |
+ if (this.active) { |
|
2541 |
+ var value = this.get(); |
|
2542 |
+ if ( |
|
2543 |
+ value !== this.value || |
|
2544 |
+ // Deep watchers and watchers on Object/Arrays should fire even |
|
2545 |
+ // when the value is the same, because the value may |
|
2546 |
+ // have mutated. |
|
2547 |
+ isObject(value) || |
|
2548 |
+ this.deep |
|
2549 |
+ ) { |
|
2550 |
+ // set new value |
|
2551 |
+ var oldValue = this.value; |
|
2552 |
+ this.value = value; |
|
2553 |
+ if (this.user) { |
|
2554 |
+ try { |
|
2555 |
+ this.cb.call(this.vm, value, oldValue); |
|
2556 |
+ } catch (e) { |
|
2557 |
+ handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\"")); |
|
2558 |
+ } |
|
2559 |
+ } else { |
|
2560 |
+ this.cb.call(this.vm, value, oldValue); |
|
2561 |
+ } |
|
2562 |
+ } |
|
2563 |
+ } |
|
2564 |
+}; |
|
2565 |
+ |
|
2566 |
+/** |
|
2567 |
+ * Evaluate the value of the watcher. |
|
2568 |
+ * This only gets called for lazy watchers. |
|
2569 |
+ */ |
|
2570 |
+Watcher.prototype.evaluate = function evaluate () { |
|
2571 |
+ this.value = this.get(); |
|
2572 |
+ this.dirty = false; |
|
2573 |
+}; |
|
2574 |
+ |
|
2575 |
+/** |
|
2576 |
+ * Depend on all deps collected by this watcher. |
|
2577 |
+ */ |
|
2578 |
+Watcher.prototype.depend = function depend () { |
|
2579 |
+ var this$1 = this; |
|
2580 |
+ |
|
2581 |
+ var i = this.deps.length; |
|
2582 |
+ while (i--) { |
|
2583 |
+ this$1.deps[i].depend(); |
|
2584 |
+ } |
|
2585 |
+}; |
|
2586 |
+ |
|
2587 |
+/** |
|
2588 |
+ * Remove self from all dependencies' subscriber list. |
|
2589 |
+ */ |
|
2590 |
+Watcher.prototype.teardown = function teardown () { |
|
2591 |
+ var this$1 = this; |
|
2592 |
+ |
|
2593 |
+ if (this.active) { |
|
2594 |
+ // remove self from vm's watcher list |
|
2595 |
+ // this is a somewhat expensive operation so we skip it |
|
2596 |
+ // if the vm is being destroyed. |
|
2597 |
+ if (!this.vm._isBeingDestroyed) { |
|
2598 |
+ remove(this.vm._watchers, this); |
|
2599 |
+ } |
|
2600 |
+ var i = this.deps.length; |
|
2601 |
+ while (i--) { |
|
2602 |
+ this$1.deps[i].removeSub(this$1); |
|
2603 |
+ } |
|
2604 |
+ this.active = false; |
|
2605 |
+ } |
|
2606 |
+}; |
|
2607 |
+ |
|
2608 |
+/** |
|
2609 |
+ * Recursively traverse an object to evoke all converted |
|
2610 |
+ * getters, so that every nested property inside the object |
|
2611 |
+ * is collected as a "deep" dependency. |
|
2612 |
+ */ |
|
2613 |
+var seenObjects = new _Set(); |
|
2614 |
+function traverse (val) { |
|
2615 |
+ seenObjects.clear(); |
|
2616 |
+ _traverse(val, seenObjects); |
|
2617 |
+} |
|
2618 |
+ |
|
2619 |
+function _traverse (val, seen) { |
|
2620 |
+ var i, keys; |
|
2621 |
+ var isA = Array.isArray(val); |
|
2622 |
+ if ((!isA && !isObject(val)) || !Object.isExtensible(val)) { |
|
2623 |
+ return |
|
2624 |
+ } |
|
2625 |
+ if (val.__ob__) { |
|
2626 |
+ var depId = val.__ob__.dep.id; |
|
2627 |
+ if (seen.has(depId)) { |
|
2628 |
+ return |
|
2629 |
+ } |
|
2630 |
+ seen.add(depId); |
|
2631 |
+ } |
|
2632 |
+ if (isA) { |
|
2633 |
+ i = val.length; |
|
2634 |
+ while (i--) { _traverse(val[i], seen); } |
|
2635 |
+ } else { |
|
2636 |
+ keys = Object.keys(val); |
|
2637 |
+ i = keys.length; |
|
2638 |
+ while (i--) { _traverse(val[keys[i]], seen); } |
|
2639 |
+ } |
|
2640 |
+} |
|
2641 |
+ |
|
2642 |
+/* */ |
|
2643 |
+ |
|
2644 |
+var sharedPropertyDefinition = { |
|
2645 |
+ enumerable: true, |
|
2646 |
+ configurable: true, |
|
2647 |
+ get: noop, |
|
2648 |
+ set: noop |
|
2649 |
+}; |
|
2650 |
+ |
|
2651 |
+function proxy (target, sourceKey, key) { |
|
2652 |
+ sharedPropertyDefinition.get = function proxyGetter () { |
|
2653 |
+ return this[sourceKey][key] |
|
2654 |
+ }; |
|
2655 |
+ sharedPropertyDefinition.set = function proxySetter (val) { |
|
2656 |
+ this[sourceKey][key] = val; |
|
2657 |
+ }; |
|
2658 |
+ Object.defineProperty(target, key, sharedPropertyDefinition); |
|
2659 |
+} |
|
2660 |
+ |
|
2661 |
+function initState (vm) { |
|
2662 |
+ vm._watchers = []; |
|
2663 |
+ var opts = vm.$options; |
|
2664 |
+ if (opts.props) { initProps(vm, opts.props); } |
|
2665 |
+ if (opts.methods) { initMethods(vm, opts.methods); } |
|
2666 |
+ if (opts.data) { |
|
2667 |
+ initData(vm); |
|
2668 |
+ } else { |
|
2669 |
+ observe(vm._data = {}, true /* asRootData */); |
|
2670 |
+ } |
|
2671 |
+ if (opts.computed) { initComputed(vm, opts.computed); } |
|
2672 |
+ if (opts.watch) { initWatch(vm, opts.watch); } |
|
2673 |
+} |
|
2674 |
+ |
|
2675 |
+var isReservedProp = { key: 1, ref: 1, slot: 1 }; |
|
2676 |
+ |
|
2677 |
+function initProps (vm, propsOptions) { |
|
2678 |
+ var propsData = vm.$options.propsData || {}; |
|
2679 |
+ var props = vm._props = {}; |
|
2680 |
+ // cache prop keys so that future props updates can iterate using Array |
|
2681 |
+ // instead of dynamic object key enumeration. |
|
2682 |
+ var keys = vm.$options._propKeys = []; |
|
2683 |
+ var isRoot = !vm.$parent; |
|
2684 |
+ // root instance props should be converted |
|
2685 |
+ observerState.shouldConvert = isRoot; |
|
2686 |
+ var loop = function ( key ) { |
|
2687 |
+ keys.push(key); |
|
2688 |
+ var value = validateProp(key, propsOptions, propsData, vm); |
|
2689 |
+ /* istanbul ignore else */ |
|
2690 |
+ { |
|
2691 |
+ if (isReservedProp[key]) { |
|
2692 |
+ warn( |
|
2693 |
+ ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."), |
|
2694 |
+ vm |
|
2695 |
+ ); |
|
2696 |
+ } |
|
2697 |
+ defineReactive$$1(props, key, value, function () { |
|
2698 |
+ if (vm.$parent && !observerState.isSettingProps) { |
|
2699 |
+ warn( |
|
2700 |
+ "Avoid mutating a prop directly since the value will be " + |
|
2701 |
+ "overwritten whenever the parent component re-renders. " + |
|
2702 |
+ "Instead, use a data or computed property based on the prop's " + |
|
2703 |
+ "value. Prop being mutated: \"" + key + "\"", |
|
2704 |
+ vm |
|
2705 |
+ ); |
|
2706 |
+ } |
|
2707 |
+ }); |
|
2708 |
+ } |
|
2709 |
+ // static props are already proxied on the component's prototype |
|
2710 |
+ // during Vue.extend(). We only need to proxy props defined at |
|
2711 |
+ // instantiation here. |
|
2712 |
+ if (!(key in vm)) { |
|
2713 |
+ proxy(vm, "_props", key); |
|
2714 |
+ } |
|
2715 |
+ }; |
|
2716 |
+ |
|
2717 |
+ for (var key in propsOptions) loop( key ); |
|
2718 |
+ observerState.shouldConvert = true; |
|
2719 |
+} |
|
2720 |
+ |
|
2721 |
+function initData (vm) { |
|
2722 |
+ var data = vm.$options.data; |
|
2723 |
+ data = vm._data = typeof data === 'function' |
|
2724 |
+ ? getData(data, vm) |
|
2725 |
+ : data || {}; |
|
2726 |
+ if (!isPlainObject(data)) { |
|
2727 |
+ data = {}; |
|
2728 |
+ "development" !== 'production' && warn( |
|
2729 |
+ 'data functions should return an object:\n' + |
|
2730 |
+ 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', |
|
2731 |
+ vm |
|
2732 |
+ ); |
|
2733 |
+ } |
|
2734 |
+ // proxy data on instance |
|
2735 |
+ var keys = Object.keys(data); |
|
2736 |
+ var props = vm.$options.props; |
|
2737 |
+ var i = keys.length; |
|
2738 |
+ while (i--) { |
|
2739 |
+ if (props && hasOwn(props, keys[i])) { |
|
2740 |
+ "development" !== 'production' && warn( |
|
2741 |
+ "The data property \"" + (keys[i]) + "\" is already declared as a prop. " + |
|
2742 |
+ "Use prop default value instead.", |
|
2743 |
+ vm |
|
2744 |
+ ); |
|
2745 |
+ } else if (!isReserved(keys[i])) { |
|
2746 |
+ proxy(vm, "_data", keys[i]); |
|
2747 |
+ } |
|
2748 |
+ } |
|
2749 |
+ // observe data |
|
2750 |
+ observe(data, true /* asRootData */); |
|
2751 |
+} |
|
2752 |
+ |
|
2753 |
+function getData (data, vm) { |
|
2754 |
+ try { |
|
2755 |
+ return data.call(vm) |
|
2756 |
+ } catch (e) { |
|
2757 |
+ handleError(e, vm, "data()"); |
|
2758 |
+ return {} |
|
2759 |
+ } |
|
2760 |
+} |
|
2761 |
+ |
|
2762 |
+var computedWatcherOptions = { lazy: true }; |
|
2763 |
+ |
|
2764 |
+function initComputed (vm, computed) { |
|
2765 |
+ var watchers = vm._computedWatchers = Object.create(null); |
|
2766 |
+ |
|
2767 |
+ for (var key in computed) { |
|
2768 |
+ var userDef = computed[key]; |
|
2769 |
+ var getter = typeof userDef === 'function' ? userDef : userDef.get; |
|
2770 |
+ { |
|
2771 |
+ if (getter === undefined) { |
|
2772 |
+ warn( |
|
2773 |
+ ("No getter function has been defined for computed property \"" + key + "\"."), |
|
2774 |
+ vm |
|
2775 |
+ ); |
|
2776 |
+ getter = noop; |
|
2777 |
+ } |
|
2778 |
+ } |
|
2779 |
+ // create internal watcher for the computed property. |
|
2780 |
+ watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions); |
|
2781 |
+ |
|
2782 |
+ // component-defined computed properties are already defined on the |
|
2783 |
+ // component prototype. We only need to define computed properties defined |
|
2784 |
+ // at instantiation here. |
|
2785 |
+ if (!(key in vm)) { |
|
2786 |
+ defineComputed(vm, key, userDef); |
|
2787 |
+ } |
|
2788 |
+ } |
|
2789 |
+} |
|
2790 |
+ |
|
2791 |
+function defineComputed (target, key, userDef) { |
|
2792 |
+ if (typeof userDef === 'function') { |
|
2793 |
+ sharedPropertyDefinition.get = createComputedGetter(key); |
|
2794 |
+ sharedPropertyDefinition.set = noop; |
|
2795 |
+ } else { |
|
2796 |
+ sharedPropertyDefinition.get = userDef.get |
|
2797 |
+ ? userDef.cache !== false |
|
2798 |
+ ? createComputedGetter(key) |
|
2799 |
+ : userDef.get |
|
2800 |
+ : noop; |
|
2801 |
+ sharedPropertyDefinition.set = userDef.set |
|
2802 |
+ ? userDef.set |
|
2803 |
+ : noop; |
|
2804 |
+ } |
|
2805 |
+ Object.defineProperty(target, key, sharedPropertyDefinition); |
|
2806 |
+} |
|
2807 |
+ |
|
2808 |
+function createComputedGetter (key) { |
|
2809 |
+ return function computedGetter () { |
|
2810 |
+ var watcher = this._computedWatchers && this._computedWatchers[key]; |
|
2811 |
+ if (watcher) { |
|
2812 |
+ if (watcher.dirty) { |
|
2813 |
+ watcher.evaluate(); |
|
2814 |
+ } |
|
2815 |
+ if (Dep.target) { |
|
2816 |
+ watcher.depend(); |
|
2817 |
+ } |
|
2818 |
+ return watcher.value |
|
2819 |
+ } |
|
2820 |
+ } |
|
2821 |
+} |
|
2822 |
+ |
|
2823 |
+function initMethods (vm, methods) { |
|
2824 |
+ var props = vm.$options.props; |
|
2825 |
+ for (var key in methods) { |
|
2826 |
+ vm[key] = methods[key] == null ? noop : bind(methods[key], vm); |
|
2827 |
+ { |
|
2828 |
+ if (methods[key] == null) { |
|
2829 |
+ warn( |
|
2830 |
+ "method \"" + key + "\" has an undefined value in the component definition. " + |
|
2831 |
+ "Did you reference the function correctly?", |
|
2832 |
+ vm |
|
2833 |
+ ); |
|
2834 |
+ } |
|
2835 |
+ if (props && hasOwn(props, key)) { |
|
2836 |
+ warn( |
|
2837 |
+ ("method \"" + key + "\" has already been defined as a prop."), |
|
2838 |
+ vm |
|
2839 |
+ ); |
|
2840 |
+ } |
|
2841 |
+ } |
|
2842 |
+ } |
|
2843 |
+} |
|
2844 |
+ |
|
2845 |
+function initWatch (vm, watch) { |
|
2846 |
+ for (var key in watch) { |
|
2847 |
+ var handler = watch[key]; |
|
2848 |
+ if (Array.isArray(handler)) { |
|
2849 |
+ for (var i = 0; i < handler.length; i++) { |
|
2850 |
+ createWatcher(vm, key, handler[i]); |
|
2851 |
+ } |
|
2852 |
+ } else { |
|
2853 |
+ createWatcher(vm, key, handler); |
|
2854 |
+ } |
|
2855 |
+ } |
|
2856 |
+} |
|
2857 |
+ |
|
2858 |
+function createWatcher (vm, key, handler) { |
|
2859 |
+ var options; |
|
2860 |
+ if (isPlainObject(handler)) { |
|
2861 |
+ options = handler; |
|
2862 |
+ handler = handler.handler; |
|
2863 |
+ } |
|
2864 |
+ if (typeof handler === 'string') { |
|
2865 |
+ handler = vm[handler]; |
|
2866 |
+ } |
|
2867 |
+ vm.$watch(key, handler, options); |
|
2868 |
+} |
|
2869 |
+ |
|
2870 |
+function stateMixin (Vue) { |
|
2871 |
+ // flow somehow has problems with directly declared definition object |
|
2872 |
+ // when using Object.defineProperty, so we have to procedurally build up |
|
2873 |
+ // the object here. |
|
2874 |
+ var dataDef = {}; |
|
2875 |
+ dataDef.get = function () { return this._data }; |
|
2876 |
+ var propsDef = {}; |
|
2877 |
+ propsDef.get = function () { return this._props }; |
|
2878 |
+ { |
|
2879 |
+ dataDef.set = function (newData) { |
|
2880 |
+ warn( |
|
2881 |
+ 'Avoid replacing instance root $data. ' + |
|
2882 |
+ 'Use nested data properties instead.', |
|
2883 |
+ this |
|
2884 |
+ ); |
|
2885 |
+ }; |
|
2886 |
+ propsDef.set = function () { |
|
2887 |
+ warn("$props is readonly.", this); |
|
2888 |
+ }; |
|
2889 |
+ } |
|
2890 |
+ Object.defineProperty(Vue.prototype, '$data', dataDef); |
|
2891 |
+ Object.defineProperty(Vue.prototype, '$props', propsDef); |
|
2892 |
+ |
|
2893 |
+ Vue.prototype.$set = set; |
|
2894 |
+ Vue.prototype.$delete = del; |
|
2895 |
+ |
|
2896 |
+ Vue.prototype.$watch = function ( |
|
2897 |
+ expOrFn, |
|
2898 |
+ cb, |
|
2899 |
+ options |
|
2900 |
+ ) { |
|
2901 |
+ var vm = this; |
|
2902 |
+ options = options || {}; |
|
2903 |
+ options.user = true; |
|
2904 |
+ var watcher = new Watcher(vm, expOrFn, cb, options); |
|
2905 |
+ if (options.immediate) { |
|
2906 |
+ cb.call(vm, watcher.value); |
|
2907 |
+ } |
|
2908 |
+ return function unwatchFn () { |
|
2909 |
+ watcher.teardown(); |
|
2910 |
+ } |
|
2911 |
+ }; |
|
2912 |
+} |
|
2913 |
+ |
|
2914 |
+/* */ |
|
2915 |
+ |
|
2916 |
+// hooks to be invoked on component VNodes during patch |
|
2917 |
+var componentVNodeHooks = { |
|
2918 |
+ init: function init ( |
|
2919 |
+ vnode, |
|
2920 |
+ hydrating, |
|
2921 |
+ parentElm, |
|
2922 |
+ refElm |
|
2923 |
+ ) { |
|
2924 |
+ if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) { |
|
2925 |
+ var child = vnode.componentInstance = createComponentInstanceForVnode( |
|
2926 |
+ vnode, |
|
2927 |
+ activeInstance, |
|
2928 |
+ parentElm, |
|
2929 |
+ refElm |
|
2930 |
+ ); |
|
2931 |
+ child.$mount(hydrating ? vnode.elm : undefined, hydrating); |
|
2932 |
+ } else if (vnode.data.keepAlive) { |
|
2933 |
+ // kept-alive components, treat as a patch |
|
2934 |
+ var mountedNode = vnode; // work around flow |
|
2935 |
+ componentVNodeHooks.prepatch(mountedNode, mountedNode); |
|
2936 |
+ } |
|
2937 |
+ }, |
|
2938 |
+ |
|
2939 |
+ prepatch: function prepatch (oldVnode, vnode) { |
|
2940 |
+ var options = vnode.componentOptions; |
|
2941 |
+ var child = vnode.componentInstance = oldVnode.componentInstance; |
|
2942 |
+ updateChildComponent( |
|
2943 |
+ child, |
|
2944 |
+ options.propsData, // updated props |
|
2945 |
+ options.listeners, // updated listeners |
|
2946 |
+ vnode, // new parent vnode |
|
2947 |
+ options.children // new children |
|
2948 |
+ ); |
|
2949 |
+ }, |
|
2950 |
+ |
|
2951 |
+ insert: function insert (vnode) { |
|
2952 |
+ if (!vnode.componentInstance._isMounted) { |
|
2953 |
+ vnode.componentInstance._isMounted = true; |
|
2954 |
+ callHook(vnode.componentInstance, 'mounted'); |
|
2955 |
+ } |
|
2956 |
+ if (vnode.data.keepAlive) { |
|
2957 |
+ activateChildComponent(vnode.componentInstance, true /* direct */); |
|
2958 |
+ } |
|
2959 |
+ }, |
|
2960 |
+ |
|
2961 |
+ destroy: function destroy (vnode) { |
|
2962 |
+ if (!vnode.componentInstance._isDestroyed) { |
|
2963 |
+ if (!vnode.data.keepAlive) { |
|
2964 |
+ vnode.componentInstance.$destroy(); |
|
2965 |
+ } else { |
|
2966 |
+ deactivateChildComponent(vnode.componentInstance, true /* direct */); |
|
2967 |
+ } |
|
2968 |
+ } |
|
2969 |
+ } |
|
2970 |
+}; |
|
2971 |
+ |
|
2972 |
+var hooksToMerge = Object.keys(componentVNodeHooks); |
|
2973 |
+ |
|
2974 |
+function createComponent ( |
|
2975 |
+ Ctor, |
|
2976 |
+ data, |
|
2977 |
+ context, |
|
2978 |
+ children, |
|
2979 |
+ tag |
|
2980 |
+) { |
|
2981 |
+ if (!Ctor) { |
|
2982 |
+ return |
|
2983 |
+ } |
|
2984 |
+ |
|
2985 |
+ var baseCtor = context.$options._base; |
|
2986 |
+ if (isObject(Ctor)) { |
|
2987 |
+ Ctor = baseCtor.extend(Ctor); |
|
2988 |
+ } |
|
2989 |
+ |
|
2990 |
+ if (typeof Ctor !== 'function') { |
|
2991 |
+ { |
|
2992 |
+ warn(("Invalid Component definition: " + (String(Ctor))), context); |
|
2993 |
+ } |
|
2994 |
+ return |
|
2995 |
+ } |
|
2996 |
+ |
|
2997 |
+ // async component |
|
2998 |
+ if (!Ctor.cid) { |
|
2999 |
+ if (Ctor.resolved) { |
|
3000 |
+ Ctor = Ctor.resolved; |
|
3001 |
+ } else { |
|
3002 |
+ Ctor = resolveAsyncComponent(Ctor, baseCtor, function () { |
|
3003 |
+ // it's ok to queue this on every render because |
|
3004 |
+ // $forceUpdate is buffered by the scheduler. |
|
3005 |
+ context.$forceUpdate(); |
|
3006 |
+ }); |
|
3007 |
+ if (!Ctor) { |
|
3008 |
+ // return nothing if this is indeed an async component |
|
3009 |
+ // wait for the callback to trigger parent update. |
|
3010 |
+ return |
|
3011 |
+ } |
|
3012 |
+ } |
|
3013 |
+ } |
|
3014 |
+ |
|
3015 |
+ // resolve constructor options in case global mixins are applied after |
|
3016 |
+ // component constructor creation |
|
3017 |
+ resolveConstructorOptions(Ctor); |
|
3018 |
+ |
|
3019 |
+ data = data || {}; |
|
3020 |
+ |
|
3021 |
+ // transform component v-model data into props & events |
|
3022 |
+ if (data.model) { |
|
3023 |
+ transformModel(Ctor.options, data); |
|
3024 |
+ } |
|
3025 |
+ |
|
3026 |
+ // extract props |
|
3027 |
+ var propsData = extractProps(data, Ctor, tag); |
|
3028 |
+ |
|
3029 |
+ // functional component |
|
3030 |
+ if (Ctor.options.functional) { |
|
3031 |
+ return createFunctionalComponent(Ctor, propsData, data, context, children) |
|
3032 |
+ } |
|
3033 |
+ |
|
3034 |
+ // extract listeners, since these needs to be treated as |
|
3035 |
+ // child component listeners instead of DOM listeners |
|
3036 |
+ var listeners = data.on; |
|
3037 |
+ // replace with listeners with .native modifier |
|
3038 |
+ data.on = data.nativeOn; |
|
3039 |
+ |
|
3040 |
+ if (Ctor.options.abstract) { |
|
3041 |
+ // abstract components do not keep anything |
|
3042 |
+ // other than props & listeners |
|
3043 |
+ data = {}; |
|
3044 |
+ } |
|
3045 |
+ |
|
3046 |
+ // merge component management hooks onto the placeholder node |
|
3047 |
+ mergeHooks(data); |
|
3048 |
+ |
|
3049 |
+ // return a placeholder vnode |
|
3050 |
+ var name = Ctor.options.name || tag; |
|
3051 |
+ var vnode = new VNode( |
|
3052 |
+ ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), |
|
3053 |
+ data, undefined, undefined, undefined, context, |
|
3054 |
+ { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children } |
|
3055 |
+ ); |
|
3056 |
+ return vnode |
|
3057 |
+} |
|
3058 |
+ |
|
3059 |
+function createFunctionalComponent ( |
|
3060 |
+ Ctor, |
|
3061 |
+ propsData, |
|
3062 |
+ data, |
|
3063 |
+ context, |
|
3064 |
+ children |
|
3065 |
+) { |
|
3066 |
+ var props = {}; |
|
3067 |
+ var propOptions = Ctor.options.props; |
|
3068 |
+ if (propOptions) { |
|
3069 |
+ for (var key in propOptions) { |
|
3070 |
+ props[key] = validateProp(key, propOptions, propsData); |
|
3071 |
+ } |
|
3072 |
+ } |
|
3073 |
+ // ensure the createElement function in functional components |
|
3074 |
+ // gets a unique context - this is necessary for correct named slot check |
|
3075 |
+ var _context = Object.create(context); |
|
3076 |
+ var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); }; |
|
3077 |
+ var vnode = Ctor.options.render.call(null, h, { |
|
3078 |
+ props: props, |
|
3079 |
+ data: data, |
|
3080 |
+ parent: context, |
|
3081 |
+ children: children, |
|
3082 |
+ slots: function () { return resolveSlots(children, context); } |
|
3083 |
+ }); |
|
3084 |
+ if (vnode instanceof VNode) { |
|
3085 |
+ vnode.functionalContext = context; |
|
3086 |
+ if (data.slot) { |
|
3087 |
+ (vnode.data || (vnode.data = {})).slot = data.slot; |
|
3088 |
+ } |
|
3089 |
+ } |
|
3090 |
+ return vnode |
|
3091 |
+} |
|
3092 |
+ |
|
3093 |
+function createComponentInstanceForVnode ( |
|
3094 |
+ vnode, // we know it's MountedComponentVNode but flow doesn't |
|
3095 |
+ parent, // activeInstance in lifecycle state |
|
3096 |
+ parentElm, |
|
3097 |
+ refElm |
|
3098 |
+) { |
|
3099 |
+ var vnodeComponentOptions = vnode.componentOptions; |
|
3100 |
+ var options = { |
|
3101 |
+ _isComponent: true, |
|
3102 |
+ parent: parent, |
|
3103 |
+ propsData: vnodeComponentOptions.propsData, |
|
3104 |
+ _componentTag: vnodeComponentOptions.tag, |
|
3105 |
+ _parentVnode: vnode, |
|
3106 |
+ _parentListeners: vnodeComponentOptions.listeners, |
|
3107 |
+ _renderChildren: vnodeComponentOptions.children, |
|
3108 |
+ _parentElm: parentElm || null, |
|
3109 |
+ _refElm: refElm || null |
|
3110 |
+ }; |
|
3111 |
+ // check inline-template render functions |
|
3112 |
+ var inlineTemplate = vnode.data.inlineTemplate; |
|
3113 |
+ if (inlineTemplate) { |
|
3114 |
+ options.render = inlineTemplate.render; |
|
3115 |
+ options.staticRenderFns = inlineTemplate.staticRenderFns; |
|
3116 |
+ } |
|
3117 |
+ return new vnodeComponentOptions.Ctor(options) |
|
3118 |
+} |
|
3119 |
+ |
|
3120 |
+function resolveAsyncComponent ( |
|
3121 |
+ factory, |
|
3122 |
+ baseCtor, |
|
3123 |
+ cb |
|
3124 |
+) { |
|
3125 |
+ if (factory.requested) { |
|
3126 |
+ // pool callbacks |
|
3127 |
+ factory.pendingCallbacks.push(cb); |
|
3128 |
+ } else { |
|
3129 |
+ factory.requested = true; |
|
3130 |
+ var cbs = factory.pendingCallbacks = [cb]; |
|
3131 |
+ var sync = true; |
|
3132 |
+ |
|
3133 |
+ var resolve = function (res) { |
|
3134 |
+ if (isObject(res)) { |
|
3135 |
+ res = baseCtor.extend(res); |
|
3136 |
+ } |
|
3137 |
+ // cache resolved |
|
3138 |
+ factory.resolved = res; |
|
3139 |
+ // invoke callbacks only if this is not a synchronous resolve |
|
3140 |
+ // (async resolves are shimmed as synchronous during SSR) |
|
3141 |
+ if (!sync) { |
|
3142 |
+ for (var i = 0, l = cbs.length; i < l; i++) { |
|
3143 |
+ cbs[i](res); |
|
3144 |
+ } |
|
3145 |
+ } |
|
3146 |
+ }; |
|
3147 |
+ |
|
3148 |
+ var reject = function (reason) { |
|
3149 |
+ "development" !== 'production' && warn( |
|
3150 |
+ "Failed to resolve async component: " + (String(factory)) + |
|
3151 |
+ (reason ? ("\nReason: " + reason) : '') |
|
3152 |
+ ); |
|
3153 |
+ }; |
|
3154 |
+ |
|
3155 |
+ var res = factory(resolve, reject); |
|
3156 |
+ |
|
3157 |
+ // handle promise |
|
3158 |
+ if (res && typeof res.then === 'function' && !factory.resolved) { |
|
3159 |
+ res.then(resolve, reject); |
|
3160 |
+ } |
|
3161 |
+ |
|
3162 |
+ sync = false; |
|
3163 |
+ // return in case resolved synchronously |
|
3164 |
+ return factory.resolved |
|
3165 |
+ } |
|
3166 |
+} |
|
3167 |
+ |
|
3168 |
+function extractProps (data, Ctor, tag) { |
|
3169 |
+ // we are only extracting raw values here. |
|
3170 |
+ // validation and default values are handled in the child |
|
3171 |
+ // component itself. |
|
3172 |
+ var propOptions = Ctor.options.props; |
|
3173 |
+ if (!propOptions) { |
|
3174 |
+ return |
|
3175 |
+ } |
|
3176 |
+ var res = {}; |
|
3177 |
+ var attrs = data.attrs; |
|
3178 |
+ var props = data.props; |
|
3179 |
+ var domProps = data.domProps; |
|
3180 |
+ if (attrs || props || domProps) { |
|
3181 |
+ for (var key in propOptions) { |
|
3182 |
+ var altKey = hyphenate(key); |
|
3183 |
+ { |
|
3184 |
+ var keyInLowerCase = key.toLowerCase(); |
|
3185 |
+ if ( |
|
3186 |
+ key !== keyInLowerCase && |
|
3187 |
+ attrs && attrs.hasOwnProperty(keyInLowerCase) |
|
3188 |
+ ) { |
|
3189 |
+ tip( |
|
3190 |
+ "Prop \"" + keyInLowerCase + "\" is passed to component " + |
|
3191 |
+ (formatComponentName(tag || Ctor)) + ", but the declared prop name is" + |
|
3192 |
+ " \"" + key + "\". " + |
|
3193 |
+ "Note that HTML attributes are case-insensitive and camelCased " + |
|
3194 |
+ "props need to use their kebab-case equivalents when using in-DOM " + |
|
3195 |
+ "templates. You should probably use \"" + altKey + "\" instead of \"" + key + "\"." |
|
3196 |
+ ); |
|
3197 |
+ } |
|
3198 |
+ } |
|
3199 |
+ checkProp(res, props, key, altKey, true) || |
|
3200 |
+ checkProp(res, attrs, key, altKey) || |
|
3201 |
+ checkProp(res, domProps, key, altKey); |
|
3202 |
+ } |
|
3203 |
+ } |
|
3204 |
+ return res |
|
3205 |
+} |
|
3206 |
+ |
|
3207 |
+function checkProp ( |
|
3208 |
+ res, |
|
3209 |
+ hash, |
|
3210 |
+ key, |
|
3211 |
+ altKey, |
|
3212 |
+ preserve |
|
3213 |
+) { |
|
3214 |
+ if (hash) { |
|
3215 |
+ if (hasOwn(hash, key)) { |
|
3216 |
+ res[key] = hash[key]; |
|
3217 |
+ if (!preserve) { |
|
3218 |
+ delete hash[key]; |
|
3219 |
+ } |
|
3220 |
+ return true |
|
3221 |
+ } else if (hasOwn(hash, altKey)) { |
|
3222 |
+ res[key] = hash[altKey]; |
|
3223 |
+ if (!preserve) { |
|
3224 |
+ delete hash[altKey]; |
|
3225 |
+ } |
|
3226 |
+ return true |
|
3227 |
+ } |
|
3228 |
+ } |
|
3229 |
+ return false |
|
3230 |
+} |
|
3231 |
+ |
|
3232 |
+function mergeHooks (data) { |
|
3233 |
+ if (!data.hook) { |
|
3234 |
+ data.hook = {}; |
|
3235 |
+ } |
|
3236 |
+ for (var i = 0; i < hooksToMerge.length; i++) { |
|
3237 |
+ var key = hooksToMerge[i]; |
|
3238 |
+ var fromParent = data.hook[key]; |
|
3239 |
+ var ours = componentVNodeHooks[key]; |
|
3240 |
+ data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours; |
|
3241 |
+ } |
|
3242 |
+} |
|
3243 |
+ |
|
3244 |
+function mergeHook$1 (one, two) { |
|
3245 |
+ return function (a, b, c, d) { |
|
3246 |
+ one(a, b, c, d); |
|
3247 |
+ two(a, b, c, d); |
|
3248 |
+ } |
|
3249 |
+} |
|
3250 |
+ |
|
3251 |
+// transform component v-model info (value and callback) into |
|
3252 |
+// prop and event handler respectively. |
|
3253 |
+function transformModel (options, data) { |
|
3254 |
+ var prop = (options.model && options.model.prop) || 'value'; |
|
3255 |
+ var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value; |
|
3256 |
+ var on = data.on || (data.on = {}); |
|
3257 |
+ if (on[event]) { |
|
3258 |
+ on[event] = [data.model.callback].concat(on[event]); |
|
3259 |
+ } else { |
|
3260 |
+ on[event] = data.model.callback; |
|
3261 |
+ } |
|
3262 |
+} |
|
3263 |
+ |
|
3264 |
+/* */ |
|
3265 |
+ |
|
3266 |
+var SIMPLE_NORMALIZE = 1; |
|
3267 |
+var ALWAYS_NORMALIZE = 2; |
|
3268 |
+ |
|
3269 |
+// wrapper function for providing a more flexible interface |
|
3270 |
+// without getting yelled at by flow |
|
3271 |
+function createElement ( |
|
3272 |
+ context, |
|
3273 |
+ tag, |
|
3274 |
+ data, |
|
3275 |
+ children, |
|
3276 |
+ normalizationType, |
|
3277 |
+ alwaysNormalize |
|
3278 |
+) { |
|
3279 |
+ if (Array.isArray(data) || isPrimitive(data)) { |
|
3280 |
+ normalizationType = children; |
|
3281 |
+ children = data; |
|
3282 |
+ data = undefined; |
|
3283 |
+ } |
|
3284 |
+ if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; } |
|
3285 |
+ return _createElement(context, tag, data, children, normalizationType) |
|
3286 |
+} |
|
3287 |
+ |
|
3288 |
+function _createElement ( |
|
3289 |
+ context, |
|
3290 |
+ tag, |
|
3291 |
+ data, |
|
3292 |
+ children, |
|
3293 |
+ normalizationType |
|
3294 |
+) { |
|
3295 |
+ if (data && data.__ob__) { |
|
3296 |
+ "development" !== 'production' && warn( |
|
3297 |
+ "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" + |
|
3298 |
+ 'Always create fresh vnode data objects in each render!', |
|
3299 |
+ context |
|
3300 |
+ ); |
|
3301 |
+ return createEmptyVNode() |
|
3302 |
+ } |
|
3303 |
+ if (!tag) { |
|
3304 |
+ // in case of component :is set to falsy value |
|
3305 |
+ return createEmptyVNode() |
|
3306 |
+ } |
|
3307 |
+ // support single function children as default scoped slot |
|
3308 |
+ if (Array.isArray(children) && |
|
3309 |
+ typeof children[0] === 'function') { |
|
3310 |
+ data = data || {}; |
|
3311 |
+ data.scopedSlots = { default: children[0] }; |
|
3312 |
+ children.length = 0; |
|
3313 |
+ } |
|
3314 |
+ if (normalizationType === ALWAYS_NORMALIZE) { |
|
3315 |
+ children = normalizeChildren(children); |
|
3316 |
+ } else if (normalizationType === SIMPLE_NORMALIZE) { |
|
3317 |
+ children = simpleNormalizeChildren(children); |
|
3318 |
+ } |
|
3319 |
+ var vnode, ns; |
|
3320 |
+ if (typeof tag === 'string') { |
|
3321 |
+ var Ctor; |
|
3322 |
+ ns = config.getTagNamespace(tag); |
|
3323 |
+ if (config.isReservedTag(tag)) { |
|
3324 |
+ // platform built-in elements |
|
3325 |
+ vnode = new VNode( |
|
3326 |
+ config.parsePlatformTagName(tag), data, children, |
|
3327 |
+ undefined, undefined, context |
|
3328 |
+ ); |
|
3329 |
+ } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) { |
|
3330 |
+ // component |
|
3331 |
+ vnode = createComponent(Ctor, data, context, children, tag); |
|
3332 |
+ } else { |
|
3333 |
+ // unknown or unlisted namespaced elements |
|
3334 |
+ // check at runtime because it may get assigned a namespace when its |
|
3335 |
+ // parent normalizes children |
|
3336 |
+ vnode = new VNode( |
|
3337 |
+ tag, data, children, |
|
3338 |
+ undefined, undefined, context |
|
3339 |
+ ); |
|
3340 |
+ } |
|
3341 |
+ } else { |
|
3342 |
+ // direct component options / constructor |
|
3343 |
+ vnode = createComponent(tag, data, context, children); |
|
3344 |
+ } |
|
3345 |
+ if (vnode) { |
|
3346 |
+ if (ns) { applyNS(vnode, ns); } |
|
3347 |
+ return vnode |
|
3348 |
+ } else { |
|
3349 |
+ return createEmptyVNode() |
|
3350 |
+ } |
|
3351 |
+} |
|
3352 |
+ |
|
3353 |
+function applyNS (vnode, ns) { |
|
3354 |
+ vnode.ns = ns; |
|
3355 |
+ if (vnode.tag === 'foreignObject') { |
|
3356 |
+ // use default namespace inside foreignObject |
|
3357 |
+ return |
|
3358 |
+ } |
|
3359 |
+ if (vnode.children) { |
|
3360 |
+ for (var i = 0, l = vnode.children.length; i < l; i++) { |
|
3361 |
+ var child = vnode.children[i]; |
|
3362 |
+ if (child.tag && !child.ns) { |
|
3363 |
+ applyNS(child, ns); |
|
3364 |
+ } |
|
3365 |
+ } |
|
3366 |
+ } |
|
3367 |
+} |
|
3368 |
+ |
|
3369 |
+/* */ |
|
3370 |
+ |
|
3371 |
+/** |
|
3372 |
+ * Runtime helper for rendering v-for lists. |
|
3373 |
+ */ |
|
3374 |
+function renderList ( |
|
3375 |
+ val, |
|
3376 |
+ render |
|
3377 |
+) { |
|
3378 |
+ var ret, i, l, keys, key; |
|
3379 |
+ if (Array.isArray(val) || typeof val === 'string') { |
|
3380 |
+ ret = new Array(val.length); |
|
3381 |
+ for (i = 0, l = val.length; i < l; i++) { |
|
3382 |
+ ret[i] = render(val[i], i); |
|
3383 |
+ } |
|
3384 |
+ } else if (typeof val === 'number') { |
|
3385 |
+ ret = new Array(val); |
|
3386 |
+ for (i = 0; i < val; i++) { |
|
3387 |
+ ret[i] = render(i + 1, i); |
|
3388 |
+ } |
|
3389 |
+ } else if (isObject(val)) { |
|
3390 |
+ keys = Object.keys(val); |
|
3391 |
+ ret = new Array(keys.length); |
|
3392 |
+ for (i = 0, l = keys.length; i < l; i++) { |
|
3393 |
+ key = keys[i]; |
|
3394 |
+ ret[i] = render(val[key], key, i); |
|
3395 |
+ } |
|
3396 |
+ } |
|
3397 |
+ return ret |
|
3398 |
+} |
|
3399 |
+ |
|
3400 |
+/* */ |
|
3401 |
+ |
|
3402 |
+/** |
|
3403 |
+ * Runtime helper for rendering <slot> |
|
3404 |
+ */ |
|
3405 |
+function renderSlot ( |
|
3406 |
+ name, |
|
3407 |
+ fallback, |
|
3408 |
+ props, |
|
3409 |
+ bindObject |
|
3410 |
+) { |
|
3411 |
+ var scopedSlotFn = this.$scopedSlots[name]; |
|
3412 |
+ if (scopedSlotFn) { // scoped slot |
|
3413 |
+ props = props || {}; |
|
3414 |
+ if (bindObject) { |
|
3415 |
+ extend(props, bindObject); |
|
3416 |
+ } |
|
3417 |
+ return scopedSlotFn(props) || fallback |
|
3418 |
+ } else { |
|
3419 |
+ var slotNodes = this.$slots[name]; |
|
3420 |
+ // warn duplicate slot usage |
|
3421 |
+ if (slotNodes && "development" !== 'production') { |
|
3422 |
+ slotNodes._rendered && warn( |
|
3423 |
+ "Duplicate presence of slot \"" + name + "\" found in the same render tree " + |
|
3424 |
+ "- this will likely cause render errors.", |
|
3425 |
+ this |
|
3426 |
+ ); |
|
3427 |
+ slotNodes._rendered = true; |
|
3428 |
+ } |
|
3429 |
+ return slotNodes || fallback |
|
3430 |
+ } |
|
3431 |
+} |
|
3432 |
+ |
|
3433 |
+/* */ |
|
3434 |
+ |
|
3435 |
+/** |
|
3436 |
+ * Runtime helper for resolving filters |
|
3437 |
+ */ |
|
3438 |
+function resolveFilter (id) { |
|
3439 |
+ return resolveAsset(this.$options, 'filters', id, true) || identity |
|
3440 |
+} |
|
3441 |
+ |
|
3442 |
+/* */ |
|
3443 |
+ |
|
3444 |
+/** |
|
3445 |
+ * Runtime helper for checking keyCodes from config. |
|
3446 |
+ */ |
|
3447 |
+function checkKeyCodes ( |
|
3448 |
+ eventKeyCode, |
|
3449 |
+ key, |
|
3450 |
+ builtInAlias |
|
3451 |
+) { |
|
3452 |
+ var keyCodes = config.keyCodes[key] || builtInAlias; |
|
3453 |
+ if (Array.isArray(keyCodes)) { |
|
3454 |
+ return keyCodes.indexOf(eventKeyCode) === -1 |
|
3455 |
+ } else { |
|
3456 |
+ return keyCodes !== eventKeyCode |
|
3457 |
+ } |
|
3458 |
+} |
|
3459 |
+ |
|
3460 |
+/* */ |
|
3461 |
+ |
|
3462 |
+/** |
|
3463 |
+ * Runtime helper for merging v-bind="object" into a VNode's data. |
|
3464 |
+ */ |
|
3465 |
+function bindObjectProps ( |
|
3466 |
+ data, |
|
3467 |
+ tag, |
|
3468 |
+ value, |
|
3469 |
+ asProp |
|
3470 |
+) { |
|
3471 |
+ if (value) { |
|
3472 |
+ if (!isObject(value)) { |
|
3473 |
+ "development" !== 'production' && warn( |
|
3474 |
+ 'v-bind without argument expects an Object or Array value', |
|
3475 |
+ this |
|
3476 |
+ ); |
|
3477 |
+ } else { |
|
3478 |
+ if (Array.isArray(value)) { |
|
3479 |
+ value = toObject(value); |
|
3480 |
+ } |
|
3481 |
+ var hash; |
|
3482 |
+ for (var key in value) { |
|
3483 |
+ if (key === 'class' || key === 'style') { |
|
3484 |
+ hash = data; |
|
3485 |
+ } else { |
|
3486 |
+ var type = data.attrs && data.attrs.type; |
|
3487 |
+ hash = asProp || config.mustUseProp(tag, type, key) |
|
3488 |
+ ? data.domProps || (data.domProps = {}) |
|
3489 |
+ : data.attrs || (data.attrs = {}); |
|
3490 |
+ } |
|
3491 |
+ if (!(key in hash)) { |
|
3492 |
+ hash[key] = value[key]; |
|
3493 |
+ } |
|
3494 |
+ } |
|
3495 |
+ } |
|
3496 |
+ } |
|
3497 |
+ return data |
|
3498 |
+} |
|
3499 |
+ |
|
3500 |
+/* */ |
|
3501 |
+ |
|
3502 |
+/** |
|
3503 |
+ * Runtime helper for rendering static trees. |
|
3504 |
+ */ |
|
3505 |
+function renderStatic ( |
|
3506 |
+ index, |
|
3507 |
+ isInFor |
|
3508 |
+) { |
|
3509 |
+ var tree = this._staticTrees[index]; |
|
3510 |
+ // if has already-rendered static tree and not inside v-for, |
|
3511 |
+ // we can reuse the same tree by doing a shallow clone. |
|
3512 |
+ if (tree && !isInFor) { |
|
3513 |
+ return Array.isArray(tree) |
|
3514 |
+ ? cloneVNodes(tree) |
|
3515 |
+ : cloneVNode(tree) |
|
3516 |
+ } |
|
3517 |
+ // otherwise, render a fresh tree. |
|
3518 |
+ tree = this._staticTrees[index] = |
|
3519 |
+ this.$options.staticRenderFns[index].call(this._renderProxy); |
|
3520 |
+ markStatic(tree, ("__static__" + index), false); |
|
3521 |
+ return tree |
|
3522 |
+} |
|
3523 |
+ |
|
3524 |
+/** |
|
3525 |
+ * Runtime helper for v-once. |
|
3526 |
+ * Effectively it means marking the node as static with a unique key. |
|
3527 |
+ */ |
|
3528 |
+function markOnce ( |
|
3529 |
+ tree, |
|
3530 |
+ index, |
|
3531 |
+ key |
|
3532 |
+) { |
|
3533 |
+ markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true); |
|
3534 |
+ return tree |
|
3535 |
+} |
|
3536 |
+ |
|
3537 |
+function markStatic ( |
|
3538 |
+ tree, |
|
3539 |
+ key, |
|
3540 |
+ isOnce |
|
3541 |
+) { |
|
3542 |
+ if (Array.isArray(tree)) { |
|
3543 |
+ for (var i = 0; i < tree.length; i++) { |
|
3544 |
+ if (tree[i] && typeof tree[i] !== 'string') { |
|
3545 |
+ markStaticNode(tree[i], (key + "_" + i), isOnce); |
|
3546 |
+ } |
|
3547 |
+ } |
|
3548 |
+ } else { |
|
3549 |
+ markStaticNode(tree, key, isOnce); |
|
3550 |
+ } |
|
3551 |
+} |
|
3552 |
+ |
|
3553 |
+function markStaticNode (node, key, isOnce) { |
|
3554 |
+ node.isStatic = true; |
|
3555 |
+ node.key = key; |
|
3556 |
+ node.isOnce = isOnce; |
|
3557 |
+} |
|
3558 |
+ |
|
3559 |
+/* */ |
|
3560 |
+ |
|
3561 |
+function initRender (vm) { |
|
3562 |
+ vm.$vnode = null; // the placeholder node in parent tree |
|
3563 |
+ vm._vnode = null; // the root of the child tree |
|
3564 |
+ vm._staticTrees = null; |
|
3565 |
+ var parentVnode = vm.$options._parentVnode; |
|
3566 |
+ var renderContext = parentVnode && parentVnode.context; |
|
3567 |
+ vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext); |
|
3568 |
+ vm.$scopedSlots = emptyObject; |
|
3569 |
+ // bind the createElement fn to this instance |
|
3570 |
+ // so that we get proper render context inside it. |
|
3571 |
+ // args order: tag, data, children, normalizationType, alwaysNormalize |
|
3572 |
+ // internal version is used by render functions compiled from templates |
|
3573 |
+ vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); }; |
|
3574 |
+ // normalization is always applied for the public version, used in |
|
3575 |
+ // user-written render functions. |
|
3576 |
+ vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }; |
|
3577 |
+} |
|
3578 |
+ |
|
3579 |
+function renderMixin (Vue) { |
|
3580 |
+ Vue.prototype.$nextTick = function (fn) { |
|
3581 |
+ return nextTick(fn, this) |
|
3582 |
+ }; |
|
3583 |
+ |
|
3584 |
+ Vue.prototype._render = function () { |
|
3585 |
+ var vm = this; |
|
3586 |
+ var ref = vm.$options; |
|
3587 |
+ var render = ref.render; |
|
3588 |
+ var staticRenderFns = ref.staticRenderFns; |
|
3589 |
+ var _parentVnode = ref._parentVnode; |
|
3590 |
+ |
|
3591 |
+ if (vm._isMounted) { |
|
3592 |
+ // clone slot nodes on re-renders |
|
3593 |
+ for (var key in vm.$slots) { |
|
3594 |
+ vm.$slots[key] = cloneVNodes(vm.$slots[key]); |
|
3595 |
+ } |
|
3596 |
+ } |
|
3597 |
+ |
|
3598 |
+ vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject; |
|
3599 |
+ |
|
3600 |
+ if (staticRenderFns && !vm._staticTrees) { |
|
3601 |
+ vm._staticTrees = []; |
|
3602 |
+ } |
|
3603 |
+ // set parent vnode. this allows render functions to have access |
|
3604 |
+ // to the data on the placeholder node. |
|
3605 |
+ vm.$vnode = _parentVnode; |
|
3606 |
+ // render self |
|
3607 |
+ var vnode; |
|
3608 |
+ try { |
|
3609 |
+ vnode = render.call(vm._renderProxy, vm.$createElement); |
|
3610 |
+ } catch (e) { |
|
3611 |
+ handleError(e, vm, "render function"); |
|
3612 |
+ // return error render result, |
|
3613 |
+ // or previous vnode to prevent render error causing blank component |
|
3614 |
+ /* istanbul ignore else */ |
|
3615 |
+ { |
|
3616 |
+ vnode = vm.$options.renderError |
|
3617 |
+ ? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e) |
|
3618 |
+ : vm._vnode; |
|
3619 |
+ } |
|
3620 |
+ } |
|
3621 |
+ // return empty vnode in case the render function errored out |
|
3622 |
+ if (!(vnode instanceof VNode)) { |
|
3623 |
+ if ("development" !== 'production' && Array.isArray(vnode)) { |
|
3624 |
+ warn( |
|
3625 |
+ 'Multiple root nodes returned from render function. Render function ' + |
|
3626 |
+ 'should return a single root node.', |
|
3627 |
+ vm |
|
3628 |
+ ); |
|
3629 |
+ } |
|
3630 |
+ vnode = createEmptyVNode(); |
|
3631 |
+ } |
|
3632 |
+ // set parent |
|
3633 |
+ vnode.parent = _parentVnode; |
|
3634 |
+ return vnode |
|
3635 |
+ }; |
|
3636 |
+ |
|
3637 |
+ // internal render helpers. |
|
3638 |
+ // these are exposed on the instance prototype to reduce generated render |
|
3639 |
+ // code size. |
|
3640 |
+ Vue.prototype._o = markOnce; |
|
3641 |
+ Vue.prototype._n = toNumber; |
|
3642 |
+ Vue.prototype._s = _toString; |
|
3643 |
+ Vue.prototype._l = renderList; |
|
3644 |
+ Vue.prototype._t = renderSlot; |
|
3645 |
+ Vue.prototype._q = looseEqual; |
|
3646 |
+ Vue.prototype._i = looseIndexOf; |
|
3647 |
+ Vue.prototype._m = renderStatic; |
|
3648 |
+ Vue.prototype._f = resolveFilter; |
|
3649 |
+ Vue.prototype._k = checkKeyCodes; |
|
3650 |
+ Vue.prototype._b = bindObjectProps; |
|
3651 |
+ Vue.prototype._v = createTextVNode; |
|
3652 |
+ Vue.prototype._e = createEmptyVNode; |
|
3653 |
+ Vue.prototype._u = resolveScopedSlots; |
|
3654 |
+} |
|
3655 |
+ |
|
3656 |
+/* */ |
|
3657 |
+ |
|
3658 |
+function initProvide (vm) { |
|
3659 |
+ var provide = vm.$options.provide; |
|
3660 |
+ if (provide) { |
|
3661 |
+ vm._provided = typeof provide === 'function' |
|
3662 |
+ ? provide.call(vm) |
|
3663 |
+ : provide; |
|
3664 |
+ } |
|
3665 |
+} |
|
3666 |
+ |
|
3667 |
+function initInjections (vm) { |
|
3668 |
+ var inject = vm.$options.inject; |
|
3669 |
+ if (inject) { |
|
3670 |
+ // inject is :any because flow is not smart enough to figure out cached |
|
3671 |
+ // isArray here |
|
3672 |
+ var isArray = Array.isArray(inject); |
|
3673 |
+ var keys = isArray |
|
3674 |
+ ? inject |
|
3675 |
+ : hasSymbol |
|
3676 |
+ ? Reflect.ownKeys(inject) |
|
3677 |
+ : Object.keys(inject); |
|
3678 |
+ |
|
3679 |
+ var loop = function ( i ) { |
|
3680 |
+ var key = keys[i]; |
|
3681 |
+ var provideKey = isArray ? key : inject[key]; |
|
3682 |
+ var source = vm; |
|
3683 |
+ while (source) { |
|
3684 |
+ if (source._provided && provideKey in source._provided) { |
|
3685 |
+ /* istanbul ignore else */ |
|
3686 |
+ { |
|
3687 |
+ defineReactive$$1(vm, key, source._provided[provideKey], function () { |
|
3688 |
+ warn( |
|
3689 |
+ "Avoid mutating an injected value directly since the changes will be " + |
|
3690 |
+ "overwritten whenever the provided component re-renders. " + |
|
3691 |
+ "injection being mutated: \"" + key + "\"", |
|
3692 |
+ vm |
|
3693 |
+ ); |
|
3694 |
+ }); |
|
3695 |
+ } |
|
3696 |
+ break |
|
3697 |
+ } |
|
3698 |
+ source = source.$parent; |
|
3699 |
+ } |
|
3700 |
+ }; |
|
3701 |
+ |
|
3702 |
+ for (var i = 0; i < keys.length; i++) loop( i ); |
|
3703 |
+ } |
|
3704 |
+} |
|
3705 |
+ |
|
3706 |
+/* */ |
|
3707 |
+ |
|
3708 |
+var uid = 0; |
|
3709 |
+ |
|
3710 |
+function initMixin (Vue) { |
|
3711 |
+ Vue.prototype._init = function (options) { |
|
3712 |
+ var vm = this; |
|
3713 |
+ // a uid |
|
3714 |
+ vm._uid = uid++; |
|
3715 |
+ |
|
3716 |
+ var startTag, endTag; |
|
3717 |
+ /* istanbul ignore if */ |
|
3718 |
+ if ("development" !== 'production' && config.performance && mark) { |
|
3719 |
+ startTag = "vue-perf-init:" + (vm._uid); |
|
3720 |
+ endTag = "vue-perf-end:" + (vm._uid); |
|
3721 |
+ mark(startTag); |
|
3722 |
+ } |
|
3723 |
+ |
|
3724 |
+ // a flag to avoid this being observed |
|
3725 |
+ vm._isVue = true; |
|
3726 |
+ // merge options |
|
3727 |
+ if (options && options._isComponent) { |
|
3728 |
+ // optimize internal component instantiation |
|
3729 |
+ // since dynamic options merging is pretty slow, and none of the |
|
3730 |
+ // internal component options needs special treatment. |
|
3731 |
+ initInternalComponent(vm, options); |
|
3732 |
+ } else { |
|
3733 |
+ vm.$options = mergeOptions( |
|
3734 |
+ resolveConstructorOptions(vm.constructor), |
|
3735 |
+ options || {}, |
|
3736 |
+ vm |
|
3737 |
+ ); |
|
3738 |
+ } |
|
3739 |
+ /* istanbul ignore else */ |
|
3740 |
+ { |
|
3741 |
+ initProxy(vm); |
|
3742 |
+ } |
|
3743 |
+ // expose real self |
|
3744 |
+ vm._self = vm; |
|
3745 |
+ initLifecycle(vm); |
|
3746 |
+ initEvents(vm); |
|
3747 |
+ initRender(vm); |
|
3748 |
+ callHook(vm, 'beforeCreate'); |
|
3749 |
+ initInjections(vm); // resolve injections before data/props |
|
3750 |
+ initState(vm); |
|
3751 |
+ initProvide(vm); // resolve provide after data/props |
|
3752 |
+ callHook(vm, 'created'); |
|
3753 |
+ |
|
3754 |
+ /* istanbul ignore if */ |
|
3755 |
+ if ("development" !== 'production' && config.performance && mark) { |
|
3756 |
+ vm._name = formatComponentName(vm, false); |
|
3757 |
+ mark(endTag); |
|
3758 |
+ measure(((vm._name) + " init"), startTag, endTag); |
|
3759 |
+ } |
|
3760 |
+ |
|
3761 |
+ if (vm.$options.el) { |
|
3762 |
+ vm.$mount(vm.$options.el); |
|
3763 |
+ } |
|
3764 |
+ }; |
|
3765 |
+} |
|
3766 |
+ |
|
3767 |
+function initInternalComponent (vm, options) { |
|
3768 |
+ var opts = vm.$options = Object.create(vm.constructor.options); |
|
3769 |
+ // doing this because it's faster than dynamic enumeration. |
|
3770 |
+ opts.parent = options.parent; |
|
3771 |
+ opts.propsData = options.propsData; |
|
3772 |
+ opts._parentVnode = options._parentVnode; |
|
3773 |
+ opts._parentListeners = options._parentListeners; |
|
3774 |
+ opts._renderChildren = options._renderChildren; |
|
3775 |
+ opts._componentTag = options._componentTag; |
|
3776 |
+ opts._parentElm = options._parentElm; |
|
3777 |
+ opts._refElm = options._refElm; |
|
3778 |
+ if (options.render) { |
|
3779 |
+ opts.render = options.render; |
|
3780 |
+ opts.staticRenderFns = options.staticRenderFns; |
|
3781 |
+ } |
|
3782 |
+} |
|
3783 |
+ |
|
3784 |
+function resolveConstructorOptions (Ctor) { |
|
3785 |
+ var options = Ctor.options; |
|
3786 |
+ if (Ctor.super) { |
|
3787 |
+ var superOptions = resolveConstructorOptions(Ctor.super); |
|
3788 |
+ var cachedSuperOptions = Ctor.superOptions; |
|
3789 |
+ if (superOptions !== cachedSuperOptions) { |
|
3790 |
+ // super option changed, |
|
3791 |
+ // need to resolve new options. |
|
3792 |
+ Ctor.superOptions = superOptions; |
|
3793 |
+ // check if there are any late-modified/attached options (#4976) |
|
3794 |
+ var modifiedOptions = resolveModifiedOptions(Ctor); |
|
3795 |
+ // update base extend options |
|
3796 |
+ if (modifiedOptions) { |
|
3797 |
+ extend(Ctor.extendOptions, modifiedOptions); |
|
3798 |
+ } |
|
3799 |
+ options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions); |
|
3800 |
+ if (options.name) { |
|
3801 |
+ options.components[options.name] = Ctor; |
|
3802 |
+ } |
|
3803 |
+ } |
|
3804 |
+ } |
|
3805 |
+ return options |
|
3806 |
+} |
|
3807 |
+ |
|
3808 |
+function resolveModifiedOptions (Ctor) { |
|
3809 |
+ var modified; |
|
3810 |
+ var latest = Ctor.options; |
|
3811 |
+ var sealed = Ctor.sealedOptions; |
|
3812 |
+ for (var key in latest) { |
|
3813 |
+ if (latest[key] !== sealed[key]) { |
|
3814 |
+ if (!modified) { modified = {}; } |
|
3815 |
+ modified[key] = dedupe(latest[key], sealed[key]); |
|
3816 |
+ } |
|
3817 |
+ } |
|
3818 |
+ return modified |
|
3819 |
+} |
|
3820 |
+ |
|
3821 |
+function dedupe (latest, sealed) { |
|
3822 |
+ // compare latest and sealed to ensure lifecycle hooks won't be duplicated |
|
3823 |
+ // between merges |
|
3824 |
+ if (Array.isArray(latest)) { |
|
3825 |
+ var res = []; |
|
3826 |
+ sealed = Array.isArray(sealed) ? sealed : [sealed]; |
|
3827 |
+ for (var i = 0; i < latest.length; i++) { |
|
3828 |
+ if (sealed.indexOf(latest[i]) < 0) { |
|
3829 |
+ res.push(latest[i]); |
|
3830 |
+ } |
|
3831 |
+ } |
|
3832 |
+ return res |
|
3833 |
+ } else { |
|
3834 |
+ return latest |
|
3835 |
+ } |
|
3836 |
+} |
|
3837 |
+ |
|
3838 |
+function Vue$3 (options) { |
|
3839 |
+ if ("development" !== 'production' && |
|
3840 |
+ !(this instanceof Vue$3)) { |
|
3841 |
+ warn('Vue is a constructor and should be called with the `new` keyword'); |
|
3842 |
+ } |
|
3843 |
+ this._init(options); |
|
3844 |
+} |
|
3845 |
+ |
|
3846 |
+initMixin(Vue$3); |
|
3847 |
+stateMixin(Vue$3); |
|
3848 |
+eventsMixin(Vue$3); |
|
3849 |
+lifecycleMixin(Vue$3); |
|
3850 |
+renderMixin(Vue$3); |
|
3851 |
+ |
|
3852 |
+/* */ |
|
3853 |
+ |
|
3854 |
+function initUse (Vue) { |
|
3855 |
+ Vue.use = function (plugin) { |
|
3856 |
+ /* istanbul ignore if */ |
|
3857 |
+ if (plugin.installed) { |
|
3858 |
+ return |
|
3859 |
+ } |
|
3860 |
+ // additional parameters |
|
3861 |
+ var args = toArray(arguments, 1); |
|
3862 |
+ args.unshift(this); |
|
3863 |
+ if (typeof plugin.install === 'function') { |
|
3864 |
+ plugin.install.apply(plugin, args); |
|
3865 |
+ } else if (typeof plugin === 'function') { |
|
3866 |
+ plugin.apply(null, args); |
|
3867 |
+ } |
|
3868 |
+ plugin.installed = true; |
|
3869 |
+ return this |
|
3870 |
+ }; |
|
3871 |
+} |
|
3872 |
+ |
|
3873 |
+/* */ |
|
3874 |
+ |
|
3875 |
+function initMixin$1 (Vue) { |
|
3876 |
+ Vue.mixin = function (mixin) { |
|
3877 |
+ this.options = mergeOptions(this.options, mixin); |
|
3878 |
+ }; |
|
3879 |
+} |
|
3880 |
+ |
|
3881 |
+/* */ |
|
3882 |
+ |
|
3883 |
+function initExtend (Vue) { |
|
3884 |
+ /** |
|
3885 |
+ * Each instance constructor, including Vue, has a unique |
|
3886 |
+ * cid. This enables us to create wrapped "child |
|
3887 |
+ * constructors" for prototypal inheritance and cache them. |
|
3888 |
+ */ |
|
3889 |
+ Vue.cid = 0; |
|
3890 |
+ var cid = 1; |
|
3891 |
+ |
|
3892 |
+ /** |
|
3893 |
+ * Class inheritance |
|
3894 |
+ */ |
|
3895 |
+ Vue.extend = function (extendOptions) { |
|
3896 |
+ extendOptions = extendOptions || {}; |
|
3897 |
+ var Super = this; |
|
3898 |
+ var SuperId = Super.cid; |
|
3899 |
+ var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {}); |
|
3900 |
+ if (cachedCtors[SuperId]) { |
|
3901 |
+ return cachedCtors[SuperId] |
|
3902 |
+ } |
|
3903 |
+ |
|
3904 |
+ var name = extendOptions.name || Super.options.name; |
|
3905 |
+ { |
|
3906 |
+ if (!/^[a-zA-Z][\w-]*$/.test(name)) { |
|
3907 |
+ warn( |
|
3908 |
+ 'Invalid component name: "' + name + '". Component names ' + |
|
3909 |
+ 'can only contain alphanumeric characters and the hyphen, ' + |
|
3910 |
+ 'and must start with a letter.' |
|
3911 |
+ ); |
|
3912 |
+ } |
|
3913 |
+ } |
|
3914 |
+ |
|
3915 |
+ var Sub = function VueComponent (options) { |
|
3916 |
+ this._init(options); |
|
3917 |
+ }; |
|
3918 |
+ Sub.prototype = Object.create(Super.prototype); |
|
3919 |
+ Sub.prototype.constructor = Sub; |
|
3920 |
+ Sub.cid = cid++; |
|
3921 |
+ Sub.options = mergeOptions( |
|
3922 |
+ Super.options, |
|
3923 |
+ extendOptions |
|
3924 |
+ ); |
|
3925 |
+ Sub['super'] = Super; |
|
3926 |
+ |
|
3927 |
+ // For props and computed properties, we define the proxy getters on |
|
3928 |
+ // the Vue instances at extension time, on the extended prototype. This |
|
3929 |
+ // avoids Object.defineProperty calls for each instance created. |
|
3930 |
+ if (Sub.options.props) { |
|
3931 |
+ initProps$1(Sub); |
|
3932 |
+ } |
|
3933 |
+ if (Sub.options.computed) { |
|
3934 |
+ initComputed$1(Sub); |
|
3935 |
+ } |
|
3936 |
+ |
|
3937 |
+ // allow further extension/mixin/plugin usage |
|
3938 |
+ Sub.extend = Super.extend; |
|
3939 |
+ Sub.mixin = Super.mixin; |
|
3940 |
+ Sub.use = Super.use; |
|
3941 |
+ |
|
3942 |
+ // create asset registers, so extended classes |
|
3943 |
+ // can have their private assets too. |
|
3944 |
+ config._assetTypes.forEach(function (type) { |
|
3945 |
+ Sub[type] = Super[type]; |
|
3946 |
+ }); |
|
3947 |
+ // enable recursive self-lookup |
|
3948 |
+ if (name) { |
|
3949 |
+ Sub.options.components[name] = Sub; |
|
3950 |
+ } |
|
3951 |
+ |
|
3952 |
+ // keep a reference to the super options at extension time. |
|
3953 |
+ // later at instantiation we can check if Super's options have |
|
3954 |
+ // been updated. |
|
3955 |
+ Sub.superOptions = Super.options; |
|
3956 |
+ Sub.extendOptions = extendOptions; |
|
3957 |
+ Sub.sealedOptions = extend({}, Sub.options); |
|
3958 |
+ |
|
3959 |
+ // cache constructor |
|
3960 |
+ cachedCtors[SuperId] = Sub; |
|
3961 |
+ return Sub |
|
3962 |
+ }; |
|
3963 |
+} |
|
3964 |
+ |
|
3965 |
+function initProps$1 (Comp) { |
|
3966 |
+ var props = Comp.options.props; |
|
3967 |
+ for (var key in props) { |
|
3968 |
+ proxy(Comp.prototype, "_props", key); |
|
3969 |
+ } |
|
3970 |
+} |
|
3971 |
+ |
|
3972 |
+function initComputed$1 (Comp) { |
|
3973 |
+ var computed = Comp.options.computed; |
|
3974 |
+ for (var key in computed) { |
|
3975 |
+ defineComputed(Comp.prototype, key, computed[key]); |
|
3976 |
+ } |
|
3977 |
+} |
|
3978 |
+ |
|
3979 |
+/* */ |
|
3980 |
+ |
|
3981 |
+function initAssetRegisters (Vue) { |
|
3982 |
+ /** |
|
3983 |
+ * Create asset registration methods. |
|
3984 |
+ */ |
|
3985 |
+ config._assetTypes.forEach(function (type) { |
|
3986 |
+ Vue[type] = function ( |
|
3987 |
+ id, |
|
3988 |
+ definition |
|
3989 |
+ ) { |
|
3990 |
+ if (!definition) { |
|
3991 |
+ return this.options[type + 's'][id] |
|
3992 |
+ } else { |
|
3993 |
+ /* istanbul ignore if */ |
|
3994 |
+ { |
|
3995 |
+ if (type === 'component' && config.isReservedTag(id)) { |
|
3996 |
+ warn( |
|
3997 |
+ 'Do not use built-in or reserved HTML elements as component ' + |
|
3998 |
+ 'id: ' + id |
|
3999 |
+ ); |
|
4000 |
+ } |
|
4001 |
+ } |
|
4002 |
+ if (type === 'component' && isPlainObject(definition)) { |
|
4003 |
+ definition.name = definition.name || id; |
|
4004 |
+ definition = this.options._base.extend(definition); |
|
4005 |
+ } |
|
4006 |
+ if (type === 'directive' && typeof definition === 'function') { |
|
4007 |
+ definition = { bind: definition, update: definition }; |
|
4008 |
+ } |
|
4009 |
+ this.options[type + 's'][id] = definition; |
|
4010 |
+ return definition |
|
4011 |
+ } |
|
4012 |
+ }; |
|
4013 |
+ }); |
|
4014 |
+} |
|
4015 |
+ |
|
4016 |
+/* */ |
|
4017 |
+ |
|
4018 |
+var patternTypes = [String, RegExp]; |
|
4019 |
+ |
|
4020 |
+function getComponentName (opts) { |
|
4021 |
+ return opts && (opts.Ctor.options.name || opts.tag) |
|
4022 |
+} |
|
4023 |
+ |
|
4024 |
+function matches (pattern, name) { |
|
4025 |
+ if (typeof pattern === 'string') { |
|
4026 |
+ return pattern.split(',').indexOf(name) > -1 |
|
4027 |
+ } else if (pattern instanceof RegExp) { |
|
4028 |
+ return pattern.test(name) |
|
4029 |
+ } |
|
4030 |
+ /* istanbul ignore next */ |
|
4031 |
+ return false |
|
4032 |
+} |
|
4033 |
+ |
|
4034 |
+function pruneCache (cache, filter) { |
|
4035 |
+ for (var key in cache) { |
|
4036 |
+ var cachedNode = cache[key]; |
|
4037 |
+ if (cachedNode) { |
|
4038 |
+ var name = getComponentName(cachedNode.componentOptions); |
|
4039 |
+ if (name && !filter(name)) { |
|
4040 |
+ pruneCacheEntry(cachedNode); |
|
4041 |
+ cache[key] = null; |
|
4042 |
+ } |
|
4043 |
+ } |
|
4044 |
+ } |
|
4045 |
+} |
|
4046 |
+ |
|
4047 |
+function pruneCacheEntry (vnode) { |
|
4048 |
+ if (vnode) { |
|
4049 |
+ if (!vnode.componentInstance._inactive) { |
|
4050 |
+ callHook(vnode.componentInstance, 'deactivated'); |
|
4051 |
+ } |
|
4052 |
+ vnode.componentInstance.$destroy(); |
|
4053 |
+ } |
|
4054 |
+} |
|
4055 |
+ |
|
4056 |
+var KeepAlive = { |
|
4057 |
+ name: 'keep-alive', |
|
4058 |
+ abstract: true, |
|
4059 |
+ |
|
4060 |
+ props: { |
|
4061 |
+ include: patternTypes, |
|
4062 |
+ exclude: patternTypes |
|
4063 |
+ }, |
|
4064 |
+ |
|
4065 |
+ created: function created () { |
|
4066 |
+ this.cache = Object.create(null); |
|
4067 |
+ }, |
|
4068 |
+ |
|
4069 |
+ destroyed: function destroyed () { |
|
4070 |
+ var this$1 = this; |
|
4071 |
+ |
|
4072 |
+ for (var key in this$1.cache) { |
|
4073 |
+ pruneCacheEntry(this$1.cache[key]); |
|
4074 |
+ } |
|
4075 |
+ }, |
|
4076 |
+ |
|
4077 |
+ watch: { |
|
4078 |
+ include: function include (val) { |
|
4079 |
+ pruneCache(this.cache, function (name) { return matches(val, name); }); |
|
4080 |
+ }, |
|
4081 |
+ exclude: function exclude (val) { |
|
4082 |
+ pruneCache(this.cache, function (name) { return !matches(val, name); }); |
|
4083 |
+ } |
|
4084 |
+ }, |
|
4085 |
+ |
|
4086 |
+ render: function render () { |
|
4087 |
+ var vnode = getFirstComponentChild(this.$slots.default); |
|
4088 |
+ var componentOptions = vnode && vnode.componentOptions; |
|
4089 |
+ if (componentOptions) { |
|
4090 |
+ // check pattern |
|
4091 |
+ var name = getComponentName(componentOptions); |
|
4092 |
+ if (name && ( |
|
4093 |
+ (this.include && !matches(this.include, name)) || |
|
4094 |
+ (this.exclude && matches(this.exclude, name)) |
|
4095 |
+ )) { |
|
4096 |
+ return vnode |
|
4097 |
+ } |
|
4098 |
+ var key = vnode.key == null |
|
4099 |
+ // same constructor may get registered as different local components |
|
4100 |
+ // so cid alone is not enough (#3269) |
|
4101 |
+ ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '') |
|
4102 |
+ : vnode.key; |
|
4103 |
+ if (this.cache[key]) { |
|
4104 |
+ vnode.componentInstance = this.cache[key].componentInstance; |
|
4105 |
+ } else { |
|
4106 |
+ this.cache[key] = vnode; |
|
4107 |
+ } |
|
4108 |
+ vnode.data.keepAlive = true; |
|
4109 |
+ } |
|
4110 |
+ return vnode |
|
4111 |
+ } |
|
4112 |
+}; |
|
4113 |
+ |
|
4114 |
+var builtInComponents = { |
|
4115 |
+ KeepAlive: KeepAlive |
|
4116 |
+}; |
|
4117 |
+ |
|
4118 |
+/* */ |
|
4119 |
+ |
|
4120 |
+function initGlobalAPI (Vue) { |
|
4121 |
+ // config |
|
4122 |
+ var configDef = {}; |
|
4123 |
+ configDef.get = function () { return config; }; |
|
4124 |
+ { |
|
4125 |
+ configDef.set = function () { |
|
4126 |
+ warn( |
|
4127 |
+ 'Do not replace the Vue.config object, set individual fields instead.' |
|
4128 |
+ ); |
|
4129 |
+ }; |
|
4130 |
+ } |
|
4131 |
+ Object.defineProperty(Vue, 'config', configDef); |
|
4132 |
+ |
|
4133 |
+ // exposed util methods. |
|
4134 |
+ // NOTE: these are not considered part of the public API - avoid relying on |
|
4135 |
+ // them unless you are aware of the risk. |
|
4136 |
+ Vue.util = { |
|
4137 |
+ warn: warn, |
|
4138 |
+ extend: extend, |
|
4139 |
+ mergeOptions: mergeOptions, |
|
4140 |
+ defineReactive: defineReactive$$1 |
|
4141 |
+ }; |
|
4142 |
+ |
|
4143 |
+ Vue.set = set; |
|
4144 |
+ Vue.delete = del; |
|
4145 |
+ Vue.nextTick = nextTick; |
|
4146 |
+ |
|
4147 |
+ Vue.options = Object.create(null); |
|
4148 |
+ config._assetTypes.forEach(function (type) { |
|
4149 |
+ Vue.options[type + 's'] = Object.create(null); |
|
4150 |
+ }); |
|
4151 |
+ |
|
4152 |
+ // this is used to identify the "base" constructor to extend all plain-object |
|
4153 |
+ // components with in Weex's multi-instance scenarios. |
|
4154 |
+ Vue.options._base = Vue; |
|
4155 |
+ |
|
4156 |
+ extend(Vue.options.components, builtInComponents); |
|
4157 |
+ |
|
4158 |
+ initUse(Vue); |
|
4159 |
+ initMixin$1(Vue); |
|
4160 |
+ initExtend(Vue); |
|
4161 |
+ initAssetRegisters(Vue); |
|
4162 |
+} |
|
4163 |
+ |
|
4164 |
+initGlobalAPI(Vue$3); |
|
4165 |
+ |
|
4166 |
+Object.defineProperty(Vue$3.prototype, '$isServer', { |
|
4167 |
+ get: isServerRendering |
|
4168 |
+}); |
|
4169 |
+ |
|
4170 |
+Vue$3.version = '2.2.6'; |
|
4171 |
+ |
|
4172 |
+/* */ |
|
4173 |
+ |
|
4174 |
+// attributes that should be using props for binding |
|
4175 |
+var acceptValue = makeMap('input,textarea,option,select'); |
|
4176 |
+var mustUseProp = function (tag, type, attr) { |
|
4177 |
+ return ( |
|
4178 |
+ (attr === 'value' && acceptValue(tag)) && type !== 'button' || |
|
4179 |
+ (attr === 'selected' && tag === 'option') || |
|
4180 |
+ (attr === 'checked' && tag === 'input') || |
|
4181 |
+ (attr === 'muted' && tag === 'video') |
|
4182 |
+ ) |
|
4183 |
+}; |
|
4184 |
+ |
|
4185 |
+var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck'); |
|
4186 |
+ |
|
4187 |
+var isBooleanAttr = makeMap( |
|
4188 |
+ 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + |
|
4189 |
+ 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + |
|
4190 |
+ 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + |
|
4191 |
+ 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + |
|
4192 |
+ 'required,reversed,scoped,seamless,selected,sortable,translate,' + |
|
4193 |
+ 'truespeed,typemustmatch,visible' |
|
4194 |
+); |
|
4195 |
+ |
|
4196 |
+var xlinkNS = 'http://www.w3.org/1999/xlink'; |
|
4197 |
+ |
|
4198 |
+var isXlink = function (name) { |
|
4199 |
+ return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink' |
|
4200 |
+}; |
|
4201 |
+ |
|
4202 |
+var getXlinkProp = function (name) { |
|
4203 |
+ return isXlink(name) ? name.slice(6, name.length) : '' |
|
4204 |
+}; |
|
4205 |
+ |
|
4206 |
+var isFalsyAttrValue = function (val) { |
|
4207 |
+ return val == null || val === false |
|
4208 |
+}; |
|
4209 |
+ |
|
4210 |
+/* */ |
|
4211 |
+ |
|
4212 |
+function genClassForVnode (vnode) { |
|
4213 |
+ var data = vnode.data; |
|
4214 |
+ var parentNode = vnode; |
|
4215 |
+ var childNode = vnode; |
|
4216 |
+ while (childNode.componentInstance) { |
|
4217 |
+ childNode = childNode.componentInstance._vnode; |
|
4218 |
+ if (childNode.data) { |
|
4219 |
+ data = mergeClassData(childNode.data, data); |
|
4220 |
+ } |
|
4221 |
+ } |
|
4222 |
+ while ((parentNode = parentNode.parent)) { |
|
4223 |
+ if (parentNode.data) { |
|
4224 |
+ data = mergeClassData(data, parentNode.data); |
|
4225 |
+ } |
|
4226 |
+ } |
|
4227 |
+ return genClassFromData(data) |
|
4228 |
+} |
|
4229 |
+ |
|
4230 |
+function mergeClassData (child, parent) { |
|
4231 |
+ return { |
|
4232 |
+ staticClass: concat(child.staticClass, parent.staticClass), |
|
4233 |
+ class: child.class |
|
4234 |
+ ? [child.class, parent.class] |
|
4235 |
+ : parent.class |
|
4236 |
+ } |
|
4237 |
+} |
|
4238 |
+ |
|
4239 |
+function genClassFromData (data) { |
|
4240 |
+ var dynamicClass = data.class; |
|
4241 |
+ var staticClass = data.staticClass; |
|
4242 |
+ if (staticClass || dynamicClass) { |
|
4243 |
+ return concat(staticClass, stringifyClass(dynamicClass)) |
|
4244 |
+ } |
|
4245 |
+ /* istanbul ignore next */ |
|
4246 |
+ return '' |
|
4247 |
+} |
|
4248 |
+ |
|
4249 |
+function concat (a, b) { |
|
4250 |
+ return a ? b ? (a + ' ' + b) : a : (b || '') |
|
4251 |
+} |
|
4252 |
+ |
|
4253 |
+function stringifyClass (value) { |
|
4254 |
+ var res = ''; |
|
4255 |
+ if (!value) { |
|
4256 |
+ return res |
|
4257 |
+ } |
|
4258 |
+ if (typeof value === 'string') { |
|
4259 |
+ return value |
|
4260 |
+ } |
|
4261 |
+ if (Array.isArray(value)) { |
|
4262 |
+ var stringified; |
|
4263 |
+ for (var i = 0, l = value.length; i < l; i++) { |
|
4264 |
+ if (value[i]) { |
|
4265 |
+ if ((stringified = stringifyClass(value[i]))) { |
|
4266 |
+ res += stringified + ' '; |
|
4267 |
+ } |
|
4268 |
+ } |
|
4269 |
+ } |
|
4270 |
+ return res.slice(0, -1) |
|
4271 |
+ } |
|
4272 |
+ if (isObject(value)) { |
|
4273 |
+ for (var key in value) { |
|
4274 |
+ if (value[key]) { res += key + ' '; } |
|
4275 |
+ } |
|
4276 |
+ return res.slice(0, -1) |
|
4277 |
+ } |
|
4278 |
+ /* istanbul ignore next */ |
|
4279 |
+ return res |
|
4280 |
+} |
|
4281 |
+ |
|
4282 |
+/* */ |
|
4283 |
+ |
|
4284 |
+var namespaceMap = { |
|
4285 |
+ svg: 'http://www.w3.org/2000/svg', |
|
4286 |
+ math: 'http://www.w3.org/1998/Math/MathML' |
|
4287 |
+}; |
|
4288 |
+ |
|
4289 |
+var isHTMLTag = makeMap( |
|
4290 |
+ 'html,body,base,head,link,meta,style,title,' + |
|
4291 |
+ 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + |
|
4292 |
+ 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' + |
|
4293 |
+ 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + |
|
4294 |
+ 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + |
|
4295 |
+ 'embed,object,param,source,canvas,script,noscript,del,ins,' + |
|
4296 |
+ 'caption,col,colgroup,table,thead,tbody,td,th,tr,' + |
|
4297 |
+ 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + |
|
4298 |
+ 'output,progress,select,textarea,' + |
|
4299 |
+ 'details,dialog,menu,menuitem,summary,' + |
|
4300 |
+ 'content,element,shadow,template' |
|
4301 |
+); |
|
4302 |
+ |
|
4303 |
+// this map is intentionally selective, only covering SVG elements that may |
|
4304 |
+// contain child elements. |
|
4305 |
+var isSVG = makeMap( |
|
4306 |
+ 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' + |
|
4307 |
+ 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + |
|
4308 |
+ 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', |
|
4309 |
+ true |
|
4310 |
+); |
|
4311 |
+ |
|
4312 |
+var isPreTag = function (tag) { return tag === 'pre'; }; |
|
4313 |
+ |
|
4314 |
+var isReservedTag = function (tag) { |
|
4315 |
+ return isHTMLTag(tag) || isSVG(tag) |
|
4316 |
+}; |
|
4317 |
+ |
|
4318 |
+function getTagNamespace (tag) { |
|
4319 |
+ if (isSVG(tag)) { |
|
4320 |
+ return 'svg' |
|
4321 |
+ } |
|
4322 |
+ // basic support for MathML |
|
4323 |
+ // note it doesn't support other MathML elements being component roots |
|
4324 |
+ if (tag === 'math') { |
|
4325 |
+ return 'math' |
|
4326 |
+ } |
|
4327 |
+} |
|
4328 |
+ |
|
4329 |
+var unknownElementCache = Object.create(null); |
|
4330 |
+function isUnknownElement (tag) { |
|
4331 |
+ /* istanbul ignore if */ |
|
4332 |
+ if (!inBrowser) { |
|
4333 |
+ return true |
|
4334 |
+ } |
|
4335 |
+ if (isReservedTag(tag)) { |
|
4336 |
+ return false |
|
4337 |
+ } |
|
4338 |
+ tag = tag.toLowerCase(); |
|
4339 |
+ /* istanbul ignore if */ |
|
4340 |
+ if (unknownElementCache[tag] != null) { |
|
4341 |
+ return unknownElementCache[tag] |
|
4342 |
+ } |
|
4343 |
+ var el = document.createElement(tag); |
|
4344 |
+ if (tag.indexOf('-') > -1) { |
|
4345 |
+ // http://stackoverflow.com/a/28210364/1070244 |
|
4346 |
+ return (unknownElementCache[tag] = ( |
|
4347 |
+ el.constructor === window.HTMLUnknownElement || |
|
4348 |
+ el.constructor === window.HTMLElement |
|
4349 |
+ )) |
|
4350 |
+ } else { |
|
4351 |
+ return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString())) |
|
4352 |
+ } |
|
4353 |
+} |
|
4354 |
+ |
|
4355 |
+/* */ |
|
4356 |
+ |
|
4357 |
+/** |
|
4358 |
+ * Query an element selector if it's not an element already. |
|
4359 |
+ */ |
|
4360 |
+function query (el) { |
|
4361 |
+ if (typeof el === 'string') { |
|
4362 |
+ var selected = document.querySelector(el); |
|
4363 |
+ if (!selected) { |
|
4364 |
+ "development" !== 'production' && warn( |
|
4365 |
+ 'Cannot find element: ' + el |
|
4366 |
+ ); |
|
4367 |
+ return document.createElement('div') |
|
4368 |
+ } |
|
4369 |
+ return selected |
|
4370 |
+ } else { |
|
4371 |
+ return el |
|
4372 |
+ } |
|
4373 |
+} |
|
4374 |
+ |
|
4375 |
+/* */ |
|
4376 |
+ |
|
4377 |
+function createElement$1 (tagName, vnode) { |
|
4378 |
+ var elm = document.createElement(tagName); |
|
4379 |
+ if (tagName !== 'select') { |
|
4380 |
+ return elm |
|
4381 |
+ } |
|
4382 |
+ // false or null will remove the attribute but undefined will not |
|
4383 |
+ if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) { |
|
4384 |
+ elm.setAttribute('multiple', 'multiple'); |
|
4385 |
+ } |
|
4386 |
+ return elm |
|
4387 |
+} |
|
4388 |
+ |
|
4389 |
+function createElementNS (namespace, tagName) { |
|
4390 |
+ return document.createElementNS(namespaceMap[namespace], tagName) |
|
4391 |
+} |
|
4392 |
+ |
|
4393 |
+function createTextNode (text) { |
|
4394 |
+ return document.createTextNode(text) |
|
4395 |
+} |
|
4396 |
+ |
|
4397 |
+function createComment (text) { |
|
4398 |
+ return document.createComment(text) |
|
4399 |
+} |
|
4400 |
+ |
|
4401 |
+function insertBefore (parentNode, newNode, referenceNode) { |
|
4402 |
+ parentNode.insertBefore(newNode, referenceNode); |
|
4403 |
+} |
|
4404 |
+ |
|
4405 |
+function removeChild (node, child) { |
|
4406 |
+ node.removeChild(child); |
|
4407 |
+} |
|
4408 |
+ |
|
4409 |
+function appendChild (node, child) { |
|
4410 |
+ node.appendChild(child); |
|
4411 |
+} |
|
4412 |
+ |
|
4413 |
+function parentNode (node) { |
|
4414 |
+ return node.parentNode |
|
4415 |
+} |
|
4416 |
+ |
|
4417 |
+function nextSibling (node) { |
|
4418 |
+ return node.nextSibling |
|
4419 |
+} |
|
4420 |
+ |
|
4421 |
+function tagName (node) { |
|
4422 |
+ return node.tagName |
|
4423 |
+} |
|
4424 |
+ |
|
4425 |
+function setTextContent (node, text) { |
|
4426 |
+ node.textContent = text; |
|
4427 |
+} |
|
4428 |
+ |
|
4429 |
+function setAttribute (node, key, val) { |
|
4430 |
+ node.setAttribute(key, val); |
|
4431 |
+} |
|
4432 |
+ |
|
4433 |
+ |
|
4434 |
+var nodeOps = Object.freeze({ |
|
4435 |
+ createElement: createElement$1, |
|
4436 |
+ createElementNS: createElementNS, |
|
4437 |
+ createTextNode: createTextNode, |
|
4438 |
+ createComment: createComment, |
|
4439 |
+ insertBefore: insertBefore, |
|
4440 |
+ removeChild: removeChild, |
|
4441 |
+ appendChild: appendChild, |
|
4442 |
+ parentNode: parentNode, |
|
4443 |
+ nextSibling: nextSibling, |
|
4444 |
+ tagName: tagName, |
|
4445 |
+ setTextContent: setTextContent, |
|
4446 |
+ setAttribute: setAttribute |
|
4447 |
+}); |
|
4448 |
+ |
|
4449 |
+/* */ |
|
4450 |
+ |
|
4451 |
+var ref = { |
|
4452 |
+ create: function create (_, vnode) { |
|
4453 |
+ registerRef(vnode); |
|
4454 |
+ }, |
|
4455 |
+ update: function update (oldVnode, vnode) { |
|
4456 |
+ if (oldVnode.data.ref !== vnode.data.ref) { |
|
4457 |
+ registerRef(oldVnode, true); |
|
4458 |
+ registerRef(vnode); |
|
4459 |
+ } |
|
4460 |
+ }, |
|
4461 |
+ destroy: function destroy (vnode) { |
|
4462 |
+ registerRef(vnode, true); |
|
4463 |
+ } |
|
4464 |
+}; |
|
4465 |
+ |
|
4466 |
+function registerRef (vnode, isRemoval) { |
|
4467 |
+ var key = vnode.data.ref; |
|
4468 |
+ if (!key) { return } |
|
4469 |
+ |
|
4470 |
+ var vm = vnode.context; |
|
4471 |
+ var ref = vnode.componentInstance || vnode.elm; |
|
4472 |
+ var refs = vm.$refs; |
|
4473 |
+ if (isRemoval) { |
|
4474 |
+ if (Array.isArray(refs[key])) { |
|
4475 |
+ remove(refs[key], ref); |
|
4476 |
+ } else if (refs[key] === ref) { |
|
4477 |
+ refs[key] = undefined; |
|
4478 |
+ } |
|
4479 |
+ } else { |
|
4480 |
+ if (vnode.data.refInFor) { |
|
4481 |
+ if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) { |
|
4482 |
+ refs[key].push(ref); |
|
4483 |
+ } else { |
|
4484 |
+ refs[key] = [ref]; |
|
4485 |
+ } |
|
4486 |
+ } else { |
|
4487 |
+ refs[key] = ref; |
|
4488 |
+ } |
|
4489 |
+ } |
|
4490 |
+} |
|
4491 |
+ |
|
4492 |
+/** |
|
4493 |
+ * Virtual DOM patching algorithm based on Snabbdom by |
|
4494 |
+ * Simon Friis Vindum (@paldepind) |
|
4495 |
+ * Licensed under the MIT License |
|
4496 |
+ * https://github.com/paldepind/snabbdom/blob/master/LICENSE |
|
4497 |
+ * |
|
4498 |
+ * modified by Evan You (@yyx990803) |
|
4499 |
+ * |
|
4500 |
+ |
|
4501 |
+/* |
|
4502 |
+ * Not type-checking this because this file is perf-critical and the cost |
|
4503 |
+ * of making flow understand it is not worth it. |
|
4504 |
+ */ |
|
4505 |
+ |
|
4506 |
+var emptyNode = new VNode('', {}, []); |
|
4507 |
+ |
|
4508 |
+var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; |
|
4509 |
+ |
|
4510 |
+function isUndef (v) { |
|
4511 |
+ return v === undefined || v === null |
|
4512 |
+} |
|
4513 |
+ |
|
4514 |
+function isDef (v) { |
|
4515 |
+ return v !== undefined && v !== null |
|
4516 |
+} |
|
4517 |
+ |
|
4518 |
+function isTrue (v) { |
|
4519 |
+ return v === true |
|
4520 |
+} |
|
4521 |
+ |
|
4522 |
+function sameVnode (a, b) { |
|
4523 |
+ return ( |
|
4524 |
+ a.key === b.key && |
|
4525 |
+ a.tag === b.tag && |
|
4526 |
+ a.isComment === b.isComment && |
|
4527 |
+ isDef(a.data) === isDef(b.data) && |
|
4528 |
+ sameInputType(a, b) |
|
4529 |
+ ) |
|
4530 |
+} |
|
4531 |
+ |
|
4532 |
+// Some browsers do not support dynamically changing type for <input> |
|
4533 |
+// so they need to be treated as different nodes |
|
4534 |
+function sameInputType (a, b) { |
|
4535 |
+ if (a.tag !== 'input') { return true } |
|
4536 |
+ var i; |
|
4537 |
+ var typeA = isDef(i = a.data) && isDef(i = i.attrs) && i.type; |
|
4538 |
+ var typeB = isDef(i = b.data) && isDef(i = i.attrs) && i.type; |
|
4539 |
+ return typeA === typeB |
|
4540 |
+} |
|
4541 |
+ |
|
4542 |
+function createKeyToOldIdx (children, beginIdx, endIdx) { |
|
4543 |
+ var i, key; |
|
4544 |
+ var map = {}; |
|
4545 |
+ for (i = beginIdx; i <= endIdx; ++i) { |
|
4546 |
+ key = children[i].key; |
|
4547 |
+ if (isDef(key)) { map[key] = i; } |
|
4548 |
+ } |
|
4549 |
+ return map |
|
4550 |
+} |
|
4551 |
+ |
|
4552 |
+function createPatchFunction (backend) { |
|
4553 |
+ var i, j; |
|
4554 |
+ var cbs = {}; |
|
4555 |
+ |
|
4556 |
+ var modules = backend.modules; |
|
4557 |
+ var nodeOps = backend.nodeOps; |
|
4558 |
+ |
|
4559 |
+ for (i = 0; i < hooks.length; ++i) { |
|
4560 |
+ cbs[hooks[i]] = []; |
|
4561 |
+ for (j = 0; j < modules.length; ++j) { |
|
4562 |
+ if (isDef(modules[j][hooks[i]])) { |
|
4563 |
+ cbs[hooks[i]].push(modules[j][hooks[i]]); |
|
4564 |
+ } |
|
4565 |
+ } |
|
4566 |
+ } |
|
4567 |
+ |
|
4568 |
+ function emptyNodeAt (elm) { |
|
4569 |
+ return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm) |
|
4570 |
+ } |
|
4571 |
+ |
|
4572 |
+ function createRmCb (childElm, listeners) { |
|
4573 |
+ function remove$$1 () { |
|
4574 |
+ if (--remove$$1.listeners === 0) { |
|
4575 |
+ removeNode(childElm); |
|
4576 |
+ } |
|
4577 |
+ } |
|
4578 |
+ remove$$1.listeners = listeners; |
|
4579 |
+ return remove$$1 |
|
4580 |
+ } |
|
4581 |
+ |
|
4582 |
+ function removeNode (el) { |
|
4583 |
+ var parent = nodeOps.parentNode(el); |
|
4584 |
+ // element may have already been removed due to v-html / v-text |
|
4585 |
+ if (isDef(parent)) { |
|
4586 |
+ nodeOps.removeChild(parent, el); |
|
4587 |
+ } |
|
4588 |
+ } |
|
4589 |
+ |
|
4590 |
+ var inPre = 0; |
|
4591 |
+ function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) { |
|
4592 |
+ vnode.isRootInsert = !nested; // for transition enter check |
|
4593 |
+ if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { |
|
4594 |
+ return |
|
4595 |
+ } |
|
4596 |
+ |
|
4597 |
+ var data = vnode.data; |
|
4598 |
+ var children = vnode.children; |
|
4599 |
+ var tag = vnode.tag; |
|
4600 |
+ if (isDef(tag)) { |
|
4601 |
+ { |
|
4602 |
+ if (data && data.pre) { |
|
4603 |
+ inPre++; |
|
4604 |
+ } |
|
4605 |
+ if ( |
|
4606 |
+ !inPre && |
|
4607 |
+ !vnode.ns && |
|
4608 |
+ !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) && |
|
4609 |
+ config.isUnknownElement(tag) |
|
4610 |
+ ) { |
|
4611 |
+ warn( |
|
4612 |
+ 'Unknown custom element: <' + tag + '> - did you ' + |
|
4613 |
+ 'register the component correctly? For recursive components, ' + |
|
4614 |
+ 'make sure to provide the "name" option.', |
|
4615 |
+ vnode.context |
|
4616 |
+ ); |
|
4617 |
+ } |
|
4618 |
+ } |
|
4619 |
+ vnode.elm = vnode.ns |
|
4620 |
+ ? nodeOps.createElementNS(vnode.ns, tag) |
|
4621 |
+ : nodeOps.createElement(tag, vnode); |
|
4622 |
+ setScope(vnode); |
|
4623 |
+ |
|
4624 |
+ /* istanbul ignore if */ |
|
4625 |
+ { |
|
4626 |
+ createChildren(vnode, children, insertedVnodeQueue); |
|
4627 |
+ if (isDef(data)) { |
|
4628 |
+ invokeCreateHooks(vnode, insertedVnodeQueue); |
|
4629 |
+ } |
|
4630 |
+ insert(parentElm, vnode.elm, refElm); |
|
4631 |
+ } |
|
4632 |
+ |
|
4633 |
+ if ("development" !== 'production' && data && data.pre) { |
|
4634 |
+ inPre--; |
|
4635 |
+ } |
|
4636 |
+ } else if (isTrue(vnode.isComment)) { |
|
4637 |
+ vnode.elm = nodeOps.createComment(vnode.text); |
|
4638 |
+ insert(parentElm, vnode.elm, refElm); |
|
4639 |
+ } else { |
|
4640 |
+ vnode.elm = nodeOps.createTextNode(vnode.text); |
|
4641 |
+ insert(parentElm, vnode.elm, refElm); |
|
4642 |
+ } |
|
4643 |
+ } |
|
4644 |
+ |
|
4645 |
+ function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) { |
|
4646 |
+ var i = vnode.data; |
|
4647 |
+ if (isDef(i)) { |
|
4648 |
+ var isReactivated = isDef(vnode.componentInstance) && i.keepAlive; |
|
4649 |
+ if (isDef(i = i.hook) && isDef(i = i.init)) { |
|
4650 |
+ i(vnode, false /* hydrating */, parentElm, refElm); |
|
4651 |
+ } |
|
4652 |
+ // after calling the init hook, if the vnode is a child component |
|
4653 |
+ // it should've created a child instance and mounted it. the child |
|
4654 |
+ // component also has set the placeholder vnode's elm. |
|
4655 |
+ // in that case we can just return the element and be done. |
|
4656 |
+ if (isDef(vnode.componentInstance)) { |
|
4657 |
+ initComponent(vnode, insertedVnodeQueue); |
|
4658 |
+ if (isTrue(isReactivated)) { |
|
4659 |
+ reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm); |
|
4660 |
+ } |
|
4661 |
+ return true |
|
4662 |
+ } |
|
4663 |
+ } |
|
4664 |
+ } |
|
4665 |
+ |
|
4666 |
+ function initComponent (vnode, insertedVnodeQueue) { |
|
4667 |
+ if (isDef(vnode.data.pendingInsert)) { |
|
4668 |
+ insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert); |
|
4669 |
+ } |
|
4670 |
+ vnode.elm = vnode.componentInstance.$el; |
|
4671 |
+ if (isPatchable(vnode)) { |
|
4672 |
+ invokeCreateHooks(vnode, insertedVnodeQueue); |
|
4673 |
+ setScope(vnode); |
|
4674 |
+ } else { |
|
4675 |
+ // empty component root. |
|
4676 |
+ // skip all element-related modules except for ref (#3455) |
|
4677 |
+ registerRef(vnode); |
|
4678 |
+ // make sure to invoke the insert hook |
|
4679 |
+ insertedVnodeQueue.push(vnode); |
|
4680 |
+ } |
|
4681 |
+ } |
|
4682 |
+ |
|
4683 |
+ function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) { |
|
4684 |
+ var i; |
|
4685 |
+ // hack for #4339: a reactivated component with inner transition |
|
4686 |
+ // does not trigger because the inner node's created hooks are not called |
|
4687 |
+ // again. It's not ideal to involve module-specific logic in here but |
|
4688 |
+ // there doesn't seem to be a better way to do it. |
|
4689 |
+ var innerNode = vnode; |
|
4690 |
+ while (innerNode.componentInstance) { |
|
4691 |
+ innerNode = innerNode.componentInstance._vnode; |
|
4692 |
+ if (isDef(i = innerNode.data) && isDef(i = i.transition)) { |
|
4693 |
+ for (i = 0; i < cbs.activate.length; ++i) { |
|
4694 |
+ cbs.activate[i](emptyNode, innerNode); |
|
4695 |
+ } |
|
4696 |
+ insertedVnodeQueue.push(innerNode); |
|
4697 |
+ break |
|
4698 |
+ } |
|
4699 |
+ } |
|
4700 |
+ // unlike a newly created component, |
|
4701 |
+ // a reactivated keep-alive component doesn't insert itself |
|
4702 |
+ insert(parentElm, vnode.elm, refElm); |
|
4703 |
+ } |
|
4704 |
+ |
|
4705 |
+ function insert (parent, elm, ref) { |
|
4706 |
+ if (isDef(parent)) { |
|
4707 |
+ if (isDef(ref)) { |
|
4708 |
+ nodeOps.insertBefore(parent, elm, ref); |
|
4709 |
+ } else { |
|
4710 |
+ nodeOps.appendChild(parent, elm); |
|
4711 |
+ } |
|
4712 |
+ } |
|
4713 |
+ } |
|
4714 |
+ |
|
4715 |
+ function createChildren (vnode, children, insertedVnodeQueue) { |
|
4716 |
+ if (Array.isArray(children)) { |
|
4717 |
+ for (var i = 0; i < children.length; ++i) { |
|
4718 |
+ createElm(children[i], insertedVnodeQueue, vnode.elm, null, true); |
|
4719 |
+ } |
|
4720 |
+ } else if (isPrimitive(vnode.text)) { |
|
4721 |
+ nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text)); |
|
4722 |
+ } |
|
4723 |
+ } |
|
4724 |
+ |
|
4725 |
+ function isPatchable (vnode) { |
|
4726 |
+ while (vnode.componentInstance) { |
|
4727 |
+ vnode = vnode.componentInstance._vnode; |
|
4728 |
+ } |
|
4729 |
+ return isDef(vnode.tag) |
|
4730 |
+ } |
|
4731 |
+ |
|
4732 |
+ function invokeCreateHooks (vnode, insertedVnodeQueue) { |
|
4733 |
+ for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { |
|
4734 |
+ cbs.create[i$1](emptyNode, vnode); |
|
4735 |
+ } |
|
4736 |
+ i = vnode.data.hook; // Reuse variable |
|
4737 |
+ if (isDef(i)) { |
|
4738 |
+ if (isDef(i.create)) { i.create(emptyNode, vnode); } |
|
4739 |
+ if (isDef(i.insert)) { insertedVnodeQueue.push(vnode); } |
|
4740 |
+ } |
|
4741 |
+ } |
|
4742 |
+ |
|
4743 |
+ // set scope id attribute for scoped CSS. |
|
4744 |
+ // this is implemented as a special case to avoid the overhead |
|
4745 |
+ // of going through the normal attribute patching process. |
|
4746 |
+ function setScope (vnode) { |
|
4747 |
+ var i; |
|
4748 |
+ var ancestor = vnode; |
|
4749 |
+ while (ancestor) { |
|
4750 |
+ if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) { |
|
4751 |
+ nodeOps.setAttribute(vnode.elm, i, ''); |
|
4752 |
+ } |
|
4753 |
+ ancestor = ancestor.parent; |
|
4754 |
+ } |
|
4755 |
+ // for slot content they should also get the scopeId from the host instance. |
|
4756 |
+ if (isDef(i = activeInstance) && |
|
4757 |
+ i !== vnode.context && |
|
4758 |
+ isDef(i = i.$options._scopeId)) { |
|
4759 |
+ nodeOps.setAttribute(vnode.elm, i, ''); |
|
4760 |
+ } |
|
4761 |
+ } |
|
4762 |
+ |
|
4763 |
+ function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { |
|
4764 |
+ for (; startIdx <= endIdx; ++startIdx) { |
|
4765 |
+ createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm); |
|
4766 |
+ } |
|
4767 |
+ } |
|
4768 |
+ |
|
4769 |
+ function invokeDestroyHook (vnode) { |
|
4770 |
+ var i, j; |
|
4771 |
+ var data = vnode.data; |
|
4772 |
+ if (isDef(data)) { |
|
4773 |
+ if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); } |
|
4774 |
+ for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); } |
|
4775 |
+ } |
|
4776 |
+ if (isDef(i = vnode.children)) { |
|
4777 |
+ for (j = 0; j < vnode.children.length; ++j) { |
|
4778 |
+ invokeDestroyHook(vnode.children[j]); |
|
4779 |
+ } |
|
4780 |
+ } |
|
4781 |
+ } |
|
4782 |
+ |
|
4783 |
+ function removeVnodes (parentElm, vnodes, startIdx, endIdx) { |
|
4784 |
+ for (; startIdx <= endIdx; ++startIdx) { |
|
4785 |
+ var ch = vnodes[startIdx]; |
|
4786 |
+ if (isDef(ch)) { |
|
4787 |
+ if (isDef(ch.tag)) { |
|
4788 |
+ removeAndInvokeRemoveHook(ch); |
|
4789 |
+ invokeDestroyHook(ch); |
|
4790 |
+ } else { // Text node |
|
4791 |
+ removeNode(ch.elm); |
|
4792 |
+ } |
|
4793 |
+ } |
|
4794 |
+ } |
|
4795 |
+ } |
|
4796 |
+ |
|
4797 |
+ function removeAndInvokeRemoveHook (vnode, rm) { |
|
4798 |
+ if (isDef(rm) || isDef(vnode.data)) { |
|
4799 |
+ var listeners = cbs.remove.length + 1; |
|
4800 |
+ if (isDef(rm)) { |
|
4801 |
+ // we have a recursively passed down rm callback |
|
4802 |
+ // increase the listeners count |
|
4803 |
+ rm.listeners += listeners; |
|
4804 |
+ } else { |
|
4805 |
+ // directly removing |
|
4806 |
+ rm = createRmCb(vnode.elm, listeners); |
|
4807 |
+ } |
|
4808 |
+ // recursively invoke hooks on child component root node |
|
4809 |
+ if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) { |
|
4810 |
+ removeAndInvokeRemoveHook(i, rm); |
|
4811 |
+ } |
|
4812 |
+ for (i = 0; i < cbs.remove.length; ++i) { |
|
4813 |
+ cbs.remove[i](vnode, rm); |
|
4814 |
+ } |
|
4815 |
+ if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) { |
|
4816 |
+ i(vnode, rm); |
|
4817 |
+ } else { |
|
4818 |
+ rm(); |
|
4819 |
+ } |
|
4820 |
+ } else { |
|
4821 |
+ removeNode(vnode.elm); |
|
4822 |
+ } |
|
4823 |
+ } |
|
4824 |
+ |
|
4825 |
+ function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { |
|
4826 |
+ var oldStartIdx = 0; |
|
4827 |
+ var newStartIdx = 0; |
|
4828 |
+ var oldEndIdx = oldCh.length - 1; |
|
4829 |
+ var oldStartVnode = oldCh[0]; |
|
4830 |
+ var oldEndVnode = oldCh[oldEndIdx]; |
|
4831 |
+ var newEndIdx = newCh.length - 1; |
|
4832 |
+ var newStartVnode = newCh[0]; |
|
4833 |
+ var newEndVnode = newCh[newEndIdx]; |
|
4834 |
+ var oldKeyToIdx, idxInOld, elmToMove, refElm; |
|
4835 |
+ |
|
4836 |
+ // removeOnly is a special flag used only by <transition-group> |
|
4837 |
+ // to ensure removed elements stay in correct relative positions |
|
4838 |
+ // during leaving transitions |
|
4839 |
+ var canMove = !removeOnly; |
|
4840 |
+ |
|
4841 |
+ while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { |
|
4842 |
+ if (isUndef(oldStartVnode)) { |
|
4843 |
+ oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left |
|
4844 |
+ } else if (isUndef(oldEndVnode)) { |
|
4845 |
+ oldEndVnode = oldCh[--oldEndIdx]; |
|
4846 |
+ } else if (sameVnode(oldStartVnode, newStartVnode)) { |
|
4847 |
+ patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue); |
|
4848 |
+ oldStartVnode = oldCh[++oldStartIdx]; |
|
4849 |
+ newStartVnode = newCh[++newStartIdx]; |
|
4850 |
+ } else if (sameVnode(oldEndVnode, newEndVnode)) { |
|
4851 |
+ patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue); |
|
4852 |
+ oldEndVnode = oldCh[--oldEndIdx]; |
|
4853 |
+ newEndVnode = newCh[--newEndIdx]; |
|
4854 |
+ } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right |
|
4855 |
+ patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue); |
|
4856 |
+ canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)); |
|
4857 |
+ oldStartVnode = oldCh[++oldStartIdx]; |
|
4858 |
+ newEndVnode = newCh[--newEndIdx]; |
|
4859 |
+ } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left |
|
4860 |
+ patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue); |
|
4861 |
+ canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm); |
|
4862 |
+ oldEndVnode = oldCh[--oldEndIdx]; |
|
4863 |
+ newStartVnode = newCh[++newStartIdx]; |
|
4864 |
+ } else { |
|
4865 |
+ if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); } |
|
4866 |
+ idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null; |
|
4867 |
+ if (isUndef(idxInOld)) { // New element |
|
4868 |
+ createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); |
|
4869 |
+ newStartVnode = newCh[++newStartIdx]; |
|
4870 |
+ } else { |
|
4871 |
+ elmToMove = oldCh[idxInOld]; |
|
4872 |
+ /* istanbul ignore if */ |
|
4873 |
+ if ("development" !== 'production' && !elmToMove) { |
|
4874 |
+ warn( |
|
4875 |
+ 'It seems there are duplicate keys that is causing an update error. ' + |
|
4876 |
+ 'Make sure each v-for item has a unique key.' |
|
4877 |
+ ); |
|
4878 |
+ } |
|
4879 |
+ if (sameVnode(elmToMove, newStartVnode)) { |
|
4880 |
+ patchVnode(elmToMove, newStartVnode, insertedVnodeQueue); |
|
4881 |
+ oldCh[idxInOld] = undefined; |
|
4882 |
+ canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm); |
|
4883 |
+ newStartVnode = newCh[++newStartIdx]; |
|
4884 |
+ } else { |
|
4885 |
+ // same key but different element. treat as new element |
|
4886 |
+ createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); |
|
4887 |
+ newStartVnode = newCh[++newStartIdx]; |
|
4888 |
+ } |
|
4889 |
+ } |
|
4890 |
+ } |
|
4891 |
+ } |
|
4892 |
+ if (oldStartIdx > oldEndIdx) { |
|
4893 |
+ refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm; |
|
4894 |
+ addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue); |
|
4895 |
+ } else if (newStartIdx > newEndIdx) { |
|
4896 |
+ removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx); |
|
4897 |
+ } |
|
4898 |
+ } |
|
4899 |
+ |
|
4900 |
+ function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) { |
|
4901 |
+ if (oldVnode === vnode) { |
|
4902 |
+ return |
|
4903 |
+ } |
|
4904 |
+ // reuse element for static trees. |
|
4905 |
+ // note we only do this if the vnode is cloned - |
|
4906 |
+ // if the new node is not cloned it means the render functions have been |
|
4907 |
+ // reset by the hot-reload-api and we need to do a proper re-render. |
|
4908 |
+ if (isTrue(vnode.isStatic) && |
|
4909 |
+ isTrue(oldVnode.isStatic) && |
|
4910 |
+ vnode.key === oldVnode.key && |
|
4911 |
+ (isTrue(vnode.isCloned) || isTrue(vnode.isOnce))) { |
|
4912 |
+ vnode.elm = oldVnode.elm; |
|
4913 |
+ vnode.componentInstance = oldVnode.componentInstance; |
|
4914 |
+ return |
|
4915 |
+ } |
|
4916 |
+ var i; |
|
4917 |
+ var data = vnode.data; |
|
4918 |
+ if (isDef(data) && isDef(i = data.hook) && isDef(i = i.prepatch)) { |
|
4919 |
+ i(oldVnode, vnode); |
|
4920 |
+ } |
|
4921 |
+ var elm = vnode.elm = oldVnode.elm; |
|
4922 |
+ var oldCh = oldVnode.children; |
|
4923 |
+ var ch = vnode.children; |
|
4924 |
+ if (isDef(data) && isPatchable(vnode)) { |
|
4925 |
+ for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); } |
|
4926 |
+ if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); } |
|
4927 |
+ } |
|
4928 |
+ if (isUndef(vnode.text)) { |
|
4929 |
+ if (isDef(oldCh) && isDef(ch)) { |
|
4930 |
+ if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); } |
|
4931 |
+ } else if (isDef(ch)) { |
|
4932 |
+ if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } |
|
4933 |
+ addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); |
|
4934 |
+ } else if (isDef(oldCh)) { |
|
4935 |
+ removeVnodes(elm, oldCh, 0, oldCh.length - 1); |
|
4936 |
+ } else if (isDef(oldVnode.text)) { |
|
4937 |
+ nodeOps.setTextContent(elm, ''); |
|
4938 |
+ } |
|
4939 |
+ } else if (oldVnode.text !== vnode.text) { |
|
4940 |
+ nodeOps.setTextContent(elm, vnode.text); |
|
4941 |
+ } |
|
4942 |
+ if (isDef(data)) { |
|
4943 |
+ if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); } |
|
4944 |
+ } |
|
4945 |
+ } |
|
4946 |
+ |
|
4947 |
+ function invokeInsertHook (vnode, queue, initial) { |
|
4948 |
+ // delay insert hooks for component root nodes, invoke them after the |
|
4949 |
+ // element is really inserted |
|
4950 |
+ if (isTrue(initial) && isDef(vnode.parent)) { |
|
4951 |
+ vnode.parent.data.pendingInsert = queue; |
|
4952 |
+ } else { |
|
4953 |
+ for (var i = 0; i < queue.length; ++i) { |
|
4954 |
+ queue[i].data.hook.insert(queue[i]); |
|
4955 |
+ } |
|
4956 |
+ } |
|
4957 |
+ } |
|
4958 |
+ |
|
4959 |
+ var bailed = false; |
|
4960 |
+ // list of modules that can skip create hook during hydration because they |
|
4961 |
+ // are already rendered on the client or has no need for initialization |
|
4962 |
+ var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key'); |
|
4963 |
+ |
|
4964 |
+ // Note: this is a browser-only function so we can assume elms are DOM nodes. |
|
4965 |
+ function hydrate (elm, vnode, insertedVnodeQueue) { |
|
4966 |
+ { |
|
4967 |
+ if (!assertNodeMatch(elm, vnode)) { |
|
4968 |
+ return false |
|
4969 |
+ } |
|
4970 |
+ } |
|
4971 |
+ vnode.elm = elm; |
|
4972 |
+ var tag = vnode.tag; |
|
4973 |
+ var data = vnode.data; |
|
4974 |
+ var children = vnode.children; |
|
4975 |
+ if (isDef(data)) { |
|
4976 |
+ if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); } |
|
4977 |
+ if (isDef(i = vnode.componentInstance)) { |
|
4978 |
+ // child component. it should have hydrated its own tree. |
|
4979 |
+ initComponent(vnode, insertedVnodeQueue); |
|
4980 |
+ return true |
|
4981 |
+ } |
|
4982 |
+ } |
|
4983 |
+ if (isDef(tag)) { |
|
4984 |
+ if (isDef(children)) { |
|
4985 |
+ // empty element, allow client to pick up and populate children |
|
4986 |
+ if (!elm.hasChildNodes()) { |
|
4987 |
+ createChildren(vnode, children, insertedVnodeQueue); |
|
4988 |
+ } else { |
|
4989 |
+ var childrenMatch = true; |
|
4990 |
+ var childNode = elm.firstChild; |
|
4991 |
+ for (var i$1 = 0; i$1 < children.length; i$1++) { |
|
4992 |
+ if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) { |
|
4993 |
+ childrenMatch = false; |
|
4994 |
+ break |
|
4995 |
+ } |
|
4996 |
+ childNode = childNode.nextSibling; |
|
4997 |
+ } |
|
4998 |
+ // if childNode is not null, it means the actual childNodes list is |
|
4999 |
+ // longer than the virtual children list. |
|
5000 |
+ if (!childrenMatch || childNode) { |
|
5001 |
+ if ("development" !== 'production' && |
|
5002 |
+ typeof console !== 'undefined' && |
|
5003 |
+ !bailed) { |
|
5004 |
+ bailed = true; |
|
5005 |
+ console.warn('Parent: ', elm); |
|
5006 |
+ console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); |
|
5007 |
+ } |
|
5008 |
+ return false |
|
5009 |
+ } |
|
5010 |
+ } |
|
5011 |
+ } |
|
5012 |
+ if (isDef(data)) { |
|
5013 |
+ for (var key in data) { |
|
5014 |
+ if (!isRenderedModule(key)) { |
|
5015 |
+ invokeCreateHooks(vnode, insertedVnodeQueue); |
|
5016 |
+ break |
|
5017 |
+ } |
|
5018 |
+ } |
|
5019 |
+ } |
|
5020 |
+ } else if (elm.data !== vnode.text) { |
|
5021 |
+ elm.data = vnode.text; |
|
5022 |
+ } |
|
5023 |
+ return true |
|
5024 |
+ } |
|
5025 |
+ |
|
5026 |
+ function assertNodeMatch (node, vnode) { |
|
5027 |
+ if (isDef(vnode.tag)) { |
|
5028 |
+ return ( |
|
5029 |
+ vnode.tag.indexOf('vue-component') === 0 || |
|
5030 |
+ vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) |
|
5031 |
+ ) |
|
5032 |
+ } else { |
|
5033 |
+ return node.nodeType === (vnode.isComment ? 8 : 3) |
|
5034 |
+ } |
|
5035 |
+ } |
|
5036 |
+ |
|
5037 |
+ return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) { |
|
5038 |
+ if (isUndef(vnode)) { |
|
5039 |
+ if (isDef(oldVnode)) { invokeDestroyHook(oldVnode); } |
|
5040 |
+ return |
|
5041 |
+ } |
|
5042 |
+ |
|
5043 |
+ var isInitialPatch = false; |
|
5044 |
+ var insertedVnodeQueue = []; |
|
5045 |
+ |
|
5046 |
+ if (isUndef(oldVnode)) { |
|
5047 |
+ // empty mount (likely as component), create new root element |
|
5048 |
+ isInitialPatch = true; |
|
5049 |
+ createElm(vnode, insertedVnodeQueue, parentElm, refElm); |
|
5050 |
+ } else { |
|
5051 |
+ var isRealElement = isDef(oldVnode.nodeType); |
|
5052 |
+ if (!isRealElement && sameVnode(oldVnode, vnode)) { |
|
5053 |
+ // patch existing root node |
|
5054 |
+ patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly); |
|
5055 |
+ } else { |
|
5056 |
+ if (isRealElement) { |
|
5057 |
+ // mounting to a real element |
|
5058 |
+ // check if this is server-rendered content and if we can perform |
|
5059 |
+ // a successful hydration. |
|
5060 |
+ if (oldVnode.nodeType === 1 && oldVnode.hasAttribute('server-rendered')) { |
|
5061 |
+ oldVnode.removeAttribute('server-rendered'); |
|
5062 |
+ hydrating = true; |
|
5063 |
+ } |
|
5064 |
+ if (isTrue(hydrating)) { |
|
5065 |
+ if (hydrate(oldVnode, vnode, insertedVnodeQueue)) { |
|
5066 |
+ invokeInsertHook(vnode, insertedVnodeQueue, true); |
|
5067 |
+ return oldVnode |
|
5068 |
+ } else { |
|
5069 |
+ warn( |
|
5070 |
+ 'The client-side rendered virtual DOM tree is not matching ' + |
|
5071 |
+ 'server-rendered content. This is likely caused by incorrect ' + |
|
5072 |
+ 'HTML markup, for example nesting block-level elements inside ' + |
|
5073 |
+ '<p>, or missing <tbody>. Bailing hydration and performing ' + |
|
5074 |
+ 'full client-side render.' |
|
5075 |
+ ); |
|
5076 |
+ } |
|
5077 |
+ } |
|
5078 |
+ // either not server-rendered, or hydration failed. |
|
5079 |
+ // create an empty node and replace it |
|
5080 |
+ oldVnode = emptyNodeAt(oldVnode); |
|
5081 |
+ } |
|
5082 |
+ // replacing existing element |
|
5083 |
+ var oldElm = oldVnode.elm; |
|
5084 |
+ var parentElm$1 = nodeOps.parentNode(oldElm); |
|
5085 |
+ createElm( |
|
5086 |
+ vnode, |
|
5087 |
+ insertedVnodeQueue, |
|
5088 |
+ // extremely rare edge case: do not insert if old element is in a |
|
5089 |
+ // leaving transition. Only happens when combining transition + |
|
5090 |
+ // keep-alive + HOCs. (#4590) |
|
5091 |
+ oldElm._leaveCb ? null : parentElm$1, |
|
5092 |
+ nodeOps.nextSibling(oldElm) |
|
5093 |
+ ); |
|
5094 |
+ |
|
5095 |
+ if (isDef(vnode.parent)) { |
|
5096 |
+ // component root element replaced. |
|
5097 |
+ // update parent placeholder node element, recursively |
|
5098 |
+ var ancestor = vnode.parent; |
|
5099 |
+ while (ancestor) { |
|
5100 |
+ ancestor.elm = vnode.elm; |
|
5101 |
+ ancestor = ancestor.parent; |
|
5102 |
+ } |
|
5103 |
+ if (isPatchable(vnode)) { |
|
5104 |
+ for (var i = 0; i < cbs.create.length; ++i) { |
|
5105 |
+ cbs.create[i](emptyNode, vnode.parent); |
|
5106 |
+ } |
|
5107 |
+ } |
|
5108 |
+ } |
|
5109 |
+ |
|
5110 |
+ if (isDef(parentElm$1)) { |
|
5111 |
+ removeVnodes(parentElm$1, [oldVnode], 0, 0); |
|
5112 |
+ } else if (isDef(oldVnode.tag)) { |
|
5113 |
+ invokeDestroyHook(oldVnode); |
|
5114 |
+ } |
|
5115 |
+ } |
|
5116 |
+ } |
|
5117 |
+ |
|
5118 |
+ invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch); |
|
5119 |
+ return vnode.elm |
|
5120 |
+ } |
|
5121 |
+} |
|
5122 |
+ |
|
5123 |
+/* */ |
|
5124 |
+ |
|
5125 |
+var directives = { |
|
5126 |
+ create: updateDirectives, |
|
5127 |
+ update: updateDirectives, |
|
5128 |
+ destroy: function unbindDirectives (vnode) { |
|
5129 |
+ updateDirectives(vnode, emptyNode); |
|
5130 |
+ } |
|
5131 |
+}; |
|
5132 |
+ |
|
5133 |
+function updateDirectives (oldVnode, vnode) { |
|
5134 |
+ if (oldVnode.data.directives || vnode.data.directives) { |
|
5135 |
+ _update(oldVnode, vnode); |
|
5136 |
+ } |
|
5137 |
+} |
|
5138 |
+ |
|
5139 |
+function _update (oldVnode, vnode) { |
|
5140 |
+ var isCreate = oldVnode === emptyNode; |
|
5141 |
+ var isDestroy = vnode === emptyNode; |
|
5142 |
+ var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context); |
|
5143 |
+ var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context); |
|
5144 |
+ |
|
5145 |
+ var dirsWithInsert = []; |
|
5146 |
+ var dirsWithPostpatch = []; |
|
5147 |
+ |
|
5148 |
+ var key, oldDir, dir; |
|
5149 |
+ for (key in newDirs) { |
|
5150 |
+ oldDir = oldDirs[key]; |
|
5151 |
+ dir = newDirs[key]; |
|
5152 |
+ if (!oldDir) { |
|
5153 |
+ // new directive, bind |
|
5154 |
+ callHook$1(dir, 'bind', vnode, oldVnode); |
|
5155 |
+ if (dir.def && dir.def.inserted) { |
|
5156 |
+ dirsWithInsert.push(dir); |
|
5157 |
+ } |
|
5158 |
+ } else { |
|
5159 |
+ // existing directive, update |
|
5160 |
+ dir.oldValue = oldDir.value; |
|
5161 |
+ callHook$1(dir, 'update', vnode, oldVnode); |
|
5162 |
+ if (dir.def && dir.def.componentUpdated) { |
|
5163 |
+ dirsWithPostpatch.push(dir); |
|
5164 |
+ } |
|
5165 |
+ } |
|
5166 |
+ } |
|
5167 |
+ |
|
5168 |
+ if (dirsWithInsert.length) { |
|
5169 |
+ var callInsert = function () { |
|
5170 |
+ for (var i = 0; i < dirsWithInsert.length; i++) { |
|
5171 |
+ callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode); |
|
5172 |
+ } |
|
5173 |
+ }; |
|
5174 |
+ if (isCreate) { |
|
5175 |
+ mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert); |
|
5176 |
+ } else { |
|
5177 |
+ callInsert(); |
|
5178 |
+ } |
|
5179 |
+ } |
|
5180 |
+ |
|
5181 |
+ if (dirsWithPostpatch.length) { |
|
5182 |
+ mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () { |
|
5183 |
+ for (var i = 0; i < dirsWithPostpatch.length; i++) { |
|
5184 |
+ callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); |
|
5185 |
+ } |
|
5186 |
+ }); |
|
5187 |
+ } |
|
5188 |
+ |
|
5189 |
+ if (!isCreate) { |
|
5190 |
+ for (key in oldDirs) { |
|
5191 |
+ if (!newDirs[key]) { |
|
5192 |
+ // no longer present, unbind |
|
5193 |
+ callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy); |
|
5194 |
+ } |
|
5195 |
+ } |
|
5196 |
+ } |
|
5197 |
+} |
|
5198 |
+ |
|
5199 |
+var emptyModifiers = Object.create(null); |
|
5200 |
+ |
|
5201 |
+function normalizeDirectives$1 ( |
|
5202 |
+ dirs, |
|
5203 |
+ vm |
|
5204 |
+) { |
|
5205 |
+ var res = Object.create(null); |
|
5206 |
+ if (!dirs) { |
|
5207 |
+ return res |
|
5208 |
+ } |
|
5209 |
+ var i, dir; |
|
5210 |
+ for (i = 0; i < dirs.length; i++) { |
|
5211 |
+ dir = dirs[i]; |
|
5212 |
+ if (!dir.modifiers) { |
|
5213 |
+ dir.modifiers = emptyModifiers; |
|
5214 |
+ } |
|
5215 |
+ res[getRawDirName(dir)] = dir; |
|
5216 |
+ dir.def = resolveAsset(vm.$options, 'directives', dir.name, true); |
|
5217 |
+ } |
|
5218 |
+ return res |
|
5219 |
+} |
|
5220 |
+ |
|
5221 |
+function getRawDirName (dir) { |
|
5222 |
+ return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.'))) |
|
5223 |
+} |
|
5224 |
+ |
|
5225 |
+function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) { |
|
5226 |
+ var fn = dir.def && dir.def[hook]; |
|
5227 |
+ if (fn) { |
|
5228 |
+ fn(vnode.elm, dir, vnode, oldVnode, isDestroy); |
|
5229 |
+ } |
|
5230 |
+} |
|
5231 |
+ |
|
5232 |
+var baseModules = [ |
|
5233 |
+ ref, |
|
5234 |
+ directives |
|
5235 |
+]; |
|
5236 |
+ |
|
5237 |
+/* */ |
|
5238 |
+ |
|
5239 |
+function updateAttrs (oldVnode, vnode) { |
|
5240 |
+ if (!oldVnode.data.attrs && !vnode.data.attrs) { |
|
5241 |
+ return |
|
5242 |
+ } |
|
5243 |
+ var key, cur, old; |
|
5244 |
+ var elm = vnode.elm; |
|
5245 |
+ var oldAttrs = oldVnode.data.attrs || {}; |
|
5246 |
+ var attrs = vnode.data.attrs || {}; |
|
5247 |
+ // clone observed objects, as the user probably wants to mutate it |
|
5248 |
+ if (attrs.__ob__) { |
|
5249 |
+ attrs = vnode.data.attrs = extend({}, attrs); |
|
5250 |
+ } |
|
5251 |
+ |
|
5252 |
+ for (key in attrs) { |
|
5253 |
+ cur = attrs[key]; |
|
5254 |
+ old = oldAttrs[key]; |
|
5255 |
+ if (old !== cur) { |
|
5256 |
+ setAttr(elm, key, cur); |
|
5257 |
+ } |
|
5258 |
+ } |
|
5259 |
+ // #4391: in IE9, setting type can reset value for input[type=radio] |
|
5260 |
+ /* istanbul ignore if */ |
|
5261 |
+ if (isIE9 && attrs.value !== oldAttrs.value) { |
|
5262 |
+ setAttr(elm, 'value', attrs.value); |
|
5263 |
+ } |
|
5264 |
+ for (key in oldAttrs) { |
|
5265 |
+ if (attrs[key] == null) { |
|
5266 |
+ if (isXlink(key)) { |
|
5267 |
+ elm.removeAttributeNS(xlinkNS, getXlinkProp(key)); |
|
5268 |
+ } else if (!isEnumeratedAttr(key)) { |
|
5269 |
+ elm.removeAttribute(key); |
|
5270 |
+ } |
|
5271 |
+ } |
|
5272 |
+ } |
|
5273 |
+} |
|
5274 |
+ |
|
5275 |
+function setAttr (el, key, value) { |
|
5276 |
+ if (isBooleanAttr(key)) { |
|
5277 |
+ // set attribute for blank value |
|
5278 |
+ // e.g. <option disabled>Select one</option> |
|
5279 |
+ if (isFalsyAttrValue(value)) { |
|
5280 |
+ el.removeAttribute(key); |
|
5281 |
+ } else { |
|
5282 |
+ el.setAttribute(key, key); |
|
5283 |
+ } |
|
5284 |
+ } else if (isEnumeratedAttr(key)) { |
|
5285 |
+ el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'); |
|
5286 |
+ } else if (isXlink(key)) { |
|
5287 |
+ if (isFalsyAttrValue(value)) { |
|
5288 |
+ el.removeAttributeNS(xlinkNS, getXlinkProp(key)); |
|
5289 |
+ } else { |
|
5290 |
+ el.setAttributeNS(xlinkNS, key, value); |
|
5291 |
+ } |
|
5292 |
+ } else { |
|
5293 |
+ if (isFalsyAttrValue(value)) { |
|
5294 |
+ el.removeAttribute(key); |
|
5295 |
+ } else { |
|
5296 |
+ el.setAttribute(key, value); |
|
5297 |
+ } |
|
5298 |
+ } |
|
5299 |
+} |
|
5300 |
+ |
|
5301 |
+var attrs = { |
|
5302 |
+ create: updateAttrs, |
|
5303 |
+ update: updateAttrs |
|
5304 |
+}; |
|
5305 |
+ |
|
5306 |
+/* */ |
|
5307 |
+ |
|
5308 |
+function updateClass (oldVnode, vnode) { |
|
5309 |
+ var el = vnode.elm; |
|
5310 |
+ var data = vnode.data; |
|
5311 |
+ var oldData = oldVnode.data; |
|
5312 |
+ if (!data.staticClass && !data.class && |
|
5313 |
+ (!oldData || (!oldData.staticClass && !oldData.class))) { |
|
5314 |
+ return |
|
5315 |
+ } |
|
5316 |
+ |
|
5317 |
+ var cls = genClassForVnode(vnode); |
|
5318 |
+ |
|
5319 |
+ // handle transition classes |
|
5320 |
+ var transitionClass = el._transitionClasses; |
|
5321 |
+ if (transitionClass) { |
|
5322 |
+ cls = concat(cls, stringifyClass(transitionClass)); |
|
5323 |
+ } |
|
5324 |
+ |
|
5325 |
+ // set the class |
|
5326 |
+ if (cls !== el._prevClass) { |
|
5327 |
+ el.setAttribute('class', cls); |
|
5328 |
+ el._prevClass = cls; |
|
5329 |
+ } |
|
5330 |
+} |
|
5331 |
+ |
|
5332 |
+var klass = { |
|
5333 |
+ create: updateClass, |
|
5334 |
+ update: updateClass |
|
5335 |
+}; |
|
5336 |
+ |
|
5337 |
+/* */ |
|
5338 |
+ |
|
5339 |
+var validDivisionCharRE = /[\w).+\-_$\]]/; |
|
5340 |
+ |
|
5341 |
+function parseFilters (exp) { |
|
5342 |
+ var inSingle = false; |
|
5343 |
+ var inDouble = false; |
|
5344 |
+ var inTemplateString = false; |
|
5345 |
+ var inRegex = false; |
|
5346 |
+ var curly = 0; |
|
5347 |
+ var square = 0; |
|
5348 |
+ var paren = 0; |
|
5349 |
+ var lastFilterIndex = 0; |
|
5350 |
+ var c, prev, i, expression, filters; |
|
5351 |
+ |
|
5352 |
+ for (i = 0; i < exp.length; i++) { |
|
5353 |
+ prev = c; |
|
5354 |
+ c = exp.charCodeAt(i); |
|
5355 |
+ if (inSingle) { |
|
5356 |
+ if (c === 0x27 && prev !== 0x5C) { inSingle = false; } |
|
5357 |
+ } else if (inDouble) { |
|
5358 |
+ if (c === 0x22 && prev !== 0x5C) { inDouble = false; } |
|
5359 |
+ } else if (inTemplateString) { |
|
5360 |
+ if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; } |
|
5361 |
+ } else if (inRegex) { |
|
5362 |
+ if (c === 0x2f && prev !== 0x5C) { inRegex = false; } |
|
5363 |
+ } else if ( |
|
5364 |
+ c === 0x7C && // pipe |
|
5365 |
+ exp.charCodeAt(i + 1) !== 0x7C && |
|
5366 |
+ exp.charCodeAt(i - 1) !== 0x7C && |
|
5367 |
+ !curly && !square && !paren |
|
5368 |
+ ) { |
|
5369 |
+ if (expression === undefined) { |
|
5370 |
+ // first filter, end of expression |
|
5371 |
+ lastFilterIndex = i + 1; |
|
5372 |
+ expression = exp.slice(0, i).trim(); |
|
5373 |
+ } else { |
|
5374 |
+ pushFilter(); |
|
5375 |
+ } |
|
5376 |
+ } else { |
|
5377 |
+ switch (c) { |
|
5378 |
+ case 0x22: inDouble = true; break // " |
|
5379 |
+ case 0x27: inSingle = true; break // ' |
|
5380 |
+ case 0x60: inTemplateString = true; break // ` |
|
5381 |
+ case 0x28: paren++; break // ( |
|
5382 |
+ case 0x29: paren--; break // ) |
|
5383 |
+ case 0x5B: square++; break // [ |
|
5384 |
+ case 0x5D: square--; break // ] |
|
5385 |
+ case 0x7B: curly++; break // { |
|
5386 |
+ case 0x7D: curly--; break // } |
|
5387 |
+ } |
|
5388 |
+ if (c === 0x2f) { // / |
|
5389 |
+ var j = i - 1; |
|
5390 |
+ var p = (void 0); |
|
5391 |
+ // find first non-whitespace prev char |
|
5392 |
+ for (; j >= 0; j--) { |
|
5393 |
+ p = exp.charAt(j); |
|
5394 |
+ if (p !== ' ') { break } |
|
5395 |
+ } |
|
5396 |
+ if (!p || !validDivisionCharRE.test(p)) { |
|
5397 |
+ inRegex = true; |
|
5398 |
+ } |
|
5399 |
+ } |
|
5400 |
+ } |
|
5401 |
+ } |
|
5402 |
+ |
|
5403 |
+ if (expression === undefined) { |
|
5404 |
+ expression = exp.slice(0, i).trim(); |
|
5405 |
+ } else if (lastFilterIndex !== 0) { |
|
5406 |
+ pushFilter(); |
|
5407 |
+ } |
|
5408 |
+ |
|
5409 |
+ function pushFilter () { |
|
5410 |
+ (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()); |
|
5411 |
+ lastFilterIndex = i + 1; |
|
5412 |
+ } |
|
5413 |
+ |
|
5414 |
+ if (filters) { |
|
5415 |
+ for (i = 0; i < filters.length; i++) { |
|
5416 |
+ expression = wrapFilter(expression, filters[i]); |
|
5417 |
+ } |
|
5418 |
+ } |
|
5419 |
+ |
|
5420 |
+ return expression |
|
5421 |
+} |
|
5422 |
+ |
|
5423 |
+function wrapFilter (exp, filter) { |
|
5424 |
+ var i = filter.indexOf('('); |
|
5425 |
+ if (i < 0) { |
|
5426 |
+ // _f: resolveFilter |
|
5427 |
+ return ("_f(\"" + filter + "\")(" + exp + ")") |
|
5428 |
+ } else { |
|
5429 |
+ var name = filter.slice(0, i); |
|
5430 |
+ var args = filter.slice(i + 1); |
|
5431 |
+ return ("_f(\"" + name + "\")(" + exp + "," + args) |
|
5432 |
+ } |
|
5433 |
+} |
|
5434 |
+ |
|
5435 |
+/* */ |
|
5436 |
+ |
|
5437 |
+function baseWarn (msg) { |
|
5438 |
+ console.error(("[Vue compiler]: " + msg)); |
|
5439 |
+} |
|
5440 |
+ |
|
5441 |
+function pluckModuleFunction ( |
|
5442 |
+ modules, |
|
5443 |
+ key |
|
5444 |
+) { |
|
5445 |
+ return modules |
|
5446 |
+ ? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; }) |
|
5447 |
+ : [] |
|
5448 |
+} |
|
5449 |
+ |
|
5450 |
+function addProp (el, name, value) { |
|
5451 |
+ (el.props || (el.props = [])).push({ name: name, value: value }); |
|
5452 |
+} |
|
5453 |
+ |
|
5454 |
+function addAttr (el, name, value) { |
|
5455 |
+ (el.attrs || (el.attrs = [])).push({ name: name, value: value }); |
|
5456 |
+} |
|
5457 |
+ |
|
5458 |
+function addDirective ( |
|
5459 |
+ el, |
|
5460 |
+ name, |
|
5461 |
+ rawName, |
|
5462 |
+ value, |
|
5463 |
+ arg, |
|
5464 |
+ modifiers |
|
5465 |
+) { |
|
5466 |
+ (el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers }); |
|
5467 |
+} |
|
5468 |
+ |
|
5469 |
+function addHandler ( |
|
5470 |
+ el, |
|
5471 |
+ name, |
|
5472 |
+ value, |
|
5473 |
+ modifiers, |
|
5474 |
+ important |
|
5475 |
+) { |
|
5476 |
+ // check capture modifier |
|
5477 |
+ if (modifiers && modifiers.capture) { |
|
5478 |
+ delete modifiers.capture; |
|
5479 |
+ name = '!' + name; // mark the event as captured |
|
5480 |
+ } |
|
5481 |
+ if (modifiers && modifiers.once) { |
|
5482 |
+ delete modifiers.once; |
|
5483 |
+ name = '~' + name; // mark the event as once |
|
5484 |
+ } |
|
5485 |
+ var events; |
|
5486 |
+ if (modifiers && modifiers.native) { |
|
5487 |
+ delete modifiers.native; |
|
5488 |
+ events = el.nativeEvents || (el.nativeEvents = {}); |
|
5489 |
+ } else { |
|
5490 |
+ events = el.events || (el.events = {}); |
|
5491 |
+ } |
|
5492 |
+ var newHandler = { value: value, modifiers: modifiers }; |
|
5493 |
+ var handlers = events[name]; |
|
5494 |
+ /* istanbul ignore if */ |
|
5495 |
+ if (Array.isArray(handlers)) { |
|
5496 |
+ important ? handlers.unshift(newHandler) : handlers.push(newHandler); |
|
5497 |
+ } else if (handlers) { |
|
5498 |
+ events[name] = important ? [newHandler, handlers] : [handlers, newHandler]; |
|
5499 |
+ } else { |
|
5500 |
+ events[name] = newHandler; |
|
5501 |
+ } |
|
5502 |
+} |
|
5503 |
+ |
|
5504 |
+function getBindingAttr ( |
|
5505 |
+ el, |
|
5506 |
+ name, |
|
5507 |
+ getStatic |
|
5508 |
+) { |
|
5509 |
+ var dynamicValue = |
|
5510 |
+ getAndRemoveAttr(el, ':' + name) || |
|
5511 |
+ getAndRemoveAttr(el, 'v-bind:' + name); |
|
5512 |
+ if (dynamicValue != null) { |
|
5513 |
+ return parseFilters(dynamicValue) |
|
5514 |
+ } else if (getStatic !== false) { |
|
5515 |
+ var staticValue = getAndRemoveAttr(el, name); |
|
5516 |
+ if (staticValue != null) { |
|
5517 |
+ return JSON.stringify(staticValue) |
|
5518 |
+ } |
|
5519 |
+ } |
|
5520 |
+} |
|
5521 |
+ |
|
5522 |
+function getAndRemoveAttr (el, name) { |
|
5523 |
+ var val; |
|
5524 |
+ if ((val = el.attrsMap[name]) != null) { |
|
5525 |
+ var list = el.attrsList; |
|
5526 |
+ for (var i = 0, l = list.length; i < l; i++) { |
|
5527 |
+ if (list[i].name === name) { |
|
5528 |
+ list.splice(i, 1); |
|
5529 |
+ break |
|
5530 |
+ } |
|
5531 |
+ } |
|
5532 |
+ } |
|
5533 |
+ return val |
|
5534 |
+} |
|
5535 |
+ |
|
5536 |
+/* */ |
|
5537 |
+ |
|
5538 |
+/** |
|
5539 |
+ * Cross-platform code generation for component v-model |
|
5540 |
+ */ |
|
5541 |
+function genComponentModel ( |
|
5542 |
+ el, |
|
5543 |
+ value, |
|
5544 |
+ modifiers |
|
5545 |
+) { |
|
5546 |
+ var ref = modifiers || {}; |
|
5547 |
+ var number = ref.number; |
|
5548 |
+ var trim = ref.trim; |
|
5549 |
+ |
|
5550 |
+ var baseValueExpression = '$$v'; |
|
5551 |
+ var valueExpression = baseValueExpression; |
|
5552 |
+ if (trim) { |
|
5553 |
+ valueExpression = |
|
5554 |
+ "(typeof " + baseValueExpression + " === 'string'" + |
|
5555 |
+ "? " + baseValueExpression + ".trim()" + |
|
5556 |
+ ": " + baseValueExpression + ")"; |
|
5557 |
+ } |
|
5558 |
+ if (number) { |
|
5559 |
+ valueExpression = "_n(" + valueExpression + ")"; |
|
5560 |
+ } |
|
5561 |
+ var assignment = genAssignmentCode(value, valueExpression); |
|
5562 |
+ |
|
5563 |
+ el.model = { |
|
5564 |
+ value: ("(" + value + ")"), |
|
5565 |
+ expression: ("\"" + value + "\""), |
|
5566 |
+ callback: ("function (" + baseValueExpression + ") {" + assignment + "}") |
|
5567 |
+ }; |
|
5568 |
+} |
|
5569 |
+ |
|
5570 |
+/** |
|
5571 |
+ * Cross-platform codegen helper for generating v-model value assignment code. |
|
5572 |
+ */ |
|
5573 |
+function genAssignmentCode ( |
|
5574 |
+ value, |
|
5575 |
+ assignment |
|
5576 |
+) { |
|
5577 |
+ var modelRs = parseModel(value); |
|
5578 |
+ if (modelRs.idx === null) { |
|
5579 |
+ return (value + "=" + assignment) |
|
5580 |
+ } else { |
|
5581 |
+ return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" + |
|
5582 |
+ "if (!Array.isArray($$exp)){" + |
|
5583 |
+ value + "=" + assignment + "}" + |
|
5584 |
+ "else{$$exp.splice($$idx, 1, " + assignment + ")}" |
|
5585 |
+ } |
|
5586 |
+} |
|
5587 |
+ |
|
5588 |
+/** |
|
5589 |
+ * parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val) |
|
5590 |
+ * |
|
5591 |
+ * for loop possible cases: |
|
5592 |
+ * |
|
5593 |
+ * - test |
|
5594 |
+ * - test[idx] |
|
5595 |
+ * - test[test1[idx]] |
|
5596 |
+ * - test["a"][idx] |
|
5597 |
+ * - xxx.test[a[a].test1[idx]] |
|
5598 |
+ * - test.xxx.a["asa"][test1[idx]] |
|
5599 |
+ * |
|
5600 |
+ */ |
|
5601 |
+ |
|
5602 |
+var len; |
|
5603 |
+var str; |
|
5604 |
+var chr; |
|
5605 |
+var index$1; |
|
5606 |
+var expressionPos; |
|
5607 |
+var expressionEndPos; |
|
5608 |
+ |
|
5609 |
+function parseModel (val) { |
|
5610 |
+ str = val; |
|
5611 |
+ len = str.length; |
|
5612 |
+ index$1 = expressionPos = expressionEndPos = 0; |
|
5613 |
+ |
|
5614 |
+ if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) { |
|
5615 |
+ return { |
|
5616 |
+ exp: val, |
|
5617 |
+ idx: null |
|
5618 |
+ } |
|
5619 |
+ } |
|
5620 |
+ |
|
5621 |
+ while (!eof()) { |
|
5622 |
+ chr = next(); |
|
5623 |
+ /* istanbul ignore if */ |
|
5624 |
+ if (isStringStart(chr)) { |
|
5625 |
+ parseString(chr); |
|
5626 |
+ } else if (chr === 0x5B) { |
|
5627 |
+ parseBracket(chr); |
|
5628 |
+ } |
|
5629 |
+ } |
|
5630 |
+ |
|
5631 |
+ return { |
|
5632 |
+ exp: val.substring(0, expressionPos), |
|
5633 |
+ idx: val.substring(expressionPos + 1, expressionEndPos) |
|
5634 |
+ } |
|
5635 |
+} |
|
5636 |
+ |
|
5637 |
+function next () { |
|
5638 |
+ return str.charCodeAt(++index$1) |
|
5639 |
+} |
|
5640 |
+ |
|
5641 |
+function eof () { |
|
5642 |
+ return index$1 >= len |
|
5643 |
+} |
|
5644 |
+ |
|
5645 |
+function isStringStart (chr) { |
|
5646 |
+ return chr === 0x22 || chr === 0x27 |
|
5647 |
+} |
|
5648 |
+ |
|
5649 |
+function parseBracket (chr) { |
|
5650 |
+ var inBracket = 1; |
|
5651 |
+ expressionPos = index$1; |
|
5652 |
+ while (!eof()) { |
|
5653 |
+ chr = next(); |
|
5654 |
+ if (isStringStart(chr)) { |
|
5655 |
+ parseString(chr); |
|
5656 |
+ continue |
|
5657 |
+ } |
|
5658 |
+ if (chr === 0x5B) { inBracket++; } |
|
5659 |
+ if (chr === 0x5D) { inBracket--; } |
|
5660 |
+ if (inBracket === 0) { |
|
5661 |
+ expressionEndPos = index$1; |
|
5662 |
+ break |
|
5663 |
+ } |
|
5664 |
+ } |
|
5665 |
+} |
|
5666 |
+ |
|
5667 |
+function parseString (chr) { |
|
5668 |
+ var stringQuote = chr; |
|
5669 |
+ while (!eof()) { |
|
5670 |
+ chr = next(); |
|
5671 |
+ if (chr === stringQuote) { |
|
5672 |
+ break |
|
5673 |
+ } |
|
5674 |
+ } |
|
5675 |
+} |
|
5676 |
+ |
|
5677 |
+/* */ |
|
5678 |
+ |
|
5679 |
+var warn$1; |
|
5680 |
+ |
|
5681 |
+// in some cases, the event used has to be determined at runtime |
|
5682 |
+// so we used some reserved tokens during compile. |
|
5683 |
+var RANGE_TOKEN = '__r'; |
|
5684 |
+var CHECKBOX_RADIO_TOKEN = '__c'; |
|
5685 |
+ |
|
5686 |
+function model ( |
|
5687 |
+ el, |
|
5688 |
+ dir, |
|
5689 |
+ _warn |
|
5690 |
+) { |
|
5691 |
+ warn$1 = _warn; |
|
5692 |
+ var value = dir.value; |
|
5693 |
+ var modifiers = dir.modifiers; |
|
5694 |
+ var tag = el.tag; |
|
5695 |
+ var type = el.attrsMap.type; |
|
5696 |
+ |
|
5697 |
+ { |
|
5698 |
+ var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type']; |
|
5699 |
+ if (tag === 'input' && dynamicType) { |
|
5700 |
+ warn$1( |
|
5701 |
+ "<input :type=\"" + dynamicType + "\" v-model=\"" + value + "\">:\n" + |
|
5702 |
+ "v-model does not support dynamic input types. Use v-if branches instead." |
|
5703 |
+ ); |
|
5704 |
+ } |
|
5705 |
+ // inputs with type="file" are read only and setting the input's |
|
5706 |
+ // value will throw an error. |
|
5707 |
+ if (tag === 'input' && type === 'file') { |
|
5708 |
+ warn$1( |
|
5709 |
+ "<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" + |
|
5710 |
+ "File inputs are read only. Use a v-on:change listener instead." |
|
5711 |
+ ); |
|
5712 |
+ } |
|
5713 |
+ } |
|
5714 |
+ |
|
5715 |
+ if (tag === 'select') { |
|
5716 |
+ genSelect(el, value, modifiers); |
|
5717 |
+ } else if (tag === 'input' && type === 'checkbox') { |
|
5718 |
+ genCheckboxModel(el, value, modifiers); |
|
5719 |
+ } else if (tag === 'input' && type === 'radio') { |
|
5720 |
+ genRadioModel(el, value, modifiers); |
|
5721 |
+ } else if (tag === 'input' || tag === 'textarea') { |
|
5722 |
+ genDefaultModel(el, value, modifiers); |
|
5723 |
+ } else if (!config.isReservedTag(tag)) { |
|
5724 |
+ genComponentModel(el, value, modifiers); |
|
5725 |
+ // component v-model doesn't need extra runtime |
|
5726 |
+ return false |
|
5727 |
+ } else { |
|
5728 |
+ warn$1( |
|
5729 |
+ "<" + (el.tag) + " v-model=\"" + value + "\">: " + |
|
5730 |
+ "v-model is not supported on this element type. " + |
|
5731 |
+ 'If you are working with contenteditable, it\'s recommended to ' + |
|
5732 |
+ 'wrap a library dedicated for that purpose inside a custom component.' |
|
5733 |
+ ); |
|
5734 |
+ } |
|
5735 |
+ |
|
5736 |
+ // ensure runtime directive metadata |
|
5737 |
+ return true |
|
5738 |
+} |
|
5739 |
+ |
|
5740 |
+function genCheckboxModel ( |
|
5741 |
+ el, |
|
5742 |
+ value, |
|
5743 |
+ modifiers |
|
5744 |
+) { |
|
5745 |
+ var number = modifiers && modifiers.number; |
|
5746 |
+ var valueBinding = getBindingAttr(el, 'value') || 'null'; |
|
5747 |
+ var trueValueBinding = getBindingAttr(el, 'true-value') || 'true'; |
|
5748 |
+ var falseValueBinding = getBindingAttr(el, 'false-value') || 'false'; |
|
5749 |
+ addProp(el, 'checked', |
|
5750 |
+ "Array.isArray(" + value + ")" + |
|
5751 |
+ "?_i(" + value + "," + valueBinding + ")>-1" + ( |
|
5752 |
+ trueValueBinding === 'true' |
|
5753 |
+ ? (":(" + value + ")") |
|
5754 |
+ : (":_q(" + value + "," + trueValueBinding + ")") |
|
5755 |
+ ) |
|
5756 |
+ ); |
|
5757 |
+ addHandler(el, CHECKBOX_RADIO_TOKEN, |
|
5758 |
+ "var $$a=" + value + "," + |
|
5759 |
+ '$$el=$event.target,' + |
|
5760 |
+ "$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" + |
|
5761 |
+ 'if(Array.isArray($$a)){' + |
|
5762 |
+ "var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," + |
|
5763 |
+ '$$i=_i($$a,$$v);' + |
|
5764 |
+ "if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" + |
|
5765 |
+ "else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" + |
|
5766 |
+ "}else{" + value + "=$$c}", |
|
5767 |
+ null, true |
|
5768 |
+ ); |
|
5769 |
+} |
|
5770 |
+ |
|
5771 |
+function genRadioModel ( |
|
5772 |
+ el, |
|
5773 |
+ value, |
|
5774 |
+ modifiers |
|
5775 |
+) { |
|
5776 |
+ var number = modifiers && modifiers.number; |
|
5777 |
+ var valueBinding = getBindingAttr(el, 'value') || 'null'; |
|
5778 |
+ valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding; |
|
5779 |
+ addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")")); |
|
5780 |
+ addHandler(el, CHECKBOX_RADIO_TOKEN, genAssignmentCode(value, valueBinding), null, true); |
|
5781 |
+} |
|
5782 |
+ |
|
5783 |
+function genSelect ( |
|
5784 |
+ el, |
|
5785 |
+ value, |
|
5786 |
+ modifiers |
|
5787 |
+) { |
|
5788 |
+ var number = modifiers && modifiers.number; |
|
5789 |
+ var selectedVal = "Array.prototype.filter" + |
|
5790 |
+ ".call($event.target.options,function(o){return o.selected})" + |
|
5791 |
+ ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" + |
|
5792 |
+ "return " + (number ? '_n(val)' : 'val') + "})"; |
|
5793 |
+ |
|
5794 |
+ var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'; |
|
5795 |
+ var code = "var $$selectedVal = " + selectedVal + ";"; |
|
5796 |
+ code = code + " " + (genAssignmentCode(value, assignment)); |
|
5797 |
+ addHandler(el, 'change', code, null, true); |
|
5798 |
+} |
|
5799 |
+ |
|
5800 |
+function genDefaultModel ( |
|
5801 |
+ el, |
|
5802 |
+ value, |
|
5803 |
+ modifiers |
|
5804 |
+) { |
|
5805 |
+ var type = el.attrsMap.type; |
|
5806 |
+ var ref = modifiers || {}; |
|
5807 |
+ var lazy = ref.lazy; |
|
5808 |
+ var number = ref.number; |
|
5809 |
+ var trim = ref.trim; |
|
5810 |
+ var needCompositionGuard = !lazy && type !== 'range'; |
|
5811 |
+ var event = lazy |
|
5812 |
+ ? 'change' |
|
5813 |
+ : type === 'range' |
|
5814 |
+ ? RANGE_TOKEN |
|
5815 |
+ : 'input'; |
|
5816 |
+ |
|
5817 |
+ var valueExpression = '$event.target.value'; |
|
5818 |
+ if (trim) { |
|
5819 |
+ valueExpression = "$event.target.value.trim()"; |
|
5820 |
+ } |
|
5821 |
+ if (number) { |
|
5822 |
+ valueExpression = "_n(" + valueExpression + ")"; |
|
5823 |
+ } |
|
5824 |
+ |
|
5825 |
+ var code = genAssignmentCode(value, valueExpression); |
|
5826 |
+ if (needCompositionGuard) { |
|
5827 |
+ code = "if($event.target.composing)return;" + code; |
|
5828 |
+ } |
|
5829 |
+ |
|
5830 |
+ addProp(el, 'value', ("(" + value + ")")); |
|
5831 |
+ addHandler(el, event, code, null, true); |
|
5832 |
+ if (trim || number || type === 'number') { |
|
5833 |
+ addHandler(el, 'blur', '$forceUpdate()'); |
|
5834 |
+ } |
|
5835 |
+} |
|
5836 |
+ |
|
5837 |
+/* */ |
|
5838 |
+ |
|
5839 |
+// normalize v-model event tokens that can only be determined at runtime. |
|
5840 |
+// it's important to place the event as the first in the array because |
|
5841 |
+// the whole point is ensuring the v-model callback gets called before |
|
5842 |
+// user-attached handlers. |
|
5843 |
+function normalizeEvents (on) { |
|
5844 |
+ var event; |
|
5845 |
+ /* istanbul ignore if */ |
|
5846 |
+ if (on[RANGE_TOKEN]) { |
|
5847 |
+ // IE input[type=range] only supports `change` event |
|
5848 |
+ event = isIE ? 'change' : 'input'; |
|
5849 |
+ on[event] = [].concat(on[RANGE_TOKEN], on[event] || []); |
|
5850 |
+ delete on[RANGE_TOKEN]; |
|
5851 |
+ } |
|
5852 |
+ if (on[CHECKBOX_RADIO_TOKEN]) { |
|
5853 |
+ // Chrome fires microtasks in between click/change, leads to #4521 |
|
5854 |
+ event = isChrome ? 'click' : 'change'; |
|
5855 |
+ on[event] = [].concat(on[CHECKBOX_RADIO_TOKEN], on[event] || []); |
|
5856 |
+ delete on[CHECKBOX_RADIO_TOKEN]; |
|
5857 |
+ } |
|
5858 |
+} |
|
5859 |
+ |
|
5860 |
+var target$1; |
|
5861 |
+ |
|
5862 |
+function add$1 ( |
|
5863 |
+ event, |
|
5864 |
+ handler, |
|
5865 |
+ once, |
|
5866 |
+ capture |
|
5867 |
+) { |
|
5868 |
+ if (once) { |
|
5869 |
+ var oldHandler = handler; |
|
5870 |
+ var _target = target$1; // save current target element in closure |
|
5871 |
+ handler = function (ev) { |
|
5872 |
+ var res = arguments.length === 1 |
|
5873 |
+ ? oldHandler(ev) |
|
5874 |
+ : oldHandler.apply(null, arguments); |
|
5875 |
+ if (res !== null) { |
|
5876 |
+ remove$2(event, handler, capture, _target); |
|
5877 |
+ } |
|
5878 |
+ }; |
|
5879 |
+ } |
|
5880 |
+ target$1.addEventListener(event, handler, capture); |
|
5881 |
+} |
|
5882 |
+ |
|
5883 |
+function remove$2 ( |
|
5884 |
+ event, |
|
5885 |
+ handler, |
|
5886 |
+ capture, |
|
5887 |
+ _target |
|
5888 |
+) { |
|
5889 |
+ (_target || target$1).removeEventListener(event, handler, capture); |
|
5890 |
+} |
|
5891 |
+ |
|
5892 |
+function updateDOMListeners (oldVnode, vnode) { |
|
5893 |
+ if (!oldVnode.data.on && !vnode.data.on) { |
|
5894 |
+ return |
|
5895 |
+ } |
|
5896 |
+ var on = vnode.data.on || {}; |
|
5897 |
+ var oldOn = oldVnode.data.on || {}; |
|
5898 |
+ target$1 = vnode.elm; |
|
5899 |
+ normalizeEvents(on); |
|
5900 |
+ updateListeners(on, oldOn, add$1, remove$2, vnode.context); |
|
5901 |
+} |
|
5902 |
+ |
|
5903 |
+var events = { |
|
5904 |
+ create: updateDOMListeners, |
|
5905 |
+ update: updateDOMListeners |
|
5906 |
+}; |
|
5907 |
+ |
|
5908 |
+/* */ |
|
5909 |
+ |
|
5910 |
+function updateDOMProps (oldVnode, vnode) { |
|
5911 |
+ if (!oldVnode.data.domProps && !vnode.data.domProps) { |
|
5912 |
+ return |
|
5913 |
+ } |
|
5914 |
+ var key, cur; |
|
5915 |
+ var elm = vnode.elm; |
|
5916 |
+ var oldProps = oldVnode.data.domProps || {}; |
|
5917 |
+ var props = vnode.data.domProps || {}; |
|
5918 |
+ // clone observed objects, as the user probably wants to mutate it |
|
5919 |
+ if (props.__ob__) { |
|
5920 |
+ props = vnode.data.domProps = extend({}, props); |
|
5921 |
+ } |
|
5922 |
+ |
|
5923 |
+ for (key in oldProps) { |
|
5924 |
+ if (props[key] == null) { |
|
5925 |
+ elm[key] = ''; |
|
5926 |
+ } |
|
5927 |
+ } |
|
5928 |
+ for (key in props) { |
|
5929 |
+ cur = props[key]; |
|
5930 |
+ // ignore children if the node has textContent or innerHTML, |
|
5931 |
+ // as these will throw away existing DOM nodes and cause removal errors |
|
5932 |
+ // on subsequent patches (#3360) |
|
5933 |
+ if (key === 'textContent' || key === 'innerHTML') { |
|
5934 |
+ if (vnode.children) { vnode.children.length = 0; } |
|
5935 |
+ if (cur === oldProps[key]) { continue } |
|
5936 |
+ } |
|
5937 |
+ |
|
5938 |
+ if (key === 'value') { |
|
5939 |
+ // store value as _value as well since |
|
5940 |
+ // non-string values will be stringified |
|
5941 |
+ elm._value = cur; |
|
5942 |
+ // avoid resetting cursor position when value is the same |
|
5943 |
+ var strCur = cur == null ? '' : String(cur); |
|
5944 |
+ if (shouldUpdateValue(elm, vnode, strCur)) { |
|
5945 |
+ elm.value = strCur; |
|
5946 |
+ } |
|
5947 |
+ } else { |
|
5948 |
+ elm[key] = cur; |
|
5949 |
+ } |
|
5950 |
+ } |
|
5951 |
+} |
|
5952 |
+ |
|
5953 |
+// check platforms/web/util/attrs.js acceptValue |
|
5954 |
+ |
|
5955 |
+ |
|
5956 |
+function shouldUpdateValue ( |
|
5957 |
+ elm, |
|
5958 |
+ vnode, |
|
5959 |
+ checkVal |
|
5960 |
+) { |
|
5961 |
+ return (!elm.composing && ( |
|
5962 |
+ vnode.tag === 'option' || |
|
5963 |
+ isDirty(elm, checkVal) || |
|
5964 |
+ isInputChanged(elm, checkVal) |
|
5965 |
+ )) |
|
5966 |
+} |
|
5967 |
+ |
|
5968 |
+function isDirty (elm, checkVal) { |
|
5969 |
+ // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value |
|
5970 |
+ return document.activeElement !== elm && elm.value !== checkVal |
|
5971 |
+} |
|
5972 |
+ |
|
5973 |
+function isInputChanged (elm, newVal) { |
|
5974 |
+ var value = elm.value; |
|
5975 |
+ var modifiers = elm._vModifiers; // injected by v-model runtime |
|
5976 |
+ if ((modifiers && modifiers.number) || elm.type === 'number') { |
|
5977 |
+ return toNumber(value) !== toNumber(newVal) |
|
5978 |
+ } |
|
5979 |
+ if (modifiers && modifiers.trim) { |
|
5980 |
+ return value.trim() !== newVal.trim() |
|
5981 |
+ } |
|
5982 |
+ return value !== newVal |
|
5983 |
+} |
|
5984 |
+ |
|
5985 |
+var domProps = { |
|
5986 |
+ create: updateDOMProps, |
|
5987 |
+ update: updateDOMProps |
|
5988 |
+}; |
|
5989 |
+ |
|
5990 |
+/* */ |
|
5991 |
+ |
|
5992 |
+var parseStyleText = cached(function (cssText) { |
|
5993 |
+ var res = {}; |
|
5994 |
+ var listDelimiter = /;(?![^(]*\))/g; |
|
5995 |
+ var propertyDelimiter = /:(.+)/; |
|
5996 |
+ cssText.split(listDelimiter).forEach(function (item) { |
|
5997 |
+ if (item) { |
|
5998 |
+ var tmp = item.split(propertyDelimiter); |
|
5999 |
+ tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()); |
|
6000 |
+ } |
|
6001 |
+ }); |
|
6002 |
+ return res |
|
6003 |
+}); |
|
6004 |
+ |
|
6005 |
+// merge static and dynamic style data on the same vnode |
|
6006 |
+function normalizeStyleData (data) { |
|
6007 |
+ var style = normalizeStyleBinding(data.style); |
|
6008 |
+ // static style is pre-processed into an object during compilation |
|
6009 |
+ // and is always a fresh object, so it's safe to merge into it |
|
6010 |
+ return data.staticStyle |
|
6011 |
+ ? extend(data.staticStyle, style) |
|
6012 |
+ : style |
|
6013 |
+} |
|
6014 |
+ |
|
6015 |
+// normalize possible array / string values into Object |
|
6016 |
+function normalizeStyleBinding (bindingStyle) { |
|
6017 |
+ if (Array.isArray(bindingStyle)) { |
|
6018 |
+ return toObject(bindingStyle) |
|
6019 |
+ } |
|
6020 |
+ if (typeof bindingStyle === 'string') { |
|
6021 |
+ return parseStyleText(bindingStyle) |
|
6022 |
+ } |
|
6023 |
+ return bindingStyle |
|
6024 |
+} |
|
6025 |
+ |
|
6026 |
+/** |
|
6027 |
+ * parent component style should be after child's |
|
6028 |
+ * so that parent component's style could override it |
|
6029 |
+ */ |
|
6030 |
+function getStyle (vnode, checkChild) { |
|
6031 |
+ var res = {}; |
|
6032 |
+ var styleData; |
|
6033 |
+ |
|
6034 |
+ if (checkChild) { |
|
6035 |
+ var childNode = vnode; |
|
6036 |
+ while (childNode.componentInstance) { |
|
6037 |
+ childNode = childNode.componentInstance._vnode; |
|
6038 |
+ if (childNode.data && (styleData = normalizeStyleData(childNode.data))) { |
|
6039 |
+ extend(res, styleData); |
|
6040 |
+ } |
|
6041 |
+ } |
|
6042 |
+ } |
|
6043 |
+ |
|
6044 |
+ if ((styleData = normalizeStyleData(vnode.data))) { |
|
6045 |
+ extend(res, styleData); |
|
6046 |
+ } |
|
6047 |
+ |
|
6048 |
+ var parentNode = vnode; |
|
6049 |
+ while ((parentNode = parentNode.parent)) { |
|
6050 |
+ if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) { |
|
6051 |
+ extend(res, styleData); |
|
6052 |
+ } |
|
6053 |
+ } |
|
6054 |
+ return res |
|
6055 |
+} |
|
6056 |
+ |
|
6057 |
+/* */ |
|
6058 |
+ |
|
6059 |
+var cssVarRE = /^--/; |
|
6060 |
+var importantRE = /\s*!important$/; |
|
6061 |
+var setProp = function (el, name, val) { |
|
6062 |
+ /* istanbul ignore if */ |
|
6063 |
+ if (cssVarRE.test(name)) { |
|
6064 |
+ el.style.setProperty(name, val); |
|
6065 |
+ } else if (importantRE.test(val)) { |
|
6066 |
+ el.style.setProperty(name, val.replace(importantRE, ''), 'important'); |
|
6067 |
+ } else { |
|
6068 |
+ el.style[normalize(name)] = val; |
|
6069 |
+ } |
|
6070 |
+}; |
|
6071 |
+ |
|
6072 |
+var prefixes = ['Webkit', 'Moz', 'ms']; |
|
6073 |
+ |
|
6074 |
+var testEl; |
|
6075 |
+var normalize = cached(function (prop) { |
|
6076 |
+ testEl = testEl || document.createElement('div'); |
|
6077 |
+ prop = camelize(prop); |
|
6078 |
+ if (prop !== 'filter' && (prop in testEl.style)) { |
|
6079 |
+ return prop |
|
6080 |
+ } |
|
6081 |
+ var upper = prop.charAt(0).toUpperCase() + prop.slice(1); |
|
6082 |
+ for (var i = 0; i < prefixes.length; i++) { |
|
6083 |
+ var prefixed = prefixes[i] + upper; |
|
6084 |
+ if (prefixed in testEl.style) { |
|
6085 |
+ return prefixed |
|
6086 |
+ } |
|
6087 |
+ } |
|
6088 |
+}); |
|
6089 |
+ |
|
6090 |
+function updateStyle (oldVnode, vnode) { |
|
6091 |
+ var data = vnode.data; |
|
6092 |
+ var oldData = oldVnode.data; |
|
6093 |
+ |
|
6094 |
+ if (!data.staticStyle && !data.style && |
|
6095 |
+ !oldData.staticStyle && !oldData.style) { |
|
6096 |
+ return |
|
6097 |
+ } |
|
6098 |
+ |
|
6099 |
+ var cur, name; |
|
6100 |
+ var el = vnode.elm; |
|
6101 |
+ var oldStaticStyle = oldVnode.data.staticStyle; |
|
6102 |
+ var oldStyleBinding = oldVnode.data.style || {}; |
|
6103 |
+ |
|
6104 |
+ // if static style exists, stylebinding already merged into it when doing normalizeStyleData |
|
6105 |
+ var oldStyle = oldStaticStyle || oldStyleBinding; |
|
6106 |
+ |
|
6107 |
+ var style = normalizeStyleBinding(vnode.data.style) || {}; |
|
6108 |
+ |
|
6109 |
+ vnode.data.style = style.__ob__ ? extend({}, style) : style; |
|
6110 |
+ |
|
6111 |
+ var newStyle = getStyle(vnode, true); |
|
6112 |
+ |
|
6113 |
+ for (name in oldStyle) { |
|
6114 |
+ if (newStyle[name] == null) { |
|
6115 |
+ setProp(el, name, ''); |
|
6116 |
+ } |
|
6117 |
+ } |
|
6118 |
+ for (name in newStyle) { |
|
6119 |
+ cur = newStyle[name]; |
|
6120 |
+ if (cur !== oldStyle[name]) { |
|
6121 |
+ // ie9 setting to null has no effect, must use empty string |
|
6122 |
+ setProp(el, name, cur == null ? '' : cur); |
|
6123 |
+ } |
|
6124 |
+ } |
|
6125 |
+} |
|
6126 |
+ |
|
6127 |
+var style = { |
|
6128 |
+ create: updateStyle, |
|
6129 |
+ update: updateStyle |
|
6130 |
+}; |
|
6131 |
+ |
|
6132 |
+/* */ |
|
6133 |
+ |
|
6134 |
+/** |
|
6135 |
+ * Add class with compatibility for SVG since classList is not supported on |
|
6136 |
+ * SVG elements in IE |
|
6137 |
+ */ |
|
6138 |
+function addClass (el, cls) { |
|
6139 |
+ /* istanbul ignore if */ |
|
6140 |
+ if (!cls || !(cls = cls.trim())) { |
|
6141 |
+ return |
|
6142 |
+ } |
|
6143 |
+ |
|
6144 |
+ /* istanbul ignore else */ |
|
6145 |
+ if (el.classList) { |
|
6146 |
+ if (cls.indexOf(' ') > -1) { |
|
6147 |
+ cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); }); |
|
6148 |
+ } else { |
|
6149 |
+ el.classList.add(cls); |
|
6150 |
+ } |
|
6151 |
+ } else { |
|
6152 |
+ var cur = " " + (el.getAttribute('class') || '') + " "; |
|
6153 |
+ if (cur.indexOf(' ' + cls + ' ') < 0) { |
|
6154 |
+ el.setAttribute('class', (cur + cls).trim()); |
|
6155 |
+ } |
|
6156 |
+ } |
|
6157 |
+} |
|
6158 |
+ |
|
6159 |
+/** |
|
6160 |
+ * Remove class with compatibility for SVG since classList is not supported on |
|
6161 |
+ * SVG elements in IE |
|
6162 |
+ */ |
|
6163 |
+function removeClass (el, cls) { |
|
6164 |
+ /* istanbul ignore if */ |
|
6165 |
+ if (!cls || !(cls = cls.trim())) { |
|
6166 |
+ return |
|
6167 |
+ } |
|
6168 |
+ |
|
6169 |
+ /* istanbul ignore else */ |
|
6170 |
+ if (el.classList) { |
|
6171 |
+ if (cls.indexOf(' ') > -1) { |
|
6172 |
+ cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); }); |
|
6173 |
+ } else { |
|
6174 |
+ el.classList.remove(cls); |
|
6175 |
+ } |
|
6176 |
+ } else { |
|
6177 |
+ var cur = " " + (el.getAttribute('class') || '') + " "; |
|
6178 |
+ var tar = ' ' + cls + ' '; |
|
6179 |
+ while (cur.indexOf(tar) >= 0) { |
|
6180 |
+ cur = cur.replace(tar, ' '); |
|
6181 |
+ } |
|
6182 |
+ el.setAttribute('class', cur.trim()); |
|
6183 |
+ } |
|
6184 |
+} |
|
6185 |
+ |
|
6186 |
+/* */ |
|
6187 |
+ |
|
6188 |
+function resolveTransition (def$$1) { |
|
6189 |
+ if (!def$$1) { |
|
6190 |
+ return |
|
6191 |
+ } |
|
6192 |
+ /* istanbul ignore else */ |
|
6193 |
+ if (typeof def$$1 === 'object') { |
|
6194 |
+ var res = {}; |
|
6195 |
+ if (def$$1.css !== false) { |
|
6196 |
+ extend(res, autoCssTransition(def$$1.name || 'v')); |
|
6197 |
+ } |
|
6198 |
+ extend(res, def$$1); |
|
6199 |
+ return res |
|
6200 |
+ } else if (typeof def$$1 === 'string') { |
|
6201 |
+ return autoCssTransition(def$$1) |
|
6202 |
+ } |
|
6203 |
+} |
|
6204 |
+ |
|
6205 |
+var autoCssTransition = cached(function (name) { |
|
6206 |
+ return { |
|
6207 |
+ enterClass: (name + "-enter"), |
|
6208 |
+ enterToClass: (name + "-enter-to"), |
|
6209 |
+ enterActiveClass: (name + "-enter-active"), |
|
6210 |
+ leaveClass: (name + "-leave"), |
|
6211 |
+ leaveToClass: (name + "-leave-to"), |
|
6212 |
+ leaveActiveClass: (name + "-leave-active") |
|
6213 |
+ } |
|
6214 |
+}); |
|
6215 |
+ |
|
6216 |
+var hasTransition = inBrowser && !isIE9; |
|
6217 |
+var TRANSITION = 'transition'; |
|
6218 |
+var ANIMATION = 'animation'; |
|
6219 |
+ |
|
6220 |
+// Transition property/event sniffing |
|
6221 |
+var transitionProp = 'transition'; |
|
6222 |
+var transitionEndEvent = 'transitionend'; |
|
6223 |
+var animationProp = 'animation'; |
|
6224 |
+var animationEndEvent = 'animationend'; |
|
6225 |
+if (hasTransition) { |
|
6226 |
+ /* istanbul ignore if */ |
|
6227 |
+ if (window.ontransitionend === undefined && |
|
6228 |
+ window.onwebkittransitionend !== undefined) { |
|
6229 |
+ transitionProp = 'WebkitTransition'; |
|
6230 |
+ transitionEndEvent = 'webkitTransitionEnd'; |
|
6231 |
+ } |
|
6232 |
+ if (window.onanimationend === undefined && |
|
6233 |
+ window.onwebkitanimationend !== undefined) { |
|
6234 |
+ animationProp = 'WebkitAnimation'; |
|
6235 |
+ animationEndEvent = 'webkitAnimationEnd'; |
|
6236 |
+ } |
|
6237 |
+} |
|
6238 |
+ |
|
6239 |
+// binding to window is necessary to make hot reload work in IE in strict mode |
|
6240 |
+var raf = inBrowser && window.requestAnimationFrame |
|
6241 |
+ ? window.requestAnimationFrame.bind(window) |
|
6242 |
+ : setTimeout; |
|
6243 |
+ |
|
6244 |
+function nextFrame (fn) { |
|
6245 |
+ raf(function () { |
|
6246 |
+ raf(fn); |
|
6247 |
+ }); |
|
6248 |
+} |
|
6249 |
+ |
|
6250 |
+function addTransitionClass (el, cls) { |
|
6251 |
+ (el._transitionClasses || (el._transitionClasses = [])).push(cls); |
|
6252 |
+ addClass(el, cls); |
|
6253 |
+} |
|
6254 |
+ |
|
6255 |
+function removeTransitionClass (el, cls) { |
|
6256 |
+ if (el._transitionClasses) { |
|
6257 |
+ remove(el._transitionClasses, cls); |
|
6258 |
+ } |
|
6259 |
+ removeClass(el, cls); |
|
6260 |
+} |
|
6261 |
+ |
|
6262 |
+function whenTransitionEnds ( |
|
6263 |
+ el, |
|
6264 |
+ expectedType, |
|
6265 |
+ cb |
|
6266 |
+) { |
|
6267 |
+ var ref = getTransitionInfo(el, expectedType); |
|
6268 |
+ var type = ref.type; |
|
6269 |
+ var timeout = ref.timeout; |
|
6270 |
+ var propCount = ref.propCount; |
|
6271 |
+ if (!type) { return cb() } |
|
6272 |
+ var event = type === TRANSITION ? transitionEndEvent : animationEndEvent; |
|
6273 |
+ var ended = 0; |
|
6274 |
+ var end = function () { |
|
6275 |
+ el.removeEventListener(event, onEnd); |
|
6276 |
+ cb(); |
|
6277 |
+ }; |
|
6278 |
+ var onEnd = function (e) { |
|
6279 |
+ if (e.target === el) { |
|
6280 |
+ if (++ended >= propCount) { |
|
6281 |
+ end(); |
|
6282 |
+ } |
|
6283 |
+ } |
|
6284 |
+ }; |
|
6285 |
+ setTimeout(function () { |
|
6286 |
+ if (ended < propCount) { |
|
6287 |
+ end(); |
|
6288 |
+ } |
|
6289 |
+ }, timeout + 1); |
|
6290 |
+ el.addEventListener(event, onEnd); |
|
6291 |
+} |
|
6292 |
+ |
|
6293 |
+var transformRE = /\b(transform|all)(,|$)/; |
|
6294 |
+ |
|
6295 |
+function getTransitionInfo (el, expectedType) { |
|
6296 |
+ var styles = window.getComputedStyle(el); |
|
6297 |
+ var transitionDelays = styles[transitionProp + 'Delay'].split(', '); |
|
6298 |
+ var transitionDurations = styles[transitionProp + 'Duration'].split(', '); |
|
6299 |
+ var transitionTimeout = getTimeout(transitionDelays, transitionDurations); |
|
6300 |
+ var animationDelays = styles[animationProp + 'Delay'].split(', '); |
|
6301 |
+ var animationDurations = styles[animationProp + 'Duration'].split(', '); |
|
6302 |
+ var animationTimeout = getTimeout(animationDelays, animationDurations); |
|
6303 |
+ |
|
6304 |
+ var type; |
|
6305 |
+ var timeout = 0; |
|
6306 |
+ var propCount = 0; |
|
6307 |
+ /* istanbul ignore if */ |
|
6308 |
+ if (expectedType === TRANSITION) { |
|
6309 |
+ if (transitionTimeout > 0) { |
|
6310 |
+ type = TRANSITION; |
|
6311 |
+ timeout = transitionTimeout; |
|
6312 |
+ propCount = transitionDurations.length; |
|
6313 |
+ } |
|
6314 |
+ } else if (expectedType === ANIMATION) { |
|
6315 |
+ if (animationTimeout > 0) { |
|
6316 |
+ type = ANIMATION; |
|
6317 |
+ timeout = animationTimeout; |
|
6318 |
+ propCount = animationDurations.length; |
|
6319 |
+ } |
|
6320 |
+ } else { |
|
6321 |
+ timeout = Math.max(transitionTimeout, animationTimeout); |
|
6322 |
+ type = timeout > 0 |
|
6323 |
+ ? transitionTimeout > animationTimeout |
|
6324 |
+ ? TRANSITION |
|
6325 |
+ : ANIMATION |
|
6326 |
+ : null; |
|
6327 |
+ propCount = type |
|
6328 |
+ ? type === TRANSITION |
|
6329 |
+ ? transitionDurations.length |
|
6330 |
+ : animationDurations.length |
|
6331 |
+ : 0; |
|
6332 |
+ } |
|
6333 |
+ var hasTransform = |
|
6334 |
+ type === TRANSITION && |
|
6335 |
+ transformRE.test(styles[transitionProp + 'Property']); |
|
6336 |
+ return { |
|
6337 |
+ type: type, |
|
6338 |
+ timeout: timeout, |
|
6339 |
+ propCount: propCount, |
|
6340 |
+ hasTransform: hasTransform |
|
6341 |
+ } |
|
6342 |
+} |
|
6343 |
+ |
|
6344 |
+function getTimeout (delays, durations) { |
|
6345 |
+ /* istanbul ignore next */ |
|
6346 |
+ while (delays.length < durations.length) { |
|
6347 |
+ delays = delays.concat(delays); |
|
6348 |
+ } |
|
6349 |
+ |
|
6350 |
+ return Math.max.apply(null, durations.map(function (d, i) { |
|
6351 |
+ return toMs(d) + toMs(delays[i]) |
|
6352 |
+ })) |
|
6353 |
+} |
|
6354 |
+ |
|
6355 |
+function toMs (s) { |
|
6356 |
+ return Number(s.slice(0, -1)) * 1000 |
|
6357 |
+} |
|
6358 |
+ |
|
6359 |
+/* */ |
|
6360 |
+ |
|
6361 |
+function enter (vnode, toggleDisplay) { |
|
6362 |
+ var el = vnode.elm; |
|
6363 |
+ |
|
6364 |
+ // call leave callback now |
|
6365 |
+ if (el._leaveCb) { |
|
6366 |
+ el._leaveCb.cancelled = true; |
|
6367 |
+ el._leaveCb(); |
|
6368 |
+ } |
|
6369 |
+ |
|
6370 |
+ var data = resolveTransition(vnode.data.transition); |
|
6371 |
+ if (!data) { |
|
6372 |
+ return |
|
6373 |
+ } |
|
6374 |
+ |
|
6375 |
+ /* istanbul ignore if */ |
|
6376 |
+ if (el._enterCb || el.nodeType !== 1) { |
|
6377 |
+ return |
|
6378 |
+ } |
|
6379 |
+ |
|
6380 |
+ var css = data.css; |
|
6381 |
+ var type = data.type; |
|
6382 |
+ var enterClass = data.enterClass; |
|
6383 |
+ var enterToClass = data.enterToClass; |
|
6384 |
+ var enterActiveClass = data.enterActiveClass; |
|
6385 |
+ var appearClass = data.appearClass; |
|
6386 |
+ var appearToClass = data.appearToClass; |
|
6387 |
+ var appearActiveClass = data.appearActiveClass; |
|
6388 |
+ var beforeEnter = data.beforeEnter; |
|
6389 |
+ var enter = data.enter; |
|
6390 |
+ var afterEnter = data.afterEnter; |
|
6391 |
+ var enterCancelled = data.enterCancelled; |
|
6392 |
+ var beforeAppear = data.beforeAppear; |
|
6393 |
+ var appear = data.appear; |
|
6394 |
+ var afterAppear = data.afterAppear; |
|
6395 |
+ var appearCancelled = data.appearCancelled; |
|
6396 |
+ var duration = data.duration; |
|
6397 |
+ |
|
6398 |
+ // activeInstance will always be the <transition> component managing this |
|
6399 |
+ // transition. One edge case to check is when the <transition> is placed |
|
6400 |
+ // as the root node of a child component. In that case we need to check |
|
6401 |
+ // <transition>'s parent for appear check. |
|
6402 |
+ var context = activeInstance; |
|
6403 |
+ var transitionNode = activeInstance.$vnode; |
|
6404 |
+ while (transitionNode && transitionNode.parent) { |
|
6405 |
+ transitionNode = transitionNode.parent; |
|
6406 |
+ context = transitionNode.context; |
|
6407 |
+ } |
|
6408 |
+ |
|
6409 |
+ var isAppear = !context._isMounted || !vnode.isRootInsert; |
|
6410 |
+ |
|
6411 |
+ if (isAppear && !appear && appear !== '') { |
|
6412 |
+ return |
|
6413 |
+ } |
|
6414 |
+ |
|
6415 |
+ var startClass = isAppear && appearClass |
|
6416 |
+ ? appearClass |
|
6417 |
+ : enterClass; |
|
6418 |
+ var activeClass = isAppear && appearActiveClass |
|
6419 |
+ ? appearActiveClass |
|
6420 |
+ : enterActiveClass; |
|
6421 |
+ var toClass = isAppear && appearToClass |
|
6422 |
+ ? appearToClass |
|
6423 |
+ : enterToClass; |
|
6424 |
+ |
|
6425 |
+ var beforeEnterHook = isAppear |
|
6426 |
+ ? (beforeAppear || beforeEnter) |
|
6427 |
+ : beforeEnter; |
|
6428 |
+ var enterHook = isAppear |
|
6429 |
+ ? (typeof appear === 'function' ? appear : enter) |
|
6430 |
+ : enter; |
|
6431 |
+ var afterEnterHook = isAppear |
|
6432 |
+ ? (afterAppear || afterEnter) |
|
6433 |
+ : afterEnter; |
|
6434 |
+ var enterCancelledHook = isAppear |
|
6435 |
+ ? (appearCancelled || enterCancelled) |
|
6436 |
+ : enterCancelled; |
|
6437 |
+ |
|
6438 |
+ var explicitEnterDuration = toNumber( |
|
6439 |
+ isObject(duration) |
|
6440 |
+ ? duration.enter |
|
6441 |
+ : duration |
|
6442 |
+ ); |
|
6443 |
+ |
|
6444 |
+ if ("development" !== 'production' && explicitEnterDuration != null) { |
|
6445 |
+ checkDuration(explicitEnterDuration, 'enter', vnode); |
|
6446 |
+ } |
|
6447 |
+ |
|
6448 |
+ var expectsCSS = css !== false && !isIE9; |
|
6449 |
+ var userWantsControl = getHookArgumentsLength(enterHook); |
|
6450 |
+ |
|
6451 |
+ var cb = el._enterCb = once(function () { |
|
6452 |
+ if (expectsCSS) { |
|
6453 |
+ removeTransitionClass(el, toClass); |
|
6454 |
+ removeTransitionClass(el, activeClass); |
|
6455 |
+ } |
|
6456 |
+ if (cb.cancelled) { |
|
6457 |
+ if (expectsCSS) { |
|
6458 |
+ removeTransitionClass(el, startClass); |
|
6459 |
+ } |
|
6460 |
+ enterCancelledHook && enterCancelledHook(el); |
|
6461 |
+ } else { |
|
6462 |
+ afterEnterHook && afterEnterHook(el); |
|
6463 |
+ } |
|
6464 |
+ el._enterCb = null; |
|
6465 |
+ }); |
|
6466 |
+ |
|
6467 |
+ if (!vnode.data.show) { |
|
6468 |
+ // remove pending leave element on enter by injecting an insert hook |
|
6469 |
+ mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () { |
|
6470 |
+ var parent = el.parentNode; |
|
6471 |
+ var pendingNode = parent && parent._pending && parent._pending[vnode.key]; |
|
6472 |
+ if (pendingNode && |
|
6473 |
+ pendingNode.tag === vnode.tag && |
|
6474 |
+ pendingNode.elm._leaveCb) { |
|
6475 |
+ pendingNode.elm._leaveCb(); |
|
6476 |
+ } |
|
6477 |
+ enterHook && enterHook(el, cb); |
|
6478 |
+ }); |
|
6479 |
+ } |
|
6480 |
+ |
|
6481 |
+ // start enter transition |
|
6482 |
+ beforeEnterHook && beforeEnterHook(el); |
|
6483 |
+ if (expectsCSS) { |
|
6484 |
+ addTransitionClass(el, startClass); |
|
6485 |
+ addTransitionClass(el, activeClass); |
|
6486 |
+ nextFrame(function () { |
|
6487 |
+ addTransitionClass(el, toClass); |
|
6488 |
+ removeTransitionClass(el, startClass); |
|
6489 |
+ if (!cb.cancelled && !userWantsControl) { |
|
6490 |
+ if (isValidDuration(explicitEnterDuration)) { |
|
6491 |
+ setTimeout(cb, explicitEnterDuration); |
|
6492 |
+ } else { |
|
6493 |
+ whenTransitionEnds(el, type, cb); |
|
6494 |
+ } |
|
6495 |
+ } |
|
6496 |
+ }); |
|
6497 |
+ } |
|
6498 |
+ |
|
6499 |
+ if (vnode.data.show) { |
|
6500 |
+ toggleDisplay && toggleDisplay(); |
|
6501 |
+ enterHook && enterHook(el, cb); |
|
6502 |
+ } |
|
6503 |
+ |
|
6504 |
+ if (!expectsCSS && !userWantsControl) { |
|
6505 |
+ cb(); |
|
6506 |
+ } |
|
6507 |
+} |
|
6508 |
+ |
|
6509 |
+function leave (vnode, rm) { |
|
6510 |
+ var el = vnode.elm; |
|
6511 |
+ |
|
6512 |
+ // call enter callback now |
|
6513 |
+ if (el._enterCb) { |
|
6514 |
+ el._enterCb.cancelled = true; |
|
6515 |
+ el._enterCb(); |
|
6516 |
+ } |
|
6517 |
+ |
|
6518 |
+ var data = resolveTransition(vnode.data.transition); |
|
6519 |
+ if (!data) { |
|
6520 |
+ return rm() |
|
6521 |
+ } |
|
6522 |
+ |
|
6523 |
+ /* istanbul ignore if */ |
|
6524 |
+ if (el._leaveCb || el.nodeType !== 1) { |
|
6525 |
+ return |
|
6526 |
+ } |
|
6527 |
+ |
|
6528 |
+ var css = data.css; |
|
6529 |
+ var type = data.type; |
|
6530 |
+ var leaveClass = data.leaveClass; |
|
6531 |
+ var leaveToClass = data.leaveToClass; |
|
6532 |
+ var leaveActiveClass = data.leaveActiveClass; |
|
6533 |
+ var beforeLeave = data.beforeLeave; |
|
6534 |
+ var leave = data.leave; |
|
6535 |
+ var afterLeave = data.afterLeave; |
|
6536 |
+ var leaveCancelled = data.leaveCancelled; |
|
6537 |
+ var delayLeave = data.delayLeave; |
|
6538 |
+ var duration = data.duration; |
|
6539 |
+ |
|
6540 |
+ var expectsCSS = css !== false && !isIE9; |
|
6541 |
+ var userWantsControl = getHookArgumentsLength(leave); |
|
6542 |
+ |
|
6543 |
+ var explicitLeaveDuration = toNumber( |
|
6544 |
+ isObject(duration) |
|
6545 |
+ ? duration.leave |
|
6546 |
+ : duration |
|
6547 |
+ ); |
|
6548 |
+ |
|
6549 |
+ if ("development" !== 'production' && explicitLeaveDuration != null) { |
|
6550 |
+ checkDuration(explicitLeaveDuration, 'leave', vnode); |
|
6551 |
+ } |
|
6552 |
+ |
|
6553 |
+ var cb = el._leaveCb = once(function () { |
|
6554 |
+ if (el.parentNode && el.parentNode._pending) { |
|
6555 |
+ el.parentNode._pending[vnode.key] = null; |
|
6556 |
+ } |
|
6557 |
+ if (expectsCSS) { |
|
6558 |
+ removeTransitionClass(el, leaveToClass); |
|
6559 |
+ removeTransitionClass(el, leaveActiveClass); |
|
6560 |
+ } |
|
6561 |
+ if (cb.cancelled) { |
|
6562 |
+ if (expectsCSS) { |
|
6563 |
+ removeTransitionClass(el, leaveClass); |
|
6564 |
+ } |
|
6565 |
+ leaveCancelled && leaveCancelled(el); |
|
6566 |
+ } else { |
|
6567 |
+ rm(); |
|
6568 |
+ afterLeave && afterLeave(el); |
|
6569 |
+ } |
|
6570 |
+ el._leaveCb = null; |
|
6571 |
+ }); |
|
6572 |
+ |
|
6573 |
+ if (delayLeave) { |
|
6574 |
+ delayLeave(performLeave); |
|
6575 |
+ } else { |
|
6576 |
+ performLeave(); |
|
6577 |
+ } |
|
6578 |
+ |
|
6579 |
+ function performLeave () { |
|
6580 |
+ // the delayed leave may have already been cancelled |
|
6581 |
+ if (cb.cancelled) { |
|
6582 |
+ return |
|
6583 |
+ } |
|
6584 |
+ // record leaving element |
|
6585 |
+ if (!vnode.data.show) { |
|
6586 |
+ (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode; |
|
6587 |
+ } |
|
6588 |
+ beforeLeave && beforeLeave(el); |
|
6589 |
+ if (expectsCSS) { |
|
6590 |
+ addTransitionClass(el, leaveClass); |
|
6591 |
+ addTransitionClass(el, leaveActiveClass); |
|
6592 |
+ nextFrame(function () { |
|
6593 |
+ addTransitionClass(el, leaveToClass); |
|
6594 |
+ removeTransitionClass(el, leaveClass); |
|
6595 |
+ if (!cb.cancelled && !userWantsControl) { |
|
6596 |
+ if (isValidDuration(explicitLeaveDuration)) { |
|
6597 |
+ setTimeout(cb, explicitLeaveDuration); |
|
6598 |
+ } else { |
|
6599 |
+ whenTransitionEnds(el, type, cb); |
|
6600 |
+ } |
|
6601 |
+ } |
|
6602 |
+ }); |
|
6603 |
+ } |
|
6604 |
+ leave && leave(el, cb); |
|
6605 |
+ if (!expectsCSS && !userWantsControl) { |
|
6606 |
+ cb(); |
|
6607 |
+ } |
|
6608 |
+ } |
|
6609 |
+} |
|
6610 |
+ |
|
6611 |
+// only used in dev mode |
|
6612 |
+function checkDuration (val, name, vnode) { |
|
6613 |
+ if (typeof val !== 'number') { |
|
6614 |
+ warn( |
|
6615 |
+ "<transition> explicit " + name + " duration is not a valid number - " + |
|
6616 |
+ "got " + (JSON.stringify(val)) + ".", |
|
6617 |
+ vnode.context |
|
6618 |
+ ); |
|
6619 |
+ } else if (isNaN(val)) { |
|
6620 |
+ warn( |
|
6621 |
+ "<transition> explicit " + name + " duration is NaN - " + |
|
6622 |
+ 'the duration expression might be incorrect.', |
|
6623 |
+ vnode.context |
|
6624 |
+ ); |
|
6625 |
+ } |
|
6626 |
+} |
|
6627 |
+ |
|
6628 |
+function isValidDuration (val) { |
|
6629 |
+ return typeof val === 'number' && !isNaN(val) |
|
6630 |
+} |
|
6631 |
+ |
|
6632 |
+/** |
|
6633 |
+ * Normalize a transition hook's argument length. The hook may be: |
|
6634 |
+ * - a merged hook (invoker) with the original in .fns |
|
6635 |
+ * - a wrapped component method (check ._length) |
|
6636 |
+ * - a plain function (.length) |
|
6637 |
+ */ |
|
6638 |
+function getHookArgumentsLength (fn) { |
|
6639 |
+ if (!fn) { return false } |
|
6640 |
+ var invokerFns = fn.fns; |
|
6641 |
+ if (invokerFns) { |
|
6642 |
+ // invoker |
|
6643 |
+ return getHookArgumentsLength( |
|
6644 |
+ Array.isArray(invokerFns) |
|
6645 |
+ ? invokerFns[0] |
|
6646 |
+ : invokerFns |
|
6647 |
+ ) |
|
6648 |
+ } else { |
|
6649 |
+ return (fn._length || fn.length) > 1 |
|
6650 |
+ } |
|
6651 |
+} |
|
6652 |
+ |
|
6653 |
+function _enter (_, vnode) { |
|
6654 |
+ if (!vnode.data.show) { |
|
6655 |
+ enter(vnode); |
|
6656 |
+ } |
|
6657 |
+} |
|
6658 |
+ |
|
6659 |
+var transition = inBrowser ? { |
|
6660 |
+ create: _enter, |
|
6661 |
+ activate: _enter, |
|
6662 |
+ remove: function remove$$1 (vnode, rm) { |
|
6663 |
+ /* istanbul ignore else */ |
|
6664 |
+ if (!vnode.data.show) { |
|
6665 |
+ leave(vnode, rm); |
|
6666 |
+ } else { |
|
6667 |
+ rm(); |
|
6668 |
+ } |
|
6669 |
+ } |
|
6670 |
+} : {}; |
|
6671 |
+ |
|
6672 |
+var platformModules = [ |
|
6673 |
+ attrs, |
|
6674 |
+ klass, |
|
6675 |
+ events, |
|
6676 |
+ domProps, |
|
6677 |
+ style, |
|
6678 |
+ transition |
|
6679 |
+]; |
|
6680 |
+ |
|
6681 |
+/* */ |
|
6682 |
+ |
|
6683 |
+// the directive module should be applied last, after all |
|
6684 |
+// built-in modules have been applied. |
|
6685 |
+var modules = platformModules.concat(baseModules); |
|
6686 |
+ |
|
6687 |
+var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules }); |
|
6688 |
+ |
|
6689 |
+/** |
|
6690 |
+ * Not type checking this file because flow doesn't like attaching |
|
6691 |
+ * properties to Elements. |
|
6692 |
+ */ |
|
6693 |
+ |
|
6694 |
+/* istanbul ignore if */ |
|
6695 |
+if (isIE9) { |
|
6696 |
+ // http://www.matts411.com/post/internet-explorer-9-oninput/ |
|
6697 |
+ document.addEventListener('selectionchange', function () { |
|
6698 |
+ var el = document.activeElement; |
|
6699 |
+ if (el && el.vmodel) { |
|
6700 |
+ trigger(el, 'input'); |
|
6701 |
+ } |
|
6702 |
+ }); |
|
6703 |
+} |
|
6704 |
+ |
|
6705 |
+var model$1 = { |
|
6706 |
+ inserted: function inserted (el, binding, vnode) { |
|
6707 |
+ if (vnode.tag === 'select') { |
|
6708 |
+ var cb = function () { |
|
6709 |
+ setSelected(el, binding, vnode.context); |
|
6710 |
+ }; |
|
6711 |
+ cb(); |
|
6712 |
+ /* istanbul ignore if */ |
|
6713 |
+ if (isIE || isEdge) { |
|
6714 |
+ setTimeout(cb, 0); |
|
6715 |
+ } |
|
6716 |
+ } else if (vnode.tag === 'textarea' || el.type === 'text' || el.type === 'password') { |
|
6717 |
+ el._vModifiers = binding.modifiers; |
|
6718 |
+ if (!binding.modifiers.lazy) { |
|
6719 |
+ if (!isAndroid) { |
|
6720 |
+ el.addEventListener('compositionstart', onCompositionStart); |
|
6721 |
+ el.addEventListener('compositionend', onCompositionEnd); |
|
6722 |
+ } |
|
6723 |
+ /* istanbul ignore if */ |
|
6724 |
+ if (isIE9) { |
|
6725 |
+ el.vmodel = true; |
|
6726 |
+ } |
|
6727 |
+ } |
|
6728 |
+ } |
|
6729 |
+ }, |
|
6730 |
+ componentUpdated: function componentUpdated (el, binding, vnode) { |
|
6731 |
+ if (vnode.tag === 'select') { |
|
6732 |
+ setSelected(el, binding, vnode.context); |
|
6733 |
+ // in case the options rendered by v-for have changed, |
|
6734 |
+ // it's possible that the value is out-of-sync with the rendered options. |
|
6735 |
+ // detect such cases and filter out values that no longer has a matching |
|
6736 |
+ // option in the DOM. |
|
6737 |
+ var needReset = el.multiple |
|
6738 |
+ ? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); }) |
|
6739 |
+ : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options); |
|
6740 |
+ if (needReset) { |
|
6741 |
+ trigger(el, 'change'); |
|
6742 |
+ } |
|
6743 |
+ } |
|
6744 |
+ } |
|
6745 |
+}; |
|
6746 |
+ |
|
6747 |
+function setSelected (el, binding, vm) { |
|
6748 |
+ var value = binding.value; |
|
6749 |
+ var isMultiple = el.multiple; |
|
6750 |
+ if (isMultiple && !Array.isArray(value)) { |
|
6751 |
+ "development" !== 'production' && warn( |
|
6752 |
+ "<select multiple v-model=\"" + (binding.expression) + "\"> " + |
|
6753 |
+ "expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)), |
|
6754 |
+ vm |
|
6755 |
+ ); |
|
6756 |
+ return |
|
6757 |
+ } |
|
6758 |
+ var selected, option; |
|
6759 |
+ for (var i = 0, l = el.options.length; i < l; i++) { |
|
6760 |
+ option = el.options[i]; |
|
6761 |
+ if (isMultiple) { |
|
6762 |
+ selected = looseIndexOf(value, getValue(option)) > -1; |
|
6763 |
+ if (option.selected !== selected) { |
|
6764 |
+ option.selected = selected; |
|
6765 |
+ } |
|
6766 |
+ } else { |
|
6767 |
+ if (looseEqual(getValue(option), value)) { |
|
6768 |
+ if (el.selectedIndex !== i) { |
|
6769 |
+ el.selectedIndex = i; |
|
6770 |
+ } |
|
6771 |
+ return |
|
6772 |
+ } |
|
6773 |
+ } |
|
6774 |
+ } |
|
6775 |
+ if (!isMultiple) { |
|
6776 |
+ el.selectedIndex = -1; |
|
6777 |
+ } |
|
6778 |
+} |
|
6779 |
+ |
|
6780 |
+function hasNoMatchingOption (value, options) { |
|
6781 |
+ for (var i = 0, l = options.length; i < l; i++) { |
|
6782 |
+ if (looseEqual(getValue(options[i]), value)) { |
|
6783 |
+ return false |
|
6784 |
+ } |
|
6785 |
+ } |
|
6786 |
+ return true |
|
6787 |
+} |
|
6788 |
+ |
|
6789 |
+function getValue (option) { |
|
6790 |
+ return '_value' in option |
|
6791 |
+ ? option._value |
|
6792 |
+ : option.value |
|
6793 |
+} |
|
6794 |
+ |
|
6795 |
+function onCompositionStart (e) { |
|
6796 |
+ e.target.composing = true; |
|
6797 |
+} |
|
6798 |
+ |
|
6799 |
+function onCompositionEnd (e) { |
|
6800 |
+ e.target.composing = false; |
|
6801 |
+ trigger(e.target, 'input'); |
|
6802 |
+} |
|
6803 |
+ |
|
6804 |
+function trigger (el, type) { |
|
6805 |
+ var e = document.createEvent('HTMLEvents'); |
|
6806 |
+ e.initEvent(type, true, true); |
|
6807 |
+ el.dispatchEvent(e); |
|
6808 |
+} |
|
6809 |
+ |
|
6810 |
+/* */ |
|
6811 |
+ |
|
6812 |
+// recursively search for possible transition defined inside the component root |
|
6813 |
+function locateNode (vnode) { |
|
6814 |
+ return vnode.componentInstance && (!vnode.data || !vnode.data.transition) |
|
6815 |
+ ? locateNode(vnode.componentInstance._vnode) |
|
6816 |
+ : vnode |
|
6817 |
+} |
|
6818 |
+ |
|
6819 |
+var show = { |
|
6820 |
+ bind: function bind (el, ref, vnode) { |
|
6821 |
+ var value = ref.value; |
|
6822 |
+ |
|
6823 |
+ vnode = locateNode(vnode); |
|
6824 |
+ var transition = vnode.data && vnode.data.transition; |
|
6825 |
+ var originalDisplay = el.__vOriginalDisplay = |
|
6826 |
+ el.style.display === 'none' ? '' : el.style.display; |
|
6827 |
+ if (value && transition && !isIE9) { |
|
6828 |
+ vnode.data.show = true; |
|
6829 |
+ enter(vnode, function () { |
|
6830 |
+ el.style.display = originalDisplay; |
|
6831 |
+ }); |
|
6832 |
+ } else { |
|
6833 |
+ el.style.display = value ? originalDisplay : 'none'; |
|
6834 |
+ } |
|
6835 |
+ }, |
|
6836 |
+ |
|
6837 |
+ update: function update (el, ref, vnode) { |
|
6838 |
+ var value = ref.value; |
|
6839 |
+ var oldValue = ref.oldValue; |
|
6840 |
+ |
|
6841 |
+ /* istanbul ignore if */ |
|
6842 |
+ if (value === oldValue) { return } |
|
6843 |
+ vnode = locateNode(vnode); |
|
6844 |
+ var transition = vnode.data && vnode.data.transition; |
|
6845 |
+ if (transition && !isIE9) { |
|
6846 |
+ vnode.data.show = true; |
|
6847 |
+ if (value) { |
|
6848 |
+ enter(vnode, function () { |
|
6849 |
+ el.style.display = el.__vOriginalDisplay; |
|
6850 |
+ }); |
|
6851 |
+ } else { |
|
6852 |
+ leave(vnode, function () { |
|
6853 |
+ el.style.display = 'none'; |
|
6854 |
+ }); |
|
6855 |
+ } |
|
6856 |
+ } else { |
|
6857 |
+ el.style.display = value ? el.__vOriginalDisplay : 'none'; |
|
6858 |
+ } |
|
6859 |
+ }, |
|
6860 |
+ |
|
6861 |
+ unbind: function unbind ( |
|
6862 |
+ el, |
|
6863 |
+ binding, |
|
6864 |
+ vnode, |
|
6865 |
+ oldVnode, |
|
6866 |
+ isDestroy |
|
6867 |
+ ) { |
|
6868 |
+ if (!isDestroy) { |
|
6869 |
+ el.style.display = el.__vOriginalDisplay; |
|
6870 |
+ } |
|
6871 |
+ } |
|
6872 |
+}; |
|
6873 |
+ |
|
6874 |
+var platformDirectives = { |
|
6875 |
+ model: model$1, |
|
6876 |
+ show: show |
|
6877 |
+}; |
|
6878 |
+ |
|
6879 |
+/* */ |
|
6880 |
+ |
|
6881 |
+// Provides transition support for a single element/component. |
|
6882 |
+// supports transition mode (out-in / in-out) |
|
6883 |
+ |
|
6884 |
+var transitionProps = { |
|
6885 |
+ name: String, |
|
6886 |
+ appear: Boolean, |
|
6887 |
+ css: Boolean, |
|
6888 |
+ mode: String, |
|
6889 |
+ type: String, |
|
6890 |
+ enterClass: String, |
|
6891 |
+ leaveClass: String, |
|
6892 |
+ enterToClass: String, |
|
6893 |
+ leaveToClass: String, |
|
6894 |
+ enterActiveClass: String, |
|
6895 |
+ leaveActiveClass: String, |
|
6896 |
+ appearClass: String, |
|
6897 |
+ appearActiveClass: String, |
|
6898 |
+ appearToClass: String, |
|
6899 |
+ duration: [Number, String, Object] |
|
6900 |
+}; |
|
6901 |
+ |
|
6902 |
+// in case the child is also an abstract component, e.g. <keep-alive> |
|
6903 |
+// we want to recursively retrieve the real component to be rendered |
|
6904 |
+function getRealChild (vnode) { |
|
6905 |
+ var compOptions = vnode && vnode.componentOptions; |
|
6906 |
+ if (compOptions && compOptions.Ctor.options.abstract) { |
|
6907 |
+ return getRealChild(getFirstComponentChild(compOptions.children)) |
|
6908 |
+ } else { |
|
6909 |
+ return vnode |
|
6910 |
+ } |
|
6911 |
+} |
|
6912 |
+ |
|
6913 |
+function extractTransitionData (comp) { |
|
6914 |
+ var data = {}; |
|
6915 |
+ var options = comp.$options; |
|
6916 |
+ // props |
|
6917 |
+ for (var key in options.propsData) { |
|
6918 |
+ data[key] = comp[key]; |
|
6919 |
+ } |
|
6920 |
+ // events. |
|
6921 |
+ // extract listeners and pass them directly to the transition methods |
|
6922 |
+ var listeners = options._parentListeners; |
|
6923 |
+ for (var key$1 in listeners) { |
|
6924 |
+ data[camelize(key$1)] = listeners[key$1]; |
|
6925 |
+ } |
|
6926 |
+ return data |
|
6927 |
+} |
|
6928 |
+ |
|
6929 |
+function placeholder (h, rawChild) { |
|
6930 |
+ return /\d-keep-alive$/.test(rawChild.tag) |
|
6931 |
+ ? h('keep-alive') |
|
6932 |
+ : null |
|
6933 |
+} |
|
6934 |
+ |
|
6935 |
+function hasParentTransition (vnode) { |
|
6936 |
+ while ((vnode = vnode.parent)) { |
|
6937 |
+ if (vnode.data.transition) { |
|
6938 |
+ return true |
|
6939 |
+ } |
|
6940 |
+ } |
|
6941 |
+} |
|
6942 |
+ |
|
6943 |
+function isSameChild (child, oldChild) { |
|
6944 |
+ return oldChild.key === child.key && oldChild.tag === child.tag |
|
6945 |
+} |
|
6946 |
+ |
|
6947 |
+var Transition = { |
|
6948 |
+ name: 'transition', |
|
6949 |
+ props: transitionProps, |
|
6950 |
+ abstract: true, |
|
6951 |
+ |
|
6952 |
+ render: function render (h) { |
|
6953 |
+ var this$1 = this; |
|
6954 |
+ |
|
6955 |
+ var children = this.$slots.default; |
|
6956 |
+ if (!children) { |
|
6957 |
+ return |
|
6958 |
+ } |
|
6959 |
+ |
|
6960 |
+ // filter out text nodes (possible whitespaces) |
|
6961 |
+ children = children.filter(function (c) { return c.tag; }); |
|
6962 |
+ /* istanbul ignore if */ |
|
6963 |
+ if (!children.length) { |
|
6964 |
+ return |
|
6965 |
+ } |
|
6966 |
+ |
|
6967 |
+ // warn multiple elements |
|
6968 |
+ if ("development" !== 'production' && children.length > 1) { |
|
6969 |
+ warn( |
|
6970 |
+ '<transition> can only be used on a single element. Use ' + |
|
6971 |
+ '<transition-group> for lists.', |
|
6972 |
+ this.$parent |
|
6973 |
+ ); |
|
6974 |
+ } |
|
6975 |
+ |
|
6976 |
+ var mode = this.mode; |
|
6977 |
+ |
|
6978 |
+ // warn invalid mode |
|
6979 |
+ if ("development" !== 'production' && |
|
6980 |
+ mode && mode !== 'in-out' && mode !== 'out-in') { |
|
6981 |
+ warn( |
|
6982 |
+ 'invalid <transition> mode: ' + mode, |
|
6983 |
+ this.$parent |
|
6984 |
+ ); |
|
6985 |
+ } |
|
6986 |
+ |
|
6987 |
+ var rawChild = children[0]; |
|
6988 |
+ |
|
6989 |
+ // if this is a component root node and the component's |
|
6990 |
+ // parent container node also has transition, skip. |
|
6991 |
+ if (hasParentTransition(this.$vnode)) { |
|
6992 |
+ return rawChild |
|
6993 |
+ } |
|
6994 |
+ |
|
6995 |
+ // apply transition data to child |
|
6996 |
+ // use getRealChild() to ignore abstract components e.g. keep-alive |
|
6997 |
+ var child = getRealChild(rawChild); |
|
6998 |
+ /* istanbul ignore if */ |
|
6999 |
+ if (!child) { |
|
7000 |
+ return rawChild |
|
7001 |
+ } |
|
7002 |
+ |
|
7003 |
+ if (this._leaving) { |
|
7004 |
+ return placeholder(h, rawChild) |
|
7005 |
+ } |
|
7006 |
+ |
|
7007 |
+ // ensure a key that is unique to the vnode type and to this transition |
|
7008 |
+ // component instance. This key will be used to remove pending leaving nodes |
|
7009 |
+ // during entering. |
|
7010 |
+ var id = "__transition-" + (this._uid) + "-"; |
|
7011 |
+ child.key = child.key == null |
|
7012 |
+ ? id + child.tag |
|
7013 |
+ : isPrimitive(child.key) |
|
7014 |
+ ? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key) |
|
7015 |
+ : child.key; |
|
7016 |
+ |
|
7017 |
+ var data = (child.data || (child.data = {})).transition = extractTransitionData(this); |
|
7018 |
+ var oldRawChild = this._vnode; |
|
7019 |
+ var oldChild = getRealChild(oldRawChild); |
|
7020 |
+ |
|
7021 |
+ // mark v-show |
|
7022 |
+ // so that the transition module can hand over the control to the directive |
|
7023 |
+ if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) { |
|
7024 |
+ child.data.show = true; |
|
7025 |
+ } |
|
7026 |
+ |
|
7027 |
+ if (oldChild && oldChild.data && !isSameChild(child, oldChild)) { |
|
7028 |
+ // replace old child transition data with fresh one |
|
7029 |
+ // important for dynamic transitions! |
|
7030 |
+ var oldData = oldChild && (oldChild.data.transition = extend({}, data)); |
|
7031 |
+ // handle transition mode |
|
7032 |
+ if (mode === 'out-in') { |
|
7033 |
+ // return placeholder node and queue update when leave finishes |
|
7034 |
+ this._leaving = true; |
|
7035 |
+ mergeVNodeHook(oldData, 'afterLeave', function () { |
|
7036 |
+ this$1._leaving = false; |
|
7037 |
+ this$1.$forceUpdate(); |
|
7038 |
+ }); |
|
7039 |
+ return placeholder(h, rawChild) |
|
7040 |
+ } else if (mode === 'in-out') { |
|
7041 |
+ var delayedLeave; |
|
7042 |
+ var performLeave = function () { delayedLeave(); }; |
|
7043 |
+ mergeVNodeHook(data, 'afterEnter', performLeave); |
|
7044 |
+ mergeVNodeHook(data, 'enterCancelled', performLeave); |
|
7045 |
+ mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; }); |
|
7046 |
+ } |
|
7047 |
+ } |
|
7048 |
+ |
|
7049 |
+ return rawChild |
|
7050 |
+ } |
|
7051 |
+}; |
|
7052 |
+ |
|
7053 |
+/* */ |
|
7054 |
+ |
|
7055 |
+// Provides transition support for list items. |
|
7056 |
+// supports move transitions using the FLIP technique. |
|
7057 |
+ |
|
7058 |
+// Because the vdom's children update algorithm is "unstable" - i.e. |
|
7059 |
+// it doesn't guarantee the relative positioning of removed elements, |
|
7060 |
+// we force transition-group to update its children into two passes: |
|
7061 |
+// in the first pass, we remove all nodes that need to be removed, |
|
7062 |
+// triggering their leaving transition; in the second pass, we insert/move |
|
7063 |
+// into the final desired state. This way in the second pass removed |
|
7064 |
+// nodes will remain where they should be. |
|
7065 |
+ |
|
7066 |
+var props = extend({ |
|
7067 |
+ tag: String, |
|
7068 |
+ moveClass: String |
|
7069 |
+}, transitionProps); |
|
7070 |
+ |
|
7071 |
+delete props.mode; |
|
7072 |
+ |
|
7073 |
+var TransitionGroup = { |
|
7074 |
+ props: props, |
|
7075 |
+ |
|
7076 |
+ render: function render (h) { |
|
7077 |
+ var tag = this.tag || this.$vnode.data.tag || 'span'; |
|
7078 |
+ var map = Object.create(null); |
|
7079 |
+ var prevChildren = this.prevChildren = this.children; |
|
7080 |
+ var rawChildren = this.$slots.default || []; |
|
7081 |
+ var children = this.children = []; |
|
7082 |
+ var transitionData = extractTransitionData(this); |
|
7083 |
+ |
|
7084 |
+ for (var i = 0; i < rawChildren.length; i++) { |
|
7085 |
+ var c = rawChildren[i]; |
|
7086 |
+ if (c.tag) { |
|
7087 |
+ if (c.key != null && String(c.key).indexOf('__vlist') !== 0) { |
|
7088 |
+ children.push(c); |
|
7089 |
+ map[c.key] = c |
|
7090 |
+ ;(c.data || (c.data = {})).transition = transitionData; |
|
7091 |
+ } else { |
|
7092 |
+ var opts = c.componentOptions; |
|
7093 |
+ var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag; |
|
7094 |
+ warn(("<transition-group> children must be keyed: <" + name + ">")); |
|
7095 |
+ } |
|
7096 |
+ } |
|
7097 |
+ } |
|
7098 |
+ |
|
7099 |
+ if (prevChildren) { |
|
7100 |
+ var kept = []; |
|
7101 |
+ var removed = []; |
|
7102 |
+ for (var i$1 = 0; i$1 < prevChildren.length; i$1++) { |
|
7103 |
+ var c$1 = prevChildren[i$1]; |
|
7104 |
+ c$1.data.transition = transitionData; |
|
7105 |
+ c$1.data.pos = c$1.elm.getBoundingClientRect(); |
|
7106 |
+ if (map[c$1.key]) { |
|
7107 |
+ kept.push(c$1); |
|
7108 |
+ } else { |
|
7109 |
+ removed.push(c$1); |
|
7110 |
+ } |
|
7111 |
+ } |
|
7112 |
+ this.kept = h(tag, null, kept); |
|
7113 |
+ this.removed = removed; |
|
7114 |
+ } |
|
7115 |
+ |
|
7116 |
+ return h(tag, null, children) |
|
7117 |
+ }, |
|
7118 |
+ |
|
7119 |
+ beforeUpdate: function beforeUpdate () { |
|
7120 |
+ // force removing pass |
|
7121 |
+ this.__patch__( |
|
7122 |
+ this._vnode, |
|
7123 |
+ this.kept, |
|
7124 |
+ false, // hydrating |
|
7125 |
+ true // removeOnly (!important, avoids unnecessary moves) |
|
7126 |
+ ); |
|
7127 |
+ this._vnode = this.kept; |
|
7128 |
+ }, |
|
7129 |
+ |
|
7130 |
+ updated: function updated () { |
|
7131 |
+ var children = this.prevChildren; |
|
7132 |
+ var moveClass = this.moveClass || ((this.name || 'v') + '-move'); |
|
7133 |
+ if (!children.length || !this.hasMove(children[0].elm, moveClass)) { |
|
7134 |
+ return |
|
7135 |
+ } |
|
7136 |
+ |
|
7137 |
+ // we divide the work into three loops to avoid mixing DOM reads and writes |
|
7138 |
+ // in each iteration - which helps prevent layout thrashing. |
|
7139 |
+ children.forEach(callPendingCbs); |
|
7140 |
+ children.forEach(recordPosition); |
|
7141 |
+ children.forEach(applyTranslation); |
|
7142 |
+ |
|
7143 |
+ // force reflow to put everything in position |
|
7144 |
+ var body = document.body; |
|
7145 |
+ var f = body.offsetHeight; // eslint-disable-line |
|
7146 |
+ |
|
7147 |
+ children.forEach(function (c) { |
|
7148 |
+ if (c.data.moved) { |
|
7149 |
+ var el = c.elm; |
|
7150 |
+ var s = el.style; |
|
7151 |
+ addTransitionClass(el, moveClass); |
|
7152 |
+ s.transform = s.WebkitTransform = s.transitionDuration = ''; |
|
7153 |
+ el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) { |
|
7154 |
+ if (!e || /transform$/.test(e.propertyName)) { |
|
7155 |
+ el.removeEventListener(transitionEndEvent, cb); |
|
7156 |
+ el._moveCb = null; |
|
7157 |
+ removeTransitionClass(el, moveClass); |
|
7158 |
+ } |
|
7159 |
+ }); |
|
7160 |
+ } |
|
7161 |
+ }); |
|
7162 |
+ }, |
|
7163 |
+ |
|
7164 |
+ methods: { |
|
7165 |
+ hasMove: function hasMove (el, moveClass) { |
|
7166 |
+ /* istanbul ignore if */ |
|
7167 |
+ if (!hasTransition) { |
|
7168 |
+ return false |
|
7169 |
+ } |
|
7170 |
+ if (this._hasMove != null) { |
|
7171 |
+ return this._hasMove |
|
7172 |
+ } |
|
7173 |
+ // Detect whether an element with the move class applied has |
|
7174 |
+ // CSS transitions. Since the element may be inside an entering |
|
7175 |
+ // transition at this very moment, we make a clone of it and remove |
|
7176 |
+ // all other transition classes applied to ensure only the move class |
|
7177 |
+ // is applied. |
|
7178 |
+ var clone = el.cloneNode(); |
|
7179 |
+ if (el._transitionClasses) { |
|
7180 |
+ el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); }); |
|
7181 |
+ } |
|
7182 |
+ addClass(clone, moveClass); |
|
7183 |
+ clone.style.display = 'none'; |
|
7184 |
+ this.$el.appendChild(clone); |
|
7185 |
+ var info = getTransitionInfo(clone); |
|
7186 |
+ this.$el.removeChild(clone); |
|
7187 |
+ return (this._hasMove = info.hasTransform) |
|
7188 |
+ } |
|
7189 |
+ } |
|
7190 |
+}; |
|
7191 |
+ |
|
7192 |
+function callPendingCbs (c) { |
|
7193 |
+ /* istanbul ignore if */ |
|
7194 |
+ if (c.elm._moveCb) { |
|
7195 |
+ c.elm._moveCb(); |
|
7196 |
+ } |
|
7197 |
+ /* istanbul ignore if */ |
|
7198 |
+ if (c.elm._enterCb) { |
|
7199 |
+ c.elm._enterCb(); |
|
7200 |
+ } |
|
7201 |
+} |
|
7202 |
+ |
|
7203 |
+function recordPosition (c) { |
|
7204 |
+ c.data.newPos = c.elm.getBoundingClientRect(); |
|
7205 |
+} |
|
7206 |
+ |
|
7207 |
+function applyTranslation (c) { |
|
7208 |
+ var oldPos = c.data.pos; |
|
7209 |
+ var newPos = c.data.newPos; |
|
7210 |
+ var dx = oldPos.left - newPos.left; |
|
7211 |
+ var dy = oldPos.top - newPos.top; |
|
7212 |
+ if (dx || dy) { |
|
7213 |
+ c.data.moved = true; |
|
7214 |
+ var s = c.elm.style; |
|
7215 |
+ s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)"; |
|
7216 |
+ s.transitionDuration = '0s'; |
|
7217 |
+ } |
|
7218 |
+} |
|
7219 |
+ |
|
7220 |
+var platformComponents = { |
|
7221 |
+ Transition: Transition, |
|
7222 |
+ TransitionGroup: TransitionGroup |
|
7223 |
+}; |
|
7224 |
+ |
|
7225 |
+/* */ |
|
7226 |
+ |
|
7227 |
+// install platform specific utils |
|
7228 |
+Vue$3.config.mustUseProp = mustUseProp; |
|
7229 |
+Vue$3.config.isReservedTag = isReservedTag; |
|
7230 |
+Vue$3.config.getTagNamespace = getTagNamespace; |
|
7231 |
+Vue$3.config.isUnknownElement = isUnknownElement; |
|
7232 |
+ |
|
7233 |
+// install platform runtime directives & components |
|
7234 |
+extend(Vue$3.options.directives, platformDirectives); |
|
7235 |
+extend(Vue$3.options.components, platformComponents); |
|
7236 |
+ |
|
7237 |
+// install platform patch function |
|
7238 |
+Vue$3.prototype.__patch__ = inBrowser ? patch : noop; |
|
7239 |
+ |
|
7240 |
+// public mount method |
|
7241 |
+Vue$3.prototype.$mount = function ( |
|
7242 |
+ el, |
|
7243 |
+ hydrating |
|
7244 |
+) { |
|
7245 |
+ el = el && inBrowser ? query(el) : undefined; |
|
7246 |
+ return mountComponent(this, el, hydrating) |
|
7247 |
+}; |
|
7248 |
+ |
|
7249 |
+// devtools global hook |
|
7250 |
+/* istanbul ignore next */ |
|
7251 |
+setTimeout(function () { |
|
7252 |
+ if (config.devtools) { |
|
7253 |
+ if (devtools) { |
|
7254 |
+ devtools.emit('init', Vue$3); |
|
7255 |
+ } else if ("development" !== 'production' && isChrome) { |
|
7256 |
+ console[console.info ? 'info' : 'log']( |
|
7257 |
+ 'Download the Vue Devtools extension for a better development experience:\n' + |
|
7258 |
+ 'https://github.com/vuejs/vue-devtools' |
|
7259 |
+ ); |
|
7260 |
+ } |
|
7261 |
+ } |
|
7262 |
+ if ("development" !== 'production' && |
|
7263 |
+ config.productionTip !== false && |
|
7264 |
+ inBrowser && typeof console !== 'undefined') { |
|
7265 |
+ console[console.info ? 'info' : 'log']( |
|
7266 |
+ "You are running Vue in development mode.\n" + |
|
7267 |
+ "Make sure to turn on production mode when deploying for production.\n" + |
|
7268 |
+ "See more tips at https://vuejs.org/guide/deployment.html" |
|
7269 |
+ ); |
|
7270 |
+ } |
|
7271 |
+}, 0); |
|
7272 |
+ |
|
7273 |
+/* */ |
|
7274 |
+ |
|
7275 |
+// check whether current browser encodes a char inside attribute values |
|
7276 |
+function shouldDecode (content, encoded) { |
|
7277 |
+ var div = document.createElement('div'); |
|
7278 |
+ div.innerHTML = "<div a=\"" + content + "\">"; |
|
7279 |
+ return div.innerHTML.indexOf(encoded) > 0 |
|
7280 |
+} |
|
7281 |
+ |
|
7282 |
+// #3663 |
|
7283 |
+// IE encodes newlines inside attribute values while other browsers don't |
|
7284 |
+var shouldDecodeNewlines = inBrowser ? shouldDecode('\n', ' ') : false; |
|
7285 |
+ |
|
7286 |
+/* */ |
|
7287 |
+ |
|
7288 |
+var isUnaryTag = makeMap( |
|
7289 |
+ 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + |
|
7290 |
+ 'link,meta,param,source,track,wbr' |
|
7291 |
+); |
|
7292 |
+ |
|
7293 |
+// Elements that you can, intentionally, leave open |
|
7294 |
+// (and which close themselves) |
|
7295 |
+var canBeLeftOpenTag = makeMap( |
|
7296 |
+ 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' |
|
7297 |
+); |
|
7298 |
+ |
|
7299 |
+// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 |
|
7300 |
+// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content |
|
7301 |
+var isNonPhrasingTag = makeMap( |
|
7302 |
+ 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + |
|
7303 |
+ 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + |
|
7304 |
+ 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + |
|
7305 |
+ 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + |
|
7306 |
+ 'title,tr,track' |
|
7307 |
+); |
|
7308 |
+ |
|
7309 |
+/* */ |
|
7310 |
+ |
|
7311 |
+var decoder; |
|
7312 |
+ |
|
7313 |
+function decode (html) { |
|
7314 |
+ decoder = decoder || document.createElement('div'); |
|
7315 |
+ decoder.innerHTML = html; |
|
7316 |
+ return decoder.textContent |
|
7317 |
+} |
|
7318 |
+ |
|
7319 |
+/** |
|
7320 |
+ * Not type-checking this file because it's mostly vendor code. |
|
7321 |
+ */ |
|
7322 |
+ |
|
7323 |
+/*! |
|
7324 |
+ * HTML Parser By John Resig (ejohn.org) |
|
7325 |
+ * Modified by Juriy "kangax" Zaytsev |
|
7326 |
+ * Original code by Erik Arvidsson, Mozilla Public License |
|
7327 |
+ * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js |
|
7328 |
+ */ |
|
7329 |
+ |
|
7330 |
+// Regular Expressions for parsing tags and attributes |
|
7331 |
+var singleAttrIdentifier = /([^\s"'<>/=]+)/; |
|
7332 |
+var singleAttrAssign = /(?:=)/; |
|
7333 |
+var singleAttrValues = [ |
|
7334 |
+ // attr value double quotes |
|
7335 |
+ /"([^"]*)"+/.source, |
|
7336 |
+ // attr value, single quotes |
|
7337 |
+ /'([^']*)'+/.source, |
|
7338 |
+ // attr value, no quotes |
|
7339 |
+ /([^\s"'=<>`]+)/.source |
|
7340 |
+]; |
|
7341 |
+var attribute = new RegExp( |
|
7342 |
+ '^\\s*' + singleAttrIdentifier.source + |
|
7343 |
+ '(?:\\s*(' + singleAttrAssign.source + ')' + |
|
7344 |
+ '\\s*(?:' + singleAttrValues.join('|') + '))?' |
|
7345 |
+); |
|
7346 |
+ |
|
7347 |
+// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName |
|
7348 |
+// but for Vue templates we can enforce a simple charset |
|
7349 |
+var ncname = '[a-zA-Z_][\\w\\-\\.]*'; |
|
7350 |
+var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')'; |
|
7351 |
+var startTagOpen = new RegExp('^<' + qnameCapture); |
|
7352 |
+var startTagClose = /^\s*(\/?)>/; |
|
7353 |
+var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>'); |
|
7354 |
+var doctype = /^<!DOCTYPE [^>]+>/i; |
|
7355 |
+var comment = /^<!--/; |
|
7356 |
+var conditionalComment = /^<!\[/; |
|
7357 |
+ |
|
7358 |
+var IS_REGEX_CAPTURING_BROKEN = false; |
|
7359 |
+'x'.replace(/x(.)?/g, function (m, g) { |
|
7360 |
+ IS_REGEX_CAPTURING_BROKEN = g === ''; |
|
7361 |
+}); |
|
7362 |
+ |
|
7363 |
+// Special Elements (can contain anything) |
|
7364 |
+var isPlainTextElement = makeMap('script,style,textarea', true); |
|
7365 |
+var reCache = {}; |
|
7366 |
+ |
|
7367 |
+var decodingMap = { |
|
7368 |
+ '<': '<', |
|
7369 |
+ '>': '>', |
|
7370 |
+ '"': '"', |
|
7371 |
+ '&': '&', |
|
7372 |
+ ' ': '\n' |
|
7373 |
+}; |
|
7374 |
+var encodedAttr = /&(?:lt|gt|quot|amp);/g; |
|
7375 |
+var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g; |
|
7376 |
+ |
|
7377 |
+function decodeAttr (value, shouldDecodeNewlines) { |
|
7378 |
+ var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr; |
|
7379 |
+ return value.replace(re, function (match) { return decodingMap[match]; }) |
|
7380 |
+} |
|
7381 |
+ |
|
7382 |
+function parseHTML (html, options) { |
|
7383 |
+ var stack = []; |
|
7384 |
+ var expectHTML = options.expectHTML; |
|
7385 |
+ var isUnaryTag$$1 = options.isUnaryTag || no; |
|
7386 |
+ var canBeLeftOpenTag$$1 = options.canBeLeftOpenTag || no; |
|
7387 |
+ var index = 0; |
|
7388 |
+ var last, lastTag; |
|
7389 |
+ while (html) { |
|
7390 |
+ last = html; |
|
7391 |
+ // Make sure we're not in a plaintext content element like script/style |
|
7392 |
+ if (!lastTag || !isPlainTextElement(lastTag)) { |
|
7393 |
+ var textEnd = html.indexOf('<'); |
|
7394 |
+ if (textEnd === 0) { |
|
7395 |
+ // Comment: |
|
7396 |
+ if (comment.test(html)) { |
|
7397 |
+ var commentEnd = html.indexOf('-->'); |
|
7398 |
+ |
|
7399 |
+ if (commentEnd >= 0) { |
|
7400 |
+ advance(commentEnd + 3); |
|
7401 |
+ continue |
|
7402 |
+ } |
|
7403 |
+ } |
|
7404 |
+ |
|
7405 |
+ // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment |
|
7406 |
+ if (conditionalComment.test(html)) { |
|
7407 |
+ var conditionalEnd = html.indexOf(']>'); |
|
7408 |
+ |
|
7409 |
+ if (conditionalEnd >= 0) { |
|
7410 |
+ advance(conditionalEnd + 2); |
|
7411 |
+ continue |
|
7412 |
+ } |
|
7413 |
+ } |
|
7414 |
+ |
|
7415 |
+ // Doctype: |
|
7416 |
+ var doctypeMatch = html.match(doctype); |
|
7417 |
+ if (doctypeMatch) { |
|
7418 |
+ advance(doctypeMatch[0].length); |
|
7419 |
+ continue |
|
7420 |
+ } |
|
7421 |
+ |
|
7422 |
+ // End tag: |
|
7423 |
+ var endTagMatch = html.match(endTag); |
|
7424 |
+ if (endTagMatch) { |
|
7425 |
+ var curIndex = index; |
|
7426 |
+ advance(endTagMatch[0].length); |
|
7427 |
+ parseEndTag(endTagMatch[1], curIndex, index); |
|
7428 |
+ continue |
|
7429 |
+ } |
|
7430 |
+ |
|
7431 |
+ // Start tag: |
|
7432 |
+ var startTagMatch = parseStartTag(); |
|
7433 |
+ if (startTagMatch) { |
|
7434 |
+ handleStartTag(startTagMatch); |
|
7435 |
+ continue |
|
7436 |
+ } |
|
7437 |
+ } |
|
7438 |
+ |
|
7439 |
+ var text = (void 0), rest$1 = (void 0), next = (void 0); |
|
7440 |
+ if (textEnd >= 0) { |
|
7441 |
+ rest$1 = html.slice(textEnd); |
|
7442 |
+ while ( |
|
7443 |
+ !endTag.test(rest$1) && |
|
7444 |
+ !startTagOpen.test(rest$1) && |
|
7445 |
+ !comment.test(rest$1) && |
|
7446 |
+ !conditionalComment.test(rest$1) |
|
7447 |
+ ) { |
|
7448 |
+ // < in plain text, be forgiving and treat it as text |
|
7449 |
+ next = rest$1.indexOf('<', 1); |
|
7450 |
+ if (next < 0) { break } |
|
7451 |
+ textEnd += next; |
|
7452 |
+ rest$1 = html.slice(textEnd); |
|
7453 |
+ } |
|
7454 |
+ text = html.substring(0, textEnd); |
|
7455 |
+ advance(textEnd); |
|
7456 |
+ } |
|
7457 |
+ |
|
7458 |
+ if (textEnd < 0) { |
|
7459 |
+ text = html; |
|
7460 |
+ html = ''; |
|
7461 |
+ } |
|
7462 |
+ |
|
7463 |
+ if (options.chars && text) { |
|
7464 |
+ options.chars(text); |
|
7465 |
+ } |
|
7466 |
+ } else { |
|
7467 |
+ var stackedTag = lastTag.toLowerCase(); |
|
7468 |
+ var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i')); |
|
7469 |
+ var endTagLength = 0; |
|
7470 |
+ var rest = html.replace(reStackedTag, function (all, text, endTag) { |
|
7471 |
+ endTagLength = endTag.length; |
|
7472 |
+ if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') { |
|
7473 |
+ text = text |
|
7474 |
+ .replace(/<!--([\s\S]*?)-->/g, '$1') |
|
7475 |
+ .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); |
|
7476 |
+ } |
|
7477 |
+ if (options.chars) { |
|
7478 |
+ options.chars(text); |
|
7479 |
+ } |
|
7480 |
+ return '' |
|
7481 |
+ }); |
|
7482 |
+ index += html.length - rest.length; |
|
7483 |
+ html = rest; |
|
7484 |
+ parseEndTag(stackedTag, index - endTagLength, index); |
|
7485 |
+ } |
|
7486 |
+ |
|
7487 |
+ if (html === last) { |
|
7488 |
+ options.chars && options.chars(html); |
|
7489 |
+ if ("development" !== 'production' && !stack.length && options.warn) { |
|
7490 |
+ options.warn(("Mal-formatted tag at end of template: \"" + html + "\"")); |
|
7491 |
+ } |
|
7492 |
+ break |
|
7493 |
+ } |
|
7494 |
+ } |
|
7495 |
+ |
|
7496 |
+ // Clean up any remaining tags |
|
7497 |
+ parseEndTag(); |
|
7498 |
+ |
|
7499 |
+ function advance (n) { |
|
7500 |
+ index += n; |
|
7501 |
+ html = html.substring(n); |
|
7502 |
+ } |
|
7503 |
+ |
|
7504 |
+ function parseStartTag () { |
|
7505 |
+ var start = html.match(startTagOpen); |
|
7506 |
+ if (start) { |
|
7507 |
+ var match = { |
|
7508 |
+ tagName: start[1], |
|
7509 |
+ attrs: [], |
|
7510 |
+ start: index |
|
7511 |
+ }; |
|
7512 |
+ advance(start[0].length); |
|
7513 |
+ var end, attr; |
|
7514 |
+ while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) { |
|
7515 |
+ advance(attr[0].length); |
|
7516 |
+ match.attrs.push(attr); |
|
7517 |
+ } |
|
7518 |
+ if (end) { |
|
7519 |
+ match.unarySlash = end[1]; |
|
7520 |
+ advance(end[0].length); |
|
7521 |
+ match.end = index; |
|
7522 |
+ return match |
|
7523 |
+ } |
|
7524 |
+ } |
|
7525 |
+ } |
|
7526 |
+ |
|
7527 |
+ function handleStartTag (match) { |
|
7528 |
+ var tagName = match.tagName; |
|
7529 |
+ var unarySlash = match.unarySlash; |
|
7530 |
+ |
|
7531 |
+ if (expectHTML) { |
|
7532 |
+ if (lastTag === 'p' && isNonPhrasingTag(tagName)) { |
|
7533 |
+ parseEndTag(lastTag); |
|
7534 |
+ } |
|
7535 |
+ if (canBeLeftOpenTag$$1(tagName) && lastTag === tagName) { |
|
7536 |
+ parseEndTag(tagName); |
|
7537 |
+ } |
|
7538 |
+ } |
|
7539 |
+ |
|
7540 |
+ var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash; |
|
7541 |
+ |
|
7542 |
+ var l = match.attrs.length; |
|
7543 |
+ var attrs = new Array(l); |
|
7544 |
+ for (var i = 0; i < l; i++) { |
|
7545 |
+ var args = match.attrs[i]; |
|
7546 |
+ // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778 |
|
7547 |
+ if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) { |
|
7548 |
+ if (args[3] === '') { delete args[3]; } |
|
7549 |
+ if (args[4] === '') { delete args[4]; } |
|
7550 |
+ if (args[5] === '') { delete args[5]; } |
|
7551 |
+ } |
|
7552 |
+ var value = args[3] || args[4] || args[5] || ''; |
|
7553 |
+ attrs[i] = { |
|
7554 |
+ name: args[1], |
|
7555 |
+ value: decodeAttr( |
|
7556 |
+ value, |
|
7557 |
+ options.shouldDecodeNewlines |
|
7558 |
+ ) |
|
7559 |
+ }; |
|
7560 |
+ } |
|
7561 |
+ |
|
7562 |
+ if (!unary) { |
|
7563 |
+ stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs }); |
|
7564 |
+ lastTag = tagName; |
|
7565 |
+ } |
|
7566 |
+ |
|
7567 |
+ if (options.start) { |
|
7568 |
+ options.start(tagName, attrs, unary, match.start, match.end); |
|
7569 |
+ } |
|
7570 |
+ } |
|
7571 |
+ |
|
7572 |
+ function parseEndTag (tagName, start, end) { |
|
7573 |
+ var pos, lowerCasedTagName; |
|
7574 |
+ if (start == null) { start = index; } |
|
7575 |
+ if (end == null) { end = index; } |
|
7576 |
+ |
|
7577 |
+ if (tagName) { |
|
7578 |
+ lowerCasedTagName = tagName.toLowerCase(); |
|
7579 |
+ } |
|
7580 |
+ |
|
7581 |
+ // Find the closest opened tag of the same type |
|
7582 |
+ if (tagName) { |
|
7583 |
+ for (pos = stack.length - 1; pos >= 0; pos--) { |
|
7584 |
+ if (stack[pos].lowerCasedTag === lowerCasedTagName) { |
|
7585 |
+ break |
|
7586 |
+ } |
|
7587 |
+ } |
|
7588 |
+ } else { |
|
7589 |
+ // If no tag name is provided, clean shop |
|
7590 |
+ pos = 0; |
|
7591 |
+ } |
|
7592 |
+ |
|
7593 |
+ if (pos >= 0) { |
|
7594 |
+ // Close all the open elements, up the stack |
|
7595 |
+ for (var i = stack.length - 1; i >= pos; i--) { |
|
7596 |
+ if ("development" !== 'production' && |
|
7597 |
+ (i > pos || !tagName) && |
|
7598 |
+ options.warn) { |
|
7599 |
+ options.warn( |
|
7600 |
+ ("tag <" + (stack[i].tag) + "> has no matching end tag.") |
|
7601 |
+ ); |
|
7602 |
+ } |
|
7603 |
+ if (options.end) { |
|
7604 |
+ options.end(stack[i].tag, start, end); |
|
7605 |
+ } |
|
7606 |
+ } |
|
7607 |
+ |
|
7608 |
+ // Remove the open elements from the stack |
|
7609 |
+ stack.length = pos; |
|
7610 |
+ lastTag = pos && stack[pos - 1].tag; |
|
7611 |
+ } else if (lowerCasedTagName === 'br') { |
|
7612 |
+ if (options.start) { |
|
7613 |
+ options.start(tagName, [], true, start, end); |
|
7614 |
+ } |
|
7615 |
+ } else if (lowerCasedTagName === 'p') { |
|
7616 |
+ if (options.start) { |
|
7617 |
+ options.start(tagName, [], false, start, end); |
|
7618 |
+ } |
|
7619 |
+ if (options.end) { |
|
7620 |
+ options.end(tagName, start, end); |
|
7621 |
+ } |
|
7622 |
+ } |
|
7623 |
+ } |
|
7624 |
+} |
|
7625 |
+ |
|
7626 |
+/* */ |
|
7627 |
+ |
|
7628 |
+var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g; |
|
7629 |
+var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; |
|
7630 |
+ |
|
7631 |
+var buildRegex = cached(function (delimiters) { |
|
7632 |
+ var open = delimiters[0].replace(regexEscapeRE, '\\$&'); |
|
7633 |
+ var close = delimiters[1].replace(regexEscapeRE, '\\$&'); |
|
7634 |
+ return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') |
|
7635 |
+}); |
|
7636 |
+ |
|
7637 |
+function parseText ( |
|
7638 |
+ text, |
|
7639 |
+ delimiters |
|
7640 |
+) { |
|
7641 |
+ var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; |
|
7642 |
+ if (!tagRE.test(text)) { |
|
7643 |
+ return |
|
7644 |
+ } |
|
7645 |
+ var tokens = []; |
|
7646 |
+ var lastIndex = tagRE.lastIndex = 0; |
|
7647 |
+ var match, index; |
|
7648 |
+ while ((match = tagRE.exec(text))) { |
|
7649 |
+ index = match.index; |
|
7650 |
+ // push text token |
|
7651 |
+ if (index > lastIndex) { |
|
7652 |
+ tokens.push(JSON.stringify(text.slice(lastIndex, index))); |
|
7653 |
+ } |
|
7654 |
+ // tag token |
|
7655 |
+ var exp = parseFilters(match[1].trim()); |
|
7656 |
+ tokens.push(("_s(" + exp + ")")); |
|
7657 |
+ lastIndex = index + match[0].length; |
|
7658 |
+ } |
|
7659 |
+ if (lastIndex < text.length) { |
|
7660 |
+ tokens.push(JSON.stringify(text.slice(lastIndex))); |
|
7661 |
+ } |
|
7662 |
+ return tokens.join('+') |
|
7663 |
+} |
|
7664 |
+ |
|
7665 |
+/* */ |
|
7666 |
+ |
|
7667 |
+var onRE = /^@|^v-on:/; |
|
7668 |
+var dirRE = /^v-|^@|^:/; |
|
7669 |
+var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/; |
|
7670 |
+var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/; |
|
7671 |
+ |
|
7672 |
+var argRE = /:(.*)$/; |
|
7673 |
+var bindRE = /^:|^v-bind:/; |
|
7674 |
+var modifierRE = /\.[^.]+/g; |
|
7675 |
+ |
|
7676 |
+var decodeHTMLCached = cached(decode); |
|
7677 |
+ |
|
7678 |
+// configurable state |
|
7679 |
+var warn$2; |
|
7680 |
+var delimiters; |
|
7681 |
+var transforms; |
|
7682 |
+var preTransforms; |
|
7683 |
+var postTransforms; |
|
7684 |
+var platformIsPreTag; |
|
7685 |
+var platformMustUseProp; |
|
7686 |
+var platformGetTagNamespace; |
|
7687 |
+ |
|
7688 |
+/** |
|
7689 |
+ * Convert HTML string to AST. |
|
7690 |
+ */ |
|
7691 |
+function parse ( |
|
7692 |
+ template, |
|
7693 |
+ options |
|
7694 |
+) { |
|
7695 |
+ warn$2 = options.warn || baseWarn; |
|
7696 |
+ platformGetTagNamespace = options.getTagNamespace || no; |
|
7697 |
+ platformMustUseProp = options.mustUseProp || no; |
|
7698 |
+ platformIsPreTag = options.isPreTag || no; |
|
7699 |
+ preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); |
|
7700 |
+ transforms = pluckModuleFunction(options.modules, 'transformNode'); |
|
7701 |
+ postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); |
|
7702 |
+ delimiters = options.delimiters; |
|
7703 |
+ |
|
7704 |
+ var stack = []; |
|
7705 |
+ var preserveWhitespace = options.preserveWhitespace !== false; |
|
7706 |
+ var root; |
|
7707 |
+ var currentParent; |
|
7708 |
+ var inVPre = false; |
|
7709 |
+ var inPre = false; |
|
7710 |
+ var warned = false; |
|
7711 |
+ |
|
7712 |
+ function warnOnce (msg) { |
|
7713 |
+ if (!warned) { |
|
7714 |
+ warned = true; |
|
7715 |
+ warn$2(msg); |
|
7716 |
+ } |
|
7717 |
+ } |
|
7718 |
+ |
|
7719 |
+ function endPre (element) { |
|
7720 |
+ // check pre state |
|
7721 |
+ if (element.pre) { |
|
7722 |
+ inVPre = false; |
|
7723 |
+ } |
|
7724 |
+ if (platformIsPreTag(element.tag)) { |
|
7725 |
+ inPre = false; |
|
7726 |
+ } |
|
7727 |
+ } |
|
7728 |
+ |
|
7729 |
+ parseHTML(template, { |
|
7730 |
+ warn: warn$2, |
|
7731 |
+ expectHTML: options.expectHTML, |
|
7732 |
+ isUnaryTag: options.isUnaryTag, |
|
7733 |
+ canBeLeftOpenTag: options.canBeLeftOpenTag, |
|
7734 |
+ shouldDecodeNewlines: options.shouldDecodeNewlines, |
|
7735 |
+ start: function start (tag, attrs, unary) { |
|
7736 |
+ // check namespace. |
|
7737 |
+ // inherit parent ns if there is one |
|
7738 |
+ var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag); |
|
7739 |
+ |
|
7740 |
+ // handle IE svg bug |
|
7741 |
+ /* istanbul ignore if */ |
|
7742 |
+ if (isIE && ns === 'svg') { |
|
7743 |
+ attrs = guardIESVGBug(attrs); |
|
7744 |
+ } |
|
7745 |
+ |
|
7746 |
+ var element = { |
|
7747 |
+ type: 1, |
|
7748 |
+ tag: tag, |
|
7749 |
+ attrsList: attrs, |
|
7750 |
+ attrsMap: makeAttrsMap(attrs), |
|
7751 |
+ parent: currentParent, |
|
7752 |
+ children: [] |
|
7753 |
+ }; |
|
7754 |
+ if (ns) { |
|
7755 |
+ element.ns = ns; |
|
7756 |
+ } |
|
7757 |
+ |
|
7758 |
+ if (isForbiddenTag(element) && !isServerRendering()) { |
|
7759 |
+ element.forbidden = true; |
|
7760 |
+ "development" !== 'production' && warn$2( |
|
7761 |
+ 'Templates should only be responsible for mapping the state to the ' + |
|
7762 |
+ 'UI. Avoid placing tags with side-effects in your templates, such as ' + |
|
7763 |
+ "<" + tag + ">" + ', as they will not be parsed.' |
|
7764 |
+ ); |
|
7765 |
+ } |
|
7766 |
+ |
|
7767 |
+ // apply pre-transforms |
|
7768 |
+ for (var i = 0; i < preTransforms.length; i++) { |
|
7769 |
+ preTransforms[i](element, options); |
|
7770 |
+ } |
|
7771 |
+ |
|
7772 |
+ if (!inVPre) { |
|
7773 |
+ processPre(element); |
|
7774 |
+ if (element.pre) { |
|
7775 |
+ inVPre = true; |
|
7776 |
+ } |
|
7777 |
+ } |
|
7778 |
+ if (platformIsPreTag(element.tag)) { |
|
7779 |
+ inPre = true; |
|
7780 |
+ } |
|
7781 |
+ if (inVPre) { |
|
7782 |
+ processRawAttrs(element); |
|
7783 |
+ } else { |
|
7784 |
+ processFor(element); |
|
7785 |
+ processIf(element); |
|
7786 |
+ processOnce(element); |
|
7787 |
+ processKey(element); |
|
7788 |
+ |
|
7789 |
+ // determine whether this is a plain element after |
|
7790 |
+ // removing structural attributes |
|
7791 |
+ element.plain = !element.key && !attrs.length; |
|
7792 |
+ |
|
7793 |
+ processRef(element); |
|
7794 |
+ processSlot(element); |
|
7795 |
+ processComponent(element); |
|
7796 |
+ for (var i$1 = 0; i$1 < transforms.length; i$1++) { |
|
7797 |
+ transforms[i$1](element, options); |
|
7798 |
+ } |
|
7799 |
+ processAttrs(element); |
|
7800 |
+ } |
|
7801 |
+ |
|
7802 |
+ function checkRootConstraints (el) { |
|
7803 |
+ { |
|
7804 |
+ if (el.tag === 'slot' || el.tag === 'template') { |
|
7805 |
+ warnOnce( |
|
7806 |
+ "Cannot use <" + (el.tag) + "> as component root element because it may " + |
|
7807 |
+ 'contain multiple nodes.' |
|
7808 |
+ ); |
|
7809 |
+ } |
|
7810 |
+ if (el.attrsMap.hasOwnProperty('v-for')) { |
|
7811 |
+ warnOnce( |
|
7812 |
+ 'Cannot use v-for on stateful component root element because ' + |
|
7813 |
+ 'it renders multiple elements.' |
|
7814 |
+ ); |
|
7815 |
+ } |
|
7816 |
+ } |
|
7817 |
+ } |
|
7818 |
+ |
|
7819 |
+ // tree management |
|
7820 |
+ if (!root) { |
|
7821 |
+ root = element; |
|
7822 |
+ checkRootConstraints(root); |
|
7823 |
+ } else if (!stack.length) { |
|
7824 |
+ // allow root elements with v-if, v-else-if and v-else |
|
7825 |
+ if (root.if && (element.elseif || element.else)) { |
|
7826 |
+ checkRootConstraints(element); |
|
7827 |
+ addIfCondition(root, { |
|
7828 |
+ exp: element.elseif, |
|
7829 |
+ block: element |
|
7830 |
+ }); |
|
7831 |
+ } else { |
|
7832 |
+ warnOnce( |
|
7833 |
+ "Component template should contain exactly one root element. " + |
|
7834 |
+ "If you are using v-if on multiple elements, " + |
|
7835 |
+ "use v-else-if to chain them instead." |
|
7836 |
+ ); |
|
7837 |
+ } |
|
7838 |
+ } |
|
7839 |
+ if (currentParent && !element.forbidden) { |
|
7840 |
+ if (element.elseif || element.else) { |
|
7841 |
+ processIfConditions(element, currentParent); |
|
7842 |
+ } else if (element.slotScope) { // scoped slot |
|
7843 |
+ currentParent.plain = false; |
|
7844 |
+ var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element; |
|
7845 |
+ } else { |
|
7846 |
+ currentParent.children.push(element); |
|
7847 |
+ element.parent = currentParent; |
|
7848 |
+ } |
|
7849 |
+ } |
|
7850 |
+ if (!unary) { |
|
7851 |
+ currentParent = element; |
|
7852 |
+ stack.push(element); |
|
7853 |
+ } else { |
|
7854 |
+ endPre(element); |
|
7855 |
+ } |
|
7856 |
+ // apply post-transforms |
|
7857 |
+ for (var i$2 = 0; i$2 < postTransforms.length; i$2++) { |
|
7858 |
+ postTransforms[i$2](element, options); |
|
7859 |
+ } |
|
7860 |
+ }, |
|
7861 |
+ |
|
7862 |
+ end: function end () { |
|
7863 |
+ // remove trailing whitespace |
|
7864 |
+ var element = stack[stack.length - 1]; |
|
7865 |
+ var lastNode = element.children[element.children.length - 1]; |
|
7866 |
+ if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) { |
|
7867 |
+ element.children.pop(); |
|
7868 |
+ } |
|
7869 |
+ // pop stack |
|
7870 |
+ stack.length -= 1; |
|
7871 |
+ currentParent = stack[stack.length - 1]; |
|
7872 |
+ endPre(element); |
|
7873 |
+ }, |
|
7874 |
+ |
|
7875 |
+ chars: function chars (text) { |
|
7876 |
+ if (!currentParent) { |
|
7877 |
+ { |
|
7878 |
+ if (text === template) { |
|
7879 |
+ warnOnce( |
|
7880 |
+ 'Component template requires a root element, rather than just text.' |
|
7881 |
+ ); |
|
7882 |
+ } else if ((text = text.trim())) { |
|
7883 |
+ warnOnce( |
|
7884 |
+ ("text \"" + text + "\" outside root element will be ignored.") |
|
7885 |
+ ); |
|
7886 |
+ } |
|
7887 |
+ } |
|
7888 |
+ return |
|
7889 |
+ } |
|
7890 |
+ // IE textarea placeholder bug |
|
7891 |
+ /* istanbul ignore if */ |
|
7892 |
+ if (isIE && |
|
7893 |
+ currentParent.tag === 'textarea' && |
|
7894 |
+ currentParent.attrsMap.placeholder === text) { |
|
7895 |
+ return |
|
7896 |
+ } |
|
7897 |
+ var children = currentParent.children; |
|
7898 |
+ text = inPre || text.trim() |
|
7899 |
+ ? decodeHTMLCached(text) |
|
7900 |
+ // only preserve whitespace if its not right after a starting tag |
|
7901 |
+ : preserveWhitespace && children.length ? ' ' : ''; |
|
7902 |
+ if (text) { |
|
7903 |
+ var expression; |
|
7904 |
+ if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) { |
|
7905 |
+ children.push({ |
|
7906 |
+ type: 2, |
|
7907 |
+ expression: expression, |
|
7908 |
+ text: text |
|
7909 |
+ }); |
|
7910 |
+ } else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') { |
|
7911 |
+ children.push({ |
|
7912 |
+ type: 3, |
|
7913 |
+ text: text |
|
7914 |
+ }); |
|
7915 |
+ } |
|
7916 |
+ } |
|
7917 |
+ } |
|
7918 |
+ }); |
|
7919 |
+ return root |
|
7920 |
+} |
|
7921 |
+ |
|
7922 |
+function processPre (el) { |
|
7923 |
+ if (getAndRemoveAttr(el, 'v-pre') != null) { |
|
7924 |
+ el.pre = true; |
|
7925 |
+ } |
|
7926 |
+} |
|
7927 |
+ |
|
7928 |
+function processRawAttrs (el) { |
|
7929 |
+ var l = el.attrsList.length; |
|
7930 |
+ if (l) { |
|
7931 |
+ var attrs = el.attrs = new Array(l); |
|
7932 |
+ for (var i = 0; i < l; i++) { |
|
7933 |
+ attrs[i] = { |
|
7934 |
+ name: el.attrsList[i].name, |
|
7935 |
+ value: JSON.stringify(el.attrsList[i].value) |
|
7936 |
+ }; |
|
7937 |
+ } |
|
7938 |
+ } else if (!el.pre) { |
|
7939 |
+ // non root node in pre blocks with no attributes |
|
7940 |
+ el.plain = true; |
|
7941 |
+ } |
|
7942 |
+} |
|
7943 |
+ |
|
7944 |
+function processKey (el) { |
|
7945 |
+ var exp = getBindingAttr(el, 'key'); |
|
7946 |
+ if (exp) { |
|
7947 |
+ if ("development" !== 'production' && el.tag === 'template') { |
|
7948 |
+ warn$2("<template> cannot be keyed. Place the key on real elements instead."); |
|
7949 |
+ } |
|
7950 |
+ el.key = exp; |
|
7951 |
+ } |
|
7952 |
+} |
|
7953 |
+ |
|
7954 |
+function processRef (el) { |
|
7955 |
+ var ref = getBindingAttr(el, 'ref'); |
|
7956 |
+ if (ref) { |
|
7957 |
+ el.ref = ref; |
|
7958 |
+ el.refInFor = checkInFor(el); |
|
7959 |
+ } |
|
7960 |
+} |
|
7961 |
+ |
|
7962 |
+function processFor (el) { |
|
7963 |
+ var exp; |
|
7964 |
+ if ((exp = getAndRemoveAttr(el, 'v-for'))) { |
|
7965 |
+ var inMatch = exp.match(forAliasRE); |
|
7966 |
+ if (!inMatch) { |
|
7967 |
+ "development" !== 'production' && warn$2( |
|
7968 |
+ ("Invalid v-for expression: " + exp) |
|
7969 |
+ ); |
|
7970 |
+ return |
|
7971 |
+ } |
|
7972 |
+ el.for = inMatch[2].trim(); |
|
7973 |
+ var alias = inMatch[1].trim(); |
|
7974 |
+ var iteratorMatch = alias.match(forIteratorRE); |
|
7975 |
+ if (iteratorMatch) { |
|
7976 |
+ el.alias = iteratorMatch[1].trim(); |
|
7977 |
+ el.iterator1 = iteratorMatch[2].trim(); |
|
7978 |
+ if (iteratorMatch[3]) { |
|
7979 |
+ el.iterator2 = iteratorMatch[3].trim(); |
|
7980 |
+ } |
|
7981 |
+ } else { |
|
7982 |
+ el.alias = alias; |
|
7983 |
+ } |
|
7984 |
+ } |
|
7985 |
+} |
|
7986 |
+ |
|
7987 |
+function processIf (el) { |
|
7988 |
+ var exp = getAndRemoveAttr(el, 'v-if'); |
|
7989 |
+ if (exp) { |
|
7990 |
+ el.if = exp; |
|
7991 |
+ addIfCondition(el, { |
|
7992 |
+ exp: exp, |
|
7993 |
+ block: el |
|
7994 |
+ }); |
|
7995 |
+ } else { |
|
7996 |
+ if (getAndRemoveAttr(el, 'v-else') != null) { |
|
7997 |
+ el.else = true; |
|
7998 |
+ } |
|
7999 |
+ var elseif = getAndRemoveAttr(el, 'v-else-if'); |
|
8000 |
+ if (elseif) { |
|
8001 |
+ el.elseif = elseif; |
|
8002 |
+ } |
|
8003 |
+ } |
|
8004 |
+} |
|
8005 |
+ |
|
8006 |
+function processIfConditions (el, parent) { |
|
8007 |
+ var prev = findPrevElement(parent.children); |
|
8008 |
+ if (prev && prev.if) { |
|
8009 |
+ addIfCondition(prev, { |
|
8010 |
+ exp: el.elseif, |
|
8011 |
+ block: el |
|
8012 |
+ }); |
|
8013 |
+ } else { |
|
8014 |
+ warn$2( |
|
8015 |
+ "v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " + |
|
8016 |
+ "used on element <" + (el.tag) + "> without corresponding v-if." |
|
8017 |
+ ); |
|
8018 |
+ } |
|
8019 |
+} |
|
8020 |
+ |
|
8021 |
+function findPrevElement (children) { |
|
8022 |
+ var i = children.length; |
|
8023 |
+ while (i--) { |
|
8024 |
+ if (children[i].type === 1) { |
|
8025 |
+ return children[i] |
|
8026 |
+ } else { |
|
8027 |
+ if ("development" !== 'production' && children[i].text !== ' ') { |
|
8028 |
+ warn$2( |
|
8029 |
+ "text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " + |
|
8030 |
+ "will be ignored." |
|
8031 |
+ ); |
|
8032 |
+ } |
|
8033 |
+ children.pop(); |
|
8034 |
+ } |
|
8035 |
+ } |
|
8036 |
+} |
|
8037 |
+ |
|
8038 |
+function addIfCondition (el, condition) { |
|
8039 |
+ if (!el.ifConditions) { |
|
8040 |
+ el.ifConditions = []; |
|
8041 |
+ } |
|
8042 |
+ el.ifConditions.push(condition); |
|
8043 |
+} |
|
8044 |
+ |
|
8045 |
+function processOnce (el) { |
|
8046 |
+ var once$$1 = getAndRemoveAttr(el, 'v-once'); |
|
8047 |
+ if (once$$1 != null) { |
|
8048 |
+ el.once = true; |
|
8049 |
+ } |
|
8050 |
+} |
|
8051 |
+ |
|
8052 |
+function processSlot (el) { |
|
8053 |
+ if (el.tag === 'slot') { |
|
8054 |
+ el.slotName = getBindingAttr(el, 'name'); |
|
8055 |
+ if ("development" !== 'production' && el.key) { |
|
8056 |
+ warn$2( |
|
8057 |
+ "`key` does not work on <slot> because slots are abstract outlets " + |
|
8058 |
+ "and can possibly expand into multiple elements. " + |
|
8059 |
+ "Use the key on a wrapping element instead." |
|
8060 |
+ ); |
|
8061 |
+ } |
|
8062 |
+ } else { |
|
8063 |
+ var slotTarget = getBindingAttr(el, 'slot'); |
|
8064 |
+ if (slotTarget) { |
|
8065 |
+ el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget; |
|
8066 |
+ } |
|
8067 |
+ if (el.tag === 'template') { |
|
8068 |
+ el.slotScope = getAndRemoveAttr(el, 'scope'); |
|
8069 |
+ } |
|
8070 |
+ } |
|
8071 |
+} |
|
8072 |
+ |
|
8073 |
+function processComponent (el) { |
|
8074 |
+ var binding; |
|
8075 |
+ if ((binding = getBindingAttr(el, 'is'))) { |
|
8076 |
+ el.component = binding; |
|
8077 |
+ } |
|
8078 |
+ if (getAndRemoveAttr(el, 'inline-template') != null) { |
|
8079 |
+ el.inlineTemplate = true; |
|
8080 |
+ } |
|
8081 |
+} |
|
8082 |
+ |
|
8083 |
+function processAttrs (el) { |
|
8084 |
+ var list = el.attrsList; |
|
8085 |
+ var i, l, name, rawName, value, modifiers, isProp; |
|
8086 |
+ for (i = 0, l = list.length; i < l; i++) { |
|
8087 |
+ name = rawName = list[i].name; |
|
8088 |
+ value = list[i].value; |
|
8089 |
+ if (dirRE.test(name)) { |
|
8090 |
+ // mark element as dynamic |
|
8091 |
+ el.hasBindings = true; |
|
8092 |
+ // modifiers |
|
8093 |
+ modifiers = parseModifiers(name); |
|
8094 |
+ if (modifiers) { |
|
8095 |
+ name = name.replace(modifierRE, ''); |
|
8096 |
+ } |
|
8097 |
+ if (bindRE.test(name)) { // v-bind |
|
8098 |
+ name = name.replace(bindRE, ''); |
|
8099 |
+ value = parseFilters(value); |
|
8100 |
+ isProp = false; |
|
8101 |
+ if (modifiers) { |
|
8102 |
+ if (modifiers.prop) { |
|
8103 |
+ isProp = true; |
|
8104 |
+ name = camelize(name); |
|
8105 |
+ if (name === 'innerHtml') { name = 'innerHTML'; } |
|
8106 |
+ } |
|
8107 |
+ if (modifiers.camel) { |
|
8108 |
+ name = camelize(name); |
|
8109 |
+ } |
|
8110 |
+ } |
|
8111 |
+ if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) { |
|
8112 |
+ addProp(el, name, value); |
|
8113 |
+ } else { |
|
8114 |
+ addAttr(el, name, value); |
|
8115 |
+ } |
|
8116 |
+ } else if (onRE.test(name)) { // v-on |
|
8117 |
+ name = name.replace(onRE, ''); |
|
8118 |
+ addHandler(el, name, value, modifiers); |
|
8119 |
+ } else { // normal directives |
|
8120 |
+ name = name.replace(dirRE, ''); |
|
8121 |
+ // parse arg |
|
8122 |
+ var argMatch = name.match(argRE); |
|
8123 |
+ var arg = argMatch && argMatch[1]; |
|
8124 |
+ if (arg) { |
|
8125 |
+ name = name.slice(0, -(arg.length + 1)); |
|
8126 |
+ } |
|
8127 |
+ addDirective(el, name, rawName, value, arg, modifiers); |
|
8128 |
+ if ("development" !== 'production' && name === 'model') { |
|
8129 |
+ checkForAliasModel(el, value); |
|
8130 |
+ } |
|
8131 |
+ } |
|
8132 |
+ } else { |
|
8133 |
+ // literal attribute |
|
8134 |
+ { |
|
8135 |
+ var expression = parseText(value, delimiters); |
|
8136 |
+ if (expression) { |
|
8137 |
+ warn$2( |
|
8138 |
+ name + "=\"" + value + "\": " + |
|
8139 |
+ 'Interpolation inside attributes has been removed. ' + |
|
8140 |
+ 'Use v-bind or the colon shorthand instead. For example, ' + |
|
8141 |
+ 'instead of <div id="{{ val }}">, use <div :id="val">.' |
|
8142 |
+ ); |
|
8143 |
+ } |
|
8144 |
+ } |
|
8145 |
+ addAttr(el, name, JSON.stringify(value)); |
|
8146 |
+ } |
|
8147 |
+ } |
|
8148 |
+} |
|
8149 |
+ |
|
8150 |
+function checkInFor (el) { |
|
8151 |
+ var parent = el; |
|
8152 |
+ while (parent) { |
|
8153 |
+ if (parent.for !== undefined) { |
|
8154 |
+ return true |
|
8155 |
+ } |
|
8156 |
+ parent = parent.parent; |
|
8157 |
+ } |
|
8158 |
+ return false |
|
8159 |
+} |
|
8160 |
+ |
|
8161 |
+function parseModifiers (name) { |
|
8162 |
+ var match = name.match(modifierRE); |
|
8163 |
+ if (match) { |
|
8164 |
+ var ret = {}; |
|
8165 |
+ match.forEach(function (m) { ret[m.slice(1)] = true; }); |
|
8166 |
+ return ret |
|
8167 |
+ } |
|
8168 |
+} |
|
8169 |
+ |
|
8170 |
+function makeAttrsMap (attrs) { |
|
8171 |
+ var map = {}; |
|
8172 |
+ for (var i = 0, l = attrs.length; i < l; i++) { |
|
8173 |
+ if ("development" !== 'production' && map[attrs[i].name] && !isIE) { |
|
8174 |
+ warn$2('duplicate attribute: ' + attrs[i].name); |
|
8175 |
+ } |
|
8176 |
+ map[attrs[i].name] = attrs[i].value; |
|
8177 |
+ } |
|
8178 |
+ return map |
|
8179 |
+} |
|
8180 |
+ |
|
8181 |
+function isForbiddenTag (el) { |
|
8182 |
+ return ( |
|
8183 |
+ el.tag === 'style' || |
|
8184 |
+ (el.tag === 'script' && ( |
|
8185 |
+ !el.attrsMap.type || |
|
8186 |
+ el.attrsMap.type === 'text/javascript' |
|
8187 |
+ )) |
|
8188 |
+ ) |
|
8189 |
+} |
|
8190 |
+ |
|
8191 |
+var ieNSBug = /^xmlns:NS\d+/; |
|
8192 |
+var ieNSPrefix = /^NS\d+:/; |
|
8193 |
+ |
|
8194 |
+/* istanbul ignore next */ |
|
8195 |
+function guardIESVGBug (attrs) { |
|
8196 |
+ var res = []; |
|
8197 |
+ for (var i = 0; i < attrs.length; i++) { |
|
8198 |
+ var attr = attrs[i]; |
|
8199 |
+ if (!ieNSBug.test(attr.name)) { |
|
8200 |
+ attr.name = attr.name.replace(ieNSPrefix, ''); |
|
8201 |
+ res.push(attr); |
|
8202 |
+ } |
|
8203 |
+ } |
|
8204 |
+ return res |
|
8205 |
+} |
|
8206 |
+ |
|
8207 |
+function checkForAliasModel (el, value) { |
|
8208 |
+ var _el = el; |
|
8209 |
+ while (_el) { |
|
8210 |
+ if (_el.for && _el.alias === value) { |
|
8211 |
+ warn$2( |
|
8212 |
+ "<" + (el.tag) + " v-model=\"" + value + "\">: " + |
|
8213 |
+ "You are binding v-model directly to a v-for iteration alias. " + |
|
8214 |
+ "This will not be able to modify the v-for source array because " + |
|
8215 |
+ "writing to the alias is like modifying a function local variable. " + |
|
8216 |
+ "Consider using an array of objects and use v-model on an object property instead." |
|
8217 |
+ ); |
|
8218 |
+ } |
|
8219 |
+ _el = _el.parent; |
|
8220 |
+ } |
|
8221 |
+} |
|
8222 |
+ |
|
8223 |
+/* */ |
|
8224 |
+ |
|
8225 |
+var isStaticKey; |
|
8226 |
+var isPlatformReservedTag; |
|
8227 |
+ |
|
8228 |
+var genStaticKeysCached = cached(genStaticKeys$1); |
|
8229 |
+ |
|
8230 |
+/** |
|
8231 |
+ * Goal of the optimizer: walk the generated template AST tree |
|
8232 |
+ * and detect sub-trees that are purely static, i.e. parts of |
|
8233 |
+ * the DOM that never needs to change. |
|
8234 |
+ * |
|
8235 |
+ * Once we detect these sub-trees, we can: |
|
8236 |
+ * |
|
8237 |
+ * 1. Hoist them into constants, so that we no longer need to |
|
8238 |
+ * create fresh nodes for them on each re-render; |
|
8239 |
+ * 2. Completely skip them in the patching process. |
|
8240 |
+ */ |
|
8241 |
+function optimize (root, options) { |
|
8242 |
+ if (!root) { return } |
|
8243 |
+ isStaticKey = genStaticKeysCached(options.staticKeys || ''); |
|
8244 |
+ isPlatformReservedTag = options.isReservedTag || no; |
|
8245 |
+ // first pass: mark all non-static nodes. |
|
8246 |
+ markStatic$1(root); |
|
8247 |
+ // second pass: mark static roots. |
|
8248 |
+ markStaticRoots(root, false); |
|
8249 |
+} |
|
8250 |
+ |
|
8251 |
+function genStaticKeys$1 (keys) { |
|
8252 |
+ return makeMap( |
|
8253 |
+ 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' + |
|
8254 |
+ (keys ? ',' + keys : '') |
|
8255 |
+ ) |
|
8256 |
+} |
|
8257 |
+ |
|
8258 |
+function markStatic$1 (node) { |
|
8259 |
+ node.static = isStatic(node); |
|
8260 |
+ if (node.type === 1) { |
|
8261 |
+ // do not make component slot content static. this avoids |
|
8262 |
+ // 1. components not able to mutate slot nodes |
|
8263 |
+ // 2. static slot content fails for hot-reloading |
|
8264 |
+ if ( |
|
8265 |
+ !isPlatformReservedTag(node.tag) && |
|
8266 |
+ node.tag !== 'slot' && |
|
8267 |
+ node.attrsMap['inline-template'] == null |
|
8268 |
+ ) { |
|
8269 |
+ return |
|
8270 |
+ } |
|
8271 |
+ for (var i = 0, l = node.children.length; i < l; i++) { |
|
8272 |
+ var child = node.children[i]; |
|
8273 |
+ markStatic$1(child); |
|
8274 |
+ if (!child.static) { |
|
8275 |
+ node.static = false; |
|
8276 |
+ } |
|
8277 |
+ } |
|
8278 |
+ } |
|
8279 |
+} |
|
8280 |
+ |
|
8281 |
+function markStaticRoots (node, isInFor) { |
|
8282 |
+ if (node.type === 1) { |
|
8283 |
+ if (node.static || node.once) { |
|
8284 |
+ node.staticInFor = isInFor; |
|
8285 |
+ } |
|
8286 |
+ // For a node to qualify as a static root, it should have children that |
|
8287 |
+ // are not just static text. Otherwise the cost of hoisting out will |
|
8288 |
+ // outweigh the benefits and it's better off to just always render it fresh. |
|
8289 |
+ if (node.static && node.children.length && !( |
|
8290 |
+ node.children.length === 1 && |
|
8291 |
+ node.children[0].type === 3 |
|
8292 |
+ )) { |
|
8293 |
+ node.staticRoot = true; |
|
8294 |
+ return |
|
8295 |
+ } else { |
|
8296 |
+ node.staticRoot = false; |
|
8297 |
+ } |
|
8298 |
+ if (node.children) { |
|
8299 |
+ for (var i = 0, l = node.children.length; i < l; i++) { |
|
8300 |
+ markStaticRoots(node.children[i], isInFor || !!node.for); |
|
8301 |
+ } |
|
8302 |
+ } |
|
8303 |
+ if (node.ifConditions) { |
|
8304 |
+ walkThroughConditionsBlocks(node.ifConditions, isInFor); |
|
8305 |
+ } |
|
8306 |
+ } |
|
8307 |
+} |
|
8308 |
+ |
|
8309 |
+function walkThroughConditionsBlocks (conditionBlocks, isInFor) { |
|
8310 |
+ for (var i = 1, len = conditionBlocks.length; i < len; i++) { |
|
8311 |
+ markStaticRoots(conditionBlocks[i].block, isInFor); |
|
8312 |
+ } |
|
8313 |
+} |
|
8314 |
+ |
|
8315 |
+function isStatic (node) { |
|
8316 |
+ if (node.type === 2) { // expression |
|
8317 |
+ return false |
|
8318 |
+ } |
|
8319 |
+ if (node.type === 3) { // text |
|
8320 |
+ return true |
|
8321 |
+ } |
|
8322 |
+ return !!(node.pre || ( |
|
8323 |
+ !node.hasBindings && // no dynamic bindings |
|
8324 |
+ !node.if && !node.for && // not v-if or v-for or v-else |
|
8325 |
+ !isBuiltInTag(node.tag) && // not a built-in |
|
8326 |
+ isPlatformReservedTag(node.tag) && // not a component |
|
8327 |
+ !isDirectChildOfTemplateFor(node) && |
|
8328 |
+ Object.keys(node).every(isStaticKey) |
|
8329 |
+ )) |
|
8330 |
+} |
|
8331 |
+ |
|
8332 |
+function isDirectChildOfTemplateFor (node) { |
|
8333 |
+ while (node.parent) { |
|
8334 |
+ node = node.parent; |
|
8335 |
+ if (node.tag !== 'template') { |
|
8336 |
+ return false |
|
8337 |
+ } |
|
8338 |
+ if (node.for) { |
|
8339 |
+ return true |
|
8340 |
+ } |
|
8341 |
+ } |
|
8342 |
+ return false |
|
8343 |
+} |
|
8344 |
+ |
|
8345 |
+/* */ |
|
8346 |
+ |
|
8347 |
+var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; |
|
8348 |
+var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/; |
|
8349 |
+ |
|
8350 |
+// keyCode aliases |
|
8351 |
+var keyCodes = { |
|
8352 |
+ esc: 27, |
|
8353 |
+ tab: 9, |
|
8354 |
+ enter: 13, |
|
8355 |
+ space: 32, |
|
8356 |
+ up: 38, |
|
8357 |
+ left: 37, |
|
8358 |
+ right: 39, |
|
8359 |
+ down: 40, |
|
8360 |
+ 'delete': [8, 46] |
|
8361 |
+}; |
|
8362 |
+ |
|
8363 |
+// #4868: modifiers that prevent the execution of the listener |
|
8364 |
+// need to explicitly return null so that we can determine whether to remove |
|
8365 |
+// the listener for .once |
|
8366 |
+var genGuard = function (condition) { return ("if(" + condition + ")return null;"); }; |
|
8367 |
+ |
|
8368 |
+var modifierCode = { |
|
8369 |
+ stop: '$event.stopPropagation();', |
|
8370 |
+ prevent: '$event.preventDefault();', |
|
8371 |
+ self: genGuard("$event.target !== $event.currentTarget"), |
|
8372 |
+ ctrl: genGuard("!$event.ctrlKey"), |
|
8373 |
+ shift: genGuard("!$event.shiftKey"), |
|
8374 |
+ alt: genGuard("!$event.altKey"), |
|
8375 |
+ meta: genGuard("!$event.metaKey"), |
|
8376 |
+ left: genGuard("'button' in $event && $event.button !== 0"), |
|
8377 |
+ middle: genGuard("'button' in $event && $event.button !== 1"), |
|
8378 |
+ right: genGuard("'button' in $event && $event.button !== 2") |
|
8379 |
+}; |
|
8380 |
+ |
|
8381 |
+function genHandlers (events, native) { |
|
8382 |
+ var res = native ? 'nativeOn:{' : 'on:{'; |
|
8383 |
+ for (var name in events) { |
|
8384 |
+ res += "\"" + name + "\":" + (genHandler(name, events[name])) + ","; |
|
8385 |
+ } |
|
8386 |
+ return res.slice(0, -1) + '}' |
|
8387 |
+} |
|
8388 |
+ |
|
8389 |
+function genHandler ( |
|
8390 |
+ name, |
|
8391 |
+ handler |
|
8392 |
+) { |
|
8393 |
+ if (!handler) { |
|
8394 |
+ return 'function(){}' |
|
8395 |
+ } |
|
8396 |
+ |
|
8397 |
+ if (Array.isArray(handler)) { |
|
8398 |
+ return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]") |
|
8399 |
+ } |
|
8400 |
+ |
|
8401 |
+ var isMethodPath = simplePathRE.test(handler.value); |
|
8402 |
+ var isFunctionExpression = fnExpRE.test(handler.value); |
|
8403 |
+ |
|
8404 |
+ if (!handler.modifiers) { |
|
8405 |
+ return isMethodPath || isFunctionExpression |
|
8406 |
+ ? handler.value |
|
8407 |
+ : ("function($event){" + (handler.value) + "}") // inline statement |
|
8408 |
+ } else { |
|
8409 |
+ var code = ''; |
|
8410 |
+ var genModifierCode = ''; |
|
8411 |
+ var keys = []; |
|
8412 |
+ for (var key in handler.modifiers) { |
|
8413 |
+ if (modifierCode[key]) { |
|
8414 |
+ genModifierCode += modifierCode[key]; |
|
8415 |
+ // left/right |
|
8416 |
+ if (keyCodes[key]) { |
|
8417 |
+ keys.push(key); |
|
8418 |
+ } |
|
8419 |
+ } else { |
|
8420 |
+ keys.push(key); |
|
8421 |
+ } |
|
8422 |
+ } |
|
8423 |
+ if (keys.length) { |
|
8424 |
+ code += genKeyFilter(keys); |
|
8425 |
+ } |
|
8426 |
+ // Make sure modifiers like prevent and stop get executed after key filtering |
|
8427 |
+ if (genModifierCode) { |
|
8428 |
+ code += genModifierCode; |
|
8429 |
+ } |
|
8430 |
+ var handlerCode = isMethodPath |
|
8431 |
+ ? handler.value + '($event)' |
|
8432 |
+ : isFunctionExpression |
|
8433 |
+ ? ("(" + (handler.value) + ")($event)") |
|
8434 |
+ : handler.value; |
|
8435 |
+ return ("function($event){" + code + handlerCode + "}") |
|
8436 |
+ } |
|
8437 |
+} |
|
8438 |
+ |
|
8439 |
+function genKeyFilter (keys) { |
|
8440 |
+ return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;") |
|
8441 |
+} |
|
8442 |
+ |
|
8443 |
+function genFilterCode (key) { |
|
8444 |
+ var keyVal = parseInt(key, 10); |
|
8445 |
+ if (keyVal) { |
|
8446 |
+ return ("$event.keyCode!==" + keyVal) |
|
8447 |
+ } |
|
8448 |
+ var alias = keyCodes[key]; |
|
8449 |
+ return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")") |
|
8450 |
+} |
|
8451 |
+ |
|
8452 |
+/* */ |
|
8453 |
+ |
|
8454 |
+function bind$1 (el, dir) { |
|
8455 |
+ el.wrapData = function (code) { |
|
8456 |
+ return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")") |
|
8457 |
+ }; |
|
8458 |
+} |
|
8459 |
+ |
|
8460 |
+/* */ |
|
8461 |
+ |
|
8462 |
+var baseDirectives = { |
|
8463 |
+ bind: bind$1, |
|
8464 |
+ cloak: noop |
|
8465 |
+}; |
|
8466 |
+ |
|
8467 |
+/* */ |
|
8468 |
+ |
|
8469 |
+// configurable state |
|
8470 |
+var warn$3; |
|
8471 |
+var transforms$1; |
|
8472 |
+var dataGenFns; |
|
8473 |
+var platformDirectives$1; |
|
8474 |
+var isPlatformReservedTag$1; |
|
8475 |
+var staticRenderFns; |
|
8476 |
+var onceCount; |
|
8477 |
+var currentOptions; |
|
8478 |
+ |
|
8479 |
+function generate ( |
|
8480 |
+ ast, |
|
8481 |
+ options |
|
8482 |
+) { |
|
8483 |
+ // save previous staticRenderFns so generate calls can be nested |
|
8484 |
+ var prevStaticRenderFns = staticRenderFns; |
|
8485 |
+ var currentStaticRenderFns = staticRenderFns = []; |
|
8486 |
+ var prevOnceCount = onceCount; |
|
8487 |
+ onceCount = 0; |
|
8488 |
+ currentOptions = options; |
|
8489 |
+ warn$3 = options.warn || baseWarn; |
|
8490 |
+ transforms$1 = pluckModuleFunction(options.modules, 'transformCode'); |
|
8491 |
+ dataGenFns = pluckModuleFunction(options.modules, 'genData'); |
|
8492 |
+ platformDirectives$1 = options.directives || {}; |
|
8493 |
+ isPlatformReservedTag$1 = options.isReservedTag || no; |
|
8494 |
+ var code = ast ? genElement(ast) : '_c("div")'; |
|
8495 |
+ staticRenderFns = prevStaticRenderFns; |
|
8496 |
+ onceCount = prevOnceCount; |
|
8497 |
+ return { |
|
8498 |
+ render: ("with(this){return " + code + "}"), |
|
8499 |
+ staticRenderFns: currentStaticRenderFns |
|
8500 |
+ } |
|
8501 |
+} |
|
8502 |
+ |
|
8503 |
+function genElement (el) { |
|
8504 |
+ if (el.staticRoot && !el.staticProcessed) { |
|
8505 |
+ return genStatic(el) |
|
8506 |
+ } else if (el.once && !el.onceProcessed) { |
|
8507 |
+ return genOnce(el) |
|
8508 |
+ } else if (el.for && !el.forProcessed) { |
|
8509 |
+ return genFor(el) |
|
8510 |
+ } else if (el.if && !el.ifProcessed) { |
|
8511 |
+ return genIf(el) |
|
8512 |
+ } else if (el.tag === 'template' && !el.slotTarget) { |
|
8513 |
+ return genChildren(el) || 'void 0' |
|
8514 |
+ } else if (el.tag === 'slot') { |
|
8515 |
+ return genSlot(el) |
|
8516 |
+ } else { |
|
8517 |
+ // component or element |
|
8518 |
+ var code; |
|
8519 |
+ if (el.component) { |
|
8520 |
+ code = genComponent(el.component, el); |
|
8521 |
+ } else { |
|
8522 |
+ var data = el.plain ? undefined : genData(el); |
|
8523 |
+ |
|
8524 |
+ var children = el.inlineTemplate ? null : genChildren(el, true); |
|
8525 |
+ code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; |
|
8526 |
+ } |
|
8527 |
+ // module transforms |
|
8528 |
+ for (var i = 0; i < transforms$1.length; i++) { |
|
8529 |
+ code = transforms$1[i](el, code); |
|
8530 |
+ } |
|
8531 |
+ return code |
|
8532 |
+ } |
|
8533 |
+} |
|
8534 |
+ |
|
8535 |
+// hoist static sub-trees out |
|
8536 |
+function genStatic (el) { |
|
8537 |
+ el.staticProcessed = true; |
|
8538 |
+ staticRenderFns.push(("with(this){return " + (genElement(el)) + "}")); |
|
8539 |
+ return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")") |
|
8540 |
+} |
|
8541 |
+ |
|
8542 |
+// v-once |
|
8543 |
+function genOnce (el) { |
|
8544 |
+ el.onceProcessed = true; |
|
8545 |
+ if (el.if && !el.ifProcessed) { |
|
8546 |
+ return genIf(el) |
|
8547 |
+ } else if (el.staticInFor) { |
|
8548 |
+ var key = ''; |
|
8549 |
+ var parent = el.parent; |
|
8550 |
+ while (parent) { |
|
8551 |
+ if (parent.for) { |
|
8552 |
+ key = parent.key; |
|
8553 |
+ break |
|
8554 |
+ } |
|
8555 |
+ parent = parent.parent; |
|
8556 |
+ } |
|
8557 |
+ if (!key) { |
|
8558 |
+ "development" !== 'production' && warn$3( |
|
8559 |
+ "v-once can only be used inside v-for that is keyed. " |
|
8560 |
+ ); |
|
8561 |
+ return genElement(el) |
|
8562 |
+ } |
|
8563 |
+ return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")") |
|
8564 |
+ } else { |
|
8565 |
+ return genStatic(el) |
|
8566 |
+ } |
|
8567 |
+} |
|
8568 |
+ |
|
8569 |
+function genIf (el) { |
|
8570 |
+ el.ifProcessed = true; // avoid recursion |
|
8571 |
+ return genIfConditions(el.ifConditions.slice()) |
|
8572 |
+} |
|
8573 |
+ |
|
8574 |
+function genIfConditions (conditions) { |
|
8575 |
+ if (!conditions.length) { |
|
8576 |
+ return '_e()' |
|
8577 |
+ } |
|
8578 |
+ |
|
8579 |
+ var condition = conditions.shift(); |
|
8580 |
+ if (condition.exp) { |
|
8581 |
+ return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions))) |
|
8582 |
+ } else { |
|
8583 |
+ return ("" + (genTernaryExp(condition.block))) |
|
8584 |
+ } |
|
8585 |
+ |
|
8586 |
+ // v-if with v-once should generate code like (a)?_m(0):_m(1) |
|
8587 |
+ function genTernaryExp (el) { |
|
8588 |
+ return el.once ? genOnce(el) : genElement(el) |
|
8589 |
+ } |
|
8590 |
+} |
|
8591 |
+ |
|
8592 |
+function genFor (el) { |
|
8593 |
+ var exp = el.for; |
|
8594 |
+ var alias = el.alias; |
|
8595 |
+ var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; |
|
8596 |
+ var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; |
|
8597 |
+ |
|
8598 |
+ if ( |
|
8599 |
+ "development" !== 'production' && |
|
8600 |
+ maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key |
|
8601 |
+ ) { |
|
8602 |
+ warn$3( |
|
8603 |
+ "<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " + |
|
8604 |
+ "v-for should have explicit keys. " + |
|
8605 |
+ "See https://vuejs.org/guide/list.html#key for more info.", |
|
8606 |
+ true /* tip */ |
|
8607 |
+ ); |
|
8608 |
+ } |
|
8609 |
+ |
|
8610 |
+ el.forProcessed = true; // avoid recursion |
|
8611 |
+ return "_l((" + exp + ")," + |
|
8612 |
+ "function(" + alias + iterator1 + iterator2 + "){" + |
|
8613 |
+ "return " + (genElement(el)) + |
|
8614 |
+ '})' |
|
8615 |
+} |
|
8616 |
+ |
|
8617 |
+function genData (el) { |
|
8618 |
+ var data = '{'; |
|
8619 |
+ |
|
8620 |
+ // directives first. |
|
8621 |
+ // directives may mutate the el's other properties before they are generated. |
|
8622 |
+ var dirs = genDirectives(el); |
|
8623 |
+ if (dirs) { data += dirs + ','; } |
|
8624 |
+ |
|
8625 |
+ // key |
|
8626 |
+ if (el.key) { |
|
8627 |
+ data += "key:" + (el.key) + ","; |
|
8628 |
+ } |
|
8629 |
+ // ref |
|
8630 |
+ if (el.ref) { |
|
8631 |
+ data += "ref:" + (el.ref) + ","; |
|
8632 |
+ } |
|
8633 |
+ if (el.refInFor) { |
|
8634 |
+ data += "refInFor:true,"; |
|
8635 |
+ } |
|
8636 |
+ // pre |
|
8637 |
+ if (el.pre) { |
|
8638 |
+ data += "pre:true,"; |
|
8639 |
+ } |
|
8640 |
+ // record original tag name for components using "is" attribute |
|
8641 |
+ if (el.component) { |
|
8642 |
+ data += "tag:\"" + (el.tag) + "\","; |
|
8643 |
+ } |
|
8644 |
+ // module data generation functions |
|
8645 |
+ for (var i = 0; i < dataGenFns.length; i++) { |
|
8646 |
+ data += dataGenFns[i](el); |
|
8647 |
+ } |
|
8648 |
+ // attributes |
|
8649 |
+ if (el.attrs) { |
|
8650 |
+ data += "attrs:{" + (genProps(el.attrs)) + "},"; |
|
8651 |
+ } |
|
8652 |
+ // DOM props |
|
8653 |
+ if (el.props) { |
|
8654 |
+ data += "domProps:{" + (genProps(el.props)) + "},"; |
|
8655 |
+ } |
|
8656 |
+ // event handlers |
|
8657 |
+ if (el.events) { |
|
8658 |
+ data += (genHandlers(el.events)) + ","; |
|
8659 |
+ } |
|
8660 |
+ if (el.nativeEvents) { |
|
8661 |
+ data += (genHandlers(el.nativeEvents, true)) + ","; |
|
8662 |
+ } |
|
8663 |
+ // slot target |
|
8664 |
+ if (el.slotTarget) { |
|
8665 |
+ data += "slot:" + (el.slotTarget) + ","; |
|
8666 |
+ } |
|
8667 |
+ // scoped slots |
|
8668 |
+ if (el.scopedSlots) { |
|
8669 |
+ data += (genScopedSlots(el.scopedSlots)) + ","; |
|
8670 |
+ } |
|
8671 |
+ // component v-model |
|
8672 |
+ if (el.model) { |
|
8673 |
+ data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},"; |
|
8674 |
+ } |
|
8675 |
+ // inline-template |
|
8676 |
+ if (el.inlineTemplate) { |
|
8677 |
+ var inlineTemplate = genInlineTemplate(el); |
|
8678 |
+ if (inlineTemplate) { |
|
8679 |
+ data += inlineTemplate + ","; |
|
8680 |
+ } |
|
8681 |
+ } |
|
8682 |
+ data = data.replace(/,$/, '') + '}'; |
|
8683 |
+ // v-bind data wrap |
|
8684 |
+ if (el.wrapData) { |
|
8685 |
+ data = el.wrapData(data); |
|
8686 |
+ } |
|
8687 |
+ return data |
|
8688 |
+} |
|
8689 |
+ |
|
8690 |
+function genDirectives (el) { |
|
8691 |
+ var dirs = el.directives; |
|
8692 |
+ if (!dirs) { return } |
|
8693 |
+ var res = 'directives:['; |
|
8694 |
+ var hasRuntime = false; |
|
8695 |
+ var i, l, dir, needRuntime; |
|
8696 |
+ for (i = 0, l = dirs.length; i < l; i++) { |
|
8697 |
+ dir = dirs[i]; |
|
8698 |
+ needRuntime = true; |
|
8699 |
+ var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name]; |
|
8700 |
+ if (gen) { |
|
8701 |
+ // compile-time directive that manipulates AST. |
|
8702 |
+ // returns true if it also needs a runtime counterpart. |
|
8703 |
+ needRuntime = !!gen(el, dir, warn$3); |
|
8704 |
+ } |
|
8705 |
+ if (needRuntime) { |
|
8706 |
+ hasRuntime = true; |
|
8707 |
+ res += "{name:\"" + (dir.name) + "\",rawName:\"" + (dir.rawName) + "\"" + (dir.value ? (",value:(" + (dir.value) + "),expression:" + (JSON.stringify(dir.value))) : '') + (dir.arg ? (",arg:\"" + (dir.arg) + "\"") : '') + (dir.modifiers ? (",modifiers:" + (JSON.stringify(dir.modifiers))) : '') + "},"; |
|
8708 |
+ } |
|
8709 |
+ } |
|
8710 |
+ if (hasRuntime) { |
|
8711 |
+ return res.slice(0, -1) + ']' |
|
8712 |
+ } |
|
8713 |
+} |
|
8714 |
+ |
|
8715 |
+function genInlineTemplate (el) { |
|
8716 |
+ var ast = el.children[0]; |
|
8717 |
+ if ("development" !== 'production' && ( |
|
8718 |
+ el.children.length > 1 || ast.type !== 1 |
|
8719 |
+ )) { |
|
8720 |
+ warn$3('Inline-template components must have exactly one child element.'); |
|
8721 |
+ } |
|
8722 |
+ if (ast.type === 1) { |
|
8723 |
+ var inlineRenderFns = generate(ast, currentOptions); |
|
8724 |
+ return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}") |
|
8725 |
+ } |
|
8726 |
+} |
|
8727 |
+ |
|
8728 |
+function genScopedSlots (slots) { |
|
8729 |
+ return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])") |
|
8730 |
+} |
|
8731 |
+ |
|
8732 |
+function genScopedSlot (key, el) { |
|
8733 |
+ return "[" + key + ",function(" + (String(el.attrsMap.scope)) + "){" + |
|
8734 |
+ "return " + (el.tag === 'template' |
|
8735 |
+ ? genChildren(el) || 'void 0' |
|
8736 |
+ : genElement(el)) + "}]" |
|
8737 |
+} |
|
8738 |
+ |
|
8739 |
+function genChildren (el, checkSkip) { |
|
8740 |
+ var children = el.children; |
|
8741 |
+ if (children.length) { |
|
8742 |
+ var el$1 = children[0]; |
|
8743 |
+ // optimize single v-for |
|
8744 |
+ if (children.length === 1 && |
|
8745 |
+ el$1.for && |
|
8746 |
+ el$1.tag !== 'template' && |
|
8747 |
+ el$1.tag !== 'slot') { |
|
8748 |
+ return genElement(el$1) |
|
8749 |
+ } |
|
8750 |
+ var normalizationType = checkSkip ? getNormalizationType(children) : 0; |
|
8751 |
+ return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : '')) |
|
8752 |
+ } |
|
8753 |
+} |
|
8754 |
+ |
|
8755 |
+// determine the normalization needed for the children array. |
|
8756 |
+// 0: no normalization needed |
|
8757 |
+// 1: simple normalization needed (possible 1-level deep nested array) |
|
8758 |
+// 2: full normalization needed |
|
8759 |
+function getNormalizationType (children) { |
|
8760 |
+ var res = 0; |
|
8761 |
+ for (var i = 0; i < children.length; i++) { |
|
8762 |
+ var el = children[i]; |
|
8763 |
+ if (el.type !== 1) { |
|
8764 |
+ continue |
|
8765 |
+ } |
|
8766 |
+ if (needsNormalization(el) || |
|
8767 |
+ (el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) { |
|
8768 |
+ res = 2; |
|
8769 |
+ break |
|
8770 |
+ } |
|
8771 |
+ if (maybeComponent(el) || |
|
8772 |
+ (el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) { |
|
8773 |
+ res = 1; |
|
8774 |
+ } |
|
8775 |
+ } |
|
8776 |
+ return res |
|
8777 |
+} |
|
8778 |
+ |
|
8779 |
+function needsNormalization (el) { |
|
8780 |
+ return el.for !== undefined || el.tag === 'template' || el.tag === 'slot' |
|
8781 |
+} |
|
8782 |
+ |
|
8783 |
+function maybeComponent (el) { |
|
8784 |
+ return !isPlatformReservedTag$1(el.tag) |
|
8785 |
+} |
|
8786 |
+ |
|
8787 |
+function genNode (node) { |
|
8788 |
+ if (node.type === 1) { |
|
8789 |
+ return genElement(node) |
|
8790 |
+ } else { |
|
8791 |
+ return genText(node) |
|
8792 |
+ } |
|
8793 |
+} |
|
8794 |
+ |
|
8795 |
+function genText (text) { |
|
8796 |
+ return ("_v(" + (text.type === 2 |
|
8797 |
+ ? text.expression // no need for () because already wrapped in _s() |
|
8798 |
+ : transformSpecialNewlines(JSON.stringify(text.text))) + ")") |
|
8799 |
+} |
|
8800 |
+ |
|
8801 |
+function genSlot (el) { |
|
8802 |
+ var slotName = el.slotName || '"default"'; |
|
8803 |
+ var children = genChildren(el); |
|
8804 |
+ var res = "_t(" + slotName + (children ? ("," + children) : ''); |
|
8805 |
+ var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}"); |
|
8806 |
+ var bind$$1 = el.attrsMap['v-bind']; |
|
8807 |
+ if ((attrs || bind$$1) && !children) { |
|
8808 |
+ res += ",null"; |
|
8809 |
+ } |
|
8810 |
+ if (attrs) { |
|
8811 |
+ res += "," + attrs; |
|
8812 |
+ } |
|
8813 |
+ if (bind$$1) { |
|
8814 |
+ res += (attrs ? '' : ',null') + "," + bind$$1; |
|
8815 |
+ } |
|
8816 |
+ return res + ')' |
|
8817 |
+} |
|
8818 |
+ |
|
8819 |
+// componentName is el.component, take it as argument to shun flow's pessimistic refinement |
|
8820 |
+function genComponent (componentName, el) { |
|
8821 |
+ var children = el.inlineTemplate ? null : genChildren(el, true); |
|
8822 |
+ return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")") |
|
8823 |
+} |
|
8824 |
+ |
|
8825 |
+function genProps (props) { |
|
8826 |
+ var res = ''; |
|
8827 |
+ for (var i = 0; i < props.length; i++) { |
|
8828 |
+ var prop = props[i]; |
|
8829 |
+ res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ","; |
|
8830 |
+ } |
|
8831 |
+ return res.slice(0, -1) |
|
8832 |
+} |
|
8833 |
+ |
|
8834 |
+// #3895, #4268 |
|
8835 |
+function transformSpecialNewlines (text) { |
|
8836 |
+ return text |
|
8837 |
+ .replace(/\u2028/g, '\\u2028') |
|
8838 |
+ .replace(/\u2029/g, '\\u2029') |
|
8839 |
+} |
|
8840 |
+ |
|
8841 |
+/* */ |
|
8842 |
+ |
|
8843 |
+// these keywords should not appear inside expressions, but operators like |
|
8844 |
+// typeof, instanceof and in are allowed |
|
8845 |
+var prohibitedKeywordRE = new RegExp('\\b' + ( |
|
8846 |
+ 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + |
|
8847 |
+ 'super,throw,while,yield,delete,export,import,return,switch,default,' + |
|
8848 |
+ 'extends,finally,continue,debugger,function,arguments' |
|
8849 |
+).split(',').join('\\b|\\b') + '\\b'); |
|
8850 |
+ |
|
8851 |
+// these unary operators should not be used as property/method names |
|
8852 |
+var unaryOperatorsRE = new RegExp('\\b' + ( |
|
8853 |
+ 'delete,typeof,void' |
|
8854 |
+).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)'); |
|
8855 |
+ |
|
8856 |
+// check valid identifier for v-for |
|
8857 |
+var identRE = /[A-Za-z_$][\w$]*/; |
|
8858 |
+ |
|
8859 |
+// strip strings in expressions |
|
8860 |
+var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g; |
|
8861 |
+ |
|
8862 |
+// detect problematic expressions in a template |
|
8863 |
+function detectErrors (ast) { |
|
8864 |
+ var errors = []; |
|
8865 |
+ if (ast) { |
|
8866 |
+ checkNode(ast, errors); |
|
8867 |
+ } |
|
8868 |
+ return errors |
|
8869 |
+} |
|
8870 |
+ |
|
8871 |
+function checkNode (node, errors) { |
|
8872 |
+ if (node.type === 1) { |
|
8873 |
+ for (var name in node.attrsMap) { |
|
8874 |
+ if (dirRE.test(name)) { |
|
8875 |
+ var value = node.attrsMap[name]; |
|
8876 |
+ if (value) { |
|
8877 |
+ if (name === 'v-for') { |
|
8878 |
+ checkFor(node, ("v-for=\"" + value + "\""), errors); |
|
8879 |
+ } else if (onRE.test(name)) { |
|
8880 |
+ checkEvent(value, (name + "=\"" + value + "\""), errors); |
|
8881 |
+ } else { |
|
8882 |
+ checkExpression(value, (name + "=\"" + value + "\""), errors); |
|
8883 |
+ } |
|
8884 |
+ } |
|
8885 |
+ } |
|
8886 |
+ } |
|
8887 |
+ if (node.children) { |
|
8888 |
+ for (var i = 0; i < node.children.length; i++) { |
|
8889 |
+ checkNode(node.children[i], errors); |
|
8890 |
+ } |
|
8891 |
+ } |
|
8892 |
+ } else if (node.type === 2) { |
|
8893 |
+ checkExpression(node.expression, node.text, errors); |
|
8894 |
+ } |
|
8895 |
+} |
|
8896 |
+ |
|
8897 |
+function checkEvent (exp, text, errors) { |
|
8898 |
+ var keywordMatch = exp.replace(stripStringRE, '').match(unaryOperatorsRE); |
|
8899 |
+ if (keywordMatch) { |
|
8900 |
+ errors.push( |
|
8901 |
+ "avoid using JavaScript unary operator as property name: " + |
|
8902 |
+ "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()) |
|
8903 |
+ ); |
|
8904 |
+ } |
|
8905 |
+ checkExpression(exp, text, errors); |
|
8906 |
+} |
|
8907 |
+ |
|
8908 |
+function checkFor (node, text, errors) { |
|
8909 |
+ checkExpression(node.for || '', text, errors); |
|
8910 |
+ checkIdentifier(node.alias, 'v-for alias', text, errors); |
|
8911 |
+ checkIdentifier(node.iterator1, 'v-for iterator', text, errors); |
|
8912 |
+ checkIdentifier(node.iterator2, 'v-for iterator', text, errors); |
|
8913 |
+} |
|
8914 |
+ |
|
8915 |
+function checkIdentifier (ident, type, text, errors) { |
|
8916 |
+ if (typeof ident === 'string' && !identRE.test(ident)) { |
|
8917 |
+ errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim()))); |
|
8918 |
+ } |
|
8919 |
+} |
|
8920 |
+ |
|
8921 |
+function checkExpression (exp, text, errors) { |
|
8922 |
+ try { |
|
8923 |
+ new Function(("return " + exp)); |
|
8924 |
+ } catch (e) { |
|
8925 |
+ var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE); |
|
8926 |
+ if (keywordMatch) { |
|
8927 |
+ errors.push( |
|
8928 |
+ "avoid using JavaScript keyword as property name: " + |
|
8929 |
+ "\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()) |
|
8930 |
+ ); |
|
8931 |
+ } else { |
|
8932 |
+ errors.push(("invalid expression: " + (text.trim()))); |
|
8933 |
+ } |
|
8934 |
+ } |
|
8935 |
+} |
|
8936 |
+ |
|
8937 |
+/* */ |
|
8938 |
+ |
|
8939 |
+function baseCompile ( |
|
8940 |
+ template, |
|
8941 |
+ options |
|
8942 |
+) { |
|
8943 |
+ var ast = parse(template.trim(), options); |
|
8944 |
+ optimize(ast, options); |
|
8945 |
+ var code = generate(ast, options); |
|
8946 |
+ return { |
|
8947 |
+ ast: ast, |
|
8948 |
+ render: code.render, |
|
8949 |
+ staticRenderFns: code.staticRenderFns |
|
8950 |
+ } |
|
8951 |
+} |
|
8952 |
+ |
|
8953 |
+function makeFunction (code, errors) { |
|
8954 |
+ try { |
|
8955 |
+ return new Function(code) |
|
8956 |
+ } catch (err) { |
|
8957 |
+ errors.push({ err: err, code: code }); |
|
8958 |
+ return noop |
|
8959 |
+ } |
|
8960 |
+} |
|
8961 |
+ |
|
8962 |
+function createCompiler (baseOptions) { |
|
8963 |
+ var functionCompileCache = Object.create(null); |
|
8964 |
+ |
|
8965 |
+ function compile ( |
|
8966 |
+ template, |
|
8967 |
+ options |
|
8968 |
+ ) { |
|
8969 |
+ var finalOptions = Object.create(baseOptions); |
|
8970 |
+ var errors = []; |
|
8971 |
+ var tips = []; |
|
8972 |
+ finalOptions.warn = function (msg, tip$$1) { |
|
8973 |
+ (tip$$1 ? tips : errors).push(msg); |
|
8974 |
+ }; |
|
8975 |
+ |
|
8976 |
+ if (options) { |
|
8977 |
+ // merge custom modules |
|
8978 |
+ if (options.modules) { |
|
8979 |
+ finalOptions.modules = (baseOptions.modules || []).concat(options.modules); |
|
8980 |
+ } |
|
8981 |
+ // merge custom directives |
|
8982 |
+ if (options.directives) { |
|
8983 |
+ finalOptions.directives = extend( |
|
8984 |
+ Object.create(baseOptions.directives), |
|
8985 |
+ options.directives |
|
8986 |
+ ); |
|
8987 |
+ } |
|
8988 |
+ // copy other options |
|
8989 |
+ for (var key in options) { |
|
8990 |
+ if (key !== 'modules' && key !== 'directives') { |
|
8991 |
+ finalOptions[key] = options[key]; |
|
8992 |
+ } |
|
8993 |
+ } |
|
8994 |
+ } |
|
8995 |
+ |
|
8996 |
+ var compiled = baseCompile(template, finalOptions); |
|
8997 |
+ { |
|
8998 |
+ errors.push.apply(errors, detectErrors(compiled.ast)); |
|
8999 |
+ } |
|
9000 |
+ compiled.errors = errors; |
|
9001 |
+ compiled.tips = tips; |
|
9002 |
+ return compiled |
|
9003 |
+ } |
|
9004 |
+ |
|
9005 |
+ function compileToFunctions ( |
|
9006 |
+ template, |
|
9007 |
+ options, |
|
9008 |
+ vm |
|
9009 |
+ ) { |
|
9010 |
+ options = options || {}; |
|
9011 |
+ |
|
9012 |
+ /* istanbul ignore if */ |
|
9013 |
+ { |
|
9014 |
+ // detect possible CSP restriction |
|
9015 |
+ try { |
|
9016 |
+ new Function('return 1'); |
|
9017 |
+ } catch (e) { |
|
9018 |
+ if (e.toString().match(/unsafe-eval|CSP/)) { |
|
9019 |
+ warn( |
|
9020 |
+ 'It seems you are using the standalone build of Vue.js in an ' + |
|
9021 |
+ 'environment with Content Security Policy that prohibits unsafe-eval. ' + |
|
9022 |
+ 'The template compiler cannot work in this environment. Consider ' + |
|
9023 |
+ 'relaxing the policy to allow unsafe-eval or pre-compiling your ' + |
|
9024 |
+ 'templates into render functions.' |
|
9025 |
+ ); |
|
9026 |
+ } |
|
9027 |
+ } |
|
9028 |
+ } |
|
9029 |
+ |
|
9030 |
+ // check cache |
|
9031 |
+ var key = options.delimiters |
|
9032 |
+ ? String(options.delimiters) + template |
|
9033 |
+ : template; |
|
9034 |
+ if (functionCompileCache[key]) { |
|
9035 |
+ return functionCompileCache[key] |
|
9036 |
+ } |
|
9037 |
+ |
|
9038 |
+ // compile |
|
9039 |
+ var compiled = compile(template, options); |
|
9040 |
+ |
|
9041 |
+ // check compilation errors/tips |
|
9042 |
+ { |
|
9043 |
+ if (compiled.errors && compiled.errors.length) { |
|
9044 |
+ warn( |
|
9045 |
+ "Error compiling template:\n\n" + template + "\n\n" + |
|
9046 |
+ compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n', |
|
9047 |
+ vm |
|
9048 |
+ ); |
|
9049 |
+ } |
|
9050 |
+ if (compiled.tips && compiled.tips.length) { |
|
9051 |
+ compiled.tips.forEach(function (msg) { return tip(msg, vm); }); |
|
9052 |
+ } |
|
9053 |
+ } |
|
9054 |
+ |
|
9055 |
+ // turn code into functions |
|
9056 |
+ var res = {}; |
|
9057 |
+ var fnGenErrors = []; |
|
9058 |
+ res.render = makeFunction(compiled.render, fnGenErrors); |
|
9059 |
+ var l = compiled.staticRenderFns.length; |
|
9060 |
+ res.staticRenderFns = new Array(l); |
|
9061 |
+ for (var i = 0; i < l; i++) { |
|
9062 |
+ res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors); |
|
9063 |
+ } |
|
9064 |
+ |
|
9065 |
+ // check function generation errors. |
|
9066 |
+ // this should only happen if there is a bug in the compiler itself. |
|
9067 |
+ // mostly for codegen development use |
|
9068 |
+ /* istanbul ignore if */ |
|
9069 |
+ { |
|
9070 |
+ if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) { |
|
9071 |
+ warn( |
|
9072 |
+ "Failed to generate render function:\n\n" + |
|
9073 |
+ fnGenErrors.map(function (ref) { |
|
9074 |
+ var err = ref.err; |
|
9075 |
+ var code = ref.code; |
|
9076 |
+ |
|
9077 |
+ return ((err.toString()) + " in\n\n" + code + "\n"); |
|
9078 |
+ }).join('\n'), |
|
9079 |
+ vm |
|
9080 |
+ ); |
|
9081 |
+ } |
|
9082 |
+ } |
|
9083 |
+ |
|
9084 |
+ return (functionCompileCache[key] = res) |
|
9085 |
+ } |
|
9086 |
+ |
|
9087 |
+ return { |
|
9088 |
+ compile: compile, |
|
9089 |
+ compileToFunctions: compileToFunctions |
|
9090 |
+ } |
|
9091 |
+} |
|
9092 |
+ |
|
9093 |
+/* */ |
|
9094 |
+ |
|
9095 |
+function transformNode (el, options) { |
|
9096 |
+ var warn = options.warn || baseWarn; |
|
9097 |
+ var staticClass = getAndRemoveAttr(el, 'class'); |
|
9098 |
+ if ("development" !== 'production' && staticClass) { |
|
9099 |
+ var expression = parseText(staticClass, options.delimiters); |
|
9100 |
+ if (expression) { |
|
9101 |
+ warn( |
|
9102 |
+ "class=\"" + staticClass + "\": " + |
|
9103 |
+ 'Interpolation inside attributes has been removed. ' + |
|
9104 |
+ 'Use v-bind or the colon shorthand instead. For example, ' + |
|
9105 |
+ 'instead of <div class="{{ val }}">, use <div :class="val">.' |
|
9106 |
+ ); |
|
9107 |
+ } |
|
9108 |
+ } |
|
9109 |
+ if (staticClass) { |
|
9110 |
+ el.staticClass = JSON.stringify(staticClass); |
|
9111 |
+ } |
|
9112 |
+ var classBinding = getBindingAttr(el, 'class', false /* getStatic */); |
|
9113 |
+ if (classBinding) { |
|
9114 |
+ el.classBinding = classBinding; |
|
9115 |
+ } |
|
9116 |
+} |
|
9117 |
+ |
|
9118 |
+function genData$1 (el) { |
|
9119 |
+ var data = ''; |
|
9120 |
+ if (el.staticClass) { |
|
9121 |
+ data += "staticClass:" + (el.staticClass) + ","; |
|
9122 |
+ } |
|
9123 |
+ if (el.classBinding) { |
|
9124 |
+ data += "class:" + (el.classBinding) + ","; |
|
9125 |
+ } |
|
9126 |
+ return data |
|
9127 |
+} |
|
9128 |
+ |
|
9129 |
+var klass$1 = { |
|
9130 |
+ staticKeys: ['staticClass'], |
|
9131 |
+ transformNode: transformNode, |
|
9132 |
+ genData: genData$1 |
|
9133 |
+}; |
|
9134 |
+ |
|
9135 |
+/* */ |
|
9136 |
+ |
|
9137 |
+function transformNode$1 (el, options) { |
|
9138 |
+ var warn = options.warn || baseWarn; |
|
9139 |
+ var staticStyle = getAndRemoveAttr(el, 'style'); |
|
9140 |
+ if (staticStyle) { |
|
9141 |
+ /* istanbul ignore if */ |
|
9142 |
+ { |
|
9143 |
+ var expression = parseText(staticStyle, options.delimiters); |
|
9144 |
+ if (expression) { |
|
9145 |
+ warn( |
|
9146 |
+ "style=\"" + staticStyle + "\": " + |
|
9147 |
+ 'Interpolation inside attributes has been removed. ' + |
|
9148 |
+ 'Use v-bind or the colon shorthand instead. For example, ' + |
|
9149 |
+ 'instead of <div style="{{ val }}">, use <div :style="val">.' |
|
9150 |
+ ); |
|
9151 |
+ } |
|
9152 |
+ } |
|
9153 |
+ el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); |
|
9154 |
+ } |
|
9155 |
+ |
|
9156 |
+ var styleBinding = getBindingAttr(el, 'style', false /* getStatic */); |
|
9157 |
+ if (styleBinding) { |
|
9158 |
+ el.styleBinding = styleBinding; |
|
9159 |
+ } |
|
9160 |
+} |
|
9161 |
+ |
|
9162 |
+function genData$2 (el) { |
|
9163 |
+ var data = ''; |
|
9164 |
+ if (el.staticStyle) { |
|
9165 |
+ data += "staticStyle:" + (el.staticStyle) + ","; |
|
9166 |
+ } |
|
9167 |
+ if (el.styleBinding) { |
|
9168 |
+ data += "style:(" + (el.styleBinding) + "),"; |
|
9169 |
+ } |
|
9170 |
+ return data |
|
9171 |
+} |
|
9172 |
+ |
|
9173 |
+var style$1 = { |
|
9174 |
+ staticKeys: ['staticStyle'], |
|
9175 |
+ transformNode: transformNode$1, |
|
9176 |
+ genData: genData$2 |
|
9177 |
+}; |
|
9178 |
+ |
|
9179 |
+var modules$1 = [ |
|
9180 |
+ klass$1, |
|
9181 |
+ style$1 |
|
9182 |
+]; |
|
9183 |
+ |
|
9184 |
+/* */ |
|
9185 |
+ |
|
9186 |
+function text (el, dir) { |
|
9187 |
+ if (dir.value) { |
|
9188 |
+ addProp(el, 'textContent', ("_s(" + (dir.value) + ")")); |
|
9189 |
+ } |
|
9190 |
+} |
|
9191 |
+ |
|
9192 |
+/* */ |
|
9193 |
+ |
|
9194 |
+function html (el, dir) { |
|
9195 |
+ if (dir.value) { |
|
9196 |
+ addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")")); |
|
9197 |
+ } |
|
9198 |
+} |
|
9199 |
+ |
|
9200 |
+var directives$1 = { |
|
9201 |
+ model: model, |
|
9202 |
+ text: text, |
|
9203 |
+ html: html |
|
9204 |
+}; |
|
9205 |
+ |
|
9206 |
+/* */ |
|
9207 |
+ |
|
9208 |
+var baseOptions = { |
|
9209 |
+ expectHTML: true, |
|
9210 |
+ modules: modules$1, |
|
9211 |
+ directives: directives$1, |
|
9212 |
+ isPreTag: isPreTag, |
|
9213 |
+ isUnaryTag: isUnaryTag, |
|
9214 |
+ mustUseProp: mustUseProp, |
|
9215 |
+ canBeLeftOpenTag: canBeLeftOpenTag, |
|
9216 |
+ isReservedTag: isReservedTag, |
|
9217 |
+ getTagNamespace: getTagNamespace, |
|
9218 |
+ staticKeys: genStaticKeys(modules$1) |
|
9219 |
+}; |
|
9220 |
+ |
|
9221 |
+var ref$1 = createCompiler(baseOptions); |
|
9222 |
+var compileToFunctions = ref$1.compileToFunctions; |
|
9223 |
+ |
|
9224 |
+/* */ |
|
9225 |
+ |
|
9226 |
+var idToTemplate = cached(function (id) { |
|
9227 |
+ var el = query(id); |
|
9228 |
+ return el && el.innerHTML |
|
9229 |
+}); |
|
9230 |
+ |
|
9231 |
+var mount = Vue$3.prototype.$mount; |
|
9232 |
+Vue$3.prototype.$mount = function ( |
|
9233 |
+ el, |
|
9234 |
+ hydrating |
|
9235 |
+) { |
|
9236 |
+ el = el && query(el); |
|
9237 |
+ |
|
9238 |
+ /* istanbul ignore if */ |
|
9239 |
+ if (el === document.body || el === document.documentElement) { |
|
9240 |
+ "development" !== 'production' && warn( |
|
9241 |
+ "Do not mount Vue to <html> or <body> - mount to normal elements instead." |
|
9242 |
+ ); |
|
9243 |
+ return this |
|
9244 |
+ } |
|
9245 |
+ |
|
9246 |
+ var options = this.$options; |
|
9247 |
+ // resolve template/el and convert to render function |
|
9248 |
+ if (!options.render) { |
|
9249 |
+ var template = options.template; |
|
9250 |
+ if (template) { |
|
9251 |
+ if (typeof template === 'string') { |
|
9252 |
+ if (template.charAt(0) === '#') { |
|
9253 |
+ template = idToTemplate(template); |
|
9254 |
+ /* istanbul ignore if */ |
|
9255 |
+ if ("development" !== 'production' && !template) { |
|
9256 |
+ warn( |
|
9257 |
+ ("Template element not found or is empty: " + (options.template)), |
|
9258 |
+ this |
|
9259 |
+ ); |
|
9260 |
+ } |
|
9261 |
+ } |
|
9262 |
+ } else if (template.nodeType) { |
|
9263 |
+ template = template.innerHTML; |
|
9264 |
+ } else { |
|
9265 |
+ { |
|
9266 |
+ warn('invalid template option:' + template, this); |
|
9267 |
+ } |
|
9268 |
+ return this |
|
9269 |
+ } |
|
9270 |
+ } else if (el) { |
|
9271 |
+ template = getOuterHTML(el); |
|
9272 |
+ } |
|
9273 |
+ if (template) { |
|
9274 |
+ /* istanbul ignore if */ |
|
9275 |
+ if ("development" !== 'production' && config.performance && mark) { |
|
9276 |
+ mark('compile'); |
|
9277 |
+ } |
|
9278 |
+ |
|
9279 |
+ var ref = compileToFunctions(template, { |
|
9280 |
+ shouldDecodeNewlines: shouldDecodeNewlines, |
|
9281 |
+ delimiters: options.delimiters |
|
9282 |
+ }, this); |
|
9283 |
+ var render = ref.render; |
|
9284 |
+ var staticRenderFns = ref.staticRenderFns; |
|
9285 |
+ options.render = render; |
|
9286 |
+ options.staticRenderFns = staticRenderFns; |
|
9287 |
+ |
|
9288 |
+ /* istanbul ignore if */ |
|
9289 |
+ if ("development" !== 'production' && config.performance && mark) { |
|
9290 |
+ mark('compile end'); |
|
9291 |
+ measure(((this._name) + " compile"), 'compile', 'compile end'); |
|
9292 |
+ } |
|
9293 |
+ } |
|
9294 |
+ } |
|
9295 |
+ return mount.call(this, el, hydrating) |
|
9296 |
+}; |
|
9297 |
+ |
|
9298 |
+/** |
|
9299 |
+ * Get outerHTML of elements, taking care |
|
9300 |
+ * of SVG elements in IE as well. |
|
9301 |
+ */ |
|
9302 |
+function getOuterHTML (el) { |
|
9303 |
+ if (el.outerHTML) { |
|
9304 |
+ return el.outerHTML |
|
9305 |
+ } else { |
|
9306 |
+ var container = document.createElement('div'); |
|
9307 |
+ container.appendChild(el.cloneNode(true)); |
|
9308 |
+ return container.innerHTML |
|
9309 |
+ } |
|
9310 |
+} |
|
9311 |
+ |
|
9312 |
+Vue$3.compile = compileToFunctions; |
|
9313 |
+ |
|
9314 |
+return Vue$3; |
|
9315 |
+ |
|
9316 |
+}))); |
@@ -3,6 +3,7 @@ var relay_status = [ 1, 1, 1, 1] |
||
3 | 3 |
|
4 | 4 |
module.exports.start = function(router, channel){ |
5 | 5 |
logger.info("Starting Relay controller module"); |
6 |
+ |
|
6 | 7 |
router.post('/switch_relay', function (req, res) { |
7 | 8 |
logger.info("Received request for switching relays", req.body); |
8 | 9 |
channel.emit('news', { hello: 'again' }); |
@@ -1,4 +1,4 @@ |
||
1 |
-<main class="bd-masthead" id="content" role="main"> |
|
1 |
+<main id="app" class="bd-masthead" id="content" role="main"> |
|
2 | 2 |
<div class="container navbar-shift spacer-md"> |
3 | 3 |
|
4 | 4 |
<div class="dashhead"> |
@@ -12,75 +12,113 @@ |
||
12 | 12 |
</div> |
13 | 13 |
<hr class="dashhead-line"> |
14 | 14 |
<div class="row spacer-sm"> |
15 |
- <div class="col-sm-3"> |
|
16 |
- <div class="statcard statcard-success"> |
|
17 |
- <i class="fa fa-microchip icon-header" aria-hidden="true"></i> |
|
18 |
- <h3 class="statcard-number">ON</h3> |
|
19 |
- <span class="statcard-title">Raspberry Pi</span> |
|
15 |
+ <div class="col-sm-4"> |
|
16 |
+ <div class="statcard statcard-divided"> |
|
17 |
+ <div class="statcard-header"> |
|
18 |
+ <i class="fa fa-microchip icon-header" aria-hidden="true"></i> |
|
19 |
+ <h3 class="statcard-number">ACTIVE</h3> |
|
20 |
+ <span class="statcard-title">Automation Server</span> |
|
21 |
+ </div> |
|
22 |
+ <div class="statcard-content"> |
|
23 |
+ <dl class="row"> |
|
24 |
+ <dt class="col-sm-3">CPU</dt> |
|
25 |
+ <dd class="col-sm-9">45%</dd> |
|
26 |
+ <dt class="col-sm-3">RAM</dt> |
|
27 |
+ <dd class="col-sm-9">560M of 1024M</dd> |
|
28 |
+ <dt class="col-sm-3 text-truncate">Disk</dt> |
|
29 |
+ <dd class="col-sm-9">13.5Gb of 100Gb</dd> |
|
30 |
+ </dl> |
|
31 |
+ <div class="row spacer-sm"> |
|
32 |
+ <div class="col-12"> |
|
33 |
+ <button type="button" class="btn btn-outline-secondary btn-sm btn-block disabled"><i class="fa fa-refresh" aria-hidden="true"></i> Reboot Server</button> |
|
34 |
+ </div> |
|
35 |
+ </div> |
|
36 |
+ </div> |
|
20 | 37 |
</div> |
21 | 38 |
</div> |
22 |
- <div class="col-sm-3"> |
|
23 |
- <div class="statcard"> |
|
24 |
- <i class="fa fa-lightbulb-o icon-header" aria-hidden="true"></i> |
|
25 |
- <h3 class="statcard-number">OFF</h3> |
|
26 |
- <span class="statcard-title">Light</span> |
|
39 |
+ <div class="col-sm-4"> |
|
40 |
+ <div class="statcard statcard-divided"> |
|
41 |
+ <div class="statcard-header"> |
|
42 |
+ <i class="fa fa-wifi icon-header" aria-hidden="true"></i> |
|
43 |
+ <h3 class="statcard-number">ACTIVE</h3> |
|
44 |
+ <span class="statcard-title">Wifi Routers</span> |
|
45 |
+ </div> |
|
46 |
+ <div class="statcard-content"> |
|
47 |
+ <dl class="row"> |
|
48 |
+ <dt class="col-sm-8">Number of devices</dt> |
|
49 |
+ <dd class="col-sm-4">2</dd> |
|
50 |
+ <dt class="col-sm-8">Router Main</dt> |
|
51 |
+ <dd class="col-sm-4">OK</dd> |
|
52 |
+ <dt class="col-sm-8 text-truncate">Repeater 1</dt> |
|
53 |
+ <dd class="col-sm-4">OK</dd> |
|
54 |
+ </dl> |
|
55 |
+ <div class="row spacer-sm"> |
|
56 |
+ <div class="col-6"> |
|
57 |
+ <button type="button" class="btn btn-outline-secondary btn-sm btn-block disabled"><i class="fa fa-refresh" aria-hidden="true"></i> Main Router</button> |
|
58 |
+ </div> |
|
59 |
+ <div class="col-6"> |
|
60 |
+ <button type="button" class="btn btn-outline-secondary btn-sm btn-block disabled"><i class="fa fa-refresh" aria-hidden="true"></i> Repeater 1</button> |
|
61 |
+ </div> |
|
62 |
+ </div> |
|
63 |
+ </div> |
|
27 | 64 |
</div> |
28 | 65 |
</div> |
29 |
- <div class="col-sm-3"> |
|
30 |
- <div class="statcard statcard-success"> |
|
31 |
- <i class="fa fa-plug icon-header" aria-hidden="true"></i> |
|
32 |
- <h3 class="statcard-number">ON</h3> |
|
33 |
- <span class="statcard-title">Satelite</span> |
|
66 |
+ <div class="col-sm-4"> |
|
67 |
+ <div class="statcard statcard-divided"> |
|
68 |
+ <div class="statcard-header"> |
|
69 |
+ <i class="fa fa-wifi icon-header" aria-hidden="true"></i> |
|
70 |
+ <h3 class="statcard-number">ACTIVE</h3> |
|
71 |
+ <span class="statcard-title">Sattelite Connection</span> |
|
72 |
+ </div> |
|
73 |
+ <div class="statcard-content"> |
|
74 |
+ <dl class="row"> |
|
75 |
+ <dt class="col-sm-8">Connection Status</dt> |
|
76 |
+ <dd class="col-sm-4">Operacional</dd> |
|
77 |
+ <dt class="col-sm-8">Bandwith (day)</dt> |
|
78 |
+ <dd class="col-sm-4">0%</dd> |
|
79 |
+ <dt class="col-sm-8 text-truncate">Bandwith (night)</dt> |
|
80 |
+ <dd class="col-sm-4">15%</dd> |
|
81 |
+ </dl> |
|
82 |
+ <div class="row spacer-sm"> |
|
83 |
+ <div class="col-12"> |
|
84 |
+ <button type="button" class="btn btn-outline-secondary btn-sm btn-block disabled"><i class="fa fa-refresh" aria-hidden="true"></i> Reconect</button> |
|
85 |
+ </div> |
|
86 |
+ </div> |
|
87 |
+ </div> |
|
34 | 88 |
</div> |
35 | 89 |
</div> |
36 |
- <div class="col-sm-3"> |
|
37 |
- <div class="statcard statcard-success"> |
|
38 |
- <i class="fa fa-plug icon-header" aria-hidden="true"></i> |
|
39 |
- <h3 class="statcard-number">ON</h3> |
|
40 |
- <span class="statcard-title">WIFI Router</span> |
|
90 |
+ </div> |
|
91 |
+ <div class="row spacer-sm"> |
|
92 |
+ <div class="col-sm-4"> |
|
93 |
+ <div class="statcard"> |
|
94 |
+ <i class="fa fa-lightbulb-o icon-header" aria-hidden="true"></i> |
|
95 |
+ <button type="button" class="btn btn-outline-secondary " style="float: right; margin-top: 2px;">Turn On</button> |
|
96 |
+ <h3 class="statcard-number">OFF</h3> |
|
97 |
+ <span class="statcard-title">Light</span> |
|
98 |
+ |
|
41 | 99 |
</div> |
42 | 100 |
</div> |
43 |
- <div class="col-sm-3"> |
|
101 |
+ <div class="col-sm-4"> |
|
44 | 102 |
<div class="statcard"> |
45 | 103 |
<i class="fa fa-thermometer-quarter icon-header" aria-hidden="true"></i> |
46 |
- <h3 class="statcard-number">15ºC</h3> |
|
47 |
- <span class="statcard-title">External Temp.</span> |
|
104 |
+ <h3 class="statcard-number">{{temperature_external}}</h3> |
|
105 |
+ <span class="statcard-title">External Temperature</span> |
|
48 | 106 |
</div> |
49 | 107 |
</div> |
50 |
- <div class="col-sm-3"> |
|
108 |
+ <!-- <div class="col-sm-4"> |
|
51 | 109 |
<div class="statcard "> |
52 | 110 |
<i class="fa fa-thermometer-half icon-header" aria-hidden="true"></i> |
53 | 111 |
<h3 class="statcard-number">24ºC</h3> |
54 | 112 |
<span class="statcard-title">Internal Temp.</span> |
55 | 113 |
</div> |
56 | 114 |
</div> |
57 |
- <div class="col-sm-3"> |
|
115 |
+ <div class="col-sm-4"> |
|
58 | 116 |
<div class="statcard "> |
59 | 117 |
<i class="fa fa-tint icon-header" aria-hidden="true"></i> |
60 | 118 |
<h3 class="statcard-number">60%</h3> |
61 | 119 |
<span class="statcard-title">Humidity</span> |
62 | 120 |
</div> |
63 |
- </div> |
|
64 |
- </div> |
|
65 |
- <div class="row spacer-sm"> |
|
66 |
- <div class="col-sm-6"> |
|
67 |
- <div class="card"> |
|
68 |
- <div class="card-body"> |
|
69 |
- <h4 class="card-title">Special title treatment</h4> |
|
70 |
- <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> |
|
71 |
- <a href="#" class="btn btn-primary">Go somewhere</a> |
|
72 |
- </div> |
|
73 |
- </div> |
|
74 |
- </div> |
|
75 |
- <div class="col-sm-6"> |
|
76 |
- <div class="card"> |
|
77 |
- <div class="card-body"> |
|
78 |
- <h4 class="card-title">Special title treatment</h4> |
|
79 |
- <p class="card-text">With supporting text below as a natural lead-in to additional content.</p> |
|
80 |
- <a href="#" class="btn btn-primary">Go somewhere</a> |
|
81 |
- </div> |
|
82 |
- </div> |
|
83 |
- </div> |
|
121 |
+ </div> --> |
|
84 | 122 |
</div> |
85 | 123 |
</div> |
86 | 124 |
|
@@ -89,8 +127,22 @@ |
||
89 | 127 |
<script src="/socket.io/socket.io.js"></script> |
90 | 128 |
<script> |
91 | 129 |
var socket = io.connect('http://localhost:3100/'); |
92 |
- socket.on('news', function (data) { |
|
93 |
- console.log(data); |
|
94 |
- socket.emit('my other event', { my: 'data' }); |
|
130 |
+ |
|
131 |
+ var app = new Vue({ |
|
132 |
+ el: "#app", |
|
133 |
+ data: { |
|
134 |
+ temperature_external: "--", |
|
135 |
+ }, |
|
136 |
+ methods: { |
|
137 |
+ example: function(example_var){ |
|
138 |
+ app.example(); |
|
139 |
+ } |
|
140 |
+ } |
|
141 |
+ }) |
|
142 |
+ |
|
143 |
+ socket.on('temperature_external', function (data) { |
|
144 |
+ var temp = Math.round( data.temperature * 10 ) / 10; |
|
145 |
+ app.temperature_external = temp + "ºC"; |
|
95 | 146 |
}); |
147 |
+ |
|
96 | 148 |
</script> |
@@ -24,6 +24,8 @@ |
||
24 | 24 |
<link rel="apple-touch-icon" href="/apple-touch-icon.png"> |
25 | 25 |
<link rel="icon" href="/favicon.ico"> |
26 | 26 |
|
27 |
+ <script src="/vue@2.2.6.js"></script> |
|
28 |
+ |
|
27 | 29 |
</head> |
28 | 30 |
|
29 | 31 |
<body class="bd-home" data-gr-c-s-loaded="true"> |
@@ -55,6 +57,7 @@ |
||
55 | 57 |
<%- body %> |
56 | 58 |
|
57 | 59 |
|
60 |
+ |
|
58 | 61 |
<script src="/bootstrap-4.0.0-beta/js/vendor/jquery-slim.min.js"></script> |
59 | 62 |
<script src="/bootstrap-4.0.0-beta/js/vendor/popper.min.js"></script> |
60 | 63 |
|