Skip to content

Commit

Permalink
Merge pull request #346 from sveltejs/gh-336-accept-doctype-in-any-case
Browse files Browse the repository at this point in the history
accept DOCTYPE element in any case
  • Loading branch information
Rich-Harris authored Mar 6, 2017
2 parents 8f20923 + 52b3a43 commit 9ae74d9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/generators/server-side-rendering/visitors/Element.js
Original file line number Diff line number Diff line change
@@ -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 ) {
Expand Down Expand Up @@ -44,7 +44,7 @@ export default {
return;
}

if ( !voidElementNames.test( node.name ) ) {
if ( !isVoidElementName( node.name ) ) {
generator.append( `</${node.name}>` );
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/parse/state/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"'=<>\/`]/;
Expand Down Expand Up @@ -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 );
}

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

Expand Down
5 changes: 5 additions & 0 deletions src/utils/isVoidElementName.js
Original file line number Diff line number Diff line change
@@ -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 change: 0 additions & 1 deletion src/utils/voidElementNames.js

This file was deleted.

0 comments on commit 9ae74d9

Please sign in to comment.