polyfills.Object.create.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":{"ie":"6 - 8","safari":"4","firefox":"<4","firefox_mob":"<4"},"dependencies":["Object.defineProperties"],"docs":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create","detectSource":"'create' in Object","testSource":"","baseDir":"Object/create","hasTests":true,"testsSource":"/* eslint-env mocha, browser */\n/* global proclaim */\n\nit(\"Should create inherited object\", function() {\n\tvar parent = { foo: 'bar', obj: {} };\n\tvar child = Object.create(parent);\n\n\tproclaim.isTypeOf(child, 'object');\n\tproclaim.notStrictEqual(parent, child);\n\tproclaim.equal(child.foo, parent.foo);\n\tproclaim.equal(child.obj, parent.obj);\n});\n\nit(\"Should create inherited object from a Native Object\", function() {\n\tvar parent = document;\n\tvar child = Object.create(parent);\n\n\tproclaim.equal(typeof child, 'object');\n\tproclaim.notStrictEqual(parent, child);\n\tproclaim.equal(child.window, parent.window);\n\tproclaim.equal(child.ELEMENT_NODE, parent.ELEMENT_NODE);\n});\n\nit(\"Should throw a TypeError if called with undefined\", function() {\n\tproclaim.throws(function() { Object.create(undefined); }, TypeError);\n});\n\nit(\"Should create an object if called with null\", function() {\n\tproclaim.equal(typeof Object.create(null), 'object');\n});\n\nit(\"Should throw a TypeError if called with a boolean primitive\", function() {\n\tproclaim.throws(function() { Object.create(true); }, TypeError);\n});\n\nit(\"Should throw a TypeError if called with a number primitive\", function() {\n\tproclaim.throws(function() { Object.create(100); }, TypeError);\n});\n\nit(\"Should not throw a TypeError if called with Function objects\", function() {\n\tproclaim.doesNotThrow(function() {\n\t\tObject.create(Function);\n\t});\n\tproclaim.doesNotThrow(function() {\n\t\tObject.create(Function.prototype);\n\t});\n});\n\nit(\"Should return an instance of Object\", function() {\n\tproclaim.isInstanceOf(Object.create({}), Object);\n});\n\nit(\"Should set the prototype of the passed-in object\", function() {\n\tfunction Base() {}\n\n\tvar\n\tsupportsProto = ''.__proto__ === String.prototype,\n\tb = new Base(),\n\tbb = Object.create(b);\n\n\tproclaim.equal(supportsProto ? bb.__proto__ : bb.constructor.prototype, b);\n});\nit(\"Should allow additional properties to be defined\", function() {\n\tfunction Base() {}\n\n\tvar\n\tb = new Base(),\n\tbb = Object.create(b, {\n\t\tx: {\n\t\t\tvalue: true,\n\t\t\twritable: false\n\t\t},\n\t\ty: {\n\t\t\tvalue: \"str\",\n\t\t\twritable: false\n\t\t}\n\t});\n\n\tproclaim.equal(bb.x, true);\n\tproclaim.equal(bb.y, \"str\");\n\tproclaim.equal(b.x, undefined);\n\tproclaim.equal(b.y, undefined);\n});\n\n// http://www.ecma-international.org/ecma-262/5.1/#sec-15.2.3.5\n// https://github.com/tc39/test262/blob/master/test/suite/ch15/15.2/15.2.3/15.2.3.5/15.2.3.5-4-100.js\nit(\"If the second argument is present and not undefined, add own properties to result object as if by calling the standard built-in function Object.defineProperties with arguments returned object and Properties.\", function() {\n\tvar newObj = Object.create({}, {\n\t\tprop: {\n\t\t\tvalue: \"ownDataProperty\"\n\t\t}\n\t});\n\n\tvar result1 = newObj.hasOwnProperty(\"prop\");\n\n\t// Avoid Object.defineProperty's writable test in old IE\n\t// delete newObj.prop;\n\n\t// var result2 = newObj.hasOwnProperty(\"prop\");\n\n\tproclaim.equal(result1, true);\n\t// proclaim.equal(result2, true);\n});"}