Skip to content

beforeunload return value is not respected #47579

@datbth

Description

@datbth

Which @angular/* package(s) are the source of the bug?

zone.js

Is this a regression?

No

Description

When zone.js is not loaded, returning a value in beforeunload event handler causes the browser to ask for confirmation: https://jsfiddle.net/datbth/b57ur4ky/45/

When zone.js is loaded, returning a value in beforeunload event handler does nothing: https://jsfiddle.net/datbth/b57ur4ky/44/

Reproduction steps:

  1. Visit the jsfiddle link
  2. Click Bind Event
  3. Click Reload
  4. Expected result: browser asking for confirmation
    image

Please provide a link to a minimal reproduction of the bug

https://jsfiddle.net/datbth/b57ur4ky/44/

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Chrome Version 105.0.5195.125 (Official Build) (64-bit)  
Ubuntu 22.04.1 LTS
Zone.js 0.11.8

Anything else?

I know that practically almost all browsers are supporting preventDefault and returnValue to negate the unload (ref). But my bigger concern is about how zone.js is handling the return values of event handlers and whether it breaks other events as well.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: zonesIssues related to zone.jsstate: has PR

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions