Use lambda functions instead of .bind
Closed, ResolvedPublic

Description

Lambdas can be ported, .bind is hard to directly port.
Lambdas in newer node versions reduce the friction of using inline callbacks.

ssastry created this task.Sep 24 2018, 8:32 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 24 2018, 8:32 PM
ssastry triaged this task as Normal priority.Sep 24 2018, 8:32 PM
ssastry added a subscriber: cscott.Wed, Dec 5, 4:23 PM

@cscott's insight was right here because when I was trying to replace bind with lambda functions in DOMPostProcessor, I tripped with mysterious test failures till I realized that domVisitor variable was being reused a lot which works with .bind because the object is bound before being overwritten. But, with lambda functions, the overwriting means that all invocations get the last written value which is buggy. Without porting over to lambda functions, we might have tripped on this bug during the PHP port.

Change 477804 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] DOMPostProcessor: Replace .bind usage with lambda functions

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

Change 478112 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Eliminate most .bind(..) usages from wt2html token transformers

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

Change 478119 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Remove .bind() usages from lib/wt2html except TokenTransformManager

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

Change 478120 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Remove .bind() usages in lib/html2wt code

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

Change 478121 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Remove .bind() usages in lib/config files

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

Change 478122 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Remove .bind() usages in native extension code.

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

Change 478123 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Remove .bind() usages in all lib/* files except those skipped earlier

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

Change 478127 had a related patch set uploaded (by Subramanya Sastry; owner: Subramanya Sastry):
[mediawiki/services/parsoid@master] Remove .bind() usages from bin/, tools/, and tests/

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

Change 477804 merged by jenkins-bot:
[mediawiki/services/parsoid@master] DOMPostProcessor: Replace .bind usage with lambda functions

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

Change 478112 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Eliminate most .bind(..) usages from wt2html token transformers

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

Change 478119 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Remove .bind() usages from lib/wt2html except TokenTransformManager

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

Change 478120 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Remove .bind() usages in lib/html2wt code

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

Change 478121 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Remove .bind() usages in lib/config files

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

Change 478122 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Remove .bind() usages in native extension code.

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

Change 478123 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Remove .bind() usages in all lib/* files except those skipped earlier

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

Change 478127 merged by jenkins-bot:
[mediawiki/services/parsoid@master] Remove .bind() usages from bin/, tools/, and tests/

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

ssastry closed this task as Resolved.Sun, Dec 9, 8:17 PM
ssastry claimed this task.