Today I looked at the source code of the jQuery function removeClass:
There is the following line:
className = (" " + elem.className + " ").replace( rclass, " " );
rclass:
rclass = /[\n\t\r]/g,
In the book "JavaScript The Definitve Guide" from David Flanagan, 6th Edition, on page 438 there are the following sentence:
..., so the HTML class attribute is available to JavaScript code using the name className. ... and the class attribute holds a space-separated list of class names.
Why the jQuery coders assume that the class names can also be separated by tabs and line feeds?
Lots of web "developers" know almost nothing about what they are doing and thus write crappy code containing e.g. tab- or linefeed-separated class names.
It is a common principle to "be generous when reading but strict when writing", i.e. accept things that do not really follow $standard but never create such things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With