diff --git a/src/compiler/compile/Component.ts b/src/compiler/compile/Component.ts index ed2b10e404..c4620a3f9d 100644 --- a/src/compiler/compile/Component.ts +++ b/src/compiler/compile/Component.ts @@ -628,11 +628,13 @@ export default class Component { } const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let'); + const imported = node.type.startsWith('Import'); this.add_var({ name, initialised: instance_scope.initialised_declarations.has(name), - writable + writable, + imported }); this.node_for_declaration.set(name, node); diff --git a/src/compiler/compile/nodes/Element.ts b/src/compiler/compile/nodes/Element.ts index 9ebef8d6e8..3975bc850c 100644 --- a/src/compiler/compile/nodes/Element.ts +++ b/src/compiler/compile/nodes/Element.ts @@ -184,7 +184,7 @@ export default class Element extends Node { case 'Attribute': case 'Spread': - // special case + // special case if (node.name === 'xmlns') this.namespace = node.value[0].data; this.attributes.push(new Attribute(component, this, scope, node)); @@ -239,10 +239,10 @@ export default class Element extends Node { } validate() { - if (this.component.var_lookup.has(this.name) || this.scope.names.has(this.name)) { + if (this.component.var_lookup.has(this.name) && this.component.var_lookup.get(this.name).imported) { this.component.warn(this, { code: 'lowercase-component-name', - message: `A lowercase tag <${this.name}> will be treated as a regular HTML element`, + message: `A lowercase tag <${this.name}> will be treated as a regular HTML element` }); } diff --git a/src/compiler/interfaces.ts b/src/compiler/interfaces.ts index a5e286462f..9889e16151 100644 --- a/src/compiler/interfaces.ts +++ b/src/compiler/interfaces.ts @@ -161,6 +161,7 @@ export interface Var { hoistable?: boolean; subscribable?: boolean; is_reactive_dependency?: boolean; + imported?: boolean; } export interface CssResult { diff --git a/test/validator/samples/component-name-lowercase-2/input.svelte b/test/validator/samples/component-name-lowercase-2/input.svelte deleted file mode 100644 index 8905895f52..0000000000 --- a/test/validator/samples/component-name-lowercase-2/input.svelte +++ /dev/null @@ -1,6 +0,0 @@ - -{#each array as item} - -{/each} \ No newline at end of file diff --git a/test/validator/samples/component-name-lowercase-2/warnings.json b/test/validator/samples/component-name-lowercase-2/warnings.json deleted file mode 100644 index 1b589d48d1..0000000000 --- a/test/validator/samples/component-name-lowercase-2/warnings.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "code": "lowercase-component-name", - "end": { - "character": 64, - "column": 10, - "line": 5 - }, - "message": "A lowercase tag will be treated as a regular HTML element", - "pos": 56, - "start": { - "character": 56, - "column": 2, - "line": 5 - } - } -] diff --git a/test/validator/samples/component-name-lowercase/input.svelte b/test/validator/samples/component-name-lowercase/input.svelte index d54f096eac..e531235f70 100644 --- a/test/validator/samples/component-name-lowercase/input.svelte +++ b/test/validator/samples/component-name-lowercase/input.svelte @@ -1,5 +1,7 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/test/validator/samples/component-name-lowercase/warnings.json b/test/validator/samples/component-name-lowercase/warnings.json index a4eb74c9db..7d0d29391d 100644 --- a/test/validator/samples/component-name-lowercase/warnings.json +++ b/test/validator/samples/component-name-lowercase/warnings.json @@ -2,16 +2,16 @@ { "code": "lowercase-component-name", "message": "A lowercase tag will be treated as a regular HTML element", - "pos": 75, - "end": { - "character": 95, - "column": 20, - "line": 5 - }, + "pos": 84, "start": { - "character": 75, + "character": 84, "column": 0, - "line": 5 + "line": 6 + }, + "end": { + "character": 104, + "column": 20, + "line": 6 } } ]