Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

couple gotchas with css #8

Closed
mattdesl opened this issue Apr 23, 2015 · 3 comments
Closed

couple gotchas with css #8

mattdesl opened this issue Apr 23, 2015 · 3 comments

Comments

@mattdesl
Copy link

Cool library. 👍

Just skimming the css() function and noticed a couple pitfalls that you may want to mention in the docs.

  • there is no vendor prefixing on css()
  • case is not normalized; so element.css('backgroundColor') !== element.css('background-color')
  • this also means css('zIndex', 0) is treated as pixels, css('z-index', 0) is treated as a number
  • does not handle cssFloat edge case
@bendc
Copy link
Owner

bendc commented Apr 23, 2015

Thanks a lot @mattdesl, great feedback :)

You're absolutely right about mentioning the case differences, will fix. I'm not sure to understand what's the cssFloat edge case though?

@xzyfer
Copy link

xzyfer commented Apr 23, 2015

I believe this is what @mattdesl is referring to -

element.style.cssFloat = 'left'; // correct
element.style.float = 'left'; // incorrect

Note: If you're referring to this property from JavaScript as a member of the element.style object, you must spell it as cssFloat. [...] This is an exception to the rule that the name of the DOM member is the camel-case name of the dash-separated CSS name (and is due to the fact that "float" is a reserved word in JavaScript, as with the need to escape "class" as "className" and escape 's "for" as "htmlFor").

source - https://developer.mozilla.org/en-US/docs/Web/CSS/float

@bendc
Copy link
Owner

bendc commented Apr 23, 2015

Oh ok yeah, sure. Well I guess this could just fall into the "just use CSS property names" restriction from @mattdesl's other comments. Some things do work, like element.css('backgroundColor', 'red') but I feel like giving just a simpler, more restrictive note about property names will be easier here.

@bendc bendc closed this as completed Apr 23, 2015
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

No branches or pull requests

3 participants