vuejs 1.0.17 → 1.0.18.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +5 -5
- data/README.md +13 -0
- data/lib/vuejs/post_message.rb +0 -6
- data/lib/vuejs/version.rb +1 -1
- data/vendor/assets/javascripts/vue.js +778 -766
- metadata +10 -12
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Vue.js v1.0.
|
2
|
+
* Vue.js v1.0.18
|
3
3
|
* (c) 2016 Evan You
|
4
4
|
* Released under the MIT License.
|
5
5
|
*/
|
@@ -289,7 +289,7 @@
|
|
289
289
|
var isArray = Array.isArray;
|
290
290
|
|
291
291
|
/**
|
292
|
-
* Define a
|
292
|
+
* Define a property.
|
293
293
|
*
|
294
294
|
* @param {Object} obj
|
295
295
|
* @param {String} key
|
@@ -909,6 +909,13 @@ var text = Object.freeze({
|
|
909
909
|
|
910
910
|
warnExpressionErrors: true,
|
911
911
|
|
912
|
+
/**
|
913
|
+
* Whether to allow devtools inspection.
|
914
|
+
* Disabled by default in production builds.
|
915
|
+
*/
|
916
|
+
|
917
|
+
devtools: 'development' !== 'production',
|
918
|
+
|
912
919
|
/**
|
913
920
|
* Internal flag to indicate the delimiters have been
|
914
921
|
* changed.
|
@@ -1493,830 +1500,863 @@ var transition = Object.freeze({
|
|
1493
1500
|
}
|
1494
1501
|
}
|
1495
1502
|
|
1496
|
-
var
|
1497
|
-
var reservedTagRE = /^(slot|partial|component)$/;
|
1498
|
-
|
1499
|
-
var isUnknownElement = undefined;
|
1500
|
-
if ('development' !== 'production') {
|
1501
|
-
isUnknownElement = function (el, tag) {
|
1502
|
-
if (tag.indexOf('-') > -1) {
|
1503
|
-
// http://stackoverflow.com/a/28210364/1070244
|
1504
|
-
return el.constructor === window.HTMLUnknownElement || el.constructor === window.HTMLElement;
|
1505
|
-
} else {
|
1506
|
-
return (/HTMLUnknownElement/.test(el.toString()) &&
|
1507
|
-
// Chrome returns unknown for several HTML5 elements.
|
1508
|
-
// https://code.google.com/p/chromium/issues/detail?id=540526
|
1509
|
-
!/^(data|time|rtc|rb)$/.test(tag)
|
1510
|
-
);
|
1511
|
-
}
|
1512
|
-
};
|
1513
|
-
}
|
1503
|
+
var uid$1 = 0;
|
1514
1504
|
|
1515
1505
|
/**
|
1516
|
-
*
|
1517
|
-
*
|
1506
|
+
* A dep is an observable that can have multiple
|
1507
|
+
* directives subscribing to it.
|
1518
1508
|
*
|
1519
|
-
* @
|
1520
|
-
* @param {Object} options
|
1521
|
-
* @return {Object|undefined}
|
1509
|
+
* @constructor
|
1522
1510
|
*/
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
var hasAttrs = el.hasAttributes();
|
1527
|
-
if (!commonTagRE.test(tag) && !reservedTagRE.test(tag)) {
|
1528
|
-
if (resolveAsset(options, 'components', tag)) {
|
1529
|
-
return { id: tag };
|
1530
|
-
} else {
|
1531
|
-
var is = hasAttrs && getIsBinding(el);
|
1532
|
-
if (is) {
|
1533
|
-
return is;
|
1534
|
-
} else if ('development' !== 'production') {
|
1535
|
-
var expectedTag = options._componentNameMap && options._componentNameMap[tag];
|
1536
|
-
if (expectedTag) {
|
1537
|
-
warn('Unknown custom element: <' + tag + '> - ' + 'did you mean <' + expectedTag + '>? ' + 'HTML is case-insensitive, remember to use kebab-case in templates.');
|
1538
|
-
} else if (isUnknownElement(el, tag)) {
|
1539
|
-
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
|
1540
|
-
}
|
1541
|
-
}
|
1542
|
-
}
|
1543
|
-
} else if (hasAttrs) {
|
1544
|
-
return getIsBinding(el);
|
1545
|
-
}
|
1511
|
+
function Dep() {
|
1512
|
+
this.id = uid$1++;
|
1513
|
+
this.subs = [];
|
1546
1514
|
}
|
1547
1515
|
|
1516
|
+
// the current target watcher being evaluated.
|
1517
|
+
// this is globally unique because there could be only one
|
1518
|
+
// watcher being evaluated at any time.
|
1519
|
+
Dep.target = null;
|
1520
|
+
|
1548
1521
|
/**
|
1549
|
-
*
|
1522
|
+
* Add a directive subscriber.
|
1550
1523
|
*
|
1551
|
-
* @param {
|
1552
|
-
* @return {Object|undefined}
|
1524
|
+
* @param {Directive} sub
|
1553
1525
|
*/
|
1554
1526
|
|
1555
|
-
function
|
1556
|
-
|
1557
|
-
|
1558
|
-
if (exp != null) {
|
1559
|
-
return { id: exp };
|
1560
|
-
} else {
|
1561
|
-
exp = getBindAttr(el, 'is');
|
1562
|
-
if (exp != null) {
|
1563
|
-
return { id: exp, dynamic: true };
|
1564
|
-
}
|
1565
|
-
}
|
1566
|
-
}
|
1527
|
+
Dep.prototype.addSub = function (sub) {
|
1528
|
+
this.subs.push(sub);
|
1529
|
+
};
|
1567
1530
|
|
1568
1531
|
/**
|
1569
|
-
*
|
1532
|
+
* Remove a directive subscriber.
|
1570
1533
|
*
|
1571
|
-
* @param {
|
1572
|
-
* @param {Object} prop
|
1573
|
-
* @param {*} value
|
1534
|
+
* @param {Directive} sub
|
1574
1535
|
*/
|
1575
1536
|
|
1576
|
-
function
|
1577
|
-
|
1578
|
-
|
1579
|
-
vm[key] = vm._data[key] = assertProp(prop, value) ? value : undefined;
|
1580
|
-
}
|
1537
|
+
Dep.prototype.removeSub = function (sub) {
|
1538
|
+
this.subs.$remove(sub);
|
1539
|
+
};
|
1581
1540
|
|
1582
1541
|
/**
|
1583
|
-
*
|
1584
|
-
*
|
1585
|
-
* @param {Object} prop
|
1586
|
-
* @param {*} value
|
1542
|
+
* Add self as a dependency to the target watcher.
|
1587
1543
|
*/
|
1588
1544
|
|
1589
|
-
function
|
1590
|
-
|
1591
|
-
|
1592
|
-
value == null) // null or undefined
|
1593
|
-
) {
|
1594
|
-
return true;
|
1595
|
-
}
|
1596
|
-
var options = prop.options;
|
1597
|
-
var type = options.type;
|
1598
|
-
var valid = true;
|
1599
|
-
var expectedType;
|
1600
|
-
if (type) {
|
1601
|
-
if (type === String) {
|
1602
|
-
expectedType = 'string';
|
1603
|
-
valid = typeof value === expectedType;
|
1604
|
-
} else if (type === Number) {
|
1605
|
-
expectedType = 'number';
|
1606
|
-
valid = typeof value === 'number';
|
1607
|
-
} else if (type === Boolean) {
|
1608
|
-
expectedType = 'boolean';
|
1609
|
-
valid = typeof value === 'boolean';
|
1610
|
-
} else if (type === Function) {
|
1611
|
-
expectedType = 'function';
|
1612
|
-
valid = typeof value === 'function';
|
1613
|
-
} else if (type === Object) {
|
1614
|
-
expectedType = 'object';
|
1615
|
-
valid = isPlainObject(value);
|
1616
|
-
} else if (type === Array) {
|
1617
|
-
expectedType = 'array';
|
1618
|
-
valid = isArray(value);
|
1619
|
-
} else {
|
1620
|
-
valid = value instanceof type;
|
1621
|
-
}
|
1622
|
-
}
|
1623
|
-
if (!valid) {
|
1624
|
-
'development' !== 'production' && warn('Invalid prop: type check failed for ' + prop.path + '="' + prop.raw + '".' + ' Expected ' + formatType(expectedType) + ', got ' + formatValue(value) + '.');
|
1625
|
-
return false;
|
1626
|
-
}
|
1627
|
-
var validator = options.validator;
|
1628
|
-
if (validator) {
|
1629
|
-
if (!validator(value)) {
|
1630
|
-
'development' !== 'production' && warn('Invalid prop: custom validator check failed for ' + prop.path + '="' + prop.raw + '"');
|
1631
|
-
return false;
|
1632
|
-
}
|
1633
|
-
}
|
1634
|
-
return true;
|
1635
|
-
}
|
1545
|
+
Dep.prototype.depend = function () {
|
1546
|
+
Dep.target.addDep(this);
|
1547
|
+
};
|
1636
1548
|
|
1637
1549
|
/**
|
1638
|
-
*
|
1639
|
-
*
|
1640
|
-
* @param {*} value
|
1641
|
-
* @param {Object} options
|
1642
|
-
* @return {*}
|
1550
|
+
* Notify all subscribers of a new value.
|
1643
1551
|
*/
|
1644
1552
|
|
1645
|
-
function
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1553
|
+
Dep.prototype.notify = function () {
|
1554
|
+
// stablize the subscriber list first
|
1555
|
+
var subs = toArray(this.subs);
|
1556
|
+
for (var i = 0, l = subs.length; i < l; i++) {
|
1557
|
+
subs[i].update();
|
1649
1558
|
}
|
1650
|
-
|
1651
|
-
return coerce(value);
|
1652
|
-
}
|
1653
|
-
|
1654
|
-
function formatType(val) {
|
1655
|
-
return val ? val.charAt(0).toUpperCase() + val.slice(1) : 'custom type';
|
1656
|
-
}
|
1559
|
+
};
|
1657
1560
|
|
1658
|
-
|
1659
|
-
|
1660
|
-
}
|
1561
|
+
var arrayProto = Array.prototype;
|
1562
|
+
var arrayMethods = Object.create(arrayProto)
|
1661
1563
|
|
1662
1564
|
/**
|
1663
|
-
*
|
1664
|
-
* how to merge a parent option value and a child option
|
1665
|
-
* value into the final value.
|
1666
|
-
*
|
1667
|
-
* All strategy functions follow the same signature:
|
1668
|
-
*
|
1669
|
-
* @param {*} parentVal
|
1670
|
-
* @param {*} childVal
|
1671
|
-
* @param {Vue} [vm]
|
1565
|
+
* Intercept mutating methods and emit events
|
1672
1566
|
*/
|
1673
1567
|
|
1674
|
-
|
1568
|
+
;['push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse'].forEach(function (method) {
|
1569
|
+
// cache original method
|
1570
|
+
var original = arrayProto[method];
|
1571
|
+
def(arrayMethods, method, function mutator() {
|
1572
|
+
// avoid leaking arguments:
|
1573
|
+
// http://jsperf.com/closure-with-arguments
|
1574
|
+
var i = arguments.length;
|
1575
|
+
var args = new Array(i);
|
1576
|
+
while (i--) {
|
1577
|
+
args[i] = arguments[i];
|
1578
|
+
}
|
1579
|
+
var result = original.apply(this, args);
|
1580
|
+
var ob = this.__ob__;
|
1581
|
+
var inserted;
|
1582
|
+
switch (method) {
|
1583
|
+
case 'push':
|
1584
|
+
inserted = args;
|
1585
|
+
break;
|
1586
|
+
case 'unshift':
|
1587
|
+
inserted = args;
|
1588
|
+
break;
|
1589
|
+
case 'splice':
|
1590
|
+
inserted = args.slice(2);
|
1591
|
+
break;
|
1592
|
+
}
|
1593
|
+
if (inserted) ob.observeArray(inserted);
|
1594
|
+
// notify change
|
1595
|
+
ob.dep.notify();
|
1596
|
+
return result;
|
1597
|
+
});
|
1598
|
+
});
|
1675
1599
|
|
1676
1600
|
/**
|
1677
|
-
*
|
1601
|
+
* Swap the element at the given index with a new value
|
1602
|
+
* and emits corresponding event.
|
1603
|
+
*
|
1604
|
+
* @param {Number} index
|
1605
|
+
* @param {*} val
|
1606
|
+
* @return {*} - replaced element
|
1678
1607
|
*/
|
1679
1608
|
|
1680
|
-
function
|
1681
|
-
|
1682
|
-
|
1683
|
-
toVal = to[key];
|
1684
|
-
fromVal = from[key];
|
1685
|
-
if (!hasOwn(to, key)) {
|
1686
|
-
set(to, key, fromVal);
|
1687
|
-
} else if (isObject(toVal) && isObject(fromVal)) {
|
1688
|
-
mergeData(toVal, fromVal);
|
1689
|
-
}
|
1609
|
+
def(arrayProto, '$set', function $set(index, val) {
|
1610
|
+
if (index >= this.length) {
|
1611
|
+
this.length = Number(index) + 1;
|
1690
1612
|
}
|
1691
|
-
return
|
1692
|
-
}
|
1613
|
+
return this.splice(index, 1, val)[0];
|
1614
|
+
});
|
1693
1615
|
|
1694
1616
|
/**
|
1695
|
-
*
|
1617
|
+
* Convenience method to remove the element at given index.
|
1618
|
+
*
|
1619
|
+
* @param {Number} index
|
1620
|
+
* @param {*} val
|
1696
1621
|
*/
|
1697
1622
|
|
1698
|
-
|
1699
|
-
if
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
if (typeof childVal !== 'function') {
|
1705
|
-
'development' !== 'production' && warn('The "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.');
|
1706
|
-
return parentVal;
|
1707
|
-
}
|
1708
|
-
if (!parentVal) {
|
1709
|
-
return childVal;
|
1710
|
-
}
|
1711
|
-
// when parentVal & childVal are both present,
|
1712
|
-
// we need to return a function that returns the
|
1713
|
-
// merged result of both functions... no need to
|
1714
|
-
// check if parentVal is a function here because
|
1715
|
-
// it has to be a function to pass previous merges.
|
1716
|
-
return function mergedDataFn() {
|
1717
|
-
return mergeData(childVal.call(this), parentVal.call(this));
|
1718
|
-
};
|
1719
|
-
} else if (parentVal || childVal) {
|
1720
|
-
return function mergedInstanceDataFn() {
|
1721
|
-
// instance merge
|
1722
|
-
var instanceData = typeof childVal === 'function' ? childVal.call(vm) : childVal;
|
1723
|
-
var defaultData = typeof parentVal === 'function' ? parentVal.call(vm) : undefined;
|
1724
|
-
if (instanceData) {
|
1725
|
-
return mergeData(instanceData, defaultData);
|
1726
|
-
} else {
|
1727
|
-
return defaultData;
|
1728
|
-
}
|
1729
|
-
};
|
1623
|
+
def(arrayProto, '$remove', function $remove(item) {
|
1624
|
+
/* istanbul ignore if */
|
1625
|
+
if (!this.length) return;
|
1626
|
+
var index = indexOf(this, item);
|
1627
|
+
if (index > -1) {
|
1628
|
+
return this.splice(index, 1);
|
1730
1629
|
}
|
1731
|
-
};
|
1630
|
+
});
|
1631
|
+
|
1632
|
+
var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
1732
1633
|
|
1733
1634
|
/**
|
1734
|
-
*
|
1635
|
+
* Observer class that are attached to each observed
|
1636
|
+
* object. Once attached, the observer converts target
|
1637
|
+
* object's property keys into getter/setters that
|
1638
|
+
* collect dependencies and dispatches updates.
|
1639
|
+
*
|
1640
|
+
* @param {Array|Object} value
|
1641
|
+
* @constructor
|
1735
1642
|
*/
|
1736
1643
|
|
1737
|
-
|
1738
|
-
|
1739
|
-
|
1740
|
-
|
1644
|
+
function Observer(value) {
|
1645
|
+
this.value = value;
|
1646
|
+
this.dep = new Dep();
|
1647
|
+
def(value, '__ob__', this);
|
1648
|
+
if (isArray(value)) {
|
1649
|
+
var augment = hasProto ? protoAugment : copyAugment;
|
1650
|
+
augment(value, arrayMethods, arrayKeys);
|
1651
|
+
this.observeArray(value);
|
1652
|
+
} else {
|
1653
|
+
this.walk(value);
|
1741
1654
|
}
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
};
|
1655
|
+
}
|
1656
|
+
|
1657
|
+
// Instance methods
|
1746
1658
|
|
1747
1659
|
/**
|
1748
|
-
*
|
1660
|
+
* Walk through each property and convert them into
|
1661
|
+
* getter/setters. This method should only be called when
|
1662
|
+
* value type is Object.
|
1663
|
+
*
|
1664
|
+
* @param {Object} obj
|
1749
1665
|
*/
|
1750
1666
|
|
1751
|
-
|
1752
|
-
|
1667
|
+
Observer.prototype.walk = function (obj) {
|
1668
|
+
var keys = Object.keys(obj);
|
1669
|
+
for (var i = 0, l = keys.length; i < l; i++) {
|
1670
|
+
this.convert(keys[i], obj[keys[i]]);
|
1671
|
+
}
|
1753
1672
|
};
|
1754
1673
|
|
1755
1674
|
/**
|
1756
|
-
*
|
1675
|
+
* Observe a list of Array items.
|
1676
|
+
*
|
1677
|
+
* @param {Array} items
|
1757
1678
|
*/
|
1758
1679
|
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1680
|
+
Observer.prototype.observeArray = function (items) {
|
1681
|
+
for (var i = 0, l = items.length; i < l; i++) {
|
1682
|
+
observe(items[i]);
|
1683
|
+
}
|
1762
1684
|
};
|
1763
1685
|
|
1764
1686
|
/**
|
1765
|
-
*
|
1687
|
+
* Convert a property into getter/setter so we can emit
|
1688
|
+
* the events when the property is accessed/changed.
|
1766
1689
|
*
|
1767
|
-
*
|
1768
|
-
*
|
1769
|
-
* options and parent options.
|
1690
|
+
* @param {String} key
|
1691
|
+
* @param {*} val
|
1770
1692
|
*/
|
1771
1693
|
|
1772
|
-
function
|
1773
|
-
|
1774
|
-
|
1775
|
-
}
|
1776
|
-
|
1777
|
-
config._assetTypes.forEach(function (type) {
|
1778
|
-
strats[type + 's'] = mergeAssets;
|
1779
|
-
});
|
1694
|
+
Observer.prototype.convert = function (key, val) {
|
1695
|
+
defineReactive(this.value, key, val);
|
1696
|
+
};
|
1780
1697
|
|
1781
1698
|
/**
|
1782
|
-
*
|
1699
|
+
* Add an owner vm, so that when $set/$delete mutations
|
1700
|
+
* happen we can notify owner vms to proxy the keys and
|
1701
|
+
* digest the watchers. This is only called when the object
|
1702
|
+
* is observed as an instance's root $data.
|
1783
1703
|
*
|
1784
|
-
*
|
1785
|
-
* another, so we merge them as arrays.
|
1704
|
+
* @param {Vue} vm
|
1786
1705
|
*/
|
1787
1706
|
|
1788
|
-
|
1789
|
-
|
1790
|
-
if (!parentVal) return childVal;
|
1791
|
-
var ret = {};
|
1792
|
-
extend(ret, parentVal);
|
1793
|
-
for (var key in childVal) {
|
1794
|
-
var parent = ret[key];
|
1795
|
-
var child = childVal[key];
|
1796
|
-
if (parent && !isArray(parent)) {
|
1797
|
-
parent = [parent];
|
1798
|
-
}
|
1799
|
-
ret[key] = parent ? parent.concat(child) : [child];
|
1800
|
-
}
|
1801
|
-
return ret;
|
1707
|
+
Observer.prototype.addVm = function (vm) {
|
1708
|
+
(this.vms || (this.vms = [])).push(vm);
|
1802
1709
|
};
|
1803
1710
|
|
1804
1711
|
/**
|
1805
|
-
*
|
1712
|
+
* Remove an owner vm. This is called when the object is
|
1713
|
+
* swapped out as an instance's $data object.
|
1714
|
+
*
|
1715
|
+
* @param {Vue} vm
|
1806
1716
|
*/
|
1807
1717
|
|
1808
|
-
|
1809
|
-
|
1810
|
-
if (!parentVal) return childVal;
|
1811
|
-
var ret = Object.create(null);
|
1812
|
-
extend(ret, parentVal);
|
1813
|
-
extend(ret, childVal);
|
1814
|
-
return ret;
|
1718
|
+
Observer.prototype.removeVm = function (vm) {
|
1719
|
+
this.vms.$remove(vm);
|
1815
1720
|
};
|
1816
1721
|
|
1722
|
+
// helpers
|
1723
|
+
|
1817
1724
|
/**
|
1818
|
-
*
|
1725
|
+
* Augment an target Object or Array by intercepting
|
1726
|
+
* the prototype chain using __proto__
|
1727
|
+
*
|
1728
|
+
* @param {Object|Array} target
|
1729
|
+
* @param {Object} proto
|
1819
1730
|
*/
|
1820
1731
|
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1732
|
+
function protoAugment(target, src) {
|
1733
|
+
/* eslint-disable no-proto */
|
1734
|
+
target.__proto__ = src;
|
1735
|
+
/* eslint-enable no-proto */
|
1736
|
+
}
|
1824
1737
|
|
1825
1738
|
/**
|
1826
|
-
*
|
1827
|
-
*
|
1739
|
+
* Augment an target Object or Array by defining
|
1740
|
+
* hidden properties.
|
1828
1741
|
*
|
1829
|
-
* @param {Object}
|
1742
|
+
* @param {Object|Array} target
|
1743
|
+
* @param {Object} proto
|
1830
1744
|
*/
|
1831
1745
|
|
1832
|
-
function
|
1833
|
-
|
1834
|
-
var
|
1835
|
-
|
1836
|
-
var def;
|
1837
|
-
if ('development' !== 'production') {
|
1838
|
-
var map = options._componentNameMap = {};
|
1839
|
-
}
|
1840
|
-
for (var i = 0, l = ids.length; i < l; i++) {
|
1841
|
-
var key = ids[i];
|
1842
|
-
if (commonTagRE.test(key) || reservedTagRE.test(key)) {
|
1843
|
-
'development' !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key);
|
1844
|
-
continue;
|
1845
|
-
}
|
1846
|
-
// record a all lowercase <-> kebab-case mapping for
|
1847
|
-
// possible custom element case error warning
|
1848
|
-
if ('development' !== 'production') {
|
1849
|
-
map[key.replace(/-/g, '').toLowerCase()] = hyphenate(key);
|
1850
|
-
}
|
1851
|
-
def = components[key];
|
1852
|
-
if (isPlainObject(def)) {
|
1853
|
-
components[key] = Vue.extend(def);
|
1854
|
-
}
|
1855
|
-
}
|
1746
|
+
function copyAugment(target, src, keys) {
|
1747
|
+
for (var i = 0, l = keys.length; i < l; i++) {
|
1748
|
+
var key = keys[i];
|
1749
|
+
def(target, key, src[key]);
|
1856
1750
|
}
|
1857
1751
|
}
|
1858
1752
|
|
1859
1753
|
/**
|
1860
|
-
*
|
1861
|
-
*
|
1754
|
+
* Attempt to create an observer instance for a value,
|
1755
|
+
* returns the new observer if successfully observed,
|
1756
|
+
* or the existing observer if the value already has one.
|
1862
1757
|
*
|
1863
|
-
* @param {
|
1758
|
+
* @param {*} value
|
1759
|
+
* @param {Vue} [vm]
|
1760
|
+
* @return {Observer|undefined}
|
1761
|
+
* @static
|
1864
1762
|
*/
|
1865
1763
|
|
1866
|
-
function
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
options.props[val] = null;
|
1876
|
-
} else if (val.name) {
|
1877
|
-
options.props[val.name] = val;
|
1878
|
-
}
|
1879
|
-
}
|
1880
|
-
} else if (isPlainObject(props)) {
|
1881
|
-
var keys = Object.keys(props);
|
1882
|
-
i = keys.length;
|
1883
|
-
while (i--) {
|
1884
|
-
val = props[keys[i]];
|
1885
|
-
if (typeof val === 'function') {
|
1886
|
-
props[keys[i]] = { type: val };
|
1887
|
-
}
|
1888
|
-
}
|
1764
|
+
function observe(value, vm) {
|
1765
|
+
if (!value || typeof value !== 'object') {
|
1766
|
+
return;
|
1767
|
+
}
|
1768
|
+
var ob;
|
1769
|
+
if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
|
1770
|
+
ob = value.__ob__;
|
1771
|
+
} else if ((isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
|
1772
|
+
ob = new Observer(value);
|
1889
1773
|
}
|
1774
|
+
if (ob && vm) {
|
1775
|
+
ob.addVm(vm);
|
1776
|
+
}
|
1777
|
+
return ob;
|
1890
1778
|
}
|
1891
1779
|
|
1892
1780
|
/**
|
1893
|
-
*
|
1894
|
-
* into the key-value Object format.
|
1781
|
+
* Define a reactive property on an Object.
|
1895
1782
|
*
|
1896
|
-
* @param {Object
|
1897
|
-
* @
|
1783
|
+
* @param {Object} obj
|
1784
|
+
* @param {String} key
|
1785
|
+
* @param {*} val
|
1786
|
+
* @param {Boolean} doNotObserve
|
1898
1787
|
*/
|
1899
1788
|
|
1900
|
-
function
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1789
|
+
function defineReactive(obj, key, val, doNotObserve) {
|
1790
|
+
var dep = new Dep();
|
1791
|
+
|
1792
|
+
var property = Object.getOwnPropertyDescriptor(obj, key);
|
1793
|
+
if (property && property.configurable === false) {
|
1794
|
+
return;
|
1795
|
+
}
|
1796
|
+
|
1797
|
+
// cater for pre-defined getter/setters
|
1798
|
+
var getter = property && property.get;
|
1799
|
+
var setter = property && property.set;
|
1800
|
+
|
1801
|
+
// if doNotObserve is true, only use the child value observer
|
1802
|
+
// if it already exists, and do not attempt to create it.
|
1803
|
+
// this allows freezing a large object from the root and
|
1804
|
+
// avoid unnecessary observation inside v-for fragments.
|
1805
|
+
var childOb = doNotObserve ? isObject(val) && val.__ob__ : observe(val);
|
1806
|
+
Object.defineProperty(obj, key, {
|
1807
|
+
enumerable: true,
|
1808
|
+
configurable: true,
|
1809
|
+
get: function reactiveGetter() {
|
1810
|
+
var value = getter ? getter.call(obj) : val;
|
1811
|
+
if (Dep.target) {
|
1812
|
+
dep.depend();
|
1813
|
+
if (childOb) {
|
1814
|
+
childOb.dep.depend();
|
1815
|
+
}
|
1816
|
+
if (isArray(value)) {
|
1817
|
+
for (var e, i = 0, l = value.length; i < l; i++) {
|
1818
|
+
e = value[i];
|
1819
|
+
e && e.__ob__ && e.__ob__.dep.depend();
|
1820
|
+
}
|
1821
|
+
}
|
1822
|
+
}
|
1823
|
+
return value;
|
1824
|
+
},
|
1825
|
+
set: function reactiveSetter(newVal) {
|
1826
|
+
var value = getter ? getter.call(obj) : val;
|
1827
|
+
if (newVal === value) {
|
1828
|
+
return;
|
1829
|
+
}
|
1830
|
+
if (setter) {
|
1831
|
+
setter.call(obj, newVal);
|
1910
1832
|
} else {
|
1911
|
-
|
1833
|
+
val = newVal;
|
1912
1834
|
}
|
1835
|
+
childOb = doNotObserve ? isObject(newVal) && newVal.__ob__ : observe(newVal);
|
1836
|
+
dep.notify();
|
1913
1837
|
}
|
1914
|
-
|
1915
|
-
|
1916
|
-
|
1838
|
+
});
|
1839
|
+
}
|
1840
|
+
|
1841
|
+
var commonTagRE = /^(div|p|span|img|a|b|i|br|ul|ol|li|h1|h2|h3|h4|h5|h6|code|pre|table|th|td|tr|form|label|input|select|option|nav|article|section|header|footer)$/i;
|
1842
|
+
var reservedTagRE = /^(slot|partial|component)$/i;
|
1843
|
+
|
1844
|
+
var isUnknownElement = undefined;
|
1845
|
+
if ('development' !== 'production') {
|
1846
|
+
isUnknownElement = function (el, tag) {
|
1847
|
+
if (tag.indexOf('-') > -1) {
|
1848
|
+
// http://stackoverflow.com/a/28210364/1070244
|
1849
|
+
return el.constructor === window.HTMLUnknownElement || el.constructor === window.HTMLElement;
|
1850
|
+
} else {
|
1851
|
+
return (/HTMLUnknownElement/.test(el.toString()) &&
|
1852
|
+
// Chrome returns unknown for several HTML5 elements.
|
1853
|
+
// https://code.google.com/p/chromium/issues/detail?id=540526
|
1854
|
+
!/^(data|time|rtc|rb)$/.test(tag)
|
1855
|
+
);
|
1856
|
+
}
|
1857
|
+
};
|
1917
1858
|
}
|
1918
1859
|
|
1919
1860
|
/**
|
1920
|
-
*
|
1921
|
-
*
|
1861
|
+
* Check if an element is a component, if yes return its
|
1862
|
+
* component id.
|
1922
1863
|
*
|
1923
|
-
* @param {
|
1924
|
-
* @param {Object}
|
1925
|
-
* @
|
1926
|
-
* an instantiation merge.
|
1864
|
+
* @param {Element} el
|
1865
|
+
* @param {Object} options
|
1866
|
+
* @return {Object|undefined}
|
1927
1867
|
*/
|
1928
1868
|
|
1929
|
-
function
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
1869
|
+
function checkComponentAttr(el, options) {
|
1870
|
+
var tag = el.tagName.toLowerCase();
|
1871
|
+
var hasAttrs = el.hasAttributes();
|
1872
|
+
if (!commonTagRE.test(tag) && !reservedTagRE.test(tag)) {
|
1873
|
+
if (resolveAsset(options, 'components', tag)) {
|
1874
|
+
return { id: tag };
|
1875
|
+
} else {
|
1876
|
+
var is = hasAttrs && getIsBinding(el);
|
1877
|
+
if (is) {
|
1878
|
+
return is;
|
1879
|
+
} else if ('development' !== 'production') {
|
1880
|
+
var expectedTag = options._componentNameMap && options._componentNameMap[tag];
|
1881
|
+
if (expectedTag) {
|
1882
|
+
warn('Unknown custom element: <' + tag + '> - ' + 'did you mean <' + expectedTag + '>? ' + 'HTML is case-insensitive, remember to use kebab-case in templates.');
|
1883
|
+
} else if (isUnknownElement(el, tag)) {
|
1884
|
+
warn('Unknown custom element: <' + tag + '> - did you ' + 'register the component correctly? For recursive components, ' + 'make sure to provide the "name" option.');
|
1885
|
+
}
|
1886
|
+
}
|
1945
1887
|
}
|
1888
|
+
} else if (hasAttrs) {
|
1889
|
+
return getIsBinding(el);
|
1946
1890
|
}
|
1947
|
-
function mergeField(key) {
|
1948
|
-
var strat = strats[key] || defaultStrat;
|
1949
|
-
options[key] = strat(parent[key], child[key], vm, key);
|
1950
|
-
}
|
1951
|
-
return options;
|
1952
1891
|
}
|
1953
1892
|
|
1954
1893
|
/**
|
1955
|
-
*
|
1956
|
-
* This function is used because child instances need access
|
1957
|
-
* to assets defined in its ancestor chain.
|
1894
|
+
* Get "is" binding from an element.
|
1958
1895
|
*
|
1959
|
-
* @param {
|
1960
|
-
* @
|
1961
|
-
* @param {String} id
|
1962
|
-
* @return {Object|Function}
|
1896
|
+
* @param {Element} el
|
1897
|
+
* @return {Object|undefined}
|
1963
1898
|
*/
|
1964
1899
|
|
1965
|
-
function
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1900
|
+
function getIsBinding(el) {
|
1901
|
+
// dynamic syntax
|
1902
|
+
var exp = getAttr(el, 'is');
|
1903
|
+
if (exp != null) {
|
1904
|
+
return { id: exp };
|
1905
|
+
} else {
|
1906
|
+
exp = getBindAttr(el, 'is');
|
1907
|
+
if (exp != null) {
|
1908
|
+
return { id: exp, dynamic: true };
|
1909
|
+
}
|
1969
1910
|
}
|
1970
|
-
var assets = options[type];
|
1971
|
-
var camelizedId;
|
1972
|
-
return assets[id] ||
|
1973
|
-
// camelCase ID
|
1974
|
-
assets[camelizedId = camelize(id)] ||
|
1975
|
-
// Pascal Case ID
|
1976
|
-
assets[camelizedId.charAt(0).toUpperCase() + camelizedId.slice(1)];
|
1977
1911
|
}
|
1978
1912
|
|
1979
1913
|
/**
|
1980
|
-
*
|
1914
|
+
* Set a prop's initial value on a vm and its data object.
|
1915
|
+
*
|
1916
|
+
* @param {Vue} vm
|
1917
|
+
* @param {Object} prop
|
1918
|
+
* @param {*} value
|
1981
1919
|
*/
|
1982
1920
|
|
1983
|
-
function
|
1984
|
-
|
1985
|
-
|
1921
|
+
function initProp(vm, prop, value) {
|
1922
|
+
var key = prop.path;
|
1923
|
+
value = coerceProp(prop, value);
|
1924
|
+
if (value === undefined) {
|
1925
|
+
value = getPropDefaultValue(vm, prop.options);
|
1926
|
+
}
|
1927
|
+
if (assertProp(prop, value)) {
|
1928
|
+
defineReactive(vm, key, value, true /* doNotObserve */);
|
1986
1929
|
}
|
1987
1930
|
}
|
1988
1931
|
|
1989
|
-
var uid$1 = 0;
|
1990
|
-
|
1991
1932
|
/**
|
1992
|
-
*
|
1993
|
-
* directives subscribing to it.
|
1933
|
+
* Get the default value of a prop.
|
1994
1934
|
*
|
1995
|
-
* @
|
1935
|
+
* @param {Vue} vm
|
1936
|
+
* @param {Object} options
|
1937
|
+
* @return {*}
|
1996
1938
|
*/
|
1997
|
-
function Dep() {
|
1998
|
-
this.id = uid$1++;
|
1999
|
-
this.subs = [];
|
2000
|
-
}
|
2001
1939
|
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
2005
|
-
|
1940
|
+
function getPropDefaultValue(vm, options) {
|
1941
|
+
// no default, return undefined
|
1942
|
+
if (!hasOwn(options, 'default')) {
|
1943
|
+
// absent boolean value defaults to false
|
1944
|
+
return options.type === Boolean ? false : undefined;
|
1945
|
+
}
|
1946
|
+
var def = options['default'];
|
1947
|
+
// warn against non-factory defaults for Object & Array
|
1948
|
+
if (isObject(def)) {
|
1949
|
+
'development' !== 'production' && warn('Object/Array as default prop values will be shared ' + 'across multiple instances. Use a factory function ' + 'to return the default value instead.');
|
1950
|
+
}
|
1951
|
+
// call factory function for non-Function types
|
1952
|
+
return typeof def === 'function' && options.type !== Function ? def.call(vm) : def;
|
1953
|
+
}
|
2006
1954
|
|
2007
1955
|
/**
|
2008
|
-
*
|
1956
|
+
* Assert whether a prop is valid.
|
2009
1957
|
*
|
2010
|
-
* @param {
|
1958
|
+
* @param {Object} prop
|
1959
|
+
* @param {*} value
|
2011
1960
|
*/
|
2012
1961
|
|
2013
|
-
|
2014
|
-
|
2015
|
-
|
1962
|
+
function assertProp(prop, value) {
|
1963
|
+
if (!prop.options.required && ( // non-required
|
1964
|
+
prop.raw === null || // abscent
|
1965
|
+
value == null) // null or undefined
|
1966
|
+
) {
|
1967
|
+
return true;
|
1968
|
+
}
|
1969
|
+
var options = prop.options;
|
1970
|
+
var type = options.type;
|
1971
|
+
var valid = true;
|
1972
|
+
var expectedType;
|
1973
|
+
if (type) {
|
1974
|
+
if (type === String) {
|
1975
|
+
expectedType = 'string';
|
1976
|
+
valid = typeof value === expectedType;
|
1977
|
+
} else if (type === Number) {
|
1978
|
+
expectedType = 'number';
|
1979
|
+
valid = typeof value === 'number';
|
1980
|
+
} else if (type === Boolean) {
|
1981
|
+
expectedType = 'boolean';
|
1982
|
+
valid = typeof value === 'boolean';
|
1983
|
+
} else if (type === Function) {
|
1984
|
+
expectedType = 'function';
|
1985
|
+
valid = typeof value === 'function';
|
1986
|
+
} else if (type === Object) {
|
1987
|
+
expectedType = 'object';
|
1988
|
+
valid = isPlainObject(value);
|
1989
|
+
} else if (type === Array) {
|
1990
|
+
expectedType = 'array';
|
1991
|
+
valid = isArray(value);
|
1992
|
+
} else {
|
1993
|
+
valid = value instanceof type;
|
1994
|
+
}
|
1995
|
+
}
|
1996
|
+
if (!valid) {
|
1997
|
+
'development' !== 'production' && warn('Invalid prop: type check failed for ' + prop.path + '="' + prop.raw + '".' + ' Expected ' + formatType(expectedType) + ', got ' + formatValue(value) + '.');
|
1998
|
+
return false;
|
1999
|
+
}
|
2000
|
+
var validator = options.validator;
|
2001
|
+
if (validator) {
|
2002
|
+
if (!validator(value)) {
|
2003
|
+
'development' !== 'production' && warn('Invalid prop: custom validator check failed for ' + prop.path + '="' + prop.raw + '"');
|
2004
|
+
return false;
|
2005
|
+
}
|
2006
|
+
}
|
2007
|
+
return true;
|
2008
|
+
}
|
2016
2009
|
|
2017
2010
|
/**
|
2018
|
-
*
|
2011
|
+
* Force parsing value with coerce option.
|
2019
2012
|
*
|
2020
|
-
* @param {
|
2013
|
+
* @param {*} value
|
2014
|
+
* @param {Object} options
|
2015
|
+
* @return {*}
|
2021
2016
|
*/
|
2022
2017
|
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2018
|
+
function coerceProp(prop, value) {
|
2019
|
+
var coerce = prop.options.coerce;
|
2020
|
+
if (!coerce) {
|
2021
|
+
return value;
|
2022
|
+
}
|
2023
|
+
// coerce is a function
|
2024
|
+
return coerce(value);
|
2025
|
+
}
|
2026
|
+
|
2027
|
+
function formatType(val) {
|
2028
|
+
return val ? val.charAt(0).toUpperCase() + val.slice(1) : 'custom type';
|
2029
|
+
}
|
2030
|
+
|
2031
|
+
function formatValue(val) {
|
2032
|
+
return Object.prototype.toString.call(val).slice(8, -1);
|
2033
|
+
}
|
2026
2034
|
|
2027
2035
|
/**
|
2028
|
-
*
|
2036
|
+
* Option overwriting strategies are functions that handle
|
2037
|
+
* how to merge a parent option value and a child option
|
2038
|
+
* value into the final value.
|
2039
|
+
*
|
2040
|
+
* All strategy functions follow the same signature:
|
2041
|
+
*
|
2042
|
+
* @param {*} parentVal
|
2043
|
+
* @param {*} childVal
|
2044
|
+
* @param {Vue} [vm]
|
2029
2045
|
*/
|
2030
2046
|
|
2031
|
-
|
2032
|
-
Dep.target.addDep(this);
|
2033
|
-
};
|
2047
|
+
var strats = config.optionMergeStrategies = Object.create(null);
|
2034
2048
|
|
2035
2049
|
/**
|
2036
|
-
*
|
2050
|
+
* Helper that recursively merges two data objects together.
|
2037
2051
|
*/
|
2038
2052
|
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2053
|
+
function mergeData(to, from) {
|
2054
|
+
var key, toVal, fromVal;
|
2055
|
+
for (key in from) {
|
2056
|
+
toVal = to[key];
|
2057
|
+
fromVal = from[key];
|
2058
|
+
if (!hasOwn(to, key)) {
|
2059
|
+
set(to, key, fromVal);
|
2060
|
+
} else if (isObject(toVal) && isObject(fromVal)) {
|
2061
|
+
mergeData(toVal, fromVal);
|
2062
|
+
}
|
2044
2063
|
}
|
2045
|
-
|
2046
|
-
|
2047
|
-
var arrayProto = Array.prototype;
|
2048
|
-
var arrayMethods = Object.create(arrayProto)
|
2064
|
+
return to;
|
2065
|
+
}
|
2049
2066
|
|
2050
2067
|
/**
|
2051
|
-
*
|
2068
|
+
* Data
|
2052
2069
|
*/
|
2053
2070
|
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
// http://jsperf.com/closure-with-arguments
|
2060
|
-
var i = arguments.length;
|
2061
|
-
var args = new Array(i);
|
2062
|
-
while (i--) {
|
2063
|
-
args[i] = arguments[i];
|
2071
|
+
strats.data = function (parentVal, childVal, vm) {
|
2072
|
+
if (!vm) {
|
2073
|
+
// in a Vue.extend merge, both should be functions
|
2074
|
+
if (!childVal) {
|
2075
|
+
return parentVal;
|
2064
2076
|
}
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
switch (method) {
|
2069
|
-
case 'push':
|
2070
|
-
inserted = args;
|
2071
|
-
break;
|
2072
|
-
case 'unshift':
|
2073
|
-
inserted = args;
|
2074
|
-
break;
|
2075
|
-
case 'splice':
|
2076
|
-
inserted = args.slice(2);
|
2077
|
-
break;
|
2077
|
+
if (typeof childVal !== 'function') {
|
2078
|
+
'development' !== 'production' && warn('The "data" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.');
|
2079
|
+
return parentVal;
|
2078
2080
|
}
|
2079
|
-
if (
|
2080
|
-
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2081
|
+
if (!parentVal) {
|
2082
|
+
return childVal;
|
2083
|
+
}
|
2084
|
+
// when parentVal & childVal are both present,
|
2085
|
+
// we need to return a function that returns the
|
2086
|
+
// merged result of both functions... no need to
|
2087
|
+
// check if parentVal is a function here because
|
2088
|
+
// it has to be a function to pass previous merges.
|
2089
|
+
return function mergedDataFn() {
|
2090
|
+
return mergeData(childVal.call(this), parentVal.call(this));
|
2091
|
+
};
|
2092
|
+
} else if (parentVal || childVal) {
|
2093
|
+
return function mergedInstanceDataFn() {
|
2094
|
+
// instance merge
|
2095
|
+
var instanceData = typeof childVal === 'function' ? childVal.call(vm) : childVal;
|
2096
|
+
var defaultData = typeof parentVal === 'function' ? parentVal.call(vm) : undefined;
|
2097
|
+
if (instanceData) {
|
2098
|
+
return mergeData(instanceData, defaultData);
|
2099
|
+
} else {
|
2100
|
+
return defaultData;
|
2101
|
+
}
|
2102
|
+
};
|
2103
|
+
}
|
2104
|
+
};
|
2085
2105
|
|
2086
2106
|
/**
|
2087
|
-
*
|
2088
|
-
* and emits corresponding event.
|
2089
|
-
*
|
2090
|
-
* @param {Number} index
|
2091
|
-
* @param {*} val
|
2092
|
-
* @return {*} - replaced element
|
2107
|
+
* El
|
2093
2108
|
*/
|
2094
2109
|
|
2095
|
-
|
2096
|
-
if (
|
2097
|
-
|
2110
|
+
strats.el = function (parentVal, childVal, vm) {
|
2111
|
+
if (!vm && childVal && typeof childVal !== 'function') {
|
2112
|
+
'development' !== 'production' && warn('The "el" option should be a function ' + 'that returns a per-instance value in component ' + 'definitions.');
|
2113
|
+
return;
|
2098
2114
|
}
|
2099
|
-
|
2100
|
-
|
2115
|
+
var ret = childVal || parentVal;
|
2116
|
+
// invoke the element factory if this is instance merge
|
2117
|
+
return vm && typeof ret === 'function' ? ret.call(vm) : ret;
|
2118
|
+
};
|
2101
2119
|
|
2102
2120
|
/**
|
2103
|
-
*
|
2104
|
-
*
|
2105
|
-
* @param {Number} index
|
2106
|
-
* @param {*} val
|
2121
|
+
* Hooks and param attributes are merged as arrays.
|
2107
2122
|
*/
|
2108
2123
|
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
var index = indexOf(this, item);
|
2113
|
-
if (index > -1) {
|
2114
|
-
return this.splice(index, 1);
|
2115
|
-
}
|
2116
|
-
});
|
2117
|
-
|
2118
|
-
var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
|
2124
|
+
strats.init = strats.created = strats.ready = strats.attached = strats.detached = strats.beforeCompile = strats.compiled = strats.beforeDestroy = strats.destroyed = strats.activate = function (parentVal, childVal) {
|
2125
|
+
return childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal;
|
2126
|
+
};
|
2119
2127
|
|
2120
2128
|
/**
|
2121
|
-
*
|
2122
|
-
* object. Once attached, the observer converts target
|
2123
|
-
* object's property keys into getter/setters that
|
2124
|
-
* collect dependencies and dispatches updates.
|
2125
|
-
*
|
2126
|
-
* @param {Array|Object} value
|
2127
|
-
* @constructor
|
2129
|
+
* 0.11 deprecation warning
|
2128
2130
|
*/
|
2129
2131
|
|
2130
|
-
function
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
if (isArray(value)) {
|
2135
|
-
var augment = hasProto ? protoAugment : copyAugment;
|
2136
|
-
augment(value, arrayMethods, arrayKeys);
|
2137
|
-
this.observeArray(value);
|
2138
|
-
} else {
|
2139
|
-
this.walk(value);
|
2140
|
-
}
|
2141
|
-
}
|
2142
|
-
|
2143
|
-
// Instance methods
|
2132
|
+
strats.paramAttributes = function () {
|
2133
|
+
/* istanbul ignore next */
|
2134
|
+
'development' !== 'production' && warn('"paramAttributes" option has been deprecated in 0.12. ' + 'Use "props" instead.');
|
2135
|
+
};
|
2144
2136
|
|
2145
2137
|
/**
|
2146
|
-
*
|
2147
|
-
* getter/setters. This method should only be called when
|
2148
|
-
* value type is Object.
|
2138
|
+
* Assets
|
2149
2139
|
*
|
2150
|
-
*
|
2140
|
+
* When a vm is present (instance creation), we need to do
|
2141
|
+
* a three-way merge between constructor options, instance
|
2142
|
+
* options and parent options.
|
2151
2143
|
*/
|
2152
2144
|
|
2153
|
-
|
2154
|
-
var
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
2158
|
-
|
2145
|
+
function mergeAssets(parentVal, childVal) {
|
2146
|
+
var res = Object.create(parentVal);
|
2147
|
+
return childVal ? extend(res, guardArrayAssets(childVal)) : res;
|
2148
|
+
}
|
2149
|
+
|
2150
|
+
config._assetTypes.forEach(function (type) {
|
2151
|
+
strats[type + 's'] = mergeAssets;
|
2152
|
+
});
|
2159
2153
|
|
2160
2154
|
/**
|
2161
|
-
*
|
2155
|
+
* Events & Watchers.
|
2162
2156
|
*
|
2163
|
-
*
|
2157
|
+
* Events & watchers hashes should not overwrite one
|
2158
|
+
* another, so we merge them as arrays.
|
2164
2159
|
*/
|
2165
2160
|
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2161
|
+
strats.watch = strats.events = function (parentVal, childVal) {
|
2162
|
+
if (!childVal) return parentVal;
|
2163
|
+
if (!parentVal) return childVal;
|
2164
|
+
var ret = {};
|
2165
|
+
extend(ret, parentVal);
|
2166
|
+
for (var key in childVal) {
|
2167
|
+
var parent = ret[key];
|
2168
|
+
var child = childVal[key];
|
2169
|
+
if (parent && !isArray(parent)) {
|
2170
|
+
parent = [parent];
|
2171
|
+
}
|
2172
|
+
ret[key] = parent ? parent.concat(child) : [child];
|
2169
2173
|
}
|
2174
|
+
return ret;
|
2170
2175
|
};
|
2171
2176
|
|
2172
2177
|
/**
|
2173
|
-
*
|
2174
|
-
* the events when the property is accessed/changed.
|
2175
|
-
*
|
2176
|
-
* @param {String} key
|
2177
|
-
* @param {*} val
|
2178
|
+
* Other object hashes.
|
2178
2179
|
*/
|
2179
2180
|
|
2180
|
-
|
2181
|
-
|
2181
|
+
strats.props = strats.methods = strats.computed = function (parentVal, childVal) {
|
2182
|
+
if (!childVal) return parentVal;
|
2183
|
+
if (!parentVal) return childVal;
|
2184
|
+
var ret = Object.create(null);
|
2185
|
+
extend(ret, parentVal);
|
2186
|
+
extend(ret, childVal);
|
2187
|
+
return ret;
|
2182
2188
|
};
|
2183
2189
|
|
2184
2190
|
/**
|
2185
|
-
*
|
2186
|
-
* happen we can notify owner vms to proxy the keys and
|
2187
|
-
* digest the watchers. This is only called when the object
|
2188
|
-
* is observed as an instance's root $data.
|
2189
|
-
*
|
2190
|
-
* @param {Vue} vm
|
2191
|
+
* Default strategy.
|
2191
2192
|
*/
|
2192
2193
|
|
2193
|
-
|
2194
|
-
|
2194
|
+
var defaultStrat = function defaultStrat(parentVal, childVal) {
|
2195
|
+
return childVal === undefined ? parentVal : childVal;
|
2195
2196
|
};
|
2196
2197
|
|
2197
2198
|
/**
|
2198
|
-
*
|
2199
|
-
*
|
2199
|
+
* Make sure component options get converted to actual
|
2200
|
+
* constructors.
|
2200
2201
|
*
|
2201
|
-
* @param {
|
2202
|
+
* @param {Object} options
|
2202
2203
|
*/
|
2203
2204
|
|
2204
|
-
|
2205
|
-
|
2206
|
-
|
2207
|
-
|
2208
|
-
|
2205
|
+
function guardComponents(options) {
|
2206
|
+
if (options.components) {
|
2207
|
+
var components = options.components = guardArrayAssets(options.components);
|
2208
|
+
var ids = Object.keys(components);
|
2209
|
+
var def;
|
2210
|
+
if ('development' !== 'production') {
|
2211
|
+
var map = options._componentNameMap = {};
|
2212
|
+
}
|
2213
|
+
for (var i = 0, l = ids.length; i < l; i++) {
|
2214
|
+
var key = ids[i];
|
2215
|
+
if (commonTagRE.test(key) || reservedTagRE.test(key)) {
|
2216
|
+
'development' !== 'production' && warn('Do not use built-in or reserved HTML elements as component ' + 'id: ' + key);
|
2217
|
+
continue;
|
2218
|
+
}
|
2219
|
+
// record a all lowercase <-> kebab-case mapping for
|
2220
|
+
// possible custom element case error warning
|
2221
|
+
if ('development' !== 'production') {
|
2222
|
+
map[key.replace(/-/g, '').toLowerCase()] = hyphenate(key);
|
2223
|
+
}
|
2224
|
+
def = components[key];
|
2225
|
+
if (isPlainObject(def)) {
|
2226
|
+
components[key] = Vue.extend(def);
|
2227
|
+
}
|
2228
|
+
}
|
2229
|
+
}
|
2230
|
+
}
|
2209
2231
|
|
2210
2232
|
/**
|
2211
|
-
*
|
2212
|
-
*
|
2233
|
+
* Ensure all props option syntax are normalized into the
|
2234
|
+
* Object-based format.
|
2213
2235
|
*
|
2214
|
-
* @param {Object
|
2215
|
-
* @param {Object} proto
|
2236
|
+
* @param {Object} options
|
2216
2237
|
*/
|
2217
2238
|
|
2218
|
-
function
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2239
|
+
function guardProps(options) {
|
2240
|
+
var props = options.props;
|
2241
|
+
var i, val;
|
2242
|
+
if (isArray(props)) {
|
2243
|
+
options.props = {};
|
2244
|
+
i = props.length;
|
2245
|
+
while (i--) {
|
2246
|
+
val = props[i];
|
2247
|
+
if (typeof val === 'string') {
|
2248
|
+
options.props[val] = null;
|
2249
|
+
} else if (val.name) {
|
2250
|
+
options.props[val.name] = val;
|
2251
|
+
}
|
2252
|
+
}
|
2253
|
+
} else if (isPlainObject(props)) {
|
2254
|
+
var keys = Object.keys(props);
|
2255
|
+
i = keys.length;
|
2256
|
+
while (i--) {
|
2257
|
+
val = props[keys[i]];
|
2258
|
+
if (typeof val === 'function') {
|
2259
|
+
props[keys[i]] = { type: val };
|
2260
|
+
}
|
2261
|
+
}
|
2262
|
+
}
|
2222
2263
|
}
|
2223
2264
|
|
2224
2265
|
/**
|
2225
|
-
*
|
2226
|
-
*
|
2266
|
+
* Guard an Array-format assets option and converted it
|
2267
|
+
* into the key-value Object format.
|
2227
2268
|
*
|
2228
|
-
* @param {Object|Array}
|
2229
|
-
* @
|
2269
|
+
* @param {Object|Array} assets
|
2270
|
+
* @return {Object}
|
2230
2271
|
*/
|
2231
2272
|
|
2232
|
-
function
|
2233
|
-
|
2234
|
-
var
|
2235
|
-
|
2273
|
+
function guardArrayAssets(assets) {
|
2274
|
+
if (isArray(assets)) {
|
2275
|
+
var res = {};
|
2276
|
+
var i = assets.length;
|
2277
|
+
var asset;
|
2278
|
+
while (i--) {
|
2279
|
+
asset = assets[i];
|
2280
|
+
var id = typeof asset === 'function' ? asset.options && asset.options.name || asset.id : asset.name || asset.id;
|
2281
|
+
if (!id) {
|
2282
|
+
'development' !== 'production' && warn('Array-syntax assets must provide a "name" or "id" field.');
|
2283
|
+
} else {
|
2284
|
+
res[id] = asset;
|
2285
|
+
}
|
2286
|
+
}
|
2287
|
+
return res;
|
2236
2288
|
}
|
2289
|
+
return assets;
|
2237
2290
|
}
|
2238
2291
|
|
2239
2292
|
/**
|
2240
|
-
*
|
2241
|
-
*
|
2242
|
-
* or the existing observer if the value already has one.
|
2293
|
+
* Merge two option objects into a new one.
|
2294
|
+
* Core utility used in both instantiation and inheritance.
|
2243
2295
|
*
|
2244
|
-
* @param {
|
2245
|
-
* @param {
|
2246
|
-
* @
|
2247
|
-
*
|
2296
|
+
* @param {Object} parent
|
2297
|
+
* @param {Object} child
|
2298
|
+
* @param {Vue} [vm] - if vm is present, indicates this is
|
2299
|
+
* an instantiation merge.
|
2248
2300
|
*/
|
2249
2301
|
|
2250
|
-
function
|
2251
|
-
|
2252
|
-
|
2302
|
+
function mergeOptions(parent, child, vm) {
|
2303
|
+
guardComponents(child);
|
2304
|
+
guardProps(child);
|
2305
|
+
var options = {};
|
2306
|
+
var key;
|
2307
|
+
if (child.mixins) {
|
2308
|
+
for (var i = 0, l = child.mixins.length; i < l; i++) {
|
2309
|
+
parent = mergeOptions(parent, child.mixins[i], vm);
|
2310
|
+
}
|
2253
2311
|
}
|
2254
|
-
|
2255
|
-
|
2256
|
-
ob = value.__ob__;
|
2257
|
-
} else if ((isArray(value) || isPlainObject(value)) && Object.isExtensible(value) && !value._isVue) {
|
2258
|
-
ob = new Observer(value);
|
2312
|
+
for (key in parent) {
|
2313
|
+
mergeField(key);
|
2259
2314
|
}
|
2260
|
-
|
2261
|
-
|
2315
|
+
for (key in child) {
|
2316
|
+
if (!hasOwn(parent, key)) {
|
2317
|
+
mergeField(key);
|
2318
|
+
}
|
2262
2319
|
}
|
2263
|
-
|
2320
|
+
function mergeField(key) {
|
2321
|
+
var strat = strats[key] || defaultStrat;
|
2322
|
+
options[key] = strat(parent[key], child[key], vm, key);
|
2323
|
+
}
|
2324
|
+
return options;
|
2264
2325
|
}
|
2265
2326
|
|
2266
2327
|
/**
|
2267
|
-
*
|
2328
|
+
* Resolve an asset.
|
2329
|
+
* This function is used because child instances need access
|
2330
|
+
* to assets defined in its ancestor chain.
|
2268
2331
|
*
|
2269
|
-
* @param {Object}
|
2270
|
-
* @param {String}
|
2271
|
-
* @param {
|
2332
|
+
* @param {Object} options
|
2333
|
+
* @param {String} type
|
2334
|
+
* @param {String} id
|
2335
|
+
* @return {Object|Function}
|
2272
2336
|
*/
|
2273
2337
|
|
2274
|
-
function
|
2275
|
-
|
2276
|
-
|
2277
|
-
var property = Object.getOwnPropertyDescriptor(obj, key);
|
2278
|
-
if (property && property.configurable === false) {
|
2338
|
+
function resolveAsset(options, type, id) {
|
2339
|
+
/* istanbul ignore if */
|
2340
|
+
if (typeof id !== 'string') {
|
2279
2341
|
return;
|
2280
2342
|
}
|
2343
|
+
var assets = options[type];
|
2344
|
+
var camelizedId;
|
2345
|
+
return assets[id] ||
|
2346
|
+
// camelCase ID
|
2347
|
+
assets[camelizedId = camelize(id)] ||
|
2348
|
+
// Pascal Case ID
|
2349
|
+
assets[camelizedId.charAt(0).toUpperCase() + camelizedId.slice(1)];
|
2350
|
+
}
|
2281
2351
|
|
2282
|
-
|
2283
|
-
|
2284
|
-
|
2352
|
+
/**
|
2353
|
+
* Assert asset exists
|
2354
|
+
*/
|
2285
2355
|
|
2286
|
-
|
2287
|
-
|
2288
|
-
|
2289
|
-
|
2290
|
-
get: function reactiveGetter() {
|
2291
|
-
var value = getter ? getter.call(obj) : val;
|
2292
|
-
if (Dep.target) {
|
2293
|
-
dep.depend();
|
2294
|
-
if (childOb) {
|
2295
|
-
childOb.dep.depend();
|
2296
|
-
}
|
2297
|
-
if (isArray(value)) {
|
2298
|
-
for (var e, i = 0, l = value.length; i < l; i++) {
|
2299
|
-
e = value[i];
|
2300
|
-
e && e.__ob__ && e.__ob__.dep.depend();
|
2301
|
-
}
|
2302
|
-
}
|
2303
|
-
}
|
2304
|
-
return value;
|
2305
|
-
},
|
2306
|
-
set: function reactiveSetter(newVal) {
|
2307
|
-
var value = getter ? getter.call(obj) : val;
|
2308
|
-
if (newVal === value) {
|
2309
|
-
return;
|
2310
|
-
}
|
2311
|
-
if (setter) {
|
2312
|
-
setter.call(obj, newVal);
|
2313
|
-
} else {
|
2314
|
-
val = newVal;
|
2315
|
-
}
|
2316
|
-
childOb = observe(newVal);
|
2317
|
-
dep.notify();
|
2318
|
-
}
|
2319
|
-
});
|
2356
|
+
function assertAsset(val, type, id) {
|
2357
|
+
if (!val) {
|
2358
|
+
'development' !== 'production' && warn('Failed to resolve ' + type + ': ' + id);
|
2359
|
+
}
|
2320
2360
|
}
|
2321
2361
|
|
2322
2362
|
|
@@ -2465,13 +2505,6 @@ var transition = Object.freeze({
|
|
2465
2505
|
this.$parent.$children.push(this);
|
2466
2506
|
}
|
2467
2507
|
|
2468
|
-
// save raw constructor data before merge
|
2469
|
-
// so that we know which properties are provided at
|
2470
|
-
// instantiation.
|
2471
|
-
if ('development' !== 'production') {
|
2472
|
-
this._runtimeData = options.data;
|
2473
|
-
}
|
2474
|
-
|
2475
2508
|
// merge options.
|
2476
2509
|
options = this.$options = mergeOptions(this.constructor.options, options, this);
|
2477
2510
|
|
@@ -2482,6 +2515,11 @@ var transition = Object.freeze({
|
|
2482
2515
|
// it will be filled up in _initScope().
|
2483
2516
|
this._data = {};
|
2484
2517
|
|
2518
|
+
// save raw constructor data before merge
|
2519
|
+
// so that we know which properties are provided at
|
2520
|
+
// instantiation.
|
2521
|
+
this._runtimeData = options.data;
|
2522
|
+
|
2485
2523
|
// call init hook
|
2486
2524
|
this._callHook('init');
|
2487
2525
|
|
@@ -2839,7 +2877,7 @@ var path = Object.freeze({
|
|
2839
2877
|
var allowedKeywordsRE = new RegExp('^(' + allowedKeywords.replace(/,/g, '\\b|') + '\\b)');
|
2840
2878
|
|
2841
2879
|
// keywords that don't make sense inside expressions
|
2842
|
-
var improperKeywords = 'break,case,class,catch,const,continue,debugger,default,' + 'delete,do,else,export,extends,finally,for,function,if,' + 'import,in,instanceof,let,return,super,switch,throw,try,' + 'var,while,with,yield,enum,await,implements,package,' + '
|
2880
|
+
var improperKeywords = 'break,case,class,catch,const,continue,debugger,default,' + 'delete,do,else,export,extends,finally,for,function,if,' + 'import,in,instanceof,let,return,super,switch,throw,try,' + 'var,while,with,yield,enum,await,implements,package,' + 'protected,static,interface,private,public';
|
2843
2881
|
var improperKeywordsRE = new RegExp('^(' + improperKeywords.replace(/,/g, '\\b|') + '\\b)');
|
2844
2882
|
|
2845
2883
|
var wsRE = /\s/g;
|
@@ -3030,6 +3068,8 @@ var expression = Object.freeze({
|
|
3030
3068
|
// before user watchers so that when user watchers are
|
3031
3069
|
// triggered, the DOM would have already been in updated
|
3032
3070
|
// state.
|
3071
|
+
|
3072
|
+
var queueIndex;
|
3033
3073
|
var queue = [];
|
3034
3074
|
var userQueue = [];
|
3035
3075
|
var has = {};
|
@@ -3059,7 +3099,7 @@ var expression = Object.freeze({
|
|
3059
3099
|
runBatcherQueue(userQueue);
|
3060
3100
|
// dev tool hook
|
3061
3101
|
/* istanbul ignore if */
|
3062
|
-
if (devtools) {
|
3102
|
+
if (devtools && config.devtools) {
|
3063
3103
|
devtools.emit('flush');
|
3064
3104
|
}
|
3065
3105
|
resetBatcherState();
|
@@ -3074,8 +3114,8 @@ var expression = Object.freeze({
|
|
3074
3114
|
function runBatcherQueue(queue) {
|
3075
3115
|
// do not cache length because more watchers might be pushed
|
3076
3116
|
// as we run existing watchers
|
3077
|
-
for (
|
3078
|
-
var watcher = queue[
|
3117
|
+
for (queueIndex = 0; queueIndex < queue.length; queueIndex++) {
|
3118
|
+
var watcher = queue[queueIndex];
|
3079
3119
|
var id = watcher.id;
|
3080
3120
|
has[id] = null;
|
3081
3121
|
watcher.run();
|
@@ -3104,20 +3144,20 @@ var expression = Object.freeze({
|
|
3104
3144
|
function pushWatcher(watcher) {
|
3105
3145
|
var id = watcher.id;
|
3106
3146
|
if (has[id] == null) {
|
3107
|
-
// if an internal watcher is pushed, but the internal
|
3108
|
-
// queue is already depleted, we run it immediately.
|
3109
3147
|
if (internalQueueDepleted && !watcher.user) {
|
3110
|
-
watcher
|
3111
|
-
|
3112
|
-
|
3113
|
-
|
3114
|
-
|
3115
|
-
|
3116
|
-
|
3117
|
-
|
3118
|
-
|
3119
|
-
waiting
|
3120
|
-
|
3148
|
+
// an internal watcher triggered by a user watcher...
|
3149
|
+
// let's run it immediately after current user watcher is done.
|
3150
|
+
userQueue.splice(queueIndex + 1, 0, watcher);
|
3151
|
+
} else {
|
3152
|
+
// push watcher into appropriate queue
|
3153
|
+
var q = watcher.user ? userQueue : queue;
|
3154
|
+
has[id] = q.length;
|
3155
|
+
q.push(watcher);
|
3156
|
+
// queue the flush
|
3157
|
+
if (!waiting) {
|
3158
|
+
waiting = true;
|
3159
|
+
nextTick(flushBatcherQueue);
|
3160
|
+
}
|
3121
3161
|
}
|
3122
3162
|
}
|
3123
3163
|
}
|
@@ -3151,13 +3191,15 @@ var expression = Object.freeze({
|
|
3151
3191
|
var isFn = typeof expOrFn === 'function';
|
3152
3192
|
this.vm = vm;
|
3153
3193
|
vm._watchers.push(this);
|
3154
|
-
this.expression =
|
3194
|
+
this.expression = expOrFn;
|
3155
3195
|
this.cb = cb;
|
3156
3196
|
this.id = ++uid$2; // uid for batching
|
3157
3197
|
this.active = true;
|
3158
3198
|
this.dirty = this.lazy; // for lazy watchers
|
3159
|
-
this.deps =
|
3160
|
-
this.newDeps =
|
3199
|
+
this.deps = [];
|
3200
|
+
this.newDeps = [];
|
3201
|
+
this.depIds = Object.create(null);
|
3202
|
+
this.newDepIds = null;
|
3161
3203
|
this.prevError = null; // for async error stacks
|
3162
3204
|
// parse expression for getter/setter
|
3163
3205
|
if (isFn) {
|
@@ -3174,23 +3216,6 @@ var expression = Object.freeze({
|
|
3174
3216
|
this.queued = this.shallow = false;
|
3175
3217
|
}
|
3176
3218
|
|
3177
|
-
/**
|
3178
|
-
* Add a dependency to this directive.
|
3179
|
-
*
|
3180
|
-
* @param {Dep} dep
|
3181
|
-
*/
|
3182
|
-
|
3183
|
-
Watcher.prototype.addDep = function (dep) {
|
3184
|
-
var id = dep.id;
|
3185
|
-
if (!this.newDeps[id]) {
|
3186
|
-
this.newDeps[id] = dep;
|
3187
|
-
if (!this.deps[id]) {
|
3188
|
-
this.deps[id] = dep;
|
3189
|
-
dep.addSub(this);
|
3190
|
-
}
|
3191
|
-
}
|
3192
|
-
};
|
3193
|
-
|
3194
3219
|
/**
|
3195
3220
|
* Evaluate the getter, and re-collect dependencies.
|
3196
3221
|
*/
|
@@ -3266,7 +3291,25 @@ var expression = Object.freeze({
|
|
3266
3291
|
|
3267
3292
|
Watcher.prototype.beforeGet = function () {
|
3268
3293
|
Dep.target = this;
|
3269
|
-
this.
|
3294
|
+
this.newDepIds = Object.create(null);
|
3295
|
+
this.newDeps.length = 0;
|
3296
|
+
};
|
3297
|
+
|
3298
|
+
/**
|
3299
|
+
* Add a dependency to this directive.
|
3300
|
+
*
|
3301
|
+
* @param {Dep} dep
|
3302
|
+
*/
|
3303
|
+
|
3304
|
+
Watcher.prototype.addDep = function (dep) {
|
3305
|
+
var id = dep.id;
|
3306
|
+
if (!this.newDepIds[id]) {
|
3307
|
+
this.newDepIds[id] = true;
|
3308
|
+
this.newDeps.push(dep);
|
3309
|
+
if (!this.depIds[id]) {
|
3310
|
+
dep.addSub(this);
|
3311
|
+
}
|
3312
|
+
}
|
3270
3313
|
};
|
3271
3314
|
|
3272
3315
|
/**
|
@@ -3275,15 +3318,17 @@ var expression = Object.freeze({
|
|
3275
3318
|
|
3276
3319
|
Watcher.prototype.afterGet = function () {
|
3277
3320
|
Dep.target = null;
|
3278
|
-
var
|
3279
|
-
var i = ids.length;
|
3321
|
+
var i = this.deps.length;
|
3280
3322
|
while (i--) {
|
3281
|
-
var
|
3282
|
-
if (!this.
|
3283
|
-
|
3323
|
+
var dep = this.deps[i];
|
3324
|
+
if (!this.newDepIds[dep.id]) {
|
3325
|
+
dep.removeSub(this);
|
3284
3326
|
}
|
3285
3327
|
}
|
3328
|
+
this.depIds = this.newDepIds;
|
3329
|
+
var tmp = this.deps;
|
3286
3330
|
this.deps = this.newDeps;
|
3331
|
+
this.newDeps = tmp;
|
3287
3332
|
};
|
3288
3333
|
|
3289
3334
|
/**
|
@@ -3371,10 +3416,9 @@ var expression = Object.freeze({
|
|
3371
3416
|
*/
|
3372
3417
|
|
3373
3418
|
Watcher.prototype.depend = function () {
|
3374
|
-
var
|
3375
|
-
var i = depIds.length;
|
3419
|
+
var i = this.deps.length;
|
3376
3420
|
while (i--) {
|
3377
|
-
this.deps[
|
3421
|
+
this.deps[i].depend();
|
3378
3422
|
}
|
3379
3423
|
};
|
3380
3424
|
|
@@ -3391,10 +3435,9 @@ var expression = Object.freeze({
|
|
3391
3435
|
if (!this.vm._isBeingDestroyed && !this.vm._vForRemoving) {
|
3392
3436
|
this.vm._watchers.$remove(this);
|
3393
3437
|
}
|
3394
|
-
var
|
3395
|
-
var i = depIds.length;
|
3438
|
+
var i = this.deps.length;
|
3396
3439
|
while (i--) {
|
3397
|
-
this.deps[
|
3440
|
+
this.deps[i].removeSub(this);
|
3398
3441
|
}
|
3399
3442
|
this.active = false;
|
3400
3443
|
this.vm = this.cb = this.value = null;
|
@@ -3462,7 +3505,7 @@ var expression = Object.freeze({
|
|
3462
3505
|
return isTemplate(node) && isFragment(node.content);
|
3463
3506
|
}
|
3464
3507
|
|
3465
|
-
var tagRE$1 = /<([\w
|
3508
|
+
var tagRE$1 = /<([\w:-]+)/;
|
3466
3509
|
var entityRE = /&#?\w+?;/;
|
3467
3510
|
|
3468
3511
|
/**
|
@@ -3584,6 +3627,7 @@ var expression = Object.freeze({
|
|
3584
3627
|
*/
|
3585
3628
|
|
3586
3629
|
function cloneNode(node) {
|
3630
|
+
/* istanbul ignore if */
|
3587
3631
|
if (!node.querySelectorAll) {
|
3588
3632
|
return node.cloneNode();
|
3589
3633
|
}
|
@@ -3893,7 +3937,7 @@ var template = Object.freeze({
|
|
3893
3937
|
*/
|
3894
3938
|
|
3895
3939
|
function attach(child) {
|
3896
|
-
if (!child._isAttached) {
|
3940
|
+
if (!child._isAttached && inDoc(child.$el)) {
|
3897
3941
|
child._callHook('attached');
|
3898
3942
|
}
|
3899
3943
|
}
|
@@ -3905,7 +3949,7 @@ var template = Object.freeze({
|
|
3905
3949
|
*/
|
3906
3950
|
|
3907
3951
|
function detach(child) {
|
3908
|
-
if (child._isAttached) {
|
3952
|
+
if (child._isAttached && !inDoc(child.$el)) {
|
3909
3953
|
child._callHook('detached');
|
3910
3954
|
}
|
3911
3955
|
}
|
@@ -4174,7 +4218,7 @@ var template = Object.freeze({
|
|
4174
4218
|
// for two-way binding on alias
|
4175
4219
|
scope.$forContext = this;
|
4176
4220
|
// define scope properties
|
4177
|
-
defineReactive(scope, alias, value);
|
4221
|
+
defineReactive(scope, alias, value, true /* do not observe */);
|
4178
4222
|
defineReactive(scope, '$index', index);
|
4179
4223
|
if (key) {
|
4180
4224
|
defineReactive(scope, '$key', key);
|
@@ -4558,12 +4602,11 @@ var template = Object.freeze({
|
|
4558
4602
|
var next = el.nextElementSibling;
|
4559
4603
|
if (next && getAttr(next, 'v-else') !== null) {
|
4560
4604
|
remove(next);
|
4561
|
-
this.
|
4605
|
+
this.elseEl = next;
|
4562
4606
|
}
|
4563
4607
|
// check main block
|
4564
4608
|
this.anchor = createAnchor('v-if');
|
4565
4609
|
replace(el, this.anchor);
|
4566
|
-
this.factory = new FragmentFactory(this.vm, el);
|
4567
4610
|
} else {
|
4568
4611
|
'development' !== 'production' && warn('v-if="' + this.expression + '" cannot be ' + 'used on an instance root element.');
|
4569
4612
|
this.invalid = true;
|
@@ -4586,6 +4629,10 @@ var template = Object.freeze({
|
|
4586
4629
|
this.elseFrag.remove();
|
4587
4630
|
this.elseFrag = null;
|
4588
4631
|
}
|
4632
|
+
// lazy init factory
|
4633
|
+
if (!this.factory) {
|
4634
|
+
this.factory = new FragmentFactory(this.vm, this.el);
|
4635
|
+
}
|
4589
4636
|
this.frag = this.factory.create(this._host, this._scope, this._frag);
|
4590
4637
|
this.frag.before(this.anchor);
|
4591
4638
|
},
|
@@ -4595,7 +4642,10 @@ var template = Object.freeze({
|
|
4595
4642
|
this.frag.remove();
|
4596
4643
|
this.frag = null;
|
4597
4644
|
}
|
4598
|
-
if (this.
|
4645
|
+
if (this.elseEl && !this.elseFrag) {
|
4646
|
+
if (!this.elseFactory) {
|
4647
|
+
this.elseFactory = new FragmentFactory(this.elseEl._context || this.vm, this.elseEl);
|
4648
|
+
}
|
4599
4649
|
this.elseFrag = this.elseFactory.create(this._host, this._scope, this._frag);
|
4600
4650
|
this.elseFrag.before(this.anchor);
|
4601
4651
|
}
|
@@ -4684,6 +4734,10 @@ var template = Object.freeze({
|
|
4684
4734
|
});
|
4685
4735
|
this.on('blur', function () {
|
4686
4736
|
self.focused = false;
|
4737
|
+
// do not sync value after fragment removal (#2017)
|
4738
|
+
if (!self._frag || self._frag.inserted) {
|
4739
|
+
self.rawListener();
|
4740
|
+
}
|
4687
4741
|
});
|
4688
4742
|
}
|
4689
4743
|
|
@@ -5131,7 +5185,7 @@ var template = Object.freeze({
|
|
5131
5185
|
}
|
5132
5186
|
// key filter
|
5133
5187
|
var keys = Object.keys(this.modifiers).filter(function (key) {
|
5134
|
-
return key !== 'stop' && key !== 'prevent';
|
5188
|
+
return key !== 'stop' && key !== 'prevent' && key !== 'self';
|
5135
5189
|
});
|
5136
5190
|
if (keys.length) {
|
5137
5191
|
handler = keyFilter(handler, keys);
|
@@ -5757,6 +5811,7 @@ var template = Object.freeze({
|
|
5757
5811
|
if (!child || this.keepAlive) {
|
5758
5812
|
if (child) {
|
5759
5813
|
// remove ref
|
5814
|
+
child._inactive = true;
|
5760
5815
|
child._updateRef(true);
|
5761
5816
|
}
|
5762
5817
|
return;
|
@@ -5809,10 +5864,8 @@ var template = Object.freeze({
|
|
5809
5864
|
var self = this;
|
5810
5865
|
var current = this.childVM;
|
5811
5866
|
// for devtool inspection
|
5812
|
-
if (
|
5813
|
-
|
5814
|
-
target._inactive = false;
|
5815
|
-
}
|
5867
|
+
if (current) current._inactive = true;
|
5868
|
+
target._inactive = false;
|
5816
5869
|
this.childVM = target;
|
5817
5870
|
switch (self.params.transitionMode) {
|
5818
5871
|
case 'in-out':
|
@@ -6461,7 +6514,7 @@ var template = Object.freeze({
|
|
6461
6514
|
vm._props[path] = prop;
|
6462
6515
|
if (raw === null) {
|
6463
6516
|
// initialize absent prop
|
6464
|
-
initProp(vm, prop,
|
6517
|
+
initProp(vm, prop, undefined);
|
6465
6518
|
} else if (prop.dynamic) {
|
6466
6519
|
// dynamic prop
|
6467
6520
|
if (prop.mode === propBindingModes.ONE_TIME) {
|
@@ -6496,29 +6549,6 @@ var template = Object.freeze({
|
|
6496
6549
|
};
|
6497
6550
|
}
|
6498
6551
|
|
6499
|
-
/**
|
6500
|
-
* Get the default value of a prop.
|
6501
|
-
*
|
6502
|
-
* @param {Vue} vm
|
6503
|
-
* @param {Object} options
|
6504
|
-
* @return {*}
|
6505
|
-
*/
|
6506
|
-
|
6507
|
-
function getDefault(vm, options) {
|
6508
|
-
// no default, return undefined
|
6509
|
-
if (!hasOwn(options, 'default')) {
|
6510
|
-
// absent boolean value defaults to false
|
6511
|
-
return options.type === Boolean ? false : undefined;
|
6512
|
-
}
|
6513
|
-
var def = options['default'];
|
6514
|
-
// warn against non-factory defaults for Object & Array
|
6515
|
-
if (isObject(def)) {
|
6516
|
-
'development' !== 'production' && warn('Object/Array as default prop values will be shared ' + 'across multiple instances. Use a factory function ' + 'to return the default value instead.');
|
6517
|
-
}
|
6518
|
-
// call factory function for non-Function types
|
6519
|
-
return typeof def === 'function' && options.type !== Function ? def.call(vm) : def;
|
6520
|
-
}
|
6521
|
-
|
6522
6552
|
// special binding prefixes
|
6523
6553
|
var bindRE = /^v-bind:|^:/;
|
6524
6554
|
var onRE = /^v-on:|^@/;
|
@@ -7403,7 +7433,7 @@ var template = Object.freeze({
|
|
7403
7433
|
if (!to.hasAttribute(name) && !specialCharRE.test(name)) {
|
7404
7434
|
to.setAttribute(name, value);
|
7405
7435
|
} else if (name === 'class' && !parseText(value)) {
|
7406
|
-
value.split(/\s+/).forEach(function (cls) {
|
7436
|
+
value.trim().split(/\s+/).forEach(function (cls) {
|
7407
7437
|
addClass(to, cls);
|
7408
7438
|
});
|
7409
7439
|
}
|
@@ -7421,39 +7451,25 @@ var template = Object.freeze({
|
|
7421
7451
|
* @param {Vue} vm
|
7422
7452
|
*/
|
7423
7453
|
|
7424
|
-
function
|
7454
|
+
function resolveSlots(vm, content) {
|
7425
7455
|
if (!content) {
|
7426
7456
|
return;
|
7427
7457
|
}
|
7428
|
-
var contents = vm._slotContents =
|
7429
|
-
var
|
7430
|
-
|
7431
|
-
|
7432
|
-
|
7433
|
-
|
7434
|
-
|
7435
|
-
if (name = slot.getAttribute('name')) {
|
7436
|
-
select(slot, name);
|
7437
|
-
} else if ('development' !== 'production' && (name = getBindAttr(slot, 'name'))) {
|
7438
|
-
warn('<slot :name="' + name + '">: slot names cannot be dynamic.');
|
7439
|
-
} else {
|
7440
|
-
// default slot
|
7441
|
-
hasDefault = true;
|
7442
|
-
}
|
7443
|
-
/* eslint-enable no-cond-assign */
|
7444
|
-
}
|
7445
|
-
if (hasDefault) {
|
7446
|
-
contents['default'] = extractFragment(content.childNodes, content);
|
7458
|
+
var contents = vm._slotContents = Object.create(null);
|
7459
|
+
var el, name;
|
7460
|
+
for (var i = 0, l = content.children.length; i < l; i++) {
|
7461
|
+
el = content.children[i];
|
7462
|
+
/* eslint-disable no-cond-assign */
|
7463
|
+
if (name = el.getAttribute('slot')) {
|
7464
|
+
(contents[name] || (contents[name] = [])).push(el);
|
7447
7465
|
}
|
7466
|
+
/* eslint-enable no-cond-assign */
|
7448
7467
|
}
|
7449
|
-
|
7450
|
-
|
7451
|
-
|
7452
|
-
|
7453
|
-
|
7454
|
-
if (nodes.length) {
|
7455
|
-
contents[name] = extractFragment(nodes, content);
|
7456
|
-
}
|
7468
|
+
for (name in contents) {
|
7469
|
+
contents[name] = extractFragment(contents[name], content);
|
7470
|
+
}
|
7471
|
+
if (content.hasChildNodes()) {
|
7472
|
+
contents['default'] = extractFragment(content.childNodes, content);
|
7457
7473
|
}
|
7458
7474
|
}
|
7459
7475
|
|
@@ -7461,7 +7477,6 @@ var template = Object.freeze({
|
|
7461
7477
|
* Extract qualified content nodes from a node list.
|
7462
7478
|
*
|
7463
7479
|
* @param {NodeList} nodes
|
7464
|
-
* @param {Element} parent
|
7465
7480
|
* @return {DocumentFragment}
|
7466
7481
|
*/
|
7467
7482
|
|
@@ -7470,13 +7485,11 @@ var template = Object.freeze({
|
|
7470
7485
|
nodes = toArray(nodes);
|
7471
7486
|
for (var i = 0, l = nodes.length; i < l; i++) {
|
7472
7487
|
var node = nodes[i];
|
7473
|
-
if (node.
|
7474
|
-
|
7475
|
-
|
7476
|
-
node = parseTemplate(node);
|
7477
|
-
}
|
7478
|
-
frag.appendChild(node);
|
7488
|
+
if (isTemplate(node) && !node.hasAttribute('v-if') && !node.hasAttribute('v-for')) {
|
7489
|
+
parent.removeChild(node);
|
7490
|
+
node = parseTemplate(node);
|
7479
7491
|
}
|
7492
|
+
frag.appendChild(node);
|
7480
7493
|
}
|
7481
7494
|
return frag;
|
7482
7495
|
}
|
@@ -7489,7 +7502,7 @@ var template = Object.freeze({
|
|
7489
7502
|
compileRoot: compileRoot,
|
7490
7503
|
terminalDirectives: terminalDirectives,
|
7491
7504
|
transclude: transclude,
|
7492
|
-
|
7505
|
+
resolveSlots: resolveSlots
|
7493
7506
|
});
|
7494
7507
|
|
7495
7508
|
function stateMixin (Vue) {
|
@@ -7549,33 +7562,25 @@ var template = Object.freeze({
|
|
7549
7562
|
*/
|
7550
7563
|
|
7551
7564
|
Vue.prototype._initData = function () {
|
7552
|
-
var
|
7553
|
-
var
|
7554
|
-
var
|
7555
|
-
var runtimeData;
|
7556
|
-
if ('development' !== 'production') {
|
7557
|
-
runtimeData = (typeof this._runtimeData === 'function' ? this._runtimeData() : this._runtimeData) || {};
|
7558
|
-
this._runtimeData = null;
|
7559
|
-
}
|
7560
|
-
if (optionsData) {
|
7561
|
-
this._data = optionsData;
|
7562
|
-
for (var prop in propsData) {
|
7563
|
-
if ('development' !== 'production' && hasOwn(optionsData, prop) && !hasOwn(runtimeData, prop)) {
|
7564
|
-
warn('Data field "' + prop + '" is already defined ' + 'as a prop. Use prop default value instead.');
|
7565
|
-
}
|
7566
|
-
if (this._props[prop].raw !== null || !hasOwn(optionsData, prop)) {
|
7567
|
-
set(optionsData, prop, propsData[prop]);
|
7568
|
-
}
|
7569
|
-
}
|
7570
|
-
}
|
7571
|
-
var data = this._data;
|
7565
|
+
var dataFn = this.$options.data;
|
7566
|
+
var data = this._data = dataFn ? dataFn() : {};
|
7567
|
+
var props = this._props;
|
7568
|
+
var runtimeData = this._runtimeData ? typeof this._runtimeData === 'function' ? this._runtimeData() : this._runtimeData : null;
|
7572
7569
|
// proxy data on instance
|
7573
7570
|
var keys = Object.keys(data);
|
7574
7571
|
var i, key;
|
7575
7572
|
i = keys.length;
|
7576
7573
|
while (i--) {
|
7577
7574
|
key = keys[i];
|
7578
|
-
|
7575
|
+
// there are two scenarios where we can proxy a data key:
|
7576
|
+
// 1. it's not already defined as a prop
|
7577
|
+
// 2. it's provided via a instantiation option AND there are no
|
7578
|
+
// template prop present
|
7579
|
+
if (!props || !hasOwn(props, key) || runtimeData && hasOwn(runtimeData, key) && props[key].raw === null) {
|
7580
|
+
this._proxy(key);
|
7581
|
+
} else if ('development' !== 'production') {
|
7582
|
+
warn('Data field "' + key + '" is already defined ' + 'as a prop. Use prop default value instead.');
|
7583
|
+
}
|
7579
7584
|
}
|
7580
7585
|
// observe data
|
7581
7586
|
observe(data, this);
|
@@ -8253,9 +8258,8 @@ var template = Object.freeze({
|
|
8253
8258
|
var contextOptions = this._context && this._context.$options;
|
8254
8259
|
var rootLinker = compileRoot(el, options, contextOptions);
|
8255
8260
|
|
8256
|
-
//
|
8257
|
-
|
8258
|
-
scanSlots(el, options._content, this);
|
8261
|
+
// resolve slot distribution
|
8262
|
+
resolveSlots(this, options._content);
|
8259
8263
|
|
8260
8264
|
// compile and link the rest
|
8261
8265
|
var contentLinkFn;
|
@@ -8687,9 +8691,15 @@ var template = Object.freeze({
|
|
8687
8691
|
}
|
8688
8692
|
// include computed fields
|
8689
8693
|
if (!path) {
|
8690
|
-
|
8694
|
+
var key;
|
8695
|
+
for (key in this.$options.computed) {
|
8691
8696
|
data[key] = clean(this[key]);
|
8692
8697
|
}
|
8698
|
+
if (this._props) {
|
8699
|
+
for (key in this._props) {
|
8700
|
+
data[key] = clean(this[key]);
|
8701
|
+
}
|
8702
|
+
}
|
8693
8703
|
}
|
8694
8704
|
console.log(data);
|
8695
8705
|
};
|
@@ -9675,14 +9685,16 @@ var template = Object.freeze({
|
|
9675
9685
|
|
9676
9686
|
installGlobalAPI(Vue);
|
9677
9687
|
|
9678
|
-
Vue.version = '1.0.
|
9688
|
+
Vue.version = '1.0.18';
|
9679
9689
|
|
9680
9690
|
// devtools global hook
|
9681
9691
|
/* istanbul ignore next */
|
9682
|
-
if (devtools) {
|
9683
|
-
devtools
|
9684
|
-
|
9685
|
-
|
9692
|
+
if (config.devtools) {
|
9693
|
+
if (devtools) {
|
9694
|
+
devtools.emit('init', Vue);
|
9695
|
+
} else if ('development' !== 'production' && inBrowser && /Chrome\/\d+/.test(window.navigator.userAgent)) {
|
9696
|
+
console.log('Download the Vue Devtools for a better development experience:\n' + 'https://github.com/vuejs/vue-devtools');
|
9697
|
+
}
|
9686
9698
|
}
|
9687
9699
|
|
9688
9700
|
return Vue;
|