-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix safari no styles #132
Fix safari no styles #132
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ describe 'Turbolinks', -> | |
|
||
visit = ({options, url}, callback) -> | ||
$(document).one('page:load', (event) -> | ||
setTimeout((-> callback(event)), 0) | ||
setTimeout((-> callback(event) if callback), 0) | ||
) | ||
Turbolinks.visit('/' + url, options) | ||
|
||
|
@@ -185,6 +185,33 @@ describe 'Turbolinks', -> | |
assertLinks(['foo.css']) | ||
done() | ||
|
||
it 'many subsequent navigations do not break head asset tracking', (done) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unless we have a way to run Safari in CI, these don't seem valuable. They probably give a false sense of confidence to the next people who come along and try to update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair. I'll wipe them. :) |
||
requestsToDo = 10 | ||
|
||
recursiveVisit = -> | ||
visit url: 'twoLinksInHead', -> | ||
visit url: 'singleLinkInHead', -> | ||
assertLinks(['foo.css']) | ||
requestsToDo -=1 | ||
return recursiveVisit() if requestsToDo > 0 | ||
done() | ||
|
||
recursiveVisit() | ||
|
||
it 'many subsequent synchronous navigations do not break head asset tracking', (done) -> | ||
requestsToDo = 10 | ||
|
||
recursiveVisit = -> | ||
visit url: 'twoLinksInHead' | ||
visit url: 'singleLinkInHead' | ||
visit url: 'twoLinksInHead', -> | ||
assertLinks(['foo.css', 'bar.css']) | ||
requestsToDo -=1 | ||
return recursiveVisit() if requestsToDo > 0 | ||
done() | ||
|
||
recursiveVisit() | ||
|
||
describe 'transforms the current head to have the same links in the same order as the upstream document with minimal moves', -> | ||
it 'maintains order when moving from an empty head to a page with link nodes.', (done) -> | ||
linkTagInserted = sinon.spy() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this do anything that the original turbolinks fix doesn't do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It outputs considerably more legible javascript than a coffeescript array comprehension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
Array.prototype.slice
instead of[].slice
? http://stackoverflow.com/questions/9006553/slice-or-array-prototype-slice suggests prototype is more performant, unfortunately jsperf is dead :(There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance diffs here are so negligible it doesn't really matter what you choose unless you're going to run this hundreds of thousands of times.
Average of running 1 million instances. Each one of these were run 5 separate times.
That's about 16ms diff at 1 million times, about 1 frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, at that point it's mostly a matter of whether you think
Array.prototype.slice.call
or[].slice.call
looks nicer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! 👍 as is!