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

[svelte-parse] unquoted attribute values that include a moustache treated as text #178

Closed
halfnelson opened this issue Nov 10, 2020 · 4 comments · Fixed by #198
Closed
Labels
bug Something isn't working

Comments

@halfnelson
Copy link
Contributor

consider the following

<h1 attr=static{dynamic} />

svelte parses (and compiles) this as an attribute made of two values (text part and moustache tag)

{
            "type": "Attribute",
            "name": "attr",
            "value": [
              {
                "type": "Text",
                "raw": "static",
                "data": "static"
              },
              {
                "type": "MustacheTag",
                "expression": {
                  "type": "Identifier",
                  "name": "dynamic"
                }
              }
            ]
          }

svast currently parses this as

 {
          "type": "svelteProperty",
          "name": "attr",
          "value": [
            {
              "type": "text",
              "value": "staticdynamic",
            }
          ],
          "modifiers": [],
          "shorthand": "none",

        }
@halfnelson
Copy link
Contributor Author

However this does work if it is quoted

@pngwn
Copy link
Owner

pngwn commented Nov 10, 2020

Ah. This will be due to the special handling of quoted and unquoted attribute values.

@pngwn pngwn added svelte-parse bug Something isn't working labels Nov 28, 2020
@pngwn
Copy link
Owner

pngwn commented Nov 29, 2020

This is kindof hardcoded to be a single value right now, it needs similar handling to quoted expressions. See #174 (comment)

@pngwn
Copy link
Owner

pngwn commented Dec 6, 2020

This should be fixed in svelte-parse@0.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants