Closed Bug 1400659 Opened 8 years ago Closed 8 years ago

Correction to the description of Event.preventDefault()

Categories

(Developer Documentation Graveyard :: General, enhancement, P5)

All
Other
enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: regspam, Unassigned)

References

()

Details

:: Developer Documentation Request Request Type: Correction Gecko Version: unspecified Technical Contact: :: Details 1. The article starts with "The Event interface's preventDefault() method tells the user agent that if the event goes unhandled, its default action should not be taken as it normally would be", which should perhaps be changed to just "The Event interface's preventDefault() method tells the user agent that the event's default action should not be taken", as it's (not) taken regardless of whether the event is handled or not. 2. The article continues with "The event continues to propagate as usual with only the exception that the event does nothing if no event listeners call stopPropagation(), which terminates propagation at once". This should perhaps be reduced to "The event continues to propagate as usual", as stopPropagation() doesn't prevent the default action from being taken. An example illustrating the idea of part 2: <meta charset="utf-8"> <span id="sp" style="border: solid 1px red">click<input type="checkbox" id="in"></span> <script> document.getElementById("sp").addEventListener("click", function(e) { console.log("<span> (capturing phase)"); e.stopPropagation(); }, true); document.getElementById("in").addEventListener("click", function(e) { console.log("<input> reached"); }, true); </script> If you click the checkbox, the console output will be "<span> (capturing phase)". The event propagation stops, <input> isn't reached, but the default action is still taken - the checkbox gets checked. I experimented with capturing/bubbling phases and it seems stopPropagation() does not in any way affect the default action being taken.
Yep. You're right. Most of these changes were made by someone else already; I've made some adjustments to them and this should now be resolved.
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.