mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
accept DOCTYPE element in any case
This commit is contained in:
parent
6cfb4d4470
commit
1d891de648
@ -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 );
|
||||
|
||||
|
5
src/utils/isVoidElementName.js
Normal file
5
src/utils/isVoidElementName.js
Normal file
@ -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…
Reference in New Issue
Block a user