Page MenuHomePhabricator

Allow explicit naming of constructors in OO.Factory
Closed, ResolvedPublic

Description

oo.Factory.prototype.register( constructor ) requires the function given in constructor to have a "static" name property. I see no real necessity for this restriction. Instead an optional name parameter should be added to register which will be used instead of the static name if provided.

Without this the oo.Factory "class" can be quite useless when we want to register it with 3rd party constructors not following oojs conventions or if we have two factories where we want to register the same constructor for different purposes under different names.

See also:

Event Timeline

Danwe raised the priority of this task from to Needs Triage.
Danwe updated the task description. (Show Details)
Danwe added a project: OOjs core.
Danwe subscribed.
Krinkle triaged this task as Medium priority.May 8 2017, 12:40 AM
Krinkle renamed this task from oo.Factory: static name requirement seems unnecessary and inflexible to Allow explicit naming of constructors in OO.Factory.Apr 5 2019, 5:34 PM
Krinkle claimed this task.
Krinkle moved this task from Accepted Enhancement to Done on the OOjs core board.

Change 501647 had a related patch set uploaded (by Krinkle; owner: Krinkle):
[oojs/core@master] Factory: Support registration by name

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

Krinkle lowered the priority of this task from Medium to Low.Apr 6 2019, 11:39 PM

Change 501647 merged by jenkins-bot:
[oojs/core@master] Factory: Support registration by name

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

Krinkle edited projects, added Performance-Team; removed Patch-For-Review.