Socket
Socket
Sign inDemoInstall

vue-docgen-api

Package Overview
Dependencies
86
Maintainers
3
Versions
269
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.52.0 to 4.54.2

31

dist/script-handlers/classPropHandler.test.js

@@ -15,2 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const babel_parser_1 = __importDefault(require("../babel-parser"));

@@ -48,3 +49,3 @@ const Documentation_1 = __importDefault(require("../Documentation"));

yield (0, classPropHandler_1.default)(documentation, def, ast, options);
expect(mockPropDescriptor).toMatchObject(matchedObj);
(0, vitest_1.expect)(mockPropDescriptor).toMatchObject(matchedObj);
});

@@ -60,3 +61,3 @@ }

yield tester(src, {});
expect(documentation.getPropDescriptor).not.toHaveBeenCalledWith('someData');
(0, vitest_1.expect)(documentation.getPropDescriptor).not.toHaveBeenCalledWith('someData');
}));

@@ -73,3 +74,3 @@ it('should detect all data that have the prop decorator', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('test');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('test');
}));

@@ -86,3 +87,3 @@ it('should detect all data with composite types', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('test');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('test');
}));

@@ -99,6 +100,6 @@ it('should get default expression from the prop decorator', () => __awaiter(void 0, void 0, void 0, function* () {

defaultValue: {
value: `'hello'`
value: '"hello"'
}
});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testDefault');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testDefault');
}));

@@ -116,3 +117,3 @@ it('should get required from the prop decorator', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testRequired');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testRequired');
}));

@@ -132,3 +133,3 @@ it('should extract descriptions from leading comments', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testDescribed');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testDescribed');
}));

@@ -150,3 +151,3 @@ it('should parse the @values tag as its own', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('color');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('color');
}));

@@ -163,3 +164,3 @@ it('should parse get the values from TS type', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('color');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('color');
}));

@@ -176,3 +177,3 @@ it('should extract type from decorator arguments', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testTyped');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testTyped');
}));

@@ -189,3 +190,3 @@ it('should extract type from decorator itself', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testTyped');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testTyped');
}));

@@ -204,3 +205,3 @@ it('should document props as decorator argument', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testTyped');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testTyped');
}));

@@ -220,4 +221,4 @@ it('should parse union types properly', () => __awaiter(void 0, void 0, void 0, function* () {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('id');
expect(mockPropDescriptor.type).toMatchInlineSnapshot(`
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('id');
(0, vitest_1.expect)(mockPropDescriptor.type).toMatchInlineSnapshot(`
{

@@ -224,0 +225,0 @@ "elements": [

@@ -15,2 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const dedent_1 = __importDefault(require("dedent"));

@@ -69,4 +70,4 @@ const babel_parser_1 = __importDefault(require("../babel-parser"));

}
expect(mockPropDescriptor.required).toBeFalsy();
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testArray');
(0, vitest_1.expect)(mockPropDescriptor.required).toBeFalsy();
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testArray');
}));

@@ -89,3 +90,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: { name: 'array' }

@@ -102,3 +103,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: { name: 'array' }

@@ -117,3 +118,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: { name: 'string|number' }

@@ -130,3 +131,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: { name: 'array' }

@@ -147,3 +148,3 @@ });

}
expect(mockPropDescriptor.required).toBeUndefined();
(0, vitest_1.expect)(mockPropDescriptor.required).toBeUndefined();
}));

@@ -158,3 +159,3 @@ it('should return the right props type string', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: { name: 'string' }

@@ -171,3 +172,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: { name: 'string|number' }

@@ -186,3 +187,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: { name: 'boolean' }

@@ -202,3 +203,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: {

@@ -216,3 +217,3 @@ func: true

}`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: {

@@ -225,3 +226,3 @@ func: true

const src = ['export default {', ' props: {', ' toto', ' }', '}'].join('\n');
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: {}

@@ -246,3 +247,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
required: true

@@ -263,4 +264,4 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
defaultValue: { value: `'normal'` }
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
defaultValue: { value: `"normal"` }
});

@@ -280,3 +281,3 @@ }));

`;
expect((yield parserTest(src)).defaultValue).toMatchInlineSnapshot(`
(0, vitest_1.expect)((yield parserTest(src)).defaultValue).toMatchInlineSnapshot(`
{

@@ -309,3 +310,3 @@ "func": true,

const defaultValue = removeWhitespaceForTest(testParsed.defaultValue);
expect(defaultValue).toMatchObject({
(0, vitest_1.expect)(defaultValue).toMatchObject({
func: true,

@@ -334,3 +335,3 @@ value: `function(){if(logger.mounted){return[];}else{returnundefined;}}`

const defaultValue = removeWhitespaceForTest(testParsed.defaultValue);
expect(defaultValue).toMatchObject({
(0, vitest_1.expect)(defaultValue).toMatchObject({
func: true,

@@ -352,6 +353,6 @@ value: `()=>{if(logger.mounted){return[];}else{returnundefined;}}`

const defaultValue = removeWhitespaceForTest(testParsed.defaultValue);
expect(defaultValue).toMatchObject({ value: '{a:1}' });
(0, vitest_1.expect)(defaultValue).toMatchObject({ value: '{a:1}' });
}));
// type, format of default input, result of parsing
test.each([
vitest_1.test.each([
['Object', 'default: () => ({ a: 1 })', '{a:1}', ''],

@@ -396,3 +397,3 @@ ['Object', 'default: () => { return { a: 1 } }', '{a:1}', ''],

const defaultValue = removeWhitespaceForTest(testParsed.defaultValue);
expect(defaultValue).toMatchObject({ value: output });
(0, vitest_1.expect)(defaultValue).toMatchObject({ value: output });
}));

@@ -414,3 +415,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
description: 'test description'

@@ -433,7 +434,7 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
description: 'test description'
});
expect(documentation.getPropDescriptor).not.toHaveBeenCalledWith('test');
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('v-model');
(0, vitest_1.expect)(documentation.getPropDescriptor).not.toHaveBeenCalledWith('test');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('v-model');
}));

@@ -455,7 +456,7 @@ it('should set the @model property as v-model instead of value even with a type', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
description: 'Binding from v-model'
});
expect(documentation.getPropDescriptor).not.toHaveBeenCalledWith('value');
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('v-model');
(0, vitest_1.expect)(documentation.getPropDescriptor).not.toHaveBeenCalledWith('value');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('v-model');
}));

@@ -479,7 +480,7 @@ it('should set the v-model instead of value with model property', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
description: 'Value of the field'
});
expect(documentation.getPropDescriptor).not.toHaveBeenCalledWith('value');
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('v-model');
(0, vitest_1.expect)(documentation.getPropDescriptor).not.toHaveBeenCalledWith('value');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('v-model');
}));

@@ -503,7 +504,7 @@ it('should not set the v-model instead of value if model property has only event', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
description: 'Value of the field'
});
expect(documentation.getPropDescriptor).not.toHaveBeenCalledWith('v-model');
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('value');
(0, vitest_1.expect)(documentation.getPropDescriptor).not.toHaveBeenCalledWith('v-model');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('value');
}));

@@ -528,3 +529,3 @@ });

`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
description: 'color of the component',

@@ -541,3 +542,3 @@ values: ['dark', 'light', 'red', 'blue'],

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('color');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('color');
}));

@@ -557,3 +558,3 @@ it('should check the validator method for super standard values', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
(0, vitest_1.expect)((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
}));

@@ -573,3 +574,3 @@ it('should check the validator method for super standard values with the diff signs', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
(0, vitest_1.expect)((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
}));

@@ -589,3 +590,3 @@ it('should check the validator function for super standard values with the diff signs', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
(0, vitest_1.expect)((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
}));

@@ -604,3 +605,3 @@ it('should check the validator arrow function for inline values', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
(0, vitest_1.expect)((yield parserTest(src)).values).toMatchObject(['dark', 'light', 'red', 'blue']);
}));

@@ -621,3 +622,3 @@ it('should check the validator method for identifiers', () => __awaiter(void 0, void 0, void 0, function* () {

`;
expect((yield parserTest(src, undefined, (0, babel_parser_1.default)().parse(src))).values).toMatchObject([
(0, vitest_1.expect)((yield parserTest(src, undefined, (0, babel_parser_1.default)().parse(src))).values).toMatchObject([
'dark',

@@ -641,9 +642,9 @@ 'light',

});`;
expect(yield parserTest(src, ['typescript'])).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src, ['typescript'])).toMatchObject({
type: {
name: "SelectOption['value']"
name: 'SelectOption["value"]'
},
required: true
});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('tsvalue');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('tsvalue');
}));

@@ -657,3 +658,3 @@ it('should parse values in TypeScript typings', () => __awaiter(void 0, void 0, void 0, function* () {

});`;
expect(yield parserTest(src, ['typescript'])).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src, ['typescript'])).toMatchObject({
values: ['foo', 'bar'],

@@ -664,3 +665,3 @@ type: {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('tsvalue');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('tsvalue');
}));

@@ -677,3 +678,3 @@ it('should parse values in TypeScript typings with complete object', () => __awaiter(void 0, void 0, void 0, function* () {

});`;
expect(yield parserTest(src, ['typescript'])).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src, ['typescript'])).toMatchObject({
values: ['foo', 'bar'],

@@ -685,3 +686,3 @@ type: {

});
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('tsvalue');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('tsvalue');
}));

@@ -698,3 +699,3 @@ it('should understand As annotations at the end of a prop definition', () => __awaiter(void 0, void 0, void 0, function* () {

});`;
expect(yield parserTest(src, ['typescript'])).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src, ['typescript'])).toMatchObject({
type: {

@@ -719,3 +720,3 @@ name: 'SocialNetwork[]'

});`;
expect(yield parserTest(src, ['typescript'])).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src, ['typescript'])).toMatchObject({
defaultValue: {

@@ -741,3 +742,3 @@ value: '"cover"'

};`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
type: {

@@ -761,3 +762,3 @@ name: '{ bar: number, foo: string }'

};`;
expect(yield parserTest(src)).toMatchObject({
(0, vitest_1.expect)(yield parserTest(src)).toMatchObject({
values: ['bar + boo', 'foo & baz'],

@@ -764,0 +765,0 @@ type: {

@@ -180,2 +180,7 @@ "use strict";

descriptor.description = description;
const fixedNameMatch = description.match(/^(\S+) - (.*)$/);
if (fixedNameMatch) {
descriptor.name = fixedNameMatch[1];
descriptor.description = fixedNameMatch[2];
}
}

@@ -182,0 +187,0 @@ const tags = jsDoc.tags.filter(t => t.title !== 'slot' && t.title !== 'binding');

@@ -15,2 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const babel_parser_1 = __importDefault(require("../babel-parser"));

@@ -60,4 +61,4 @@ const resolveExportedComponent_1 = __importDefault(require("../utils/resolveExportedComponent"));

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testProps');
expect(prop).toMatchInlineSnapshot(`
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testProps');
(0, vitest_1.expect)(prop).toMatchInlineSnapshot(`
{

@@ -83,3 +84,3 @@ "description": "",

const prop = yield parserTest(src);
expect(prop).toMatchInlineSnapshot(`
(0, vitest_1.expect)(prop).toMatchInlineSnapshot(`
{

@@ -108,3 +109,3 @@ "description": "Should the prop be tested?",

const prop = yield parserTest(src);
expect(prop).toMatchInlineSnapshot(`
(0, vitest_1.expect)(prop).toMatchInlineSnapshot(`
{

@@ -134,3 +135,3 @@ "description": "Should the prop be required?",

const prop = yield parserTest(src);
expect(prop).toMatchInlineSnapshot(`
(0, vitest_1.expect)(prop).toMatchInlineSnapshot(`
{

@@ -158,5 +159,5 @@ "description": "Should the prop be required?",

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('testProps');
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('anotherTestProps');
expect(prop.type).toMatchObject({
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('testProps');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('anotherTestProps');
(0, vitest_1.expect)(prop.type).toMatchObject({
name: 'boolean'

@@ -175,4 +176,4 @@ });

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('anotherTestProps');
expect(prop.description).toBe('A very nice prop');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('anotherTestProps');
(0, vitest_1.expect)(prop.description).toBe('A very nice prop');
}));

@@ -186,4 +187,4 @@ it('shows optional fields as non-required props', () => __awaiter(void 0, void 0, void 0, function* () {

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('optional');
expect(prop.required).toBe(false);
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('optional');
(0, vitest_1.expect)(prop.required).toBe(false);
}));

@@ -197,4 +198,4 @@ it('shows non optional fields as required props', () => __awaiter(void 0, void 0, void 0, function* () {

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('required');
expect(prop.required).toBe(true);
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('required');
(0, vitest_1.expect)(prop.required).toBe(true);
}));

@@ -208,4 +209,4 @@ it('resolves arrays', () => __awaiter(void 0, void 0, void 0, function* () {

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('arrays');
expect(prop.type).toMatchInlineSnapshot(`
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('arrays');
(0, vitest_1.expect)(prop.type).toMatchInlineSnapshot(`
{

@@ -237,6 +238,6 @@ "elements": [

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('complex');
expect(prop.type).toMatchObject({
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('complex');
(0, vitest_1.expect)(prop.type).toMatchObject({
name: `{
foo: number,
foo: number
bar: boolean

@@ -260,5 +261,5 @@ }`

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('inInterface');
expect(prop.required).toBe(true);
expect(prop.description).toBe('describe the local prop');
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('inInterface');
(0, vitest_1.expect)(prop.required).toBe(true);
(0, vitest_1.expect)(prop.description).toBe('describe the local prop');
}));

@@ -277,4 +278,4 @@ it('show prop type names when they are defined elsewhere', () => __awaiter(void 0, void 0, void 0, function* () {

const prop = yield parserTest(src);
expect(documentation.getPropDescriptor).toHaveBeenCalledWith('param');
expect(prop.type).toMatchObject({ name: 'LocalType' });
(0, vitest_1.expect)(documentation.getPropDescriptor).toHaveBeenCalledWith('param');
(0, vitest_1.expect)(prop.type).toMatchObject({ name: 'LocalType' });
}));

@@ -294,5 +295,5 @@ });

const prop = yield parserTest(src);
expect(prop.defaultValue && prop.defaultValue.value).toContain(`myValue: true`);
(0, vitest_1.expect)(prop.defaultValue && prop.defaultValue.value).toContain(`myValue: true`);
}));
});
});

@@ -39,3 +39,14 @@ "use strict";

const nameProp = templateAst.props.filter(guards_1.isAttributeNode).find(b => b.name === 'name');
const slotName = nameProp && nameProp.value && nameProp.value.content ? nameProp.value.content : 'default';
let slotName = nameProp && nameProp.value ? nameProp.value.content : undefined;
if (!slotName) {
const dynExpr = templateAst.props
.filter(guards_1.isDirectiveNode)
.find(b => b.name === 'bind' && (0, guards_1.isSimpleExpressionNode)(b.arg) && b.arg.content === 'name');
if (dynExpr && (0, guards_1.isSimpleExpressionNode)(dynExpr.exp) && dynExpr.exp) {
slotName = dynExpr.exp.content;
}
else {
slotName = 'default';
}
}
const bindings = templateAst.props.filter(

@@ -42,0 +53,0 @@ // only keep simple binds and static attributes

@@ -79,2 +79,34 @@ "use strict";

});
it('should parse dynamic slot names', () => {
const ast = (0, compiler_dom_1.parse)([
'<!-- @slot first slot found -->',
'<slot :name="`dynamicName`">',
' <div>',
' <h1>title of the template</h1>',
' </div>',
'</slot>'
].join('\n'));
(0, parse_template_1.traverse)(ast.children[1], doc, [slotHandler_1.default], ast.children, {
functional: false
});
expect(doc.toObject().slots).toMatchObject([
{ name: '`dynamicName`', description: 'first slot found' }
]);
});
it('should parse dynamic slot names but prefer a fixed name', () => {
const ast = (0, compiler_dom_1.parse)([
'<!-- @slot theFixedName - first slot found -->',
'<slot :name="`dynamicName`">',
' <div>',
' <h1>title of the template</h1>',
' </div>',
'</slot>'
].join('\n'));
(0, parse_template_1.traverse)(ast.children[1], doc, [slotHandler_1.default], ast.children, {
functional: false
});
expect(doc.toObject().slots).toMatchObject([
{ name: 'theFixedName', description: 'first slot found' }
]);
});
it('should pick up the name of a slot', () => {

@@ -81,0 +113,0 @@ const ast = (0, compiler_dom_1.parse)([

{
"name": "vue-docgen-api",
"version": "4.52.0",
"version": "4.54.2",
"description": "Toolbox to extract information from Vue component files for documentation generation purposes.",

@@ -36,3 +36,3 @@ "homepage": "https://vue-styleguidist.github.io",

"pug": "^3.0.2",
"recast": "0.21.1",
"recast": "0.21.5",
"ts-map": "^1.0.3",

@@ -47,7 +47,7 @@ "vue-inbrowser-compiler-independent-utils": "^4.52.0"

"globby": "10.0.2",
"vue": "2.7.8",
"vue": "2.7.11",
"vue-class-component": "7.2.6",
"vue-clickaway": "2.2.2",
"vue-property-decorator": "7.3.0",
"vuetify": "2.6.8"
"vuetify": "2.6.10"
},

@@ -54,0 +54,0 @@ "scripts": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc