diff --git a/packages/bbob-plugin-helper/src/TagNode.ts b/packages/bbob-plugin-helper/src/TagNode.ts index 40c1eec1..49866bd0 100644 --- a/packages/bbob-plugin-helper/src/TagNode.ts +++ b/packages/bbob-plugin-helper/src/TagNode.ts @@ -105,7 +105,7 @@ export class TagNode implements TagNodeObject { return `${tagStart}${content}${this.toTagEnd({ openTag, closeTag })}`; } - static create(tag: string, attrs: Record = {}, content: TagNodeTree = []) { + static create(tag: string, attrs: Record = {}, content: TagNodeTree = null) { return new TagNode(tag, attrs, content) } diff --git a/packages/bbob-plugin-helper/test/TagNode.test.ts b/packages/bbob-plugin-helper/test/TagNode.test.ts index 9a0977aa..03833426 100644 --- a/packages/bbob-plugin-helper/test/TagNode.test.ts +++ b/packages/bbob-plugin-helper/test/TagNode.test.ts @@ -44,6 +44,18 @@ describe('@bbob/plugin-helper/TagNode', () => { expect(newTagNode.content).toEqual(tagNode.content); }); + test('null content', () => { + const tagNode = TagNode.create('img'); + + expect(String(tagNode)).toBe('[img]'); + }); + + test('array content', () => { + const tagNode = TagNode.create('img', {}, []); + + expect(String(tagNode)).toBe('[img]'); + }); + describe('toString', () => { test('tag with content and params', () => { const tagNode = TagNode.create('test', {test: 1}, ['Hello']);