Making fit.js functional on IE8

HTMLElement doesn't exist in IE8, so swapped in two places for typeof
undefined check and target.nodeType == 1

IE8 uses attachEvent rather than addEventListener