welsonjs/node_modules/modernizr/feature-detects/css/multiplebgs.js

23 lines
841 B
JavaScript

/*!
{
"name": "CSS Multiple Backgrounds",
"caniuse": "multibackgrounds",
"property": "multiplebgs",
"tags": ["css"]
}
!*/
define(['Modernizr', 'createElement'], function(Modernizr, createElement) {
// Setting multiple images AND a color on the background shorthand property
// and then querying the style.background property value for the number of
// occurrences of "url(" is a reliable method for detecting ACTUAL support for this!
Modernizr.addTest('multiplebgs', function() {
var style = createElement('a').style;
style.cssText = 'background:url(https://),url(https://),red url(https://)';
// If the UA supports multiple backgrounds, there should be three occurrences
// of the string "url(" in the return value for elemStyle.background
return (/(url\s*\(.*?){3}/).test(style.background);
});
});