I think there's a corner case here with double quotes in the ID. Probably no one will ever hit it though since quotes in IDs is crazy :)
Whether it's worth the cost of escaping to fix, I'm not sure. Probably not.

```js
# at a JS console
var d = document.createElement('div')
d.innerHTML = '<div id=\'4"2\'>'
document.body.appendChild(d)
document.querySelector('[id="4"2"]')
# SyntaxError: Failed to execute query: '[id="4"2"]' is not a valid selector.
document.querySelector('[id="4\\"2"]')
# returns: <div id=​"4"2">​</div>​
```