Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added detection of type worker option and aspect ratio #2702

Merged
merged 7 commits into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions feature-detects/css/aspectratio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*!
{
"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'], function (Modernizr, createElement) {
Modernizr.addTest("aspectratio", function () {
if (typeof CSS !== "object" && typeof CSS.supports === "function") {
return CSS.supports('aspect-ratio', '1 / 1')
} else {
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;
}
}
});
});
42 changes: 42 additions & 0 deletions feature-detects/workers/workertypeoption.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*!
{
"name": "worker type option test",
"property": "workertypeoption",
"caniuse":"mdn-api_worker_worker_ecmascript_modules",
"tags": ["web worker type options", "web worker"],
"builderAliases": ["worker_type_options"],
"authors": ["Debadutta Panda"],
"notes": [{
"name": "MDN Docs",
"href": "https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker"
}]
}
!*/
/* DOC
Detect working status of all Workeroptions
https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker
*/
define(['Modernizr'], function (Modernizr) {
Modernizr.addTest("workertypeoption", function () {
if ('Worker' in window) {
var isTypeOptionSupported = false,
textTypeOption = {
get type() {
isTypeOptionSupported = true;
return "module"
}
},
scriptText = `var message='hello'`,
blob = new Blob([scriptText], { type: 'text/javascript' }),
url = URL.createObjectURL(blob)
try {
new Worker(url, textTypeOption).terminate();
return isTypeOptionSupported;
} catch (err) {
return false;
}
} else {
return false;
}
});
});
2 changes: 2 additions & 0 deletions lib/config-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"css/all",
"css/animations",
"css/appearance",
"css/aspectratio",
"css/backdropfilter",
"css/backgroundblendmode",
"css/backgroundcliptext",
Expand Down Expand Up @@ -318,6 +319,7 @@
"window/framed",
"window/matchmedia",
"window/resizeobserver",
"workers/workertypeoption",
"workers/blobworkers",
"workers/dataworkers",
"workers/sharedworkers",
Expand Down
2 changes: 2 additions & 0 deletions test/browser/integration/caniuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ window.caniusecb = function(caniuse) {
cssvmaxunit: 'viewport-units',
cssvminunit: 'viewport-units',
cssvwunit: 'viewport-units',
cssaspectratio:'mdn-css_properties_aspect-ratio',
customelements: 'custom-elementsv1',
customproperties: 'css-variables',
dataset: 'dataset',
Expand Down Expand Up @@ -178,6 +179,7 @@ window.caniusecb = function(caniuse) {
websockets: 'websockets',
websqldatabase: 'sql-storage',
webworkers: 'webworkers',
workertypeoption:'mdn-api_worker_worker_ecmascript_modules',
willchange: 'will-change',
xhr2: 'xhr2'
};
Expand Down