Bad handling of complex DOM ids using querySelector
Using the statement:
document.querySelector(`#${ id }`)
where id is a string representing a DOM id can only handle a certain subset of allowable id strings. For example, whitespace will break this, because querySelector parses the given query string as a CSS query selector.
To fix, use document.getElementById for queries against element ids:
document.getElementById(`${ id }`)