pull/8535/head
Nguyen Tran 3 years ago
parent 27a4e2f5e8
commit 72c7f7a2c9

@ -68,7 +68,7 @@ export default class SlotTemplate extends Node {
if (!this.slot_template_name) { if (!this.slot_template_name) {
this.slot_template_name = 'default'; this.slot_template_name = 'default';
this.is_static = false; this.is_static = true;
this.slot_attribute = new Attribute(component, this, scope, { this.slot_attribute = new Attribute(component, this, scope, {
type: 'Attribute', type: 'Attribute',
name: 'slot', name: 'slot',

@ -30,7 +30,7 @@ const regex_invalid_variable_identifier_characters = /[^a-zA-Z_$]/g;
export default class InlineComponentWrapper extends Wrapper { export default class InlineComponentWrapper extends Wrapper {
var: Identifier; var: Identifier;
slots: Map<SlotTemplate, SlotDefinition> = new Map(); slots: Map<SlotTemplate, SlotDefinition> = new Map();
staic_slot_names: Set<string> = new Set(); static_slot_names: Set<string> = new Set();
node: InlineComponent; node: InlineComponent;
fragment: FragmentWrapper; fragment: FragmentWrapper;
children: Array<Wrapper | FragmentWrapper> = []; children: Array<Wrapper | FragmentWrapper> = [];
@ -99,13 +99,13 @@ export default class InlineComponentWrapper extends Wrapper {
set_slot(slot: SlotTemplate, slot_definition: SlotDefinition) { set_slot(slot: SlotTemplate, slot_definition: SlotDefinition) {
if (slot.is_static) { if (slot.is_static) {
const name = slot.slot_template_name; const name = slot.slot_template_name;
if (this.staic_slot_names.has(name)) { if (this.static_slot_names.has(name)) {
if (name === 'default') { if (name === 'default') {
throw new Error('Found elements without slot attribute when using slot="default"'); throw new Error('Found elements without slot attribute when using slot="default"');
} }
throw new Error(`Duplicate slot name "${name}" in <${this.node.name}>`); throw new Error(`Duplicate slot name "${name}" in <${this.node.name}>`);
} else { } else {
this.staic_slot_names.add(name); this.static_slot_names.add(name);
} }
} }

Loading…
Cancel
Save