Last modified: 2014-09-13 08:38:31 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T69738, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 67738 - MarkAsHelpful: Don't use global delegate event handlers
MarkAsHelpful: Don't use global delegate event handlers
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
MarkAsHelpful (Other open bugs)
unspecified
All All
: Lowest normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: performance
Depends on:
Blocks: code_quality
  Show dependency treegraph
 
Reported: 2014-07-09 17:35 UTC by Krinkle
Modified: 2014-09-13 08:38 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Krinkle 2014-07-09 17:35:05 UTC
Follows-up bug 67356.

The usage of live() was mitigated by using a global delegate selector (which is what "live()" did internally). That'll keep it working, but really it shouldn't be using that in the first place.

jQuery.live was deprecated because it masked the fact that it added a global event handler and matched every node from a user event against a css selector.

By being forced to use $(document).on('click', selector, fn) it emphasises that this is a global listener and is intended to encourage you to instead re-evaluate what this code is doing.

It should probably be listening on a common parent much lower down the tree than the document root.

I suspect that maybe this doesn't even have to be a delegate handler at all. It seems MarkAsHelpful does make assumptions about the matched node (it calls .parent().parent()).

If MarkAshelpful really does add new links asynchronously after document ready,, it should listen on a common ancestor instead.

If it doesn't and the live() was just an overambitious oversight, then it can be swapped for a regular query with on('click', fn).
Comment 1 Andre Klapper 2014-07-14 10:10:43 UTC
[Setting lowest priority as this extension isn't deployed anymore according to bug 67772 comment 1]

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links