-
Notifications
You must be signed in to change notification settings - Fork 64
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
avoid iterating a live nodelist #588
Conversation
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 |
Yes but we do and that's why we can't use this CSS-only strategy.
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. |
(Well, no, it's iterating 30k elements, but it's still true that the iteration itself is now ~instant.) |
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. |
To be used for suppressing automatic insertion of targets when printing, cf. tc39/ecmarkup#578 and tc39/ecmarkup#588 (comment)
ecma262 PR: tc39/ecma262#3301 |
To be used for suppressing automatic insertion of targets when printing, cf. tc39/ecmarkup#578 and tc39/ecmarkup#588 (comment)
This step is still surprisingly slow but this makes it take 5 seconds instead of 10 on my machine.