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

Bug when self closing tag is before top level script/style #194

Closed
dummdidumm opened this issue Jun 15, 2020 · 0 comments
Closed

Bug when self closing tag is before top level script/style #194

dummdidumm opened this issue Jun 15, 2020 · 0 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@dummdidumm
Copy link
Member

Describe the bug
The current extractTag util has a bug:
parse5 is very html spec compliant, also when it comes to self-closing tags. That means that something like <SelfClosing /> <p>bla</p> will not parse as we would expect - the node would also span <p>bla</p> and more, until parse5 would see a real closing tag (</SelfClosing>).

The result of this bug is that it can mess up source mappings and therefore errors/warnings are shown in the wrong place.

Workaround

Don't use self closing components.

To Reproduce
Short Test that fails with the current implementation:

        it('can extract with self-closing component before it', () => {
            const extracted = extractTag('<SelfClosing /><style></style>', 'style');
            assert.equal(!!extracted, true);
        });

Expected behavior
Should work, because Svelte can also deal with it.

System (please complete the following information):

  • OS: -
  • IDE: VSCode
  • Plugin/Package: Svelte Beta

Additional Information
We can maybe switch to using the svelte compiler's parse output once the parser is more error forgiving (sveltejs/svelte#4818)

@dummdidumm dummdidumm added the bug Something isn't working label Jun 15, 2020
dummdidumm pushed a commit to dummdidumm/language-tools that referenced this issue Jun 30, 2020
sveltejs#194

Now using the html language service which provides a simple parse method which does the tag nesting logic for us, we then have to do additional checks that we are not inside a moustache tag.
dummdidumm added a commit that referenced this issue Jun 30, 2020
* (fix) can extract with self-closing component before it

#194

Now using the html language service which provides a simple parse method which does the tag nesting logic for us, we then have to do additional checks that we are not inside a moustache tag.
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

1 participant