fix slot attribute validation

pull/1367/head
Rich Harris 7 years ago
parent 3bb673d590
commit de9b3a56be

@ -136,16 +136,16 @@ export default class Slot extends Element {
getStaticAttributeValue(name: string) {
const attribute = this.attributes.find(
(attr: Node) => attr.name.toLowerCase() === name
attr => attr.name.toLowerCase() === name
);
if (!attribute) return null;
if (attribute.value === true) return true;
if (attribute.value.length === 0) return '';
if (attribute.isTrue) return true;
if (attribute.chunks.length === 0) return '';
if (attribute.value.length === 1 && attribute.value[0].type === 'Text') {
return attribute.value[0].data;
if (attribute.chunks.length === 1 && attribute.chunks[0].type === 'Text') {
return attribute.chunks[0].data;
}
return null;

@ -295,9 +295,11 @@ function checkSlotAttribute(validator: Validator, node: Node, attribute: Node, s
let i = stack.length;
while (i--) {
const parent = stack[i];
if (parent.type === 'Element') {
if (parent.type === 'Component') {
// if we're inside a component or a custom element, gravy
if (parent.name === 'svelte:self' || parent.name === 'svelte:component' || validator.components.has(parent.name)) return;
} else if (parent.type === 'Element') {
if (/-/.test(parent.name)) return;
}

Loading…
Cancel
Save