Refactor hasAttribute method to check the browser once instead on 3 times.