From 93cd3787d6f92e00fa65ff3c8bcebdcc43320f32 Mon Sep 17 00:00:00 2001 From: Marcos Caceres Date: Sun, 12 Feb 2017 23:55:06 +1100 Subject: [PATCH] fix(w3c/style): jump to hash after fixup (closes #452) --- js/w3c/style.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/w3c/style.js b/js/w3c/style.js index 13f50ba704..31701c00af 100644 --- a/js/w3c/style.js +++ b/js/w3c/style.js @@ -11,6 +11,11 @@ define([ ], function(utils, pubsubhub) { function attachFixupScript(doc, version) { var script = doc.createElement("script"); + script.addEventListener("load", function() { + if (window.location.hash) { + window.location = window.location; + } + }); var helperScript = "https://www.w3.org/scripts/TR/{version}/fixup.js" .replace("{version}", version); script.src = helperScript; @@ -30,7 +35,7 @@ define([ "initial-scale": "1", "shrink-to-fit": "no", }; - meta.content = utils.toKeyValuePairs(contentProps).replace(/\"/g, "") + meta.content = utils.toKeyValuePairs(contentProps).replace(/\"/g, ""); return meta; } @@ -76,7 +81,7 @@ define([ }] .map(utils.createResourceHint.bind(utils)) .reduce(function(frag, link) { - frag.appendChild(link) + frag.appendChild(link); return frag; }, document.createDocumentFragment()); return resourceHints; @@ -141,7 +146,7 @@ define([ if (version && !conf.noToc) { pubsubhub.sub("end-all", function() { attachFixupScript(doc, version); - }, {once: true}); + }, { once: true }); } var finalVersionPath = (version) ? version + "/" : ""; finalStyleURL = styleBaseURL.replace("{version}", finalVersionPath);