It was hypothesized that querySelector was not available, not that the entire DOM API was not available. However, if we suppose that the entire DOM API was not available, there would no way to access the HTML nodes so no algorithm is going to save you anyway.