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

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
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