Pretty sure this is happening in the WP Nav Walker. You can see the source here: https://developer.wordpress.org/reference/classes/walker_nav_menu/ I’m on my phone so the code is a little difficult to read, but it looks like the classes are being sanitized by esc_attr(). It looks like all the available filters in the Walker happen before the classes are sanitized, but it looks like there’s a filter on esc_attr that would allow you to filter content after it’s been sanitized, to “re-add” your correct classes: https://developer.wordpress.org/reference/functions/esc_attr/