{"action":"created","comment":{"url":"https://api.github.com/repos/Shopify/turbograft/pulls/comments/77104979","id":77104979,"diff_hunk":"@@ -4,39 +4,56 @@ class window.TurboHead\n   update: (successCallback, failureCallback) ->\n     activeAssets = extractTrackedAssets(@activeDocument)\n     upstreamAssets = extractTrackedAssets(@upstreamDocument)\n-    {activeScripts, newScripts} = processScripts(activeAssets, upstreamAssets)\n \n-    if hasScriptConflict(activeScripts, newScripts)\n-      return failureCallback()\n+    newScripts = upstreamAssets\n+      .filter(filterForNodeType('SCRIPT'))\n+      .filter(noMatchFor({attribute: 'src', inCollection: activeAssets}))\n \n-    updateLinkTags(activeAssets, upstreamAssets)\n-    updateScriptTags(@activeDocument, newScripts, successCallback)\n+    newLinks = upstreamAssets\n+      .filter(filterForNodeType('LINK'))\n+      .filter(noMatchFor({attribute: 'href', inCollection: activeAssets}))\n \n-updateLinkTags = (activeAssets, upstreamAssets) ->\n-  activeLinks = activeAssets.filter(filterForNodeType('LINK'))\n-  upstreamLinks = upstreamAssets.filter(filterForNodeType('LINK'))\n-  remainingActiveLinks = removeStaleLinks(activeLinks, upstreamLinks)\n-  reorderedActiveLinks = reorderActiveLinks(remainingActiveLinks, upstreamLinks)\n-  insertNewLinks(reorderedActiveLinks, upstreamLinks)\n+    if newScripts.concat(newLinks).some(hasAssetConflicts(activeAssets))\n+      return failureCallback()\n \n-updateScriptTags = (activeDocument, newScripts, callback) ->\n-  asyncSeries(\n-    newScripts.map((scriptNode) -> insertScriptTask(activeDocument, scriptNode)),\n-    callback\n-  )\n+    updateTasks = [\n+      (done) => updateLinkTags(@activeDocument, newLinks, done),","path":"lib/assets/javascripts/turbograft/turbohead.coffee","position":33,"original_position":33,"commit_id":"bca20abbca62db74faa6315f4e766627aed544d7","original_commit_id":"bca20abbca62db74faa6315f4e766627aed544d7","user":{"login":"GoodForOneFare","id":673655,"avatar_url":"https://avatars.githubusercontent.com/u/673655?v=3","gravatar_id":"","url":"https://api.github.com/users/GoodForOneFare","html_url":"https://github.com/GoodForOneFare","followers_url":"https://api.github.com/users/GoodForOneFare/followers","following_url":"https://api.github.com/users/GoodForOneFare/following{/other_user}","gists_url":"https://api.github.com/users/GoodForOneFare/gists{/gist_id}","starred_url":"https://api.github.com/users/GoodForOneFare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoodForOneFare/subscriptions","organizations_url":"https://api.github.com/users/GoodForOneFare/orgs","repos_url":"https://api.github.com/users/GoodForOneFare/repos","events_url":"https://api.github.com/users/GoodForOneFare/events{/privacy}","received_events_url":"https://api.github.com/users/GoodForOneFare/received_events","type":"User","site_admin":false},"body":"You mentioned leaving this as it is in Slack, but I think it's worth moving the link tags out of the async logic.  Code should reflect existing intent.","created_at":"2016-09-01T02:20:55Z","updated_at":"2016-09-01T02:20:55Z","html_url":"https://github.com/Shopify/turbograft/pull/137#discussion_r77104979","pull_request_url":"https://api.github.com/repos/Shopify/turbograft/pulls/137","_links":{"self":{"href":"https://api.github.com/repos/Shopify/turbograft/pulls/comments/77104979"},"html":{"href":"https://github.com/Shopify/turbograft/pull/137#discussion_r77104979"},"pull_request":{"href":"https://api.github.com/repos/Shopify/turbograft/pulls/137"}}},"pull_request":{"url":"https://api.github.com/repos/Shopify/turbograft/pulls/137","id":83385052,"html_url":"https://github.com/Shopify/turbograft/pull/137","diff_url":"https://github.com/Shopify/turbograft/pull/137.diff","patch_url":"https://github.com/Shopify/turbograft/pull/137.patch","issue_url":"https://api.github.com/repos/Shopify/turbograft/issues/137","number":137,"state":"open","locked":false,"title":"Revert to the simpler solution, :(","user":{"login":"TheMallen","id":4889856,"avatar_url":"https://avatars.githubusercontent.com/u/4889856?v=3","gravatar_id":"","url":"https://api.github.com/users/TheMallen","html_url":"https://github.com/TheMallen","followers_url":"https://api.github.com/users/TheMallen/followers","following_url":"https://api.github.com/users/TheMallen/following{/other_user}","gists_url":"https://api.github.com/users/TheMallen/gists{/gist_id}","starred_url":"https://api.github.com/users/TheMallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheMallen/subscriptions","organizations_url":"https://api.github.com/users/TheMallen/orgs","repos_url":"https://api.github.com/users/TheMallen/repos","events_url":"https://api.github.com/users/TheMallen/events{/privacy}","received_events_url":"https://api.github.com/users/TheMallen/received_events","type":"User","site_admin":false},"body":"\r\n![image](https://cloud.githubusercontent.com/assets/4889856/18115448/6afe2f76-6f0d-11e6-8a97-44a23c6a8783.png)\r\n![image](https://cloud.githubusercontent.com/assets/4889856/18115463/85d7959e-6f0d-11e6-84c2-17cd34e5d596.png)\r\n\r\nI'm very sad tonight.\r\n\r\nThe graph was causing flickering on new asset bundles no matter how I refactored it due to stylesheet parsing. Load events on link tags weren't working in test environments or some of the browsers I tried. The only solutions seemed to be extremely verbose and hacky (such as setting a polling function to see if asset definitions were loaded by reaching into style tags, or using other nonsense like that)\r\n\r\nAs such, I just pulled a big old 🔥  and went with the simplest possible solution that gets us what we need.\r\n\r\nOn the brightside, I kept things at a nice balance of modular and simple, so it should be relatively easy to enhance our solution if/when we think up better ones. If we can work around test environments and are ok with older browsers (like literally firefox from a couple months ago) exploding, we could have a more robust solution again in a very small PR.\r\n\r\nTLDR:\r\n- We only ever insert new head assets\r\n- `data-turbolinks-track-as` and `data-turbolinks-track` are now merged, using `data-turbolinks-track='foo'` is the same as using both of the old attributes together with a `track-as` of foo.\r\n- We don't even care about load events from links. Don't worry bout it.\r\n- Our solution suits our needs better than stealing mainstream Turbolink's because we don't want a full page refresh when we navigate to a page with less `link` tags unless we specify.\r\n\r\nAnyway, I'm going to bed now, talk to y'all tommorrow :p\r\n","created_at":"2016-08-31T03:58:13Z","updated_at":"2016-09-01T02:20:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2c0ff623e43455eeb875b085e3c62d07347778f9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Shopify/turbograft/pulls/137/commits","review_comments_url":"https://api.github.com/repos/Shopify/turbograft/pulls/137/comments","review_comment_url":"https://api.github.com/repos/Shopify/turbograft/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shopify/turbograft/issues/137/comments","statuses_url":"https://api.github.com/repos/Shopify/turbograft/statuses/bca20abbca62db74faa6315f4e766627aed544d7","head":{"label":"Shopify:revert-to-the-simpler-solution-sadface","ref":"revert-to-the-simpler-solution-sadface","sha":"bca20abbca62db74faa6315f4e766627aed544d7","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":23920094,"name":"turbograft","full_name":"Shopify/turbograft","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/turbograft","description":"Hard fork of turbolinks, adding partial page replacement strategies, and utilities.","fork":false,"url":"https://api.github.com/repos/Shopify/turbograft","forks_url":"https://api.github.com/repos/Shopify/turbograft/forks","keys_url":"https://api.github.com/repos/Shopify/turbograft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/turbograft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/turbograft/teams","hooks_url":"https://api.github.com/repos/Shopify/turbograft/hooks","issue_events_url":"https://api.github.com/repos/Shopify/turbograft/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/turbograft/events","assignees_url":"https://api.github.com/repos/Shopify/turbograft/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/turbograft/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/turbograft/tags","blobs_url":"https://api.github.com/repos/Shopify/turbograft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/turbograft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/turbograft/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/turbograft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/turbograft/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/turbograft/languages","stargazers_url":"https://api.github.com/repos/Shopify/turbograft/stargazers","contributors_url":"https://api.github.com/repos/Shopify/turbograft/contributors","subscribers_url":"https://api.github.com/repos/Shopify/turbograft/subscribers","subscription_url":"https://api.github.com/repos/Shopify/turbograft/subscription","commits_url":"https://api.github.com/repos/Shopify/turbograft/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/turbograft/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/turbograft/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/turbograft/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/turbograft/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/turbograft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/turbograft/merges","archive_url":"https://api.github.com/repos/Shopify/turbograft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/turbograft/downloads","issues_url":"https://api.github.com/repos/Shopify/turbograft/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/turbograft/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/turbograft/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/turbograft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/turbograft/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/turbograft/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/turbograft/deployments","created_at":"2014-09-11T13:47:46Z","updated_at":"2016-08-30T19:14:11Z","pushed_at":"2016-08-31T17:50:28Z","git_url":"git://github.com/Shopify/turbograft.git","ssh_url":"git@github.com:Shopify/turbograft.git","clone_url":"https://github.com/Shopify/turbograft.git","svn_url":"https://github.com/Shopify/turbograft","homepage":"","size":569,"stargazers_count":153,"watchers_count":153,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":26,"forks":14,"open_issues":26,"watchers":153,"default_branch":"master"}},"base":{"label":"Shopify:master","ref":"master","sha":"f550c81a7f939e39fe8cf6976be9274fce31e751","user":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"repo":{"id":23920094,"name":"turbograft","full_name":"Shopify/turbograft","owner":{"login":"Shopify","id":8085,"avatar_url":"https://avatars.githubusercontent.com/u/8085?v=3","gravatar_id":"","url":"https://api.github.com/users/Shopify","html_url":"https://github.com/Shopify","followers_url":"https://api.github.com/users/Shopify/followers","following_url":"https://api.github.com/users/Shopify/following{/other_user}","gists_url":"https://api.github.com/users/Shopify/gists{/gist_id}","starred_url":"https://api.github.com/users/Shopify/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shopify/subscriptions","organizations_url":"https://api.github.com/users/Shopify/orgs","repos_url":"https://api.github.com/users/Shopify/repos","events_url":"https://api.github.com/users/Shopify/events{/privacy}","received_events_url":"https://api.github.com/users/Shopify/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Shopify/turbograft","description":"Hard fork of turbolinks, adding partial page replacement strategies, and utilities.","fork":false,"url":"https://api.github.com/repos/Shopify/turbograft","forks_url":"https://api.github.com/repos/Shopify/turbograft/forks","keys_url":"https://api.github.com/repos/Shopify/turbograft/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shopify/turbograft/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shopify/turbograft/teams","hooks_url":"https://api.github.com/repos/Shopify/turbograft/hooks","issue_events_url":"https://api.github.com/repos/Shopify/turbograft/issues/events{/number}","events_url":"https://api.github.com/repos/Shopify/turbograft/events","assignees_url":"https://api.github.com/repos/Shopify/turbograft/assignees{/user}","branches_url":"https://api.github.com/repos/Shopify/turbograft/branches{/branch}","tags_url":"https://api.github.com/repos/Shopify/turbograft/tags","blobs_url":"https://api.github.com/repos/Shopify/turbograft/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shopify/turbograft/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shopify/turbograft/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shopify/turbograft/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shopify/turbograft/statuses/{sha}","languages_url":"https://api.github.com/repos/Shopify/turbograft/languages","stargazers_url":"https://api.github.com/repos/Shopify/turbograft/stargazers","contributors_url":"https://api.github.com/repos/Shopify/turbograft/contributors","subscribers_url":"https://api.github.com/repos/Shopify/turbograft/subscribers","subscription_url":"https://api.github.com/repos/Shopify/turbograft/subscription","commits_url":"https://api.github.com/repos/Shopify/turbograft/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shopify/turbograft/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shopify/turbograft/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shopify/turbograft/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shopify/turbograft/contents/{+path}","compare_url":"https://api.github.com/repos/Shopify/turbograft/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shopify/turbograft/merges","archive_url":"https://api.github.com/repos/Shopify/turbograft/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shopify/turbograft/downloads","issues_url":"https://api.github.com/repos/Shopify/turbograft/issues{/number}","pulls_url":"https://api.github.com/repos/Shopify/turbograft/pulls{/number}","milestones_url":"https://api.github.com/repos/Shopify/turbograft/milestones{/number}","notifications_url":"https://api.github.com/repos/Shopify/turbograft/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shopify/turbograft/labels{/name}","releases_url":"https://api.github.com/repos/Shopify/turbograft/releases{/id}","deployments_url":"https://api.github.com/repos/Shopify/turbograft/deployments","created_at":"2014-09-11T13:47:46Z","updated_at":"2016-08-30T19:14:11Z","pushed_at":"2016-08-31T17:50:28Z","git_url":"git://github.com/Shopify/turbograft.git","ssh_url":"git@github.com:Shopify/turbograft.git","clone_url":"https://github.com/Shopify/turbograft.git","svn_url":"https://github.com/Shopify/turbograft","homepage":"","size":569,"stargazers_count":153,"watchers_count":153,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":26,"forks":14,"open_issues":26,"watchers":153,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shopify/turbograft/pulls/137"},"html":{"href":"https://github.com/Shopify/turbograft/pull/137"},"issue":{"href":"https://api.github.com/repos/Shopify/turbograft/issues/137"},"comments":{"href":"https://api.github.com/repos/Shopify/turbograft/issues/137/comments"},"review_comments":{"href":"https://api.github.com/repos/Shopify/turbograft/pulls/137/comments"},"review_comment":{"href":"https://api.github.com/repos/Shopify/turbograft/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shopify/turbograft/pulls/137/commits"},"statuses":{"href":"https://api.github.com/repos/Shopify/turbograft/statuses/bca20abbca62db74faa6315f4e766627aed544d7"}}}}
{"actor":{"display_login":"GoodForOneFare"}}