-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should field properties be enumerable? #403
Comments
I would be inclined to match https://tc39.es/ecma262/#sec-ecmascript-standard-built-in-objects. |
That section says that built-in data properties are not enumerable "unless otherwise specified", but I'm suggesting that we do specify otherwise because instances of the Temporal types are basically Just like the index properties of strings and arrays are enumerable, so too should be the properties of Temporal type instances that hold their structured data. |
About matching existing conventions, these feel pretty similar to RegExp properties like |
If we go in the direction of considering objects with well-known property names to be equivalent to Temporal objects, should we go so far as to remove some of the checks that we have in the spec for the [[InitializedTemporalX]] slot? e.g. allow things like |
Note that this will not work even if we make the fields enumerable; |
I don't know if it's fair to say that they must be on the prototype, but that is nonetheless a good point. The above becomes much less compelling when we need to add in Object/Reflect static methods. :\ |
This would seem to be a good argument in favour of adding a Duration.with method; because |
Meeting, Mar. 5: The intention is to make the core properties enumerable, and allow calendars to add additional enumerable properties such as |
Are these own data properties? I'd expect them to be accessors on the prototype, which would make their enumerability irrelevant for most use cases (object spread, Object.assign, Object.keys/entries/values, etc). |
We did discuss that they would need to be own properties in order to be enumerable, but that deviates from an existing ES convention which is why we wanted input from the plenary on this. |
They can be enumerable without being own, but they have to be both to be included in assign/spread. Is this on the agenda yet? |
I believe @pipobscure already put it on the agenda. |
Does this still need plenary input? |
I think so, yes. |
it'd be great to have the notes landed so they can be easily referenced by the plenary, cc @ryzokuken |
Note extracted from #487: The Japanese calendar might choose to make |
A possibility raised by a few different parties in plenary is to have a method for returning plain snapshots of the fields, e.g. |
Meeting, Apr 2: Consensus is that the properties should not be own properties. Instead we will add a getFields() method, which returns a new plain JavaScript object, with all the fields as enumerable, writable, own data properties. The code snippet from the OP would become: Object.assign({}, Duration.from("PT42S").getFields()).seconds === 42 |
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
getFields() is how to get an object with enumerable own data properties. Closes: #403
It would be nice to have e.g.
Object.assign({}, Duration.from("PT42S")).seconds === 42
.The text was updated successfully, but these errors were encountered: