| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- /*!
- {
- "name": "ES5 Syntax",
- "property": "es5syntax",
- "notes": [{
- "name": "ECMAScript 5.1 Language Specification",
- "href": "https://www.ecma-international.org/ecma-262/5.1/"
- }, {
- "name": "original implementation of detect code",
- "href": "https://kangax.github.io/compat-table/es5/"
- }],
- "authors": ["Ron Waldon (@jokeyrhyme)"],
- "warnings": ["This detect uses `eval()`, so CSP may be a problem."],
- "tags": ["es5"]
- }
- !*/
- /* DOC
- Check if browser accepts ECMAScript 5 syntax.
- */
- define(['Modernizr'], function(Modernizr) {
- Modernizr.addTest('es5syntax', function() {
- var value, obj, stringAccess, getter, setter, reservedWords, zeroWidthChars;
- try {
- /* eslint no-eval: "off" */
- // Property access on strings
- stringAccess = eval('"foobar"[3] === "b"');
- // Getter in property initializer
- getter = eval('({ get x(){ return 1 } }).x === 1');
- eval('({ set x(v){ value = v; } }).x = 1');
- // Setter in property initializer
- setter = value === 1;
- // Reserved words as property names
- eval('obj = ({ if: 1 })');
- reservedWords = obj['if'] === 1;
- // Zero-width characters in identifiers
- zeroWidthChars = eval('_\u200c\u200d = true');
- return stringAccess && getter && setter && reservedWords && zeroWidthChars;
- } catch (ignore) {
- return false;
- }
- });
- });
|