Skip to content

Commit c27d933

Browse files
committed
chore: publish 1.1.3
1 parent 48100be commit c27d933

File tree

4 files changed

+205
-262
lines changed

4 files changed

+205
-262
lines changed

packages/server-test-utils/dist/vue-server-test-utils.js

+49-64
Original file line numberDiff line numberDiff line change
@@ -2149,7 +2149,6 @@ var config = {
21492149
mocks: {},
21502150
methods: {},
21512151
provide: {},
2152-
silent: true,
21532152
showDeprecationWarnings:
21542153
typeof process.env.SHOW_DEPRECATIONS !== 'undefined'
21552154
? process.env.SHOW_DEPRECATIONS
@@ -10142,71 +10141,49 @@ Wrapper.prototype.setProps = function setProps (data) {
1014210141
if (!this.vm) {
1014310142
throwError("wrapper.setProps() can only be called on a Vue instance");
1014410143
}
10145-
this.__warnIfDestroyed();
10146-
10147-
// Save the original "silent" config so that we can directly mutate props
10148-
var originalConfig = Vue__default['default'].config.silent;
10149-
Vue__default['default'].config.silent = config.silent;
1015010144

10151-
try {
10152-
Object.keys(data).forEach(function (key) {
10153-
// Don't let people set entire objects, because reactivity won't work
10154-
if (
10155-
typeof data[key] === 'object' &&
10156-
data[key] !== null &&
10157-
// $FlowIgnore : Problem with possibly null this.vm
10158-
data[key] === this$1.vm[key]
10159-
) {
10160-
throwError(
10161-
"wrapper.setProps() called with the same object of the existing " +
10162-
key + " property. You must call wrapper.setProps() with a new " +
10163-
"object to trigger reactivity"
10164-
);
10165-
}
10145+
// $FlowIgnore : Problem with possibly null this.vm
10146+
if (!this.vm.$parent.$options.$_isWrapperParent) {
10147+
throwError(
10148+
"wrapper.setProps() can only be called for top-level component"
10149+
);
10150+
}
1016610151

10167-
if (
10168-
!this$1.vm ||
10169-
!this$1.vm.$options._propKeys ||
10170-
!this$1.vm.$options._propKeys.some(function (prop) { return prop === key; })
10171-
) {
10172-
if (VUE_VERSION > 2.3) {
10173-
// $FlowIgnore : Problem with possibly null this.vm
10174-
this$1.vm.$attrs[key] = data[key];
10175-
return nextTick()
10176-
}
10177-
throwError(
10178-
"wrapper.setProps() called with " + key + " property which " +
10179-
"is not defined on the component"
10180-
);
10181-
}
10152+
this.__warnIfDestroyed();
1018210153

10183-
// Actually set the prop
10154+
Object.keys(data).forEach(function (key) {
10155+
// Don't let people set entire objects, because reactivity won't work
10156+
if (
10157+
typeof data[key] === 'object' &&
10158+
data[key] !== null &&
1018410159
// $FlowIgnore : Problem with possibly null this.vm
10185-
this$1.vm[key] = data[key];
10186-
});
10160+
data[key] === this$1.vm[key]
10161+
) {
10162+
throwError(
10163+
"wrapper.setProps() called with the same object of the existing " +
10164+
key + " property. You must call wrapper.setProps() with a new " +
10165+
"object to trigger reactivity"
10166+
);
10167+
}
10168+
10169+
if (
10170+
VUE_VERSION <= 2.3 &&
10171+
(!this$1.vm ||
10172+
!this$1.vm.$options._propKeys ||
10173+
!this$1.vm.$options._propKeys.some(function (prop) { return prop === key; }))
10174+
) {
10175+
throwError(
10176+
"wrapper.setProps() called with " + key + " property which " +
10177+
"is not defined on the component"
10178+
);
10179+
}
1018710180

1018810181
// $FlowIgnore : Problem with possibly null this.vm
10189-
this.vm.$forceUpdate();
10190-
return new Promise(function (resolve) {
10191-
nextTick().then(function () {
10192-
var isUpdated = Object.keys(data).some(function (key) {
10193-
return (
10194-
// $FlowIgnore : Problem with possibly null this.vm
10195-
this$1.vm[key] === data[key] ||
10196-
// $FlowIgnore : Problem with possibly null this.vm
10197-
(this$1.vm.$attrs && this$1.vm.$attrs[key] === data[key])
10198-
)
10199-
});
10200-
return !isUpdated ? this$1.setProps(data).then(resolve()) : resolve()
10201-
});
10202-
})
10203-
} catch (err) {
10204-
throw err
10205-
} finally {
10206-
// Ensure you teardown the modifications you made to the user's config
10207-
// After all the props are set, then reset the state
10208-
Vue__default['default'].config.silent = originalConfig;
10209-
}
10182+
var parent = this$1.vm.$parent;
10183+
parent.$set(parent.vueTestUtils_childProps, key, data[key]);
10184+
});
10185+
10186+
return nextTick()
1021010187
};
1021110188

1021210189
/**
@@ -13700,13 +13677,13 @@ function patchCreateElement(_Vue, stubs, stubAllComponents) {
1370013677

1370113678
function objectWithoutProperties (obj, exclude) { var target = {}; for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k]; return target; }
1370213679

13703-
function createContext(options, scopedSlots) {
13680+
function createContext(options, scopedSlots, currentProps) {
1370413681
var on = Object.assign({}, (options.context && options.context.on),
1370513682
options.listeners);
1370613683
return Object.assign({}, {attrs: Object.assign({}, options.attrs,
1370713684
// pass as attrs so that inheritAttrs works correctly
13708-
// propsData should take precedence over attrs
13709-
options.propsData)},
13685+
// props should take precedence over attrs
13686+
currentProps)},
1371013687
(options.context || {}),
1371113688
{on: on,
1371213689
scopedSlots: scopedSlots})
@@ -13795,15 +13772,23 @@ function createInstance(
1379513772
var originalParentComponentProvide = parentComponentOptions.provide;
1379613773
parentComponentOptions.provide = function() {
1379713774
return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
13775+
// $FlowIgnore
1379813776
getValuesFromCallableOption.call(this, options.provide))
1379913777
};
1380013778

13779+
var originalParentComponentData = parentComponentOptions.data;
13780+
parentComponentOptions.data = function() {
13781+
return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentData),
13782+
{vueTestUtils_childProps: Object.assign({}, options.propsData)})
13783+
};
13784+
1380113785
parentComponentOptions.$_doNotStubChildren = true;
13786+
parentComponentOptions.$_isWrapperParent = true;
1380213787
parentComponentOptions._isFunctionalContainer = componentOptions.functional;
1380313788
parentComponentOptions.render = function(h) {
1380413789
return h(
1380513790
Constructor,
13806-
createContext(options, scopedSlots),
13791+
createContext(options, scopedSlots, this.vueTestUtils_childProps),
1380713792
createChildren(this, h, options)
1380813793
)
1380913794
};

packages/test-utils/dist/vue-test-utils.iife.js

+52-66
Original file line numberDiff line numberDiff line change
@@ -2527,13 +2527,13 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
25272527

25282528
function objectWithoutProperties (obj, exclude) { var target = {}; for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k) && exclude.indexOf(k) === -1) target[k] = obj[k]; return target; }
25292529

2530-
function createContext(options, scopedSlots) {
2530+
function createContext(options, scopedSlots, currentProps) {
25312531
var on = Object.assign({}, (options.context && options.context.on),
25322532
options.listeners);
25332533
return Object.assign({}, {attrs: Object.assign({}, options.attrs,
25342534
// pass as attrs so that inheritAttrs works correctly
2535-
// propsData should take precedence over attrs
2536-
options.propsData)},
2535+
// props should take precedence over attrs
2536+
currentProps)},
25372537
(options.context || {}),
25382538
{on: on,
25392539
scopedSlots: scopedSlots})
@@ -2622,15 +2622,23 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
26222622
var originalParentComponentProvide = parentComponentOptions.provide;
26232623
parentComponentOptions.provide = function() {
26242624
return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
2625+
// $FlowIgnore
26252626
getValuesFromCallableOption.call(this, options.provide))
26262627
};
26272628

2629+
var originalParentComponentData = parentComponentOptions.data;
2630+
parentComponentOptions.data = function() {
2631+
return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentData),
2632+
{vueTestUtils_childProps: Object.assign({}, options.propsData)})
2633+
};
2634+
26282635
parentComponentOptions.$_doNotStubChildren = true;
2636+
parentComponentOptions.$_isWrapperParent = true;
26292637
parentComponentOptions._isFunctionalContainer = componentOptions.functional;
26302638
parentComponentOptions.render = function(h) {
26312639
return h(
26322640
Constructor,
2633-
createContext(options, scopedSlots),
2641+
createContext(options, scopedSlots, this.vueTestUtils_childProps),
26342642
createChildren(this, h, options)
26352643
)
26362644
};
@@ -2892,13 +2900,14 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
28922900
vm._error = error;
28932901
}
28942902

2903+
if (!instancedErrorHandlers.length) {
2904+
throw error
2905+
}
28952906
// should be one error handler, as only once can be registered with local vue
28962907
// regardless, if more exist (for whatever reason), invoke the other user defined error handlers
28972908
instancedErrorHandlers.forEach(function (instancedErrorHandler) {
28982909
instancedErrorHandler(error, vm, info);
28992910
});
2900-
2901-
throw error
29022911
}
29032912

29042913
function throwIfInstancesThrew(vm) {
@@ -3022,7 +3031,6 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
30223031
mocks: {},
30233032
methods: {},
30243033
provide: {},
3025-
silent: true,
30263034
showDeprecationWarnings:
30273035
true
30283036
};
@@ -11037,71 +11045,49 @@ var VueTestUtils = (function (exports, Vue, vueTemplateCompiler) {
1103711045
if (!this.vm) {
1103811046
throwError("wrapper.setProps() can only be called on a Vue instance");
1103911047
}
11040-
this.__warnIfDestroyed();
11041-
11042-
// Save the original "silent" config so that we can directly mutate props
11043-
var originalConfig = Vue__default['default'].config.silent;
11044-
Vue__default['default'].config.silent = config.silent;
1104511048

11046-
try {
11047-
Object.keys(data).forEach(function (key) {
11048-
// Don't let people set entire objects, because reactivity won't work
11049-
if (
11050-
typeof data[key] === 'object' &&
11051-
data[key] !== null &&
11052-
// $FlowIgnore : Problem with possibly null this.vm
11053-
data[key] === this$1.vm[key]
11054-
) {
11055-
throwError(
11056-
"wrapper.setProps() called with the same object of the existing " +
11057-
key + " property. You must call wrapper.setProps() with a new " +
11058-
"object to trigger reactivity"
11059-
);
11060-
}
11049+
// $FlowIgnore : Problem with possibly null this.vm
11050+
if (!this.vm.$parent.$options.$_isWrapperParent) {
11051+
throwError(
11052+
"wrapper.setProps() can only be called for top-level component"
11053+
);
11054+
}
1106111055

11062-
if (
11063-
!this$1.vm ||
11064-
!this$1.vm.$options._propKeys ||
11065-
!this$1.vm.$options._propKeys.some(function (prop) { return prop === key; })
11066-
) {
11067-
if (VUE_VERSION > 2.3) {
11068-
// $FlowIgnore : Problem with possibly null this.vm
11069-
this$1.vm.$attrs[key] = data[key];
11070-
return nextTick()
11071-
}
11072-
throwError(
11073-
"wrapper.setProps() called with " + key + " property which " +
11074-
"is not defined on the component"
11075-
);
11076-
}
11056+
this.__warnIfDestroyed();
1107711057

11078-
// Actually set the prop
11058+
Object.keys(data).forEach(function (key) {
11059+
// Don't let people set entire objects, because reactivity won't work
11060+
if (
11061+
typeof data[key] === 'object' &&
11062+
data[key] !== null &&
1107911063
// $FlowIgnore : Problem with possibly null this.vm
11080-
this$1.vm[key] = data[key];
11081-
});
11064+
data[key] === this$1.vm[key]
11065+
) {
11066+
throwError(
11067+
"wrapper.setProps() called with the same object of the existing " +
11068+
key + " property. You must call wrapper.setProps() with a new " +
11069+
"object to trigger reactivity"
11070+
);
11071+
}
11072+
11073+
if (
11074+
VUE_VERSION <= 2.3 &&
11075+
(!this$1.vm ||
11076+
!this$1.vm.$options._propKeys ||
11077+
!this$1.vm.$options._propKeys.some(function (prop) { return prop === key; }))
11078+
) {
11079+
throwError(
11080+
"wrapper.setProps() called with " + key + " property which " +
11081+
"is not defined on the component"
11082+
);
11083+
}
1108211084

1108311085
// $FlowIgnore : Problem with possibly null this.vm
11084-
this.vm.$forceUpdate();
11085-
return new Promise(function (resolve) {
11086-
nextTick().then(function () {
11087-
var isUpdated = Object.keys(data).some(function (key) {
11088-
return (
11089-
// $FlowIgnore : Problem with possibly null this.vm
11090-
this$1.vm[key] === data[key] ||
11091-
// $FlowIgnore : Problem with possibly null this.vm
11092-
(this$1.vm.$attrs && this$1.vm.$attrs[key] === data[key])
11093-
)
11094-
});
11095-
return !isUpdated ? this$1.setProps(data).then(resolve()) : resolve()
11096-
});
11097-
})
11098-
} catch (err) {
11099-
throw err
11100-
} finally {
11101-
// Ensure you teardown the modifications you made to the user's config
11102-
// After all the props are set, then reset the state
11103-
Vue__default['default'].config.silent = originalConfig;
11104-
}
11086+
var parent = this$1.vm.$parent;
11087+
parent.$set(parent.vueTestUtils_childProps, key, data[key]);
11088+
});
11089+
11090+
return nextTick()
1110511091
};
1110611092

1110711093
/**

0 commit comments

Comments
 (0)