Fix #14164: assign className in addClass/removeClass only if changed. Close gh-1331.