Skip to content
Permalink
Browse files

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

  • Loading branch information...
dmethvin committed Oct 10, 2012
1 parent 5a21150 commit a60fed4dec85e7b0c3b6fc5741b14cee1552afc4
Showing with 3 additions and 2 deletions.
  1. +2 −1 src/core.js
  2. +1 −1 src/event.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 ) ) ?

This comment has been minimized.

Copy link
@Krinkle

Krinkle Oct 11, 2012

Member

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

This comment has been minimized.

Copy link
@dmethvin

dmethvin Oct 11, 2012

Author Member

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.

function( text ) {
return text == null ?
"" :
@@ -603,7 +603,7 @@ jQuery.removeEvent = document.removeEventListener ?

if ( elem.detachEvent ) {

// #8545, #7054, preventing memory leaks for custom events in IE6-8

This comment has been minimized.

Copy link
@johnbender

johnbender 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.

This comment has been minimized.

Copy link
@dmethvin

dmethvin Oct 10, 2012

Author Member

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

This comment has been minimized.

Copy link
@johnbender

johnbender Oct 10, 2012

Making my potential novella even more interesting!

This comment has been minimized.

Copy link
@FagnerMartinsBrack

FagnerMartinsBrack Oct 11, 2012

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.

This comment has been minimized.

Copy link
@md3sum

md3sum 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 :)

// #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

This comment has been minimized.

Copy link

replied Oct 11, 2012

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

@dmethvin

This comment has been minimized.

Copy link
Member Author

replied Oct 11, 2012

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

@mikesherov

This comment has been minimized.

Copy link
Member

replied Oct 11, 2012

I came here to write what @curiousdannii wrote. 👍

Please sign in to comment.
You can’t perform that action at this time.