mirror of
https://github.com/Modernizr/Modernizr.git
synced 2026-01-09 15:47:55 -05:00
* fix(aspectratio): should only use CSS.supports when CSS is an object * chore: keep the same code style * Use feature test for css-supports detection * Cleanup more css supports usages * make sure to use window.CSS --------- Co-authored-by: veeck <gitkraken@veeck.de>
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
/*!
|
|
{
|
|
"name": "aspectratio css property",
|
|
"property": "aspectratio",
|
|
"tags": ["css aspectratio", "aspect-ratio"],
|
|
"builderAliases": ["aspectratio"],
|
|
"caniuse":"mdn-css_properties_aspect-ratio",
|
|
"authors": ["Debadutta Panda"],
|
|
"notes": [{
|
|
"name": "MDN Docs",
|
|
"href": "https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio"
|
|
}]
|
|
}
|
|
!*/
|
|
/* DOC
|
|
Detect working status of all aspectratio css property
|
|
https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio
|
|
*/
|
|
define(['Modernizr', 'createElement', 'test/css/supports'], function (Modernizr, createElement) {
|
|
Modernizr.addTest("aspectratio", function () {
|
|
var CSS = window.CSS;
|
|
if (Modernizr.supports && CSS.supports('aspect-ratio', '1 / 1')) {
|
|
return true;
|
|
}
|
|
|
|
var element = createElement('p'),
|
|
elStyle = element.style
|
|
if ('aspectRatio' in elStyle) {
|
|
elStyle.cssText = 'aspect-ratio:1 / 1'
|
|
element.remove()
|
|
return (elStyle['aspectRatio'] === '1 / 1');
|
|
} else {
|
|
element.remove();
|
|
return false;
|
|
}
|
|
});
|
|
});
|