Fixed generation of unique id values

Fixes #6371.

This resolves an odd bug where the guid() function on occasion generates unique id values that start with a number, which can trip up querySelector and querySelectorAll.

/cc @LaurentGoderre