From: jenkins-bot Date: Tue, 22 Sep 2015 07:42:04 +0000 (+0000) Subject: Merge "jquery.byteLimit: Trigger 'change' event after limitting" X-Git-Tag: 1.31.0-rc.0~9920 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=6d79d853b17dc45b8b4796e89d930f95f75e7216;p=lhc%2Fweb%2Fwiklou.git Merge "jquery.byteLimit: Trigger 'change' event after limitting" --- 6d79d853b17dc45b8b4796e89d930f95f75e7216 diff --cc resources/src/jquery/jquery.byteLimit.js index 6203239066,5ffcae8dcf..dd71a2bc4d --- a/resources/src/jquery/jquery.byteLimit.js +++ b/resources/src/jquery/jquery.byteLimit.js @@@ -86,13 -86,13 +86,13 @@@ } } - newVal = inpParts.join( '' ); - return { - newVal: newVal, - trimmed: true + newVal: inpParts.join( '' ), + // For pathological fn() that always returns a value longer than the limit, we might have + // ended up not trimming - check for this case to avoid infinite loops + trimmed: newVal !== inpParts.join( '' ) }; - } + }; var eventKeys = [ 'keyup.byteLimit', @@@ -219,9 -219,12 +219,12 @@@ // This is a side-effect of limiting after the fact. if ( res.trimmed === true ) { this.value = res.newVal; + // Trigger a 'change' event to let other scripts attached to this node know that the value + // was changed. This will also call ourselves again, but that's okay, it'll be a no-op. + $el.trigger( 'change' ); } // Always adjust prevSafeVal to reflect the input value. Not doing this could cause - // trimValueForByteLength to compare the new value to an empty string instead of the + // trimByteLength to compare the new value to an empty string instead of the // old value, resulting in trimming always from the end (bug 40850). prevSafeVal = res.newVal; } );