RCFilters: Preference length is in bytes, so use $.byteLength
authorMatthew Flaschen <mflaschen@wikimedia.org>
Wed, 13 Sep 2017 02:22:33 +0000 (22:22 -0400)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Wed, 13 Sep 2017 08:16:24 +0000 (04:16 -0400)
Also, a minor fix to $.byteLength docs

Change-Id: I0f93edb0cb61a057da5ce0876b74cd17179c6587

resources/Resources.php
resources/src/jquery/jquery.byteLength.js
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js

index f0aa9ec..ca922a3 100644 (file)
@@ -1772,6 +1772,7 @@ return [
                        'resources/src/mediawiki.rcfilters/mw.rcfilters.UriProcessor.js',
                ],
                'dependencies' => [
+                       'jquery.byteLength',
                        'oojs',
                        'mediawiki.api',
                        'mediawiki.api.options',
index 7fe25ee..222f14a 100644 (file)
@@ -11,7 +11,7 @@
  * @static
  * @inheritable
  * @param {string} str
- * @return {string}
+ * @return {number}
  */
 jQuery.byteLength = function ( str ) {
        // This basically figures out how many bytes a UTF-16 string (which is what js sees)
index f37229f..ee74ac5 100644 (file)
                // Stringify state
                stringified = JSON.stringify( state );
 
-               if ( stringified.length > 65535 ) {
+               if ( $.byteLength( stringified ) > 65535 ) {
                        // Sanity check, since the preference can only hold that.
                        return;
                }