Make sure URI comparisons include highlight states
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / mw.rcfilters.Controller.js
index e1694f6..b7b46f6 100644 (file)
         */
        mw.rcfilters.Controller.prototype._updateURL = function ( params ) {
                var currentFilterState, updatedFilterState, updatedUri,
+                       uri = new mw.Uri(),
                        notEquivalent = function ( obj1, obj2 ) {
                                var keys = Object.keys( obj1 ).concat( Object.keys( obj2 ) );
                                return keys.some( function ( key ) {
                // This will allow us to always have a proper check of whether
                // the requested new url is one to change or not, regardless of
                // actual parameter visibility/representation in the URL
-               currentFilterState = this.filtersModel.getFiltersFromParameters( new mw.Uri().query );
+               currentFilterState = this.filtersModel.getFiltersFromParameters( uri.query );
                updatedFilterState = this.filtersModel.getFiltersFromParameters( updatedUri.query );
 
+               // Include highlight states
+               $.extend( true,
+                       currentFilterState,
+                       this.filtersModel.extractHighlightValues( uri.query ),
+                       { highlight: !!Number( uri.query.highlight ) }
+               );
+               $.extend( true,
+                       updatedFilterState,
+                       this.filtersModel.extractHighlightValues( updatedUri.query ),
+                       { highlight: !!Number( updatedUri.query.highlight ) }
+               );
+
                if ( notEquivalent( currentFilterState, updatedFilterState ) ) {
                        if ( this.initializing ) {
                                // Initially, when we just build the first page load