X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fjquery%2Fjquery.byteLimit.js;h=dd71a2bc4dae74d08c886a1d7e5287c72dd9ba36;hb=46c7453ddb593a124a307a7a3944c3fcf0983d29;hp=620323906697a873f9fef52dd684903825999fb9;hpb=a5bafc48de78cba682d5670db9395bfa93c42cc8;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/jquery/jquery.byteLimit.js b/resources/src/jquery/jquery.byteLimit.js index 6203239066..dd71a2bc4d 100644 --- a/resources/src/jquery/jquery.byteLimit.js +++ b/resources/src/jquery/jquery.byteLimit.js @@ -86,11 +86,11 @@ } } - 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( '' ) }; }; @@ -219,6 +219,9 @@ // 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 // trimByteLength to compare the new value to an empty string instead of the