Skip to content
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

Style optimization #955

Merged
merged 1 commit into from Nov 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions js/w3c/style.js
Expand Up @@ -23,7 +23,6 @@ define([
// meta viewport to the top of the head - so to make sure it's the first
// thing the browser sees. See js/ui/save-html.js.
function createMetaViewport() {

var meta = document.createElement("meta");
meta.name = "viewport";
var contentProps = {
Expand All @@ -35,6 +34,14 @@ define([
return meta;
}

function createBaseStyle() {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = "https://www.w3.org/StyleSheets/TR/2016/base.css";
link.classList.add("removeOnSave");
return link;
}

function selectStyleVersion(styleVersion) {
var version = "";
switch (styleVersion) {
Expand Down Expand Up @@ -76,15 +83,18 @@ define([
}
// Collect elements for insertion
var elements = createResourceHints();

// Opportunistically apply base style
elements.appendChild(createBaseStyle());
if (!document.head.querySelector("meta[name=viewport]")) {
// Make meta viewport the first element in the head.
elements.insertBefore(createMetaViewport(), elements.firstChild);
}

document.head.insertBefore(elements, document.head.firstChild);

return {
run: function(conf, doc, cb) {

if (!conf.specStatus) {
var warn = "'specStatus' missing from ReSpec config. Defaulting to 'base'.";
conf.specStatus = "base";
Expand Down