This is bad, because:
1. It's replaces only first match.
2. It's replaces any `.` not only on the classes (eg. `a[data-foo='.']` or something).

I suggest to move this logic to the parser.