Skip to content

Using alert, prompt or confirm in an inlined event handler gives warning #2648

@EmilTholin

Description

@EmilTholin

Using alert, prompt or confirm in an inlined event handler gives a warning like 'alert' is not defined. Consider adding a <script> block with 'export let alert' to declare a prop. REPL

<script>
  let isConfirmed = false;
  let promptValue = '';
</script>

<button on:click="{() => alert('foo')}">Click me</button>
<div>
  <button on:click="{() => promptValue = prompt()}">Prompt me</button>
  {promptValue}
</div>
<div>
  <button on:click="{() => isConfirmed = confirm()}">Confirm</button>
  {isConfirmed}
</div>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions