Skip to content
Browse files

Fix #12690. Avoid use of UTF-8 chars in final files.

  • Loading branch information...
1 parent 5a21150 commit a60fed4dec85e7b0c3b6fc5741b14cee1552afc4 @dmethvin dmethvin committed Oct 10, 2012
Showing with 3 additions and 2 deletions.
  1. +2 −1 src/core.js
  2. +1 −1 src/event.js
View
3 src/core.js
@@ -605,7 +605,8 @@ jQuery.extend({
},
// Use native String.trim function wherever possible
- trim: core_trim && !core_trim.call("\uFEFF\xA0") ?
+ // Uglify converts escapes to UTF-8; this circumvents (#12690)
+ trim: core_trim && !core_trim.call( String.fromCharCode( 0xFEFF, 0xA0 ) ) ?
@Krinkle
jQuery Foundation member
Krinkle added a note Oct 11, 2012

Hm.. exactly what is this for? This wasn't a special character, it was an escaped string. I see only plain characters here.

@dmethvin
jQuery Foundation member
dmethvin added a note Oct 11, 2012

Uglify converts the escaped chars into their literal equivalents and inserts those into the final file. It's smaller fer sure, but it assumes UTF-8. Hmmm, I just retyped the comment in a different way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
function( text ) {
return text == null ?
"" :
View
2 src/event.js
@@ -603,7 +603,7 @@ jQuery.removeEvent = document.removeEventListener ?
if ( elem.detachEvent ) {
- // #8545, #7054, preventing memory leaks for custom events in IE6-8
@johnbender
johnbender added a note Oct 10, 2012

Part of me wants to make up a long and exhaustive story about where that hyphen came from, and its life inside the codebase.

@dmethvin
jQuery Foundation member
dmethvin added a note Oct 10, 2012

It's actually a couple of funny chars and not a hyphen, but it shows as a hyphen here for some reason.

@johnbender
johnbender added a note Oct 10, 2012

Making my potential novella even more interesting!

I use jQuery in a ISO-8859-1 environment so I always remove this char upon deploying. I always thought this was some kind of "hey, you should use unicode for your projects cause it is best practice, if you don't I will be messing with you every time you download a new jQuery version" or something like that.

@md3sum
md3sum added a note Nov 11, 2012

That unicode character actually caused me quite a headache for 2 hours. I was loading the jQuery file (downloaded from the site) and loading it into my overalled 'compiled' javascript file of all my code along with this jQuery file, but each time I tried to load it, python would throw a UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 88: ordinal not in range(128). Finally traced it down to that character and was about to change it here but realized @dmethvin got to it sooner. Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
// detachEvent needed property on element, by name of that event, to properly expose it to GC
if ( typeof elem[ name ] === "undefined" ) {
elem[ name ] = null;

3 comments on commit a60fed4

@curiousdannii

You should just use UglifyJS's --ascii option.

@dmethvin
jQuery Foundation member

@curiousdannii HOW DID I MISS THAT? I even went over there and read through the options.

@mikesherov
jQuery Foundation member

I came here to write what @curiousdannii wrote. :+1:

Please sign in to comment.
Something went wrong with that request. Please try again.