Merge pull request #346 from sveltejs/gh-336-accept-doctype-in-any-case

accept DOCTYPE element in any case
pull/347/head
Rich Harris 8 years ago committed by GitHub
commit 9ae74d9808

@ -1,5 +1,5 @@
import Component from './Component.js';
import voidElementNames from '../../../utils/voidElementNames.js';
import isVoidElementName from '../../../utils/isVoidElementName.js';
export default {
enter ( generator, node ) {
@ -44,7 +44,7 @@ export default {
return;
}
if ( !voidElementNames.test( node.name ) ) {
if ( !isVoidElementName( node.name ) ) {
generator.append( `</${node.name}>` );
}
}

@ -4,7 +4,7 @@ import readStyle from '../read/style.js';
import { readEventHandlerDirective, readBindingDirective } from '../read/directives.js';
import { trimStart, trimEnd } from '../utils/trim.js';
import { decodeCharacterReferences } from '../utils/html.js';
import voidElementNames from '../../utils/voidElementNames.js';
import isVoidElementName from '../../utils/isVoidElementName.js';
const validTagName = /^\!?[a-zA-Z]{1,}:?[a-zA-Z0-9\-]*/;
const invalidUnquotedAttributeCharacters = /[\s"'=<>\/`]/;
@ -84,7 +84,7 @@ export default function tag ( parser ) {
parser.allowWhitespace();
if ( isClosingTag ) {
if ( voidElementNames.test( name ) ) {
if ( isVoidElementName( name ) ) {
parser.error( `<${name}> is a void element and cannot have children, or a closing tag`, start );
}
@ -155,7 +155,7 @@ export default function tag ( parser ) {
parser.current().children.push( element );
const selfClosing = parser.eat( '/' ) || voidElementNames.test( name );
const selfClosing = parser.eat( '/' ) || isVoidElementName( name );
parser.eat( '>', true );

@ -0,0 +1,5 @@
const voidElementNames = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;
export default function isVoidElementName ( name ) {
return voidElementNames.test( name ) || name.toLowerCase() === '!doctype';
}

@ -1 +0,0 @@
export default /^(?:area|base|br|col|command|\!doctype|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;
Loading…
Cancel
Save