Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/222466
Change subject: Escape initialization if no flow-board exists in the page ...................................................................... Escape initialization if no flow-board exists in the page This is true primarily for history pages where the flow-component exists and is initialized, but flow-board doesn't exist. Make sure that if the board doesn't exist, we escape from the initialization process gracefully. Change-Id: I90b7cd01efac1396e71beec221486dfb6ff35282 --- M modules/flow-initialize.js 1 file changed, 13 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/66/222466/1 diff --git a/modules/flow-initialize.js b/modules/flow-initialize.js index 9d87aa1..0a141ee 100644 --- a/modules/flow-initialize.js +++ b/modules/flow-initialize.js @@ -10,7 +10,8 @@ */ $( document ).ready( function () { var dataBlob, navWidget, flowBoard, dmBoard, - $component = $( '.flow-component' ); + $component = $( '.flow-component' ), + $board = $( '.flow-board' ); // HACK: If there is no component, we are not on a flow // board at all, and there's no need to load anything. @@ -22,7 +23,15 @@ } mw.flow.initComponent( $component ); - flowBoard = mw.flow.getPrototypeMethod( 'component', 'getInstanceByElement' )( $( '.flow-board' ) ); + + // HACK: Similarly to the above hack, if there is no board + // we shouldn't proceed. This is true mainly to history pages + // that have the component but not the board DOM element. + if ( $board.length === 0 ) { + return; + } + + flowBoard = mw.flow.getPrototypeMethod( 'component', 'getInstanceByElement' )( $board ); // Load data model mw.flow.system = new mw.flow.dm.System( { @@ -30,7 +39,7 @@ tocPostsLimit: 50, renderedTopics: $( '.flow-topic' ).length, boardId: $component.data( 'flow-id' ), - defaultSort: $( '.flow-board' ).data( 'flow-sortby' ) + defaultSort: $board.data( 'flow-sortby' ) } ); dmBoard = mw.flow.system.getBoard(); @@ -101,7 +110,7 @@ setTimeout( function () { // Reinitialize the whole board with these nodes // flowBoard.reinitializeContainer( $rendered ); - $( '.flow-board' ).empty().append( $rendered[ 1 ] ); + $board.empty().append( $rendered[ 1 ] ); // Since we've replaced the entire board, we need to reinitialize // it. This also takes away the original navWidget, so we need to -- To view, visit https://gerrit.wikimedia.org/r/222466 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I90b7cd01efac1396e71beec221486dfb6ff35282 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits