Skip to content

Commit

Permalink
Add string case check to ObjectReader parser. Fixes #90
Browse files Browse the repository at this point in the history
  • Loading branch information
oozcitak committed Jul 28, 2021
1 parent 9ca72f1 commit 299f1a3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/readers/ObjectReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class ObjectReader extends BaseReader<ExpandObject> {
lastChild = this.parse(node, obj.apply(this))
} else if (isArray(obj) || isSet(obj)) {
forEachArray(obj, item => lastChild = this.parse(node, item), this)
} else /* if (isMap(obj) || isObject(obj)) */ {
} else if (isMap(obj) || isObject(obj)) {
// expand if object
forEachObject(obj, (key, val) => {
if (isFunction(val)) {
Expand Down Expand Up @@ -127,6 +127,11 @@ export class ObjectReader extends BaseReader<ExpandObject> {
lastChild = this.element(node, undefined, this.sanitize(key)) || lastChild
}
}, this)
} else if (!options.keepNullNodes && (obj == null)) {
// skip null and undefined nodes
} else {
// text node
lastChild = this.text(node, this.sanitize(obj)) || lastChild
}

return lastChild || node
Expand Down
2 changes: 1 addition & 1 deletion test/issues/issue-090.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe("Replicate issue", () => {
}
};
const doc = $$.create().ele(obj2);
expect(doc.end({ prettyPrint: true})).toBe(`
expect(doc.end({ headless: true, prettyPrint: true})).toBe($$.t`
<monologue>
Talk to me Goose!
<cut>dog tag shot</cut>
Expand Down

0 comments on commit 299f1a3

Please sign in to comment.