Skip to content

Options object consumption is observably different in internal branches #2855

@gibson042

Description

@gibson042

I haven't checked how recent or how widespread this is, but the current spec text exposes internal branching by how it consumes an options object in at least Temporal.PlainDate.from, Temporal.PlainDateTime.from, Temporal.PlainYearMonth.from, Temporal.PlainMonthDay.from, and Temporal.ZonedDateTime.from, e.g.

const zdtString = "2024-05-21T12:00[America/New_York]";
const makeSpy = () => new Proxy({ log: [] }, {
  ownKeys: obj => obj.log.push("[[OwnPropertyKeys]]") && ["disambiguation", "offset", "overflow", "log"].reverse(),
  getOwnPropertyDescriptor: (obj, key) => obj.log.push(`[[GetOwnProperty]] ${key}`) &&
    { value: undefined, writable: true, enumerable: true, configurable: true },
  get: (obj, key) => obj.log.push(`[[Get]] ${key}`) && obj[key],
});
const spy1 = makeSpy(), spy2 = makeSpy();
Temporal.ZonedDateTime.from(Temporal.ZonedDateTime.from(zdtString), spy1);
Temporal.ZonedDateTime.from(zdtString, spy2);

spy1.log.slice(0, -1);
/* => [
  '[[Get]] disambiguation',
  '[[Get]] offset',
  '[[Get]] overflow',
] */

spy2.log.slice(0, -1);
/* => [
  '[[OwnPropertyKeys]]',
  '[[GetOwnProperty]] log',
  '[[Get]] log',
  '[[GetOwnProperty]] overflow',
  '[[Get]] overflow',
  '[[GetOwnProperty]] offset',
  '[[Get]] offset',
  '[[GetOwnProperty]] disambiguation',
  '[[Get]] disambiguation',
] */

All of these functions should SnapshotOwnProperties up front, passing down an unobservable clone to later steps and deeper operations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    behaviorRelating to behavior defined in the proposalbugnormativeWould be a normative change to the proposalspec-textSpecification text involved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions