... | ... |
@@ -1,3 +1,4 @@ |
1 |
+<?php include_once "config.php"; ?> |
|
1 | 2 |
<!DOCTYPE html> |
2 | 3 |
<html> |
3 | 4 |
<head> |
... | ... |
@@ -26,7 +27,11 @@ |
26 | 27 |
</transition-group> |
27 | 28 |
</main> |
28 | 29 |
<footer class="o-container o-container--xsmall u-pillar-box--xsmall u-xsmall">Discussion powered by <a href="https://github.com/devnewton/taab">taab</a></footer> |
29 |
- <script src="js/vue.js" defer></script> |
|
30 |
+ <?php if (TAAB_DEV): ?> |
|
31 |
+ <script src="js/vue-dev.js" defer></script> |
|
32 |
+ <?php else: ?> |
|
33 |
+ <script src="js/vue.js" defer></script> |
|
34 |
+ <?php endif; ?> |
|
30 | 35 |
<script src="js/peg-0.10.0.js" defer></script> |
31 | 36 |
<script id="taab-backend2html" type="text/peg"> |
32 | 37 |
<?php readfile("peg/backend2html.pegjs") ?> |
33 | 38 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,10798 @@ |
1 |
+/*! |
|
2 |
+ * Vue.js v2.5.13 |
|
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 |
+var emptyObject = Object.freeze({}); |
|
15 |
+ |
|
16 |
+// these helpers produces better vm code in JS engines due to their |
|
17 |
+// explicitness and function inlining |
|
18 |
+function isUndef (v) { |
|
19 |
+ return v === undefined || v === null |
|
20 |
+} |
|
21 |
+ |
|
22 |
+function isDef (v) { |
|
23 |
+ return v !== undefined && v !== null |
|
24 |
+} |
|
25 |
+ |
|
26 |
+function isTrue (v) { |
|
27 |
+ return v === true |
|
28 |
+} |
|
29 |
+ |
|
30 |
+function isFalse (v) { |
|
31 |
+ return v === false |
|
32 |
+} |
|
33 |
+ |
|
34 |
+/** |
|
35 |
+ * Check if value is primitive |
|
36 |
+ */ |
|
37 |
+function isPrimitive (value) { |
|
38 |
+ return ( |
|
39 |
+ typeof value === 'string' || |
|
40 |
+ typeof value === 'number' || |
|
41 |
+ // $flow-disable-line |
|
42 |
+ typeof value === 'symbol' || |
|
43 |
+ typeof value === 'boolean' |
|
44 |
+ ) |
|
45 |
+} |
|
46 |
+ |
|
47 |
+/** |
|
48 |
+ * Quick object check - this is primarily used to tell |
|
49 |
+ * Objects from primitive values when we know the value |
|
50 |
+ * is a JSON-compliant type. |
|
51 |
+ */ |
|
52 |
+function isObject (obj) { |
|
53 |
+ return obj !== null && typeof obj === 'object' |
|
54 |
+} |
|
55 |
+ |
|
56 |
+/** |
|
57 |
+ * Get the raw type string of a value e.g. [object Object] |
|
58 |
+ */ |
|
59 |
+var _toString = Object.prototype.toString; |
|
60 |
+ |
|
61 |
+function toRawType (value) { |
|
62 |
+ return _toString.call(value).slice(8, -1) |
|
63 |
+} |
|
64 |
+ |
|
65 |
+/** |
|
66 |
+ * Strict object type check. Only returns true |
|
67 |
+ * for plain JavaScript objects. |
|
68 |
+ */ |
|
69 |
+function isPlainObject (obj) { |
|
70 |
+ return _toString.call(obj) === '[object Object]' |
|
71 |
+} |
|
72 |
+ |
|
73 |
+function isRegExp (v) { |
|
74 |
+ return _toString.call(v) === '[object RegExp]' |
|
75 |
+} |
|
76 |
+ |
|
77 |
+/** |
|
78 |
+ * Check if val is a valid array index. |
|
79 |
+ */ |
|
80 |
+function isValidArrayIndex (val) { |
|
81 |
+ var n = parseFloat(String(val)); |
|
82 |
+ return n >= 0 && Math.floor(n) === n && isFinite(val) |
|
83 |
+} |
|
84 |
+ |
|
85 |
+/** |
|
86 |
+ * Convert a value to a string that is actually rendered. |
|
87 |
+ */ |
|
88 |
+function toString (val) { |
|
89 |
+ return val == null |
|
90 |
+ ? '' |
|
91 |
+ : typeof val === 'object' |
|
92 |
+ ? JSON.stringify(val, null, 2) |
|
93 |
+ : String(val) |
|
94 |
+} |
|
95 |
+ |
|
96 |
+/** |
|
97 |
+ * Convert a input value to a number for persistence. |
|
98 |
+ * If the conversion fails, return original string. |
|
99 |
+ */ |
|
100 |
+function toNumber (val) { |
|
101 |
+ var n = parseFloat(val); |
|
102 |
+ return isNaN(n) ? val : n |
|
103 |
+} |
|
104 |
+ |
|
105 |
+/** |
|
106 |
+ * Make a map and return a function for checking if a key |
|
107 |
+ * is in that map. |
|
108 |
+ */ |
|
109 |
+function makeMap ( |
|
110 |
+ str, |
|
111 |
+ expectsLowerCase |
|
112 |
+) { |
|
113 |
+ var map = Object.create(null); |
|
114 |
+ var list = str.split(','); |
|
115 |
+ for (var i = 0; i < list.length; i++) { |
|
116 |
+ map[list[i]] = true; |
|
117 |
+ } |
|
118 |
+ return expectsLowerCase |
|
119 |
+ ? function (val) { return map[val.toLowerCase()]; } |
|
120 |
+ : function (val) { return map[val]; } |
|
121 |
+} |
|
122 |
+ |
|
123 |
+/** |
|
124 |
+ * Check if a tag is a built-in tag. |
|
125 |
+ */ |
|
126 |
+var isBuiltInTag = makeMap('slot,component', true); |
|
127 |
+ |
|
128 |
+/** |
|
129 |
+ * Check if a attribute is a reserved attribute. |
|
130 |
+ */ |
|
131 |
+var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is'); |
|
132 |
+ |
|
133 |
+/** |
|
134 |
+ * Remove an item from an array |
|
135 |
+ */ |
|
136 |
+function remove (arr, item) { |
|
137 |
+ if (arr.length) { |
|
138 |
+ var index = arr.indexOf(item); |
|
139 |
+ if (index > -1) { |
|
140 |
+ return arr.splice(index, 1) |
|
141 |
+ } |
|
142 |
+ } |
|
143 |
+} |
|
144 |
+ |
|
145 |
+/** |
|
146 |
+ * Check whether the object has the property. |
|
147 |
+ */ |
|
148 |
+var hasOwnProperty = Object.prototype.hasOwnProperty; |
|
149 |
+function hasOwn (obj, key) { |
|
150 |
+ return hasOwnProperty.call(obj, key) |
|
151 |
+} |
|
152 |
+ |
|
153 |
+/** |
|
154 |
+ * Create a cached version of a pure function. |
|
155 |
+ */ |
|
156 |
+function cached (fn) { |
|
157 |
+ var cache = Object.create(null); |
|
158 |
+ return (function cachedFn (str) { |
|
159 |
+ var hit = cache[str]; |
|
160 |
+ return hit || (cache[str] = fn(str)) |
|
161 |
+ }) |
|
162 |
+} |
|
163 |
+ |
|
164 |
+/** |
|
165 |
+ * Camelize a hyphen-delimited string. |
|
166 |
+ */ |
|
167 |
+var camelizeRE = /-(\w)/g; |
|
168 |
+var camelize = cached(function (str) { |
|
169 |
+ return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) |
|
170 |
+}); |
|
171 |
+ |
|
172 |
+/** |
|
173 |
+ * Capitalize a string. |
|
174 |
+ */ |
|
175 |
+var capitalize = cached(function (str) { |
|
176 |
+ return str.charAt(0).toUpperCase() + str.slice(1) |
|
177 |
+}); |
|
178 |
+ |
|
179 |
+/** |
|
180 |
+ * Hyphenate a camelCase string. |
|
181 |
+ */ |
|
182 |
+var hyphenateRE = /\B([A-Z])/g; |
|
183 |
+var hyphenate = cached(function (str) { |
|
184 |
+ return str.replace(hyphenateRE, '-$1').toLowerCase() |
|
185 |
+}); |
|
186 |
+ |
|
187 |
+/** |
|
188 |
+ * Simple bind, faster than native |
|
189 |
+ */ |
|
190 |
+function bind (fn, ctx) { |
|
191 |
+ function boundFn (a) { |
|
192 |
+ var l = arguments.length; |
|
193 |
+ return l |
|
194 |
+ ? l > 1 |
|
195 |
+ ? fn.apply(ctx, arguments) |
|
196 |
+ : fn.call(ctx, a) |
|
197 |
+ : fn.call(ctx) |
|
198 |
+ } |
|
199 |
+ // record original fn length |
|
200 |
+ boundFn._length = fn.length; |
|
201 |
+ return boundFn |
|
202 |
+} |
|
203 |
+ |
|
204 |
+/** |
|
205 |
+ * Convert an Array-like object to a real Array. |
|
206 |
+ */ |
|
207 |
+function toArray (list, start) { |
|
208 |
+ start = start || 0; |
|
209 |
+ var i = list.length - start; |
|
210 |
+ var ret = new Array(i); |
|
211 |
+ while (i--) { |
|
212 |
+ ret[i] = list[i + start]; |
|
213 |
+ } |
|
214 |
+ return ret |
|
215 |
+} |
|
216 |
+ |
|
217 |
+/** |
|
218 |
+ * Mix properties into target object. |
|
219 |
+ */ |
|
220 |
+function extend (to, _from) { |
|
221 |
+ for (var key in _from) { |
|
222 |
+ to[key] = _from[key]; |
|
223 |
+ } |
|
224 |
+ return to |
|
225 |
+} |
|
226 |
+ |
|
227 |
+/** |
|
228 |
+ * Merge an Array of Objects into a single Object. |
|
229 |
+ */ |
|
230 |
+function toObject (arr) { |
|
231 |
+ var res = {}; |
|
232 |
+ for (var i = 0; i < arr.length; i++) { |
|
233 |
+ if (arr[i]) { |
|
234 |
+ extend(res, arr[i]); |
|
235 |
+ } |
|
236 |
+ } |
|
237 |
+ return res |
|
238 |
+} |
|
239 |
+ |
|
240 |
+/** |
|
241 |
+ * Perform no operation. |
|
242 |
+ * Stubbing args to make Flow happy without leaving useless transpiled code |
|
243 |
+ * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/) |
|
244 |
+ */ |
|
245 |
+function noop (a, b, c) {} |
|
246 |
+ |
|
247 |
+/** |
|
248 |
+ * Always return false. |
|
249 |
+ */ |
|
250 |
+var no = function (a, b, c) { return false; }; |
|
251 |
+ |
|
252 |
+/** |
|
253 |
+ * Return same value |
|
254 |
+ */ |
|
255 |
+var identity = function (_) { return _; }; |
|
256 |
+ |
|
257 |
+/** |
|
258 |
+ * Generate a static keys string from compiler modules. |
|
259 |
+ */ |
|
260 |
+function genStaticKeys (modules) { |
|
261 |
+ return modules.reduce(function (keys, m) { |
|
262 |
+ return keys.concat(m.staticKeys || []) |
|
263 |
+ }, []).join(',') |
|
264 |
+} |
|
265 |
+ |
|
266 |
+/** |
|
267 |
+ * Check if two values are loosely equal - that is, |
|
268 |
+ * if they are plain objects, do they have the same shape? |
|
269 |
+ */ |
|
270 |
+function looseEqual (a, b) { |
|
271 |
+ if (a === b) { return true } |
|
272 |
+ var isObjectA = isObject(a); |
|
273 |
+ var isObjectB = isObject(b); |
|
274 |
+ if (isObjectA && isObjectB) { |
|
275 |
+ try { |
|
276 |
+ var isArrayA = Array.isArray(a); |
|
277 |
+ var isArrayB = Array.isArray(b); |
|
278 |
+ if (isArrayA && isArrayB) { |
|
279 |
+ return a.length === b.length && a.every(function (e, i) { |
|
280 |
+ return looseEqual(e, b[i]) |
|
281 |
+ }) |
|
282 |
+ } else if (!isArrayA && !isArrayB) { |
|
283 |
+ var keysA = Object.keys(a); |
|
284 |
+ var keysB = Object.keys(b); |
|
285 |
+ return keysA.length === keysB.length && keysA.every(function (key) { |
|
286 |
+ return looseEqual(a[key], b[key]) |
|
287 |
+ }) |
|
288 |
+ } else { |
|
289 |
+ /* istanbul ignore next */ |
|
290 |
+ return false |
|
291 |
+ } |
|
292 |
+ } catch (e) { |
|
293 |
+ /* istanbul ignore next */ |
|
294 |
+ return false |
|
295 |
+ } |
|
296 |
+ } else if (!isObjectA && !isObjectB) { |
|
297 |
+ return String(a) === String(b) |
|
298 |
+ } else { |
|
299 |
+ return false |
|
300 |
+ } |
|
301 |
+} |
|
302 |
+ |
|
303 |
+function looseIndexOf (arr, val) { |
|
304 |
+ for (var i = 0; i < arr.length; i++) { |
|
305 |
+ if (looseEqual(arr[i], val)) { return i } |
|
306 |
+ } |
|
307 |
+ return -1 |
|
308 |
+} |
|
309 |
+ |
|
310 |
+/** |
|
311 |
+ * Ensure a function is called only once. |
|
312 |
+ */ |
|
313 |
+function once (fn) { |
|
314 |
+ var called = false; |
|
315 |
+ return function () { |
|
316 |
+ if (!called) { |
|
317 |
+ called = true; |
|
318 |
+ fn.apply(this, arguments); |
|
319 |
+ } |
|
320 |
+ } |
|
321 |
+} |
|
322 |
+ |
|
323 |
+var SSR_ATTR = 'data-server-rendered'; |
|
324 |
+ |
|
325 |
+var ASSET_TYPES = [ |
|
326 |
+ 'component', |
|
327 |
+ 'directive', |
|
328 |
+ 'filter' |
|
329 |
+]; |
|
330 |
+ |
|
331 |
+var LIFECYCLE_HOOKS = [ |
|
332 |
+ 'beforeCreate', |
|
333 |
+ 'created', |
|
334 |
+ 'beforeMount', |
|
335 |
+ 'mounted', |
|
336 |
+ 'beforeUpdate', |
|
337 |
+ 'updated', |
|
338 |
+ 'beforeDestroy', |
|
339 |
+ 'destroyed', |
|
340 |
+ 'activated', |
|
341 |
+ 'deactivated', |
|
342 |
+ 'errorCaptured' |
|
343 |
+]; |
|
344 |
+ |
|
345 |
+/* */ |
|
346 |
+ |
|
347 |
+var config = ({ |
|
348 |
+ /** |
|
349 |
+ * Option merge strategies (used in core/util/options) |
|
350 |
+ */ |
|
351 |
+ // $flow-disable-line |
|
352 |
+ optionMergeStrategies: Object.create(null), |
|
353 |
+ |
|
354 |
+ /** |
|
355 |
+ * Whether to suppress warnings. |
|
356 |
+ */ |
|
357 |
+ silent: false, |
|
358 |
+ |
|
359 |
+ /** |
|
360 |
+ * Show production mode tip message on boot? |
|
361 |
+ */ |
|
362 |
+ productionTip: "development" !== 'production', |
|
363 |
+ |
|
364 |
+ /** |
|
365 |
+ * Whether to enable devtools |
|
366 |
+ */ |
|
367 |
+ devtools: "development" !== 'production', |
|
368 |
+ |
|
369 |
+ /** |
|
370 |
+ * Whether to record perf |
|
371 |
+ */ |
|
372 |
+ performance: false, |
|
373 |
+ |
|
374 |
+ /** |
|
375 |
+ * Error handler for watcher errors |
|
376 |
+ */ |
|
377 |
+ errorHandler: null, |
|
378 |
+ |
|
379 |
+ /** |
|
380 |
+ * Warn handler for watcher warns |
|
381 |
+ */ |
|
382 |
+ warnHandler: null, |
|
383 |
+ |
|
384 |
+ /** |
|
385 |
+ * Ignore certain custom elements |
|
386 |
+ */ |
|
387 |
+ ignoredElements: [], |
|
388 |
+ |
|
389 |
+ /** |
|
390 |
+ * Custom user key aliases for v-on |
|
391 |
+ */ |
|
392 |
+ // $flow-disable-line |
|
393 |
+ keyCodes: Object.create(null), |
|
394 |
+ |
|
395 |
+ /** |
|
396 |
+ * Check if a tag is reserved so that it cannot be registered as a |
|
397 |
+ * component. This is platform-dependent and may be overwritten. |
|
398 |
+ */ |
|
399 |
+ isReservedTag: no, |
|
400 |
+ |
|
401 |
+ /** |
|
402 |
+ * Check if an attribute is reserved so that it cannot be used as a component |
|
403 |
+ * prop. This is platform-dependent and may be overwritten. |
|
404 |
+ */ |
|
405 |
+ isReservedAttr: no, |
|
406 |
+ |
|
407 |
+ /** |
|
408 |
+ * Check if a tag is an unknown element. |
|
409 |
+ * Platform-dependent. |
|
410 |
+ */ |
|
411 |
+ isUnknownElement: no, |
|
412 |
+ |
|
413 |
+ /** |
|
414 |
+ * Get the namespace of an element |
|
415 |
+ */ |
|
416 |
+ getTagNamespace: noop, |
|
417 |
+ |
|
418 |
+ /** |
|
419 |
+ * Parse the real tag name for the specific platform. |
|
420 |
+ */ |
|
421 |
+ parsePlatformTagName: identity, |
|
422 |
+ |
|
423 |
+ /** |
|
424 |
+ * Check if an attribute must be bound using property, e.g. value |
|
425 |
+ * Platform-dependent. |
|
426 |
+ */ |
|
427 |
+ mustUseProp: no, |
|
428 |
+ |
|
429 |
+ /** |
|
430 |
+ * Exposed for legacy reasons |
|
431 |
+ */ |
|
432 |
+ _lifecycleHooks: LIFECYCLE_HOOKS |
|
433 |
+}); |
|
434 |
+ |
|
435 |
+/* */ |
|
436 |
+ |
|
437 |
+/** |
|
438 |
+ * Check if a string starts with $ or _ |
|
439 |
+ */ |
|
440 |
+function isReserved (str) { |
|
441 |
+ var c = (str + '').charCodeAt(0); |
|
442 |
+ return c === 0x24 || c === 0x5F |
|
443 |
+} |
|
444 |
+ |
|
445 |
+/** |
|
446 |
+ * Define a property. |
|
447 |
+ */ |
|
448 |
+function def (obj, key, val, enumerable) { |
|
449 |
+ Object.defineProperty(obj, key, { |
|
450 |
+ value: val, |
|
451 |
+ enumerable: !!enumerable, |
|
452 |
+ writable: true, |
|
453 |
+ configurable: true |
|
454 |
+ }); |
|
455 |
+} |
|
456 |
+ |
|
457 |
+/** |
|
458 |
+ * Parse simple path. |
|
459 |
+ */ |
|
460 |
+var bailRE = /[^\w.$]/; |
|
461 |
+function parsePath (path) { |
|
462 |
+ if (bailRE.test(path)) { |
|
463 |
+ return |
|
464 |
+ } |
|
465 |
+ var segments = path.split('.'); |
|
466 |
+ return function (obj) { |
|
467 |
+ for (var i = 0; i < segments.length; i++) { |
|
468 |
+ if (!obj) { return } |
|
469 |
+ obj = obj[segments[i]]; |
|
470 |
+ } |
|
471 |
+ return obj |
|
472 |
+ } |
|
473 |
+} |
|
474 |
+ |
|
475 |
+/* */ |
|
476 |
+ |
|
477 |
+ |
|
478 |
+// can we use __proto__? |
|
479 |
+var hasProto = '__proto__' in {}; |
|
480 |
+ |
|
481 |
+// Browser environment sniffing |
|
482 |
+var inBrowser = typeof window !== 'undefined'; |
|
483 |
+var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform; |
|
484 |
+var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase(); |
|
485 |
+var UA = inBrowser && window.navigator.userAgent.toLowerCase(); |
|
486 |
+var isIE = UA && /msie|trident/.test(UA); |
|
487 |
+var isIE9 = UA && UA.indexOf('msie 9.0') > 0; |
|
488 |
+var isEdge = UA && UA.indexOf('edge/') > 0; |
|
489 |
+var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android'); |
|
490 |
+var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios'); |
|
491 |
+var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; |
|
492 |
+ |
|
493 |
+// Firefox has a "watch" function on Object.prototype... |
|
494 |
+var nativeWatch = ({}).watch; |
|
495 |
+ |
|
496 |
+var supportsPassive = false; |
|
497 |
+if (inBrowser) { |
|
498 |
+ try { |
|
499 |
+ var opts = {}; |
|
500 |
+ Object.defineProperty(opts, 'passive', ({ |
|
501 |
+ get: function get () { |
|
502 |
+ /* istanbul ignore next */ |
|
503 |
+ supportsPassive = true; |
|
504 |
+ } |
|
505 |
+ })); // https://github.com/facebook/flow/issues/285 |
|
506 |
+ window.addEventListener('test-passive', null, opts); |
|
507 |
+ } catch (e) {} |
|
508 |
+} |
|
509 |
+ |
|
510 |
+// this needs to be lazy-evaled because vue may be required before |
|
511 |
+// vue-server-renderer can set VUE_ENV |
|
512 |
+var _isServer; |
|
513 |
+var isServerRendering = function () { |
|
514 |
+ if (_isServer === undefined) { |
|
515 |
+ /* istanbul ignore if */ |
|
516 |
+ if (!inBrowser && typeof global !== 'undefined') { |
|
517 |
+ // detect presence of vue-server-renderer and avoid |
|
518 |
+ // Webpack shimming the process |
|
519 |
+ _isServer = global['process'].env.VUE_ENV === 'server'; |
|
520 |
+ } else { |
|
521 |
+ _isServer = false; |
|
522 |
+ } |
|
523 |
+ } |
|
524 |
+ return _isServer |
|
525 |
+}; |
|
526 |
+ |
|
527 |
+// detect devtools |
|
528 |
+var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; |
|
529 |
+ |
|
530 |
+/* istanbul ignore next */ |
|
531 |
+function isNative (Ctor) { |
|
532 |
+ return typeof Ctor === 'function' && /native code/.test(Ctor.toString()) |
|
533 |
+} |
|
534 |
+ |
|
535 |
+var hasSymbol = |
|
536 |
+ typeof Symbol !== 'undefined' && isNative(Symbol) && |
|
537 |
+ typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); |
|
538 |
+ |
|
539 |
+var _Set; |
|
540 |
+/* istanbul ignore if */ // $flow-disable-line |
|
541 |
+if (typeof Set !== 'undefined' && isNative(Set)) { |
|
542 |
+ // use native Set when available. |
|
543 |
+ _Set = Set; |
|
544 |
+} else { |
|
545 |
+ // a non-standard Set polyfill that only works with primitive keys. |
|
546 |
+ _Set = (function () { |
|
547 |
+ function Set () { |
|
548 |
+ this.set = Object.create(null); |
|
549 |
+ } |
|
550 |
+ Set.prototype.has = function has (key) { |
|
551 |
+ return this.set[key] === true |
|
552 |
+ }; |
|
553 |
+ Set.prototype.add = function add (key) { |
|
554 |
+ this.set[key] = true; |
|
555 |
+ }; |
|
556 |
+ Set.prototype.clear = function clear () { |
|
557 |
+ this.set = Object.create(null); |
|
558 |
+ }; |
|
559 |
+ |
|
560 |
+ return Set; |
|
561 |
+ }()); |
|
562 |
+} |
|
563 |
+ |
|
564 |
+/* */ |
|
565 |
+ |
|
566 |
+var warn = noop; |
|
567 |
+var tip = noop; |
|
568 |
+var generateComponentTrace = (noop); // work around flow check |
|
569 |
+var formatComponentName = (noop); |
|
570 |
+ |
|
571 |
+{ |
|
572 |
+ var hasConsole = typeof console !== 'undefined'; |
|
573 |
+ var classifyRE = /(?:^|[-_])(\w)/g; |
|
574 |
+ var classify = function (str) { return str |
|
575 |
+ .replace(classifyRE, function (c) { return c.toUpperCase(); }) |
|
576 |
+ .replace(/[-_]/g, ''); }; |
|
577 |
+ |
|
578 |
+ warn = function (msg, vm) { |
|
579 |
+ var trace = vm ? generateComponentTrace(vm) : ''; |
|
580 |
+ |
|
581 |
+ if (config.warnHandler) { |
|
582 |
+ config.warnHandler.call(null, msg, vm, trace); |
|
583 |
+ } else if (hasConsole && (!config.silent)) { |
|
584 |
+ console.error(("[Vue warn]: " + msg + trace)); |
|
585 |
+ } |
|
586 |
+ }; |
|
587 |
+ |
|
588 |
+ tip = function (msg, vm) { |
|
589 |
+ if (hasConsole && (!config.silent)) { |
|
590 |
+ console.warn("[Vue tip]: " + msg + ( |
|
591 |
+ vm ? generateComponentTrace(vm) : '' |
|
592 |
+ )); |
|
593 |
+ } |
|
594 |
+ }; |
|
595 |
+ |
|
596 |
+ formatComponentName = function (vm, includeFile) { |
|
597 |
+ if (vm.$root === vm) { |
|
598 |
+ return '<Root>' |
|
599 |
+ } |
|
600 |
+ var options = typeof vm === 'function' && vm.cid != null |
|
601 |
+ ? vm.options |
|
602 |
+ : vm._isVue |
|
603 |
+ ? vm.$options || vm.constructor.options |
|
604 |
+ : vm || {}; |
|
605 |
+ var name = options.name || options._componentTag; |
|
606 |
+ var file = options.__file; |
|
607 |
+ if (!name && file) { |
|
608 |
+ var match = file.match(/([^/\\]+)\.vue$/); |
|
609 |
+ name = match && match[1]; |
|
610 |
+ } |
|
611 |
+ |
|
612 |
+ return ( |
|
613 |
+ (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") + |
|
614 |
+ (file && includeFile !== false ? (" at " + file) : '') |
|
615 |
+ ) |
|
616 |
+ }; |
|
617 |
+ |
|
618 |
+ var repeat = function (str, n) { |
|
619 |
+ var res = ''; |
|
620 |
+ while (n) { |
|
621 |
+ if (n % 2 === 1) { res += str; } |
|
622 |
+ if (n > 1) { str += str; } |
|
623 |
+ n >>= 1; |
|
624 |
+ } |
|
625 |
+ return res |
|
626 |
+ }; |
|
627 |
+ |
|
628 |
+ generateComponentTrace = function (vm) { |
|
629 |
+ if (vm._isVue && vm.$parent) { |
|
630 |
+ var tree = []; |
|
631 |
+ var currentRecursiveSequence = 0; |
|
632 |
+ while (vm) { |
|
633 |
+ if (tree.length > 0) { |
|
634 |
+ var last = tree[tree.length - 1]; |
|
635 |
+ if (last.constructor === vm.constructor) { |
|
636 |
+ currentRecursiveSequence++; |
|
637 |
+ vm = vm.$parent; |
|
638 |
+ continue |
|
639 |
+ } else if (currentRecursiveSequence > 0) { |
|
640 |
+ tree[tree.length - 1] = [last, currentRecursiveSequence]; |
|
641 |
+ currentRecursiveSequence = 0; |
|
642 |
+ } |
|
643 |
+ } |
|
644 |
+ tree.push(vm); |
|
645 |
+ vm = vm.$parent; |
|
646 |
+ } |
|
647 |
+ return '\n\nfound in\n\n' + tree |
|
648 |
+ .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm) |
|
649 |
+ ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)") |
|
650 |
+ : formatComponentName(vm))); }) |
|
651 |
+ .join('\n') |
|
652 |
+ } else { |
|
653 |
+ return ("\n\n(found in " + (formatComponentName(vm)) + ")") |
|
654 |
+ } |
|
655 |
+ }; |
|
656 |
+} |
|
657 |
+ |
|
658 |
+/* */ |
|
659 |
+ |
|
660 |
+ |
|
661 |
+var uid = 0; |
|
662 |
+ |
|
663 |
+/** |
|
664 |
+ * A dep is an observable that can have multiple |
|
665 |
+ * directives subscribing to it. |
|
666 |
+ */ |
|
667 |
+var Dep = function Dep () { |
|
668 |
+ this.id = uid++; |
|
669 |
+ this.subs = []; |
|
670 |
+}; |
|
671 |
+ |
|
672 |
+Dep.prototype.addSub = function addSub (sub) { |
|
673 |
+ this.subs.push(sub); |
|
674 |
+}; |
|
675 |
+ |
|
676 |
+Dep.prototype.removeSub = function removeSub (sub) { |
|
677 |
+ remove(this.subs, sub); |
|
678 |
+}; |
|
679 |
+ |
|
680 |
+Dep.prototype.depend = function depend () { |
|
681 |
+ if (Dep.target) { |
|
682 |
+ Dep.target.addDep(this); |
|
683 |
+ } |
|
684 |
+}; |
|
685 |
+ |
|
686 |
+Dep.prototype.notify = function notify () { |
|
687 |
+ // stabilize the subscriber list first |
|
688 |
+ var subs = this.subs.slice(); |
|
689 |
+ for (var i = 0, l = subs.length; i < l; i++) { |
|
690 |
+ subs[i].update(); |
|
691 |
+ } |
|
692 |
+}; |
|
693 |
+ |
|
694 |
+// the current target watcher being evaluated. |
|
695 |
+// this is globally unique because there could be only one |
|
696 |
+// watcher being evaluated at any time. |
|
697 |
+Dep.target = null; |
|
698 |
+var targetStack = []; |
|
699 |
+ |
|
700 |
+function pushTarget (_target) { |
|
701 |
+ if (Dep.target) { targetStack.push(Dep.target); } |
|
702 |
+ Dep.target = _target; |
|
703 |
+} |
|
704 |
+ |
|
705 |
+function popTarget () { |
|
706 |
+ Dep.target = targetStack.pop(); |
|
707 |
+} |
|
708 |
+ |
|
709 |
+/* */ |
|
710 |
+ |
|
711 |
+var VNode = function VNode ( |
|
712 |
+ tag, |
|
713 |
+ data, |
|
714 |
+ children, |
|
715 |
+ text, |
|
716 |
+ elm, |
|
717 |
+ context, |
|
718 |
+ componentOptions, |
|
719 |
+ asyncFactory |
|
720 |
+) { |
|
721 |
+ this.tag = tag; |
|
722 |
+ this.data = data; |
|
723 |
+ this.children = children; |
|
724 |
+ this.text = text; |
|
725 |
+ this.elm = elm; |
|
726 |
+ this.ns = undefined; |
|
727 |
+ this.context = context; |
|
728 |
+ this.fnContext = undefined; |
|
729 |
+ this.fnOptions = undefined; |
|
730 |
+ this.fnScopeId = undefined; |
|
731 |
+ this.key = data && data.key; |
|
732 |
+ this.componentOptions = componentOptions; |
|
733 |
+ this.componentInstance = undefined; |
|
734 |
+ this.parent = undefined; |
|
735 |
+ this.raw = false; |
|
736 |
+ this.isStatic = false; |
|
737 |
+ this.isRootInsert = true; |
|
738 |
+ this.isComment = false; |
|
739 |
+ this.isCloned = false; |
|
740 |
+ this.isOnce = false; |
|
741 |
+ this.asyncFactory = asyncFactory; |
|
742 |
+ this.asyncMeta = undefined; |
|
743 |
+ this.isAsyncPlaceholder = false; |
|
744 |
+}; |
|
745 |
+ |
|
746 |
+var prototypeAccessors = { child: { configurable: true } }; |
|
747 |
+ |
|
748 |
+// DEPRECATED: alias for componentInstance for backwards compat. |
|
749 |
+/* istanbul ignore next */ |
|
750 |
+prototypeAccessors.child.get = function () { |
|
751 |
+ return this.componentInstance |
|
752 |
+}; |
|
753 |
+ |
|
754 |
+Object.defineProperties( VNode.prototype, prototypeAccessors ); |
|
755 |
+ |
|
756 |
+var createEmptyVNode = function (text) { |
|
757 |
+ if ( text === void 0 ) text = ''; |
|
758 |
+ |
|
759 |
+ var node = new VNode(); |
|
760 |
+ node.text = text; |
|
761 |
+ node.isComment = true; |
|
762 |
+ return node |
|
763 |
+}; |
|
764 |
+ |
|
765 |
+function createTextVNode (val) { |
|
766 |
+ return new VNode(undefined, undefined, undefined, String(val)) |
|
767 |
+} |
|
768 |
+ |
|
769 |
+// optimized shallow clone |
|
770 |
+// used for static nodes and slot nodes because they may be reused across |
|
771 |
+// multiple renders, cloning them avoids errors when DOM manipulations rely |
|
772 |
+// on their elm reference. |
|
773 |
+function cloneVNode (vnode, deep) { |
|
774 |
+ var componentOptions = vnode.componentOptions; |
|
775 |
+ var cloned = new VNode( |
|
776 |
+ vnode.tag, |
|
777 |
+ vnode.data, |
|
778 |
+ vnode.children, |
|
779 |
+ vnode.text, |
|
780 |
+ vnode.elm, |
|
781 |
+ vnode.context, |
|
782 |
+ componentOptions, |
|
783 |
+ vnode.asyncFactory |
|
784 |
+ ); |
|
785 |
+ cloned.ns = vnode.ns; |
|
786 |
+ cloned.isStatic = vnode.isStatic; |
|
787 |
+ cloned.key = vnode.key; |
|
788 |
+ cloned.isComment = vnode.isComment; |
|
789 |
+ cloned.fnContext = vnode.fnContext; |
|
790 |
+ cloned.fnOptions = vnode.fnOptions; |
|
791 |
+ cloned.fnScopeId = vnode.fnScopeId; |
|
792 |
+ cloned.isCloned = true; |
|
793 |
+ if (deep) { |
|
794 |
+ if (vnode.children) { |
|
795 |
+ cloned.children = cloneVNodes(vnode.children, true); |
|
796 |
+ } |
|
797 |
+ if (componentOptions && componentOptions.children) { |
|
798 |
+ componentOptions.children = cloneVNodes(componentOptions.children, true); |
|
799 |
+ } |
|
800 |
+ } |
|
801 |
+ return cloned |
|
802 |
+} |
|
803 |
+ |
|
804 |
+function cloneVNodes (vnodes, deep) { |
|
805 |
+ var len = vnodes.length; |
|
806 |
+ var res = new Array(len); |
|
807 |
+ for (var i = 0; i < len; i++) { |
|
808 |
+ res[i] = cloneVNode(vnodes[i], deep); |
|
809 |
+ } |
|
810 |
+ return res |
|
811 |
+} |
|
812 |
+ |
|
813 |
+/* |
|
814 |
+ * not type checking this file because flow doesn't play well with |
|
815 |
+ * dynamically accessing methods on Array prototype |
|
816 |
+ */ |
|
817 |
+ |
|
818 |
+var arrayProto = Array.prototype; |
|
819 |
+var arrayMethods = Object.create(arrayProto);[ |
|
820 |
+ 'push', |
|
821 |
+ 'pop', |
|
822 |
+ 'shift', |
|
823 |
+ 'unshift', |
|
824 |
+ 'splice', |
|
825 |
+ 'sort', |
|
826 |
+ 'reverse' |
|
827 |
+].forEach(function (method) { |
|
828 |
+ // cache original method |
|
829 |
+ var original = arrayProto[method]; |
|
830 |
+ def(arrayMethods, method, function mutator () { |
|
831 |
+ var args = [], len = arguments.length; |
|
832 |
+ while ( len-- ) args[ len ] = arguments[ len ]; |
|
833 |
+ |
|
834 |
+ var result = original.apply(this, args); |
|
835 |
+ var ob = this.__ob__; |
|
836 |
+ var inserted; |
|
837 |
+ switch (method) { |
|
838 |
+ case 'push': |
|
839 |
+ case 'unshift': |
|
840 |
+ inserted = args; |
|
841 |
+ break |
|
842 |
+ case 'splice': |
|
843 |
+ inserted = args.slice(2); |
|
844 |
+ break |
|
845 |
+ } |
|
846 |
+ if (inserted) { ob.observeArray(inserted); } |
|
847 |
+ // notify change |
|
848 |
+ ob.dep.notify(); |
|
849 |
+ return result |
|
850 |
+ }); |
|
851 |
+}); |
|
852 |
+ |
|
853 |
+/* */ |
|
854 |
+ |
|
855 |
+var arrayKeys = Object.getOwnPropertyNames(arrayMethods); |
|
856 |
+ |
|
857 |
+/** |
|
858 |
+ * By default, when a reactive property is set, the new value is |
|
859 |
+ * also converted to become reactive. However when passing down props, |
|
860 |
+ * we don't want to force conversion because the value may be a nested value |
|
861 |
+ * under a frozen data structure. Converting it would defeat the optimization. |
|
862 |
+ */ |
|
863 |
+var observerState = { |
|
864 |
+ shouldConvert: true |
|
865 |
+}; |
|
866 |
+ |
|
867 |
+/** |
|
868 |
+ * Observer class that are attached to each observed |
|
869 |
+ * object. Once attached, the observer converts target |
|
870 |
+ * object's property keys into getter/setters that |
|
871 |
+ * collect dependencies and dispatches updates. |
|
872 |
+ */ |
|
873 |
+var Observer = function Observer (value) { |
|
874 |
+ this.value = value; |
|
875 |
+ this.dep = new Dep(); |
|
876 |
+ this.vmCount = 0; |
|
877 |
+ def(value, '__ob__', this); |
|
878 |
+ if (Array.isArray(value)) { |
|
879 |
+ var augment = hasProto |
|
880 |
+ ? protoAugment |
|
881 |
+ : copyAugment; |
|
882 |
+ augment(value, arrayMethods, arrayKeys); |
|
883 |
+ this.observeArray(value); |
|
884 |
+ } else { |
|
885 |
+ this.walk(value); |
|
886 |
+ } |
|
887 |
+}; |
|
888 |
+ |
|
889 |
+/** |
|
890 |
+ * Walk through each property and convert them into |
|
891 |
+ * getter/setters. This method should only be called when |
|
892 |
+ * value type is Object. |
|
893 |
+ */ |
|
894 |
+Observer.prototype.walk = function walk (obj) { |
|
895 |
+ var keys = Object.keys(obj); |
|
896 |
+ for (var i = 0; i < keys.length; i++) { |
|
897 |
+ defineReactive(obj, keys[i], obj[keys[i]]); |
|
898 |
+ } |
|
899 |
+}; |
|
900 |
+ |
|
901 |
+/** |
|
902 |
+ * Observe a list of Array items. |
|
903 |
+ */ |
|
904 |
+Observer.prototype.observeArray = function observeArray (items) { |
|
905 |
+ for (var i = 0, l = items.length; i < l; i++) { |
|
906 |
+ observe(items[i]); |
|
907 |
+ } |
|
908 |
+}; |
|
909 |
+ |
|
910 |
+// helpers |
|
911 |
+ |
|
912 |
+/** |
|
913 |
+ * Augment an target Object or Array by intercepting |
|
914 |
+ * the prototype chain using __proto__ |
|
915 |
+ */ |
|
916 |
+function protoAugment (target, src, keys) { |
|
917 |
+ /* eslint-disable no-proto */ |
|
918 |
+ target.__proto__ = src; |
|
919 |
+ /* eslint-enable no-proto */ |
|
920 |
+} |
|
921 |
+ |
|
922 |
+/** |
|
923 |
+ * Augment an target Object or Array by defining |
|
924 |
+ * hidden properties. |
|
925 |
+ */ |
|
926 |
+/* istanbul ignore next */ |
|
927 |
+function copyAugment (target, src, keys) { |
|
928 |
+ for (var i = 0, l = keys.length; i < l; i++) { |
|
929 |
+ var key = keys[i]; |
|
930 |
+ def(target, key, src[key]); |
|
931 |
+ } |
|
932 |
+} |
|
933 |
+ |
|
934 |
+/** |
|
935 |
+ * Attempt to create an observer instance for a value, |
|
936 |
+ * returns the new observer if successfully observed, |
|
937 |
+ * or the existing observer if the value already has one. |
|
938 |
+ */ |
|
939 |
+function observe (value, asRootData) { |
|
940 |
+ if (!isObject(value) || value instanceof VNode) { |
|
941 |
+ return |
|
942 |
+ } |
|
943 |
+ var ob; |
|
944 |
+ if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { |
|
945 |
+ ob = value.__ob__; |
|
946 |
+ } else if ( |
|
947 |
+ observerState.shouldConvert && |
|
948 |
+ !isServerRendering() && |
|
949 |
+ (Array.isArray(value) || isPlainObject(value)) && |
|
950 |
+ Object.isExtensible(value) && |
|
951 |
+ !value._isVue |
|
952 |
+ ) { |
|
953 |
+ ob = new Observer(value); |
|
954 |
+ } |
|
955 |
+ if (asRootData && ob) { |
|
956 |
+ ob.vmCount++; |
|
957 |
+ } |
|
958 |
+ return ob |
|
959 |
+} |
|
960 |
+ |
|
961 |
+/** |
|
962 |
+ * Define a reactive property on an Object. |
|
963 |
+ */ |
|
964 |
+function defineReactive ( |
|
965 |
+ obj, |
|
966 |
+ key, |
|
967 |
+ val, |
|
968 |
+ customSetter, |
|
969 |
+ shallow |
|
970 |
+) { |
|
971 |
+ var dep = new Dep(); |
|
972 |
+ |
|
973 |
+ var property = Object.getOwnPropertyDescriptor(obj, key); |
|
974 |
+ if (property && property.configurable === false) { |
|
975 |
+ return |
|
976 |
+ } |
|
977 |
+ |
|
978 |
+ // cater for pre-defined getter/setters |
|
979 |
+ var getter = property && property.get; |
|
980 |
+ var setter = property && property.set; |
|
981 |
+ |
|
982 |
+ var childOb = !shallow && observe(val); |
|
983 |
+ Object.defineProperty(obj, key, { |
|
984 |
+ enumerable: true, |
|
985 |
+ configurable: true, |
|
986 |
+ get: function reactiveGetter () { |
|
987 |
+ var value = getter ? getter.call(obj) : val; |
|
988 |
+ if (Dep.target) { |
|
989 |
+ dep.depend(); |
|
990 |
+ if (childOb) { |
|
991 |
+ childOb.dep.depend(); |
|
992 |
+ if (Array.isArray(value)) { |
|
993 |
+ dependArray(value); |
|
994 |
+ } |
|
995 |
+ } |
|
996 |
+ } |
|
997 |
+ return value |
|
998 |
+ }, |
|
999 |
+ set: function reactiveSetter (newVal) { |
|
1000 |
+ var value = getter ? getter.call(obj) : val; |
|
1001 |
+ /* eslint-disable no-self-compare */ |
|
1002 |
+ if (newVal === value || (newVal !== newVal && value !== value)) { |
|
1003 |
+ return |
|
1004 |
+ } |
|
1005 |
+ /* eslint-enable no-self-compare */ |
|
1006 |
+ if ("development" !== 'production' && customSetter) { |
|
1007 |
+ customSetter(); |
|
1008 |
+ } |
|
1009 |
+ if (setter) { |
|
1010 |
+ setter.call(obj, newVal); |
|
1011 |
+ } else { |
|
1012 |
+ val = newVal; |
|
1013 |
+ } |
|
1014 |
+ childOb = !shallow && observe(newVal); |
|
1015 |
+ dep.notify(); |
|
1016 |
+ } |
|
1017 |
+ }); |
|
1018 |
+} |
|
1019 |
+ |
|
1020 |
+/** |
|
1021 |
+ * Set a property on an object. Adds the new property and |
|
1022 |
+ * triggers change notification if the property doesn't |
|
1023 |
+ * already exist. |
|
1024 |
+ */ |
|
1025 |
+function set (target, key, val) { |
|
1026 |
+ if (Array.isArray(target) && isValidArrayIndex(key)) { |
|
1027 |
+ target.length = Math.max(target.length, key); |
|
1028 |
+ target.splice(key, 1, val); |
|
1029 |
+ return val |
|
1030 |
+ } |
|
1031 |
+ if (key in target && !(key in Object.prototype)) { |
|
1032 |
+ target[key] = val; |
|
1033 |
+ return val |
|
1034 |
+ } |
|
1035 |
+ var ob = (target).__ob__; |
|
1036 |
+ if (target._isVue || (ob && ob.vmCount)) { |
|
1037 |
+ "development" !== 'production' && warn( |
|
1038 |
+ 'Avoid adding reactive properties to a Vue instance or its root $data ' + |
|
1039 |
+ 'at runtime - declare it upfront in the data option.' |
|
1040 |
+ ); |
|
1041 |
+ return val |
|
1042 |
+ } |
|
1043 |
+ if (!ob) { |
|
1044 |
+ target[key] = val; |
|
1045 |
+ return val |
|
1046 |
+ } |
|
1047 |
+ defineReactive(ob.value, key, val); |
|
1048 |
+ ob.dep.notify(); |
|
1049 |
+ return val |
|
1050 |
+} |
|
1051 |
+ |
|
1052 |
+/** |
|
1053 |
+ * Delete a property and trigger change if necessary. |
|
1054 |
+ */ |
|
1055 |
+function del (target, key) { |
|
1056 |
+ if (Array.isArray(target) && isValidArrayIndex(key)) { |
|
1057 |
+ target.splice(key, 1); |
|
1058 |
+ return |
|
1059 |
+ } |
|
1060 |
+ var ob = (target).__ob__; |
|
1061 |
+ if (target._isVue || (ob && ob.vmCount)) { |
|
1062 |
+ "development" !== 'production' && warn( |
|
1063 |
+ 'Avoid deleting properties on a Vue instance or its root $data ' + |
|
1064 |
+ '- just set it to null.' |
|
1065 |
+ ); |
|
1066 |
+ return |
|
1067 |
+ } |
|
1068 |
+ if (!hasOwn(target, key)) { |
|
1069 |
+ return |
|
1070 |
+ } |
|
1071 |
+ delete target[key]; |
|
1072 |
+ if (!ob) { |
|
1073 |
+ return |
|
1074 |
+ } |
|
1075 |
+ ob.dep.notify(); |
|
1076 |
+} |
|
1077 |
+ |
|
1078 |
+/** |
|
1079 |
+ * Collect dependencies on array elements when the array is touched, since |
|
1080 |
+ * we cannot intercept array element access like property getters. |
|
1081 |
+ */ |
|
1082 |
+function dependArray (value) { |
|
1083 |
+ for (var e = (void 0), i = 0, l = value.length; i < l; i++) { |
|
1084 |
+ e = value[i]; |
|
1085 |
+ e && e.__ob__ && e.__ob__.dep.depend(); |
|
1086 |
+ if (Array.isArray(e)) { |
|
1087 |
+ dependArray(e); |
|
1088 |
+ } |
|
1089 |
+ } |
|
1090 |
+} |
|
1091 |
+ |
|
1092 |
+/* */ |
|
1093 |
+ |
|
1094 |
+/** |
|
1095 |
+ * Option overwriting strategies are functions that handle |
|
1096 |
+ * how to merge a parent option value and a child option |
|
1097 |
+ * value into the final value. |
|
1098 |
+ */ |
|
1099 |
+var strats = config.optionMergeStrategies; |
|
1100 |
+ |
|
1101 |
+/** |
|
1102 |
+ * Options with restrictions |
|
1103 |
+ */ |
|
1104 |
+{ |
|
1105 |
+ strats.el = strats.propsData = function (parent, child, vm, key) { |
|
1106 |
+ if (!vm) { |
|
1107 |
+ warn( |
|
1108 |
+ "option \"" + key + "\" can only be used during instance " + |
|
1109 |
+ 'creation with the `new` keyword.' |
|
1110 |
+ ); |
|
1111 |
+ } |
|
1112 |
+ return defaultStrat(parent, child) |
|
1113 |
+ }; |
|
1114 |
+} |
|
1115 |
+ |
|
1116 |
+/** |
|
1117 |
+ * Helper that recursively merges two data objects together. |
|
1118 |
+ */ |
|
1119 |
+function mergeData (to, from) { |
|
1120 |
+ if (!from) { return to } |
|
1121 |
+ var key, toVal, fromVal; |
|
1122 |
+ var keys = Object.keys(from); |
|
1123 |
+ for (var i = 0; i < keys.length; i++) { |
|
1124 |
+ key = keys[i]; |
|
1125 |
+ toVal = to[key]; |
|
1126 |
+ fromVal = from[key]; |
|
1127 |
+ if (!hasOwn(to, key)) { |
|
1128 |
+ set(to, key, fromVal); |
|
1129 |
+ } else if (isPlainObject(toVal) && isPlainObject(fromVal)) { |
|
1130 |
+ mergeData(toVal, fromVal); |
|
1131 |
+ } |
|
1132 |
+ } |
|
1133 |
+ return to |
|
1134 |
+} |
|
1135 |
+ |
|
1136 |
+/** |
|
1137 |
+ * Data |
|
1138 |
+ */ |
|
1139 |
+function mergeDataOrFn ( |
|
1140 |
+ parentVal, |
|
1141 |
+ childVal, |
|
1142 |
+ vm |
|
1143 |
+) { |
|
1144 |
+ if (!vm) { |
|
1145 |
+ // in a Vue.extend merge, both should be functions |
|
1146 |
+ if (!childVal) { |
|
1147 |
+ return parentVal |
|
1148 |
+ } |
|
1149 |
+ if (!parentVal) { |
|
1150 |
+ return childVal |
|
1151 |
+ } |
|
1152 |
+ // when parentVal & childVal are both present, |
|
1153 |
+ // we need to return a function that returns the |
|
1154 |
+ // merged result of both functions... no need to |
|
1155 |
+ // check if parentVal is a function here because |
|
1156 |
+ // it has to be a function to pass previous merges. |
|
1157 |
+ return function mergedDataFn () { |
|
1158 |
+ return mergeData( |
|
1159 |
+ typeof childVal === 'function' ? childVal.call(this, this) : childVal, |
|
1160 |
+ typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal |
|
1161 |
+ ) |
|
1162 |
+ } |
|
1163 |
+ } else { |
|
1164 |
+ return function mergedInstanceDataFn () { |
|
1165 |
+ // instance merge |
|
1166 |
+ var instanceData = typeof childVal === 'function' |
|
1167 |
+ ? childVal.call(vm, vm) |
|
1168 |
+ : childVal; |
|
1169 |
+ var defaultData = typeof parentVal === 'function' |
|
1170 |
+ ? parentVal.call(vm, vm) |
|
1171 |
+ : parentVal; |
|
1172 |
+ if (instanceData) { |
|
1173 |
+ return mergeData(instanceData, defaultData) |
|
1174 |
+ } else { |
|
1175 |
+ return defaultData |
|
1176 |
+ } |
|
1177 |
+ } |
|
1178 |
+ } |
|
1179 |
+} |
|
1180 |
+ |
|
1181 |
+strats.data = function ( |
|
1182 |
+ parentVal, |
|
1183 |
+ childVal, |
|
1184 |
+ vm |
|
1185 |
+) { |
|
1186 |
+ if (!vm) { |
|
1187 |
+ if (childVal && typeof childVal !== 'function') { |
|
1188 |
+ "development" !== 'production' && warn( |
|
1189 |
+ 'The "data" option should be a function ' + |
|
1190 |
+ 'that returns a per-instance value in component ' + |
|
1191 |
+ 'definitions.', |
|
1192 |
+ vm |
|
1193 |
+ ); |
|
1194 |
+ |
|
1195 |
+ return parentVal |
|
1196 |
+ } |
|
1197 |
+ return mergeDataOrFn(parentVal, childVal) |
|
1198 |
+ } |
|
1199 |
+ |
|
1200 |
+ return mergeDataOrFn(parentVal, childVal, vm) |
|
1201 |
+}; |
|
1202 |
+ |
|
1203 |
+/** |
|
1204 |
+ * Hooks and props are merged as arrays. |
|
1205 |
+ */ |
|
1206 |
+function mergeHook ( |
|
1207 |
+ parentVal, |
|
1208 |
+ childVal |
|
1209 |
+) { |
|
1210 |
+ return childVal |
|
1211 |
+ ? parentVal |
|
1212 |
+ ? parentVal.concat(childVal) |
|
1213 |
+ : Array.isArray(childVal) |
|
1214 |
+ ? childVal |
|
1215 |
+ : [childVal] |
|
1216 |
+ : parentVal |
|
1217 |
+} |
|
1218 |
+ |
|
1219 |
+LIFECYCLE_HOOKS.forEach(function (hook) { |
|
1220 |
+ strats[hook] = mergeHook; |
|
1221 |
+}); |
|
1222 |
+ |
|
1223 |
+/** |
|
1224 |
+ * Assets |
|
1225 |
+ * |
|
1226 |
+ * When a vm is present (instance creation), we need to do |
|
1227 |
+ * a three-way merge between constructor options, instance |
|
1228 |
+ * options and parent options. |
|
1229 |
+ */ |
|
1230 |
+function mergeAssets ( |
|
1231 |
+ parentVal, |
|
1232 |
+ childVal, |
|
1233 |
+ vm, |
|
1234 |
+ key |
|
1235 |
+) { |
|
1236 |
+ var res = Object.create(parentVal || null); |
|
1237 |
+ if (childVal) { |
|
1238 |
+ "development" !== 'production' && assertObjectType(key, childVal, vm); |
|
1239 |
+ return extend(res, childVal) |
|
1240 |
+ } else { |
|
1241 |
+ return res |
|
1242 |
+ } |
|
1243 |
+} |
|
1244 |
+ |
|
1245 |
+ASSET_TYPES.forEach(function (type) { |
|
1246 |
+ strats[type + 's'] = mergeAssets; |
|
1247 |
+}); |
|
1248 |
+ |
|
1249 |
+/** |
|
1250 |
+ * Watchers. |
|
1251 |
+ * |
|
1252 |
+ * Watchers hashes should not overwrite one |
|
1253 |
+ * another, so we merge them as arrays. |
|
1254 |
+ */ |
|
1255 |
+strats.watch = function ( |
|
1256 |
+ parentVal, |
|
1257 |
+ childVal, |
|
1258 |
+ vm, |
|
1259 |
+ key |
|
1260 |
+) { |
|
1261 |
+ // work around Firefox's Object.prototype.watch... |
|
1262 |
+ if (parentVal === nativeWatch) { parentVal = undefined; } |
|
1263 |
+ if (childVal === nativeWatch) { childVal = undefined; } |
|
1264 |
+ /* istanbul ignore if */ |
|
1265 |
+ if (!childVal) { return Object.create(parentVal || null) } |
|
1266 |
+ { |
|
1267 |
+ assertObjectType(key, childVal, vm); |
|
1268 |
+ } |
|
1269 |
+ if (!parentVal) { return childVal } |
|
1270 |
+ var ret = {}; |
|
1271 |
+ extend(ret, parentVal); |
|
1272 |
+ for (var key$1 in childVal) { |
|
1273 |
+ var parent = ret[key$1]; |
|
1274 |
+ var child = childVal[key$1]; |
|
1275 |
+ if (parent && !Array.isArray(parent)) { |
|
1276 |
+ parent = [parent]; |
|
1277 |
+ } |
|
1278 |
+ ret[key$1] = parent |
|
1279 |
+ ? parent.concat(child) |
|
1280 |
+ : Array.isArray(child) ? child : [child]; |
|
1281 |
+ } |
|
1282 |
+ return ret |
|
1283 |
+}; |
|
1284 |
+ |
|
1285 |
+/** |
|
1286 |
+ * Other object hashes. |
|
1287 |
+ */ |
|
1288 |
+strats.props = |
|
1289 |
+strats.methods = |
|
1290 |
+strats.inject = |
|
1291 |
+strats.computed = function ( |
|
1292 |
+ parentVal, |
|
1293 |
+ childVal, |
|
1294 |
+ vm, |
|
1295 |
+ key |
|
1296 |
+) { |
|
1297 |
+ if (childVal && "development" !== 'production') { |
|
1298 |
+ assertObjectType(key, childVal, vm); |
|
1299 |
+ } |
|
1300 |
+ if (!parentVal) { return childVal } |
|
1301 |
+ var ret = Object.create(null); |
|
1302 |
+ extend(ret, parentVal); |
|
1303 |
+ if (childVal) { extend(ret, childVal); } |
|
1304 |
+ return ret |
|
1305 |
+}; |
|
1306 |
+strats.provide = mergeDataOrFn; |
|
1307 |
+ |
|
1308 |
+/** |
|
1309 |
+ * Default strategy. |
|
1310 |
+ */ |
|
1311 |
+var defaultStrat = function (parentVal, childVal) { |
|
1312 |
+ return childVal === undefined |
|
1313 |
+ ? parentVal |
|
1314 |
+ : childVal |
|
1315 |
+}; |
|
1316 |
+ |
|
1317 |
+/** |
|
1318 |
+ * Validate component names |
|
1319 |
+ */ |
|
1320 |
+function checkComponents (options) { |
|
1321 |
+ for (var key in options.components) { |
|
1322 |
+ validateComponentName(key); |
|
1323 |
+ } |
|
1324 |
+} |
|
1325 |
+ |
|
1326 |
+function validateComponentName (name) { |
|
1327 |
+ if (!/^[a-zA-Z][\w-]*$/.test(name)) { |
|
1328 |
+ warn( |
|
1329 |
+ 'Invalid component name: "' + name + '". Component names ' + |
|
1330 |
+ 'can only contain alphanumeric characters and the hyphen, ' + |
|
1331 |
+ 'and must start with a letter.' |
|
1332 |
+ ); |
|
1333 |
+ } |
|
1334 |
+ if (isBuiltInTag(name) || config.isReservedTag(name)) { |
|
1335 |
+ warn( |
|
1336 |
+ 'Do not use built-in or reserved HTML elements as component ' + |
|
1337 |
+ 'id: ' + name |
|
1338 |
+ ); |
|
1339 |
+ } |
|
1340 |
+} |
|
1341 |
+ |
|
1342 |
+/** |
|
1343 |
+ * Ensure all props option syntax are normalized into the |
|
1344 |
+ * Object-based format. |
|
1345 |
+ */ |
|
1346 |
+function normalizeProps (options, vm) { |
|
1347 |
+ var props = options.props; |
|
1348 |
+ if (!props) { return } |
|
1349 |
+ var res = {}; |
|
1350 |
+ var i, val, name; |
|
1351 |
+ if (Array.isArray(props)) { |
|
1352 |
+ i = props.length; |
|
1353 |
+ while (i--) { |
|
1354 |
+ val = props[i]; |
|
1355 |
+ if (typeof val === 'string') { |
|
1356 |
+ name = camelize(val); |
|
1357 |
+ res[name] = { type: null }; |
|
1358 |
+ } else { |
|
1359 |
+ warn('props must be strings when using array syntax.'); |
|
1360 |
+ } |
|
1361 |
+ } |
|
1362 |
+ } else if (isPlainObject(props)) { |
|
1363 |
+ for (var key in props) { |
|
1364 |
+ val = props[key]; |
|
1365 |
+ name = camelize(key); |
|
1366 |
+ res[name] = isPlainObject(val) |
|
1367 |
+ ? val |
|
1368 |
+ : { type: val }; |
|
1369 |
+ } |
|
1370 |
+ } else { |
|
1371 |
+ warn( |
|
1372 |
+ "Invalid value for option \"props\": expected an Array or an Object, " + |
|
1373 |
+ "but got " + (toRawType(props)) + ".", |
|
1374 |
+ vm |
|
1375 |
+ ); |
|
1376 |
+ } |
|
1377 |
+ options.props = res; |
|
1378 |
+} |
|
1379 |
+ |
|
1380 |
+/** |
|
1381 |
+ * Normalize all injections into Object-based format |
|
1382 |
+ */ |
|
1383 |
+function normalizeInject (options, vm) { |
|
1384 |
+ var inject = options.inject; |
|
1385 |
+ if (!inject) { return } |
|
1386 |
+ var normalized = options.inject = {}; |
|
1387 |
+ if (Array.isArray(inject)) { |
|
1388 |
+ for (var i = 0; i < inject.length; i++) { |
|
1389 |
+ normalized[inject[i]] = { from: inject[i] }; |
|
1390 |
+ } |
|
1391 |
+ } else if (isPlainObject(inject)) { |
|
1392 |
+ for (var key in inject) { |
|
1393 |
+ var val = inject[key]; |
|
1394 |