Modifications to .css() -- Return unique CSS for element

Modifications to .css() -- Return unique CSS for element


Hey guys, been following this group for a while and thought I'd share
my two cents with the community.
I've recently developed a small plugin (~600 byte minified) that will
let you grab CSS for an element based upon another element in the same
scope/hierarchy in the DOM.
I'd like to see this kind of functionality in core, where a user could
just simply call .css() to grab a elements CSS. Consider this:
CSS (pseudo selectors):
div:first {
font-size: 25px;
background-color: #C0C0C0;
}
div:last {
font-size: 12px;
background-color: #FF0000;
}
// This will contain everything that is unique for div:first compared
to div:last
var css = $('div:first').getCSS('div:last');
// This will return an object containing all CSS unique for div:first
compared to a 'normal' div
var css = $('div:first').getCSS();
// Consider that this one contains some 100+ elements
$('#someSelector div').css(css);
You can read (and see test cases) here:
http://andreehansson.se/code/computedstyle/
In my initial testing, this method will be ~2-3 times faster then
grabbing ALL css properties for the element and injecting it to the
other ones.
Whaddayathink?