Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/vue/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type ViewModel = {
propsData?: { [key: string]: any };
_componentTag?: string;
__file?: string;
__name?: string;
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/vue/src/vendor/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const formatComponentName = (vm?: ViewModel, includeFile?: boolean): stri

const options = vm.$options;

let name = options.name || options._componentTag;
let name = options.name || options._componentTag || options.__name;
const file = options.__file;
if (!name && file) {
const match = file.match(/([^/\\]+)\.vue$/);
Expand Down
13 changes: 13 additions & 0 deletions packages/vue/test/vendor/components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,19 @@ describe('formatComponentName', () => {
});
});

describe('when the options have a __name', () => {
it('returns the __name', () => {
// arrange
vm.$options.__name = 'my-component-name';

// act
const formattedName = formatComponentName(vm);

// assert
expect(formattedName).toEqual('<MyComponentName>');
});
});

describe('when the options have a __file', () => {
describe('and we do not wish to include the filename', () => {
it.each([
Expand Down
Loading