-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow custom element to be declared with no tag and no options
- Loading branch information
1 parent
7ebf347
commit 0247cca
Showing
4 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
}] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
export let name; | ||
</script> | ||
|
||
<h1>Hello {name}!</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
} |