Closed Bug 1410785 Opened 7 years ago Closed 7 years ago

event.preventDefault() with undefined event throws the rest of the code

Categories

(Core :: DOM: Events, enhancement, P3)

58 Branch
enhancement

Tracking

()

RESOLVED DUPLICATE of bug 218415
Tracking Status
firefox58 --- affected

People

(Reporter: karlcow, Unassigned)

References

Details

(Whiteboard: [webcompat])

This is a spin off for 
* https://webcompat.com/issues/12708
* https://webcompat.com/issues/12619

These sites have this pattern

function Blah() {
   someJSCode;
   event.preventDefault(); 
   someOtherJSCode 
}

Firefox throws a ReferenceError because indeed the event is not defined, but seems to not execute the rest of the code after (aka someOtherJSCode ).

On Blink and WebKit, the rest of the code is executed. 

I'm not sure we need to solve it. Or if we need to encourage WebKit and Blink teams to fix it. Both options are available.
Flags: webcompat?
Hi Karl, in addition to the browser behaviour alignment, have we considered to reach out to the websites to correct their pages as their code is just wrong?

I doubt DOM:Event is the right module for this as it has nothing to do with "event" itself but the general behaviour when an undefined object is referenced. Javascript engine is a better one, I think ... please correct me if I am wrong.
Component: DOM: Events → JavaScript Engine
Flags: needinfo?(kdubost)
This looks like https://developer.mozilla.org/en-US/docs/Web/API/Window/event which is non-standard and not supported in Firefox. So this bug belongs into some DOM component, but certainly not into JavaScript Engine.
(In reply to André Bargull [:anba] from comment #2)
> This looks like
> https://developer.mozilla.org/en-US/docs/Web/API/Window/event which is
> non-standard and not supported in Firefox. So this bug belongs into some DOM
> component, but certainly not into JavaScript Engine.
Right, thanks for pointing that out, I did miss that. :)
Component: JavaScript Engine → DOM: Events
I am not sure if we'd consider to fix this if this is non-standard ...
Flags: needinfo?(bugs)
Priority: -- → P3
Mike might know the current status of specing window.event. Last time I looked at, it was still unclear how it would work with shadow DOM.
Flags: needinfo?(bugs) → needinfo?(miket)
Thanks. I'm working on this this week. The shadow DOM issues should be settled by https://github.com/whatwg/dom/commit/9ada239e14fe7964577276ef9d8972069e665247 (which is what Anne and I had discussed in SF... I've just been slow).

But, this is effectively a dupe of Bug 218415.

(In reply to Hsin-Yi Tsai [:hsinyi] from comment #4)
> I am not sure if we'd consider to fix this if this is non-standard ...

Once the DOM PR and wpt are merged in we should implement it to solve a whole bunch of compat issues.
Status: NEW → RESOLVED
Closed: 7 years ago
Flags: needinfo?(miket)
Flags: needinfo?(kdubost)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.