Implement Element.matches()

Fix #2769