MCPcopy
hub / github.com/keepfool/vue-tutorials / mergeOptions

Function mergeOptions

06.Router/basic/js/vue.js:1885–1918  ·  view source on GitHub ↗

* Merge two option objects into a new one. * Core utility used in both instantiation and inheritance. * * @param {Object} parent * @param {Object} child * @param {Vue} [vm] - if vm is present, indicates this is * an instantiation merge.

(parent, child, vm)

Source from the content-addressed store, hash-verified

1883 */
1884
1885 function mergeOptions(parent, child, vm) {
1886 guardComponents(child);
1887 guardProps(child);
1888 if ('development' !== 'production') {
1889 if (child.propsData && !vm) {
1890 warn('propsData can only be used as an instantiation option.');
1891 }
1892 }
1893 var options = {};
1894 var key;
1895 if (child['extends']) {
1896 parent = typeof child['extends'] === 'function' ? mergeOptions(parent, child['extends'].options, vm) : mergeOptions(parent, child['extends'], vm);
1897 }
1898 if (child.mixins) {
1899 for (var i = 0, l = child.mixins.length; i < l; i++) {
1900 var mixin = child.mixins[i];
1901 var mixinOptions = mixin.prototype instanceof Vue ? mixin.options : mixin;
1902 parent = mergeOptions(parent, mixinOptions, vm);
1903 }
1904 }
1905 for (key in parent) {
1906 mergeField(key);
1907 }
1908 for (key in child) {
1909 if (!hasOwn(parent, key)) {
1910 mergeField(key);
1911 }
1912 }
1913 function mergeField(key) {
1914 var strat = strats[key] || defaultStrat;
1915 options[key] = strat(parent[key], child[key], vm, key);
1916 }
1917 return options;
1918 }
1919
1920 /**
1921 * Resolve an asset.

Callers 2

initMixinFunction · 0.70
installGlobalAPIFunction · 0.70

Calls 5

guardComponentsFunction · 0.70
guardPropsFunction · 0.70
warnFunction · 0.70
mergeFieldFunction · 0.70
hasOwnFunction · 0.70

Tested by

no test coverage detected