mdx icon indicating copy to clipboard operation
mdx copied to clipboard

`position` is missing is `mdxJsxAttribute` node

Open JounQin opened this issue 3 years ago • 6 comments

Initial checklist

Affected packages and versions

remark-mdx

Link to runnable example

No response

Steps to reproduce

<div abc="xxx"></div>

Expected behavior

Add position in mdxJsxAttribute node

Actual behavior

{
  "type": "root",
  "children": [
    {
      "type": "mdxJsxFlowElement",
      "name": "div",
      "attributes": [
        {
          "type": "mdxJsxAttribute",
          "name": "abc",
          "value": "xxx"
        }
      ],
      "children": [],
      "position": {
        "start": {
          "line": 1,
          "column": 1,
          "offset": 0
        },
        "end": {
          "line": 1,
          "column": 22,
          "offset": 21
        }
      },
      "data": {
        "_mdxExplicitJsx": true
      }
    }
  ],
  "position": {
    "start": {
      "line": 1,
      "column": 1,
      "offset": 0
    },
    "end": {
      "line": 2,
      "column": 1,
      "offset": 22
    }
  }
}

Runtime

Node v16

Package manager

yarn v1

OS

macOS

Build and bundle tools

No response

JounQin avatar May 11 '22 15:05 JounQin

Could you try and reduce the MDX of this error, and see if it still persists? Are all those spaces needed for the problem?

wooorm avatar May 11 '22 15:05 wooorm

Could you try and reduce the MDX of this error, and see if it still persists? Are all those spaces needed for the problem?

Done, the white spaces are not required.

See https://github.com/syntax-tree/mdast-util-mdx-jsx/blob/main/lib/index.js#L190

Should move this issue to there instead.

JounQin avatar May 11 '22 15:05 JounQin

Ahh. This is not technically hard to fix. But it is somewhat intentional. In unist, nodes are in 'children'. These are somewhere else. So they're not really nodes. But maybe that doesn't matter practically.

Do you want to explore the solution in a pull request?

wooorm avatar May 11 '22 15:05 wooorm

Do you want to explore the solution in a pull request?

Yeah, I'd like to do it when I'm free this week.

JounQin avatar May 11 '22 15:05 JounQin

@wooorm Can you move this issue to https://github.com/syntax-tree/mdast-util-mdx-jsx and assign it to me?

JounQin avatar May 11 '22 15:05 JounQin

I don’t believe GH allows moving across organizations unfortunately :'( Feel free to open a small one there that references this. Or we’ll just keep this one. I’ll assign you here at least!

wooorm avatar May 11 '22 15:05 wooorm

Moved to https://github.com/syntax-tree/mdast-util-mdx-jsx/issues/8!

wooorm avatar Feb 09 '23 16:02 wooorm