Skip to main content

Bug Tracker

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 SineSwiper comment:1

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; }
	};
}

Changed April 06, 2012 11:00PM UTC by mikesherov comment:2

resolution: → duplicate
status: newclosed

Changed April 06, 2012 11:00PM UTC by mikesherov comment:3

Duplicate of #10413.

Changed April 06, 2012 11:02PM UTC by mikesherov comment:4

resolution: duplicate
status: closedreopened

Changed April 06, 2012 11:03PM UTC by mikesherov comment:5

resolution: → duplicate
status: reopenedclosed

Changed April 06, 2012 11:03PM UTC by mikesherov comment:6

Duplicate of #10679.