typeof(document) is safe