-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Preserve attributes order for element node #10958
Conversation
@@ -418,24 +418,50 @@ function print(path, options, print) { | |||
|
|||
/* ElementNode print helpers */ | |||
|
|||
function sortByLoc(a, b) { | |||
if (a.loc.start.line < b.loc.start.line) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (a.loc.start.line - b.loc.start.line) || (a.loc.start.column - b.loc.start.column)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have .offset
added in #9626, so a.loc.start.offset - b.loc.start.offset
or locStart(a) - locStart(b)
like js printer
isNonEmptyArray(node[property]) | ||
); | ||
const attributes = types | ||
.reduce((acc, type) => [...acc, ...node[type]], []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.reduce((acc, type) => [...acc, ...node[type]], []) | |
.flatMap((type) => node[type]) |
{{! this is a comment for arg 5}} | ||
@arg5="hello" | ||
...arguments | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this example a little shorter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Sorry, missed this comment, but IMHO it's good as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is odd, I thought I applied the change. If you think it's worth correcting, I'll open a PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be a minor release without a blog post, so it's okay, don't bother
Description
Closes #10203
Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨