-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional direction for literals #175
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we define that direction
must be falsy instead of undefined
for other kinds of literals? That would allow aligning direction
to language
with an empty string and still be backward compatible.
Yes, agreed, that makes sense :-) |
Co-authored-by: Thomas Bergwinkl <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Will merge this as soon as rdfjs/types#38 is merged (on hold now). |
Maybe a more detailed description is required if it's unclear why an empty string is allowed: We had a longer discussion about whether the language property should be null or empty string for non-language literals and decided to go with the empty string, so it's possible to call .toUpperCase() or slice it, even if no language was set. Aligning the direction property with the language property without having a breaking change required to allow undefined. Otherwise, I would have proposed to skip allowing undefined. Now we have the optional chaining operator in JavaScript, and that would be a good reason to use undefined or null instead of an empty string. But as long as we don't have a strong need for a breaking change, I would try to keep it consistent. That also means a factory that supports direction should an empty string instead of null or undefined. @rubensworks I can create a proposal if you agree to update the description. |
@bergos Sounds good to me! |
As mentioned in #172, RDF 1.2 is scheduled to introduce the base direction concept for literals.
This PR proposes a backwards-compatible addition to the data model spec to handle this addition in RDF.
The literal interface change is quite straightforward, I don't expect much discussion on this.
The data factory on the other hand might deserve some discussion. I went for extending the types of the second optional argument of the
literal()
method. An alternative might have been to add a third optional argument, but I didn't go for that in this PR due to the possibility of defining a direction in combination with a datatype (which is illegal according to the RDF 1.2 spec).