(Vue)
| 1728 | }; |
| 1729 | |
| 1730 | function applyOverride (Vue) { |
| 1731 | var _Vue$util = Vue.util; |
| 1732 | var extend = _Vue$util.extend; |
| 1733 | var isArray = _Vue$util.isArray; |
| 1734 | var defineReactive = _Vue$util.defineReactive; |
| 1735 | |
| 1736 | // override Vue's init and destroy process to keep track of router instances |
| 1737 | var init = Vue.prototype._init; |
| 1738 | Vue.prototype._init = function (options) { |
| 1739 | options = options || {}; |
| 1740 | var root = options._parent || options.parent || this; |
| 1741 | var router = root.$router; |
| 1742 | var route = root.$route; |
| 1743 | if (router) { |
| 1744 | // expose router |
| 1745 | this.$router = router; |
| 1746 | router._children.push(this); |
| 1747 | /* istanbul ignore if */ |
| 1748 | if (this._defineMeta) { |
| 1749 | // 0.12 |
| 1750 | this._defineMeta('$route', route); |
| 1751 | } else { |
| 1752 | // 1.0 |
| 1753 | defineReactive(this, '$route', route); |
| 1754 | } |
| 1755 | } |
| 1756 | init.call(this, options); |
| 1757 | }; |
| 1758 | |
| 1759 | var destroy = Vue.prototype._destroy; |
| 1760 | Vue.prototype._destroy = function () { |
| 1761 | if (!this._isBeingDestroyed && this.$router) { |
| 1762 | this.$router._children.$remove(this); |
| 1763 | } |
| 1764 | destroy.apply(this, arguments); |
| 1765 | }; |
| 1766 | |
| 1767 | // 1.0 only: enable route mixins |
| 1768 | var strats = Vue.config.optionMergeStrategies; |
| 1769 | var hooksToMergeRE = /^(data|activate|deactivate)$/; |
| 1770 | |
| 1771 | if (strats) { |
| 1772 | strats.route = function (parentVal, childVal) { |
| 1773 | if (!childVal) return parentVal; |
| 1774 | if (!parentVal) return childVal; |
| 1775 | var ret = {}; |
| 1776 | extend(ret, parentVal); |
| 1777 | for (var key in childVal) { |
| 1778 | var a = ret[key]; |
| 1779 | var b = childVal[key]; |
| 1780 | // for data, activate and deactivate, we need to merge them into |
| 1781 | // arrays similar to lifecycle hooks. |
| 1782 | if (a && hooksToMergeRE.test(key)) { |
| 1783 | ret[key] = (isArray(a) ? a : [a]).concat(b); |
| 1784 | } else { |
| 1785 | ret[key] = b; |
| 1786 | } |
| 1787 | } |
no test coverage detected