Re: [w3c/manifest] Add installation prompt control flow (#417)

@dominickng, `prompt()` now basically looks like this:

```JS
  prompt() {
    let error = null;

    if (internalSlots.get(this).didPrompt) {
      const msg = ".prompt() can only be called once.";
      error = new DOMException(msg, "InvalidStateError");
    } else if (this.isTrusted === false) {
      const msg = "Untrusted events can't call prompt().";
      error = new DOMException(msg, "NotAllowedError");
    } else if (this.defaultPrevented === false) {
      const msg = ".prompt() needs to be called after .preventDefault()";
      error = new DOMException(msg, "InvalidStateError");
    } else {
      internalSlots.get(this).didPrompt = true;
    }

    if (error) {
      internalSlots.get(this).userChoiceHandlers.reject(error);
      throw error;
    }
    // Show the prompt... 
 }
```



-- 
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/manifest/issues/417#issuecomment-255005986

Received on Thursday, 20 October 2016 04:26:25 UTC