Skip to content

Instantly share code, notes, and snippets.

@dshaw
Forked from KuraFire/backgroundSizeContain.js
Created September 1, 2010 14:38
Show Gist options
  • Save dshaw/560767 to your computer and use it in GitHub Desktop.
Save dshaw/560767 to your computer and use it in GitHub Desktop.
tests['backgroundsize'] = function() {
var bool = test_props_all( 'backgroundSize' );
if (bool){
bool = new Boolean(bool);
bool.contain = !!(function() {
set_css('background-size: contain');
return contains(m_style['backgroundSize'], 'contain');
});
bool.cover = !!(function() {
set_css('background-size: cover');
return contains(m_style['backgroundSize'], 'cover');
});
}
return bool;
};
@dshaw
Copy link
Author

dshaw commented Sep 1, 2010

Regarding Modernizr issue:
http://github.com/Modernizr/Modernizr/issues/issue/109

Adding support for backgroundSize: contain and backgroundSize: cover.

@dshaw
Copy link
Author

dshaw commented Sep 2, 2010

Oops, was returning a function instead of a boolean.

Fixed that, BUT it's worth noting that going down this rabbit hole breaks the existing feature in test evaluation loop and does not provide a css flag for these properties. That css flag is probably the most valuable contribution from adding these contributions. The use case that I could think of for this is primarily css related: if there's no .backgroundsize-contain support, for example, provide a sensible work around in another css block.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment