Page MenuHomePhabricator

MobileFrontend should use ES5 and discourage jQuery usage
Closed, ResolvedPublic

Description

Having global jQuery available is leading to patterns in our code that we'd like to avoid.

  • Use Function##bind instead of $.proxy
  • Use indexOf instead of inArray
  • Only allow $.ajax and $.Deferred() usage from inside Gateway classes
  • Encourage usage of View.prototype.$ instead of $ to avoid $ usage inside classes and side effects (T173539)
  • Views that interact with $( 'html,body' ) should be passed a $container parameter (option).
  • Use Object.assign (with polyfill) instead of $.extend
  • We will enforce this by removing jQuery from the default eslint config. Exceptions will need to temporarily enable the global and justify why in commit messages going forward

Details

Related Gerrit Patches:
mediawiki/extensions/MobileFrontend : masterUse Function.bind in favor of $.proxy inside components
mediawiki/extensions/MobileFrontend : masterAvoid global access of elements outside Views
mediawiki/extensions/MobileFrontend : masterHygiene: Drop usages of inArray

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 23 2017, 8:23 PM

Change 373364 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Hygiene: Drop usages of inArray

https://gerrit.wikimedia.org/r/373364

Change 373372 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Avoid global access of elements outside Views

https://gerrit.wikimedia.org/r/373372

Change 373364 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Hygiene: Drop usages of inArray

https://gerrit.wikimedia.org/r/373364

Change 373962 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Use Function.bind in favor of $.proxy

https://gerrit.wikimedia.org/r/373962

Jdlrobson moved this task from Inbox to Doing on the User-Jdlrobson board.Sep 29 2017, 1:24 PM

Change 373372 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Avoid global access of elements outside Views

https://gerrit.wikimedia.org/r/373372

Jdlrobson moved this task from Doing to Next up on the User-Jdlrobson board.Dec 7 2017, 10:09 PM

Change 373962 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Use Function.bind in favor of $.proxy inside components

https://gerrit.wikimedia.org/r/373962

Jdlrobson closed this task as Resolved.Mar 2 2018, 9:22 PM
Jdlrobson claimed this task.
Jdlrobson updated the task description. (Show Details)