Consistently use DOM API to set focus, fixes #734, #747