Skip to content

Commit 93e2785

Browse files
committed
Handle unset rdfDirection the same as null.
1 parent e297249 commit 93e2785

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# jsonld ChangeLog
22

3+
## 8.3.1 - 2023-09-xx
4+
5+
### Fixed
6+
- Handle unset `rdfDirection` the same as `null`.
7+
38
## 8.3.0 - 2023-09-06
49

510
### Added

Diff for: lib/toRdf.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ function _objectToRDF(
330330
'jsonld.InvalidRdfDirection',
331331
{value: rdfDirection});
332332
} else if('@language' in item) {
333-
if('@direction' in item && rdfDirection === null) {
333+
if('@direction' in item && !rdfDirection) {
334334
if(options.eventHandler) {
335335
// FIXME: only emit once?
336336
_handleEvent({
@@ -351,7 +351,7 @@ function _objectToRDF(
351351
object.datatype.value = datatype || RDF_LANGSTRING;
352352
object.language = item['@language'];
353353
} else {
354-
if('@direction' in item && rdfDirection === null) {
354+
if('@direction' in item && !rdfDirection) {
355355
if(options.eventHandler) {
356356
// FIXME: only emit once?
357357
_handleEvent({

Diff for: tests/misc.js

+16
Original file line numberDiff line numberDiff line change
@@ -4101,6 +4101,22 @@ _:b0 <ex:p> "v" .
41014101
});
41024102
});
41034103

4104+
it('should handle no @lang, @dir, no rdfDirection', async () => {
4105+
const input = _json_dir_nl_d;
4106+
const nq = _nq_dir_nl_nd;
4107+
4108+
await _test({
4109+
type: 'toRDF',
4110+
input,
4111+
options: {skipExpansion: true},
4112+
expected: nq,
4113+
eventCodeLog: [
4114+
'rdfDirection not set'
4115+
],
4116+
testNotSafe: true
4117+
});
4118+
});
4119+
41044120
it('should handle no @lang, @dir, rdfDirection=null', async () => {
41054121
const input = _json_dir_nl_d;
41064122
const nq = _nq_dir_nl_nd;

0 commit comments

Comments
 (0)