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: [AST] End position is wrong for self closing tags with attributes #716

Open
Princesseuh opened this issue Feb 6, 2023 · 0 comments
Assignees
Labels
downstream-blocker This issue is blocking something downstream feat: ast Related to the JSON AST output (scope)

Comments

@Princesseuh
Copy link
Member

What version of @astrojs/compiler are you using?

1.0.1

What package manager are you using?

pnpm

What operating system are you using?

macOS

Describe the Bug

If a self-closing tag has attributes on it, the end position in the AST is wrong. IT seems like it doesn't consider the attributes and instead return the end position as if it had no attributes.

Example:

<div class="hello" />
{
  type: 'element',
  name: 'div',
  attributes: [
    {
      type: 'attribute',
      kind: 'quoted',
      name: 'class',
      value: 'sdas',
      position: { start: { line: 1, column: 6, offset: 5 } }
    }
  ],
  children: [],
  position: {
    start: { line: 1, column: 1, offset: 0 },
    end: { line: 1, column: 7, offset: 6 }
  }
}

Here the end position of the div tag is end: { line: 1, column: 7, offset: 6 }, but that correspond to the end if it had no attributes:

<div class="hello" />
1234567
<div />

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-jtp7bg?file=src/pages/index.astro&on=stackblitz

@natemoo-re natemoo-re self-assigned this Feb 14, 2023
@natemoo-re natemoo-re added the feat: ast Related to the JSON AST output (scope) label Jun 27, 2023
@natemoo-re natemoo-re added the downstream-blocker This issue is blocking something downstream label Jul 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
downstream-blocker This issue is blocking something downstream feat: ast Related to the JSON AST output (scope)
Projects
None yet
Development

No branches or pull requests

2 participants