From 0247cca84a850f86dd65f0f698b93cf9aa7a379e Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Mon, 20 May 2019 17:05:57 -0300 Subject: [PATCH 1/2] Allow custom element to be declared with no tag and no options --- src/compile/Component.ts | 2 +- .../samples/no-svelte-options/_config.js | 17 +++++++++++++++++ .../samples/no-svelte-options/main.svelte | 5 +++++ .../samples/no-svelte-options/test.js | 12 ++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/custom-elements/samples/no-svelte-options/_config.js create mode 100644 test/custom-elements/samples/no-svelte-options/main.svelte create mode 100644 test/custom-elements/samples/no-svelte-options/test.js diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 86b43c1b64..a429db41f6 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -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. . To hide this warning, use ` diff --git a/test/custom-elements/samples/no-svelte-options/_config.js b/test/custom-elements/samples/no-svelte-options/_config.js new file mode 100644 index 0000000000..e45582a127 --- /dev/null +++ b/test/custom-elements/samples/no-svelte-options/_config.js @@ -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. . To hide this warning, use ", + pos: 0, + start: { + character: 0, + column: 0, + line: 1 + }, + end: { + character: 0, + column: 0, + line: 1 + } + }] +}; diff --git a/test/custom-elements/samples/no-svelte-options/main.svelte b/test/custom-elements/samples/no-svelte-options/main.svelte new file mode 100644 index 0000000000..538dc970e9 --- /dev/null +++ b/test/custom-elements/samples/no-svelte-options/main.svelte @@ -0,0 +1,5 @@ + + +

Hello {name}!

diff --git a/test/custom-elements/samples/no-svelte-options/test.js b/test/custom-elements/samples/no-svelte-options/test.js new file mode 100644 index 0000000000..c77f035088 --- /dev/null +++ b/test/custom-elements/samples/no-svelte-options/test.js @@ -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 = ``; + + const el = target.querySelector('no-tag'); + const h1 = el.shadowRoot.querySelector('h1'); + + assert.equal(h1.textContent, 'Hello world!'); +} From 4f324ce1cfda2c980fc6da6652b8b35912e25455 Mon Sep 17 00:00:00 2001 From: Rai Talha Rehman Date: Tue, 21 May 2019 06:16:31 +0500 Subject: [PATCH 2/2] update clone with https (#2787) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d03eca934..7d0af8ac2e 100644 --- a/README.md +++ b/README.md @@ -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 ```