Skip to content

Commit c4c8b0d

Browse files
author
Ryota Yamamoto
committed
feat: 🎸 not make jsonld tags when jsonld method returns null
✅ Closes: #23
1 parent 53d692e commit c4c8b0d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Diff for: ‎src/createMixin.ts

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export default (options: Options = {}): JsonldMixin => {
3333
return {};
3434
}
3535

36+
if (this.$options.jsonld.call(this) === null) {
37+
return {};
38+
}
39+
3640
const stringifiedJson = JSON.stringify(this.$options.jsonld.call(this), null, mergedOptions.space);
3741
const innerHTML = mergedOptions.space === 0 ? stringifiedJson : `\n${stringifiedJson}\n`;
3842

Diff for: ‎test/createMixin.spec.js

+6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ describe('with jsonld', () => {
8989
});
9090
});
9191

92+
test('head method returns an empty object when jsonld returns null', () => {
93+
const mock = mockInstanceFactory();
94+
mock.$options.jsonld = () => null;
95+
expect(mock.$options.head.call(mock)).toEqual({});
96+
})
97+
9298
describe('customizing indentation', () => {
9399
test('using tab', () => {
94100
const mock = mockInstanceFactory({ space: '\t' });

0 commit comments

Comments
 (0)