modified element check to avoid throwing errors on IE when passed fake elements (HTMLUnknownElement/HTMLGenericElement)