From 9c9417e531727e025c5b3ce873830f62679a3019 Mon Sep 17 00:00:00 2001 From: eemeli Date: Thu, 18 Jan 2024 16:23:43 +0000 Subject: [PATCH] fixup: [spec] `npm run build` --- index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 215388d..3f05c7e 100644 --- a/index.html +++ b/index.html @@ -2983,7 +2983,7 @@

Stage 1 Draft / January 16, 2024

Intl.MessageFormat

+

Stage 1 Draft / January 18, 2024

Intl.MessageFormat

1 MessageFormat Objects

@@ -3104,7 +3104,7 @@

1.3.4 Intl.MessageFormat.prototype.formatToParts values and onError, the following steps are taken:

-
  1. Let mf be the this value.
  2. Perform ? RequireInternalSlot(mf, [[InitializedMessageFormat]]).
  3. Let ctx be ? CreateMessageFormatContext(mf, values, onError).
  4. Let msg be ? ResolveMessage(ctx).
  5. Let result be a new empty List.
  6. For each element mv of msg, do
    1. If Type(el) is String, then
      1. Let textPart be OrdinaryObjectCreate(%Object.prototype%).
      2. Perform ! CreateDataPropertyOrThrow(textPart, "type", "text").
      3. Perform ! CreateDataPropertyOrThrow(textPart, "value", el).
      4. Append textPart to result.
    2. Else if Type(el) is Object and el has a [[MessageMarkup]] internal slot, then
      1. Let markup be ? FormatMarkupPart(ctx, el.[[MessageMarkup]]).
      2. Append markup to result
    3. Else,
      1. Assert: el has a [[MessageValue]] internal slot.
      2. Let mv be el.[[MessageValue]].
      3. Assert: Type(mv) is Object.
      4. Let toParts be ? Get(mv, "toParts").
      5. Let partResult be Completion(Call(toParts, mv)).
      6. If partResult is a normal completion, then
        1. Let parts be partResult.[[Value]].
        2. For each element part of parts, append part to result.
      7. Else,
        1. Perform ? HandleMessageFormatError(ctx, partResult).
        2. Let source be MessageValueSource(mv).
        3. Let fallbackPart be MessageFallbackPart(source).
        4. Append fallbackPart to result.
  7. Return CreateArrayFromList(result).
+
  1. Let mf be the this value.
  2. Perform ? RequireInternalSlot(mf, [[InitializedMessageFormat]]).
  3. Let ctx be ? CreateMessageFormatContext(mf, values, onError).
  4. Let msg be ? ResolveMessage(ctx).
  5. Let result be a new empty List.
  6. For each element mv of msg, do
    1. If Type(mv) is String, then
      1. Let textPart be OrdinaryObjectCreate(%Object.prototype%).
      2. Perform ! CreateDataPropertyOrThrow(textPart, "type", "text").
      3. Perform ! CreateDataPropertyOrThrow(textPart, "value", el).
      4. Append textPart to result.
    2. Else if Type(el) is Object and el has a [[MessageMarkup]] internal slot, then
      1. Let markup be ? FormatMarkupPart(ctx, el.[[MessageMarkup]]).
      2. Append markup to result
    3. Else,
      1. Assert: el has a [[MessageValue]] internal slot.
      2. Let mv be el.[[MessageValue]].
      3. Assert: Type(mv) is Object.
      4. Let toParts be ? Get(mv, "toParts").
      5. Let partResult be Completion(Call(toParts, mv)).
      6. If partResult is a normal completion, then
        1. Let parts be partResult.[[Value]].
        2. For each element part of parts, append part to result.
      7. Else,
        1. Perform ? HandleMessageFormatError(ctx, partResult).
        2. Let source be MessageValueSource(mv).
        3. Let fallbackPart be MessageFallbackPart(source).
        4. Append fallbackPart to result.
  7. Return CreateArrayFromList(result).
@@ -3295,13 +3295,13 @@

1.5.3.1 MessageFormatContext Records

1.5.4 ResolveMessage ( ctx )

The abstract operation ResolveMessage takes argument ctx (a MessageFormatContext Record) and returns a List of Strings and Objects. It resolves a message into a List of Strings and Objects with either [[MessageMarkup]] or [[MessageValue]] internal slots. It performs the following steps when called:

-
  1. Let result be an empty List.
  2. Let pattern be ? SelectPattern(ctx).
  3. For each element el of pattern,
    1. If Type(el) is String, then
      1. Append el to result.
    2. Else,
      1. Let elType be ? Get(el, "type").
      2. If elType is "markup", then
        1. Let res be OrdinaryObjectCreate(null, « [[MessageMarkup]] »).
        2. Set res.[[MessageMarkup]] to el.
      3. Else,
        1. Assert: elType is "expression".
        2. Let res be ResolveExpression(ctx, el).
      4. Append res to result.
  4. Return result.
+
  1. Let result be an empty List.
  2. Let pattern be ? SelectPattern(ctx).
  3. For each element el of pattern,
    1. If Type(el) is String, then
      1. Append el to result.
    2. Else,
      1. Assert: Type(el) is Object.
      2. Let elType be ? Get(el, "type").
      3. If elType is "markup", then
        1. Let res be OrdinaryObjectCreate(null, « [[MessageMarkup]] »).
        2. Set res.[[MessageMarkup]] to el.
      4. Else,
        1. Assert: elType is "expression".
        2. Let res be ResolveExpression(ctx, el).
      5. Append res to result.
  4. Return result.

1.5.4.1 SelectPattern ( ctx )

The abstract operation SelectPattern takes argument ctx (a MessageFormatContext Record) and returns a List of Strings and Objects with an internal slot [[MessageValue]]. It selects the pattern to format from the message data model. It performs the following steps when called:

-
  1. Let msgData be ctx.[[MessageFormat]].[[MessageData]].
  2. Let msgType be ? Get(msgData, "type").
  3. If msgType is "message", then
    1. Let pattern be ? Get(msgData, "pattern").
  4. Else,
    1. Assert: msgType is "select".
    2. Let selectorsData be ? Get(msgData, "selectors").
    3. Let selectorExpressions be ? CreateListFromArrayLike(selectorsData, « Object »).
    4. Let selectors be an empty List of Object and Null values.
    5. For each element selExp of selectorExpressions,
      1. Let sel be ResolveExpression(ctx, selExp).
      2. Let selectKey be ? Get(sel.[[MessageValue]], "selectKey").
      3. If IsCallable(selectKey) is true, then
        1. Append sel.[[MessageValue]] to selectors.
      4. Else,
        1. Let error be ThrowCompletion(TypeError).
        2. Perform ? HandleMessageFormatError(ctx, error).
        3. Append null to selectors.
    6. Let variantsArray be ? Get(msgData, "variants").
    7. Let variants be ? CreateListFromArrayLike(variantsArray, « Object »).
    8. Let selectedVariant be ? SelectVariant(ctx, selectors, variants).
  5. Return ? CreateListFromArrayLike(pattern, « String, Object »).
+
  1. Let msgData be ctx.[[MessageFormat]].[[MessageData]].
  2. Let msgType be ? Get(msgData, "type").
  3. If msgType is "message", then
    1. Let pattern be ? Get(msgData, "pattern").
  4. Else,
    1. Assert: msgType is "select".
    2. Let selectorsData be ? Get(msgData, "selectors").
    3. Let selectorExpressions be ? CreateListFromArrayLike(selectorsData, « Object »).
    4. Let selectors be an empty List.
    5. For each element selExp of selectorExpressions,
      1. Let sel be ResolveExpression(ctx, selExp).
      2. Let selectKey be ? Get(sel.[[MessageValue]], "selectKey").
      3. If IsCallable(selectKey) is true, then
        1. Append sel.[[MessageValue]] to selectors.
      4. Else,
        1. Let error be ThrowCompletion(TypeError).
        2. Perform ? HandleMessageFormatError(ctx, error).
        3. Append null to selectors.
    6. Let variantsArray be ? Get(msgData, "variants").
    7. Let variants be ? CreateListFromArrayLike(variantsArray, « Object »).
    8. Let selectedVariant be ? SelectVariant(ctx, selectors, variants).
  5. Return ? CreateListFromArrayLike(pattern, « String, Object »).