Skip to content

Commit

Permalink
fix(w3c/style): jump to hash after fixup (closes #452)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscaceres committed Feb 12, 2017
1 parent c726b14 commit 93cd378
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions js/w3c/style.js
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 93cd378

Please sign in to comment.