Closed bakkot closed 8 months ago
It occurs to me that even more time could be saved by skipping this step entirely and instead updating the print CSS to use relevant attribute-value-starts-with selectors:
+/* Render non-mailto external link targets, cf. https://url.spec.whatwg.org/#special-scheme */
-a[data-print-href]::after {
+a:is([href^='ftp:' i], [href^='sftp:' i], [href^='http:' i], [href^='https:' i], [href^='ws:' i], [href^='wss:' i])::after {
content: ' <' attr(href) '>';
color: initial;
}
This would miss new schemes until added to the CSS (which is lintable) and would be redundant for links whose text matches their target (which we should probably not have anyway—it's more accessible to name links and let user agents handle URIs).
also if you're going for speed, you should avoid for..of
aggressively.
and would be redundant for links whose text matches their target (which we should probably not have anyway—it's more accessible to name links and let user agents handle URIs)
Yes but we do and that's why we can't use this CSS-only strategy.
also if you're going for speed, you should avoid
for..of
aggressively.
The for-of is only iterating 94 elements. It's not the slow part. The slow part, for some unexplainable reason, is setting an attribute.
The for-of is only iterating 94 elements.
(Well, no, it's iterating 30k elements, but it's still true that the iteration itself is now ~instant.)
and would be redundant for links whose text matches their target (which we should probably not have anyway—it's more accessible to name links and let user agents handle URIs)
Yes but we do and that's why we can't use this CSS-only strategy.
Having them doesn't preclude a CSS-only approach, it just means that such an approach would duplicate URLs. But to address the larger point, would you object to fixing such links by giving them non-URL text?
@gibson042 You're always welcome to send a PR to 262, but (without looking) I doubt you'll completely eliminate them.
ecma262 PR: https://github.com/tc39/ecma262/pull/3301
This step is still surprisingly slow but this makes it take 5 seconds instead of 10 on my machine.