Fix an issue where sometimes the delegated listeners would try to run against text nodes