JS: Chrome/win large string corruption workaround

This commit is contained in:
Einar Lielmanis 2011-10-15 02:01:53 +03:00
parent 107a2beab5
commit d0de7952ac

View File

@ -173,13 +173,6 @@ label {
color: #888;
margin-bottom: 30px;
line-height: 130%;
}
#chrome-warning {
color: #c33;
font-size: 11px;
margin-right: 20px;
line-height: 130%;
margin-bottom: 14px;
}
</style>
<script src="jquery/jquery.js"></script>
@ -200,6 +193,18 @@ var the = {
beautify_in_progress: false
};
if (/chrome/.test(navigator.userAgent.toLowerCase())) {
// this dummy function alleviates Chrome large string corruption by
// probably shoveling the corruption bug to some other area
//
// http://code.google.com/p/chromium/issues/detail?id=100409
// http://jsbeautifier.org/chrome-bug/
String.prototype.old_charAt = String.prototype.charAt;
String.prototype.charAt = function (n) { return this.old_charAt(n); }
}
function run_tests() {
var st = new SanityTest();
run_beautifier_tests(st);
@ -361,10 +366,6 @@ $(function() {
<p><strong>Beautify, unpack or deobfuscate JavaScript, make JSON/JSONP readable, etc.</strong>.</p>
<div id="chrome-warning">
Beware, large texts <b>tend to mess up heavily in recent Chromes</b> for reasons yet unknown.<br>I'll look for the reason and the solution, but if you'd take a time to look into this problem as well, that would be awesome. Thanks!
</div>
<p>All of the source code is available on the <a href="https://github.com/einars/js-beautify">github</a>, and we have a command-line version and a python library as well.
<p>JSBeautifier is — and always will be — completely free and open, and your thanks, flattrs and donations are very heartwarming — thank you all so much!