Fixed doctype support

This commit is contained in:
Patrick Steele-Idem 2015-02-04 11:18:57 -07:00
parent 68d5e2e7cb
commit 7b0b137424
4 changed files with 13 additions and 7 deletions

View File

@ -35,15 +35,16 @@ module.exports = function transform(node, compiler) {
if (compiler.options.xhtml !== true && startTagOnly[lookupKey] === true) {
node.setStartTagOnly(true);
}
if (node.getQName() === 'html' && node.hasAttribute('html-doctype')) {
var doctype = node.getAttribute('html-doctype');
var doctype;
if (node.getQName() === 'html' && (doctype = node.getProperty('html-doctype'))) {
var docTypeNode = compiler.createNode(DocTypeNode, {
value: doctype,
pos: node.getPosition()
});
node.parentNode.insertBefore(docTypeNode, node);
node.removeAttribute('html-doctype');
}
}
};

View File

@ -3,7 +3,12 @@
"html": {
"attributes": {
"html-doctype": {
"type": "string"
"type": "custom",
"preserve-name": true
},
"*": {
"type": "string",
"ignore": true
}
}
},

View File

@ -1,6 +1,6 @@
<html-doctype value="HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;"/>
<html html-doctype="html">
<html lang="en-us" html-doctype="html">
<head>
<title>DOCTYPE Test</title>
</head>

View File

@ -1 +1 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!DOCTYPE html><html><head><title>DOCTYPE Test</title></head><body></body></html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!DOCTYPE html><html lang="en-us"><head><title>DOCTYPE Test</title></head><body></body></html>