Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit 8b09c08

Browse files
authored
Merge pull request #183 from andyearnshaw/define-properties
fixes #182: improving Object.defineProperty() detection mechanism
2 parents bdd9c9c + 9ba894c commit 8b09c08

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/12.datetimeformat.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,6 @@ defineProperty(Intl.DateTimeFormat, 'supportedLocalesOf', {
789789
get: GetFormatDateTime
790790
});
791791

792-
defineProperty(Intl.DateTimeFormat.prototype, 'formatToParts', {
793-
configurable: true,
794-
get: GetFormatToPartsDateTime
795-
});
796-
797792
function GetFormatDateTime() {
798793
let internal = this !== null && typeof this === 'object' && getInternalProperties(this);
799794

@@ -836,7 +831,7 @@ function GetFormatDateTime() {
836831
return internal['[[boundFormat]]'];
837832
}
838833

839-
function GetFormatToPartsDateTime() {
834+
Intl.DateTimeFormat.prototype.formatToParts = function formatToParts() {
840835
let internal = this !== null && typeof this === 'object' && getInternalProperties(this);
841836

842837
if (!internal || !internal['[[initializedDateTimeFormat]]'])
@@ -851,7 +846,7 @@ function GetFormatToPartsDateTime() {
851846
internal['[[boundFormatToParts]]'] = bf;
852847
}
853848
return internal['[[boundFormatToParts]]'];
854-
}
849+
};
855850

856851
function CreateDateTimeParts(dateTimeFormat, x) {
857852
// 1. If x is not a finite Number, then throw a RangeError exception.

src/util.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
const realDefineProp = (function () {
22
let sentinel = {};
33
try {
4-
Object.defineProperty(sentinel, 'a', {});
5-
return 'a' in sentinel;
4+
Object.defineProperty(sentinel, 'a', {
5+
get: function () {
6+
return 1;
7+
}
8+
});
9+
return sentinel.a === 1;
610
} catch (e) {
711
return false;
812
}

0 commit comments

Comments
 (0)