-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add latest feature detects and fixes from v4 branch (#2726)
* Fix: Update lowbandwidth condition to match new spec (#2688) * Adds PushManager feature detection #2703 (#2708) * Added detection of type worker option and aspect ratio (#2702)
- Loading branch information
Showing
6 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/*! | ||
{ | ||
"name": "PushManager", | ||
"property": "pushmanager", | ||
"caniuse": "mdn-api_pushmanager", | ||
"authors": ["Dawid Kulpa (@dawidkulpa)"], | ||
"notes": [{ | ||
"name": "MDN Docs", | ||
"href": "https://developer.mozilla.org/en-US/docs/Web/API/PushManager" | ||
}] | ||
} | ||
!*/ | ||
|
||
/* DOC | ||
Detects support for PushManager. | ||
*/ | ||
define(['Modernizr'], function(Modernizr) { | ||
Modernizr.addTest('pushmanager', 'PushManager' in window); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters