Skip to content

Loading…

Turbolinks master breaks when used with uglifier in the rails asset pipeline #346

Closed
twalpole opened this Issue · 9 comments

2 participants

@twalpole

ComponentUrl and Link classes check constructor.name against a string to prevent double initialization of objects, however when used with JS minification the names of the classes is changed and therefore the constructor names no longer match the strings checked against. This results in objects being double initialized and breaking the url passed to historyPushState.

@reed

Is there another way to do the check, or do I have to remove it?

@reed

Nevermind, I got it.

@twalpole

I think instanceof should work with coffeescript classes although I havent tried it in this case

@twalpole

or if you want to be sure its ComponentUrl and not an object further derived it
X.constructor is ComponentUrl

@reed

I was going to go with:

constructor: (@original = document.location.href) ->
    return @original if @original.constructor.name is @constructor.name

That work for you?

@twalpole

You should just be able to do. @original.constructor is ComponentUrl

@reed

That works too, but it's a comparison of two functions, which seems less efficient than comparing just the names of those functions. So I'm going to go with that. Thanks for bringing this to my attention.

@reed reed closed this in d0a67a5
@twalpole

@reed comparing 2 functions should be more performant than comparing two strings since it should boil down to just a pointer comparison

@reed

Based on this argument, I've joined your side.

Changed in c5cda21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.