Skip to content

Commit 1c16e2d

Browse files
trufaeradare
authored andcommitted
Fix invalid plist build when serializing a null
1 parent 24d38d3 commit 1c16e2d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/build.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,8 @@ function walk_obj(next, next_child) {
133133
// a typed array
134134
next_child.ele('data').raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
135135

136+
} else if ('Null' === name) {
137+
next_child.ele('null').txt('');
138+
136139
}
137140
}

test/build.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ describe('plist', function () {
141141
*/}));
142142
});
143143

144+
it('should not omit null values', function () {
145+
var xml = build({ a: null});
146+
assert.strictEqual(xml, multiline(function () {/*
147+
<?xml version="1.0" encoding="UTF-8"?>
148+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
149+
<plist version="1.0">
150+
<dict>
151+
<key>a</key>
152+
<null/>
153+
</dict>
154+
</plist>
155+
*/}));
156+
});
144157
});
145158

146159
});

0 commit comments

Comments
 (0)