Re: [w3c/payment-request] Dont block UI if .updateWith() not called (closes #589) (#591)

@zkoch, tldr:

 1. Don't block the payment sheet if the developer doesn't call `.updateWith()`. 
 1. Don't allow developers to keep recycling the event (e.g., keep a reference to a shipping change event, and then use it to update the the payment sheet when an option change event happens - see code below).  

===

Note to self, add this test: 
```
var methods = [{ supportedMethods: ["basic-card"] }];
var details = {
  total: { label: "", amount: { currency: "USD", value: "1" } },
};
var shippingOptions = [
  {
    id: "standard",
    label: "🚛 Ground Shipping (2 days)",
    amount: { currency: "USD", value: "5.00" },
    selected: true,
  },
  {
    id: "drone",
    label: "🚀 Drone Express (2 hours)",
    amount: { currency: "USD", value: "25.00" },
  },
];
details.shippingOptions = shippingOptions;
var r = new PaymentRequest(methods, details, { requestShipping: true });
r.addEventListener(
  "shippingaddresschange",
  e => {
    ev = e;
    ev.updateWith(details);
    var listener = ev2 => {
      var newDetails = { ...details };
      newDetails.total.label = "FAIL" + Math.random();
      ev.updateWith(newDetails);
    };
    r.addEventListener("shippingoptionchange", listener);
    r.addEventListener("shippingaddresschange", listener);
  },
  { once: true }
);
r.show();
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/payment-request/pull/591#issuecomment-325078077

Received on Saturday, 26 August 2017 03:05:04 UTC