Button: Modify the code to improve a minor performance.

Modify the code in'_parseClasses' function.

Fixes gh-7303