Fix #14164: assign className in addClass/removeClass only if changed. Close gh-1331. (cherry-picked from c418b94eb48188cd9329519ae5e030a52dd81cc9)