-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
doc: properly mark up deprecation anchors #34955
Conversation
Hmm, I was under the impression that Would you mind double-checking that? I'd be interested in knowing what both WHATWG and W3C have to say on the matter to ensure that this is technically correct. Have you read this following as well? |
@DerekNonGeneric https://www.w3.org/TR/html52/textlevel-semantics.html#the-i-element
And
None is deprecated, they are just two different elements. We definitely don't want to stress emphasis of those empty tags, so
That seems to be related to the use of those tags as presentational fix, but that's not what we're doing here. |
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.
Although I'm opposed to using <i>
tags in this situation, I also believe empty <a>
tags are wrong too.
We've discussed an alternative that is more screen-reader friendly instead of perhaps what might've been a hack to begin with. All of this can be handled in the same PR, it's not that difficult.
@aduh95, please let me know if it you would prefer if I addressed my own concerns.
Blocking because I feel that this type of hack is unnecessary and would be detrimental to start allowing.
@DerekNonGeneric let me rephrase your stand to check if we're on the same ground: the current state (using empty Would empty
I'm not sure to know what you mean by that exactly, can elaborate on that? I guess that's referencing the discussion earlier on this thread, but I'm not sure which part. |
What you proposed in #34955 (comment) is the de jure correct way of doing this. We don't need empty tags at all. As you mentioned, the only issue is the |
OK, so the building of the TOC items is done here if I’m not mistaken: Lines 350 to 368 in c2996ce
As you can see, it is not HTML aware, just manipulation of strings in plain JS. How would you do what you are proposing in a non-hacky way? I'm not familiar with this part of the code base, so maybe I'm missing something obvious? |
Right, so the problem is the same problem we had been experiencing with |
I don't recall, I'm afraid. I won't have time to look and try to refresh my memory tonight. I'll try to dig in tomorrow, but no guarantees. If someone else wants to do it, please don't wait for me. |
Although if all you want to know is why |
Well, we want to use |
I think using Does that work? I can think of multiple possibilities for moving the |
I'm trying to find something that says that using |
I suppose one option is to get rid of these things entirely and rely on the longer auto-generated ids. So instead of <p><a id="DEP0049"></a></p>
--
| <h3>DEP0049: <code>util.isFunction()</code><span><a class="mark" href="#deprecations_dep0049_util_isfunction" id="deprecations_dep0049_util_isfunction">#</a></span></h3> |
Empty tags are a concern for https://validator.w3.org and from an accessibility perspective, I have no idea what a screen reader would w/ something like this.
I imagine they were being used as permalinks at some point or elsewhere in the documentation. If I am mistaken, we could just remove them entirely, I have no problem w/ that. |
Another alternative would be to just use the |
That appears to be incorrect. https://validator.w3.org does not have a problem with our deprecations.html page other than a single
Well, that's what I'm asking for: A citation for that. I can't find any indication that's a correct statement. I mean, empty I could be wrong, but can someone please provide a citation?
Pretty sure it would (correctly) ignore it (or maybe indicate it can be tabbed to?). |
More evidence that we may be solving a non-problem: WebAIM WAVE does not flag this as an accessibility issue. Would seem to be pretty low-hanging fruit if it were a problem. https://wave.webaim.org/report#/https://nodejs.org/dist/latest-v14.x/docs/api/deprecations.html |
By the way, I've opened PRs for the 3 broken links reported by WAVE. If someone wants to handle the less trivial issue of resolving the lack of contrast for the stuff that ends up as red text in the syntax-highlighting, that would be most welcome. |
Nice, good investigation. Up to @aduh95 as to whether or not to pursue this fix any further. Thanks for looking into this! For the record: the table of contents generator is to blame here. It's broken for sure. |
@aduh95, to address my remaining concerns in this PR, please see the diff I've left below. Regarding… Lines 350 to 353 in c2996ce
Patch it this way… - const headingText = file.contents.slice(
+ let headingText = file.contents.slice(
node.children[0].position.start.offset,
node.position.end.offset).trim();
+ // Sanitize all HTML tags from heading text
+ headingText = headingText.replace(/<\/?[^>]+(>|$)/g, '');
const id = getId(`${realFilename}_${headingText}`, idCounters); Then all that's left to do is what you proposed in #34955 (comment). You will have a pretty nice negative diff! Do these remaining things and I will approve this PR. 👍 |
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.
I personally would prefer to either leave the <a id="DEP0XXX"></a>
tags (as I don't see any evidence they are an accessibility issue) or else remove them entirely (as I'm not sure they get used anywhere anyway and there's already an id attribute generated for the header elements automatically).
I'd prefer not to introduce HTML markup directly into the headers as it adds unnecessary complexity.
@DerekNonGeneric I'd prefer we try not to parse HTML with regular expressions because it's not possible to do it in a completely reliable way. You need to use a proper parser.
This comment has been minimized.
This comment has been minimized.
Seeing the hover effect now. Nice catch. |
It may not be an accessibility issue, but that's just a fundamentally flawed way of using HTML in general. You're not supposed to open a tag and then close it w/ nothing inside of it. For instances where that is necessary, one should be using self-closing tags. Take the
Refs: https://dev.w3.org/html5/html-author/#tags
The
We don't really need a completely reliable way, but I have no problem adding another dependency to the doctool, we do already use a few foreign dependencies for that tool anyways. |
I think the correct solution here is to remove this line as Line 67 in 6f0b87d
|
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.
Nice, thanks for fixing this. Sweet diff too.
Landed in fa105eb Thanks for sticking with this one! |
720ac66
to
fa105eb
Compare
PR-URL: nodejs#35034 Refs: nodejs#34955 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
PR-URL: #34955 Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: #34955 Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: nodejs#34955 Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is> Reviewed-By: Rich Trott <rtrott@gmail.com>
PR-URL: nodejs#35034 Refs: nodejs#34955 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
Using empty
<a>
tags here have several downsides:This PR uses the
<i>
tag instead, because it's the first one-letter tag I could think of.Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes