Side navigation
#11565 closed enhancement (duplicate)
Opened April 06, 2012 10:26PM UTC
Closed April 06, 2012 11:03PM UTC
Last modified April 06, 2012 11:03PM UTC
css() should auto-normalize vendor-specific CSS properties
| Reported by: | SineSwiper | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
Per docs for jQuery.cssHooks:
''Before normalizing a vendor-specific CSS property, first determine whether the browser supports the standard property or a vendor-prefixed variation. For example, to check for support of the border-radius property, see if any variation is a member of a temporary element's style object.''
That's a great idea! Soooo... why isn't that just the standard behavior for css()? If I want to look at MozOutlineColor, why can't I just say .css('outlineColor')?
Attachments (0)
Change History (6)
Changed April 06, 2012 10:59PM UTC by comment:1
Changed April 06, 2012 11:00PM UTC by comment:2
| resolution: | → duplicate |
|---|---|
| status: | new → closed |
Changed April 06, 2012 11:02PM UTC by comment:4
| resolution: | duplicate |
|---|---|
| status: | closed → reopened |
Changed April 06, 2012 11:03PM UTC by comment:5
| resolution: | → duplicate |
|---|---|
| status: | reopened → closed |
Working code:
var div = document.createElement('div'); for (var prop in div.style) { // Sanity checks if (! /^(Moz|Webkit|O|ms)[A-Z]/.test(prop)) continue; if (typeof prop !== 'string') continue; var cssProp = prop.replace(/^(Moz|Webkit|O|ms)/, ''); cssProp = cssProp.charAt(0).toLowerCase() + cssProp.slice(1); if (!$.cssHooks[cssProp]) $.cssHooks[cssProp] = { get: function (elem, computed, extra) { return $.css(elem, prop); }, set: function (elem, value) { elem.style[prop] = value; } }; }