https://bugzilla.wikimedia.org/show_bug.cgi?id=67738

            Bug ID: 67738
           Summary: MarkAsHelpful: Don't use global delegate event
                    handlers
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: ASSIGNED
          Keywords: performance
          Severity: normal
          Priority: Unprioritized
         Component: MarkAsHelpful
          Assignee: [email protected]
          Reporter: [email protected]
            Blocks: 700
       Web browser: ---
   Mobile Platform: ---

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).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to