mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-18 23:51:04 +00:00
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
/*!
|
|
{
|
|
"name": "ES7 Rest destructuring",
|
|
"property": ["restdestructuringarray", "restdestructuringobject"],
|
|
"caniuse" : "destructuring%20assignment",
|
|
"notes": [{
|
|
"name": "official ECMAScript 7 Destructuring Assignment draft specification",
|
|
"href": "https://tc39.es/ecma262/#sec-destructuring-assignment"
|
|
}],
|
|
"authors": ["dabretin"],
|
|
"warnings": ["ECMAScript 7 is still a only a draft, so this detect may not match the final specification or implementations."],
|
|
"tags": ["es7"]
|
|
}
|
|
!*/
|
|
/* DOC
|
|
Check if browser implements ECMAScript 7 Destructuring Assignment per specification.
|
|
*/
|
|
define(['Modernizr'], function(Modernizr) {
|
|
Modernizr.addTest('restdestructuringarray', function() {
|
|
try {
|
|
// eslint-disable-next-line
|
|
eval('var [...rest]=[1]');
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
Modernizr.addTest('restdestructuringobject', function() {
|
|
try {
|
|
// eslint-disable-next-line
|
|
eval('var {...rest}={a:1}');
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
});
|