Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11565 closed enhancement (duplicate)

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')?

Change History (6)

comment:1 Changed 11 years ago by SineSwiper

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

comment:2 Changed 11 years ago by mikesherov

Resolution: duplicate
Status: newclosed

comment:3 Changed 11 years ago by mikesherov

Duplicate of #10413.

comment:4 Changed 11 years ago by mikesherov

Resolution: duplicate
Status: closedreopened

comment:5 Changed 11 years ago by mikesherov

Resolution: duplicate
Status: reopenedclosed

comment:6 Changed 11 years ago by mikesherov

Duplicate of #10679.

Note: See TracTickets for help on using tickets.