Smalyshev has uploaded a new change for review.
https://gerrit.wikimedia.org/r/319963
Change subject: Fix visitor handling
......................................................................
Fix visitor handling
Visitor array wasn't cleaned up and elements were removed at
wrong indexes.
Bug: T149990
Change-Id: I28e670c9007dee7cbb16f2854fd0ed903274e5b6
---
M wikibase/queryService/ui/App.js
M wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js
M wikibase/queryService/ui/resultBrowser/PolestarResultBrowser.js
3 files changed, 15 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui
refs/changes/63/319963/1
diff --git a/wikibase/queryService/ui/App.js b/wikibase/queryService/ui/App.js
index 6c867f8..47a6b74 100644
--- a/wikibase/queryService/ui/App.js
+++ b/wikibase/queryService/ui/App.js
@@ -709,6 +709,8 @@
b.object = instance;
} );
+ defaultBrowser.resetVisitors();
+
// wire up
$.each( this._resultBrowsers, function( key, b ) {
defaultBrowser.addVisitor( b.object );
diff --git a/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js
b/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js
index 325f006..66b4958 100644
--- a/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js
+++ b/wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js
@@ -107,6 +107,13 @@
};
/**
+ * Reset visitors array.
+ */
+ SELF.prototype.resetVisitors = function() {
+ this._visitors = [];
+ }
+
+ /**
* Call all visitors for the piece of data
*
* @protected
@@ -114,7 +121,7 @@
* @param {String} columnKey
*/
SELF.prototype.processVisitors = function( data, columnKey ) {
- var self = this, removeVisitors = [];
+ var self = this, removeVisitors = {};
if ( this._visitors.length === 0 ) {
return;
@@ -123,14 +130,15 @@
$.each( this._visitors, function( key, v ) {
if ( v.visit && typeof v.visit === 'function' ) {
if ( v.visit( data, columnKey ) === false ) {
- removeVisitors.push( key );
+ removeVisitors[key] = true;
}
}
} );
- $.each( removeVisitors, function( key, visitorIndex ) {
- self._visitors.splice( visitorIndex, 1 );
- } );
+ // need to use filter since removal changes keys
+ self._visitors = self._visitors.filter( function( value,
visitorIndex ) {
+ return !removeVisitors[visitorIndex];
+ });
};
/**
diff --git a/wikibase/queryService/ui/resultBrowser/PolestarResultBrowser.js
b/wikibase/queryService/ui/resultBrowser/PolestarResultBrowser.js
index 4e8e4ac..b25ea34 100644
--- a/wikibase/queryService/ui/resultBrowser/PolestarResultBrowser.js
+++ b/wikibase/queryService/ui/resultBrowser/PolestarResultBrowser.js
@@ -44,15 +44,6 @@
};
/**
- * Checks whether the browser can draw the given result
- *
- * @return {boolean}
- **/
- SELF.prototype.isDrawable = function() {
- return this._drawable;
- };
-
- /**
* Receiving data from the visit
*
* @param {Object} data
--
To view, visit https://gerrit.wikimedia.org/r/319963
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I28e670c9007dee7cbb16f2854fd0ed903274e5b6
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Smalyshev <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits