Skip to content
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 #38

Merged
merged 3 commits into from
Jan 7, 2025
Merged

Conversation

rubensworks
Copy link
Member

This adds typing support for base directions in literals, as discussed in rdfjs/data-model-spec#175

Copy link

changeset-bot bot commented Nov 9, 2023

🦋 Changeset detected

Latest commit: 14f33a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@rdfjs/types Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

data-model.d.ts Outdated

export interface DirectionalLanguage {
language: string;
direction?: 'ltr' | 'rtl' | '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what cases would '' be used as input over undefined

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because direction can be a falsy value, as discussed in the PR here: rdfjs/data-model-spec#175

That actually reminds me, we should also allow null here...

@tpluscode
Copy link
Contributor

This probably is something we should also (like #6) first discuss in the spec itself?

@rubensworks
Copy link
Member Author

This probably is something we should also (like #6) first discuss in the spec itself?

Yes, we have rdfjs/data-model-spec#172 and rdfjs/data-model-spec#175 for this.

But in any case, I think we'll want to put this on hold until w3c/rdf-concepts#79 is resolved.

@rubensworks
Copy link
Member Author

@tpluscode Do you agree with merging this one? It has been open for quite a while now.
While not a breaking change, we could include it in #55.

@tpluscode
Copy link
Contributor

And what about waiting for w3c/rdf-concepts#79?

@tpluscode
Copy link
Contributor

Ah, I read into the resolution and it actually appears that this feature is not planned for RDF?

@rubensworks
Copy link
Member Author

From the discussion, I thought w3c/rdf-concepts#79 was resolved.
But the issue is still open...
I'll ask to clarify.

@rubensworks
Copy link
Member Author

Ah, I read into the resolution and it actually appears that this feature is not planned for RDF?

It is in fact going to be included (https://w3c.github.io/rdf-concepts/spec/#dfn-dir-lang-string).
That specific issue raised some questions about the way in which it is done, but the resolution was that the current approach will be kept as-is.

/**
* the direction of the language-tagged string.
*/
direction?: 'ltr' | 'rtl' | '' | null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JS noob question: The specification states direction?: DOMString. Does it allow null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not too sure about the semantics of direction?: DOMString in ReSpec.
But at least the text in rdfjs/data-model-spec#175 says where <code>direction</code> is optional or can be falsy.
Falsy includes null and undefined in JavaScript.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Should we ensure that the WebIDL definition is synchronized with the specification text before merging both MRs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null and undefined are both implicitly included in other parts of the spec, such as Term.equals().
So this would probably be part of a broader change.
Might be good to open a separate issue for this?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok! Make sense! Thank you!

@rubensworks
Copy link
Member Author

@tpluscode The issue has been resolved. Do you agree with merging this PR here?

@tpluscode
Copy link
Contributor

Ok, let's go

data-model.d.ts Show resolved Hide resolved
@tpluscode tpluscode added enhancement New feature or request and removed on hold labels Jan 7, 2025
@rubensworks rubensworks merged commit 46acfbb into master Jan 7, 2025
2 checks passed
@rubensworks rubensworks deleted the feature/direction branch January 7, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants