Skip to content

Commit

Permalink
chore(release): add dist files 1.0.0-beta.32
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Apr 8, 2020
1 parent 351f573 commit 6f5c994
Show file tree
Hide file tree
Showing 5 changed files with 489 additions and 189 deletions.
14 changes: 14 additions & 0 deletions RELEASE_NOTE_1.0.0-beta.33.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# [1.0.0-beta.33](https://github.com/vuejs/vue-test-utils/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2020-04-08)

### Bug Fixes

- **create-instance:** revert stubbing of component \_Ctor ([#1479](https://github.com/vuejs/vue-test-utils/issues/1479)) ([70b553b](https://github.com/vuejs/vue-test-utils/commit/70b553bd18158d82de5f26ff14c1f062be371245))
- Add v-slot support in scopedSlots property, fix [#1457](https://github.com/vuejs/vue-test-utils/issues/1457) ([#1485](https://github.com/vuejs/vue-test-utils/issues/1485)) ([4df7619](https://github.com/vuejs/vue-test-utils/commit/4df7619c9388528718f0a39704fd22bd6dd669af))
- **test-utils:** fix cancelable attribute in dom events ([#1460](https://github.com/vuejs/vue-test-utils/issues/1460)) ([b1a532a](https://github.com/vuejs/vue-test-utils/commit/b1a532aa72c71d2f4282f4bc31373cb143e82833))
- Respect provide from parentComponent (#1301
- #1377 string stubs dropping props (#1473)

### Features

- support lazy modifier with setValue ([#1467](https://github.com/vuejs/vue-test-utils/issues/1467)) ([afd7a82](https://github.com/vuejs/vue-test-utils/commit/afd7a82426c2e72fca61bf00881574d81dffbf68))
- support object class binding in stubbed functional components ([#1476](https://github.com/vuejs/vue-test-utils/issues/1476)) ([55f7eac](https://github.com/vuejs/vue-test-utils/commit/55f7eac5cd305b60c0b9f8340cc6d9e3f470a665))
151 changes: 106 additions & 45 deletions packages/server-test-utils/dist/vue-server-test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1953,19 +1953,16 @@ var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); };

//

function compileFromString(str) {
if (!vueTemplateCompiler.compileToFunctions) {
throwError(
"vueTemplateCompiler is undefined, you must pass " +
"precompiled components if vue-template-compiler is " +
"undefined"
);
}
return vueTemplateCompiler.compileToFunctions(str)
}

function compileTemplate(component) {
if (component.template) {
if (!vueTemplateCompiler.compileToFunctions) {
throwError(
"vueTemplateCompiler is undefined, you must pass " +
"precompiled components if vue-template-compiler is " +
"undefined"
);
}

if (component.template.charAt('#') === '#') {
var el = document.querySelector(component.template);
if (!el) {
Expand All @@ -1976,7 +1973,8 @@ function compileTemplate(component) {
component.template = el.innerHTML;
}

Object.assign(component, vueTemplateCompiler.compileToFunctions(component.template));
Object.assign(component, Object.assign({}, vueTemplateCompiler.compileToFunctions(component.template),
{name: component.name}));
}

if (component.components) {
Expand Down Expand Up @@ -2035,7 +2033,7 @@ function extractInstanceOptions(options) {
//

function isDestructuringSlotScope(slotScope) {
return slotScope[0] === '{' && slotScope[slotScope.length - 1] === '}'
return /^{.*}$/.test(slotScope)
}

function getVueTemplateCompilerHelpers(
Expand Down Expand Up @@ -2076,7 +2074,36 @@ function validateEnvironment() {
}
}

var slotScopeRe = /<[^>]+ slot-scope=\"(.+)\"/;
function isScopedSlot(slot) {
if (typeof slot === 'function') { return { match: null, slot: slot } }

var slotScopeRe = /<[^>]+ slot-scope="(.+)"/;
var vSlotRe = /<template v-slot(?::.+)?="(.+)"/;
var shortVSlotRe = /<template #.*="(.+)"/;

var hasOldSlotScope = slot.match(slotScopeRe);
var hasVSlotScopeAttr = slot.match(vSlotRe);
var hasShortVSlotScopeAttr = slot.match(shortVSlotRe);

if (hasOldSlotScope) {
return { slot: slot, match: hasOldSlotScope }
} else if (hasVSlotScopeAttr || hasShortVSlotScopeAttr) {
// Strip v-slot and #slot attributes from `template` tag. compileToFunctions leaves empty `template` tag otherwise.
var sanitizedSlot = slot.replace(
/(<template)([^>]+)(>.+<\/template>)/,
'$1$3'
);
return {
slot: sanitizedSlot,
match: hasVSlotScopeAttr || hasShortVSlotScopeAttr
}
}
// we have no matches, so we just return
return {
slot: slot,
match: null
}
}

// Hide warning about <template> disallowed as root element
function customWarn(msg) {
Expand All @@ -2098,14 +2125,18 @@ function createScopedSlots(
var loop = function ( scopedSlotName ) {
var slot = scopedSlotsOption[scopedSlotName];
var isFn = typeof slot === 'function';

var scopedSlotMatches = isScopedSlot(slot);

// Type check to silence flow (can't use isFn)
var renderFn =
typeof slot === 'function'
? slot
: vueTemplateCompiler.compileToFunctions(slot, { warn: customWarn }).render;
: vueTemplateCompiler.compileToFunctions(scopedSlotMatches.slot, { warn: customWarn })
.render;

var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];

var hasSlotScopeAttr = !isFn && slot.match(slotScopeRe);
var slotScope = hasSlotScopeAttr && hasSlotScopeAttr[1];
scopedSlots[scopedSlotName] = function(props) {
var obj;

Expand Down Expand Up @@ -2173,24 +2204,35 @@ function getCoreProperties(componentOptions) {
}

function createClassString(staticClass, dynamicClass) {
if (staticClass && dynamicClass) {
return staticClass + ' ' + dynamicClass
// :class="someComputedObject" can return a string, object or undefined
// if it is a string, we don't need to do anything special.
var evaluatedDynamicClass = dynamicClass;

// if it is an object, eg { 'foo': true }, we need to evaluate it.
// see https://github.com/vuejs/vue-test-utils/issues/1474 for more context.
if (typeof dynamicClass === 'object') {
evaluatedDynamicClass = Object.keys(dynamicClass).reduce(function (acc, key) {
if (dynamicClass[key]) {
return acc + ' ' + key
}
return acc
}, '');
}

if (staticClass && evaluatedDynamicClass) {
return staticClass + ' ' + evaluatedDynamicClass
}
return staticClass || dynamicClass
return staticClass || evaluatedDynamicClass
}

function resolveOptions(component, _Vue) {
if (isDynamicComponent(component)) {
return {}
}

if (isConstructor(component)) {
return component.options
}
var options = _Vue.extend(component).options;
component._Ctor = {};

return options
return isConstructor(component)
? component.options
: _Vue.extend(component).options
}

function getScopedSlotRenderFunctions(ctx) {
Expand Down Expand Up @@ -2253,22 +2295,31 @@ function createStubFromComponent(
}})
}

function createStubFromString(
templateString,
// DEPRECATED: converts string stub to template stub.
function createStubFromString(templateString, name) {
warn('String stubs are deprecated and will be removed in future versions');

if (templateContainsComponent(templateString, name)) {
throwError('options.stub cannot contain a circular reference');
}

return {
template: templateString,
$_doNotStubChildren: true
}
}

function setStubComponentName(
stub,
originalComponent,
name,
_Vue
) {
if ( originalComponent === void 0 ) originalComponent = {};

if (templateContainsComponent(templateString, name)) {
throwError('options.stub cannot contain a circular reference');
}
var componentOptions = resolveOptions(originalComponent, _Vue);
if (stub.name) { return }

return Object.assign({}, getCoreProperties(componentOptions),
{$_doNotStubChildren: true},
compileFromString(templateString))
var componentOptions = resolveOptions(originalComponent, _Vue);
stub.name = getCoreProperties(componentOptions).name;
}

function validateStub(stub) {
Expand All @@ -2293,18 +2344,19 @@ function createStubsFromStubsObject(
return acc
}

var component = resolveComponent$1(originalComponents, stubName);

if (stub === true) {
var component = resolveComponent$1(originalComponents, stubName);
acc[stubName] = createStubFromComponent(component, stubName, _Vue);
return acc
}

if (typeof stub === 'string') {
var component$1 = resolveComponent$1(originalComponents, stubName);
acc[stubName] = createStubFromString(stub, component$1, stubName, _Vue);
return acc
stub = createStubFromString(stub, stubName);
stubs[stubName];
}

setStubComponentName(stub, component, _Vue);
if (componentNeedsCompiling(stub)) {
compileTemplate(stub);
}
Expand All @@ -2326,7 +2378,6 @@ function shouldExtend(component, _Vue) {
function extend(component, _Vue) {
var componentOptions = component.options ? component.options : component;
var stub = _Vue.extend(componentOptions);
componentOptions._Ctor = {};
stub.options.$_vueTestUtils_original = component;
stub.options._base = _Vue;
return stub
Expand Down Expand Up @@ -2445,6 +2496,13 @@ function createChildren(vm, h, ref) {
)
}

function getValuesFromCallableOption(optionValue) {
if (typeof optionValue === 'function') {
return optionValue.call(this)
}
return optionValue
}

function createInstance(
component,
options,
Expand Down Expand Up @@ -2499,15 +2557,18 @@ function createInstance(

// make sure all extends are based on this instance
var Constructor = _Vue.extend(componentOptions).extend(instanceOptions);
componentOptions._Ctor = {};
Constructor.options._base = _Vue;

var scopedSlots = createScopedSlots(options.scopedSlots, _Vue);

var parentComponentOptions = options.parentComponent || {};

parentComponentOptions.provide = options.provide;
parentComponentOptions._provided = options.provide;
var originalParentComponentProvide = parentComponentOptions.provide;
parentComponentOptions.provide = function() {
return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
getValuesFromCallableOption.call(this, options.provide))
};

parentComponentOptions.$_doNotStubChildren = true;
parentComponentOptions._isFunctionalContainer = componentOptions.functional;
parentComponentOptions.render = function(h) {
Expand Down

0 comments on commit 6f5c994

Please sign in to comment.