OOjs UI: Fix #gatherPreInfuseState called incorrectly, causing TypeErrors
authorThiemo Mättig <thiemo.maettig@wikimedia.de>
Thu, 25 Feb 2016 13:34:01 +0000 (14:34 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 25 Feb 2016 15:15:55 +0000 (15:15 +0000)
This bug is currently live. Try opening
https://www.wikidata.org/wiki/Special:NewItem
and have a look at the JavaScript console.

Introduced in If07d40a.

This patch is a manual cherry-pick from I748a4bc, which is the same
fix in the original repository. I feel we should backport this to
production.

Bug: T106313
Bug: T128075
Change-Id: I25a5deab2c287e97086726d0acbb3afeee842e0b

resources/lib/oojs-ui/oojs-ui-core.js

index e244037..67d3c02 100644 (file)
@@ -610,13 +610,13 @@ OO.ui.Element.static.unsafeInfuse = function ( idOrNode, domPromise ) {
                }
                if ( domPromise ) {
                        // pick up dynamic state, like focus, value of form inputs, scroll position, etc.
-                       state = data.gatherPreInfuseState( $elem );
+                       state = data.constructor.static.gatherPreInfuseState( $elem, data );
                        // restore dynamic state after the new element is re-inserted into DOM under infused parent
                        domPromise.done( data.restorePreInfuseState.bind( data, state ) );
                        infusedChildren = $elem.data( 'ooui-infused-children' );
                        if ( infusedChildren && infusedChildren.length ) {
                                infusedChildren.forEach( function ( data ) {
-                                       var state = data.gatherPreInfuseState( $elem );
+                                       var state = data.constructor.static.gatherPreInfuseState( $elem, data );
                                        domPromise.done( data.restorePreInfuseState.bind( data, state ) );
                                } );
                        }