Fix matching errors with non-text nodes