|
1 | 1 | /*!
|
2 |
| - * Vue.js v1.0.27 |
| 2 | + * Vue.js v1.0.28 |
3 | 3 | * (c) 2016 Evan You
|
4 | 4 | * Released under the MIT License.
|
5 | 5 | */
|
|
405 | 405 | var isIE = UA && UA.indexOf('trident') > 0;
|
406 | 406 | var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
|
407 | 407 | var isAndroid = UA && UA.indexOf('android') > 0;
|
| 408 | + var isIOS = UA && /iphone|ipad|ipod|ios/.test(UA); |
408 | 409 |
|
409 | 410 | var transitionProp = undefined;
|
410 | 411 | var transitionEndEvent = undefined;
|
|
421 | 422 | animationEndEvent = isWebkitAnim ? 'webkitAnimationEnd' : 'animationend';
|
422 | 423 | }
|
423 | 424 |
|
| 425 | + /* istanbul ignore next */ |
| 426 | + function isNative(Ctor) { |
| 427 | + return (/native code/.test(Ctor.toString()) |
| 428 | + ); |
| 429 | + } |
| 430 | + |
424 | 431 | /**
|
425 | 432 | * Defer a task to execute it asynchronously. Ideally this
|
426 | 433 | * should be executed as a microtask, so we leverage
|
|
434 | 441 | var nextTick = (function () {
|
435 | 442 | var callbacks = [];
|
436 | 443 | var pending = false;
|
437 |
| - var timerFunc; |
| 444 | + var timerFunc = undefined; |
| 445 | + |
438 | 446 | function nextTickHandler() {
|
439 | 447 | pending = false;
|
440 | 448 | var copies = callbacks.slice(0);
|
441 |
| - callbacks = []; |
| 449 | + callbacks.length = 0; |
442 | 450 | for (var i = 0; i < copies.length; i++) {
|
443 | 451 | copies[i]();
|
444 | 452 | }
|
445 | 453 | }
|
446 | 454 |
|
447 |
| - /* istanbul ignore else */ |
448 |
| - if (inBrowser && window.postMessage && !window.importScripts && // not in WebWorker |
449 |
| - !(isAndroid && !window.requestAnimationFrame) // not in Android <= 4.3 |
450 |
| - ) { |
451 |
| - (function () { |
452 |
| - var NEXT_TICK_TOKEN = '__vue__nextTick__'; |
453 |
| - window.addEventListener('message', function (e) { |
454 |
| - if (e.source === window && e.data === NEXT_TICK_TOKEN) { |
455 |
| - nextTickHandler(); |
456 |
| - } |
457 |
| - }); |
458 |
| - timerFunc = function () { |
459 |
| - window.postMessage(NEXT_TICK_TOKEN, '*'); |
460 |
| - }; |
461 |
| - })(); |
462 |
| - } else { |
463 |
| - timerFunc = typeof global !== 'undefined' && global.setImmediate || setTimeout; |
| 455 | + // the nextTick behavior leverages the microtask queue, which can be accessed |
| 456 | + // via either native Promise.then or MutationObserver. |
| 457 | + // MutationObserver has wider support, however it is seriously bugged in |
| 458 | + // UIWebView in iOS >= 9.3.3 when triggered in touch event handlers. It |
| 459 | + // completely stops working after triggering a few times... so, if native |
| 460 | + // Promise is available, we will use it: |
| 461 | + /* istanbul ignore if */ |
| 462 | + if (typeof Promise !== 'undefined' && isNative(Promise)) { |
| 463 | + var p = Promise.resolve(); |
| 464 | + var noop = function noop() {}; |
| 465 | + timerFunc = function () { |
| 466 | + p.then(nextTickHandler); |
| 467 | + // in problematic UIWebViews, Promise.then doesn't completely break, but |
| 468 | + // it can get stuck in a weird state where callbacks are pushed into the |
| 469 | + // microtask queue but the queue isn't being flushed, until the browser |
| 470 | + // needs to do some other work, e.g. handle a timer. Therefore we can |
| 471 | + // "force" the microtask queue to be flushed by adding an empty timer. |
| 472 | + if (isIOS) setTimeout(noop); |
| 473 | + }; |
| 474 | + } else if (typeof MutationObserver !== 'undefined') { |
| 475 | + // use MutationObserver where native Promise is not available, |
| 476 | + // e.g. IE11, iOS7, Android 4.4 |
| 477 | + var counter = 1; |
| 478 | + var observer = new MutationObserver(nextTickHandler); |
| 479 | + var textNode = document.createTextNode(String(counter)); |
| 480 | + observer.observe(textNode, { |
| 481 | + characterData: true |
| 482 | + }); |
| 483 | + timerFunc = function () { |
| 484 | + counter = (counter + 1) % 2; |
| 485 | + textNode.data = String(counter); |
| 486 | + }; |
| 487 | + } else { |
| 488 | + // fallback to setTimeout |
| 489 | + /* istanbul ignore next */ |
| 490 | + timerFunc = setTimeout; |
464 | 491 | }
|
465 | 492 |
|
466 | 493 | return function (cb, ctx) {
|
|
476 | 503 |
|
477 | 504 | var Set$1 = undefined;
|
478 | 505 | /* istanbul ignore if */
|
479 |
| - if (typeof Set !== 'undefined' && Set.toString().match(/native code/)) { |
| 506 | + if (typeof Set !== 'undefined' && isNative(Set)) { |
480 | 507 | // use native Set when available.
|
481 | 508 | Set$1 = Set;
|
482 | 509 | } else {
|
|
1555 | 1582 | }
|
1556 | 1583 | }
|
1557 | 1584 |
|
1558 |
| - /** |
1559 |
| - * Find a vm from a fragment. |
1560 |
| - * |
1561 |
| - * @param {Fragment} frag |
1562 |
| - * @return {Vue|undefined} |
1563 |
| - */ |
1564 |
| - |
1565 |
| - function findVmFromFrag(frag) { |
1566 |
| - var node = frag.node; |
1567 |
| - // handle multi-node frag |
1568 |
| - if (frag.end) { |
1569 |
| - while (!node.__vue__ && node !== frag.end && node.nextSibling) { |
1570 |
| - node = node.nextSibling; |
1571 |
| - } |
1572 |
| - } |
1573 |
| - return node.__vue__; |
1574 |
| - } |
1575 |
| - |
1576 | 1585 | var uid = 0;
|
1577 | 1586 |
|
1578 | 1587 | function initMixin (Vue) {
|
|
4079 | 4088 | if (value) {
|
4080 | 4089 | if (!this.frag) {
|
4081 | 4090 | this.insert();
|
4082 |
| - this.updateRef(value); |
4083 | 4091 | }
|
4084 | 4092 | } else {
|
4085 |
| - this.updateRef(value); |
4086 | 4093 | this.remove();
|
4087 | 4094 | }
|
4088 | 4095 | },
|
|
4114 | 4121 | }
|
4115 | 4122 | },
|
4116 | 4123 |
|
4117 |
| - updateRef: function updateRef(value) { |
4118 |
| - var ref = this.descriptor.ref; |
4119 |
| - if (!ref) return; |
4120 |
| - var hash = (this.vm || this._scope).$refs; |
4121 |
| - var refs = hash[ref]; |
4122 |
| - var key = this._frag.scope.$key; |
4123 |
| - if (!refs) return; |
4124 |
| - if (value) { |
4125 |
| - if (Array.isArray(refs)) { |
4126 |
| - refs.push(findVmFromFrag(this._frag)); |
4127 |
| - } else { |
4128 |
| - refs[key] = findVmFromFrag(this._frag); |
4129 |
| - } |
4130 |
| - } else { |
4131 |
| - if (Array.isArray(refs)) { |
4132 |
| - refs.$remove(findVmFromFrag(this._frag)); |
4133 |
| - } else { |
4134 |
| - refs[key] = null; |
4135 |
| - delete refs[key]; |
4136 |
| - } |
4137 |
| - } |
4138 |
| - }, |
4139 |
| - |
4140 | 4124 | unbind: function unbind() {
|
4141 | 4125 | if (this.frag) {
|
4142 | 4126 | this.frag.destroy();
|
|
4449 | 4433 | params: ['track-by', 'stagger', 'enter-stagger', 'leave-stagger'],
|
4450 | 4434 |
|
4451 | 4435 | bind: function bind() {
|
| 4436 | + if ('development' !== 'production' && this.el.hasAttribute('v-if')) { |
| 4437 | + warn('<' + this.el.tagName.toLowerCase() + ' v-for="' + this.expression + '" v-if="' + this.el.getAttribute('v-if') + '">: ' + 'Using v-if and v-for on the same element is not recommended - ' + 'consider filtering the source Array instead.', this.vm); |
| 4438 | + } |
| 4439 | + |
4452 | 4440 | // support "item in/of items" syntax
|
4453 | 4441 | var inMatch = this.expression.match(/(.*) (?:in|of) (.*)/);
|
4454 | 4442 | if (inMatch) {
|
|
5028 | 5016 | };
|
5029 | 5017 | }
|
5030 | 5018 |
|
| 5019 | + /** |
| 5020 | + * Find a vm from a fragment. |
| 5021 | + * |
| 5022 | + * @param {Fragment} frag |
| 5023 | + * @return {Vue|undefined} |
| 5024 | + */ |
| 5025 | + |
| 5026 | + function findVmFromFrag(frag) { |
| 5027 | + var node = frag.node; |
| 5028 | + // handle multi-node frag |
| 5029 | + if (frag.end) { |
| 5030 | + while (!node.__vue__ && node !== frag.end && node.nextSibling) { |
| 5031 | + node = node.nextSibling; |
| 5032 | + } |
| 5033 | + } |
| 5034 | + return node.__vue__; |
| 5035 | + } |
| 5036 | + |
5031 | 5037 | var html = {
|
5032 | 5038 |
|
5033 | 5039 | bind: function bind() {
|
|
6500 | 6506 |
|
6501 | 6507 | var groupedMap = {};
|
6502 | 6508 | var i, j, k, l;
|
| 6509 | + var index = 0; |
| 6510 | + var priorities = []; |
6503 | 6511 | for (i = 0, j = dirs.length; i < j; i++) {
|
6504 | 6512 | var dir = dirs[i];
|
6505 | 6513 | var priority = dir.descriptor.def.priority || DEFAULT_PRIORITY;
|
6506 | 6514 | var array = groupedMap[priority];
|
6507 | 6515 | if (!array) {
|
6508 | 6516 | array = groupedMap[priority] = [];
|
| 6517 | + priorities.push(priority); |
6509 | 6518 | }
|
6510 | 6519 | array.push(dir);
|
6511 | 6520 | }
|
6512 | 6521 |
|
6513 |
| - var index = 0; |
6514 |
| - var priorities = Object.keys(groupedMap).sort(function (a, b) { |
| 6522 | + priorities.sort(function (a, b) { |
6515 | 6523 | return a > b ? -1 : a === b ? 0 : 1;
|
6516 | 6524 | });
|
6517 | 6525 | for (i = 0, j = priorities.length; i < j; i++) {
|
|
7033 | 7041 | def: def
|
7034 | 7042 | };
|
7035 | 7043 | // check ref for v-for, v-if and router-view
|
7036 |
| - if (dirName === 'for' || dirName === 'if' || dirName === 'router-view') { |
| 7044 | + if (dirName === 'for' || dirName === 'router-view') { |
7037 | 7045 | descriptor.ref = findRef(el);
|
7038 | 7046 | }
|
7039 | 7047 | var fn = function terminalNodeLinkFn(vm, el, host, scope, frag) {
|
|
9544 | 9552 | isIE: isIE,
|
9545 | 9553 | isIE9: isIE9,
|
9546 | 9554 | isAndroid: isAndroid,
|
| 9555 | + isIOS: isIOS, |
9547 | 9556 | get transitionProp () { return transitionProp; },
|
9548 | 9557 | get transitionEndEvent () { return transitionEndEvent; },
|
9549 | 9558 | get animationProp () { return animationProp; },
|
|
9574 | 9583 | removeNodeRange: removeNodeRange,
|
9575 | 9584 | isFragment: isFragment,
|
9576 | 9585 | getOuterHTML: getOuterHTML,
|
9577 |
| - findVmFromFrag: findVmFromFrag, |
9578 | 9586 | mergeOptions: mergeOptions,
|
9579 | 9587 | resolveAsset: resolveAsset,
|
9580 | 9588 | checkComponentAttr: checkComponentAttr,
|
|
10200 | 10208 |
|
10201 | 10209 | installGlobalAPI(Vue);
|
10202 | 10210 |
|
10203 |
| - Vue.version = '1.0.27'; |
| 10211 | + Vue.version = '1.0.28'; |
10204 | 10212 |
|
10205 | 10213 | // devtools global hook
|
10206 | 10214 | /* istanbul ignore next */
|
|
0 commit comments