3 * (c) 2014-2018 Evan You
4 * Released under the MIT License.
6 (function (global
, factory
) {
7 typeof exports
=== 'object' && typeof module
!== 'undefined' ? module
.exports
= factory() :
8 typeof define
=== 'function' && define
.amd
? define(factory
) :
9 (global
.Vue
= factory());
10 }(this, (function () { 'use strict';
14 var emptyObject
= Object
.freeze({});
16 // these helpers produces better vm code in JS engines due to their
17 // explicitness and function inlining
18 function isUndef (v
) {
19 return v
=== undefined || v
=== null
23 return v
!== undefined && v
!== null
30 function isFalse (v
) {
35 * Check if value is primitive
37 function isPrimitive (value
) {
39 typeof value
=== 'string' ||
40 typeof value
=== 'number' ||
42 typeof value
=== 'symbol' ||
43 typeof value
=== 'boolean'
48 * Quick object check - this is primarily used to tell
49 * Objects from primitive values when we know the value
50 * is a JSON-compliant type.
52 function isObject (obj
) {
53 return obj
!== null && typeof obj
=== 'object'
57 * Get the raw type string of a value e.g. [object Object]
59 var _toString
= Object
.prototype.toString
;
61 function toRawType (value
) {
62 return _toString
.call(value
).slice(8, -1)
66 * Strict object type check. Only returns true
67 * for plain JavaScript objects.
69 function isPlainObject (obj
) {
70 return _toString
.call(obj
) === '[object Object]'
73 function isRegExp (v
) {
74 return _toString
.call(v
) === '[object RegExp]'
78 * Check if val is a valid array index.
80 function isValidArrayIndex (val
) {
81 var n
= parseFloat(String(val
));
82 return n
>= 0 && Math
.floor(n
) === n
&& isFinite(val
)
86 * Convert a value to a string that is actually rendered.
88 function toString (val
) {
91 : typeof val
=== 'object'
92 ? JSON
.stringify(val
, null, 2)
97 * Convert a input value to a number for persistence.
98 * If the conversion fails, return original string.
100 function toNumber (val
) {
101 var n
= parseFloat(val
);
102 return isNaN(n
) ? val : n
106 * Make a map and return a function for checking if a key
113 var map
= Object
.create(null);
114 var list
= str
.split(',');
115 for (var i
= 0; i
< list
.length
; i
++) {
118 return expectsLowerCase
119 ? function (val
) { return map
[val
.toLowerCase()]; }
120 : function (val
) { return map
[val
]; }
124 * Check if a tag is a built-in tag.
126 var isBuiltInTag
= makeMap('slot,component', true);
129 * Check if a attribute is a reserved attribute.
131 var isReservedAttribute
= makeMap('key,ref,slot,slot-scope,is');
134 * Remove an item from an array
136 function remove (arr
, item
) {
138 var index
= arr
.indexOf(item
);
140 return arr
.splice(index
, 1)
146 * Check whether the object has the property.
148 var hasOwnProperty
= Object
.prototype.hasOwnProperty
;
149 function hasOwn (obj
, key
) {
150 return hasOwnProperty
.call(obj
, key
)
154 * Create a cached version of a pure function.
156 function cached (fn
) {
157 var cache
= Object
.create(null);
158 return (function cachedFn (str
) {
159 var hit
= cache
[str
];
160 return hit
|| (cache
[str
] = fn(str
))
165 * Camelize a hyphen-delimited string.
167 var camelizeRE
= /-(\w)/g;
168 var camelize
= cached(function (str
) {
169 return str
.replace(camelizeRE
, function (_
, c
) { return c
? c
.toUpperCase() : ''; })
173 * Capitalize a string.
175 var capitalize
= cached(function (str
) {
176 return str
.charAt(0).toUpperCase() + str
.slice(1)
180 * Hyphenate a camelCase string.
182 var hyphenateRE
= /\B([A-Z])/g;
183 var hyphenate
= cached(function (str
) {
184 return str
.replace(hyphenateRE
, '-$1').toLowerCase()
188 * Simple bind polyfill for environments that do not support it... e.g.
189 * PhantomJS 1.x. Technically we don't need this anymore since native bind is
190 * now more performant in most browsers, but removing it would be breaking for
191 * code that was able to run in PhantomJS 1.x, so this must be kept for
192 * backwards compatibility.
195 /* istanbul ignore next */
196 function polyfillBind (fn
, ctx
) {
197 function boundFn (a
) {
198 var l
= arguments
.length
;
201 ? fn
.apply(ctx
, arguments
)
206 boundFn
._length
= fn
.length
;
210 function nativeBind (fn
, ctx
) {
214 var bind
= Function
.prototype.bind
219 * Convert an Array-like object to a real Array.
221 function toArray (list
, start
) {
223 var i
= list
.length
- start
;
224 var ret
= new Array(i
);
226 ret
[i
] = list
[i
+ start
];
232 * Mix properties into target object.
234 function extend (to
, _from
) {
235 for (var key
in _from
) {
236 to
[key
] = _from
[key
];
242 * Merge an Array of Objects into a single Object.
244 function toObject (arr
) {
246 for (var i
= 0; i
< arr
.length
; i
++) {
255 * Perform no operation.
256 * Stubbing args to make Flow happy without leaving useless transpiled code
257 * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
259 function noop (a
, b
, c
) {}
262 * Always return false.
264 var no = function (a
, b
, c
) { return false; };
269 var identity = function (_
) { return _
; };
272 * Generate a static keys string from compiler modules.
274 function genStaticKeys (modules
) {
275 return modules
.reduce(function (keys
, m
) {
276 return keys
.concat(m
.staticKeys
|| [])
281 * Check if two values are loosely equal - that is,
282 * if they are plain objects, do they have the same shape?
284 function looseEqual (a
, b
) {
285 if (a
=== b
) { return true }
286 var isObjectA
= isObject(a
);
287 var isObjectB
= isObject(b
);
288 if (isObjectA
&& isObjectB
) {
290 var isArrayA
= Array
.isArray(a
);
291 var isArrayB
= Array
.isArray(b
);
292 if (isArrayA
&& isArrayB
) {
293 return a
.length
=== b
.length
&& a
.every(function (e
, i
) {
294 return looseEqual(e
, b
[i
])
296 } else if (!isArrayA
&& !isArrayB
) {
297 var keysA
= Object
.keys(a
);
298 var keysB
= Object
.keys(b
);
299 return keysA
.length
=== keysB
.length
&& keysA
.every(function (key
) {
300 return looseEqual(a
[key
], b
[key
])
303 /* istanbul ignore next */
307 /* istanbul ignore next */
310 } else if (!isObjectA
&& !isObjectB
) {
311 return String(a
) === String(b
)
317 function looseIndexOf (arr
, val
) {
318 for (var i
= 0; i
< arr
.length
; i
++) {
319 if (looseEqual(arr
[i
], val
)) { return i
}
325 * Ensure a function is called only once.
332 fn
.apply(this, arguments
);
337 var SSR_ATTR
= 'data-server-rendered';
345 var LIFECYCLE_HOOKS
= [
363 * Option merge strategies (used in core/util/options)
365 // $flow-disable-line
366 optionMergeStrategies: Object
.create(null),
369 * Whether to suppress warnings.
374 * Show production mode tip message on boot?
376 productionTip: "development" !== 'production',
379 * Whether to enable devtools
381 devtools: "development" !== 'production',
384 * Whether to record perf
389 * Error handler for watcher errors
394 * Warn handler for watcher warns
399 * Ignore certain custom elements
404 * Custom user key aliases for v-on
406 // $flow-disable-line
407 keyCodes: Object
.create(null),
410 * Check if a tag is reserved so that it cannot be registered as a
411 * component. This is platform-dependent and may be overwritten.
416 * Check if an attribute is reserved so that it cannot be used as a component
417 * prop. This is platform-dependent and may be overwritten.
422 * Check if a tag is an unknown element.
423 * Platform-dependent.
425 isUnknownElement: no
,
428 * Get the namespace of an element
430 getTagNamespace: noop
,
433 * Parse the real tag name for the specific platform.
435 parsePlatformTagName: identity
,
438 * Check if an attribute must be bound using property, e.g. value
439 * Platform-dependent.
444 * Exposed for legacy reasons
446 _lifecycleHooks: LIFECYCLE_HOOKS
452 * Check if a string starts with $ or _
454 function isReserved (str
) {
455 var c
= (str
+ '').charCodeAt(0);
456 return c
=== 0x24 || c
=== 0x5F
462 function def (obj
, key
, val
, enumerable
) {
463 Object
.defineProperty(obj
, key
, {
465 enumerable: !!enumerable
,
474 var bailRE
= /[^\w.$]/;
475 function parsePath (path
) {
476 if (bailRE
.test(path
)) {
479 var segments
= path
.split('.');
480 return function (obj
) {
481 for (var i
= 0; i
< segments
.length
; i
++) {
483 obj
= obj
[segments
[i
]];
491 // can we use __proto__?
492 var hasProto
= '__proto__' in {};
494 // Browser environment sniffing
495 var inBrowser
= typeof window
!== 'undefined';
496 var inWeex
= typeof WXEnvironment
!== 'undefined' && !!WXEnvironment
.platform
;
497 var weexPlatform
= inWeex
&& WXEnvironment
.platform
.toLowerCase();
498 var UA
= inBrowser
&& window
.navigator
.userAgent
.toLowerCase();
499 var isIE
= UA
&& /msie|trident/.test(UA
);
500 var isIE9
= UA
&& UA
.indexOf('msie 9.0') > 0;
501 var isEdge
= UA
&& UA
.indexOf('edge/') > 0;
502 var isAndroid
= (UA
&& UA
.indexOf('android') > 0) || (weexPlatform
=== 'android');
503 var isIOS
= (UA
&& /iphone|ipad|ipod|ios/.test(UA
)) || (weexPlatform
=== 'ios');
504 var isChrome
= UA
&& /chrome\/\d+/.test(UA
) && !isEdge
;
506 // Firefox has a "watch" function on Object.prototype...
507 var nativeWatch
= ({}).watch
;
509 var supportsPassive
= false;
513 Object
.defineProperty(opts
, 'passive', ({
514 get: function get () {
515 /* istanbul ignore next */
516 supportsPassive
= true;
518 })); // https://github.com/facebook/flow/issues/285
519 window
.addEventListener('test-passive', null, opts
);
523 // this needs to be lazy-evaled because vue may be required before
524 // vue-server-renderer can set VUE_ENV
526 var isServerRendering = function () {
527 if (_isServer
=== undefined) {
528 /* istanbul ignore if */
529 if (!inBrowser
&& !inWeex
&& typeof global
!== 'undefined') {
530 // detect presence of vue-server-renderer and avoid
531 // Webpack shimming the process
532 _isServer
= global
['process'].env
.VUE_ENV
=== 'server';
541 var devtools
= inBrowser
&& window
.__VUE_DEVTOOLS_GLOBAL_HOOK__
;
543 /* istanbul ignore next */
544 function isNative (Ctor
) {
545 return typeof Ctor
=== 'function' && /native code
/.test(Ctor
.toString())
549 typeof Symbol
!== 'undefined' && isNative(Symbol
) &&
550 typeof Reflect
!== 'undefined' && isNative(Reflect
.ownKeys
);
553 /* istanbul ignore if */ // $flow-disable-line
554 if (typeof Set
!== 'undefined' && isNative(Set
)) {
555 // use native Set when available.
558 // a non-standard Set polyfill that only works with primitive keys.
559 _Set
= (function () {
561 this.set = Object
.create(null);
563 Set
.prototype.has
= function has (key
) {
564 return this.set[key
] === true
566 Set
.prototype.add
= function add (key
) {
567 this.set[key
] = true;
569 Set
.prototype.clear
= function clear () {
570 this.set = Object
.create(null);
581 var generateComponentTrace
= (noop
); // work around flow check
582 var formatComponentName
= (noop
);
585 var hasConsole
= typeof console
!== 'undefined';
586 var classifyRE
= /(?:^|[-_])(\w)/g;
587 var classify = function (str
) { return str
588 .replace(classifyRE
, function (c
) { return c
.toUpperCase(); })
589 .replace(/[-_]/g, ''); };
591 warn = function (msg
, vm
) {
592 var trace
= vm
? generateComponentTrace(vm
) : '';
594 if (config
.warnHandler
) {
595 config
.warnHandler
.call(null, msg
, vm
, trace
);
596 } else if (hasConsole
&& (!config
.silent
)) {
597 console
.error(("[Vue warn]: " + msg
+ trace
));
601 tip = function (msg
, vm
) {
602 if (hasConsole
&& (!config
.silent
)) {
603 console
.warn("[Vue tip]: " + msg
+ (
604 vm
? generateComponentTrace(vm
) : ''
609 formatComponentName = function (vm
, includeFile
) {
610 if (vm
.$root
=== vm
) {
613 var options
= typeof vm
=== 'function' && vm
.cid
!= null
616 ? vm
.$options
|| vm
.constructor.options
618 var name
= options
.name
|| options
._componentTag
;
619 var file
= options
.__file
;
621 var match
= file
.match(/([^/\\]+)\.vue
$/);
622 name
= match
&& match
[1];
626 (name
? ("<" + (classify(name
)) + ">") : "<Anonymous>") +
627 (file
&& includeFile
!== false ? (" at " + file
) : '')
631 var repeat = function (str
, n
) {
634 if (n
% 2 === 1) { res
+= str
; }
635 if (n
> 1) { str
+= str
; }
641 generateComponentTrace = function (vm
) {
642 if (vm
._isVue
&& vm
.$parent
) {
644 var currentRecursiveSequence
= 0;
646 if (tree
.length
> 0) {
647 var last
= tree
[tree
.length
- 1];
648 if (last
.constructor === vm
.constructor) {
649 currentRecursiveSequence
++;
652 } else if (currentRecursiveSequence
> 0) {
653 tree
[tree
.length
- 1] = [last
, currentRecursiveSequence
];
654 currentRecursiveSequence
= 0;
660 return '\n\nfound in\n\n' + tree
661 .map(function (vm
, i
) { return ("" + (i
=== 0 ? '---> ' : repeat(' ', 5 + i
* 2)) + (Array
.isArray(vm
)
662 ? ((formatComponentName(vm
[0])) + "... (" + (vm
[1]) + " recursive calls)")
663 : formatComponentName(vm
))); })
666 return ("\n\n(found in " + (formatComponentName(vm
)) + ")")
677 * A dep is an observable that can have multiple
678 * directives subscribing to it.
680 var Dep
= function Dep () {
685 Dep
.prototype.addSub
= function addSub (sub
) {
689 Dep
.prototype.removeSub
= function removeSub (sub
) {
690 remove(this.subs
, sub
);
693 Dep
.prototype.depend
= function depend () {
695 Dep
.target
.addDep(this);
699 Dep
.prototype.notify
= function notify () {
700 // stabilize the subscriber list first
701 var subs
= this.subs
.slice();
702 for (var i
= 0, l
= subs
.length
; i
< l
; i
++) {
707 // the current target watcher being evaluated.
708 // this is globally unique because there could be only one
709 // watcher being evaluated at any time.
711 var targetStack
= [];
713 function pushTarget (_target
) {
714 if (Dep
.target
) { targetStack
.push(Dep
.target
); }
715 Dep
.target
= _target
;
718 function popTarget () {
719 Dep
.target
= targetStack
.pop();
724 var VNode
= function VNode (
736 this.children
= children
;
740 this.context
= context
;
741 this.fnContext
= undefined;
742 this.fnOptions
= undefined;
743 this.fnScopeId
= undefined;
744 this.key
= data
&& data
.key
;
745 this.componentOptions
= componentOptions
;
746 this.componentInstance
= undefined;
747 this.parent
= undefined;
749 this.isStatic
= false;
750 this.isRootInsert
= true;
751 this.isComment
= false;
752 this.isCloned
= false;
754 this.asyncFactory
= asyncFactory
;
755 this.asyncMeta
= undefined;
756 this.isAsyncPlaceholder
= false;
759 var prototypeAccessors
= { child: { configurable: true } };
761 // DEPRECATED: alias for componentInstance for backwards compat.
762 /* istanbul ignore next */
763 prototypeAccessors
.child
.get = function () {
764 return this.componentInstance
767 Object
.defineProperties( VNode
.prototype, prototypeAccessors
);
769 var createEmptyVNode = function (text
) {
770 if ( text
=== void 0 ) text
= '';
772 var node
= new VNode();
774 node
.isComment
= true;
778 function createTextVNode (val
) {
779 return new VNode(undefined, undefined, undefined, String(val
))
782 // optimized shallow clone
783 // used for static nodes and slot nodes because they may be reused across
784 // multiple renders, cloning them avoids errors when DOM manipulations rely
785 // on their elm reference.
786 function cloneVNode (vnode
) {
787 var cloned
= new VNode(
794 vnode
.componentOptions
,
797 cloned
.ns
= vnode
.ns
;
798 cloned
.isStatic
= vnode
.isStatic
;
799 cloned
.key
= vnode
.key
;
800 cloned
.isComment
= vnode
.isComment
;
801 cloned
.fnContext
= vnode
.fnContext
;
802 cloned
.fnOptions
= vnode
.fnOptions
;
803 cloned
.fnScopeId
= vnode
.fnScopeId
;
804 cloned
.isCloned
= true;
809 * not type checking this file because flow doesn't play well with
810 * dynamically accessing methods on Array prototype
813 var arrayProto
= Array
.prototype;
814 var arrayMethods
= Object
.create(arrayProto
);
816 var methodsToPatch
= [
827 * Intercept mutating methods and emit events
829 methodsToPatch
.forEach(function (method
) {
830 // cache original method
831 var original
= arrayProto
[method
];
832 def(arrayMethods
, method
, function mutator () {
833 var args
= [], len
= arguments
.length
;
834 while ( len
-- ) args
[ len
] = arguments
[ len
];
836 var result
= original
.apply(this, args
);
837 var ob
= this.__ob__
;
845 inserted
= args
.slice(2);
848 if (inserted
) { ob
.observeArray(inserted
); }
857 var arrayKeys
= Object
.getOwnPropertyNames(arrayMethods
);
860 * In some cases we may want to disable observation inside a component's
861 * update computation.
863 var shouldObserve
= true;
865 function toggleObserving (value
) {
866 shouldObserve
= value
;
870 * Observer class that is attached to each observed
871 * object. Once attached, the observer converts the target
872 * object's property keys into getter/setters that
873 * collect dependencies and dispatch updates.
875 var Observer
= function Observer (value
) {
877 this.dep
= new Dep();
879 def(value
, '__ob__', this);
880 if (Array
.isArray(value
)) {
881 var augment
= hasProto
884 augment(value
, arrayMethods
, arrayKeys
);
885 this.observeArray(value
);
892 * Walk through each property and convert them into
893 * getter/setters. This method should only be called when
894 * value type is Object.
896 Observer
.prototype.walk
= function walk (obj
) {
897 var keys
= Object
.keys(obj
);
898 for (var i
= 0; i
< keys
.length
; i
++) {
899 defineReactive(obj
, keys
[i
]);
904 * Observe a list of Array items.
906 Observer
.prototype.observeArray
= function observeArray (items
) {
907 for (var i
= 0, l
= items
.length
; i
< l
; i
++) {
915 * Augment an target Object or Array by intercepting
916 * the prototype chain using __proto__
918 function protoAugment (target
, src
, keys
) {
919 /* eslint-disable no-proto */
920 target
.__proto__
= src
;
921 /* eslint-enable no-proto */
925 * Augment an target Object or Array by defining
928 /* istanbul ignore next */
929 function copyAugment (target
, src
, keys
) {
930 for (var i
= 0, l
= keys
.length
; i
< l
; i
++) {
932 def(target
, key
, src
[key
]);
937 * Attempt to create an observer instance for a value,
938 * returns the new observer if successfully observed,
939 * or the existing observer if the value already has one.
941 function observe (value
, asRootData
) {
942 if (!isObject(value
) || value
instanceof VNode
) {
946 if (hasOwn(value
, '__ob__') && value
.__ob__
instanceof Observer
) {
950 !isServerRendering() &&
951 (Array
.isArray(value
) || isPlainObject(value
)) &&
952 Object
.isExtensible(value
) &&
955 ob
= new Observer(value
);
957 if (asRootData
&& ob
) {
964 * Define a reactive property on an Object.
966 function defineReactive (
975 var property
= Object
.getOwnPropertyDescriptor(obj
, key
);
976 if (property
&& property
.configurable
=== false) {
980 // cater for pre-defined getter/setters
981 var getter
= property
&& property
.get;
982 if (!getter
&& arguments
.length
=== 2) {
985 var setter
= property
&& property
.set;
987 var childOb
= !shallow
&& observe(val
);
988 Object
.defineProperty(obj
, key
, {
991 get: function reactiveGetter () {
992 var value
= getter
? getter
.call(obj
) : val
;
996 childOb
.dep
.depend();
997 if (Array
.isArray(value
)) {
1004 set: function reactiveSetter (newVal
) {
1005 var value
= getter
? getter
.call(obj
) : val
;
1006 /* eslint-disable no-self-compare */
1007 if (newVal
=== value
|| (newVal
!== newVal
&& value
!== value
)) {
1010 /* eslint-enable no-self-compare */
1011 if ("development" !== 'production' && customSetter
) {
1015 setter
.call(obj
, newVal
);
1019 childOb
= !shallow
&& observe(newVal
);
1026 * Set a property on an object. Adds the new property and
1027 * triggers change notification if the property doesn't
1030 function set (target
, key
, val
) {
1031 if ("development" !== 'production' &&
1032 (isUndef(target
) || isPrimitive(target
))
1034 warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target
))));
1036 if (Array
.isArray(target
) && isValidArrayIndex(key
)) {
1037 target
.length
= Math
.max(target
.length
, key
);
1038 target
.splice(key
, 1, val
);
1041 if (key
in target
&& !(key
in Object
.prototype)) {
1045 var ob
= (target
).__ob__
;
1046 if (target
._isVue
|| (ob
&& ob
.vmCount
)) {
1047 "development" !== 'production' && warn(
1048 'Avoid adding reactive properties to a Vue instance or its root $data ' +
1049 'at runtime - declare it upfront in the data option.'
1057 defineReactive(ob
.value
, key
, val
);
1063 * Delete a property and trigger change if necessary.
1065 function del (target
, key
) {
1066 if ("development" !== 'production' &&
1067 (isUndef(target
) || isPrimitive(target
))
1069 warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target
))));
1071 if (Array
.isArray(target
) && isValidArrayIndex(key
)) {
1072 target
.splice(key
, 1);
1075 var ob
= (target
).__ob__
;
1076 if (target
._isVue
|| (ob
&& ob
.vmCount
)) {
1077 "development" !== 'production' && warn(
1078 'Avoid deleting properties on a Vue instance or its root $data ' +
1079 '- just set it to null.'
1083 if (!hasOwn(target
, key
)) {
1094 * Collect dependencies on array elements when the array is touched, since
1095 * we cannot intercept array element access like property getters.
1097 function dependArray (value
) {
1098 for (var e
= (void 0), i
= 0, l
= value
.length
; i
< l
; i
++) {
1100 e
&& e
.__ob__
&& e
.__ob__
.dep
.depend();
1101 if (Array
.isArray(e
)) {
1110 * Option overwriting strategies are functions that handle
1111 * how to merge a parent option value and a child option
1112 * value into the final value.
1114 var strats
= config
.optionMergeStrategies
;
1117 * Options with restrictions
1120 strats
.el
= strats
.propsData = function (parent
, child
, vm
, key
) {
1123 "option \"" + key
+ "\" can only be used during instance " +
1124 'creation with the `new` keyword.'
1127 return defaultStrat(parent
, child
)
1132 * Helper that recursively merges two data objects together.
1134 function mergeData (to
, from) {
1135 if (!from) { return to
}
1136 var key
, toVal
, fromVal
;
1137 var keys
= Object
.keys(from);
1138 for (var i
= 0; i
< keys
.length
; i
++) {
1141 fromVal
= from[key
];
1142 if (!hasOwn(to
, key
)) {
1143 set(to
, key
, fromVal
);
1144 } else if (isPlainObject(toVal
) && isPlainObject(fromVal
)) {
1145 mergeData(toVal
, fromVal
);
1154 function mergeDataOrFn (
1160 // in a Vue.extend merge, both should be functions
1167 // when parentVal & childVal are both present,
1168 // we need to return a function that returns the
1169 // merged result of both functions... no need to
1170 // check if parentVal is a function here because
1171 // it has to be a function to pass previous merges.
1172 return function mergedDataFn () {
1174 typeof childVal
=== 'function' ? childVal
.call(this, this) : childVal
,
1175 typeof parentVal
=== 'function' ? parentVal
.call(this, this) : parentVal
1179 return function mergedInstanceDataFn () {
1181 var instanceData
= typeof childVal
=== 'function'
1182 ? childVal
.call(vm
, vm
)
1184 var defaultData
= typeof parentVal
=== 'function'
1185 ? parentVal
.call(vm
, vm
)
1188 return mergeData(instanceData
, defaultData
)
1196 strats
.data = function (
1202 if (childVal
&& typeof childVal
!== 'function') {
1203 "development" !== 'production' && warn(
1204 'The "data" option should be a function ' +
1205 'that returns a per-instance value in component ' +
1212 return mergeDataOrFn(parentVal
, childVal
)
1215 return mergeDataOrFn(parentVal
, childVal
, vm
)
1219 * Hooks and props are merged as arrays.
1221 function mergeHook (
1227 ? parentVal
.concat(childVal
)
1228 : Array
.isArray(childVal
)
1234 LIFECYCLE_HOOKS
.forEach(function (hook
) {
1235 strats
[hook
] = mergeHook
;
1241 * When a vm is present (instance creation), we need to do
1242 * a three-way merge between constructor options, instance
1243 * options and parent options.
1245 function mergeAssets (
1251 var res
= Object
.create(parentVal
|| null);
1253 "development" !== 'production' && assertObjectType(key
, childVal
, vm
);
1254 return extend(res
, childVal
)
1260 ASSET_TYPES
.forEach(function (type
) {
1261 strats
[type
+ 's'] = mergeAssets
;
1267 * Watchers hashes should not overwrite one
1268 * another, so we merge them as arrays.
1270 strats
.watch = function (
1276 // work around Firefox's Object.prototype.watch...
1277 if (parentVal
=== nativeWatch
) { parentVal
= undefined; }
1278 if (childVal
=== nativeWatch
) { childVal
= undefined; }
1279 /* istanbul ignore if */
1280 if (!childVal
) { return Object
.create(parentVal
|| null) }
1282 assertObjectType(key
, childVal
, vm
);
1284 if (!parentVal
) { return childVal
}
1286 extend(ret
, parentVal
);
1287 for (var key
$1 in childVal
) {
1288 var parent
= ret
[key
$1];
1289 var child
= childVal
[key
$1];
1290 if (parent
&& !Array
.isArray(parent
)) {
1294 ? parent
.concat(child
)
1295 : Array
.isArray(child
) ? child : [child
];
1301 * Other object hashes.
1306 strats
.computed = function (
1312 if (childVal
&& "development" !== 'production') {
1313 assertObjectType(key
, childVal
, vm
);
1315 if (!parentVal
) { return childVal
}
1316 var ret
= Object
.create(null);
1317 extend(ret
, parentVal
);
1318 if (childVal
) { extend(ret
, childVal
); }
1321 strats
.provide
= mergeDataOrFn
;
1326 var defaultStrat = function (parentVal
, childVal
) {
1327 return childVal
=== undefined
1333 * Validate component names
1335 function checkComponents (options
) {
1336 for (var key
in options
.components
) {
1337 validateComponentName(key
);
1341 function validateComponentName (name
) {
1342 if (!/^[a-zA-Z][\w-]*$/.test(name
)) {
1344 'Invalid component name: "' + name
+ '". Component names ' +
1345 'can only contain alphanumeric characters and the hyphen, ' +
1346 'and must start with a letter.'
1349 if (isBuiltInTag(name
) || config
.isReservedTag(name
)) {
1351 'Do not use built-in or reserved HTML elements as component ' +
1358 * Ensure all props option syntax are normalized into the
1359 * Object-based format.
1361 function normalizeProps (options
, vm
) {
1362 var props
= options
.props
;
1363 if (!props
) { return }
1366 if (Array
.isArray(props
)) {
1370 if (typeof val
=== 'string') {
1371 name
= camelize(val
);
1372 res
[name
] = { type: null };
1374 warn('props must be strings when using array syntax.');
1377 } else if (isPlainObject(props
)) {
1378 for (var key
in props
) {
1380 name
= camelize(key
);
1381 res
[name
] = isPlainObject(val
)
1387 "Invalid value for option \"props\": expected an Array or an Object, " +
1388 "but got " + (toRawType(props
)) + ".",
1392 options
.props
= res
;
1396 * Normalize all injections into Object-based format
1398 function normalizeInject (options
, vm
) {
1399 var inject
= options
.inject
;
1400 if (!inject
) { return }
1401 var normalized
= options
.inject
= {};
1402 if (Array
.isArray(inject
)) {
1403 for (var i
= 0; i
< inject
.length
; i
++) {
1404 normalized
[inject
[i
]] = { from: inject
[i
] };
1406 } else if (isPlainObject(inject
)) {
1407 for (var key
in inject
) {
1408 var val
= inject
[key
];
1409 normalized
[key
] = isPlainObject(val
)
1410 ? extend({ from: key
}, val
)
1415 "Invalid value for option \"inject\": expected an Array or an Object, " +
1416 "but got " + (toRawType(inject
)) + ".",
1423 * Normalize raw function directives into object format.
1425 function normalizeDirectives (options
) {
1426 var dirs
= options
.directives
;
1428 for (var key
in dirs
) {
1429 var def
= dirs
[key
];
1430 if (typeof def
=== 'function') {
1431 dirs
[key
] = { bind: def
, update: def
};
1437 function assertObjectType (name
, value
, vm
) {
1438 if (!isPlainObject(value
)) {
1440 "Invalid value for option \"" + name
+ "\": expected an Object, " +
1441 "but got " + (toRawType(value
)) + ".",
1448 * Merge two option objects into a new one.
1449 * Core utility used in both instantiation and inheritance.
1451 function mergeOptions (
1457 checkComponents(child
);
1460 if (typeof child
=== 'function') {
1461 child
= child
.options
;
1464 normalizeProps(child
, vm
);
1465 normalizeInject(child
, vm
);
1466 normalizeDirectives(child
);
1467 var extendsFrom
= child
.extends;
1469 parent
= mergeOptions(parent
, extendsFrom
, vm
);
1472 for (var i
= 0, l
= child
.mixins
.length
; i
< l
; i
++) {
1473 parent
= mergeOptions(parent
, child
.mixins
[i
], vm
);
1478 for (key
in parent
) {
1481 for (key
in child
) {
1482 if (!hasOwn(parent
, key
)) {
1486 function mergeField (key
) {
1487 var strat
= strats
[key
] || defaultStrat
;
1488 options
[key
] = strat(parent
[key
], child
[key
], vm
, key
);
1495 * This function is used because child instances need access
1496 * to assets defined in its ancestor chain.
1498 function resolveAsset (
1504 /* istanbul ignore if */
1505 if (typeof id
!== 'string') {
1508 var assets
= options
[type
];
1509 // check local registration variations first
1510 if (hasOwn(assets
, id
)) { return assets
[id
] }
1511 var camelizedId
= camelize(id
);
1512 if (hasOwn(assets
, camelizedId
)) { return assets
[camelizedId
] }
1513 var PascalCaseId
= capitalize(camelizedId
);
1514 if (hasOwn(assets
, PascalCaseId
)) { return assets
[PascalCaseId
] }
1515 // fallback to prototype chain
1516 var res
= assets
[id
] || assets
[camelizedId
] || assets
[PascalCaseId
];
1517 if ("development" !== 'production' && warnMissing
&& !res
) {
1519 'Failed to resolve ' + type
.slice(0, -1) + ': ' + id
,
1528 function validateProp (
1534 var prop
= propOptions
[key
];
1535 var absent
= !hasOwn(propsData
, key
);
1536 var value
= propsData
[key
];
1538 var booleanIndex
= getTypeIndex(Boolean
, prop
.type
);
1539 if (booleanIndex
> -1) {
1540 if (absent
&& !hasOwn(prop
, 'default')) {
1542 } else if (value
=== '' || value
=== hyphenate(key
)) {
1543 // only cast empty string / same name to boolean if
1544 // boolean has higher priority
1545 var stringIndex
= getTypeIndex(String
, prop
.type
);
1546 if (stringIndex
< 0 || booleanIndex
< stringIndex
) {
1551 // check default value
1552 if (value
=== undefined) {
1553 value
= getPropDefaultValue(vm
, prop
, key
);
1554 // since the default value is a fresh copy,
1555 // make sure to observe it.
1556 var prevShouldObserve
= shouldObserve
;
1557 toggleObserving(true);
1559 toggleObserving(prevShouldObserve
);
1562 assertProp(prop
, key
, value
, vm
, absent
);
1568 * Get the default value of a prop.
1570 function getPropDefaultValue (vm
, prop
, key
) {
1571 // no default, return undefined
1572 if (!hasOwn(prop
, 'default')) {
1575 var def
= prop
.default;
1576 // warn against non-factory defaults for Object & Array
1577 if ("development" !== 'production' && isObject(def
)) {
1579 'Invalid default value for prop "' + key
+ '": ' +
1580 'Props with type Object/Array must use a factory function ' +
1581 'to return the default value.',
1585 // the raw prop value was also undefined from previous render,
1586 // return previous default value to avoid unnecessary watcher trigger
1587 if (vm
&& vm
.$options
.propsData
&&
1588 vm
.$options
.propsData
[key
] === undefined &&
1589 vm
._props
[key
] !== undefined
1591 return vm
._props
[key
]
1593 // call factory function for non-Function types
1594 // a value is Function if its prototype is function even across different execution context
1595 return typeof def
=== 'function' && getType(prop
.type
) !== 'Function'
1601 * Assert whether a prop is valid.
1603 function assertProp (
1610 if (prop
.required
&& absent
) {
1612 'Missing required prop: "' + name
+ '"',
1617 if (value
== null && !prop
.required
) {
1620 var type
= prop
.type
;
1621 var valid
= !type
|| type
=== true;
1622 var expectedTypes
= [];
1624 if (!Array
.isArray(type
)) {
1627 for (var i
= 0; i
< type
.length
&& !valid
; i
++) {
1628 var assertedType
= assertType(value
, type
[i
]);
1629 expectedTypes
.push(assertedType
.expectedType
|| '');
1630 valid
= assertedType
.valid
;
1635 "Invalid prop: type check failed for prop \"" + name
+ "\"." +
1636 " Expected " + (expectedTypes
.map(capitalize
).join(', ')) +
1637 ", got " + (toRawType(value
)) + ".",
1642 var validator
= prop
.validator
;
1644 if (!validator(value
)) {
1646 'Invalid prop: custom validator check failed for prop "' + name
+ '".',
1653 var simpleCheckRE
= /^(String|Number|Boolean|Function|Symbol)$/;
1655 function assertType (value
, type
) {
1657 var expectedType
= getType(type
);
1658 if (simpleCheckRE
.test(expectedType
)) {
1659 var t
= typeof value
;
1660 valid
= t
=== expectedType
.toLowerCase();
1661 // for primitive wrapper objects
1662 if (!valid
&& t
=== 'object') {
1663 valid
= value
instanceof type
;
1665 } else if (expectedType
=== 'Object') {
1666 valid
= isPlainObject(value
);
1667 } else if (expectedType
=== 'Array') {
1668 valid
= Array
.isArray(value
);
1670 valid
= value
instanceof type
;
1674 expectedType: expectedType
1679 * Use function string name to check built-in types,
1680 * because a simple equality check will fail when running
1681 * across different vms / iframes.
1683 function getType (fn
) {
1684 var match
= fn
&& fn
.toString().match(/^\s
*function (\w
+)/);
1685 return match
? match
[1] : ''
1688 function isSameType (a
, b
) {
1689 return getType(a
) === getType(b
)
1692 function getTypeIndex (type
, expectedTypes
) {
1693 if (!Array
.isArray(expectedTypes
)) {
1694 return isSameType(expectedTypes
, type
) ? 0 : -1
1696 for (var i
= 0, len
= expectedTypes
.length
; i
< len
; i
++) {
1697 if (isSameType(expectedTypes
[i
], type
)) {
1706 function handleError (err
, vm
, info
) {
1709 while ((cur
= cur
.$parent
)) {
1710 var hooks
= cur
.$options
.errorCaptured
;
1712 for (var i
= 0; i
< hooks
.length
; i
++) {
1714 var capture
= hooks
[i
].call(cur
, err
, vm
, info
) === false;
1715 if (capture
) { return }
1717 globalHandleError(e
, cur
, 'errorCaptured hook');
1723 globalHandleError(err
, vm
, info
);
1726 function globalHandleError (err
, vm
, info
) {
1727 if (config
.errorHandler
) {
1729 return config
.errorHandler
.call(null, err
, vm
, info
)
1731 logError(e
, null, 'config.errorHandler');
1734 logError(err
, vm
, info
);
1737 function logError (err
, vm
, info
) {
1739 warn(("Error in " + info
+ ": \"" + (err
.toString()) + "\""), vm
);
1741 /* istanbul ignore else */
1742 if ((inBrowser
|| inWeex
) && typeof console
!== 'undefined') {
1750 /* globals MessageChannel */
1753 var pending
= false;
1755 function flushCallbacks () {
1757 var copies
= callbacks
.slice(0);
1758 callbacks
.length
= 0;
1759 for (var i
= 0; i
< copies
.length
; i
++) {
1764 // Here we have async deferring wrappers using both microtasks and (macro) tasks.
1765 // In < 2.4 we used microtasks everywhere, but there are some scenarios where
1766 // microtasks have too high a priority and fire in between supposedly
1767 // sequential events (e.g. #4521, #6690) or even between bubbling of the same
1768 // event (#6566). However, using (macro) tasks everywhere also has subtle problems
1769 // when state is changed right before repaint (e.g. #6813, out-in transitions).
1770 // Here we use microtask by default, but expose a way to force (macro) task when
1771 // needed (e.g. in event handlers attached by v-on).
1774 var useMacroTask
= false;
1776 // Determine (macro) task defer implementation.
1777 // Technically setImmediate should be the ideal choice, but it's only available
1778 // in IE. The only polyfill that consistently queues the callback after all DOM
1779 // events triggered in the same loop is by using MessageChannel.
1780 /* istanbul ignore if */
1781 if (typeof setImmediate
!== 'undefined' && isNative(setImmediate
)) {
1782 macroTimerFunc = function () {
1783 setImmediate(flushCallbacks
);
1785 } else if (typeof MessageChannel
!== 'undefined' && (
1786 isNative(MessageChannel
) ||
1788 MessageChannel
.toString() === '[object MessageChannelConstructor]'
1790 var channel
= new MessageChannel();
1791 var port
= channel
.port2
;
1792 channel
.port1
.onmessage
= flushCallbacks
;
1793 macroTimerFunc = function () {
1794 port
.postMessage(1);
1797 /* istanbul ignore next */
1798 macroTimerFunc = function () {
1799 setTimeout(flushCallbacks
, 0);
1803 // Determine microtask defer implementation.
1804 /* istanbul ignore next, $flow-disable-line */
1805 if (typeof Promise
!== 'undefined' && isNative(Promise
)) {
1806 var p
= Promise
.resolve();
1807 microTimerFunc = function () {
1808 p
.then(flushCallbacks
);
1809 // in problematic UIWebViews, Promise.then doesn't completely break, but
1810 // it can get stuck in a weird state where callbacks are pushed into the
1811 // microtask queue but the queue isn't being flushed, until the browser
1812 // needs to do some other work, e.g. handle a timer. Therefore we can
1813 // "force" the microtask queue to be flushed by adding an empty timer.
1814 if (isIOS
) { setTimeout(noop
); }
1817 // fallback to macro
1818 microTimerFunc
= macroTimerFunc
;
1822 * Wrap a function so that if any code inside triggers state change,
1823 * the changes are queued using a (macro) task instead of a microtask.
1825 function withMacroTask (fn
) {
1826 return fn
._withTask
|| (fn
._withTask = function () {
1827 useMacroTask
= true;
1828 var res
= fn
.apply(null, arguments
);
1829 useMacroTask
= false;
1834 function nextTick (cb
, ctx
) {
1836 callbacks
.push(function () {
1841 handleError(e
, ctx
, 'nextTick');
1843 } else if (_resolve
) {
1855 // $flow-disable-line
1856 if (!cb
&& typeof Promise
!== 'undefined') {
1857 return new Promise(function (resolve
) {
1869 var perf
= inBrowser
&& window
.performance
;
1870 /* istanbul ignore if */
1878 mark = function (tag
) { return perf
.mark(tag
); };
1879 measure = function (name
, startTag
, endTag
) {
1880 perf
.measure(name
, startTag
, endTag
);
1881 perf
.clearMarks(startTag
);
1882 perf
.clearMarks(endTag
);
1883 perf
.clearMeasures(name
);
1888 /* not type checking this file because flow doesn't play well with Proxy */
1893 var allowedGlobals
= makeMap(
1894 'Infinity,undefined,NaN,isFinite,isNaN,' +
1895 'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
1896 'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
1897 'require' // for Webpack/Browserify
1900 var warnNonPresent = function (target
, key
) {
1902 "Property or method \"" + key
+ "\" is not defined on the instance but " +
1903 'referenced during render. Make sure that this property is reactive, ' +
1904 'either in the data option, or for class-based components, by ' +
1905 'initializing the property. ' +
1906 'See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.',
1912 typeof Proxy
!== 'undefined' && isNative(Proxy
);
1915 var isBuiltInModifier
= makeMap('stop,prevent,self,ctrl,shift,alt,meta,exact');
1916 config
.keyCodes
= new Proxy(config
.keyCodes
, {
1917 set: function set (target
, key
, value
) {
1918 if (isBuiltInModifier(key
)) {
1919 warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key
));
1922 target
[key
] = value
;
1930 has: function has (target
, key
) {
1931 var has
= key
in target
;
1932 var isAllowed
= allowedGlobals(key
) || key
.charAt(0) === '_';
1933 if (!has
&& !isAllowed
) {
1934 warnNonPresent(target
, key
);
1936 return has
|| !isAllowed
1941 get: function get (target
, key
) {
1942 if (typeof key
=== 'string' && !(key
in target
)) {
1943 warnNonPresent(target
, key
);
1949 initProxy
= function initProxy (vm
) {
1951 // determine which proxy handler to use
1952 var options
= vm
.$options
;
1953 var handlers
= options
.render
&& options
.render
._withStripped
1956 vm
._renderProxy
= new Proxy(vm
, handlers
);
1958 vm
._renderProxy
= vm
;
1965 var seenObjects
= new _Set();
1968 * Recursively traverse an object to evoke all converted
1969 * getters, so that every nested property inside the object
1970 * is collected as a "deep" dependency.
1972 function traverse (val
) {
1973 _traverse(val
, seenObjects
);
1974 seenObjects
.clear();
1977 function _traverse (val
, seen
) {
1979 var isA
= Array
.isArray(val
);
1980 if ((!isA
&& !isObject(val
)) || Object
.isFrozen(val
) || val
instanceof VNode
) {
1984 var depId
= val
.__ob__
.dep
.id
;
1985 if (seen
.has(depId
)) {
1992 while (i
--) { _traverse(val
[i
], seen
); }
1994 keys
= Object
.keys(val
);
1996 while (i
--) { _traverse(val
[keys
[i
]], seen
); }
2002 var normalizeEvent
= cached(function (name
) {
2003 var passive
= name
.charAt(0) === '&';
2004 name
= passive
? name
.slice(1) : name
;
2005 var once
$$1 = name
.charAt(0) === '~'; // Prefixed last, checked first
2006 name
= once
$$1 ? name
.slice(1) : name
;
2007 var capture
= name
.charAt(0) === '!';
2008 name
= capture
? name
.slice(1) : name
;
2017 function createFnInvoker (fns
) {
2018 function invoker () {
2019 var arguments
$1 = arguments
;
2021 var fns
= invoker
.fns
;
2022 if (Array
.isArray(fns
)) {
2023 var cloned
= fns
.slice();
2024 for (var i
= 0; i
< cloned
.length
; i
++) {
2025 cloned
[i
].apply(null, arguments
$1);
2028 // return handler return value for single handlers
2029 return fns
.apply(null, arguments
)
2036 function updateListeners (
2043 var name
, def
, cur
, old
, event
;
2045 def
= cur
= on
[name
];
2047 event
= normalizeEvent(name
);
2048 /* istanbul ignore if */
2050 "development" !== 'production' && warn(
2051 "Invalid handler for event \"" + (event
.name
) + "\": got " + String(cur
),
2054 } else if (isUndef(old
)) {
2055 if (isUndef(cur
.fns
)) {
2056 cur
= on
[name
] = createFnInvoker(cur
);
2058 add(event
.name
, cur
, event
.once
, event
.capture
, event
.passive
, event
.params
);
2059 } else if (cur
!== old
) {
2064 for (name
in oldOn
) {
2065 if (isUndef(on
[name
])) {
2066 event
= normalizeEvent(name
);
2067 remove
$$1(event
.name
, oldOn
[name
], event
.capture
);
2074 function mergeVNodeHook (def
, hookKey
, hook
) {
2075 if (def
instanceof VNode
) {
2076 def
= def
.data
.hook
|| (def
.data
.hook
= {});
2079 var oldHook
= def
[hookKey
];
2081 function wrappedHook () {
2082 hook
.apply(this, arguments
);
2083 // important: remove merged hook to ensure it's called only once
2084 // and prevent memory leak
2085 remove(invoker
.fns
, wrappedHook
);
2088 if (isUndef(oldHook
)) {
2090 invoker
= createFnInvoker([wrappedHook
]);
2092 /* istanbul ignore if */
2093 if (isDef(oldHook
.fns
) && isTrue(oldHook
.merged
)) {
2094 // already a merged invoker
2096 invoker
.fns
.push(wrappedHook
);
2098 // existing plain hook
2099 invoker
= createFnInvoker([oldHook
, wrappedHook
]);
2103 invoker
.merged
= true;
2104 def
[hookKey
] = invoker
;
2109 function extractPropsFromVNodeData (
2114 // we are only extracting raw values here.
2115 // validation and default values are handled in the child
2116 // component itself.
2117 var propOptions
= Ctor
.options
.props
;
2118 if (isUndef(propOptions
)) {
2122 var attrs
= data
.attrs
;
2123 var props
= data
.props
;
2124 if (isDef(attrs
) || isDef(props
)) {
2125 for (var key
in propOptions
) {
2126 var altKey
= hyphenate(key
);
2128 var keyInLowerCase
= key
.toLowerCase();
2130 key
!== keyInLowerCase
&&
2131 attrs
&& hasOwn(attrs
, keyInLowerCase
)
2134 "Prop \"" + keyInLowerCase
+ "\" is passed to component " +
2135 (formatComponentName(tag
|| Ctor
)) + ", but the declared prop name is" +
2136 " \"" + key
+ "\". " +
2137 "Note that HTML attributes are case-insensitive and camelCased " +
2138 "props need to use their kebab-case equivalents when using in-DOM " +
2139 "templates. You should probably use \"" + altKey
+ "\" instead of \"" + key
+ "\"."
2143 checkProp(res
, props
, key
, altKey
, true) ||
2144 checkProp(res
, attrs
, key
, altKey
, false);
2150 function checkProp (
2158 if (hasOwn(hash
, key
)) {
2159 res
[key
] = hash
[key
];
2164 } else if (hasOwn(hash
, altKey
)) {
2165 res
[key
] = hash
[altKey
];
2167 delete hash
[altKey
];
2177 // The template compiler attempts to minimize the need for normalization by
2178 // statically analyzing the template at compile time.
2180 // For plain HTML markup, normalization can be completely skipped because the
2181 // generated render function is guaranteed to return Array<VNode>. There are
2182 // two cases where extra normalization is needed:
2184 // 1. When the children contains components - because a functional component
2185 // may return an Array instead of a single root. In this case, just a simple
2186 // normalization is needed - if any child is an Array, we flatten the whole
2187 // thing with Array.prototype.concat. It is guaranteed to be only 1-level deep
2188 // because functional components already normalize their own children.
2189 function simpleNormalizeChildren (children
) {
2190 for (var i
= 0; i
< children
.length
; i
++) {
2191 if (Array
.isArray(children
[i
])) {
2192 return Array
.prototype.concat
.apply([], children
)
2198 // 2. When the children contains constructs that always generated nested Arrays,
2199 // e.g. <template>, <slot>, v-for, or when the children is provided by user
2200 // with hand-written render functions / JSX. In such cases a full normalization
2201 // is needed to cater to all possible types of children values.
2202 function normalizeChildren (children
) {
2203 return isPrimitive(children
)
2204 ? [createTextVNode(children
)]
2205 : Array
.isArray(children
)
2206 ? normalizeArrayChildren(children
)
2210 function isTextNode (node
) {
2211 return isDef(node
) && isDef(node
.text
) && isFalse(node
.isComment
)
2214 function normalizeArrayChildren (children
, nestedIndex
) {
2216 var i
, c
, lastIndex
, last
;
2217 for (i
= 0; i
< children
.length
; i
++) {
2219 if (isUndef(c
) || typeof c
=== 'boolean') { continue }
2220 lastIndex
= res
.length
- 1;
2221 last
= res
[lastIndex
];
2223 if (Array
.isArray(c
)) {
2225 c
= normalizeArrayChildren(c
, ((nestedIndex
|| '') + "_" + i
));
2226 // merge adjacent text nodes
2227 if (isTextNode(c
[0]) && isTextNode(last
)) {
2228 res
[lastIndex
] = createTextVNode(last
.text
+ (c
[0]).text
);
2231 res
.push
.apply(res
, c
);
2233 } else if (isPrimitive(c
)) {
2234 if (isTextNode(last
)) {
2235 // merge adjacent text nodes
2236 // this is necessary for SSR hydration because text nodes are
2237 // essentially merged when rendered to HTML strings
2238 res
[lastIndex
] = createTextVNode(last
.text
+ c
);
2239 } else if (c
!== '') {
2240 // convert primitive to vnode
2241 res
.push(createTextVNode(c
));
2244 if (isTextNode(c
) && isTextNode(last
)) {
2245 // merge adjacent text nodes
2246 res
[lastIndex
] = createTextVNode(last
.text
+ c
.text
);
2248 // default key for nested array children (likely generated by v-for)
2249 if (isTrue(children
._isVList
) &&
2252 isDef(nestedIndex
)) {
2253 c
.key
= "__vlist" + nestedIndex
+ "_" + i
+ "__";
2264 function ensureCtor (comp
, base
) {
2267 (hasSymbol
&& comp
[Symbol
.toStringTag
] === 'Module')
2269 comp
= comp
.default;
2271 return isObject(comp
)
2276 function createAsyncPlaceholder (
2283 var node
= createEmptyVNode();
2284 node
.asyncFactory
= factory
;
2285 node
.asyncMeta
= { data: data
, context: context
, children: children
, tag: tag
};
2289 function resolveAsyncComponent (
2294 if (isTrue(factory
.error
) && isDef(factory
.errorComp
)) {
2295 return factory
.errorComp
2298 if (isDef(factory
.resolved
)) {
2299 return factory
.resolved
2302 if (isTrue(factory
.loading
) && isDef(factory
.loadingComp
)) {
2303 return factory
.loadingComp
2306 if (isDef(factory
.contexts
)) {
2308 factory
.contexts
.push(context
);
2310 var contexts
= factory
.contexts
= [context
];
2313 var forceRender = function () {
2314 for (var i
= 0, l
= contexts
.length
; i
< l
; i
++) {
2315 contexts
[i
].$forceUpdate();
2319 var resolve
= once(function (res
) {
2321 factory
.resolved
= ensureCtor(res
, baseCtor
);
2322 // invoke callbacks only if this is not a synchronous resolve
2323 // (async resolves are shimmed as synchronous during SSR)
2329 var reject
= once(function (reason
) {
2330 "development" !== 'production' && warn(
2331 "Failed to resolve async component: " + (String(factory
)) +
2332 (reason
? ("\nReason: " + reason
) : '')
2334 if (isDef(factory
.errorComp
)) {
2335 factory
.error
= true;
2340 var res
= factory(resolve
, reject
);
2342 if (isObject(res
)) {
2343 if (typeof res
.then
=== 'function') {
2345 if (isUndef(factory
.resolved
)) {
2346 res
.then(resolve
, reject
);
2348 } else if (isDef(res
.component
) && typeof res
.component
.then
=== 'function') {
2349 res
.component
.then(resolve
, reject
);
2351 if (isDef(res
.error
)) {
2352 factory
.errorComp
= ensureCtor(res
.error
, baseCtor
);
2355 if (isDef(res
.loading
)) {
2356 factory
.loadingComp
= ensureCtor(res
.loading
, baseCtor
);
2357 if (res
.delay
=== 0) {
2358 factory
.loading
= true;
2360 setTimeout(function () {
2361 if (isUndef(factory
.resolved
) && isUndef(factory
.error
)) {
2362 factory
.loading
= true;
2365 }, res
.delay
|| 200);
2369 if (isDef(res
.timeout
)) {
2370 setTimeout(function () {
2371 if (isUndef(factory
.resolved
)) {
2373 "timeout (" + (res
.timeout
) + "ms)"
2382 // return in case resolved synchronously
2383 return factory
.loading
2384 ? factory
.loadingComp
2391 function isAsyncPlaceholder (node
) {
2392 return node
.isComment
&& node
.asyncFactory
2397 function getFirstComponentChild (children
) {
2398 if (Array
.isArray(children
)) {
2399 for (var i
= 0; i
< children
.length
; i
++) {
2400 var c
= children
[i
];
2401 if (isDef(c
) && (isDef(c
.componentOptions
) || isAsyncPlaceholder(c
))) {
2412 function initEvents (vm
) {
2413 vm
._events
= Object
.create(null);
2414 vm
._hasHookEvent
= false;
2415 // init parent attached events
2416 var listeners
= vm
.$options
._parentListeners
;
2418 updateComponentListeners(vm
, listeners
);
2424 function add (event
, fn
, once
) {
2426 target
.$once(event
, fn
);
2428 target
.$on(event
, fn
);
2432 function remove
$1 (event
, fn
) {
2433 target
.$off(event
, fn
);
2436 function updateComponentListeners (
2442 updateListeners(listeners
, oldListeners
|| {}, add
, remove
$1, vm
);
2446 function eventsMixin (Vue
) {
2447 var hookRE
= /^hook:/;
2448 Vue
.prototype.$on = function (event
, fn
) {
2452 if (Array
.isArray(event
)) {
2453 for (var i
= 0, l
= event
.length
; i
< l
; i
++) {
2454 this$1.$on(event
[i
], fn
);
2457 (vm
._events
[event
] || (vm
._events
[event
] = [])).push(fn
);
2458 // optimize hook:event cost by using a boolean flag marked at registration
2459 // instead of a hash lookup
2460 if (hookRE
.test(event
)) {
2461 vm
._hasHookEvent
= true;
2467 Vue
.prototype.$once = function (event
, fn
) {
2471 fn
.apply(vm
, arguments
);
2478 Vue
.prototype.$off = function (event
, fn
) {
2483 if (!arguments
.length
) {
2484 vm
._events
= Object
.create(null);
2488 if (Array
.isArray(event
)) {
2489 for (var i
= 0, l
= event
.length
; i
< l
; i
++) {
2490 this$1.$off(event
[i
], fn
);
2495 var cbs
= vm
._events
[event
];
2500 vm
._events
[event
] = null;
2506 var i
$1 = cbs
.length
;
2509 if (cb
=== fn
|| cb
.fn
=== fn
) {
2518 Vue
.prototype.$emit = function (event
) {
2521 var lowerCaseEvent
= event
.toLowerCase();
2522 if (lowerCaseEvent
!== event
&& vm
._events
[lowerCaseEvent
]) {
2524 "Event \"" + lowerCaseEvent
+ "\" is emitted in component " +
2525 (formatComponentName(vm
)) + " but the handler is registered for \"" + event
+ "\". " +
2526 "Note that HTML attributes are case-insensitive and you cannot use " +
2527 "v-on to listen to camelCase events when using in-DOM templates. " +
2528 "You should probably use \"" + (hyphenate(event
)) + "\" instead of \"" + event
+ "\"."
2532 var cbs
= vm
._events
[event
];
2534 cbs
= cbs
.length
> 1 ? toArray(cbs
) : cbs
;
2535 var args
= toArray(arguments
, 1);
2536 for (var i
= 0, l
= cbs
.length
; i
< l
; i
++) {
2538 cbs
[i
].apply(vm
, args
);
2540 handleError(e
, vm
, ("event handler for \"" + event
+ "\""));
2553 * Runtime helper for resolving raw children VNodes into a slot object.
2555 function resolveSlots (
2563 for (var i
= 0, l
= children
.length
; i
< l
; i
++) {
2564 var child
= children
[i
];
2565 var data
= child
.data
;
2566 // remove slot attribute if the node is resolved as a Vue slot node
2567 if (data
&& data
.attrs
&& data
.attrs
.slot
) {
2568 delete data
.attrs
.slot
;
2570 // named slots should only be respected if the vnode was rendered in the
2572 if ((child
.context
=== context
|| child
.fnContext
=== context
) &&
2573 data
&& data
.slot
!= null
2575 var name
= data
.slot
;
2576 var slot
= (slots
[name
] || (slots
[name
] = []));
2577 if (child
.tag
=== 'template') {
2578 slot
.push
.apply(slot
, child
.children
|| []);
2583 (slots
.default || (slots
.default = [])).push(child
);
2586 // ignore slots that contains only whitespace
2587 for (var name
$1 in slots
) {
2588 if (slots
[name
$1].every(isWhitespace
)) {
2589 delete slots
[name
$1];
2595 function isWhitespace (node
) {
2596 return (node
.isComment
&& !node
.asyncFactory
) || node
.text
=== ' '
2599 function resolveScopedSlots (
2600 fns
, // see flow/vnode
2604 for (var i
= 0; i
< fns
.length
; i
++) {
2605 if (Array
.isArray(fns
[i
])) {
2606 resolveScopedSlots(fns
[i
], res
);
2608 res
[fns
[i
].key
] = fns
[i
].fn
;
2616 var activeInstance
= null;
2617 var isUpdatingChildComponent
= false;
2619 function initLifecycle (vm
) {
2620 var options
= vm
.$options
;
2622 // locate first non-abstract parent
2623 var parent
= options
.parent
;
2624 if (parent
&& !options
.abstract) {
2625 while (parent
.$options
.abstract && parent
.$parent
) {
2626 parent
= parent
.$parent
;
2628 parent
.$children
.push(vm
);
2631 vm
.$parent
= parent
;
2632 vm
.$root
= parent
? parent
.$root : vm
;
2638 vm
._inactive
= null;
2639 vm
._directInactive
= false;
2640 vm
._isMounted
= false;
2641 vm
._isDestroyed
= false;
2642 vm
._isBeingDestroyed
= false;
2645 function lifecycleMixin (Vue
) {
2646 Vue
.prototype._update = function (vnode
, hydrating
) {
2648 if (vm
._isMounted
) {
2649 callHook(vm
, 'beforeUpdate');
2651 var prevEl
= vm
.$el
;
2652 var prevVnode
= vm
._vnode
;
2653 var prevActiveInstance
= activeInstance
;
2654 activeInstance
= vm
;
2656 // Vue.prototype.__patch__ is injected in entry points
2657 // based on the rendering backend used.
2660 vm
.$el
= vm
.__patch__(
2661 vm
.$el
, vnode
, hydrating
, false /* removeOnly */,
2662 vm
.$options
._parentElm
,
2665 // no need for the ref nodes after initial patch
2666 // this prevents keeping a detached DOM tree in memory (#5851)
2667 vm
.$options
._parentElm
= vm
.$options
._refElm
= null;
2670 vm
.$el
= vm
.__patch__(prevVnode
, vnode
);
2672 activeInstance
= prevActiveInstance
;
2673 // update __vue__ reference
2675 prevEl
.__vue__
= null;
2678 vm
.$el
.__vue__
= vm
;
2680 // if parent is an HOC, update its $el as well
2681 if (vm
.$vnode
&& vm
.$parent
&& vm
.$vnode
=== vm
.$parent
._vnode
) {
2682 vm
.$parent
.$el
= vm
.$el
;
2684 // updated hook is called by the scheduler to ensure that children are
2685 // updated in a parent's updated hook.
2688 Vue
.prototype.$forceUpdate = function () {
2691 vm
._watcher
.update();
2695 Vue
.prototype.$destroy = function () {
2697 if (vm
._isBeingDestroyed
) {
2700 callHook(vm
, 'beforeDestroy');
2701 vm
._isBeingDestroyed
= true;
2702 // remove self from parent
2703 var parent
= vm
.$parent
;
2704 if (parent
&& !parent
._isBeingDestroyed
&& !vm
.$options
.abstract) {
2705 remove(parent
.$children
, vm
);
2707 // teardown watchers
2709 vm
._watcher
.teardown();
2711 var i
= vm
._watchers
.length
;
2713 vm
._watchers
[i
].teardown();
2715 // remove reference from data ob
2716 // frozen object may not have observer.
2717 if (vm
._data
.__ob__
) {
2718 vm
._data
.__ob__
.vmCount
--;
2720 // call the last hook...
2721 vm
._isDestroyed
= true;
2722 // invoke destroy hooks on current rendered tree
2723 vm
.__patch__(vm
._vnode
, null);
2724 // fire destroyed hook
2725 callHook(vm
, 'destroyed');
2726 // turn off all instance listeners.
2728 // remove __vue__ reference
2730 vm
.$el
.__vue__
= null;
2732 // release circular reference (#6759)
2734 vm
.$vnode
.parent
= null;
2739 function mountComponent (
2745 if (!vm
.$options
.render
) {
2746 vm
.$options
.render
= createEmptyVNode
;
2748 /* istanbul ignore if */
2749 if ((vm
.$options
.template
&& vm
.$options
.template
.charAt(0) !== '#') ||
2750 vm
.$options
.el
|| el
) {
2752 'You are using the runtime-only build of Vue where the template ' +
2753 'compiler is not available. Either pre-compile the templates into ' +
2754 'render functions, or use the compiler-included build.',
2759 'Failed to mount component: template or render function not defined.',
2765 callHook(vm
, 'beforeMount');
2767 var updateComponent
;
2768 /* istanbul ignore if */
2769 if ("development" !== 'production' && config
.performance
&& mark
) {
2770 updateComponent = function () {
2771 var name
= vm
._name
;
2773 var startTag
= "vue-perf-start:" + id
;
2774 var endTag
= "vue-perf-end:" + id
;
2777 var vnode
= vm
._render();
2779 measure(("vue " + name
+ " render"), startTag
, endTag
);
2782 vm
._update(vnode
, hydrating
);
2784 measure(("vue " + name
+ " patch"), startTag
, endTag
);
2787 updateComponent = function () {
2788 vm
._update(vm
._render(), hydrating
);
2792 // we set this to vm._watcher inside the watcher's constructor
2793 // since the watcher's initial patch may call $forceUpdate (e.g. inside child
2794 // component's mounted hook), which relies on vm._watcher being already defined
2795 new Watcher(vm
, updateComponent
, noop
, null, true /* isRenderWatcher */);
2798 // manually mounted instance, call mounted on self
2799 // mounted is called for render-created child components in its inserted hook
2800 if (vm
.$vnode
== null) {
2801 vm
._isMounted
= true;
2802 callHook(vm
, 'mounted');
2807 function updateChildComponent (
2815 isUpdatingChildComponent
= true;
2818 // determine whether component has slot children
2819 // we need to do this before overwriting $options._renderChildren
2820 var hasChildren
= !!(
2821 renderChildren
|| // has new static slots
2822 vm
.$options
._renderChildren
|| // has old static slots
2823 parentVnode
.data
.scopedSlots
|| // has new scoped slots
2824 vm
.$scopedSlots
!== emptyObject
// has old scoped slots
2827 vm
.$options
._parentVnode
= parentVnode
;
2828 vm
.$vnode
= parentVnode
; // update vm's placeholder node without re-render
2830 if (vm
._vnode
) { // update child tree's parent
2831 vm
._vnode
.parent
= parentVnode
;
2833 vm
.$options
._renderChildren
= renderChildren
;
2835 // update $attrs and $listeners hash
2836 // these are also reactive so they may trigger child update if the child
2837 // used them during render
2838 vm
.$attrs
= parentVnode
.data
.attrs
|| emptyObject
;
2839 vm
.$listeners
= listeners
|| emptyObject
;
2842 if (propsData
&& vm
.$options
.props
) {
2843 toggleObserving(false);
2844 var props
= vm
._props
;
2845 var propKeys
= vm
.$options
._propKeys
|| [];
2846 for (var i
= 0; i
< propKeys
.length
; i
++) {
2847 var key
= propKeys
[i
];
2848 var propOptions
= vm
.$options
.props
; // wtf flow?
2849 props
[key
] = validateProp(key
, propOptions
, propsData
, vm
);
2851 toggleObserving(true);
2852 // keep a copy of raw propsData
2853 vm
.$options
.propsData
= propsData
;
2857 listeners
= listeners
|| emptyObject
;
2858 var oldListeners
= vm
.$options
._parentListeners
;
2859 vm
.$options
._parentListeners
= listeners
;
2860 updateComponentListeners(vm
, listeners
, oldListeners
);
2862 // resolve slots + force update if has children
2864 vm
.$slots
= resolveSlots(renderChildren
, parentVnode
.context
);
2869 isUpdatingChildComponent
= false;
2873 function isInInactiveTree (vm
) {
2874 while (vm
&& (vm
= vm
.$parent
)) {
2875 if (vm
._inactive
) { return true }
2880 function activateChildComponent (vm
, direct
) {
2882 vm
._directInactive
= false;
2883 if (isInInactiveTree(vm
)) {
2886 } else if (vm
._directInactive
) {
2889 if (vm
._inactive
|| vm
._inactive
=== null) {
2890 vm
._inactive
= false;
2891 for (var i
= 0; i
< vm
.$children
.length
; i
++) {
2892 activateChildComponent(vm
.$children
[i
]);
2894 callHook(vm
, 'activated');
2898 function deactivateChildComponent (vm
, direct
) {
2900 vm
._directInactive
= true;
2901 if (isInInactiveTree(vm
)) {
2905 if (!vm
._inactive
) {
2906 vm
._inactive
= true;
2907 for (var i
= 0; i
< vm
.$children
.length
; i
++) {
2908 deactivateChildComponent(vm
.$children
[i
]);
2910 callHook(vm
, 'deactivated');
2914 function callHook (vm
, hook
) {
2915 // #7573 disable dep collection when invoking lifecycle hooks
2917 var handlers
= vm
.$options
[hook
];
2919 for (var i
= 0, j
= handlers
.length
; i
< j
; i
++) {
2921 handlers
[i
].call(vm
);
2923 handleError(e
, vm
, (hook
+ " hook"));
2927 if (vm
._hasHookEvent
) {
2928 vm
.$emit('hook:' + hook
);
2936 var MAX_UPDATE_COUNT
= 100;
2939 var activatedChildren
= [];
2942 var waiting
= false;
2943 var flushing
= false;
2947 * Reset the scheduler's state.
2949 function resetSchedulerState () {
2950 index
= queue
.length
= activatedChildren
.length
= 0;
2955 waiting
= flushing
= false;
2959 * Flush both queues and run the watchers.
2961 function flushSchedulerQueue () {
2965 // Sort queue before flush.
2966 // This ensures that:
2967 // 1. Components are updated from parent to child. (because parent is always
2968 // created before the child)
2969 // 2. A component's user watchers are run before its render watcher (because
2970 // user watchers are created before the render watcher)
2971 // 3. If a component is destroyed during a parent component's watcher run,
2972 // its watchers can be skipped.
2973 queue
.sort(function (a
, b
) { return a
.id
- b
.id
; });
2975 // do not cache length because more watchers might be pushed
2976 // as we run existing watchers
2977 for (index
= 0; index
< queue
.length
; index
++) {
2978 watcher
= queue
[index
];
2982 // in dev build, check and stop circular updates.
2983 if ("development" !== 'production' && has
[id
] != null) {
2984 circular
[id
] = (circular
[id
] || 0) + 1;
2985 if (circular
[id
] > MAX_UPDATE_COUNT
) {
2987 'You may have an infinite update loop ' + (
2989 ? ("in watcher with expression \"" + (watcher
.expression
) + "\"")
2990 : "in a component render function."
2999 // keep copies of post queues before resetting state
3000 var activatedQueue
= activatedChildren
.slice();
3001 var updatedQueue
= queue
.slice();
3003 resetSchedulerState();
3005 // call component updated and activated hooks
3006 callActivatedHooks(activatedQueue
);
3007 callUpdatedHooks(updatedQueue
);
3010 /* istanbul ignore if */
3011 if (devtools
&& config
.devtools
) {
3012 devtools
.emit('flush');
3016 function callUpdatedHooks (queue
) {
3017 var i
= queue
.length
;
3019 var watcher
= queue
[i
];
3020 var vm
= watcher
.vm
;
3021 if (vm
._watcher
=== watcher
&& vm
._isMounted
) {
3022 callHook(vm
, 'updated');
3028 * Queue a kept-alive component that was activated during patch.
3029 * The queue will be processed after the entire tree has been patched.
3031 function queueActivatedComponent (vm
) {
3032 // setting _inactive to false here so that a render function can
3033 // rely on checking whether it's in an inactive tree (e.g. router-view)
3034 vm
._inactive
= false;
3035 activatedChildren
.push(vm
);
3038 function callActivatedHooks (queue
) {
3039 for (var i
= 0; i
< queue
.length
; i
++) {
3040 queue
[i
]._inactive
= true;
3041 activateChildComponent(queue
[i
], true /* true */);
3046 * Push a watcher into the watcher queue.
3047 * Jobs with duplicate IDs will be skipped unless it's
3048 * pushed when the queue is being flushed.
3050 function queueWatcher (watcher
) {
3051 var id
= watcher
.id
;
3052 if (has
[id
] == null) {
3055 queue
.push(watcher
);
3057 // if already flushing, splice the watcher based on its id
3058 // if already past its id, it will be run next immediately.
3059 var i
= queue
.length
- 1;
3060 while (i
> index
&& queue
[i
].id
> watcher
.id
) {
3063 queue
.splice(i
+ 1, 0, watcher
);
3068 nextTick(flushSchedulerQueue
);
3078 * A watcher parses an expression, collects dependencies,
3079 * and fires callback when the expression value changes.
3080 * This is used for both the $watch() api and directives.
3082 var Watcher
= function Watcher (
3090 if (isRenderWatcher
) {
3093 vm
._watchers
.push(this);
3096 this.deep
= !!options
.deep
;
3097 this.user
= !!options
.user
;
3098 this.lazy
= !!options
.lazy
;
3099 this.sync
= !!options
.sync
;
3101 this.deep
= this.user
= this.lazy
= this.sync
= false;
3104 this.id
= ++uid
$1; // uid for batching
3106 this.dirty
= this.lazy
; // for lazy watchers
3109 this.depIds
= new _Set();
3110 this.newDepIds
= new _Set();
3111 this.expression
= expOrFn
.toString();
3112 // parse expression for getter
3113 if (typeof expOrFn
=== 'function') {
3114 this.getter
= expOrFn
;
3116 this.getter
= parsePath(expOrFn
);
3118 this.getter = function () {};
3119 "development" !== 'production' && warn(
3120 "Failed watching path: \"" + expOrFn
+ "\" " +
3121 'Watcher only accepts simple dot-delimited paths. ' +
3122 'For full control, use a function instead.',
3127 this.value
= this.lazy
3133 * Evaluate the getter, and re-collect dependencies.
3135 Watcher
.prototype.get = function get () {
3140 value
= this.getter
.call(vm
, vm
);
3143 handleError(e
, vm
, ("getter for watcher \"" + (this.expression
) + "\""));
3148 // "touch" every property so they are all tracked as
3149 // dependencies for deep watching
3160 * Add a dependency to this directive.
3162 Watcher
.prototype.addDep
= function addDep (dep
) {
3164 if (!this.newDepIds
.has(id
)) {
3165 this.newDepIds
.add(id
);
3166 this.newDeps
.push(dep
);
3167 if (!this.depIds
.has(id
)) {
3174 * Clean up for dependency collection.
3176 Watcher
.prototype.cleanupDeps
= function cleanupDeps () {
3179 var i
= this.deps
.length
;
3181 var dep
= this$1.deps
[i
];
3182 if (!this$1.newDepIds
.has(dep
.id
)) {
3183 dep
.removeSub(this$1);
3186 var tmp
= this.depIds
;
3187 this.depIds
= this.newDepIds
;
3188 this.newDepIds
= tmp
;
3189 this.newDepIds
.clear();
3191 this.deps
= this.newDeps
;
3193 this.newDeps
.length
= 0;
3197 * Subscriber interface.
3198 * Will be called when a dependency changes.
3200 Watcher
.prototype.update
= function update () {
3201 /* istanbul ignore else */
3204 } else if (this.sync
) {
3212 * Scheduler job interface.
3213 * Will be called by the scheduler.
3215 Watcher
.prototype.run
= function run () {
3217 var value
= this.get();
3219 value
!== this.value
||
3220 // Deep watchers and watchers on Object/Arrays should fire even
3221 // when the value is the same, because the value may
3227 var oldValue
= this.value
;
3231 this.cb
.call(this.vm
, value
, oldValue
);
3233 handleError(e
, this.vm
, ("callback for watcher \"" + (this.expression
) + "\""));
3236 this.cb
.call(this.vm
, value
, oldValue
);
3243 * Evaluate the value of the watcher.
3244 * This only gets called for lazy watchers.
3246 Watcher
.prototype.evaluate
= function evaluate () {
3247 this.value
= this.get();
3252 * Depend on all deps collected by this watcher.
3254 Watcher
.prototype.depend
= function depend () {
3257 var i
= this.deps
.length
;
3259 this$1.deps
[i
].depend();
3264 * Remove self from all dependencies' subscriber list.
3266 Watcher
.prototype.teardown
= function teardown () {
3270 // remove self from vm's watcher list
3271 // this is a somewhat expensive operation so we skip it
3272 // if the vm is being destroyed.
3273 if (!this.vm
._isBeingDestroyed
) {
3274 remove(this.vm
._watchers
, this);
3276 var i
= this.deps
.length
;
3278 this$1.deps
[i
].removeSub(this$1);
3280 this.active
= false;
3286 var sharedPropertyDefinition
= {
3293 function proxy (target
, sourceKey
, key
) {
3294 sharedPropertyDefinition
.get = function proxyGetter () {
3295 return this[sourceKey
][key
]
3297 sharedPropertyDefinition
.set = function proxySetter (val
) {
3298 this[sourceKey
][key
] = val
;
3300 Object
.defineProperty(target
, key
, sharedPropertyDefinition
);
3303 function initState (vm
) {
3305 var opts
= vm
.$options
;
3306 if (opts
.props
) { initProps(vm
, opts
.props
); }
3307 if (opts
.methods
) { initMethods(vm
, opts
.methods
); }
3311 observe(vm
._data
= {}, true /* asRootData */);
3313 if (opts
.computed
) { initComputed(vm
, opts
.computed
); }
3314 if (opts
.watch
&& opts
.watch
!== nativeWatch
) {
3315 initWatch(vm
, opts
.watch
);
3319 function initProps (vm
, propsOptions
) {
3320 var propsData
= vm
.$options
.propsData
|| {};
3321 var props
= vm
._props
= {};
3322 // cache prop keys so that future props updates can iterate using Array
3323 // instead of dynamic object key enumeration.
3324 var keys
= vm
.$options
._propKeys
= [];
3325 var isRoot
= !vm
.$parent
;
3326 // root instance props should be converted
3328 toggleObserving(false);
3330 var loop = function ( key
) {
3332 var value
= validateProp(key
, propsOptions
, propsData
, vm
);
3333 /* istanbul ignore else */
3335 var hyphenatedKey
= hyphenate(key
);
3336 if (isReservedAttribute(hyphenatedKey
) ||
3337 config
.isReservedAttr(hyphenatedKey
)) {
3339 ("\"" + hyphenatedKey
+ "\" is a reserved attribute and cannot be used as component prop."),
3343 defineReactive(props
, key
, value
, function () {
3344 if (vm
.$parent
&& !isUpdatingChildComponent
) {
3346 "Avoid mutating a prop directly since the value will be " +
3347 "overwritten whenever the parent component re-renders. " +
3348 "Instead, use a data or computed property based on the prop's " +
3349 "value. Prop being mutated: \"" + key
+ "\"",
3355 // static props are already proxied on the component's prototype
3356 // during Vue.extend(). We only need to proxy props defined at
3357 // instantiation here.
3359 proxy(vm
, "_props", key
);
3363 for (var key
in propsOptions
) loop( key
);
3364 toggleObserving(true);
3367 function initData (vm
) {
3368 var data
= vm
.$options
.data
;
3369 data
= vm
._data
= typeof data
=== 'function'
3372 if (!isPlainObject(data
)) {
3374 "development" !== 'production' && warn(
3375 'data functions should return an object:\n' +
3376 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function',
3380 // proxy data on instance
3381 var keys
= Object
.keys(data
);
3382 var props
= vm
.$options
.props
;
3383 var methods
= vm
.$options
.methods
;
3384 var i
= keys
.length
;
3388 if (methods
&& hasOwn(methods
, key
)) {
3390 ("Method \"" + key
+ "\" has already been defined as a data property."),
3395 if (props
&& hasOwn(props
, key
)) {
3396 "development" !== 'production' && warn(
3397 "The data property \"" + key
+ "\" is already declared as a prop. " +
3398 "Use prop default value instead.",
3401 } else if (!isReserved(key
)) {
3402 proxy(vm
, "_data", key
);
3406 observe(data
, true /* asRootData */);
3409 function getData (data
, vm
) {
3410 // #7573 disable dep collection when invoking data getters
3413 return data
.call(vm
, vm
)
3415 handleError(e
, vm
, "data()");
3422 var computedWatcherOptions
= { lazy: true };
3424 function initComputed (vm
, computed
) {
3425 // $flow-disable-line
3426 var watchers
= vm
._computedWatchers
= Object
.create(null);
3427 // computed properties are just getters during SSR
3428 var isSSR
= isServerRendering();
3430 for (var key
in computed
) {
3431 var userDef
= computed
[key
];
3432 var getter
= typeof userDef
=== 'function' ? userDef : userDef
.get;
3433 if ("development" !== 'production' && getter
== null) {
3435 ("Getter is missing for computed property \"" + key
+ "\"."),
3441 // create internal watcher for the computed property.
3442 watchers
[key
] = new Watcher(
3446 computedWatcherOptions
3450 // component-defined computed properties are already defined on the
3451 // component prototype. We only need to define computed properties defined
3452 // at instantiation here.
3454 defineComputed(vm
, key
, userDef
);
3456 if (key
in vm
.$data
) {
3457 warn(("The computed property \"" + key
+ "\" is already defined in data."), vm
);
3458 } else if (vm
.$options
.props
&& key
in vm
.$options
.props
) {
3459 warn(("The computed property \"" + key
+ "\" is already defined as a prop."), vm
);
3465 function defineComputed (
3470 var shouldCache
= !isServerRendering();
3471 if (typeof userDef
=== 'function') {
3472 sharedPropertyDefinition
.get = shouldCache
3473 ? createComputedGetter(key
)
3475 sharedPropertyDefinition
.set = noop
;
3477 sharedPropertyDefinition
.get = userDef
.get
3478 ? shouldCache
&& userDef
.cache
!== false
3479 ? createComputedGetter(key
)
3482 sharedPropertyDefinition
.set = userDef
.set
3486 if ("development" !== 'production' &&
3487 sharedPropertyDefinition
.set === noop
) {
3488 sharedPropertyDefinition
.set = function () {
3490 ("Computed property \"" + key
+ "\" was assigned to but it has no setter."),
3495 Object
.defineProperty(target
, key
, sharedPropertyDefinition
);
3498 function createComputedGetter (key
) {
3499 return function computedGetter () {
3500 var watcher
= this._computedWatchers
&& this._computedWatchers
[key
];
3502 if (watcher
.dirty
) {
3508 return watcher
.value
3513 function initMethods (vm
, methods
) {
3514 var props
= vm
.$options
.props
;
3515 for (var key
in methods
) {
3517 if (methods
[key
] == null) {
3519 "Method \"" + key
+ "\" has an undefined value in the component definition. " +
3520 "Did you reference the function correctly?",
3524 if (props
&& hasOwn(props
, key
)) {
3526 ("Method \"" + key
+ "\" has already been defined as a prop."),
3530 if ((key
in vm
) && isReserved(key
)) {
3532 "Method \"" + key
+ "\" conflicts with an existing Vue instance method. " +
3533 "Avoid defining component methods that start with _ or $."
3537 vm
[key
] = methods
[key
] == null ? noop : bind(methods
[key
], vm
);
3541 function initWatch (vm
, watch
) {
3542 for (var key
in watch
) {
3543 var handler
= watch
[key
];
3544 if (Array
.isArray(handler
)) {
3545 for (var i
= 0; i
< handler
.length
; i
++) {
3546 createWatcher(vm
, key
, handler
[i
]);
3549 createWatcher(vm
, key
, handler
);
3554 function createWatcher (
3560 if (isPlainObject(handler
)) {
3562 handler
= handler
.handler
;
3564 if (typeof handler
=== 'string') {
3565 handler
= vm
[handler
];
3567 return vm
.$watch(expOrFn
, handler
, options
)
3570 function stateMixin (Vue
) {
3571 // flow somehow has problems with directly declared definition object
3572 // when using Object.defineProperty, so we have to procedurally build up
3575 dataDef
.get = function () { return this._data
};
3577 propsDef
.get = function () { return this._props
};
3579 dataDef
.set = function (newData
) {
3581 'Avoid replacing instance root $data. ' +
3582 'Use nested data properties instead.',
3586 propsDef
.set = function () {
3587 warn("$props is readonly.", this);
3590 Object
.defineProperty(Vue
.prototype, '$data', dataDef
);
3591 Object
.defineProperty(Vue
.prototype, '$props', propsDef
);
3593 Vue
.prototype.$set = set;
3594 Vue
.prototype.$delete = del
;
3596 Vue
.prototype.$watch = function (
3602 if (isPlainObject(cb
)) {
3603 return createWatcher(vm
, expOrFn
, cb
, options
)
3605 options
= options
|| {};
3606 options
.user
= true;
3607 var watcher
= new Watcher(vm
, expOrFn
, cb
, options
);
3608 if (options
.immediate
) {
3609 cb
.call(vm
, watcher
.value
);
3611 return function unwatchFn () {
3619 function initProvide (vm
) {
3620 var provide
= vm
.$options
.provide
;
3622 vm
._provided
= typeof provide
=== 'function'
3628 function initInjections (vm
) {
3629 var result
= resolveInject(vm
.$options
.inject
, vm
);
3631 toggleObserving(false);
3632 Object
.keys(result
).forEach(function (key
) {
3633 /* istanbul ignore else */
3635 defineReactive(vm
, key
, result
[key
], function () {
3637 "Avoid mutating an injected value directly since the changes will be " +
3638 "overwritten whenever the provided component re-renders. " +
3639 "injection being mutated: \"" + key
+ "\"",
3645 toggleObserving(true);
3649 function resolveInject (inject
, vm
) {
3651 // inject is :any because flow is not smart enough to figure out cached
3652 var result
= Object
.create(null);
3653 var keys
= hasSymbol
3654 ? Reflect
.ownKeys(inject
).filter(function (key
) {
3655 /* istanbul ignore next */
3656 return Object
.getOwnPropertyDescriptor(inject
, key
).enumerable
3658 : Object
.keys(inject
);
3660 for (var i
= 0; i
< keys
.length
; i
++) {
3662 var provideKey
= inject
[key
].from;
3665 if (source
._provided
&& hasOwn(source
._provided
, provideKey
)) {
3666 result
[key
] = source
._provided
[provideKey
];
3669 source
= source
.$parent
;
3672 if ('default' in inject
[key
]) {
3673 var provideDefault
= inject
[key
].default;
3674 result
[key
] = typeof provideDefault
=== 'function'
3675 ? provideDefault
.call(vm
)
3678 warn(("Injection \"" + key
+ "\" not found"), vm
);
3689 * Runtime helper for rendering v-for lists.
3691 function renderList (
3695 var ret
, i
, l
, keys
, key
;
3696 if (Array
.isArray(val
) || typeof val
=== 'string') {
3697 ret
= new Array(val
.length
);
3698 for (i
= 0, l
= val
.length
; i
< l
; i
++) {
3699 ret
[i
] = render(val
[i
], i
);
3701 } else if (typeof val
=== 'number') {
3702 ret
= new Array(val
);
3703 for (i
= 0; i
< val
; i
++) {
3704 ret
[i
] = render(i
+ 1, i
);
3706 } else if (isObject(val
)) {
3707 keys
= Object
.keys(val
);
3708 ret
= new Array(keys
.length
);
3709 for (i
= 0, l
= keys
.length
; i
< l
; i
++) {
3711 ret
[i
] = render(val
[key
], key
, i
);
3715 (ret
)._isVList
= true;
3723 * Runtime helper for rendering <slot>
3725 function renderSlot (
3731 var scopedSlotFn
= this.$scopedSlots
[name
];
3733 if (scopedSlotFn
) { // scoped slot
3734 props
= props
|| {};
3736 if ("development" !== 'production' && !isObject(bindObject
)) {
3738 'slot v-bind without argument expects an Object',
3742 props
= extend(extend({}, bindObject
), props
);
3744 nodes
= scopedSlotFn(props
) || fallback
;
3746 var slotNodes
= this.$slots
[name
];
3747 // warn duplicate slot usage
3749 if ("development" !== 'production' && slotNodes
._rendered
) {
3751 "Duplicate presence of slot \"" + name
+ "\" found in the same render tree " +
3752 "- this will likely cause render errors.",
3756 slotNodes
._rendered
= true;
3758 nodes
= slotNodes
|| fallback
;
3761 var target
= props
&& props
.slot
;
3763 return this.$createElement('template', { slot: target
}, nodes
)
3772 * Runtime helper for resolving filters
3774 function resolveFilter (id
) {
3775 return resolveAsset(this.$options
, 'filters', id
, true) || identity
3780 function isKeyNotMatch (expect
, actual
) {
3781 if (Array
.isArray(expect
)) {
3782 return expect
.indexOf(actual
) === -1
3784 return expect
!== actual
3789 * Runtime helper for checking keyCodes from config.
3790 * exposed as Vue.prototype._k
3791 * passing in eventKeyName as last argument separately for backwards compat
3793 function checkKeyCodes (
3800 var mappedKeyCode
= config
.keyCodes
[key
] || builtInKeyCode
;
3801 if (builtInKeyName
&& eventKeyName
&& !config
.keyCodes
[key
]) {
3802 return isKeyNotMatch(builtInKeyName
, eventKeyName
)
3803 } else if (mappedKeyCode
) {
3804 return isKeyNotMatch(mappedKeyCode
, eventKeyCode
)
3805 } else if (eventKeyName
) {
3806 return hyphenate(eventKeyName
) !== key
3813 * Runtime helper for merging v-bind="object" into a VNode's data.
3815 function bindObjectProps (
3823 if (!isObject(value
)) {
3824 "development" !== 'production' && warn(
3825 'v-bind without argument expects an Object or Array value',
3829 if (Array
.isArray(value
)) {
3830 value
= toObject(value
);
3833 var loop = function ( key
) {
3837 isReservedAttribute(key
)
3841 var type
= data
.attrs
&& data
.attrs
.type
;
3842 hash
= asProp
|| config
.mustUseProp(tag
, type
, key
)
3843 ? data
.domProps
|| (data
.domProps
= {})
3844 : data
.attrs
|| (data
.attrs
= {});
3846 if (!(key
in hash
)) {
3847 hash
[key
] = value
[key
];
3850 var on
= data
.on
|| (data
.on
= {});
3851 on
[("update:" + key
)] = function ($event
) {
3852 value
[key
] = $event
;
3858 for (var key
in value
) loop( key
);
3867 * Runtime helper for rendering static trees.
3869 function renderStatic (
3873 var cached
= this._staticTrees
|| (this._staticTrees
= []);
3874 var tree
= cached
[index
];
3875 // if has already-rendered static tree and not inside v-for,
3876 // we can reuse the same tree.
3877 if (tree
&& !isInFor
) {
3880 // otherwise, render a fresh tree.
3881 tree
= cached
[index
] = this.$options
.staticRenderFns
[index
].call(
3884 this // for render fns generated for functional component templates
3886 markStatic(tree
, ("__static__" + index
), false);
3891 * Runtime helper for v-once.
3892 * Effectively it means marking the node as static with a unique key.
3899 markStatic(tree
, ("__once__" + index
+ (key
? ("_" + key
) : "")), true);
3903 function markStatic (
3908 if (Array
.isArray(tree
)) {
3909 for (var i
= 0; i
< tree
.length
; i
++) {
3910 if (tree
[i
] && typeof tree
[i
] !== 'string') {
3911 markStaticNode(tree
[i
], (key
+ "_" + i
), isOnce
);
3915 markStaticNode(tree
, key
, isOnce
);
3919 function markStaticNode (node
, key
, isOnce
) {
3920 node
.isStatic
= true;
3922 node
.isOnce
= isOnce
;
3927 function bindObjectListeners (data
, value
) {
3929 if (!isPlainObject(value
)) {
3930 "development" !== 'production' && warn(
3931 'v-on without argument expects an Object value',
3935 var on
= data
.on
= data
.on
? extend({}, data
.on
) : {};
3936 for (var key
in value
) {
3937 var existing
= on
[key
];
3938 var ours
= value
[key
];
3939 on
[key
] = existing
? [].concat(existing
, ours
) : ours
;
3948 function installRenderHelpers (target
) {
3949 target
._o
= markOnce
;
3950 target
._n
= toNumber
;
3951 target
._s
= toString
;
3952 target
._l
= renderList
;
3953 target
._t
= renderSlot
;
3954 target
._q
= looseEqual
;
3955 target
._i
= looseIndexOf
;
3956 target
._m
= renderStatic
;
3957 target
._f
= resolveFilter
;
3958 target
._k
= checkKeyCodes
;
3959 target
._b
= bindObjectProps
;
3960 target
._v
= createTextVNode
;
3961 target
._e
= createEmptyVNode
;
3962 target
._u
= resolveScopedSlots
;
3963 target
._g
= bindObjectListeners
;
3968 function FunctionalRenderContext (
3975 var options
= Ctor
.options
;
3976 // ensure the createElement function in functional components
3977 // gets a unique context - this is necessary for correct named slot check
3979 if (hasOwn(parent
, '_uid')) {
3980 contextVm
= Object
.create(parent
);
3981 // $flow-disable-line
3982 contextVm
._original
= parent
;
3984 // the context vm passed in is a functional context as well.
3985 // in this case we want to make sure we are able to get a hold to the
3986 // real context instance.
3988 // $flow-disable-line
3989 parent
= parent
._original
;
3991 var isCompiled
= isTrue(options
._compiled
);
3992 var needNormalization
= !isCompiled
;
3996 this.children
= children
;
3997 this.parent
= parent
;
3998 this.listeners
= data
.on
|| emptyObject
;
3999 this.injections
= resolveInject(options
.inject
, parent
);
4000 this.slots = function () { return resolveSlots(children
, parent
); };
4002 // support for compiled functional template
4004 // exposing $options for renderStatic()
4005 this.$options
= options
;
4006 // pre-resolve slots for renderSlot()
4007 this.$slots
= this.slots();
4008 this.$scopedSlots
= data
.scopedSlots
|| emptyObject
;
4011 if (options
._scopeId
) {
4012 this._c = function (a
, b
, c
, d
) {
4013 var vnode
= createElement(contextVm
, a
, b
, c
, d
, needNormalization
);
4014 if (vnode
&& !Array
.isArray(vnode
)) {
4015 vnode
.fnScopeId
= options
._scopeId
;
4016 vnode
.fnContext
= parent
;
4021 this._c = function (a
, b
, c
, d
) { return createElement(contextVm
, a
, b
, c
, d
, needNormalization
); };
4025 installRenderHelpers(FunctionalRenderContext
.prototype);
4027 function createFunctionalComponent (
4034 var options
= Ctor
.options
;
4036 var propOptions
= options
.props
;
4037 if (isDef(propOptions
)) {
4038 for (var key
in propOptions
) {
4039 props
[key
] = validateProp(key
, propOptions
, propsData
|| emptyObject
);
4042 if (isDef(data
.attrs
)) { mergeProps(props
, data
.attrs
); }
4043 if (isDef(data
.props
)) { mergeProps(props
, data
.props
); }
4046 var renderContext
= new FunctionalRenderContext(
4054 var vnode
= options
.render
.call(null, renderContext
._c
, renderContext
);
4056 if (vnode
instanceof VNode
) {
4057 return cloneAndMarkFunctionalResult(vnode
, data
, renderContext
.parent
, options
)
4058 } else if (Array
.isArray(vnode
)) {
4059 var vnodes
= normalizeChildren(vnode
) || [];
4060 var res
= new Array(vnodes
.length
);
4061 for (var i
= 0; i
< vnodes
.length
; i
++) {
4062 res
[i
] = cloneAndMarkFunctionalResult(vnodes
[i
], data
, renderContext
.parent
, options
);
4068 function cloneAndMarkFunctionalResult (vnode
, data
, contextVm
, options
) {
4069 // #7817 clone node before setting fnContext, otherwise if the node is reused
4070 // (e.g. it was from a cached normal slot) the fnContext causes named slots
4071 // that should not be matched to match.
4072 var clone
= cloneVNode(vnode
);
4073 clone
.fnContext
= contextVm
;
4074 clone
.fnOptions
= options
;
4076 (clone
.data
|| (clone
.data
= {})).slot
= data
.slot
;
4081 function mergeProps (to
, from) {
4082 for (var key
in from) {
4083 to
[camelize(key
)] = from[key
];
4092 // Register the component hook to weex native render engine.
4093 // The hook will be triggered by native, not javascript.
4096 // Updates the state of the component to weex native render engine.
4100 // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4102 // listening on native callback
4108 // inline hooks to be invoked on component VNodes during patch
4109 var componentVNodeHooks
= {
4110 init: function init (
4117 vnode
.componentInstance
&&
4118 !vnode
.componentInstance
._isDestroyed
&&
4119 vnode
.data
.keepAlive
4121 // kept-alive components, treat as a patch
4122 var mountedNode
= vnode
; // work around flow
4123 componentVNodeHooks
.prepatch(mountedNode
, mountedNode
);
4125 var child
= vnode
.componentInstance
= createComponentInstanceForVnode(
4131 child
.$mount(hydrating
? vnode
.elm : undefined, hydrating
);
4135 prepatch: function prepatch (oldVnode
, vnode
) {
4136 var options
= vnode
.componentOptions
;
4137 var child
= vnode
.componentInstance
= oldVnode
.componentInstance
;
4138 updateChildComponent(
4140 options
.propsData
, // updated props
4141 options
.listeners
, // updated listeners
4142 vnode
, // new parent vnode
4143 options
.children
// new children
4147 insert: function insert (vnode
) {
4148 var context
= vnode
.context
;
4149 var componentInstance
= vnode
.componentInstance
;
4150 if (!componentInstance
._isMounted
) {
4151 componentInstance
._isMounted
= true;
4152 callHook(componentInstance
, 'mounted');
4154 if (vnode
.data
.keepAlive
) {
4155 if (context
._isMounted
) {
4157 // During updates, a kept-alive component's child components may
4158 // change, so directly walking the tree here may call activated hooks
4159 // on incorrect children. Instead we push them into a queue which will
4160 // be processed after the whole patch process ended.
4161 queueActivatedComponent(componentInstance
);
4163 activateChildComponent(componentInstance
, true /* direct */);
4168 destroy: function destroy (vnode
) {
4169 var componentInstance
= vnode
.componentInstance
;
4170 if (!componentInstance
._isDestroyed
) {
4171 if (!vnode
.data
.keepAlive
) {
4172 componentInstance
.$destroy();
4174 deactivateChildComponent(componentInstance
, true /* direct */);
4180 var hooksToMerge
= Object
.keys(componentVNodeHooks
);
4182 function createComponent (
4189 if (isUndef(Ctor
)) {
4193 var baseCtor
= context
.$options
._base
;
4195 // plain options object: turn it into a constructor
4196 if (isObject(Ctor
)) {
4197 Ctor
= baseCtor
.extend(Ctor
);
4200 // if at this stage it's not a constructor or an async component factory,
4202 if (typeof Ctor
!== 'function') {
4204 warn(("Invalid Component definition: " + (String(Ctor
))), context
);
4211 if (isUndef(Ctor
.cid
)) {
4212 asyncFactory
= Ctor
;
4213 Ctor
= resolveAsyncComponent(asyncFactory
, baseCtor
, context
);
4214 if (Ctor
=== undefined) {
4215 // return a placeholder node for async component, which is rendered
4216 // as a comment node but preserves all the raw information for the node.
4217 // the information will be used for async server-rendering and hydration.
4218 return createAsyncPlaceholder(
4230 // resolve constructor options in case global mixins are applied after
4231 // component constructor creation
4232 resolveConstructorOptions(Ctor
);
4234 // transform component v-model data into props & events
4235 if (isDef(data
.model
)) {
4236 transformModel(Ctor
.options
, data
);
4240 var propsData
= extractPropsFromVNodeData(data
, Ctor
, tag
);
4242 // functional component
4243 if (isTrue(Ctor
.options
.functional
)) {
4244 return createFunctionalComponent(Ctor
, propsData
, data
, context
, children
)
4247 // extract listeners, since these needs to be treated as
4248 // child component listeners instead of DOM listeners
4249 var listeners
= data
.on
;
4250 // replace with listeners with .native modifier
4251 // so it gets processed during parent component patch.
4252 data
.on
= data
.nativeOn
;
4254 if (isTrue(Ctor
.options
.abstract)) {
4255 // abstract components do not keep anything
4256 // other than props & listeners & slot
4259 var slot
= data
.slot
;
4266 // install component management hooks onto the placeholder node
4267 installComponentHooks(data
);
4269 // return a placeholder vnode
4270 var name
= Ctor
.options
.name
|| tag
;
4271 var vnode
= new VNode(
4272 ("vue-component-" + (Ctor
.cid
) + (name
? ("-" + name
) : '')),
4273 data
, undefined, undefined, undefined, context
,
4274 { Ctor: Ctor
, propsData: propsData
, listeners: listeners
, tag: tag
, children: children
},
4278 // Weex specific: invoke recycle-list optimized @render function for
4279 // extracting cell-slot template.
4280 // https://github.com/Hanks10100/weex-native-directive/tree/master/component
4281 /* istanbul ignore if */
4285 function createComponentInstanceForVnode (
4286 vnode
, // we know it's MountedComponentVNode but flow doesn't
4287 parent
, // activeInstance in lifecycle state
4294 _parentVnode: vnode
,
4295 _parentElm: parentElm
|| null,
4296 _refElm: refElm
|| null
4298 // check inline-template render functions
4299 var inlineTemplate
= vnode
.data
.inlineTemplate
;
4300 if (isDef(inlineTemplate
)) {
4301 options
.render
= inlineTemplate
.render
;
4302 options
.staticRenderFns
= inlineTemplate
.staticRenderFns
;
4304 return new vnode
.componentOptions
.Ctor(options
)
4307 function installComponentHooks (data
) {
4308 var hooks
= data
.hook
|| (data
.hook
= {});
4309 for (var i
= 0; i
< hooksToMerge
.length
; i
++) {
4310 var key
= hooksToMerge
[i
];
4311 hooks
[key
] = componentVNodeHooks
[key
];
4315 // transform component v-model info (value and callback) into
4316 // prop and event handler respectively.
4317 function transformModel (options
, data
) {
4318 var prop
= (options
.model
&& options
.model
.prop
) || 'value';
4319 var event
= (options
.model
&& options
.model
.event
) || 'input';(data
.props
|| (data
.props
= {}))[prop
] = data
.model
.value
;
4320 var on
= data
.on
|| (data
.on
= {});
4321 if (isDef(on
[event
])) {
4322 on
[event
] = [data
.model
.callback
].concat(on
[event
]);
4324 on
[event
] = data
.model
.callback
;
4330 var SIMPLE_NORMALIZE
= 1;
4331 var ALWAYS_NORMALIZE
= 2;
4333 // wrapper function for providing a more flexible interface
4334 // without getting yelled at by flow
4335 function createElement (
4343 if (Array
.isArray(data
) || isPrimitive(data
)) {
4344 normalizationType
= children
;
4348 if (isTrue(alwaysNormalize
)) {
4349 normalizationType
= ALWAYS_NORMALIZE
;
4351 return _createElement(context
, tag
, data
, children
, normalizationType
)
4354 function _createElement (
4361 if (isDef(data
) && isDef((data
).__ob__
)) {
4362 "development" !== 'production' && warn(
4363 "Avoid using observed data object as vnode data: " + (JSON
.stringify(data
)) + "\n" +
4364 'Always create fresh vnode data objects in each render!',
4367 return createEmptyVNode()
4369 // object syntax in v-bind
4370 if (isDef(data
) && isDef(data
.is
)) {
4374 // in case of component :is set to falsy value
4375 return createEmptyVNode()
4377 // warn against non-primitive key
4378 if ("development" !== 'production' &&
4379 isDef(data
) && isDef(data
.key
) && !isPrimitive(data
.key
)
4383 'Avoid using non-primitive value as key, ' +
4384 'use string/number value instead.',
4389 // support single function children as default scoped slot
4390 if (Array
.isArray(children
) &&
4391 typeof children
[0] === 'function'
4394 data
.scopedSlots
= { default: children
[0] };
4395 children
.length
= 0;
4397 if (normalizationType
=== ALWAYS_NORMALIZE
) {
4398 children
= normalizeChildren(children
);
4399 } else if (normalizationType
=== SIMPLE_NORMALIZE
) {
4400 children
= simpleNormalizeChildren(children
);
4403 if (typeof tag
=== 'string') {
4405 ns
= (context
.$vnode
&& context
.$vnode
.ns
) || config
.getTagNamespace(tag
);
4406 if (config
.isReservedTag(tag
)) {
4407 // platform built-in elements
4409 config
.parsePlatformTagName(tag
), data
, children
,
4410 undefined, undefined, context
4412 } else if (isDef(Ctor
= resolveAsset(context
.$options
, 'components', tag
))) {
4414 vnode
= createComponent(Ctor
, data
, context
, children
, tag
);
4416 // unknown or unlisted namespaced elements
4417 // check at runtime because it may get assigned a namespace when its
4418 // parent normalizes children
4420 tag
, data
, children
,
4421 undefined, undefined, context
4425 // direct component options / constructor
4426 vnode
= createComponent(tag
, data
, context
, children
);
4428 if (Array
.isArray(vnode
)) {
4430 } else if (isDef(vnode
)) {
4431 if (isDef(ns
)) { applyNS(vnode
, ns
); }
4432 if (isDef(data
)) { registerDeepBindings(data
); }
4435 return createEmptyVNode()
4439 function applyNS (vnode
, ns
, force
) {
4441 if (vnode
.tag
=== 'foreignObject') {
4442 // use default namespace inside foreignObject
4446 if (isDef(vnode
.children
)) {
4447 for (var i
= 0, l
= vnode
.children
.length
; i
< l
; i
++) {
4448 var child
= vnode
.children
[i
];
4449 if (isDef(child
.tag
) && (
4450 isUndef(child
.ns
) || (isTrue(force
) && child
.tag
!== 'svg'))) {
4451 applyNS(child
, ns
, force
);
4458 // necessary to ensure parent re-render when deep bindings like :style and
4459 // :class are used on slot nodes
4460 function registerDeepBindings (data
) {
4461 if (isObject(data
.style
)) {
4462 traverse(data
.style
);
4464 if (isObject(data
.class)) {
4465 traverse(data
.class);
4471 function initRender (vm
) {
4472 vm
._vnode
= null; // the root of the child tree
4473 vm
._staticTrees
= null; // v-once cached trees
4474 var options
= vm
.$options
;
4475 var parentVnode
= vm
.$vnode
= options
._parentVnode
; // the placeholder node in parent tree
4476 var renderContext
= parentVnode
&& parentVnode
.context
;
4477 vm
.$slots
= resolveSlots(options
._renderChildren
, renderContext
);
4478 vm
.$scopedSlots
= emptyObject
;
4479 // bind the createElement fn to this instance
4480 // so that we get proper render context inside it.
4481 // args order: tag, data, children, normalizationType, alwaysNormalize
4482 // internal version is used by render functions compiled from templates
4483 vm
._c = function (a
, b
, c
, d
) { return createElement(vm
, a
, b
, c
, d
, false); };
4484 // normalization is always applied for the public version, used in
4485 // user-written render functions.
4486 vm
.$createElement = function (a
, b
, c
, d
) { return createElement(vm
, a
, b
, c
, d
, true); };
4488 // $attrs & $listeners are exposed for easier HOC creation.
4489 // they need to be reactive so that HOCs using them are always updated
4490 var parentData
= parentVnode
&& parentVnode
.data
;
4492 /* istanbul ignore else */
4494 defineReactive(vm
, '$attrs', parentData
&& parentData
.attrs
|| emptyObject
, function () {
4495 !isUpdatingChildComponent
&& warn("$attrs is readonly.", vm
);
4497 defineReactive(vm
, '$listeners', options
._parentListeners
|| emptyObject
, function () {
4498 !isUpdatingChildComponent
&& warn("$listeners is readonly.", vm
);
4503 function renderMixin (Vue
) {
4504 // install runtime convenience helpers
4505 installRenderHelpers(Vue
.prototype);
4507 Vue
.prototype.$nextTick = function (fn
) {
4508 return nextTick(fn
, this)
4511 Vue
.prototype._render = function () {
4513 var ref
= vm
.$options
;
4514 var render
= ref
.render
;
4515 var _parentVnode
= ref
._parentVnode
;
4517 // reset _rendered flag on slots for duplicate slot check
4519 for (var key
in vm
.$slots
) {
4520 // $flow-disable-line
4521 vm
.$slots
[key
]._rendered
= false;
4526 vm
.$scopedSlots
= _parentVnode
.data
.scopedSlots
|| emptyObject
;
4529 // set parent vnode. this allows render functions to have access
4530 // to the data on the placeholder node.
4531 vm
.$vnode
= _parentVnode
;
4535 vnode
= render
.call(vm
._renderProxy
, vm
.$createElement
);
4537 handleError(e
, vm
, "render");
4538 // return error render result,
4539 // or previous vnode to prevent render error causing blank component
4540 /* istanbul ignore else */
4542 if (vm
.$options
.renderError
) {
4544 vnode
= vm
.$options
.renderError
.call(vm
._renderProxy
, vm
.$createElement
, e
);
4546 handleError(e
, vm
, "renderError");
4554 // return empty vnode in case the render function errored out
4555 if (!(vnode
instanceof VNode
)) {
4556 if ("development" !== 'production' && Array
.isArray(vnode
)) {
4558 'Multiple root nodes returned from render function. Render function ' +
4559 'should return a single root node.',
4563 vnode
= createEmptyVNode();
4566 vnode
.parent
= _parentVnode
;
4575 function initMixin (Vue
) {
4576 Vue
.prototype._init = function (options
) {
4581 var startTag
, endTag
;
4582 /* istanbul ignore if */
4583 if ("development" !== 'production' && config
.performance
&& mark
) {
4584 startTag
= "vue-perf-start:" + (vm
._uid
);
4585 endTag
= "vue-perf-end:" + (vm
._uid
);
4589 // a flag to avoid this being observed
4592 if (options
&& options
._isComponent
) {
4593 // optimize internal component instantiation
4594 // since dynamic options merging is pretty slow, and none of the
4595 // internal component options needs special treatment.
4596 initInternalComponent(vm
, options
);
4598 vm
.$options
= mergeOptions(
4599 resolveConstructorOptions(vm
.constructor),
4604 /* istanbul ignore else */
4613 callHook(vm
, 'beforeCreate');
4614 initInjections(vm
); // resolve injections before data/props
4616 initProvide(vm
); // resolve provide after data/props
4617 callHook(vm
, 'created');
4619 /* istanbul ignore if */
4620 if ("development" !== 'production' && config
.performance
&& mark
) {
4621 vm
._name
= formatComponentName(vm
, false);
4623 measure(("vue " + (vm
._name
) + " init"), startTag
, endTag
);
4626 if (vm
.$options
.el
) {
4627 vm
.$mount(vm
.$options
.el
);
4632 function initInternalComponent (vm
, options
) {
4633 var opts
= vm
.$options
= Object
.create(vm
.constructor.options
);
4634 // doing this because it's faster than dynamic enumeration.
4635 var parentVnode
= options
._parentVnode
;
4636 opts
.parent
= options
.parent
;
4637 opts
._parentVnode
= parentVnode
;
4638 opts
._parentElm
= options
._parentElm
;
4639 opts
._refElm
= options
._refElm
;
4641 var vnodeComponentOptions
= parentVnode
.componentOptions
;
4642 opts
.propsData
= vnodeComponentOptions
.propsData
;
4643 opts
._parentListeners
= vnodeComponentOptions
.listeners
;
4644 opts
._renderChildren
= vnodeComponentOptions
.children
;
4645 opts
._componentTag
= vnodeComponentOptions
.tag
;
4647 if (options
.render
) {
4648 opts
.render
= options
.render
;
4649 opts
.staticRenderFns
= options
.staticRenderFns
;
4653 function resolveConstructorOptions (Ctor
) {
4654 var options
= Ctor
.options
;
4656 var superOptions
= resolveConstructorOptions(Ctor
.super);
4657 var cachedSuperOptions
= Ctor
.superOptions
;
4658 if (superOptions
!== cachedSuperOptions
) {
4659 // super option changed,
4660 // need to resolve new options.
4661 Ctor
.superOptions
= superOptions
;
4662 // check if there are any late-modified/attached options (#4976)
4663 var modifiedOptions
= resolveModifiedOptions(Ctor
);
4664 // update base extend options
4665 if (modifiedOptions
) {
4666 extend(Ctor
.extendOptions
, modifiedOptions
);
4668 options
= Ctor
.options
= mergeOptions(superOptions
, Ctor
.extendOptions
);
4670 options
.components
[options
.name
] = Ctor
;
4677 function resolveModifiedOptions (Ctor
) {
4679 var latest
= Ctor
.options
;
4680 var extended
= Ctor
.extendOptions
;
4681 var sealed
= Ctor
.sealedOptions
;
4682 for (var key
in latest
) {
4683 if (latest
[key
] !== sealed
[key
]) {
4684 if (!modified
) { modified
= {}; }
4685 modified
[key
] = dedupe(latest
[key
], extended
[key
], sealed
[key
]);
4691 function dedupe (latest
, extended
, sealed
) {
4692 // compare latest and sealed to ensure lifecycle hooks won't be duplicated
4694 if (Array
.isArray(latest
)) {
4696 sealed
= Array
.isArray(sealed
) ? sealed : [sealed
];
4697 extended
= Array
.isArray(extended
) ? extended : [extended
];
4698 for (var i
= 0; i
< latest
.length
; i
++) {
4699 // push original options and not sealed options to exclude duplicated options
4700 if (extended
.indexOf(latest
[i
]) >= 0 || sealed
.indexOf(latest
[i
]) < 0) {
4701 res
.push(latest
[i
]);
4710 function Vue (options
) {
4711 if ("development" !== 'production' &&
4712 !(this instanceof Vue
)
4714 warn('Vue is a constructor and should be called with the `new` keyword');
4716 this._init(options
);
4722 lifecycleMixin(Vue
);
4727 function initUse (Vue
) {
4728 Vue
.use = function (plugin
) {
4729 var installedPlugins
= (this._installedPlugins
|| (this._installedPlugins
= []));
4730 if (installedPlugins
.indexOf(plugin
) > -1) {
4734 // additional parameters
4735 var args
= toArray(arguments
, 1);
4737 if (typeof plugin
.install
=== 'function') {
4738 plugin
.install
.apply(plugin
, args
);
4739 } else if (typeof plugin
=== 'function') {
4740 plugin
.apply(null, args
);
4742 installedPlugins
.push(plugin
);
4749 function initMixin
$1 (Vue
) {
4750 Vue
.mixin = function (mixin
) {
4751 this.options
= mergeOptions(this.options
, mixin
);
4758 function initExtend (Vue
) {
4760 * Each instance constructor, including Vue, has a unique
4761 * cid. This enables us to create wrapped "child
4762 * constructors" for prototypal inheritance and cache them.
4770 Vue
.extend = function (extendOptions
) {
4771 extendOptions
= extendOptions
|| {};
4773 var SuperId
= Super
.cid
;
4774 var cachedCtors
= extendOptions
._Ctor
|| (extendOptions
._Ctor
= {});
4775 if (cachedCtors
[SuperId
]) {
4776 return cachedCtors
[SuperId
]
4779 var name
= extendOptions
.name
|| Super
.options
.name
;
4780 if ("development" !== 'production' && name
) {
4781 validateComponentName(name
);
4784 var Sub
= function VueComponent (options
) {
4785 this._init(options
);
4787 Sub
.prototype = Object
.create(Super
.prototype);
4788 Sub
.prototype.constructor = Sub
;
4790 Sub
.options
= mergeOptions(
4794 Sub
['super'] = Super
;
4796 // For props and computed properties, we define the proxy getters on
4797 // the Vue instances at extension time, on the extended prototype. This
4798 // avoids Object.defineProperty calls for each instance created.
4799 if (Sub
.options
.props
) {
4802 if (Sub
.options
.computed
) {
4803 initComputed
$1(Sub
);
4806 // allow further extension/mixin/plugin usage
4807 Sub
.extend
= Super
.extend
;
4808 Sub
.mixin
= Super
.mixin
;
4809 Sub
.use = Super
.use;
4811 // create asset registers, so extended classes
4812 // can have their private assets too.
4813 ASSET_TYPES
.forEach(function (type
) {
4814 Sub
[type
] = Super
[type
];
4816 // enable recursive self-lookup
4818 Sub
.options
.components
[name
] = Sub
;
4821 // keep a reference to the super options at extension time.
4822 // later at instantiation we can check if Super's options have
4824 Sub
.superOptions
= Super
.options
;
4825 Sub
.extendOptions
= extendOptions
;
4826 Sub
.sealedOptions
= extend({}, Sub
.options
);
4828 // cache constructor
4829 cachedCtors
[SuperId
] = Sub
;
4834 function initProps
$1 (Comp
) {
4835 var props
= Comp
.options
.props
;
4836 for (var key
in props
) {
4837 proxy(Comp
.prototype, "_props", key
);
4841 function initComputed
$1 (Comp
) {
4842 var computed
= Comp
.options
.computed
;
4843 for (var key
in computed
) {
4844 defineComputed(Comp
.prototype, key
, computed
[key
]);
4850 function initAssetRegisters (Vue
) {
4852 * Create asset registration methods.
4854 ASSET_TYPES
.forEach(function (type
) {
4855 Vue
[type
] = function (
4860 return this.options
[type
+ 's'][id
]
4862 /* istanbul ignore if */
4863 if ("development" !== 'production' && type
=== 'component') {
4864 validateComponentName(id
);
4866 if (type
=== 'component' && isPlainObject(definition
)) {
4867 definition
.name
= definition
.name
|| id
;
4868 definition
= this.options
._base
.extend(definition
);
4870 if (type
=== 'directive' && typeof definition
=== 'function') {
4871 definition
= { bind: definition
, update: definition
};
4873 this.options
[type
+ 's'][id
] = definition
;
4882 function getComponentName (opts
) {
4883 return opts
&& (opts
.Ctor
.options
.name
|| opts
.tag
)
4886 function matches (pattern
, name
) {
4887 if (Array
.isArray(pattern
)) {
4888 return pattern
.indexOf(name
) > -1
4889 } else if (typeof pattern
=== 'string') {
4890 return pattern
.split(',').indexOf(name
) > -1
4891 } else if (isRegExp(pattern
)) {
4892 return pattern
.test(name
)
4894 /* istanbul ignore next */
4898 function pruneCache (keepAliveInstance
, filter
) {
4899 var cache
= keepAliveInstance
.cache
;
4900 var keys
= keepAliveInstance
.keys
;
4901 var _vnode
= keepAliveInstance
._vnode
;
4902 for (var key
in cache
) {
4903 var cachedNode
= cache
[key
];
4905 var name
= getComponentName(cachedNode
.componentOptions
);
4906 if (name
&& !filter(name
)) {
4907 pruneCacheEntry(cache
, key
, keys
, _vnode
);
4913 function pruneCacheEntry (
4919 var cached
$$1 = cache
[key
];
4920 if (cached
$$1 && (!current
|| cached
$$1.tag
!== current
.tag
)) {
4921 cached
$$1.componentInstance
.$destroy();
4927 var patternTypes
= [String
, RegExp
, Array
];
4934 include: patternTypes
,
4935 exclude: patternTypes
,
4936 max: [String
, Number
]
4939 created: function created () {
4940 this.cache
= Object
.create(null);
4944 destroyed: function destroyed () {
4947 for (var key
in this$1.cache
) {
4948 pruneCacheEntry(this$1.cache
, key
, this$1.keys
);
4952 mounted: function mounted () {
4955 this.$watch('include', function (val
) {
4956 pruneCache(this$1, function (name
) { return matches(val
, name
); });
4958 this.$watch('exclude', function (val
) {
4959 pruneCache(this$1, function (name
) { return !matches(val
, name
); });
4963 render: function render () {
4964 var slot
= this.$slots
.default;
4965 var vnode
= getFirstComponentChild(slot
);
4966 var componentOptions
= vnode
&& vnode
.componentOptions
;
4967 if (componentOptions
) {
4969 var name
= getComponentName(componentOptions
);
4971 var include
= ref
.include
;
4972 var exclude
= ref
.exclude
;
4975 (include
&& (!name
|| !matches(include
, name
))) ||
4977 (exclude
&& name
&& matches(exclude
, name
))
4983 var cache
= ref
$1.cache
;
4984 var keys
= ref
$1.keys
;
4985 var key
= vnode
.key
== null
4986 // same constructor may get registered as different local components
4987 // so cid alone is not enough (#3269)
4988 ? componentOptions
.Ctor
.cid
+ (componentOptions
.tag
? ("::" + (componentOptions
.tag
)) : '')
4991 vnode
.componentInstance
= cache
[key
].componentInstance
;
4992 // make current key freshest
4998 // prune oldest entry
4999 if (this.max
&& keys
.length
> parseInt(this.max
)) {
5000 pruneCacheEntry(cache
, keys
[0], keys
, this._vnode
);
5004 vnode
.data
.keepAlive
= true;
5006 return vnode
|| (slot
&& slot
[0])
5010 var builtInComponents
= {
5011 KeepAlive: KeepAlive
5016 function initGlobalAPI (Vue
) {
5019 configDef
.get = function () { return config
; };
5021 configDef
.set = function () {
5023 'Do not replace the Vue.config object, set individual fields instead.'
5027 Object
.defineProperty(Vue
, 'config', configDef
);
5029 // exposed util methods.
5030 // NOTE: these are not considered part of the public API - avoid relying on
5031 // them unless you are aware of the risk.
5035 mergeOptions: mergeOptions
,
5036 defineReactive: defineReactive
5041 Vue
.nextTick
= nextTick
;
5043 Vue
.options
= Object
.create(null);
5044 ASSET_TYPES
.forEach(function (type
) {
5045 Vue
.options
[type
+ 's'] = Object
.create(null);
5048 // this is used to identify the "base" constructor to extend all plain-object
5049 // components with in Weex's multi-instance scenarios.
5050 Vue
.options
._base
= Vue
;
5052 extend(Vue
.options
.components
, builtInComponents
);
5057 initAssetRegisters(Vue
);
5062 Object
.defineProperty(Vue
.prototype, '$isServer', {
5063 get: isServerRendering
5066 Object
.defineProperty(Vue
.prototype, '$ssrContext', {
5067 get: function get () {
5068 /* istanbul ignore next */
5069 return this.$vnode
&& this.$vnode
.ssrContext
5073 // expose FunctionalRenderContext for ssr runtime helper installation
5074 Object
.defineProperty(Vue
, 'FunctionalRenderContext', {
5075 value: FunctionalRenderContext
5078 Vue
.version
= '2.5.16';
5082 // these are reserved for web because they are directly compiled away
5083 // during template compilation
5084 var isReservedAttr
= makeMap('style,class');
5086 // attributes that should be using props for binding
5087 var acceptValue
= makeMap('input,textarea,option,select,progress');
5088 var mustUseProp = function (tag
, type
, attr
) {
5090 (attr
=== 'value' && acceptValue(tag
)) && type
!== 'button' ||
5091 (attr
=== 'selected' && tag
=== 'option') ||
5092 (attr
=== 'checked' && tag
=== 'input') ||
5093 (attr
=== 'muted' && tag
=== 'video')
5097 var isEnumeratedAttr
= makeMap('contenteditable,draggable,spellcheck');
5099 var isBooleanAttr
= makeMap(
5100 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
5101 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
5102 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
5103 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
5104 'required,reversed,scoped,seamless,selected,sortable,translate,' +
5105 'truespeed,typemustmatch,visible'
5108 var xlinkNS
= 'http://www.w3.org/1999/xlink';
5110 var isXlink = function (name
) {
5111 return name
.charAt(5) === ':' && name
.slice(0, 5) === 'xlink'
5114 var getXlinkProp = function (name
) {
5115 return isXlink(name
) ? name
.slice(6, name
.length
) : ''
5118 var isFalsyAttrValue = function (val
) {
5119 return val
== null || val
=== false
5124 function genClassForVnode (vnode
) {
5125 var data
= vnode
.data
;
5126 var parentNode
= vnode
;
5127 var childNode
= vnode
;
5128 while (isDef(childNode
.componentInstance
)) {
5129 childNode
= childNode
.componentInstance
._vnode
;
5130 if (childNode
&& childNode
.data
) {
5131 data
= mergeClassData(childNode
.data
, data
);
5134 while (isDef(parentNode
= parentNode
.parent
)) {
5135 if (parentNode
&& parentNode
.data
) {
5136 data
= mergeClassData(data
, parentNode
.data
);
5139 return renderClass(data
.staticClass
, data
.class)
5142 function mergeClassData (child
, parent
) {
5144 staticClass: concat(child
.staticClass
, parent
.staticClass
),
5145 class: isDef(child
.class)
5146 ? [child
.class, parent
.class]
5151 function renderClass (
5155 if (isDef(staticClass
) || isDef(dynamicClass
)) {
5156 return concat(staticClass
, stringifyClass(dynamicClass
))
5158 /* istanbul ignore next */
5162 function concat (a
, b
) {
5163 return a
? b
? (a
+ ' ' + b
) : a : (b
|| '')
5166 function stringifyClass (value
) {
5167 if (Array
.isArray(value
)) {
5168 return stringifyArray(value
)
5170 if (isObject(value
)) {
5171 return stringifyObject(value
)
5173 if (typeof value
=== 'string') {
5176 /* istanbul ignore next */
5180 function stringifyArray (value
) {
5183 for (var i
= 0, l
= value
.length
; i
< l
; i
++) {
5184 if (isDef(stringified
= stringifyClass(value
[i
])) && stringified
!== '') {
5185 if (res
) { res
+= ' '; }
5192 function stringifyObject (value
) {
5194 for (var key
in value
) {
5196 if (res
) { res
+= ' '; }
5205 var namespaceMap
= {
5206 svg: 'http://www.w3.org/2000/svg',
5207 math: 'http://www.w3.org/1998/Math/MathML'
5210 var isHTMLTag
= makeMap(
5211 'html,body,base,head,link,meta,style,title,' +
5212 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
5213 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
5214 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
5215 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' +
5216 'embed,object,param,source,canvas,script,noscript,del,ins,' +
5217 'caption,col,colgroup,table,thead,tbody,td,th,tr,' +
5218 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
5219 'output,progress,select,textarea,' +
5220 'details,dialog,menu,menuitem,summary,' +
5221 'content,element,shadow,template,blockquote,iframe,tfoot'
5224 // this map is intentionally selective, only covering SVG elements that may
5225 // contain child elements.
5226 var isSVG
= makeMap(
5227 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
5228 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
5229 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
5233 var isPreTag = function (tag
) { return tag
=== 'pre'; };
5235 var isReservedTag = function (tag
) {
5236 return isHTMLTag(tag
) || isSVG(tag
)
5239 function getTagNamespace (tag
) {
5243 // basic support for MathML
5244 // note it doesn't support other MathML elements being component roots
5245 if (tag
=== 'math') {
5250 var unknownElementCache
= Object
.create(null);
5251 function isUnknownElement (tag
) {
5252 /* istanbul ignore if */
5256 if (isReservedTag(tag
)) {
5259 tag
= tag
.toLowerCase();
5260 /* istanbul ignore if */
5261 if (unknownElementCache
[tag
] != null) {
5262 return unknownElementCache
[tag
]
5264 var el
= document
.createElement(tag
);
5265 if (tag
.indexOf('-') > -1) {
5266 // http://stackoverflow.com/a/28210364/1070244
5267 return (unknownElementCache
[tag
] = (
5268 el
.constructor === window
.HTMLUnknownElement
||
5269 el
.constructor === window
.HTMLElement
5272 return (unknownElementCache
[tag
] = /HTMLUnknownElement/.test(el
.toString()))
5276 var isTextInputType
= makeMap('text,number,password,search,email,tel,url');
5281 * Query an element selector if it's not an element already.
5283 function query (el
) {
5284 if (typeof el
=== 'string') {
5285 var selected
= document
.querySelector(el
);
5287 "development" !== 'production' && warn(
5288 'Cannot find element: ' + el
5290 return document
.createElement('div')
5300 function createElement
$1 (tagName
, vnode
) {
5301 var elm
= document
.createElement(tagName
);
5302 if (tagName
!== 'select') {
5305 // false or null will remove the attribute but undefined will not
5306 if (vnode
.data
&& vnode
.data
.attrs
&& vnode
.data
.attrs
.multiple
!== undefined) {
5307 elm
.setAttribute('multiple', 'multiple');
5312 function createElementNS (namespace, tagName
) {
5313 return document
.createElementNS(namespaceMap
[namespace], tagName
)
5316 function createTextNode (text
) {
5317 return document
.createTextNode(text
)
5320 function createComment (text
) {
5321 return document
.createComment(text
)
5324 function insertBefore (parentNode
, newNode
, referenceNode
) {
5325 parentNode
.insertBefore(newNode
, referenceNode
);
5328 function removeChild (node
, child
) {
5329 node
.removeChild(child
);
5332 function appendChild (node
, child
) {
5333 node
.appendChild(child
);
5336 function parentNode (node
) {
5337 return node
.parentNode
5340 function nextSibling (node
) {
5341 return node
.nextSibling
5344 function tagName (node
) {
5348 function setTextContent (node
, text
) {
5349 node
.textContent
= text
;
5352 function setStyleScope (node
, scopeId
) {
5353 node
.setAttribute(scopeId
, '');
5357 var nodeOps
= Object
.freeze({
5358 createElement: createElement
$1,
5359 createElementNS: createElementNS
,
5360 createTextNode: createTextNode
,
5361 createComment: createComment
,
5362 insertBefore: insertBefore
,
5363 removeChild: removeChild
,
5364 appendChild: appendChild
,
5365 parentNode: parentNode
,
5366 nextSibling: nextSibling
,
5368 setTextContent: setTextContent
,
5369 setStyleScope: setStyleScope
5375 create: function create (_
, vnode
) {
5378 update: function update (oldVnode
, vnode
) {
5379 if (oldVnode
.data
.ref
!== vnode
.data
.ref
) {
5380 registerRef(oldVnode
, true);
5384 destroy: function destroy (vnode
) {
5385 registerRef(vnode
, true);
5389 function registerRef (vnode
, isRemoval
) {
5390 var key
= vnode
.data
.ref
;
5391 if (!isDef(key
)) { return }
5393 var vm
= vnode
.context
;
5394 var ref
= vnode
.componentInstance
|| vnode
.elm
;
5395 var refs
= vm
.$refs
;
5397 if (Array
.isArray(refs
[key
])) {
5398 remove(refs
[key
], ref
);
5399 } else if (refs
[key
] === ref
) {
5400 refs
[key
] = undefined;
5403 if (vnode
.data
.refInFor
) {
5404 if (!Array
.isArray(refs
[key
])) {
5406 } else if (refs
[key
].indexOf(ref
) < 0) {
5407 // $flow-disable-line
5408 refs
[key
].push(ref
);
5417 * Virtual DOM patching algorithm based on Snabbdom by
5418 * Simon Friis Vindum (@paldepind)
5419 * Licensed under the MIT License
5420 * https://github.com/paldepind/snabbdom/blob/master/LICENSE
5422 * modified by Evan You (@yyx990803)
5424 * Not type-checking this because this file is perf-critical and the cost
5425 * of making flow understand it is not worth it.
5428 var emptyNode
= new VNode('', {}, []);
5430 var hooks
= ['create', 'activate', 'update', 'remove', 'destroy'];
5432 function sameVnode (a
, b
) {
5434 a
.key
=== b
.key
&& (
5437 a
.isComment
=== b
.isComment
&&
5438 isDef(a
.data
) === isDef(b
.data
) &&
5441 isTrue(a
.isAsyncPlaceholder
) &&
5442 a
.asyncFactory
=== b
.asyncFactory
&&
5443 isUndef(b
.asyncFactory
.error
)
5449 function sameInputType (a
, b
) {
5450 if (a
.tag
!== 'input') { return true }
5452 var typeA
= isDef(i
= a
.data
) && isDef(i
= i
.attrs
) && i
.type
;
5453 var typeB
= isDef(i
= b
.data
) && isDef(i
= i
.attrs
) && i
.type
;
5454 return typeA
=== typeB
|| isTextInputType(typeA
) && isTextInputType(typeB
)
5457 function createKeyToOldIdx (children
, beginIdx
, endIdx
) {
5460 for (i
= beginIdx
; i
<= endIdx
; ++i
) {
5461 key
= children
[i
].key
;
5462 if (isDef(key
)) { map
[key
] = i
; }
5467 function createPatchFunction (backend
) {
5471 var modules
= backend
.modules
;
5472 var nodeOps
= backend
.nodeOps
;
5474 for (i
= 0; i
< hooks
.length
; ++i
) {
5476 for (j
= 0; j
< modules
.length
; ++j
) {
5477 if (isDef(modules
[j
][hooks
[i
]])) {
5478 cbs
[hooks
[i
]].push(modules
[j
][hooks
[i
]]);
5483 function emptyNodeAt (elm
) {
5484 return new VNode(nodeOps
.tagName(elm
).toLowerCase(), {}, [], undefined, elm
)
5487 function createRmCb (childElm
, listeners
) {
5488 function remove () {
5489 if (--remove
.listeners
=== 0) {
5490 removeNode(childElm
);
5493 remove
.listeners
= listeners
;
5497 function removeNode (el
) {
5498 var parent
= nodeOps
.parentNode(el
);
5499 // element may have already been removed due to v-html / v-text
5500 if (isDef(parent
)) {
5501 nodeOps
.removeChild(parent
, el
);
5505 function isUnknownElement
$$1 (vnode
, inVPre
) {
5510 config
.ignoredElements
.length
&&
5511 config
.ignoredElements
.some(function (ignore
) {
5512 return isRegExp(ignore
)
5513 ? ignore
.test(vnode
.tag
)
5514 : ignore
=== vnode
.tag
5517 config
.isUnknownElement(vnode
.tag
)
5521 var creatingElmInVPre
= 0;
5523 function createElm (
5532 if (isDef(vnode
.elm
) && isDef(ownerArray
)) {
5533 // This vnode was used in a previous render!
5534 // now it's used as a new node, overwriting its elm would cause
5535 // potential patch errors down the road when it's used as an insertion
5536 // reference node. Instead, we clone the node on-demand before creating
5537 // associated DOM element for it.
5538 vnode
= ownerArray
[index
] = cloneVNode(vnode
);
5541 vnode
.isRootInsert
= !nested
; // for transition enter check
5542 if (createComponent(vnode
, insertedVnodeQueue
, parentElm
, refElm
)) {
5546 var data
= vnode
.data
;
5547 var children
= vnode
.children
;
5548 var tag
= vnode
.tag
;
5551 if (data
&& data
.pre
) {
5552 creatingElmInVPre
++;
5554 if (isUnknownElement
$$1(vnode
, creatingElmInVPre
)) {
5556 'Unknown custom element: <' + tag
+ '> - did you ' +
5557 'register the component correctly? For recursive components, ' +
5558 'make sure to provide the "name" option.',
5564 vnode
.elm
= vnode
.ns
5565 ? nodeOps
.createElementNS(vnode
.ns
, tag
)
5566 : nodeOps
.createElement(tag
, vnode
);
5569 /* istanbul ignore if */
5571 createChildren(vnode
, children
, insertedVnodeQueue
);
5573 invokeCreateHooks(vnode
, insertedVnodeQueue
);
5575 insert(parentElm
, vnode
.elm
, refElm
);
5578 if ("development" !== 'production' && data
&& data
.pre
) {
5579 creatingElmInVPre
--;
5581 } else if (isTrue(vnode
.isComment
)) {
5582 vnode
.elm
= nodeOps
.createComment(vnode
.text
);
5583 insert(parentElm
, vnode
.elm
, refElm
);
5585 vnode
.elm
= nodeOps
.createTextNode(vnode
.text
);
5586 insert(parentElm
, vnode
.elm
, refElm
);
5590 function createComponent (vnode
, insertedVnodeQueue
, parentElm
, refElm
) {
5593 var isReactivated
= isDef(vnode
.componentInstance
) && i
.keepAlive
;
5594 if (isDef(i
= i
.hook
) && isDef(i
= i
.init
)) {
5595 i(vnode
, false /* hydrating */, parentElm
, refElm
);
5597 // after calling the init hook, if the vnode is a child component
5598 // it should've created a child instance and mounted it. the child
5599 // component also has set the placeholder vnode's elm.
5600 // in that case we can just return the element and be done.
5601 if (isDef(vnode
.componentInstance
)) {
5602 initComponent(vnode
, insertedVnodeQueue
);
5603 if (isTrue(isReactivated
)) {
5604 reactivateComponent(vnode
, insertedVnodeQueue
, parentElm
, refElm
);
5611 function initComponent (vnode
, insertedVnodeQueue
) {
5612 if (isDef(vnode
.data
.pendingInsert
)) {
5613 insertedVnodeQueue
.push
.apply(insertedVnodeQueue
, vnode
.data
.pendingInsert
);
5614 vnode
.data
.pendingInsert
= null;
5616 vnode
.elm
= vnode
.componentInstance
.$el
;
5617 if (isPatchable(vnode
)) {
5618 invokeCreateHooks(vnode
, insertedVnodeQueue
);
5621 // empty component root.
5622 // skip all element-related modules except for ref (#3455)
5624 // make sure to invoke the insert hook
5625 insertedVnodeQueue
.push(vnode
);
5629 function reactivateComponent (vnode
, insertedVnodeQueue
, parentElm
, refElm
) {
5631 // hack for #4339: a reactivated component with inner transition
5632 // does not trigger because the inner node's created hooks are not called
5633 // again. It's not ideal to involve module-specific logic in here but
5634 // there doesn't seem to be a better way to do it.
5635 var innerNode
= vnode
;
5636 while (innerNode
.componentInstance
) {
5637 innerNode
= innerNode
.componentInstance
._vnode
;
5638 if (isDef(i
= innerNode
.data
) && isDef(i
= i
.transition
)) {
5639 for (i
= 0; i
< cbs
.activate
.length
; ++i
) {
5640 cbs
.activate
[i
](emptyNode
, innerNode
);
5642 insertedVnodeQueue
.push(innerNode
);
5646 // unlike a newly created component,
5647 // a reactivated keep-alive component doesn't insert itself
5648 insert(parentElm
, vnode
.elm
, refElm
);
5651 function insert (parent
, elm
, ref
$$1) {
5652 if (isDef(parent
)) {
5653 if (isDef(ref
$$1)) {
5654 if (ref
$$1.parentNode
=== parent
) {
5655 nodeOps
.insertBefore(parent
, elm
, ref
$$1);
5658 nodeOps
.appendChild(parent
, elm
);
5663 function createChildren (vnode
, children
, insertedVnodeQueue
) {
5664 if (Array
.isArray(children
)) {
5666 checkDuplicateKeys(children
);
5668 for (var i
= 0; i
< children
.length
; ++i
) {
5669 createElm(children
[i
], insertedVnodeQueue
, vnode
.elm
, null, true, children
, i
);
5671 } else if (isPrimitive(vnode
.text
)) {
5672 nodeOps
.appendChild(vnode
.elm
, nodeOps
.createTextNode(String(vnode
.text
)));
5676 function isPatchable (vnode
) {
5677 while (vnode
.componentInstance
) {
5678 vnode
= vnode
.componentInstance
._vnode
;
5680 return isDef(vnode
.tag
)
5683 function invokeCreateHooks (vnode
, insertedVnodeQueue
) {
5684 for (var i
$1 = 0; i
$1 < cbs
.create
.length
; ++i
$1) {
5685 cbs
.create
[i
$1](emptyNode
, vnode
);
5687 i
= vnode
.data
.hook
; // Reuse variable
5689 if (isDef(i
.create
)) { i
.create(emptyNode
, vnode
); }
5690 if (isDef(i
.insert
)) { insertedVnodeQueue
.push(vnode
); }
5694 // set scope id attribute for scoped CSS.
5695 // this is implemented as a special case to avoid the overhead
5696 // of going through the normal attribute patching process.
5697 function setScope (vnode
) {
5699 if (isDef(i
= vnode
.fnScopeId
)) {
5700 nodeOps
.setStyleScope(vnode
.elm
, i
);
5702 var ancestor
= vnode
;
5704 if (isDef(i
= ancestor
.context
) && isDef(i
= i
.$options
._scopeId
)) {
5705 nodeOps
.setStyleScope(vnode
.elm
, i
);
5707 ancestor
= ancestor
.parent
;
5710 // for slot content they should also get the scopeId from the host instance.
5711 if (isDef(i
= activeInstance
) &&
5712 i
!== vnode
.context
&&
5713 i
!== vnode
.fnContext
&&
5714 isDef(i
= i
.$options
._scopeId
)
5716 nodeOps
.setStyleScope(vnode
.elm
, i
);
5720 function addVnodes (parentElm
, refElm
, vnodes
, startIdx
, endIdx
, insertedVnodeQueue
) {
5721 for (; startIdx
<= endIdx
; ++startIdx
) {
5722 createElm(vnodes
[startIdx
], insertedVnodeQueue
, parentElm
, refElm
, false, vnodes
, startIdx
);
5726 function invokeDestroyHook (vnode
) {
5728 var data
= vnode
.data
;
5730 if (isDef(i
= data
.hook
) && isDef(i
= i
.destroy
)) { i(vnode
); }
5731 for (i
= 0; i
< cbs
.destroy
.length
; ++i
) { cbs
.destroy
[i
](vnode
); }
5733 if (isDef(i
= vnode
.children
)) {
5734 for (j
= 0; j
< vnode
.children
.length
; ++j
) {
5735 invokeDestroyHook(vnode
.children
[j
]);
5740 function removeVnodes (parentElm
, vnodes
, startIdx
, endIdx
) {
5741 for (; startIdx
<= endIdx
; ++startIdx
) {
5742 var ch
= vnodes
[startIdx
];
5744 if (isDef(ch
.tag
)) {
5745 removeAndInvokeRemoveHook(ch
);
5746 invokeDestroyHook(ch
);
5747 } else { // Text node
5754 function removeAndInvokeRemoveHook (vnode
, rm
) {
5755 if (isDef(rm
) || isDef(vnode
.data
)) {
5757 var listeners
= cbs
.remove
.length
+ 1;
5759 // we have a recursively passed down rm callback
5760 // increase the listeners count
5761 rm
.listeners
+= listeners
;
5763 // directly removing
5764 rm
= createRmCb(vnode
.elm
, listeners
);
5766 // recursively invoke hooks on child component root node
5767 if (isDef(i
= vnode
.componentInstance
) && isDef(i
= i
._vnode
) && isDef(i
.data
)) {
5768 removeAndInvokeRemoveHook(i
, rm
);
5770 for (i
= 0; i
< cbs
.remove
.length
; ++i
) {
5771 cbs
.remove
[i
](vnode
, rm
);
5773 if (isDef(i
= vnode
.data
.hook
) && isDef(i
= i
.remove
)) {
5779 removeNode(vnode
.elm
);
5783 function updateChildren (parentElm
, oldCh
, newCh
, insertedVnodeQueue
, removeOnly
) {
5784 var oldStartIdx
= 0;
5785 var newStartIdx
= 0;
5786 var oldEndIdx
= oldCh
.length
- 1;
5787 var oldStartVnode
= oldCh
[0];
5788 var oldEndVnode
= oldCh
[oldEndIdx
];
5789 var newEndIdx
= newCh
.length
- 1;
5790 var newStartVnode
= newCh
[0];
5791 var newEndVnode
= newCh
[newEndIdx
];
5792 var oldKeyToIdx
, idxInOld
, vnodeToMove
, refElm
;
5794 // removeOnly is a special flag used only by <transition-group>
5795 // to ensure removed elements stay in correct relative positions
5796 // during leaving transitions
5797 var canMove
= !removeOnly
;
5800 checkDuplicateKeys(newCh
);
5803 while (oldStartIdx
<= oldEndIdx
&& newStartIdx
<= newEndIdx
) {
5804 if (isUndef(oldStartVnode
)) {
5805 oldStartVnode
= oldCh
[++oldStartIdx
]; // Vnode has been moved left
5806 } else if (isUndef(oldEndVnode
)) {
5807 oldEndVnode
= oldCh
[--oldEndIdx
];
5808 } else if (sameVnode(oldStartVnode
, newStartVnode
)) {
5809 patchVnode(oldStartVnode
, newStartVnode
, insertedVnodeQueue
);
5810 oldStartVnode
= oldCh
[++oldStartIdx
];
5811 newStartVnode
= newCh
[++newStartIdx
];
5812 } else if (sameVnode(oldEndVnode
, newEndVnode
)) {
5813 patchVnode(oldEndVnode
, newEndVnode
, insertedVnodeQueue
);
5814 oldEndVnode
= oldCh
[--oldEndIdx
];
5815 newEndVnode
= newCh
[--newEndIdx
];
5816 } else if (sameVnode(oldStartVnode
, newEndVnode
)) { // Vnode moved right
5817 patchVnode(oldStartVnode
, newEndVnode
, insertedVnodeQueue
);
5818 canMove
&& nodeOps
.insertBefore(parentElm
, oldStartVnode
.elm
, nodeOps
.nextSibling(oldEndVnode
.elm
));
5819 oldStartVnode
= oldCh
[++oldStartIdx
];
5820 newEndVnode
= newCh
[--newEndIdx
];
5821 } else if (sameVnode(oldEndVnode
, newStartVnode
)) { // Vnode moved left
5822 patchVnode(oldEndVnode
, newStartVnode
, insertedVnodeQueue
);
5823 canMove
&& nodeOps
.insertBefore(parentElm
, oldEndVnode
.elm
, oldStartVnode
.elm
);
5824 oldEndVnode
= oldCh
[--oldEndIdx
];
5825 newStartVnode
= newCh
[++newStartIdx
];
5827 if (isUndef(oldKeyToIdx
)) { oldKeyToIdx
= createKeyToOldIdx(oldCh
, oldStartIdx
, oldEndIdx
); }
5828 idxInOld
= isDef(newStartVnode
.key
)
5829 ? oldKeyToIdx
[newStartVnode
.key
]
5830 : findIdxInOld(newStartVnode
, oldCh
, oldStartIdx
, oldEndIdx
);
5831 if (isUndef(idxInOld
)) { // New element
5832 createElm(newStartVnode
, insertedVnodeQueue
, parentElm
, oldStartVnode
.elm
, false, newCh
, newStartIdx
);
5834 vnodeToMove
= oldCh
[idxInOld
];
5835 if (sameVnode(vnodeToMove
, newStartVnode
)) {
5836 patchVnode(vnodeToMove
, newStartVnode
, insertedVnodeQueue
);
5837 oldCh
[idxInOld
] = undefined;
5838 canMove
&& nodeOps
.insertBefore(parentElm
, vnodeToMove
.elm
, oldStartVnode
.elm
);
5840 // same key but different element. treat as new element
5841 createElm(newStartVnode
, insertedVnodeQueue
, parentElm
, oldStartVnode
.elm
, false, newCh
, newStartIdx
);
5844 newStartVnode
= newCh
[++newStartIdx
];
5847 if (oldStartIdx
> oldEndIdx
) {
5848 refElm
= isUndef(newCh
[newEndIdx
+ 1]) ? null : newCh
[newEndIdx
+ 1].elm
;
5849 addVnodes(parentElm
, refElm
, newCh
, newStartIdx
, newEndIdx
, insertedVnodeQueue
);
5850 } else if (newStartIdx
> newEndIdx
) {
5851 removeVnodes(parentElm
, oldCh
, oldStartIdx
, oldEndIdx
);
5855 function checkDuplicateKeys (children
) {
5857 for (var i
= 0; i
< children
.length
; i
++) {
5858 var vnode
= children
[i
];
5859 var key
= vnode
.key
;
5861 if (seenKeys
[key
]) {
5863 ("Duplicate keys detected: '" + key
+ "'. This may cause an update error."),
5867 seenKeys
[key
] = true;
5873 function findIdxInOld (node
, oldCh
, start
, end
) {
5874 for (var i
= start
; i
< end
; i
++) {
5876 if (isDef(c
) && sameVnode(node
, c
)) { return i
}
5880 function patchVnode (oldVnode
, vnode
, insertedVnodeQueue
, removeOnly
) {
5881 if (oldVnode
=== vnode
) {
5885 var elm
= vnode
.elm
= oldVnode
.elm
;
5887 if (isTrue(oldVnode
.isAsyncPlaceholder
)) {
5888 if (isDef(vnode
.asyncFactory
.resolved
)) {
5889 hydrate(oldVnode
.elm
, vnode
, insertedVnodeQueue
);
5891 vnode
.isAsyncPlaceholder
= true;
5896 // reuse element for static trees.
5897 // note we only do this if the vnode is cloned -
5898 // if the new node is not cloned it means the render functions have been
5899 // reset by the hot-reload-api and we need to do a proper re-render.
5900 if (isTrue(vnode
.isStatic
) &&
5901 isTrue(oldVnode
.isStatic
) &&
5902 vnode
.key
=== oldVnode
.key
&&
5903 (isTrue(vnode
.isCloned
) || isTrue(vnode
.isOnce
))
5905 vnode
.componentInstance
= oldVnode
.componentInstance
;
5910 var data
= vnode
.data
;
5911 if (isDef(data
) && isDef(i
= data
.hook
) && isDef(i
= i
.prepatch
)) {
5915 var oldCh
= oldVnode
.children
;
5916 var ch
= vnode
.children
;
5917 if (isDef(data
) && isPatchable(vnode
)) {
5918 for (i
= 0; i
< cbs
.update
.length
; ++i
) { cbs
.update
[i
](oldVnode
, vnode
); }
5919 if (isDef(i
= data
.hook
) && isDef(i
= i
.update
)) { i(oldVnode
, vnode
); }
5921 if (isUndef(vnode
.text
)) {
5922 if (isDef(oldCh
) && isDef(ch
)) {
5923 if (oldCh
!== ch
) { updateChildren(elm
, oldCh
, ch
, insertedVnodeQueue
, removeOnly
); }
5924 } else if (isDef(ch
)) {
5925 if (isDef(oldVnode
.text
)) { nodeOps
.setTextContent(elm
, ''); }
5926 addVnodes(elm
, null, ch
, 0, ch
.length
- 1, insertedVnodeQueue
);
5927 } else if (isDef(oldCh
)) {
5928 removeVnodes(elm
, oldCh
, 0, oldCh
.length
- 1);
5929 } else if (isDef(oldVnode
.text
)) {
5930 nodeOps
.setTextContent(elm
, '');
5932 } else if (oldVnode
.text
!== vnode
.text
) {
5933 nodeOps
.setTextContent(elm
, vnode
.text
);
5936 if (isDef(i
= data
.hook
) && isDef(i
= i
.postpatch
)) { i(oldVnode
, vnode
); }
5940 function invokeInsertHook (vnode
, queue
, initial
) {
5941 // delay insert hooks for component root nodes, invoke them after the
5942 // element is really inserted
5943 if (isTrue(initial
) && isDef(vnode
.parent
)) {
5944 vnode
.parent
.data
.pendingInsert
= queue
;
5946 for (var i
= 0; i
< queue
.length
; ++i
) {
5947 queue
[i
].data
.hook
.insert(queue
[i
]);
5952 var hydrationBailed
= false;
5953 // list of modules that can skip create hook during hydration because they
5954 // are already rendered on the client or has no need for initialization
5955 // Note: style is excluded because it relies on initial clone for future
5956 // deep updates (#7063).
5957 var isRenderedModule
= makeMap('attrs,class,staticClass,staticStyle,key');
5959 // Note: this is a browser-only function so we can assume elms are DOM nodes.
5960 function hydrate (elm
, vnode
, insertedVnodeQueue
, inVPre
) {
5962 var tag
= vnode
.tag
;
5963 var data
= vnode
.data
;
5964 var children
= vnode
.children
;
5965 inVPre
= inVPre
|| (data
&& data
.pre
);
5968 if (isTrue(vnode
.isComment
) && isDef(vnode
.asyncFactory
)) {
5969 vnode
.isAsyncPlaceholder
= true;
5972 // assert node match
5974 if (!assertNodeMatch(elm
, vnode
, inVPre
)) {
5979 if (isDef(i
= data
.hook
) && isDef(i
= i
.init
)) { i(vnode
, true /* hydrating */); }
5980 if (isDef(i
= vnode
.componentInstance
)) {
5981 // child component. it should have hydrated its own tree.
5982 initComponent(vnode
, insertedVnodeQueue
);
5987 if (isDef(children
)) {
5988 // empty element, allow client to pick up and populate children
5989 if (!elm
.hasChildNodes()) {
5990 createChildren(vnode
, children
, insertedVnodeQueue
);
5992 // v-html and domProps: innerHTML
5993 if (isDef(i
= data
) && isDef(i
= i
.domProps
) && isDef(i
= i
.innerHTML
)) {
5994 if (i
!== elm
.innerHTML
) {
5995 /* istanbul ignore if */
5996 if ("development" !== 'production' &&
5997 typeof console
!== 'undefined' &&
6000 hydrationBailed
= true;
6001 console
.warn('Parent: ', elm
);
6002 console
.warn('server innerHTML: ', i
);
6003 console
.warn('client innerHTML: ', elm
.innerHTML
);
6008 // iterate and compare children lists
6009 var childrenMatch
= true;
6010 var childNode
= elm
.firstChild
;
6011 for (var i
$1 = 0; i
$1 < children
.length
; i
$1++) {
6012 if (!childNode
|| !hydrate(childNode
, children
[i
$1], insertedVnodeQueue
, inVPre
)) {
6013 childrenMatch
= false;
6016 childNode
= childNode
.nextSibling
;
6018 // if childNode is not null, it means the actual childNodes list is
6019 // longer than the virtual children list.
6020 if (!childrenMatch
|| childNode
) {
6021 /* istanbul ignore if */
6022 if ("development" !== 'production' &&
6023 typeof console
!== 'undefined' &&
6026 hydrationBailed
= true;
6027 console
.warn('Parent: ', elm
);
6028 console
.warn('Mismatching childNodes vs. VNodes: ', elm
.childNodes
, children
);
6036 var fullInvoke
= false;
6037 for (var key
in data
) {
6038 if (!isRenderedModule(key
)) {
6040 invokeCreateHooks(vnode
, insertedVnodeQueue
);
6044 if (!fullInvoke
&& data
['class']) {
6045 // ensure collecting deps for deep class bindings for future updates
6046 traverse(data
['class']);
6049 } else if (elm
.data
!== vnode
.text
) {
6050 elm
.data
= vnode
.text
;
6055 function assertNodeMatch (node
, vnode
, inVPre
) {
6056 if (isDef(vnode
.tag
)) {
6057 return vnode
.tag
.indexOf('vue-component') === 0 || (
6058 !isUnknownElement
$$1(vnode
, inVPre
) &&
6059 vnode
.tag
.toLowerCase() === (node
.tagName
&& node
.tagName
.toLowerCase())
6062 return node
.nodeType
=== (vnode
.isComment
? 8 : 3)
6066 return function patch (oldVnode
, vnode
, hydrating
, removeOnly
, parentElm
, refElm
) {
6067 if (isUndef(vnode
)) {
6068 if (isDef(oldVnode
)) { invokeDestroyHook(oldVnode
); }
6072 var isInitialPatch
= false;
6073 var insertedVnodeQueue
= [];
6075 if (isUndef(oldVnode
)) {
6076 // empty mount (likely as component), create new root element
6077 isInitialPatch
= true;
6078 createElm(vnode
, insertedVnodeQueue
, parentElm
, refElm
);
6080 var isRealElement
= isDef(oldVnode
.nodeType
);
6081 if (!isRealElement
&& sameVnode(oldVnode
, vnode
)) {
6082 // patch existing root node
6083 patchVnode(oldVnode
, vnode
, insertedVnodeQueue
, removeOnly
);
6085 if (isRealElement
) {
6086 // mounting to a real element
6087 // check if this is server-rendered content and if we can perform
6088 // a successful hydration.
6089 if (oldVnode
.nodeType
=== 1 && oldVnode
.hasAttribute(SSR_ATTR
)) {
6090 oldVnode
.removeAttribute(SSR_ATTR
);
6093 if (isTrue(hydrating
)) {
6094 if (hydrate(oldVnode
, vnode
, insertedVnodeQueue
)) {
6095 invokeInsertHook(vnode
, insertedVnodeQueue
, true);
6099 'The client-side rendered virtual DOM tree is not matching ' +
6100 'server-rendered content. This is likely caused by incorrect ' +
6101 'HTML markup, for example nesting block-level elements inside ' +
6102 '<p>, or missing <tbody>. Bailing hydration and performing ' +
6103 'full client-side render.'
6107 // either not server-rendered, or hydration failed.
6108 // create an empty node and replace it
6109 oldVnode
= emptyNodeAt(oldVnode
);
6112 // replacing existing element
6113 var oldElm
= oldVnode
.elm
;
6114 var parentElm
$1 = nodeOps
.parentNode(oldElm
);
6120 // extremely rare edge case: do not insert if old element is in a
6121 // leaving transition. Only happens when combining transition +
6122 // keep-alive + HOCs. (#4590)
6123 oldElm
._leaveCb
? null : parentElm
$1,
6124 nodeOps
.nextSibling(oldElm
)
6127 // update parent placeholder node element, recursively
6128 if (isDef(vnode
.parent
)) {
6129 var ancestor
= vnode
.parent
;
6130 var patchable
= isPatchable(vnode
);
6132 for (var i
= 0; i
< cbs
.destroy
.length
; ++i
) {
6133 cbs
.destroy
[i
](ancestor
);
6135 ancestor
.elm
= vnode
.elm
;
6137 for (var i
$1 = 0; i
$1 < cbs
.create
.length
; ++i
$1) {
6138 cbs
.create
[i
$1](emptyNode
, ancestor
);
6141 // invoke insert hooks that may have been merged by create hooks.
6142 // e.g. for directives that uses the "inserted" hook.
6143 var insert
= ancestor
.data
.hook
.insert
;
6144 if (insert
.merged
) {
6145 // start at index 1 to avoid re-invoking component mounted hook
6146 for (var i
$2 = 1; i
$2 < insert
.fns
.length
; i
$2++) {
6151 registerRef(ancestor
);
6153 ancestor
= ancestor
.parent
;
6158 if (isDef(parentElm
$1)) {
6159 removeVnodes(parentElm
$1, [oldVnode
], 0, 0);
6160 } else if (isDef(oldVnode
.tag
)) {
6161 invokeDestroyHook(oldVnode
);
6166 invokeInsertHook(vnode
, insertedVnodeQueue
, isInitialPatch
);
6174 create: updateDirectives
,
6175 update: updateDirectives
,
6176 destroy: function unbindDirectives (vnode
) {
6177 updateDirectives(vnode
, emptyNode
);
6181 function updateDirectives (oldVnode
, vnode
) {
6182 if (oldVnode
.data
.directives
|| vnode
.data
.directives
) {
6183 _update(oldVnode
, vnode
);
6187 function _update (oldVnode
, vnode
) {
6188 var isCreate
= oldVnode
=== emptyNode
;
6189 var isDestroy
= vnode
=== emptyNode
;
6190 var oldDirs
= normalizeDirectives
$1(oldVnode
.data
.directives
, oldVnode
.context
);
6191 var newDirs
= normalizeDirectives
$1(vnode
.data
.directives
, vnode
.context
);
6193 var dirsWithInsert
= [];
6194 var dirsWithPostpatch
= [];
6196 var key
, oldDir
, dir
;
6197 for (key
in newDirs
) {
6198 oldDir
= oldDirs
[key
];
6201 // new directive, bind
6202 callHook
$1(dir
, 'bind', vnode
, oldVnode
);
6203 if (dir
.def
&& dir
.def
.inserted
) {
6204 dirsWithInsert
.push(dir
);
6207 // existing directive, update
6208 dir
.oldValue
= oldDir
.value
;
6209 callHook
$1(dir
, 'update', vnode
, oldVnode
);
6210 if (dir
.def
&& dir
.def
.componentUpdated
) {
6211 dirsWithPostpatch
.push(dir
);
6216 if (dirsWithInsert
.length
) {
6217 var callInsert = function () {
6218 for (var i
= 0; i
< dirsWithInsert
.length
; i
++) {
6219 callHook
$1(dirsWithInsert
[i
], 'inserted', vnode
, oldVnode
);
6223 mergeVNodeHook(vnode
, 'insert', callInsert
);
6229 if (dirsWithPostpatch
.length
) {
6230 mergeVNodeHook(vnode
, 'postpatch', function () {
6231 for (var i
= 0; i
< dirsWithPostpatch
.length
; i
++) {
6232 callHook
$1(dirsWithPostpatch
[i
], 'componentUpdated', vnode
, oldVnode
);
6238 for (key
in oldDirs
) {
6239 if (!newDirs
[key
]) {
6240 // no longer present, unbind
6241 callHook
$1(oldDirs
[key
], 'unbind', oldVnode
, oldVnode
, isDestroy
);
6247 var emptyModifiers
= Object
.create(null);
6249 function normalizeDirectives
$1 (
6253 var res
= Object
.create(null);
6255 // $flow-disable-line
6259 for (i
= 0; i
< dirs
.length
; i
++) {
6261 if (!dir
.modifiers
) {
6262 // $flow-disable-line
6263 dir
.modifiers
= emptyModifiers
;
6265 res
[getRawDirName(dir
)] = dir
;
6266 dir
.def
= resolveAsset(vm
.$options
, 'directives', dir
.name
, true);
6268 // $flow-disable-line
6272 function getRawDirName (dir
) {
6273 return dir
.rawName
|| ((dir
.name
) + "." + (Object
.keys(dir
.modifiers
|| {}).join('.')))
6276 function callHook
$1 (dir
, hook
, vnode
, oldVnode
, isDestroy
) {
6277 var fn
= dir
.def
&& dir
.def
[hook
];
6280 fn(vnode
.elm
, dir
, vnode
, oldVnode
, isDestroy
);
6282 handleError(e
, vnode
.context
, ("directive " + (dir
.name
) + " " + hook
+ " hook"));
6294 function updateAttrs (oldVnode
, vnode
) {
6295 var opts
= vnode
.componentOptions
;
6296 if (isDef(opts
) && opts
.Ctor
.options
.inheritAttrs
=== false) {
6299 if (isUndef(oldVnode
.data
.attrs
) && isUndef(vnode
.data
.attrs
)) {
6303 var elm
= vnode
.elm
;
6304 var oldAttrs
= oldVnode
.data
.attrs
|| {};
6305 var attrs
= vnode
.data
.attrs
|| {};
6306 // clone observed objects, as the user probably wants to mutate it
6307 if (isDef(attrs
.__ob__
)) {
6308 attrs
= vnode
.data
.attrs
= extend({}, attrs
);
6311 for (key
in attrs
) {
6313 old
= oldAttrs
[key
];
6315 setAttr(elm
, key
, cur
);
6318 // #4391: in IE9, setting type can reset value for input[type=radio]
6319 // #6666: IE/Edge forces progress value down to 1 before setting a max
6320 /* istanbul ignore if */
6321 if ((isIE
|| isEdge
) && attrs
.value
!== oldAttrs
.value
) {
6322 setAttr(elm
, 'value', attrs
.value
);
6324 for (key
in oldAttrs
) {
6325 if (isUndef(attrs
[key
])) {
6327 elm
.removeAttributeNS(xlinkNS
, getXlinkProp(key
));
6328 } else if (!isEnumeratedAttr(key
)) {
6329 elm
.removeAttribute(key
);
6335 function setAttr (el
, key
, value
) {
6336 if (el
.tagName
.indexOf('-') > -1) {
6337 baseSetAttr(el
, key
, value
);
6338 } else if (isBooleanAttr(key
)) {
6339 // set attribute for blank value
6340 // e.g. <option disabled>Select one</option>
6341 if (isFalsyAttrValue(value
)) {
6342 el
.removeAttribute(key
);
6344 // technically allowfullscreen is a boolean attribute for <iframe>,
6345 // but Flash expects a value of "true" when used on <embed> tag
6346 value
= key
=== 'allowfullscreen' && el
.tagName
=== 'EMBED'
6349 el
.setAttribute(key
, value
);
6351 } else if (isEnumeratedAttr(key
)) {
6352 el
.setAttribute(key
, isFalsyAttrValue(value
) || value
=== 'false' ? 'false' : 'true');
6353 } else if (isXlink(key
)) {
6354 if (isFalsyAttrValue(value
)) {
6355 el
.removeAttributeNS(xlinkNS
, getXlinkProp(key
));
6357 el
.setAttributeNS(xlinkNS
, key
, value
);
6360 baseSetAttr(el
, key
, value
);
6364 function baseSetAttr (el
, key
, value
) {
6365 if (isFalsyAttrValue(value
)) {
6366 el
.removeAttribute(key
);
6368 // #7138: IE10 & 11 fires input event when setting placeholder on
6369 // <textarea>... block the first input event and remove the blocker
6371 /* istanbul ignore if */
6374 el
.tagName
=== 'TEXTAREA' &&
6375 key
=== 'placeholder' && !el
.__ieph
6377 var blocker = function (e
) {
6378 e
.stopImmediatePropagation();
6379 el
.removeEventListener('input', blocker
);
6381 el
.addEventListener('input', blocker
);
6382 // $flow-disable-line
6383 el
.__ieph
= true; /* IE placeholder patched */
6385 el
.setAttribute(key
, value
);
6390 create: updateAttrs
,
6396 function updateClass (oldVnode
, vnode
) {
6398 var data
= vnode
.data
;
6399 var oldData
= oldVnode
.data
;
6401 isUndef(data
.staticClass
) &&
6402 isUndef(data
.class) && (
6403 isUndef(oldData
) || (
6404 isUndef(oldData
.staticClass
) &&
6405 isUndef(oldData
.class)
6412 var cls
= genClassForVnode(vnode
);
6414 // handle transition classes
6415 var transitionClass
= el
._transitionClasses
;
6416 if (isDef(transitionClass
)) {
6417 cls
= concat(cls
, stringifyClass(transitionClass
));
6421 if (cls
!== el
._prevClass
) {
6422 el
.setAttribute('class', cls
);
6423 el
._prevClass
= cls
;
6428 create: updateClass
,
6434 var validDivisionCharRE
= /[\w).+\-_$\]]/;
6436 function parseFilters (exp
) {
6437 var inSingle
= false;
6438 var inDouble
= false;
6439 var inTemplateString
= false;
6440 var inRegex
= false;
6444 var lastFilterIndex
= 0;
6445 var c
, prev
, i
, expression
, filters
;
6447 for (i
= 0; i
< exp
.length
; i
++) {
6449 c
= exp
.charCodeAt(i
);
6451 if (c
=== 0x27 && prev
!== 0x5C) { inSingle
= false; }
6452 } else if (inDouble
) {
6453 if (c
=== 0x22 && prev
!== 0x5C) { inDouble
= false; }
6454 } else if (inTemplateString
) {
6455 if (c
=== 0x60 && prev
!== 0x5C) { inTemplateString
= false; }
6456 } else if (inRegex
) {
6457 if (c
=== 0x2f && prev
!== 0x5C) { inRegex
= false; }
6459 c
=== 0x7C && // pipe
6460 exp
.charCodeAt(i
+ 1) !== 0x7C &&
6461 exp
.charCodeAt(i
- 1) !== 0x7C &&
6462 !curly
&& !square
&& !paren
6464 if (expression
=== undefined) {
6465 // first filter, end of expression
6466 lastFilterIndex
= i
+ 1;
6467 expression
= exp
.slice(0, i
).trim();
6473 case 0x22: inDouble
= true; break // "
6474 case 0x27: inSingle
= true; break // '
6475 case 0x60: inTemplateString
= true; break // `
6476 case 0x28: paren
++; break // (
6477 case 0x29: paren
--; break // )
6478 case 0x5B: square
++; break // [
6479 case 0x5D: square
--; break // ]
6480 case 0x7B: curly
++; break // {
6481 case 0x7D: curly
--; break // }
6483 if (c
=== 0x2f) { // /
6486 // find first non-whitespace prev char
6487 for (; j
>= 0; j
--) {
6489 if (p
!== ' ') { break }
6491 if (!p
|| !validDivisionCharRE
.test(p
)) {
6498 if (expression
=== undefined) {
6499 expression
= exp
.slice(0, i
).trim();
6500 } else if (lastFilterIndex
!== 0) {
6504 function pushFilter () {
6505 (filters
|| (filters
= [])).push(exp
.slice(lastFilterIndex
, i
).trim());
6506 lastFilterIndex
= i
+ 1;
6510 for (i
= 0; i
< filters
.length
; i
++) {
6511 expression
= wrapFilter(expression
, filters
[i
]);
6518 function wrapFilter (exp
, filter
) {
6519 var i
= filter
.indexOf('(');
6521 // _f: resolveFilter
6522 return ("_f(\"" + filter
+ "\")(" + exp
+ ")")
6524 var name
= filter
.slice(0, i
);
6525 var args
= filter
.slice(i
+ 1);
6526 return ("_f(\"" + name
+ "\")(" + exp
+ (args
!== ')' ? ',' + args : args
))
6532 function baseWarn (msg
) {
6533 console
.error(("[Vue compiler]: " + msg
));
6536 function pluckModuleFunction (
6541 ? modules
.map(function (m
) { return m
[key
]; }).filter(function (_
) { return _
; })
6545 function addProp (el
, name
, value
) {
6546 (el
.props
|| (el
.props
= [])).push({ name: name
, value: value
});
6550 function addAttr (el
, name
, value
) {
6551 (el
.attrs
|| (el
.attrs
= [])).push({ name: name
, value: value
});
6555 // add a raw attr (use this in preTransforms)
6556 function addRawAttr (el
, name
, value
) {
6557 el
.attrsMap
[name
] = value
;
6558 el
.attrsList
.push({ name: name
, value: value
});
6561 function addDirective (
6569 (el
.directives
|| (el
.directives
= [])).push({ name: name
, rawName: rawName
, value: value
, arg: arg
, modifiers: modifiers
});
6573 function addHandler (
6581 modifiers
= modifiers
|| emptyObject
;
6582 // warn prevent and passive modifier
6583 /* istanbul ignore if */
6585 "development" !== 'production' && warn
&&
6586 modifiers
.prevent
&& modifiers
.passive
6589 'passive and prevent can\'t be used together. ' +
6590 'Passive handler can\'t prevent default event.'
6594 // check capture modifier
6595 if (modifiers
.capture
) {
6596 delete modifiers
.capture
;
6597 name
= '!' + name
; // mark the event as captured
6599 if (modifiers
.once
) {
6600 delete modifiers
.once
;
6601 name
= '~' + name
; // mark the event as once
6603 /* istanbul ignore if */
6604 if (modifiers
.passive
) {
6605 delete modifiers
.passive
;
6606 name
= '&' + name
; // mark the event as passive
6609 // normalize click.right and click.middle since they don't actually fire
6610 // this is technically browser-specific, but at least for now browsers are
6611 // the only target envs that have right/middle clicks.
6612 if (name
=== 'click') {
6613 if (modifiers
.right
) {
6614 name
= 'contextmenu';
6615 delete modifiers
.right
;
6616 } else if (modifiers
.middle
) {
6622 if (modifiers
.native) {
6623 delete modifiers
.native;
6624 events
= el
.nativeEvents
|| (el
.nativeEvents
= {});
6626 events
= el
.events
|| (el
.events
= {});
6632 if (modifiers
!== emptyObject
) {
6633 newHandler
.modifiers
= modifiers
;
6636 var handlers
= events
[name
];
6637 /* istanbul ignore if */
6638 if (Array
.isArray(handlers
)) {
6639 important
? handlers
.unshift(newHandler
) : handlers
.push(newHandler
);
6640 } else if (handlers
) {
6641 events
[name
] = important
? [newHandler
, handlers
] : [handlers
, newHandler
];
6643 events
[name
] = newHandler
;
6649 function getBindingAttr (
6655 getAndRemoveAttr(el
, ':' + name
) ||
6656 getAndRemoveAttr(el
, 'v-bind:' + name
);
6657 if (dynamicValue
!= null) {
6658 return parseFilters(dynamicValue
)
6659 } else if (getStatic
!== false) {
6660 var staticValue
= getAndRemoveAttr(el
, name
);
6661 if (staticValue
!= null) {
6662 return JSON
.stringify(staticValue
)
6667 // note: this only removes the attr from the Array (attrsList) so that it
6668 // doesn't get processed by processAttrs.
6669 // By default it does NOT remove it from the map (attrsMap) because the map is
6670 // needed during codegen.
6671 function getAndRemoveAttr (
6677 if ((val
= el
.attrsMap
[name
]) != null) {
6678 var list
= el
.attrsList
;
6679 for (var i
= 0, l
= list
.length
; i
< l
; i
++) {
6680 if (list
[i
].name
=== name
) {
6686 if (removeFromMap
) {
6687 delete el
.attrsMap
[name
];
6695 * Cross-platform code generation for component v-model
6697 function genComponentModel (
6702 var ref
= modifiers
|| {};
6703 var number
= ref
.number
;
6704 var trim
= ref
.trim
;
6706 var baseValueExpression
= '$$v';
6707 var valueExpression
= baseValueExpression
;
6710 "(typeof " + baseValueExpression
+ " === 'string'" +
6711 "? " + baseValueExpression
+ ".trim()" +
6712 ": " + baseValueExpression
+ ")";
6715 valueExpression
= "_n(" + valueExpression
+ ")";
6717 var assignment
= genAssignmentCode(value
, valueExpression
);
6720 value: ("(" + value
+ ")"),
6721 expression: ("\"" + value
+ "\""),
6722 callback: ("function (" + baseValueExpression
+ ") {" + assignment
+ "}")
6727 * Cross-platform codegen helper for generating v-model value assignment code.
6729 function genAssignmentCode (
6733 var res
= parseModel(value
);
6734 if (res
.key
=== null) {
6735 return (value
+ "=" + assignment
)
6737 return ("$set(" + (res
.exp
) + ", " + (res
.key
) + ", " + assignment
+ ")")
6742 * Parse a v-model expression into a base path and a final key segment.
6743 * Handles both dot-path and possible square brackets.
6749 * - test[test1[key]]
6751 * - xxx.test[a[a].test1[key]]
6752 * - test.xxx.a["asa"][test1[key]]
6761 var expressionEndPos
;
6765 function parseModel (val
) {
6766 // Fix https://github.com/vuejs/vue/pull/7730
6767 // allow v-model="obj.val " (trailing whitespace)
6771 if (val
.indexOf('[') < 0 || val
.lastIndexOf(']') < len
- 1) {
6772 index
$1 = val
.lastIndexOf('.');
6775 exp: val
.slice(0, index
$1),
6776 key: '"' + val
.slice(index
$1 + 1) + '"'
6787 index
$1 = expressionPos
= expressionEndPos
= 0;
6791 /* istanbul ignore if */
6792 if (isStringStart(chr
)) {
6794 } else if (chr
=== 0x5B) {
6800 exp: val
.slice(0, expressionPos
),
6801 key: val
.slice(expressionPos
+ 1, expressionEndPos
)
6806 return str
.charCodeAt(++index
$1)
6810 return index
$1 >= len
6813 function isStringStart (chr
) {
6814 return chr
=== 0x22 || chr
=== 0x27
6817 function parseBracket (chr
) {
6819 expressionPos
= index
$1;
6822 if (isStringStart(chr
)) {
6826 if (chr
=== 0x5B) { inBracket
++; }
6827 if (chr
=== 0x5D) { inBracket
--; }
6828 if (inBracket
=== 0) {
6829 expressionEndPos
= index
$1;
6835 function parseString (chr
) {
6836 var stringQuote
= chr
;
6839 if (chr
=== stringQuote
) {
6849 // in some cases, the event used has to be determined at runtime
6850 // so we used some reserved tokens during compile.
6851 var RANGE_TOKEN
= '__r';
6852 var CHECKBOX_RADIO_TOKEN
= '__c';
6860 var value
= dir
.value
;
6861 var modifiers
= dir
.modifiers
;
6863 var type
= el
.attrsMap
.type
;
6866 // inputs with type="file" are read only and setting the input's
6867 // value will throw an error.
6868 if (tag
=== 'input' && type
=== 'file') {
6870 "<" + (el
.tag
) + " v-model=\"" + value
+ "\" type=\"file\">:\n" +
6871 "File inputs are read only. Use a v-on:change listener instead."
6877 genComponentModel(el
, value
, modifiers
);
6878 // component v-model doesn't need extra runtime
6880 } else if (tag
=== 'select') {
6881 genSelect(el
, value
, modifiers
);
6882 } else if (tag
=== 'input' && type
=== 'checkbox') {
6883 genCheckboxModel(el
, value
, modifiers
);
6884 } else if (tag
=== 'input' && type
=== 'radio') {
6885 genRadioModel(el
, value
, modifiers
);
6886 } else if (tag
=== 'input' || tag
=== 'textarea') {
6887 genDefaultModel(el
, value
, modifiers
);
6888 } else if (!config
.isReservedTag(tag
)) {
6889 genComponentModel(el
, value
, modifiers
);
6890 // component v-model doesn't need extra runtime
6894 "<" + (el
.tag
) + " v-model=\"" + value
+ "\">: " +
6895 "v-model is not supported on this element type. " +
6896 'If you are working with contenteditable, it\'s recommended to ' +
6897 'wrap a library dedicated for that purpose inside a custom component.'
6901 // ensure runtime directive metadata
6905 function genCheckboxModel (
6910 var number
= modifiers
&& modifiers
.number
;
6911 var valueBinding
= getBindingAttr(el
, 'value') || 'null';
6912 var trueValueBinding
= getBindingAttr(el
, 'true-value') || 'true';
6913 var falseValueBinding
= getBindingAttr(el
, 'false-value') || 'false';
6914 addProp(el
, 'checked',
6915 "Array.isArray(" + value
+ ")" +
6916 "?_i(" + value
+ "," + valueBinding
+ ")>-1" + (
6917 trueValueBinding
=== 'true'
6918 ? (":(" + value
+ ")")
6919 : (":_q(" + value
+ "," + trueValueBinding
+ ")")
6922 addHandler(el
, 'change',
6923 "var $$a=" + value
+ "," +
6924 '$$el=$event.target,' +
6925 "$$c=$$el.checked?(" + trueValueBinding
+ "):(" + falseValueBinding
+ ");" +
6926 'if(Array.isArray($$a)){' +
6927 "var $$v=" + (number
? '_n(' + valueBinding
+ ')' : valueBinding
) + "," +
6928 '$$i=_i($$a,$$v);' +
6929 "if($$el.checked){$$i<0&&(" + (genAssignmentCode(value
, '$$a.concat([$$v])')) + ")}" +
6930 "else{$$i>-1&&(" + (genAssignmentCode(value
, '$$a.slice(0,$$i).concat($$a.slice($$i+1))')) + ")}" +
6931 "}else{" + (genAssignmentCode(value
, '$$c')) + "}",
6936 function genRadioModel (
6941 var number
= modifiers
&& modifiers
.number
;
6942 var valueBinding
= getBindingAttr(el
, 'value') || 'null';
6943 valueBinding
= number
? ("_n(" + valueBinding
+ ")") : valueBinding
;
6944 addProp(el
, 'checked', ("_q(" + value
+ "," + valueBinding
+ ")"));
6945 addHandler(el
, 'change', genAssignmentCode(value
, valueBinding
), null, true);
6948 function genSelect (
6953 var number
= modifiers
&& modifiers
.number
;
6954 var selectedVal
= "Array.prototype.filter" +
6955 ".call($event.target.options,function(o){return o.selected})" +
6956 ".map(function(o){var val = \"_value\" in o ? o._value : o.value;" +
6957 "return " + (number
? '_n(val)' : 'val') + "})";
6959 var assignment
= '$event.target.multiple ? $$selectedVal : $$selectedVal[0]';
6960 var code
= "var $$selectedVal = " + selectedVal
+ ";";
6961 code
= code
+ " " + (genAssignmentCode(value
, assignment
));
6962 addHandler(el
, 'change', code
, null, true);
6965 function genDefaultModel (
6970 var type
= el
.attrsMap
.type
;
6972 // warn if v-bind:value conflicts with v-model
6973 // except for inputs with v-bind:type
6975 var value
$1 = el
.attrsMap
['v-bind:value'] || el
.attrsMap
[':value'];
6976 var typeBinding
= el
.attrsMap
['v-bind:type'] || el
.attrsMap
[':type'];
6977 if (value
$1 && !typeBinding
) {
6978 var binding
= el
.attrsMap
['v-bind:value'] ? 'v-bind:value' : ':value';
6980 binding
+ "=\"" + value
$1 + "\" conflicts with v-model on the same element " +
6981 'because the latter already expands to a value binding internally'
6986 var ref
= modifiers
|| {};
6987 var lazy
= ref
.lazy
;
6988 var number
= ref
.number
;
6989 var trim
= ref
.trim
;
6990 var needCompositionGuard
= !lazy
&& type
!== 'range';
6997 var valueExpression
= '$event.target.value';
6999 valueExpression
= "$event.target.value.trim()";
7002 valueExpression
= "_n(" + valueExpression
+ ")";
7005 var code
= genAssignmentCode(value
, valueExpression
);
7006 if (needCompositionGuard
) {
7007 code
= "if($event.target.composing)return;" + code
;
7010 addProp(el
, 'value', ("(" + value
+ ")"));
7011 addHandler(el
, event
, code
, null, true);
7012 if (trim
|| number
) {
7013 addHandler(el
, 'blur', '$forceUpdate()');
7019 // normalize v-model event tokens that can only be determined at runtime.
7020 // it's important to place the event as the first in the array because
7021 // the whole point is ensuring the v-model callback gets called before
7022 // user-attached handlers.
7023 function normalizeEvents (on
) {
7024 /* istanbul ignore if */
7025 if (isDef(on
[RANGE_TOKEN
])) {
7026 // IE input[type=range] only supports `change` event
7027 var event
= isIE
? 'change' : 'input';
7028 on
[event
] = [].concat(on
[RANGE_TOKEN
], on
[event
] || []);
7029 delete on
[RANGE_TOKEN
];
7031 // This was originally intended to fix #4521 but no longer necessary
7032 // after 2.5. Keeping it for backwards compat with generated code from < 2.4
7033 /* istanbul ignore if */
7034 if (isDef(on
[CHECKBOX_RADIO_TOKEN
])) {
7035 on
.change
= [].concat(on
[CHECKBOX_RADIO_TOKEN
], on
.change
|| []);
7036 delete on
[CHECKBOX_RADIO_TOKEN
];
7042 function createOnceHandler (handler
, event
, capture
) {
7043 var _target
= target
$1; // save current target element in closure
7044 return function onceHandler () {
7045 var res
= handler
.apply(null, arguments
);
7047 remove
$2(event
, onceHandler
, capture
, _target
);
7059 handler
= withMacroTask(handler
);
7060 if (once
$$1) { handler
= createOnceHandler(handler
, event
, capture
); }
7061 target
$1.addEventListener(
7065 ? { capture: capture
, passive: passive
}
7076 (_target
|| target
$1).removeEventListener(
7078 handler
._withTask
|| handler
,
7083 function updateDOMListeners (oldVnode
, vnode
) {
7084 if (isUndef(oldVnode
.data
.on
) && isUndef(vnode
.data
.on
)) {
7087 var on
= vnode
.data
.on
|| {};
7088 var oldOn
= oldVnode
.data
.on
|| {};
7089 target
$1 = vnode
.elm
;
7090 normalizeEvents(on
);
7091 updateListeners(on
, oldOn
, add
$1, remove
$2, vnode
.context
);
7092 target
$1 = undefined;
7096 create: updateDOMListeners
,
7097 update: updateDOMListeners
7102 function updateDOMProps (oldVnode
, vnode
) {
7103 if (isUndef(oldVnode
.data
.domProps
) && isUndef(vnode
.data
.domProps
)) {
7107 var elm
= vnode
.elm
;
7108 var oldProps
= oldVnode
.data
.domProps
|| {};
7109 var props
= vnode
.data
.domProps
|| {};
7110 // clone observed objects, as the user probably wants to mutate it
7111 if (isDef(props
.__ob__
)) {
7112 props
= vnode
.data
.domProps
= extend({}, props
);
7115 for (key
in oldProps
) {
7116 if (isUndef(props
[key
])) {
7120 for (key
in props
) {
7122 // ignore children if the node has textContent or innerHTML,
7123 // as these will throw away existing DOM nodes and cause removal errors
7124 // on subsequent patches (#3360)
7125 if (key
=== 'textContent' || key
=== 'innerHTML') {
7126 if (vnode
.children
) { vnode
.children
.length
= 0; }
7127 if (cur
=== oldProps
[key
]) { continue }
7128 // #6601 work around Chrome version <= 55 bug where single textNode
7129 // replaced by innerHTML/textContent retains its parentNode property
7130 if (elm
.childNodes
.length
=== 1) {
7131 elm
.removeChild(elm
.childNodes
[0]);
7135 if (key
=== 'value') {
7136 // store value as _value as well since
7137 // non-string values will be stringified
7139 // avoid resetting cursor position when value is the same
7140 var strCur
= isUndef(cur
) ? '' : String(cur
);
7141 if (shouldUpdateValue(elm
, strCur
)) {
7150 // check platforms/web/util/attrs.js acceptValue
7153 function shouldUpdateValue (elm
, checkVal
) {
7154 return (!elm
.composing
&& (
7155 elm
.tagName
=== 'OPTION' ||
7156 isNotInFocusAndDirty(elm
, checkVal
) ||
7157 isDirtyWithModifiers(elm
, checkVal
)
7161 function isNotInFocusAndDirty (elm
, checkVal
) {
7162 // return true when textbox (.number and .trim) loses focus and its value is
7163 // not equal to the updated value
7164 var notInFocus
= true;
7166 // work around IE bug when accessing document.activeElement in an iframe
7167 try { notInFocus
= document
.activeElement
!== elm
; } catch (e
) {}
7168 return notInFocus
&& elm
.value
!== checkVal
7171 function isDirtyWithModifiers (elm
, newVal
) {
7172 var value
= elm
.value
;
7173 var modifiers
= elm
._vModifiers
; // injected by v-model runtime
7174 if (isDef(modifiers
)) {
7175 if (modifiers
.lazy
) {
7176 // inputs with lazy should only be updated when not in focus
7179 if (modifiers
.number
) {
7180 return toNumber(value
) !== toNumber(newVal
)
7182 if (modifiers
.trim
) {
7183 return value
.trim() !== newVal
.trim()
7186 return value
!== newVal
7190 create: updateDOMProps
,
7191 update: updateDOMProps
7196 var parseStyleText
= cached(function (cssText
) {
7198 var listDelimiter
= /;(?![^(]*\))/g;
7199 var propertyDelimiter
= /:(.+)/;
7200 cssText
.split(listDelimiter
).forEach(function (item
) {
7202 var tmp
= item
.split(propertyDelimiter
);
7203 tmp
.length
> 1 && (res
[tmp
[0].trim()] = tmp
[1].trim());
7209 // merge static and dynamic style data on the same vnode
7210 function normalizeStyleData (data
) {
7211 var style
= normalizeStyleBinding(data
.style
);
7212 // static style is pre-processed into an object during compilation
7213 // and is always a fresh object, so it's safe to merge into it
7214 return data
.staticStyle
7215 ? extend(data
.staticStyle
, style
)
7219 // normalize possible array / string values into Object
7220 function normalizeStyleBinding (bindingStyle
) {
7221 if (Array
.isArray(bindingStyle
)) {
7222 return toObject(bindingStyle
)
7224 if (typeof bindingStyle
=== 'string') {
7225 return parseStyleText(bindingStyle
)
7231 * parent component style should be after child's
7232 * so that parent component's style could override it
7234 function getStyle (vnode
, checkChild
) {
7239 var childNode
= vnode
;
7240 while (childNode
.componentInstance
) {
7241 childNode
= childNode
.componentInstance
._vnode
;
7243 childNode
&& childNode
.data
&&
7244 (styleData
= normalizeStyleData(childNode
.data
))
7246 extend(res
, styleData
);
7251 if ((styleData
= normalizeStyleData(vnode
.data
))) {
7252 extend(res
, styleData
);
7255 var parentNode
= vnode
;
7256 while ((parentNode
= parentNode
.parent
)) {
7257 if (parentNode
.data
&& (styleData
= normalizeStyleData(parentNode
.data
))) {
7258 extend(res
, styleData
);
7266 var cssVarRE
= /^--/;
7267 var importantRE
= /\s*!important$/;
7268 var setProp = function (el
, name
, val
) {
7269 /* istanbul ignore if */
7270 if (cssVarRE
.test(name
)) {
7271 el
.style
.setProperty(name
, val
);
7272 } else if (importantRE
.test(val
)) {
7273 el
.style
.setProperty(name
, val
.replace(importantRE
, ''), 'important');
7275 var normalizedName
= normalize(name
);
7276 if (Array
.isArray(val
)) {
7277 // Support values array created by autoprefixer, e.g.
7278 // {display: ["-webkit-box", "-ms-flexbox", "flex"]}
7279 // Set them one by one, and the browser will only set those it can recognize
7280 for (var i
= 0, len
= val
.length
; i
< len
; i
++) {
7281 el
.style
[normalizedName
] = val
[i
];
7284 el
.style
[normalizedName
] = val
;
7289 var vendorNames
= ['Webkit', 'Moz', 'ms'];
7292 var normalize
= cached(function (prop
) {
7293 emptyStyle
= emptyStyle
|| document
.createElement('div').style
;
7294 prop
= camelize(prop
);
7295 if (prop
!== 'filter' && (prop
in emptyStyle
)) {
7298 var capName
= prop
.charAt(0).toUpperCase() + prop
.slice(1);
7299 for (var i
= 0; i
< vendorNames
.length
; i
++) {
7300 var name
= vendorNames
[i
] + capName
;
7301 if (name
in emptyStyle
) {
7307 function updateStyle (oldVnode
, vnode
) {
7308 var data
= vnode
.data
;
7309 var oldData
= oldVnode
.data
;
7311 if (isUndef(data
.staticStyle
) && isUndef(data
.style
) &&
7312 isUndef(oldData
.staticStyle
) && isUndef(oldData
.style
)
7319 var oldStaticStyle
= oldData
.staticStyle
;
7320 var oldStyleBinding
= oldData
.normalizedStyle
|| oldData
.style
|| {};
7322 // if static style exists, stylebinding already merged into it when doing normalizeStyleData
7323 var oldStyle
= oldStaticStyle
|| oldStyleBinding
;
7325 var style
= normalizeStyleBinding(vnode
.data
.style
) || {};
7327 // store normalized style under a different key for next diff
7328 // make sure to clone it if it's reactive, since the user likely wants
7330 vnode
.data
.normalizedStyle
= isDef(style
.__ob__
)
7334 var newStyle
= getStyle(vnode
, true);
7336 for (name
in oldStyle
) {
7337 if (isUndef(newStyle
[name
])) {
7338 setProp(el
, name
, '');
7341 for (name
in newStyle
) {
7342 cur
= newStyle
[name
];
7343 if (cur
!== oldStyle
[name
]) {
7344 // ie9 setting to null has no effect, must use empty string
7345 setProp(el
, name
, cur
== null ? '' : cur
);
7351 create: updateStyle
,
7358 * Add class with compatibility for SVG since classList is not supported on
7359 * SVG elements in IE
7361 function addClass (el
, cls
) {
7362 /* istanbul ignore if */
7363 if (!cls
|| !(cls
= cls
.trim())) {
7367 /* istanbul ignore else */
7369 if (cls
.indexOf(' ') > -1) {
7370 cls
.split(/\s+/).forEach(function (c
) { return el
.classList
.add(c
); });
7372 el
.classList
.add(cls
);
7375 var cur
= " " + (el
.getAttribute('class') || '') + " ";
7376 if (cur
.indexOf(' ' + cls
+ ' ') < 0) {
7377 el
.setAttribute('class', (cur
+ cls
).trim());
7383 * Remove class with compatibility for SVG since classList is not supported on
7384 * SVG elements in IE
7386 function removeClass (el
, cls
) {
7387 /* istanbul ignore if */
7388 if (!cls
|| !(cls
= cls
.trim())) {
7392 /* istanbul ignore else */
7394 if (cls
.indexOf(' ') > -1) {
7395 cls
.split(/\s+/).forEach(function (c
) { return el
.classList
.remove(c
); });
7397 el
.classList
.remove(cls
);
7399 if (!el
.classList
.length
) {
7400 el
.removeAttribute('class');
7403 var cur
= " " + (el
.getAttribute('class') || '') + " ";
7404 var tar
= ' ' + cls
+ ' ';
7405 while (cur
.indexOf(tar
) >= 0) {
7406 cur
= cur
.replace(tar
, ' ');
7410 el
.setAttribute('class', cur
);
7412 el
.removeAttribute('class');
7419 function resolveTransition (def
) {
7423 /* istanbul ignore else */
7424 if (typeof def
=== 'object') {
7426 if (def
.css
!== false) {
7427 extend(res
, autoCssTransition(def
.name
|| 'v'));
7431 } else if (typeof def
=== 'string') {
7432 return autoCssTransition(def
)
7436 var autoCssTransition
= cached(function (name
) {
7438 enterClass: (name
+ "-enter"),
7439 enterToClass: (name
+ "-enter-to"),
7440 enterActiveClass: (name
+ "-enter-active"),
7441 leaveClass: (name
+ "-leave"),
7442 leaveToClass: (name
+ "-leave-to"),
7443 leaveActiveClass: (name
+ "-leave-active")
7447 var hasTransition
= inBrowser
&& !isIE9
;
7448 var TRANSITION
= 'transition';
7449 var ANIMATION
= 'animation';
7451 // Transition property/event sniffing
7452 var transitionProp
= 'transition';
7453 var transitionEndEvent
= 'transitionend';
7454 var animationProp
= 'animation';
7455 var animationEndEvent
= 'animationend';
7456 if (hasTransition
) {
7457 /* istanbul ignore if */
7458 if (window
.ontransitionend
=== undefined &&
7459 window
.onwebkittransitionend
!== undefined
7461 transitionProp
= 'WebkitTransition';
7462 transitionEndEvent
= 'webkitTransitionEnd';
7464 if (window
.onanimationend
=== undefined &&
7465 window
.onwebkitanimationend
!== undefined
7467 animationProp
= 'WebkitAnimation';
7468 animationEndEvent
= 'webkitAnimationEnd';
7472 // binding to window is necessary to make hot reload work in IE in strict mode
7474 ? window
.requestAnimationFrame
7475 ? window
.requestAnimationFrame
.bind(window
)
7477 : /* istanbul ignore next */ function (fn
) { return fn(); };
7479 function nextFrame (fn
) {
7485 function addTransitionClass (el
, cls
) {
7486 var transitionClasses
= el
._transitionClasses
|| (el
._transitionClasses
= []);
7487 if (transitionClasses
.indexOf(cls
) < 0) {
7488 transitionClasses
.push(cls
);
7493 function removeTransitionClass (el
, cls
) {
7494 if (el
._transitionClasses
) {
7495 remove(el
._transitionClasses
, cls
);
7497 removeClass(el
, cls
);
7500 function whenTransitionEnds (
7505 var ref
= getTransitionInfo(el
, expectedType
);
7506 var type
= ref
.type
;
7507 var timeout
= ref
.timeout
;
7508 var propCount
= ref
.propCount
;
7509 if (!type
) { return cb() }
7510 var event
= type
=== TRANSITION
? transitionEndEvent : animationEndEvent
;
7512 var end = function () {
7513 el
.removeEventListener(event
, onEnd
);
7516 var onEnd = function (e
) {
7517 if (e
.target
=== el
) {
7518 if (++ended
>= propCount
) {
7523 setTimeout(function () {
7524 if (ended
< propCount
) {
7528 el
.addEventListener(event
, onEnd
);
7531 var transformRE
= /\b(transform|all)(,|$)/;
7533 function getTransitionInfo (el
, expectedType
) {
7534 var styles
= window
.getComputedStyle(el
);
7535 var transitionDelays
= styles
[transitionProp
+ 'Delay'].split(', ');
7536 var transitionDurations
= styles
[transitionProp
+ 'Duration'].split(', ');
7537 var transitionTimeout
= getTimeout(transitionDelays
, transitionDurations
);
7538 var animationDelays
= styles
[animationProp
+ 'Delay'].split(', ');
7539 var animationDurations
= styles
[animationProp
+ 'Duration'].split(', ');
7540 var animationTimeout
= getTimeout(animationDelays
, animationDurations
);
7545 /* istanbul ignore if */
7546 if (expectedType
=== TRANSITION
) {
7547 if (transitionTimeout
> 0) {
7549 timeout
= transitionTimeout
;
7550 propCount
= transitionDurations
.length
;
7552 } else if (expectedType
=== ANIMATION
) {
7553 if (animationTimeout
> 0) {
7555 timeout
= animationTimeout
;
7556 propCount
= animationDurations
.length
;
7559 timeout
= Math
.max(transitionTimeout
, animationTimeout
);
7561 ? transitionTimeout
> animationTimeout
7566 ? type
=== TRANSITION
7567 ? transitionDurations
.length
7568 : animationDurations
.length
7572 type
=== TRANSITION
&&
7573 transformRE
.test(styles
[transitionProp
+ 'Property']);
7577 propCount: propCount
,
7578 hasTransform: hasTransform
7582 function getTimeout (delays
, durations
) {
7583 /* istanbul ignore next */
7584 while (delays
.length
< durations
.length
) {
7585 delays
= delays
.concat(delays
);
7588 return Math
.max
.apply(null, durations
.map(function (d
, i
) {
7589 return toMs(d
) + toMs(delays
[i
])
7594 return Number(s
.slice(0, -1)) * 1000
7599 function enter (vnode
, toggleDisplay
) {
7602 // call leave callback now
7603 if (isDef(el
._leaveCb
)) {
7604 el
._leaveCb
.cancelled
= true;
7608 var data
= resolveTransition(vnode
.data
.transition
);
7609 if (isUndef(data
)) {
7613 /* istanbul ignore if */
7614 if (isDef(el
._enterCb
) || el
.nodeType
!== 1) {
7619 var type
= data
.type
;
7620 var enterClass
= data
.enterClass
;
7621 var enterToClass
= data
.enterToClass
;
7622 var enterActiveClass
= data
.enterActiveClass
;
7623 var appearClass
= data
.appearClass
;
7624 var appearToClass
= data
.appearToClass
;
7625 var appearActiveClass
= data
.appearActiveClass
;
7626 var beforeEnter
= data
.beforeEnter
;
7627 var enter
= data
.enter
;
7628 var afterEnter
= data
.afterEnter
;
7629 var enterCancelled
= data
.enterCancelled
;
7630 var beforeAppear
= data
.beforeAppear
;
7631 var appear
= data
.appear
;
7632 var afterAppear
= data
.afterAppear
;
7633 var appearCancelled
= data
.appearCancelled
;
7634 var duration
= data
.duration
;
7636 // activeInstance will always be the <transition> component managing this
7637 // transition. One edge case to check is when the <transition> is placed
7638 // as the root node of a child component. In that case we need to check
7639 // <transition>'s parent for appear check.
7640 var context
= activeInstance
;
7641 var transitionNode
= activeInstance
.$vnode
;
7642 while (transitionNode
&& transitionNode
.parent
) {
7643 transitionNode
= transitionNode
.parent
;
7644 context
= transitionNode
.context
;
7647 var isAppear
= !context
._isMounted
|| !vnode
.isRootInsert
;
7649 if (isAppear
&& !appear
&& appear
!== '') {
7653 var startClass
= isAppear
&& appearClass
7656 var activeClass
= isAppear
&& appearActiveClass
7659 var toClass
= isAppear
&& appearToClass
7663 var beforeEnterHook
= isAppear
7664 ? (beforeAppear
|| beforeEnter
)
7666 var enterHook
= isAppear
7667 ? (typeof appear
=== 'function' ? appear : enter
)
7669 var afterEnterHook
= isAppear
7670 ? (afterAppear
|| afterEnter
)
7672 var enterCancelledHook
= isAppear
7673 ? (appearCancelled
|| enterCancelled
)
7676 var explicitEnterDuration
= toNumber(
7682 if ("development" !== 'production' && explicitEnterDuration
!= null) {
7683 checkDuration(explicitEnterDuration
, 'enter', vnode
);
7686 var expectsCSS
= css
!== false && !isIE9
;
7687 var userWantsControl
= getHookArgumentsLength(enterHook
);
7689 var cb
= el
._enterCb
= once(function () {
7691 removeTransitionClass(el
, toClass
);
7692 removeTransitionClass(el
, activeClass
);
7696 removeTransitionClass(el
, startClass
);
7698 enterCancelledHook
&& enterCancelledHook(el
);
7700 afterEnterHook
&& afterEnterHook(el
);
7705 if (!vnode
.data
.show
) {
7706 // remove pending leave element on enter by injecting an insert hook
7707 mergeVNodeHook(vnode
, 'insert', function () {
7708 var parent
= el
.parentNode
;
7709 var pendingNode
= parent
&& parent
._pending
&& parent
._pending
[vnode
.key
];
7711 pendingNode
.tag
=== vnode
.tag
&&
7712 pendingNode
.elm
._leaveCb
7714 pendingNode
.elm
._leaveCb();
7716 enterHook
&& enterHook(el
, cb
);
7720 // start enter transition
7721 beforeEnterHook
&& beforeEnterHook(el
);
7723 addTransitionClass(el
, startClass
);
7724 addTransitionClass(el
, activeClass
);
7725 nextFrame(function () {
7726 removeTransitionClass(el
, startClass
);
7727 if (!cb
.cancelled
) {
7728 addTransitionClass(el
, toClass
);
7729 if (!userWantsControl
) {
7730 if (isValidDuration(explicitEnterDuration
)) {
7731 setTimeout(cb
, explicitEnterDuration
);
7733 whenTransitionEnds(el
, type
, cb
);
7740 if (vnode
.data
.show
) {
7741 toggleDisplay
&& toggleDisplay();
7742 enterHook
&& enterHook(el
, cb
);
7745 if (!expectsCSS
&& !userWantsControl
) {
7750 function leave (vnode
, rm
) {
7753 // call enter callback now
7754 if (isDef(el
._enterCb
)) {
7755 el
._enterCb
.cancelled
= true;
7759 var data
= resolveTransition(vnode
.data
.transition
);
7760 if (isUndef(data
) || el
.nodeType
!== 1) {
7764 /* istanbul ignore if */
7765 if (isDef(el
._leaveCb
)) {
7770 var type
= data
.type
;
7771 var leaveClass
= data
.leaveClass
;
7772 var leaveToClass
= data
.leaveToClass
;
7773 var leaveActiveClass
= data
.leaveActiveClass
;
7774 var beforeLeave
= data
.beforeLeave
;
7775 var leave
= data
.leave
;
7776 var afterLeave
= data
.afterLeave
;
7777 var leaveCancelled
= data
.leaveCancelled
;
7778 var delayLeave
= data
.delayLeave
;
7779 var duration
= data
.duration
;
7781 var expectsCSS
= css
!== false && !isIE9
;
7782 var userWantsControl
= getHookArgumentsLength(leave
);
7784 var explicitLeaveDuration
= toNumber(
7790 if ("development" !== 'production' && isDef(explicitLeaveDuration
)) {
7791 checkDuration(explicitLeaveDuration
, 'leave', vnode
);
7794 var cb
= el
._leaveCb
= once(function () {
7795 if (el
.parentNode
&& el
.parentNode
._pending
) {
7796 el
.parentNode
._pending
[vnode
.key
] = null;
7799 removeTransitionClass(el
, leaveToClass
);
7800 removeTransitionClass(el
, leaveActiveClass
);
7804 removeTransitionClass(el
, leaveClass
);
7806 leaveCancelled
&& leaveCancelled(el
);
7809 afterLeave
&& afterLeave(el
);
7815 delayLeave(performLeave
);
7820 function performLeave () {
7821 // the delayed leave may have already been cancelled
7825 // record leaving element
7826 if (!vnode
.data
.show
) {
7827 (el
.parentNode
._pending
|| (el
.parentNode
._pending
= {}))[(vnode
.key
)] = vnode
;
7829 beforeLeave
&& beforeLeave(el
);
7831 addTransitionClass(el
, leaveClass
);
7832 addTransitionClass(el
, leaveActiveClass
);
7833 nextFrame(function () {
7834 removeTransitionClass(el
, leaveClass
);
7835 if (!cb
.cancelled
) {
7836 addTransitionClass(el
, leaveToClass
);
7837 if (!userWantsControl
) {
7838 if (isValidDuration(explicitLeaveDuration
)) {
7839 setTimeout(cb
, explicitLeaveDuration
);
7841 whenTransitionEnds(el
, type
, cb
);
7847 leave
&& leave(el
, cb
);
7848 if (!expectsCSS
&& !userWantsControl
) {
7854 // only used in dev mode
7855 function checkDuration (val
, name
, vnode
) {
7856 if (typeof val
!== 'number') {
7858 "<transition> explicit " + name
+ " duration is not a valid number - " +
7859 "got " + (JSON
.stringify(val
)) + ".",
7862 } else if (isNaN(val
)) {
7864 "<transition> explicit " + name
+ " duration is NaN - " +
7865 'the duration expression might be incorrect.',
7871 function isValidDuration (val
) {
7872 return typeof val
=== 'number' && !isNaN(val
)
7876 * Normalize a transition hook's argument length. The hook may be:
7877 * - a merged hook (invoker) with the original in .fns
7878 * - a wrapped component method (check ._length)
7879 * - a plain function (.length)
7881 function getHookArgumentsLength (fn
) {
7885 var invokerFns
= fn
.fns
;
7886 if (isDef(invokerFns
)) {
7888 return getHookArgumentsLength(
7889 Array
.isArray(invokerFns
)
7894 return (fn
._length
|| fn
.length
) > 1
7898 function _enter (_
, vnode
) {
7899 if (vnode
.data
.show
!== true) {
7904 var transition
= inBrowser
? {
7907 remove: function remove
$$1 (vnode
, rm
) {
7908 /* istanbul ignore else */
7909 if (vnode
.data
.show
!== true) {
7917 var platformModules
= [
7928 // the directive module should be applied last, after all
7929 // built-in modules have been applied.
7930 var modules
= platformModules
.concat(baseModules
);
7932 var patch
= createPatchFunction({ nodeOps: nodeOps
, modules: modules
});
7935 * Not type checking this file because flow doesn't like attaching
7936 * properties to Elements.
7939 /* istanbul ignore if */
7941 // http://www.matts411.com/post/internet-explorer-9-oninput/
7942 document
.addEventListener('selectionchange', function () {
7943 var el
= document
.activeElement
;
7944 if (el
&& el
.vmodel
) {
7945 trigger(el
, 'input');
7951 inserted: function inserted (el
, binding
, vnode
, oldVnode
) {
7952 if (vnode
.tag
=== 'select') {
7954 if (oldVnode
.elm
&& !oldVnode
.elm
._vOptions
) {
7955 mergeVNodeHook(vnode
, 'postpatch', function () {
7956 directive
.componentUpdated(el
, binding
, vnode
);
7959 setSelected(el
, binding
, vnode
.context
);
7961 el
._vOptions
= [].map
.call(el
.options
, getValue
);
7962 } else if (vnode
.tag
=== 'textarea' || isTextInputType(el
.type
)) {
7963 el
._vModifiers
= binding
.modifiers
;
7964 if (!binding
.modifiers
.lazy
) {
7965 el
.addEventListener('compositionstart', onCompositionStart
);
7966 el
.addEventListener('compositionend', onCompositionEnd
);
7967 // Safari < 10.2 & UIWebView doesn't fire compositionend when
7968 // switching focus before confirming composition choice
7969 // this also fixes the issue where some browsers e.g. iOS Chrome
7970 // fires "change" instead of "input" on autocomplete.
7971 el
.addEventListener('change', onCompositionEnd
);
7972 /* istanbul ignore if */
7980 componentUpdated: function componentUpdated (el
, binding
, vnode
) {
7981 if (vnode
.tag
=== 'select') {
7982 setSelected(el
, binding
, vnode
.context
);
7983 // in case the options rendered by v-for have changed,
7984 // it's possible that the value is out-of-sync with the rendered options.
7985 // detect such cases and filter out values that no longer has a matching
7986 // option in the DOM.
7987 var prevOptions
= el
._vOptions
;
7988 var curOptions
= el
._vOptions
= [].map
.call(el
.options
, getValue
);
7989 if (curOptions
.some(function (o
, i
) { return !looseEqual(o
, prevOptions
[i
]); })) {
7990 // trigger change event if
7991 // no matching option found for at least one value
7992 var needReset
= el
.multiple
7993 ? binding
.value
.some(function (v
) { return hasNoMatchingOption(v
, curOptions
); })
7994 : binding
.value
!== binding
.oldValue
&& hasNoMatchingOption(binding
.value
, curOptions
);
7996 trigger(el
, 'change');
8003 function setSelected (el
, binding
, vm
) {
8004 actuallySetSelected(el
, binding
, vm
);
8005 /* istanbul ignore if */
8006 if (isIE
|| isEdge
) {
8007 setTimeout(function () {
8008 actuallySetSelected(el
, binding
, vm
);
8013 function actuallySetSelected (el
, binding
, vm
) {
8014 var value
= binding
.value
;
8015 var isMultiple
= el
.multiple
;
8016 if (isMultiple
&& !Array
.isArray(value
)) {
8017 "development" !== 'production' && warn(
8018 "<select multiple v-model=\"" + (binding
.expression
) + "\"> " +
8019 "expects an Array value for its binding, but got " + (Object
.prototype.toString
.call(value
).slice(8, -1)),
8024 var selected
, option
;
8025 for (var i
= 0, l
= el
.options
.length
; i
< l
; i
++) {
8026 option
= el
.options
[i
];
8028 selected
= looseIndexOf(value
, getValue(option
)) > -1;
8029 if (option
.selected
!== selected
) {
8030 option
.selected
= selected
;
8033 if (looseEqual(getValue(option
), value
)) {
8034 if (el
.selectedIndex
!== i
) {
8035 el
.selectedIndex
= i
;
8042 el
.selectedIndex
= -1;
8046 function hasNoMatchingOption (value
, options
) {
8047 return options
.every(function (o
) { return !looseEqual(o
, value
); })
8050 function getValue (option
) {
8051 return '_value' in option
8056 function onCompositionStart (e
) {
8057 e
.target
.composing
= true;
8060 function onCompositionEnd (e
) {
8061 // prevent triggering an input event for no reason
8062 if (!e
.target
.composing
) { return }
8063 e
.target
.composing
= false;
8064 trigger(e
.target
, 'input');
8067 function trigger (el
, type
) {
8068 var e
= document
.createEvent('HTMLEvents');
8069 e
.initEvent(type
, true, true);
8070 el
.dispatchEvent(e
);
8075 // recursively search for possible transition defined inside the component root
8076 function locateNode (vnode
) {
8077 return vnode
.componentInstance
&& (!vnode
.data
|| !vnode
.data
.transition
)
8078 ? locateNode(vnode
.componentInstance
._vnode
)
8083 bind: function bind (el
, ref
, vnode
) {
8084 var value
= ref
.value
;
8086 vnode
= locateNode(vnode
);
8087 var transition
$$1 = vnode
.data
&& vnode
.data
.transition
;
8088 var originalDisplay
= el
.__vOriginalDisplay
=
8089 el
.style
.display
=== 'none' ? '' : el
.style
.display
;
8090 if (value
&& transition
$$1) {
8091 vnode
.data
.show
= true;
8092 enter(vnode
, function () {
8093 el
.style
.display
= originalDisplay
;
8096 el
.style
.display
= value
? originalDisplay : 'none';
8100 update: function update (el
, ref
, vnode
) {
8101 var value
= ref
.value
;
8102 var oldValue
= ref
.oldValue
;
8104 /* istanbul ignore if */
8105 if (!value
=== !oldValue
) { return }
8106 vnode
= locateNode(vnode
);
8107 var transition
$$1 = vnode
.data
&& vnode
.data
.transition
;
8108 if (transition
$$1) {
8109 vnode
.data
.show
= true;
8111 enter(vnode
, function () {
8112 el
.style
.display
= el
.__vOriginalDisplay
;
8115 leave(vnode
, function () {
8116 el
.style
.display
= 'none';
8120 el
.style
.display
= value
? el
.__vOriginalDisplay : 'none';
8124 unbind: function unbind (
8132 el
.style
.display
= el
.__vOriginalDisplay
;
8137 var platformDirectives
= {
8144 // Provides transition support for a single element/component.
8145 // supports transition mode (out-in / in-out)
8147 var transitionProps
= {
8155 enterToClass: String
,
8156 leaveToClass: String
,
8157 enterActiveClass: String
,
8158 leaveActiveClass: String
,
8159 appearClass: String
,
8160 appearActiveClass: String
,
8161 appearToClass: String
,
8162 duration: [Number
, String
, Object
]
8165 // in case the child is also an abstract component, e.g. <keep-alive>
8166 // we want to recursively retrieve the real component to be rendered
8167 function getRealChild (vnode
) {
8168 var compOptions
= vnode
&& vnode
.componentOptions
;
8169 if (compOptions
&& compOptions
.Ctor
.options
.abstract) {
8170 return getRealChild(getFirstComponentChild(compOptions
.children
))
8176 function extractTransitionData (comp
) {
8178 var options
= comp
.$options
;
8180 for (var key
in options
.propsData
) {
8181 data
[key
] = comp
[key
];
8184 // extract listeners and pass them directly to the transition methods
8185 var listeners
= options
._parentListeners
;
8186 for (var key
$1 in listeners
) {
8187 data
[camelize(key
$1)] = listeners
[key
$1];
8192 function placeholder (h
, rawChild
) {
8193 if (/\d-keep-alive$/.test(rawChild
.tag
)) {
8194 return h('keep-alive', {
8195 props: rawChild
.componentOptions
.propsData
8200 function hasParentTransition (vnode
) {
8201 while ((vnode
= vnode
.parent
)) {
8202 if (vnode
.data
.transition
) {
8208 function isSameChild (child
, oldChild
) {
8209 return oldChild
.key
=== child
.key
&& oldChild
.tag
=== child
.tag
8214 props: transitionProps
,
8217 render: function render (h
) {
8220 var children
= this.$slots
.default;
8225 // filter out text nodes (possible whitespaces)
8226 children
= children
.filter(function (c
) { return c
.tag
|| isAsyncPlaceholder(c
); });
8227 /* istanbul ignore if */
8228 if (!children
.length
) {
8232 // warn multiple elements
8233 if ("development" !== 'production' && children
.length
> 1) {
8235 '<transition> can only be used on a single element. Use ' +
8236 '<transition-group> for lists.',
8241 var mode
= this.mode
;
8243 // warn invalid mode
8244 if ("development" !== 'production' &&
8245 mode
&& mode
!== 'in-out' && mode
!== 'out-in'
8248 'invalid <transition> mode: ' + mode
,
8253 var rawChild
= children
[0];
8255 // if this is a component root node and the component's
8256 // parent container node also has transition, skip.
8257 if (hasParentTransition(this.$vnode
)) {
8261 // apply transition data to child
8262 // use getRealChild() to ignore abstract components e.g. keep-alive
8263 var child
= getRealChild(rawChild
);
8264 /* istanbul ignore if */
8269 if (this._leaving
) {
8270 return placeholder(h
, rawChild
)
8273 // ensure a key that is unique to the vnode type and to this transition
8274 // component instance. This key will be used to remove pending leaving nodes
8276 var id
= "__transition-" + (this._uid
) + "-";
8277 child
.key
= child
.key
== null
8281 : isPrimitive(child
.key
)
8282 ? (String(child
.key
).indexOf(id
) === 0 ? child
.key : id
+ child
.key
)
8285 var data
= (child
.data
|| (child
.data
= {})).transition
= extractTransitionData(this);
8286 var oldRawChild
= this._vnode
;
8287 var oldChild
= getRealChild(oldRawChild
);
8290 // so that the transition module can hand over the control to the directive
8291 if (child
.data
.directives
&& child
.data
.directives
.some(function (d
) { return d
.name
=== 'show'; })) {
8292 child
.data
.show
= true;
8298 !isSameChild(child
, oldChild
) &&
8299 !isAsyncPlaceholder(oldChild
) &&
8300 // #6687 component root is a comment node
8301 !(oldChild
.componentInstance
&& oldChild
.componentInstance
._vnode
.isComment
)
8303 // replace old child transition data with fresh one
8304 // important for dynamic transitions!
8305 var oldData
= oldChild
.data
.transition
= extend({}, data
);
8306 // handle transition mode
8307 if (mode
=== 'out-in') {
8308 // return placeholder node and queue update when leave finishes
8309 this._leaving
= true;
8310 mergeVNodeHook(oldData
, 'afterLeave', function () {
8311 this$1._leaving
= false;
8312 this$1.$forceUpdate();
8314 return placeholder(h
, rawChild
)
8315 } else if (mode
=== 'in-out') {
8316 if (isAsyncPlaceholder(child
)) {
8320 var performLeave = function () { delayedLeave(); };
8321 mergeVNodeHook(data
, 'afterEnter', performLeave
);
8322 mergeVNodeHook(data
, 'enterCancelled', performLeave
);
8323 mergeVNodeHook(oldData
, 'delayLeave', function (leave
) { delayedLeave
= leave
; });
8333 // Provides transition support for list items.
8334 // supports move transitions using the FLIP technique.
8336 // Because the vdom's children update algorithm is "unstable" - i.e.
8337 // it doesn't guarantee the relative positioning of removed elements,
8338 // we force transition-group to update its children into two passes:
8339 // in the first pass, we remove all nodes that need to be removed,
8340 // triggering their leaving transition; in the second pass, we insert/move
8341 // into the final desired state. This way in the second pass removed
8342 // nodes will remain where they should be.
8344 var props
= extend({
8347 }, transitionProps
);
8351 var TransitionGroup
= {
8354 render: function render (h
) {
8355 var tag
= this.tag
|| this.$vnode
.data
.tag
|| 'span';
8356 var map
= Object
.create(null);
8357 var prevChildren
= this.prevChildren
= this.children
;
8358 var rawChildren
= this.$slots
.default || [];
8359 var children
= this.children
= [];
8360 var transitionData
= extractTransitionData(this);
8362 for (var i
= 0; i
< rawChildren
.length
; i
++) {
8363 var c
= rawChildren
[i
];
8365 if (c
.key
!= null && String(c
.key
).indexOf('__vlist') !== 0) {
8368 ;(c
.data
|| (c
.data
= {})).transition
= transitionData
;
8370 var opts
= c
.componentOptions
;
8371 var name
= opts
? (opts
.Ctor
.options
.name
|| opts
.tag
|| '') : c
.tag
;
8372 warn(("<transition-group> children must be keyed: <" + name
+ ">"));
8380 for (var i
$1 = 0; i
$1 < prevChildren
.length
; i
$1++) {
8381 var c
$1 = prevChildren
[i
$1];
8382 c
$1.data
.transition
= transitionData
;
8383 c
$1.data
.pos
= c
$1.elm
.getBoundingClientRect();
8390 this.kept
= h(tag
, null, kept
);
8391 this.removed
= removed
;
8394 return h(tag
, null, children
)
8397 beforeUpdate: function beforeUpdate () {
8398 // force removing pass
8403 true // removeOnly (!important, avoids unnecessary moves)
8405 this._vnode
= this.kept
;
8408 updated: function updated () {
8409 var children
= this.prevChildren
;
8410 var moveClass
= this.moveClass
|| ((this.name
|| 'v') + '-move');
8411 if (!children
.length
|| !this.hasMove(children
[0].elm
, moveClass
)) {
8415 // we divide the work into three loops to avoid mixing DOM reads and writes
8416 // in each iteration - which helps prevent layout thrashing.
8417 children
.forEach(callPendingCbs
);
8418 children
.forEach(recordPosition
);
8419 children
.forEach(applyTranslation
);
8421 // force reflow to put everything in position
8422 // assign to this to avoid being removed in tree-shaking
8423 // $flow-disable-line
8424 this._reflow
= document
.body
.offsetHeight
;
8426 children
.forEach(function (c
) {
8430 addTransitionClass(el
, moveClass
);
8431 s
.transform
= s
.WebkitTransform
= s
.transitionDuration
= '';
8432 el
.addEventListener(transitionEndEvent
, el
._moveCb
= function cb (e
) {
8433 if (!e
|| /transform$/.test(e
.propertyName
)) {
8434 el
.removeEventListener(transitionEndEvent
, cb
);
8436 removeTransitionClass(el
, moveClass
);
8444 hasMove: function hasMove (el
, moveClass
) {
8445 /* istanbul ignore if */
8446 if (!hasTransition
) {
8449 /* istanbul ignore if */
8450 if (this._hasMove
) {
8451 return this._hasMove
8453 // Detect whether an element with the move class applied has
8454 // CSS transitions. Since the element may be inside an entering
8455 // transition at this very moment, we make a clone of it and remove
8456 // all other transition classes applied to ensure only the move class
8458 var clone
= el
.cloneNode();
8459 if (el
._transitionClasses
) {
8460 el
._transitionClasses
.forEach(function (cls
) { removeClass(clone
, cls
); });
8462 addClass(clone
, moveClass
);
8463 clone
.style
.display
= 'none';
8464 this.$el
.appendChild(clone
);
8465 var info
= getTransitionInfo(clone
);
8466 this.$el
.removeChild(clone
);
8467 return (this._hasMove
= info
.hasTransform
)
8472 function callPendingCbs (c
) {
8473 /* istanbul ignore if */
8474 if (c
.elm
._moveCb
) {
8477 /* istanbul ignore if */
8478 if (c
.elm
._enterCb
) {
8483 function recordPosition (c
) {
8484 c
.data
.newPos
= c
.elm
.getBoundingClientRect();
8487 function applyTranslation (c
) {
8488 var oldPos
= c
.data
.pos
;
8489 var newPos
= c
.data
.newPos
;
8490 var dx
= oldPos
.left
- newPos
.left
;
8491 var dy
= oldPos
.top
- newPos
.top
;
8493 c
.data
.moved
= true;
8494 var s
= c
.elm
.style
;
8495 s
.transform
= s
.WebkitTransform
= "translate(" + dx
+ "px," + dy
+ "px)";
8496 s
.transitionDuration
= '0s';
8500 var platformComponents
= {
8501 Transition: Transition
,
8502 TransitionGroup: TransitionGroup
8507 // install platform specific utils
8508 Vue
.config
.mustUseProp
= mustUseProp
;
8509 Vue
.config
.isReservedTag
= isReservedTag
;
8510 Vue
.config
.isReservedAttr
= isReservedAttr
;
8511 Vue
.config
.getTagNamespace
= getTagNamespace
;
8512 Vue
.config
.isUnknownElement
= isUnknownElement
;
8514 // install platform runtime directives & components
8515 extend(Vue
.options
.directives
, platformDirectives
);
8516 extend(Vue
.options
.components
, platformComponents
);
8518 // install platform patch function
8519 Vue
.prototype.__patch__
= inBrowser
? patch : noop
;
8521 // public mount method
8522 Vue
.prototype.$mount = function (
8526 el
= el
&& inBrowser
? query(el
) : undefined;
8527 return mountComponent(this, el
, hydrating
)
8530 // devtools global hook
8531 /* istanbul ignore next */
8533 setTimeout(function () {
8534 if (config
.devtools
) {
8536 devtools
.emit('init', Vue
);
8538 "development" !== 'production' &&
8539 "development" !== 'test' &&
8542 console
[console
.info
? 'info' : 'log'](
8543 'Download the Vue Devtools extension for a better development experience:\n' +
8544 'https://github.com/vuejs/vue-devtools'
8548 if ("development" !== 'production' &&
8549 "development" !== 'test' &&
8550 config
.productionTip
!== false &&
8551 typeof console
!== 'undefined'
8553 console
[console
.info
? 'info' : 'log'](
8554 "You are running Vue in development mode.\n" +
8555 "Make sure to turn on production mode when deploying for production.\n" +
8556 "See more tips at https://vuejs.org/guide/deployment.html"
8564 var defaultTagRE
= /\{\{((?:.|\n)+?)\}\}/g;
8565 var regexEscapeRE
= /[-.*+?^${}()|[\]\/\\]/g;
8567 var buildRegex
= cached(function (delimiters
) {
8568 var open
= delimiters
[0].replace(regexEscapeRE
, '\\$&');
8569 var close
= delimiters
[1].replace(regexEscapeRE
, '\\$&');
8570 return new RegExp(open
+ '((?:.|\\n)+?)' + close
, 'g')
8575 function parseText (
8579 var tagRE
= delimiters
? buildRegex(delimiters
) : defaultTagRE
;
8580 if (!tagRE
.test(text
)) {
8585 var lastIndex
= tagRE
.lastIndex
= 0;
8586 var match
, index
, tokenValue
;
8587 while ((match
= tagRE
.exec(text
))) {
8588 index
= match
.index
;
8590 if (index
> lastIndex
) {
8591 rawTokens
.push(tokenValue
= text
.slice(lastIndex
, index
));
8592 tokens
.push(JSON
.stringify(tokenValue
));
8595 var exp
= parseFilters(match
[1].trim());
8596 tokens
.push(("_s(" + exp
+ ")"));
8597 rawTokens
.push({ '@binding': exp
});
8598 lastIndex
= index
+ match
[0].length
;
8600 if (lastIndex
< text
.length
) {
8601 rawTokens
.push(tokenValue
= text
.slice(lastIndex
));
8602 tokens
.push(JSON
.stringify(tokenValue
));
8605 expression: tokens
.join('+'),
8612 function transformNode (el
, options
) {
8613 var warn
= options
.warn
|| baseWarn
;
8614 var staticClass
= getAndRemoveAttr(el
, 'class');
8615 if ("development" !== 'production' && staticClass
) {
8616 var res
= parseText(staticClass
, options
.delimiters
);
8619 "class=\"" + staticClass
+ "\": " +
8620 'Interpolation inside attributes has been removed. ' +
8621 'Use v-bind or the colon shorthand instead. For example, ' +
8622 'instead of <div class="{{ val }}">, use <div :class="val">.'
8627 el
.staticClass
= JSON
.stringify(staticClass
);
8629 var classBinding
= getBindingAttr(el
, 'class', false /* getStatic */);
8631 el
.classBinding
= classBinding
;
8635 function genData (el
) {
8637 if (el
.staticClass
) {
8638 data
+= "staticClass:" + (el
.staticClass
) + ",";
8640 if (el
.classBinding
) {
8641 data
+= "class:" + (el
.classBinding
) + ",";
8647 staticKeys: ['staticClass'],
8648 transformNode: transformNode
,
8654 function transformNode
$1 (el
, options
) {
8655 var warn
= options
.warn
|| baseWarn
;
8656 var staticStyle
= getAndRemoveAttr(el
, 'style');
8658 /* istanbul ignore if */
8660 var res
= parseText(staticStyle
, options
.delimiters
);
8663 "style=\"" + staticStyle
+ "\": " +
8664 'Interpolation inside attributes has been removed. ' +
8665 'Use v-bind or the colon shorthand instead. For example, ' +
8666 'instead of <div style="{{ val }}">, use <div :style="val">.'
8670 el
.staticStyle
= JSON
.stringify(parseStyleText(staticStyle
));
8673 var styleBinding
= getBindingAttr(el
, 'style', false /* getStatic */);
8675 el
.styleBinding
= styleBinding
;
8679 function genData
$1 (el
) {
8681 if (el
.staticStyle
) {
8682 data
+= "staticStyle:" + (el
.staticStyle
) + ",";
8684 if (el
.styleBinding
) {
8685 data
+= "style:(" + (el
.styleBinding
) + "),";
8691 staticKeys: ['staticStyle'],
8692 transformNode: transformNode
$1,
8701 decode: function decode (html
) {
8702 decoder
= decoder
|| document
.createElement('div');
8703 decoder
.innerHTML
= html
;
8704 return decoder
.textContent
8710 var isUnaryTag
= makeMap(
8711 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
8712 'link,meta,param,source,track,wbr'
8715 // Elements that you can, intentionally, leave open
8716 // (and which close themselves)
8717 var canBeLeftOpenTag
= makeMap(
8718 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
8721 // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
8722 // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
8723 var isNonPhrasingTag
= makeMap(
8724 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
8725 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
8726 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
8727 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
8732 * Not type-checking this file because it's mostly vendor code.
8736 * HTML Parser By John Resig (ejohn.org)
8737 * Modified by Juriy "kangax" Zaytsev
8738 * Original code by Erik Arvidsson, Mozilla Public License
8739 * http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
8742 // Regular Expressions for parsing tags and attributes
8743 var attribute
= /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/;
8744 // could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
8745 // but for Vue templates we can enforce a simple charset
8746 var ncname
= '[a-zA-Z_][\\w\\-\\.]*';
8747 var qnameCapture
= "((?:" + ncname
+ "\\:)?" + ncname
+ ")";
8748 var startTagOpen
= new RegExp(("^<" + qnameCapture
));
8749 var startTagClose
= /^\s*(\/?)>/;
8750 var endTag
= new RegExp(("^<\\/" + qnameCapture
+ "[^>]*>"));
8751 var doctype
= /^<!DOCTYPE
[^>]+>/i
;
8752 // #7298: escape - to avoid being pased as HTML comment when inlined in page
8753 var comment
= /^<!\--/;
8754 var conditionalComment
= /^<!\[/;
8756 var IS_REGEX_CAPTURING_BROKEN
= false;
8757 'x'.replace(/x(.)?/g, function (m
, g
) {
8758 IS_REGEX_CAPTURING_BROKEN
= g
=== '';
8761 // Special Elements (can contain anything)
8762 var isPlainTextElement
= makeMap('script,style,textarea', true);
8773 var encodedAttr
= /&(?:lt|gt|quot|amp);/g;
8774 var encodedAttrWithNewLines
= /&(?:lt|gt|quot|amp|#10|#9);/g;
8777 var isIgnoreNewlineTag
= makeMap('pre,textarea', true);
8778 var shouldIgnoreFirstNewline = function (tag
, html
) { return tag
&& isIgnoreNewlineTag(tag
) && html
[0] === '\n'; };
8780 function decodeAttr (value
, shouldDecodeNewlines
) {
8781 var re
= shouldDecodeNewlines
? encodedAttrWithNewLines : encodedAttr
;
8782 return value
.replace(re
, function (match
) { return decodingMap
[match
]; })
8785 function parseHTML (html
, options
) {
8787 var expectHTML
= options
.expectHTML
;
8788 var isUnaryTag
$$1 = options
.isUnaryTag
|| no
;
8789 var canBeLeftOpenTag
$$1 = options
.canBeLeftOpenTag
|| no
;
8794 // Make sure we're not in a plaintext content element like script/style
8795 if (!lastTag
|| !isPlainTextElement(lastTag
)) {
8796 var textEnd
= html
.indexOf('<');
8797 if (textEnd
=== 0) {
8799 if (comment
.test(html
)) {
8800 var commentEnd
= html
.indexOf('-->');
8802 if (commentEnd
>= 0) {
8803 if (options
.shouldKeepComment
) {
8804 options
.comment(html
.substring(4, commentEnd
));
8806 advance(commentEnd
+ 3);
8811 // http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment
8812 if (conditionalComment
.test(html
)) {
8813 var conditionalEnd
= html
.indexOf(']>');
8815 if (conditionalEnd
>= 0) {
8816 advance(conditionalEnd
+ 2);
8822 var doctypeMatch
= html
.match(doctype
);
8824 advance(doctypeMatch
[0].length
);
8829 var endTagMatch
= html
.match(endTag
);
8831 var curIndex
= index
;
8832 advance(endTagMatch
[0].length
);
8833 parseEndTag(endTagMatch
[1], curIndex
, index
);
8838 var startTagMatch
= parseStartTag();
8839 if (startTagMatch
) {
8840 handleStartTag(startTagMatch
);
8841 if (shouldIgnoreFirstNewline(lastTag
, html
)) {
8848 var text
= (void 0), rest
= (void 0), next
= (void 0);
8850 rest
= html
.slice(textEnd
);
8852 !endTag
.test(rest
) &&
8853 !startTagOpen
.test(rest
) &&
8854 !comment
.test(rest
) &&
8855 !conditionalComment
.test(rest
)
8857 // < in plain text, be forgiving and treat it as text
8858 next
= rest
.indexOf('<', 1);
8859 if (next
< 0) { break }
8861 rest
= html
.slice(textEnd
);
8863 text
= html
.substring(0, textEnd
);
8872 if (options
.chars
&& text
) {
8873 options
.chars(text
);
8876 var endTagLength
= 0;
8877 var stackedTag
= lastTag
.toLowerCase();
8878 var reStackedTag
= reCache
[stackedTag
] || (reCache
[stackedTag
] = new RegExp('([\\s\\S]*?)(</' + stackedTag
+ '[^>]*>)', 'i'));
8879 var rest
$1 = html
.replace(reStackedTag
, function (all
, text
, endTag
) {
8880 endTagLength
= endTag
.length
;
8881 if (!isPlainTextElement(stackedTag
) && stackedTag
!== 'noscript') {
8883 .replace(/<!\--([\s\S]*?)-->/g, '$1') // #7298
8884 .replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1');
8886 if (shouldIgnoreFirstNewline(stackedTag
, text
)) {
8887 text
= text
.slice(1);
8889 if (options
.chars
) {
8890 options
.chars(text
);
8894 index
+= html
.length
- rest
$1.length
;
8896 parseEndTag(stackedTag
, index
- endTagLength
, index
);
8899 if (html
=== last
) {
8900 options
.chars
&& options
.chars(html
);
8901 if ("development" !== 'production' && !stack
.length
&& options
.warn
) {
8902 options
.warn(("Mal-formatted tag at end of template: \"" + html
+ "\""));
8908 // Clean up any remaining tags
8911 function advance (n
) {
8913 html
= html
.substring(n
);
8916 function parseStartTag () {
8917 var start
= html
.match(startTagOpen
);
8924 advance(start
[0].length
);
8926 while (!(end
= html
.match(startTagClose
)) && (attr
= html
.match(attribute
))) {
8927 advance(attr
[0].length
);
8928 match
.attrs
.push(attr
);
8931 match
.unarySlash
= end
[1];
8932 advance(end
[0].length
);
8939 function handleStartTag (match
) {
8940 var tagName
= match
.tagName
;
8941 var unarySlash
= match
.unarySlash
;
8944 if (lastTag
=== 'p' && isNonPhrasingTag(tagName
)) {
8945 parseEndTag(lastTag
);
8947 if (canBeLeftOpenTag
$$1(tagName
) && lastTag
=== tagName
) {
8948 parseEndTag(tagName
);
8952 var unary
= isUnaryTag
$$1(tagName
) || !!unarySlash
;
8954 var l
= match
.attrs
.length
;
8955 var attrs
= new Array(l
);
8956 for (var i
= 0; i
< l
; i
++) {
8957 var args
= match
.attrs
[i
];
8958 // hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778
8959 if (IS_REGEX_CAPTURING_BROKEN
&& args
[0].indexOf('""') === -1) {
8960 if (args
[3] === '') { delete args
[3]; }
8961 if (args
[4] === '') { delete args
[4]; }
8962 if (args
[5] === '') { delete args
[5]; }
8964 var value
= args
[3] || args
[4] || args
[5] || '';
8965 var shouldDecodeNewlines
= tagName
=== 'a' && args
[1] === 'href'
8966 ? options
.shouldDecodeNewlinesForHref
8967 : options
.shouldDecodeNewlines
;
8970 value: decodeAttr(value
, shouldDecodeNewlines
)
8975 stack
.push({ tag: tagName
, lowerCasedTag: tagName
.toLowerCase(), attrs: attrs
});
8979 if (options
.start
) {
8980 options
.start(tagName
, attrs
, unary
, match
.start
, match
.end
);
8984 function parseEndTag (tagName
, start
, end
) {
8985 var pos
, lowerCasedTagName
;
8986 if (start
== null) { start
= index
; }
8987 if (end
== null) { end
= index
; }
8990 lowerCasedTagName
= tagName
.toLowerCase();
8993 // Find the closest opened tag of the same type
8995 for (pos
= stack
.length
- 1; pos
>= 0; pos
--) {
8996 if (stack
[pos
].lowerCasedTag
=== lowerCasedTagName
) {
9001 // If no tag name is provided, clean shop
9006 // Close all the open elements, up the stack
9007 for (var i
= stack
.length
- 1; i
>= pos
; i
--) {
9008 if ("development" !== 'production' &&
9009 (i
> pos
|| !tagName
) &&
9013 ("tag <" + (stack
[i
].tag
) + "> has no matching end tag.")
9017 options
.end(stack
[i
].tag
, start
, end
);
9021 // Remove the open elements from the stack
9023 lastTag
= pos
&& stack
[pos
- 1].tag
;
9024 } else if (lowerCasedTagName
=== 'br') {
9025 if (options
.start
) {
9026 options
.start(tagName
, [], true, start
, end
);
9028 } else if (lowerCasedTagName
=== 'p') {
9029 if (options
.start
) {
9030 options
.start(tagName
, [], false, start
, end
);
9033 options
.end(tagName
, start
, end
);
9041 var onRE
= /^@|^v-on:/;
9042 var dirRE
= /^v-|^@|^:/;
9043 var forAliasRE
= /([^]*?)\s+(?:in|of)\s+([^]*)/;
9044 var forIteratorRE
= /,([^,\}\]]*)(?:,([^,\}\]]*))?$/;
9045 var stripParensRE
= /^\(|\)$/g;
9047 var argRE
= /:(.*)$/;
9048 var bindRE
= /^:|^v-bind:/;
9049 var modifierRE
= /\.[^.]+/g;
9051 var decodeHTMLCached
= cached(he
.decode
);
9053 // configurable state
9059 var platformIsPreTag
;
9060 var platformMustUseProp
;
9061 var platformGetTagNamespace
;
9065 function createASTElement (
9074 attrsMap: makeAttrsMap(attrs
),
9081 * Convert HTML string to AST.
9087 warn
$2 = options
.warn
|| baseWarn
;
9089 platformIsPreTag
= options
.isPreTag
|| no
;
9090 platformMustUseProp
= options
.mustUseProp
|| no
;
9091 platformGetTagNamespace
= options
.getTagNamespace
|| no
;
9093 transforms
= pluckModuleFunction(options
.modules
, 'transformNode');
9094 preTransforms
= pluckModuleFunction(options
.modules
, 'preTransformNode');
9095 postTransforms
= pluckModuleFunction(options
.modules
, 'postTransformNode');
9097 delimiters
= options
.delimiters
;
9100 var preserveWhitespace
= options
.preserveWhitespace
!== false;
9107 function warnOnce (msg
) {
9114 function closeElement (element
) {
9119 if (platformIsPreTag(element
.tag
)) {
9122 // apply post-transforms
9123 for (var i
= 0; i
< postTransforms
.length
; i
++) {
9124 postTransforms
[i
](element
, options
);
9128 parseHTML(template
, {
9130 expectHTML: options
.expectHTML
,
9131 isUnaryTag: options
.isUnaryTag
,
9132 canBeLeftOpenTag: options
.canBeLeftOpenTag
,
9133 shouldDecodeNewlines: options
.shouldDecodeNewlines
,
9134 shouldDecodeNewlinesForHref: options
.shouldDecodeNewlinesForHref
,
9135 shouldKeepComment: options
.comments
,
9136 start: function start (tag
, attrs
, unary
) {
9138 // inherit parent ns if there is one
9139 var ns
= (currentParent
&& currentParent
.ns
) || platformGetTagNamespace(tag
);
9141 // handle IE svg bug
9142 /* istanbul ignore if */
9143 if (isIE
&& ns
=== 'svg') {
9144 attrs
= guardIESVGBug(attrs
);
9147 var element
= createASTElement(tag
, attrs
, currentParent
);
9152 if (isForbiddenTag(element
) && !isServerRendering()) {
9153 element
.forbidden
= true;
9154 "development" !== 'production' && warn
$2(
9155 'Templates should only be responsible for mapping the state to the ' +
9156 'UI. Avoid placing tags with side-effects in your templates, such as ' +
9157 "<" + tag
+ ">" + ', as they will not be parsed.'
9161 // apply pre-transforms
9162 for (var i
= 0; i
< preTransforms
.length
; i
++) {
9163 element
= preTransforms
[i
](element
, options
) || element
;
9167 processPre(element
);
9172 if (platformIsPreTag(element
.tag
)) {
9176 processRawAttrs(element
);
9177 } else if (!element
.processed
) {
9178 // structural directives
9179 processFor(element
);
9181 processOnce(element
);
9182 // element-scope stuff
9183 processElement(element
, options
);
9186 function checkRootConstraints (el
) {
9188 if (el
.tag
=== 'slot' || el
.tag
=== 'template') {
9190 "Cannot use <" + (el
.tag
) + "> as component root element because it may " +
9191 'contain multiple nodes.'
9194 if (el
.attrsMap
.hasOwnProperty('v-for')) {
9196 'Cannot use v-for on stateful component root element because ' +
9197 'it renders multiple elements.'
9206 checkRootConstraints(root
);
9207 } else if (!stack
.length
) {
9208 // allow root elements with v-if, v-else-if and v-else
9209 if (root
.if && (element
.elseif
|| element
.else)) {
9210 checkRootConstraints(element
);
9211 addIfCondition(root
, {
9212 exp: element
.elseif
,
9217 "Component template should contain exactly one root element. " +
9218 "If you are using v-if on multiple elements, " +
9219 "use v-else-if to chain them instead."
9223 if (currentParent
&& !element
.forbidden
) {
9224 if (element
.elseif
|| element
.else) {
9225 processIfConditions(element
, currentParent
);
9226 } else if (element
.slotScope
) { // scoped slot
9227 currentParent
.plain
= false;
9228 var name
= element
.slotTarget
|| '"default"';(currentParent
.scopedSlots
|| (currentParent
.scopedSlots
= {}))[name
] = element
;
9230 currentParent
.children
.push(element
);
9231 element
.parent
= currentParent
;
9235 currentParent
= element
;
9236 stack
.push(element
);
9238 closeElement(element
);
9242 end: function end () {
9243 // remove trailing whitespace
9244 var element
= stack
[stack
.length
- 1];
9245 var lastNode
= element
.children
[element
.children
.length
- 1];
9246 if (lastNode
&& lastNode
.type
=== 3 && lastNode
.text
=== ' ' && !inPre
) {
9247 element
.children
.pop();
9251 currentParent
= stack
[stack
.length
- 1];
9252 closeElement(element
);
9255 chars: function chars (text
) {
9256 if (!currentParent
) {
9258 if (text
=== template
) {
9260 'Component template requires a root element, rather than just text.'
9262 } else if ((text
= text
.trim())) {
9264 ("text \"" + text
+ "\" outside root element will be ignored.")
9270 // IE textarea placeholder bug
9271 /* istanbul ignore if */
9273 currentParent
.tag
=== 'textarea' &&
9274 currentParent
.attrsMap
.placeholder
=== text
9278 var children
= currentParent
.children
;
9279 text
= inPre
|| text
.trim()
9280 ? isTextTag(currentParent
) ? text : decodeHTMLCached(text
)
9281 // only preserve whitespace if its not right after a starting tag
9282 : preserveWhitespace
&& children
.length
? ' ' : '';
9285 if (!inVPre
&& text
!== ' ' && (res
= parseText(text
, delimiters
))) {
9288 expression: res
.expression
,
9292 } else if (text
!== ' ' || !children
.length
|| children
[children
.length
- 1].text
!== ' ') {
9300 comment: function comment (text
) {
9301 currentParent
.children
.push({
9311 function processPre (el
) {
9312 if (getAndRemoveAttr(el
, 'v-pre') != null) {
9317 function processRawAttrs (el
) {
9318 var l
= el
.attrsList
.length
;
9320 var attrs
= el
.attrs
= new Array(l
);
9321 for (var i
= 0; i
< l
; i
++) {
9323 name: el
.attrsList
[i
].name
,
9324 value: JSON
.stringify(el
.attrsList
[i
].value
)
9327 } else if (!el
.pre
) {
9328 // non root node in pre blocks with no attributes
9333 function processElement (element
, options
) {
9334 processKey(element
);
9336 // determine whether this is a plain element after
9337 // removing structural attributes
9338 element
.plain
= !element
.key
&& !element
.attrsList
.length
;
9340 processRef(element
);
9341 processSlot(element
);
9342 processComponent(element
);
9343 for (var i
= 0; i
< transforms
.length
; i
++) {
9344 element
= transforms
[i
](element
, options
) || element
;
9346 processAttrs(element
);
9349 function processKey (el
) {
9350 var exp
= getBindingAttr(el
, 'key');
9352 if ("development" !== 'production' && el
.tag
=== 'template') {
9353 warn
$2("<template> cannot be keyed. Place the key on real elements instead.");
9359 function processRef (el
) {
9360 var ref
= getBindingAttr(el
, 'ref');
9363 el
.refInFor
= checkInFor(el
);
9367 function processFor (el
) {
9369 if ((exp
= getAndRemoveAttr(el
, 'v-for'))) {
9370 var res
= parseFor(exp
);
9375 ("Invalid v-for expression: " + exp
)
9383 function parseFor (exp
) {
9384 var inMatch
= exp
.match(forAliasRE
);
9385 if (!inMatch
) { return }
9387 res
.for = inMatch
[2].trim();
9388 var alias
= inMatch
[1].trim().replace(stripParensRE
, '');
9389 var iteratorMatch
= alias
.match(forIteratorRE
);
9390 if (iteratorMatch
) {
9391 res
.alias
= alias
.replace(forIteratorRE
, '');
9392 res
.iterator1
= iteratorMatch
[1].trim();
9393 if (iteratorMatch
[2]) {
9394 res
.iterator2
= iteratorMatch
[2].trim();
9402 function processIf (el
) {
9403 var exp
= getAndRemoveAttr(el
, 'v-if');
9406 addIfCondition(el
, {
9411 if (getAndRemoveAttr(el
, 'v-else') != null) {
9414 var elseif
= getAndRemoveAttr(el
, 'v-else-if');
9421 function processIfConditions (el
, parent
) {
9422 var prev
= findPrevElement(parent
.children
);
9423 if (prev
&& prev
.if) {
9424 addIfCondition(prev
, {
9430 "v-" + (el
.elseif
? ('else-if="' + el
.elseif
+ '"') : 'else') + " " +
9431 "used on element <" + (el
.tag
) + "> without corresponding v-if."
9436 function findPrevElement (children
) {
9437 var i
= children
.length
;
9439 if (children
[i
].type
=== 1) {
9442 if ("development" !== 'production' && children
[i
].text
!== ' ') {
9444 "text \"" + (children
[i
].text
.trim()) + "\" between v-if and v-else(-if) " +
9453 function addIfCondition (el
, condition
) {
9454 if (!el
.ifConditions
) {
9455 el
.ifConditions
= [];
9457 el
.ifConditions
.push(condition
);
9460 function processOnce (el
) {
9461 var once
$$1 = getAndRemoveAttr(el
, 'v-once');
9462 if (once
$$1 != null) {
9467 function processSlot (el
) {
9468 if (el
.tag
=== 'slot') {
9469 el
.slotName
= getBindingAttr(el
, 'name');
9470 if ("development" !== 'production' && el
.key
) {
9472 "`key` does not work on <slot> because slots are abstract outlets " +
9473 "and can possibly expand into multiple elements. " +
9474 "Use the key on a wrapping element instead."
9479 if (el
.tag
=== 'template') {
9480 slotScope
= getAndRemoveAttr(el
, 'scope');
9481 /* istanbul ignore if */
9482 if ("development" !== 'production' && slotScope
) {
9484 "the \"scope\" attribute for scoped slots have been deprecated and " +
9485 "replaced by \"slot-scope\" since 2.5. The new \"slot-scope\" attribute " +
9486 "can also be used on plain elements in addition to <template> to " +
9487 "denote scoped slots.",
9491 el
.slotScope
= slotScope
|| getAndRemoveAttr(el
, 'slot-scope');
9492 } else if ((slotScope
= getAndRemoveAttr(el
, 'slot-scope'))) {
9493 /* istanbul ignore if */
9494 if ("development" !== 'production' && el
.attrsMap
['v-for']) {
9496 "Ambiguous combined usage of slot-scope and v-for on <" + (el
.tag
) + "> " +
9497 "(v-for takes higher priority). Use a wrapper <template> for the " +
9498 "scoped slot to make it clearer.",
9502 el
.slotScope
= slotScope
;
9504 var slotTarget
= getBindingAttr(el
, 'slot');
9506 el
.slotTarget
= slotTarget
=== '""' ? '"default"' : slotTarget
;
9507 // preserve slot as an attribute for native shadow DOM compat
9508 // only for non-scoped slots.
9509 if (el
.tag
!== 'template' && !el
.slotScope
) {
9510 addAttr(el
, 'slot', slotTarget
);
9516 function processComponent (el
) {
9518 if ((binding
= getBindingAttr(el
, 'is'))) {
9519 el
.component
= binding
;
9521 if (getAndRemoveAttr(el
, 'inline-template') != null) {
9522 el
.inlineTemplate
= true;
9526 function processAttrs (el
) {
9527 var list
= el
.attrsList
;
9528 var i
, l
, name
, rawName
, value
, modifiers
, isProp
;
9529 for (i
= 0, l
= list
.length
; i
< l
; i
++) {
9530 name
= rawName
= list
[i
].name
;
9531 value
= list
[i
].value
;
9532 if (dirRE
.test(name
)) {
9533 // mark element as dynamic
9534 el
.hasBindings
= true;
9536 modifiers
= parseModifiers(name
);
9538 name
= name
.replace(modifierRE
, '');
9540 if (bindRE
.test(name
)) { // v-bind
9541 name
= name
.replace(bindRE
, '');
9542 value
= parseFilters(value
);
9545 if (modifiers
.prop
) {
9547 name
= camelize(name
);
9548 if (name
=== 'innerHtml') { name
= 'innerHTML'; }
9550 if (modifiers
.camel
) {
9551 name
= camelize(name
);
9553 if (modifiers
.sync
) {
9556 ("update:" + (camelize(name
))),
9557 genAssignmentCode(value
, "$event")
9562 !el
.component
&& platformMustUseProp(el
.tag
, el
.attrsMap
.type
, name
)
9564 addProp(el
, name
, value
);
9566 addAttr(el
, name
, value
);
9568 } else if (onRE
.test(name
)) { // v-on
9569 name
= name
.replace(onRE
, '');
9570 addHandler(el
, name
, value
, modifiers
, false, warn
$2);
9571 } else { // normal directives
9572 name
= name
.replace(dirRE
, '');
9574 var argMatch
= name
.match(argRE
);
9575 var arg
= argMatch
&& argMatch
[1];
9577 name
= name
.slice(0, -(arg
.length
+ 1));
9579 addDirective(el
, name
, rawName
, value
, arg
, modifiers
);
9580 if ("development" !== 'production' && name
=== 'model') {
9581 checkForAliasModel(el
, value
);
9585 // literal attribute
9587 var res
= parseText(value
, delimiters
);
9590 name
+ "=\"" + value
+ "\": " +
9591 'Interpolation inside attributes has been removed. ' +
9592 'Use v-bind or the colon shorthand instead. For example, ' +
9593 'instead of <div id="{{ val }}">, use <div :id="val">.'
9597 addAttr(el
, name
, JSON
.stringify(value
));
9598 // #6887 firefox doesn't update muted state if set via attribute
9599 // even immediately after element creation
9600 if (!el
.component
&&
9602 platformMustUseProp(el
.tag
, el
.attrsMap
.type
, name
)) {
9603 addProp(el
, name
, 'true');
9609 function checkInFor (el
) {
9612 if (parent
.for !== undefined) {
9615 parent
= parent
.parent
;
9620 function parseModifiers (name
) {
9621 var match
= name
.match(modifierRE
);
9624 match
.forEach(function (m
) { ret
[m
.slice(1)] = true; });
9629 function makeAttrsMap (attrs
) {
9631 for (var i
= 0, l
= attrs
.length
; i
< l
; i
++) {
9633 "development" !== 'production' &&
9634 map
[attrs
[i
].name
] && !isIE
&& !isEdge
9636 warn
$2('duplicate attribute: ' + attrs
[i
].name
);
9638 map
[attrs
[i
].name
] = attrs
[i
].value
;
9643 // for script (e.g. type="x/template") or style, do not decode content
9644 function isTextTag (el
) {
9645 return el
.tag
=== 'script' || el
.tag
=== 'style'
9648 function isForbiddenTag (el
) {
9650 el
.tag
=== 'style' ||
9651 (el
.tag
=== 'script' && (
9652 !el
.attrsMap
.type
||
9653 el
.attrsMap
.type
=== 'text/javascript'
9658 var ieNSBug
= /^xmlns:NS\d+/;
9659 var ieNSPrefix
= /^NS\d+:/;
9661 /* istanbul ignore next */
9662 function guardIESVGBug (attrs
) {
9664 for (var i
= 0; i
< attrs
.length
; i
++) {
9665 var attr
= attrs
[i
];
9666 if (!ieNSBug
.test(attr
.name
)) {
9667 attr
.name
= attr
.name
.replace(ieNSPrefix
, '');
9674 function checkForAliasModel (el
, value
) {
9677 if (_el
.for && _el
.alias
=== value
) {
9679 "<" + (el
.tag
) + " v-model=\"" + value
+ "\">: " +
9680 "You are binding v-model directly to a v-for iteration alias. " +
9681 "This will not be able to modify the v-for source array because " +
9682 "writing to the alias is like modifying a function local variable. " +
9683 "Consider using an array of objects and use v-model on an object property instead."
9693 * Expand input[v-model] with dyanmic type bindings into v-if-else chains
9695 * <input v-model="data[type]" :type="type">
9697 * <input v-if="type === 'checkbox'" type="checkbox" v-model="data[type]">
9698 * <input v-else-if="type === 'radio'" type="radio" v-model="data[type]">
9699 * <input v-else :type="type" v-model="data[type]">
9702 function preTransformNode (el
, options
) {
9703 if (el
.tag
=== 'input') {
9704 var map
= el
.attrsMap
;
9705 if (!map
['v-model']) {
9710 if (map
[':type'] || map
['v-bind:type']) {
9711 typeBinding
= getBindingAttr(el
, 'type');
9713 if (!map
.type
&& !typeBinding
&& map
['v-bind']) {
9714 typeBinding
= "(" + (map
['v-bind']) + ").type";
9718 var ifCondition
= getAndRemoveAttr(el
, 'v-if', true);
9719 var ifConditionExtra
= ifCondition
? ("&&(" + ifCondition
+ ")") : "";
9720 var hasElse
= getAndRemoveAttr(el
, 'v-else', true) != null;
9721 var elseIfCondition
= getAndRemoveAttr(el
, 'v-else-if', true);
9723 var branch0
= cloneASTElement(el
);
9724 // process for on the main node
9725 processFor(branch0
);
9726 addRawAttr(branch0
, 'type', 'checkbox');
9727 processElement(branch0
, options
);
9728 branch0
.processed
= true; // prevent it from double-processed
9729 branch0
.if = "(" + typeBinding
+ ")==='checkbox'" + ifConditionExtra
;
9730 addIfCondition(branch0
, {
9734 // 2. add radio else-if condition
9735 var branch1
= cloneASTElement(el
);
9736 getAndRemoveAttr(branch1
, 'v-for', true);
9737 addRawAttr(branch1
, 'type', 'radio');
9738 processElement(branch1
, options
);
9739 addIfCondition(branch0
, {
9740 exp: "(" + typeBinding
+ ")==='radio'" + ifConditionExtra
,
9744 var branch2
= cloneASTElement(el
);
9745 getAndRemoveAttr(branch2
, 'v-for', true);
9746 addRawAttr(branch2
, ':type', typeBinding
);
9747 processElement(branch2
, options
);
9748 addIfCondition(branch0
, {
9754 branch0
.else = true;
9755 } else if (elseIfCondition
) {
9756 branch0
.elseif
= elseIfCondition
;
9764 function cloneASTElement (el
) {
9765 return createASTElement(el
.tag
, el
.attrsList
.slice(), el
.parent
)
9769 preTransformNode: preTransformNode
9780 function text (el
, dir
) {
9782 addProp(el
, 'textContent', ("_s(" + (dir
.value
) + ")"));
9788 function html (el
, dir
) {
9790 addProp(el
, 'innerHTML', ("_s(" + (dir
.value
) + ")"));
9794 var directives
$1 = {
9805 directives: directives
$1,
9807 isUnaryTag: isUnaryTag
,
9808 mustUseProp: mustUseProp
,
9809 canBeLeftOpenTag: canBeLeftOpenTag
,
9810 isReservedTag: isReservedTag
,
9811 getTagNamespace: getTagNamespace
,
9812 staticKeys: genStaticKeys(modules
$1)
9818 var isPlatformReservedTag
;
9820 var genStaticKeysCached
= cached(genStaticKeys
$1);
9823 * Goal of the optimizer: walk the generated template AST tree
9824 * and detect sub-trees that are purely static, i.e. parts of
9825 * the DOM that never needs to change.
9827 * Once we detect these sub-trees, we can:
9829 * 1. Hoist them into constants, so that we no longer need to
9830 * create fresh nodes for them on each re-render;
9831 * 2. Completely skip them in the patching process.
9833 function optimize (root
, options
) {
9834 if (!root
) { return }
9835 isStaticKey
= genStaticKeysCached(options
.staticKeys
|| '');
9836 isPlatformReservedTag
= options
.isReservedTag
|| no
;
9837 // first pass: mark all non-static nodes.
9839 // second pass: mark static roots.
9840 markStaticRoots(root
, false);
9843 function genStaticKeys
$1 (keys
) {
9845 'type,tag,attrsList,attrsMap,plain,parent,children,attrs' +
9846 (keys
? ',' + keys : '')
9850 function markStatic
$1 (node
) {
9851 node
.static = isStatic(node
);
9852 if (node
.type
=== 1) {
9853 // do not make component slot content static. this avoids
9854 // 1. components not able to mutate slot nodes
9855 // 2. static slot content fails for hot-reloading
9857 !isPlatformReservedTag(node
.tag
) &&
9858 node
.tag
!== 'slot' &&
9859 node
.attrsMap
['inline-template'] == null
9863 for (var i
= 0, l
= node
.children
.length
; i
< l
; i
++) {
9864 var child
= node
.children
[i
];
9865 markStatic
$1(child
);
9866 if (!child
.static) {
9867 node
.static = false;
9870 if (node
.ifConditions
) {
9871 for (var i
$1 = 1, l
$1 = node
.ifConditions
.length
; i
$1 < l
$1; i
$1++) {
9872 var block
= node
.ifConditions
[i
$1].block
;
9873 markStatic
$1(block
);
9874 if (!block
.static) {
9875 node
.static = false;
9882 function markStaticRoots (node
, isInFor
) {
9883 if (node
.type
=== 1) {
9884 if (node
.static || node
.once
) {
9885 node
.staticInFor
= isInFor
;
9887 // For a node to qualify as a static root, it should have children that
9888 // are not just static text. Otherwise the cost of hoisting out will
9889 // outweigh the benefits and it's better off to just always render it fresh.
9890 if (node
.static && node
.children
.length
&& !(
9891 node
.children
.length
=== 1 &&
9892 node
.children
[0].type
=== 3
9894 node
.staticRoot
= true;
9897 node
.staticRoot
= false;
9899 if (node
.children
) {
9900 for (var i
= 0, l
= node
.children
.length
; i
< l
; i
++) {
9901 markStaticRoots(node
.children
[i
], isInFor
|| !!node
.for);
9904 if (node
.ifConditions
) {
9905 for (var i
$1 = 1, l
$1 = node
.ifConditions
.length
; i
$1 < l
$1; i
$1++) {
9906 markStaticRoots(node
.ifConditions
[i
$1].block
, isInFor
);
9912 function isStatic (node
) {
9913 if (node
.type
=== 2) { // expression
9916 if (node
.type
=== 3) { // text
9919 return !!(node
.pre
|| (
9920 !node
.hasBindings
&& // no dynamic bindings
9921 !node
.if && !node
.for && // not v-if or v-for or v-else
9922 !isBuiltInTag(node
.tag
) && // not a built-in
9923 isPlatformReservedTag(node
.tag
) && // not a component
9924 !isDirectChildOfTemplateFor(node
) &&
9925 Object
.keys(node
).every(isStaticKey
)
9929 function isDirectChildOfTemplateFor (node
) {
9930 while (node
.parent
) {
9932 if (node
.tag
!== 'template') {
9944 var fnExpRE
= /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
9945 var simplePathRE
= /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
9947 // KeyboardEvent.keyCode aliases
9960 // KeyboardEvent.key aliases
9966 // #7806: IE11 uses key names without `Arrow` prefix for arrow keys.
9967 up: ['Up', 'ArrowUp'],
9968 left: ['Left', 'ArrowLeft'],
9969 right: ['Right', 'ArrowRight'],
9970 down: ['Down', 'ArrowDown'],
9971 'delete': ['Backspace', 'Delete']
9974 // #4868: modifiers that prevent the execution of the listener
9975 // need to explicitly return null so that we can determine whether to remove
9976 // the listener for .once
9977 var genGuard = function (condition
) { return ("if(" + condition
+ ")return null;"); };
9979 var modifierCode
= {
9980 stop: '$event.stopPropagation();',
9981 prevent: '$event.preventDefault();',
9982 self: genGuard("$event.target !== $event.currentTarget"),
9983 ctrl: genGuard("!$event.ctrlKey"),
9984 shift: genGuard("!$event.shiftKey"),
9985 alt: genGuard("!$event.altKey"),
9986 meta: genGuard("!$event.metaKey"),
9987 left: genGuard("'button' in $event && $event.button !== 0"),
9988 middle: genGuard("'button' in $event && $event.button !== 1"),
9989 right: genGuard("'button' in $event && $event.button !== 2")
9992 function genHandlers (
9997 var res
= isNative
? 'nativeOn:{' : 'on:{';
9998 for (var name
in events
) {
9999 res
+= "\"" + name
+ "\":" + (genHandler(name
, events
[name
])) + ",";
10001 return res
.slice(0, -1) + '}'
10004 function genHandler (
10009 return 'function(){}'
10012 if (Array
.isArray(handler
)) {
10013 return ("[" + (handler
.map(function (handler
) { return genHandler(name
, handler
); }).join(',')) + "]")
10016 var isMethodPath
= simplePathRE
.test(handler
.value
);
10017 var isFunctionExpression
= fnExpRE
.test(handler
.value
);
10019 if (!handler
.modifiers
) {
10020 if (isMethodPath
|| isFunctionExpression
) {
10021 return handler
.value
10023 /* istanbul ignore if */
10024 return ("function($event){" + (handler
.value
) + "}") // inline statement
10027 var genModifierCode
= '';
10029 for (var key
in handler
.modifiers
) {
10030 if (modifierCode
[key
]) {
10031 genModifierCode
+= modifierCode
[key
];
10033 if (keyCodes
[key
]) {
10036 } else if (key
=== 'exact') {
10037 var modifiers
= (handler
.modifiers
);
10038 genModifierCode
+= genGuard(
10039 ['ctrl', 'shift', 'alt', 'meta']
10040 .filter(function (keyModifier
) { return !modifiers
[keyModifier
]; })
10041 .map(function (keyModifier
) { return ("$event." + keyModifier
+ "Key"); })
10049 code
+= genKeyFilter(keys
);
10051 // Make sure modifiers like prevent and stop get executed after key filtering
10052 if (genModifierCode
) {
10053 code
+= genModifierCode
;
10055 var handlerCode
= isMethodPath
10056 ? ("return " + (handler
.value
) + "($event)")
10057 : isFunctionExpression
10058 ? ("return (" + (handler
.value
) + ")($event)")
10060 /* istanbul ignore if */
10061 return ("function($event){" + code
+ handlerCode
+ "}")
10065 function genKeyFilter (keys
) {
10066 return ("if(!('button' in $event)&&" + (keys
.map(genFilterCode
).join('&&')) + ")return null;")
10069 function genFilterCode (key
) {
10070 var keyVal
= parseInt(key
, 10);
10072 return ("$event.keyCode!==" + keyVal
)
10074 var keyCode
= keyCodes
[key
];
10075 var keyName
= keyNames
[key
];
10077 "_k($event.keyCode," +
10078 (JSON
.stringify(key
)) + "," +
10079 (JSON
.stringify(keyCode
)) + "," +
10081 "" + (JSON
.stringify(keyName
)) +
10088 function on (el
, dir
) {
10089 if ("development" !== 'production' && dir
.modifiers
) {
10090 warn("v-on without argument does not support modifiers.");
10092 el
.wrapListeners = function (code
) { return ("_g(" + code
+ "," + (dir
.value
) + ")"); };
10097 function bind
$1 (el
, dir
) {
10098 el
.wrapData = function (code
) {
10099 return ("_b(" + code
+ ",'" + (el
.tag
) + "'," + (dir
.value
) + "," + (dir
.modifiers
&& dir
.modifiers
.prop
? 'true' : 'false') + (dir
.modifiers
&& dir
.modifiers
.sync
? ',true' : '') + ")")
10105 var baseDirectives
= {
10113 var CodegenState
= function CodegenState (options
) {
10114 this.options
= options
;
10115 this.warn
= options
.warn
|| baseWarn
;
10116 this.transforms
= pluckModuleFunction(options
.modules
, 'transformCode');
10117 this.dataGenFns
= pluckModuleFunction(options
.modules
, 'genData');
10118 this.directives
= extend(extend({}, baseDirectives
), options
.directives
);
10119 var isReservedTag
= options
.isReservedTag
|| no
;
10120 this.maybeComponent = function (el
) { return !isReservedTag(el
.tag
); };
10122 this.staticRenderFns
= [];
10127 function generate (
10131 var state
= new CodegenState(options
);
10132 var code
= ast
? genElement(ast
, state
) : '_c("div")';
10134 render: ("with(this){return " + code
+ "}"),
10135 staticRenderFns: state
.staticRenderFns
10139 function genElement (el
, state
) {
10140 if (el
.staticRoot
&& !el
.staticProcessed
) {
10141 return genStatic(el
, state
)
10142 } else if (el
.once
&& !el
.onceProcessed
) {
10143 return genOnce(el
, state
)
10144 } else if (el
.for && !el
.forProcessed
) {
10145 return genFor(el
, state
)
10146 } else if (el
.if && !el
.ifProcessed
) {
10147 return genIf(el
, state
)
10148 } else if (el
.tag
=== 'template' && !el
.slotTarget
) {
10149 return genChildren(el
, state
) || 'void 0'
10150 } else if (el
.tag
=== 'slot') {
10151 return genSlot(el
, state
)
10153 // component or element
10155 if (el
.component
) {
10156 code
= genComponent(el
.component
, el
, state
);
10158 var data
= el
.plain
? undefined : genData
$2(el
, state
);
10160 var children
= el
.inlineTemplate
? null : genChildren(el
, state
, true);
10161 code
= "_c('" + (el
.tag
) + "'" + (data
? ("," + data
) : '') + (children
? ("," + children
) : '') + ")";
10163 // module transforms
10164 for (var i
= 0; i
< state
.transforms
.length
; i
++) {
10165 code
= state
.transforms
[i
](el
, code
);
10171 // hoist static sub-trees out
10172 function genStatic (el
, state
) {
10173 el
.staticProcessed
= true;
10174 state
.staticRenderFns
.push(("with(this){return " + (genElement(el
, state
)) + "}"));
10175 return ("_m(" + (state
.staticRenderFns
.length
- 1) + (el
.staticInFor
? ',true' : '') + ")")
10179 function genOnce (el
, state
) {
10180 el
.onceProcessed
= true;
10181 if (el
.if && !el
.ifProcessed
) {
10182 return genIf(el
, state
)
10183 } else if (el
.staticInFor
) {
10185 var parent
= el
.parent
;
10191 parent
= parent
.parent
;
10194 "development" !== 'production' && state
.warn(
10195 "v-once can only be used inside v-for that is keyed. "
10197 return genElement(el
, state
)
10199 return ("_o(" + (genElement(el
, state
)) + "," + (state
.onceId
++) + "," + key
+ ")")
10201 return genStatic(el
, state
)
10211 el
.ifProcessed
= true; // avoid recursion
10212 return genIfConditions(el
.ifConditions
.slice(), state
, altGen
, altEmpty
)
10215 function genIfConditions (
10221 if (!conditions
.length
) {
10222 return altEmpty
|| '_e()'
10225 var condition
= conditions
.shift();
10226 if (condition
.exp
) {
10227 return ("(" + (condition
.exp
) + ")?" + (genTernaryExp(condition
.block
)) + ":" + (genIfConditions(conditions
, state
, altGen
, altEmpty
)))
10229 return ("" + (genTernaryExp(condition
.block
)))
10232 // v-if with v-once should generate code like (a)?_m(0):_m(1)
10233 function genTernaryExp (el
) {
10235 ? altGen(el
, state
)
10237 ? genOnce(el
, state
)
10238 : genElement(el
, state
)
10249 var alias
= el
.alias
;
10250 var iterator1
= el
.iterator1
? ("," + (el
.iterator1
)) : '';
10251 var iterator2
= el
.iterator2
? ("," + (el
.iterator2
)) : '';
10253 if ("development" !== 'production' &&
10254 state
.maybeComponent(el
) &&
10255 el
.tag
!== 'slot' &&
10256 el
.tag
!== 'template' &&
10260 "<" + (el
.tag
) + " v-for=\"" + alias
+ " in " + exp
+ "\">: component lists rendered with " +
10261 "v-for should have explicit keys. " +
10262 "See https://vuejs.org/guide/list.html#key for more info.",
10267 el
.forProcessed
= true; // avoid recursion
10268 return (altHelper
|| '_l') + "((" + exp
+ ")," +
10269 "function(" + alias
+ iterator1
+ iterator2
+ "){" +
10270 "return " + ((altGen
|| genElement
)(el
, state
)) +
10274 function genData
$2 (el
, state
) {
10277 // directives first.
10278 // directives may mutate the el's other properties before they are generated.
10279 var dirs
= genDirectives(el
, state
);
10280 if (dirs
) { data
+= dirs
+ ','; }
10284 data
+= "key:" + (el
.key
) + ",";
10288 data
+= "ref:" + (el
.ref
) + ",";
10291 data
+= "refInFor:true,";
10295 data
+= "pre:true,";
10297 // record original tag name for components using "is" attribute
10298 if (el
.component
) {
10299 data
+= "tag:\"" + (el
.tag
) + "\",";
10301 // module data generation functions
10302 for (var i
= 0; i
< state
.dataGenFns
.length
; i
++) {
10303 data
+= state
.dataGenFns
[i
](el
);
10307 data
+= "attrs:{" + (genProps(el
.attrs
)) + "},";
10311 data
+= "domProps:{" + (genProps(el
.props
)) + "},";
10315 data
+= (genHandlers(el
.events
, false, state
.warn
)) + ",";
10317 if (el
.nativeEvents
) {
10318 data
+= (genHandlers(el
.nativeEvents
, true, state
.warn
)) + ",";
10321 // only for non-scoped slots
10322 if (el
.slotTarget
&& !el
.slotScope
) {
10323 data
+= "slot:" + (el
.slotTarget
) + ",";
10326 if (el
.scopedSlots
) {
10327 data
+= (genScopedSlots(el
.scopedSlots
, state
)) + ",";
10329 // component v-model
10331 data
+= "model:{value:" + (el
.model
.value
) + ",callback:" + (el
.model
.callback
) + ",expression:" + (el
.model
.expression
) + "},";
10334 if (el
.inlineTemplate
) {
10335 var inlineTemplate
= genInlineTemplate(el
, state
);
10336 if (inlineTemplate
) {
10337 data
+= inlineTemplate
+ ",";
10340 data
= data
.replace(/,$/, '') + '}';
10341 // v-bind data wrap
10343 data
= el
.wrapData(data
);
10346 if (el
.wrapListeners
) {
10347 data
= el
.wrapListeners(data
);
10352 function genDirectives (el
, state
) {
10353 var dirs
= el
.directives
;
10354 if (!dirs
) { return }
10355 var res
= 'directives:[';
10356 var hasRuntime
= false;
10357 var i
, l
, dir
, needRuntime
;
10358 for (i
= 0, l
= dirs
.length
; i
< l
; i
++) {
10360 needRuntime
= true;
10361 var gen
= state
.directives
[dir
.name
];
10363 // compile-time directive that manipulates AST.
10364 // returns true if it also needs a runtime counterpart.
10365 needRuntime
= !!gen(el
, dir
, state
.warn
);
10369 res
+= "{name:\"" + (dir
.name
) + "\",rawName:\"" + (dir
.rawName
) + "\"" + (dir
.value
? (",value:(" + (dir
.value
) + "),expression:" + (JSON
.stringify(dir
.value
))) : '') + (dir
.arg
? (",arg:\"" + (dir
.arg
) + "\"") : '') + (dir
.modifiers
? (",modifiers:" + (JSON
.stringify(dir
.modifiers
))) : '') + "},";
10373 return res
.slice(0, -1) + ']'
10377 function genInlineTemplate (el
, state
) {
10378 var ast
= el
.children
[0];
10379 if ("development" !== 'production' && (
10380 el
.children
.length
!== 1 || ast
.type
!== 1
10382 state
.warn('Inline-template components must have exactly one child element.');
10384 if (ast
.type
=== 1) {
10385 var inlineRenderFns
= generate(ast
, state
.options
);
10386 return ("inlineTemplate:{render:function(){" + (inlineRenderFns
.render
) + "},staticRenderFns:[" + (inlineRenderFns
.staticRenderFns
.map(function (code
) { return ("function(){" + code
+ "}"); }).join(',')) + "]}")
10390 function genScopedSlots (
10394 return ("scopedSlots:_u([" + (Object
.keys(slots
).map(function (key
) {
10395 return genScopedSlot(key
, slots
[key
], state
)
10396 }).join(',')) + "])")
10399 function genScopedSlot (
10404 if (el
.for && !el
.forProcessed
) {
10405 return genForScopedSlot(key
, el
, state
)
10407 var fn
= "function(" + (String(el
.slotScope
)) + "){" +
10408 "return " + (el
.tag
=== 'template'
10410 ? ((el
.if) + "?" + (genChildren(el
, state
) || 'undefined') + ":undefined")
10411 : genChildren(el
, state
) || 'undefined'
10412 : genElement(el
, state
)) + "}";
10413 return ("{key:" + key
+ ",fn:" + fn
+ "}")
10416 function genForScopedSlot (
10422 var alias
= el
.alias
;
10423 var iterator1
= el
.iterator1
? ("," + (el
.iterator1
)) : '';
10424 var iterator2
= el
.iterator2
? ("," + (el
.iterator2
)) : '';
10425 el
.forProcessed
= true; // avoid recursion
10426 return "_l((" + exp
+ ")," +
10427 "function(" + alias
+ iterator1
+ iterator2
+ "){" +
10428 "return " + (genScopedSlot(key
, el
, state
)) +
10432 function genChildren (
10439 var children
= el
.children
;
10440 if (children
.length
) {
10441 var el
$1 = children
[0];
10442 // optimize single v-for
10443 if (children
.length
=== 1 &&
10445 el
$1.tag
!== 'template' &&
10446 el
$1.tag
!== 'slot'
10448 return (altGenElement
|| genElement
)(el
$1, state
)
10450 var normalizationType
= checkSkip
10451 ? getNormalizationType(children
, state
.maybeComponent
)
10453 var gen
= altGenNode
|| genNode
;
10454 return ("[" + (children
.map(function (c
) { return gen(c
, state
); }).join(',')) + "]" + (normalizationType
? ("," + normalizationType
) : ''))
10458 // determine the normalization needed for the children array.
10459 // 0: no normalization needed
10460 // 1: simple normalization needed (possible 1-level deep nested array)
10461 // 2: full normalization needed
10462 function getNormalizationType (
10467 for (var i
= 0; i
< children
.length
; i
++) {
10468 var el
= children
[i
];
10469 if (el
.type
!== 1) {
10472 if (needsNormalization(el
) ||
10473 (el
.ifConditions
&& el
.ifConditions
.some(function (c
) { return needsNormalization(c
.block
); }))) {
10477 if (maybeComponent(el
) ||
10478 (el
.ifConditions
&& el
.ifConditions
.some(function (c
) { return maybeComponent(c
.block
); }))) {
10485 function needsNormalization (el
) {
10486 return el
.for !== undefined || el
.tag
=== 'template' || el
.tag
=== 'slot'
10489 function genNode (node
, state
) {
10490 if (node
.type
=== 1) {
10491 return genElement(node
, state
)
10492 } if (node
.type
=== 3 && node
.isComment
) {
10493 return genComment(node
)
10495 return genText(node
)
10499 function genText (text
) {
10500 return ("_v(" + (text
.type
=== 2
10501 ? text
.expression
// no need for () because already wrapped in _s()
10502 : transformSpecialNewlines(JSON
.stringify(text
.text
))) + ")")
10505 function genComment (comment
) {
10506 return ("_e(" + (JSON
.stringify(comment
.text
)) + ")")
10509 function genSlot (el
, state
) {
10510 var slotName
= el
.slotName
|| '"default"';
10511 var children
= genChildren(el
, state
);
10512 var res
= "_t(" + slotName
+ (children
? ("," + children
) : '');
10513 var attrs
= el
.attrs
&& ("{" + (el
.attrs
.map(function (a
) { return ((camelize(a
.name
)) + ":" + (a
.value
)); }).join(',')) + "}");
10514 var bind
$$1 = el
.attrsMap
['v-bind'];
10515 if ((attrs
|| bind
$$1) && !children
) {
10519 res
+= "," + attrs
;
10522 res
+= (attrs
? '' : ',null') + "," + bind
$$1;
10527 // componentName is el.component, take it as argument to shun flow's pessimistic refinement
10528 function genComponent (
10533 var children
= el
.inlineTemplate
? null : genChildren(el
, state
, true);
10534 return ("_c(" + componentName
+ "," + (genData
$2(el
, state
)) + (children
? ("," + children
) : '') + ")")
10537 function genProps (props
) {
10539 for (var i
= 0; i
< props
.length
; i
++) {
10540 var prop
= props
[i
];
10541 /* istanbul ignore if */
10543 res
+= "\"" + (prop
.name
) + "\":" + (transformSpecialNewlines(prop
.value
)) + ",";
10546 return res
.slice(0, -1)
10550 function transformSpecialNewlines (text
) {
10552 .replace(/\u2028/g, '\\u2028')
10553 .replace(/\u2029/g, '\\u2029')
10558 // these keywords should not appear inside expressions, but operators like
10559 // typeof, instanceof and in are allowed
10560 var prohibitedKeywordRE
= new RegExp('\\b' + (
10561 'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
10562 'super,throw,while,yield,delete,export,import,return,switch,default,' +
10563 'extends,finally,continue,debugger,function,arguments'
10564 ).split(',').join('\\b|\\b') + '\\b');
10566 // these unary operators should not be used as property/method names
10567 var unaryOperatorsRE
= new RegExp('\\b' + (
10568 'delete,typeof,void'
10569 ).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)');
10571 // strip strings in expressions
10572 var stripStringRE
= /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g;
10574 // detect problematic expressions in a template
10575 function detectErrors (ast
) {
10578 checkNode(ast
, errors
);
10583 function checkNode (node
, errors
) {
10584 if (node
.type
=== 1) {
10585 for (var name
in node
.attrsMap
) {
10586 if (dirRE
.test(name
)) {
10587 var value
= node
.attrsMap
[name
];
10589 if (name
=== 'v-for') {
10590 checkFor(node
, ("v-for=\"" + value
+ "\""), errors
);
10591 } else if (onRE
.test(name
)) {
10592 checkEvent(value
, (name
+ "=\"" + value
+ "\""), errors
);
10594 checkExpression(value
, (name
+ "=\"" + value
+ "\""), errors
);
10599 if (node
.children
) {
10600 for (var i
= 0; i
< node
.children
.length
; i
++) {
10601 checkNode(node
.children
[i
], errors
);
10604 } else if (node
.type
=== 2) {
10605 checkExpression(node
.expression
, node
.text
, errors
);
10609 function checkEvent (exp
, text
, errors
) {
10610 var stipped
= exp
.replace(stripStringRE
, '');
10611 var keywordMatch
= stipped
.match(unaryOperatorsRE
);
10612 if (keywordMatch
&& stipped
.charAt(keywordMatch
.index
- 1) !== '$') {
10614 "avoid using JavaScript unary operator as property name: " +
10615 "\"" + (keywordMatch
[0]) + "\" in expression " + (text
.trim())
10618 checkExpression(exp
, text
, errors
);
10621 function checkFor (node
, text
, errors
) {
10622 checkExpression(node
.for || '', text
, errors
);
10623 checkIdentifier(node
.alias
, 'v-for alias', text
, errors
);
10624 checkIdentifier(node
.iterator1
, 'v-for iterator', text
, errors
);
10625 checkIdentifier(node
.iterator2
, 'v-for iterator', text
, errors
);
10628 function checkIdentifier (
10634 if (typeof ident
=== 'string') {
10636 new Function(("var " + ident
+ "=_"));
10638 errors
.push(("invalid " + type
+ " \"" + ident
+ "\" in expression: " + (text
.trim())));
10643 function checkExpression (exp
, text
, errors
) {
10645 new Function(("return " + exp
));
10647 var keywordMatch
= exp
.replace(stripStringRE
, '').match(prohibitedKeywordRE
);
10648 if (keywordMatch
) {
10650 "avoid using JavaScript keyword as property name: " +
10651 "\"" + (keywordMatch
[0]) + "\"\n Raw expression: " + (text
.trim())
10655 "invalid expression: " + (e
.message
) + " in\n\n" +
10656 " " + exp
+ "\n\n" +
10657 " Raw expression: " + (text
.trim()) + "\n"
10665 function createFunction (code
, errors
) {
10667 return new Function(code
)
10669 errors
.push({ err: err
, code: code
});
10674 function createCompileToFunctionFn (compile
) {
10675 var cache
= Object
.create(null);
10677 return function compileToFunctions (
10682 options
= extend({}, options
);
10683 var warn
$$1 = options
.warn
|| warn
;
10684 delete options
.warn
;
10686 /* istanbul ignore if */
10688 // detect possible CSP restriction
10690 new Function('return 1');
10692 if (e
.toString().match(/unsafe-eval|CSP/)) {
10694 'It seems you are using the standalone build of Vue.js in an ' +
10695 'environment with Content Security Policy that prohibits unsafe-eval. ' +
10696 'The template compiler cannot work in this environment. Consider ' +
10697 'relaxing the policy to allow unsafe-eval or pre-compiling your ' +
10698 'templates into render functions.'
10705 var key
= options
.delimiters
10706 ? String(options
.delimiters
) + template
10713 var compiled
= compile(template
, options
);
10715 // check compilation errors/tips
10717 if (compiled
.errors
&& compiled
.errors
.length
) {
10719 "Error compiling template:\n\n" + template
+ "\n\n" +
10720 compiled
.errors
.map(function (e
) { return ("- " + e
); }).join('\n') + '\n',
10724 if (compiled
.tips
&& compiled
.tips
.length
) {
10725 compiled
.tips
.forEach(function (msg
) { return tip(msg
, vm
); });
10729 // turn code into functions
10731 var fnGenErrors
= [];
10732 res
.render
= createFunction(compiled
.render
, fnGenErrors
);
10733 res
.staticRenderFns
= compiled
.staticRenderFns
.map(function (code
) {
10734 return createFunction(code
, fnGenErrors
)
10737 // check function generation errors.
10738 // this should only happen if there is a bug in the compiler itself.
10739 // mostly for codegen development use
10740 /* istanbul ignore if */
10742 if ((!compiled
.errors
|| !compiled
.errors
.length
) && fnGenErrors
.length
) {
10744 "Failed to generate render function:\n\n" +
10745 fnGenErrors
.map(function (ref
) {
10747 var code
= ref
.code
;
10749 return ((err
.toString()) + " in\n\n" + code
+ "\n");
10756 return (cache
[key
] = res
)
10762 function createCompilerCreator (baseCompile
) {
10763 return function createCompiler (baseOptions
) {
10768 var finalOptions
= Object
.create(baseOptions
);
10771 finalOptions
.warn = function (msg
, tip
) {
10772 (tip
? tips : errors
).push(msg
);
10776 // merge custom modules
10777 if (options
.modules
) {
10778 finalOptions
.modules
=
10779 (baseOptions
.modules
|| []).concat(options
.modules
);
10781 // merge custom directives
10782 if (options
.directives
) {
10783 finalOptions
.directives
= extend(
10784 Object
.create(baseOptions
.directives
|| null),
10788 // copy other options
10789 for (var key
in options
) {
10790 if (key
!== 'modules' && key
!== 'directives') {
10791 finalOptions
[key
] = options
[key
];
10796 var compiled
= baseCompile(template
, finalOptions
);
10798 errors
.push
.apply(errors
, detectErrors(compiled
.ast
));
10800 compiled
.errors
= errors
;
10801 compiled
.tips
= tips
;
10807 compileToFunctions: createCompileToFunctionFn(compile
)
10814 // `createCompilerCreator` allows creating compilers that use alternative
10815 // parser/optimizer/codegen, e.g the SSR optimizing compiler.
10816 // Here we just export a default compiler using the default parts.
10817 var createCompiler
= createCompilerCreator(function baseCompile (
10821 var ast
= parse(template
.trim(), options
);
10822 if (options
.optimize
!== false) {
10823 optimize(ast
, options
);
10825 var code
= generate(ast
, options
);
10828 render: code
.render
,
10829 staticRenderFns: code
.staticRenderFns
10835 var ref
$1 = createCompiler(baseOptions
);
10836 var compileToFunctions
= ref
$1.compileToFunctions
;
10840 // check whether current browser encodes a char inside attribute values
10842 function getShouldDecode (href
) {
10843 div
= div
|| document
.createElement('div');
10844 div
.innerHTML
= href
? "<a href=\"\n\"/>" : "<div a=\"\n\"/>";
10845 return div
.innerHTML
.indexOf(' ') > 0
10848 // #3663: IE encodes newlines inside attribute values while other browsers don't
10849 var shouldDecodeNewlines
= inBrowser
? getShouldDecode(false) : false;
10850 // #6828: chrome encodes content in a[href]
10851 var shouldDecodeNewlinesForHref
= inBrowser
? getShouldDecode(true) : false;
10855 var idToTemplate
= cached(function (id
) {
10856 var el
= query(id
);
10857 return el
&& el
.innerHTML
10860 var mount
= Vue
.prototype.$mount
;
10861 Vue
.prototype.$mount = function (
10865 el
= el
&& query(el
);
10867 /* istanbul ignore if */
10868 if (el
=== document
.body
|| el
=== document
.documentElement
) {
10869 "development" !== 'production' && warn(
10870 "Do not mount Vue to <html> or <body> - mount to normal elements instead."
10875 var options
= this.$options
;
10876 // resolve template/el and convert to render function
10877 if (!options
.render
) {
10878 var template
= options
.template
;
10880 if (typeof template
=== 'string') {
10881 if (template
.charAt(0) === '#') {
10882 template
= idToTemplate(template
);
10883 /* istanbul ignore if */
10884 if ("development" !== 'production' && !template
) {
10886 ("Template element not found or is empty: " + (options
.template
)),
10891 } else if (template
.nodeType
) {
10892 template
= template
.innerHTML
;
10895 warn('invalid template option:' + template
, this);
10900 template
= getOuterHTML(el
);
10903 /* istanbul ignore if */
10904 if ("development" !== 'production' && config
.performance
&& mark
) {
10908 var ref
= compileToFunctions(template
, {
10909 shouldDecodeNewlines: shouldDecodeNewlines
,
10910 shouldDecodeNewlinesForHref: shouldDecodeNewlinesForHref
,
10911 delimiters: options
.delimiters
,
10912 comments: options
.comments
10914 var render
= ref
.render
;
10915 var staticRenderFns
= ref
.staticRenderFns
;
10916 options
.render
= render
;
10917 options
.staticRenderFns
= staticRenderFns
;
10919 /* istanbul ignore if */
10920 if ("development" !== 'production' && config
.performance
&& mark
) {
10921 mark('compile end');
10922 measure(("vue " + (this._name
) + " compile"), 'compile', 'compile end');
10926 return mount
.call(this, el
, hydrating
)
10930 * Get outerHTML of elements, taking care
10931 * of SVG elements in IE as well.
10933 function getOuterHTML (el
) {
10934 if (el
.outerHTML
) {
10935 return el
.outerHTML
10937 var container
= document
.createElement('div');
10938 container
.appendChild(el
.cloneNode(true));
10939 return container
.innerHTML
10943 Vue
.compile
= compileToFunctions
;