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

feat(core/dfn): add data-defines on some patterns of term/definition association #4620

Merged
merged 10 commits into from
Jan 29, 2024

Conversation

dontcallmedom
Copy link
Member

As discussed in #4522
See also w3c/reffy#1444

src/core/dfn.js Outdated Show resolved Hide resolved
src/core/dfn.js Outdated Show resolved Hide resolved
src/core/dfn.js Outdated Show resolved Hide resolved
src/core/dfn.js Outdated Show resolved Hide resolved
Co-authored-by: François Daoust <[email protected]>
src/core/dfn.js Outdated Show resolved Hide resolved
src/core/dfn.js Outdated Show resolved Hide resolved
@marcoscaceres
Copy link
Contributor

marcoscaceres commented Dec 22, 2023

I'm not loving dfn-desc to be honest... it's not as author friendly as it could be and not in line with other CSS named we use in bikeshed and respec (e.g., <dl class="algorithm">). Could we just use "definition" instead:

<p class="definition">
   This is a <dfn>term</dfn> that is being defined.
</p>

<p>
   This is some term <dfn>term</dfn> that is being defined.
   And <span class="definition">this is some <dfn>other</dfn> that is being defined</span>
</p>

We can still use data-dfn-desc as the thing, but ReSpec should add that... that's what we do for class="export": it becomes data-export="" after processing.

src/core/dfn.js Outdated Show resolved Hide resolved
Copy link
Contributor

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

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

Suggested some changes...

src/core/dfn.js Outdated Show resolved Hide resolved
<dt><dfn>different convention</dfn></dt>
<dd id="desc2">Different conventions can be applied to associate a term with its description</dd>
</dl>
<dl>
Copy link
Member

Choose a reason for hiding this comment

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

Thinking out loud:
Do we want/need to handle the cases with multiple dt or multiple dd?
Multiple dt: as an alias.. sounds like job for data-lt
Multiple dd: why?

@sidvishnoi sidvishnoi changed the title Add data-defines on well-known patterns of term/definition association feat(core/dfn): add data-defines on some patterns of term/definition association Dec 22, 2023
src/core/dfn.js Outdated
// A dl with class hasdefinitions marks all next siblings of dt with the class
// definition
/** @type NodeListOf<HTMLElement> */
const describedDTs = document.querySelectorAll("dl.hasdefinitions dt");
Copy link
Member

Choose a reason for hiding this comment

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

Maybe dl.definitions?

Copy link
Member Author

Choose a reason for hiding this comment

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

the reason I was liking "hasdefinitions" more than just "definitions" is that it is more easily distinguishable from the other pattern (it's easy to see that "hasdefinitions" is different from "definition", but it would really easy to confuse "definition" and "definitions" which generate quite different behavior).

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense, but still feels a little odd to me. Maybe I can get used to it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Wasn't loving hasdefinitions either tbh. I updated the PR to use "definitions".

src/core/dfn.js Outdated
let curEl = el;
let dfn;
while (curEl) {
dfn = curEl.querySelector("dfn[data-dfn-type]");
Copy link
Member

Choose a reason for hiding this comment

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

A comment explaining why [data-dfn-type] would be be nice.

Copy link
Member

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

Just one nit: dl.hasdefinitions should probably become dl.definitions.

src/core/dfn.js Outdated

// - Sets data-defines on well-known definition content patterns
function addDefinitionPointers() {
// A dl with class hasdefinitions marks all next siblings of dt with the class
Copy link
Contributor

@marcoscaceres marcoscaceres Dec 28, 2023

Choose a reason for hiding this comment

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

I don't dislike this (dl.definitions), but I feel this is overstepping based on what we have previously discussed. I still think we should start with an extremely simple / basic system and build it up very incrementally (and eventually get to this, but I don't think we are there yet).

Copy link
Member Author

Choose a reason for hiding this comment

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

a <dl> containing definitions is exactly what the VC spec (our initial customer) is using AFAICT; if we're not going to support that convention, I'm not sure we need a respec patch at all at the moment (since reffy recognizes data-defines without any additional help).

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, and that might be ok. But let's settle on the convention for:

  • container (p, span) has .definition
  • and multiple: dl.definitions

And explicitly marked as such.

Copy link
Contributor

@marcoscaceres marcoscaceres left a comment

Choose a reason for hiding this comment

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

I think this is good as a start.

We might need to deal with edge cases like:

<p class="definition">
  <dfn>a</dfn> ... <dfn>b</dfn>
</p>

src/core/dfn.js Outdated Show resolved Hide resolved
@dontcallmedom
Copy link
Member Author

is there anything blocking this or should I go ahead and merge it at this point?

@sidvishnoi
Copy link
Member

OK by me. @marcoscaceres?
Let me know I'll merge and release.

@sidvishnoi
Copy link
Member

Going ahead with the merge given Marcos approved already.

@sidvishnoi sidvishnoi merged commit 390d8b6 into speced:main Jan 29, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants