index: Improve HTMLElement duck typing

This patch prevents passing a non-element to `ClassList`.