check for HTMLTemplateElement existence properly before using.