Page MenuHomePhabricator

Consistently trim spaces when building the sort keys
Closed, ResolvedPublic

Description

Follow-up to T326081 and T326474.

Trim spaces from the output of getElementSortKey(). This way we don't have to take care of it afterwards, and the handlers consistently receive a trimmed value:

  • is() handlers: they were already receiving trimmed values. The number parser was just applying a redundant trim.
  • format() handlers: they were receiving non-trimmed values. Some handlers (namely text and date) were applying a trim afterwards, the others were not.

Event Timeline

Change 876352 had a related patch set uploaded (by Gerrit Patch Uploader; author: Hank Hulet):

[mediawiki/core@master] Consistently trim spaces when building the sort keys

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

Change 876352 merged by jenkins-bot:

[mediawiki/core@master] jquery.tablesorter: Consistently trim spaces when building the sort keys

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

As a reminder, this comment (Gerrit doesn't send me email notifications).

Change 878015 had a related patch set uploaded (by Gerrit Patch Uploader; author: Hank Hulet):

[mediawiki/core@master] jquery.tablesorter: Normalize spaces in all cases when retrieving the sort keys

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

I'm thinking of a better approach, maybe it would be better to use a dedicated inner function for nested processing, rather than reusing the root getElementSortKey().

Uploaded patchset 3, that uses an inner function. I think it's definitely a better approach.

Uploaded patchset 4, which takes advantage of the fact that the root getElementSortKey() is executed only on cell elements (i.e. not on <img> tags etc.). It consolidates the code, which was needlessly split, and saves redundant executions of .nodeName.toLowerCase() (from 1 to 0 execution on the root node, and from 2 to 1 execution on (almost) every child node).

Update: Uploaded patchset 5, because ESLint forced me to avoid variable shadowing (it was also affecting patchset 3). Fortunately I managed to figure out a better name.

(Gerrit doesn't send me email notifications).

You should be able to register an account at https://wikitech.wikimedia.org and use it to log into Gerrit, which will let you comment on patches and get notifications, even if you can't or don't want to use Git to submit the patches themselves. (The current patch is failing unit tests.)

Change 878015 merged by jenkins-bot:

[mediawiki/core@master] jquery.tablesorter: Normalize spaces in all cases when retrieving the sort keys

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