2
0
mirror of https://github.com/tenrok/BBob.git synced 2026-06-17 19:21:20 +03:00

fix(plugin-helper): avoid some malformed attributes in attrsToString (#26)

* attrsToString: To avoid some malformed attributes

Error:
```
TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at attrsToString
```

This errors appears if no `attrs` setted in custom tag:
```
const BBcodePresetTemp = BbobPresetHTML5.extend((tags: any) => {
	tags.br = () => ({
		tag: 'br',
		// attrs: {}, // <-- Comment this line for error and add [br] to text
		content: null,
	});

	return tags;
});
```
This commit is contained in:
Vladimir
2019-06-27 16:49:28 +10:00
committed by Nikolay Kostyurin
parent 5291543855
commit 09ff9af9a2
2 changed files with 12 additions and 2 deletions
@@ -79,4 +79,8 @@ describe('@bbob/plugin-helper', () => {
disabled: true
})).toBe(` tag="test" foo="bar" disabled`)
})
test('attrsToString undefined', () => {
expect(attrsToString(undefined)).toBe('')
})
});