| 1 |
/*! |
| 2 |
* Vue.js v2.2.4 |
| 3 |
* (c) 2014-2017 Evan You |
| 4 |
* Released under the MIT License. |
| 5 |
*/ |
| 6 |
(function (global, factory) { |
| 7 |
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| 8 |
typeof define === 'function' && define.amd ? define(factory) : |
| 9 |
(global.Vue = factory()); |
| 10 |
}(this, (function () { 'use strict'; |
| 11 |
|
| 12 |
/* */ |
| 13 |
|
| 14 |
/** |
| 15 |
* Convert a value to a string that is actually rendered. |
| 16 |
*/ |
| 17 |
function _toString (val) { |
| 18 |
return val == null |
| 19 |
? '' |
| 20 |
: typeof val === 'object' |
| 21 |
? JSON.stringify(val, null, 2) |
| 22 |
: String(val) |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Convert a input value to a number for persistence. |
| 27 |
* If the conversion fails, return original string. |
| 28 |
*/ |
| 29 |
function toNumber (val) { |
| 30 |
var n = parseFloat(val); |
| 31 |
return isNaN(n) ? val : n |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Make a map and return a function for checking if a key |
| 36 |
* is in that map. |
| 37 |
*/ |
| 38 |
function makeMap ( |
| 39 |
str, |
| 40 |
expectsLowerCase |
| 41 |
) { |
| 42 |
var map = Object.create(null); |
| 43 |
var list = str.split(','); |
| 44 |
for (var i = 0; i < list.length; i++) { |
| 45 |
map[list[i]] = true; |
| 46 |
} |
| 47 |
return expectsLowerCase |
| 48 |
? function (val) { return map[val.toLowerCase()]; } |
| 49 |
: function (val) { return map[val]; } |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Check if a tag is a built-in tag. |
| 54 |
*/ |
| 55 |
var isBuiltInTag = makeMap('slot,component', true); |
| 56 |
|
| 57 |
/** |
| 58 |
* Remove an item from an array |
| 59 |
*/ |
| 60 |
function remove (arr, item) { |
| 61 |
if (arr.length) { |
| 62 |
var index = arr.indexOf(item); |
| 63 |
if (index > -1) { |
| 64 |
return arr.splice(index, 1) |
| 65 |
} |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Check whether the object has the property. |
| 71 |
*/ |
| 72 |
var hasOwnProperty = Object.prototype.hasOwnProperty; |
| 73 |
function hasOwn (obj, key) { |
| 74 |
return hasOwnProperty.call(obj, key) |
| 75 |
} |
| 76 |
|
| 77 |
/** |
| 78 |
* Check if value is primitive |
| 79 |
*/ |
| 80 |
function isPrimitive (value) { |
| 81 |
return typeof value === 'string' || typeof value === 'number' |
| 82 |
} |
| 83 |
|
| 84 |
/** |
| 85 |
* Create a cached version of a pure function. |
| 86 |
*/ |
| 87 |
function cached (fn) { |
| 88 |
var cache = Object.create(null); |
| 89 |
return (function cachedFn (str) { |
| 90 |
var hit = cache[str]; |
| 91 |
return hit || (cache[str] = fn(str)) |
| 92 |
}) |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* Camelize a hyphen-delimited string. |
| 97 |
*/ |
| 98 |
var camelizeRE = /-(\w)/g; |
| 99 |
var camelize = cached(function (str) { |
| 100 |
return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }) |
| 101 |
}); |
| 102 |
|
| 103 |
/** |
| 104 |
* Capitalize a string. |
| 105 |
*/ |
| 106 |
var capitalize = cached(function (str) { |
| 107 |
return str.charAt(0).toUpperCase() + str.slice(1) |
| 108 |
}); |
| 109 |
|
| 110 |
/** |
| 111 |
* Hyphenate a camelCase string. |
| 112 |
*/ |
| 113 |
var hyphenateRE = /([^-])([A-Z])/g; |
| 114 |
var hyphenate = cached(function (str) { |
| 115 |
return str |
| 116 |
.replace(hyphenateRE, '$1-$2') |
| 117 |
.replace(hyphenateRE, '$1-$2') |
| 118 |
.toLowerCase() |
| 119 |
}); |
| 120 |
|
| 121 |
/** |
| 122 |
* Simple bind, faster than native |
| 123 |
*/ |
| 124 |
function bind (fn, ctx) { |
| 125 |
function boundFn (a) { |
| 126 |
var l = arguments.length; |
| 127 |
return l |
| 128 |
? l > 1 |
| 129 |
? fn.apply(ctx, arguments) |
| 130 |
: fn.call(ctx, a) |
| 131 |
: fn.call(ctx) |
| 132 |
} |
| 133 |
// record original fn length |
| 134 |
boundFn._length = fn.length; |
| 135 |
return boundFn |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* Convert an Array-like object to a real Array. |
| 140 |
*/ |
| 141 |
function toArray (list, start) { |
| 142 |
start = start || 0; |
| 143 |
var i = list.length - start; |
| 144 |
var ret = new Array(i); |
| 145 |
while (i--) { |
| 146 |
ret[i] = list[i + start]; |
| 147 |
} |
| 148 |
return ret |
| 149 |
} |
| 150 |
|
| 151 |
/** |
| 152 |
* Mix properties into target object. |
| 153 |
*/ |
| 154 |
function extend (to, _from) { |
| 155 |
for (var key in _from) { |
| 156 |
to[key] = _from[key]; |
| 157 |
} |
| 158 |
return to |
| 159 |
} |
| 160 |
|
| 161 |
/** |
| 162 |
* Quick object check - this is primarily used to tell |
| 163 |
* Objects from primitive values when we know the value |
| 164 |
* is a JSON-compliant type. |
| 165 |
*/ |
| 166 |
function isObject (obj) { |
| 167 |
return obj !== null && typeof obj === 'object' |
| 168 |
} |
| 169 |
|
| 170 |
/** |
| 171 |
* Strict object type check. Only returns true |
| 172 |
* for plain JavaScript objects. |
| 173 |
*/ |
| 174 |
var toString = Object.prototype.toString; |
| 175 |
var OBJECT_STRING = '[object Object]'; |
| 176 |
function isPlainObject (obj) { |
| 177 |
return toString.call(obj) === OBJECT_STRING |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Merge an Array of Objects into a single Object. |
| 182 |
*/ |
| 183 |
function toObject (arr) { |
| 184 |
var res = {}; |
| 185 |
for (var i = 0; i < arr.length; i++) { |
| 186 |
if (arr[i]) { |
| 187 |
extend(res, arr[i]); |
| 188 |
} |
| 189 |
} |
| 190 |
return res |
| 191 |
} |
| 192 |
|
| 193 |
/** |
| 194 |
* Perform no operation. |
| 195 |
*/ |
| 196 |
function noop () {} |
| 197 |
|
| 198 |
/** |
| 199 |
* Always return false. |
| 200 |
*/ |
| 201 |
var no = function () { return false; }; |
| 202 |
|
| 203 |
/** |
| 204 |
* Return same value |
| 205 |
*/ |
| 206 |
var identity = function (_) { return _; }; |
| 207 |
|
| 208 |
/** |
| 209 |
* Generate a static keys string from compiler modules. |
| 210 |
*/ |
| 211 |
function genStaticKeys (modules) { |
| 212 |
return modules.reduce(function (keys, m) { |
| 213 |
return keys.concat(m.staticKeys || []) |
| 214 |
}, []).join(',') |
| 215 |
} |
| 216 |
|
| 217 |
/** |
| 218 |
* Check if two values are loosely equal - that is, |
| 219 |
* if they are plain objects, do they have the same shape? |
| 220 |
*/ |
| 221 |
function looseEqual (a, b) { |
| 222 |
var isObjectA = isObject(a); |
| 223 |
var isObjectB = isObject(b); |
| 224 |
if (isObjectA && isObjectB) { |
| 225 |
try { |
| 226 |
return JSON.stringify(a) === JSON.stringify(b) |
| 227 |
} catch (e) { |
| 228 |
// possible circular reference |
| 229 |
return a === b |
| 230 |
} |
| 231 |
} else if (!isObjectA && !isObjectB) { |
| 232 |
return String(a) === String(b) |
| 233 |
} else { |
| 234 |
return false |
| 235 |
} |
| 236 |
} |
| 237 |
|
| 238 |
function looseIndexOf (arr, val) { |
| 239 |
for (var i = 0; i < arr.length; i++) { |
| 240 |
if (looseEqual(arr[i], val)) { return i } |
| 241 |
} |
| 242 |
return -1 |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* Ensure a function is called only once. |
| 247 |
*/ |
| 248 |
function once (fn) { |
| 249 |
var called = false; |
| 250 |
return function () { |
| 251 |
if (!called) { |
| 252 |
called = true; |
| 253 |
fn(); |
| 254 |
} |
| 255 |
} |
| 256 |
} |
| 257 |
|
| 258 |
/* */ |
| 259 |
|
| 260 |
var config = { |
| 261 |
/** |
| 262 |
* Option merge strategies (used in core/util/options) |
| 263 |
*/ |
| 264 |
optionMergeStrategies: Object.create(null), |
| 265 |
|
| 266 |
/** |
| 267 |
* Whether to suppress warnings. |
| 268 |
*/ |
| 269 |
silent: false, |
| 270 |
|
| 271 |
/** |
| 272 |
* Show production mode tip message on boot? |
| 273 |
*/ |
| 274 |
productionTip: "development" !== 'production', |
| 275 |
|
| 276 |
/** |
| 277 |
* Whether to enable devtools |
| 278 |
*/ |
| 279 |
devtools: "development" !== 'production', |
| 280 |
|
| 281 |
/** |
| 282 |
* Whether to record perf |
| 283 |
*/ |
| 284 |
performance: false, |
| 285 |
|
| 286 |
/** |
| 287 |
* Error handler for watcher errors |
| 288 |
*/ |
| 289 |
errorHandler: null, |
| 290 |
|
| 291 |
/** |
| 292 |
* Ignore certain custom elements |
| 293 |
*/ |
| 294 |
ignoredElements: [], |
| 295 |
|
| 296 |
/** |
| 297 |
* Custom user key aliases for v-on |
| 298 |
*/ |
| 299 |
keyCodes: Object.create(null), |
| 300 |
|
| 301 |
/** |
| 302 |
* Check if a tag is reserved so that it cannot be registered as a |
| 303 |
* component. This is platform-dependent and may be overwritten. |
| 304 |
*/ |
| 305 |
isReservedTag: no, |
| 306 |
|
| 307 |
/** |
| 308 |
* Check if a tag is an unknown element. |
| 309 |
* Platform-dependent. |
| 310 |
*/ |
| 311 |
isUnknownElement: no, |
| 312 |
|
| 313 |
/** |
| 314 |
* Get the namespace of an element |
| 315 |
*/ |
| 316 |
getTagNamespace: noop, |
| 317 |
|
| 318 |
/** |
| 319 |
* Parse the real tag name for the specific platform. |
| 320 |
*/ |
| 321 |
parsePlatformTagName: identity, |
| 322 |
|
| 323 |
/** |
| 324 |
* Check if an attribute must be bound using property, e.g. value |
| 325 |
* Platform-dependent. |
| 326 |
*/ |
| 327 |
mustUseProp: no, |
| 328 |
|
| 329 |
/** |
| 330 |
* List of asset types that a component can own. |
| 331 |
*/ |
| 332 |
_assetTypes: [ |
| 333 |
'component', |
| 334 |
'directive', |
| 335 |
'filter' |
| 336 |
], |
| 337 |
|
| 338 |
/** |
| 339 |
* List of lifecycle hooks. |
| 340 |
*/ |
| 341 |
_lifecycleHooks: [ |
| 342 |
'beforeCreate', |
| 343 |
'created', |
| 344 |
'beforeMount', |
| 345 |
'mounted', |
| 346 |
'beforeUpdate', |
| 347 |
'updated', |
| 348 |
'beforeDestroy', |
| 349 |
'destroyed', |
| 350 |
'activated', |
| 351 |
'deactivated' |
| 352 |
], |
| 353 |
|
| 354 |
/** |
| 355 |
* Max circular updates allowed in a scheduler flush cycle. |
| 356 |
*/ |
| 357 |
_maxUpdateCount: 100 |
| 358 |
}; |
| 359 |
|
| 360 |
/* */ |
| 361 |
|
| 362 |
var emptyObject = Object.freeze({}); |
| 363 |
|
| 364 |
/** |
| 365 |
* Check if a string starts with $ or _ |
| 366 |
*/ |
| 367 |
function isReserved (str) { |
| 368 |
var c = (str + '').charCodeAt(0); |
| 369 |
return c === 0x24 || c === 0x5F |
| 370 |
} |
| 371 |
|
| 372 |
/** |
| 373 |
* Define a property. |
| 374 |
*/ |
| 375 |
function def (obj, key, val, enumerable) { |
| 376 |
Object.defineProperty(obj, key, { |
| 377 |
value: val, |
| 378 |
enumerable: !!enumerable, |
| 379 |
writable: true, |
| 380 |
configurable: true |
| 381 |
}); |
| 382 |
} |
| 383 |
|
| 384 |
/** |
| 385 |
* Parse simple path. |
| 386 |
*/ |
| 387 |
var bailRE = /[^\w.$]/; |
| 388 |
function parsePath (path) { |
| 389 |
if (bailRE.test(path)) { |
| 390 |
return |
| 391 |
} |
| 392 |
var segments = path.split('.'); |
| 393 |
return function (obj) { |
| 394 |
for (var i = 0; i < segments.length; i++) { |
| 395 |
if (!obj) { return } |
| 396 |
obj = obj[segments[i]]; |
| 397 |
} |
| 398 |
return obj |
| 399 |
} |
| 400 |
} |
| 401 |
|
| 402 |
/* */ |
| 403 |
/* globals MutationObserver */ |
| 404 |
|
| 405 |
// can we use __proto__? |
| 406 |
var hasProto = '__proto__' in {}; |
| 407 |
|
| 408 |
// Browser environment sniffing |
| 409 |
var inBrowser = typeof window !== 'undefined'; |
| 410 |
var UA = inBrowser && window.navigator.userAgent.toLowerCase(); |
| 411 |
var isIE = UA && /msie|trident/.test(UA); |
| 412 |
var isIE9 = UA && UA.indexOf('msie 9.0') > 0; |
| 413 |
var isEdge = UA && UA.indexOf('edge/') > 0; |
| 414 |
var isAndroid = UA && UA.indexOf('android') > 0; |
| 415 |
var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); |
| 416 |
var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge; |
| 417 |
|
| 418 |
// this needs to be lazy-evaled because vue may be required before |
| 419 |
// vue-server-renderer can set VUE_ENV |
| 420 |
var _isServer; |
| 421 |
var isServerRendering = function () { |
| 422 |
if (_isServer === undefined) { |
| 423 |
/* istanbul ignore if */ |
| 424 |
if (!inBrowser && typeof global !== 'undefined') { |
| 425 |
// detect presence of vue-server-renderer and avoid |
| 426 |
// Webpack shimming the process |
| 427 |
_isServer = global['process'].env.VUE_ENV === 'server'; |
| 428 |
} else { |
| 429 |
_isServer = false; |
| 430 |
} |
| 431 |
} |
| 432 |
return _isServer |
| 433 |
}; |
| 434 |
|
| 435 |
// detect devtools |
| 436 |
var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__; |
| 437 |
|
| 438 |
/* istanbul ignore next */ |
| 439 |
function isNative (Ctor) { |
| 440 |
return /native code/.test(Ctor.toString()) |
| 441 |
} |
| 442 |
|
| 443 |
var hasSymbol = |
| 444 |
typeof Symbol !== 'undefined' && isNative(Symbol) && |
| 445 |
typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys); |
| 446 |
|
| 447 |
/** |
| 448 |
* Defer a task to execute it asynchronously. |
| 449 |
*/ |
| 450 |
var nextTick = (function () { |
| 451 |
var callbacks = []; |
| 452 |
var pending = false; |
| 453 |
var timerFunc; |
| 454 |
|
| 455 |
function nextTickHandler () { |
| 456 |
pending = false; |
| 457 |
var copies = callbacks.slice(0); |
| 458 |
callbacks.length = 0; |
| 459 |
for (var i = 0; i < copies.length; i++) { |
| 460 |
copies[i](); |
| 461 |
} |
| 462 |
} |
| 463 |
|
| 464 |
// the nextTick behavior leverages the microtask queue, which can be accessed |
| 465 |
// via either native Promise.then or MutationObserver. |
| 466 |
// MutationObserver has wider support, however it is seriously bugged in |
| 467 |
// UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It |
| 468 |
// completely stops working after triggering a few times... so, if native |
| 469 |
// Promise is available, we will use it: |
| 470 |
/* istanbul ignore if */ |
| 471 |
if (typeof Promise !== 'undefined' && isNative(Promise)) { |
| 472 |
var p = Promise.resolve(); |
| 473 |
var logError = function (err) { console.error(err); }; |
| 474 |
timerFunc = function () { |
| 475 |
p.then(nextTickHandler).catch(logError); |
| 476 |
// in problematic UIWebViews, Promise.then doesn't completely break, but |
| 477 |
// it can get stuck in a weird state where callbacks are pushed into the |
| 478 |
// microtask queue but the queue isn't being flushed, until the browser |
| 479 |
// needs to do some other work, e.g. handle a timer. Therefore we can |
| 480 |
// "force" the microtask queue to be flushed by adding an empty timer. |
| 481 |
if (isIOS) { setTimeout(noop); } |
| 482 |
}; |
| 483 |
} else if (typeof MutationObserver !== 'undefined' && ( |
| 484 |
isNative(MutationObserver) || |
| 485 |
// PhantomJS and iOS 7.x |
| 486 |
MutationObserver.toString() === '[object MutationObserverConstructor]' |
| 487 |
)) { |
| 488 |
// use MutationObserver where native Promise is not available, |
| 489 |
// e.g. PhantomJS IE11, iOS7, Android 4.4 |
| 490 |
var counter = 1; |
| 491 |
var observer = new MutationObserver(nextTickHandler); |
| 492 |
var textNode = document.createTextNode(String(counter)); |
| 493 |
observer.observe(textNode, { |
| 494 |
characterData: true |
| 495 |
}); |
| 496 |
timerFunc = function () { |
| 497 |
counter = (counter + 1) % 2; |
| 498 |
textNode.data = String(counter); |
| 499 |
}; |
| 500 |
} else { |
| 501 |
// fallback to setTimeout |
| 502 |
/* istanbul ignore next */ |
| 503 |
timerFunc = function () { |
| 504 |
setTimeout(nextTickHandler, 0); |
| 505 |
}; |
| 506 |
} |
| 507 |
|
| 508 |
return function queueNextTick (cb, ctx) { |
| 509 |
var _resolve; |
| 510 |
callbacks.push(function () { |
| 511 |
if (cb) { cb.call(ctx); } |
| 512 |
if (_resolve) { _resolve(ctx); } |
| 513 |
}); |
| 514 |
if (!pending) { |
| 515 |
pending = true; |
| 516 |
timerFunc(); |
| 517 |
} |
| 518 |
if (!cb && typeof Promise !== 'undefined') { |
| 519 |
return new Promise(function (resolve) { |
| 520 |
_resolve = resolve; |
| 521 |
}) |
| 522 |
} |
| 523 |
} |
| 524 |
})(); |
| 525 |
|
| 526 |
var _Set; |
| 527 |
/* istanbul ignore if */ |
| 528 |
if (typeof Set !== 'undefined' && isNative(Set)) { |
| 529 |
// use native Set when available. |
| 530 |
_Set = Set; |
| 531 |
} else { |
| 532 |
// a non-standard Set polyfill that only works with primitive keys. |
| 533 |
_Set = (function () { |
| 534 |
function Set () { |
| 535 |
this.set = Object.create(null); |
| 536 |
} |
| 537 |
Set.prototype.has = function has (key) { |
| 538 |
return this.set[key] === true |
| 539 |
}; |
| 540 |
Set.prototype.add = function add (key) { |
| 541 |
this.set[key] = true; |
| 542 |
}; |
| 543 |
Set.prototype.clear = function clear () { |
| 544 |
this.set = Object.create(null); |
| 545 |
}; |
| 546 |
|
| 547 |
return Set; |
| 548 |
}()); |
| 549 |
} |
| 550 |
|
| 551 |
var warn = noop; |
| 552 |
var tip = noop; |
| 553 |
var formatComponentName; |
| 554 |
|
| 555 |
{ |
| 556 |
var hasConsole = typeof console !== 'undefined'; |
| 557 |
var classifyRE = /(?:^|[-_])(\w)/g; |
| 558 |
var classify = function (str) { return str |
| 559 |
.replace(classifyRE, function (c) { return c.toUpperCase(); }) |
| 560 |
.replace(/[-_]/g, ''); }; |
| 561 |
|
| 562 |
warn = function (msg, vm) { |
| 563 |
if (hasConsole && (!config.silent)) { |
| 564 |
console.error("[Vue warn]: " + msg + " " + ( |
| 565 |
vm ? formatLocation(formatComponentName(vm)) : '' |
| 566 |
)); |
| 567 |
} |
| 568 |
}; |
| 569 |
|
| 570 |
tip = function (msg, vm) { |
| 571 |
if (hasConsole && (!config.silent)) { |
| 572 |
console.warn("[Vue tip]: " + msg + " " + ( |
| 573 |
vm ? formatLocation(formatComponentName(vm)) : '' |
| 574 |
)); |
| 575 |
} |
| 576 |
}; |
| 577 |
|
| 578 |
formatComponentName = function (vm, includeFile) { |
| 579 |
if (vm.$root === vm) { |
| 580 |
return '<Root>' |
| 581 |
} |
| 582 |
var name = typeof vm === 'function' && vm.options |
| 583 |
? vm.options.name |
| 584 |
: vm._isVue |
| 585 |
? vm.$options.name || vm.$options._componentTag |
| 586 |
: vm.name; |
| 587 |
|
| 588 |
var file = vm._isVue && vm.$options.__file; |
| 589 |
if (!name && file) { |
| 590 |
var match = file.match(/([^/\\]+)\.vue$/); |
| 591 |
name = match && match[1]; |
| 592 |
} |
| 593 |
|
| 594 |
return ( |
| 595 |
(name ? ("<" + (classify(name)) + ">") : "<Anonymous>") + |
| 596 |
(file && includeFile !== false ? (" at " + file) : '') |
| 597 |
) |
| 598 |
}; |
| 599 |
|
| 600 |
var formatLocation = function (str) { |
| 601 |
if (str === "<Anonymous>") { |
| 602 |
str += " - use the \"name\" option for better debugging messages."; |
| 603 |
} |
| 604 |
return ("\n(found in " + str + ")") |
| 605 |
}; |
| 606 |
} |
| 607 |
|
| 608 |
/* */ |
| 609 |
|
| 610 |
|
| 611 |
var uid$1 = 0; |
| 612 |
|
| 613 |
/** |
| 614 |
* A dep is an observable that can have multiple |
| 615 |
* directives subscribing to it. |
| 616 |
*/ |
| 617 |
var Dep = function Dep () { |
| 618 |
this.id = uid$1++; |
| 619 |
this.subs = []; |
| 620 |
}; |
| 621 |
|
| 622 |
Dep.prototype.addSub = function addSub (sub) { |
| 623 |
this.subs.push(sub); |
| 624 |
}; |
| 625 |
|
| 626 |
Dep.prototype.removeSub = function removeSub (sub) { |
| 627 |
remove(this.subs, sub); |
| 628 |
}; |
| 629 |
|
| 630 |
Dep.prototype.depend = function depend () { |
| 631 |
if (Dep.target) { |
| 632 |
Dep.target.addDep(this); |
| 633 |
} |
| 634 |
}; |
| 635 |
|
| 636 |
Dep.prototype.notify = function notify () { |
| 637 |
// stabilize the subscriber list first |
| 638 |
var subs = this.subs.slice(); |
| 639 |
for (var i = 0, l = subs.length; i < l; i++) { |
| 640 |
subs[i].update(); |
| 641 |
} |
| 642 |
}; |
| 643 |
|
| 644 |
// the current target watcher being evaluated. |
| 645 |
// this is globally unique because there could be only one |
| 646 |
// watcher being evaluated at any time. |
| 647 |
Dep.target = null; |
| 648 |
var targetStack = []; |
| 649 |
|
| 650 |
function pushTarget (_target) { |
| 651 |
if (Dep.target) { targetStack.push(Dep.target); } |
| 652 |
Dep.target = _target; |
| 653 |
} |
| 654 |
|
| 655 |
function popTarget () { |
| 656 |
Dep.target = targetStack.pop(); |
| 657 |
} |
| 658 |
|
| 659 |
/* |
| 660 |
* not type checking this file because flow doesn't play well with |
| 661 |
* dynamically accessing methods on Array prototype |
| 662 |
*/ |
| 663 |
|
| 664 |
var arrayProto = Array.prototype; |
| 665 |
var arrayMethods = Object.create(arrayProto);[ |
| 666 |
'push', |
| 667 |
'pop', |
| 668 |
'shift', |
| 669 |
'unshift', |
| 670 |
'splice', |
| 671 |
'sort', |
| 672 |
'reverse' |
| 673 |
] |
| 674 |
.forEach(function (method) { |
| 675 |
// cache original method |
| 676 |
var original = arrayProto[method]; |
| 677 |
def(arrayMethods, method, function mutator () { |
| 678 |
var arguments$1 = arguments; |
| 679 |
|
| 680 |
// avoid leaking arguments: |
| 681 |
// http://jsperf.com/closure-with-arguments |
| 682 |
var i = arguments.length; |
| 683 |
var args = new Array(i); |
| 684 |
while (i--) { |
| 685 |
args[i] = arguments$1[i]; |
| 686 |
} |
| 687 |
var result = original.apply(this, args); |
| 688 |
var ob = this.__ob__; |
| 689 |
var inserted; |
| 690 |
switch (method) { |
| 691 |
case 'push': |
| 692 |
inserted = args; |
| 693 |
break |
| 694 |
case 'unshift': |
| 695 |
inserted = args; |
| 696 |
break |
| 697 |
case 'splice': |
| 698 |
inserted = args.slice(2); |
| 699 |
break |
| 700 |
} |
| 701 |
if (inserted) { ob.observeArray(inserted); } |
| 702 |
// notify change |
| 703 |
ob.dep.notify(); |
| 704 |
return result |
| 705 |
}); |
| 706 |
}); |
| 707 |
|
| 708 |
/* */ |
| 709 |
|
| 710 |
var arrayKeys = Object.getOwnPropertyNames(arrayMethods); |
| 711 |
|
| 712 |
/** |
| 713 |
* By default, when a reactive property is set, the new value is |
| 714 |
* also converted to become reactive. However when passing down props, |
| 715 |
* we don't want to force conversion because the value may be a nested value |
| 716 |
* under a frozen data structure. Converting it would defeat the optimization. |
| 717 |
*/ |
| 718 |
var observerState = { |
| 719 |
shouldConvert: true, |
| 720 |
isSettingProps: false |
| 721 |
}; |
| 722 |
|
| 723 |
/** |
| 724 |
* Observer class that are attached to each observed |
| 725 |
* object. Once attached, the observer converts target |
| 726 |
* object's property keys into getter/setters that |
| 727 |
* collect dependencies and dispatches updates. |
| 728 |
*/ |
| 729 |
var Observer = function Observer (value) { |
| 730 |
this.value = value; |
| 731 |
this.dep = new Dep(); |
| 732 |
this.vmCount = 0; |
| 733 |
def(value, '__ob__', this); |
| 734 |
if (Array.isArray(value)) { |
| 735 |
var augment = hasProto |
| 736 |
? protoAugment |
| 737 |
: copyAugment; |
| 738 |
augment(value, arrayMethods, arrayKeys); |
| 739 |
this.observeArray(value); |
| 740 |
} else { |
| 741 |
this.walk(value); |
| 742 |
} |
| 743 |
}; |
| 744 |
|
| 745 |
/** |
| 746 |
* Walk through each property and convert them into |
| 747 |
* getter/setters. This method should only be called when |
| 748 |
* value type is Object. |
| 749 |
*/ |
| 750 |
Observer.prototype.walk = function walk (obj) { |
| 751 |
var keys = Object.keys(obj); |
| 752 |
for (var i = 0; i < keys.length; i++) { |
| 753 |
defineReactive$$1(obj, keys[i], obj[keys[i]]); |
| 754 |
} |
| 755 |
}; |
| 756 |
|
| 757 |
/** |
| 758 |
* Observe a list of Array items. |
| 759 |
*/ |
| 760 |
Observer.prototype.observeArray = function observeArray (items) { |
| 761 |
for (var i = 0, l = items.length; i < l; i++) { |
| 762 |
observe(items[i]); |
| 763 |
} |
| 764 |
}; |
| 765 |
|
| 766 |
// helpers |
| 767 |
|
| 768 |
/** |
| 769 |
* Augment an target Object or Array by intercepting |
| 770 |
* the prototype chain using __proto__ |
| 771 |
*/ |
| 772 |
function protoAugment (target, src) { |
| 773 |
/* eslint-disable no-proto */ |
| 774 |
target.__proto__ = src; |
| 775 |
/* eslint-enable no-proto */ |
| 776 |
} |
| 777 |
|
| 778 |
/** |
| 779 |
* Augment an target Object or Array by defining |
| 780 |
* hidden properties. |
| 781 |
*/ |
| 782 |
/* istanbul ignore next */ |
| 783 |
function copyAugment (target, src, keys) { |
| 784 |
for (var i = 0, l = keys.length; i < l; i++) { |
| 785 |
var key = keys[i]; |
| 786 |
def(target, key, src[key]); |
| 787 |
} |
| 788 |
} |
| 789 |
|
| 790 |
/** |
| 791 |
* Attempt to create an observer instance for a value, |
| 792 |
* returns the new observer if successfully observed, |
| 793 |
* or the existing observer if the value already has one. |
| 794 |
*/ |
| 795 |
function observe (value, asRootData) { |
| 796 |
if (!isObject(value)) { |
| 797 |
return |
| 798 |
} |
| 799 |
var ob; |
| 800 |
if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) { |
| 801 |
ob = value.__ob__; |
| 802 |
} else if ( |
| 803 |
observerState.shouldConvert && |
| 804 |
!isServerRendering() && |
| 805 |
(Array.isArray(value) || isPlainObject(value)) && |
| 806 |
Object.isExtensible(value) && |
| 807 |
!value._isVue |
| 808 |
) { |
| 809 |
ob = new Observer(value); |
| 810 |
} |
| 811 |
if (asRootData && ob) { |
| 812 |
ob.vmCount++; |
| 813 |
} |
| 814 |
return ob |
| 815 |
} |
| 816 |
|
| 817 |
/** |
| 818 |
* Define a reactive property on an Object. |
| 819 |
*/ |
| 820 |
function defineReactive$$1 ( |
| 821 |
obj, |
| 822 |
key, |
| 823 |
val, |
| 824 |
customSetter |
| 825 |
) { |
| 826 |
var dep = new Dep(); |
| 827 |
|
| 828 |
var property = Object.getOwnPropertyDescriptor(obj, key); |
| 829 |
if (property && property.configurable === false) { |
| 830 |
return |
| 831 |
} |
| 832 |
|
| 833 |
// cater for pre-defined getter/setters |
| 834 |
var getter = property && property.get; |
| 835 |
var setter = property && property.set; |
| 836 |
|
| 837 |
var childOb = observe(val); |
| 838 |
Object.defineProperty(obj, key, { |
| 839 |
enumerable: true, |
| 840 |
configurable: true, |
| 841 |
get: function reactiveGetter () { |
| 842 |
var value = getter ? getter.call(obj) : val; |
| 843 |
if (Dep.target) { |
| 844 |
dep.depend(); |
| 845 |
if (childOb) { |
| 846 |
childOb.dep.depend(); |
| 847 |
} |
| 848 |
if (Array.isArray(value)) { |
| 849 |
dependArray(value); |
| 850 |
} |
| 851 |
} |
| 852 |
return value |
| 853 |
}, |
| 854 |
set: function reactiveSetter (newVal) { |
| 855 |
var value = getter ? getter.call(obj) : val; |
| 856 |
/* eslint-disable no-self-compare */ |
| 857 |
if (newVal === value || (newVal !== newVal && value !== value)) { |
| 858 |
return |
| 859 |
} |
| 860 |
/* eslint-enable no-self-compare */ |
| 861 |
if ("development" !== 'production' && customSetter) { |
| 862 |
customSetter(); |
| 863 |
} |
| 864 |
if (setter) { |
| 865 |
setter.call(obj, newVal); |
| 866 |
} else { |
| 867 |
val = newVal; |
| 868 |
} |
| 869 |
childOb = observe(newVal); |
| 870 |
dep.notify(); |
| 871 |
} |
| 872 |
}); |
| 873 |
} |
| 874 |
|
| 875 |
/** |
| 876 |
* Set a property on an object. Adds the new property and |
| 877 |
* triggers change notification if the property doesn't |
| 878 |
* already exist. |
| 879 |
*/ |
| 880 |
function set (target, key, val) { |
| 881 |
if (Array.isArray(target)) { |
| 882 |
target.length = Math.max(target.length, key); |
| 883 |
target.splice(key, 1, val); |
| 884 |
return val |
| 885 |
} |
| 886 |
if (hasOwn(target, key)) { |
| 887 |
target[key] = val; |
| 888 |
return val |
| 889 |
} |
| 890 |
var ob = target.__ob__; |
| 891 |
if (target._isVue || (ob && ob.vmCount)) { |
| 892 |
"development" !== 'production' && warn( |
| 893 |
'Avoid adding reactive properties to a Vue instance or its root $data ' + |
| 894 |
'at runtime - declare it upfront in the data option.' |
| 895 |
); |
| 896 |
return val |
| 897 |
} |
| 898 |
if (!ob) { |
| 899 |
target[key] = val; |
| 900 |
return val |
| 901 |
} |
| 902 |
defineReactive$$1(ob.value, key, val); |
| 903 |
ob.dep.notify(); |
| 904 |
return val |
| 905 |
} |
| 906 |
|
| 907 |
/** |
| 908 |
* Delete a property and trigger change if necessary. |
| 909 |
*/ |
| 910 |
function del (target, key) { |
| 911 |
if (Array.isArray(target)) { |
| 912 |
target.splice(key, 1); |
| 913 |
return |
| 914 |
} |
| 915 |
var ob = target.__ob__; |
| 916 |
if (target._isVue || (ob && ob.vmCount)) { |
| 917 |
"development" !== 'production' && warn( |
| 918 |
'Avoid deleting properties on a Vue instance or its root $data ' + |
| 919 |
'- just set it to null.' |
| 920 |
); |
| 921 |
return |
| 922 |
} |
| 923 |
if (!hasOwn(target, key)) { |
| 924 |
return |
| 925 |
} |
| 926 |
delete target[key]; |
| 927 |
if (!ob) { |
| 928 |
return |
| 929 |
} |
| 930 |
ob.dep.notify(); |
| 931 |
} |
| 932 |
|
| 933 |
/** |
| 934 |
* Collect dependencies on array elements when the array is touched, since |
| 935 |
* we cannot intercept array element access like property getters. |
| 936 |
*/ |
| 937 |
function dependArray (value) { |
| 938 |
for (var e = (void 0), i = 0, l = value.length; i < l; i++) { |
| 939 |
e = value[i]; |
| 940 |
e && e.__ob__ && e.__ob__.dep.depend(); |
| 941 |
if (Array.isArray(e)) { |
| 942 |
dependArray(e); |
| 943 |
} |
| 944 |
} |
| 945 |
} |
| 946 |
|
| 947 |
/* */ |
| 948 |
|
| 949 |
/** |
| 950 |
* Option overwriting strategies are functions that handle |
| 951 |
* how to merge a parent option value and a child option |
| 952 |
* value into the final value. |
| 953 |
*/ |
| 954 |
var strats = config.optionMergeStrategies; |
| 955 |
|
| 956 |
/** |
| 957 |
* Options with restrictions |
| 958 |
*/ |
| 959 |
{ |
| 960 |
strats.el = strats.propsData = function (parent, child, vm, key) { |
| 961 |
if (!vm) { |
| 962 |
warn( |
| 963 |
"option \"" + key + "\" can only be used during instance " + |
| 964 |
'creation with the `new` keyword.' |
| 965 |
); |
| 966 |
} |
| 967 |
return defaultStrat(parent, child) |
| 968 |
}; |
| 969 |
} |
| 970 |
|
| 971 |
/** |
| 972 |
* Helper that recursively merges two data objects together. |
| 973 |
*/ |
| 974 |
function mergeData (to, from) { |
| 975 |
if (!from) { return to } |
| 976 |
var key, toVal, fromVal; |
| 977 |
var keys = Object.keys(from); |
| 978 |
for (var i = 0; i < keys.length; i++) { |
| 979 |
key = keys[i]; |
| 980 |
toVal = to[key]; |
| 981 |
fromVal = from[key]; |
| 982 |
if (!hasOwn(to, key)) { |
| 983 |
set(to, key, fromVal); |
| 984 |
} else if (isPlainObject(toVal) && isPlainObject(fromVal)) { |
| 985 |
mergeData(toVal, fromVal); |
| 986 |
} |
| 987 |
} |
| 988 |
return to |
| 989 |
} |
| 990 |
|
| 991 |
/** |
| 992 |
* Data |
| 993 |
*/ |
| 994 |
strats.data = function ( |
| 995 |
parentVal, |
| 996 |
childVal, |
| 997 |
vm |
| 998 |
) { |
| 999 |
if (!vm) { |
| 1000 |
// in a Vue.extend merge, both should be functions |
| 1001 |
if (!childVal) { |
| 1002 |
return parentVal |
| 1003 |
} |
| 1004 |
if (typeof childVal !== 'function') { |
| 1005 |
"development" !== 'production' && warn( |
| 1006 |
'The "data" option should be a function ' + |
| 1007 |
'that returns a per-instance value in component ' + |
| 1008 |
'definitions.', |
| 1009 |
vm |
| 1010 |
); |
| 1011 |
return parentVal |
| 1012 |
} |
| 1013 |
if (!parentVal) { |
| 1014 |
return childVal |
| 1015 |
} |
| 1016 |
// when parentVal & childVal are both present, |
| 1017 |
// we need to return a function that returns the |
| 1018 |
// merged result of both functions... no need to |
| 1019 |
// check if parentVal is a function here because |
| 1020 |
// it has to be a function to pass previous merges. |
| 1021 |
return function mergedDataFn () { |
| 1022 |
return mergeData( |
| 1023 |
childVal.call(this), |
| 1024 |
parentVal.call(this) |
| 1025 |
) |
| 1026 |
} |
| 1027 |
} else if (parentVal || childVal) { |
| 1028 |
return function mergedInstanceDataFn () { |
| 1029 |
// instance merge |
| 1030 |
var instanceData = typeof childVal === 'function' |
| 1031 |
? childVal.call(vm) |
| 1032 |
: childVal; |
| 1033 |
var defaultData = typeof parentVal === 'function' |
| 1034 |
? parentVal.call(vm) |
| 1035 |
: undefined; |
| 1036 |
if (instanceData) { |
| 1037 |
return mergeData(instanceData, defaultData) |
| 1038 |
} else { |
| 1039 |
return defaultData |
| 1040 |
} |
| 1041 |
} |
| 1042 |
} |
| 1043 |
}; |
| 1044 |
|
| 1045 |
/** |
| 1046 |
* Hooks and props are merged as arrays. |
| 1047 |
*/ |
| 1048 |
function mergeHook ( |
| 1049 |
parentVal, |
| 1050 |
childVal |
| 1051 |
) { |
| 1052 |
return childVal |
| 1053 |
? parentVal |
| 1054 |
? parentVal.concat(childVal) |
| 1055 |
: Array.isArray(childVal) |
| 1056 |
? childVal |
| 1057 |
: [childVal] |
| 1058 |
: parentVal |
| 1059 |
} |
| 1060 |
|
| 1061 |
config._lifecycleHooks.forEach(function (hook) { |
| 1062 |
strats[hook] = mergeHook; |
| 1063 |
}); |
| 1064 |
|
| 1065 |
/** |
| 1066 |
* Assets |
| 1067 |
* |
| 1068 |
* When a vm is present (instance creation), we need to do |
| 1069 |
* a three-way merge between constructor options, instance |
| 1070 |
* options and parent options. |
| 1071 |
*/ |
| 1072 |
function mergeAssets (parentVal, childVal) { |
| 1073 |
var res = Object.create(parentVal || null); |
| 1074 |
return childVal |
| 1075 |
? extend(res, childVal) |
| 1076 |
: res |
| 1077 |
} |
| 1078 |
|
| 1079 |
config._assetTypes.forEach(function (type) { |
| 1080 |
strats[type + 's'] = mergeAssets; |
| 1081 |
}); |
| 1082 |
|
| 1083 |
/** |
| 1084 |
* Watchers. |
| 1085 |
* |
| 1086 |
* Watchers hashes should not overwrite one |
| 1087 |
* another, so we merge them as arrays. |
| 1088 |
*/ |
| 1089 |
strats.watch = function (parentVal, childVal) { |
| 1090 |
/* istanbul ignore if */ |
| 1091 |
if (!childVal) { return Object.create(parentVal || null) } |
| 1092 |
if (!parentVal) { return childVal } |
| 1093 |
var ret = {}; |
| 1094 |
extend(ret, parentVal); |
| 1095 |
for (var key in childVal) { |
| 1096 |
var parent = ret[key]; |
| 1097 |
var child = childVal[key]; |
| 1098 |
if (parent && !Array.isArray(parent)) { |
| 1099 |
parent = [parent]; |
| 1100 |
} |
| 1101 |
ret[key] = parent |
| 1102 |
? parent.concat(child) |
| 1103 |
: [child]; |
| 1104 |
} |
| 1105 |
return ret |
| 1106 |
}; |
| 1107 |
|
| 1108 |
/** |
| 1109 |
* Other object hashes. |
| 1110 |
*/ |
| 1111 |
strats.props = |
| 1112 |
strats.methods = |
| 1113 |
strats.computed = function (parentVal, childVal) { |
| 1114 |
if (!childVal) { return Object.create(parentVal || null) } |
| 1115 |
if (!parentVal) { return childVal } |
| 1116 |
var ret = Object.create(null); |
| 1117 |
extend(ret, parentVal); |
| 1118 |
extend(ret, childVal); |
| 1119 |
return ret |
| 1120 |
}; |
| 1121 |
|
| 1122 |
/** |
| 1123 |
* Default strategy. |
| 1124 |
*/ |
| 1125 |
var defaultStrat = function (parentVal, childVal) { |
| 1126 |
return childVal === undefined |
| 1127 |
? parentVal |
| 1128 |
: childVal |
| 1129 |
}; |
| 1130 |
|
| 1131 |
/** |
| 1132 |
* Validate component names |
| 1133 |
*/ |
| 1134 |
function checkComponents (options) { |
| 1135 |
for (var key in options.components) { |
| 1136 |
var lower = key.toLowerCase(); |
| 1137 |
if (isBuiltInTag(lower) || config.isReservedTag(lower)) { |
| 1138 |
warn( |
| 1139 |
'Do not use built-in or reserved HTML elements as component ' + |
| 1140 |
'id: ' + key |
| 1141 |
); |
| 1142 |
} |
| 1143 |
} |
| 1144 |
} |
| 1145 |
|
| 1146 |
/** |
| 1147 |
* Ensure all props option syntax are normalized into the |
| 1148 |
* Object-based format. |
| 1149 |
*/ |
| 1150 |
function normalizeProps (options) { |
| 1151 |
var props = options.props; |
| 1152 |
if (!props) { return } |
| 1153 |
var res = {}; |
| 1154 |
var i, val, name; |
| 1155 |
if (Array.isArray(props)) { |
| 1156 |
i = props.length; |
| 1157 |
while (i--) { |
| 1158 |
val = props[i]; |
| 1159 |
if (typeof val === 'string') { |
| 1160 |
name = camelize(val); |
| 1161 |
res[name] = { type: null }; |
| 1162 |
} else { |
| 1163 |
warn('props must be strings when using array syntax.'); |
| 1164 |
} |
| 1165 |
} |
| 1166 |
} else if (isPlainObject(props)) { |
| 1167 |
for (var key in props) { |
| 1168 |
val = props[key]; |
| 1169 |
name = camelize(key); |
| 1170 |
res[name] = isPlainObject(val) |
| 1171 |
? val |
| 1172 |
: { type: val }; |
| 1173 |
} |
| 1174 |
} |
| 1175 |
options.props = res; |
| 1176 |
} |
| 1177 |
|
| 1178 |
/** |
| 1179 |
* Normalize raw function directives into object format. |
| 1180 |
*/ |
| 1181 |
function normalizeDirectives (options) { |
| 1182 |
var dirs = options.directives; |
| 1183 |
if (dirs) { |
| 1184 |
for (var key in dirs) { |
| 1185 |
var def = dirs[key]; |
| 1186 |
if (typeof def === 'function') { |
| 1187 |
dirs[key] = { bind: def, update: def }; |
| 1188 |
} |
| 1189 |
} |
| 1190 |
} |
| 1191 |
} |
| 1192 |
|
| 1193 |
/** |
| 1194 |
* Merge two option objects into a new one. |
| 1195 |
* Core utility used in both instantiation and inheritance. |
| 1196 |
*/ |
| 1197 |
function mergeOptions ( |
| 1198 |
parent, |
| 1199 |
child, |
| 1200 |
vm |
| 1201 |
) { |
| 1202 |
{ |
| 1203 |
checkComponents(child); |
| 1204 |
} |
| 1205 |
normalizeProps(child); |
| 1206 |
normalizeDirectives(child); |
| 1207 |
var extendsFrom = child.extends; |
| 1208 |
if (extendsFrom) { |
| 1209 |
parent = typeof extendsFrom === 'function' |
| 1210 |
? mergeOptions(parent, extendsFrom.options, vm) |
| 1211 |
: mergeOptions(parent, extendsFrom, vm); |
| 1212 |
} |
| 1213 |
if (child.mixins) { |
| 1214 |
for (var i = 0, l = child.mixins.length; i < l; i++) { |
| 1215 |
var mixin = child.mixins[i]; |
| 1216 |
if (mixin.prototype instanceof Vue$3) { |
| 1217 |
mixin = mixin.options; |
| 1218 |
} |
| 1219 |
parent = mergeOptions(parent, mixin, vm); |
| 1220 |
} |
| 1221 |
} |
| 1222 |
var options = {}; |
| 1223 |
var key; |
| 1224 |
for (key in parent) { |
| 1225 |
mergeField(key); |
| 1226 |
} |
| 1227 |
for (key in child) { |
| 1228 |
if (!hasOwn(parent, key)) { |
| 1229 |
mergeField(key); |
| 1230 |
} |
| 1231 |
} |
| 1232 |
function mergeField (key) { |
| 1233 |
var strat = strats[key] || defaultStrat; |
| 1234 |
options[key] = strat(parent[key], child[key], vm, key); |
| 1235 |
} |
| 1236 |
return options |
| 1237 |
} |
| 1238 |
|
| 1239 |
/** |
| 1240 |
* Resolve an asset. |
| 1241 |
* This function is used because child instances need access |
| 1242 |
* to assets defined in its ancestor chain. |
| 1243 |
*/ |
| 1244 |
function resolveAsset ( |
| 1245 |
options, |
| 1246 |
type, |
| 1247 |
id, |
| 1248 |
warnMissing |
| 1249 |
) { |
| 1250 |
/* istanbul ignore if */ |
| 1251 |
if (typeof id !== 'string') { |
| 1252 |
return |
| 1253 |
} |
| 1254 |
var assets = options[type]; |
| 1255 |
// check local registration variations first |
| 1256 |
if (hasOwn(assets, id)) { return assets[id] } |
| 1257 |
var camelizedId = camelize(id); |
| 1258 |
if (hasOwn(assets, camelizedId)) { return assets[camelizedId] } |
| 1259 |
var PascalCaseId = capitalize(camelizedId); |
| 1260 |
if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] } |
| 1261 |
// fallback to prototype chain |
| 1262 |
var res = assets[id] || assets[camelizedId] || assets[PascalCaseId]; |
| 1263 |
if ("development" !== 'production' && warnMissing && !res) { |
| 1264 |
warn( |
| 1265 |
'Failed to resolve ' + type.slice(0, -1) + ': ' + id, |
| 1266 |
options |
| 1267 |
); |
| 1268 |
} |
| 1269 |
return res |
| 1270 |
} |
| 1271 |
|
| 1272 |
/* */ |
| 1273 |
|
| 1274 |
function validateProp ( |
| 1275 |
key, |
| 1276 |
propOptions, |
| 1277 |
propsData, |
| 1278 |
vm |
| 1279 |
) { |
| 1280 |
var prop = propOptions[key]; |
| 1281 |
var absent = !hasOwn(propsData, key); |
| 1282 |
var value = propsData[key]; |
| 1283 |
// handle boolean props |
| 1284 |
if (isType(Boolean, prop.type)) { |
| 1285 |
if (absent && !hasOwn(prop, 'default')) { |
| 1286 |
value = false; |
| 1287 |
} else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) { |
| 1288 |
value = true; |
| 1289 |
} |
| 1290 |
} |
| 1291 |
// check default value |
| 1292 |
if (value === undefined) { |
| 1293 |
value = getPropDefaultValue(vm, prop, key); |
| 1294 |
// since the default value is a fresh copy, |
| 1295 |
// make sure to observe it. |
| 1296 |
var prevShouldConvert = observerState.shouldConvert; |
| 1297 |
observerState.shouldConvert = true; |
| 1298 |
observe(value); |
| 1299 |
observerState.shouldConvert = prevShouldConvert; |
| 1300 |
} |
| 1301 |
{ |
| 1302 |
assertProp(prop, key, value, vm, absent); |
| 1303 |
} |
| 1304 |
return value |
| 1305 |
} |
| 1306 |
|
| 1307 |
/** |
| 1308 |
* Get the default value of a prop. |
| 1309 |
*/ |
| 1310 |
function getPropDefaultValue (vm, prop, key) { |
| 1311 |
// no default, return undefined |
| 1312 |
if (!hasOwn(prop, 'default')) { |
| 1313 |
return undefined |
| 1314 |
} |
| 1315 |
var def = prop.default; |
| 1316 |
// warn against non-factory defaults for Object & Array |
| 1317 |
if ("development" !== 'production' && isObject(def)) { |
| 1318 |
warn( |
| 1319 |
'Invalid default value for prop "' + key + '": ' + |
| 1320 |
'Props with type Object/Array must use a factory function ' + |
| 1321 |
'to return the default value.', |
| 1322 |
vm |
| 1323 |
); |
| 1324 |
} |
| 1325 |
// the raw prop value was also undefined from previous render, |
| 1326 |
// return previous default value to avoid unnecessary watcher trigger |
| 1327 |
if (vm && vm.$options.propsData && |
| 1328 |
vm.$options.propsData[key] === undefined && |
| 1329 |
vm._props[key] !== undefined) { |
| 1330 |
return vm._props[key] |
| 1331 |
} |
| 1332 |
// call factory function for non-Function types |
| 1333 |
// a value is Function if its prototype is function even across different execution context |
| 1334 |
return typeof def === 'function' && getType(prop.type) !== 'Function' |
| 1335 |
? def.call(vm) |
| 1336 |
: def |
| 1337 |
} |
| 1338 |
|
| 1339 |
/** |
| 1340 |
* Assert whether a prop is valid. |
| 1341 |
*/ |
| 1342 |
function assertProp ( |
| 1343 |
prop, |
| 1344 |
name, |
| 1345 |
value, |
| 1346 |
vm, |
| 1347 |
absent |
| 1348 |
) { |
| 1349 |
if (prop.required && absent) { |
| 1350 |
warn( |
| 1351 |
'Missing required prop: "' + name + '"', |
| 1352 |
vm |
| 1353 |
); |
| 1354 |
return |
| 1355 |
} |
| 1356 |
if (value == null && !prop.required) { |
| 1357 |
return |
| 1358 |
} |
| 1359 |
var type = prop.type; |
| 1360 |
var valid = !type || type === true; |
| 1361 |
var expectedTypes = []; |
| 1362 |
if (type) { |
| 1363 |
if (!Array.isArray(type)) { |
| 1364 |
type = [type]; |
| 1365 |
} |
| 1366 |
for (var i = 0; i < type.length && !valid; i++) { |
| 1367 |
var assertedType = assertType(value, type[i]); |
| 1368 |
expectedTypes.push(assertedType.expectedType || ''); |
| 1369 |
valid = assertedType.valid; |
| 1370 |
} |
| 1371 |
} |
| 1372 |
if (!valid) { |
| 1373 |
warn( |
| 1374 |
'Invalid prop: type check failed for prop "' + name + '".' + |
| 1375 |
' Expected ' + expectedTypes.map(capitalize).join(', ') + |
| 1376 |
', got ' + Object.prototype.toString.call(value).slice(8, -1) + '.', |
| 1377 |
vm |
| 1378 |
); |
| 1379 |
return |
| 1380 |
} |
| 1381 |
var validator = prop.validator; |
| 1382 |
if (validator) { |
| 1383 |
if (!validator(value)) { |
| 1384 |
warn( |
| 1385 |
'Invalid prop: custom validator check failed for prop "' + name + '".', |
| 1386 |
vm |
| 1387 |
); |
| 1388 |
} |
| 1389 |
} |
| 1390 |
} |
| 1391 |
|
| 1392 |
/** |
| 1393 |
* Assert the type of a value |
| 1394 |
*/ |
| 1395 |
function assertType (value, type) { |
| 1396 |
var valid; |
| 1397 |
var expectedType = getType(type); |
| 1398 |
if (expectedType === 'String') { |
| 1399 |
valid = typeof value === (expectedType = 'string'); |
| 1400 |
} else if (expectedType === 'Number') { |
| 1401 |
valid = typeof value === (expectedType = 'number'); |
| 1402 |
} else if (expectedType === 'Boolean') { |
| 1403 |
valid = typeof value === (expectedType = 'boolean'); |
| 1404 |
} else if (expectedType === 'Function') { |
| 1405 |
valid = typeof value === (expectedType = 'function'); |
| 1406 |
} else if (expectedType === 'Object') { |
| 1407 |
valid = isPlainObject(value); |
| 1408 |
} else if (expectedType === 'Array') { |
| 1409 |
valid = Array.isArray(value); |
| 1410 |
} else { |
| 1411 |
valid = value instanceof type; |
| 1412 |
} |
| 1413 |
return { |
| 1414 |
valid: valid, |
| 1415 |
expectedType: expectedType |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
/** |
| 1420 |
* Use function string name to check built-in types, |
| 1421 |
* because a simple equality check will fail when running |
| 1422 |
* across different vms / iframes. |
| 1423 |
*/ |
| 1424 |
function getType (fn) { |
| 1425 |
var match = fn && fn.toString().match(/^\s*function (\w+)/); |
| 1426 |
return match && match[1] |
| 1427 |
} |
| 1428 |
|
| 1429 |
function isType (type, fn) { |
| 1430 |
if (!Array.isArray(fn)) { |
| 1431 |
return getType(fn) === getType(type) |
| 1432 |
} |
| 1433 |
for (var i = 0, len = fn.length; i < len; i++) { |
| 1434 |
if (getType(fn[i]) === getType(type)) { |
| 1435 |
return true |
| 1436 |
} |
| 1437 |
} |
| 1438 |
/* istanbul ignore next */ |
| 1439 |
return false |
| 1440 |
} |
| 1441 |
|
| 1442 |
function handleError (err, vm, info) { |
| 1443 |
if (config.errorHandler) { |
| 1444 |
config.errorHandler.call(null, err, vm, info); |
| 1445 |
} else { |
| 1446 |
{ |
| 1447 |
warn(("Error in " + info + ":"), vm); |
| 1448 |
} |
| 1449 |
/* istanbul ignore else */ |
| 1450 |
if (inBrowser && typeof console !== 'undefined') { |
| 1451 |
console.error(err); |
| 1452 |
} else { |
| 1453 |
throw err |
| 1454 |
} |
| 1455 |
} |
| 1456 |
} |
| 1457 |
|
| 1458 |
/* not type checking this file because flow doesn't play well with Proxy */ |
| 1459 |
|
| 1460 |
var initProxy; |
| 1461 |
|
| 1462 |
{ |
| 1463 |
var allowedGlobals = makeMap( |
| 1464 |
'Infinity,undefined,NaN,isFinite,isNaN,' + |
| 1465 |
'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' + |
| 1466 |
'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' + |
| 1467 |
'require' // for Webpack/Browserify |
| 1468 |
); |
| 1469 |
|
| 1470 |
var warnNonPresent = function (target, key) { |
| 1471 |
warn( |
| 1472 |
"Property or method \"" + key + "\" is not defined on the instance but " + |
| 1473 |
"referenced during render. Make sure to declare reactive data " + |
| 1474 |
"properties in the data option.", |
| 1475 |
target |
| 1476 |
); |
| 1477 |
}; |
| 1478 |
|
| 1479 |
var hasProxy = |
| 1480 |
typeof Proxy !== 'undefined' && |
| 1481 |
Proxy.toString().match(/native code/); |
| 1482 |
|
| 1483 |
if (hasProxy) { |
| 1484 |
var isBuiltInModifier = makeMap('stop,prevent,self,ctrl,shift,alt,meta'); |
| 1485 |
config.keyCodes = new Proxy(config.keyCodes, { |
| 1486 |
set: function set (target, key, value) { |
| 1487 |
if (isBuiltInModifier(key)) { |
| 1488 |
warn(("Avoid overwriting built-in modifier in config.keyCodes: ." + key)); |
| 1489 |
return false |
| 1490 |
} else { |
| 1491 |
target[key] = value; |
| 1492 |
return true |
| 1493 |
} |
| 1494 |
} |
| 1495 |
}); |
| 1496 |
} |
| 1497 |
|
| 1498 |
var hasHandler = { |
| 1499 |
has: function has (target, key) { |
| 1500 |
var has = key in target; |
| 1501 |
var isAllowed = allowedGlobals(key) || key.charAt(0) === '_'; |
| 1502 |
if (!has && !isAllowed) { |
| 1503 |
warnNonPresent(target, key); |
| 1504 |
} |
| 1505 |
return has || !isAllowed |
| 1506 |
} |
| 1507 |
}; |
| 1508 |
|
| 1509 |
var getHandler = { |
| 1510 |
get: function get (target, key) { |
| 1511 |
if (typeof key === 'string' && !(key in target)) { |
| 1512 |
warnNonPresent(target, key); |
| 1513 |
} |
| 1514 |
return target[key] |
| 1515 |
} |
| 1516 |
}; |
| 1517 |
|
| 1518 |
initProxy = function initProxy (vm) { |
| 1519 |
if (hasProxy) { |
| 1520 |
// determine which proxy handler to use |
| 1521 |
var options = vm.$options; |
| 1522 |
var handlers = options.render && options.render._withStripped |
| 1523 |
? getHandler |
| 1524 |
: hasHandler; |
| 1525 |
vm._renderProxy = new Proxy(vm, handlers); |
| 1526 |
} else { |
| 1527 |
vm._renderProxy = vm; |
| 1528 |
} |
| 1529 |
}; |
| 1530 |
} |
| 1531 |
|
| 1532 |
var mark; |
| 1533 |
var measure; |
| 1534 |
|
| 1535 |
{ |
| 1536 |
var perf = inBrowser && window.performance; |
| 1537 |
/* istanbul ignore if */ |
| 1538 |
if ( |
| 1539 |
perf && |
| 1540 |
perf.mark && |
| 1541 |
perf.measure && |
| 1542 |
perf.clearMarks && |
| 1543 |
perf.clearMeasures |
| 1544 |
) { |
| 1545 |
mark = function (tag) { return perf.mark(tag); }; |
| 1546 |
measure = function (name, startTag, endTag) { |
| 1547 |
perf.measure(name, startTag, endTag); |
| 1548 |
perf.clearMarks(startTag); |
| 1549 |
perf.clearMarks(endTag); |
| 1550 |
perf.clearMeasures(name); |
| 1551 |
}; |
| 1552 |
} |
| 1553 |
} |
| 1554 |
|
| 1555 |
/* */ |
| 1556 |
|
| 1557 |
var VNode = function VNode ( |
| 1558 |
tag, |
| 1559 |
data, |
| 1560 |
children, |
| 1561 |
text, |
| 1562 |
elm, |
| 1563 |
context, |
| 1564 |
componentOptions |
| 1565 |
) { |
| 1566 |
this.tag = tag; |
| 1567 |
this.data = data; |
| 1568 |
this.children = children; |
| 1569 |
this.text = text; |
| 1570 |
this.elm = elm; |
| 1571 |
this.ns = undefined; |
| 1572 |
this.context = context; |
| 1573 |
this.functionalContext = undefined; |
| 1574 |
this.key = data && data.key; |
| 1575 |
this.componentOptions = componentOptions; |
| 1576 |
this.componentInstance = undefined; |
| 1577 |
this.parent = undefined; |
| 1578 |
this.raw = false; |
| 1579 |
this.isStatic = false; |
| 1580 |
this.isRootInsert = true; |
| 1581 |
this.isComment = false; |
| 1582 |
this.isCloned = false; |
| 1583 |
this.isOnce = false; |
| 1584 |
}; |
| 1585 |
|
| 1586 |
var prototypeAccessors = { child: {} }; |
| 1587 |
|
| 1588 |
// DEPRECATED: alias for componentInstance for backwards compat. |
| 1589 |
/* istanbul ignore next */ |
| 1590 |
prototypeAccessors.child.get = function () { |
| 1591 |
return this.componentInstance |
| 1592 |
}; |
| 1593 |
|
| 1594 |
Object.defineProperties( VNode.prototype, prototypeAccessors ); |
| 1595 |
|
| 1596 |
var createEmptyVNode = function () { |
| 1597 |
var node = new VNode(); |
| 1598 |
node.text = ''; |
| 1599 |
node.isComment = true; |
| 1600 |
return node |
| 1601 |
}; |
| 1602 |
|
| 1603 |
function createTextVNode (val) { |
| 1604 |
return new VNode(undefined, undefined, undefined, String(val)) |
| 1605 |
} |
| 1606 |
|
| 1607 |
// optimized shallow clone |
| 1608 |
// used for static nodes and slot nodes because they may be reused across |
| 1609 |
// multiple renders, cloning them avoids errors when DOM manipulations rely |
| 1610 |
// on their elm reference. |
| 1611 |
function cloneVNode (vnode) { |
| 1612 |
var cloned = new VNode( |
| 1613 |
vnode.tag, |
| 1614 |
vnode.data, |
| 1615 |
vnode.children, |
| 1616 |
vnode.text, |
| 1617 |
vnode.elm, |
| 1618 |
vnode.context, |
| 1619 |
vnode.componentOptions |
| 1620 |
); |
| 1621 |
cloned.ns = vnode.ns; |
| 1622 |
cloned.isStatic = vnode.isStatic; |
| 1623 |
cloned.key = vnode.key; |
| 1624 |
cloned.isCloned = true; |
| 1625 |
return cloned |
| 1626 |
} |
| 1627 |
|
| 1628 |
function cloneVNodes (vnodes) { |
| 1629 |
var len = vnodes.length; |
| 1630 |
var res = new Array(len); |
| 1631 |
for (var i = 0; i < len; i++) { |
| 1632 |
res[i] = cloneVNode(vnodes[i]); |
| 1633 |
} |
| 1634 |
return res |
| 1635 |
} |
| 1636 |
|
| 1637 |
/* */ |
| 1638 |
|
| 1639 |
var normalizeEvent = cached(function (name) { |
| 1640 |
var once$$1 = name.charAt(0) === '~'; // Prefixed last, checked first |
| 1641 |
name = once$$1 ? name.slice(1) : name; |
| 1642 |
var capture = name.charAt(0) === '!'; |
| 1643 |
name = capture ? name.slice(1) : name; |
| 1644 |
return { |
| 1645 |
name: name, |
| 1646 |
once: once$$1, |
| 1647 |
capture: capture |
| 1648 |
} |
| 1649 |
}); |
| 1650 |
|
| 1651 |
function createFnInvoker (fns) { |
| 1652 |
function invoker () { |
| 1653 |
var arguments$1 = arguments; |
| 1654 |
|
| 1655 |
var fns = invoker.fns; |
| 1656 |
if (Array.isArray(fns)) { |
| 1657 |
for (var i = 0; i < fns.length; i++) { |
| 1658 |
fns[i].apply(null, arguments$1); |
| 1659 |
} |
| 1660 |
} else { |
| 1661 |
// return handler return value for single handlers |
| 1662 |
return fns.apply(null, arguments) |
| 1663 |
} |
| 1664 |
} |
| 1665 |
invoker.fns = fns; |
| 1666 |
return invoker |
| 1667 |
} |
| 1668 |
|
| 1669 |
function updateListeners ( |
| 1670 |
on, |
| 1671 |
oldOn, |
| 1672 |
add, |
| 1673 |
remove$$1, |
| 1674 |
vm |
| 1675 |
) { |
| 1676 |
var name, cur, old, event; |
| 1677 |
for (name in on) { |
| 1678 |
cur = on[name]; |
| 1679 |
old = oldOn[name]; |
| 1680 |
event = normalizeEvent(name); |
| 1681 |
if (!cur) { |
| 1682 |
"development" !== 'production' && warn( |
| 1683 |
"Invalid handler for event \"" + (event.name) + "\": got " + String(cur), |
| 1684 |
vm |
| 1685 |
); |
| 1686 |
} else if (!old) { |
| 1687 |
if (!cur.fns) { |
| 1688 |
cur = on[name] = createFnInvoker(cur); |
| 1689 |
} |
| 1690 |
add(event.name, cur, event.once, event.capture); |
| 1691 |
} else if (cur !== old) { |
| 1692 |
old.fns = cur; |
| 1693 |
on[name] = old; |
| 1694 |
} |
| 1695 |
} |
| 1696 |
for (name in oldOn) { |
| 1697 |
if (!on[name]) { |
| 1698 |
event = normalizeEvent(name); |
| 1699 |
remove$$1(event.name, oldOn[name], event.capture); |
| 1700 |
} |
| 1701 |
} |
| 1702 |
} |
| 1703 |
|
| 1704 |
/* */ |
| 1705 |
|
| 1706 |
function mergeVNodeHook (def, hookKey, hook) { |
| 1707 |
var invoker; |
| 1708 |
var oldHook = def[hookKey]; |
| 1709 |
|
| 1710 |
function wrappedHook () { |
| 1711 |
hook.apply(this, arguments); |
| 1712 |
// important: remove merged hook to ensure it's called only once |
| 1713 |
// and prevent memory leak |
| 1714 |
remove(invoker.fns, wrappedHook); |
| 1715 |
} |
| 1716 |
|
| 1717 |
if (!oldHook) { |
| 1718 |
// no existing hook |
| 1719 |
invoker = createFnInvoker([wrappedHook]); |
| 1720 |
} else { |
| 1721 |
/* istanbul ignore if */ |
| 1722 |
if (oldHook.fns && oldHook.merged) { |
| 1723 |
// already a merged invoker |
| 1724 |
invoker = oldHook; |
| 1725 |
invoker.fns.push(wrappedHook); |
| 1726 |
} else { |
| 1727 |
// existing plain hook |
| 1728 |
invoker = createFnInvoker([oldHook, wrappedHook]); |
| 1729 |
} |
| 1730 |
} |
| 1731 |
|
| 1732 |
invoker.merged = true; |
| 1733 |
def[hookKey] = invoker; |
| 1734 |
} |
| 1735 |
|
| 1736 |
/* */ |
| 1737 |
|
| 1738 |
// The template compiler attempts to minimize the need for normalization by |
| 1739 |
// statically analyzing the template at compile time. |
| 1740 |
// |
| 1741 |
// For plain HTML markup, normalization can be completely skipped because the |
| 1742 |
// generated render function is guaranteed to return Array<VNode>. There are |
| 1743 |
// two cases where extra normalization is needed: |
| 1744 |
|
| 1745 |
// 1. When the children contains components - because a functional component |
| 1746 |
// may return an Array instead of a single root. In this case, just a simple |
| 1747 |
// normalization is needed - if any child is an Array, we flatten the whole |
| 1748 |
// thing with Array.prototype.concat. It is guaranteed to be only 1-level deep |
| 1749 |
// because functional components already normalize their own children. |
| 1750 |
function simpleNormalizeChildren (children) { |
| 1751 |
for (var i = 0; i < children.length; i++) { |
| 1752 |
if (Array.isArray(children[i])) { |
| 1753 |
return Array.prototype.concat.apply([], children) |
| 1754 |
} |
| 1755 |
} |
| 1756 |
return children |
| 1757 |
} |
| 1758 |
|
| 1759 |
// 2. When the children contains constructs that always generated nested Arrays, |
| 1760 |
// e.g. <template>, <slot>, v-for, or when the children is provided by user |
| 1761 |
// with hand-written render functions / JSX. In such cases a full normalization |
| 1762 |
// is needed to cater to all possible types of children values. |
| 1763 |
function normalizeChildren (children) { |
| 1764 |
return isPrimitive(children) |
| 1765 |
? [createTextVNode(children)] |
| 1766 |
: Array.isArray(children) |
| 1767 |
? normalizeArrayChildren(children) |
| 1768 |
: undefined |
| 1769 |
} |
| 1770 |
|
| 1771 |
function normalizeArrayChildren (children, nestedIndex) { |
| 1772 |
var res = []; |
| 1773 |
var i, c, last; |
| 1774 |
for (i = 0; i < children.length; i++) { |
| 1775 |
c = children[i]; |
| 1776 |
if (c == null || typeof c === 'boolean') { continue } |
| 1777 |
last = res[res.length - 1]; |
| 1778 |
// nested |
| 1779 |
if (Array.isArray(c)) { |
| 1780 |
res.push.apply(res, normalizeArrayChildren(c, ((nestedIndex || '') + "_" + i))); |
| 1781 |
} else if (isPrimitive(c)) { |
| 1782 |
if (last && last.text) { |
| 1783 |
last.text += String(c); |
| 1784 |
} else if (c !== '') { |
| 1785 |
// convert primitive to vnode |
| 1786 |
res.push(createTextVNode(c)); |
| 1787 |
} |
| 1788 |
} else { |
| 1789 |
if (c.text && last && last.text) { |
| 1790 |
res[res.length - 1] = createTextVNode(last.text + c.text); |
| 1791 |
} else { |
| 1792 |
// default key for nested array children (likely generated by v-for) |
| 1793 |
if (c.tag && c.key == null && nestedIndex != null) { |
| 1794 |
c.key = "__vlist" + nestedIndex + "_" + i + "__"; |
| 1795 |
} |
| 1796 |
res.push(c); |
| 1797 |
} |
| 1798 |
} |
| 1799 |
} |
| 1800 |
return res |
| 1801 |
} |
| 1802 |
|
| 1803 |
/* */ |
| 1804 |
|
| 1805 |
function getFirstComponentChild (children) { |
| 1806 |
return children && children.filter(function (c) { return c && c.componentOptions; })[0] |
| 1807 |
} |
| 1808 |
|
| 1809 |
/* */ |
| 1810 |
|
| 1811 |
function initEvents (vm) { |
| 1812 |
vm._events = Object.create(null); |
| 1813 |
vm._hasHookEvent = false; |
| 1814 |
// init parent attached events |
| 1815 |
var listeners = vm.$options._parentListeners; |
| 1816 |
if (listeners) { |
| 1817 |
updateComponentListeners(vm, listeners); |
| 1818 |
} |
| 1819 |
} |
| 1820 |
|
| 1821 |
var target; |
| 1822 |
|
| 1823 |
function add (event, fn, once$$1) { |
| 1824 |
if (once$$1) { |
| 1825 |
target.$once(event, fn); |
| 1826 |
} else { |
| 1827 |
target.$on(event, fn); |
| 1828 |
} |
| 1829 |
} |
| 1830 |
|
| 1831 |
function remove$1 (event, fn) { |
| 1832 |
target.$off(event, fn); |
| 1833 |
} |
| 1834 |
|
| 1835 |
function updateComponentListeners ( |
| 1836 |
vm, |
| 1837 |
listeners, |
| 1838 |
oldListeners |
| 1839 |
) { |
| 1840 |
target = vm; |
| 1841 |
updateListeners(listeners, oldListeners || {}, add, remove$1, vm); |
| 1842 |
} |
| 1843 |
|
| 1844 |
function eventsMixin (Vue) { |
| 1845 |
var hookRE = /^hook:/; |
| 1846 |
Vue.prototype.$on = function (event, fn) { |
| 1847 |
var this$1 = this; |
| 1848 |
|
| 1849 |
var vm = this; |
| 1850 |
if (Array.isArray(event)) { |
| 1851 |
for (var i = 0, l = event.length; i < l; i++) { |
| 1852 |
this$1.$on(event[i], fn); |
| 1853 |
} |
| 1854 |
} else { |
| 1855 |
(vm._events[event] || (vm._events[event] = [])).push(fn); |
| 1856 |
// optimize hook:event cost by using a boolean flag marked at registration |
| 1857 |
// instead of a hash lookup |
| 1858 |
if (hookRE.test(event)) { |
| 1859 |
vm._hasHookEvent = true; |
| 1860 |
} |
| 1861 |
} |
| 1862 |
return vm |
| 1863 |
}; |
| 1864 |
|
| 1865 |
Vue.prototype.$once = function (event, fn) { |
| 1866 |
var vm = this; |
| 1867 |
function on () { |
| 1868 |
vm.$off(event, on); |
| 1869 |
fn.apply(vm, arguments); |
| 1870 |
} |
| 1871 |
on.fn = fn; |
| 1872 |
vm.$on(event, on); |
| 1873 |
return vm |
| 1874 |
}; |
| 1875 |
|
| 1876 |
Vue.prototype.$off = function (event, fn) { |
| 1877 |
var this$1 = this; |
| 1878 |
|
| 1879 |
var vm = this; |
| 1880 |
// all |
| 1881 |
if (!arguments.length) { |
| 1882 |
vm._events = Object.create(null); |
| 1883 |
return vm |
| 1884 |
} |
| 1885 |
// array of events |
| 1886 |
if (Array.isArray(event)) { |
| 1887 |
for (var i$1 = 0, l = event.length; i$1 < l; i$1++) { |
| 1888 |
this$1.$off(event[i$1], fn); |
| 1889 |
} |
| 1890 |
return vm |
| 1891 |
} |
| 1892 |
// specific event |
| 1893 |
var cbs = vm._events[event]; |
| 1894 |
if (!cbs) { |
| 1895 |
return vm |
| 1896 |
} |
| 1897 |
if (arguments.length === 1) { |
| 1898 |
vm._events[event] = null; |
| 1899 |
return vm |
| 1900 |
} |
| 1901 |
// specific handler |
| 1902 |
var cb; |
| 1903 |
var i = cbs.length; |
| 1904 |
while (i--) { |
| 1905 |
cb = cbs[i]; |
| 1906 |
if (cb === fn || cb.fn === fn) { |
| 1907 |
cbs.splice(i, 1); |
| 1908 |
break |
| 1909 |
} |
| 1910 |
} |
| 1911 |
return vm |
| 1912 |
}; |
| 1913 |
|
| 1914 |
Vue.prototype.$emit = function (event) { |
| 1915 |
var vm = this; |
| 1916 |
var cbs = vm._events[event]; |
| 1917 |
if (cbs) { |
| 1918 |
cbs = cbs.length > 1 ? toArray(cbs) : cbs; |
| 1919 |
var args = toArray(arguments, 1); |
| 1920 |
for (var i = 0, l = cbs.length; i < l; i++) { |
| 1921 |
cbs[i].apply(vm, args); |
| 1922 |
} |
| 1923 |
} |
| 1924 |
return vm |
| 1925 |
}; |
| 1926 |
} |
| 1927 |
|
| 1928 |
/* */ |
| 1929 |
|
| 1930 |
/** |
| 1931 |
* Runtime helper for resolving raw children VNodes into a slot object. |
| 1932 |
*/ |
| 1933 |
function resolveSlots ( |
| 1934 |
children, |
| 1935 |
context |
| 1936 |
) { |
| 1937 |
var slots = {}; |
| 1938 |
if (!children) { |
| 1939 |
return slots |
| 1940 |
} |
| 1941 |
var defaultSlot = []; |
| 1942 |
var name, child; |
| 1943 |
for (var i = 0, l = children.length; i < l; i++) { |
| 1944 |
child = children[i]; |
| 1945 |
// named slots should only be respected if the vnode was rendered in the |
| 1946 |
// same context. |
| 1947 |
if ((child.context === context || child.functionalContext === context) && |
| 1948 |
child.data && (name = child.data.slot)) { |
| 1949 |
var slot = (slots[name] || (slots[name] = [])); |
| 1950 |
if (child.tag === 'template') { |
| 1951 |
slot.push.apply(slot, child.children); |
| 1952 |
} else { |
| 1953 |
slot.push(child); |
| 1954 |
} |
| 1955 |
} else { |
| 1956 |
defaultSlot.push(child); |
| 1957 |
} |
| 1958 |
} |
| 1959 |
// ignore whitespace |
| 1960 |
if (!defaultSlot.every(isWhitespace)) { |
| 1961 |
slots.default = defaultSlot; |
| 1962 |
} |
| 1963 |
return slots |
| 1964 |
} |
| 1965 |
|
| 1966 |
function isWhitespace (node) { |
| 1967 |
return node.isComment || node.text === ' ' |
| 1968 |
} |
| 1969 |
|
| 1970 |
function resolveScopedSlots ( |
| 1971 |
fns |
| 1972 |
) { |
| 1973 |
var res = {}; |
| 1974 |
for (var i = 0; i < fns.length; i++) { |
| 1975 |
res[fns[i][0]] = fns[i][1]; |
| 1976 |
} |
| 1977 |
return res |
| 1978 |
} |
| 1979 |
|
| 1980 |
/* */ |
| 1981 |
|
| 1982 |
var activeInstance = null; |
| 1983 |
|
| 1984 |
function initLifecycle (vm) { |
| 1985 |
var options = vm.$options; |
| 1986 |
|
| 1987 |
// locate first non-abstract parent |
| 1988 |
var parent = options.parent; |
| 1989 |
if (parent && !options.abstract) { |
| 1990 |
while (parent.$options.abstract && parent.$parent) { |
| 1991 |
parent = parent.$parent; |
| 1992 |
} |
| 1993 |
parent.$children.push(vm); |
| 1994 |
} |
| 1995 |
|
| 1996 |
vm.$parent = parent; |
| 1997 |
vm.$root = parent ? parent.$root : vm; |
| 1998 |
|
| 1999 |
vm.$children = []; |
| 2000 |
vm.$refs = {}; |
| 2001 |
|
| 2002 |
vm._watcher = null; |
| 2003 |
vm._inactive = null; |
| 2004 |
vm._directInactive = false; |
| 2005 |
vm._isMounted = false; |
| 2006 |
vm._isDestroyed = false; |
| 2007 |
vm._isBeingDestroyed = false; |
| 2008 |
} |
| 2009 |
|
| 2010 |
function lifecycleMixin (Vue) { |
| 2011 |
Vue.prototype._update = function (vnode, hydrating) { |
| 2012 |
var vm = this; |
| 2013 |
if (vm._isMounted) { |
| 2014 |
callHook(vm, 'beforeUpdate'); |
| 2015 |
} |
| 2016 |
var prevEl = vm.$el; |
| 2017 |
var prevVnode = vm._vnode; |
| 2018 |
var prevActiveInstance = activeInstance; |
| 2019 |
activeInstance = vm; |
| 2020 |
vm._vnode = vnode; |
| 2021 |
// Vue.prototype.__patch__ is injected in entry points |
| 2022 |
// based on the rendering backend used. |
| 2023 |
if (!prevVnode) { |
| 2024 |
// initial render |
| 2025 |
vm.$el = vm.__patch__( |
| 2026 |
vm.$el, vnode, hydrating, false /* removeOnly */, |
| 2027 |
vm.$options._parentElm, |
| 2028 |
vm.$options._refElm |
| 2029 |
); |
| 2030 |
} else { |
| 2031 |
// updates |
| 2032 |
vm.$el = vm.__patch__(prevVnode, vnode); |
| 2033 |
} |
| 2034 |
activeInstance = prevActiveInstance; |
| 2035 |
// update __vue__ reference |
| 2036 |
if (prevEl) { |
| 2037 |
prevEl.__vue__ = null; |
| 2038 |
} |
| 2039 |
if (vm.$el) { |
| 2040 |
vm.$el.__vue__ = vm; |
| 2041 |
} |
| 2042 |
// if parent is an HOC, update its $el as well |
| 2043 |
if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { |
| 2044 |
vm.$parent.$el = vm.$el; |
| 2045 |
} |
| 2046 |
// updated hook is called by the scheduler to ensure that children are |
| 2047 |
// updated in a parent's updated hook. |
| 2048 |
}; |
| 2049 |
|
| 2050 |
Vue.prototype.$forceUpdate = function () { |
| 2051 |
var vm = this; |
| 2052 |
if (vm._watcher) { |
| 2053 |
vm._watcher.update(); |
| 2054 |
} |
| 2055 |
}; |
| 2056 |
|
| 2057 |
Vue.prototype.$destroy = function () { |
| 2058 |
var vm = this; |
| 2059 |
if (vm._isBeingDestroyed) { |
| 2060 |
return |
| 2061 |
} |
| 2062 |
callHook(vm, 'beforeDestroy'); |
| 2063 |
vm._isBeingDestroyed = true; |
| 2064 |
// remove self from parent |
| 2065 |
var parent = vm.$parent; |
| 2066 |
if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { |
| 2067 |
remove(parent.$children, vm); |
| 2068 |
} |
| 2069 |
// teardown watchers |
| 2070 |
if (vm._watcher) { |
| 2071 |
vm._watcher.teardown(); |
| 2072 |
} |
| 2073 |
var i = vm._watchers.length; |
| 2074 |
while (i--) { |
| 2075 |
vm._watchers[i].teardown(); |
| 2076 |
} |
| 2077 |
// remove reference from data ob |
| 2078 |
// frozen object may not have observer. |
| 2079 |
if (vm._data.__ob__) { |
| 2080 |
vm._data.__ob__.vmCount--; |
| 2081 |
} |
| 2082 |
// call the last hook... |
| 2083 |
vm._isDestroyed = true; |
| 2084 |
callHook(vm, 'destroyed'); |
| 2085 |
// turn off all instance listeners. |
| 2086 |
vm.$off(); |
| 2087 |
// remove __vue__ reference |
| 2088 |
if (vm.$el) { |
| 2089 |
vm.$el.__vue__ = null; |
| 2090 |
} |
| 2091 |
// invoke destroy hooks on current rendered tree |
| 2092 |
vm.__patch__(vm._vnode, null); |
| 2093 |
}; |
| 2094 |
} |
| 2095 |
|
| 2096 |
function mountComponent ( |
| 2097 |
vm, |
| 2098 |
el, |
| 2099 |
hydrating |
| 2100 |
) { |
| 2101 |
vm.$el = el; |
| 2102 |
if (!vm.$options.render) { |
| 2103 |
vm.$options.render = createEmptyVNode; |
| 2104 |
{ |
| 2105 |
/* istanbul ignore if */ |
| 2106 |
if ((vm.$options.template && vm.$options.template.charAt(0) !== '#') || |
| 2107 |
vm.$options.el || el) { |
| 2108 |
warn( |
| 2109 |
'You are using the runtime-only build of Vue where the template ' + |
| 2110 |
'compiler is not available. Either pre-compile the templates into ' + |
| 2111 |
'render functions, or use the compiler-included build.', |
| 2112 |
vm |
| 2113 |
); |
| 2114 |
} else { |
| 2115 |
warn( |
| 2116 |
'Failed to mount component: template or render function not defined.', |
| 2117 |
vm |
| 2118 |
); |
| 2119 |
} |
| 2120 |
} |
| 2121 |
} |
| 2122 |
callHook(vm, 'beforeMount'); |
| 2123 |
|
| 2124 |
var updateComponent; |
| 2125 |
/* istanbul ignore if */ |
| 2126 |
if ("development" !== 'production' && config.performance && mark) { |
| 2127 |
updateComponent = function () { |
| 2128 |
var name = vm._name; |
| 2129 |
var id = vm._uid; |
| 2130 |
var startTag = "vue-perf-start:" + id; |
| 2131 |
var endTag = "vue-perf-end:" + id; |
| 2132 |
|
| 2133 |
mark(startTag); |
| 2134 |
var vnode = vm._render(); |
| 2135 |
mark(endTag); |
| 2136 |
measure((name + " render"), startTag, endTag); |
| 2137 |
|
| 2138 |
mark(startTag); |
| 2139 |
vm._update(vnode, hydrating); |
| 2140 |
mark(endTag); |
| 2141 |
measure((name + " patch"), startTag, endTag); |
| 2142 |
}; |
| 2143 |
} else { |
| 2144 |
updateComponent = function () { |
| 2145 |
vm._update(vm._render(), hydrating); |
| 2146 |
}; |
| 2147 |
} |
| 2148 |
|
| 2149 |
vm._watcher = new Watcher(vm, updateComponent, noop); |
| 2150 |
hydrating = false; |
| 2151 |
|
| 2152 |
// manually mounted instance, call mounted on self |
| 2153 |
// mounted is called for render-created child components in its inserted hook |
| 2154 |
if (vm.$vnode == null) { |
| 2155 |
vm._isMounted = true; |
| 2156 |
callHook(vm, 'mounted'); |
| 2157 |
} |
| 2158 |
return vm |
| 2159 |
} |
| 2160 |
|
| 2161 |
function updateChildComponent ( |
| 2162 |
vm, |
| 2163 |
propsData, |
| 2164 |
listeners, |
| 2165 |
parentVnode, |
| 2166 |
renderChildren |
| 2167 |
) { |
| 2168 |
// determine whether component has slot children |
| 2169 |
// we need to do this before overwriting $options._renderChildren |
| 2170 |
var hasChildren = !!( |
| 2171 |
renderChildren || // has new static slots |
| 2172 |
vm.$options._renderChildren || // has old static slots |
| 2173 |
parentVnode.data.scopedSlots || // has new scoped slots |
| 2174 |
vm.$scopedSlots !== emptyObject // has old scoped slots |
| 2175 |
); |
| 2176 |
|
| 2177 |
vm.$options._parentVnode = parentVnode; |
| 2178 |
vm.$vnode = parentVnode; // update vm's placeholder node without re-render |
| 2179 |
if (vm._vnode) { // update child tree's parent |
| 2180 |
vm._vnode.parent = parentVnode; |
| 2181 |
} |
| 2182 |
vm.$options._renderChildren = renderChildren; |
| 2183 |
|
| 2184 |
// update props |
| 2185 |
if (propsData && vm.$options.props) { |
| 2186 |
observerState.shouldConvert = false; |
| 2187 |
{ |
| 2188 |
observerState.isSettingProps = true; |
| 2189 |
} |
| 2190 |
var props = vm._props; |
| 2191 |
var propKeys = vm.$options._propKeys || []; |
| 2192 |
for (var i = 0; i < propKeys.length; i++) { |
| 2193 |
var key = propKeys[i]; |
| 2194 |
props[key] = validateProp(key, vm.$options.props, propsData, vm); |
| 2195 |
} |
| 2196 |
observerState.shouldConvert = true; |
| 2197 |
{ |
| 2198 |
observerState.isSettingProps = false; |
| 2199 |
} |
| 2200 |
// keep a copy of raw propsData |
| 2201 |
vm.$options.propsData = propsData; |
| 2202 |
} |
| 2203 |
// update listeners |
| 2204 |
if (listeners) { |
| 2205 |
var oldListeners = vm.$options._parentListeners; |
| 2206 |
vm.$options._parentListeners = listeners; |
| 2207 |
updateComponentListeners(vm, listeners, oldListeners); |
| 2208 |
} |
| 2209 |
// resolve slots + force update if has children |
| 2210 |
if (hasChildren) { |
| 2211 |
vm.$slots = resolveSlots(renderChildren, parentVnode.context); |
| 2212 |
vm.$forceUpdate(); |
| 2213 |
} |
| 2214 |
} |
| 2215 |
|
| 2216 |
function isInInactiveTree (vm) { |
| 2217 |
while (vm && (vm = vm.$parent)) { |
| 2218 |
if (vm._inactive) { return true } |
| 2219 |
} |
| 2220 |
return false |
| 2221 |
} |
| 2222 |
|
| 2223 |
function activateChildComponent (vm, direct) { |
| 2224 |
if (direct) { |
| 2225 |
vm._directInactive = false; |
| 2226 |
if (isInInactiveTree(vm)) { |
| 2227 |
return |
| 2228 |
} |
| 2229 |
} else if (vm._directInactive) { |
| 2230 |
return |
| 2231 |
} |
| 2232 |
if (vm._inactive || vm._inactive == null) { |
| 2233 |
vm._inactive = false; |
| 2234 |
for (var i = 0; i < vm.$children.length; i++) { |
| 2235 |
activateChildComponent(vm.$children[i]); |
| 2236 |
} |
| 2237 |
callHook(vm, 'activated'); |
| 2238 |
} |
| 2239 |
} |
| 2240 |
|
| 2241 |
function deactivateChildComponent (vm, direct) { |
| 2242 |
if (direct) { |
| 2243 |
vm._directInactive = true; |
| 2244 |
if (isInInactiveTree(vm)) { |
| 2245 |
return |
| 2246 |
} |
| 2247 |
} |
| 2248 |
if (!vm._inactive) { |
| 2249 |
vm._inactive = true; |
| 2250 |
for (var i = 0; i < vm.$children.length; i++) { |
| 2251 |
deactivateChildComponent(vm.$children[i]); |
| 2252 |
} |
| 2253 |
callHook(vm, 'deactivated'); |
| 2254 |
} |
| 2255 |
} |
| 2256 |
|
| 2257 |
function callHook (vm, hook) { |
| 2258 |
var handlers = vm.$options[hook]; |
| 2259 |
if (handlers) { |
| 2260 |
for (var i = 0, j = handlers.length; i < j; i++) { |
| 2261 |
try { |
| 2262 |
handlers[i].call(vm); |
| 2263 |
} catch (e) { |
| 2264 |
handleError(e, vm, (hook + " hook")); |
| 2265 |
} |
| 2266 |
} |
| 2267 |
} |
| 2268 |
if (vm._hasHookEvent) { |
| 2269 |
vm.$emit('hook:' + hook); |
| 2270 |
} |
| 2271 |
} |
| 2272 |
|
| 2273 |
/* */ |
| 2274 |
|
| 2275 |
|
| 2276 |
var queue = []; |
| 2277 |
var has = {}; |
| 2278 |
var circular = {}; |
| 2279 |
var waiting = false; |
| 2280 |
var flushing = false; |
| 2281 |
var index = 0; |
| 2282 |
|
| 2283 |
/** |
| 2284 |
* Reset the scheduler's state. |
| 2285 |
*/ |
| 2286 |
function resetSchedulerState () { |
| 2287 |
queue.length = 0; |
| 2288 |
has = {}; |
| 2289 |
{ |
| 2290 |
circular = {}; |
| 2291 |
} |
| 2292 |
waiting = flushing = false; |
| 2293 |
} |
| 2294 |
|
| 2295 |
/** |
| 2296 |
* Flush both queues and run the watchers. |
| 2297 |
*/ |
| 2298 |
function flushSchedulerQueue () { |
| 2299 |
flushing = true; |
| 2300 |
var watcher, id, vm; |
| 2301 |
|
| 2302 |
// Sort queue before flush. |
| 2303 |
// This ensures that: |
| 2304 |
// 1. Components are updated from parent to child. (because parent is always |
| 2305 |
// created before the child) |
| 2306 |
// 2. A component's user watchers are run before its render watcher (because |
| 2307 |
// user watchers are created before the render watcher) |
| 2308 |
// 3. If a component is destroyed during a parent component's watcher run, |
| 2309 |
// its watchers can be skipped. |
| 2310 |
queue.sort(function (a, b) { return a.id - b.id; }); |
| 2311 |
|
| 2312 |
// do not cache length because more watchers might be pushed |
| 2313 |
// as we run existing watchers |
| 2314 |
for (index = 0; index < queue.length; index++) { |
| 2315 |
watcher = queue[index]; |
| 2316 |
id = watcher.id; |
| 2317 |
has[id] = null; |
| 2318 |
watcher.run(); |
| 2319 |
// in dev build, check and stop circular updates. |
| 2320 |
if ("development" !== 'production' && has[id] != null) { |
| 2321 |
circular[id] = (circular[id] || 0) + 1; |
| 2322 |
if (circular[id] > config._maxUpdateCount) { |
| 2323 |
warn( |
| 2324 |
'You may have an infinite update loop ' + ( |
| 2325 |
watcher.user |
| 2326 |
? ("in watcher with expression \"" + (watcher.expression) + "\"") |
| 2327 |
: "in a component render function." |
| 2328 |
), |
| 2329 |
watcher.vm |
| 2330 |
); |
| 2331 |
break |
| 2332 |
} |
| 2333 |
} |
| 2334 |
} |
| 2335 |
|
| 2336 |
// call updated hooks |
| 2337 |
index = queue.length; |
| 2338 |
while (index--) { |
| 2339 |
watcher = queue[index]; |
| 2340 |
vm = watcher.vm; |
| 2341 |
if (vm._watcher === watcher && vm._isMounted) { |
| 2342 |
callHook(vm, 'updated'); |
| 2343 |
} |
| 2344 |
} |
| 2345 |
|
| 2346 |
// devtool hook |
| 2347 |
/* istanbul ignore if */ |
| 2348 |
if (devtools && config.devtools) { |
| 2349 |
devtools.emit('flush'); |
| 2350 |
} |
| 2351 |
|
| 2352 |
resetSchedulerState(); |
| 2353 |
} |
| 2354 |
|
| 2355 |
/** |
| 2356 |
* Push a watcher into the watcher queue. |
| 2357 |
* Jobs with duplicate IDs will be skipped unless it's |
| 2358 |
* pushed when the queue is being flushed. |
| 2359 |
*/ |
| 2360 |
function queueWatcher (watcher) { |
| 2361 |
var id = watcher.id; |
| 2362 |
if (has[id] == null) { |
| 2363 |
has[id] = true; |
| 2364 |
if (!flushing) { |
| 2365 |
queue.push(watcher); |
| 2366 |
} else { |
| 2367 |
// if already flushing, splice the watcher based on its id |
| 2368 |
// if already past its id, it will be run next immediately. |
| 2369 |
var i = queue.length - 1; |
| 2370 |
while (i >= 0 && queue[i].id > watcher.id) { |
| 2371 |
i--; |
| 2372 |
} |
| 2373 |
queue.splice(Math.max(i, index) + 1, 0, watcher); |
| 2374 |
} |
| 2375 |
// queue the flush |
| 2376 |
if (!waiting) { |
| 2377 |
waiting = true; |
| 2378 |
nextTick(flushSchedulerQueue); |
| 2379 |
} |
| 2380 |
} |
| 2381 |
} |
| 2382 |
|
| 2383 |
/* */ |
| 2384 |
|
| 2385 |
var uid$2 = 0; |
| 2386 |
|
| 2387 |
/** |
| 2388 |
* A watcher parses an expression, collects dependencies, |
| 2389 |
* and fires callback when the expression value changes. |
| 2390 |
* This is used for both the $watch() api and directives. |
| 2391 |
*/ |
| 2392 |
var Watcher = function Watcher ( |
| 2393 |
vm, |
| 2394 |
expOrFn, |
| 2395 |
cb, |
| 2396 |
options |
| 2397 |
) { |
| 2398 |
this.vm = vm; |
| 2399 |
vm._watchers.push(this); |
| 2400 |
// options |
| 2401 |
if (options) { |
| 2402 |
this.deep = !!options.deep; |
| 2403 |
this.user = !!options.user; |
| 2404 |
this.lazy = !!options.lazy; |
| 2405 |
this.sync = !!options.sync; |
| 2406 |
} else { |
| 2407 |
this.deep = this.user = this.lazy = this.sync = false; |
| 2408 |
} |
| 2409 |
this.cb = cb; |
| 2410 |
this.id = ++uid$2; // uid for batching |
| 2411 |
this.active = true; |
| 2412 |
this.dirty = this.lazy; // for lazy watchers |
| 2413 |
this.deps = []; |
| 2414 |
this.newDeps = []; |
| 2415 |
this.depIds = new _Set(); |
| 2416 |
this.newDepIds = new _Set(); |
| 2417 |
this.expression = expOrFn.toString(); |
| 2418 |
// parse expression for getter |
| 2419 |
if (typeof expOrFn === 'function') { |
| 2420 |
this.getter = expOrFn; |
| 2421 |
} else { |
| 2422 |
this.getter = parsePath(expOrFn); |
| 2423 |
if (!this.getter) { |
| 2424 |
this.getter = function () {}; |
| 2425 |
"development" !== 'production' && warn( |
| 2426 |
"Failed watching path: \"" + expOrFn + "\" " + |
| 2427 |
'Watcher only accepts simple dot-delimited paths. ' + |
| 2428 |
'For full control, use a function instead.', |
| 2429 |
vm |
| 2430 |
); |
| 2431 |
} |
| 2432 |
} |
| 2433 |
this.value = this.lazy |
| 2434 |
? undefined |
| 2435 |
: this.get(); |
| 2436 |
}; |
| 2437 |
|
| 2438 |
/** |
| 2439 |
* Evaluate the getter, and re-collect dependencies. |
| 2440 |
*/ |
| 2441 |
Watcher.prototype.get = function get () { |
| 2442 |
pushTarget(this); |
| 2443 |
var value; |
| 2444 |
var vm = this.vm; |
| 2445 |
if (this.user) { |
| 2446 |
try { |
| 2447 |
value = this.getter.call(vm, vm); |
| 2448 |
} catch (e) { |
| 2449 |
handleError(e, vm, ("getter for watcher \"" + (this.expression) + "\"")); |
| 2450 |
} |
| 2451 |
} else { |
| 2452 |
value = this.getter.call(vm, vm); |
| 2453 |
} |
| 2454 |
// "touch" every property so they are all tracked as |
| 2455 |
// dependencies for deep watching |
| 2456 |
if (this.deep) { |
| 2457 |
traverse(value); |
| 2458 |
} |
| 2459 |
popTarget(); |
| 2460 |
this.cleanupDeps(); |
| 2461 |
return value |
| 2462 |
}; |
| 2463 |
|
| 2464 |
/** |
| 2465 |
* Add a dependency to this directive. |
| 2466 |
*/ |
| 2467 |
Watcher.prototype.addDep = function addDep (dep) { |
| 2468 |
var id = dep.id; |
| 2469 |
if (!this.newDepIds.has(id)) { |
| 2470 |
this.newDepIds.add(id); |
| 2471 |
this.newDeps.push(dep); |
| 2472 |
if (!this.depIds.has(id)) { |
| 2473 |
dep.addSub(this); |
| 2474 |
} |
| 2475 |
} |
| 2476 |
}; |
| 2477 |
|
| 2478 |
/** |
| 2479 |
* Clean up for dependency collection. |
| 2480 |
*/ |
| 2481 |
Watcher.prototype.cleanupDeps = function cleanupDeps () { |
| 2482 |
var this$1 = this; |
| 2483 |
|
| 2484 |
var i = this.deps.length; |
| 2485 |
while (i--) { |
| 2486 |
var dep = this$1.deps[i]; |
| 2487 |
if (!this$1.newDepIds.has(dep.id)) { |
| 2488 |
dep.removeSub(this$1); |
| 2489 |
} |
| 2490 |
} |
| 2491 |
var tmp = this.depIds; |
| 2492 |
this.depIds = this.newDepIds; |
| 2493 |
this.newDepIds = tmp; |
| 2494 |
this.newDepIds.clear(); |
| 2495 |
tmp = this.deps; |
| 2496 |
this.deps = this.newDeps; |
| 2497 |
this.newDeps = tmp; |
| 2498 |
this.newDeps.length = 0; |
| 2499 |
}; |
| 2500 |
|
| 2501 |
/** |
| 2502 |
* Subscriber interface. |
| 2503 |
* Will be called when a dependency changes. |
| 2504 |
*/ |
| 2505 |
Watcher.prototype.update = function update () { |
| 2506 |
/* istanbul ignore else */ |
| 2507 |
if (this.lazy) { |
| 2508 |
this.dirty = true; |
| 2509 |
} else if (this.sync) { |
| 2510 |
this.run(); |
| 2511 |
} else { |
| 2512 |
queueWatcher(this); |
| 2513 |
} |
| 2514 |
}; |
| 2515 |
|
| 2516 |
/** |
| 2517 |
* Scheduler job interface. |
| 2518 |
* Will be called by the scheduler. |
| 2519 |
*/ |
| 2520 |
Watcher.prototype.run = function run () { |
| 2521 |
if (this.active) { |
| 2522 |
var value = this.get(); |
| 2523 |
if ( |
| 2524 |
value !== this.value || |
| 2525 |
// Deep watchers and watchers on Object/Arrays should fire even |
| 2526 |
// when the value is the same, because the value may |
| 2527 |
// have mutated. |
| 2528 |
isObject(value) || |
| 2529 |
this.deep |
| 2530 |
) { |
| 2531 |
// set new value |
| 2532 |
var oldValue = this.value; |
| 2533 |
this.value = value; |
| 2534 |
if (this.user) { |
| 2535 |
try { |
| 2536 |
this.cb.call(this.vm, value, oldValue); |
| 2537 |
} catch (e) { |
| 2538 |
handleError(e, this.vm, ("callback for watcher \"" + (this.expression) + "\"")); |
| 2539 |
} |
| 2540 |
} else { |
| 2541 |
this.cb.call(this.vm, value, oldValue); |
| 2542 |
} |
| 2543 |
} |
| 2544 |
} |
| 2545 |
}; |
| 2546 |
|
| 2547 |
/** |
| 2548 |
* Evaluate the value of the watcher. |
| 2549 |
* This only gets called for lazy watchers. |
| 2550 |
*/ |
| 2551 |
Watcher.prototype.evaluate = function evaluate () { |
| 2552 |
this.value = this.get(); |
| 2553 |
this.dirty = false; |
| 2554 |
}; |
| 2555 |
|
| 2556 |
/** |
| 2557 |
* Depend on all deps collected by this watcher. |
| 2558 |
*/ |
| 2559 |
Watcher.prototype.depend = function depend () { |
| 2560 |
var this$1 = this; |
| 2561 |
|
| 2562 |
var i = this.deps.length; |
| 2563 |
while (i--) { |
| 2564 |
this$1.deps[i].depend(); |
| 2565 |
} |
| 2566 |
}; |
| 2567 |
|
| 2568 |
/** |
| 2569 |
* Remove self from all dependencies' subscriber list. |
| 2570 |
*/ |
| 2571 |
Watcher.prototype.teardown = function teardown () { |
| 2572 |
var this$1 = this; |
| 2573 |
|
| 2574 |
if (this.active) { |
| 2575 |
// remove self from vm's watcher list |
| 2576 |
// this is a somewhat expensive operation so we skip it |
| 2577 |
// if the vm is being destroyed. |
| 2578 |
if (!this.vm._isBeingDestroyed) { |
| 2579 |
remove(this.vm._watchers, this); |
| 2580 |
} |
| 2581 |
var i = this.deps.length; |
| 2582 |
while (i--) { |
| 2583 |
this$1.deps[i].removeSub(this$1); |
| 2584 |
} |
| 2585 |
this.active = false; |
| 2586 |
} |
| 2587 |
}; |
| 2588 |
|
| 2589 |
/** |
| 2590 |
* Recursively traverse an object to evoke all converted |
| 2591 |
* getters, so that every nested property inside the object |
| 2592 |
* is collected as a "deep" dependency. |
| 2593 |
*/ |
| 2594 |
var seenObjects = new _Set(); |
| 2595 |
function traverse (val) { |
| 2596 |
seenObjects.clear(); |
| 2597 |
_traverse(val, seenObjects); |
| 2598 |
} |
| 2599 |
|
| 2600 |
function _traverse (val, seen) { |
| 2601 |
var i, keys; |
| 2602 |
var isA = Array.isArray(val); |
| 2603 |
if ((!isA && !isObject(val)) || !Object.isExtensible(val)) { |
| 2604 |
return |
| 2605 |
} |
| 2606 |
if (val.__ob__) { |
| 2607 |
var depId = val.__ob__.dep.id; |
| 2608 |
if (seen.has(depId)) { |
| 2609 |
return |
| 2610 |
} |
| 2611 |
seen.add(depId); |
| 2612 |
} |
| 2613 |
if (isA) { |
| 2614 |
i = val.length; |
| 2615 |
while (i--) { _traverse(val[i], seen); } |
| 2616 |
} else { |
| 2617 |
keys = Object.keys(val); |
| 2618 |
i = keys.length; |
| 2619 |
while (i--) { _traverse(val[keys[i]], seen); } |
| 2620 |
} |
| 2621 |
} |
| 2622 |
|
| 2623 |
/* */ |
| 2624 |
|
| 2625 |
var sharedPropertyDefinition = { |
| 2626 |
enumerable: true, |
| 2627 |
configurable: true, |
| 2628 |
get: noop, |
| 2629 |
set: noop |
| 2630 |
}; |
| 2631 |
|
| 2632 |
function proxy (target, sourceKey, key) { |
| 2633 |
sharedPropertyDefinition.get = function proxyGetter () { |
| 2634 |
return this[sourceKey][key] |
| 2635 |
}; |
| 2636 |
sharedPropertyDefinition.set = function proxySetter (val) { |
| 2637 |
this[sourceKey][key] = val; |
| 2638 |
}; |
| 2639 |
Object.defineProperty(target, key, sharedPropertyDefinition); |
| 2640 |
} |
| 2641 |
|
| 2642 |
function initState (vm) { |
| 2643 |
vm._watchers = []; |
| 2644 |
var opts = vm.$options; |
| 2645 |
if (opts.props) { initProps(vm, opts.props); } |
| 2646 |
if (opts.methods) { initMethods(vm, opts.methods); } |
| 2647 |
if (opts.data) { |
| 2648 |
initData(vm); |
| 2649 |
} else { |
| 2650 |
observe(vm._data = {}, true /* asRootData */); |
| 2651 |
} |
| 2652 |
if (opts.computed) { initComputed(vm, opts.computed); } |
| 2653 |
if (opts.watch) { initWatch(vm, opts.watch); } |
| 2654 |
} |
| 2655 |
|
| 2656 |
var isReservedProp = { key: 1, ref: 1, slot: 1 }; |
| 2657 |
|
| 2658 |
function initProps (vm, propsOptions) { |
| 2659 |
var propsData = vm.$options.propsData || {}; |
| 2660 |
var props = vm._props = {}; |
| 2661 |
// cache prop keys so that future props updates can iterate using Array |
| 2662 |
// instead of dynamic object key enumeration. |
| 2663 |
var keys = vm.$options._propKeys = []; |
| 2664 |
var isRoot = !vm.$parent; |
| 2665 |
// root instance props should be converted |
| 2666 |
observerState.shouldConvert = isRoot; |
| 2667 |
var loop = function ( key ) { |
| 2668 |
keys.push(key); |
| 2669 |
var value = validateProp(key, propsOptions, propsData, vm); |
| 2670 |
/* istanbul ignore else */ |
| 2671 |
{ |
| 2672 |
if (isReservedProp[key]) { |
| 2673 |
warn( |
| 2674 |
("\"" + key + "\" is a reserved attribute and cannot be used as component prop."), |
| 2675 |
vm |
| 2676 |
); |
| 2677 |
} |
| 2678 |
defineReactive$$1(props, key, value, function () { |
| 2679 |
if (vm.$parent && !observerState.isSettingProps) { |
| 2680 |
warn( |
| 2681 |
"Avoid mutating a prop directly since the value will be " + |
| 2682 |
"overwritten whenever the parent component re-renders. " + |
| 2683 |
"Instead, use a data or computed property based on the prop's " + |
| 2684 |
"value. Prop being mutated: \"" + key + "\"", |
| 2685 |
vm |
| 2686 |
); |
| 2687 |
} |
| 2688 |
}); |
| 2689 |
} |
| 2690 |
// static props are already proxied on the component's prototype |
| 2691 |
// during Vue.extend(). We only need to proxy props defined at |
| 2692 |
// instantiation here. |
| 2693 |
if (!(key in vm)) { |
| 2694 |
proxy(vm, "_props", key); |
| 2695 |
} |
| 2696 |
}; |
| 2697 |
|
| 2698 |
for (var key in propsOptions) loop( key ); |
| 2699 |
observerState.shouldConvert = true; |
| 2700 |
} |
| 2701 |
|
| 2702 |
function initData (vm) { |
| 2703 |
var data = vm.$options.data; |
| 2704 |
data = vm._data = typeof data === 'function' |
| 2705 |
? data.call(vm) |
| 2706 |
: data || {}; |
| 2707 |
if (!isPlainObject(data)) { |
| 2708 |
data = {}; |
| 2709 |
"development" !== 'production' && warn( |
| 2710 |
'data functions should return an object:\n' + |
| 2711 |
'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', |
| 2712 |
vm |
| 2713 |
); |
| 2714 |
} |
| 2715 |
// proxy data on instance |
| 2716 |
var keys = Object.keys(data); |
| 2717 |
var props = vm.$options.props; |
| 2718 |
var i = keys.length; |
| 2719 |
while (i--) { |
| 2720 |
if (props && hasOwn(props, keys[i])) { |
| 2721 |
"development" !== 'production' && warn( |
| 2722 |
"The data property \"" + (keys[i]) + "\" is already declared as a prop. " + |
| 2723 |
"Use prop default value instead.", |
| 2724 |
vm |
| 2725 |
); |
| 2726 |
} else if (!isReserved(keys[i])) { |
| 2727 |
proxy(vm, "_data", keys[i]); |
| 2728 |
} |
| 2729 |
} |
| 2730 |
// observe data |
| 2731 |
observe(data, true /* asRootData */); |
| 2732 |
} |
| 2733 |
|
| 2734 |
var computedWatcherOptions = { lazy: true }; |
| 2735 |
|
| 2736 |
function initComputed (vm, computed) { |
| 2737 |
var watchers = vm._computedWatchers = Object.create(null); |
| 2738 |
|
| 2739 |
for (var key in computed) { |
| 2740 |
var userDef = computed[key]; |
| 2741 |
var getter = typeof userDef === 'function' ? userDef : userDef.get; |
| 2742 |
// create internal watcher for the computed property. |
| 2743 |
watchers[key] = new Watcher(vm, getter, noop, computedWatcherOptions); |
| 2744 |
|
| 2745 |
// component-defined computed properties are already defined on the |
| 2746 |
// component prototype. We only need to define computed properties defined |
| 2747 |
// at instantiation here. |
| 2748 |
if (!(key in vm)) { |
| 2749 |
defineComputed(vm, key, userDef); |
| 2750 |
} |
| 2751 |
} |
| 2752 |
} |
| 2753 |
|
| 2754 |
function defineComputed (target, key, userDef) { |
| 2755 |
if (typeof userDef === 'function') { |
| 2756 |
sharedPropertyDefinition.get = createComputedGetter(key); |
| 2757 |
sharedPropertyDefinition.set = noop; |
| 2758 |
} else { |
| 2759 |
sharedPropertyDefinition.get = userDef.get |
| 2760 |
? userDef.cache !== false |
| 2761 |
? createComputedGetter(key) |
| 2762 |
: userDef.get |
| 2763 |
: noop; |
| 2764 |
sharedPropertyDefinition.set = userDef.set |
| 2765 |
? userDef.set |
| 2766 |
: noop; |
| 2767 |
} |
| 2768 |
Object.defineProperty(target, key, sharedPropertyDefinition); |
| 2769 |
} |
| 2770 |
|
| 2771 |
function createComputedGetter (key) { |
| 2772 |
return function computedGetter () { |
| 2773 |
var watcher = this._computedWatchers && this._computedWatchers[key]; |
| 2774 |
if (watcher) { |
| 2775 |
if (watcher.dirty) { |
| 2776 |
watcher.evaluate(); |
| 2777 |
} |
| 2778 |
if (Dep.target) { |
| 2779 |
watcher.depend(); |
| 2780 |
} |
| 2781 |
return watcher.value |
| 2782 |
} |
| 2783 |
} |
| 2784 |
} |
| 2785 |
|
| 2786 |
function initMethods (vm, methods) { |
| 2787 |
var props = vm.$options.props; |
| 2788 |
for (var key in methods) { |
| 2789 |
vm[key] = methods[key] == null ? noop : bind(methods[key], vm); |
| 2790 |
{ |
| 2791 |
if (methods[key] == null) { |
| 2792 |
warn( |
| 2793 |
"method \"" + key + "\" has an undefined value in the component definition. " + |
| 2794 |
"Did you reference the function correctly?", |
| 2795 |
vm |
| 2796 |
); |
| 2797 |
} |
| 2798 |
if (props && hasOwn(props, key)) { |
| 2799 |
warn( |
| 2800 |
("method \"" + key + "\" has already been defined as a prop."), |
| 2801 |
vm |
| 2802 |
); |
| 2803 |
} |
| 2804 |
} |
| 2805 |
} |
| 2806 |
} |
| 2807 |
|
| 2808 |
function initWatch (vm, watch) { |
| 2809 |
for (var key in watch) { |
| 2810 |
var handler = watch[key]; |
| 2811 |
if (Array.isArray(handler)) { |
| 2812 |
for (var i = 0; i < handler.length; i++) { |
| 2813 |
createWatcher(vm, key, handler[i]); |
| 2814 |
} |
| 2815 |
} else { |
| 2816 |
createWatcher(vm, key, handler); |
| 2817 |
} |
| 2818 |
} |
| 2819 |
} |
| 2820 |
|
| 2821 |
function createWatcher (vm, key, handler) { |
| 2822 |
var options; |
| 2823 |
if (isPlainObject(handler)) { |
| 2824 |
options = handler; |
| 2825 |
handler = handler.handler; |
| 2826 |
} |
| 2827 |
if (typeof handler === 'string') { |
| 2828 |
handler = vm[handler]; |
| 2829 |
} |
| 2830 |
vm.$watch(key, handler, options); |
| 2831 |
} |
| 2832 |
|
| 2833 |
function stateMixin (Vue) { |
| 2834 |
// flow somehow has problems with directly declared definition object |
| 2835 |
// when using Object.defineProperty, so we have to procedurally build up |
| 2836 |
// the object here. |
| 2837 |
var dataDef = {}; |
| 2838 |
dataDef.get = function () { return this._data }; |
| 2839 |
var propsDef = {}; |
| 2840 |
propsDef.get = function () { return this._props }; |
| 2841 |
{ |
| 2842 |
dataDef.set = function (newData) { |
| 2843 |
warn( |
| 2844 |
'Avoid replacing instance root $data. ' + |
| 2845 |
'Use nested data properties instead.', |
| 2846 |
this |
| 2847 |
); |
| 2848 |
}; |
| 2849 |
propsDef.set = function () { |
| 2850 |
warn("$props is readonly.", this); |
| 2851 |
}; |
| 2852 |
} |
| 2853 |
Object.defineProperty(Vue.prototype, '$data', dataDef); |
| 2854 |
Object.defineProperty(Vue.prototype, '$props', propsDef); |
| 2855 |
|
| 2856 |
Vue.prototype.$set = set; |
| 2857 |
Vue.prototype.$delete = del; |
| 2858 |
|
| 2859 |
Vue.prototype.$watch = function ( |
| 2860 |
expOrFn, |
| 2861 |
cb, |
| 2862 |
options |
| 2863 |
) { |
| 2864 |
var vm = this; |
| 2865 |
options = options || {}; |
| 2866 |
options.user = true; |
| 2867 |
var watcher = new Watcher(vm, expOrFn, cb, options); |
| 2868 |
if (options.immediate) { |
| 2869 |
cb.call(vm, watcher.value); |
| 2870 |
} |
| 2871 |
return function unwatchFn () { |
| 2872 |
watcher.teardown(); |
| 2873 |
} |
| 2874 |
}; |
| 2875 |
} |
| 2876 |
|
| 2877 |
/* */ |
| 2878 |
|
| 2879 |
// hooks to be invoked on component VNodes during patch |
| 2880 |
var componentVNodeHooks = { |
| 2881 |
init: function init ( |
| 2882 |
vnode, |
| 2883 |
hydrating, |
| 2884 |
parentElm, |
| 2885 |
refElm |
| 2886 |
) { |
| 2887 |
if (!vnode.componentInstance || vnode.componentInstance._isDestroyed) { |
| 2888 |
var child = vnode.componentInstance = createComponentInstanceForVnode( |
| 2889 |
vnode, |
| 2890 |
activeInstance, |
| 2891 |
parentElm, |
| 2892 |
refElm |
| 2893 |
); |
| 2894 |
child.$mount(hydrating ? vnode.elm : undefined, hydrating); |
| 2895 |
} else if (vnode.data.keepAlive) { |
| 2896 |
// kept-alive components, treat as a patch |
| 2897 |
var mountedNode = vnode; // work around flow |
| 2898 |
componentVNodeHooks.prepatch(mountedNode, mountedNode); |
| 2899 |
} |
| 2900 |
}, |
| 2901 |
|
| 2902 |
prepatch: function prepatch (oldVnode, vnode) { |
| 2903 |
var options = vnode.componentOptions; |
| 2904 |
var child = vnode.componentInstance = oldVnode.componentInstance; |
| 2905 |
updateChildComponent( |
| 2906 |
child, |
| 2907 |
options.propsData, // updated props |
| 2908 |
options.listeners, // updated listeners |
| 2909 |
vnode, // new parent vnode |
| 2910 |
options.children // new children |
| 2911 |
); |
| 2912 |
}, |
| 2913 |
|
| 2914 |
insert: function insert (vnode) { |
| 2915 |
if (!vnode.componentInstance._isMounted) { |
| 2916 |
vnode.componentInstance._isMounted = true; |
| 2917 |
callHook(vnode.componentInstance, 'mounted'); |
| 2918 |
} |
| 2919 |
if (vnode.data.keepAlive) { |
| 2920 |
activateChildComponent(vnode.componentInstance, true /* direct */); |
| 2921 |
} |
| 2922 |
}, |
| 2923 |
|
| 2924 |
destroy: function destroy (vnode) { |
| 2925 |
if (!vnode.componentInstance._isDestroyed) { |
| 2926 |
if (!vnode.data.keepAlive) { |
| 2927 |
vnode.componentInstance.$destroy(); |
| 2928 |
} else { |
| 2929 |
deactivateChildComponent(vnode.componentInstance, true /* direct */); |
| 2930 |
} |
| 2931 |
} |
| 2932 |
} |
| 2933 |
}; |
| 2934 |
|
| 2935 |
var hooksToMerge = Object.keys(componentVNodeHooks); |
| 2936 |
|
| 2937 |
function createComponent ( |
| 2938 |
Ctor, |
| 2939 |
data, |
| 2940 |
context, |
| 2941 |
children, |
| 2942 |
tag |
| 2943 |
) { |
| 2944 |
if (!Ctor) { |
| 2945 |
return |
| 2946 |
} |
| 2947 |
|
| 2948 |
var baseCtor = context.$options._base; |
| 2949 |
if (isObject(Ctor)) { |
| 2950 |
Ctor = baseCtor.extend(Ctor); |
| 2951 |
} |
| 2952 |
|
| 2953 |
if (typeof Ctor !== 'function') { |
| 2954 |
{ |
| 2955 |
warn(("Invalid Component definition: " + (String(Ctor))), context); |
| 2956 |
} |
| 2957 |
return |
| 2958 |
} |
| 2959 |
|
| 2960 |
// async component |
| 2961 |
if (!Ctor.cid) { |
| 2962 |
if (Ctor.resolved) { |
| 2963 |
Ctor = Ctor.resolved; |
| 2964 |
} else { |
| 2965 |
Ctor = resolveAsyncComponent(Ctor, baseCtor, function () { |
| 2966 |
// it's ok to queue this on every render because |
| 2967 |
// $forceUpdate is buffered by the scheduler. |
| 2968 |
context.$forceUpdate(); |
| 2969 |
}); |
| 2970 |
if (!Ctor) { |
| 2971 |
// return nothing if this is indeed an async component |
| 2972 |
// wait for the callback to trigger parent update. |
| 2973 |
return |
| 2974 |
} |
| 2975 |
} |
| 2976 |
} |
| 2977 |
|
| 2978 |
// resolve constructor options in case global mixins are applied after |
| 2979 |
// component constructor creation |
| 2980 |
resolveConstructorOptions(Ctor); |
| 2981 |
|
| 2982 |
data = data || {}; |
| 2983 |
|
| 2984 |
// transform component v-model data into props & events |
| 2985 |
if (data.model) { |
| 2986 |
transformModel(Ctor.options, data); |
| 2987 |
} |
| 2988 |
|
| 2989 |
// extract props |
| 2990 |
var propsData = extractProps(data, Ctor); |
| 2991 |
|
| 2992 |
// functional component |
| 2993 |
if (Ctor.options.functional) { |
| 2994 |
return createFunctionalComponent(Ctor, propsData, data, context, children) |
| 2995 |
} |
| 2996 |
|
| 2997 |
// extract listeners, since these needs to be treated as |
| 2998 |
// child component listeners instead of DOM listeners |
| 2999 |
var listeners = data.on; |
| 3000 |
// replace with listeners with .native modifier |
| 3001 |
data.on = data.nativeOn; |
| 3002 |
|
| 3003 |
if (Ctor.options.abstract) { |
| 3004 |
// abstract components do not keep anything |
| 3005 |
// other than props & listeners |
| 3006 |
data = {}; |
| 3007 |
} |
| 3008 |
|
| 3009 |
// merge component management hooks onto the placeholder node |
| 3010 |
mergeHooks(data); |
| 3011 |
|
| 3012 |
// return a placeholder vnode |
| 3013 |
var name = Ctor.options.name || tag; |
| 3014 |
var vnode = new VNode( |
| 3015 |
("vue-component-" + (Ctor.cid) + (name ? ("-" + name) : '')), |
| 3016 |
data, undefined, undefined, undefined, context, |
| 3017 |
{ Ctor: Ctor, propsData: propsData, listeners: listeners, tag: tag, children: children } |
| 3018 |
); |
| 3019 |
return vnode |
| 3020 |
} |
| 3021 |
|
| 3022 |
function createFunctionalComponent ( |
| 3023 |
Ctor, |
| 3024 |
propsData, |
| 3025 |
data, |
| 3026 |
context, |
| 3027 |
children |
| 3028 |
) { |
| 3029 |
var props = {}; |
| 3030 |
var propOptions = Ctor.options.props; |
| 3031 |
if (propOptions) { |
| 3032 |
for (var key in propOptions) { |
| 3033 |
props[key] = validateProp(key, propOptions, propsData); |
| 3034 |
} |
| 3035 |
} |
| 3036 |
// ensure the createElement function in functional components |
| 3037 |
// gets a unique context - this is necessary for correct named slot check |
| 3038 |
var _context = Object.create(context); |
| 3039 |
var h = function (a, b, c, d) { return createElement(_context, a, b, c, d, true); }; |
| 3040 |
var vnode = Ctor.options.render.call(null, h, { |
| 3041 |
props: props, |
| 3042 |
data: data, |
| 3043 |
parent: context, |
| 3044 |
children: children, |
| 3045 |
slots: function () { return resolveSlots(children, context); } |
| 3046 |
}); |
| 3047 |
if (vnode instanceof VNode) { |
| 3048 |
vnode.functionalContext = context; |
| 3049 |
if (data.slot) { |
| 3050 |
(vnode.data || (vnode.data = {})).slot = data.slot; |
| 3051 |
} |
| 3052 |
} |
| 3053 |
return vnode |
| 3054 |
} |
| 3055 |
|
| 3056 |
function createComponentInstanceForVnode ( |
| 3057 |
vnode, // we know it's MountedComponentVNode but flow doesn't |
| 3058 |
parent, // activeInstance in lifecycle state |
| 3059 |
parentElm, |
| 3060 |
refElm |
| 3061 |
) { |
| 3062 |
var vnodeComponentOptions = vnode.componentOptions; |
| 3063 |
var options = { |
| 3064 |
_isComponent: true, |
| 3065 |
parent: parent, |
| 3066 |
propsData: vnodeComponentOptions.propsData, |
| 3067 |
_componentTag: vnodeComponentOptions.tag, |
| 3068 |
_parentVnode: vnode, |
| 3069 |
_parentListeners: vnodeComponentOptions.listeners, |
| 3070 |
_renderChildren: vnodeComponentOptions.children, |
| 3071 |
_parentElm: parentElm || null, |
| 3072 |
_refElm: refElm || null |
| 3073 |
}; |
| 3074 |
// check inline-template render functions |
| 3075 |
var inlineTemplate = vnode.data.inlineTemplate; |
| 3076 |
if (inlineTemplate) { |
| 3077 |
options.render = inlineTemplate.render; |
| 3078 |
options.staticRenderFns = inlineTemplate.staticRenderFns; |
| 3079 |
} |
| 3080 |
return new vnodeComponentOptions.Ctor(options) |
| 3081 |
} |
| 3082 |
|
| 3083 |
function resolveAsyncComponent ( |
| 3084 |
factory, |
| 3085 |
baseCtor, |
| 3086 |
cb |
| 3087 |
) { |
| 3088 |
if (factory.requested) { |
| 3089 |
// pool callbacks |
| 3090 |
factory.pendingCallbacks.push(cb); |
| 3091 |
} else { |
| 3092 |
factory.requested = true; |
| 3093 |
var cbs = factory.pendingCallbacks = [cb]; |
| 3094 |
var sync = true; |
| 3095 |
|
| 3096 |
var resolve = function (res) { |
| 3097 |
if (isObject(res)) { |
| 3098 |
res = baseCtor.extend(res); |
| 3099 |
} |
| 3100 |
// cache resolved |
| 3101 |
factory.resolved = res; |
| 3102 |
// invoke callbacks only if this is not a synchronous resolve |
| 3103 |
// (async resolves are shimmed as synchronous during SSR) |
| 3104 |
if (!sync) { |
| 3105 |
for (var i = 0, l = cbs.length; i < l; i++) { |
| 3106 |
cbs[i](res); |
| 3107 |
} |
| 3108 |
} |
| 3109 |
}; |
| 3110 |
|
| 3111 |
var reject = function (reason) { |
| 3112 |
"development" !== 'production' && warn( |
| 3113 |
"Failed to resolve async component: " + (String(factory)) + |
| 3114 |
(reason ? ("\nReason: " + reason) : '') |
| 3115 |
); |
| 3116 |
}; |
| 3117 |
|
| 3118 |
var res = factory(resolve, reject); |
| 3119 |
|
| 3120 |
// handle promise |
| 3121 |
if (res && typeof res.then === 'function' && !factory.resolved) { |
| 3122 |
res.then(resolve, reject); |
| 3123 |
} |
| 3124 |
|
| 3125 |
sync = false; |
| 3126 |
// return in case resolved synchronously |
| 3127 |
return factory.resolved |
| 3128 |
} |
| 3129 |
} |
| 3130 |
|
| 3131 |
function extractProps (data, Ctor) { |
| 3132 |
// we are only extracting raw values here. |
| 3133 |
// validation and default values are handled in the child |
| 3134 |
// component itself. |
| 3135 |
var propOptions = Ctor.options.props; |
| 3136 |
if (!propOptions) { |
| 3137 |
return |
| 3138 |
} |
| 3139 |
var res = {}; |
| 3140 |
var attrs = data.attrs; |
| 3141 |
var props = data.props; |
| 3142 |
var domProps = data.domProps; |
| 3143 |
if (attrs || props || domProps) { |
| 3144 |
for (var key in propOptions) { |
| 3145 |
var altKey = hyphenate(key); |
| 3146 |
{ |
| 3147 |
var keyInLowerCase = key.toLowerCase(); |
| 3148 |
if ( |
| 3149 |
key !== keyInLowerCase && |
| 3150 |
attrs && attrs.hasOwnProperty(keyInLowerCase) |
| 3151 |
) { |
| 3152 |
warn( |
| 3153 |
"Prop \"" + keyInLowerCase + "\" is not declared in component " + |
| 3154 |
(formatComponentName(Ctor)) + ". Note that HTML attributes are " + |
| 3155 |
"case-insensitive and camelCased props need to use their kebab-case " + |
| 3156 |
"equivalents when using in-DOM templates. You should probably use " + |
| 3157 |
"\"" + altKey + "\" instead of \"" + key + "\"." |
| 3158 |
); |
| 3159 |
} |
| 3160 |
} |
| 3161 |
checkProp(res, props, key, altKey, true) || |
| 3162 |
checkProp(res, attrs, key, altKey) || |
| 3163 |
checkProp(res, domProps, key, altKey); |
| 3164 |
} |
| 3165 |
} |
| 3166 |
return res |
| 3167 |
} |
| 3168 |
|
| 3169 |
function checkProp ( |
| 3170 |
res, |
| 3171 |
hash, |
| 3172 |
key, |
| 3173 |
altKey, |
| 3174 |
preserve |
| 3175 |
) { |
| 3176 |
if (hash) { |
| 3177 |
if (hasOwn(hash, key)) { |
| 3178 |
res[key] = hash[key]; |
| 3179 |
if (!preserve) { |
| 3180 |
delete hash[key]; |
| 3181 |
} |
| 3182 |
return true |
| 3183 |
} else if (hasOwn(hash, altKey)) { |
| 3184 |
res[key] = hash[altKey]; |
| 3185 |
if (!preserve) { |
| 3186 |
delete hash[altKey]; |
| 3187 |
} |
| 3188 |
return true |
| 3189 |
} |
| 3190 |
} |
| 3191 |
return false |
| 3192 |
} |
| 3193 |
|
| 3194 |
function mergeHooks (data) { |
| 3195 |
if (!data.hook) { |
| 3196 |
data.hook = {}; |
| 3197 |
} |
| 3198 |
for (var i = 0; i < hooksToMerge.length; i++) { |
| 3199 |
var key = hooksToMerge[i]; |
| 3200 |
var fromParent = data.hook[key]; |
| 3201 |
var ours = componentVNodeHooks[key]; |
| 3202 |
data.hook[key] = fromParent ? mergeHook$1(ours, fromParent) : ours; |
| 3203 |
} |
| 3204 |
} |
| 3205 |
|
| 3206 |
function mergeHook$1 (one, two) { |
| 3207 |
return function (a, b, c, d) { |
| 3208 |
one(a, b, c, d); |
| 3209 |
two(a, b, c, d); |
| 3210 |
} |
| 3211 |
} |
| 3212 |
|
| 3213 |
// transform component v-model info (value and callback) into |
| 3214 |
// prop and event handler respectively. |
| 3215 |
function transformModel (options, data) { |
| 3216 |
var prop = (options.model && options.model.prop) || 'value'; |
| 3217 |
var event = (options.model && options.model.event) || 'input';(data.props || (data.props = {}))[prop] = data.model.value; |
| 3218 |
var on = data.on || (data.on = {}); |
| 3219 |
if (on[event]) { |
| 3220 |
on[event] = [data.model.callback].concat(on[event]); |
| 3221 |
} else { |
| 3222 |
on[event] = data.model.callback; |
| 3223 |
} |
| 3224 |
} |
| 3225 |
|
| 3226 |
/* */ |
| 3227 |
|
| 3228 |
var SIMPLE_NORMALIZE = 1; |
| 3229 |
var ALWAYS_NORMALIZE = 2; |
| 3230 |
|
| 3231 |
// wrapper function for providing a more flexible interface |
| 3232 |
// without getting yelled at by flow |
| 3233 |
function createElement ( |
| 3234 |
context, |
| 3235 |
tag, |
| 3236 |
data, |
| 3237 |
children, |
| 3238 |
normalizationType, |
| 3239 |
alwaysNormalize |
| 3240 |
) { |
| 3241 |
if (Array.isArray(data) || isPrimitive(data)) { |
| 3242 |
normalizationType = children; |
| 3243 |
children = data; |
| 3244 |
data = undefined; |
| 3245 |
} |
| 3246 |
if (alwaysNormalize) { normalizationType = ALWAYS_NORMALIZE; } |
| 3247 |
return _createElement(context, tag, data, children, normalizationType) |
| 3248 |
} |
| 3249 |
|
| 3250 |
function _createElement ( |
| 3251 |
context, |
| 3252 |
tag, |
| 3253 |
data, |
| 3254 |
children, |
| 3255 |
normalizationType |
| 3256 |
) { |
| 3257 |
if (data && data.__ob__) { |
| 3258 |
"development" !== 'production' && warn( |
| 3259 |
"Avoid using observed data object as vnode data: " + (JSON.stringify(data)) + "\n" + |
| 3260 |
'Always create fresh vnode data objects in each render!', |
| 3261 |
context |
| 3262 |
); |
| 3263 |
return createEmptyVNode() |
| 3264 |
} |
| 3265 |
if (!tag) { |
| 3266 |
// in case of component :is set to falsy value |
| 3267 |
return createEmptyVNode() |
| 3268 |
} |
| 3269 |
// support single function children as default scoped slot |
| 3270 |
if (Array.isArray(children) && |
| 3271 |
typeof children[0] === 'function') { |
| 3272 |
data = data || {}; |
| 3273 |
data.scopedSlots = { default: children[0] }; |
| 3274 |
children.length = 0; |
| 3275 |
} |
| 3276 |
if (normalizationType === ALWAYS_NORMALIZE) { |
| 3277 |
children = normalizeChildren(children); |
| 3278 |
} else if (normalizationType === SIMPLE_NORMALIZE) { |
| 3279 |
children = simpleNormalizeChildren(children); |
| 3280 |
} |
| 3281 |
var vnode, ns; |
| 3282 |
if (typeof tag === 'string') { |
| 3283 |
var Ctor; |
| 3284 |
ns = config.getTagNamespace(tag); |
| 3285 |
if (config.isReservedTag(tag)) { |
| 3286 |
// platform built-in elements |
| 3287 |
vnode = new VNode( |
| 3288 |
config.parsePlatformTagName(tag), data, children, |
| 3289 |
undefined, undefined, context |
| 3290 |
); |
| 3291 |
} else if ((Ctor = resolveAsset(context.$options, 'components', tag))) { |
| 3292 |
// component |
| 3293 |
vnode = createComponent(Ctor, data, context, children, tag); |
| 3294 |
} else { |
| 3295 |
// unknown or unlisted namespaced elements |
| 3296 |
// check at runtime because it may get assigned a namespace when its |
| 3297 |
// parent normalizes children |
| 3298 |
vnode = new VNode( |
| 3299 |
tag, data, children, |
| 3300 |
undefined, undefined, context |
| 3301 |
); |
| 3302 |
} |
| 3303 |
} else { |
| 3304 |
// direct component options / constructor |
| 3305 |
vnode = createComponent(tag, data, context, children); |
| 3306 |
} |
| 3307 |
if (vnode) { |
| 3308 |
if (ns) { applyNS(vnode, ns); } |
| 3309 |
return vnode |
| 3310 |
} else { |
| 3311 |
return createEmptyVNode() |
| 3312 |
} |
| 3313 |
} |
| 3314 |
|
| 3315 |
function applyNS (vnode, ns) { |
| 3316 |
vnode.ns = ns; |
| 3317 |
if (vnode.tag === 'foreignObject') { |
| 3318 |
// use default namespace inside foreignObject |
| 3319 |
return |
| 3320 |
} |
| 3321 |
if (vnode.children) { |
| 3322 |
for (var i = 0, l = vnode.children.length; i < l; i++) { |
| 3323 |
var child = vnode.children[i]; |
| 3324 |
if (child.tag && !child.ns) { |
| 3325 |
applyNS(child, ns); |
| 3326 |
} |
| 3327 |
} |
| 3328 |
} |
| 3329 |
} |
| 3330 |
|
| 3331 |
/* */ |
| 3332 |
|
| 3333 |
/** |
| 3334 |
* Runtime helper for rendering v-for lists. |
| 3335 |
*/ |
| 3336 |
function renderList ( |
| 3337 |
val, |
| 3338 |
render |
| 3339 |
) { |
| 3340 |
var ret, i, l, keys, key; |
| 3341 |
if (Array.isArray(val) || typeof val === 'string') { |
| 3342 |
ret = new Array(val.length); |
| 3343 |
for (i = 0, l = val.length; i < l; i++) { |
| 3344 |
ret[i] = render(val[i], i); |
| 3345 |
} |
| 3346 |
} else if (typeof val === 'number') { |
| 3347 |
ret = new Array(val); |
| 3348 |
for (i = 0; i < val; i++) { |
| 3349 |
ret[i] = render(i + 1, i); |
| 3350 |
} |
| 3351 |
} else if (isObject(val)) { |
| 3352 |
keys = Object.keys(val); |
| 3353 |
ret = new Array(keys.length); |
| 3354 |
for (i = 0, l = keys.length; i < l; i++) { |
| 3355 |
key = keys[i]; |
| 3356 |
ret[i] = render(val[key], key, i); |
| 3357 |
} |
| 3358 |
} |
| 3359 |
return ret |
| 3360 |
} |
| 3361 |
|
| 3362 |
/* */ |
| 3363 |
|
| 3364 |
/** |
| 3365 |
* Runtime helper for rendering <slot> |
| 3366 |
*/ |
| 3367 |
function renderSlot ( |
| 3368 |
name, |
| 3369 |
fallback, |
| 3370 |
props, |
| 3371 |
bindObject |
| 3372 |
) { |
| 3373 |
var scopedSlotFn = this.$scopedSlots[name]; |
| 3374 |
if (scopedSlotFn) { // scoped slot |
| 3375 |
props = props || {}; |
| 3376 |
if (bindObject) { |
| 3377 |
extend(props, bindObject); |
| 3378 |
} |
| 3379 |
return scopedSlotFn(props) || fallback |
| 3380 |
} else { |
| 3381 |
var slotNodes = this.$slots[name]; |
| 3382 |
// warn duplicate slot usage |
| 3383 |
if (slotNodes && "development" !== 'production') { |
| 3384 |
slotNodes._rendered && warn( |
| 3385 |
"Duplicate presence of slot \"" + name + "\" found in the same render tree " + |
| 3386 |
"- this will likely cause render errors.", |
| 3387 |
this |
| 3388 |
); |
| 3389 |
slotNodes._rendered = true; |
| 3390 |
} |
| 3391 |
return slotNodes || fallback |
| 3392 |
} |
| 3393 |
} |
| 3394 |
|
| 3395 |
/* */ |
| 3396 |
|
| 3397 |
/** |
| 3398 |
* Runtime helper for resolving filters |
| 3399 |
*/ |
| 3400 |
function resolveFilter (id) { |
| 3401 |
return resolveAsset(this.$options, 'filters', id, true) || identity |
| 3402 |
} |
| 3403 |
|
| 3404 |
/* */ |
| 3405 |
|
| 3406 |
/** |
| 3407 |
* Runtime helper for checking keyCodes from config. |
| 3408 |
*/ |
| 3409 |
function checkKeyCodes ( |
| 3410 |
eventKeyCode, |
| 3411 |
key, |
| 3412 |
builtInAlias |
| 3413 |
) { |
| 3414 |
var keyCodes = config.keyCodes[key] || builtInAlias; |
| 3415 |
if (Array.isArray(keyCodes)) { |
| 3416 |
return keyCodes.indexOf(eventKeyCode) === -1 |
| 3417 |
} else { |
| 3418 |
return keyCodes !== eventKeyCode |
| 3419 |
} |
| 3420 |
} |
| 3421 |
|
| 3422 |
/* */ |
| 3423 |
|
| 3424 |
/** |
| 3425 |
* Runtime helper for merging v-bind="object" into a VNode's data. |
| 3426 |
*/ |
| 3427 |
function bindObjectProps ( |
| 3428 |
data, |
| 3429 |
tag, |
| 3430 |
value, |
| 3431 |
asProp |
| 3432 |
) { |
| 3433 |
if (value) { |
| 3434 |
if (!isObject(value)) { |
| 3435 |
"development" !== 'production' && warn( |
| 3436 |
'v-bind without argument expects an Object or Array value', |
| 3437 |
this |
| 3438 |
); |
| 3439 |
} else { |
| 3440 |
if (Array.isArray(value)) { |
| 3441 |
value = toObject(value); |
| 3442 |
} |
| 3443 |
var hash; |
| 3444 |
for (var key in value) { |
| 3445 |
if (key === 'class' || key === 'style') { |
| 3446 |
hash = data; |
| 3447 |
} else { |
| 3448 |
var type = data.attrs && data.attrs.type; |
| 3449 |
hash = asProp || config.mustUseProp(tag, type, key) |
| 3450 |
? data.domProps || (data.domProps = {}) |
| 3451 |
: data.attrs || (data.attrs = {}); |
| 3452 |
} |
| 3453 |
if (!(key in hash)) { |
| 3454 |
hash[key] = value[key]; |
| 3455 |
} |
| 3456 |
} |
| 3457 |
} |
| 3458 |
} |
| 3459 |
return data |
| 3460 |
} |
| 3461 |
|
| 3462 |
/* */ |
| 3463 |
|
| 3464 |
/** |
| 3465 |
* Runtime helper for rendering static trees. |
| 3466 |
*/ |
| 3467 |
function renderStatic ( |
| 3468 |
index, |
| 3469 |
isInFor |
| 3470 |
) { |
| 3471 |
var tree = this._staticTrees[index]; |
| 3472 |
// if has already-rendered static tree and not inside v-for, |
| 3473 |
// we can reuse the same tree by doing a shallow clone. |
| 3474 |
if (tree && !isInFor) { |
| 3475 |
return Array.isArray(tree) |
| 3476 |
? cloneVNodes(tree) |
| 3477 |
: cloneVNode(tree) |
| 3478 |
} |
| 3479 |
// otherwise, render a fresh tree. |
| 3480 |
tree = this._staticTrees[index] = |
| 3481 |
this.$options.staticRenderFns[index].call(this._renderProxy); |
| 3482 |
markStatic(tree, ("__static__" + index), false); |
| 3483 |
return tree |
| 3484 |
} |
| 3485 |
|
| 3486 |
/** |
| 3487 |
* Runtime helper for v-once. |
| 3488 |
* Effectively it means marking the node as static with a unique key. |
| 3489 |
*/ |
| 3490 |
function markOnce ( |
| 3491 |
tree, |
| 3492 |
index, |
| 3493 |
key |
| 3494 |
) { |
| 3495 |
markStatic(tree, ("__once__" + index + (key ? ("_" + key) : "")), true); |
| 3496 |
return tree |
| 3497 |
} |
| 3498 |
|
| 3499 |
function markStatic ( |
| 3500 |
tree, |
| 3501 |
key, |
| 3502 |
isOnce |
| 3503 |
) { |
| 3504 |
if (Array.isArray(tree)) { |
| 3505 |
for (var i = 0; i < tree.length; i++) { |
| 3506 |
if (tree[i] && typeof tree[i] !== 'string') { |
| 3507 |
markStaticNode(tree[i], (key + "_" + i), isOnce); |
| 3508 |
} |
| 3509 |
} |
| 3510 |
} else { |
| 3511 |
markStaticNode(tree, key, isOnce); |
| 3512 |
} |
| 3513 |
} |
| 3514 |
|
| 3515 |
function markStaticNode (node, key, isOnce) { |
| 3516 |
node.isStatic = true; |
| 3517 |
node.key = key; |
| 3518 |
node.isOnce = isOnce; |
| 3519 |
} |
| 3520 |
|
| 3521 |
/* */ |
| 3522 |
|
| 3523 |
function initRender (vm) { |
| 3524 |
vm.$vnode = null; // the placeholder node in parent tree |
| 3525 |
vm._vnode = null; // the root of the child tree |
| 3526 |
vm._staticTrees = null; |
| 3527 |
var parentVnode = vm.$options._parentVnode; |
| 3528 |
var renderContext = parentVnode && parentVnode.context; |
| 3529 |
vm.$slots = resolveSlots(vm.$options._renderChildren, renderContext); |
| 3530 |
vm.$scopedSlots = emptyObject; |
| 3531 |
// bind the createElement fn to this instance |
| 3532 |
// so that we get proper render context inside it. |
| 3533 |
// args order: tag, data, children, normalizationType, alwaysNormalize |
| 3534 |
// internal version is used by render functions compiled from templates |
| 3535 |
vm._c = function (a, b, c, d) { return createElement(vm, a, b, c, d, false); }; |
| 3536 |
// normalization is always applied for the public version, used in |
| 3537 |
// user-written render functions. |
| 3538 |
vm.$createElement = function (a, b, c, d) { return createElement(vm, a, b, c, d, true); }; |
| 3539 |
} |
| 3540 |
|
| 3541 |
function renderMixin (Vue) { |
| 3542 |
Vue.prototype.$nextTick = function (fn) { |
| 3543 |
return nextTick(fn, this) |
| 3544 |
}; |
| 3545 |
|
| 3546 |
Vue.prototype._render = function () { |
| 3547 |
var vm = this; |
| 3548 |
var ref = vm.$options; |
| 3549 |
var render = ref.render; |
| 3550 |
var staticRenderFns = ref.staticRenderFns; |
| 3551 |
var _parentVnode = ref._parentVnode; |
| 3552 |
|
| 3553 |
if (vm._isMounted) { |
| 3554 |
// clone slot nodes on re-renders |
| 3555 |
for (var key in vm.$slots) { |
| 3556 |
vm.$slots[key] = cloneVNodes(vm.$slots[key]); |
| 3557 |
} |
| 3558 |
} |
| 3559 |
|
| 3560 |
vm.$scopedSlots = (_parentVnode && _parentVnode.data.scopedSlots) || emptyObject; |
| 3561 |
|
| 3562 |
if (staticRenderFns && !vm._staticTrees) { |
| 3563 |
vm._staticTrees = []; |
| 3564 |
} |
| 3565 |
// set parent vnode. this allows render functions to have access |
| 3566 |
// to the data on the placeholder node. |
| 3567 |
vm.$vnode = _parentVnode; |
| 3568 |
// render self |
| 3569 |
var vnode; |
| 3570 |
try { |
| 3571 |
vnode = render.call(vm._renderProxy, vm.$createElement); |
| 3572 |
} catch (e) { |
| 3573 |
handleError(e, vm, "render function"); |
| 3574 |
// return error render result, |
| 3575 |
// or previous vnode to prevent render error causing blank component |
| 3576 |
/* istanbul ignore else */ |
| 3577 |
{ |
| 3578 |
vnode = vm.$options.renderError |
| 3579 |
? vm.$options.renderError.call(vm._renderProxy, vm.$createElement, e) |
| 3580 |
: vm._vnode; |
| 3581 |
} |
| 3582 |
} |
| 3583 |
// return empty vnode in case the render function errored out |
| 3584 |
if (!(vnode instanceof VNode)) { |
| 3585 |
if ("development" !== 'production' && Array.isArray(vnode)) { |
| 3586 |
warn( |
| 3587 |
'Multiple root nodes returned from render function. Render function ' + |
| 3588 |
'should return a single root node.', |
| 3589 |
vm |
| 3590 |
); |
| 3591 |
} |
| 3592 |
vnode = createEmptyVNode(); |
| 3593 |
} |
| 3594 |
// set parent |
| 3595 |
vnode.parent = _parentVnode; |
| 3596 |
return vnode |
| 3597 |
}; |
| 3598 |
|
| 3599 |
// internal render helpers. |
| 3600 |
// these are exposed on the instance prototype to reduce generated render |
| 3601 |
// code size. |
| 3602 |
Vue.prototype._o = markOnce; |
| 3603 |
Vue.prototype._n = toNumber; |
| 3604 |
Vue.prototype._s = _toString; |
| 3605 |
Vue.prototype._l = renderList; |
| 3606 |
Vue.prototype._t = renderSlot; |
| 3607 |
Vue.prototype._q = looseEqual; |
| 3608 |
Vue.prototype._i = looseIndexOf; |
| 3609 |
Vue.prototype._m = renderStatic; |
| 3610 |
Vue.prototype._f = resolveFilter; |
| 3611 |
Vue.prototype._k = checkKeyCodes; |
| 3612 |
Vue.prototype._b = bindObjectProps; |
| 3613 |
Vue.prototype._v = createTextVNode; |
| 3614 |
Vue.prototype._e = createEmptyVNode; |
| 3615 |
Vue.prototype._u = resolveScopedSlots; |
| 3616 |
} |
| 3617 |
|
| 3618 |
/* */ |
| 3619 |
|
| 3620 |
function initProvide (vm) { |
| 3621 |
var provide = vm.$options.provide; |
| 3622 |
if (provide) { |
| 3623 |
vm._provided = typeof provide === 'function' |
| 3624 |
? provide.call(vm) |
| 3625 |
: provide; |
| 3626 |
} |
| 3627 |
} |
| 3628 |
|
| 3629 |
function initInjections (vm) { |
| 3630 |
var inject = vm.$options.inject; |
| 3631 |
if (inject) { |
| 3632 |
// inject is :any because flow is not smart enough to figure out cached |
| 3633 |
// isArray here |
| 3634 |
var isArray = Array.isArray(inject); |
| 3635 |
var keys = isArray |
| 3636 |
? inject |
| 3637 |
: hasSymbol |
| 3638 |
? Reflect.ownKeys(inject) |
| 3639 |
: Object.keys(inject); |
| 3640 |
|
| 3641 |
for (var i = 0; i < keys.length; i++) { |
| 3642 |
var key = keys[i]; |
| 3643 |
var provideKey = isArray ? key : inject[key]; |
| 3644 |
var source = vm; |
| 3645 |
while (source) { |
| 3646 |
if (source._provided && provideKey in source._provided) { |
| 3647 |
vm[key] = source._provided[provideKey]; |
| 3648 |
break |
| 3649 |
} |
| 3650 |
source = source.$parent; |
| 3651 |
} |
| 3652 |
} |
| 3653 |
} |
| 3654 |
} |
| 3655 |
|
| 3656 |
/* */ |
| 3657 |
|
| 3658 |
var uid = 0; |
| 3659 |
|
| 3660 |
function initMixin (Vue) { |
| 3661 |
Vue.prototype._init = function (options) { |
| 3662 |
/* istanbul ignore if */ |
| 3663 |
if ("development" !== 'production' && config.performance && mark) { |
| 3664 |
mark('vue-perf-init'); |
| 3665 |
} |
| 3666 |
|
| 3667 |
var vm = this; |
| 3668 |
// a uid |
| 3669 |
vm._uid = uid++; |
| 3670 |
// a flag to avoid this being observed |
| 3671 |
vm._isVue = true; |
| 3672 |
// merge options |
| 3673 |
if (options && options._isComponent) { |
| 3674 |
// optimize internal component instantiation |
| 3675 |
// since dynamic options merging is pretty slow, and none of the |
| 3676 |
// internal component options needs special treatment. |
| 3677 |
initInternalComponent(vm, options); |
| 3678 |
} else { |
| 3679 |
vm.$options = mergeOptions( |
| 3680 |
resolveConstructorOptions(vm.constructor), |
| 3681 |
options || {}, |
| 3682 |
vm |
| 3683 |
); |
| 3684 |
} |
| 3685 |
/* istanbul ignore else */ |
| 3686 |
{ |
| 3687 |
initProxy(vm); |
| 3688 |
} |
| 3689 |
// expose real self |
| 3690 |
vm._self = vm; |
| 3691 |
initLifecycle(vm); |
| 3692 |
initEvents(vm); |
| 3693 |
initRender(vm); |
| 3694 |
callHook(vm, 'beforeCreate'); |
| 3695 |
initInjections(vm); // resolve injections before data/props |
| 3696 |
initState(vm); |
| 3697 |
initProvide(vm); // resolve provide after data/props |
| 3698 |
callHook(vm, 'created'); |
| 3699 |
|
| 3700 |
/* istanbul ignore if */ |
| 3701 |
if ("development" !== 'production' && config.performance && mark) { |
| 3702 |
vm._name = formatComponentName(vm, false); |
| 3703 |
mark('vue-perf-init-end'); |
| 3704 |
measure(((vm._name) + " init"), 'vue-perf-init', 'vue-perf-init-end'); |
| 3705 |
} |
| 3706 |
|
| 3707 |
if (vm.$options.el) { |
| 3708 |
vm.$mount(vm.$options.el); |
| 3709 |
} |
| 3710 |
}; |
| 3711 |
} |
| 3712 |
|
| 3713 |
function initInternalComponent (vm, options) { |
| 3714 |
var opts = vm.$options = Object.create(vm.constructor.options); |
| 3715 |
// doing this because it's faster than dynamic enumeration. |
| 3716 |
opts.parent = options.parent; |
| 3717 |
opts.propsData = options.propsData; |
| 3718 |
opts._parentVnode = options._parentVnode; |
| 3719 |
opts._parentListeners = options._parentListeners; |
| 3720 |
opts._renderChildren = options._renderChildren; |
| 3721 |
opts._componentTag = options._componentTag; |
| 3722 |
opts._parentElm = options._parentElm; |
| 3723 |
opts._refElm = options._refElm; |
| 3724 |
if (options.render) { |
| 3725 |
opts.render = options.render; |
| 3726 |
opts.staticRenderFns = options.staticRenderFns; |
| 3727 |
} |
| 3728 |
} |
| 3729 |
|
| 3730 |
function resolveConstructorOptions (Ctor) { |
| 3731 |
var options = Ctor.options; |
| 3732 |
if (Ctor.super) { |
| 3733 |
var superOptions = resolveConstructorOptions(Ctor.super); |
| 3734 |
var cachedSuperOptions = Ctor.superOptions; |
| 3735 |
if (superOptions !== cachedSuperOptions) { |
| 3736 |
// super option changed, |
| 3737 |
// need to resolve new options. |
| 3738 |
Ctor.superOptions = superOptions; |
| 3739 |
// check if there are any late-modified/attached options (#4976) |
| 3740 |
var modifiedOptions = resolveModifiedOptions(Ctor); |
| 3741 |
// update base extend options |
| 3742 |
if (modifiedOptions) { |
| 3743 |
extend(Ctor.extendOptions, modifiedOptions); |
| 3744 |
} |
| 3745 |
options = Ctor.options = mergeOptions(superOptions, Ctor.extendOptions); |
| 3746 |
if (options.name) { |
| 3747 |
options.components[options.name] = Ctor; |
| 3748 |
} |
| 3749 |
} |
| 3750 |
} |
| 3751 |
return options |
| 3752 |
} |
| 3753 |
|
| 3754 |
function resolveModifiedOptions (Ctor) { |
| 3755 |
var modified; |
| 3756 |
var latest = Ctor.options; |
| 3757 |
var sealed = Ctor.sealedOptions; |
| 3758 |
for (var key in latest) { |
| 3759 |
if (latest[key] !== sealed[key]) { |
| 3760 |
if (!modified) { modified = {}; } |
| 3761 |
modified[key] = dedupe(latest[key], sealed[key]); |
| 3762 |
} |
| 3763 |
} |
| 3764 |
return modified |
| 3765 |
} |
| 3766 |
|
| 3767 |
function dedupe (latest, sealed) { |
| 3768 |
// compare latest and sealed to ensure lifecycle hooks won't be duplicated |
| 3769 |
// between merges |
| 3770 |
if (Array.isArray(latest)) { |
| 3771 |
var res = []; |
| 3772 |
sealed = Array.isArray(sealed) ? sealed : [sealed]; |
| 3773 |
for (var i = 0; i < latest.length; i++) { |
| 3774 |
if (sealed.indexOf(latest[i]) < 0) { |
| 3775 |
res.push(latest[i]); |
| 3776 |
} |
| 3777 |
} |
| 3778 |
return res |
| 3779 |
} else { |
| 3780 |
return latest |
| 3781 |
} |
| 3782 |
} |
| 3783 |
|
| 3784 |
function Vue$3 (options) { |
| 3785 |
if ("development" !== 'production' && |
| 3786 |
!(this instanceof Vue$3)) { |
| 3787 |
warn('Vue is a constructor and should be called with the `new` keyword'); |
| 3788 |
} |
| 3789 |
this._init(options); |
| 3790 |
} |
| 3791 |
|
| 3792 |
initMixin(Vue$3); |
| 3793 |
stateMixin(Vue$3); |
| 3794 |
eventsMixin(Vue$3); |
| 3795 |
lifecycleMixin(Vue$3); |
| 3796 |
renderMixin(Vue$3); |
| 3797 |
|
| 3798 |
/* */ |
| 3799 |
|
| 3800 |
function initUse (Vue) { |
| 3801 |
Vue.use = function (plugin) { |
| 3802 |
/* istanbul ignore if */ |
| 3803 |
if (plugin.installed) { |
| 3804 |
return |
| 3805 |
} |
| 3806 |
// additional parameters |
| 3807 |
var args = toArray(arguments, 1); |
| 3808 |
args.unshift(this); |
| 3809 |
if (typeof plugin.install === 'function') { |
| 3810 |
plugin.install.apply(plugin, args); |
| 3811 |
} else if (typeof plugin === 'function') { |
| 3812 |
plugin.apply(null, args); |
| 3813 |
} |
| 3814 |
plugin.installed = true; |
| 3815 |
return this |
| 3816 |
}; |
| 3817 |
} |
| 3818 |
|
| 3819 |
/* */ |
| 3820 |
|
| 3821 |
function initMixin$1 (Vue) { |
| 3822 |
Vue.mixin = function (mixin) { |
| 3823 |
this.options = mergeOptions(this.options, mixin); |
| 3824 |
}; |
| 3825 |
} |
| 3826 |
|
| 3827 |
/* */ |
| 3828 |
|
| 3829 |
function initExtend (Vue) { |
| 3830 |
/** |
| 3831 |
* Each instance constructor, including Vue, has a unique |
| 3832 |
* cid. This enables us to create wrapped "child |
| 3833 |
* constructors" for prototypal inheritance and cache them. |
| 3834 |
*/ |
| 3835 |
Vue.cid = 0; |
| 3836 |
var cid = 1; |
| 3837 |
|
| 3838 |
/** |
| 3839 |
* Class inheritance |
| 3840 |
*/ |
| 3841 |
Vue.extend = function (extendOptions) { |
| 3842 |
extendOptions = extendOptions || {}; |
| 3843 |
var Super = this; |
| 3844 |
var SuperId = Super.cid; |
| 3845 |
var cachedCtors = extendOptions._Ctor || (extendOptions._Ctor = {}); |
| 3846 |
if (cachedCtors[SuperId]) { |
| 3847 |
return cachedCtors[SuperId] |
| 3848 |
} |
| 3849 |
|
| 3850 |
var name = extendOptions.name || Super.options.name; |
| 3851 |
{ |
| 3852 |
if (!/^[a-zA-Z][\w-]*$/.test(name)) { |
| 3853 |
warn( |
| 3854 |
'Invalid component name: "' + name + '". Component names ' + |
| 3855 |
'can only contain alphanumeric characters and the hyphen, ' + |
| 3856 |
'and must start with a letter.' |
| 3857 |
); |
| 3858 |
} |
| 3859 |
} |
| 3860 |
|
| 3861 |
var Sub = function VueComponent (options) { |
| 3862 |
this._init(options); |
| 3863 |
}; |
| 3864 |
Sub.prototype = Object.create(Super.prototype); |
| 3865 |
Sub.prototype.constructor = Sub; |
| 3866 |
Sub.cid = cid++; |
| 3867 |
Sub.options = mergeOptions( |
| 3868 |
Super.options, |
| 3869 |
extendOptions |
| 3870 |
); |
| 3871 |
Sub['super'] = Super; |
| 3872 |
|
| 3873 |
// For props and computed properties, we define the proxy getters on |
| 3874 |
// the Vue instances at extension time, on the extended prototype. This |
| 3875 |
// avoids Object.defineProperty calls for each instance created. |
| 3876 |
if (Sub.options.props) { |
| 3877 |
initProps$1(Sub); |
| 3878 |
} |
| 3879 |
if (Sub.options.computed) { |
| 3880 |
initComputed$1(Sub); |
| 3881 |
} |
| 3882 |
|
| 3883 |
// allow further extension/mixin/plugin usage |
| 3884 |
Sub.extend = Super.extend; |
| 3885 |
Sub.mixin = Super.mixin; |
| 3886 |
Sub.use = Super.use; |
| 3887 |
|
| 3888 |
// create asset registers, so extended classes |
| 3889 |
// can have their private assets too. |
| 3890 |
config._assetTypes.forEach(function (type) { |
| 3891 |
Sub[type] = Super[type]; |
| 3892 |
}); |
| 3893 |
// enable recursive self-lookup |
| 3894 |
if (name) { |
| 3895 |
Sub.options.components[name] = Sub; |
| 3896 |
} |
| 3897 |
|
| 3898 |
// keep a reference to the super options at extension time. |
| 3899 |
// later at instantiation we can check if Super's options have |
| 3900 |
// been updated. |
| 3901 |
Sub.superOptions = Super.options; |
| 3902 |
Sub.extendOptions = extendOptions; |
| 3903 |
Sub.sealedOptions = extend({}, Sub.options); |
| 3904 |
|
| 3905 |
// cache constructor |
| 3906 |
cachedCtors[SuperId] = Sub; |
| 3907 |
return Sub |
| 3908 |
}; |
| 3909 |
} |
| 3910 |
|
| 3911 |
function initProps$1 (Comp) { |
| 3912 |
var props = Comp.options.props; |
| 3913 |
for (var key in props) { |
| 3914 |
proxy(Comp.prototype, "_props", key); |
| 3915 |
} |
| 3916 |
} |
| 3917 |
|
| 3918 |
function initComputed$1 (Comp) { |
| 3919 |
var computed = Comp.options.computed; |
| 3920 |
for (var key in computed) { |
| 3921 |
defineComputed(Comp.prototype, key, computed[key]); |
| 3922 |
} |
| 3923 |
} |
| 3924 |
|
| 3925 |
/* */ |
| 3926 |
|
| 3927 |
function initAssetRegisters (Vue) { |
| 3928 |
/** |
| 3929 |
* Create asset registration methods. |
| 3930 |
*/ |
| 3931 |
config._assetTypes.forEach(function (type) { |
| 3932 |
Vue[type] = function ( |
| 3933 |
id, |
| 3934 |
definition |
| 3935 |
) { |
| 3936 |
if (!definition) { |
| 3937 |
return this.options[type + 's'][id] |
| 3938 |
} else { |
| 3939 |
/* istanbul ignore if */ |
| 3940 |
{ |
| 3941 |
if (type === 'component' && config.isReservedTag(id)) { |
| 3942 |
warn( |
| 3943 |
'Do not use built-in or reserved HTML elements as component ' + |
| 3944 |
'id: ' + id |
| 3945 |
); |
| 3946 |
} |
| 3947 |
} |
| 3948 |
if (type === 'component' && isPlainObject(definition)) { |
| 3949 |
definition.name = definition.name || id; |
| 3950 |
definition = this.options._base.extend(definition); |
| 3951 |
} |
| 3952 |
if (type === 'directive' && typeof definition === 'function') { |
| 3953 |
definition = { bind: definition, update: definition }; |
| 3954 |
} |
| 3955 |
this.options[type + 's'][id] = definition; |
| 3956 |
return definition |
| 3957 |
} |
| 3958 |
}; |
| 3959 |
}); |
| 3960 |
} |
| 3961 |
|
| 3962 |
/* */ |
| 3963 |
|
| 3964 |
var patternTypes = [String, RegExp]; |
| 3965 |
|
| 3966 |
function getComponentName (opts) { |
| 3967 |
return opts && (opts.Ctor.options.name || opts.tag) |
| 3968 |
} |
| 3969 |
|
| 3970 |
function matches (pattern, name) { |
| 3971 |
if (typeof pattern === 'string') { |
| 3972 |
return pattern.split(',').indexOf(name) > -1 |
| 3973 |
} else if (pattern instanceof RegExp) { |
| 3974 |
return pattern.test(name) |
| 3975 |
} |
| 3976 |
/* istanbul ignore next */ |
| 3977 |
return false |
| 3978 |
} |
| 3979 |
|
| 3980 |
function pruneCache (cache, filter) { |
| 3981 |
for (var key in cache) { |
| 3982 |
var cachedNode = cache[key]; |
| 3983 |
if (cachedNode) { |
| 3984 |
var name = getComponentName(cachedNode.componentOptions); |
| 3985 |
if (name && !filter(name)) { |
| 3986 |
pruneCacheEntry(cachedNode); |
| 3987 |
cache[key] = null; |
| 3988 |
} |
| 3989 |
} |
| 3990 |
} |
| 3991 |
} |
| 3992 |
|
| 3993 |
function pruneCacheEntry (vnode) { |
| 3994 |
if (vnode) { |
| 3995 |
if (!vnode.componentInstance._inactive) { |
| 3996 |
callHook(vnode.componentInstance, 'deactivated'); |
| 3997 |
} |
| 3998 |
vnode.componentInstance.$destroy(); |
| 3999 |
} |
| 4000 |
} |
| 4001 |
|
| 4002 |
var KeepAlive = { |
| 4003 |
name: 'keep-alive', |
| 4004 |
abstract: true, |
| 4005 |
|
| 4006 |
props: { |
| 4007 |
include: patternTypes, |
| 4008 |
exclude: patternTypes |
| 4009 |
}, |
| 4010 |
|
| 4011 |
created: function created () { |
| 4012 |
this.cache = Object.create(null); |
| 4013 |
}, |
| 4014 |
|
| 4015 |
destroyed: function destroyed () { |
| 4016 |
var this$1 = this; |
| 4017 |
|
| 4018 |
for (var key in this$1.cache) { |
| 4019 |
pruneCacheEntry(this$1.cache[key]); |
| 4020 |
} |
| 4021 |
}, |
| 4022 |
|
| 4023 |
watch: { |
| 4024 |
include: function include (val) { |
| 4025 |
pruneCache(this.cache, function (name) { return matches(val, name); }); |
| 4026 |
}, |
| 4027 |
exclude: function exclude (val) { |
| 4028 |
pruneCache(this.cache, function (name) { return !matches(val, name); }); |
| 4029 |
} |
| 4030 |
}, |
| 4031 |
|
| 4032 |
render: function render () { |
| 4033 |
var vnode = getFirstComponentChild(this.$slots.default); |
| 4034 |
var componentOptions = vnode && vnode.componentOptions; |
| 4035 |
if (componentOptions) { |
| 4036 |
// check pattern |
| 4037 |
var name = getComponentName(componentOptions); |
| 4038 |
if (name && ( |
| 4039 |
(this.include && !matches(this.include, name)) || |
| 4040 |
(this.exclude && matches(this.exclude, name)) |
| 4041 |
)) { |
| 4042 |
return vnode |
| 4043 |
} |
| 4044 |
var key = vnode.key == null |
| 4045 |
// same constructor may get registered as different local components |
| 4046 |
// so cid alone is not enough (#3269) |
| 4047 |
? componentOptions.Ctor.cid + (componentOptions.tag ? ("::" + (componentOptions.tag)) : '') |
| 4048 |
: vnode.key; |
| 4049 |
if (this.cache[key]) { |
| 4050 |
vnode.componentInstance = this.cache[key].componentInstance; |
| 4051 |
} else { |
| 4052 |
this.cache[key] = vnode; |
| 4053 |
} |
| 4054 |
vnode.data.keepAlive = true; |
| 4055 |
} |
| 4056 |
return vnode |
| 4057 |
} |
| 4058 |
}; |
| 4059 |
|
| 4060 |
var builtInComponents = { |
| 4061 |
KeepAlive: KeepAlive |
| 4062 |
}; |
| 4063 |
|
| 4064 |
/* */ |
| 4065 |
|
| 4066 |
function initGlobalAPI (Vue) { |
| 4067 |
// config |
| 4068 |
var configDef = {}; |
| 4069 |
configDef.get = function () { return config; }; |
| 4070 |
{ |
| 4071 |
configDef.set = function () { |
| 4072 |
warn( |
| 4073 |
'Do not replace the Vue.config object, set individual fields instead.' |
| 4074 |
); |
| 4075 |
}; |
| 4076 |
} |
| 4077 |
Object.defineProperty(Vue, 'config', configDef); |
| 4078 |
|
| 4079 |
// exposed util methods. |
| 4080 |
// NOTE: these are not considered part of the public API - avoid relying on |
| 4081 |
// them unless you are aware of the risk. |
| 4082 |
Vue.util = { |
| 4083 |
warn: warn, |
| 4084 |
extend: extend, |
| 4085 |
mergeOptions: mergeOptions, |
| 4086 |
defineReactive: defineReactive$$1 |
| 4087 |
}; |
| 4088 |
|
| 4089 |
Vue.set = set; |
| 4090 |
Vue.delete = del; |
| 4091 |
Vue.nextTick = nextTick; |
| 4092 |
|
| 4093 |
Vue.options = Object.create(null); |
| 4094 |
config._assetTypes.forEach(function (type) { |
| 4095 |
Vue.options[type + 's'] = Object.create(null); |
| 4096 |
}); |
| 4097 |
|
| 4098 |
// this is used to identify the "base" constructor to extend all plain-object |
| 4099 |
// components with in Weex's multi-instance scenarios. |
| 4100 |
Vue.options._base = Vue; |
| 4101 |
|
| 4102 |
extend(Vue.options.components, builtInComponents); |
| 4103 |
|
| 4104 |
initUse(Vue); |
| 4105 |
initMixin$1(Vue); |
| 4106 |
initExtend(Vue); |
| 4107 |
initAssetRegisters(Vue); |
| 4108 |
} |
| 4109 |
|
| 4110 |
initGlobalAPI(Vue$3); |
| 4111 |
|
| 4112 |
Object.defineProperty(Vue$3.prototype, '$isServer', { |
| 4113 |
get: isServerRendering |
| 4114 |
}); |
| 4115 |
|
| 4116 |
Vue$3.version = '2.2.4'; |
| 4117 |
|
| 4118 |
/* */ |
| 4119 |
|
| 4120 |
// attributes that should be using props for binding |
| 4121 |
var acceptValue = makeMap('input,textarea,option,select'); |
| 4122 |
var mustUseProp = function (tag, type, attr) { |
| 4123 |
return ( |
| 4124 |
(attr === 'value' && acceptValue(tag)) && type !== 'button' || |
| 4125 |
(attr === 'selected' && tag === 'option') || |
| 4126 |
(attr === 'checked' && tag === 'input') || |
| 4127 |
(attr === 'muted' && tag === 'video') |
| 4128 |
) |
| 4129 |
}; |
| 4130 |
|
| 4131 |
var isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck'); |
| 4132 |
|
| 4133 |
var isBooleanAttr = makeMap( |
| 4134 |
'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' + |
| 4135 |
'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' + |
| 4136 |
'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' + |
| 4137 |
'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' + |
| 4138 |
'required,reversed,scoped,seamless,selected,sortable,translate,' + |
| 4139 |
'truespeed,typemustmatch,visible' |
| 4140 |
); |
| 4141 |
|
| 4142 |
var xlinkNS = 'http://www.w3.org/1999/xlink'; |
| 4143 |
|
| 4144 |
var isXlink = function (name) { |
| 4145 |
return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink' |
| 4146 |
}; |
| 4147 |
|
| 4148 |
var getXlinkProp = function (name) { |
| 4149 |
return isXlink(name) ? name.slice(6, name.length) : '' |
| 4150 |
}; |
| 4151 |
|
| 4152 |
var isFalsyAttrValue = function (val) { |
| 4153 |
return val == null || val === false |
| 4154 |
}; |
| 4155 |
|
| 4156 |
/* */ |
| 4157 |
|
| 4158 |
function genClassForVnode (vnode) { |
| 4159 |
var data = vnode.data; |
| 4160 |
var parentNode = vnode; |
| 4161 |
var childNode = vnode; |
| 4162 |
while (childNode.componentInstance) { |
| 4163 |
childNode = childNode.componentInstance._vnode; |
| 4164 |
if (childNode.data) { |
| 4165 |
data = mergeClassData(childNode.data, data); |
| 4166 |
} |
| 4167 |
} |
| 4168 |
while ((parentNode = parentNode.parent)) { |
| 4169 |
if (parentNode.data) { |
| 4170 |
data = mergeClassData(data, parentNode.data); |
| 4171 |
} |
| 4172 |
} |
| 4173 |
return genClassFromData(data) |
| 4174 |
} |
| 4175 |
|
| 4176 |
function mergeClassData (child, parent) { |
| 4177 |
return { |
| 4178 |
staticClass: concat(child.staticClass, parent.staticClass), |
| 4179 |
class: child.class |
| 4180 |
? [child.class, parent.class] |
| 4181 |
: parent.class |
| 4182 |
} |
| 4183 |
} |
| 4184 |
|
| 4185 |
function genClassFromData (data) { |
| 4186 |
var dynamicClass = data.class; |
| 4187 |
var staticClass = data.staticClass; |
| 4188 |
if (staticClass || dynamicClass) { |
| 4189 |
return concat(staticClass, stringifyClass(dynamicClass)) |
| 4190 |
} |
| 4191 |
/* istanbul ignore next */ |
| 4192 |
return '' |
| 4193 |
} |
| 4194 |
|
| 4195 |
function concat (a, b) { |
| 4196 |
return a ? b ? (a + ' ' + b) : a : (b || '') |
| 4197 |
} |
| 4198 |
|
| 4199 |
function stringifyClass (value) { |
| 4200 |
var res = ''; |
| 4201 |
if (!value) { |
| 4202 |
return res |
| 4203 |
} |
| 4204 |
if (typeof value === 'string') { |
| 4205 |
return value |
| 4206 |
} |
| 4207 |
if (Array.isArray(value)) { |
| 4208 |
var stringified; |
| 4209 |
for (var i = 0, l = value.length; i < l; i++) { |
| 4210 |
if (value[i]) { |
| 4211 |
if ((stringified = stringifyClass(value[i]))) { |
| 4212 |
res += stringified + ' '; |
| 4213 |
} |
| 4214 |
} |
| 4215 |
} |
| 4216 |
return res.slice(0, -1) |
| 4217 |
} |
| 4218 |
if (isObject(value)) { |
| 4219 |
for (var key in value) { |
| 4220 |
if (value[key]) { res += key + ' '; } |
| 4221 |
} |
| 4222 |
return res.slice(0, -1) |
| 4223 |
} |
| 4224 |
/* istanbul ignore next */ |
| 4225 |
return res |
| 4226 |
} |
| 4227 |
|
| 4228 |
/* */ |
| 4229 |
|
| 4230 |
var namespaceMap = { |
| 4231 |
svg: 'http://www.w3.org/2000/svg', |
| 4232 |
math: 'http://www.w3.org/1998/Math/MathML' |
| 4233 |
}; |
| 4234 |
|
| 4235 |
var isHTMLTag = makeMap( |
| 4236 |
'html,body,base,head,link,meta,style,title,' + |
| 4237 |
'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' + |
| 4238 |
'div,dd,dl,dt,figcaption,figure,hr,img,li,main,ol,p,pre,ul,' + |
| 4239 |
'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' + |
| 4240 |
's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,' + |
| 4241 |
'embed,object,param,source,canvas,script,noscript,del,ins,' + |
| 4242 |
'caption,col,colgroup,table,thead,tbody,td,th,tr,' + |
| 4243 |
'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' + |
| 4244 |
'output,progress,select,textarea,' + |
| 4245 |
'details,dialog,menu,menuitem,summary,' + |
| 4246 |
'content,element,shadow,template' |
| 4247 |
); |
| 4248 |
|
| 4249 |
// this map is intentionally selective, only covering SVG elements that may |
| 4250 |
// contain child elements. |
| 4251 |
var isSVG = makeMap( |
| 4252 |
'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' + |
| 4253 |
'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' + |
| 4254 |
'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view', |
| 4255 |
true |
| 4256 |
); |
| 4257 |
|
| 4258 |
var isPreTag = function (tag) { return tag === 'pre'; }; |
| 4259 |
|
| 4260 |
var isReservedTag = function (tag) { |
| 4261 |
return isHTMLTag(tag) || isSVG(tag) |
| 4262 |
}; |
| 4263 |
|
| 4264 |
function getTagNamespace (tag) { |
| 4265 |
if (isSVG(tag)) { |
| 4266 |
return 'svg' |
| 4267 |
} |
| 4268 |
// basic support for MathML |
| 4269 |
// note it doesn't support other MathML elements being component roots |
| 4270 |
if (tag === 'math') { |
| 4271 |
return 'math' |
| 4272 |
} |
| 4273 |
} |
| 4274 |
|
| 4275 |
var unknownElementCache = Object.create(null); |
| 4276 |
function isUnknownElement (tag) { |
| 4277 |
/* istanbul ignore if */ |
| 4278 |
if (!inBrowser) { |
| 4279 |
return true |
| 4280 |
} |
| 4281 |
if (isReservedTag(tag)) { |
| 4282 |
return false |
| 4283 |
} |
| 4284 |
tag = tag.toLowerCase(); |
| 4285 |
/* istanbul ignore if */ |
| 4286 |
if (unknownElementCache[tag] != null) { |
| 4287 |
return unknownElementCache[tag] |
| 4288 |
} |
| 4289 |
var el = document.createElement(tag); |
| 4290 |
if (tag.indexOf('-') > -1) { |
| 4291 |
// http://stackoverflow.com/a/28210364/1070244 |
| 4292 |
return (unknownElementCache[tag] = ( |
| 4293 |
el.constructor === window.HTMLUnknownElement || |
| 4294 |
el.constructor === window.HTMLElement |
| 4295 |
)) |
| 4296 |
} else { |
| 4297 |
return (unknownElementCache[tag] = /HTMLUnknownElement/.test(el.toString())) |
| 4298 |
} |
| 4299 |
} |
| 4300 |
|
| 4301 |
/* */ |
| 4302 |
|
| 4303 |
/** |
| 4304 |
* Query an element selector if it's not an element already. |
| 4305 |
*/ |
| 4306 |
function query (el) { |
| 4307 |
if (typeof el === 'string') { |
| 4308 |
var selected = document.querySelector(el); |
| 4309 |
if (!selected) { |
| 4310 |
"development" !== 'production' && warn( |
| 4311 |
'Cannot find element: ' + el |
| 4312 |
); |
| 4313 |
return document.createElement('div') |
| 4314 |
} |
| 4315 |
return selected |
| 4316 |
} else { |
| 4317 |
return el |
| 4318 |
} |
| 4319 |
} |
| 4320 |
|
| 4321 |
/* */ |
| 4322 |
|
| 4323 |
function createElement$1 (tagName, vnode) { |
| 4324 |
var elm = document.createElement(tagName); |
| 4325 |
if (tagName !== 'select') { |
| 4326 |
return elm |
| 4327 |
} |
| 4328 |
// false or null will remove the attribute but undefined will not |
| 4329 |
if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) { |
| 4330 |
elm.setAttribute('multiple', 'multiple'); |
| 4331 |
} |
| 4332 |
return elm |
| 4333 |
} |
| 4334 |
|
| 4335 |
function createElementNS (namespace, tagName) { |
| 4336 |
return document.createElementNS(namespaceMap[namespace], tagName) |
| 4337 |
} |
| 4338 |
|
| 4339 |
function createTextNode (text) { |
| 4340 |
return document.createTextNode(text) |
| 4341 |
} |
| 4342 |
|
| 4343 |
function createComment (text) { |
| 4344 |
return document.createComment(text) |
| 4345 |
} |
| 4346 |
|
| 4347 |
function insertBefore (parentNode, newNode, referenceNode) { |
| 4348 |
parentNode.insertBefore(newNode, referenceNode); |
| 4349 |
} |
| 4350 |
|
| 4351 |
function removeChild (node, child) { |
| 4352 |
node.removeChild(child); |
| 4353 |
} |
| 4354 |
|
| 4355 |
function appendChild (node, child) { |
| 4356 |
node.appendChild(child); |
| 4357 |
} |
| 4358 |
|
| 4359 |
function parentNode (node) { |
| 4360 |
return node.parentNode |
| 4361 |
} |
| 4362 |
|
| 4363 |
function nextSibling (node) { |
| 4364 |
return node.nextSibling |
| 4365 |
} |
| 4366 |
|
| 4367 |
function tagName (node) { |
| 4368 |
return node.tagName |
| 4369 |
} |
| 4370 |
|
| 4371 |
function setTextContent (node, text) { |
| 4372 |
node.textContent = text; |
| 4373 |
} |
| 4374 |
|
| 4375 |
function setAttribute (node, key, val) { |
| 4376 |
node.setAttribute(key, val); |
| 4377 |
} |
| 4378 |
|
| 4379 |
|
| 4380 |
var nodeOps = Object.freeze({ |
| 4381 |
createElement: createElement$1, |
| 4382 |
createElementNS: createElementNS, |
| 4383 |
createTextNode: createTextNode, |
| 4384 |
createComment: createComment, |
| 4385 |
insertBefore: insertBefore, |
| 4386 |
removeChild: removeChild, |
| 4387 |
appendChild: appendChild, |
| 4388 |
parentNode: parentNode, |
| 4389 |
nextSibling: nextSibling, |
| 4390 |
tagName: tagName, |
| 4391 |
setTextContent: setTextContent, |
| 4392 |
setAttribute: setAttribute |
| 4393 |
}); |
| 4394 |
|
| 4395 |
/* */ |
| 4396 |
|
| 4397 |
var ref = { |
| 4398 |
create: function create (_, vnode) { |
| 4399 |
registerRef(vnode); |
| 4400 |
}, |
| 4401 |
update: function update (oldVnode, vnode) { |
| 4402 |
if (oldVnode.data.ref !== vnode.data.ref) { |
| 4403 |
registerRef(oldVnode, true); |
| 4404 |
registerRef(vnode); |
| 4405 |
} |
| 4406 |
}, |
| 4407 |
destroy: function destroy (vnode) { |
| 4408 |
registerRef(vnode, true); |
| 4409 |
} |
| 4410 |
}; |
| 4411 |
|
| 4412 |
function registerRef (vnode, isRemoval) { |
| 4413 |
var key = vnode.data.ref; |
| 4414 |
if (!key) { return } |
| 4415 |
|
| 4416 |
var vm = vnode.context; |
| 4417 |
var ref = vnode.componentInstance || vnode.elm; |
| 4418 |
var refs = vm.$refs; |
| 4419 |
if (isRemoval) { |
| 4420 |
if (Array.isArray(refs[key])) { |
| 4421 |
remove(refs[key], ref); |
| 4422 |
} else if (refs[key] === ref) { |
| 4423 |
refs[key] = undefined; |
| 4424 |
} |
| 4425 |
} else { |
| 4426 |
if (vnode.data.refInFor) { |
| 4427 |
if (Array.isArray(refs[key]) && refs[key].indexOf(ref) < 0) { |
| 4428 |
refs[key].push(ref); |
| 4429 |
} else { |
| 4430 |
refs[key] = [ref]; |
| 4431 |
} |
| 4432 |
} else { |
| 4433 |
refs[key] = ref; |
| 4434 |
} |
| 4435 |
} |
| 4436 |
} |
| 4437 |
|
| 4438 |
/** |
| 4439 |
* Virtual DOM patching algorithm based on Snabbdom by |
| 4440 |
* Simon Friis Vindum (@paldepind) |
| 4441 |
* Licensed under the MIT License |
| 4442 |
* https://github.com/paldepind/snabbdom/blob/master/LICENSE |
| 4443 |
* |
| 4444 |
* modified by Evan You (@yyx990803) |
| 4445 |
* |
| 4446 |
|
| 4447 |
/* |
| 4448 |
* Not type-checking this because this file is perf-critical and the cost |
| 4449 |
* of making flow understand it is not worth it. |
| 4450 |
*/ |
| 4451 |
|
| 4452 |
var emptyNode = new VNode('', {}, []); |
| 4453 |
|
| 4454 |
var hooks = ['create', 'activate', 'update', 'remove', 'destroy']; |
| 4455 |
|
| 4456 |
function isUndef (s) { |
| 4457 |
return s == null |
| 4458 |
} |
| 4459 |
|
| 4460 |
function isDef (s) { |
| 4461 |
return s != null |
| 4462 |
} |
| 4463 |
|
| 4464 |
function sameVnode (vnode1, vnode2) { |
| 4465 |
return ( |
| 4466 |
vnode1.key === vnode2.key && |
| 4467 |
vnode1.tag === vnode2.tag && |
| 4468 |
vnode1.isComment === vnode2.isComment && |
| 4469 |
!vnode1.data === !vnode2.data |
| 4470 |
) |
| 4471 |
} |
| 4472 |
|
| 4473 |
function createKeyToOldIdx (children, beginIdx, endIdx) { |
| 4474 |
var i, key; |
| 4475 |
var map = {}; |
| 4476 |
for (i = beginIdx; i <= endIdx; ++i) { |
| 4477 |
key = children[i].key; |
| 4478 |
if (isDef(key)) { map[key] = i; } |
| 4479 |
} |
| 4480 |
return map |
| 4481 |
} |
| 4482 |
|
| 4483 |
function createPatchFunction (backend) { |
| 4484 |
var i, j; |
| 4485 |
var cbs = {}; |
| 4486 |
|
| 4487 |
var modules = backend.modules; |
| 4488 |
var nodeOps = backend.nodeOps; |
| 4489 |
|
| 4490 |
for (i = 0; i < hooks.length; ++i) { |
| 4491 |
cbs[hooks[i]] = []; |
| 4492 |
for (j = 0; j < modules.length; ++j) { |
| 4493 |
if (modules[j][hooks[i]] !== undefined) { cbs[hooks[i]].push(modules[j][hooks[i]]); } |
| 4494 |
} |
| 4495 |
} |
| 4496 |
|
| 4497 |
function emptyNodeAt (elm) { |
| 4498 |
return new VNode(nodeOps.tagName(elm).toLowerCase(), {}, [], undefined, elm) |
| 4499 |
} |
| 4500 |
|
| 4501 |
function createRmCb (childElm, listeners) { |
| 4502 |
function remove$$1 () { |
| 4503 |
if (--remove$$1.listeners === 0) { |
| 4504 |
removeNode(childElm); |
| 4505 |
} |
| 4506 |
} |
| 4507 |
remove$$1.listeners = listeners; |
| 4508 |
return remove$$1 |
| 4509 |
} |
| 4510 |
|
| 4511 |
function removeNode (el) { |
| 4512 |
var parent = nodeOps.parentNode(el); |
| 4513 |
// element may have already been removed due to v-html / v-text |
| 4514 |
if (parent) { |
| 4515 |
nodeOps.removeChild(parent, el); |
| 4516 |
} |
| 4517 |
} |
| 4518 |
|
| 4519 |
var inPre = 0; |
| 4520 |
function createElm (vnode, insertedVnodeQueue, parentElm, refElm, nested) { |
| 4521 |
vnode.isRootInsert = !nested; // for transition enter check |
| 4522 |
if (createComponent(vnode, insertedVnodeQueue, parentElm, refElm)) { |
| 4523 |
return |
| 4524 |
} |
| 4525 |
|
| 4526 |
var data = vnode.data; |
| 4527 |
var children = vnode.children; |
| 4528 |
var tag = vnode.tag; |
| 4529 |
if (isDef(tag)) { |
| 4530 |
{ |
| 4531 |
if (data && data.pre) { |
| 4532 |
inPre++; |
| 4533 |
} |
| 4534 |
if ( |
| 4535 |
!inPre && |
| 4536 |
!vnode.ns && |
| 4537 |
!(config.ignoredElements.length && config.ignoredElements.indexOf(tag) > -1) && |
| 4538 |
config.isUnknownElement(tag) |
| 4539 |
) { |
| 4540 |
warn( |
| 4541 |
'Unknown custom element: <' + tag + '> - did you ' + |
| 4542 |
'register the component correctly? For recursive components, ' + |
| 4543 |
'make sure to provide the "name" option.', |
| 4544 |
vnode.context |
| 4545 |
); |
| 4546 |
} |
| 4547 |
} |
| 4548 |
vnode.elm = vnode.ns |
| 4549 |
? nodeOps.createElementNS(vnode.ns, tag) |
| 4550 |
: nodeOps.createElement(tag, vnode); |
| 4551 |
setScope(vnode); |
| 4552 |
|
| 4553 |
/* istanbul ignore if */ |
| 4554 |
{ |
| 4555 |
createChildren(vnode, children, insertedVnodeQueue); |
| 4556 |
if (isDef(data)) { |
| 4557 |
invokeCreateHooks(vnode, insertedVnodeQueue); |
| 4558 |
} |
| 4559 |
insert(parentElm, vnode.elm, refElm); |
| 4560 |
} |
| 4561 |
|
| 4562 |
if ("development" !== 'production' && data && data.pre) { |
| 4563 |
inPre--; |
| 4564 |
} |
| 4565 |
} else if (vnode.isComment) { |
| 4566 |
vnode.elm = nodeOps.createComment(vnode.text); |
| 4567 |
insert(parentElm, vnode.elm, refElm); |
| 4568 |
} else { |
| 4569 |
vnode.elm = nodeOps.createTextNode(vnode.text); |
| 4570 |
insert(parentElm, vnode.elm, refElm); |
| 4571 |
} |
| 4572 |
} |
| 4573 |
|
| 4574 |
function createComponent (vnode, insertedVnodeQueue, parentElm, refElm) { |
| 4575 |
var i = vnode.data; |
| 4576 |
if (isDef(i)) { |
| 4577 |
var isReactivated = isDef(vnode.componentInstance) && i.keepAlive; |
| 4578 |
if (isDef(i = i.hook) && isDef(i = i.init)) { |
| 4579 |
i(vnode, false /* hydrating */, parentElm, refElm); |
| 4580 |
} |
| 4581 |
// after calling the init hook, if the vnode is a child component |
| 4582 |
// it should've created a child instance and mounted it. the child |
| 4583 |
// component also has set the placeholder vnode's elm. |
| 4584 |
// in that case we can just return the element and be done. |
| 4585 |
if (isDef(vnode.componentInstance)) { |
| 4586 |
initComponent(vnode, insertedVnodeQueue); |
| 4587 |
if (isReactivated) { |
| 4588 |
reactivateComponent(vnode, insertedVnodeQueue, parentElm, refElm); |
| 4589 |
} |
| 4590 |
return true |
| 4591 |
} |
| 4592 |
} |
| 4593 |
} |
| 4594 |
|
| 4595 |
function initComponent (vnode, insertedVnodeQueue) { |
| 4596 |
if (vnode.data.pendingInsert) { |
| 4597 |
insertedVnodeQueue.push.apply(insertedVnodeQueue, vnode.data.pendingInsert); |
| 4598 |
} |
| 4599 |
vnode.elm = vnode.componentInstance.$el; |
| 4600 |
if (isPatchable(vnode)) { |
| 4601 |
invokeCreateHooks(vnode, insertedVnodeQueue); |
| 4602 |
setScope(vnode); |
| 4603 |
} else { |
| 4604 |
// empty component root. |
| 4605 |
// skip all element-related modules except for ref (#3455) |
| 4606 |
registerRef(vnode); |
| 4607 |
// make sure to invoke the insert hook |
| 4608 |
insertedVnodeQueue.push(vnode); |
| 4609 |
} |
| 4610 |
} |
| 4611 |
|
| 4612 |
function reactivateComponent (vnode, insertedVnodeQueue, parentElm, refElm) { |
| 4613 |
var i; |
| 4614 |
// hack for #4339: a reactivated component with inner transition |
| 4615 |
// does not trigger because the inner node's created hooks are not called |
| 4616 |
// again. It's not ideal to involve module-specific logic in here but |
| 4617 |
// there doesn't seem to be a better way to do it. |
| 4618 |
var innerNode = vnode; |
| 4619 |
while (innerNode.componentInstance) { |
| 4620 |
innerNode = innerNode.componentInstance._vnode; |
| 4621 |
if (isDef(i = innerNode.data) && isDef(i = i.transition)) { |
| 4622 |
for (i = 0; i < cbs.activate.length; ++i) { |
| 4623 |
cbs.activate[i](emptyNode, innerNode); |
| 4624 |
} |
| 4625 |
insertedVnodeQueue.push(innerNode); |
| 4626 |
break |
| 4627 |
} |
| 4628 |
} |
| 4629 |
// unlike a newly created component, |
| 4630 |
// a reactivated keep-alive component doesn't insert itself |
| 4631 |
insert(parentElm, vnode.elm, refElm); |
| 4632 |
} |
| 4633 |
|
| 4634 |
function insert (parent, elm, ref) { |
| 4635 |
if (parent) { |
| 4636 |
if (ref) { |
| 4637 |
nodeOps.insertBefore(parent, elm, ref); |
| 4638 |
} else { |
| 4639 |
nodeOps.appendChild(parent, elm); |
| 4640 |
} |
| 4641 |
} |
| 4642 |
} |
| 4643 |
|
| 4644 |
function createChildren (vnode, children, insertedVnodeQueue) { |
| 4645 |
if (Array.isArray(children)) { |
| 4646 |
for (var i = 0; i < children.length; ++i) { |
| 4647 |
createElm(children[i], insertedVnodeQueue, vnode.elm, null, true); |
| 4648 |
} |
| 4649 |
} else if (isPrimitive(vnode.text)) { |
| 4650 |
nodeOps.appendChild(vnode.elm, nodeOps.createTextNode(vnode.text)); |
| 4651 |
} |
| 4652 |
} |
| 4653 |
|
| 4654 |
function isPatchable (vnode) { |
| 4655 |
while (vnode.componentInstance) { |
| 4656 |
vnode = vnode.componentInstance._vnode; |
| 4657 |
} |
| 4658 |
return isDef(vnode.tag) |
| 4659 |
} |
| 4660 |
|
| 4661 |
function invokeCreateHooks (vnode, insertedVnodeQueue) { |
| 4662 |
for (var i$1 = 0; i$1 < cbs.create.length; ++i$1) { |
| 4663 |
cbs.create[i$1](emptyNode, vnode); |
| 4664 |
} |
| 4665 |
i = vnode.data.hook; // Reuse variable |
| 4666 |
if (isDef(i)) { |
| 4667 |
if (i.create) { i.create(emptyNode, vnode); } |
| 4668 |
if (i.insert) { insertedVnodeQueue.push(vnode); } |
| 4669 |
} |
| 4670 |
} |
| 4671 |
|
| 4672 |
// set scope id attribute for scoped CSS. |
| 4673 |
// this is implemented as a special case to avoid the overhead |
| 4674 |
// of going through the normal attribute patching process. |
| 4675 |
function setScope (vnode) { |
| 4676 |
var i; |
| 4677 |
var ancestor = vnode; |
| 4678 |
while (ancestor) { |
| 4679 |
if (isDef(i = ancestor.context) && isDef(i = i.$options._scopeId)) { |
| 4680 |
nodeOps.setAttribute(vnode.elm, i, ''); |
| 4681 |
} |
| 4682 |
ancestor = ancestor.parent; |
| 4683 |
} |
| 4684 |
// for slot content they should also get the scopeId from the host instance. |
| 4685 |
if (isDef(i = activeInstance) && |
| 4686 |
i !== vnode.context && |
| 4687 |
isDef(i = i.$options._scopeId)) { |
| 4688 |
nodeOps.setAttribute(vnode.elm, i, ''); |
| 4689 |
} |
| 4690 |
} |
| 4691 |
|
| 4692 |
function addVnodes (parentElm, refElm, vnodes, startIdx, endIdx, insertedVnodeQueue) { |
| 4693 |
for (; startIdx <= endIdx; ++startIdx) { |
| 4694 |
createElm(vnodes[startIdx], insertedVnodeQueue, parentElm, refElm); |
| 4695 |
} |
| 4696 |
} |
| 4697 |
|
| 4698 |
function invokeDestroyHook (vnode) { |
| 4699 |
var i, j; |
| 4700 |
var data = vnode.data; |
| 4701 |
if (isDef(data)) { |
| 4702 |
if (isDef(i = data.hook) && isDef(i = i.destroy)) { i(vnode); } |
| 4703 |
for (i = 0; i < cbs.destroy.length; ++i) { cbs.destroy[i](vnode); } |
| 4704 |
} |
| 4705 |
if (isDef(i = vnode.children)) { |
| 4706 |
for (j = 0; j < vnode.children.length; ++j) { |
| 4707 |
invokeDestroyHook(vnode.children[j]); |
| 4708 |
} |
| 4709 |
} |
| 4710 |
} |
| 4711 |
|
| 4712 |
function removeVnodes (parentElm, vnodes, startIdx, endIdx) { |
| 4713 |
for (; startIdx <= endIdx; ++startIdx) { |
| 4714 |
var ch = vnodes[startIdx]; |
| 4715 |
if (isDef(ch)) { |
| 4716 |
if (isDef(ch.tag)) { |
| 4717 |
removeAndInvokeRemoveHook(ch); |
| 4718 |
invokeDestroyHook(ch); |
| 4719 |
} else { // Text node |
| 4720 |
removeNode(ch.elm); |
| 4721 |
} |
| 4722 |
} |
| 4723 |
} |
| 4724 |
} |
| 4725 |
|
| 4726 |
function removeAndInvokeRemoveHook (vnode, rm) { |
| 4727 |
if (rm || isDef(vnode.data)) { |
| 4728 |
var listeners = cbs.remove.length + 1; |
| 4729 |
if (!rm) { |
| 4730 |
// directly removing |
| 4731 |
rm = createRmCb(vnode.elm, listeners); |
| 4732 |
} else { |
| 4733 |
// we have a recursively passed down rm callback |
| 4734 |
// increase the listeners count |
| 4735 |
rm.listeners += listeners; |
| 4736 |
} |
| 4737 |
// recursively invoke hooks on child component root node |
| 4738 |
if (isDef(i = vnode.componentInstance) && isDef(i = i._vnode) && isDef(i.data)) { |
| 4739 |
removeAndInvokeRemoveHook(i, rm); |
| 4740 |
} |
| 4741 |
for (i = 0; i < cbs.remove.length; ++i) { |
| 4742 |
cbs.remove[i](vnode, rm); |
| 4743 |
} |
| 4744 |
if (isDef(i = vnode.data.hook) && isDef(i = i.remove)) { |
| 4745 |
i(vnode, rm); |
| 4746 |
} else { |
| 4747 |
rm(); |
| 4748 |
} |
| 4749 |
} else { |
| 4750 |
removeNode(vnode.elm); |
| 4751 |
} |
| 4752 |
} |
| 4753 |
|
| 4754 |
function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { |
| 4755 |
var oldStartIdx = 0; |
| 4756 |
var newStartIdx = 0; |
| 4757 |
var oldEndIdx = oldCh.length - 1; |
| 4758 |
var oldStartVnode = oldCh[0]; |
| 4759 |
var oldEndVnode = oldCh[oldEndIdx]; |
| 4760 |
var newEndIdx = newCh.length - 1; |
| 4761 |
var newStartVnode = newCh[0]; |
| 4762 |
var newEndVnode = newCh[newEndIdx]; |
| 4763 |
var oldKeyToIdx, idxInOld, elmToMove, refElm; |
| 4764 |
|
| 4765 |
// removeOnly is a special flag used only by <transition-group> |
| 4766 |
// to ensure removed elements stay in correct relative positions |
| 4767 |
// during leaving transitions |
| 4768 |
var canMove = !removeOnly; |
| 4769 |
|
| 4770 |
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) { |
| 4771 |
if (isUndef(oldStartVnode)) { |
| 4772 |
oldStartVnode = oldCh[++oldStartIdx]; // Vnode has been moved left |
| 4773 |
} else if (isUndef(oldEndVnode)) { |
| 4774 |
oldEndVnode = oldCh[--oldEndIdx]; |
| 4775 |
} else if (sameVnode(oldStartVnode, newStartVnode)) { |
| 4776 |
patchVnode(oldStartVnode, newStartVnode, insertedVnodeQueue); |
| 4777 |
oldStartVnode = oldCh[++oldStartIdx]; |
| 4778 |
newStartVnode = newCh[++newStartIdx]; |
| 4779 |
} else if (sameVnode(oldEndVnode, newEndVnode)) { |
| 4780 |
patchVnode(oldEndVnode, newEndVnode, insertedVnodeQueue); |
| 4781 |
oldEndVnode = oldCh[--oldEndIdx]; |
| 4782 |
newEndVnode = newCh[--newEndIdx]; |
| 4783 |
} else if (sameVnode(oldStartVnode, newEndVnode)) { // Vnode moved right |
| 4784 |
patchVnode(oldStartVnode, newEndVnode, insertedVnodeQueue); |
| 4785 |
canMove && nodeOps.insertBefore(parentElm, oldStartVnode.elm, nodeOps.nextSibling(oldEndVnode.elm)); |
| 4786 |
oldStartVnode = oldCh[++oldStartIdx]; |
| 4787 |
newEndVnode = newCh[--newEndIdx]; |
| 4788 |
} else if (sameVnode(oldEndVnode, newStartVnode)) { // Vnode moved left |
| 4789 |
patchVnode(oldEndVnode, newStartVnode, insertedVnodeQueue); |
| 4790 |
canMove && nodeOps.insertBefore(parentElm, oldEndVnode.elm, oldStartVnode.elm); |
| 4791 |
oldEndVnode = oldCh[--oldEndIdx]; |
| 4792 |
newStartVnode = newCh[++newStartIdx]; |
| 4793 |
} else { |
| 4794 |
if (isUndef(oldKeyToIdx)) { oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx); } |
| 4795 |
idxInOld = isDef(newStartVnode.key) ? oldKeyToIdx[newStartVnode.key] : null; |
| 4796 |
if (isUndef(idxInOld)) { // New element |
| 4797 |
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); |
| 4798 |
newStartVnode = newCh[++newStartIdx]; |
| 4799 |
} else { |
| 4800 |
elmToMove = oldCh[idxInOld]; |
| 4801 |
/* istanbul ignore if */ |
| 4802 |
if ("development" !== 'production' && !elmToMove) { |
| 4803 |
warn( |
| 4804 |
'It seems there are duplicate keys that is causing an update error. ' + |
| 4805 |
'Make sure each v-for item has a unique key.' |
| 4806 |
); |
| 4807 |
} |
| 4808 |
if (sameVnode(elmToMove, newStartVnode)) { |
| 4809 |
patchVnode(elmToMove, newStartVnode, insertedVnodeQueue); |
| 4810 |
oldCh[idxInOld] = undefined; |
| 4811 |
canMove && nodeOps.insertBefore(parentElm, newStartVnode.elm, oldStartVnode.elm); |
| 4812 |
newStartVnode = newCh[++newStartIdx]; |
| 4813 |
} else { |
| 4814 |
// same key but different element. treat as new element |
| 4815 |
createElm(newStartVnode, insertedVnodeQueue, parentElm, oldStartVnode.elm); |
| 4816 |
newStartVnode = newCh[++newStartIdx]; |
| 4817 |
} |
| 4818 |
} |
| 4819 |
} |
| 4820 |
} |
| 4821 |
if (oldStartIdx > oldEndIdx) { |
| 4822 |
refElm = isUndef(newCh[newEndIdx + 1]) ? null : newCh[newEndIdx + 1].elm; |
| 4823 |
addVnodes(parentElm, refElm, newCh, newStartIdx, newEndIdx, insertedVnodeQueue); |
| 4824 |
} else if (newStartIdx > newEndIdx) { |
| 4825 |
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx); |
| 4826 |
} |
| 4827 |
} |
| 4828 |
|
| 4829 |
function patchVnode (oldVnode, vnode, insertedVnodeQueue, removeOnly) { |
| 4830 |
if (oldVnode === vnode) { |
| 4831 |
return |
| 4832 |
} |
| 4833 |
// reuse element for static trees. |
| 4834 |
// note we only do this if the vnode is cloned - |
| 4835 |
// if the new node is not cloned it means the render functions have been |
| 4836 |
// reset by the hot-reload-api and we need to do a proper re-render. |
| 4837 |
if (vnode.isStatic && |
| 4838 |
oldVnode.isStatic && |
| 4839 |
vnode.key === oldVnode.key && |
| 4840 |
(vnode.isCloned || vnode.isOnce)) { |
| 4841 |
vnode.elm = oldVnode.elm; |
| 4842 |
vnode.componentInstance = oldVnode.componentInstance; |
| 4843 |
return |
| 4844 |
} |
| 4845 |
var i; |
| 4846 |
var data = vnode.data; |
| 4847 |
var hasData = isDef(data); |
| 4848 |
if (hasData && isDef(i = data.hook) && isDef(i = i.prepatch)) { |
| 4849 |
i(oldVnode, vnode); |
| 4850 |
} |
| 4851 |
var elm = vnode.elm = oldVnode.elm; |
| 4852 |
var oldCh = oldVnode.children; |
| 4853 |
var ch = vnode.children; |
| 4854 |
if (hasData && isPatchable(vnode)) { |
| 4855 |
for (i = 0; i < cbs.update.length; ++i) { cbs.update[i](oldVnode, vnode); } |
| 4856 |
if (isDef(i = data.hook) && isDef(i = i.update)) { i(oldVnode, vnode); } |
| 4857 |
} |
| 4858 |
if (isUndef(vnode.text)) { |
| 4859 |
if (isDef(oldCh) && isDef(ch)) { |
| 4860 |
if (oldCh !== ch) { updateChildren(elm, oldCh, ch, insertedVnodeQueue, removeOnly); } |
| 4861 |
} else if (isDef(ch)) { |
| 4862 |
if (isDef(oldVnode.text)) { nodeOps.setTextContent(elm, ''); } |
| 4863 |
addVnodes(elm, null, ch, 0, ch.length - 1, insertedVnodeQueue); |
| 4864 |
} else if (isDef(oldCh)) { |
| 4865 |
removeVnodes(elm, oldCh, 0, oldCh.length - 1); |
| 4866 |
} else if (isDef(oldVnode.text)) { |
| 4867 |
nodeOps.setTextContent(elm, ''); |
| 4868 |
} |
| 4869 |
} else if (oldVnode.text !== vnode.text) { |
| 4870 |
nodeOps.setTextContent(elm, vnode.text); |
| 4871 |
} |
| 4872 |
if (hasData) { |
| 4873 |
if (isDef(i = data.hook) && isDef(i = i.postpatch)) { i(oldVnode, vnode); } |
| 4874 |
} |
| 4875 |
} |
| 4876 |
|
| 4877 |
function invokeInsertHook (vnode, queue, initial) { |
| 4878 |
// delay insert hooks for component root nodes, invoke them after the |
| 4879 |
// element is really inserted |
| 4880 |
if (initial && vnode.parent) { |
| 4881 |
vnode.parent.data.pendingInsert = queue; |
| 4882 |
} else { |
| 4883 |
for (var i = 0; i < queue.length; ++i) { |
| 4884 |
queue[i].data.hook.insert(queue[i]); |
| 4885 |
} |
| 4886 |
} |
| 4887 |
} |
| 4888 |
|
| 4889 |
var bailed = false; |
| 4890 |
// list of modules that can skip create hook during hydration because they |
| 4891 |
// are already rendered on the client or has no need for initialization |
| 4892 |
var isRenderedModule = makeMap('attrs,style,class,staticClass,staticStyle,key'); |
| 4893 |
|
| 4894 |
// Note: this is a browser-only function so we can assume elms are DOM nodes. |
| 4895 |
function hydrate (elm, vnode, insertedVnodeQueue) { |
| 4896 |
{ |
| 4897 |
if (!assertNodeMatch(elm, vnode)) { |
| 4898 |
return false |
| 4899 |
} |
| 4900 |
} |
| 4901 |
vnode.elm = elm; |
| 4902 |
var tag = vnode.tag; |
| 4903 |
var data = vnode.data; |
| 4904 |
var children = vnode.children; |
| 4905 |
if (isDef(data)) { |
| 4906 |
if (isDef(i = data.hook) && isDef(i = i.init)) { i(vnode, true /* hydrating */); } |
| 4907 |
if (isDef(i = vnode.componentInstance)) { |
| 4908 |
// child component. it should have hydrated its own tree. |
| 4909 |
initComponent(vnode, insertedVnodeQueue); |
| 4910 |
return true |
| 4911 |
} |
| 4912 |
} |
| 4913 |
if (isDef(tag)) { |
| 4914 |
if (isDef(children)) { |
| 4915 |
// empty element, allow client to pick up and populate children |
| 4916 |
if (!elm.hasChildNodes()) { |
| 4917 |
createChildren(vnode, children, insertedVnodeQueue); |
| 4918 |
} else { |
| 4919 |
var childrenMatch = true; |
| 4920 |
var childNode = elm.firstChild; |
| 4921 |
for (var i$1 = 0; i$1 < children.length; i$1++) { |
| 4922 |
if (!childNode || !hydrate(childNode, children[i$1], insertedVnodeQueue)) { |
| 4923 |
childrenMatch = false; |
| 4924 |
break |
| 4925 |
} |
| 4926 |
childNode = childNode.nextSibling; |
| 4927 |
} |
| 4928 |
// if childNode is not null, it means the actual childNodes list is |
| 4929 |
// longer than the virtual children list. |
| 4930 |
if (!childrenMatch || childNode) { |
| 4931 |
if ("development" !== 'production' && |
| 4932 |
typeof console !== 'undefined' && |
| 4933 |
!bailed) { |
| 4934 |
bailed = true; |
| 4935 |
console.warn('Parent: ', elm); |
| 4936 |
console.warn('Mismatching childNodes vs. VNodes: ', elm.childNodes, children); |
| 4937 |
} |
| 4938 |
return false |
| 4939 |
} |
| 4940 |
} |
| 4941 |
} |
| 4942 |
if (isDef(data)) { |
| 4943 |
for (var key in data) { |
| 4944 |
if (!isRenderedModule(key)) { |
| 4945 |
invokeCreateHooks(vnode, insertedVnodeQueue); |
| 4946 |
break |
| 4947 |
} |
| 4948 |
} |
| 4949 |
} |
| 4950 |
} else if (elm.data !== vnode.text) { |
| 4951 |
elm.data = vnode.text; |
| 4952 |
} |
| 4953 |
return true |
| 4954 |
} |
| 4955 |
|
| 4956 |
function assertNodeMatch (node, vnode) { |
| 4957 |
if (vnode.tag) { |
| 4958 |
return ( |
| 4959 |
vnode.tag.indexOf('vue-component') === 0 || |
| 4960 |
vnode.tag.toLowerCase() === (node.tagName && node.tagName.toLowerCase()) |
| 4961 |
) |
| 4962 |
} else { |
| 4963 |
return node.nodeType === (vnode.isComment ? 8 : 3) |
| 4964 |
} |
| 4965 |
} |
| 4966 |
|
| 4967 |
return function patch (oldVnode, vnode, hydrating, removeOnly, parentElm, refElm) { |
| 4968 |
if (!vnode) { |
| 4969 |
if (oldVnode) { invokeDestroyHook(oldVnode); } |
| 4970 |
return |
| 4971 |
} |
| 4972 |
|
| 4973 |
var isInitialPatch = false; |
| 4974 |
var insertedVnodeQueue = []; |
| 4975 |
|
| 4976 |
if (!oldVnode) { |
| 4977 |
// empty mount (likely as component), create new root element |
| 4978 |
isInitialPatch = true; |
| 4979 |
createElm(vnode, insertedVnodeQueue, parentElm, refElm); |
| 4980 |
} else { |
| 4981 |
var isRealElement = isDef(oldVnode.nodeType); |
| 4982 |
if (!isRealElement && sameVnode(oldVnode, vnode)) { |
| 4983 |
// patch existing root node |
| 4984 |
patchVnode(oldVnode, vnode, insertedVnodeQueue, removeOnly); |
| 4985 |
} else { |
| 4986 |
if (isRealElement) { |
| 4987 |
// mounting to a real element |
| 4988 |
// check if this is server-rendered content and if we can perform |
| 4989 |
// a successful hydration. |
| 4990 |
if (oldVnode.nodeType === 1 && oldVnode.hasAttribute('server-rendered')) { |
| 4991 |
oldVnode.removeAttribute('server-rendered'); |
| 4992 |
hydrating = true; |
| 4993 |
} |
| 4994 |
if (hydrating) { |
| 4995 |
if (hydrate(oldVnode, vnode, insertedVnodeQueue)) { |
| 4996 |
invokeInsertHook(vnode, insertedVnodeQueue, true); |
| 4997 |
return oldVnode |
| 4998 |
} else { |
| 4999 |
warn( |
| 5000 |
'The client-side rendered virtual DOM tree is not matching ' + |
| 5001 |
'server-rendered content. This is likely caused by incorrect ' + |
| 5002 |
'HTML markup, for example nesting block-level elements inside ' + |
| 5003 |
'<p>, or missing <tbody>. Bailing hydration and performing ' + |
| 5004 |
'full client-side render.' |
| 5005 |
); |
| 5006 |
} |
| 5007 |
} |
| 5008 |
// either not server-rendered, or hydration failed. |
| 5009 |
// create an empty node and replace it |
| 5010 |
oldVnode = emptyNodeAt(oldVnode); |
| 5011 |
} |
| 5012 |
// replacing existing element |
| 5013 |
var oldElm = oldVnode.elm; |
| 5014 |
var parentElm$1 = nodeOps.parentNode(oldElm); |
| 5015 |
createElm( |
| 5016 |
vnode, |
| 5017 |
insertedVnodeQueue, |
| 5018 |
// extremely rare edge case: do not insert if old element is in a |
| 5019 |
// leaving transition. Only happens when combining transition + |
| 5020 |
// keep-alive + HOCs. (#4590) |
| 5021 |
oldElm._leaveCb ? null : parentElm$1, |
| 5022 |
nodeOps.nextSibling(oldElm) |
| 5023 |
); |
| 5024 |
|
| 5025 |
if (vnode.parent) { |
| 5026 |
// component root element replaced. |
| 5027 |
// update parent placeholder node element, recursively |
| 5028 |
var ancestor = vnode.parent; |
| 5029 |
while (ancestor) { |
| 5030 |
ancestor.elm = vnode.elm; |
| 5031 |
ancestor = ancestor.parent; |
| 5032 |
} |
| 5033 |
if (isPatchable(vnode)) { |
| 5034 |
for (var i = 0; i < cbs.create.length; ++i) { |
| 5035 |
cbs.create[i](emptyNode, vnode.parent); |
| 5036 |
} |
| 5037 |
} |
| 5038 |
} |
| 5039 |
|
| 5040 |
if (parentElm$1 !== null) { |
| 5041 |
removeVnodes(parentElm$1, [oldVnode], 0, 0); |
| 5042 |
} else if (isDef(oldVnode.tag)) { |
| 5043 |
invokeDestroyHook(oldVnode); |
| 5044 |
} |
| 5045 |
} |
| 5046 |
} |
| 5047 |
|
| 5048 |
invokeInsertHook(vnode, insertedVnodeQueue, isInitialPatch); |
| 5049 |
return vnode.elm |
| 5050 |
} |
| 5051 |
} |
| 5052 |
|
| 5053 |
/* */ |
| 5054 |
|
| 5055 |
var directives = { |
| 5056 |
create: updateDirectives, |
| 5057 |
update: updateDirectives, |
| 5058 |
destroy: function unbindDirectives (vnode) { |
| 5059 |
updateDirectives(vnode, emptyNode); |
| 5060 |
} |
| 5061 |
}; |
| 5062 |
|
| 5063 |
function updateDirectives (oldVnode, vnode) { |
| 5064 |
if (oldVnode.data.directives || vnode.data.directives) { |
| 5065 |
_update(oldVnode, vnode); |
| 5066 |
} |
| 5067 |
} |
| 5068 |
|
| 5069 |
function _update (oldVnode, vnode) { |
| 5070 |
var isCreate = oldVnode === emptyNode; |
| 5071 |
var isDestroy = vnode === emptyNode; |
| 5072 |
var oldDirs = normalizeDirectives$1(oldVnode.data.directives, oldVnode.context); |
| 5073 |
var newDirs = normalizeDirectives$1(vnode.data.directives, vnode.context); |
| 5074 |
|
| 5075 |
var dirsWithInsert = []; |
| 5076 |
var dirsWithPostpatch = []; |
| 5077 |
|
| 5078 |
var key, oldDir, dir; |
| 5079 |
for (key in newDirs) { |
| 5080 |
oldDir = oldDirs[key]; |
| 5081 |
dir = newDirs[key]; |
| 5082 |
if (!oldDir) { |
| 5083 |
// new directive, bind |
| 5084 |
callHook$1(dir, 'bind', vnode, oldVnode); |
| 5085 |
if (dir.def && dir.def.inserted) { |
| 5086 |
dirsWithInsert.push(dir); |
| 5087 |
} |
| 5088 |
} else { |
| 5089 |
// existing directive, update |
| 5090 |
dir.oldValue = oldDir.value; |
| 5091 |
callHook$1(dir, 'update', vnode, oldVnode); |
| 5092 |
if (dir.def && dir.def.componentUpdated) { |
| 5093 |
dirsWithPostpatch.push(dir); |
| 5094 |
} |
| 5095 |
} |
| 5096 |
} |
| 5097 |
|
| 5098 |
if (dirsWithInsert.length) { |
| 5099 |
var callInsert = function () { |
| 5100 |
for (var i = 0; i < dirsWithInsert.length; i++) { |
| 5101 |
callHook$1(dirsWithInsert[i], 'inserted', vnode, oldVnode); |
| 5102 |
} |
| 5103 |
}; |
| 5104 |
if (isCreate) { |
| 5105 |
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', callInsert); |
| 5106 |
} else { |
| 5107 |
callInsert(); |
| 5108 |
} |
| 5109 |
} |
| 5110 |
|
| 5111 |
if (dirsWithPostpatch.length) { |
| 5112 |
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'postpatch', function () { |
| 5113 |
for (var i = 0; i < dirsWithPostpatch.length; i++) { |
| 5114 |
callHook$1(dirsWithPostpatch[i], 'componentUpdated', vnode, oldVnode); |
| 5115 |
} |
| 5116 |
}); |
| 5117 |
} |
| 5118 |
|
| 5119 |
if (!isCreate) { |
| 5120 |
for (key in oldDirs) { |
| 5121 |
if (!newDirs[key]) { |
| 5122 |
// no longer present, unbind |
| 5123 |
callHook$1(oldDirs[key], 'unbind', oldVnode, oldVnode, isDestroy); |
| 5124 |
} |
| 5125 |
} |
| 5126 |
} |
| 5127 |
} |
| 5128 |
|
| 5129 |
var emptyModifiers = Object.create(null); |
| 5130 |
|
| 5131 |
function normalizeDirectives$1 ( |
| 5132 |
dirs, |
| 5133 |
vm |
| 5134 |
) { |
| 5135 |
var res = Object.create(null); |
| 5136 |
if (!dirs) { |
| 5137 |
return res |
| 5138 |
} |
| 5139 |
var i, dir; |
| 5140 |
for (i = 0; i < dirs.length; i++) { |
| 5141 |
dir = dirs[i]; |
| 5142 |
if (!dir.modifiers) { |
| 5143 |
dir.modifiers = emptyModifiers; |
| 5144 |
} |
| 5145 |
res[getRawDirName(dir)] = dir; |
| 5146 |
dir.def = resolveAsset(vm.$options, 'directives', dir.name, true); |
| 5147 |
} |
| 5148 |
return res |
| 5149 |
} |
| 5150 |
|
| 5151 |
function getRawDirName (dir) { |
| 5152 |
return dir.rawName || ((dir.name) + "." + (Object.keys(dir.modifiers || {}).join('.'))) |
| 5153 |
} |
| 5154 |
|
| 5155 |
function callHook$1 (dir, hook, vnode, oldVnode, isDestroy) { |
| 5156 |
var fn = dir.def && dir.def[hook]; |
| 5157 |
if (fn) { |
| 5158 |
fn(vnode.elm, dir, vnode, oldVnode, isDestroy); |
| 5159 |
} |
| 5160 |
} |
| 5161 |
|
| 5162 |
var baseModules = [ |
| 5163 |
ref, |
| 5164 |
directives |
| 5165 |
]; |
| 5166 |
|
| 5167 |
/* */ |
| 5168 |
|
| 5169 |
function updateAttrs (oldVnode, vnode) { |
| 5170 |
if (!oldVnode.data.attrs && !vnode.data.attrs) { |
| 5171 |
return |
| 5172 |
} |
| 5173 |
var key, cur, old; |
| 5174 |
var elm = vnode.elm; |
| 5175 |
var oldAttrs = oldVnode.data.attrs || {}; |
| 5176 |
var attrs = vnode.data.attrs || {}; |
| 5177 |
// clone observed objects, as the user probably wants to mutate it |
| 5178 |
if (attrs.__ob__) { |
| 5179 |
attrs = vnode.data.attrs = extend({}, attrs); |
| 5180 |
} |
| 5181 |
|
| 5182 |
for (key in attrs) { |
| 5183 |
cur = attrs[key]; |
| 5184 |
old = oldAttrs[key]; |
| 5185 |
if (old !== cur) { |
| 5186 |
setAttr(elm, key, cur); |
| 5187 |
} |
| 5188 |
} |
| 5189 |
// #4391: in IE9, setting type can reset value for input[type=radio] |
| 5190 |
/* istanbul ignore if */ |
| 5191 |
if (isIE9 && attrs.value !== oldAttrs.value) { |
| 5192 |
setAttr(elm, 'value', attrs.value); |
| 5193 |
} |
| 5194 |
for (key in oldAttrs) { |
| 5195 |
if (attrs[key] == null) { |
| 5196 |
if (isXlink(key)) { |
| 5197 |
elm.removeAttributeNS(xlinkNS, getXlinkProp(key)); |
| 5198 |
} else if (!isEnumeratedAttr(key)) { |
| 5199 |
elm.removeAttribute(key); |
| 5200 |
} |
| 5201 |
} |
| 5202 |
} |
| 5203 |
} |
| 5204 |
|
| 5205 |
function setAttr (el, key, value) { |
| 5206 |
if (isBooleanAttr(key)) { |
| 5207 |
// set attribute for blank value |
| 5208 |
// e.g. <option disabled>Select one</option> |
| 5209 |
if (isFalsyAttrValue(value)) { |
| 5210 |
el.removeAttribute(key); |
| 5211 |
} else { |
| 5212 |
el.setAttribute(key, key); |
| 5213 |
} |
| 5214 |
} else if (isEnumeratedAttr(key)) { |
| 5215 |
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'); |
| 5216 |
} else if (isXlink(key)) { |
| 5217 |
if (isFalsyAttrValue(value)) { |
| 5218 |
el.removeAttributeNS(xlinkNS, getXlinkProp(key)); |
| 5219 |
} else { |
| 5220 |
el.setAttributeNS(xlinkNS, key, value); |
| 5221 |
} |
| 5222 |
} else { |
| 5223 |
if (isFalsyAttrValue(value)) { |
| 5224 |
el.removeAttribute(key); |
| 5225 |
} else { |
| 5226 |
el.setAttribute(key, value); |
| 5227 |
} |
| 5228 |
} |
| 5229 |
} |
| 5230 |
|
| 5231 |
var attrs = { |
| 5232 |
create: updateAttrs, |
| 5233 |
update: updateAttrs |
| 5234 |
}; |
| 5235 |
|
| 5236 |
/* */ |
| 5237 |
|
| 5238 |
function updateClass (oldVnode, vnode) { |
| 5239 |
var el = vnode.elm; |
| 5240 |
var data = vnode.data; |
| 5241 |
var oldData = oldVnode.data; |
| 5242 |
if (!data.staticClass && !data.class && |
| 5243 |
(!oldData || (!oldData.staticClass && !oldData.class))) { |
| 5244 |
return |
| 5245 |
} |
| 5246 |
|
| 5247 |
var cls = genClassForVnode(vnode); |
| 5248 |
|
| 5249 |
// handle transition classes |
| 5250 |
var transitionClass = el._transitionClasses; |
| 5251 |
if (transitionClass) { |
| 5252 |
cls = concat(cls, stringifyClass(transitionClass)); |
| 5253 |
} |
| 5254 |
|
| 5255 |
// set the class |
| 5256 |
if (cls !== el._prevClass) { |
| 5257 |
el.setAttribute('class', cls); |
| 5258 |
el._prevClass = cls; |
| 5259 |
} |
| 5260 |
} |
| 5261 |
|
| 5262 |
var klass = { |
| 5263 |
create: updateClass, |
| 5264 |
update: updateClass |
| 5265 |
}; |
| 5266 |
|
| 5267 |
/* */ |
| 5268 |
|
| 5269 |
var validDivisionCharRE = /[\w).+\-_$\]]/; |
| 5270 |
|
| 5271 |
function parseFilters (exp) { |
| 5272 |
var inSingle = false; |
| 5273 |
var inDouble = false; |
| 5274 |
var inTemplateString = false; |
| 5275 |
var inRegex = false; |
| 5276 |
var curly = 0; |
| 5277 |
var square = 0; |
| 5278 |
var paren = 0; |
| 5279 |
var lastFilterIndex = 0; |
| 5280 |
var c, prev, i, expression, filters; |
| 5281 |
|
| 5282 |
for (i = 0; i < exp.length; i++) { |
| 5283 |
prev = c; |
| 5284 |
c = exp.charCodeAt(i); |
| 5285 |
if (inSingle) { |
| 5286 |
if (c === 0x27 && prev !== 0x5C) { inSingle = false; } |
| 5287 |
} else if (inDouble) { |
| 5288 |
if (c === 0x22 && prev !== 0x5C) { inDouble = false; } |
| 5289 |
} else if (inTemplateString) { |
| 5290 |
if (c === 0x60 && prev !== 0x5C) { inTemplateString = false; } |
| 5291 |
} else if (inRegex) { |
| 5292 |
if (c === 0x2f && prev !== 0x5C) { inRegex = false; } |
| 5293 |
} else if ( |
| 5294 |
c === 0x7C && // pipe |
| 5295 |
exp.charCodeAt(i + 1) !== 0x7C && |
| 5296 |
exp.charCodeAt(i - 1) !== 0x7C && |
| 5297 |
!curly && !square && !paren |
| 5298 |
) { |
| 5299 |
if (expression === undefined) { |
| 5300 |
// first filter, end of expression |
| 5301 |
lastFilterIndex = i + 1; |
| 5302 |
expression = exp.slice(0, i).trim(); |
| 5303 |
} else { |
| 5304 |
pushFilter(); |
| 5305 |
} |
| 5306 |
} else { |
| 5307 |
switch (c) { |
| 5308 |
case 0x22: inDouble = true; break // " |
| 5309 |
case 0x27: inSingle = true; break // ' |
| 5310 |
case 0x60: inTemplateString = true; break // ` |
| 5311 |
case 0x28: paren++; break // ( |
| 5312 |
case 0x29: paren--; break // ) |
| 5313 |
case 0x5B: square++; break // [ |
| 5314 |
case 0x5D: square--; break // ] |
| 5315 |
case 0x7B: curly++; break // { |
| 5316 |
case 0x7D: curly--; break // } |
| 5317 |
} |
| 5318 |
if (c === 0x2f) { // / |
| 5319 |
var j = i - 1; |
| 5320 |
var p = (void 0); |
| 5321 |
// find first non-whitespace prev char |
| 5322 |
for (; j >= 0; j--) { |
| 5323 |
p = exp.charAt(j); |
| 5324 |
if (p !== ' ') { break } |
| 5325 |
} |
| 5326 |
if (!p || !validDivisionCharRE.test(p)) { |
| 5327 |
inRegex = true; |
| 5328 |
} |
| 5329 |
} |
| 5330 |
} |
| 5331 |
} |
| 5332 |
|
| 5333 |
if (expression === undefined) { |
| 5334 |
expression = exp.slice(0, i).trim(); |
| 5335 |
} else if (lastFilterIndex !== 0) { |
| 5336 |
pushFilter(); |
| 5337 |
} |
| 5338 |
|
| 5339 |
function pushFilter () { |
| 5340 |
(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()); |
| 5341 |
lastFilterIndex = i + 1; |
| 5342 |
} |
| 5343 |
|
| 5344 |
if (filters) { |
| 5345 |
for (i = 0; i < filters.length; i++) { |
| 5346 |
expression = wrapFilter(expression, filters[i]); |
| 5347 |
} |
| 5348 |
} |
| 5349 |
|
| 5350 |
return expression |
| 5351 |
} |
| 5352 |
|
| 5353 |
function wrapFilter (exp, filter) { |
| 5354 |
var i = filter.indexOf('('); |
| 5355 |
if (i < 0) { |
| 5356 |
// _f: resolveFilter |
| 5357 |
return ("_f(\"" + filter + "\")(" + exp + ")") |
| 5358 |
} else { |
| 5359 |
var name = filter.slice(0, i); |
| 5360 |
var args = filter.slice(i + 1); |
| 5361 |
return ("_f(\"" + name + "\")(" + exp + "," + args) |
| 5362 |
} |
| 5363 |
} |
| 5364 |
|
| 5365 |
/* */ |
| 5366 |
|
| 5367 |
function baseWarn (msg) { |
| 5368 |
console.error(("[Vue compiler]: " + msg)); |
| 5369 |
} |
| 5370 |
|
| 5371 |
function pluckModuleFunction ( |
| 5372 |
modules, |
| 5373 |
key |
| 5374 |
) { |
| 5375 |
return modules |
| 5376 |
? modules.map(function (m) { return m[key]; }).filter(function (_) { return _; }) |
| 5377 |
: [] |
| 5378 |
} |
| 5379 |
|
| 5380 |
function addProp (el, name, value) { |
| 5381 |
(el.props || (el.props = [])).push({ name: name, value: value }); |
| 5382 |
} |
| 5383 |
|
| 5384 |
function addAttr (el, name, value) { |
| 5385 |
(el.attrs || (el.attrs = [])).push({ name: name, value: value }); |
| 5386 |
} |
| 5387 |
|
| 5388 |
function addDirective ( |
| 5389 |
el, |
| 5390 |
name, |
| 5391 |
rawName, |
| 5392 |
value, |
| 5393 |
arg, |
| 5394 |
modifiers |
| 5395 |
) { |
| 5396 |
(el.directives || (el.directives = [])).push({ name: name, rawName: rawName, value: value, arg: arg, modifiers: modifiers }); |
| 5397 |
} |
| 5398 |
|
| 5399 |
function addHandler ( |
| 5400 |
el, |
| 5401 |
name, |
| 5402 |
value, |
| 5403 |
modifiers, |
| 5404 |
important |
| 5405 |
) { |
| 5406 |
// check capture modifier |
| 5407 |
if (modifiers && modifiers.capture) { |
| 5408 |
delete modifiers.capture; |
| 5409 |
name = '!' + name; // mark the event as captured |
| 5410 |
} |
| 5411 |
if (modifiers && modifiers.once) { |
| 5412 |
delete modifiers.once; |
| 5413 |
name = '~' + name; // mark the event as once |
| 5414 |
} |
| 5415 |
var events; |
| 5416 |
if (modifiers && modifiers.native) { |
| 5417 |
delete modifiers.native; |
| 5418 |
events = el.nativeEvents || (el.nativeEvents = {}); |
| 5419 |
} else { |
| 5420 |
events = el.events || (el.events = {}); |
| 5421 |
} |
| 5422 |
var newHandler = { value: value, modifiers: modifiers }; |
| 5423 |
var handlers = events[name]; |
| 5424 |
/* istanbul ignore if */ |
| 5425 |
if (Array.isArray(handlers)) { |
| 5426 |
important ? handlers.unshift(newHandler) : handlers.push(newHandler); |
| 5427 |
} else if (handlers) { |
| 5428 |
events[name] = important ? [newHandler, handlers] : [handlers, newHandler]; |
| 5429 |
} else { |
| 5430 |
events[name] = newHandler; |
| 5431 |
} |
| 5432 |
} |
| 5433 |
|
| 5434 |
function getBindingAttr ( |
| 5435 |
el, |
| 5436 |
name, |
| 5437 |
getStatic |
| 5438 |
) { |
| 5439 |
var dynamicValue = |
| 5440 |
getAndRemoveAttr(el, ':' + name) || |
| 5441 |
getAndRemoveAttr(el, 'v-bind:' + name); |
| 5442 |
if (dynamicValue != null) { |
| 5443 |
return parseFilters(dynamicValue) |
| 5444 |
} else if (getStatic !== false) { |
| 5445 |
var staticValue = getAndRemoveAttr(el, name); |
| 5446 |
if (staticValue != null) { |
| 5447 |
return JSON.stringify(staticValue) |
| 5448 |
} |
| 5449 |
} |
| 5450 |
} |
| 5451 |
|
| 5452 |
function getAndRemoveAttr (el, name) { |
| 5453 |
var val; |
| 5454 |
if ((val = el.attrsMap[name]) != null) { |
| 5455 |
var list = el.attrsList; |
| 5456 |
for (var i = 0, l = list.length; i < l; i++) { |
| 5457 |
if (list[i].name === name) { |
| 5458 |
list.splice(i, 1); |
| 5459 |
break |
| 5460 |
} |
| 5461 |
} |
| 5462 |
} |
| 5463 |
return val |
| 5464 |
} |
| 5465 |
|
| 5466 |
/* */ |
| 5467 |
|
| 5468 |
/** |
| 5469 |
* Cross-platform code generation for component v-model |
| 5470 |
*/ |
| 5471 |
function genComponentModel ( |
| 5472 |
el, |
| 5473 |
value, |
| 5474 |
modifiers |
| 5475 |
) { |
| 5476 |
var ref = modifiers || {}; |
| 5477 |
var number = ref.number; |
| 5478 |
var trim = ref.trim; |
| 5479 |
|
| 5480 |
var baseValueExpression = '$$v'; |
| 5481 |
var valueExpression = baseValueExpression; |
| 5482 |
if (trim) { |
| 5483 |
valueExpression = |
| 5484 |
"(typeof " + baseValueExpression + " === 'string'" + |
| 5485 |
"? " + baseValueExpression + ".trim()" + |
| 5486 |
": " + baseValueExpression + ")"; |
| 5487 |
} |
| 5488 |
if (number) { |
| 5489 |
valueExpression = "_n(" + valueExpression + ")"; |
| 5490 |
} |
| 5491 |
var assignment = genAssignmentCode(value, valueExpression); |
| 5492 |
|
| 5493 |
el.model = { |
| 5494 |
value: ("(" + value + ")"), |
| 5495 |
expression: ("\"" + value + "\""), |
| 5496 |
callback: ("function (" + baseValueExpression + ") {" + assignment + "}") |
| 5497 |
}; |
| 5498 |
} |
| 5499 |
|
| 5500 |
/** |
| 5501 |
* Cross-platform codegen helper for generating v-model value assignment code. |
| 5502 |
*/ |
| 5503 |
function genAssignmentCode ( |
| 5504 |
value, |
| 5505 |
assignment |
| 5506 |
) { |
| 5507 |
var modelRs = parseModel(value); |
| 5508 |
if (modelRs.idx === null) { |
| 5509 |
return (value + "=" + assignment) |
| 5510 |
} else { |
| 5511 |
return "var $$exp = " + (modelRs.exp) + ", $$idx = " + (modelRs.idx) + ";" + |
| 5512 |
"if (!Array.isArray($$exp)){" + |
| 5513 |
value + "=" + assignment + "}" + |
| 5514 |
"else{$$exp.splice($$idx, 1, " + assignment + ")}" |
| 5515 |
} |
| 5516 |
} |
| 5517 |
|
| 5518 |
/** |
| 5519 |
* parse directive model to do the array update transform. a[idx] = val => $$a.splice($$idx, 1, val) |
| 5520 |
* |
| 5521 |
* for loop possible cases: |
| 5522 |
* |
| 5523 |
* - test |
| 5524 |
* - test[idx] |
| 5525 |
* - test[test1[idx]] |
| 5526 |
* - test["a"][idx] |
| 5527 |
* - xxx.test[a[a].test1[idx]] |
| 5528 |
* - test.xxx.a["asa"][test1[idx]] |
| 5529 |
* |
| 5530 |
*/ |
| 5531 |
|
| 5532 |
var len; |
| 5533 |
var str; |
| 5534 |
var chr; |
| 5535 |
var index$1; |
| 5536 |
var expressionPos; |
| 5537 |
var expressionEndPos; |
| 5538 |
|
| 5539 |
function parseModel (val) { |
| 5540 |
str = val; |
| 5541 |
len = str.length; |
| 5542 |
index$1 = expressionPos = expressionEndPos = 0; |
| 5543 |
|
| 5544 |
if (val.indexOf('[') < 0 || val.lastIndexOf(']') < len - 1) { |
| 5545 |
return { |
| 5546 |
exp: val, |
| 5547 |
idx: null |
| 5548 |
} |
| 5549 |
} |
| 5550 |
|
| 5551 |
while (!eof()) { |
| 5552 |
chr = next(); |
| 5553 |
/* istanbul ignore if */ |
| 5554 |
if (isStringStart(chr)) { |
| 5555 |
parseString(chr); |
| 5556 |
} else if (chr === 0x5B) { |
| 5557 |
parseBracket(chr); |
| 5558 |
} |
| 5559 |
} |
| 5560 |
|
| 5561 |
return { |
| 5562 |
exp: val.substring(0, expressionPos), |
| 5563 |
idx: val.substring(expressionPos + 1, expressionEndPos) |
| 5564 |
} |
| 5565 |
} |
| 5566 |
|
| 5567 |
function next () { |
| 5568 |
return str.charCodeAt(++index$1) |
| 5569 |
} |
| 5570 |
|
| 5571 |
function eof () { |
| 5572 |
return index$1 >= len |
| 5573 |
} |
| 5574 |
|
| 5575 |
function isStringStart (chr) { |
| 5576 |
return chr === 0x22 || chr === 0x27 |
| 5577 |
} |
| 5578 |
|
| 5579 |
function parseBracket (chr) { |
| 5580 |
var inBracket = 1; |
| 5581 |
expressionPos = index$1; |
| 5582 |
while (!eof()) { |
| 5583 |
chr = next(); |
| 5584 |
if (isStringStart(chr)) { |
| 5585 |
parseString(chr); |
| 5586 |
continue |
| 5587 |
} |
| 5588 |
if (chr === 0x5B) { inBracket++; } |
| 5589 |
if (chr === 0x5D) { inBracket--; } |
| 5590 |
if (inBracket === 0) { |
| 5591 |
expressionEndPos = index$1; |
| 5592 |
break |
| 5593 |
} |
| 5594 |
} |
| 5595 |
} |
| 5596 |
|
| 5597 |
function parseString (chr) { |
| 5598 |
var stringQuote = chr; |
| 5599 |
while (!eof()) { |
| 5600 |
chr = next(); |
| 5601 |
if (chr === stringQuote) { |
| 5602 |
break |
| 5603 |
} |
| 5604 |
} |
| 5605 |
} |
| 5606 |
|
| 5607 |
/* */ |
| 5608 |
|
| 5609 |
var warn$1; |
| 5610 |
|
| 5611 |
// in some cases, the event used has to be determined at runtime |
| 5612 |
// so we used some reserved tokens during compile. |
| 5613 |
var RANGE_TOKEN = '__r'; |
| 5614 |
var CHECKBOX_RADIO_TOKEN = '__c'; |
| 5615 |
|
| 5616 |
function model ( |
| 5617 |
el, |
| 5618 |
dir, |
| 5619 |
_warn |
| 5620 |
) { |
| 5621 |
warn$1 = _warn; |
| 5622 |
var value = dir.value; |
| 5623 |
var modifiers = dir.modifiers; |
| 5624 |
var tag = el.tag; |
| 5625 |
var type = el.attrsMap.type; |
| 5626 |
|
| 5627 |
{ |
| 5628 |
var dynamicType = el.attrsMap['v-bind:type'] || el.attrsMap[':type']; |
| 5629 |
if (tag === 'input' && dynamicType) { |
| 5630 |
warn$1( |
| 5631 |
"<input :type=\"" + dynamicType + "\" v-model=\"" + value + "\">:\n" + |
| 5632 |
"v-model does not support dynamic input types. Use v-if branches instead." |
| 5633 |
); |
| 5634 |
} |
| 5635 |
// inputs with type="file" are read only and setting the input's |
| 5636 |
// value will throw an error. |
| 5637 |
if (tag === 'input' && type === 'file') { |
| 5638 |
warn$1( |
| 5639 |
"<" + (el.tag) + " v-model=\"" + value + "\" type=\"file\">:\n" + |
| 5640 |
"File inputs are read only. Use a v-on:change listener instead." |
| 5641 |
); |
| 5642 |
} |
| 5643 |
} |
| 5644 |
|
| 5645 |
if (tag === 'select') { |
| 5646 |
genSelect(el, value, modifiers); |
| 5647 |
} else if (tag === 'input' && type === 'checkbox') { |
| 5648 |
genCheckboxModel(el, value, modifiers); |
| 5649 |
} else if (tag === 'input' && type === 'radio') { |
| 5650 |
genRadioModel(el, value, modifiers); |
| 5651 |
} else if (tag === 'input' || tag === 'textarea') { |
| 5652 |
genDefaultModel(el, value, modifiers); |
| 5653 |
} else if (!config.isReservedTag(tag)) { |
| 5654 |
genComponentModel(el, value, modifiers); |
| 5655 |
// component v-model doesn't need extra runtime |
| 5656 |
return false |
| 5657 |
} else { |
| 5658 |
warn$1( |
| 5659 |
"<" + (el.tag) + " v-model=\"" + value + "\">: " + |
| 5660 |
"v-model is not supported on this element type. " + |
| 5661 |
'If you are working with contenteditable, it\'s recommended to ' + |
| 5662 |
'wrap a library dedicated for that purpose inside a custom component.' |
| 5663 |
); |
| 5664 |
} |
| 5665 |
|
| 5666 |
// ensure runtime directive metadata |
| 5667 |
return true |
| 5668 |
} |
| 5669 |
|
| 5670 |
function genCheckboxModel ( |
| 5671 |
el, |
| 5672 |
value, |
| 5673 |
modifiers |
| 5674 |
) { |
| 5675 |
var number = modifiers && modifiers.number; |
| 5676 |
var valueBinding = getBindingAttr(el, 'value') || 'null'; |
| 5677 |
var trueValueBinding = getBindingAttr(el, 'true-value') || 'true'; |
| 5678 |
var falseValueBinding = getBindingAttr(el, 'false-value') || 'false'; |
| 5679 |
addProp(el, 'checked', |
| 5680 |
"Array.isArray(" + value + ")" + |
| 5681 |
"?_i(" + value + "," + valueBinding + ")>-1" + ( |
| 5682 |
trueValueBinding === 'true' |
| 5683 |
? (":(" + value + ")") |
| 5684 |
: (":_q(" + value + "," + trueValueBinding + ")") |
| 5685 |
) |
| 5686 |
); |
| 5687 |
addHandler(el, CHECKBOX_RADIO_TOKEN, |
| 5688 |
"var $$a=" + value + "," + |
| 5689 |
'$$el=$event.target,' + |
| 5690 |
"$$c=$$el.checked?(" + trueValueBinding + "):(" + falseValueBinding + ");" + |
| 5691 |
'if(Array.isArray($$a)){' + |
| 5692 |
"var $$v=" + (number ? '_n(' + valueBinding + ')' : valueBinding) + "," + |
| 5693 |
'$$i=_i($$a,$$v);' + |
| 5694 |
"if($$c){$$i<0&&(" + value + "=$$a.concat($$v))}" + |
| 5695 |
"else{$$i>-1&&(" + value + "=$$a.slice(0,$$i).concat($$a.slice($$i+1)))}" + |
| 5696 |
"}else{" + value + "=$$c}", |
| 5697 |
null, true |
| 5698 |
); |
| 5699 |
} |
| 5700 |
|
| 5701 |
function genRadioModel ( |
| 5702 |
el, |
| 5703 |
value, |
| 5704 |
modifiers |
| 5705 |
) { |
| 5706 |
var number = modifiers && modifiers.number; |
| 5707 |
var valueBinding = getBindingAttr(el, 'value') || 'null'; |
| 5708 |
valueBinding = number ? ("_n(" + valueBinding + ")") : valueBinding; |
| 5709 |
addProp(el, 'checked', ("_q(" + value + "," + valueBinding + ")")); |
| 5710 |
addHandler(el, CHECKBOX_RADIO_TOKEN, genAssignmentCode(value, valueBinding), null, true); |
| 5711 |
} |
| 5712 |
|
| 5713 |
function genSelect ( |
| 5714 |
el, |
| 5715 |
value, |
| 5716 |
modifiers |
| 5717 |
) { |
| 5718 |
var number = modifiers && modifiers.number; |
| 5719 |
var selectedVal = "Array.prototype.filter" + |
| 5720 |
".call($event.target.options,function(o){return o.selected})" + |
| 5721 |
".map(function(o){var val = \"_value\" in o ? o._value : o.value;" + |
| 5722 |
"return " + (number ? '_n(val)' : 'val') + "})"; |
| 5723 |
|
| 5724 |
var assignment = '$event.target.multiple ? $$selectedVal : $$selectedVal[0]'; |
| 5725 |
var code = "var $$selectedVal = " + selectedVal + ";"; |
| 5726 |
code = code + " " + (genAssignmentCode(value, assignment)); |
| 5727 |
addHandler(el, 'change', code, null, true); |
| 5728 |
} |
| 5729 |
|
| 5730 |
function genDefaultModel ( |
| 5731 |
el, |
| 5732 |
value, |
| 5733 |
modifiers |
| 5734 |
) { |
| 5735 |
var type = el.attrsMap.type; |
| 5736 |
var ref = modifiers || {}; |
| 5737 |
var lazy = ref.lazy; |
| 5738 |
var number = ref.number; |
| 5739 |
var trim = ref.trim; |
| 5740 |
var needCompositionGuard = !lazy && type !== 'range'; |
| 5741 |
var event = lazy |
| 5742 |
? 'change' |
| 5743 |
: type === 'range' |
| 5744 |
? RANGE_TOKEN |
| 5745 |
: 'input'; |
| 5746 |
|
| 5747 |
var valueExpression = '$event.target.value'; |
| 5748 |
if (trim) { |
| 5749 |
valueExpression = "$event.target.value.trim()"; |
| 5750 |
} |
| 5751 |
if (number) { |
| 5752 |
valueExpression = "_n(" + valueExpression + ")"; |
| 5753 |
} |
| 5754 |
|
| 5755 |
var code = genAssignmentCode(value, valueExpression); |
| 5756 |
if (needCompositionGuard) { |
| 5757 |
code = "if($event.target.composing)return;" + code; |
| 5758 |
} |
| 5759 |
|
| 5760 |
addProp(el, 'value', ("(" + value + ")")); |
| 5761 |
addHandler(el, event, code, null, true); |
| 5762 |
if (trim || number || type === 'number') { |
| 5763 |
addHandler(el, 'blur', '$forceUpdate()'); |
| 5764 |
} |
| 5765 |
} |
| 5766 |
|
| 5767 |
/* */ |
| 5768 |
|
| 5769 |
// normalize v-model event tokens that can only be determined at runtime. |
| 5770 |
// it's important to place the event as the first in the array because |
| 5771 |
// the whole point is ensuring the v-model callback gets called before |
| 5772 |
// user-attached handlers. |
| 5773 |
function normalizeEvents (on) { |
| 5774 |
var event; |
| 5775 |
/* istanbul ignore if */ |
| 5776 |
if (on[RANGE_TOKEN]) { |
| 5777 |
// IE input[type=range] only supports `change` event |
| 5778 |
event = isIE ? 'change' : 'input'; |
| 5779 |
on[event] = [].concat(on[RANGE_TOKEN], on[event] || []); |
| 5780 |
delete on[RANGE_TOKEN]; |
| 5781 |
} |
| 5782 |
if (on[CHECKBOX_RADIO_TOKEN]) { |
| 5783 |
// Chrome fires microtasks in between click/change, leads to #4521 |
| 5784 |
event = isChrome ? 'click' : 'change'; |
| 5785 |
on[event] = [].concat(on[CHECKBOX_RADIO_TOKEN], on[event] || []); |
| 5786 |
delete on[CHECKBOX_RADIO_TOKEN]; |
| 5787 |
} |
| 5788 |
} |
| 5789 |
|
| 5790 |
var target$1; |
| 5791 |
|
| 5792 |
function add$1 ( |
| 5793 |
event, |
| 5794 |
handler, |
| 5795 |
once, |
| 5796 |
capture |
| 5797 |
) { |
| 5798 |
if (once) { |
| 5799 |
var oldHandler = handler; |
| 5800 |
var _target = target$1; // save current target element in closure |
| 5801 |
handler = function (ev) { |
| 5802 |
var res = arguments.length === 1 |
| 5803 |
? oldHandler(ev) |
| 5804 |
: oldHandler.apply(null, arguments); |
| 5805 |
if (res !== null) { |
| 5806 |
remove$2(event, handler, capture, _target); |
| 5807 |
} |
| 5808 |
}; |
| 5809 |
} |
| 5810 |
target$1.addEventListener(event, handler, capture); |
| 5811 |
} |
| 5812 |
|
| 5813 |
function remove$2 ( |
| 5814 |
event, |
| 5815 |
handler, |
| 5816 |
capture, |
| 5817 |
_target |
| 5818 |
) { |
| 5819 |
(_target || target$1).removeEventListener(event, handler, capture); |
| 5820 |
} |
| 5821 |
|
| 5822 |
function updateDOMListeners (oldVnode, vnode) { |
| 5823 |
if (!oldVnode.data.on && !vnode.data.on) { |
| 5824 |
return |
| 5825 |
} |
| 5826 |
var on = vnode.data.on || {}; |
| 5827 |
var oldOn = oldVnode.data.on || {}; |
| 5828 |
target$1 = vnode.elm; |
| 5829 |
normalizeEvents(on); |
| 5830 |
updateListeners(on, oldOn, add$1, remove$2, vnode.context); |
| 5831 |
} |
| 5832 |
|
| 5833 |
var events = { |
| 5834 |
create: updateDOMListeners, |
| 5835 |
update: updateDOMListeners |
| 5836 |
}; |
| 5837 |
|
| 5838 |
/* */ |
| 5839 |
|
| 5840 |
function updateDOMProps (oldVnode, vnode) { |
| 5841 |
if (!oldVnode.data.domProps && !vnode.data.domProps) { |
| 5842 |
return |
| 5843 |
} |
| 5844 |
var key, cur; |
| 5845 |
var elm = vnode.elm; |
| 5846 |
var oldProps = oldVnode.data.domProps || {}; |
| 5847 |
var props = vnode.data.domProps || {}; |
| 5848 |
// clone observed objects, as the user probably wants to mutate it |
| 5849 |
if (props.__ob__) { |
| 5850 |
props = vnode.data.domProps = extend({}, props); |
| 5851 |
} |
| 5852 |
|
| 5853 |
for (key in oldProps) { |
| 5854 |
if (props[key] == null) { |
| 5855 |
elm[key] = ''; |
| 5856 |
} |
| 5857 |
} |
| 5858 |
for (key in props) { |
| 5859 |
cur = props[key]; |
| 5860 |
// ignore children if the node has textContent or innerHTML, |
| 5861 |
// as these will throw away existing DOM nodes and cause removal errors |
| 5862 |
// on subsequent patches (#3360) |
| 5863 |
if (key === 'textContent' || key === 'innerHTML') { |
| 5864 |
if (vnode.children) { vnode.children.length = 0; } |
| 5865 |
if (cur === oldProps[key]) { continue } |
| 5866 |
} |
| 5867 |
|
| 5868 |
if (key === 'value') { |
| 5869 |
// store value as _value as well since |
| 5870 |
// non-string values will be stringified |
| 5871 |
elm._value = cur; |
| 5872 |
// avoid resetting cursor position when value is the same |
| 5873 |
var strCur = cur == null ? '' : String(cur); |
| 5874 |
if (shouldUpdateValue(elm, vnode, strCur)) { |
| 5875 |
elm.value = strCur; |
| 5876 |
} |
| 5877 |
} else { |
| 5878 |
elm[key] = cur; |
| 5879 |
} |
| 5880 |
} |
| 5881 |
} |
| 5882 |
|
| 5883 |
// check platforms/web/util/attrs.js acceptValue |
| 5884 |
|
| 5885 |
|
| 5886 |
function shouldUpdateValue ( |
| 5887 |
elm, |
| 5888 |
vnode, |
| 5889 |
checkVal |
| 5890 |
) { |
| 5891 |
return (!elm.composing && ( |
| 5892 |
vnode.tag === 'option' || |
| 5893 |
isDirty(elm, checkVal) || |
| 5894 |
isInputChanged(elm, checkVal) |
| 5895 |
)) |
| 5896 |
} |
| 5897 |
|
| 5898 |
function isDirty (elm, checkVal) { |
| 5899 |
// return true when textbox (.number and .trim) loses focus and its value is not equal to the updated value |
| 5900 |
return document.activeElement !== elm && elm.value !== checkVal |
| 5901 |
} |
| 5902 |
|
| 5903 |
function isInputChanged (elm, newVal) { |
| 5904 |
var value = elm.value; |
| 5905 |
var modifiers = elm._vModifiers; // injected by v-model runtime |
| 5906 |
if ((modifiers && modifiers.number) || elm.type === 'number') { |
| 5907 |
return toNumber(value) !== toNumber(newVal) |
| 5908 |
} |
| 5909 |
if (modifiers && modifiers.trim) { |
| 5910 |
return value.trim() !== newVal.trim() |
| 5911 |
} |
| 5912 |
return value !== newVal |
| 5913 |
} |
| 5914 |
|
| 5915 |
var domProps = { |
| 5916 |
create: updateDOMProps, |
| 5917 |
update: updateDOMProps |
| 5918 |
}; |
| 5919 |
|
| 5920 |
/* */ |
| 5921 |
|
| 5922 |
var parseStyleText = cached(function (cssText) { |
| 5923 |
var res = {}; |
| 5924 |
var listDelimiter = /;(?![^(]*\))/g; |
| 5925 |
var propertyDelimiter = /:(.+)/; |
| 5926 |
cssText.split(listDelimiter).forEach(function (item) { |
| 5927 |
if (item) { |
| 5928 |
var tmp = item.split(propertyDelimiter); |
| 5929 |
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim()); |
| 5930 |
} |
| 5931 |
}); |
| 5932 |
return res |
| 5933 |
}); |
| 5934 |
|
| 5935 |
// merge static and dynamic style data on the same vnode |
| 5936 |
function normalizeStyleData (data) { |
| 5937 |
var style = normalizeStyleBinding(data.style); |
| 5938 |
// static style is pre-processed into an object during compilation |
| 5939 |
// and is always a fresh object, so it's safe to merge into it |
| 5940 |
return data.staticStyle |
| 5941 |
? extend(data.staticStyle, style) |
| 5942 |
: style |
| 5943 |
} |
| 5944 |
|
| 5945 |
// normalize possible array / string values into Object |
| 5946 |
function normalizeStyleBinding (bindingStyle) { |
| 5947 |
if (Array.isArray(bindingStyle)) { |
| 5948 |
return toObject(bindingStyle) |
| 5949 |
} |
| 5950 |
if (typeof bindingStyle === 'string') { |
| 5951 |
return parseStyleText(bindingStyle) |
| 5952 |
} |
| 5953 |
return bindingStyle |
| 5954 |
} |
| 5955 |
|
| 5956 |
/** |
| 5957 |
* parent component style should be after child's |
| 5958 |
* so that parent component's style could override it |
| 5959 |
*/ |
| 5960 |
function getStyle (vnode, checkChild) { |
| 5961 |
var res = {}; |
| 5962 |
var styleData; |
| 5963 |
|
| 5964 |
if (checkChild) { |
| 5965 |
var childNode = vnode; |
| 5966 |
while (childNode.componentInstance) { |
| 5967 |
childNode = childNode.componentInstance._vnode; |
| 5968 |
if (childNode.data && (styleData = normalizeStyleData(childNode.data))) { |
| 5969 |
extend(res, styleData); |
| 5970 |
} |
| 5971 |
} |
| 5972 |
} |
| 5973 |
|
| 5974 |
if ((styleData = normalizeStyleData(vnode.data))) { |
| 5975 |
extend(res, styleData); |
| 5976 |
} |
| 5977 |
|
| 5978 |
var parentNode = vnode; |
| 5979 |
while ((parentNode = parentNode.parent)) { |
| 5980 |
if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) { |
| 5981 |
extend(res, styleData); |
| 5982 |
} |
| 5983 |
} |
| 5984 |
return res |
| 5985 |
} |
| 5986 |
|
| 5987 |
/* */ |
| 5988 |
|
| 5989 |
var cssVarRE = /^--/; |
| 5990 |
var importantRE = /\s*!important$/; |
| 5991 |
var setProp = function (el, name, val) { |
| 5992 |
/* istanbul ignore if */ |
| 5993 |
if (cssVarRE.test(name)) { |
| 5994 |
el.style.setProperty(name, val); |
| 5995 |
} else if (importantRE.test(val)) { |
| 5996 |
el.style.setProperty(name, val.replace(importantRE, ''), 'important'); |
| 5997 |
} else { |
| 5998 |
el.style[normalize(name)] = val; |
| 5999 |
} |
| 6000 |
}; |
| 6001 |
|
| 6002 |
var prefixes = ['Webkit', 'Moz', 'ms']; |
| 6003 |
|
| 6004 |
var testEl; |
| 6005 |
var normalize = cached(function (prop) { |
| 6006 |
testEl = testEl || document.createElement('div'); |
| 6007 |
prop = camelize(prop); |
| 6008 |
if (prop !== 'filter' && (prop in testEl.style)) { |
| 6009 |
return prop |
| 6010 |
} |
| 6011 |
var upper = prop.charAt(0).toUpperCase() + prop.slice(1); |
| 6012 |
for (var i = 0; i < prefixes.length; i++) { |
| 6013 |
var prefixed = prefixes[i] + upper; |
| 6014 |
if (prefixed in testEl.style) { |
| 6015 |
return prefixed |
| 6016 |
} |
| 6017 |
} |
| 6018 |
}); |
| 6019 |
|
| 6020 |
function updateStyle (oldVnode, vnode) { |
| 6021 |
var data = vnode.data; |
| 6022 |
var oldData = oldVnode.data; |
| 6023 |
|
| 6024 |
if (!data.staticStyle && !data.style && |
| 6025 |
!oldData.staticStyle && !oldData.style) { |
| 6026 |
return |
| 6027 |
} |
| 6028 |
|
| 6029 |
var cur, name; |
| 6030 |
var el = vnode.elm; |
| 6031 |
var oldStaticStyle = oldVnode.data.staticStyle; |
| 6032 |
var oldStyleBinding = oldVnode.data.style || {}; |
| 6033 |
|
| 6034 |
// if static style exists, stylebinding already merged into it when doing normalizeStyleData |
| 6035 |
var oldStyle = oldStaticStyle || oldStyleBinding; |
| 6036 |
|
| 6037 |
var style = normalizeStyleBinding(vnode.data.style) || {}; |
| 6038 |
|
| 6039 |
vnode.data.style = style.__ob__ ? extend({}, style) : style; |
| 6040 |
|
| 6041 |
var newStyle = getStyle(vnode, true); |
| 6042 |
|
| 6043 |
for (name in oldStyle) { |
| 6044 |
if (newStyle[name] == null) { |
| 6045 |
setProp(el, name, ''); |
| 6046 |
} |
| 6047 |
} |
| 6048 |
for (name in newStyle) { |
| 6049 |
cur = newStyle[name]; |
| 6050 |
if (cur !== oldStyle[name]) { |
| 6051 |
// ie9 setting to null has no effect, must use empty string |
| 6052 |
setProp(el, name, cur == null ? '' : cur); |
| 6053 |
} |
| 6054 |
} |
| 6055 |
} |
| 6056 |
|
| 6057 |
var style = { |
| 6058 |
create: updateStyle, |
| 6059 |
update: updateStyle |
| 6060 |
}; |
| 6061 |
|
| 6062 |
/* */ |
| 6063 |
|
| 6064 |
/** |
| 6065 |
* Add class with compatibility for SVG since classList is not supported on |
| 6066 |
* SVG elements in IE |
| 6067 |
*/ |
| 6068 |
function addClass (el, cls) { |
| 6069 |
/* istanbul ignore if */ |
| 6070 |
if (!cls || !(cls = cls.trim())) { |
| 6071 |
return |
| 6072 |
} |
| 6073 |
|
| 6074 |
/* istanbul ignore else */ |
| 6075 |
if (el.classList) { |
| 6076 |
if (cls.indexOf(' ') > -1) { |
| 6077 |
cls.split(/\s+/).forEach(function (c) { return el.classList.add(c); }); |
| 6078 |
} else { |
| 6079 |
el.classList.add(cls); |
| 6080 |
} |
| 6081 |
} else { |
| 6082 |
var cur = " " + (el.getAttribute('class') || '') + " "; |
| 6083 |
if (cur.indexOf(' ' + cls + ' ') < 0) { |
| 6084 |
el.setAttribute('class', (cur + cls).trim()); |
| 6085 |
} |
| 6086 |
} |
| 6087 |
} |
| 6088 |
|
| 6089 |
/** |
| 6090 |
* Remove class with compatibility for SVG since classList is not supported on |
| 6091 |
* SVG elements in IE |
| 6092 |
*/ |
| 6093 |
function removeClass (el, cls) { |
| 6094 |
/* istanbul ignore if */ |
| 6095 |
if (!cls || !(cls = cls.trim())) { |
| 6096 |
return |
| 6097 |
} |
| 6098 |
|
| 6099 |
/* istanbul ignore else */ |
| 6100 |
if (el.classList) { |
| 6101 |
if (cls.indexOf(' ') > -1) { |
| 6102 |
cls.split(/\s+/).forEach(function (c) { return el.classList.remove(c); }); |
| 6103 |
} else { |
| 6104 |
el.classList.remove(cls); |
| 6105 |
} |
| 6106 |
} else { |
| 6107 |
var cur = " " + (el.getAttribute('class') || '') + " "; |
| 6108 |
var tar = ' ' + cls + ' '; |
| 6109 |
while (cur.indexOf(tar) >= 0) { |
| 6110 |
cur = cur.replace(tar, ' '); |
| 6111 |
} |
| 6112 |
el.setAttribute('class', cur.trim()); |
| 6113 |
} |
| 6114 |
} |
| 6115 |
|
| 6116 |
/* */ |
| 6117 |
|
| 6118 |
function resolveTransition (def$$1) { |
| 6119 |
if (!def$$1) { |
| 6120 |
return |
| 6121 |
} |
| 6122 |
/* istanbul ignore else */ |
| 6123 |
if (typeof def$$1 === 'object') { |
| 6124 |
var res = {}; |
| 6125 |
if (def$$1.css !== false) { |
| 6126 |
extend(res, autoCssTransition(def$$1.name || 'v')); |
| 6127 |
} |
| 6128 |
extend(res, def$$1); |
| 6129 |
return res |
| 6130 |
} else if (typeof def$$1 === 'string') { |
| 6131 |
return autoCssTransition(def$$1) |
| 6132 |
} |
| 6133 |
} |
| 6134 |
|
| 6135 |
var autoCssTransition = cached(function (name) { |
| 6136 |
return { |
| 6137 |
enterClass: (name + "-enter"), |
| 6138 |
enterToClass: (name + "-enter-to"), |
| 6139 |
enterActiveClass: (name + "-enter-active"), |
| 6140 |
leaveClass: (name + "-leave"), |
| 6141 |
leaveToClass: (name + "-leave-to"), |
| 6142 |
leaveActiveClass: (name + "-leave-active") |
| 6143 |
} |
| 6144 |
}); |
| 6145 |
|
| 6146 |
var hasTransition = inBrowser && !isIE9; |
| 6147 |
var TRANSITION = 'transition'; |
| 6148 |
var ANIMATION = 'animation'; |
| 6149 |
|
| 6150 |
// Transition property/event sniffing |
| 6151 |
var transitionProp = 'transition'; |
| 6152 |
var transitionEndEvent = 'transitionend'; |
| 6153 |
var animationProp = 'animation'; |
| 6154 |
var animationEndEvent = 'animationend'; |
| 6155 |
if (hasTransition) { |
| 6156 |
/* istanbul ignore if */ |
| 6157 |
if (window.ontransitionend === undefined && |
| 6158 |
window.onwebkittransitionend !== undefined) { |
| 6159 |
transitionProp = 'WebkitTransition'; |
| 6160 |
transitionEndEvent = 'webkitTransitionEnd'; |
| 6161 |
} |
| 6162 |
if (window.onanimationend === undefined && |
| 6163 |
window.onwebkitanimationend !== undefined) { |
| 6164 |
animationProp = 'WebkitAnimation'; |
| 6165 |
animationEndEvent = 'webkitAnimationEnd'; |
| 6166 |
} |
| 6167 |
} |
| 6168 |
|
| 6169 |
// binding to window is necessary to make hot reload work in IE in strict mode |
| 6170 |
var raf = inBrowser && window.requestAnimationFrame |
| 6171 |
? window.requestAnimationFrame.bind(window) |
| 6172 |
: setTimeout; |
| 6173 |
|
| 6174 |
function nextFrame (fn) { |
| 6175 |
raf(function () { |
| 6176 |
raf(fn); |
| 6177 |
}); |
| 6178 |
} |
| 6179 |
|
| 6180 |
function addTransitionClass (el, cls) { |
| 6181 |
(el._transitionClasses || (el._transitionClasses = [])).push(cls); |
| 6182 |
addClass(el, cls); |
| 6183 |
} |
| 6184 |
|
| 6185 |
function removeTransitionClass (el, cls) { |
| 6186 |
if (el._transitionClasses) { |
| 6187 |
remove(el._transitionClasses, cls); |
| 6188 |
} |
| 6189 |
removeClass(el, cls); |
| 6190 |
} |
| 6191 |
|
| 6192 |
function whenTransitionEnds ( |
| 6193 |
el, |
| 6194 |
expectedType, |
| 6195 |
cb |
| 6196 |
) { |
| 6197 |
var ref = getTransitionInfo(el, expectedType); |
| 6198 |
var type = ref.type; |
| 6199 |
var timeout = ref.timeout; |
| 6200 |
var propCount = ref.propCount; |
| 6201 |
if (!type) { return cb() } |
| 6202 |
var event = type === TRANSITION ? transitionEndEvent : animationEndEvent; |
| 6203 |
var ended = 0; |
| 6204 |
var end = function () { |
| 6205 |
el.removeEventListener(event, onEnd); |
| 6206 |
cb(); |
| 6207 |
}; |
| 6208 |
var onEnd = function (e) { |
| 6209 |
if (e.target === el) { |
| 6210 |
if (++ended >= propCount) { |
| 6211 |
end(); |
| 6212 |
} |
| 6213 |
} |
| 6214 |
}; |
| 6215 |
setTimeout(function () { |
| 6216 |
if (ended < propCount) { |
| 6217 |
end(); |
| 6218 |
} |
| 6219 |
}, timeout + 1); |
| 6220 |
el.addEventListener(event, onEnd); |
| 6221 |
} |
| 6222 |
|
| 6223 |
var transformRE = /\b(transform|all)(,|$)/; |
| 6224 |
|
| 6225 |
function getTransitionInfo (el, expectedType) { |
| 6226 |
var styles = window.getComputedStyle(el); |
| 6227 |
var transitionDelays = styles[transitionProp + 'Delay'].split(', '); |
| 6228 |
var transitionDurations = styles[transitionProp + 'Duration'].split(', '); |
| 6229 |
var transitionTimeout = getTimeout(transitionDelays, transitionDurations); |
| 6230 |
var animationDelays = styles[animationProp + 'Delay'].split(', '); |
| 6231 |
var animationDurations = styles[animationProp + 'Duration'].split(', '); |
| 6232 |
var animationTimeout = getTimeout(animationDelays, animationDurations); |
| 6233 |
|
| 6234 |
var type; |
| 6235 |
var timeout = 0; |
| 6236 |
var propCount = 0; |
| 6237 |
/* istanbul ignore if */ |
| 6238 |
if (expectedType === TRANSITION) { |
| 6239 |
if (transitionTimeout > 0) { |
| 6240 |
type = TRANSITION; |
| 6241 |
timeout = transitionTimeout; |
| 6242 |
propCount = transitionDurations.length; |
| 6243 |
} |
| 6244 |
} else if (expectedType === ANIMATION) { |
| 6245 |
if (animationTimeout > 0) { |
| 6246 |
type = ANIMATION; |
| 6247 |
timeout = animationTimeout; |
| 6248 |
propCount = animationDurations.length; |
| 6249 |
} |
| 6250 |
} else { |
| 6251 |
timeout = Math.max(transitionTimeout, animationTimeout); |
| 6252 |
type = timeout > 0 |
| 6253 |
? transitionTimeout > animationTimeout |
| 6254 |
? TRANSITION |
| 6255 |
: ANIMATION |
| 6256 |
: null; |
| 6257 |
propCount = type |
| 6258 |
? type === TRANSITION |
| 6259 |
? transitionDurations.length |
| 6260 |
: animationDurations.length |
| 6261 |
: 0; |
| 6262 |
} |
| 6263 |
var hasTransform = |
| 6264 |
type === TRANSITION && |
| 6265 |
transformRE.test(styles[transitionProp + 'Property']); |
| 6266 |
return { |
| 6267 |
type: type, |
| 6268 |
timeout: timeout, |
| 6269 |
propCount: propCount, |
| 6270 |
hasTransform: hasTransform |
| 6271 |
} |
| 6272 |
} |
| 6273 |
|
| 6274 |
function getTimeout (delays, durations) { |
| 6275 |
/* istanbul ignore next */ |
| 6276 |
while (delays.length < durations.length) { |
| 6277 |
delays = delays.concat(delays); |
| 6278 |
} |
| 6279 |
|
| 6280 |
return Math.max.apply(null, durations.map(function (d, i) { |
| 6281 |
return toMs(d) + toMs(delays[i]) |
| 6282 |
})) |
| 6283 |
} |
| 6284 |
|
| 6285 |
function toMs (s) { |
| 6286 |
return Number(s.slice(0, -1)) * 1000 |
| 6287 |
} |
| 6288 |
|
| 6289 |
/* */ |
| 6290 |
|
| 6291 |
function enter (vnode, toggleDisplay) { |
| 6292 |
var el = vnode.elm; |
| 6293 |
|
| 6294 |
// call leave callback now |
| 6295 |
if (el._leaveCb) { |
| 6296 |
el._leaveCb.cancelled = true; |
| 6297 |
el._leaveCb(); |
| 6298 |
} |
| 6299 |
|
| 6300 |
var data = resolveTransition(vnode.data.transition); |
| 6301 |
if (!data) { |
| 6302 |
return |
| 6303 |
} |
| 6304 |
|
| 6305 |
/* istanbul ignore if */ |
| 6306 |
if (el._enterCb || el.nodeType !== 1) { |
| 6307 |
return |
| 6308 |
} |
| 6309 |
|
| 6310 |
var css = data.css; |
| 6311 |
var type = data.type; |
| 6312 |
var enterClass = data.enterClass; |
| 6313 |
var enterToClass = data.enterToClass; |
| 6314 |
var enterActiveClass = data.enterActiveClass; |
| 6315 |
var appearClass = data.appearClass; |
| 6316 |
var appearToClass = data.appearToClass; |
| 6317 |
var appearActiveClass = data.appearActiveClass; |
| 6318 |
var beforeEnter = data.beforeEnter; |
| 6319 |
var enter = data.enter; |
| 6320 |
var afterEnter = data.afterEnter; |
| 6321 |
var enterCancelled = data.enterCancelled; |
| 6322 |
var beforeAppear = data.beforeAppear; |
| 6323 |
var appear = data.appear; |
| 6324 |
var afterAppear = data.afterAppear; |
| 6325 |
var appearCancelled = data.appearCancelled; |
| 6326 |
var duration = data.duration; |
| 6327 |
|
| 6328 |
// activeInstance will always be the <transition> component managing this |
| 6329 |
// transition. One edge case to check is when the <transition> is placed |
| 6330 |
// as the root node of a child component. In that case we need to check |
| 6331 |
// <transition>'s parent for appear check. |
| 6332 |
var context = activeInstance; |
| 6333 |
var transitionNode = activeInstance.$vnode; |
| 6334 |
while (transitionNode && transitionNode.parent) { |
| 6335 |
transitionNode = transitionNode.parent; |
| 6336 |
context = transitionNode.context; |
| 6337 |
} |
| 6338 |
|
| 6339 |
var isAppear = !context._isMounted || !vnode.isRootInsert; |
| 6340 |
|
| 6341 |
if (isAppear && !appear && appear !== '') { |
| 6342 |
return |
| 6343 |
} |
| 6344 |
|
| 6345 |
var startClass = isAppear && appearClass |
| 6346 |
? appearClass |
| 6347 |
: enterClass; |
| 6348 |
var activeClass = isAppear && appearActiveClass |
| 6349 |
? appearActiveClass |
| 6350 |
: enterActiveClass; |
| 6351 |
var toClass = isAppear && appearToClass |
| 6352 |
? appearToClass |
| 6353 |
: enterToClass; |
| 6354 |
|
| 6355 |
var beforeEnterHook = isAppear |
| 6356 |
? (beforeAppear || beforeEnter) |
| 6357 |
: beforeEnter; |
| 6358 |
var enterHook = isAppear |
| 6359 |
? (typeof appear === 'function' ? appear : enter) |
| 6360 |
: enter; |
| 6361 |
var afterEnterHook = isAppear |
| 6362 |
? (afterAppear || afterEnter) |
| 6363 |
: afterEnter; |
| 6364 |
var enterCancelledHook = isAppear |
| 6365 |
? (appearCancelled || enterCancelled) |
| 6366 |
: enterCancelled; |
| 6367 |
|
| 6368 |
var explicitEnterDuration = toNumber( |
| 6369 |
isObject(duration) |
| 6370 |
? duration.enter |
| 6371 |
: duration |
| 6372 |
); |
| 6373 |
|
| 6374 |
if ("development" !== 'production' && explicitEnterDuration != null) { |
| 6375 |
checkDuration(explicitEnterDuration, 'enter', vnode); |
| 6376 |
} |
| 6377 |
|
| 6378 |
var expectsCSS = css !== false && !isIE9; |
| 6379 |
var userWantsControl = getHookArgumentsLength(enterHook); |
| 6380 |
|
| 6381 |
var cb = el._enterCb = once(function () { |
| 6382 |
if (expectsCSS) { |
| 6383 |
removeTransitionClass(el, toClass); |
| 6384 |
removeTransitionClass(el, activeClass); |
| 6385 |
} |
| 6386 |
if (cb.cancelled) { |
| 6387 |
if (expectsCSS) { |
| 6388 |
removeTransitionClass(el, startClass); |
| 6389 |
} |
| 6390 |
enterCancelledHook && enterCancelledHook(el); |
| 6391 |
} else { |
| 6392 |
afterEnterHook && afterEnterHook(el); |
| 6393 |
} |
| 6394 |
el._enterCb = null; |
| 6395 |
}); |
| 6396 |
|
| 6397 |
if (!vnode.data.show) { |
| 6398 |
// remove pending leave element on enter by injecting an insert hook |
| 6399 |
mergeVNodeHook(vnode.data.hook || (vnode.data.hook = {}), 'insert', function () { |
| 6400 |
var parent = el.parentNode; |
| 6401 |
var pendingNode = parent && parent._pending && parent._pending[vnode.key]; |
| 6402 |
if (pendingNode && |
| 6403 |
pendingNode.tag === vnode.tag && |
| 6404 |
pendingNode.elm._leaveCb) { |
| 6405 |
pendingNode.elm._leaveCb(); |
| 6406 |
} |
| 6407 |
enterHook && enterHook(el, cb); |
| 6408 |
}); |
| 6409 |
} |
| 6410 |
|
| 6411 |
// start enter transition |
| 6412 |
beforeEnterHook && beforeEnterHook(el); |
| 6413 |
if (expectsCSS) { |
| 6414 |
addTransitionClass(el, startClass); |
| 6415 |
addTransitionClass(el, activeClass); |
| 6416 |
nextFrame(function () { |
| 6417 |
addTransitionClass(el, toClass); |
| 6418 |
removeTransitionClass(el, startClass); |
| 6419 |
if (!cb.cancelled && !userWantsControl) { |
| 6420 |
if (isValidDuration(explicitEnterDuration)) { |
| 6421 |
setTimeout(cb, explicitEnterDuration); |
| 6422 |
} else { |
| 6423 |
whenTransitionEnds(el, type, cb); |
| 6424 |
} |
| 6425 |
} |
| 6426 |
}); |
| 6427 |
} |
| 6428 |
|
| 6429 |
if (vnode.data.show) { |
| 6430 |
toggleDisplay && toggleDisplay(); |
| 6431 |
enterHook && enterHook(el, cb); |
| 6432 |
} |
| 6433 |
|
| 6434 |
if (!expectsCSS && !userWantsControl) { |
| 6435 |
cb(); |
| 6436 |
} |
| 6437 |
} |
| 6438 |
|
| 6439 |
function leave (vnode, rm) { |
| 6440 |
var el = vnode.elm; |
| 6441 |
|
| 6442 |
// call enter callback now |
| 6443 |
if (el._enterCb) { |
| 6444 |
el._enterCb.cancelled = true; |
| 6445 |
el._enterCb(); |
| 6446 |
} |
| 6447 |
|
| 6448 |
var data = resolveTransition(vnode.data.transition); |
| 6449 |
if (!data) { |
| 6450 |
return rm() |
| 6451 |
} |
| 6452 |
|
| 6453 |
/* istanbul ignore if */ |
| 6454 |
if (el._leaveCb || el.nodeType !== 1) { |
| 6455 |
return |
| 6456 |
} |
| 6457 |
|
| 6458 |
var css = data.css; |
| 6459 |
var type = data.type; |
| 6460 |
var leaveClass = data.leaveClass; |
| 6461 |
var leaveToClass = data.leaveToClass; |
| 6462 |
var leaveActiveClass = data.leaveActiveClass; |
| 6463 |
var beforeLeave = data.beforeLeave; |
| 6464 |
var leave = data.leave; |
| 6465 |
var afterLeave = data.afterLeave; |
| 6466 |
var leaveCancelled = data.leaveCancelled; |
| 6467 |
var delayLeave = data.delayLeave; |
| 6468 |
var duration = data.duration; |
| 6469 |
|
| 6470 |
var expectsCSS = css !== false && !isIE9; |
| 6471 |
var userWantsControl = getHookArgumentsLength(leave); |
| 6472 |
|
| 6473 |
var explicitLeaveDuration = toNumber( |
| 6474 |
isObject(duration) |
| 6475 |
? duration.leave |
| 6476 |
: duration |
| 6477 |
); |
| 6478 |
|
| 6479 |
if ("development" !== 'production' && explicitLeaveDuration != null) { |
| 6480 |
checkDuration(explicitLeaveDuration, 'leave', vnode); |
| 6481 |
} |
| 6482 |
|
| 6483 |
var cb = el._leaveCb = once(function () { |
| 6484 |
if (el.parentNode && el.parentNode._pending) { |
| 6485 |
el.parentNode._pending[vnode.key] = null; |
| 6486 |
} |
| 6487 |
if (expectsCSS) { |
| 6488 |
removeTransitionClass(el, leaveToClass); |
| 6489 |
removeTransitionClass(el, leaveActiveClass); |
| 6490 |
} |
| 6491 |
if (cb.cancelled) { |
| 6492 |
if (expectsCSS) { |
| 6493 |
removeTransitionClass(el, leaveClass); |
| 6494 |
} |
| 6495 |
leaveCancelled && leaveCancelled(el); |
| 6496 |
} else { |
| 6497 |
rm(); |
| 6498 |
afterLeave && afterLeave(el); |
| 6499 |
} |
| 6500 |
el._leaveCb = null; |
| 6501 |
}); |
| 6502 |
|
| 6503 |
if (delayLeave) { |
| 6504 |
delayLeave(performLeave); |
| 6505 |
} else { |
| 6506 |
performLeave(); |
| 6507 |
} |
| 6508 |
|
| 6509 |
function performLeave () { |
| 6510 |
// the delayed leave may have already been cancelled |
| 6511 |
if (cb.cancelled) { |
| 6512 |
return |
| 6513 |
} |
| 6514 |
// record leaving element |
| 6515 |
if (!vnode.data.show) { |
| 6516 |
(el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key] = vnode; |
| 6517 |
} |
| 6518 |
beforeLeave && beforeLeave(el); |
| 6519 |
if (expectsCSS) { |
| 6520 |
addTransitionClass(el, leaveClass); |
| 6521 |
addTransitionClass(el, leaveActiveClass); |
| 6522 |
nextFrame(function () { |
| 6523 |
addTransitionClass(el, leaveToClass); |
| 6524 |
removeTransitionClass(el, leaveClass); |
| 6525 |
if (!cb.cancelled && !userWantsControl) { |
| 6526 |
if (isValidDuration(explicitLeaveDuration)) { |
| 6527 |
setTimeout(cb, explicitLeaveDuration); |
| 6528 |
} else { |
| 6529 |
whenTransitionEnds(el, type, cb); |
| 6530 |
} |
| 6531 |
} |
| 6532 |
}); |
| 6533 |
} |
| 6534 |
leave && leave(el, cb); |
| 6535 |
if (!expectsCSS && !userWantsControl) { |
| 6536 |
cb(); |
| 6537 |
} |
| 6538 |
} |
| 6539 |
} |
| 6540 |
|
| 6541 |
// only used in dev mode |
| 6542 |
function checkDuration (val, name, vnode) { |
| 6543 |
if (typeof val !== 'number') { |
| 6544 |
warn( |
| 6545 |
"<transition> explicit " + name + " duration is not a valid number - " + |
| 6546 |
"got " + (JSON.stringify(val)) + ".", |
| 6547 |
vnode.context |
| 6548 |
); |
| 6549 |
} else if (isNaN(val)) { |
| 6550 |
warn( |
| 6551 |
"<transition> explicit " + name + " duration is NaN - " + |
| 6552 |
'the duration expression might be incorrect.', |
| 6553 |
vnode.context |
| 6554 |
); |
| 6555 |
} |
| 6556 |
} |
| 6557 |
|
| 6558 |
function isValidDuration (val) { |
| 6559 |
return typeof val === 'number' && !isNaN(val) |
| 6560 |
} |
| 6561 |
|
| 6562 |
/** |
| 6563 |
* Normalize a transition hook's argument length. The hook may be: |
| 6564 |
* - a merged hook (invoker) with the original in .fns |
| 6565 |
* - a wrapped component method (check ._length) |
| 6566 |
* - a plain function (.length) |
| 6567 |
*/ |
| 6568 |
function getHookArgumentsLength (fn) { |
| 6569 |
if (!fn) { return false } |
| 6570 |
var invokerFns = fn.fns; |
| 6571 |
if (invokerFns) { |
| 6572 |
// invoker |
| 6573 |
return getHookArgumentsLength( |
| 6574 |
Array.isArray(invokerFns) |
| 6575 |
? invokerFns[0] |
| 6576 |
: invokerFns |
| 6577 |
) |
| 6578 |
} else { |
| 6579 |
return (fn._length || fn.length) > 1 |
| 6580 |
} |
| 6581 |
} |
| 6582 |
|
| 6583 |
function _enter (_, vnode) { |
| 6584 |
if (!vnode.data.show) { |
| 6585 |
enter(vnode); |
| 6586 |
} |
| 6587 |
} |
| 6588 |
|
| 6589 |
var transition = inBrowser ? { |
| 6590 |
create: _enter, |
| 6591 |
activate: _enter, |
| 6592 |
remove: function remove$$1 (vnode, rm) { |
| 6593 |
/* istanbul ignore else */ |
| 6594 |
if (!vnode.data.show) { |
| 6595 |
leave(vnode, rm); |
| 6596 |
} else { |
| 6597 |
rm(); |
| 6598 |
} |
| 6599 |
} |
| 6600 |
} : {}; |
| 6601 |
|
| 6602 |
var platformModules = [ |
| 6603 |
attrs, |
| 6604 |
klass, |
| 6605 |
events, |
| 6606 |
domProps, |
| 6607 |
style, |
| 6608 |
transition |
| 6609 |
]; |
| 6610 |
|
| 6611 |
/* */ |
| 6612 |
|
| 6613 |
// the directive module should be applied last, after all |
| 6614 |
// built-in modules have been applied. |
| 6615 |
var modules = platformModules.concat(baseModules); |
| 6616 |
|
| 6617 |
var patch = createPatchFunction({ nodeOps: nodeOps, modules: modules }); |
| 6618 |
|
| 6619 |
/** |
| 6620 |
* Not type checking this file because flow doesn't like attaching |
| 6621 |
* properties to Elements. |
| 6622 |
*/ |
| 6623 |
|
| 6624 |
/* istanbul ignore if */ |
| 6625 |
if (isIE9) { |
| 6626 |
// http://www.matts411.com/post/internet-explorer-9-oninput/ |
| 6627 |
document.addEventListener('selectionchange', function () { |
| 6628 |
var el = document.activeElement; |
| 6629 |
if (el && el.vmodel) { |
| 6630 |
trigger(el, 'input'); |
| 6631 |
} |
| 6632 |
}); |
| 6633 |
} |
| 6634 |
|
| 6635 |
var model$1 = { |
| 6636 |
inserted: function inserted (el, binding, vnode) { |
| 6637 |
if (vnode.tag === 'select') { |
| 6638 |
var cb = function () { |
| 6639 |
setSelected(el, binding, vnode.context); |
| 6640 |
}; |
| 6641 |
cb(); |
| 6642 |
/* istanbul ignore if */ |
| 6643 |
if (isIE || isEdge) { |
| 6644 |
setTimeout(cb, 0); |
| 6645 |
} |
| 6646 |
} else if (vnode.tag === 'textarea' || el.type === 'text') { |
| 6647 |
el._vModifiers = binding.modifiers; |
| 6648 |
if (!binding.modifiers.lazy) { |
| 6649 |
if (!isAndroid) { |
| 6650 |
el.addEventListener('compositionstart', onCompositionStart); |
| 6651 |
el.addEventListener('compositionend', onCompositionEnd); |
| 6652 |
} |
| 6653 |
/* istanbul ignore if */ |
| 6654 |
if (isIE9) { |
| 6655 |
el.vmodel = true; |
| 6656 |
} |
| 6657 |
} |
| 6658 |
} |
| 6659 |
}, |
| 6660 |
componentUpdated: function componentUpdated (el, binding, vnode) { |
| 6661 |
if (vnode.tag === 'select') { |
| 6662 |
setSelected(el, binding, vnode.context); |
| 6663 |
// in case the options rendered by v-for have changed, |
| 6664 |
// it's possible that the value is out-of-sync with the rendered options. |
| 6665 |
// detect such cases and filter out values that no longer has a matching |
| 6666 |
// option in the DOM. |
| 6667 |
var needReset = el.multiple |
| 6668 |
? binding.value.some(function (v) { return hasNoMatchingOption(v, el.options); }) |
| 6669 |
: binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, el.options); |
| 6670 |
if (needReset) { |
| 6671 |
trigger(el, 'change'); |
| 6672 |
} |
| 6673 |
} |
| 6674 |
} |
| 6675 |
}; |
| 6676 |
|
| 6677 |
function setSelected (el, binding, vm) { |
| 6678 |
var value = binding.value; |
| 6679 |
var isMultiple = el.multiple; |
| 6680 |
if (isMultiple && !Array.isArray(value)) { |
| 6681 |
"development" !== 'production' && warn( |
| 6682 |
"<select multiple v-model=\"" + (binding.expression) + "\"> " + |
| 6683 |
"expects an Array value for its binding, but got " + (Object.prototype.toString.call(value).slice(8, -1)), |
| 6684 |
vm |
| 6685 |
); |
| 6686 |
return |
| 6687 |
} |
| 6688 |
var selected, option; |
| 6689 |
for (var i = 0, l = el.options.length; i < l; i++) { |
| 6690 |
option = el.options[i]; |
| 6691 |
if (isMultiple) { |
| 6692 |
selected = looseIndexOf(value, getValue(option)) > -1; |
| 6693 |
if (option.selected !== selected) { |
| 6694 |
option.selected = selected; |
| 6695 |
} |
| 6696 |
} else { |
| 6697 |
if (looseEqual(getValue(option), value)) { |
| 6698 |
if (el.selectedIndex !== i) { |
| 6699 |
el.selectedIndex = i; |
| 6700 |
} |
| 6701 |
return |
| 6702 |
} |
| 6703 |
} |
| 6704 |
} |
| 6705 |
if (!isMultiple) { |
| 6706 |
el.selectedIndex = -1; |
| 6707 |
} |
| 6708 |
} |
| 6709 |
|
| 6710 |
function hasNoMatchingOption (value, options) { |
| 6711 |
for (var i = 0, l = options.length; i < l; i++) { |
| 6712 |
if (looseEqual(getValue(options[i]), value)) { |
| 6713 |
return false |
| 6714 |
} |
| 6715 |
} |
| 6716 |
return true |
| 6717 |
} |
| 6718 |
|
| 6719 |
function getValue (option) { |
| 6720 |
return '_value' in option |
| 6721 |
? option._value |
| 6722 |
: option.value |
| 6723 |
} |
| 6724 |
|
| 6725 |
function onCompositionStart (e) { |
| 6726 |
e.target.composing = true; |
| 6727 |
} |
| 6728 |
|
| 6729 |
function onCompositionEnd (e) { |
| 6730 |
e.target.composing = false; |
| 6731 |
trigger(e.target, 'input'); |
| 6732 |
} |
| 6733 |
|
| 6734 |
function trigger (el, type) { |
| 6735 |
var e = document.createEvent('HTMLEvents'); |
| 6736 |
e.initEvent(type, true, true); |
| 6737 |
el.dispatchEvent(e); |
| 6738 |
} |
| 6739 |
|
| 6740 |
/* */ |
| 6741 |
|
| 6742 |
// recursively search for possible transition defined inside the component root |
| 6743 |
function locateNode (vnode) { |
| 6744 |
return vnode.componentInstance && (!vnode.data || !vnode.data.transition) |
| 6745 |
? locateNode(vnode.componentInstance._vnode) |
| 6746 |
: vnode |
| 6747 |
} |
| 6748 |
|
| 6749 |
var show = { |
| 6750 |
bind: function bind (el, ref, vnode) { |
| 6751 |
var value = ref.value; |
| 6752 |
|
| 6753 |
vnode = locateNode(vnode); |
| 6754 |
var transition = vnode.data && vnode.data.transition; |
| 6755 |
var originalDisplay = el.__vOriginalDisplay = |
| 6756 |
el.style.display === 'none' ? '' : el.style.display; |
| 6757 |
if (value && transition && !isIE9) { |
| 6758 |
vnode.data.show = true; |
| 6759 |
enter(vnode, function () { |
| 6760 |
el.style.display = originalDisplay; |
| 6761 |
}); |
| 6762 |
} else { |
| 6763 |
el.style.display = value ? originalDisplay : 'none'; |
| 6764 |
} |
| 6765 |
}, |
| 6766 |
|
| 6767 |
update: function update (el, ref, vnode) { |
| 6768 |
var value = ref.value; |
| 6769 |
var oldValue = ref.oldValue; |
| 6770 |
|
| 6771 |
/* istanbul ignore if */ |
| 6772 |
if (value === oldValue) { return } |
| 6773 |
vnode = locateNode(vnode); |
| 6774 |
var transition = vnode.data && vnode.data.transition; |
| 6775 |
if (transition && !isIE9) { |
| 6776 |
vnode.data.show = true; |
| 6777 |
if (value) { |
| 6778 |
enter(vnode, function () { |
| 6779 |
el.style.display = el.__vOriginalDisplay; |
| 6780 |
}); |
| 6781 |
} else { |
| 6782 |
leave(vnode, function () { |
| 6783 |
el.style.display = 'none'; |
| 6784 |
}); |
| 6785 |
} |
| 6786 |
} else { |
| 6787 |
el.style.display = value ? el.__vOriginalDisplay : 'none'; |
| 6788 |
} |
| 6789 |
}, |
| 6790 |
|
| 6791 |
unbind: function unbind ( |
| 6792 |
el, |
| 6793 |
binding, |
| 6794 |
vnode, |
| 6795 |
oldVnode, |
| 6796 |
isDestroy |
| 6797 |
) { |
| 6798 |
if (!isDestroy) { |
| 6799 |
el.style.display = el.__vOriginalDisplay; |
| 6800 |
} |
| 6801 |
} |
| 6802 |
}; |
| 6803 |
|
| 6804 |
var platformDirectives = { |
| 6805 |
model: model$1, |
| 6806 |
show: show |
| 6807 |
}; |
| 6808 |
|
| 6809 |
/* */ |
| 6810 |
|
| 6811 |
// Provides transition support for a single element/component. |
| 6812 |
// supports transition mode (out-in / in-out) |
| 6813 |
|
| 6814 |
var transitionProps = { |
| 6815 |
name: String, |
| 6816 |
appear: Boolean, |
| 6817 |
css: Boolean, |
| 6818 |
mode: String, |
| 6819 |
type: String, |
| 6820 |
enterClass: String, |
| 6821 |
leaveClass: String, |
| 6822 |
enterToClass: String, |
| 6823 |
leaveToClass: String, |
| 6824 |
enterActiveClass: String, |
| 6825 |
leaveActiveClass: String, |
| 6826 |
appearClass: String, |
| 6827 |
appearActiveClass: String, |
| 6828 |
appearToClass: String, |
| 6829 |
duration: [Number, String, Object] |
| 6830 |
}; |
| 6831 |
|
| 6832 |
// in case the child is also an abstract component, e.g. <keep-alive> |
| 6833 |
// we want to recursively retrieve the real component to be rendered |
| 6834 |
function getRealChild (vnode) { |
| 6835 |
var compOptions = vnode && vnode.componentOptions; |
| 6836 |
if (compOptions && compOptions.Ctor.options.abstract) { |
| 6837 |
return getRealChild(getFirstComponentChild(compOptions.children)) |
| 6838 |
} else { |
| 6839 |
return vnode |
| 6840 |
} |
| 6841 |
} |
| 6842 |
|
| 6843 |
function extractTransitionData (comp) { |
| 6844 |
var data = {}; |
| 6845 |
var options = comp.$options; |
| 6846 |
// props |
| 6847 |
for (var key in options.propsData) { |
| 6848 |
data[key] = comp[key]; |
| 6849 |
} |
| 6850 |
// events. |
| 6851 |
// extract listeners and pass them directly to the transition methods |
| 6852 |
var listeners = options._parentListeners; |
| 6853 |
for (var key$1 in listeners) { |
| 6854 |
data[camelize(key$1)] = listeners[key$1]; |
| 6855 |
} |
| 6856 |
return data |
| 6857 |
} |
| 6858 |
|
| 6859 |
function placeholder (h, rawChild) { |
| 6860 |
return /\d-keep-alive$/.test(rawChild.tag) |
| 6861 |
? h('keep-alive') |
| 6862 |
: null |
| 6863 |
} |
| 6864 |
|
| 6865 |
function hasParentTransition (vnode) { |
| 6866 |
while ((vnode = vnode.parent)) { |
| 6867 |
if (vnode.data.transition) { |
| 6868 |
return true |
| 6869 |
} |
| 6870 |
} |
| 6871 |
} |
| 6872 |
|
| 6873 |
function isSameChild (child, oldChild) { |
| 6874 |
return oldChild.key === child.key && oldChild.tag === child.tag |
| 6875 |
} |
| 6876 |
|
| 6877 |
var Transition = { |
| 6878 |
name: 'transition', |
| 6879 |
props: transitionProps, |
| 6880 |
abstract: true, |
| 6881 |
|
| 6882 |
render: function render (h) { |
| 6883 |
var this$1 = this; |
| 6884 |
|
| 6885 |
var children = this.$slots.default; |
| 6886 |
if (!children) { |
| 6887 |
return |
| 6888 |
} |
| 6889 |
|
| 6890 |
// filter out text nodes (possible whitespaces) |
| 6891 |
children = children.filter(function (c) { return c.tag; }); |
| 6892 |
/* istanbul ignore if */ |
| 6893 |
if (!children.length) { |
| 6894 |
return |
| 6895 |
} |
| 6896 |
|
| 6897 |
// warn multiple elements |
| 6898 |
if ("development" !== 'production' && children.length > 1) { |
| 6899 |
warn( |
| 6900 |
'<transition> can only be used on a single element. Use ' + |
| 6901 |
'<transition-group> for lists.', |
| 6902 |
this.$parent |
| 6903 |
); |
| 6904 |
} |
| 6905 |
|
| 6906 |
var mode = this.mode; |
| 6907 |
|
| 6908 |
// warn invalid mode |
| 6909 |
if ("development" !== 'production' && |
| 6910 |
mode && mode !== 'in-out' && mode !== 'out-in') { |
| 6911 |
warn( |
| 6912 |
'invalid <transition> mode: ' + mode, |
| 6913 |
this.$parent |
| 6914 |
); |
| 6915 |
} |
| 6916 |
|
| 6917 |
var rawChild = children[0]; |
| 6918 |
|
| 6919 |
// if this is a component root node and the component's |
| 6920 |
// parent container node also has transition, skip. |
| 6921 |
if (hasParentTransition(this.$vnode)) { |
| 6922 |
return rawChild |
| 6923 |
} |
| 6924 |
|
| 6925 |
// apply transition data to child |
| 6926 |
// use getRealChild() to ignore abstract components e.g. keep-alive |
| 6927 |
var child = getRealChild(rawChild); |
| 6928 |
/* istanbul ignore if */ |
| 6929 |
if (!child) { |
| 6930 |
return rawChild |
| 6931 |
} |
| 6932 |
|
| 6933 |
if (this._leaving) { |
| 6934 |
return placeholder(h, rawChild) |
| 6935 |
} |
| 6936 |
|
| 6937 |
// ensure a key that is unique to the vnode type and to this transition |
| 6938 |
// component instance. This key will be used to remove pending leaving nodes |
| 6939 |
// during entering. |
| 6940 |
var id = "__transition-" + (this._uid) + "-"; |
| 6941 |
child.key = child.key == null |
| 6942 |
? id + child.tag |
| 6943 |
: isPrimitive(child.key) |
| 6944 |
? (String(child.key).indexOf(id) === 0 ? child.key : id + child.key) |
| 6945 |
: child.key; |
| 6946 |
|
| 6947 |
var data = (child.data || (child.data = {})).transition = extractTransitionData(this); |
| 6948 |
var oldRawChild = this._vnode; |
| 6949 |
var oldChild = getRealChild(oldRawChild); |
| 6950 |
|
| 6951 |
// mark v-show |
| 6952 |
// so that the transition module can hand over the control to the directive |
| 6953 |
if (child.data.directives && child.data.directives.some(function (d) { return d.name === 'show'; })) { |
| 6954 |
child.data.show = true; |
| 6955 |
} |
| 6956 |
|
| 6957 |
if (oldChild && oldChild.data && !isSameChild(child, oldChild)) { |
| 6958 |
// replace old child transition data with fresh one |
| 6959 |
// important for dynamic transitions! |
| 6960 |
var oldData = oldChild && (oldChild.data.transition = extend({}, data)); |
| 6961 |
// handle transition mode |
| 6962 |
if (mode === 'out-in') { |
| 6963 |
// return placeholder node and queue update when leave finishes |
| 6964 |
this._leaving = true; |
| 6965 |
mergeVNodeHook(oldData, 'afterLeave', function () { |
| 6966 |
this$1._leaving = false; |
| 6967 |
this$1.$forceUpdate(); |
| 6968 |
}); |
| 6969 |
return placeholder(h, rawChild) |
| 6970 |
} else if (mode === 'in-out') { |
| 6971 |
var delayedLeave; |
| 6972 |
var performLeave = function () { delayedLeave(); }; |
| 6973 |
mergeVNodeHook(data, 'afterEnter', performLeave); |
| 6974 |
mergeVNodeHook(data, 'enterCancelled', performLeave); |
| 6975 |
mergeVNodeHook(oldData, 'delayLeave', function (leave) { delayedLeave = leave; }); |
| 6976 |
} |
| 6977 |
} |
| 6978 |
|
| 6979 |
return rawChild |
| 6980 |
} |
| 6981 |
}; |
| 6982 |
|
| 6983 |
/* */ |
| 6984 |
|
| 6985 |
// Provides transition support for list items. |
| 6986 |
// supports move transitions using the FLIP technique. |
| 6987 |
|
| 6988 |
// Because the vdom's children update algorithm is "unstable" - i.e. |
| 6989 |
// it doesn't guarantee the relative positioning of removed elements, |
| 6990 |
// we force transition-group to update its children into two passes: |
| 6991 |
// in the first pass, we remove all nodes that need to be removed, |
| 6992 |
// triggering their leaving transition; in the second pass, we insert/move |
| 6993 |
// into the final desired state. This way in the second pass removed |
| 6994 |
// nodes will remain where they should be. |
| 6995 |
|
| 6996 |
var props = extend({ |
| 6997 |
tag: String, |
| 6998 |
moveClass: String |
| 6999 |
}, transitionProps); |
| 7000 |
|
| 7001 |
delete props.mode; |
| 7002 |
|
| 7003 |
var TransitionGroup = { |
| 7004 |
props: props, |
| 7005 |
|
| 7006 |
render: function render (h) { |
| 7007 |
var tag = this.tag || this.$vnode.data.tag || 'span'; |
| 7008 |
var map = Object.create(null); |
| 7009 |
var prevChildren = this.prevChildren = this.children; |
| 7010 |
var rawChildren = this.$slots.default || []; |
| 7011 |
var children = this.children = []; |
| 7012 |
var transitionData = extractTransitionData(this); |
| 7013 |
|
| 7014 |
for (var i = 0; i < rawChildren.length; i++) { |
| 7015 |
var c = rawChildren[i]; |
| 7016 |
if (c.tag) { |
| 7017 |
if (c.key != null && String(c.key).indexOf('__vlist') !== 0) { |
| 7018 |
children.push(c); |
| 7019 |
map[c.key] = c |
| 7020 |
;(c.data || (c.data = {})).transition = transitionData; |
| 7021 |
} else { |
| 7022 |
var opts = c.componentOptions; |
| 7023 |
var name = opts ? (opts.Ctor.options.name || opts.tag || '') : c.tag; |
| 7024 |
warn(("<transition-group> children must be keyed: <" + name + ">")); |
| 7025 |
} |
| 7026 |
} |
| 7027 |
} |
| 7028 |
|
| 7029 |
if (prevChildren) { |
| 7030 |
var kept = []; |
| 7031 |
var removed = []; |
| 7032 |
for (var i$1 = 0; i$1 < prevChildren.length; i$1++) { |
| 7033 |
var c$1 = prevChildren[i$1]; |
| 7034 |
c$1.data.transition = transitionData; |
| 7035 |
c$1.data.pos = c$1.elm.getBoundingClientRect(); |
| 7036 |
if (map[c$1.key]) { |
| 7037 |
kept.push(c$1); |
| 7038 |
} else { |
| 7039 |
removed.push(c$1); |
| 7040 |
} |
| 7041 |
} |
| 7042 |
this.kept = h(tag, null, kept); |
| 7043 |
this.removed = removed; |
| 7044 |
} |
| 7045 |
|
| 7046 |
return h(tag, null, children) |
| 7047 |
}, |
| 7048 |
|
| 7049 |
beforeUpdate: function beforeUpdate () { |
| 7050 |
// force removing pass |
| 7051 |
this.__patch__( |
| 7052 |
this._vnode, |
| 7053 |
this.kept, |
| 7054 |
false, // hydrating |
| 7055 |
true // removeOnly (!important, avoids unnecessary moves) |
| 7056 |
); |
| 7057 |
this._vnode = this.kept; |
| 7058 |
}, |
| 7059 |
|
| 7060 |
updated: function updated () { |
| 7061 |
var children = this.prevChildren; |
| 7062 |
var moveClass = this.moveClass || ((this.name || 'v') + '-move'); |
| 7063 |
if (!children.length || !this.hasMove(children[0].elm, moveClass)) { |
| 7064 |
return |
| 7065 |
} |
| 7066 |
|
| 7067 |
// we divide the work into three loops to avoid mixing DOM reads and writes |
| 7068 |
// in each iteration - which helps prevent layout thrashing. |
| 7069 |
children.forEach(callPendingCbs); |
| 7070 |
children.forEach(recordPosition); |
| 7071 |
children.forEach(applyTranslation); |
| 7072 |
|
| 7073 |
// force reflow to put everything in position |
| 7074 |
var body = document.body; |
| 7075 |
var f = body.offsetHeight; // eslint-disable-line |
| 7076 |
|
| 7077 |
children.forEach(function (c) { |
| 7078 |
if (c.data.moved) { |
| 7079 |
var el = c.elm; |
| 7080 |
var s = el.style; |
| 7081 |
addTransitionClass(el, moveClass); |
| 7082 |
s.transform = s.WebkitTransform = s.transitionDuration = ''; |
| 7083 |
el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) { |
| 7084 |
if (!e || /transform$/.test(e.propertyName)) { |
| 7085 |
el.removeEventListener(transitionEndEvent, cb); |
| 7086 |
el._moveCb = null; |
| 7087 |
removeTransitionClass(el, moveClass); |
| 7088 |
} |
| 7089 |
}); |
| 7090 |
} |
| 7091 |
}); |
| 7092 |
}, |
| 7093 |
|
| 7094 |
methods: { |
| 7095 |
hasMove: function hasMove (el, moveClass) { |
| 7096 |
/* istanbul ignore if */ |
| 7097 |
if (!hasTransition) { |
| 7098 |
return false |
| 7099 |
} |
| 7100 |
if (this._hasMove != null) { |
| 7101 |
return this._hasMove |
| 7102 |
} |
| 7103 |
// Detect whether an element with the move class applied has |
| 7104 |
// CSS transitions. Since the element may be inside an entering |
| 7105 |
// transition at this very moment, we make a clone of it and remove |
| 7106 |
// all other transition classes applied to ensure only the move class |
| 7107 |
// is applied. |
| 7108 |
var clone = el.cloneNode(); |
| 7109 |
if (el._transitionClasses) { |
| 7110 |
el._transitionClasses.forEach(function (cls) { removeClass(clone, cls); }); |
| 7111 |
} |
| 7112 |
addClass(clone, moveClass); |
| 7113 |
clone.style.display = 'none'; |
| 7114 |
this.$el.appendChild(clone); |
| 7115 |
var info = getTransitionInfo(clone); |
| 7116 |
this.$el.removeChild(clone); |
| 7117 |
return (this._hasMove = info.hasTransform) |
| 7118 |
} |
| 7119 |
} |
| 7120 |
}; |
| 7121 |
|
| 7122 |
function callPendingCbs (c) { |
| 7123 |
/* istanbul ignore if */ |
| 7124 |
if (c.elm._moveCb) { |
| 7125 |
c.elm._moveCb(); |
| 7126 |
} |
| 7127 |
/* istanbul ignore if */ |
| 7128 |
if (c.elm._enterCb) { |
| 7129 |
c.elm._enterCb(); |
| 7130 |
} |
| 7131 |
} |
| 7132 |
|
| 7133 |
function recordPosition (c) { |
| 7134 |
c.data.newPos = c.elm.getBoundingClientRect(); |
| 7135 |
} |
| 7136 |
|
| 7137 |
function applyTranslation (c) { |
| 7138 |
var oldPos = c.data.pos; |
| 7139 |
var newPos = c.data.newPos; |
| 7140 |
var dx = oldPos.left - newPos.left; |
| 7141 |
var dy = oldPos.top - newPos.top; |
| 7142 |
if (dx || dy) { |
| 7143 |
c.data.moved = true; |
| 7144 |
var s = c.elm.style; |
| 7145 |
s.transform = s.WebkitTransform = "translate(" + dx + "px," + dy + "px)"; |
| 7146 |
s.transitionDuration = '0s'; |
| 7147 |
} |
| 7148 |
} |
| 7149 |
|
| 7150 |
var platformComponents = { |
| 7151 |
Transition: Transition, |
| 7152 |
TransitionGroup: TransitionGroup |
| 7153 |
}; |
| 7154 |
|
| 7155 |
/* */ |
| 7156 |
|
| 7157 |
// install platform specific utils |
| 7158 |
Vue$3.config.mustUseProp = mustUseProp; |
| 7159 |
Vue$3.config.isReservedTag = isReservedTag; |
| 7160 |
Vue$3.config.getTagNamespace = getTagNamespace; |
| 7161 |
Vue$3.config.isUnknownElement = isUnknownElement; |
| 7162 |
|
| 7163 |
// install platform runtime directives & components |
| 7164 |
extend(Vue$3.options.directives, platformDirectives); |
| 7165 |
extend(Vue$3.options.components, platformComponents); |
| 7166 |
|
| 7167 |
// install platform patch function |
| 7168 |
Vue$3.prototype.__patch__ = inBrowser ? patch : noop; |
| 7169 |
|
| 7170 |
// public mount method |
| 7171 |
Vue$3.prototype.$mount = function ( |
| 7172 |
el, |
| 7173 |
hydrating |
| 7174 |
) { |
| 7175 |
el = el && inBrowser ? query(el) : undefined; |
| 7176 |
return mountComponent(this, el, hydrating) |
| 7177 |
}; |
| 7178 |
|
| 7179 |
// devtools global hook |
| 7180 |
/* istanbul ignore next */ |
| 7181 |
setTimeout(function () { |
| 7182 |
if (config.devtools) { |
| 7183 |
if (devtools) { |
| 7184 |
devtools.emit('init', Vue$3); |
| 7185 |
} else if ("development" !== 'production' && isChrome) { |
| 7186 |
console[console.info ? 'info' : 'log']( |
| 7187 |
'Download the Vue Devtools extension for a better development experience:\n' + |
| 7188 |
'https://github.com/vuejs/vue-devtools' |
| 7189 |
); |
| 7190 |
} |
| 7191 |
} |
| 7192 |
if ("development" !== 'production' && |
| 7193 |
config.productionTip !== false && |
| 7194 |
inBrowser && typeof console !== 'undefined') { |
| 7195 |
console[console.info ? 'info' : 'log']( |
| 7196 |
"You are running Vue in development mode.\n" + |
| 7197 |
"Make sure to turn on production mode when deploying for production.\n" + |
| 7198 |
"See more tips at https://vuejs.org/guide/deployment.html" |
| 7199 |
); |
| 7200 |
} |
| 7201 |
}, 0); |
| 7202 |
|
| 7203 |
/* */ |
| 7204 |
|
| 7205 |
// check whether current browser encodes a char inside attribute values |
| 7206 |
function shouldDecode (content, encoded) { |
| 7207 |
var div = document.createElement('div'); |
| 7208 |
div.innerHTML = "<div a=\"" + content + "\">"; |
| 7209 |
return div.innerHTML.indexOf(encoded) > 0 |
| 7210 |
} |
| 7211 |
|
| 7212 |
// #3663 |
| 7213 |
// IE encodes newlines inside attribute values while other browsers don't |
| 7214 |
var shouldDecodeNewlines = inBrowser ? shouldDecode('\n', ' ') : false; |
| 7215 |
|
| 7216 |
/* */ |
| 7217 |
|
| 7218 |
var isUnaryTag = makeMap( |
| 7219 |
'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' + |
| 7220 |
'link,meta,param,source,track,wbr' |
| 7221 |
); |
| 7222 |
|
| 7223 |
// Elements that you can, intentionally, leave open |
| 7224 |
// (and which close themselves) |
| 7225 |
var canBeLeftOpenTag = makeMap( |
| 7226 |
'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source' |
| 7227 |
); |
| 7228 |
|
| 7229 |
// HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3 |
| 7230 |
// Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content |
| 7231 |
var isNonPhrasingTag = makeMap( |
| 7232 |
'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' + |
| 7233 |
'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' + |
| 7234 |
'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' + |
| 7235 |
'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' + |
| 7236 |
'title,tr,track' |
| 7237 |
); |
| 7238 |
|
| 7239 |
/* */ |
| 7240 |
|
| 7241 |
var decoder; |
| 7242 |
|
| 7243 |
function decode (html) { |
| 7244 |
decoder = decoder || document.createElement('div'); |
| 7245 |
decoder.innerHTML = html; |
| 7246 |
return decoder.textContent |
| 7247 |
} |
| 7248 |
|
| 7249 |
/** |
| 7250 |
* Not type-checking this file because it's mostly vendor code. |
| 7251 |
*/ |
| 7252 |
|
| 7253 |
/*! |
| 7254 |
* HTML Parser By John Resig (ejohn.org) |
| 7255 |
* Modified by Juriy "kangax" Zaytsev |
| 7256 |
* Original code by Erik Arvidsson, Mozilla Public License |
| 7257 |
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js |
| 7258 |
*/ |
| 7259 |
|
| 7260 |
// Regular Expressions for parsing tags and attributes |
| 7261 |
var singleAttrIdentifier = /([^\s"'<>/=]+)/; |
| 7262 |
var singleAttrAssign = /(?:=)/; |
| 7263 |
var singleAttrValues = [ |
| 7264 |
// attr value double quotes |
| 7265 |
/"([^"]*)"+/.source, |
| 7266 |
// attr value, single quotes |
| 7267 |
/'([^']*)'+/.source, |
| 7268 |
// attr value, no quotes |
| 7269 |
/([^\s"'=<>`]+)/.source |
| 7270 |
]; |
| 7271 |
var attribute = new RegExp( |
| 7272 |
'^\\s*' + singleAttrIdentifier.source + |
| 7273 |
'(?:\\s*(' + singleAttrAssign.source + ')' + |
| 7274 |
'\\s*(?:' + singleAttrValues.join('|') + '))?' |
| 7275 |
); |
| 7276 |
|
| 7277 |
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName |
| 7278 |
// but for Vue templates we can enforce a simple charset |
| 7279 |
var ncname = '[a-zA-Z_][\\w\\-\\.]*'; |
| 7280 |
var qnameCapture = '((?:' + ncname + '\\:)?' + ncname + ')'; |
| 7281 |
var startTagOpen = new RegExp('^<' + qnameCapture); |
| 7282 |
var startTagClose = /^\s*(\/?)>/; |
| 7283 |
var endTag = new RegExp('^<\\/' + qnameCapture + '[^>]*>'); |
| 7284 |
var doctype = /^<!DOCTYPE [^>]+>/i; |
| 7285 |
var comment = /^<!--/; |
| 7286 |
var conditionalComment = /^<!\[/; |
| 7287 |
|
| 7288 |
var IS_REGEX_CAPTURING_BROKEN = false; |
| 7289 |
'x'.replace(/x(.)?/g, function (m, g) { |
| 7290 |
IS_REGEX_CAPTURING_BROKEN = g === ''; |
| 7291 |
}); |
| 7292 |
|
| 7293 |
// Special Elements (can contain anything) |
| 7294 |
var isPlainTextElement = makeMap('script,style,textarea', true); |
| 7295 |
var reCache = {}; |
| 7296 |
|
| 7297 |
var decodingMap = { |
| 7298 |
'<': '<', |
| 7299 |
'>': '>', |
| 7300 |
'"': '"', |
| 7301 |
'&': '&', |
| 7302 |
' ': '\n' |
| 7303 |
}; |
| 7304 |
var encodedAttr = /&(?:lt|gt|quot|amp);/g; |
| 7305 |
var encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#10);/g; |
| 7306 |
|
| 7307 |
function decodeAttr (value, shouldDecodeNewlines) { |
| 7308 |
var re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr; |
| 7309 |
return value.replace(re, function (match) { return decodingMap[match]; }) |
| 7310 |
} |
| 7311 |
|
| 7312 |
function parseHTML (html, options) { |
| 7313 |
var stack = []; |
| 7314 |
var expectHTML = options.expectHTML; |
| 7315 |
var isUnaryTag$$1 = options.isUnaryTag || no; |
| 7316 |
var index = 0; |
| 7317 |
var last, lastTag; |
| 7318 |
while (html) { |
| 7319 |
last = html; |
| 7320 |
// Make sure we're not in a plaintext content element like script/style |
| 7321 |
if (!lastTag || !isPlainTextElement(lastTag)) { |
| 7322 |
var textEnd = html.indexOf('<'); |
| 7323 |
if (textEnd === 0) { |
| 7324 |
// Comment: |
| 7325 |
if (comment.test(html)) { |
| 7326 |
var commentEnd = html.indexOf('-->'); |
| 7327 |
|
| 7328 |
if (commentEnd >= 0) { |
| 7329 |
advance(commentEnd + 3); |
| 7330 |
continue |
| 7331 |
} |
| 7332 |
} |
| 7333 |
|
| 7334 |
// http://en.wikipedia.org/wiki/Conditional_comment#Downlevel-revealed_conditional_comment |
| 7335 |
if (conditionalComment.test(html)) { |
| 7336 |
var conditionalEnd = html.indexOf(']>'); |
| 7337 |
|
| 7338 |
if (conditionalEnd >= 0) { |
| 7339 |
advance(conditionalEnd + 2); |
| 7340 |
continue |
| 7341 |
} |
| 7342 |
} |
| 7343 |
|
| 7344 |
// Doctype: |
| 7345 |
var doctypeMatch = html.match(doctype); |
| 7346 |
if (doctypeMatch) { |
| 7347 |
advance(doctypeMatch[0].length); |
| 7348 |
continue |
| 7349 |
} |
| 7350 |
|
| 7351 |
// End tag: |
| 7352 |
var endTagMatch = html.match(endTag); |
| 7353 |
if (endTagMatch) { |
| 7354 |
var curIndex = index; |
| 7355 |
advance(endTagMatch[0].length); |
| 7356 |
parseEndTag(endTagMatch[1], curIndex, index); |
| 7357 |
continue |
| 7358 |
} |
| 7359 |
|
| 7360 |
// Start tag: |
| 7361 |
var startTagMatch = parseStartTag(); |
| 7362 |
if (startTagMatch) { |
| 7363 |
handleStartTag(startTagMatch); |
| 7364 |
continue |
| 7365 |
} |
| 7366 |
} |
| 7367 |
|
| 7368 |
var text = (void 0), rest$1 = (void 0), next = (void 0); |
| 7369 |
if (textEnd >= 0) { |
| 7370 |
rest$1 = html.slice(textEnd); |
| 7371 |
while ( |
| 7372 |
!endTag.test(rest$1) && |
| 7373 |
!startTagOpen.test(rest$1) && |
| 7374 |
!comment.test(rest$1) && |
| 7375 |
!conditionalComment.test(rest$1) |
| 7376 |
) { |
| 7377 |
// < in plain text, be forgiving and treat it as text |
| 7378 |
next = rest$1.indexOf('<', 1); |
| 7379 |
if (next < 0) { break } |
| 7380 |
textEnd += next; |
| 7381 |
rest$1 = html.slice(textEnd); |
| 7382 |
} |
| 7383 |
text = html.substring(0, textEnd); |
| 7384 |
advance(textEnd); |
| 7385 |
} |
| 7386 |
|
| 7387 |
if (textEnd < 0) { |
| 7388 |
text = html; |
| 7389 |
html = ''; |
| 7390 |
} |
| 7391 |
|
| 7392 |
if (options.chars && text) { |
| 7393 |
options.chars(text); |
| 7394 |
} |
| 7395 |
} else { |
| 7396 |
var stackedTag = lastTag.toLowerCase(); |
| 7397 |
var reStackedTag = reCache[stackedTag] || (reCache[stackedTag] = new RegExp('([\\s\\S]*?)(</' + stackedTag + '[^>]*>)', 'i')); |
| 7398 |
var endTagLength = 0; |
| 7399 |
var rest = html.replace(reStackedTag, function (all, text, endTag) { |
| 7400 |
endTagLength = endTag.length; |
| 7401 |
if (!isPlainTextElement(stackedTag) && stackedTag !== 'noscript') { |
| 7402 |
text = text |
| 7403 |
.replace(/<!--([\s\S]*?)-->/g, '$1') |
| 7404 |
.replace(/<!\[CDATA\[([\s\S]*?)]]>/g, '$1'); |
| 7405 |
} |
| 7406 |
if (options.chars) { |
| 7407 |
options.chars(text); |
| 7408 |
} |
| 7409 |
return '' |
| 7410 |
}); |
| 7411 |
index += html.length - rest.length; |
| 7412 |
html = rest; |
| 7413 |
parseEndTag(stackedTag, index - endTagLength, index); |
| 7414 |
} |
| 7415 |
|
| 7416 |
if (html === last) { |
| 7417 |
options.chars && options.chars(html); |
| 7418 |
if ("development" !== 'production' && !stack.length && options.warn) { |
| 7419 |
options.warn(("Mal-formatted tag at end of template: \"" + html + "\"")); |
| 7420 |
} |
| 7421 |
break |
| 7422 |
} |
| 7423 |
} |
| 7424 |
|
| 7425 |
// Clean up any remaining tags |
| 7426 |
parseEndTag(); |
| 7427 |
|
| 7428 |
function advance (n) { |
| 7429 |
index += n; |
| 7430 |
html = html.substring(n); |
| 7431 |
} |
| 7432 |
|
| 7433 |
function parseStartTag () { |
| 7434 |
var start = html.match(startTagOpen); |
| 7435 |
if (start) { |
| 7436 |
var match = { |
| 7437 |
tagName: start[1], |
| 7438 |
attrs: [], |
| 7439 |
start: index |
| 7440 |
}; |
| 7441 |
advance(start[0].length); |
| 7442 |
var end, attr; |
| 7443 |
while (!(end = html.match(startTagClose)) && (attr = html.match(attribute))) { |
| 7444 |
advance(attr[0].length); |
| 7445 |
match.attrs.push(attr); |
| 7446 |
} |
| 7447 |
if (end) { |
| 7448 |
match.unarySlash = end[1]; |
| 7449 |
advance(end[0].length); |
| 7450 |
match.end = index; |
| 7451 |
return match |
| 7452 |
} |
| 7453 |
} |
| 7454 |
} |
| 7455 |
|
| 7456 |
function handleStartTag (match) { |
| 7457 |
var tagName = match.tagName; |
| 7458 |
var unarySlash = match.unarySlash; |
| 7459 |
|
| 7460 |
if (expectHTML) { |
| 7461 |
if (lastTag === 'p' && isNonPhrasingTag(tagName)) { |
| 7462 |
parseEndTag(lastTag); |
| 7463 |
} |
| 7464 |
if (canBeLeftOpenTag(tagName) && lastTag === tagName) { |
| 7465 |
parseEndTag(tagName); |
| 7466 |
} |
| 7467 |
} |
| 7468 |
|
| 7469 |
var unary = isUnaryTag$$1(tagName) || tagName === 'html' && lastTag === 'head' || !!unarySlash; |
| 7470 |
|
| 7471 |
var l = match.attrs.length; |
| 7472 |
var attrs = new Array(l); |
| 7473 |
for (var i = 0; i < l; i++) { |
| 7474 |
var args = match.attrs[i]; |
| 7475 |
// hackish work around FF bug https://bugzilla.mozilla.org/show_bug.cgi?id=369778 |
| 7476 |
if (IS_REGEX_CAPTURING_BROKEN && args[0].indexOf('""') === -1) { |
| 7477 |
if (args[3] === '') { delete args[3]; } |
| 7478 |
if (args[4] === '') { delete args[4]; } |
| 7479 |
if (args[5] === '') { delete args[5]; } |
| 7480 |
} |
| 7481 |
var value = args[3] || args[4] || args[5] || ''; |
| 7482 |
attrs[i] = { |
| 7483 |
name: args[1], |
| 7484 |
value: decodeAttr( |
| 7485 |
value, |
| 7486 |
options.shouldDecodeNewlines |
| 7487 |
) |
| 7488 |
}; |
| 7489 |
} |
| 7490 |
|
| 7491 |
if (!unary) { |
| 7492 |
stack.push({ tag: tagName, lowerCasedTag: tagName.toLowerCase(), attrs: attrs }); |
| 7493 |
lastTag = tagName; |
| 7494 |
} |
| 7495 |
|
| 7496 |
if (options.start) { |
| 7497 |
options.start(tagName, attrs, unary, match.start, match.end); |
| 7498 |
} |
| 7499 |
} |
| 7500 |
|
| 7501 |
function parseEndTag (tagName, start, end) { |
| 7502 |
var pos, lowerCasedTagName; |
| 7503 |
if (start == null) { start = index; } |
| 7504 |
if (end == null) { end = index; } |
| 7505 |
|
| 7506 |
if (tagName) { |
| 7507 |
lowerCasedTagName = tagName.toLowerCase(); |
| 7508 |
} |
| 7509 |
|
| 7510 |
// Find the closest opened tag of the same type |
| 7511 |
if (tagName) { |
| 7512 |
for (pos = stack.length - 1; pos >= 0; pos--) { |
| 7513 |
if (stack[pos].lowerCasedTag === lowerCasedTagName) { |
| 7514 |
break |
| 7515 |
} |
| 7516 |
} |
| 7517 |
} else { |
| 7518 |
// If no tag name is provided, clean shop |
| 7519 |
pos = 0; |
| 7520 |
} |
| 7521 |
|
| 7522 |
if (pos >= 0) { |
| 7523 |
// Close all the open elements, up the stack |
| 7524 |
for (var i = stack.length - 1; i >= pos; i--) { |
| 7525 |
if ("development" !== 'production' && |
| 7526 |
(i > pos || !tagName) && |
| 7527 |
options.warn) { |
| 7528 |
options.warn( |
| 7529 |
("tag <" + (stack[i].tag) + "> has no matching end tag.") |
| 7530 |
); |
| 7531 |
} |
| 7532 |
if (options.end) { |
| 7533 |
options.end(stack[i].tag, start, end); |
| 7534 |
} |
| 7535 |
} |
| 7536 |
|
| 7537 |
// Remove the open elements from the stack |
| 7538 |
stack.length = pos; |
| 7539 |
lastTag = pos && stack[pos - 1].tag; |
| 7540 |
} else if (lowerCasedTagName === 'br') { |
| 7541 |
if (options.start) { |
| 7542 |
options.start(tagName, [], true, start, end); |
| 7543 |
} |
| 7544 |
} else if (lowerCasedTagName === 'p') { |
| 7545 |
if (options.start) { |
| 7546 |
options.start(tagName, [], false, start, end); |
| 7547 |
} |
| 7548 |
if (options.end) { |
| 7549 |
options.end(tagName, start, end); |
| 7550 |
} |
| 7551 |
} |
| 7552 |
} |
| 7553 |
} |
| 7554 |
|
| 7555 |
/* */ |
| 7556 |
|
| 7557 |
var defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g; |
| 7558 |
var regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g; |
| 7559 |
|
| 7560 |
var buildRegex = cached(function (delimiters) { |
| 7561 |
var open = delimiters[0].replace(regexEscapeRE, '\\$&'); |
| 7562 |
var close = delimiters[1].replace(regexEscapeRE, '\\$&'); |
| 7563 |
return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') |
| 7564 |
}); |
| 7565 |
|
| 7566 |
function parseText ( |
| 7567 |
text, |
| 7568 |
delimiters |
| 7569 |
) { |
| 7570 |
var tagRE = delimiters ? buildRegex(delimiters) : defaultTagRE; |
| 7571 |
if (!tagRE.test(text)) { |
| 7572 |
return |
| 7573 |
} |
| 7574 |
var tokens = []; |
| 7575 |
var lastIndex = tagRE.lastIndex = 0; |
| 7576 |
var match, index; |
| 7577 |
while ((match = tagRE.exec(text))) { |
| 7578 |
index = match.index; |
| 7579 |
// push text token |
| 7580 |
if (index > lastIndex) { |
| 7581 |
tokens.push(JSON.stringify(text.slice(lastIndex, index))); |
| 7582 |
} |
| 7583 |
// tag token |
| 7584 |
var exp = parseFilters(match[1].trim()); |
| 7585 |
tokens.push(("_s(" + exp + ")")); |
| 7586 |
lastIndex = index + match[0].length; |
| 7587 |
} |
| 7588 |
if (lastIndex < text.length) { |
| 7589 |
tokens.push(JSON.stringify(text.slice(lastIndex))); |
| 7590 |
} |
| 7591 |
return tokens.join('+') |
| 7592 |
} |
| 7593 |
|
| 7594 |
/* */ |
| 7595 |
|
| 7596 |
var onRE = /^@|^v-on:/; |
| 7597 |
var dirRE = /^v-|^@|^:/; |
| 7598 |
var forAliasRE = /(.*?)\s+(?:in|of)\s+(.*)/; |
| 7599 |
var forIteratorRE = /\((\{[^}]*\}|[^,]*),([^,]*)(?:,([^,]*))?\)/; |
| 7600 |
|
| 7601 |
var argRE = /:(.*)$/; |
| 7602 |
var bindRE = /^:|^v-bind:/; |
| 7603 |
var modifierRE = /\.[^.]+/g; |
| 7604 |
|
| 7605 |
var decodeHTMLCached = cached(decode); |
| 7606 |
|
| 7607 |
// configurable state |
| 7608 |
var warn$2; |
| 7609 |
var delimiters; |
| 7610 |
var transforms; |
| 7611 |
var preTransforms; |
| 7612 |
var postTransforms; |
| 7613 |
var platformIsPreTag; |
| 7614 |
var platformMustUseProp; |
| 7615 |
var platformGetTagNamespace; |
| 7616 |
|
| 7617 |
/** |
| 7618 |
* Convert HTML string to AST. |
| 7619 |
*/ |
| 7620 |
function parse ( |
| 7621 |
template, |
| 7622 |
options |
| 7623 |
) { |
| 7624 |
warn$2 = options.warn || baseWarn; |
| 7625 |
platformGetTagNamespace = options.getTagNamespace || no; |
| 7626 |
platformMustUseProp = options.mustUseProp || no; |
| 7627 |
platformIsPreTag = options.isPreTag || no; |
| 7628 |
preTransforms = pluckModuleFunction(options.modules, 'preTransformNode'); |
| 7629 |
transforms = pluckModuleFunction(options.modules, 'transformNode'); |
| 7630 |
postTransforms = pluckModuleFunction(options.modules, 'postTransformNode'); |
| 7631 |
delimiters = options.delimiters; |
| 7632 |
|
| 7633 |
var stack = []; |
| 7634 |
var preserveWhitespace = options.preserveWhitespace !== false; |
| 7635 |
var root; |
| 7636 |
var currentParent; |
| 7637 |
var inVPre = false; |
| 7638 |
var inPre = false; |
| 7639 |
var warned = false; |
| 7640 |
|
| 7641 |
function warnOnce (msg) { |
| 7642 |
if (!warned) { |
| 7643 |
warned = true; |
| 7644 |
warn$2(msg); |
| 7645 |
} |
| 7646 |
} |
| 7647 |
|
| 7648 |
function endPre (element) { |
| 7649 |
// check pre state |
| 7650 |
if (element.pre) { |
| 7651 |
inVPre = false; |
| 7652 |
} |
| 7653 |
if (platformIsPreTag(element.tag)) { |
| 7654 |
inPre = false; |
| 7655 |
} |
| 7656 |
} |
| 7657 |
|
| 7658 |
parseHTML(template, { |
| 7659 |
warn: warn$2, |
| 7660 |
expectHTML: options.expectHTML, |
| 7661 |
isUnaryTag: options.isUnaryTag, |
| 7662 |
shouldDecodeNewlines: options.shouldDecodeNewlines, |
| 7663 |
start: function start (tag, attrs, unary) { |
| 7664 |
// check namespace. |
| 7665 |
// inherit parent ns if there is one |
| 7666 |
var ns = (currentParent && currentParent.ns) || platformGetTagNamespace(tag); |
| 7667 |
|
| 7668 |
// handle IE svg bug |
| 7669 |
/* istanbul ignore if */ |
| 7670 |
if (isIE && ns === 'svg') { |
| 7671 |
attrs = guardIESVGBug(attrs); |
| 7672 |
} |
| 7673 |
|
| 7674 |
var element = { |
| 7675 |
type: 1, |
| 7676 |
tag: tag, |
| 7677 |
attrsList: attrs, |
| 7678 |
attrsMap: makeAttrsMap(attrs), |
| 7679 |
parent: currentParent, |
| 7680 |
children: [] |
| 7681 |
}; |
| 7682 |
if (ns) { |
| 7683 |
element.ns = ns; |
| 7684 |
} |
| 7685 |
|
| 7686 |
if (isForbiddenTag(element) && !isServerRendering()) { |
| 7687 |
element.forbidden = true; |
| 7688 |
"development" !== 'production' && warn$2( |
| 7689 |
'Templates should only be responsible for mapping the state to the ' + |
| 7690 |
'UI. Avoid placing tags with side-effects in your templates, such as ' + |
| 7691 |
"<" + tag + ">" + ', as they will not be parsed.' |
| 7692 |
); |
| 7693 |
} |
| 7694 |
|
| 7695 |
// apply pre-transforms |
| 7696 |
for (var i = 0; i < preTransforms.length; i++) { |
| 7697 |
preTransforms[i](element, options); |
| 7698 |
} |
| 7699 |
|
| 7700 |
if (!inVPre) { |
| 7701 |
processPre(element); |
| 7702 |
if (element.pre) { |
| 7703 |
inVPre = true; |
| 7704 |
} |
| 7705 |
} |
| 7706 |
if (platformIsPreTag(element.tag)) { |
| 7707 |
inPre = true; |
| 7708 |
} |
| 7709 |
if (inVPre) { |
| 7710 |
processRawAttrs(element); |
| 7711 |
} else { |
| 7712 |
processFor(element); |
| 7713 |
processIf(element); |
| 7714 |
processOnce(element); |
| 7715 |
processKey(element); |
| 7716 |
|
| 7717 |
// determine whether this is a plain element after |
| 7718 |
// removing structural attributes |
| 7719 |
element.plain = !element.key && !attrs.length; |
| 7720 |
|
| 7721 |
processRef(element); |
| 7722 |
processSlot(element); |
| 7723 |
processComponent(element); |
| 7724 |
for (var i$1 = 0; i$1 < transforms.length; i$1++) { |
| 7725 |
transforms[i$1](element, options); |
| 7726 |
} |
| 7727 |
processAttrs(element); |
| 7728 |
} |
| 7729 |
|
| 7730 |
function checkRootConstraints (el) { |
| 7731 |
{ |
| 7732 |
if (el.tag === 'slot' || el.tag === 'template') { |
| 7733 |
warnOnce( |
| 7734 |
"Cannot use <" + (el.tag) + "> as component root element because it may " + |
| 7735 |
'contain multiple nodes.' |
| 7736 |
); |
| 7737 |
} |
| 7738 |
if (el.attrsMap.hasOwnProperty('v-for')) { |
| 7739 |
warnOnce( |
| 7740 |
'Cannot use v-for on stateful component root element because ' + |
| 7741 |
'it renders multiple elements.' |
| 7742 |
); |
| 7743 |
} |
| 7744 |
} |
| 7745 |
} |
| 7746 |
|
| 7747 |
// tree management |
| 7748 |
if (!root) { |
| 7749 |
root = element; |
| 7750 |
checkRootConstraints(root); |
| 7751 |
} else if (!stack.length) { |
| 7752 |
// allow root elements with v-if, v-else-if and v-else |
| 7753 |
if (root.if && (element.elseif || element.else)) { |
| 7754 |
checkRootConstraints(element); |
| 7755 |
addIfCondition(root, { |
| 7756 |
exp: element.elseif, |
| 7757 |
block: element |
| 7758 |
}); |
| 7759 |
} else { |
| 7760 |
warnOnce( |
| 7761 |
"Component template should contain exactly one root element. " + |
| 7762 |
"If you are using v-if on multiple elements, " + |
| 7763 |
"use v-else-if to chain them instead." |
| 7764 |
); |
| 7765 |
} |
| 7766 |
} |
| 7767 |
if (currentParent && !element.forbidden) { |
| 7768 |
if (element.elseif || element.else) { |
| 7769 |
processIfConditions(element, currentParent); |
| 7770 |
} else if (element.slotScope) { // scoped slot |
| 7771 |
currentParent.plain = false; |
| 7772 |
var name = element.slotTarget || '"default"';(currentParent.scopedSlots || (currentParent.scopedSlots = {}))[name] = element; |
| 7773 |
} else { |
| 7774 |
currentParent.children.push(element); |
| 7775 |
element.parent = currentParent; |
| 7776 |
} |
| 7777 |
} |
| 7778 |
if (!unary) { |
| 7779 |
currentParent = element; |
| 7780 |
stack.push(element); |
| 7781 |
} else { |
| 7782 |
endPre(element); |
| 7783 |
} |
| 7784 |
// apply post-transforms |
| 7785 |
for (var i$2 = 0; i$2 < postTransforms.length; i$2++) { |
| 7786 |
postTransforms[i$2](element, options); |
| 7787 |
} |
| 7788 |
}, |
| 7789 |
|
| 7790 |
end: function end () { |
| 7791 |
// remove trailing whitespace |
| 7792 |
var element = stack[stack.length - 1]; |
| 7793 |
var lastNode = element.children[element.children.length - 1]; |
| 7794 |
if (lastNode && lastNode.type === 3 && lastNode.text === ' ' && !inPre) { |
| 7795 |
element.children.pop(); |
| 7796 |
} |
| 7797 |
// pop stack |
| 7798 |
stack.length -= 1; |
| 7799 |
currentParent = stack[stack.length - 1]; |
| 7800 |
endPre(element); |
| 7801 |
}, |
| 7802 |
|
| 7803 |
chars: function chars (text) { |
| 7804 |
if (!currentParent) { |
| 7805 |
{ |
| 7806 |
if (text === template) { |
| 7807 |
warnOnce( |
| 7808 |
'Component template requires a root element, rather than just text.' |
| 7809 |
); |
| 7810 |
} else if ((text = text.trim())) { |
| 7811 |
warnOnce( |
| 7812 |
("text \"" + text + "\" outside root element will be ignored.") |
| 7813 |
); |
| 7814 |
} |
| 7815 |
} |
| 7816 |
return |
| 7817 |
} |
| 7818 |
// IE textarea placeholder bug |
| 7819 |
/* istanbul ignore if */ |
| 7820 |
if (isIE && |
| 7821 |
currentParent.tag === 'textarea' && |
| 7822 |
currentParent.attrsMap.placeholder === text) { |
| 7823 |
return |
| 7824 |
} |
| 7825 |
var children = currentParent.children; |
| 7826 |
text = inPre || text.trim() |
| 7827 |
? decodeHTMLCached(text) |
| 7828 |
// only preserve whitespace if its not right after a starting tag |
| 7829 |
: preserveWhitespace && children.length ? ' ' : ''; |
| 7830 |
if (text) { |
| 7831 |
var expression; |
| 7832 |
if (!inVPre && text !== ' ' && (expression = parseText(text, delimiters))) { |
| 7833 |
children.push({ |
| 7834 |
type: 2, |
| 7835 |
expression: expression, |
| 7836 |
text: text |
| 7837 |
}); |
| 7838 |
} else if (text !== ' ' || !children.length || children[children.length - 1].text !== ' ') { |
| 7839 |
children.push({ |
| 7840 |
type: 3, |
| 7841 |
text: text |
| 7842 |
}); |
| 7843 |
} |
| 7844 |
} |
| 7845 |
} |
| 7846 |
}); |
| 7847 |
return root |
| 7848 |
} |
| 7849 |
|
| 7850 |
function processPre (el) { |
| 7851 |
if (getAndRemoveAttr(el, 'v-pre') != null) { |
| 7852 |
el.pre = true; |
| 7853 |
} |
| 7854 |
} |
| 7855 |
|
| 7856 |
function processRawAttrs (el) { |
| 7857 |
var l = el.attrsList.length; |
| 7858 |
if (l) { |
| 7859 |
var attrs = el.attrs = new Array(l); |
| 7860 |
for (var i = 0; i < l; i++) { |
| 7861 |
attrs[i] = { |
| 7862 |
name: el.attrsList[i].name, |
| 7863 |
value: JSON.stringify(el.attrsList[i].value) |
| 7864 |
}; |
| 7865 |
} |
| 7866 |
} else if (!el.pre) { |
| 7867 |
// non root node in pre blocks with no attributes |
| 7868 |
el.plain = true; |
| 7869 |
} |
| 7870 |
} |
| 7871 |
|
| 7872 |
function processKey (el) { |
| 7873 |
var exp = getBindingAttr(el, 'key'); |
| 7874 |
if (exp) { |
| 7875 |
if ("development" !== 'production' && el.tag === 'template') { |
| 7876 |
warn$2("<template> cannot be keyed. Place the key on real elements instead."); |
| 7877 |
} |
| 7878 |
el.key = exp; |
| 7879 |
} |
| 7880 |
} |
| 7881 |
|
| 7882 |
function processRef (el) { |
| 7883 |
var ref = getBindingAttr(el, 'ref'); |
| 7884 |
if (ref) { |
| 7885 |
el.ref = ref; |
| 7886 |
el.refInFor = checkInFor(el); |
| 7887 |
} |
| 7888 |
} |
| 7889 |
|
| 7890 |
function processFor (el) { |
| 7891 |
var exp; |
| 7892 |
if ((exp = getAndRemoveAttr(el, 'v-for'))) { |
| 7893 |
var inMatch = exp.match(forAliasRE); |
| 7894 |
if (!inMatch) { |
| 7895 |
"development" !== 'production' && warn$2( |
| 7896 |
("Invalid v-for expression: " + exp) |
| 7897 |
); |
| 7898 |
return |
| 7899 |
} |
| 7900 |
el.for = inMatch[2].trim(); |
| 7901 |
var alias = inMatch[1].trim(); |
| 7902 |
var iteratorMatch = alias.match(forIteratorRE); |
| 7903 |
if (iteratorMatch) { |
| 7904 |
el.alias = iteratorMatch[1].trim(); |
| 7905 |
el.iterator1 = iteratorMatch[2].trim(); |
| 7906 |
if (iteratorMatch[3]) { |
| 7907 |
el.iterator2 = iteratorMatch[3].trim(); |
| 7908 |
} |
| 7909 |
} else { |
| 7910 |
el.alias = alias; |
| 7911 |
} |
| 7912 |
} |
| 7913 |
} |
| 7914 |
|
| 7915 |
function processIf (el) { |
| 7916 |
var exp = getAndRemoveAttr(el, 'v-if'); |
| 7917 |
if (exp) { |
| 7918 |
el.if = exp; |
| 7919 |
addIfCondition(el, { |
| 7920 |
exp: exp, |
| 7921 |
block: el |
| 7922 |
}); |
| 7923 |
} else { |
| 7924 |
if (getAndRemoveAttr(el, 'v-else') != null) { |
| 7925 |
el.else = true; |
| 7926 |
} |
| 7927 |
var elseif = getAndRemoveAttr(el, 'v-else-if'); |
| 7928 |
if (elseif) { |
| 7929 |
el.elseif = elseif; |
| 7930 |
} |
| 7931 |
} |
| 7932 |
} |
| 7933 |
|
| 7934 |
function processIfConditions (el, parent) { |
| 7935 |
var prev = findPrevElement(parent.children); |
| 7936 |
if (prev && prev.if) { |
| 7937 |
addIfCondition(prev, { |
| 7938 |
exp: el.elseif, |
| 7939 |
block: el |
| 7940 |
}); |
| 7941 |
} else { |
| 7942 |
warn$2( |
| 7943 |
"v-" + (el.elseif ? ('else-if="' + el.elseif + '"') : 'else') + " " + |
| 7944 |
"used on element <" + (el.tag) + "> without corresponding v-if." |
| 7945 |
); |
| 7946 |
} |
| 7947 |
} |
| 7948 |
|
| 7949 |
function findPrevElement (children) { |
| 7950 |
var i = children.length; |
| 7951 |
while (i--) { |
| 7952 |
if (children[i].type === 1) { |
| 7953 |
return children[i] |
| 7954 |
} else { |
| 7955 |
if ("development" !== 'production' && children[i].text !== ' ') { |
| 7956 |
warn$2( |
| 7957 |
"text \"" + (children[i].text.trim()) + "\" between v-if and v-else(-if) " + |
| 7958 |
"will be ignored." |
| 7959 |
); |
| 7960 |
} |
| 7961 |
children.pop(); |
| 7962 |
} |
| 7963 |
} |
| 7964 |
} |
| 7965 |
|
| 7966 |
function addIfCondition (el, condition) { |
| 7967 |
if (!el.ifConditions) { |
| 7968 |
el.ifConditions = []; |
| 7969 |
} |
| 7970 |
el.ifConditions.push(condition); |
| 7971 |
} |
| 7972 |
|
| 7973 |
function processOnce (el) { |
| 7974 |
var once$$1 = getAndRemoveAttr(el, 'v-once'); |
| 7975 |
if (once$$1 != null) { |
| 7976 |
el.once = true; |
| 7977 |
} |
| 7978 |
} |
| 7979 |
|
| 7980 |
function processSlot (el) { |
| 7981 |
if (el.tag === 'slot') { |
| 7982 |
el.slotName = getBindingAttr(el, 'name'); |
| 7983 |
if ("development" !== 'production' && el.key) { |
| 7984 |
warn$2( |
| 7985 |
"`key` does not work on <slot> because slots are abstract outlets " + |
| 7986 |
"and can possibly expand into multiple elements. " + |
| 7987 |
"Use the key on a wrapping element instead." |
| 7988 |
); |
| 7989 |
} |
| 7990 |
} else { |
| 7991 |
var slotTarget = getBindingAttr(el, 'slot'); |
| 7992 |
if (slotTarget) { |
| 7993 |
el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget; |
| 7994 |
} |
| 7995 |
if (el.tag === 'template') { |
| 7996 |
el.slotScope = getAndRemoveAttr(el, 'scope'); |
| 7997 |
} |
| 7998 |
} |
| 7999 |
} |
| 8000 |
|
| 8001 |
function processComponent (el) { |
| 8002 |
var binding; |
| 8003 |
if ((binding = getBindingAttr(el, 'is'))) { |
| 8004 |
el.component = binding; |
| 8005 |
} |
| 8006 |
if (getAndRemoveAttr(el, 'inline-template') != null) { |
| 8007 |
el.inlineTemplate = true; |
| 8008 |
} |
| 8009 |
} |
| 8010 |
|
| 8011 |
function processAttrs (el) { |
| 8012 |
var list = el.attrsList; |
| 8013 |
var i, l, name, rawName, value, modifiers, isProp; |
| 8014 |
for (i = 0, l = list.length; i < l; i++) { |
| 8015 |
name = rawName = list[i].name; |
| 8016 |
value = list[i].value; |
| 8017 |
if (dirRE.test(name)) { |
| 8018 |
// mark element as dynamic |
| 8019 |
el.hasBindings = true; |
| 8020 |
// modifiers |
| 8021 |
modifiers = parseModifiers(name); |
| 8022 |
if (modifiers) { |
| 8023 |
name = name.replace(modifierRE, ''); |
| 8024 |
} |
| 8025 |
if (bindRE.test(name)) { // v-bind |
| 8026 |
name = name.replace(bindRE, ''); |
| 8027 |
value = parseFilters(value); |
| 8028 |
isProp = false; |
| 8029 |
if (modifiers) { |
| 8030 |
if (modifiers.prop) { |
| 8031 |
isProp = true; |
| 8032 |
name = camelize(name); |
| 8033 |
if (name === 'innerHtml') { name = 'innerHTML'; } |
| 8034 |
} |
| 8035 |
if (modifiers.camel) { |
| 8036 |
name = camelize(name); |
| 8037 |
} |
| 8038 |
} |
| 8039 |
if (isProp || platformMustUseProp(el.tag, el.attrsMap.type, name)) { |
| 8040 |
addProp(el, name, value); |
| 8041 |
} else { |
| 8042 |
addAttr(el, name, value); |
| 8043 |
} |
| 8044 |
} else if (onRE.test(name)) { // v-on |
| 8045 |
name = name.replace(onRE, ''); |
| 8046 |
addHandler(el, name, value, modifiers); |
| 8047 |
} else { // normal directives |
| 8048 |
name = name.replace(dirRE, ''); |
| 8049 |
// parse arg |
| 8050 |
var argMatch = name.match(argRE); |
| 8051 |
var arg = argMatch && argMatch[1]; |
| 8052 |
if (arg) { |
| 8053 |
name = name.slice(0, -(arg.length + 1)); |
| 8054 |
} |
| 8055 |
addDirective(el, name, rawName, value, arg, modifiers); |
| 8056 |
if ("development" !== 'production' && name === 'model') { |
| 8057 |
checkForAliasModel(el, value); |
| 8058 |
} |
| 8059 |
} |
| 8060 |
} else { |
| 8061 |
// literal attribute |
| 8062 |
{ |
| 8063 |
var expression = parseText(value, delimiters); |
| 8064 |
if (expression) { |
| 8065 |
warn$2( |
| 8066 |
name + "=\"" + value + "\": " + |
| 8067 |
'Interpolation inside attributes has been removed. ' + |
| 8068 |
'Use v-bind or the colon shorthand instead. For example, ' + |
| 8069 |
'instead of <div id="{{ val }}">, use <div :id="val">.' |
| 8070 |
); |
| 8071 |
} |
| 8072 |
} |
| 8073 |
addAttr(el, name, JSON.stringify(value)); |
| 8074 |
} |
| 8075 |
} |
| 8076 |
} |
| 8077 |
|
| 8078 |
function checkInFor (el) { |
| 8079 |
var parent = el; |
| 8080 |
while (parent) { |
| 8081 |
if (parent.for !== undefined) { |
| 8082 |
return true |
| 8083 |
} |
| 8084 |
parent = parent.parent; |
| 8085 |
} |
| 8086 |
return false |
| 8087 |
} |
| 8088 |
|
| 8089 |
function parseModifiers (name) { |
| 8090 |
var match = name.match(modifierRE); |
| 8091 |
if (match) { |
| 8092 |
var ret = {}; |
| 8093 |
match.forEach(function (m) { ret[m.slice(1)] = true; }); |
| 8094 |
return ret |
| 8095 |
} |
| 8096 |
} |
| 8097 |
|
| 8098 |
function makeAttrsMap (attrs) { |
| 8099 |
var map = {}; |
| 8100 |
for (var i = 0, l = attrs.length; i < l; i++) { |
| 8101 |
if ("development" !== 'production' && map[attrs[i].name] && !isIE) { |
| 8102 |
warn$2('duplicate attribute: ' + attrs[i].name); |
| 8103 |
} |
| 8104 |
map[attrs[i].name] = attrs[i].value; |
| 8105 |
} |
| 8106 |
return map |
| 8107 |
} |
| 8108 |
|
| 8109 |
function isForbiddenTag (el) { |
| 8110 |
return ( |
| 8111 |
el.tag === 'style' || |
| 8112 |
(el.tag === 'script' && ( |
| 8113 |
!el.attrsMap.type || |
| 8114 |
el.attrsMap.type === 'text/javascript' |
| 8115 |
)) |
| 8116 |
) |
| 8117 |
} |
| 8118 |
|
| 8119 |
var ieNSBug = /^xmlns:NS\d+/; |
| 8120 |
var ieNSPrefix = /^NS\d+:/; |
| 8121 |
|
| 8122 |
/* istanbul ignore next */ |
| 8123 |
function guardIESVGBug (attrs) { |
| 8124 |
var res = []; |
| 8125 |
for (var i = 0; i < attrs.length; i++) { |
| 8126 |
var attr = attrs[i]; |
| 8127 |
if (!ieNSBug.test(attr.name)) { |
| 8128 |
attr.name = attr.name.replace(ieNSPrefix, ''); |
| 8129 |
res.push(attr); |
| 8130 |
} |
| 8131 |
} |
| 8132 |
return res |
| 8133 |
} |
| 8134 |
|
| 8135 |
function checkForAliasModel (el, value) { |
| 8136 |
var _el = el; |
| 8137 |
while (_el) { |
| 8138 |
if (_el.for && _el.alias === value) { |
| 8139 |
warn$2( |
| 8140 |
"<" + (el.tag) + " v-model=\"" + value + "\">: " + |
| 8141 |
"You are binding v-model directly to a v-for iteration alias. " + |
| 8142 |
"This will not be able to modify the v-for source array because " + |
| 8143 |
"writing to the alias is like modifying a function local variable. " + |
| 8144 |
"Consider using an array of objects and use v-model on an object property instead." |
| 8145 |
); |
| 8146 |
} |
| 8147 |
_el = _el.parent; |
| 8148 |
} |
| 8149 |
} |
| 8150 |
|
| 8151 |
/* */ |
| 8152 |
|
| 8153 |
var isStaticKey; |
| 8154 |
var isPlatformReservedTag; |
| 8155 |
|
| 8156 |
var genStaticKeysCached = cached(genStaticKeys$1); |
| 8157 |
|
| 8158 |
/** |
| 8159 |
* Goal of the optimizer: walk the generated template AST tree |
| 8160 |
* and detect sub-trees that are purely static, i.e. parts of |
| 8161 |
* the DOM that never needs to change. |
| 8162 |
* |
| 8163 |
* Once we detect these sub-trees, we can: |
| 8164 |
* |
| 8165 |
* 1. Hoist them into constants, so that we no longer need to |
| 8166 |
* create fresh nodes for them on each re-render; |
| 8167 |
* 2. Completely skip them in the patching process. |
| 8168 |
*/ |
| 8169 |
function optimize (root, options) { |
| 8170 |
if (!root) { return } |
| 8171 |
isStaticKey = genStaticKeysCached(options.staticKeys || ''); |
| 8172 |
isPlatformReservedTag = options.isReservedTag || no; |
| 8173 |
// first pass: mark all non-static nodes. |
| 8174 |
markStatic$1(root); |
| 8175 |
// second pass: mark static roots. |
| 8176 |
markStaticRoots(root, false); |
| 8177 |
} |
| 8178 |
|
| 8179 |
function genStaticKeys$1 (keys) { |
| 8180 |
return makeMap( |
| 8181 |
'type,tag,attrsList,attrsMap,plain,parent,children,attrs' + |
| 8182 |
(keys ? ',' + keys : '') |
| 8183 |
) |
| 8184 |
} |
| 8185 |
|
| 8186 |
function markStatic$1 (node) { |
| 8187 |
node.static = isStatic(node); |
| 8188 |
if (node.type === 1) { |
| 8189 |
// do not make component slot content static. this avoids |
| 8190 |
// 1. components not able to mutate slot nodes |
| 8191 |
// 2. static slot content fails for hot-reloading |
| 8192 |
if ( |
| 8193 |
!isPlatformReservedTag(node.tag) && |
| 8194 |
node.tag !== 'slot' && |
| 8195 |
node.attrsMap['inline-template'] == null |
| 8196 |
) { |
| 8197 |
return |
| 8198 |
} |
| 8199 |
for (var i = 0, l = node.children.length; i < l; i++) { |
| 8200 |
var child = node.children[i]; |
| 8201 |
markStatic$1(child); |
| 8202 |
if (!child.static) { |
| 8203 |
node.static = false; |
| 8204 |
} |
| 8205 |
} |
| 8206 |
} |
| 8207 |
} |
| 8208 |
|
| 8209 |
function markStaticRoots (node, isInFor) { |
| 8210 |
if (node.type === 1) { |
| 8211 |
if (node.static || node.once) { |
| 8212 |
node.staticInFor = isInFor; |
| 8213 |
} |
| 8214 |
// For a node to qualify as a static root, it should have children that |
| 8215 |
// are not just static text. Otherwise the cost of hoisting out will |
| 8216 |
// outweigh the benefits and it's better off to just always render it fresh. |
| 8217 |
if (node.static && node.children.length && !( |
| 8218 |
node.children.length === 1 && |
| 8219 |
node.children[0].type === 3 |
| 8220 |
)) { |
| 8221 |
node.staticRoot = true; |
| 8222 |
return |
| 8223 |
} else { |
| 8224 |
node.staticRoot = false; |
| 8225 |
} |
| 8226 |
if (node.children) { |
| 8227 |
for (var i = 0, l = node.children.length; i < l; i++) { |
| 8228 |
markStaticRoots(node.children[i], isInFor || !!node.for); |
| 8229 |
} |
| 8230 |
} |
| 8231 |
if (node.ifConditions) { |
| 8232 |
walkThroughConditionsBlocks(node.ifConditions, isInFor); |
| 8233 |
} |
| 8234 |
} |
| 8235 |
} |
| 8236 |
|
| 8237 |
function walkThroughConditionsBlocks (conditionBlocks, isInFor) { |
| 8238 |
for (var i = 1, len = conditionBlocks.length; i < len; i++) { |
| 8239 |
markStaticRoots(conditionBlocks[i].block, isInFor); |
| 8240 |
} |
| 8241 |
} |
| 8242 |
|
| 8243 |
function isStatic (node) { |
| 8244 |
if (node.type === 2) { // expression |
| 8245 |
return false |
| 8246 |
} |
| 8247 |
if (node.type === 3) { // text |
| 8248 |
return true |
| 8249 |
} |
| 8250 |
return !!(node.pre || ( |
| 8251 |
!node.hasBindings && // no dynamic bindings |
| 8252 |
!node.if && !node.for && // not v-if or v-for or v-else |
| 8253 |
!isBuiltInTag(node.tag) && // not a built-in |
| 8254 |
isPlatformReservedTag(node.tag) && // not a component |
| 8255 |
!isDirectChildOfTemplateFor(node) && |
| 8256 |
Object.keys(node).every(isStaticKey) |
| 8257 |
)) |
| 8258 |
} |
| 8259 |
|
| 8260 |
function isDirectChildOfTemplateFor (node) { |
| 8261 |
while (node.parent) { |
| 8262 |
node = node.parent; |
| 8263 |
if (node.tag !== 'template') { |
| 8264 |
return false |
| 8265 |
} |
| 8266 |
if (node.for) { |
| 8267 |
return true |
| 8268 |
} |
| 8269 |
} |
| 8270 |
return false |
| 8271 |
} |
| 8272 |
|
| 8273 |
/* */ |
| 8274 |
|
| 8275 |
var fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/; |
| 8276 |
var simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/; |
| 8277 |
|
| 8278 |
// keyCode aliases |
| 8279 |
var keyCodes = { |
| 8280 |
esc: 27, |
| 8281 |
tab: 9, |
| 8282 |
enter: 13, |
| 8283 |
space: 32, |
| 8284 |
up: 38, |
| 8285 |
left: 37, |
| 8286 |
right: 39, |
| 8287 |
down: 40, |
| 8288 |
'delete': [8, 46] |
| 8289 |
}; |
| 8290 |
|
| 8291 |
// #4868: modifiers that prevent the execution of the listener |
| 8292 |
// need to explicitly return null so that we can determine whether to remove |
| 8293 |
// the listener for .once |
| 8294 |
var genGuard = function (condition) { return ("if(" + condition + ")return null;"); }; |
| 8295 |
|
| 8296 |
var modifierCode = { |
| 8297 |
stop: '$event.stopPropagation();', |
| 8298 |
prevent: '$event.preventDefault();', |
| 8299 |
self: genGuard("$event.target !== $event.currentTarget"), |
| 8300 |
ctrl: genGuard("!$event.ctrlKey"), |
| 8301 |
shift: genGuard("!$event.shiftKey"), |
| 8302 |
alt: genGuard("!$event.altKey"), |
| 8303 |
meta: genGuard("!$event.metaKey"), |
| 8304 |
left: genGuard("'button' in $event && $event.button !== 0"), |
| 8305 |
middle: genGuard("'button' in $event && $event.button !== 1"), |
| 8306 |
right: genGuard("'button' in $event && $event.button !== 2") |
| 8307 |
}; |
| 8308 |
|
| 8309 |
function genHandlers (events, native) { |
| 8310 |
var res = native ? 'nativeOn:{' : 'on:{'; |
| 8311 |
for (var name in events) { |
| 8312 |
res += "\"" + name + "\":" + (genHandler(name, events[name])) + ","; |
| 8313 |
} |
| 8314 |
return res.slice(0, -1) + '}' |
| 8315 |
} |
| 8316 |
|
| 8317 |
function genHandler ( |
| 8318 |
name, |
| 8319 |
handler |
| 8320 |
) { |
| 8321 |
if (!handler) { |
| 8322 |
return 'function(){}' |
| 8323 |
} |
| 8324 |
|
| 8325 |
if (Array.isArray(handler)) { |
| 8326 |
return ("[" + (handler.map(function (handler) { return genHandler(name, handler); }).join(',')) + "]") |
| 8327 |
} |
| 8328 |
|
| 8329 |
var isMethodPath = simplePathRE.test(handler.value); |
| 8330 |
var isFunctionExpression = fnExpRE.test(handler.value); |
| 8331 |
|
| 8332 |
if (!handler.modifiers) { |
| 8333 |
return isMethodPath || isFunctionExpression |
| 8334 |
? handler.value |
| 8335 |
: ("function($event){" + (handler.value) + "}") // inline statement |
| 8336 |
} else { |
| 8337 |
var code = ''; |
| 8338 |
var genModifierCode = ''; |
| 8339 |
var keys = []; |
| 8340 |
for (var key in handler.modifiers) { |
| 8341 |
if (modifierCode[key]) { |
| 8342 |
genModifierCode += modifierCode[key]; |
| 8343 |
// left/right |
| 8344 |
if (keyCodes[key]) { |
| 8345 |
keys.push(key); |
| 8346 |
} |
| 8347 |
} else { |
| 8348 |
keys.push(key); |
| 8349 |
} |
| 8350 |
} |
| 8351 |
if (keys.length) { |
| 8352 |
code += genKeyFilter(keys); |
| 8353 |
} |
| 8354 |
// Make sure modifiers like prevent and stop get executed after key filtering |
| 8355 |
if (genModifierCode) { |
| 8356 |
code += genModifierCode; |
| 8357 |
} |
| 8358 |
var handlerCode = isMethodPath |
| 8359 |
? handler.value + '($event)' |
| 8360 |
: isFunctionExpression |
| 8361 |
? ("(" + (handler.value) + ")($event)") |
| 8362 |
: handler.value; |
| 8363 |
return ("function($event){" + code + handlerCode + "}") |
| 8364 |
} |
| 8365 |
} |
| 8366 |
|
| 8367 |
function genKeyFilter (keys) { |
| 8368 |
return ("if(!('button' in $event)&&" + (keys.map(genFilterCode).join('&&')) + ")return null;") |
| 8369 |
} |
| 8370 |
|
| 8371 |
function genFilterCode (key) { |
| 8372 |
var keyVal = parseInt(key, 10); |
| 8373 |
if (keyVal) { |
| 8374 |
return ("$event.keyCode!==" + keyVal) |
| 8375 |
} |
| 8376 |
var alias = keyCodes[key]; |
| 8377 |
return ("_k($event.keyCode," + (JSON.stringify(key)) + (alias ? ',' + JSON.stringify(alias) : '') + ")") |
| 8378 |
} |
| 8379 |
|
| 8380 |
/* */ |
| 8381 |
|
| 8382 |
function bind$1 (el, dir) { |
| 8383 |
el.wrapData = function (code) { |
| 8384 |
return ("_b(" + code + ",'" + (el.tag) + "'," + (dir.value) + (dir.modifiers && dir.modifiers.prop ? ',true' : '') + ")") |
| 8385 |
}; |
| 8386 |
} |
| 8387 |
|
| 8388 |
/* */ |
| 8389 |
|
| 8390 |
var baseDirectives = { |
| 8391 |
bind: bind$1, |
| 8392 |
cloak: noop |
| 8393 |
}; |
| 8394 |
|
| 8395 |
/* */ |
| 8396 |
|
| 8397 |
// configurable state |
| 8398 |
var warn$3; |
| 8399 |
var transforms$1; |
| 8400 |
var dataGenFns; |
| 8401 |
var platformDirectives$1; |
| 8402 |
var isPlatformReservedTag$1; |
| 8403 |
var staticRenderFns; |
| 8404 |
var onceCount; |
| 8405 |
var currentOptions; |
| 8406 |
|
| 8407 |
function generate ( |
| 8408 |
ast, |
| 8409 |
options |
| 8410 |
) { |
| 8411 |
// save previous staticRenderFns so generate calls can be nested |
| 8412 |
var prevStaticRenderFns = staticRenderFns; |
| 8413 |
var currentStaticRenderFns = staticRenderFns = []; |
| 8414 |
var prevOnceCount = onceCount; |
| 8415 |
onceCount = 0; |
| 8416 |
currentOptions = options; |
| 8417 |
warn$3 = options.warn || baseWarn; |
| 8418 |
transforms$1 = pluckModuleFunction(options.modules, 'transformCode'); |
| 8419 |
dataGenFns = pluckModuleFunction(options.modules, 'genData'); |
| 8420 |
platformDirectives$1 = options.directives || {}; |
| 8421 |
isPlatformReservedTag$1 = options.isReservedTag || no; |
| 8422 |
var code = ast ? genElement(ast) : '_c("div")'; |
| 8423 |
staticRenderFns = prevStaticRenderFns; |
| 8424 |
onceCount = prevOnceCount; |
| 8425 |
return { |
| 8426 |
render: ("with(this){return " + code + "}"), |
| 8427 |
staticRenderFns: currentStaticRenderFns |
| 8428 |
} |
| 8429 |
} |
| 8430 |
|
| 8431 |
function genElement (el) { |
| 8432 |
if (el.staticRoot && !el.staticProcessed) { |
| 8433 |
return genStatic(el) |
| 8434 |
} else if (el.once && !el.onceProcessed) { |
| 8435 |
return genOnce(el) |
| 8436 |
} else if (el.for && !el.forProcessed) { |
| 8437 |
return genFor(el) |
| 8438 |
} else if (el.if && !el.ifProcessed) { |
| 8439 |
return genIf(el) |
| 8440 |
} else if (el.tag === 'template' && !el.slotTarget) { |
| 8441 |
return genChildren(el) || 'void 0' |
| 8442 |
} else if (el.tag === 'slot') { |
| 8443 |
return genSlot(el) |
| 8444 |
} else { |
| 8445 |
// component or element |
| 8446 |
var code; |
| 8447 |
if (el.component) { |
| 8448 |
code = genComponent(el.component, el); |
| 8449 |
} else { |
| 8450 |
var data = el.plain ? undefined : genData(el); |
| 8451 |
|
| 8452 |
var children = el.inlineTemplate ? null : genChildren(el, true); |
| 8453 |
code = "_c('" + (el.tag) + "'" + (data ? ("," + data) : '') + (children ? ("," + children) : '') + ")"; |
| 8454 |
} |
| 8455 |
// module transforms |
| 8456 |
for (var i = 0; i < transforms$1.length; i++) { |
| 8457 |
code = transforms$1[i](el, code); |
| 8458 |
} |
| 8459 |
return code |
| 8460 |
} |
| 8461 |
} |
| 8462 |
|
| 8463 |
// hoist static sub-trees out |
| 8464 |
function genStatic (el) { |
| 8465 |
el.staticProcessed = true; |
| 8466 |
staticRenderFns.push(("with(this){return " + (genElement(el)) + "}")); |
| 8467 |
return ("_m(" + (staticRenderFns.length - 1) + (el.staticInFor ? ',true' : '') + ")") |
| 8468 |
} |
| 8469 |
|
| 8470 |
// v-once |
| 8471 |
function genOnce (el) { |
| 8472 |
el.onceProcessed = true; |
| 8473 |
if (el.if && !el.ifProcessed) { |
| 8474 |
return genIf(el) |
| 8475 |
} else if (el.staticInFor) { |
| 8476 |
var key = ''; |
| 8477 |
var parent = el.parent; |
| 8478 |
while (parent) { |
| 8479 |
if (parent.for) { |
| 8480 |
key = parent.key; |
| 8481 |
break |
| 8482 |
} |
| 8483 |
parent = parent.parent; |
| 8484 |
} |
| 8485 |
if (!key) { |
| 8486 |
"development" !== 'production' && warn$3( |
| 8487 |
"v-once can only be used inside v-for that is keyed. " |
| 8488 |
); |
| 8489 |
return genElement(el) |
| 8490 |
} |
| 8491 |
return ("_o(" + (genElement(el)) + "," + (onceCount++) + (key ? ("," + key) : "") + ")") |
| 8492 |
} else { |
| 8493 |
return genStatic(el) |
| 8494 |
} |
| 8495 |
} |
| 8496 |
|
| 8497 |
function genIf (el) { |
| 8498 |
el.ifProcessed = true; // avoid recursion |
| 8499 |
return genIfConditions(el.ifConditions.slice()) |
| 8500 |
} |
| 8501 |
|
| 8502 |
function genIfConditions (conditions) { |
| 8503 |
if (!conditions.length) { |
| 8504 |
return '_e()' |
| 8505 |
} |
| 8506 |
|
| 8507 |
var condition = conditions.shift(); |
| 8508 |
if (condition.exp) { |
| 8509 |
return ("(" + (condition.exp) + ")?" + (genTernaryExp(condition.block)) + ":" + (genIfConditions(conditions))) |
| 8510 |
} else { |
| 8511 |
return ("" + (genTernaryExp(condition.block))) |
| 8512 |
} |
| 8513 |
|
| 8514 |
// v-if with v-once should generate code like (a)?_m(0):_m(1) |
| 8515 |
function genTernaryExp (el) { |
| 8516 |
return el.once ? genOnce(el) : genElement(el) |
| 8517 |
} |
| 8518 |
} |
| 8519 |
|
| 8520 |
function genFor (el) { |
| 8521 |
var exp = el.for; |
| 8522 |
var alias = el.alias; |
| 8523 |
var iterator1 = el.iterator1 ? ("," + (el.iterator1)) : ''; |
| 8524 |
var iterator2 = el.iterator2 ? ("," + (el.iterator2)) : ''; |
| 8525 |
|
| 8526 |
if ( |
| 8527 |
"development" !== 'production' && |
| 8528 |
maybeComponent(el) && el.tag !== 'slot' && el.tag !== 'template' && !el.key |
| 8529 |
) { |
| 8530 |
warn$3( |
| 8531 |
"<" + (el.tag) + " v-for=\"" + alias + " in " + exp + "\">: component lists rendered with " + |
| 8532 |
"v-for should have explicit keys. " + |
| 8533 |
"See https://vuejs.org/guide/list.html#key for more info.", |
| 8534 |
true /* tip */ |
| 8535 |
); |
| 8536 |
} |
| 8537 |
|
| 8538 |
el.forProcessed = true; // avoid recursion |
| 8539 |
return "_l((" + exp + ")," + |
| 8540 |
"function(" + alias + iterator1 + iterator2 + "){" + |
| 8541 |
"return " + (genElement(el)) + |
| 8542 |
'})' |
| 8543 |
} |
| 8544 |
|
| 8545 |
function genData (el) { |
| 8546 |
var data = '{'; |
| 8547 |
|
| 8548 |
// directives first. |
| 8549 |
// directives may mutate the el's other properties before they are generated. |
| 8550 |
var dirs = genDirectives(el); |
| 8551 |
if (dirs) { data += dirs + ','; } |
| 8552 |
|
| 8553 |
// key |
| 8554 |
if (el.key) { |
| 8555 |
data += "key:" + (el.key) + ","; |
| 8556 |
} |
| 8557 |
// ref |
| 8558 |
if (el.ref) { |
| 8559 |
data += "ref:" + (el.ref) + ","; |
| 8560 |
} |
| 8561 |
if (el.refInFor) { |
| 8562 |
data += "refInFor:true,"; |
| 8563 |
} |
| 8564 |
// pre |
| 8565 |
if (el.pre) { |
| 8566 |
data += "pre:true,"; |
| 8567 |
} |
| 8568 |
// record original tag name for components using "is" attribute |
| 8569 |
if (el.component) { |
| 8570 |
data += "tag:\"" + (el.tag) + "\","; |
| 8571 |
} |
| 8572 |
// module data generation functions |
| 8573 |
for (var i = 0; i < dataGenFns.length; i++) { |
| 8574 |
data += dataGenFns[i](el); |
| 8575 |
} |
| 8576 |
// attributes |
| 8577 |
if (el.attrs) { |
| 8578 |
data += "attrs:{" + (genProps(el.attrs)) + "},"; |
| 8579 |
} |
| 8580 |
// DOM props |
| 8581 |
if (el.props) { |
| 8582 |
data += "domProps:{" + (genProps(el.props)) + "},"; |
| 8583 |
} |
| 8584 |
// event handlers |
| 8585 |
if (el.events) { |
| 8586 |
data += (genHandlers(el.events)) + ","; |
| 8587 |
} |
| 8588 |
if (el.nativeEvents) { |
| 8589 |
data += (genHandlers(el.nativeEvents, true)) + ","; |
| 8590 |
} |
| 8591 |
// slot target |
| 8592 |
if (el.slotTarget) { |
| 8593 |
data += "slot:" + (el.slotTarget) + ","; |
| 8594 |
} |
| 8595 |
// scoped slots |
| 8596 |
if (el.scopedSlots) { |
| 8597 |
data += (genScopedSlots(el.scopedSlots)) + ","; |
| 8598 |
} |
| 8599 |
// component v-model |
| 8600 |
if (el.model) { |
| 8601 |
data += "model:{value:" + (el.model.value) + ",callback:" + (el.model.callback) + ",expression:" + (el.model.expression) + "},"; |
| 8602 |
} |
| 8603 |
// inline-template |
| 8604 |
if (el.inlineTemplate) { |
| 8605 |
var inlineTemplate = genInlineTemplate(el); |
| 8606 |
if (inlineTemplate) { |
| 8607 |
data += inlineTemplate + ","; |
| 8608 |
} |
| 8609 |
} |
| 8610 |
data = data.replace(/,$/, '') + '}'; |
| 8611 |
// v-bind data wrap |
| 8612 |
if (el.wrapData) { |
| 8613 |
data = el.wrapData(data); |
| 8614 |
} |
| 8615 |
return data |
| 8616 |
} |
| 8617 |
|
| 8618 |
function genDirectives (el) { |
| 8619 |
var dirs = el.directives; |
| 8620 |
if (!dirs) { return } |
| 8621 |
var res = 'directives:['; |
| 8622 |
var hasRuntime = false; |
| 8623 |
var i, l, dir, needRuntime; |
| 8624 |
for (i = 0, l = dirs.length; i < l; i++) { |
| 8625 |
dir = dirs[i]; |
| 8626 |
needRuntime = true; |
| 8627 |
var gen = platformDirectives$1[dir.name] || baseDirectives[dir.name]; |
| 8628 |
if (gen) { |
| 8629 |
// compile-time directive that manipulates AST. |
| 8630 |
// returns true if it also needs a runtime counterpart. |
| 8631 |
needRuntime = !!gen(el, dir, warn$3); |
| 8632 |
} |
| 8633 |
if (needRuntime) { |
| 8634 |
hasRuntime = true; |
| 8635 |
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))) : '') + "},"; |
| 8636 |
} |
| 8637 |
} |
| 8638 |
if (hasRuntime) { |
| 8639 |
return res.slice(0, -1) + ']' |
| 8640 |
} |
| 8641 |
} |
| 8642 |
|
| 8643 |
function genInlineTemplate (el) { |
| 8644 |
var ast = el.children[0]; |
| 8645 |
if ("development" !== 'production' && ( |
| 8646 |
el.children.length > 1 || ast.type !== 1 |
| 8647 |
)) { |
| 8648 |
warn$3('Inline-template components must have exactly one child element.'); |
| 8649 |
} |
| 8650 |
if (ast.type === 1) { |
| 8651 |
var inlineRenderFns = generate(ast, currentOptions); |
| 8652 |
return ("inlineTemplate:{render:function(){" + (inlineRenderFns.render) + "},staticRenderFns:[" + (inlineRenderFns.staticRenderFns.map(function (code) { return ("function(){" + code + "}"); }).join(',')) + "]}") |
| 8653 |
} |
| 8654 |
} |
| 8655 |
|
| 8656 |
function genScopedSlots (slots) { |
| 8657 |
return ("scopedSlots:_u([" + (Object.keys(slots).map(function (key) { return genScopedSlot(key, slots[key]); }).join(',')) + "])") |
| 8658 |
} |
| 8659 |
|
| 8660 |
function genScopedSlot (key, el) { |
| 8661 |
return "[" + key + ",function(" + (String(el.attrsMap.scope)) + "){" + |
| 8662 |
"return " + (el.tag === 'template' |
| 8663 |
? genChildren(el) || 'void 0' |
| 8664 |
: genElement(el)) + "}]" |
| 8665 |
} |
| 8666 |
|
| 8667 |
function genChildren (el, checkSkip) { |
| 8668 |
var children = el.children; |
| 8669 |
if (children.length) { |
| 8670 |
var el$1 = children[0]; |
| 8671 |
// optimize single v-for |
| 8672 |
if (children.length === 1 && |
| 8673 |
el$1.for && |
| 8674 |
el$1.tag !== 'template' && |
| 8675 |
el$1.tag !== 'slot') { |
| 8676 |
return genElement(el$1) |
| 8677 |
} |
| 8678 |
var normalizationType = checkSkip ? getNormalizationType(children) : 0; |
| 8679 |
return ("[" + (children.map(genNode).join(',')) + "]" + (normalizationType ? ("," + normalizationType) : '')) |
| 8680 |
} |
| 8681 |
} |
| 8682 |
|
| 8683 |
// determine the normalization needed for the children array. |
| 8684 |
// 0: no normalization needed |
| 8685 |
// 1: simple normalization needed (possible 1-level deep nested array) |
| 8686 |
// 2: full normalization needed |
| 8687 |
function getNormalizationType (children) { |
| 8688 |
var res = 0; |
| 8689 |
for (var i = 0; i < children.length; i++) { |
| 8690 |
var el = children[i]; |
| 8691 |
if (el.type !== 1) { |
| 8692 |
continue |
| 8693 |
} |
| 8694 |
if (needsNormalization(el) || |
| 8695 |
(el.ifConditions && el.ifConditions.some(function (c) { return needsNormalization(c.block); }))) { |
| 8696 |
res = 2; |
| 8697 |
break |
| 8698 |
} |
| 8699 |
if (maybeComponent(el) || |
| 8700 |
(el.ifConditions && el.ifConditions.some(function (c) { return maybeComponent(c.block); }))) { |
| 8701 |
res = 1; |
| 8702 |
} |
| 8703 |
} |
| 8704 |
return res |
| 8705 |
} |
| 8706 |
|
| 8707 |
function needsNormalization (el) { |
| 8708 |
return el.for !== undefined || el.tag === 'template' || el.tag === 'slot' |
| 8709 |
} |
| 8710 |
|
| 8711 |
function maybeComponent (el) { |
| 8712 |
return !isPlatformReservedTag$1(el.tag) |
| 8713 |
} |
| 8714 |
|
| 8715 |
function genNode (node) { |
| 8716 |
if (node.type === 1) { |
| 8717 |
return genElement(node) |
| 8718 |
} else { |
| 8719 |
return genText(node) |
| 8720 |
} |
| 8721 |
} |
| 8722 |
|
| 8723 |
function genText (text) { |
| 8724 |
return ("_v(" + (text.type === 2 |
| 8725 |
? text.expression // no need for () because already wrapped in _s() |
| 8726 |
: transformSpecialNewlines(JSON.stringify(text.text))) + ")") |
| 8727 |
} |
| 8728 |
|
| 8729 |
function genSlot (el) { |
| 8730 |
var slotName = el.slotName || '"default"'; |
| 8731 |
var children = genChildren(el); |
| 8732 |
var res = "_t(" + slotName + (children ? ("," + children) : ''); |
| 8733 |
var attrs = el.attrs && ("{" + (el.attrs.map(function (a) { return ((camelize(a.name)) + ":" + (a.value)); }).join(',')) + "}"); |
| 8734 |
var bind$$1 = el.attrsMap['v-bind']; |
| 8735 |
if ((attrs || bind$$1) && !children) { |
| 8736 |
res += ",null"; |
| 8737 |
} |
| 8738 |
if (attrs) { |
| 8739 |
res += "," + attrs; |
| 8740 |
} |
| 8741 |
if (bind$$1) { |
| 8742 |
res += (attrs ? '' : ',null') + "," + bind$$1; |
| 8743 |
} |
| 8744 |
return res + ')' |
| 8745 |
} |
| 8746 |
|
| 8747 |
// componentName is el.component, take it as argument to shun flow's pessimistic refinement |
| 8748 |
function genComponent (componentName, el) { |
| 8749 |
var children = el.inlineTemplate ? null : genChildren(el, true); |
| 8750 |
return ("_c(" + componentName + "," + (genData(el)) + (children ? ("," + children) : '') + ")") |
| 8751 |
} |
| 8752 |
|
| 8753 |
function genProps (props) { |
| 8754 |
var res = ''; |
| 8755 |
for (var i = 0; i < props.length; i++) { |
| 8756 |
var prop = props[i]; |
| 8757 |
res += "\"" + (prop.name) + "\":" + (transformSpecialNewlines(prop.value)) + ","; |
| 8758 |
} |
| 8759 |
return res.slice(0, -1) |
| 8760 |
} |
| 8761 |
|
| 8762 |
// #3895, #4268 |
| 8763 |
function transformSpecialNewlines (text) { |
| 8764 |
return text |
| 8765 |
.replace(/\u2028/g, '\\u2028') |
| 8766 |
.replace(/\u2029/g, '\\u2029') |
| 8767 |
} |
| 8768 |
|
| 8769 |
/* */ |
| 8770 |
|
| 8771 |
// these keywords should not appear inside expressions, but operators like |
| 8772 |
// typeof, instanceof and in are allowed |
| 8773 |
var prohibitedKeywordRE = new RegExp('\\b' + ( |
| 8774 |
'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' + |
| 8775 |
'super,throw,while,yield,delete,export,import,return,switch,default,' + |
| 8776 |
'extends,finally,continue,debugger,function,arguments' |
| 8777 |
).split(',').join('\\b|\\b') + '\\b'); |
| 8778 |
|
| 8779 |
// these unary operators should not be used as property/method names |
| 8780 |
var unaryOperatorsRE = new RegExp('\\b' + ( |
| 8781 |
'delete,typeof,void' |
| 8782 |
).split(',').join('\\s*\\([^\\)]*\\)|\\b') + '\\s*\\([^\\)]*\\)'); |
| 8783 |
|
| 8784 |
// check valid identifier for v-for |
| 8785 |
var identRE = /[A-Za-z_$][\w$]*/; |
| 8786 |
|
| 8787 |
// strip strings in expressions |
| 8788 |
var stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g; |
| 8789 |
|
| 8790 |
// detect problematic expressions in a template |
| 8791 |
function detectErrors (ast) { |
| 8792 |
var errors = []; |
| 8793 |
if (ast) { |
| 8794 |
checkNode(ast, errors); |
| 8795 |
} |
| 8796 |
return errors |
| 8797 |
} |
| 8798 |
|
| 8799 |
function checkNode (node, errors) { |
| 8800 |
if (node.type === 1) { |
| 8801 |
for (var name in node.attrsMap) { |
| 8802 |
if (dirRE.test(name)) { |
| 8803 |
var value = node.attrsMap[name]; |
| 8804 |
if (value) { |
| 8805 |
if (name === 'v-for') { |
| 8806 |
checkFor(node, ("v-for=\"" + value + "\""), errors); |
| 8807 |
} else if (onRE.test(name)) { |
| 8808 |
checkEvent(value, (name + "=\"" + value + "\""), errors); |
| 8809 |
} else { |
| 8810 |
checkExpression(value, (name + "=\"" + value + "\""), errors); |
| 8811 |
} |
| 8812 |
} |
| 8813 |
} |
| 8814 |
} |
| 8815 |
if (node.children) { |
| 8816 |
for (var i = 0; i < node.children.length; i++) { |
| 8817 |
checkNode(node.children[i], errors); |
| 8818 |
} |
| 8819 |
} |
| 8820 |
} else if (node.type === 2) { |
| 8821 |
checkExpression(node.expression, node.text, errors); |
| 8822 |
} |
| 8823 |
} |
| 8824 |
|
| 8825 |
function checkEvent (exp, text, errors) { |
| 8826 |
var keywordMatch = exp.replace(stripStringRE, '').match(unaryOperatorsRE); |
| 8827 |
if (keywordMatch) { |
| 8828 |
errors.push( |
| 8829 |
"avoid using JavaScript unary operator as property name: " + |
| 8830 |
"\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()) |
| 8831 |
); |
| 8832 |
} |
| 8833 |
checkExpression(exp, text, errors); |
| 8834 |
} |
| 8835 |
|
| 8836 |
function checkFor (node, text, errors) { |
| 8837 |
checkExpression(node.for || '', text, errors); |
| 8838 |
checkIdentifier(node.alias, 'v-for alias', text, errors); |
| 8839 |
checkIdentifier(node.iterator1, 'v-for iterator', text, errors); |
| 8840 |
checkIdentifier(node.iterator2, 'v-for iterator', text, errors); |
| 8841 |
} |
| 8842 |
|
| 8843 |
function checkIdentifier (ident, type, text, errors) { |
| 8844 |
if (typeof ident === 'string' && !identRE.test(ident)) { |
| 8845 |
errors.push(("invalid " + type + " \"" + ident + "\" in expression: " + (text.trim()))); |
| 8846 |
} |
| 8847 |
} |
| 8848 |
|
| 8849 |
function checkExpression (exp, text, errors) { |
| 8850 |
try { |
| 8851 |
new Function(("return " + exp)); |
| 8852 |
} catch (e) { |
| 8853 |
var keywordMatch = exp.replace(stripStringRE, '').match(prohibitedKeywordRE); |
| 8854 |
if (keywordMatch) { |
| 8855 |
errors.push( |
| 8856 |
"avoid using JavaScript keyword as property name: " + |
| 8857 |
"\"" + (keywordMatch[0]) + "\" in expression " + (text.trim()) |
| 8858 |
); |
| 8859 |
} else { |
| 8860 |
errors.push(("invalid expression: " + (text.trim()))); |
| 8861 |
} |
| 8862 |
} |
| 8863 |
} |
| 8864 |
|
| 8865 |
/* */ |
| 8866 |
|
| 8867 |
function baseCompile ( |
| 8868 |
template, |
| 8869 |
options |
| 8870 |
) { |
| 8871 |
var ast = parse(template.trim(), options); |
| 8872 |
optimize(ast, options); |
| 8873 |
var code = generate(ast, options); |
| 8874 |
return { |
| 8875 |
ast: ast, |
| 8876 |
render: code.render, |
| 8877 |
staticRenderFns: code.staticRenderFns |
| 8878 |
} |
| 8879 |
} |
| 8880 |
|
| 8881 |
function makeFunction (code, errors) { |
| 8882 |
try { |
| 8883 |
return new Function(code) |
| 8884 |
} catch (err) { |
| 8885 |
errors.push({ err: err, code: code }); |
| 8886 |
return noop |
| 8887 |
} |
| 8888 |
} |
| 8889 |
|
| 8890 |
function createCompiler (baseOptions) { |
| 8891 |
var functionCompileCache = Object.create(null); |
| 8892 |
|
| 8893 |
function compile ( |
| 8894 |
template, |
| 8895 |
options |
| 8896 |
) { |
| 8897 |
var finalOptions = Object.create(baseOptions); |
| 8898 |
var errors = []; |
| 8899 |
var tips = []; |
| 8900 |
finalOptions.warn = function (msg, tip$$1) { |
| 8901 |
(tip$$1 ? tips : errors).push(msg); |
| 8902 |
}; |
| 8903 |
|
| 8904 |
if (options) { |
| 8905 |
// merge custom modules |
| 8906 |
if (options.modules) { |
| 8907 |
finalOptions.modules = (baseOptions.modules || []).concat(options.modules); |
| 8908 |
} |
| 8909 |
// merge custom directives |
| 8910 |
if (options.directives) { |
| 8911 |
finalOptions.directives = extend( |
| 8912 |
Object.create(baseOptions.directives), |
| 8913 |
options.directives |
| 8914 |
); |
| 8915 |
} |
| 8916 |
// copy other options |
| 8917 |
for (var key in options) { |
| 8918 |
if (key !== 'modules' && key !== 'directives') { |
| 8919 |
finalOptions[key] = options[key]; |
| 8920 |
} |
| 8921 |
} |
| 8922 |
} |
| 8923 |
|
| 8924 |
var compiled = baseCompile(template, finalOptions); |
| 8925 |
{ |
| 8926 |
errors.push.apply(errors, detectErrors(compiled.ast)); |
| 8927 |
} |
| 8928 |
compiled.errors = errors; |
| 8929 |
compiled.tips = tips; |
| 8930 |
return compiled |
| 8931 |
} |
| 8932 |
|
| 8933 |
function compileToFunctions ( |
| 8934 |
template, |
| 8935 |
options, |
| 8936 |
vm |
| 8937 |
) { |
| 8938 |
options = options || {}; |
| 8939 |
|
| 8940 |
/* istanbul ignore if */ |
| 8941 |
{ |
| 8942 |
// detect possible CSP restriction |
| 8943 |
try { |
| 8944 |
new Function('return 1'); |
| 8945 |
} catch (e) { |
| 8946 |
if (e.toString().match(/unsafe-eval|CSP/)) { |
| 8947 |
warn( |
| 8948 |
'It seems you are using the standalone build of Vue.js in an ' + |
| 8949 |
'environment with Content Security Policy that prohibits unsafe-eval. ' + |
| 8950 |
'The template compiler cannot work in this environment. Consider ' + |
| 8951 |
'relaxing the policy to allow unsafe-eval or pre-compiling your ' + |
| 8952 |
'templates into render functions.' |
| 8953 |
); |
| 8954 |
} |
| 8955 |
} |
| 8956 |
} |
| 8957 |
|
| 8958 |
// check cache |
| 8959 |
var key = options.delimiters |
| 8960 |
? String(options.delimiters) + template |
| 8961 |
: template; |
| 8962 |
if (functionCompileCache[key]) { |
| 8963 |
return functionCompileCache[key] |
| 8964 |
} |
| 8965 |
|
| 8966 |
// compile |
| 8967 |
var compiled = compile(template, options); |
| 8968 |
|
| 8969 |
// check compilation errors/tips |
| 8970 |
{ |
| 8971 |
if (compiled.errors && compiled.errors.length) { |
| 8972 |
warn( |
| 8973 |
"Error compiling template:\n\n" + template + "\n\n" + |
| 8974 |
compiled.errors.map(function (e) { return ("- " + e); }).join('\n') + '\n', |
| 8975 |
vm |
| 8976 |
); |
| 8977 |
} |
| 8978 |
if (compiled.tips && compiled.tips.length) { |
| 8979 |
compiled.tips.forEach(function (msg) { return tip(msg, vm); }); |
| 8980 |
} |
| 8981 |
} |
| 8982 |
|
| 8983 |
// turn code into functions |
| 8984 |
var res = {}; |
| 8985 |
var fnGenErrors = []; |
| 8986 |
res.render = makeFunction(compiled.render, fnGenErrors); |
| 8987 |
var l = compiled.staticRenderFns.length; |
| 8988 |
res.staticRenderFns = new Array(l); |
| 8989 |
for (var i = 0; i < l; i++) { |
| 8990 |
res.staticRenderFns[i] = makeFunction(compiled.staticRenderFns[i], fnGenErrors); |
| 8991 |
} |
| 8992 |
|
| 8993 |
// check function generation errors. |
| 8994 |
// this should only happen if there is a bug in the compiler itself. |
| 8995 |
// mostly for codegen development use |
| 8996 |
/* istanbul ignore if */ |
| 8997 |
{ |
| 8998 |
if ((!compiled.errors || !compiled.errors.length) && fnGenErrors.length) { |
| 8999 |
warn( |
| 9000 |
"Failed to generate render function:\n\n" + |
| 9001 |
fnGenErrors.map(function (ref) { |
| 9002 |
var err = ref.err; |
| 9003 |
var code = ref.code; |
| 9004 |
|
| 9005 |
return ((err.toString()) + " in\n\n" + code + "\n"); |
| 9006 |
}).join('\n'), |
| 9007 |
vm |
| 9008 |
); |
| 9009 |
} |
| 9010 |
} |
| 9011 |
|
| 9012 |
return (functionCompileCache[key] = res) |
| 9013 |
} |
| 9014 |
|
| 9015 |
return { |
| 9016 |
compile: compile, |
| 9017 |
compileToFunctions: compileToFunctions |
| 9018 |
} |
| 9019 |
} |
| 9020 |
|
| 9021 |
/* */ |
| 9022 |
|
| 9023 |
function transformNode (el, options) { |
| 9024 |
var warn = options.warn || baseWarn; |
| 9025 |
var staticClass = getAndRemoveAttr(el, 'class'); |
| 9026 |
if ("development" !== 'production' && staticClass) { |
| 9027 |
var expression = parseText(staticClass, options.delimiters); |
| 9028 |
if (expression) { |
| 9029 |
warn( |
| 9030 |
"class=\"" + staticClass + "\": " + |
| 9031 |
'Interpolation inside attributes has been removed. ' + |
| 9032 |
'Use v-bind or the colon shorthand instead. For example, ' + |
| 9033 |
'instead of <div class="{{ val }}">, use <div :class="val">.' |
| 9034 |
); |
| 9035 |
} |
| 9036 |
} |
| 9037 |
if (staticClass) { |
| 9038 |
el.staticClass = JSON.stringify(staticClass); |
| 9039 |
} |
| 9040 |
var classBinding = getBindingAttr(el, 'class', false /* getStatic */); |
| 9041 |
if (classBinding) { |
| 9042 |
el.classBinding = classBinding; |
| 9043 |
} |
| 9044 |
} |
| 9045 |
|
| 9046 |
function genData$1 (el) { |
| 9047 |
var data = ''; |
| 9048 |
if (el.staticClass) { |
| 9049 |
data += "staticClass:" + (el.staticClass) + ","; |
| 9050 |
} |
| 9051 |
if (el.classBinding) { |
| 9052 |
data += "class:" + (el.classBinding) + ","; |
| 9053 |
} |
| 9054 |
return data |
| 9055 |
} |
| 9056 |
|
| 9057 |
var klass$1 = { |
| 9058 |
staticKeys: ['staticClass'], |
| 9059 |
transformNode: transformNode, |
| 9060 |
genData: genData$1 |
| 9061 |
}; |
| 9062 |
|
| 9063 |
/* */ |
| 9064 |
|
| 9065 |
function transformNode$1 (el, options) { |
| 9066 |
var warn = options.warn || baseWarn; |
| 9067 |
var staticStyle = getAndRemoveAttr(el, 'style'); |
| 9068 |
if (staticStyle) { |
| 9069 |
/* istanbul ignore if */ |
| 9070 |
{ |
| 9071 |
var expression = parseText(staticStyle, options.delimiters); |
| 9072 |
if (expression) { |
| 9073 |
warn( |
| 9074 |
"style=\"" + staticStyle + "\": " + |
| 9075 |
'Interpolation inside attributes has been removed. ' + |
| 9076 |
'Use v-bind or the colon shorthand instead. For example, ' + |
| 9077 |
'instead of <div style="{{ val }}">, use <div :style="val">.' |
| 9078 |
); |
| 9079 |
} |
| 9080 |
} |
| 9081 |
el.staticStyle = JSON.stringify(parseStyleText(staticStyle)); |
| 9082 |
} |
| 9083 |
|
| 9084 |
var styleBinding = getBindingAttr(el, 'style', false /* getStatic */); |
| 9085 |
if (styleBinding) { |
| 9086 |
el.styleBinding = styleBinding; |
| 9087 |
} |
| 9088 |
} |
| 9089 |
|
| 9090 |
function genData$2 (el) { |
| 9091 |
var data = ''; |
| 9092 |
if (el.staticStyle) { |
| 9093 |
data += "staticStyle:" + (el.staticStyle) + ","; |
| 9094 |
} |
| 9095 |
if (el.styleBinding) { |
| 9096 |
data += "style:(" + (el.styleBinding) + "),"; |
| 9097 |
} |
| 9098 |
return data |
| 9099 |
} |
| 9100 |
|
| 9101 |
var style$1 = { |
| 9102 |
staticKeys: ['staticStyle'], |
| 9103 |
transformNode: transformNode$1, |
| 9104 |
genData: genData$2 |
| 9105 |
}; |
| 9106 |
|
| 9107 |
var modules$1 = [ |
| 9108 |
klass$1, |
| 9109 |
style$1 |
| 9110 |
]; |
| 9111 |
|
| 9112 |
/* */ |
| 9113 |
|
| 9114 |
function text (el, dir) { |
| 9115 |
if (dir.value) { |
| 9116 |
addProp(el, 'textContent', ("_s(" + (dir.value) + ")")); |
| 9117 |
} |
| 9118 |
} |
| 9119 |
|
| 9120 |
/* */ |
| 9121 |
|
| 9122 |
function html (el, dir) { |
| 9123 |
if (dir.value) { |
| 9124 |
addProp(el, 'innerHTML', ("_s(" + (dir.value) + ")")); |
| 9125 |
} |
| 9126 |
} |
| 9127 |
|
| 9128 |
var directives$1 = { |
| 9129 |
model: model, |
| 9130 |
text: text, |
| 9131 |
html: html |
| 9132 |
}; |
| 9133 |
|
| 9134 |
/* */ |
| 9135 |
|
| 9136 |
var baseOptions = { |
| 9137 |
expectHTML: true, |
| 9138 |
modules: modules$1, |
| 9139 |
directives: directives$1, |
| 9140 |
isPreTag: isPreTag, |
| 9141 |
isUnaryTag: isUnaryTag, |
| 9142 |
mustUseProp: mustUseProp, |
| 9143 |
isReservedTag: isReservedTag, |
| 9144 |
getTagNamespace: getTagNamespace, |
| 9145 |
staticKeys: genStaticKeys(modules$1) |
| 9146 |
}; |
| 9147 |
|
| 9148 |
var ref$1 = createCompiler(baseOptions); |
| 9149 |
var compileToFunctions = ref$1.compileToFunctions; |
| 9150 |
|
| 9151 |
/* */ |
| 9152 |
|
| 9153 |
var idToTemplate = cached(function (id) { |
| 9154 |
var el = query(id); |
| 9155 |
return el && el.innerHTML |
| 9156 |
}); |
| 9157 |
|
| 9158 |
var mount = Vue$3.prototype.$mount; |
| 9159 |
Vue$3.prototype.$mount = function ( |
| 9160 |
el, |
| 9161 |
hydrating |
| 9162 |
) { |
| 9163 |
el = el && query(el); |
| 9164 |
|
| 9165 |
/* istanbul ignore if */ |
| 9166 |
if (el === document.body || el === document.documentElement) { |
| 9167 |
"development" !== 'production' && warn( |
| 9168 |
"Do not mount Vue to <html> or <body> - mount to normal elements instead." |
| 9169 |
); |
| 9170 |
return this |
| 9171 |
} |
| 9172 |
|
| 9173 |
var options = this.$options; |
| 9174 |
// resolve template/el and convert to render function |
| 9175 |
if (!options.render) { |
| 9176 |
var template = options.template; |
| 9177 |
if (template) { |
| 9178 |
if (typeof template === 'string') { |
| 9179 |
if (template.charAt(0) === '#') { |
| 9180 |
template = idToTemplate(template); |
| 9181 |
/* istanbul ignore if */ |
| 9182 |
if ("development" !== 'production' && !template) { |
| 9183 |
warn( |
| 9184 |
("Template element not found or is empty: " + (options.template)), |
| 9185 |
this |
| 9186 |
); |
| 9187 |
} |
| 9188 |
} |
| 9189 |
} else if (template.nodeType) { |
| 9190 |
template = template.innerHTML; |
| 9191 |
} else { |
| 9192 |
{ |
| 9193 |
warn('invalid template option:' + template, this); |
| 9194 |
} |
| 9195 |
return this |
| 9196 |
} |
| 9197 |
} else if (el) { |
| 9198 |
template = getOuterHTML(el); |
| 9199 |
} |
| 9200 |
if (template) { |
| 9201 |
/* istanbul ignore if */ |
| 9202 |
if ("development" !== 'production' && config.performance && mark) { |
| 9203 |
mark('compile'); |
| 9204 |
} |
| 9205 |
|
| 9206 |
var ref = compileToFunctions(template, { |
| 9207 |
shouldDecodeNewlines: shouldDecodeNewlines, |
| 9208 |
delimiters: options.delimiters |
| 9209 |
}, this); |
| 9210 |
var render = ref.render; |
| 9211 |
var staticRenderFns = ref.staticRenderFns; |
| 9212 |
options.render = render; |
| 9213 |
options.staticRenderFns = staticRenderFns; |
| 9214 |
|
| 9215 |
/* istanbul ignore if */ |
| 9216 |
if ("development" !== 'production' && config.performance && mark) { |
| 9217 |
mark('compile end'); |
| 9218 |
measure(((this._name) + " compile"), 'compile', 'compile end'); |
| 9219 |
} |
| 9220 |
} |
| 9221 |
} |
| 9222 |
return mount.call(this, el, hydrating) |
| 9223 |
}; |
| 9224 |
|
| 9225 |
/** |
| 9226 |
* Get outerHTML of elements, taking care |
| 9227 |
* of SVG elements in IE as well. |
| 9228 |
*/ |
| 9229 |
function getOuterHTML (el) { |
| 9230 |
if (el.outerHTML) { |
| 9231 |
return el.outerHTML |
| 9232 |
} else { |
| 9233 |
var container = document.createElement('div'); |
| 9234 |
container.appendChild(el.cloneNode(true)); |
| 9235 |
return container.innerHTML |
| 9236 |
} |
| 9237 |
} |
| 9238 |
|
| 9239 |
Vue$3.compile = compileToFunctions; |
| 9240 |
|
| 9241 |
return Vue$3; |
| 9242 |
|
| 9243 |
}))); |
| 9244 |
|