Skip to content

Comments

Added css Hook#72

Closed
think2011 wants to merge 1 commit intogabceb:masterfrom
think2011:master
Closed

Added css Hook#72
think2011 wants to merge 1 commit intogabceb:masterfrom
think2011:master

Conversation

@think2011
Copy link

qq20151224-0

@think2011
Copy link
Author

: (

@gabceb
Copy link
Owner

gabceb commented Dec 24, 2015

Hi @think2011. Could you share the thinking behind this functionality? At the moment I'm leaning towards not merging since IMO adding css classes to elements is outside of the responsabilities of this library. Would love to hear your thoughts.

@le717
Copy link
Contributor

le717 commented Dec 24, 2015

I am against merging this PR. Let me explain why.

I could see a use-case for these classes. Since the script detects the browser being run, the classes can be used to apply browser-specific CSS to remedy certain browser bugs and inconsistencies (I have dealt with that myself). It also follows the trend Modernizr helped set by classing the <html> element with the names of available features for appropriate fallback styling and/or features. I believe I have seen this type of browser-identification classes before, through from Modernizr or another script I do not know.

I am against this PR for a fundamental reason: the script "detects" the browser being run. In order to "detect" the browser we scan and extract details from the user-agent. The problem is the user-agent can be changed at will, making it 100% unreliable. Because the detection and classes would be dependent on an unstable value, one merely must change their UA to receive code/styling that did not apply to their browser.

That is why I am against merging this PR. I can sympathize with the need to apply browser-specific styling (although that is dangerous now that browsers use an evergreen update model), but adding those classes via UA-sniffing is not the way to do it. (I actually wrote a small script to feature-detect browsers for this express purpose. Yes it is an anti-pattern (which is why I do not release it), but it is what it is.).

@gabceb
Copy link
Owner

gabceb commented Dec 24, 2015

Im with you @le717. Lets see what @think2011 thinks.

@think2011
Copy link
Author

#box {
    margin-left:20px;
}
.ie8 #box {
    margin-left:21px;
}

Like Modernizr, It's useful for my present work.

And thanks for you explanation @le717, I agree with this point :-)

@think2011 think2011 closed this Dec 25, 2015
@gabceb
Copy link
Owner

gabceb commented Dec 25, 2015

👍🏻

@le717
Copy link
Contributor

le717 commented Dec 25, 2015

@think2011 If you are trying to target old IE, I recommend researching IE conditionals and separate your IE hacks into a separate stylesheet. :)

@think2011
Copy link
Author

@le717 Thanks :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants