fix #1595 document.activeElement can be null on some browsers
fix #1595 document.activeElement can be null on some browsers

This commit fixes an issue with commit ba8b45d89c9c24075a22846d41422896afe84ab0 (#1591):
as document.activeElement can be null on some browsers, it is better to
check whether it is non-null before using it.

simonarbuckle/ariatemplates,vcarle/ariatemplates,simonarbuckle/ariatemplates,simonarbuckle/ariatemplates,fbasso/ariatemplates,benouat/ariatemplates,ymeine/ariatemplates,ariatemplates/ariatemplates,vcarle/ariatemplates,fbasso/ariatemplates,ymeine/ariatemplates,benouat/ariatemplates,divdavem/ariatemplates,vcarle/ariatemplates,ariatemplates/ariatemplates,benouat/ariatemplates,divdavem/ariatemplates,divdavem/ariatemplates,ariatemplates/ariatemplates,fbasso/ariatemplates,ymeine/ariatemplates