polyfills.Object.defineProperty.meta.json Maven / Gradle / Ivy
The newest version!
{"aliases":["es5","modernizr:es5object","default-3.3","default-3.4","default-3.5","default-3.6","default","blissfuljs"],"browsers":{"firefox":"3.6","safari":"4 - 4.1","ios_saf":"4.3","firefox_mob":"3.6","ie":"6 - 8"},"notes":["In browsers that have no hooks to define getter functions (notably IE <= 8), attempting to defineProperty with a getter or setter function will fail. Since failing silently would likely break your application, we throw an exception. In IE8, this can be hard to diagnose because the console will just say 'Exception thrown and not caught'"],"docs":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty","detectSource":"// In IE8, defineProperty could only act on DOM elements, so full support\n// for the feature requires the ability to set a property on an arbitrary object\n'defineProperty' in Object && (function() {\n\ttry {\n\t\tvar a = {};\n\t\tObject.defineProperty(a, 'test', {value:42});\n\t\treturn true;\n\t} catch(e) {\n\t\treturn false\n\t}\n}())","testSource":"","baseDir":"Object/defineProperty","hasTests":true,"testsSource":"/* eslint-env mocha, browser*/\n/* global proclaim, it */\n\ndescribe('Basic functionality', function () {\n\tvar\n\tobject = {},\n\tproperty = 'foo',\n\tvalue = 'bar';\n\n\tit('Returns the object being defined', function () {\n\t\tproclaim.deepEqual(Object.defineProperty(object, property, {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\twritable: true\n\t\t}), object);\n\t});\n\n\tit('Assigns a property', function () {\n\t\tObject.defineProperty(object, property, {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\twritable: true\n\t\t});\n\t\tproclaim.equal(property in object, true);\n\t});\n\n\tit('Assigns a property with a value', function () {\n\t\tObject.defineProperty(object, property, {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: value,\n\t\t\twritable: true\n\t\t});\n\n\t\tproclaim.equal(object[property], value);\n\t});\n\n\tit('Assigns a property with a getter if getters are supported by the engine, else throws', function () {\n\t\ttry {\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tget: function () {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tif (e.message !== \"Getters & setters cannot be defined on this javascript engine\") {\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\n\t\tproclaim.equal(object[property], value);\n\t});\n});\n\ndescribe('Error handling', function () {\n\tvar\n\tobject = {},\n\tproperty = 'foo',\n\tvalue = 'bar';\n\n\tit('Throws an error when called on a non-object', function() {\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty();\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(undefined);\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(null);\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty('');\n\t\t});\n\t});\n\n\tit('Throws an error when descriptor is a non-object', function() {\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property);\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, undefined);\n\t\t});\n\n\t\t// Crashes Edge 14 on Sauce Labs, works on BrowserStack\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, null);\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, '');\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property);\n\t\t}, /^Property description must be an object/);\n\t});\n\n\tit('Throws an error when both an accessor and a value are specified', function () {\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tvalue: value,\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\tget: function () {}\n\t\t\t});\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tvalue: value,\n\t\t\t\twritable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t\tset: function () {}\n\t\t\t});\n\t\t});\n\t});\n\n\tit('Throws an error when an accessor is specified and writable is set', function () {\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tget: function () {},\n\t\t\t\twritable: false\n\t\t\t});\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tget: function () {},\n\t\t\t\twritable: true\n\t\t\t});\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tset: function () {},\n\t\t\t\twritable: false\n\t\t\t});\n\t\t});\n\n\t\tproclaim.throws(function () {\n\t\t\tObject.defineProperty(object, property, {\n\t\t\t\tset: function () {},\n\t\t\t\twritable: true\n\t\t\t});\n\t\t});\n\t});\n});"}