Skip to content

Commit

Permalink
Create Value.defineByDescriptor, fix create when Object.create
Browse files Browse the repository at this point in the history
…is unavailable.
  • Loading branch information
ljharb committed Jun 14, 2015
1 parent cba1442 commit 18dc5f5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion es6-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
Prototype.prototype = prototype;
var object = new Prototype();
if (typeof properties !== 'undefined') {
defineProperties(object, properties);
Object.keys(properties).forEach(function (key) {
Value.defineByDescriptor(object, key, properties[key]);
});
}
return object;
};
Expand Down Expand Up @@ -208,6 +210,13 @@
object[property] = newValue;
}
},
defineByDescriptor: function (object, property, descriptor) {
if (supportsDescriptors) {
Object.defineProperty(object, property, descriptor);
} else if ('value' in descriptor) {
object[property] = descriptor.value;
}
},
preserveToString: function (target, source) {
defineProperty(target, 'toString', source.toString.bind(source), true);
}
Expand Down

0 comments on commit 18dc5f5

Please sign in to comment.