Page MenuHomePhabricator

Throw error if OO.ui.Element.static.unsafeInfuse is called on more than one node
Closed, ResolvedPublic

Description

The public methods OO.ui.infuse and OO.ui.Element.static.infuse call the private method OO.ui.Element.static.unsafeInfuse. These methods accept an HTMLElement or a jQuery collection. Their documentation implies that the jQuery collection should only contain one node, but this is not actually enforced.

If a jQuery collection containing more than one node is passed, the data from the first node will be used to silently overwrite any subsequent nodes. Instead, an error should be thrown.

Event Timeline

Most callers do only pass one node, so this should be safe to do: https://codesearch.wmcloud.org/deployed/?q=.infuse%5C(&i=nope&files=&repos=

A counter-example (and the reason this issue was noticed) is cloner.js: T270961

Change 652609 had a related patch set uploaded (by Tchanders; owner: Tchanders):
[oojs/ui@master] Throw error if OO.ui.infuse called on more than one node

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

Change 652609 merged by jenkins-bot:
[oojs/ui@master] Throw error if OO.ui.infuse called on more than one node

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

Change 658692 had a related patch set uploaded (by Jforrester; owner: Jforrester):
[mediawiki/core@master] Update OOUI to v0.41.1

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

Change 658692 merged by jenkins-bot:
[mediawiki/core@master] Update OOUI to v0.41.1

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

Volker_E triaged this task as Medium priority.Mar 14 2021, 7:37 PM
Volker_E moved this task from Backlog to OOUI-0.41.1 on the OOUI board.
Volker_E edited projects, added OOUI (OOUI-0.41.1); removed OOUI.