Skip to content

Commit

Permalink
check hasDefinePropertiesPrototype. Relevant to cujojs#29
Browse files Browse the repository at this point in the history
  • Loading branch information
Kimi-GitHub committed Apr 1, 2014
1 parent a48bbc8 commit bc8ef6d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions object.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ define(function (require) {
'object-defineproperties-dom': function () {
return doc && hasDefineProperties(testEl);
},
'object-defineproperties-prototype': function () {
return hasDefinePropertiesPrototype(function () {});
},
'object-getownpropertydescriptor-obj': function () {
return hasGetOwnPropertyDescriptor({});
},
Expand Down Expand Up @@ -196,6 +199,10 @@ define(function (require) {
? useNativeForDom(Object.defineProperties, defineProperties)
: defineProperties;
}
else if (!has('object-defineproperties-prototype')) {
Object.defineProperties = shims.defineProperties
= defineProperties;
}

if (!has('object-defineproperty-obj')) {
// check if dom has it (IE8)
Expand Down Expand Up @@ -245,6 +252,17 @@ define(function (require) {
}
}

function hasDefinePropertiesPrototype(fn) {
if (('defineProperties' in Object)) {
try {
// test it
Object.defineProperties(fn, { 'prototype': { value: { test: true } } })
return (new fn).test === true && fn.prototype.test === true;
}
catch (ex) { /* squelch */ }
}
}

function hasGetOwnPropertyDescriptor (object) {
if (('getOwnPropertyDescriptor' in Object)) {
object['sentinel3'] = true;
Expand Down

0 comments on commit bc8ef6d

Please sign in to comment.