Check if extended_valid_elements is a string before concatenating to it.