Skip to content

Commit

Permalink
Merge pull request #183 from andyearnshaw/define-properties
Browse files Browse the repository at this point in the history
fixes #182: improving Object.defineProperty() detection mechanism
  • Loading branch information
caridy authored Jun 16, 2016
2 parents bdd9c9c + 9ba894c commit 8b09c08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 2 additions & 7 deletions src/12.datetimeformat.js
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,6 @@ defineProperty(Intl.DateTimeFormat, 'supportedLocalesOf', {
get: GetFormatDateTime
});

defineProperty(Intl.DateTimeFormat.prototype, 'formatToParts', {
configurable: true,
get: GetFormatToPartsDateTime
});

function GetFormatDateTime() {
let internal = this !== null && typeof this === 'object' && getInternalProperties(this);

Expand Down Expand Up @@ -836,7 +831,7 @@ function GetFormatDateTime() {
return internal['[[boundFormat]]'];
}

function GetFormatToPartsDateTime() {
Intl.DateTimeFormat.prototype.formatToParts = function formatToParts() {
let internal = this !== null && typeof this === 'object' && getInternalProperties(this);

if (!internal || !internal['[[initializedDateTimeFormat]]'])
Expand All @@ -851,7 +846,7 @@ function GetFormatToPartsDateTime() {
internal['[[boundFormatToParts]]'] = bf;
}
return internal['[[boundFormatToParts]]'];
}
};

function CreateDateTimeParts(dateTimeFormat, x) {
// 1. If x is not a finite Number, then throw a RangeError exception.
Expand Down
8 changes: 6 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
const realDefineProp = (function () {
let sentinel = {};
try {
Object.defineProperty(sentinel, 'a', {});
return 'a' in sentinel;
Object.defineProperty(sentinel, 'a', {
get: function () {
return 1;
}
});
return sentinel.a === 1;
} catch (e) {
return false;
}
Expand Down

0 comments on commit 8b09c08

Please sign in to comment.