Check if a DOM element matches a CSS selector