Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/229668
Change subject: Element: DWIM when repeatedly infusing the same node
......................................................................
Element: DWIM when repeatedly infusing the same node
Infusing a node causes it to be removed from the DOM and replaced with
the infused widget's node. If anyone is holding a reference to it when
this happens, they're left with a useless unattached node, that can
confusingly be infused again, generating a new Widget every time,
similarly unattached and useless.
Let's do something smart and intuitive and return the original infused
widget when a previously-infused node is infused again. We already
have code to handle no-op OO.ui.infuse() on infused widgets' nodes,
so this is a one-line change.
Bug: T105828
Change-Id: I11fd1c7f2434f904b9ddc94b0903f8278e06f3a1
---
M src/Element.js
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/68/229668/1
diff --git a/src/Element.js b/src/Element.js
index f1f45d3..49a91d6 100644
--- a/src/Element.js
+++ b/src/Element.js
@@ -200,6 +200,9 @@
// now replace old DOM with this new DOM.
if ( top ) {
$elem.replaceWith( obj.$element );
+ // This element is now gone from the DOM, but if anyone is
holding a reference to it,
+ // let's allow them to OO.ui.infuse() it and do what they
expect (T105828)
+ $elem.data( 'ooui-infused', obj );
}
obj.$element.data( 'ooui-infused', obj );
// set the 'data-ooui' attribute so we can identify infused widgets
--
To view, visit https://gerrit.wikimedia.org/r/229668
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I11fd1c7f2434f904b9ddc94b0903f8278e06f3a1
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits