Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect HTML is generated #866

Closed
peter23 opened this issue Sep 21, 2017 · 4 comments
Closed

Incorrect HTML is generated #866

peter23 opened this issue Sep 21, 2017 · 4 comments
Labels

Comments

@peter23
Copy link

peter23 commented Sep 21, 2017

Hello.

I have HTML:

<div>
	<span><i></i></span>
	<span><i></i></span>
</div>

But Svelte outputs it in the following way:

<div>
	<span><i></i></span>
	<i>
		<span><i></i></span>
	</i>
</div>

I'm using version 1.4.0.

You can see it there: https://svelte.technology/repl?version=1.40.0&gist=5061e03f1ec98ae67e0e7d7a3da4963e

@Conduitry Conduitry added the bug label Sep 21, 2017
@Rich-Harris
Copy link
Member

Wow, that's nuts. This works...

div.innerHTML = "<span><i></i></span>\n\t<span><i></i></span>";

...but this (the code that's being generated) fails:

div.innerHTML = "<span><i/></span>\n\t<span><i/></span>";

I wonder what condition determines whether you can use a self-closing tag versus when you must have an opening and a closing tag.

@Conduitry
Copy link
Member

https://stackoverflow.com/questions/3558119/are-non-void-self-closing-tags-valid-in-html5 It sounds like according to the spec only void elements are allowed to be self-closing. I don't know how that corresponds to this weird behavior exactly, but it would probably be wise to only output self-closing elements for things we know are void elements - or actually to just output the lone tag e.g. <input> instead of <input/> to save a character.

@stalkerg
Copy link
Contributor

@Conduitry your branch working for me very well.

Rich-Harris added a commit that referenced this issue Sep 23, 2017
do not use self-closing tags in .innerHTML
@Rich-Harris
Copy link
Member

Released 1.40.1 with the fix — thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants