- From: Marcos Cáceres <notifications@github.com>
- Date: Mon, 07 Nov 2016 01:43:10 -0800
- To: w3c/manifest <manifest@noreply.github.com>
- Message-ID: <w3c/manifest/pull/520/c258789304@github.com>
This is what the text is based on: ``` class BeforeInstallPromptEvent extends Event { constructor(typeArg, eventInit) { // WebIDL Guard. Not in spec, as it's all handled by WebIDL. if (arguments.length === 0) { throw new TypeError("Not enough arguments. Expected at least 1."); } const initType = typeof eventInit; if (arguments.length === 2 && initType !== "undefined" && initType !== "object") { throw new TypeError("Value can't be converted to a dictionary."); } super(typeArg, Object.assign({ cancelable: true }, eventInit)); if (eventInit && !hasValidUserChoice(eventInit)) { const msg = `The provided value '${eventInit.userChoice}' is not a valid` + " enum value of type AppBannerPromptOutcome."; throw new TypeError(msg); } // End WebIDL guard. let outcome = null; const internal = { didPrompt: false, }; internalSlots.set(this, internal); internal.userResponsePromise = new Promise((resolve, reject) => { const props = { "promptOutcome": { get() { return outcome; }, set: function(value) { if (outcome) { return; } outcome = value; resolve(createUserResponseObject(this)); }.bind(this), // 'this' is the BeforeInstallPromptEvent instance }, "rejectPromptPromise": { value(domException) { reject(domException); }, }, }; Object.defineProperties(internal, props); }); if (eventInit && eventInit.userChoice) { internal.promptOutcome = eventInit.userChoice; } } /** * prompt() method * * @return {[Promise]} The internal [[\userResponsePromise]] * @see https://www.w3.org/TR/appmanifest/#prompt-method */ async prompt() { const internal = internalSlots.get(this); if (internal.promptOutcome !== null) { return internal.userResponsePromise; } if (!this.isTrusted) { const msg = ".prompt() can only called by trusted events."; internal.rejectPromptPromise(new DOMException(msg, "NotAllowedError")); } else if (!internal.didPrompt) { await requestInstallPrompt(this); } return internal.userResponsePromise; } } ``` -- 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/pull/520#issuecomment-258789304
Received on Monday, 7 November 2016 09:43:42 UTC