diff --git a/index.html b/index.html index cd956de2..3ba2069b 100644 --- a/index.html +++ b/index.html @@ -1631,8 +1631,12 @@

The updateWith method MUST act as follows:

    -
  1. Let target be the PaymentRequest object that - is the target of the event. +
  2. Let target be the value of this + PaymentRequestUpdateEvent event's target + attribute. +
  3. +
  4. If target is not a PaymentRequest + object, then throw a TypeError.
  5. If the dispatch flag is unset, then throw an InvalidStateError. @@ -1657,30 +1661,33 @@

    allows the user to accept the payment request. This is to ensure that the payment is not accepted until the web page has made changes required by the change. The web page MUST settle the - promise d to indicate that the payment request is - valid again. + promise d to indicate that the payment request is valid + again.

    The user agent SHOULD disable any part of the user interface that could cause another update event to be fired. Only one update may be processed at a time.

  6. -
  7. Return from the method and perform the remaining steps in - parallel. -
  8. -
  9. Wait until d settles. -
    - If d never settles then the payment request is - blocked. Users should always be able to cancel a payment - request. Implementations may choose to implement a timeout for - pending updates if d doesn't settle in a +
  10. +

    + Return from the method and perform the remaining steps in + parallel. +

    +

    + The remaining steps are conditional on the promise d + settling. If d never settles then the payment + request is blocked. Users should always be able to cancel a + payment request. Implementations may choose to implement a + timeout for pending updates if d doesn't settle in a reasonable amount of time. If an implementation chooses to - implement a timeout, d should be rejected when the - timeout expires. Such a timeout is a fatal error for the - payment request. - + implement a timeout, they must execute the steps listed below + in the "upon rejection" path. Such a timeout is a fatal error + for the payment request. +

  11. -
  12. If d is rejected, then: +
  13. + Upon rejection of d:
    1. Abort the current user interaction and close down any remaining user interface. @@ -1692,115 +1699,181 @@

      target.[[\acceptPromise]] with an AbortError.

    2. -
    3. Abort this algorithm. -
    - If the promise d is rejected then this is a fatal + If the promise d is rejected then this is a fatal error for the payment request. This would potentially leave the payment request in an inconsistent state since the web page hasn't successfully handled the change event. Consequently, if - d is rejected then the payment request is aborted. + d is rejected then the payment request is aborted.

    User agents might show an error message to the user when this occurs.

  14. -
  15. If d is resolved with details and - details is a PaymentDetails dictionary, then: +
  16. + Upon fulfillment of d with value + value:
      -
    1. If details contains a total value - and total.amount.value is a valid decimal - monetary value and the first character of - total.amount.value is NOT U+002D HYPHEN-MINUS, - then copy total value to the total - field of target.[[\details]] - (total MUST be a non-negative amount). +
    2. Let details be the result of converting + value to a PaymentDetails dictionary. If this + throws an exception, abort these substeps, and optionally show + an error message to the user.
    3. -
    4. If details contains a - displayItems value and every PaymentItem in - the displayItems has an amount.value - containing a valid decimal monetary value, then copy - details.displayItems to the - displayItems field of - target.[[\details]]. -
    5. -
    6. If details contains a modifiers - value, then: +
    7. If the total member + of details is present, then:
        -
      1. Let modifiers be the sequence - details.modifiers. +
      2. Let value be + details.total.amount.value.
      3. -
      4. For each PaymentDetailsModifier in - modifiers, if the total field is - supplied and is not a valid decimal monetary value, - then set modifiers to an empty sequence. +
      5. If value is a valid decimal monetary + value and the first character of value is + not U+002D HYPHEN-MINUS, then copy + details.total to the total field of + target.[[\details]]. (Negative total + amounts are ignored.)
      6. -
      7. For each PaymentDetailsModifier in - modifiers, if the - additionalDisplayItems sequence contains any - PaymentItem objects with an amount that - is not a valid decimal monetary value, then set - modifiers to an empty sequence. -
      8. -
      9. Copy modifiers to the modifiers +
      +
    8. +
    9. If the displayItems member of + details is present, then: +
        +
      1. If every PaymentItem in + details.displayItems has an + amount.value containing a + valid decimal monetary value, then copy + details.displayItems to the + displayItems field of target.[[\details]].
    10. -
    11. If details contains a - shippingOptions sequence, then: +
    12. If the modifiers + member of details is present, then:
        -
      1. Let shippingOptions be the sequence - details.shippingOptions. +
      2. Let modifiers be the sequence + details.modifiers. +
      3. +
      4. For each PaymentDetailsModifier + modifier in modifiers: +
          +
        1. If the total member of + modifier is present and + member.total.amount.value is not a + valid decimal monetary value, then set + modifiers to an empty sequence, and jump to + the step labeled copy modifiers below. +
        2. +
        3. If the additionalDisplayItems + member of modifier is present, then for each + PaymentItem item in + modifier.additionalDisplayItems: +
            +
          1. Let amountValue be + item.amount.value. +
          2. +
          3. If amountValue is not a valid + decimal monetary value, then set + modifiers to an empty sequence, and jump + to the step labeled copy modifiers below. +
          4. +
          +
        4. +
      5. -
      6. If the shippingOptions sequence contains - multiple PaymentShippingOption objects that have the - same id, then set shippingOptions - to the empty sequence. +
      7. + Copy modifiers: Copy modifiers to the + modifiers field + of target.[[\details]].
      8. -
      9. If the shippingOptions sequence contains a - PaymentShippingOption that has an - amount.value that is not a valid decimal - monetary value, then set shippingOptions to - the empty sequence. +
      +
    13. +
    14. If the shippingOptions member of + details is present, and + target.[[\options]].requestShipping is true, + then: +
        +
      1. Let options be + details.shippingOptions.
      2. -
      3. Copy shippingOptions to the - shippingOptions field of - target.[[\details]]. +
      4. Let seenIDs be an empty list.
      5. -
      6. Let newOption be null. +
      7. For each option in options: +
          +
        1. If option.amount.value is not a + valid decimal monetary value, then set + options to the empty sequence and break. +
        2. +
        3. If seenIDs contains + option.id, then set + options to an empty sequence and break. +
        4. +
        5. Append option.id to + seenIDs. +
        6. +
      8. -
      9. If target.[[\details]] contains a - shippingOptions sequence and if any - PaymentShippingOption in the sequence has the - selected field set to true, then set - newOption to the id of the last - PaymentShippingOption in the sequence with - selected set to true. +
      10. For each option in options (which + may have been reset to the empty sequence in the previous + step): +
          +
        1. If option.selected is true, + then set selectedShippingOption to + option.id. +
        2. +
      11. -
      12. Set the value of shippingOption on - target to newOption. +
      13. Copy options to the shippingOptions field + of target.[[\details]].
    15. -
    16. If details contains an error - value, then the user agent should update the user - interface to display the error message contained in - error. +
    17. If the error member + of details is present, then the user agent + should update the user interface to display the error message + contained in error.
  17. -
  18. Set [[\waitForUpdate]] to false. -
  19. -
  20. Set target.[[\updating]] to false. -
  21. -
  22. The user agent should update the user interface based on - any changed values in target. The user agent SHOULD - re-enable user interface elements that might have been disabled in - the steps above if appropriate. +
  23. In either case, run the following steps, after either the upon + rejection or upon fulfillment steps have concluded: +
      +
    1. Set [[\waitForUpdate]] to false. +
    2. +
    3. Set target.[[\updating]] to false. +
    4. +
    5. The user agent should update the user interface + based on any changed values in target. The user + agent SHOULD re-enable user interface elements that might have + been disabled in the steps above if appropriate. +
    6. +
@@ -2107,6 +2180,13 @@

object using JSON.parse with no loss of data.

+
+ Writing Promise-Using Specifications +
+
+ The terms upon fulfillment and upon rejection + are defined by [[!PROMISES-GUIDE]]. +
DOM4
@@ -2162,7 +2242,7 @@

- WebIDL + Web IDL
When this specification says to throw an error, the @@ -2174,6 +2254,10 @@

The term extended attribute is defined by [[!WEBIDL-2]].

+

+ The algorithm for converting an ECMAScript value to a + dictionary is defined by [[!WEBIDL-2]]. +

Secure Contexts