(Vue)
| 8780 | } |
| 8781 | |
| 8782 | function miscMixin (Vue) { |
| 8783 | /** |
| 8784 | * Apply a list of filter (descriptors) to a value. |
| 8785 | * Using plain for loops here because this will be called in |
| 8786 | * the getter of any watcher with filters so it is very |
| 8787 | * performance sensitive. |
| 8788 | * |
| 8789 | * @param {*} value |
| 8790 | * @param {*} [oldValue] |
| 8791 | * @param {Array} filters |
| 8792 | * @param {Boolean} write |
| 8793 | * @return {*} |
| 8794 | */ |
| 8795 | |
| 8796 | Vue.prototype._applyFilters = function (value, oldValue, filters, write) { |
| 8797 | var filter, fn, args, arg, offset, i, l, j, k; |
| 8798 | for (i = 0, l = filters.length; i < l; i++) { |
| 8799 | filter = filters[write ? l - i - 1 : i]; |
| 8800 | fn = resolveAsset(this.$options, 'filters', filter.name, true); |
| 8801 | if (!fn) continue; |
| 8802 | fn = write ? fn.write : fn.read || fn; |
| 8803 | if (typeof fn !== 'function') continue; |
| 8804 | args = write ? [value, oldValue] : [value]; |
| 8805 | offset = write ? 2 : 1; |
| 8806 | if (filter.args) { |
| 8807 | for (j = 0, k = filter.args.length; j < k; j++) { |
| 8808 | arg = filter.args[j]; |
| 8809 | args[j + offset] = arg.dynamic ? this.$get(arg.value) : arg.value; |
| 8810 | } |
| 8811 | } |
| 8812 | value = fn.apply(this, args); |
| 8813 | } |
| 8814 | return value; |
| 8815 | }; |
| 8816 | |
| 8817 | /** |
| 8818 | * Resolve a component, depending on whether the component |
| 8819 | * is defined normally or using an async factory function. |
| 8820 | * Resolves synchronously if already resolved, otherwise |
| 8821 | * resolves asynchronously and caches the resolved |
| 8822 | * constructor on the factory. |
| 8823 | * |
| 8824 | * @param {String|Function} value |
| 8825 | * @param {Function} cb |
| 8826 | */ |
| 8827 | |
| 8828 | Vue.prototype._resolveComponent = function (value, cb) { |
| 8829 | var factory; |
| 8830 | if (typeof value === 'function') { |
| 8831 | factory = value; |
| 8832 | } else { |
| 8833 | factory = resolveAsset(this.$options, 'components', value, true); |
| 8834 | } |
| 8835 | /* istanbul ignore if */ |
| 8836 | if (!factory) { |
| 8837 | return; |
| 8838 | } |
| 8839 | // async component factory |
no test coverage detected