Use of querySelectorEscape misguided
I'm working with a document that has an id starting with a digit, '3rd-party', and adding TOC page numbers via
.toc a::after {
content: "p. " target-counter(attr(href), page);
float: right;
}
I get an exception (line numbers are probably off from paged.esm.js):
> An uncaught exception happened within the HTML page http://localhost:8081/refguide/_attachments/refguide-pdf.pdf: Error: DOMException: Failed to execute 'querySelector' on 'Element': '#3rd-party' is not a valid selector.
at http://localhost:8081/_/js/paged.js:29604:37
at NodeList.forEach (<anonymous>)
at http://localhost:8081/_/js/paged.js:29598:12
at Array.forEach (<anonymous>)
at TargetCounters.afterPageLayout (http://localhost:8081/_/js/paged.js:29591:36)
at http://localhost:8081/_/js/paged.js:1164:25
at Array.forEach (<anonymous>)
at Hook.trigger (http://localhost:8081/_/js/paged.js:1163:14)
at Chunker.layout (http://localhost:8081/_/js/paged.js:2716:37)
at async Chunker.renderAsync (http://localhost:8081/_/js/paged.js:2637:16)
Looking into the code, I believe the escaping code is being applied to the wrong string. I believe it should be escaping the id, not the id prefixed by the '#' 'it's an id' symbol.
To try to verify this, I made the beginnings of util.js querySelectorEscape look like this:
export function querySelectorEscape(value) {
if (arguments.length == 0) {
throw new TypeError("`CSS.escape` requires an argument.");
}
var string = String(value);
if (string.charAt(0) === '#') {
return '#' + querySelectorEscape(string.slice(1))
}
and now my document processes without exceptions. This doesn't seem like an appropriate patch, and I'm not sure what other inputs this function might receive, so I'm hoping the experts can fix this in a good way.