Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sveltejs/svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed May 21, 2019
2 parents a0b876f + e4c5569 commit 9f154e9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Pull requests are encouraged and always welcome. [Pick an issue](https://github.
To install and work on Svelte locally:

```bash
git clone git@github.com:sveltejs/svelte.git
git clone https://github.com/sveltejs/svelte.git
cd svelte
npm install
```
Expand Down
2 changes: 1 addition & 1 deletion src/compile/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default class Component {

if (compile_options.customElement) {
if (this.component_options.tag === undefined && compile_options.tag === undefined) {
const svelteOptions = ast.html.children.find(child => child.name === 'svelte:options');
const svelteOptions = ast.html.children.find(child => child.name === 'svelte:options') || { start: 0, end: 0 };
this.warn(svelteOptions, {
code: 'custom-element-no-tag',
message: `No custom element 'tag' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. <svelte:options tag="my-thing"/>. To hide this warning, use <svelte:options tag={null}/>`
Expand Down
17 changes: 17 additions & 0 deletions test/custom-elements/samples/no-svelte-options/_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default {
warnings: [{
code: "custom-element-no-tag",
message: "No custom element 'tag' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. <svelte:options tag=\"my-thing\"/>. To hide this warning, use <svelte:options tag={null}/>",
pos: 0,
start: {
character: 0,
column: 0,
line: 1
},
end: {
character: 0,
column: 0,
line: 1
}
}]
};
5 changes: 5 additions & 0 deletions test/custom-elements/samples/no-svelte-options/main.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
export let name;
</script>

<h1>Hello {name}!</h1>
12 changes: 12 additions & 0 deletions test/custom-elements/samples/no-svelte-options/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as assert from 'assert';
import CustomElement from './main.svelte';

export default function (target) {
customElements.define('no-tag', CustomElement);
target.innerHTML = `<no-tag name="world"></no-tag>`;

const el = target.querySelector('no-tag');
const h1 = el.shadowRoot.querySelector('h1');

assert.equal(h1.textContent, 'Hello world!');
}

0 comments on commit 9f154e9

Please sign in to comment.