├── .babelrc
├── .gitignore
├── .npmignore
├── LICENSE
├── README.md
├── dist
└── vue-testing.js
├── package.json
├── src
└── index.js
└── webpack
├── webpack-bundle.config.js
├── webpack-test.config.js
└── webpack.config.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["es2015"],
3 | "plugins": ["transform-object-rest-spread"]
4 | }
5 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | node_modules/
3 | yarn.lock
4 |
5 | test/
6 | karma.conf.js
7 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | build/
2 | src/
3 | test/
4 | webpack/
5 |
6 | .babelrc
7 | browser.html
8 | index.html
9 | karma.conf.js
10 | yarn.lock
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Naufal Rabbani
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vue Testing
2 |
3 | Let's make Vue Testing And [Mocking](https://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html) Become Easier And Much Fun.
4 |
5 | ## Installation
6 | ```bash
7 | npm install vue-testing inject-loader --save-dev
8 | ```
9 |
10 | ## Motivation
11 | If you're testing without [```vue-testing```](https://github.com/BosNaufal/vue-testing) you'll realize that you have a long boilerplate code to mock up your component. Let me show you how it looks. It's taken from [https://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html](https://vue-loader.vuejs.org/en/workflow/testing-with-mocks.html)
12 |
13 | ```html
14 |
15 |
16 |
{{ msg }}
17 |
18 |
19 |
31 | ```
32 |
33 | ```javascript
34 | // example.spec.js
35 |
36 | // Import the component and make the injection preparation
37 | const ExampleInjector = require('!!vue?inject!./example.vue')
38 |
39 | // Inject and Mock External Resource
40 | const ExampleWithMocks = ExampleInjector({
41 | // mock it
42 | '../service': {
43 | msg: 'Hello from a mocked service!'
44 | }
45 | })
46 |
47 | it('should render', () => {
48 | // Render the component manually
49 | const vm = new Vue({
50 | template: '
',
51 | components: {
52 | 'test': ExampleWithMocks
53 | }
54 | }).$mount()
55 | expect(vm.$el.querySelector('.msg').textContent).toBe('Hello from a mocked service!')
56 | })
57 | ```
58 |
59 | ### Magic Vue Properties
60 | Probably, you'll not get frustated with that code. Cause it's simple. until your component uses vue properties that magically injected by some plugin. For example ```vue-router``` injects ```this.$router``` and ```this.$route``` Or ```vuex``` injects ```this.$store```. It will throw error variable undefined since we not render the whole app. So, How do you handle it without touching your component code? It needs some effort.
61 |
62 | ```html
63 |
64 |
65 |
{{ msg }}
66 |
67 |
68 |
85 | ```
86 |
87 | ```javascript
88 | // example.spec.js
89 |
90 | // Import the component and make the injection preparation
91 | const ExampleInjector = require('!!vue?inject!./example.vue')
92 |
93 | // Inject and Mock External Resource
94 | const ExampleWithMocks = ExampleInjector({
95 | // mock it
96 | '../service': {
97 | msg: 'Hello from a mocked service!'
98 | }
99 | })
100 |
101 | // You can inject magic properties this way
102 | ExampleWithMocks.beforeCreate = function () {
103 | this.$route = { params: {} }
104 | this.$router = { push: () => {} }
105 | }
106 |
107 | it('should render', () => {
108 | // Render the component manually
109 | const vm = new Vue({
110 | template: '
',
111 | components: {
112 | 'test': ExampleWithMocks
113 | }
114 | }).$mount()
115 |
116 | expect(vm.$el.querySelector('.msg').textContent).toBe('Hello from a mocked service!')
117 | })
118 | ```
119 |
120 | ### Vuex Helper Function
121 | Oke, let's say that you always pass the router params via props since ```vue-router@2.2.x```. But you'll still get the problem when you're using vuex helper function like ```mapActions```, ```mapStates```, ```mapGetters```. Sure, you need write more.
122 |
123 | ```html
124 |
125 |
126 |
{{ msg }}
127 |
128 |
129 |
158 | ```
159 |
160 | ```javascript
161 | // example.spec.js
162 |
163 | // Import the component and make the injection preparation
164 | const ExampleInjector = require('!!vue?inject!./example.vue')
165 |
166 | // Inject and Mock External Resource
167 | const ExampleWithMocks = ExampleInjector({
168 | // mock it
169 | '../service': {
170 | msg: 'Hello from a mocked service!'
171 | },
172 |
173 | 'vuex': {
174 | mapActions: () => {}
175 | }
176 | })
177 |
178 | // Mock The Method To Put Your Spy
179 | ExampleWithMocks.methods = {
180 | ...ExampleWithMocks.methods,
181 | test: function() {
182 | return spy
183 | }
184 | }
185 |
186 | // You can inject magic properties this way
187 | ExampleWithMocks.beforeCreate = function () {
188 | this.$route = { params: {} }
189 | this.$router = { push: () => {} }
190 | }
191 |
192 | it('should render', () => {
193 | // Render the component manually
194 | const vm = new Vue({
195 | template: '
',
196 | components: {
197 | 'test': ExampleWithMocks
198 | }
199 | }).$mount()
200 |
201 | expect(vm.$el.querySelector('.msg').textContent).toBe('Hello from a mocked service!')
202 | })
203 | ```
204 |
205 | ## Let's Make It Simple!
206 | Let's make it simple with ```vue-testing```. You'll just need little effort to mock your component constructor. Take a peek.
207 | ```javascript
208 | // example.spec.js
209 |
210 | // Import Vue Testing Helpers
211 | import { mockComponent, mount } from 'vue-testing';
212 |
213 | // Import the component and make the injection preparation
214 | const ExampleInjector = require('!!vue?inject!./example.vue')
215 |
216 | // Mock It!
217 | let Component = mockComponent(ExampleInjector, {
218 |
219 | // You can inject component properties via propsData
220 | propsData: {
221 | msg: 'hai'
222 | },
223 |
224 | // Even You can inject the local state without breaking your beforeCreate function
225 | // It will save you from mapStates and mapGetters vuex function error in testing
226 | states: {
227 | localState: 'hello',
228 | $route: {
229 | params: {}
230 | },
231 | $router: {
232 | push: () => {}
233 | }
234 | },
235 |
236 | // You can inject the actions to be your local methods!
237 | // It will save you from mapActions vuex function error in testing
238 | actions: {
239 | test: () => spy
240 | },
241 |
242 |
243 | // Default integrated with vuex-saga
244 | // It will save you from mapSagas vuex-saga function error in testing
245 | sagas: {
246 | test: () => {}
247 | },
248 |
249 |
250 | // Mock the external module
251 | // You can just put all in one scope
252 | '../service': {
253 | msg: 'Hello from a mocked service!'
254 | },
255 | 'jquery': () => {}
256 | 'external-module': {}
257 | })
258 |
259 |
260 | describe('ExampleComponent', function () {
261 |
262 | let vm;
263 | beforeEach(function () {
264 | // Mount it!
265 | // Mount it in every test scope. So you'll get fresh component
266 | vm = mount(Component)
267 | })
268 |
269 | // Focus On Your Test!
270 | it('Some Test', function () {
271 | const actual = vm.$el.querySelector('.msg').textContent
272 | const expected = 'Hello from a mocked service!'
273 | expect(actual).toBe(expected)
274 | })
275 |
276 | })
277 | ```
278 |
279 | ## Have You Tested Your Components? You Should Be~
280 |
281 | ## Thank You for Making this useful~
282 |
283 | ## Let's talk about some projects with me
284 | Just Contact Me At:
285 | - Email: [bosnaufalemail@gmail.com](mailto:bosnaufalemail@gmail.com)
286 | - Skype Id: bosnaufal254
287 | - twitter: [@BosNaufal](https://twitter.com/BosNaufal)
288 |
289 |
290 | ## License
291 | [MIT](http://opensource.org/licenses/MIT)
292 | Copyright (c) Naufal Rabbani
293 |
--------------------------------------------------------------------------------
/dist/vue-testing.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Copyright (c) Naufal Rabbani (http://github.com/BosNaufal)
3 | * Licensed Under MIT (http://opensource.org/licenses/MIT)
4 | *
5 | * Vue Testing @ Version 0.0.2
6 | *
7 | */
8 | (function webpackUniversalModuleDefinition(root, factory) {
9 | if(typeof exports === 'object' && typeof module === 'object')
10 | module.exports = factory();
11 | else if(typeof define === 'function' && define.amd)
12 | define([], factory);
13 | else if(typeof exports === 'object')
14 | exports["VueTesting"] = factory();
15 | else
16 | root["VueTesting"] = factory();
17 | })(this, function() {
18 | return /******/ (function(modules) { // webpackBootstrap
19 | /******/ // The module cache
20 | /******/ var installedModules = {};
21 |
22 | /******/ // The require function
23 | /******/ function __webpack_require__(moduleId) {
24 |
25 | /******/ // Check if module is in cache
26 | /******/ if(installedModules[moduleId])
27 | /******/ return installedModules[moduleId].exports;
28 |
29 | /******/ // Create a new module (and put it into the cache)
30 | /******/ var module = installedModules[moduleId] = {
31 | /******/ exports: {},
32 | /******/ id: moduleId,
33 | /******/ loaded: false
34 | /******/ };
35 |
36 | /******/ // Execute the module function
37 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
38 |
39 | /******/ // Flag the module as loaded
40 | /******/ module.loaded = true;
41 |
42 | /******/ // Return the exports of the module
43 | /******/ return module.exports;
44 | /******/ }
45 |
46 |
47 | /******/ // expose the modules object (__webpack_modules__)
48 | /******/ __webpack_require__.m = modules;
49 |
50 | /******/ // expose the module cache
51 | /******/ __webpack_require__.c = installedModules;
52 |
53 | /******/ // __webpack_public_path__
54 | /******/ __webpack_require__.p = "../dist/";
55 |
56 | /******/ // Load entry module and return exports
57 | /******/ return __webpack_require__(0);
58 | /******/ })
59 | /************************************************************************/
60 | /******/ ([
61 | /* 0 */
62 | /***/ function(module, exports, __webpack_require__) {
63 |
64 | 'use strict';
65 |
66 | Object.defineProperty(exports, "__esModule", {
67 | value: true
68 | });
69 |
70 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
71 |
72 | var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
73 |
74 | exports.mount = mount;
75 | exports.injectState = injectState;
76 | exports.defaultInjections = defaultInjections;
77 | exports.mockComponent = mockComponent;
78 |
79 | var _vue = __webpack_require__(1);
80 |
81 | var _vue2 = _interopRequireDefault(_vue);
82 |
83 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
84 |
85 | // To Mount Component
86 | function mount(component) {
87 | var Ctor = _vue2.default.extend(component);
88 | var propsData = component.$propsDataInjection;
89 | var vm = new Ctor({ propsData: propsData }).$mount();
90 | return vm;
91 | }
92 |
93 | // To Make State Injections
94 | function injectState(Component, injections) {
95 | var defaultValue = Component.data ? Component.data() : {};
96 | Component.data = function () {
97 | return _extends({}, defaultValue, injections);
98 | };
99 | return Component;
100 | }
101 |
102 | // To Make a Mock Injection for default Injections
103 | function defaultInjections(injects) {
104 |
105 | // If No Injections
106 | var injections = {
107 | 'vuex': {
108 | mapStates: function mapStates() {},
109 | mapActions: function mapActions() {},
110 | mapGetters: function mapGetters() {}
111 | },
112 | 'vuex-saga': {
113 | mapSagas: function mapSagas() {}
114 | }
115 | };
116 |
117 | if (!injects) return { injections: injections, stateInjections: {}, propsData: {} };
118 |
119 | // If there's an injection
120 | // Destruct
121 | var internal = {};
122 | var others = {};
123 | var keys = Object.keys(injects);
124 | keys.forEach(function (key) {
125 | if (key !== 'states' && key !== 'actions' && key !== 'getters' && key !== 'sagas' && key !== 'propsData') {
126 | others[key] = injects[key];
127 | } else {
128 | internal[key] = injects[key];
129 | }
130 | });
131 |
132 | // Vuex Injections
133 | if (internal['sagas']) injections['vuex-saga'].mapSagas = function () {
134 | return internal['sagas'];
135 | };
136 | if (internal['actions']) injections['vuex'].mapActions = function () {
137 | return internal['actions'];
138 | };
139 |
140 | // Others injections
141 | if ((typeof others === 'undefined' ? 'undefined' : _typeof(others)) === 'object') injections = _extends({}, injections, others);
142 |
143 | // If There's some state Injections
144 | var stateInjections = void 0;
145 | if (internal['getters'] || internal['states']) {
146 | // Combine Getters and States Injections
147 | var states = _extends({}, internal['getters'], internal['states']);
148 |
149 | // Save the state injections
150 | stateInjections = states;
151 | }
152 |
153 | return { injections: injections, stateInjections: stateInjections, propsData: internal['propsData'] };
154 | }
155 |
156 | // Wrap it all to mock a component constructor
157 | function mockComponent(injector, injects) {
158 | var _defaultInjections = defaultInjections(injects),
159 | injections = _defaultInjections.injections,
160 | stateInjections = _defaultInjections.stateInjections,
161 | propsData = _defaultInjections.propsData;
162 |
163 | // Inject it!
164 |
165 |
166 | var Component = injector(_extends({}, injections));
167 |
168 | // Inject States From getters And states Argumen
169 | Component = injectState(Component, stateInjections);
170 |
171 | // Inject propsData
172 | Component.$propsDataInjection = propsData;
173 |
174 | return Component;
175 | }
176 |
177 | var combine = { mockComponent: mockComponent, mount: mount };
178 | exports.default = combine;
179 |
180 | /***/ },
181 | /* 1 */
182 | /***/ function(module, exports, __webpack_require__) {
183 |
184 | /* WEBPACK VAR INJECTION */(function(global) {/*!
185 | * Vue.js v2.1.10
186 | * (c) 2014-2017 Evan You
187 | * Released under the MIT License.
188 | */
189 | 'use strict';
190 |
191 | /* */
192 |
193 | /**
194 | * Convert a value to a string that is actually rendered.
195 | */
196 | function _toString (val) {
197 | return val == null
198 | ? ''
199 | : typeof val === 'object'
200 | ? JSON.stringify(val, null, 2)
201 | : String(val)
202 | }
203 |
204 | /**
205 | * Convert a input value to a number for persistence.
206 | * If the conversion fails, return original string.
207 | */
208 | function toNumber (val) {
209 | var n = parseFloat(val);
210 | return isNaN(n) ? val : n
211 | }
212 |
213 | /**
214 | * Make a map and return a function for checking if a key
215 | * is in that map.
216 | */
217 | function makeMap (
218 | str,
219 | expectsLowerCase
220 | ) {
221 | var map = Object.create(null);
222 | var list = str.split(',');
223 | for (var i = 0; i < list.length; i++) {
224 | map[list[i]] = true;
225 | }
226 | return expectsLowerCase
227 | ? function (val) { return map[val.toLowerCase()]; }
228 | : function (val) { return map[val]; }
229 | }
230 |
231 | /**
232 | * Check if a tag is a built-in tag.
233 | */
234 | var isBuiltInTag = makeMap('slot,component', true);
235 |
236 | /**
237 | * Remove an item from an array
238 | */
239 | function remove$1 (arr, item) {
240 | if (arr.length) {
241 | var index = arr.indexOf(item);
242 | if (index > -1) {
243 | return arr.splice(index, 1)
244 | }
245 | }
246 | }
247 |
248 | /**
249 | * Check whether the object has the property.
250 | */
251 | var hasOwnProperty = Object.prototype.hasOwnProperty;
252 | function hasOwn (obj, key) {
253 | return hasOwnProperty.call(obj, key)
254 | }
255 |
256 | /**
257 | * Check if value is primitive
258 | */
259 | function isPrimitive (value) {
260 | return typeof value === 'string' || typeof value === 'number'
261 | }
262 |
263 | /**
264 | * Create a cached version of a pure function.
265 | */
266 | function cached (fn) {
267 | var cache = Object.create(null);
268 | return (function cachedFn (str) {
269 | var hit = cache[str];
270 | return hit || (cache[str] = fn(str))
271 | })
272 | }
273 |
274 | /**
275 | * Camelize a hyphen-delimited string.
276 | */
277 | var camelizeRE = /-(\w)/g;
278 | var camelize = cached(function (str) {
279 | return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
280 | });
281 |
282 | /**
283 | * Capitalize a string.
284 | */
285 | var capitalize = cached(function (str) {
286 | return str.charAt(0).toUpperCase() + str.slice(1)
287 | });
288 |
289 | /**
290 | * Hyphenate a camelCase string.
291 | */
292 | var hyphenateRE = /([^-])([A-Z])/g;
293 | var hyphenate = cached(function (str) {
294 | return str
295 | .replace(hyphenateRE, '$1-$2')
296 | .replace(hyphenateRE, '$1-$2')
297 | .toLowerCase()
298 | });
299 |
300 | /**
301 | * Simple bind, faster than native
302 | */
303 | function bind$1 (fn, ctx) {
304 | function boundFn (a) {
305 | var l = arguments.length;
306 | return l
307 | ? l > 1
308 | ? fn.apply(ctx, arguments)
309 | : fn.call(ctx, a)
310 | : fn.call(ctx)
311 | }
312 | // record original fn length
313 | boundFn._length = fn.length;
314 | return boundFn
315 | }
316 |
317 | /**
318 | * Convert an Array-like object to a real Array.
319 | */
320 | function toArray (list, start) {
321 | start = start || 0;
322 | var i = list.length - start;
323 | var ret = new Array(i);
324 | while (i--) {
325 | ret[i] = list[i + start];
326 | }
327 | return ret
328 | }
329 |
330 | /**
331 | * Mix properties into target object.
332 | */
333 | function extend (to, _from) {
334 | for (var key in _from) {
335 | to[key] = _from[key];
336 | }
337 | return to
338 | }
339 |
340 | /**
341 | * Quick object check - this is primarily used to tell
342 | * Objects from primitive values when we know the value
343 | * is a JSON-compliant type.
344 | */
345 | function isObject (obj) {
346 | return obj !== null && typeof obj === 'object'
347 | }
348 |
349 | /**
350 | * Strict object type check. Only returns true
351 | * for plain JavaScript objects.
352 | */
353 | var toString = Object.prototype.toString;
354 | var OBJECT_STRING = '[object Object]';
355 | function isPlainObject (obj) {
356 | return toString.call(obj) === OBJECT_STRING
357 | }
358 |
359 | /**
360 | * Merge an Array of Objects into a single Object.
361 | */
362 | function toObject (arr) {
363 | var res = {};
364 | for (var i = 0; i < arr.length; i++) {
365 | if (arr[i]) {
366 | extend(res, arr[i]);
367 | }
368 | }
369 | return res
370 | }
371 |
372 | /**
373 | * Perform no operation.
374 | */
375 | function noop () {}
376 |
377 | /**
378 | * Always return false.
379 | */
380 | var no = function () { return false; };
381 |
382 | /**
383 | * Return same value
384 | */
385 | var identity = function (_) { return _; };
386 |
387 | /**
388 | * Generate a static keys string from compiler modules.
389 | */
390 | function genStaticKeys (modules) {
391 | return modules.reduce(function (keys, m) {
392 | return keys.concat(m.staticKeys || [])
393 | }, []).join(',')
394 | }
395 |
396 | /**
397 | * Check if two values are loosely equal - that is,
398 | * if they are plain objects, do they have the same shape?
399 | */
400 | function looseEqual (a, b) {
401 | var isObjectA = isObject(a);
402 | var isObjectB = isObject(b);
403 | if (isObjectA && isObjectB) {
404 | return JSON.stringify(a) === JSON.stringify(b)
405 | } else if (!isObjectA && !isObjectB) {
406 | return String(a) === String(b)
407 | } else {
408 | return false
409 | }
410 | }
411 |
412 | function looseIndexOf (arr, val) {
413 | for (var i = 0; i < arr.length; i++) {
414 | if (looseEqual(arr[i], val)) { return i }
415 | }
416 | return -1
417 | }
418 |
419 | /* */
420 |
421 | var config = {
422 | /**
423 | * Option merge strategies (used in core/util/options)
424 | */
425 | optionMergeStrategies: Object.create(null),
426 |
427 | /**
428 | * Whether to suppress warnings.
429 | */
430 | silent: false,
431 |
432 | /**
433 | * Whether to enable devtools
434 | */
435 | devtools: ("production") !== 'production',
436 |
437 | /**
438 | * Error handler for watcher errors
439 | */
440 | errorHandler: null,
441 |
442 | /**
443 | * Ignore certain custom elements
444 | */
445 | ignoredElements: [],
446 |
447 | /**
448 | * Custom user key aliases for v-on
449 | */
450 | keyCodes: Object.create(null),
451 |
452 | /**
453 | * Check if a tag is reserved so that it cannot be registered as a
454 | * component. This is platform-dependent and may be overwritten.
455 | */
456 | isReservedTag: no,
457 |
458 | /**
459 | * Check if a tag is an unknown element.
460 | * Platform-dependent.
461 | */
462 | isUnknownElement: no,
463 |
464 | /**
465 | * Get the namespace of an element
466 | */
467 | getTagNamespace: noop,
468 |
469 | /**
470 | * Parse the real tag name for the specific platform.
471 | */
472 | parsePlatformTagName: identity,
473 |
474 | /**
475 | * Check if an attribute must be bound using property, e.g. value
476 | * Platform-dependent.
477 | */
478 | mustUseProp: no,
479 |
480 | /**
481 | * List of asset types that a component can own.
482 | */
483 | _assetTypes: [
484 | 'component',
485 | 'directive',
486 | 'filter'
487 | ],
488 |
489 | /**
490 | * List of lifecycle hooks.
491 | */
492 | _lifecycleHooks: [
493 | 'beforeCreate',
494 | 'created',
495 | 'beforeMount',
496 | 'mounted',
497 | 'beforeUpdate',
498 | 'updated',
499 | 'beforeDestroy',
500 | 'destroyed',
501 | 'activated',
502 | 'deactivated'
503 | ],
504 |
505 | /**
506 | * Max circular updates allowed in a scheduler flush cycle.
507 | */
508 | _maxUpdateCount: 100
509 | };
510 |
511 | /* */
512 |
513 | /**
514 | * Check if a string starts with $ or _
515 | */
516 | function isReserved (str) {
517 | var c = (str + '').charCodeAt(0);
518 | return c === 0x24 || c === 0x5F
519 | }
520 |
521 | /**
522 | * Define a property.
523 | */
524 | function def (obj, key, val, enumerable) {
525 | Object.defineProperty(obj, key, {
526 | value: val,
527 | enumerable: !!enumerable,
528 | writable: true,
529 | configurable: true
530 | });
531 | }
532 |
533 | /**
534 | * Parse simple path.
535 | */
536 | var bailRE = /[^\w.$]/;
537 | function parsePath (path) {
538 | if (bailRE.test(path)) {
539 | return
540 | } else {
541 | var segments = path.split('.');
542 | return function (obj) {
543 | for (var i = 0; i < segments.length; i++) {
544 | if (!obj) { return }
545 | obj = obj[segments[i]];
546 | }
547 | return obj
548 | }
549 | }
550 | }
551 |
552 | /* */
553 | /* globals MutationObserver */
554 |
555 | // can we use __proto__?
556 | var hasProto = '__proto__' in {};
557 |
558 | // Browser environment sniffing
559 | var inBrowser = typeof window !== 'undefined';
560 | var UA = inBrowser && window.navigator.userAgent.toLowerCase();
561 | var isIE = UA && /msie|trident/.test(UA);
562 | var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
563 | var isEdge = UA && UA.indexOf('edge/') > 0;
564 | var isAndroid = UA && UA.indexOf('android') > 0;
565 | var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA);
566 |
567 | // this needs to be lazy-evaled because vue may be required before
568 | // vue-server-renderer can set VUE_ENV
569 | var _isServer;
570 | var isServerRendering = function () {
571 | if (_isServer === undefined) {
572 | /* istanbul ignore if */
573 | if (!inBrowser && typeof global !== 'undefined') {
574 | // detect presence of vue-server-renderer and avoid
575 | // Webpack shimming the process
576 | _isServer = global['process'].env.VUE_ENV === 'server';
577 | } else {
578 | _isServer = false;
579 | }
580 | }
581 | return _isServer
582 | };
583 |
584 | // detect devtools
585 | var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
586 |
587 | /* istanbul ignore next */
588 | function isNative (Ctor) {
589 | return /native code/.test(Ctor.toString())
590 | }
591 |
592 | /**
593 | * Defer a task to execute it asynchronously.
594 | */
595 | var nextTick = (function () {
596 | var callbacks = [];
597 | var pending = false;
598 | var timerFunc;
599 |
600 | function nextTickHandler () {
601 | pending = false;
602 | var copies = callbacks.slice(0);
603 | callbacks.length = 0;
604 | for (var i = 0; i < copies.length; i++) {
605 | copies[i]();
606 | }
607 | }
608 |
609 | // the nextTick behavior leverages the microtask queue, which can be accessed
610 | // via either native Promise.then or MutationObserver.
611 | // MutationObserver has wider support, however it is seriously bugged in
612 | // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It
613 | // completely stops working after triggering a few times... so, if native
614 | // Promise is available, we will use it:
615 | /* istanbul ignore if */
616 | if (typeof Promise !== 'undefined' && isNative(Promise)) {
617 | var p = Promise.resolve();
618 | var logError = function (err) { console.error(err); };
619 | timerFunc = function () {
620 | p.then(nextTickHandler).catch(logError);
621 | // in problematic UIWebViews, Promise.then doesn't completely break, but
622 | // it can get stuck in a weird state where callbacks are pushed into the
623 | // microtask queue but the queue isn't being flushed, until the browser
624 | // needs to do some other work, e.g. handle a timer. Therefore we can
625 | // "force" the microtask queue to be flushed by adding an empty timer.
626 | if (isIOS) { setTimeout(noop); }
627 | };
628 | } else if (typeof MutationObserver !== 'undefined' && (
629 | isNative(MutationObserver) ||
630 | // PhantomJS and iOS 7.x
631 | MutationObserver.toString() === '[object MutationObserverConstructor]'
632 | )) {
633 | // use MutationObserver where native Promise is not available,
634 | // e.g. PhantomJS IE11, iOS7, Android 4.4
635 | var counter = 1;
636 | var observer = new MutationObserver(nextTickHandler);
637 | var textNode = document.createTextNode(String(counter));
638 | observer.observe(textNode, {
639 | characterData: true
640 | });
641 | timerFunc = function () {
642 | counter = (counter + 1) % 2;
643 | textNode.data = String(counter);
644 | };
645 | } else {
646 | // fallback to setTimeout
647 | /* istanbul ignore next */
648 | timerFunc = function () {
649 | setTimeout(nextTickHandler, 0);
650 | };
651 | }
652 |
653 | return function queueNextTick (cb, ctx) {
654 | var _resolve;
655 | callbacks.push(function () {
656 | if (cb) { cb.call(ctx); }
657 | if (_resolve) { _resolve(ctx); }
658 | });
659 | if (!pending) {
660 | pending = true;
661 | timerFunc();
662 | }
663 | if (!cb && typeof Promise !== 'undefined') {
664 | return new Promise(function (resolve) {
665 | _resolve = resolve;
666 | })
667 | }
668 | }
669 | })();
670 |
671 | var _Set;
672 | /* istanbul ignore if */
673 | if (typeof Set !== 'undefined' && isNative(Set)) {
674 | // use native Set when available.
675 | _Set = Set;
676 | } else {
677 | // a non-standard Set polyfill that only works with primitive keys.
678 | _Set = (function () {
679 | function Set () {
680 | this.set = Object.create(null);
681 | }
682 | Set.prototype.has = function has (key) {
683 | return this.set[key] === true
684 | };
685 | Set.prototype.add = function add (key) {
686 | this.set[key] = true;
687 | };
688 | Set.prototype.clear = function clear () {
689 | this.set = Object.create(null);
690 | };
691 |
692 | return Set;
693 | }());
694 | }
695 |
696 | var warn = noop;
697 | var formatComponentName;
698 |
699 | if (false) {
700 | var hasConsole = typeof console !== 'undefined';
701 |
702 | warn = function (msg, vm) {
703 | if (hasConsole && (!config.silent)) {
704 | console.error("[Vue warn]: " + msg + " " + (
705 | vm ? formatLocation(formatComponentName(vm)) : ''
706 | ));
707 | }
708 | };
709 |
710 | formatComponentName = function (vm) {
711 | if (vm.$root === vm) {
712 | return 'root instance'
713 | }
714 | var name = vm._isVue
715 | ? vm.$options.name || vm.$options._componentTag
716 | : vm.name;
717 | return (
718 | (name ? ("component <" + name + ">") : "anonymous component") +
719 | (vm._isVue && vm.$options.__file ? (" at " + (vm.$options.__file)) : '')
720 | )
721 | };
722 |
723 | var formatLocation = function (str) {
724 | if (str === 'anonymous component') {
725 | str += " - use the \"name\" option for better debugging messages.";
726 | }
727 | return ("\n(found in " + str + ")")
728 | };
729 | }
730 |
731 | /* */
732 |
733 |
734 | var uid$1 = 0;
735 |
736 | /**
737 | * A dep is an observable that can have multiple
738 | * directives subscribing to it.
739 | */
740 | var Dep = function Dep () {
741 | this.id = uid$1++;
742 | this.subs = [];
743 | };
744 |
745 | Dep.prototype.addSub = function addSub (sub) {
746 | this.subs.push(sub);
747 | };
748 |
749 | Dep.prototype.removeSub = function removeSub (sub) {
750 | remove$1(this.subs, sub);
751 | };
752 |
753 | Dep.prototype.depend = function depend () {
754 | if (Dep.target) {
755 | Dep.target.addDep(this);
756 | }
757 | };
758 |
759 | Dep.prototype.notify = function notify () {
760 | // stablize the subscriber list first
761 | var subs = this.subs.slice();
762 | for (var i = 0, l = subs.length; i < l; i++) {
763 | subs[i].update();
764 | }
765 | };
766 |
767 | // the current target watcher being evaluated.
768 | // this is globally unique because there could be only one
769 | // watcher being evaluated at any time.
770 | Dep.target = null;
771 | var targetStack = [];
772 |
773 | function pushTarget (_target) {
774 | if (Dep.target) { targetStack.push(Dep.target); }
775 | Dep.target = _target;
776 | }
777 |
778 | function popTarget () {
779 | Dep.target = targetStack.pop();
780 | }
781 |
782 | /*
783 | * not type checking this file because flow doesn't play well with
784 | * dynamically accessing methods on Array prototype
785 | */
786 |
787 | var arrayProto = Array.prototype;
788 | var arrayMethods = Object.create(arrayProto);[
789 | 'push',
790 | 'pop',
791 | 'shift',
792 | 'unshift',
793 | 'splice',
794 | 'sort',
795 | 'reverse'
796 | ]
797 | .forEach(function (method) {
798 | // cache original method
799 | var original = arrayProto[method];
800 | def(arrayMethods, method, function mutator () {
801 | var arguments$1 = arguments;
802 |
803 | // avoid leaking arguments:
804 | // http://jsperf.com/closure-with-arguments
805 | var i = arguments.length;
806 | var args = new Array(i);
807 | while (i--) {
808 | args[i] = arguments$1[i];
809 | }
810 | var result = original.apply(this, args);
811 | var ob = this.__ob__;
812 | var inserted;
813 | switch (method) {
814 | case 'push':
815 | inserted = args;
816 | break
817 | case 'unshift':
818 | inserted = args;
819 | break
820 | case 'splice':
821 | inserted = args.slice(2);
822 | break
823 | }
824 | if (inserted) { ob.observeArray(inserted); }
825 | // notify change
826 | ob.dep.notify();
827 | return result
828 | });
829 | });
830 |
831 | /* */
832 |
833 | var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
834 |
835 | /**
836 | * By default, when a reactive property is set, the new value is
837 | * also converted to become reactive. However when passing down props,
838 | * we don't want to force conversion because the value may be a nested value
839 | * under a frozen data structure. Converting it would defeat the optimization.
840 | */
841 | var observerState = {
842 | shouldConvert: true,
843 | isSettingProps: false
844 | };
845 |
846 | /**
847 | * Observer class that are attached to each observed
848 | * object. Once attached, the observer converts target
849 | * object's property keys into getter/setters that
850 | * collect dependencies and dispatches updates.
851 | */
852 | var Observer = function Observer (value) {
853 | this.value = value;
854 | this.dep = new Dep();
855 | this.vmCount = 0;
856 | def(value, '__ob__', this);
857 | if (Array.isArray(value)) {
858 | var augment = hasProto
859 | ? protoAugment
860 | : copyAugment;
861 | augment(value, arrayMethods, arrayKeys);
862 | this.observeArray(value);
863 | } else {
864 | this.walk(value);
865 | }
866 | };
867 |
868 | /**
869 | * Walk through each property and convert them into
870 | * getter/setters. This method should only be called when
871 | * value type is Object.
872 | */
873 | Observer.prototype.walk = function walk (obj) {
874 | var keys = Object.keys(obj);
875 | for (var i = 0; i < keys.length; i++) {
876 | defineReactive$$1(obj, keys[i], obj[keys[i]]);
877 | }
878 | };
879 |
880 | /**
881 | * Observe a list of Array items.
882 | */
883 | Observer.prototype.observeArray = function observeArray (items) {
884 | for (var i = 0, l = items.length; i < l; i++) {
885 | observe(items[i]);
886 | }
887 | };
888 |
889 | // helpers
890 |
891 | /**
892 | * Augment an target Object or Array by intercepting
893 | * the prototype chain using __proto__
894 | */
895 | function protoAugment (target, src) {
896 | /* eslint-disable no-proto */
897 | target.__proto__ = src;
898 | /* eslint-enable no-proto */
899 | }
900 |
901 | /**
902 | * Augment an target Object or Array by defining
903 | * hidden properties.
904 | */
905 | /* istanbul ignore next */
906 | function copyAugment (target, src, keys) {
907 | for (var i = 0, l = keys.length; i < l; i++) {
908 | var key = keys[i];
909 | def(target, key, src[key]);
910 | }
911 | }
912 |
913 | /**
914 | * Attempt to create an observer instance for a value,
915 | * returns the new observer if successfully observed,
916 | * or the existing observer if the value already has one.
917 | */
918 | function observe (value, asRootData) {
919 | if (!isObject(value)) {
920 | return
921 | }
922 | var ob;
923 | if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
924 | ob = value.__ob__;
925 | } else if (
926 | observerState.shouldConvert &&
927 | !isServerRendering() &&
928 | (Array.isArray(value) || isPlainObject(value)) &&
929 | Object.isExtensible(value) &&
930 | !value._isVue
931 | ) {
932 | ob = new Observer(value);
933 | }
934 | if (asRootData && ob) {
935 | ob.vmCount++;
936 | }
937 | return ob
938 | }
939 |
940 | /**
941 | * Define a reactive property on an Object.
942 | */
943 | function defineReactive$$1 (
944 | obj,
945 | key,
946 | val,
947 | customSetter
948 | ) {
949 | var dep = new Dep();
950 |
951 | var property = Object.getOwnPropertyDescriptor(obj, key);
952 | if (property && property.configurable === false) {
953 | return
954 | }
955 |
956 | // cater for pre-defined getter/setters
957 | var getter = property && property.get;
958 | var setter = property && property.set;
959 |
960 | var childOb = observe(val);
961 | Object.defineProperty(obj, key, {
962 | enumerable: true,
963 | configurable: true,
964 | get: function reactiveGetter () {
965 | var value = getter ? getter.call(obj) : val;
966 | if (Dep.target) {
967 | dep.depend();
968 | if (childOb) {
969 | childOb.dep.depend();
970 | }
971 | if (Array.isArray(value)) {
972 | dependArray(value);
973 | }
974 | }
975 | return value
976 | },
977 | set: function reactiveSetter (newVal) {
978 | var value = getter ? getter.call(obj) : val;
979 | /* eslint-disable no-self-compare */
980 | if (newVal === value || (newVal !== newVal && value !== value)) {
981 | return
982 | }
983 | /* eslint-enable no-self-compare */
984 | if (false) {
985 | customSetter();
986 | }
987 | if (setter) {
988 | setter.call(obj, newVal);
989 | } else {
990 | val = newVal;
991 | }
992 | childOb = observe(newVal);
993 | dep.notify();
994 | }
995 | });
996 | }
997 |
998 | /**
999 | * Set a property on an object. Adds the new property and
1000 | * triggers change notification if the property doesn't
1001 | * already exist.
1002 | */
1003 | function set$1 (obj, key, val) {
1004 | if (Array.isArray(obj)) {
1005 | obj.length = Math.max(obj.length, key);
1006 | obj.splice(key, 1, val);
1007 | return val
1008 | }
1009 | if (hasOwn(obj, key)) {
1010 | obj[key] = val;
1011 | return
1012 | }
1013 | var ob = obj.__ob__;
1014 | if (obj._isVue || (ob && ob.vmCount)) {
1015 | ("production") !== 'production' && warn(
1016 | 'Avoid adding reactive properties to a Vue instance or its root $data ' +
1017 | 'at runtime - declare it upfront in the data option.'
1018 | );
1019 | return
1020 | }
1021 | if (!ob) {
1022 | obj[key] = val;
1023 | return
1024 | }
1025 | defineReactive$$1(ob.value, key, val);
1026 | ob.dep.notify();
1027 | return val
1028 | }
1029 |
1030 | /**
1031 | * Delete a property and trigger change if necessary.
1032 | */
1033 | function del (obj, key) {
1034 | var ob = obj.__ob__;
1035 | if (obj._isVue || (ob && ob.vmCount)) {
1036 | ("production") !== 'production' && warn(
1037 | 'Avoid deleting properties on a Vue instance or its root $data ' +
1038 | '- just set it to null.'
1039 | );
1040 | return
1041 | }
1042 | if (!hasOwn(obj, key)) {
1043 | return
1044 | }
1045 | delete obj[key];
1046 | if (!ob) {
1047 | return
1048 | }
1049 | ob.dep.notify();
1050 | }
1051 |
1052 | /**
1053 | * Collect dependencies on array elements when the array is touched, since
1054 | * we cannot intercept array element access like property getters.
1055 | */
1056 | function dependArray (value) {
1057 | for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
1058 | e = value[i];
1059 | e && e.__ob__ && e.__ob__.dep.depend();
1060 | if (Array.isArray(e)) {
1061 | dependArray(e);
1062 | }
1063 | }
1064 | }
1065 |
1066 | /* */
1067 |
1068 | /**
1069 | * Option overwriting strategies are functions that handle
1070 | * how to merge a parent option value and a child option
1071 | * value into the final value.
1072 | */
1073 | var strats = config.optionMergeStrategies;
1074 |
1075 | /**
1076 | * Options with restrictions
1077 | */
1078 | if (false) {
1079 | strats.el = strats.propsData = function (parent, child, vm, key) {
1080 | if (!vm) {
1081 | warn(
1082 | "option \"" + key + "\" can only be used during instance " +
1083 | 'creation with the `new` keyword.'
1084 | );
1085 | }
1086 | return defaultStrat(parent, child)
1087 | };
1088 | }
1089 |
1090 | /**
1091 | * Helper that recursively merges two data objects together.
1092 | */
1093 | function mergeData (to, from) {
1094 | if (!from) { return to }
1095 | var key, toVal, fromVal;
1096 | var keys = Object.keys(from);
1097 | for (var i = 0; i < keys.length; i++) {
1098 | key = keys[i];
1099 | toVal = to[key];
1100 | fromVal = from[key];
1101 | if (!hasOwn(to, key)) {
1102 | set$1(to, key, fromVal);
1103 | } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
1104 | mergeData(toVal, fromVal);
1105 | }
1106 | }
1107 | return to
1108 | }
1109 |
1110 | /**
1111 | * Data
1112 | */
1113 | strats.data = function (
1114 | parentVal,
1115 | childVal,
1116 | vm
1117 | ) {
1118 | if (!vm) {
1119 | // in a Vue.extend merge, both should be functions
1120 | if (!childVal) {
1121 | return parentVal
1122 | }
1123 | if (typeof childVal !== 'function') {
1124 | ("production") !== 'production' && warn(
1125 | 'The "data" option should be a function ' +
1126 | 'that returns a per-instance value in component ' +
1127 | 'definitions.',
1128 | vm
1129 | );
1130 | return parentVal
1131 | }
1132 | if (!parentVal) {
1133 | return childVal
1134 | }
1135 | // when parentVal & childVal are both present,
1136 | // we need to return a function that returns the
1137 | // merged result of both functions... no need to
1138 | // check if parentVal is a function here because
1139 | // it has to be a function to pass previous merges.
1140 | return function mergedDataFn () {
1141 | return mergeData(
1142 | childVal.call(this),
1143 | parentVal.call(this)
1144 | )
1145 | }
1146 | } else if (parentVal || childVal) {
1147 | return function mergedInstanceDataFn () {
1148 | // instance merge
1149 | var instanceData = typeof childVal === 'function'
1150 | ? childVal.call(vm)
1151 | : childVal;
1152 | var defaultData = typeof parentVal === 'function'
1153 | ? parentVal.call(vm)
1154 | : undefined;
1155 | if (instanceData) {
1156 | return mergeData(instanceData, defaultData)
1157 | } else {
1158 | return defaultData
1159 | }
1160 | }
1161 | }
1162 | };
1163 |
1164 | /**
1165 | * Hooks and param attributes are merged as arrays.
1166 | */
1167 | function mergeHook (
1168 | parentVal,
1169 | childVal
1170 | ) {
1171 | return childVal
1172 | ? parentVal
1173 | ? parentVal.concat(childVal)
1174 | : Array.isArray(childVal)
1175 | ? childVal
1176 | : [childVal]
1177 | : parentVal
1178 | }
1179 |
1180 | config._lifecycleHooks.forEach(function (hook) {
1181 | strats[hook] = mergeHook;
1182 | });
1183 |
1184 | /**
1185 | * Assets
1186 | *
1187 | * When a vm is present (instance creation), we need to do
1188 | * a three-way merge between constructor options, instance
1189 | * options and parent options.
1190 | */
1191 | function mergeAssets (parentVal, childVal) {
1192 | var res = Object.create(parentVal || null);
1193 | return childVal
1194 | ? extend(res, childVal)
1195 | : res
1196 | }
1197 |
1198 | config._assetTypes.forEach(function (type) {
1199 | strats[type + 's'] = mergeAssets;
1200 | });
1201 |
1202 | /**
1203 | * Watchers.
1204 | *
1205 | * Watchers hashes should not overwrite one
1206 | * another, so we merge them as arrays.
1207 | */
1208 | strats.watch = function (parentVal, childVal) {
1209 | /* istanbul ignore if */
1210 | if (!childVal) { return parentVal }
1211 | if (!parentVal) { return childVal }
1212 | var ret = {};
1213 | extend(ret, parentVal);
1214 | for (var key in childVal) {
1215 | var parent = ret[key];
1216 | var child = childVal[key];
1217 | if (parent && !Array.isArray(parent)) {
1218 | parent = [parent];
1219 | }
1220 | ret[key] = parent
1221 | ? parent.concat(child)
1222 | : [child];
1223 | }
1224 | return ret
1225 | };
1226 |
1227 | /**
1228 | * Other object hashes.
1229 | */
1230 | strats.props =
1231 | strats.methods =
1232 | strats.computed = function (parentVal, childVal) {
1233 | if (!childVal) { return parentVal }
1234 | if (!parentVal) { return childVal }
1235 | var ret = Object.create(null);
1236 | extend(ret, parentVal);
1237 | extend(ret, childVal);
1238 | return ret
1239 | };
1240 |
1241 | /**
1242 | * Default strategy.
1243 | */
1244 | var defaultStrat = function (parentVal, childVal) {
1245 | return childVal === undefined
1246 | ? parentVal
1247 | : childVal
1248 | };
1249 |
1250 | /**
1251 | * Validate component names
1252 | */
1253 | function checkComponents (options) {
1254 | for (var key in options.components) {
1255 | var lower = key.toLowerCase();
1256 | if (isBuiltInTag(lower) || config.isReservedTag(lower)) {
1257 | warn(
1258 | 'Do not use built-in or reserved HTML elements as component ' +
1259 | 'id: ' + key
1260 | );
1261 | }
1262 | }
1263 | }
1264 |
1265 | /**
1266 | * Ensure all props option syntax are normalized into the
1267 | * Object-based format.
1268 | */
1269 | function normalizeProps (options) {
1270 | var props = options.props;
1271 | if (!props) { return }
1272 | var res = {};
1273 | var i, val, name;
1274 | if (Array.isArray(props)) {
1275 | i = props.length;
1276 | while (i--) {
1277 | val = props[i];
1278 | if (typeof val === 'string') {
1279 | name = camelize(val);
1280 | res[name] = { type: null };
1281 | } else if (false) {
1282 | warn('props must be strings when using array syntax.');
1283 | }
1284 | }
1285 | } else if (isPlainObject(props)) {
1286 | for (var key in props) {
1287 | val = props[key];
1288 | name = camelize(key);
1289 | res[name] = isPlainObject(val)
1290 | ? val
1291 | : { type: val };
1292 | }
1293 | }
1294 | options.props = res;
1295 | }
1296 |
1297 | /**
1298 | * Normalize raw function directives into object format.
1299 | */
1300 | function normalizeDirectives (options) {
1301 | var dirs = options.directives;
1302 | if (dirs) {
1303 | for (var key in dirs) {
1304 | var def = dirs[key];
1305 | if (typeof def === 'function') {
1306 | dirs[key] = { bind: def, update: def };
1307 | }
1308 | }
1309 | }
1310 | }
1311 |
1312 | /**
1313 | * Merge two option objects into a new one.
1314 | * Core utility used in both instantiation and inheritance.
1315 | */
1316 | function mergeOptions (
1317 | parent,
1318 | child,
1319 | vm
1320 | ) {
1321 | if (false) {
1322 | checkComponents(child);
1323 | }
1324 | normalizeProps(child);
1325 | normalizeDirectives(child);
1326 | var extendsFrom = child.extends;
1327 | if (extendsFrom) {
1328 | parent = typeof extendsFrom === 'function'
1329 | ? mergeOptions(parent, extendsFrom.options, vm)
1330 | : mergeOptions(parent, extendsFrom, vm);
1331 | }
1332 | if (child.mixins) {
1333 | for (var i = 0, l = child.mixins.length; i < l; i++) {
1334 | var mixin = child.mixins[i];
1335 | if (mixin.prototype instanceof Vue$2) {
1336 | mixin = mixin.options;
1337 | }
1338 | parent = mergeOptions(parent, mixin, vm);
1339 | }
1340 | }
1341 | var options = {};
1342 | var key;
1343 | for (key in parent) {
1344 | mergeField(key);
1345 | }
1346 | for (key in child) {
1347 | if (!hasOwn(parent, key)) {
1348 | mergeField(key);
1349 | }
1350 | }
1351 | function mergeField (key) {
1352 | var strat = strats[key] || defaultStrat;
1353 | options[key] = strat(parent[key], child[key], vm, key);
1354 | }
1355 | return options
1356 | }
1357 |
1358 | /**
1359 | * Resolve an asset.
1360 | * This function is used because child instances need access
1361 | * to assets defined in its ancestor chain.
1362 | */
1363 | function resolveAsset (
1364 | options,
1365 | type,
1366 | id,
1367 | warnMissing
1368 | ) {
1369 | /* istanbul ignore if */
1370 | if (typeof id !== 'string') {
1371 | return
1372 | }
1373 | var assets = options[type];
1374 | // check local registration variations first
1375 | if (hasOwn(assets, id)) { return assets[id] }
1376 | var camelizedId = camelize(id);
1377 | if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
1378 | var PascalCaseId = capitalize(camelizedId);
1379 | if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
1380 | // fallback to prototype chain
1381 | var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
1382 | if (false) {
1383 | warn(
1384 | 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
1385 | options
1386 | );
1387 | }
1388 | return res
1389 | }
1390 |
1391 | /* */
1392 |
1393 | function validateProp (
1394 | key,
1395 | propOptions,
1396 | propsData,
1397 | vm
1398 | ) {
1399 | var prop = propOptions[key];
1400 | var absent = !hasOwn(propsData, key);
1401 | var value = propsData[key];
1402 | // handle boolean props
1403 | if (isType(Boolean, prop.type)) {
1404 | if (absent && !hasOwn(prop, 'default')) {
1405 | value = false;
1406 | } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
1407 | value = true;
1408 | }
1409 | }
1410 | // check default value
1411 | if (value === undefined) {
1412 | value = getPropDefaultValue(vm, prop, key);
1413 | // since the default value is a fresh copy,
1414 | // make sure to observe it.
1415 | var prevShouldConvert = observerState.shouldConvert;
1416 | observerState.shouldConvert = true;
1417 | observe(value);
1418 | observerState.shouldConvert = prevShouldConvert;
1419 | }
1420 | if (false) {
1421 | assertProp(prop, key, value, vm, absent);
1422 | }
1423 | return value
1424 | }
1425 |
1426 | /**
1427 | * Get the default value of a prop.
1428 | */
1429 | function getPropDefaultValue (vm, prop, key) {
1430 | // no default, return undefined
1431 | if (!hasOwn(prop, 'default')) {
1432 | return undefined
1433 | }
1434 | var def = prop.default;
1435 | // warn against non-factory defaults for Object & Array
1436 | if (isObject(def)) {
1437 | ("production") !== 'production' && warn(
1438 | 'Invalid default value for prop "' + key + '": ' +
1439 | 'Props with type Object/Array must use a factory function ' +
1440 | 'to return the default value.',
1441 | vm
1442 | );
1443 | }
1444 | // the raw prop value was also undefined from previous render,
1445 | // return previous default value to avoid unnecessary watcher trigger
1446 | if (vm && vm.$options.propsData &&
1447 | vm.$options.propsData[key] === undefined &&
1448 | vm[key] !== undefined) {
1449 | return vm[key]
1450 | }
1451 | // call factory function for non-Function types
1452 | return typeof def === 'function' && prop.type !== Function
1453 | ? def.call(vm)
1454 | : def
1455 | }
1456 |
1457 | /**
1458 | * Assert whether a prop is valid.
1459 | */
1460 | function assertProp (
1461 | prop,
1462 | name,
1463 | value,
1464 | vm,
1465 | absent
1466 | ) {
1467 | if (prop.required && absent) {
1468 | warn(
1469 | 'Missing required prop: "' + name + '"',
1470 | vm
1471 | );
1472 | return
1473 | }
1474 | if (value == null && !prop.required) {
1475 | return
1476 | }
1477 | var type = prop.type;
1478 | var valid = !type || type === true;
1479 | var expectedTypes = [];
1480 | if (type) {
1481 | if (!Array.isArray(type)) {
1482 | type = [type];
1483 | }
1484 | for (var i = 0; i < type.length && !valid; i++) {
1485 | var assertedType = assertType(value, type[i]);
1486 | expectedTypes.push(assertedType.expectedType || '');
1487 | valid = assertedType.valid;
1488 | }
1489 | }
1490 | if (!valid) {
1491 | warn(
1492 | 'Invalid prop: type check failed for prop "' + name + '".' +
1493 | ' Expected ' + expectedTypes.map(capitalize).join(', ') +
1494 | ', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.',
1495 | vm
1496 | );
1497 | return
1498 | }
1499 | var validator = prop.validator;
1500 | if (validator) {
1501 | if (!validator(value)) {
1502 | warn(
1503 | 'Invalid prop: custom validator check failed for prop "' + name + '".',
1504 | vm
1505 | );
1506 | }
1507 | }
1508 | }
1509 |
1510 | /**
1511 | * Assert the type of a value
1512 | */
1513 | function assertType (value, type) {
1514 | var valid;
1515 | var expectedType = getType(type);
1516 | if (expectedType === 'String') {
1517 | valid = typeof value === (expectedType = 'string');
1518 | } else if (expectedType === 'Number') {
1519 | valid = typeof value === (expectedType = 'number');
1520 | } else if (expectedType === 'Boolean') {
1521 | valid = typeof value === (expectedType = 'boolean');
1522 | } else if (expectedType === 'Function') {
1523 | valid = typeof value === (expectedType = 'function');
1524 | } else if (expectedType === 'Object') {
1525 | valid = isPlainObject(value);
1526 | } else if (expectedType === 'Array') {
1527 | valid = Array.isArray(value);
1528 | } else {
1529 | valid = value instanceof type;
1530 | }
1531 | return {
1532 | valid: valid,
1533 | expectedType: expectedType
1534 | }
1535 | }
1536 |
1537 | /**
1538 | * Use function string name to check built-in types,
1539 | * because a simple equality check will fail when running
1540 | * across different vms / iframes.
1541 | */
1542 | function getType (fn) {
1543 | var match = fn && fn.toString().match(/^\s*function (\w+)/);
1544 | return match && match[1]
1545 | }
1546 |
1547 | function isType (type, fn) {
1548 | if (!Array.isArray(fn)) {
1549 | return getType(fn) === getType(type)
1550 | }
1551 | for (var i = 0, len = fn.length; i < len; i++) {
1552 | if (getType(fn[i]) === getType(type)) {
1553 | return true
1554 | }
1555 | }
1556 | /* istanbul ignore next */
1557 | return false
1558 | }
1559 |
1560 |
1561 |
1562 | var util = Object.freeze({
1563 | defineReactive: defineReactive$$1,
1564 | _toString: _toString,
1565 | toNumber: toNumber,
1566 | makeMap: makeMap,
1567 | isBuiltInTag: isBuiltInTag,
1568 | remove: remove$1,
1569 | hasOwn: hasOwn,
1570 | isPrimitive: isPrimitive,
1571 | cached: cached,
1572 | camelize: camelize,
1573 | capitalize: capitalize,
1574 | hyphenate: hyphenate,
1575 | bind: bind$1,
1576 | toArray: toArray,
1577 | extend: extend,
1578 | isObject: isObject,
1579 | isPlainObject: isPlainObject,
1580 | toObject: toObject,
1581 | noop: noop,
1582 | no: no,
1583 | identity: identity,
1584 | genStaticKeys: genStaticKeys,
1585 | looseEqual: looseEqual,
1586 | looseIndexOf: looseIndexOf,
1587 | isReserved: isReserved,
1588 | def: def,
1589 | parsePath: parsePath,
1590 | hasProto: hasProto,
1591 | inBrowser: inBrowser,
1592 | UA: UA,
1593 | isIE: isIE,
1594 | isIE9: isIE9,
1595 | isEdge: isEdge,
1596 | isAndroid: isAndroid,
1597 | isIOS: isIOS,
1598 | isServerRendering: isServerRendering,
1599 | devtools: devtools,
1600 | nextTick: nextTick,
1601 | get _Set () { return _Set; },
1602 | mergeOptions: mergeOptions,
1603 | resolveAsset: resolveAsset,
1604 | get warn () { return warn; },
1605 | get formatComponentName () { return formatComponentName; },
1606 | validateProp: validateProp
1607 | });
1608 |
1609 | /* not type checking this file because flow doesn't play well with Proxy */
1610 |
1611 | var initProxy;
1612 |
1613 | if (false) {
1614 | var allowedGlobals = makeMap(
1615 | 'Infinity,undefined,NaN,isFinite,isNaN,' +
1616 | 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
1617 | 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
1618 | 'require' // for Webpack/Browserify
1619 | );
1620 |
1621 | var warnNonPresent = function (target, key) {
1622 | warn(
1623 | "Property or method \"" + key + "\" is not defined on the instance but " +
1624 | "referenced during render. Make sure to declare reactive data " +
1625 | "properties in the data option.",
1626 | target
1627 | );
1628 | };
1629 |
1630 | var hasProxy =
1631 | typeof Proxy !== 'undefined' &&
1632 | Proxy.toString().match(/native code/);
1633 |
1634 | if (hasProxy) {
1635 | var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta');
1636 | config.keyCodes = new Proxy(config.keyCodes, {
1637 | set: function set (target, key, value) {
1638 | if (isBuiltInModifier(key)) {
1639 | warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key));
1640 | return false
1641 | } else {
1642 | target[key] = value;
1643 | return true
1644 | }
1645 | }
1646 | });
1647 | }
1648 |
1649 | var hasHandler = {
1650 | has: function has (target, key) {
1651 | var has = key in target;
1652 | var isAllowed = allowedGlobals(key) || key.charAt(0) === '_';
1653 | if (!has && !isAllowed) {
1654 | warnNonPresent(target, key);
1655 | }
1656 | return has || !isAllowed
1657 | }
1658 | };
1659 |
1660 | var getHandler = {
1661 | get: function get (target, key) {
1662 | if (typeof key === 'string' && !(key in target)) {
1663 | warnNonPresent(target, key);
1664 | }
1665 | return target[key]
1666 | }
1667 | };
1668 |
1669 | initProxy = function initProxy (vm) {
1670 | if (hasProxy) {
1671 | // determine which proxy handler to use
1672 | var options = vm.$options;
1673 | var handlers = options.render && options.render._withStripped
1674 | ? getHandler
1675 | : hasHandler;
1676 | vm._renderProxy = new Proxy(vm, handlers);
1677 | } else {
1678 | vm._renderProxy = vm;
1679 | }
1680 | };
1681 | }
1682 |
1683 | /* */
1684 |
1685 | var VNode = function VNode (
1686 | tag,
1687 | data,
1688 | children,
1689 | text,
1690 | elm,
1691 | context,
1692 | componentOptions
1693 | ) {
1694 | this.tag = tag;
1695 | this.data = data;
1696 | this.children = children;
1697 | this.text = text;
1698 | this.elm = elm;
1699 | this.ns = undefined;
1700 | this.context = context;
1701 | this.functionalContext = undefined;
1702 | this.key = data && data.key;
1703 | this.componentOptions = componentOptions;
1704 | this.componentInstance = undefined;
1705 | this.parent = undefined;
1706 | this.raw = false;
1707 | this.isStatic = false;
1708 | this.isRootInsert = true;
1709 | this.isComment = false;
1710 | this.isCloned = false;
1711 | this.isOnce = false;
1712 | };
1713 |
1714 | var prototypeAccessors = { child: {} };
1715 |
1716 | // DEPRECATED: alias for componentInstance for backwards compat.
1717 | /* istanbul ignore next */
1718 | prototypeAccessors.child.get = function () {
1719 | return this.componentInstance
1720 | };
1721 |
1722 | Object.defineProperties( VNode.prototype, prototypeAccessors );
1723 |
1724 | var createEmptyVNode = function () {
1725 | var node = new VNode();
1726 | node.text = '';
1727 | node.isComment = true;
1728 | return node
1729 | };
1730 |
1731 | function createTextVNode (val) {
1732 | return new VNode(undefined, undefined, undefined, String(val))
1733 | }
1734 |
1735 | // optimized shallow clone
1736 | // used for static nodes and slot nodes because they may be reused across
1737 | // multiple renders, cloning them avoids errors when DOM manipulations rely
1738 | // on their elm reference.
1739 | function cloneVNode (vnode) {
1740 | var cloned = new VNode(
1741 | vnode.tag,
1742 | vnode.data,
1743 | vnode.children,
1744 | vnode.text,
1745 | vnode.elm,
1746 | vnode.context,
1747 | vnode.componentOptions
1748 | );
1749 | cloned.ns = vnode.ns;
1750 | cloned.isStatic = vnode.isStatic;
1751 | cloned.key = vnode.key;
1752 | cloned.isCloned = true;
1753 | return cloned
1754 | }
1755 |
1756 | function cloneVNodes (vnodes) {
1757 | var res = new Array(vnodes.length);
1758 | for (var i = 0; i < vnodes.length; i++) {
1759 | res[i] = cloneVNode(vnodes[i]);
1760 | }
1761 | return res
1762 | }
1763 |
1764 | /* */
1765 |
1766 | var hooks = { init: init, prepatch: prepatch, insert: insert, destroy: destroy$1 };
1767 | var hooksToMerge = Object.keys(hooks);
1768 |
1769 | function createComponent (
1770 | Ctor,
1771 | data,
1772 | context,
1773 | children,
1774 | tag
1775 | ) {
1776 | if (!Ctor) {
1777 | return
1778 | }
1779 |
1780 | var baseCtor = context.$options._base;
1781 | if (isObject(Ctor)) {
1782 | Ctor = baseCtor.extend(Ctor);
1783 | }
1784 |
1785 | if (typeof Ctor !== 'function') {
1786 | if (false) {
1787 | warn(("Invalid Component definition: " + (String(Ctor))), context);
1788 | }
1789 | return
1790 | }
1791 |
1792 | // async component
1793 | if (!Ctor.cid) {
1794 | if (Ctor.resolved) {
1795 | Ctor = Ctor.resolved;
1796 | } else {
1797 | Ctor = resolveAsyncComponent(Ctor, baseCtor, function () {
1798 | // it's ok to queue this on every render because
1799 | // $forceUpdate is buffered by the scheduler.
1800 | context.$forceUpdate();
1801 | });
1802 | if (!Ctor) {
1803 | // return nothing if this is indeed an async component
1804 | // wait for the callback to trigger parent update.
1805 | return
1806 | }
1807 | }
1808 | }
1809 |
1810 | // resolve constructor options in case global mixins are applied after
1811 | // component constructor creation
1812 | resolveConstructorOptions(Ctor);
1813 |
1814 | data = data || {};
1815 |
1816 | // extract props
1817 | var propsData = extractProps(data, Ctor);
1818 |
1819 | // functional component
1820 | if (Ctor.options.functional) {
1821 | return createFunctionalComponent(Ctor, propsData, data, context, children)
1822 | }
1823 |
1824 | // extract listeners, since these needs to be treated as
1825 | // child component listeners instead of DOM listeners
1826 | var listeners = data.on;
1827 | // replace with listeners with .native modifier
1828 | data.on = data.nativeOn;
1829 |
1830 | if (Ctor.options.abstract) {
1831 | // abstract components do not keep anything
1832 | // other than props & listeners
1833 | data = {};
1834 | }
1835 |
1836 | // merge component management hooks onto the placeholder node
1837 | mergeHooks(data);
1838 |
1839 | // return a placeholder vnode
1840 | var name = Ctor.options.name || tag;
1841 | var vnode = new VNode(
1842 | ("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')),
1843 | data, undefined, undefined, undefined, context,
1844 | { Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children }
1845 | );
1846 | return vnode
1847 | }
1848 |
1849 | function createFunctionalComponent (
1850 | Ctor,
1851 | propsData,
1852 | data,
1853 | context,
1854 | children
1855 | ) {
1856 | var props = {};
1857 | var propOptions = Ctor.options.props;
1858 | if (propOptions) {
1859 | for (var key in propOptions) {
1860 | props[key] = validateProp(key, propOptions, propsData);
1861 | }
1862 | }
1863 | // ensure the createElement function in functional components
1864 | // gets a unique context - this is necessary for correct named slot check
1865 | var _context = Object.create(context);
1866 | var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); };
1867 | var vnode = Ctor.options.render.call(null, h, {
1868 | props: props,
1869 | data: data,
1870 | parent: context,
1871 | children: children,
1872 | slots: function () { return resolveSlots(children, context); }
1873 | });
1874 | if (vnode instanceof VNode) {
1875 | vnode.functionalContext = context;
1876 | if (data.slot) {
1877 | (vnode.data || (vnode.data = {})).slot = data.slot;
1878 | }
1879 | }
1880 | return vnode
1881 | }
1882 |
1883 | function createComponentInstanceForVnode (
1884 | vnode, // we know it's MountedComponentVNode but flow doesn't
1885 | parent, // activeInstance in lifecycle state
1886 | parentElm,
1887 | refElm
1888 | ) {
1889 | var vnodeComponentOptions = vnode.componentOptions;
1890 | var options = {
1891 | _isComponent: true,
1892 | parent: parent,
1893 | propsData: vnodeComponentOptions.propsData,
1894 | _componentTag: vnodeComponentOptions.tag,
1895 | _parentVnode: vnode,
1896 | _parentListeners: vnodeComponentOptions.listeners,
1897 | _renderChildren: vnodeComponentOptions.children,
1898 | _parentElm: parentElm || null,
1899 | _refElm: refElm || null
1900 | };
1901 | // check inline-template render functions
1902 | var inlineTemplate = vnode.data.inlineTemplate;
1903 | if (inlineTemplate) {
1904 | options.render = inlineTemplate.render;
1905 | options.staticRenderFns = inlineTemplate.staticRenderFns;
1906 | }
1907 | return new vnodeComponentOptions.Ctor(options)
1908 | }
1909 |
1910 | function init (
1911 | vnode,
1912 | hydrating,
1913 | parentElm,
1914 | refElm
1915 | ) {
1916 | if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) {
1917 | var child = vnode.componentInstance = createComponentInstanceForVnode(
1918 | vnode,
1919 | activeInstance,
1920 | parentElm,
1921 | refElm
1922 | );
1923 | child.$mount(hydrating ? vnode.elm : undefined, hydrating);
1924 | } else if (vnode.data.keepAlive) {
1925 | // kept-alive components, treat as a patch
1926 | var mountedNode = vnode; // work around flow
1927 | prepatch(mountedNode, mountedNode);
1928 | }
1929 | }
1930 |
1931 | function prepatch (
1932 | oldVnode,
1933 | vnode
1934 | ) {
1935 | var options = vnode.componentOptions;
1936 | var child = vnode.componentInstance = oldVnode.componentInstance;
1937 | child._updateFromParent(
1938 | options.propsData, // updated props
1939 | options.listeners, // updated listeners
1940 | vnode, // new parent vnode
1941 | options.children // new children
1942 | );
1943 | }
1944 |
1945 | function insert (vnode) {
1946 | if (!vnode.componentInstance._isMounted) {
1947 | vnode.componentInstance._isMounted = true;
1948 | callHook(vnode.componentInstance, 'mounted');
1949 | }
1950 | if (vnode.data.keepAlive) {
1951 | vnode.componentInstance._inactive = false;
1952 | callHook(vnode.componentInstance, 'activated');
1953 | }
1954 | }
1955 |
1956 | function destroy$1 (vnode) {
1957 | if (!vnode.componentInstance._isDestroyed) {
1958 | if (!vnode.data.keepAlive) {
1959 | vnode.componentInstance.$destroy();
1960 | } else {
1961 | vnode.componentInstance._inactive = true;
1962 | callHook(vnode.componentInstance, 'deactivated');
1963 | }
1964 | }
1965 | }
1966 |
1967 | function resolveAsyncComponent (
1968 | factory,
1969 | baseCtor,
1970 | cb
1971 | ) {
1972 | if (factory.requested) {
1973 | // pool callbacks
1974 | factory.pendingCallbacks.push(cb);
1975 | } else {
1976 | factory.requested = true;
1977 | var cbs = factory.pendingCallbacks = [cb];
1978 | var sync = true;
1979 |
1980 | var resolve = function (res) {
1981 | if (isObject(res)) {
1982 | res = baseCtor.extend(res);
1983 | }
1984 | // cache resolved
1985 | factory.resolved = res;
1986 | // invoke callbacks only if this is not a synchronous resolve
1987 | // (async resolves are shimmed as synchronous during SSR)
1988 | if (!sync) {
1989 | for (var i = 0, l = cbs.length; i < l; i++) {
1990 | cbs[i](res);
1991 | }
1992 | }
1993 | };
1994 |
1995 | var reject = function (reason) {
1996 | ("production") !== 'production' && warn(
1997 | "Failed to resolve async component: " + (String(factory)) +
1998 | (reason ? ("\nReason: " + reason) : '')
1999 | );
2000 | };
2001 |
2002 | var res = factory(resolve, reject);
2003 |
2004 | // handle promise
2005 | if (res && typeof res.then === 'function' && !factory.resolved) {
2006 | res.then(resolve, reject);
2007 | }
2008 |
2009 | sync = false;
2010 | // return in case resolved synchronously
2011 | return factory.resolved
2012 | }
2013 | }
2014 |
2015 | function extractProps (data, Ctor) {
2016 | // we are only extracting raw values here.
2017 | // validation and default values are handled in the child
2018 | // component itself.
2019 | var propOptions = Ctor.options.props;
2020 | if (!propOptions) {
2021 | return
2022 | }
2023 | var res = {};
2024 | var attrs = data.attrs;
2025 | var props = data.props;
2026 | var domProps = data.domProps;
2027 | if (attrs || props || domProps) {
2028 | for (var key in propOptions) {
2029 | var altKey = hyphenate(key);
2030 | checkProp(res, props, key, altKey, true) ||
2031 | checkProp(res, attrs, key, altKey) ||
2032 | checkProp(res, domProps, key, altKey);
2033 | }
2034 | }
2035 | return res
2036 | }
2037 |
2038 | function checkProp (
2039 | res,
2040 | hash,
2041 | key,
2042 | altKey,
2043 | preserve
2044 | ) {
2045 | if (hash) {
2046 | if (hasOwn(hash, key)) {
2047 | res[key] = hash[key];
2048 | if (!preserve) {
2049 | delete hash[key];
2050 | }
2051 | return true
2052 | } else if (hasOwn(hash, altKey)) {
2053 | res[key] = hash[altKey];
2054 | if (!preserve) {
2055 | delete hash[altKey];
2056 | }
2057 | return true
2058 | }
2059 | }
2060 | return false
2061 | }
2062 |
2063 | function mergeHooks (data) {
2064 | if (!data.hook) {
2065 | data.hook = {};
2066 | }
2067 | for (var i = 0; i < hooksToMerge.length; i++) {
2068 | var key = hooksToMerge[i];
2069 | var fromParent = data.hook[key];
2070 | var ours = hooks[key];
2071 | data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours;
2072 | }
2073 | }
2074 |
2075 | function mergeHook$1 (one, two) {
2076 | return function (a, b, c, d) {
2077 | one(a, b, c, d);
2078 | two(a, b, c, d);
2079 | }
2080 | }
2081 |
2082 | /* */
2083 |
2084 | function mergeVNodeHook (def, hookKey, hook, key) {
2085 | key = key + hookKey;
2086 | var injectedHash = def.__injected || (def.__injected = {});
2087 | if (!injectedHash[key]) {
2088 | injectedHash[key] = true;
2089 | var oldHook = def[hookKey];
2090 | if (oldHook) {
2091 | def[hookKey] = function () {
2092 | oldHook.apply(this, arguments);
2093 | hook.apply(this, arguments);
2094 | };
2095 | } else {
2096 | def[hookKey] = hook;
2097 | }
2098 | }
2099 | }
2100 |
2101 | /* */
2102 |
2103 | var normalizeEvent = cached(function (name) {
2104 | var once = name.charAt(0) === '~'; // Prefixed last, checked first
2105 | name = once ? name.slice(1) : name;
2106 | var capture = name.charAt(0) === '!';
2107 | name = capture ? name.slice(1) : name;
2108 | return {
2109 | name: name,
2110 | once: once,
2111 | capture: capture
2112 | }
2113 | });
2114 |
2115 | function createEventHandle (fn) {
2116 | var handle = {
2117 | fn: fn,
2118 | invoker: function () {
2119 | var arguments$1 = arguments;
2120 |
2121 | var fn = handle.fn;
2122 | if (Array.isArray(fn)) {
2123 | for (var i = 0; i < fn.length; i++) {
2124 | fn[i].apply(null, arguments$1);
2125 | }
2126 | } else {
2127 | fn.apply(null, arguments);
2128 | }
2129 | }
2130 | };
2131 | return handle
2132 | }
2133 |
2134 | function updateListeners (
2135 | on,
2136 | oldOn,
2137 | add,
2138 | remove$$1,
2139 | vm
2140 | ) {
2141 | var name, cur, old, event;
2142 | for (name in on) {
2143 | cur = on[name];
2144 | old = oldOn[name];
2145 | event = normalizeEvent(name);
2146 | if (!cur) {
2147 | ("production") !== 'production' && warn(
2148 | "Invalid handler for event \"" + (event.name) + "\": got " + String(cur),
2149 | vm
2150 | );
2151 | } else if (!old) {
2152 | if (!cur.invoker) {
2153 | cur = on[name] = createEventHandle(cur);
2154 | }
2155 | add(event.name, cur.invoker, event.once, event.capture);
2156 | } else if (cur !== old) {
2157 | old.fn = cur;
2158 | on[name] = old;
2159 | }
2160 | }
2161 | for (name in oldOn) {
2162 | if (!on[name]) {
2163 | event = normalizeEvent(name);
2164 | remove$$1(event.name, oldOn[name].invoker, event.capture);
2165 | }
2166 | }
2167 | }
2168 |
2169 | /* */
2170 |
2171 | // The template compiler attempts to minimize the need for normalization by
2172 | // statically analyzing the template at compile time.
2173 | //
2174 | // For plain HTML markup, normalization can be completely skipped because the
2175 | // generated render function is guaranteed to return Array. There are
2176 | // two cases where extra normalization is needed:
2177 |
2178 | // 1. When the children contains components - because a functional component
2179 | // may return an Array instead of a single root. In this case, just a simple
2180 | // nomralization is needed - if any child is an Array, we flatten the whole
2181 | // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
2182 | // because functional components already normalize their own children.
2183 | function simpleNormalizeChildren (children) {
2184 | for (var i = 0; i < children.length; i++) {
2185 | if (Array.isArray(children[i])) {
2186 | return Array.prototype.concat.apply([], children)
2187 | }
2188 | }
2189 | return children
2190 | }
2191 |
2192 | // 2. When the children contains constrcuts that always generated nested Arrays,
2193 | // e.g. , , v-for, or when the children is provided by user
2194 | // with hand-written render functions / JSX. In such cases a full normalization
2195 | // is needed to cater to all possible types of children values.
2196 | function normalizeChildren (children) {
2197 | return isPrimitive(children)
2198 | ? [createTextVNode(children)]
2199 | : Array.isArray(children)
2200 | ? normalizeArrayChildren(children)
2201 | : undefined
2202 | }
2203 |
2204 | function normalizeArrayChildren (children, nestedIndex) {
2205 | var res = [];
2206 | var i, c, last;
2207 | for (i = 0; i < children.length; i++) {
2208 | c = children[i];
2209 | if (c == null || typeof c === 'boolean') { continue }
2210 | last = res[res.length - 1];
2211 | // nested
2212 | if (Array.isArray(c)) {
2213 | res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i)));
2214 | } else if (isPrimitive(c)) {
2215 | if (last && last.text) {
2216 | last.text += String(c);
2217 | } else if (c !== '') {
2218 | // convert primitive to vnode
2219 | res.push(createTextVNode(c));
2220 | }
2221 | } else {
2222 | if (c.text && last && last.text) {
2223 | res[res.length - 1] = createTextVNode(last.text + c.text);
2224 | } else {
2225 | // default key for nested array children (likely generated by v-for)
2226 | if (c.tag && c.key == null && nestedIndex != null) {
2227 | c.key = "__vlist" + nestedIndex + "_" + i + "__";
2228 | }
2229 | res.push(c);
2230 | }
2231 | }
2232 | }
2233 | return res
2234 | }
2235 |
2236 | /* */
2237 |
2238 | function getFirstComponentChild (children) {
2239 | return children && children.filter(function (c) { return c && c.componentOptions; })[0]
2240 | }
2241 |
2242 | /* */
2243 |
2244 | var SIMPLE_NORMALIZE = 1;
2245 | var ALWAYS_NORMALIZE = 2;
2246 |
2247 | // wrapper function for providing a more flexible interface
2248 | // without getting yelled at by flow
2249 | function createElement (
2250 | context,
2251 | tag,
2252 | data,
2253 | children,
2254 | normalizationType,
2255 | alwaysNormalize
2256 | ) {
2257 | if (Array.isArray(data) || isPrimitive(data)) {
2258 | normalizationType = children;
2259 | children = data;
2260 | data = undefined;
2261 | }
2262 | if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; }
2263 | return _createElement(context, tag, data, children, normalizationType)
2264 | }
2265 |
2266 | function _createElement (
2267 | context,
2268 | tag,
2269 | data,
2270 | children,
2271 | normalizationType
2272 | ) {
2273 | if (data && data.__ob__) {
2274 | ("production") !== 'production' && warn(
2275 | "Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" +
2276 | 'Always create fresh vnode data objects in each render!',
2277 | context
2278 | );
2279 | return createEmptyVNode()
2280 | }
2281 | if (!tag) {
2282 | // in case of component :is set to falsy value
2283 | return createEmptyVNode()
2284 | }
2285 | // support single function children as default scoped slot
2286 | if (Array.isArray(children) &&
2287 | typeof children[0] === 'function') {
2288 | data = data || {};
2289 | data.scopedSlots = { default: children[0] };
2290 | children.length = 0;
2291 | }
2292 | if (normalizationType === ALWAYS_NORMALIZE) {
2293 | children = normalizeChildren(children);
2294 | } else if (normalizationType === SIMPLE_NORMALIZE) {
2295 | children = simpleNormalizeChildren(children);
2296 | }
2297 | var vnode, ns;
2298 | if (typeof tag === 'string') {
2299 | var Ctor;
2300 | ns = config.getTagNamespace(tag);
2301 | if (config.isReservedTag(tag)) {
2302 | // platform built-in elements
2303 | vnode = new VNode(
2304 | config.parsePlatformTagName(tag), data, children,
2305 | undefined, undefined, context
2306 | );
2307 | } else if ((Ctor = resolveAsset(context.$options, 'components', tag))) {
2308 | // component
2309 | vnode = createComponent(Ctor, data, context, children, tag);
2310 | } else {
2311 | // unknown or unlisted namespaced elements
2312 | // check at runtime because it may get assigned a namespace when its
2313 | // parent normalizes children
2314 | vnode = new VNode(
2315 | tag, data, children,
2316 | undefined, undefined, context
2317 | );
2318 | }
2319 | } else {
2320 | // direct component options / constructor
2321 | vnode = createComponent(tag, data, context, children);
2322 | }
2323 | if (vnode) {
2324 | if (ns) { applyNS(vnode, ns); }
2325 | return vnode
2326 | } else {
2327 | return createEmptyVNode()
2328 | }
2329 | }
2330 |
2331 | function applyNS (vnode, ns) {
2332 | vnode.ns = ns;
2333 | if (vnode.tag === 'foreignObject') {
2334 | // use default namespace inside foreignObject
2335 | return
2336 | }
2337 | if (vnode.children) {
2338 | for (var i = 0, l = vnode.children.length; i < l; i++) {
2339 | var child = vnode.children[i];
2340 | if (child.tag && !child.ns) {
2341 | applyNS(child, ns);
2342 | }
2343 | }
2344 | }
2345 | }
2346 |
2347 | /* */
2348 |
2349 | function initRender (vm) {
2350 | vm.$vnode = null; // the placeholder node in parent tree
2351 | vm._vnode = null; // the root of the child tree
2352 | vm._staticTrees = null;
2353 | var parentVnode = vm.$options._parentVnode;
2354 | var renderContext = parentVnode && parentVnode.context;
2355 | vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext);
2356 | vm.$scopedSlots = {};
2357 | // bind the createElement fn to this instance
2358 | // so that we get proper render context inside it.
2359 | // args order: tag, data, children, normalizationType, alwaysNormalize
2360 | // internal version is used by render functions compiled from templates
2361 | vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); };
2362 | // normalization is always applied for the public version, used in
2363 | // user-written render functions.
2364 | vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); };
2365 | }
2366 |
2367 | function renderMixin (Vue) {
2368 | Vue.prototype.$nextTick = function (fn) {
2369 | return nextTick(fn, this)
2370 | };
2371 |
2372 | Vue.prototype._render = function () {
2373 | var vm = this;
2374 | var ref = vm.$options;
2375 | var render = ref.render;
2376 | var staticRenderFns = ref.staticRenderFns;
2377 | var _parentVnode = ref._parentVnode;
2378 |
2379 | if (vm._isMounted) {
2380 | // clone slot nodes on re-renders
2381 | for (var key in vm.$slots) {
2382 | vm.$slots[key] = cloneVNodes(vm.$slots[key]);
2383 | }
2384 | }
2385 |
2386 | if (_parentVnode && _parentVnode.data.scopedSlots) {
2387 | vm.$scopedSlots = _parentVnode.data.scopedSlots;
2388 | }
2389 |
2390 | if (staticRenderFns && !vm._staticTrees) {
2391 | vm._staticTrees = [];
2392 | }
2393 | // set parent vnode. this allows render functions to have access
2394 | // to the data on the placeholder node.
2395 | vm.$vnode = _parentVnode;
2396 | // render self
2397 | var vnode;
2398 | try {
2399 | vnode = render.call(vm._renderProxy, vm.$createElement);
2400 | } catch (e) {
2401 | /* istanbul ignore else */
2402 | if (config.errorHandler) {
2403 | config.errorHandler.call(null, e, vm);
2404 | } else {
2405 | if (false) {
2406 | warn(("Error when rendering " + (formatComponentName(vm)) + ":"));
2407 | }
2408 | throw e
2409 | }
2410 | // return previous vnode to prevent render error causing blank component
2411 | vnode = vm._vnode;
2412 | }
2413 | // return empty vnode in case the render function errored out
2414 | if (!(vnode instanceof VNode)) {
2415 | if (false) {
2416 | warn(
2417 | 'Multiple root nodes returned from render function. Render function ' +
2418 | 'should return a single root node.',
2419 | vm
2420 | );
2421 | }
2422 | vnode = createEmptyVNode();
2423 | }
2424 | // set parent
2425 | vnode.parent = _parentVnode;
2426 | return vnode
2427 | };
2428 |
2429 | // toString for mustaches
2430 | Vue.prototype._s = _toString;
2431 | // convert text to vnode
2432 | Vue.prototype._v = createTextVNode;
2433 | // number conversion
2434 | Vue.prototype._n = toNumber;
2435 | // empty vnode
2436 | Vue.prototype._e = createEmptyVNode;
2437 | // loose equal
2438 | Vue.prototype._q = looseEqual;
2439 | // loose indexOf
2440 | Vue.prototype._i = looseIndexOf;
2441 |
2442 | // render static tree by index
2443 | Vue.prototype._m = function renderStatic (
2444 | index,
2445 | isInFor
2446 | ) {
2447 | var tree = this._staticTrees[index];
2448 | // if has already-rendered static tree and not inside v-for,
2449 | // we can reuse the same tree by doing a shallow clone.
2450 | if (tree && !isInFor) {
2451 | return Array.isArray(tree)
2452 | ? cloneVNodes(tree)
2453 | : cloneVNode(tree)
2454 | }
2455 | // otherwise, render a fresh tree.
2456 | tree = this._staticTrees[index] = this.$options.staticRenderFns[index].call(this._renderProxy);
2457 | markStatic(tree, ("__static__" + index), false);
2458 | return tree
2459 | };
2460 |
2461 | // mark node as static (v-once)
2462 | Vue.prototype._o = function markOnce (
2463 | tree,
2464 | index,
2465 | key
2466 | ) {
2467 | markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true);
2468 | return tree
2469 | };
2470 |
2471 | function markStatic (tree, key, isOnce) {
2472 | if (Array.isArray(tree)) {
2473 | for (var i = 0; i < tree.length; i++) {
2474 | if (tree[i] && typeof tree[i] !== 'string') {
2475 | markStaticNode(tree[i], (key + "_" + i), isOnce);
2476 | }
2477 | }
2478 | } else {
2479 | markStaticNode(tree, key, isOnce);
2480 | }
2481 | }
2482 |
2483 | function markStaticNode (node, key, isOnce) {
2484 | node.isStatic = true;
2485 | node.key = key;
2486 | node.isOnce = isOnce;
2487 | }
2488 |
2489 | // filter resolution helper
2490 | Vue.prototype._f = function resolveFilter (id) {
2491 | return resolveAsset(this.$options, 'filters', id, true) || identity
2492 | };
2493 |
2494 | // render v-for
2495 | Vue.prototype._l = function renderList (
2496 | val,
2497 | render
2498 | ) {
2499 | var ret, i, l, keys, key;
2500 | if (Array.isArray(val) || typeof val === 'string') {
2501 | ret = new Array(val.length);
2502 | for (i = 0, l = val.length; i < l; i++) {
2503 | ret[i] = render(val[i], i);
2504 | }
2505 | } else if (typeof val === 'number') {
2506 | ret = new Array(val);
2507 | for (i = 0; i < val; i++) {
2508 | ret[i] = render(i + 1, i);
2509 | }
2510 | } else if (isObject(val)) {
2511 | keys = Object.keys(val);
2512 | ret = new Array(keys.length);
2513 | for (i = 0, l = keys.length; i < l; i++) {
2514 | key = keys[i];
2515 | ret[i] = render(val[key], key, i);
2516 | }
2517 | }
2518 | return ret
2519 | };
2520 |
2521 | // renderSlot
2522 | Vue.prototype._t = function (
2523 | name,
2524 | fallback,
2525 | props,
2526 | bindObject
2527 | ) {
2528 | var scopedSlotFn = this.$scopedSlots[name];
2529 | if (scopedSlotFn) { // scoped slot
2530 | props = props || {};
2531 | if (bindObject) {
2532 | extend(props, bindObject);
2533 | }
2534 | return scopedSlotFn(props) || fallback
2535 | } else {
2536 | var slotNodes = this.$slots[name];
2537 | // warn duplicate slot usage
2538 | if (slotNodes && ("production") !== 'production') {
2539 | slotNodes._rendered && warn(
2540 | "Duplicate presence of slot \"" + name + "\" found in the same render tree " +
2541 | "- this will likely cause render errors.",
2542 | this
2543 | );
2544 | slotNodes._rendered = true;
2545 | }
2546 | return slotNodes || fallback
2547 | }
2548 | };
2549 |
2550 | // apply v-bind object
2551 | Vue.prototype._b = function bindProps (
2552 | data,
2553 | tag,
2554 | value,
2555 | asProp
2556 | ) {
2557 | if (value) {
2558 | if (!isObject(value)) {
2559 | ("production") !== 'production' && warn(
2560 | 'v-bind without argument expects an Object or Array value',
2561 | this
2562 | );
2563 | } else {
2564 | if (Array.isArray(value)) {
2565 | value = toObject(value);
2566 | }
2567 | for (var key in value) {
2568 | if (key === 'class' || key === 'style') {
2569 | data[key] = value[key];
2570 | } else {
2571 | var type = data.attrs && data.attrs.type;
2572 | var hash = asProp || config.mustUseProp(tag, type, key)
2573 | ? data.domProps || (data.domProps = {})
2574 | : data.attrs || (data.attrs = {});
2575 | hash[key] = value[key];
2576 | }
2577 | }
2578 | }
2579 | }
2580 | return data
2581 | };
2582 |
2583 | // check v-on keyCodes
2584 | Vue.prototype._k = function checkKeyCodes (
2585 | eventKeyCode,
2586 | key,
2587 | builtInAlias
2588 | ) {
2589 | var keyCodes = config.keyCodes[key] || builtInAlias;
2590 | if (Array.isArray(keyCodes)) {
2591 | return keyCodes.indexOf(eventKeyCode) === -1
2592 | } else {
2593 | return keyCodes !== eventKeyCode
2594 | }
2595 | };
2596 | }
2597 |
2598 | function resolveSlots (
2599 | children,
2600 | context
2601 | ) {
2602 | var slots = {};
2603 | if (!children) {
2604 | return slots
2605 | }
2606 | var defaultSlot = [];
2607 | var name, child;
2608 | for (var i = 0, l = children.length; i < l; i++) {
2609 | child = children[i];
2610 | // named slots should only be respected if the vnode was rendered in the
2611 | // same context.
2612 | if ((child.context === context || child.functionalContext === context) &&
2613 | child.data && (name = child.data.slot)) {
2614 | var slot = (slots[name] || (slots[name] = []));
2615 | if (child.tag === 'template') {
2616 | slot.push.apply(slot, child.children);
2617 | } else {
2618 | slot.push(child);
2619 | }
2620 | } else {
2621 | defaultSlot.push(child);
2622 | }
2623 | }
2624 | // ignore single whitespace
2625 | if (defaultSlot.length && !(
2626 | defaultSlot.length === 1 &&
2627 | (defaultSlot[0].text === ' ' || defaultSlot[0].isComment)
2628 | )) {
2629 | slots.default = defaultSlot;
2630 | }
2631 | return slots
2632 | }
2633 |
2634 | /* */
2635 |
2636 | function initEvents (vm) {
2637 | vm._events = Object.create(null);
2638 | vm._hasHookEvent = false;
2639 | // init parent attached events
2640 | var listeners = vm.$options._parentListeners;
2641 | if (listeners) {
2642 | updateComponentListeners(vm, listeners);
2643 | }
2644 | }
2645 |
2646 | var target;
2647 |
2648 | function add$1 (event, fn, once) {
2649 | if (once) {
2650 | target.$once(event, fn);
2651 | } else {
2652 | target.$on(event, fn);
2653 | }
2654 | }
2655 |
2656 | function remove$2 (event, fn) {
2657 | target.$off(event, fn);
2658 | }
2659 |
2660 | function updateComponentListeners (
2661 | vm,
2662 | listeners,
2663 | oldListeners
2664 | ) {
2665 | target = vm;
2666 | updateListeners(listeners, oldListeners || {}, add$1, remove$2, vm);
2667 | }
2668 |
2669 | function eventsMixin (Vue) {
2670 | var hookRE = /^hook:/;
2671 | Vue.prototype.$on = function (event, fn) {
2672 | var vm = this;(vm._events[event] || (vm._events[event] = [])).push(fn);
2673 | // optimize hook:event cost by using a boolean flag marked at registration
2674 | // instead of a hash lookup
2675 | if (hookRE.test(event)) {
2676 | vm._hasHookEvent = true;
2677 | }
2678 | return vm
2679 | };
2680 |
2681 | Vue.prototype.$once = function (event, fn) {
2682 | var vm = this;
2683 | function on () {
2684 | vm.$off(event, on);
2685 | fn.apply(vm, arguments);
2686 | }
2687 | on.fn = fn;
2688 | vm.$on(event, on);
2689 | return vm
2690 | };
2691 |
2692 | Vue.prototype.$off = function (event, fn) {
2693 | var vm = this;
2694 | // all
2695 | if (!arguments.length) {
2696 | vm._events = Object.create(null);
2697 | return vm
2698 | }
2699 | // specific event
2700 | var cbs = vm._events[event];
2701 | if (!cbs) {
2702 | return vm
2703 | }
2704 | if (arguments.length === 1) {
2705 | vm._events[event] = null;
2706 | return vm
2707 | }
2708 | // specific handler
2709 | var cb;
2710 | var i = cbs.length;
2711 | while (i--) {
2712 | cb = cbs[i];
2713 | if (cb === fn || cb.fn === fn) {
2714 | cbs.splice(i, 1);
2715 | break
2716 | }
2717 | }
2718 | return vm
2719 | };
2720 |
2721 | Vue.prototype.$emit = function (event) {
2722 | var vm = this;
2723 | var cbs = vm._events[event];
2724 | if (cbs) {
2725 | cbs = cbs.length > 1 ? toArray(cbs) : cbs;
2726 | var args = toArray(arguments, 1);
2727 | for (var i = 0, l = cbs.length; i < l; i++) {
2728 | cbs[i].apply(vm, args);
2729 | }
2730 | }
2731 | return vm
2732 | };
2733 | }
2734 |
2735 | /* */
2736 |
2737 | var activeInstance = null;
2738 |
2739 | function initLifecycle (vm) {
2740 | var options = vm.$options;
2741 |
2742 | // locate first non-abstract parent
2743 | var parent = options.parent;
2744 | if (parent && !options.abstract) {
2745 | while (parent.$options.abstract && parent.$parent) {
2746 | parent = parent.$parent;
2747 | }
2748 | parent.$children.push(vm);
2749 | }
2750 |
2751 | vm.$parent = parent;
2752 | vm.$root = parent ? parent.$root : vm;
2753 |
2754 | vm.$children = [];
2755 | vm.$refs = {};
2756 |
2757 | vm._watcher = null;
2758 | vm._inactive = false;
2759 | vm._isMounted = false;
2760 | vm._isDestroyed = false;
2761 | vm._isBeingDestroyed = false;
2762 | }
2763 |
2764 | function lifecycleMixin (Vue) {
2765 | Vue.prototype._mount = function (
2766 | el,
2767 | hydrating
2768 | ) {
2769 | var vm = this;
2770 | vm.$el = el;
2771 | if (!vm.$options.render) {
2772 | vm.$options.render = createEmptyVNode;
2773 | if (false) {
2774 | /* istanbul ignore if */
2775 | if (vm.$options.template && vm.$options.template.charAt(0) !== '#') {
2776 | warn(
2777 | 'You are using the runtime-only build of Vue where the template ' +
2778 | 'option is not available. Either pre-compile the templates into ' +
2779 | 'render functions, or use the compiler-included build.',
2780 | vm
2781 | );
2782 | } else {
2783 | warn(
2784 | 'Failed to mount component: template or render function not defined.',
2785 | vm
2786 | );
2787 | }
2788 | }
2789 | }
2790 | callHook(vm, 'beforeMount');
2791 | vm._watcher = new Watcher(vm, function updateComponent () {
2792 | vm._update(vm._render(), hydrating);
2793 | }, noop);
2794 | hydrating = false;
2795 | // manually mounted instance, call mounted on self
2796 | // mounted is called for render-created child components in its inserted hook
2797 | if (vm.$vnode == null) {
2798 | vm._isMounted = true;
2799 | callHook(vm, 'mounted');
2800 | }
2801 | return vm
2802 | };
2803 |
2804 | Vue.prototype._update = function (vnode, hydrating) {
2805 | var vm = this;
2806 | if (vm._isMounted) {
2807 | callHook(vm, 'beforeUpdate');
2808 | }
2809 | var prevEl = vm.$el;
2810 | var prevVnode = vm._vnode;
2811 | var prevActiveInstance = activeInstance;
2812 | activeInstance = vm;
2813 | vm._vnode = vnode;
2814 | // Vue.prototype.__patch__ is injected in entry points
2815 | // based on the rendering backend used.
2816 | if (!prevVnode) {
2817 | // initial render
2818 | vm.$el = vm.__patch__(
2819 | vm.$el, vnode, hydrating, false /* removeOnly */,
2820 | vm.$options._parentElm,
2821 | vm.$options._refElm
2822 | );
2823 | } else {
2824 | // updates
2825 | vm.$el = vm.__patch__(prevVnode, vnode);
2826 | }
2827 | activeInstance = prevActiveInstance;
2828 | // update __vue__ reference
2829 | if (prevEl) {
2830 | prevEl.__vue__ = null;
2831 | }
2832 | if (vm.$el) {
2833 | vm.$el.__vue__ = vm;
2834 | }
2835 | // if parent is an HOC, update its $el as well
2836 | if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) {
2837 | vm.$parent.$el = vm.$el;
2838 | }
2839 | // updated hook is called by the scheduler to ensure that children are
2840 | // updated in a parent's updated hook.
2841 | };
2842 |
2843 | Vue.prototype._updateFromParent = function (
2844 | propsData,
2845 | listeners,
2846 | parentVnode,
2847 | renderChildren
2848 | ) {
2849 | var vm = this;
2850 | var hasChildren = !!(vm.$options._renderChildren || renderChildren);
2851 | vm.$options._parentVnode = parentVnode;
2852 | vm.$vnode = parentVnode; // update vm's placeholder node without re-render
2853 | if (vm._vnode) { // update child tree's parent
2854 | vm._vnode.parent = parentVnode;
2855 | }
2856 | vm.$options._renderChildren = renderChildren;
2857 | // update props
2858 | if (propsData && vm.$options.props) {
2859 | observerState.shouldConvert = false;
2860 | if (false) {
2861 | observerState.isSettingProps = true;
2862 | }
2863 | var propKeys = vm.$options._propKeys || [];
2864 | for (var i = 0; i < propKeys.length; i++) {
2865 | var key = propKeys[i];
2866 | vm[key] = validateProp(key, vm.$options.props, propsData, vm);
2867 | }
2868 | observerState.shouldConvert = true;
2869 | if (false) {
2870 | observerState.isSettingProps = false;
2871 | }
2872 | vm.$options.propsData = propsData;
2873 | }
2874 | // update listeners
2875 | if (listeners) {
2876 | var oldListeners = vm.$options._parentListeners;
2877 | vm.$options._parentListeners = listeners;
2878 | updateComponentListeners(vm, listeners, oldListeners);
2879 | }
2880 | // resolve slots + force update if has children
2881 | if (hasChildren) {
2882 | vm.$slots = resolveSlots(renderChildren, parentVnode.context);
2883 | vm.$forceUpdate();
2884 | }
2885 | };
2886 |
2887 | Vue.prototype.$forceUpdate = function () {
2888 | var vm = this;
2889 | if (vm._watcher) {
2890 | vm._watcher.update();
2891 | }
2892 | };
2893 |
2894 | Vue.prototype.$destroy = function () {
2895 | var vm = this;
2896 | if (vm._isBeingDestroyed) {
2897 | return
2898 | }
2899 | callHook(vm, 'beforeDestroy');
2900 | vm._isBeingDestroyed = true;
2901 | // remove self from parent
2902 | var parent = vm.$parent;
2903 | if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) {
2904 | remove$1(parent.$children, vm);
2905 | }
2906 | // teardown watchers
2907 | if (vm._watcher) {
2908 | vm._watcher.teardown();
2909 | }
2910 | var i = vm._watchers.length;
2911 | while (i--) {
2912 | vm._watchers[i].teardown();
2913 | }
2914 | // remove reference from data ob
2915 | // frozen object may not have observer.
2916 | if (vm._data.__ob__) {
2917 | vm._data.__ob__.vmCount--;
2918 | }
2919 | // call the last hook...
2920 | vm._isDestroyed = true;
2921 | callHook(vm, 'destroyed');
2922 | // turn off all instance listeners.
2923 | vm.$off();
2924 | // remove __vue__ reference
2925 | if (vm.$el) {
2926 | vm.$el.__vue__ = null;
2927 | }
2928 | // invoke destroy hooks on current rendered tree
2929 | vm.__patch__(vm._vnode, null);
2930 | };
2931 | }
2932 |
2933 | function callHook (vm, hook) {
2934 | var handlers = vm.$options[hook];
2935 | if (handlers) {
2936 | for (var i = 0, j = handlers.length; i < j; i++) {
2937 | handlers[i].call(vm);
2938 | }
2939 | }
2940 | if (vm._hasHookEvent) {
2941 | vm.$emit('hook:' + hook);
2942 | }
2943 | }
2944 |
2945 | /* */
2946 |
2947 |
2948 | var queue = [];
2949 | var has$1 = {};
2950 | var circular = {};
2951 | var waiting = false;
2952 | var flushing = false;
2953 | var index = 0;
2954 |
2955 | /**
2956 | * Reset the scheduler's state.
2957 | */
2958 | function resetSchedulerState () {
2959 | queue.length = 0;
2960 | has$1 = {};
2961 | if (false) {
2962 | circular = {};
2963 | }
2964 | waiting = flushing = false;
2965 | }
2966 |
2967 | /**
2968 | * Flush both queues and run the watchers.
2969 | */
2970 | function flushSchedulerQueue () {
2971 | flushing = true;
2972 | var watcher, id, vm;
2973 |
2974 | // Sort queue before flush.
2975 | // This ensures that:
2976 | // 1. Components are updated from parent to child. (because parent is always
2977 | // created before the child)
2978 | // 2. A component's user watchers are run before its render watcher (because
2979 | // user watchers are created before the render watcher)
2980 | // 3. If a component is destroyed during a parent component's watcher run,
2981 | // its watchers can be skipped.
2982 | queue.sort(function (a, b) { return a.id - b.id; });
2983 |
2984 | // do not cache length because more watchers might be pushed
2985 | // as we run existing watchers
2986 | for (index = 0; index < queue.length; index++) {
2987 | watcher = queue[index];
2988 | id = watcher.id;
2989 | has$1[id] = null;
2990 | watcher.run();
2991 | // in dev build, check and stop circular updates.
2992 | if (false) {
2993 | circular[id] = (circular[id] || 0) + 1;
2994 | if (circular[id] > config._maxUpdateCount) {
2995 | warn(
2996 | 'You may have an infinite update loop ' + (
2997 | watcher.user
2998 | ? ("in watcher with expression \"" + (watcher.expression) + "\"")
2999 | : "in a component render function."
3000 | ),
3001 | watcher.vm
3002 | );
3003 | break
3004 | }
3005 | }
3006 | }
3007 |
3008 | // call updated hooks
3009 | index = queue.length;
3010 | while (index--) {
3011 | watcher = queue[index];
3012 | vm = watcher.vm;
3013 | if (vm._watcher === watcher && vm._isMounted) {
3014 | callHook(vm, 'updated');
3015 | }
3016 | }
3017 |
3018 | // devtool hook
3019 | /* istanbul ignore if */
3020 | if (devtools && config.devtools) {
3021 | devtools.emit('flush');
3022 | }
3023 |
3024 | resetSchedulerState();
3025 | }
3026 |
3027 | /**
3028 | * Push a watcher into the watcher queue.
3029 | * Jobs with duplicate IDs will be skipped unless it's
3030 | * pushed when the queue is being flushed.
3031 | */
3032 | function queueWatcher (watcher) {
3033 | var id = watcher.id;
3034 | if (has$1[id] == null) {
3035 | has$1[id] = true;
3036 | if (!flushing) {
3037 | queue.push(watcher);
3038 | } else {
3039 | // if already flushing, splice the watcher based on its id
3040 | // if already past its id, it will be run next immediately.
3041 | var i = queue.length - 1;
3042 | while (i >= 0 && queue[i].id > watcher.id) {
3043 | i--;
3044 | }
3045 | queue.splice(Math.max(i, index) + 1, 0, watcher);
3046 | }
3047 | // queue the flush
3048 | if (!waiting) {
3049 | waiting = true;
3050 | nextTick(flushSchedulerQueue);
3051 | }
3052 | }
3053 | }
3054 |
3055 | /* */
3056 |
3057 | var uid$2 = 0;
3058 |
3059 | /**
3060 | * A watcher parses an expression, collects dependencies,
3061 | * and fires callback when the expression value changes.
3062 | * This is used for both the $watch() api and directives.
3063 | */
3064 | var Watcher = function Watcher (
3065 | vm,
3066 | expOrFn,
3067 | cb,
3068 | options
3069 | ) {
3070 | this.vm = vm;
3071 | vm._watchers.push(this);
3072 | // options
3073 | if (options) {
3074 | this.deep = !!options.deep;
3075 | this.user = !!options.user;
3076 | this.lazy = !!options.lazy;
3077 | this.sync = !!options.sync;
3078 | } else {
3079 | this.deep = this.user = this.lazy = this.sync = false;
3080 | }
3081 | this.cb = cb;
3082 | this.id = ++uid$2; // uid for batching
3083 | this.active = true;
3084 | this.dirty = this.lazy; // for lazy watchers
3085 | this.deps = [];
3086 | this.newDeps = [];
3087 | this.depIds = new _Set();
3088 | this.newDepIds = new _Set();
3089 | this.expression = false
3090 | ? expOrFn.toString()
3091 | : '';
3092 | // parse expression for getter
3093 | if (typeof expOrFn === 'function') {
3094 | this.getter = expOrFn;
3095 | } else {
3096 | this.getter = parsePath(expOrFn);
3097 | if (!this.getter) {
3098 | this.getter = function () {};
3099 | ("production") !== 'production' && warn(
3100 | "Failed watching path: \"" + expOrFn + "\" " +
3101 | 'Watcher only accepts simple dot-delimited paths. ' +
3102 | 'For full control, use a function instead.',
3103 | vm
3104 | );
3105 | }
3106 | }
3107 | this.value = this.lazy
3108 | ? undefined
3109 | : this.get();
3110 | };
3111 |
3112 | /**
3113 | * Evaluate the getter, and re-collect dependencies.
3114 | */
3115 | Watcher.prototype.get = function get () {
3116 | pushTarget(this);
3117 | var value = this.getter.call(this.vm, this.vm);
3118 | // "touch" every property so they are all tracked as
3119 | // dependencies for deep watching
3120 | if (this.deep) {
3121 | traverse(value);
3122 | }
3123 | popTarget();
3124 | this.cleanupDeps();
3125 | return value
3126 | };
3127 |
3128 | /**
3129 | * Add a dependency to this directive.
3130 | */
3131 | Watcher.prototype.addDep = function addDep (dep) {
3132 | var id = dep.id;
3133 | if (!this.newDepIds.has(id)) {
3134 | this.newDepIds.add(id);
3135 | this.newDeps.push(dep);
3136 | if (!this.depIds.has(id)) {
3137 | dep.addSub(this);
3138 | }
3139 | }
3140 | };
3141 |
3142 | /**
3143 | * Clean up for dependency collection.
3144 | */
3145 | Watcher.prototype.cleanupDeps = function cleanupDeps () {
3146 | var this$1 = this;
3147 |
3148 | var i = this.deps.length;
3149 | while (i--) {
3150 | var dep = this$1.deps[i];
3151 | if (!this$1.newDepIds.has(dep.id)) {
3152 | dep.removeSub(this$1);
3153 | }
3154 | }
3155 | var tmp = this.depIds;
3156 | this.depIds = this.newDepIds;
3157 | this.newDepIds = tmp;
3158 | this.newDepIds.clear();
3159 | tmp = this.deps;
3160 | this.deps = this.newDeps;
3161 | this.newDeps = tmp;
3162 | this.newDeps.length = 0;
3163 | };
3164 |
3165 | /**
3166 | * Subscriber interface.
3167 | * Will be called when a dependency changes.
3168 | */
3169 | Watcher.prototype.update = function update () {
3170 | /* istanbul ignore else */
3171 | if (this.lazy) {
3172 | this.dirty = true;
3173 | } else if (this.sync) {
3174 | this.run();
3175 | } else {
3176 | queueWatcher(this);
3177 | }
3178 | };
3179 |
3180 | /**
3181 | * Scheduler job interface.
3182 | * Will be called by the scheduler.
3183 | */
3184 | Watcher.prototype.run = function run () {
3185 | if (this.active) {
3186 | var value = this.get();
3187 | if (
3188 | value !== this.value ||
3189 | // Deep watchers and watchers on Object/Arrays should fire even
3190 | // when the value is the same, because the value may
3191 | // have mutated.
3192 | isObject(value) ||
3193 | this.deep
3194 | ) {
3195 | // set new value
3196 | var oldValue = this.value;
3197 | this.value = value;
3198 | if (this.user) {
3199 | try {
3200 | this.cb.call(this.vm, value, oldValue);
3201 | } catch (e) {
3202 | /* istanbul ignore else */
3203 | if (config.errorHandler) {
3204 | config.errorHandler.call(null, e, this.vm);
3205 | } else {
3206 | ("production") !== 'production' && warn(
3207 | ("Error in watcher \"" + (this.expression) + "\""),
3208 | this.vm
3209 | );
3210 | throw e
3211 | }
3212 | }
3213 | } else {
3214 | this.cb.call(this.vm, value, oldValue);
3215 | }
3216 | }
3217 | }
3218 | };
3219 |
3220 | /**
3221 | * Evaluate the value of the watcher.
3222 | * This only gets called for lazy watchers.
3223 | */
3224 | Watcher.prototype.evaluate = function evaluate () {
3225 | this.value = this.get();
3226 | this.dirty = false;
3227 | };
3228 |
3229 | /**
3230 | * Depend on all deps collected by this watcher.
3231 | */
3232 | Watcher.prototype.depend = function depend () {
3233 | var this$1 = this;
3234 |
3235 | var i = this.deps.length;
3236 | while (i--) {
3237 | this$1.deps[i].depend();
3238 | }
3239 | };
3240 |
3241 | /**
3242 | * Remove self from all dependencies' subscriber list.
3243 | */
3244 | Watcher.prototype.teardown = function teardown () {
3245 | var this$1 = this;
3246 |
3247 | if (this.active) {
3248 | // remove self from vm's watcher list
3249 | // this is a somewhat expensive operation so we skip it
3250 | // if the vm is being destroyed.
3251 | if (!this.vm._isBeingDestroyed) {
3252 | remove$1(this.vm._watchers, this);
3253 | }
3254 | var i = this.deps.length;
3255 | while (i--) {
3256 | this$1.deps[i].removeSub(this$1);
3257 | }
3258 | this.active = false;
3259 | }
3260 | };
3261 |
3262 | /**
3263 | * Recursively traverse an object to evoke all converted
3264 | * getters, so that every nested property inside the object
3265 | * is collected as a "deep" dependency.
3266 | */
3267 | var seenObjects = new _Set();
3268 | function traverse (val) {
3269 | seenObjects.clear();
3270 | _traverse(val, seenObjects);
3271 | }
3272 |
3273 | function _traverse (val, seen) {
3274 | var i, keys;
3275 | var isA = Array.isArray(val);
3276 | if ((!isA && !isObject(val)) || !Object.isExtensible(val)) {
3277 | return
3278 | }
3279 | if (val.__ob__) {
3280 | var depId = val.__ob__.dep.id;
3281 | if (seen.has(depId)) {
3282 | return
3283 | }
3284 | seen.add(depId);
3285 | }
3286 | if (isA) {
3287 | i = val.length;
3288 | while (i--) { _traverse(val[i], seen); }
3289 | } else {
3290 | keys = Object.keys(val);
3291 | i = keys.length;
3292 | while (i--) { _traverse(val[keys[i]], seen); }
3293 | }
3294 | }
3295 |
3296 | /* */
3297 |
3298 | function initState (vm) {
3299 | vm._watchers = [];
3300 | var opts = vm.$options;
3301 | if (opts.props) { initProps(vm, opts.props); }
3302 | if (opts.methods) { initMethods(vm, opts.methods); }
3303 | if (opts.data) {
3304 | initData(vm);
3305 | } else {
3306 | observe(vm._data = {}, true /* asRootData */);
3307 | }
3308 | if (opts.computed) { initComputed(vm, opts.computed); }
3309 | if (opts.watch) { initWatch(vm, opts.watch); }
3310 | }
3311 |
3312 | var isReservedProp = { key: 1, ref: 1, slot: 1 };
3313 |
3314 | function initProps (vm, props) {
3315 | var propsData = vm.$options.propsData || {};
3316 | var keys = vm.$options._propKeys = Object.keys(props);
3317 | var isRoot = !vm.$parent;
3318 | // root instance props should be converted
3319 | observerState.shouldConvert = isRoot;
3320 | var loop = function ( i ) {
3321 | var key = keys[i];
3322 | /* istanbul ignore else */
3323 | if (false) {
3324 | if (isReservedProp[key]) {
3325 | warn(
3326 | ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."),
3327 | vm
3328 | );
3329 | }
3330 | defineReactive$$1(vm, key, validateProp(key, props, propsData, vm), function () {
3331 | if (vm.$parent && !observerState.isSettingProps) {
3332 | warn(
3333 | "Avoid mutating a prop directly since the value will be " +
3334 | "overwritten whenever the parent component re-renders. " +
3335 | "Instead, use a data or computed property based on the prop's " +
3336 | "value. Prop being mutated: \"" + key + "\"",
3337 | vm
3338 | );
3339 | }
3340 | });
3341 | } else {
3342 | defineReactive$$1(vm, key, validateProp(key, props, propsData, vm));
3343 | }
3344 | };
3345 |
3346 | for (var i = 0; i < keys.length; i++) loop( i );
3347 | observerState.shouldConvert = true;
3348 | }
3349 |
3350 | function initData (vm) {
3351 | var data = vm.$options.data;
3352 | data = vm._data = typeof data === 'function'
3353 | ? data.call(vm)
3354 | : data || {};
3355 | if (!isPlainObject(data)) {
3356 | data = {};
3357 | ("production") !== 'production' && warn(
3358 | 'data functions should return an object:\n' +
3359 | 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
3360 | vm
3361 | );
3362 | }
3363 | // proxy data on instance
3364 | var keys = Object.keys(data);
3365 | var props = vm.$options.props;
3366 | var i = keys.length;
3367 | while (i--) {
3368 | if (props && hasOwn(props, keys[i])) {
3369 | ("production") !== 'production' && warn(
3370 | "The data property \"" + (keys[i]) + "\" is already declared as a prop. " +
3371 | "Use prop default value instead.",
3372 | vm
3373 | );
3374 | } else {
3375 | proxy(vm, keys[i]);
3376 | }
3377 | }
3378 | // observe data
3379 | observe(data, true /* asRootData */);
3380 | }
3381 |
3382 | var computedSharedDefinition = {
3383 | enumerable: true,
3384 | configurable: true,
3385 | get: noop,
3386 | set: noop
3387 | };
3388 |
3389 | function initComputed (vm, computed) {
3390 | for (var key in computed) {
3391 | /* istanbul ignore if */
3392 | if (false) {
3393 | warn(
3394 | "existing instance property \"" + key + "\" will be " +
3395 | "overwritten by a computed property with the same name.",
3396 | vm
3397 | );
3398 | }
3399 | var userDef = computed[key];
3400 | if (typeof userDef === 'function') {
3401 | computedSharedDefinition.get = makeComputedGetter(userDef, vm);
3402 | computedSharedDefinition.set = noop;
3403 | } else {
3404 | computedSharedDefinition.get = userDef.get
3405 | ? userDef.cache !== false
3406 | ? makeComputedGetter(userDef.get, vm)
3407 | : bind$1(userDef.get, vm)
3408 | : noop;
3409 | computedSharedDefinition.set = userDef.set
3410 | ? bind$1(userDef.set, vm)
3411 | : noop;
3412 | }
3413 | Object.defineProperty(vm, key, computedSharedDefinition);
3414 | }
3415 | }
3416 |
3417 | function makeComputedGetter (getter, owner) {
3418 | var watcher = new Watcher(owner, getter, noop, {
3419 | lazy: true
3420 | });
3421 | return function computedGetter () {
3422 | if (watcher.dirty) {
3423 | watcher.evaluate();
3424 | }
3425 | if (Dep.target) {
3426 | watcher.depend();
3427 | }
3428 | return watcher.value
3429 | }
3430 | }
3431 |
3432 | function initMethods (vm, methods) {
3433 | for (var key in methods) {
3434 | vm[key] = methods[key] == null ? noop : bind$1(methods[key], vm);
3435 | if (false) {
3436 | warn(
3437 | "method \"" + key + "\" has an undefined value in the component definition. " +
3438 | "Did you reference the function correctly?",
3439 | vm
3440 | );
3441 | }
3442 | }
3443 | }
3444 |
3445 | function initWatch (vm, watch) {
3446 | for (var key in watch) {
3447 | var handler = watch[key];
3448 | if (Array.isArray(handler)) {
3449 | for (var i = 0; i < handler.length; i++) {
3450 | createWatcher(vm, key, handler[i]);
3451 | }
3452 | } else {
3453 | createWatcher(vm, key, handler);
3454 | }
3455 | }
3456 | }
3457 |
3458 | function createWatcher (vm, key, handler) {
3459 | var options;
3460 | if (isPlainObject(handler)) {
3461 | options = handler;
3462 | handler = handler.handler;
3463 | }
3464 | if (typeof handler === 'string') {
3465 | handler = vm[handler];
3466 | }
3467 | vm.$watch(key, handler, options);
3468 | }
3469 |
3470 | function stateMixin (Vue) {
3471 | // flow somehow has problems with directly declared definition object
3472 | // when using Object.defineProperty, so we have to procedurally build up
3473 | // the object here.
3474 | var dataDef = {};
3475 | dataDef.get = function () {
3476 | return this._data
3477 | };
3478 | if (false) {
3479 | dataDef.set = function (newData) {
3480 | warn(
3481 | 'Avoid replacing instance root $data. ' +
3482 | 'Use nested data properties instead.',
3483 | this
3484 | );
3485 | };
3486 | }
3487 | Object.defineProperty(Vue.prototype, '$data', dataDef);
3488 |
3489 | Vue.prototype.$set = set$1;
3490 | Vue.prototype.$delete = del;
3491 |
3492 | Vue.prototype.$watch = function (
3493 | expOrFn,
3494 | cb,
3495 | options
3496 | ) {
3497 | var vm = this;
3498 | options = options || {};
3499 | options.user = true;
3500 | var watcher = new Watcher(vm, expOrFn, cb, options);
3501 | if (options.immediate) {
3502 | cb.call(vm, watcher.value);
3503 | }
3504 | return function unwatchFn () {
3505 | watcher.teardown();
3506 | }
3507 | };
3508 | }
3509 |
3510 | function proxy (vm, key) {
3511 | if (!isReserved(key)) {
3512 | Object.defineProperty(vm, key, {
3513 | configurable: true,
3514 | enumerable: true,
3515 | get: function proxyGetter () {
3516 | return vm._data[key]
3517 | },
3518 | set: function proxySetter (val) {
3519 | vm._data[key] = val;
3520 | }
3521 | });
3522 | }
3523 | }
3524 |
3525 | /* */
3526 |
3527 | var uid = 0;
3528 |
3529 | function initMixin (Vue) {
3530 | Vue.prototype._init = function (options) {
3531 | var vm = this;
3532 | // a uid
3533 | vm._uid = uid++;
3534 | // a flag to avoid this being observed
3535 | vm._isVue = true;
3536 | // merge options
3537 | if (options && options._isComponent) {
3538 | // optimize internal component instantiation
3539 | // since dynamic options merging is pretty slow, and none of the
3540 | // internal component options needs special treatment.
3541 | initInternalComponent(vm, options);
3542 | } else {
3543 | vm.$options = mergeOptions(
3544 | resolveConstructorOptions(vm.constructor),
3545 | options || {},
3546 | vm
3547 | );
3548 | }
3549 | /* istanbul ignore else */
3550 | if (false) {
3551 | initProxy(vm);
3552 | } else {
3553 | vm._renderProxy = vm;
3554 | }
3555 | // expose real self
3556 | vm._self = vm;
3557 | initLifecycle(vm);
3558 | initEvents(vm);
3559 | initRender(vm);
3560 | callHook(vm, 'beforeCreate');
3561 | initState(vm);
3562 | callHook(vm, 'created');
3563 | if (vm.$options.el) {
3564 | vm.$mount(vm.$options.el);
3565 | }
3566 | };
3567 | }
3568 |
3569 | function initInternalComponent (vm, options) {
3570 | var opts = vm.$options = Object.create(vm.constructor.options);
3571 | // doing this because it's faster than dynamic enumeration.
3572 | opts.parent = options.parent;
3573 | opts.propsData = options.propsData;
3574 | opts._parentVnode = options._parentVnode;
3575 | opts._parentListeners = options._parentListeners;
3576 | opts._renderChildren = options._renderChildren;
3577 | opts._componentTag = options._componentTag;
3578 | opts._parentElm = options._parentElm;
3579 | opts._refElm = options._refElm;
3580 | if (options.render) {
3581 | opts.render = options.render;
3582 | opts.staticRenderFns = options.staticRenderFns;
3583 | }
3584 | }
3585 |
3586 | function resolveConstructorOptions (Ctor) {
3587 | var options = Ctor.options;
3588 | if (Ctor.super) {
3589 | var superOptions = Ctor.super.options;
3590 | var cachedSuperOptions = Ctor.superOptions;
3591 | var extendOptions = Ctor.extendOptions;
3592 | if (superOptions !== cachedSuperOptions) {
3593 | // super option changed
3594 | Ctor.superOptions = superOptions;
3595 | extendOptions.render = options.render;
3596 | extendOptions.staticRenderFns = options.staticRenderFns;
3597 | extendOptions._scopeId = options._scopeId;
3598 | options = Ctor.options = mergeOptions(superOptions, extendOptions);
3599 | if (options.name) {
3600 | options.components[options.name] = Ctor;
3601 | }
3602 | }
3603 | }
3604 | return options
3605 | }
3606 |
3607 | function Vue$2 (options) {
3608 | if (false) {
3609 | warn('Vue is a constructor and should be called with the `new` keyword');
3610 | }
3611 | this._init(options);
3612 | }
3613 |
3614 | initMixin(Vue$2);
3615 | stateMixin(Vue$2);
3616 | eventsMixin(Vue$2);
3617 | lifecycleMixin(Vue$2);
3618 | renderMixin(Vue$2);
3619 |
3620 | /* */
3621 |
3622 | function initUse (Vue) {
3623 | Vue.use = function (plugin) {
3624 | /* istanbul ignore if */
3625 | if (plugin.installed) {
3626 | return
3627 | }
3628 | // additional parameters
3629 | var args = toArray(arguments, 1);
3630 | args.unshift(this);
3631 | if (typeof plugin.install === 'function') {
3632 | plugin.install.apply(plugin, args);
3633 | } else {
3634 | plugin.apply(null, args);
3635 | }
3636 | plugin.installed = true;
3637 | return this
3638 | };
3639 | }
3640 |
3641 | /* */
3642 |
3643 | function initMixin$1 (Vue) {
3644 | Vue.mixin = function (mixin) {
3645 | this.options = mergeOptions(this.options, mixin);
3646 | };
3647 | }
3648 |
3649 | /* */
3650 |
3651 | function initExtend (Vue) {
3652 | /**
3653 | * Each instance constructor, including Vue, has a unique
3654 | * cid. This enables us to create wrapped "child
3655 | * constructors" for prototypal inheritance and cache them.
3656 | */
3657 | Vue.cid = 0;
3658 | var cid = 1;
3659 |
3660 | /**
3661 | * Class inheritance
3662 | */
3663 | Vue.extend = function (extendOptions) {
3664 | extendOptions = extendOptions || {};
3665 | var Super = this;
3666 | var SuperId = Super.cid;
3667 | var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {});
3668 | if (cachedCtors[SuperId]) {
3669 | return cachedCtors[SuperId]
3670 | }
3671 | var name = extendOptions.name || Super.options.name;
3672 | if (false) {
3673 | if (!/^[a-zA-Z][\w-]*$/.test(name)) {
3674 | warn(
3675 | 'Invalid component name: "' + name + '". Component names ' +
3676 | 'can only contain alphanumeric characters and the hyphen, ' +
3677 | 'and must start with a letter.'
3678 | );
3679 | }
3680 | }
3681 | var Sub = function VueComponent (options) {
3682 | this._init(options);
3683 | };
3684 | Sub.prototype = Object.create(Super.prototype);
3685 | Sub.prototype.constructor = Sub;
3686 | Sub.cid = cid++;
3687 | Sub.options = mergeOptions(
3688 | Super.options,
3689 | extendOptions
3690 | );
3691 | Sub['super'] = Super;
3692 | // allow further extension/mixin/plugin usage
3693 | Sub.extend = Super.extend;
3694 | Sub.mixin = Super.mixin;
3695 | Sub.use = Super.use;
3696 | // create asset registers, so extended classes
3697 | // can have their private assets too.
3698 | config._assetTypes.forEach(function (type) {
3699 | Sub[type] = Super[type];
3700 | });
3701 | // enable recursive self-lookup
3702 | if (name) {
3703 | Sub.options.components[name] = Sub;
3704 | }
3705 | // keep a reference to the super options at extension time.
3706 | // later at instantiation we can check if Super's options have
3707 | // been updated.
3708 | Sub.superOptions = Super.options;
3709 | Sub.extendOptions = extendOptions;
3710 | // cache constructor
3711 | cachedCtors[SuperId] = Sub;
3712 | return Sub
3713 | };
3714 | }
3715 |
3716 | /* */
3717 |
3718 | function initAssetRegisters (Vue) {
3719 | /**
3720 | * Create asset registration methods.
3721 | */
3722 | config._assetTypes.forEach(function (type) {
3723 | Vue[type] = function (
3724 | id,
3725 | definition
3726 | ) {
3727 | if (!definition) {
3728 | return this.options[type + 's'][id]
3729 | } else {
3730 | /* istanbul ignore if */
3731 | if (false) {
3732 | if (type === 'component' && config.isReservedTag(id)) {
3733 | warn(
3734 | 'Do not use built-in or reserved HTML elements as component ' +
3735 | 'id: ' + id
3736 | );
3737 | }
3738 | }
3739 | if (type === 'component' && isPlainObject(definition)) {
3740 | definition.name = definition.name || id;
3741 | definition = this.options._base.extend(definition);
3742 | }
3743 | if (type === 'directive' && typeof definition === 'function') {
3744 | definition = { bind: definition, update: definition };
3745 | }
3746 | this.options[type + 's'][id] = definition;
3747 | return definition
3748 | }
3749 | };
3750 | });
3751 | }
3752 |
3753 | /* */
3754 |
3755 | var patternTypes = [String, RegExp];
3756 |
3757 | function getComponentName (opts) {
3758 | return opts && (opts.Ctor.options.name || opts.tag)
3759 | }
3760 |
3761 | function matches (pattern, name) {
3762 | if (typeof pattern === 'string') {
3763 | return pattern.split(',').indexOf(name) > -1
3764 | } else {
3765 | return pattern.test(name)
3766 | }
3767 | }
3768 |
3769 | function pruneCache (cache, filter) {
3770 | for (var key in cache) {
3771 | var cachedNode = cache[key];
3772 | if (cachedNode) {
3773 | var name = getComponentName(cachedNode.componentOptions);
3774 | if (name && !filter(name)) {
3775 | pruneCacheEntry(cachedNode);
3776 | cache[key] = null;
3777 | }
3778 | }
3779 | }
3780 | }
3781 |
3782 | function pruneCacheEntry (vnode) {
3783 | if (vnode) {
3784 | if (!vnode.componentInstance._inactive) {
3785 | callHook(vnode.componentInstance, 'deactivated');
3786 | }
3787 | vnode.componentInstance.$destroy();
3788 | }
3789 | }
3790 |
3791 | var KeepAlive = {
3792 | name: 'keep-alive',
3793 | abstract: true,
3794 |
3795 | props: {
3796 | include: patternTypes,
3797 | exclude: patternTypes
3798 | },
3799 |
3800 | created: function created () {
3801 | this.cache = Object.create(null);
3802 | },
3803 |
3804 | destroyed: function destroyed () {
3805 | var this$1 = this;
3806 |
3807 | for (var key in this.cache) {
3808 | pruneCacheEntry(this$1.cache[key]);
3809 | }
3810 | },
3811 |
3812 | watch: {
3813 | include: function include (val) {
3814 | pruneCache(this.cache, function (name) { return matches(val, name); });
3815 | },
3816 | exclude: function exclude (val) {
3817 | pruneCache(this.cache, function (name) { return !matches(val, name); });
3818 | }
3819 | },
3820 |
3821 | render: function render () {
3822 | var vnode = getFirstComponentChild(this.$slots.default);
3823 | var componentOptions = vnode && vnode.componentOptions;
3824 | if (componentOptions) {
3825 | // check pattern
3826 | var name = getComponentName(componentOptions);
3827 | if (name && (
3828 | (this.include && !matches(this.include, name)) ||
3829 | (this.exclude && matches(this.exclude, name))
3830 | )) {
3831 | return vnode
3832 | }
3833 | var key = vnode.key == null
3834 | // same constructor may get registered as different local components
3835 | // so cid alone is not enough (#3269)
3836 | ? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '')
3837 | : vnode.key;
3838 | if (this.cache[key]) {
3839 | vnode.componentInstance = this.cache[key].componentInstance;
3840 | } else {
3841 | this.cache[key] = vnode;
3842 | }
3843 | vnode.data.keepAlive = true;
3844 | }
3845 | return vnode
3846 | }
3847 | };
3848 |
3849 | var builtInComponents = {
3850 | KeepAlive: KeepAlive
3851 | };
3852 |
3853 | /* */
3854 |
3855 | function initGlobalAPI (Vue) {
3856 | // config
3857 | var configDef = {};
3858 | configDef.get = function () { return config; };
3859 | if (false) {
3860 | configDef.set = function () {
3861 | warn(
3862 | 'Do not replace the Vue.config object, set individual fields instead.'
3863 | );
3864 | };
3865 | }
3866 | Object.defineProperty(Vue, 'config', configDef);
3867 | Vue.util = util;
3868 | Vue.set = set$1;
3869 | Vue.delete = del;
3870 | Vue.nextTick = nextTick;
3871 |
3872 | Vue.options = Object.create(null);
3873 | config._assetTypes.forEach(function (type) {
3874 | Vue.options[type + 's'] = Object.create(null);
3875 | });
3876 |
3877 | // this is used to identify the "base" constructor to extend all plain-object
3878 | // components with in Weex's multi-instance scenarios.
3879 | Vue.options._base = Vue;
3880 |
3881 | extend(Vue.options.components, builtInComponents);
3882 |
3883 | initUse(Vue);
3884 | initMixin$1(Vue);
3885 | initExtend(Vue);
3886 | initAssetRegisters(Vue);
3887 | }
3888 |
3889 | initGlobalAPI(Vue$2);
3890 |
3891 | Object.defineProperty(Vue$2.prototype, '$isServer', {
3892 | get: isServerRendering
3893 | });
3894 |
3895 | Vue$2.version = '2.1.10';
3896 |
3897 | /* */
3898 |
3899 | // attributes that should be using props for binding
3900 | var acceptValue = makeMap('input,textarea,option,select');
3901 | var mustUseProp = function (tag, type, attr) {
3902 | return (
3903 | (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
3904 | (attr === 'selected' && tag === 'option') ||
3905 | (attr === 'checked' && tag === 'input') ||
3906 | (attr === 'muted' && tag === 'video')
3907 | )
3908 | };
3909 |
3910 | var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck');
3911 |
3912 | var isBooleanAttr = makeMap(
3913 | 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
3914 | 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
3915 | 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
3916 | 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
3917 | 'required,reversed,scoped,seamless,selected,sortable,translate,' +
3918 | 'truespeed,typemustmatch,visible'
3919 | );
3920 |
3921 | var xlinkNS = 'http://www.w3.org/1999/xlink';
3922 |
3923 | var isXlink = function (name) {
3924 | return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
3925 | };
3926 |
3927 | var getXlinkProp = function (name) {
3928 | return isXlink(name) ? name.slice(6, name.length) : ''
3929 | };
3930 |
3931 | var isFalsyAttrValue = function (val) {
3932 | return val == null || val === false
3933 | };
3934 |
3935 | /* */
3936 |
3937 | function genClassForVnode (vnode) {
3938 | var data = vnode.data;
3939 | var parentNode = vnode;
3940 | var childNode = vnode;
3941 | while (childNode.componentInstance) {
3942 | childNode = childNode.componentInstance._vnode;
3943 | if (childNode.data) {
3944 | data = mergeClassData(childNode.data, data);
3945 | }
3946 | }
3947 | while ((parentNode = parentNode.parent)) {
3948 | if (parentNode.data) {
3949 | data = mergeClassData(data, parentNode.data);
3950 | }
3951 | }
3952 | return genClassFromData(data)
3953 | }
3954 |
3955 | function mergeClassData (child, parent) {
3956 | return {
3957 | staticClass: concat(child.staticClass, parent.staticClass),
3958 | class: child.class
3959 | ? [child.class, parent.class]
3960 | : parent.class
3961 | }
3962 | }
3963 |
3964 | function genClassFromData (data) {
3965 | var dynamicClass = data.class;
3966 | var staticClass = data.staticClass;
3967 | if (staticClass || dynamicClass) {
3968 | return concat(staticClass, stringifyClass(dynamicClass))
3969 | }
3970 | /* istanbul ignore next */
3971 | return ''
3972 | }
3973 |
3974 | function concat (a, b) {
3975 | return a ? b ? (a + ' ' + b) : a : (b || '')
3976 | }
3977 |
3978 | function stringifyClass (value) {
3979 | var res = '';
3980 | if (!value) {
3981 | return res
3982 | }
3983 | if (typeof value === 'string') {
3984 | return value
3985 | }
3986 | if (Array.isArray(value)) {
3987 | var stringified;
3988 | for (var i = 0, l = value.length; i < l; i++) {
3989 | if (value[i]) {
3990 | if ((stringified = stringifyClass(value[i]))) {
3991 | res += stringified + ' ';
3992 | }
3993 | }
3994 | }
3995 | return res.slice(0, -1)
3996 | }
3997 | if (isObject(value)) {
3998 | for (var key in value) {
3999 | if (value[key]) { res += key + ' '; }
4000 | }
4001 | return res.slice(0, -1)
4002 | }
4003 | /* istanbul ignore next */
4004 | return res
4005 | }
4006 |
4007 | /* */
4008 |
4009 | var namespaceMap = {
4010 | svg: 'http://www.w3.org/2000/svg',
4011 | math: 'http://www.w3.org/1998/Math/MathML'
4012 | };
4013 |
4014 | var isHTMLTag = makeMap(
4015 | 'html,body,base,head,link,meta,style,title,' +
4016 | 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
4017 | 'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' +
4018 | 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
4019 | 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
4020 | 'embed,object,param,source,canvas,script,noscript,del,ins,' +
4021 | 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
4022 | 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
4023 | 'output,progress,select,textarea,' +
4024 | 'details,dialog,menu,menuitem,summary,' +
4025 | 'content,element,shadow,template'
4026 | );
4027 |
4028 | // this map is intentionally selective, only covering SVG elements that may
4029 | // contain child elements.
4030 | var isSVG = makeMap(
4031 | 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,' +
4032 | 'font-face,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
4033 | 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
4034 | true
4035 | );
4036 |
4037 |
4038 |
4039 | var isReservedTag = function (tag) {
4040 | return isHTMLTag(tag) || isSVG(tag)
4041 | };
4042 |
4043 | function getTagNamespace (tag) {
4044 | if (isSVG(tag)) {
4045 | return 'svg'
4046 | }
4047 | // basic support for MathML
4048 | // note it doesn't support other MathML elements being component roots
4049 | if (tag === 'math') {
4050 | return 'math'
4051 | }
4052 | }
4053 |
4054 | var unknownElementCache = Object.create(null);
4055 | function isUnknownElement (tag) {
4056 | /* istanbul ignore if */
4057 | if (!inBrowser) {
4058 | return true
4059 | }
4060 | if (isReservedTag(tag)) {
4061 | return false
4062 | }
4063 | tag = tag.toLowerCase();
4064 | /* istanbul ignore if */
4065 | if (unknownElementCache[tag] != null) {
4066 | return unknownElementCache[tag]
4067 | }
4068 | var el = document.createElement(tag);
4069 | if (tag.indexOf('-') > -1) {
4070 | // http://stackoverflow.com/a/28210364/1070244
4071 | return (unknownElementCache[tag] = (
4072 | el.constructor === window.HTMLUnknownElement ||
4073 | el.constructor === window.HTMLElement
4074 | ))
4075 | } else {
4076 | return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString()))
4077 | }
4078 | }
4079 |
4080 | /* */
4081 |
4082 | /**
4083 | * Query an element selector if it's not an element already.
4084 | */
4085 | function query (el) {
4086 | if (typeof el === 'string') {
4087 | var selector = el;
4088 | el = document.querySelector(el);
4089 | if (!el) {
4090 | ("production") !== 'production' && warn(
4091 | 'Cannot find element: ' + selector
4092 | );
4093 | return document.createElement('div')
4094 | }
4095 | }
4096 | return el
4097 | }
4098 |
4099 | /* */
4100 |
4101 | function createElement$1 (tagName, vnode) {
4102 | var elm = document.createElement(tagName);
4103 | if (tagName !== 'select') {
4104 | return elm
4105 | }
4106 | if (vnode.data && vnode.data.attrs && 'multiple' in vnode.data.attrs) {
4107 | elm.setAttribute('multiple', 'multiple');
4108 | }
4109 | return elm
4110 | }
4111 |
4112 | function createElementNS (namespace, tagName) {
4113 | return document.createElementNS(namespaceMap[namespace], tagName)
4114 | }
4115 |
4116 | function createTextNode (text) {
4117 | return document.createTextNode(text)
4118 | }
4119 |
4120 | function createComment (text) {
4121 | return document.createComment(text)
4122 | }
4123 |
4124 | function insertBefore (parentNode, newNode, referenceNode) {
4125 | parentNode.insertBefore(newNode, referenceNode);
4126 | }
4127 |
4128 | function removeChild (node, child) {
4129 | node.removeChild(child);
4130 | }
4131 |
4132 | function appendChild (node, child) {
4133 | node.appendChild(child);
4134 | }
4135 |
4136 | function parentNode (node) {
4137 | return node.parentNode
4138 | }
4139 |
4140 | function nextSibling (node) {
4141 | return node.nextSibling
4142 | }
4143 |
4144 | function tagName (node) {
4145 | return node.tagName
4146 | }
4147 |
4148 | function setTextContent (node, text) {
4149 | node.textContent = text;
4150 | }
4151 |
4152 | function setAttribute (node, key, val) {
4153 | node.setAttribute(key, val);
4154 | }
4155 |
4156 |
4157 | var nodeOps = Object.freeze({
4158 | createElement: createElement$1,
4159 | createElementNS: createElementNS,
4160 | createTextNode: createTextNode,
4161 | createComment: createComment,
4162 | insertBefore: insertBefore,
4163 | removeChild: removeChild,
4164 | appendChild: appendChild,
4165 | parentNode: parentNode,
4166 | nextSibling: nextSibling,
4167 | tagName: tagName,
4168 | setTextContent: setTextContent,
4169 | setAttribute: setAttribute
4170 | });
4171 |
4172 | /* */
4173 |
4174 | var ref = {
4175 | create: function create (_, vnode) {
4176 | registerRef(vnode);
4177 | },
4178 | update: function update (oldVnode, vnode) {
4179 | if (oldVnode.data.ref !== vnode.data.ref) {
4180 | registerRef(oldVnode, true);
4181 | registerRef(vnode);
4182 | }
4183 | },
4184 | destroy: function destroy (vnode) {
4185 | registerRef(vnode, true);
4186 | }
4187 | };
4188 |
4189 | function registerRef (vnode, isRemoval) {
4190 | var key = vnode.data.ref;
4191 | if (!key) { return }
4192 |
4193 | var vm = vnode.context;
4194 | var ref = vnode.componentInstance || vnode.elm;
4195 | var refs = vm.$refs;
4196 | if (isRemoval) {
4197 | if (Array.isArray(refs[key])) {
4198 | remove$1(refs[key], ref);
4199 | } else if (refs[key] === ref) {
4200 | refs[key] = undefined;
4201 | }
4202 | } else {
4203 | if (vnode.data.refInFor) {
4204 | if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) {
4205 | refs[key].push(ref);
4206 | } else {
4207 | refs[key] = [ref];
4208 | }
4209 | } else {
4210 | refs[key] = ref;
4211 | }
4212 | }
4213 | }
4214 |
4215 | /**
4216 | * Virtual DOM patching algorithm based on Snabbdom by
4217 | * Simon Friis Vindum (@paldepind)
4218 | * Licensed under the MIT License
4219 | * https://github.com/paldepind/snabbdom/blob/master/LICENSE
4220 | *
4221 | * modified by Evan You (@yyx990803)
4222 | *
4223 |
4224 | /*
4225 | * Not type-checking this because this file is perf-critical and the cost
4226 | * of making flow understand it is not worth it.
4227 | */
4228 |
4229 | var emptyNode = new VNode('', {}, []);
4230 |
4231 | var hooks$1 = ['create', 'activate', 'update', 'remove', 'destroy'];
4232 |
4233 | function isUndef (s) {
4234 | return s == null
4235 | }
4236 |
4237 | function isDef (s) {
4238 | return s != null
4239 | }
4240 |
4241 | function sameVnode (vnode1, vnode2) {
4242 | return (
4243 | vnode1.key === vnode2.key &&
4244 | vnode1.tag === vnode2.tag &&
4245 | vnode1.isComment === vnode2.isComment &&
4246 | !vnode1.data === !vnode2.data
4247 | )
4248 | }
4249 |
4250 | function createKeyToOldIdx (children, beginIdx, endIdx) {
4251 | var i, key;
4252 | var map = {};
4253 | for (i = beginIdx; i <= endIdx; ++i) {
4254 | key = children[i].key;
4255 | if (isDef(key)) { map[key] = i; }
4256 | }
4257 | return map
4258 | }
4259 |
4260 | function createPatchFunction (backend) {
4261 | var i, j;
4262 | var cbs = {};
4263 |
4264 | var modules = backend.modules;
4265 | var nodeOps = backend.nodeOps;
4266 |
4267 | for (i = 0; i < hooks$1.length; ++i) {
4268 | cbs[hooks$1[i]] = [];
4269 | for (j = 0; j < modules.length; ++j) {
4270 | if (modules[j][hooks$1[i]] !== undefined) { cbs[hooks$1[i]].push(modules[j][hooks$1[i]]); }
4271 | }
4272 | }
4273 |
4274 | function emptyNodeAt (elm) {
4275 | return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm)
4276 | }
4277 |
4278 | function createRmCb (childElm, listeners) {
4279 | function remove$$1 () {
4280 | if (--remove$$1.listeners === 0) {
4281 | removeNode(childElm);
4282 | }
4283 | }
4284 | remove$$1.listeners = listeners;
4285 | return remove$$1
4286 | }
4287 |
4288 | function removeNode (el) {
4289 | var parent = nodeOps.parentNode(el);
4290 | // element may have already been removed due to v-html / v-text
4291 | if (parent) {
4292 | nodeOps.removeChild(parent, el);
4293 | }
4294 | }
4295 |
4296 | var inPre = 0;
4297 | function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) {
4298 | vnode.isRootInsert = !nested; // for transition enter check
4299 | if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) {
4300 | return
4301 | }
4302 |
4303 | var data = vnode.data;
4304 | var children = vnode.children;
4305 | var tag = vnode.tag;
4306 | if (isDef(tag)) {
4307 | if (false) {
4308 | if (data && data.pre) {
4309 | inPre++;
4310 | }
4311 | if (
4312 | !inPre &&
4313 | !vnode.ns &&
4314 | !(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) &&
4315 | config.isUnknownElement(tag)
4316 | ) {
4317 | warn(
4318 | 'Unknown custom element: <' + tag + '> - did you ' +
4319 | 'register the component correctly? For recursive components, ' +
4320 | 'make sure to provide the "name" option.',
4321 | vnode.context
4322 | );
4323 | }
4324 | }
4325 | vnode.elm = vnode.ns
4326 | ? nodeOps.createElementNS(vnode.ns, tag)
4327 | : nodeOps.createElement(tag, vnode);
4328 | setScope(vnode);
4329 |
4330 | /* istanbul ignore if */
4331 | {
4332 | createChildren(vnode, children, insertedVnodeQueue);
4333 | if (isDef(data)) {
4334 | invokeCreateHooks(vnode, insertedVnodeQueue);
4335 | }
4336 | insert(parentElm, vnode.elm, refElm);
4337 | }
4338 |
4339 | if (false) {
4340 | inPre--;
4341 | }
4342 | } else if (vnode.isComment) {
4343 | vnode.elm = nodeOps.createComment(vnode.text);
4344 | insert(parentElm, vnode.elm, refElm);
4345 | } else {
4346 | vnode.elm = nodeOps.createTextNode(vnode.text);
4347 | insert(parentElm, vnode.elm, refElm);
4348 | }
4349 | }
4350 |
4351 | function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
4352 | var i = vnode.data;
4353 | if (isDef(i)) {
4354 | var isReactivated = isDef(vnode.componentInstance) && i.keepAlive;
4355 | if (isDef(i = i.hook) && isDef(i = i.init)) {
4356 | i(vnode, false /* hydrating */, parentElm, refElm);
4357 | }
4358 | // after calling the init hook, if the vnode is a child component
4359 | // it should've created a child instance and mounted it. the child
4360 | // component also has set the placeholder vnode's elm.
4361 | // in that case we can just return the element and be done.
4362 | if (isDef(vnode.componentInstance)) {
4363 | initComponent(vnode, insertedVnodeQueue);
4364 | if (isReactivated) {
4365 | reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm);
4366 | }
4367 | return true
4368 | }
4369 | }
4370 | }
4371 |
4372 | function initComponent (vnode, insertedVnodeQueue) {
4373 | if (vnode.data.pendingInsert) {
4374 | insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert);
4375 | }
4376 | vnode.elm = vnode.componentInstance.$el;
4377 | if (isPatchable(vnode)) {
4378 | invokeCreateHooks(vnode, insertedVnodeQueue);
4379 | setScope(vnode);
4380 | } else {
4381 | // empty component root.
4382 | // skip all element-related modules except for ref (#3455)
4383 | registerRef(vnode);
4384 | // make sure to invoke the insert hook
4385 | insertedVnodeQueue.push(vnode);
4386 | }
4387 | }
4388 |
4389 | function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) {
4390 | var i;
4391 | // hack for #4339: a reactivated component with inner transition
4392 | // does not trigger because the inner node's created hooks are not called
4393 | // again. It's not ideal to involve module-specific logic in here but
4394 | // there doesn't seem to be a better way to do it.
4395 | var innerNode = vnode;
4396 | while (innerNode.componentInstance) {
4397 | innerNode = innerNode.componentInstance._vnode;
4398 | if (isDef(i = innerNode.data) && isDef(i = i.transition)) {
4399 | for (i = 0; i < cbs.activate.length; ++i) {
4400 | cbs.activate[i](emptyNode, innerNode);
4401 | }
4402 | insertedVnodeQueue.push(innerNode);
4403 | break
4404 | }
4405 | }
4406 | // unlike a newly created component,
4407 | // a reactivated keep-alive component doesn't insert itself
4408 | insert(parentElm, vnode.elm, refElm);
4409 | }
4410 |
4411 | function insert (parent, elm, ref) {
4412 | if (parent) {
4413 | if (ref) {
4414 | nodeOps.insertBefore(parent, elm, ref);
4415 | } else {
4416 | nodeOps.appendChild(parent, elm);
4417 | }
4418 | }
4419 | }
4420 |
4421 | function createChildren (vnode, children, insertedVnodeQueue) {
4422 | if (Array.isArray(children)) {
4423 | for (var i = 0; i < children.length; ++i) {
4424 | createElm(children[i], insertedVnodeQueue, vnode.elm, null, true);
4425 | }
4426 | } else if (isPrimitive(vnode.text)) {
4427 | nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text));
4428 | }
4429 | }
4430 |
4431 | function isPatchable (vnode) {
4432 | while (vnode.componentInstance) {
4433 | vnode = vnode.componentInstance._vnode;
4434 | }
4435 | return isDef(vnode.tag)
4436 | }
4437 |
4438 | function invokeCreateHooks (vnode, insertedVnodeQueue) {
4439 | for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) {
4440 | cbs.create[i$1](emptyNode, vnode);
4441 | }
4442 | i = vnode.data.hook; // Reuse variable
4443 | if (isDef(i)) {
4444 | if (i.create) { i.create(emptyNode, vnode); }
4445 | if (i.insert) { insertedVnodeQueue.push(vnode); }
4446 | }
4447 | }
4448 |
4449 | // set scope id attribute for scoped CSS.
4450 | // this is implemented as a special case to avoid the overhead
4451 | // of going through the normal attribute patching process.
4452 | function setScope (vnode) {
4453 | var i;
4454 | if (isDef(i = vnode.context) && isDef(i = i.$options._scopeId)) {
4455 | nodeOps.setAttribute(vnode.elm, i, '');
4456 | }
4457 | if (isDef(i = activeInstance) &&
4458 | i !== vnode.context &&
4459 | isDef(i = i.$options._scopeId)) {
4460 | nodeOps.setAttribute(vnode.elm, i, '');
4461 | }
4462 | }
4463 |
4464 | function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) {
4465 | for (; startIdx <= endIdx; ++startIdx) {
4466 | createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm);
4467 | }
4468 | }
4469 |
4470 | function invokeDestroyHook (vnode) {
4471 | var i, j;
4472 | var data = vnode.data;
4473 | if (isDef(data)) {
4474 | if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); }
4475 | for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); }
4476 | }
4477 | if (isDef(i = vnode.children)) {
4478 | for (j = 0; j < vnode.children.length; ++j) {
4479 | invokeDestroyHook(vnode.children[j]);
4480 | }
4481 | }
4482 | }
4483 |
4484 | function removeVnodes (parentElm, vnodes, startIdx, endIdx) {
4485 | for (; startIdx <= endIdx; ++startIdx) {
4486 | var ch = vnodes[startIdx];
4487 | if (isDef(ch)) {
4488 | if (isDef(ch.tag)) {
4489 | removeAndInvokeRemoveHook(ch);
4490 | invokeDestroyHook(ch);
4491 | } else { // Text node
4492 | removeNode(ch.elm);
4493 | }
4494 | }
4495 | }
4496 | }
4497 |
4498 | function removeAndInvokeRemoveHook (vnode, rm) {
4499 | if (rm || isDef(vnode.data)) {
4500 | var listeners = cbs.remove.length + 1;
4501 | if (!rm) {
4502 | // directly removing
4503 | rm = createRmCb(vnode.elm, listeners);
4504 | } else {
4505 | // we have a recursively passed down rm callback
4506 | // increase the listeners count
4507 | rm.listeners += listeners;
4508 | }
4509 | // recursively invoke hooks on child component root node
4510 | if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) {
4511 | removeAndInvokeRemoveHook(i, rm);
4512 | }
4513 | for (i = 0; i < cbs.remove.length; ++i) {
4514 | cbs.remove[i](vnode, rm);
4515 | }
4516 | if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) {
4517 | i(vnode, rm);
4518 | } else {
4519 | rm();
4520 | }
4521 | } else {
4522 | removeNode(vnode.elm);
4523 | }
4524 | }
4525 |
4526 | function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) {
4527 | var oldStartIdx = 0;
4528 | var newStartIdx = 0;
4529 | var oldEndIdx = oldCh.length - 1;
4530 | var oldStartVnode = oldCh[0];
4531 | var oldEndVnode = oldCh[oldEndIdx];
4532 | var newEndIdx = newCh.length - 1;
4533 | var newStartVnode = newCh[0];
4534 | var newEndVnode = newCh[newEndIdx];
4535 | var oldKeyToIdx, idxInOld, elmToMove, refElm;
4536 |
4537 | // removeOnly is a special flag used only by
4538 | // to ensure removed elements stay in correct relative positions
4539 | // during leaving transitions
4540 | var canMove = !removeOnly;
4541 |
4542 | while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
4543 | if (isUndef(oldStartVnode)) {
4544 | oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left
4545 | } else if (isUndef(oldEndVnode)) {
4546 | oldEndVnode = oldCh[--oldEndIdx];
4547 | } else if (sameVnode(oldStartVnode, newStartVnode)) {
4548 | patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue);
4549 | oldStartVnode = oldCh[++oldStartIdx];
4550 | newStartVnode = newCh[++newStartIdx];
4551 | } else if (sameVnode(oldEndVnode, newEndVnode)) {
4552 | patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue);
4553 | oldEndVnode = oldCh[--oldEndIdx];
4554 | newEndVnode = newCh[--newEndIdx];
4555 | } else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right
4556 | patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue);
4557 | canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm));
4558 | oldStartVnode = oldCh[++oldStartIdx];
4559 | newEndVnode = newCh[--newEndIdx];
4560 | } else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left
4561 | patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue);
4562 | canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm);
4563 | oldEndVnode = oldCh[--oldEndIdx];
4564 | newStartVnode = newCh[++newStartIdx];
4565 | } else {
4566 | if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); }
4567 | idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null;
4568 | if (isUndef(idxInOld)) { // New element
4569 | createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
4570 | newStartVnode = newCh[++newStartIdx];
4571 | } else {
4572 | elmToMove = oldCh[idxInOld];
4573 | /* istanbul ignore if */
4574 | if (false) {
4575 | warn(
4576 | 'It seems there are duplicate keys that is causing an update error. ' +
4577 | 'Make sure each v-for item has a unique key.'
4578 | );
4579 | }
4580 | if (sameVnode(elmToMove, newStartVnode)) {
4581 | patchVnode(elmToMove, newStartVnode, insertedVnodeQueue);
4582 | oldCh[idxInOld] = undefined;
4583 | canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm);
4584 | newStartVnode = newCh[++newStartIdx];
4585 | } else {
4586 | // same key but different element. treat as new element
4587 | createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm);
4588 | newStartVnode = newCh[++newStartIdx];
4589 | }
4590 | }
4591 | }
4592 | }
4593 | if (oldStartIdx > oldEndIdx) {
4594 | refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm;
4595 | addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue);
4596 | } else if (newStartIdx > newEndIdx) {
4597 | removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
4598 | }
4599 | }
4600 |
4601 | function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) {
4602 | if (oldVnode === vnode) {
4603 | return
4604 | }
4605 | // reuse element for static trees.
4606 | // note we only do this if the vnode is cloned -
4607 | // if the new node is not cloned it means the render functions have been
4608 | // reset by the hot-reload-api and we need to do a proper re-render.
4609 | if (vnode.isStatic &&
4610 | oldVnode.isStatic &&
4611 | vnode.key === oldVnode.key &&
4612 | (vnode.isCloned || vnode.isOnce)) {
4613 | vnode.elm = oldVnode.elm;
4614 | vnode.componentInstance = oldVnode.componentInstance;
4615 | return
4616 | }
4617 | var i;
4618 | var data = vnode.data;
4619 | var hasData = isDef(data);
4620 | if (hasData && isDef(i = data.hook) && isDef(i = i.prepatch)) {
4621 | i(oldVnode, vnode);
4622 | }
4623 | var elm = vnode.elm = oldVnode.elm;
4624 | var oldCh = oldVnode.children;
4625 | var ch = vnode.children;
4626 | if (hasData && isPatchable(vnode)) {
4627 | for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); }
4628 | if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); }
4629 | }
4630 | if (isUndef(vnode.text)) {
4631 | if (isDef(oldCh) && isDef(ch)) {
4632 | if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); }
4633 | } else if (isDef(ch)) {
4634 | if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); }
4635 | addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue);
4636 | } else if (isDef(oldCh)) {
4637 | removeVnodes(elm, oldCh, 0, oldCh.length - 1);
4638 | } else if (isDef(oldVnode.text)) {
4639 | nodeOps.setTextContent(elm, '');
4640 | }
4641 | } else if (oldVnode.text !== vnode.text) {
4642 | nodeOps.setTextContent(elm, vnode.text);
4643 | }
4644 | if (hasData) {
4645 | if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); }
4646 | }
4647 | }
4648 |
4649 | function invokeInsertHook (vnode, queue, initial) {
4650 | // delay insert hooks for component root nodes, invoke them after the
4651 | // element is really inserted
4652 | if (initial && vnode.parent) {
4653 | vnode.parent.data.pendingInsert = queue;
4654 | } else {
4655 | for (var i = 0; i < queue.length; ++i) {
4656 | queue[i].data.hook.insert(queue[i]);
4657 | }
4658 | }
4659 | }
4660 |
4661 | var bailed = false;
4662 | // list of modules that can skip create hook during hydration because they
4663 | // are already rendered on the client or has no need for initialization
4664 | var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key');
4665 |
4666 | // Note: this is a browser-only function so we can assume elms are DOM nodes.
4667 | function hydrate (elm, vnode, insertedVnodeQueue) {
4668 | if (false) {
4669 | if (!assertNodeMatch(elm, vnode)) {
4670 | return false
4671 | }
4672 | }
4673 | vnode.elm = elm;
4674 | var tag = vnode.tag;
4675 | var data = vnode.data;
4676 | var children = vnode.children;
4677 | if (isDef(data)) {
4678 | if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); }
4679 | if (isDef(i = vnode.componentInstance)) {
4680 | // child component. it should have hydrated its own tree.
4681 | initComponent(vnode, insertedVnodeQueue);
4682 | return true
4683 | }
4684 | }
4685 | if (isDef(tag)) {
4686 | if (isDef(children)) {
4687 | // empty element, allow client to pick up and populate children
4688 | if (!elm.hasChildNodes()) {
4689 | createChildren(vnode, children, insertedVnodeQueue);
4690 | } else {
4691 | var childrenMatch = true;
4692 | var childNode = elm.firstChild;
4693 | for (var i$1 = 0; i$1 < children.length; i$1++) {
4694 | if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) {
4695 | childrenMatch = false;
4696 | break
4697 | }
4698 | childNode = childNode.nextSibling;
4699 | }
4700 | // if childNode is not null, it means the actual childNodes list is
4701 | // longer than the virtual children list.
4702 | if (!childrenMatch || childNode) {
4703 | if (false) {
4704 | bailed = true;
4705 | console.warn('Parent: ', elm);
4706 | console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children);
4707 | }
4708 | return false
4709 | }
4710 | }
4711 | }
4712 | if (isDef(data)) {
4713 | for (var key in data) {
4714 | if (!isRenderedModule(key)) {
4715 | invokeCreateHooks(vnode, insertedVnodeQueue);
4716 | break
4717 | }
4718 | }
4719 | }
4720 | } else if (elm.data !== vnode.text) {
4721 | elm.data = vnode.text;
4722 | }
4723 | return true
4724 | }
4725 |
4726 | function assertNodeMatch (node, vnode) {
4727 | if (vnode.tag) {
4728 | return (
4729 | vnode.tag.indexOf('vue-component') === 0 ||
4730 | vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase())
4731 | )
4732 | } else {
4733 | return node.nodeType === (vnode.isComment ? 8 : 3)
4734 | }
4735 | }
4736 |
4737 | return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) {
4738 | if (!vnode) {
4739 | if (oldVnode) { invokeDestroyHook(oldVnode); }
4740 | return
4741 | }
4742 |
4743 | var isInitialPatch = false;
4744 | var insertedVnodeQueue = [];
4745 |
4746 | if (!oldVnode) {
4747 | // empty mount (likely as component), create new root element
4748 | isInitialPatch = true;
4749 | createElm(vnode, insertedVnodeQueue, parentElm, refElm);
4750 | } else {
4751 | var isRealElement = isDef(oldVnode.nodeType);
4752 | if (!isRealElement && sameVnode(oldVnode, vnode)) {
4753 | // patch existing root node
4754 | patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly);
4755 | } else {
4756 | if (isRealElement) {
4757 | // mounting to a real element
4758 | // check if this is server-rendered content and if we can perform
4759 | // a successful hydration.
4760 | if (oldVnode.nodeType === 1 && oldVnode.hasAttribute('server-rendered')) {
4761 | oldVnode.removeAttribute('server-rendered');
4762 | hydrating = true;
4763 | }
4764 | if (hydrating) {
4765 | if (hydrate(oldVnode, vnode, insertedVnodeQueue)) {
4766 | invokeInsertHook(vnode, insertedVnodeQueue, true);
4767 | return oldVnode
4768 | } else if (false) {
4769 | warn(
4770 | 'The client-side rendered virtual DOM tree is not matching ' +
4771 | 'server-rendered content. This is likely caused by incorrect ' +
4772 | 'HTML markup, for example nesting block-level elements inside ' +
4773 | '
, or missing
. Bailing hydration and performing ' +
4774 | 'full client-side render.'
4775 | );
4776 | }
4777 | }
4778 | // either not server-rendered, or hydration failed.
4779 | // create an empty node and replace it
4780 | oldVnode = emptyNodeAt(oldVnode);
4781 | }
4782 | // replacing existing element
4783 | var oldElm = oldVnode.elm;
4784 | var parentElm$1 = nodeOps.parentNode(oldElm);
4785 | createElm(
4786 | vnode,
4787 | insertedVnodeQueue,
4788 | // extremely rare edge case: do not insert if old element is in a
4789 | // leaving transition. Only happens when combining transition +
4790 | // keep-alive + HOCs. (#4590)
4791 | oldElm._leaveCb ? null : parentElm$1,
4792 | nodeOps.nextSibling(oldElm)
4793 | );
4794 |
4795 | if (vnode.parent) {
4796 | // component root element replaced.
4797 | // update parent placeholder node element, recursively
4798 | var ancestor = vnode.parent;
4799 | while (ancestor) {
4800 | ancestor.elm = vnode.elm;
4801 | ancestor = ancestor.parent;
4802 | }
4803 | if (isPatchable(vnode)) {
4804 | for (var i = 0; i < cbs.create.length; ++i) {
4805 | cbs.create[i](emptyNode, vnode.parent);
4806 | }
4807 | }
4808 | }
4809 |
4810 | if (parentElm$1 !== null) {
4811 | removeVnodes(parentElm$1, [oldVnode], 0, 0);
4812 | } else if (isDef(oldVnode.tag)) {
4813 | invokeDestroyHook(oldVnode);
4814 | }
4815 | }
4816 | }
4817 |
4818 | invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch);
4819 | return vnode.elm
4820 | }
4821 | }
4822 |
4823 | /* */
4824 |
4825 | var directives = {
4826 | create: updateDirectives,
4827 | update: updateDirectives,
4828 | destroy: function unbindDirectives (vnode) {
4829 | updateDirectives(vnode, emptyNode);
4830 | }
4831 | };
4832 |
4833 | function updateDirectives (oldVnode, vnode) {
4834 | if (oldVnode.data.directives || vnode.data.directives) {
4835 | _update(oldVnode, vnode);
4836 | }
4837 | }
4838 |
4839 | function _update (oldVnode, vnode) {
4840 | var isCreate = oldVnode === emptyNode;
4841 | var isDestroy = vnode === emptyNode;
4842 | var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context);
4843 | var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context);
4844 |
4845 | var dirsWithInsert = [];
4846 | var dirsWithPostpatch = [];
4847 |
4848 | var key, oldDir, dir;
4849 | for (key in newDirs) {
4850 | oldDir = oldDirs[key];
4851 | dir = newDirs[key];
4852 | if (!oldDir) {
4853 | // new directive, bind
4854 | callHook$1(dir, 'bind', vnode, oldVnode);
4855 | if (dir.def && dir.def.inserted) {
4856 | dirsWithInsert.push(dir);
4857 | }
4858 | } else {
4859 | // existing directive, update
4860 | dir.oldValue = oldDir.value;
4861 | callHook$1(dir, 'update', vnode, oldVnode);
4862 | if (dir.def && dir.def.componentUpdated) {
4863 | dirsWithPostpatch.push(dir);
4864 | }
4865 | }
4866 | }
4867 |
4868 | if (dirsWithInsert.length) {
4869 | var callInsert = function () {
4870 | for (var i = 0; i < dirsWithInsert.length; i++) {
4871 | callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode);
4872 | }
4873 | };
4874 | if (isCreate) {
4875 | mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert, 'dir-insert');
4876 | } else {
4877 | callInsert();
4878 | }
4879 | }
4880 |
4881 | if (dirsWithPostpatch.length) {
4882 | mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () {
4883 | for (var i = 0; i < dirsWithPostpatch.length; i++) {
4884 | callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode);
4885 | }
4886 | }, 'dir-postpatch');
4887 | }
4888 |
4889 | if (!isCreate) {
4890 | for (key in oldDirs) {
4891 | if (!newDirs[key]) {
4892 | // no longer present, unbind
4893 | callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy);
4894 | }
4895 | }
4896 | }
4897 | }
4898 |
4899 | var emptyModifiers = Object.create(null);
4900 |
4901 | function normalizeDirectives$1 (
4902 | dirs,
4903 | vm
4904 | ) {
4905 | var res = Object.create(null);
4906 | if (!dirs) {
4907 | return res
4908 | }
4909 | var i, dir;
4910 | for (i = 0; i < dirs.length; i++) {
4911 | dir = dirs[i];
4912 | if (!dir.modifiers) {
4913 | dir.modifiers = emptyModifiers;
4914 | }
4915 | res[getRawDirName(dir)] = dir;
4916 | dir.def = resolveAsset(vm.$options, 'directives', dir.name, true);
4917 | }
4918 | return res
4919 | }
4920 |
4921 | function getRawDirName (dir) {
4922 | return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.')))
4923 | }
4924 |
4925 | function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) {
4926 | var fn = dir.def && dir.def[hook];
4927 | if (fn) {
4928 | fn(vnode.elm, dir, vnode, oldVnode, isDestroy);
4929 | }
4930 | }
4931 |
4932 | var baseModules = [
4933 | ref,
4934 | directives
4935 | ];
4936 |
4937 | /* */
4938 |
4939 | function updateAttrs (oldVnode, vnode) {
4940 | if (!oldVnode.data.attrs && !vnode.data.attrs) {
4941 | return
4942 | }
4943 | var key, cur, old;
4944 | var elm = vnode.elm;
4945 | var oldAttrs = oldVnode.data.attrs || {};
4946 | var attrs = vnode.data.attrs || {};
4947 | // clone observed objects, as the user probably wants to mutate it
4948 | if (attrs.__ob__) {
4949 | attrs = vnode.data.attrs = extend({}, attrs);
4950 | }
4951 |
4952 | for (key in attrs) {
4953 | cur = attrs[key];
4954 | old = oldAttrs[key];
4955 | if (old !== cur) {
4956 | setAttr(elm, key, cur);
4957 | }
4958 | }
4959 | // #4391: in IE9, setting type can reset value for input[type=radio]
4960 | /* istanbul ignore if */
4961 | if (isIE9 && attrs.value !== oldAttrs.value) {
4962 | setAttr(elm, 'value', attrs.value);
4963 | }
4964 | for (key in oldAttrs) {
4965 | if (attrs[key] == null) {
4966 | if (isXlink(key)) {
4967 | elm.removeAttributeNS(xlinkNS, getXlinkProp(key));
4968 | } else if (!isEnumeratedAttr(key)) {
4969 | elm.removeAttribute(key);
4970 | }
4971 | }
4972 | }
4973 | }
4974 |
4975 | function setAttr (el, key, value) {
4976 | if (isBooleanAttr(key)) {
4977 | // set attribute for blank value
4978 | // e.g.
4979 | if (isFalsyAttrValue(value)) {
4980 | el.removeAttribute(key);
4981 | } else {
4982 | el.setAttribute(key, key);
4983 | }
4984 | } else if (isEnumeratedAttr(key)) {
4985 | el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true');
4986 | } else if (isXlink(key)) {
4987 | if (isFalsyAttrValue(value)) {
4988 | el.removeAttributeNS(xlinkNS, getXlinkProp(key));
4989 | } else {
4990 | el.setAttributeNS(xlinkNS, key, value);
4991 | }
4992 | } else {
4993 | if (isFalsyAttrValue(value)) {
4994 | el.removeAttribute(key);
4995 | } else {
4996 | el.setAttribute(key, value);
4997 | }
4998 | }
4999 | }
5000 |
5001 | var attrs = {
5002 | create: updateAttrs,
5003 | update: updateAttrs
5004 | };
5005 |
5006 | /* */
5007 |
5008 | function updateClass (oldVnode, vnode) {
5009 | var el = vnode.elm;
5010 | var data = vnode.data;
5011 | var oldData = oldVnode.data;
5012 | if (!data.staticClass && !data.class &&
5013 | (!oldData || (!oldData.staticClass && !oldData.class))) {
5014 | return
5015 | }
5016 |
5017 | var cls = genClassForVnode(vnode);
5018 |
5019 | // handle transition classes
5020 | var transitionClass = el._transitionClasses;
5021 | if (transitionClass) {
5022 | cls = concat(cls, stringifyClass(transitionClass));
5023 | }
5024 |
5025 | // set the class
5026 | if (cls !== el._prevClass) {
5027 | el.setAttribute('class', cls);
5028 | el._prevClass = cls;
5029 | }
5030 | }
5031 |
5032 | var klass = {
5033 | create: updateClass,
5034 | update: updateClass
5035 | };
5036 |
5037 | /* */
5038 |
5039 | var target$1;
5040 |
5041 | function add$2 (
5042 | event,
5043 | handler,
5044 | once,
5045 | capture
5046 | ) {
5047 | if (once) {
5048 | var oldHandler = handler;
5049 | var _target = target$1; // save current target element in closure
5050 | handler = function (ev) {
5051 | remove$3(event, handler, capture, _target);
5052 | arguments.length === 1
5053 | ? oldHandler(ev)
5054 | : oldHandler.apply(null, arguments);
5055 | };
5056 | }
5057 | target$1.addEventListener(event, handler, capture);
5058 | }
5059 |
5060 | function remove$3 (
5061 | event,
5062 | handler,
5063 | capture,
5064 | _target
5065 | ) {
5066 | (_target || target$1).removeEventListener(event, handler, capture);
5067 | }
5068 |
5069 | function updateDOMListeners (oldVnode, vnode) {
5070 | if (!oldVnode.data.on && !vnode.data.on) {
5071 | return
5072 | }
5073 | var on = vnode.data.on || {};
5074 | var oldOn = oldVnode.data.on || {};
5075 | target$1 = vnode.elm;
5076 | updateListeners(on, oldOn, add$2, remove$3, vnode.context);
5077 | }
5078 |
5079 | var events = {
5080 | create: updateDOMListeners,
5081 | update: updateDOMListeners
5082 | };
5083 |
5084 | /* */
5085 |
5086 | function updateDOMProps (oldVnode, vnode) {
5087 | if (!oldVnode.data.domProps && !vnode.data.domProps) {
5088 | return
5089 | }
5090 | var key, cur;
5091 | var elm = vnode.elm;
5092 | var oldProps = oldVnode.data.domProps || {};
5093 | var props = vnode.data.domProps || {};
5094 | // clone observed objects, as the user probably wants to mutate it
5095 | if (props.__ob__) {
5096 | props = vnode.data.domProps = extend({}, props);
5097 | }
5098 |
5099 | for (key in oldProps) {
5100 | if (props[key] == null) {
5101 | elm[key] = '';
5102 | }
5103 | }
5104 | for (key in props) {
5105 | cur = props[key];
5106 | // ignore children if the node has textContent or innerHTML,
5107 | // as these will throw away existing DOM nodes and cause removal errors
5108 | // on subsequent patches (#3360)
5109 | if (key === 'textContent' || key === 'innerHTML') {
5110 | if (vnode.children) { vnode.children.length = 0; }
5111 | if (cur === oldProps[key]) { continue }
5112 | }
5113 |
5114 | if (key === 'value') {
5115 | // store value as _value as well since
5116 | // non-string values will be stringified
5117 | elm._value = cur;
5118 | // avoid resetting cursor position when value is the same
5119 | var strCur = cur == null ? '' : String(cur);
5120 | if (shouldUpdateValue(elm, vnode, strCur)) {
5121 | elm.value = strCur;
5122 | }
5123 | } else {
5124 | elm[key] = cur;
5125 | }
5126 | }
5127 | }
5128 |
5129 | // check platforms/web/util/attrs.js acceptValue
5130 |
5131 |
5132 | function shouldUpdateValue (
5133 | elm,
5134 | vnode,
5135 | checkVal
5136 | ) {
5137 | return (!elm.composing && (
5138 | vnode.tag === 'option' ||
5139 | isDirty(elm, checkVal) ||
5140 | isInputChanged(vnode, checkVal)
5141 | ))
5142 | }
5143 |
5144 | function isDirty (elm, checkVal) {
5145 | // return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value
5146 | return document.activeElement !== elm && elm.value !== checkVal
5147 | }
5148 |
5149 | function isInputChanged (vnode, newVal) {
5150 | var value = vnode.elm.value;
5151 | var modifiers = vnode.elm._vModifiers; // injected by v-model runtime
5152 | if ((modifiers && modifiers.number) || vnode.elm.type === 'number') {
5153 | return toNumber(value) !== toNumber(newVal)
5154 | }
5155 | if (modifiers && modifiers.trim) {
5156 | return value.trim() !== newVal.trim()
5157 | }
5158 | return value !== newVal
5159 | }
5160 |
5161 | var domProps = {
5162 | create: updateDOMProps,
5163 | update: updateDOMProps
5164 | };
5165 |
5166 | /* */
5167 |
5168 | var parseStyleText = cached(function (cssText) {
5169 | var res = {};
5170 | var listDelimiter = /;(?![^(]*\))/g;
5171 | var propertyDelimiter = /:(.+)/;
5172 | cssText.split(listDelimiter).forEach(function (item) {
5173 | if (item) {
5174 | var tmp = item.split(propertyDelimiter);
5175 | tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim());
5176 | }
5177 | });
5178 | return res
5179 | });
5180 |
5181 | // merge static and dynamic style data on the same vnode
5182 | function normalizeStyleData (data) {
5183 | var style = normalizeStyleBinding(data.style);
5184 | // static style is pre-processed into an object during compilation
5185 | // and is always a fresh object, so it's safe to merge into it
5186 | return data.staticStyle
5187 | ? extend(data.staticStyle, style)
5188 | : style
5189 | }
5190 |
5191 | // normalize possible array / string values into Object
5192 | function normalizeStyleBinding (bindingStyle) {
5193 | if (Array.isArray(bindingStyle)) {
5194 | return toObject(bindingStyle)
5195 | }
5196 | if (typeof bindingStyle === 'string') {
5197 | return parseStyleText(bindingStyle)
5198 | }
5199 | return bindingStyle
5200 | }
5201 |
5202 | /**
5203 | * parent component style should be after child's
5204 | * so that parent component's style could override it
5205 | */
5206 | function getStyle (vnode, checkChild) {
5207 | var res = {};
5208 | var styleData;
5209 |
5210 | if (checkChild) {
5211 | var childNode = vnode;
5212 | while (childNode.componentInstance) {
5213 | childNode = childNode.componentInstance._vnode;
5214 | if (childNode.data && (styleData = normalizeStyleData(childNode.data))) {
5215 | extend(res, styleData);
5216 | }
5217 | }
5218 | }
5219 |
5220 | if ((styleData = normalizeStyleData(vnode.data))) {
5221 | extend(res, styleData);
5222 | }
5223 |
5224 | var parentNode = vnode;
5225 | while ((parentNode = parentNode.parent)) {
5226 | if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
5227 | extend(res, styleData);
5228 | }
5229 | }
5230 | return res
5231 | }
5232 |
5233 | /* */
5234 |
5235 | var cssVarRE = /^--/;
5236 | var importantRE = /\s*!important$/;
5237 | var setProp = function (el, name, val) {
5238 | /* istanbul ignore if */
5239 | if (cssVarRE.test(name)) {
5240 | el.style.setProperty(name, val);
5241 | } else if (importantRE.test(val)) {
5242 | el.style.setProperty(name, val.replace(importantRE, ''), 'important');
5243 | } else {
5244 | el.style[normalize(name)] = val;
5245 | }
5246 | };
5247 |
5248 | var prefixes = ['Webkit', 'Moz', 'ms'];
5249 |
5250 | var testEl;
5251 | var normalize = cached(function (prop) {
5252 | testEl = testEl || document.createElement('div');
5253 | prop = camelize(prop);
5254 | if (prop !== 'filter' && (prop in testEl.style)) {
5255 | return prop
5256 | }
5257 | var upper = prop.charAt(0).toUpperCase() + prop.slice(1);
5258 | for (var i = 0; i < prefixes.length; i++) {
5259 | var prefixed = prefixes[i] + upper;
5260 | if (prefixed in testEl.style) {
5261 | return prefixed
5262 | }
5263 | }
5264 | });
5265 |
5266 | function updateStyle (oldVnode, vnode) {
5267 | var data = vnode.data;
5268 | var oldData = oldVnode.data;
5269 |
5270 | if (!data.staticStyle && !data.style &&
5271 | !oldData.staticStyle && !oldData.style) {
5272 | return
5273 | }
5274 |
5275 | var cur, name;
5276 | var el = vnode.elm;
5277 | var oldStaticStyle = oldVnode.data.staticStyle;
5278 | var oldStyleBinding = oldVnode.data.style || {};
5279 |
5280 | // if static style exists, stylebinding already merged into it when doing normalizeStyleData
5281 | var oldStyle = oldStaticStyle || oldStyleBinding;
5282 |
5283 | var style = normalizeStyleBinding(vnode.data.style) || {};
5284 |
5285 | vnode.data.style = style.__ob__ ? extend({}, style) : style;
5286 |
5287 | var newStyle = getStyle(vnode, true);
5288 |
5289 | for (name in oldStyle) {
5290 | if (newStyle[name] == null) {
5291 | setProp(el, name, '');
5292 | }
5293 | }
5294 | for (name in newStyle) {
5295 | cur = newStyle[name];
5296 | if (cur !== oldStyle[name]) {
5297 | // ie9 setting to null has no effect, must use empty string
5298 | setProp(el, name, cur == null ? '' : cur);
5299 | }
5300 | }
5301 | }
5302 |
5303 | var style = {
5304 | create: updateStyle,
5305 | update: updateStyle
5306 | };
5307 |
5308 | /* */
5309 |
5310 | /**
5311 | * Add class with compatibility for SVG since classList is not supported on
5312 | * SVG elements in IE
5313 | */
5314 | function addClass (el, cls) {
5315 | /* istanbul ignore if */
5316 | if (!cls || !cls.trim()) {
5317 | return
5318 | }
5319 |
5320 | /* istanbul ignore else */
5321 | if (el.classList) {
5322 | if (cls.indexOf(' ') > -1) {
5323 | cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); });
5324 | } else {
5325 | el.classList.add(cls);
5326 | }
5327 | } else {
5328 | var cur = ' ' + el.getAttribute('class') + ' ';
5329 | if (cur.indexOf(' ' + cls + ' ') < 0) {
5330 | el.setAttribute('class', (cur + cls).trim());
5331 | }
5332 | }
5333 | }
5334 |
5335 | /**
5336 | * Remove class with compatibility for SVG since classList is not supported on
5337 | * SVG elements in IE
5338 | */
5339 | function removeClass (el, cls) {
5340 | /* istanbul ignore if */
5341 | if (!cls || !cls.trim()) {
5342 | return
5343 | }
5344 |
5345 | /* istanbul ignore else */
5346 | if (el.classList) {
5347 | if (cls.indexOf(' ') > -1) {
5348 | cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); });
5349 | } else {
5350 | el.classList.remove(cls);
5351 | }
5352 | } else {
5353 | var cur = ' ' + el.getAttribute('class') + ' ';
5354 | var tar = ' ' + cls + ' ';
5355 | while (cur.indexOf(tar) >= 0) {
5356 | cur = cur.replace(tar, ' ');
5357 | }
5358 | el.setAttribute('class', cur.trim());
5359 | }
5360 | }
5361 |
5362 | /* */
5363 |
5364 | var hasTransition = inBrowser && !isIE9;
5365 | var TRANSITION = 'transition';
5366 | var ANIMATION = 'animation';
5367 |
5368 | // Transition property/event sniffing
5369 | var transitionProp = 'transition';
5370 | var transitionEndEvent = 'transitionend';
5371 | var animationProp = 'animation';
5372 | var animationEndEvent = 'animationend';
5373 | if (hasTransition) {
5374 | /* istanbul ignore if */
5375 | if (window.ontransitionend === undefined &&
5376 | window.onwebkittransitionend !== undefined) {
5377 | transitionProp = 'WebkitTransition';
5378 | transitionEndEvent = 'webkitTransitionEnd';
5379 | }
5380 | if (window.onanimationend === undefined &&
5381 | window.onwebkitanimationend !== undefined) {
5382 | animationProp = 'WebkitAnimation';
5383 | animationEndEvent = 'webkitAnimationEnd';
5384 | }
5385 | }
5386 |
5387 | // binding to window is necessary to make hot reload work in IE in strict mode
5388 | var raf = inBrowser && window.requestAnimationFrame
5389 | ? window.requestAnimationFrame.bind(window)
5390 | : setTimeout;
5391 |
5392 | function nextFrame (fn) {
5393 | raf(function () {
5394 | raf(fn);
5395 | });
5396 | }
5397 |
5398 | function addTransitionClass (el, cls) {
5399 | (el._transitionClasses || (el._transitionClasses = [])).push(cls);
5400 | addClass(el, cls);
5401 | }
5402 |
5403 | function removeTransitionClass (el, cls) {
5404 | if (el._transitionClasses) {
5405 | remove$1(el._transitionClasses, cls);
5406 | }
5407 | removeClass(el, cls);
5408 | }
5409 |
5410 | function whenTransitionEnds (
5411 | el,
5412 | expectedType,
5413 | cb
5414 | ) {
5415 | var ref = getTransitionInfo(el, expectedType);
5416 | var type = ref.type;
5417 | var timeout = ref.timeout;
5418 | var propCount = ref.propCount;
5419 | if (!type) { return cb() }
5420 | var event = type === TRANSITION ? transitionEndEvent : animationEndEvent;
5421 | var ended = 0;
5422 | var end = function () {
5423 | el.removeEventListener(event, onEnd);
5424 | cb();
5425 | };
5426 | var onEnd = function (e) {
5427 | if (e.target === el) {
5428 | if (++ended >= propCount) {
5429 | end();
5430 | }
5431 | }
5432 | };
5433 | setTimeout(function () {
5434 | if (ended < propCount) {
5435 | end();
5436 | }
5437 | }, timeout + 1);
5438 | el.addEventListener(event, onEnd);
5439 | }
5440 |
5441 | var transformRE = /\b(transform|all)(,|$)/;
5442 |
5443 | function getTransitionInfo (el, expectedType) {
5444 | var styles = window.getComputedStyle(el);
5445 | var transitioneDelays = styles[transitionProp + 'Delay'].split(', ');
5446 | var transitionDurations = styles[transitionProp + 'Duration'].split(', ');
5447 | var transitionTimeout = getTimeout(transitioneDelays, transitionDurations);
5448 | var animationDelays = styles[animationProp + 'Delay'].split(', ');
5449 | var animationDurations = styles[animationProp + 'Duration'].split(', ');
5450 | var animationTimeout = getTimeout(animationDelays, animationDurations);
5451 |
5452 | var type;
5453 | var timeout = 0;
5454 | var propCount = 0;
5455 | /* istanbul ignore if */
5456 | if (expectedType === TRANSITION) {
5457 | if (transitionTimeout > 0) {
5458 | type = TRANSITION;
5459 | timeout = transitionTimeout;
5460 | propCount = transitionDurations.length;
5461 | }
5462 | } else if (expectedType === ANIMATION) {
5463 | if (animationTimeout > 0) {
5464 | type = ANIMATION;
5465 | timeout = animationTimeout;
5466 | propCount = animationDurations.length;
5467 | }
5468 | } else {
5469 | timeout = Math.max(transitionTimeout, animationTimeout);
5470 | type = timeout > 0
5471 | ? transitionTimeout > animationTimeout
5472 | ? TRANSITION
5473 | : ANIMATION
5474 | : null;
5475 | propCount = type
5476 | ? type === TRANSITION
5477 | ? transitionDurations.length
5478 | : animationDurations.length
5479 | : 0;
5480 | }
5481 | var hasTransform =
5482 | type === TRANSITION &&
5483 | transformRE.test(styles[transitionProp + 'Property']);
5484 | return {
5485 | type: type,
5486 | timeout: timeout,
5487 | propCount: propCount,
5488 | hasTransform: hasTransform
5489 | }
5490 | }
5491 |
5492 | function getTimeout (delays, durations) {
5493 | /* istanbul ignore next */
5494 | while (delays.length < durations.length) {
5495 | delays = delays.concat(delays);
5496 | }
5497 |
5498 | return Math.max.apply(null, durations.map(function (d, i) {
5499 | return toMs(d) + toMs(delays[i])
5500 | }))
5501 | }
5502 |
5503 | function toMs (s) {
5504 | return Number(s.slice(0, -1)) * 1000
5505 | }
5506 |
5507 | /* */
5508 |
5509 | function enter (vnode, toggleDisplay) {
5510 | var el = vnode.elm;
5511 |
5512 | // call leave callback now
5513 | if (el._leaveCb) {
5514 | el._leaveCb.cancelled = true;
5515 | el._leaveCb();
5516 | }
5517 |
5518 | var data = resolveTransition(vnode.data.transition);
5519 | if (!data) {
5520 | return
5521 | }
5522 |
5523 | /* istanbul ignore if */
5524 | if (el._enterCb || el.nodeType !== 1) {
5525 | return
5526 | }
5527 |
5528 | var css = data.css;
5529 | var type = data.type;
5530 | var enterClass = data.enterClass;
5531 | var enterToClass = data.enterToClass;
5532 | var enterActiveClass = data.enterActiveClass;
5533 | var appearClass = data.appearClass;
5534 | var appearToClass = data.appearToClass;
5535 | var appearActiveClass = data.appearActiveClass;
5536 | var beforeEnter = data.beforeEnter;
5537 | var enter = data.enter;
5538 | var afterEnter = data.afterEnter;
5539 | var enterCancelled = data.enterCancelled;
5540 | var beforeAppear = data.beforeAppear;
5541 | var appear = data.appear;
5542 | var afterAppear = data.afterAppear;
5543 | var appearCancelled = data.appearCancelled;
5544 |
5545 | // activeInstance will always be the component managing this
5546 | // transition. One edge case to check is when the is placed
5547 | // as the root node of a child component. In that case we need to check
5548 | // 's parent for appear check.
5549 | var context = activeInstance;
5550 | var transitionNode = activeInstance.$vnode;
5551 | while (transitionNode && transitionNode.parent) {
5552 | transitionNode = transitionNode.parent;
5553 | context = transitionNode.context;
5554 | }
5555 |
5556 | var isAppear = !context._isMounted || !vnode.isRootInsert;
5557 |
5558 | if (isAppear && !appear && appear !== '') {
5559 | return
5560 | }
5561 |
5562 | var startClass = isAppear ? appearClass : enterClass;
5563 | var activeClass = isAppear ? appearActiveClass : enterActiveClass;
5564 | var toClass = isAppear ? appearToClass : enterToClass;
5565 | var beforeEnterHook = isAppear ? (beforeAppear || beforeEnter) : beforeEnter;
5566 | var enterHook = isAppear ? (typeof appear === 'function' ? appear : enter) : enter;
5567 | var afterEnterHook = isAppear ? (afterAppear || afterEnter) : afterEnter;
5568 | var enterCancelledHook = isAppear ? (appearCancelled || enterCancelled) : enterCancelled;
5569 |
5570 | var expectsCSS = css !== false && !isIE9;
5571 | var userWantsControl =
5572 | enterHook &&
5573 | // enterHook may be a bound method which exposes
5574 | // the length of original fn as _length
5575 | (enterHook._length || enterHook.length) > 1;
5576 |
5577 | var cb = el._enterCb = once(function () {
5578 | if (expectsCSS) {
5579 | removeTransitionClass(el, toClass);
5580 | removeTransitionClass(el, activeClass);
5581 | }
5582 | if (cb.cancelled) {
5583 | if (expectsCSS) {
5584 | removeTransitionClass(el, startClass);
5585 | }
5586 | enterCancelledHook && enterCancelledHook(el);
5587 | } else {
5588 | afterEnterHook && afterEnterHook(el);
5589 | }
5590 | el._enterCb = null;
5591 | });
5592 |
5593 | if (!vnode.data.show) {
5594 | // remove pending leave element on enter by injecting an insert hook
5595 | mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () {
5596 | var parent = el.parentNode;
5597 | var pendingNode = parent && parent._pending && parent._pending[vnode.key];
5598 | if (pendingNode &&
5599 | pendingNode.tag === vnode.tag &&
5600 | pendingNode.elm._leaveCb) {
5601 | pendingNode.elm._leaveCb();
5602 | }
5603 | enterHook && enterHook(el, cb);
5604 | }, 'transition-insert');
5605 | }
5606 |
5607 | // start enter transition
5608 | beforeEnterHook && beforeEnterHook(el);
5609 | if (expectsCSS) {
5610 | addTransitionClass(el, startClass);
5611 | addTransitionClass(el, activeClass);
5612 | nextFrame(function () {
5613 | addTransitionClass(el, toClass);
5614 | removeTransitionClass(el, startClass);
5615 | if (!cb.cancelled && !userWantsControl) {
5616 | whenTransitionEnds(el, type, cb);
5617 | }
5618 | });
5619 | }
5620 |
5621 | if (vnode.data.show) {
5622 | toggleDisplay && toggleDisplay();
5623 | enterHook && enterHook(el, cb);
5624 | }
5625 |
5626 | if (!expectsCSS && !userWantsControl) {
5627 | cb();
5628 | }
5629 | }
5630 |
5631 | function leave (vnode, rm) {
5632 | var el = vnode.elm;
5633 |
5634 | // call enter callback now
5635 | if (el._enterCb) {
5636 | el._enterCb.cancelled = true;
5637 | el._enterCb();
5638 | }
5639 |
5640 | var data = resolveTransition(vnode.data.transition);
5641 | if (!data) {
5642 | return rm()
5643 | }
5644 |
5645 | /* istanbul ignore if */
5646 | if (el._leaveCb || el.nodeType !== 1) {
5647 | return
5648 | }
5649 |
5650 | var css = data.css;
5651 | var type = data.type;
5652 | var leaveClass = data.leaveClass;
5653 | var leaveToClass = data.leaveToClass;
5654 | var leaveActiveClass = data.leaveActiveClass;
5655 | var beforeLeave = data.beforeLeave;
5656 | var leave = data.leave;
5657 | var afterLeave = data.afterLeave;
5658 | var leaveCancelled = data.leaveCancelled;
5659 | var delayLeave = data.delayLeave;
5660 |
5661 | var expectsCSS = css !== false && !isIE9;
5662 | var userWantsControl =
5663 | leave &&
5664 | // leave hook may be a bound method which exposes
5665 | // the length of original fn as _length
5666 | (leave._length || leave.length) > 1;
5667 |
5668 | var cb = el._leaveCb = once(function () {
5669 | if (el.parentNode && el.parentNode._pending) {
5670 | el.parentNode._pending[vnode.key] = null;
5671 | }
5672 | if (expectsCSS) {
5673 | removeTransitionClass(el, leaveToClass);
5674 | removeTransitionClass(el, leaveActiveClass);
5675 | }
5676 | if (cb.cancelled) {
5677 | if (expectsCSS) {
5678 | removeTransitionClass(el, leaveClass);
5679 | }
5680 | leaveCancelled && leaveCancelled(el);
5681 | } else {
5682 | rm();
5683 | afterLeave && afterLeave(el);
5684 | }
5685 | el._leaveCb = null;
5686 | });
5687 |
5688 | if (delayLeave) {
5689 | delayLeave(performLeave);
5690 | } else {
5691 | performLeave();
5692 | }
5693 |
5694 | function performLeave () {
5695 | // the delayed leave may have already been cancelled
5696 | if (cb.cancelled) {
5697 | return
5698 | }
5699 | // record leaving element
5700 | if (!vnode.data.show) {
5701 | (el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode;
5702 | }
5703 | beforeLeave && beforeLeave(el);
5704 | if (expectsCSS) {
5705 | addTransitionClass(el, leaveClass);
5706 | addTransitionClass(el, leaveActiveClass);
5707 | nextFrame(function () {
5708 | addTransitionClass(el, leaveToClass);
5709 | removeTransitionClass(el, leaveClass);
5710 | if (!cb.cancelled && !userWantsControl) {
5711 | whenTransitionEnds(el, type, cb);
5712 | }
5713 | });
5714 | }
5715 | leave && leave(el, cb);
5716 | if (!expectsCSS && !userWantsControl) {
5717 | cb();
5718 | }
5719 | }
5720 | }
5721 |
5722 | function resolveTransition (def$$1) {
5723 | if (!def$$1) {
5724 | return
5725 | }
5726 | /* istanbul ignore else */
5727 | if (typeof def$$1 === 'object') {
5728 | var res = {};
5729 | if (def$$1.css !== false) {
5730 | extend(res, autoCssTransition(def$$1.name || 'v'));
5731 | }
5732 | extend(res, def$$1);
5733 | return res
5734 | } else if (typeof def$$1 === 'string') {
5735 | return autoCssTransition(def$$1)
5736 | }
5737 | }
5738 |
5739 | var autoCssTransition = cached(function (name) {
5740 | return {
5741 | enterClass: (name + "-enter"),
5742 | leaveClass: (name + "-leave"),
5743 | appearClass: (name + "-enter"),
5744 | enterToClass: (name + "-enter-to"),
5745 | leaveToClass: (name + "-leave-to"),
5746 | appearToClass: (name + "-enter-to"),
5747 | enterActiveClass: (name + "-enter-active"),
5748 | leaveActiveClass: (name + "-leave-active"),
5749 | appearActiveClass: (name + "-enter-active")
5750 | }
5751 | });
5752 |
5753 | function once (fn) {
5754 | var called = false;
5755 | return function () {
5756 | if (!called) {
5757 | called = true;
5758 | fn();
5759 | }
5760 | }
5761 | }
5762 |
5763 | function _enter (_, vnode) {
5764 | if (!vnode.data.show) {
5765 | enter(vnode);
5766 | }
5767 | }
5768 |
5769 | var transition = inBrowser ? {
5770 | create: _enter,
5771 | activate: _enter,
5772 | remove: function remove (vnode, rm) {
5773 | /* istanbul ignore else */
5774 | if (!vnode.data.show) {
5775 | leave(vnode, rm);
5776 | } else {
5777 | rm();
5778 | }
5779 | }
5780 | } : {};
5781 |
5782 | var platformModules = [
5783 | attrs,
5784 | klass,
5785 | events,
5786 | domProps,
5787 | style,
5788 | transition
5789 | ];
5790 |
5791 | /* */
5792 |
5793 | // the directive module should be applied last, after all
5794 | // built-in modules have been applied.
5795 | var modules = platformModules.concat(baseModules);
5796 |
5797 | var patch$1 = createPatchFunction({ nodeOps: nodeOps, modules: modules });
5798 |
5799 | /**
5800 | * Not type checking this file because flow doesn't like attaching
5801 | * properties to Elements.
5802 | */
5803 |
5804 | var modelableTagRE = /^input|select|textarea|vue-component-[0-9]+(-[0-9a-zA-Z_-]*)?$/;
5805 |
5806 | /* istanbul ignore if */
5807 | if (isIE9) {
5808 | // http://www.matts411.com/post/internet-explorer-9-oninput/
5809 | document.addEventListener('selectionchange', function () {
5810 | var el = document.activeElement;
5811 | if (el && el.vmodel) {
5812 | trigger(el, 'input');
5813 | }
5814 | });
5815 | }
5816 |
5817 | var model = {
5818 | inserted: function inserted (el, binding, vnode) {
5819 | if (false) {
5820 | if (!modelableTagRE.test(vnode.tag)) {
5821 | warn(
5822 | "v-model is not supported on element type: <" + (vnode.tag) + ">. " +
5823 | 'If you are working with contenteditable, it\'s recommended to ' +
5824 | 'wrap a library dedicated for that purpose inside a custom component.',
5825 | vnode.context
5826 | );
5827 | }
5828 | }
5829 | if (vnode.tag === 'select') {
5830 | var cb = function () {
5831 | setSelected(el, binding, vnode.context);
5832 | };
5833 | cb();
5834 | /* istanbul ignore if */
5835 | if (isIE || isEdge) {
5836 | setTimeout(cb, 0);
5837 | }
5838 | } else if (vnode.tag === 'textarea' || el.type === 'text') {
5839 | el._vModifiers = binding.modifiers;
5840 | if (!binding.modifiers.lazy) {
5841 | if (!isAndroid) {
5842 | el.addEventListener('compositionstart', onCompositionStart);
5843 | el.addEventListener('compositionend', onCompositionEnd);
5844 | }
5845 | /* istanbul ignore if */
5846 | if (isIE9) {
5847 | el.vmodel = true;
5848 | }
5849 | }
5850 | }
5851 | },
5852 | componentUpdated: function componentUpdated (el, binding, vnode) {
5853 | if (vnode.tag === 'select') {
5854 | setSelected(el, binding, vnode.context);
5855 | // in case the options rendered by v-for have changed,
5856 | // it's possible that the value is out-of-sync with the rendered options.
5857 | // detect such cases and filter out values that no longer has a matching
5858 | // option in the DOM.
5859 | var needReset = el.multiple
5860 | ? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); })
5861 | : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options);
5862 | if (needReset) {
5863 | trigger(el, 'change');
5864 | }
5865 | }
5866 | }
5867 | };
5868 |
5869 | function setSelected (el, binding, vm) {
5870 | var value = binding.value;
5871 | var isMultiple = el.multiple;
5872 | if (isMultiple && !Array.isArray(value)) {
5873 | ("production") !== 'production' && warn(
5874 | "