Reputation: 1755
I'm new to Modernizr. This may seem like an incredibly OCD question, but I'm curious as to why Modernizr adds a preceding space when it assigns a class to my page's html
tag when it is the only class assigned?
For instance when I inspect my page in a desktop context, my page's html
tag looks like so:
<html dir="ltr" lang="en-AU" style="" class=" no-touchevents">
instead of:
<html dir="ltr" lang="en-AU" style="" class="no-touchevents">
Is there a rationale as to why Modernizr adds classes in this manner?
Upvotes: 2
Views: 59
Reputation: 1256
Here's the source code for adding classes in modernizer: https://github.com/Modernizr/Modernizr/blob/e2c27dcd32d6185846ce3c6c83d7634cfa402d19/src/setClasses.js
Looks like it's just because they're doing a +=
on the className and are including a space in case the element already has some classes assigned.
Upvotes: 4