Implementing the DOM contains() method