mint icon indicating copy to clipboard operation
mint copied to clipboard

`Window.prompt` should distinguish between empty Ok and Cancel

Open midnightmonster opened this issue 2 years ago • 0 comments

// JavaScript
const answer = window.prompt("What's your name?","");
const greeting = answer === null ? "How rude!" : answer ? `Hello, ${answer}!` : "I'll call you Darth";
alert(greeting);
// Mint
sequence {
  greeting = sequence {
    answer = Window.prompt("What's your name?","")
    if(answer == ""){
      "I'll call you Darth" // Never happens
    } else {
      "Hello, #{answer}!"
    }
  } catch String => reason {
    "How rude!"
  }
  Window.alert(greeting)
}

In JavaScript, if the User selects 'Ok' without entering anything, the alert is "I'll call you Darth". In Mint, that condition never happens.

midnightmonster avatar Apr 10 '22 19:04 midnightmonster