Skip to content

Preserve attributes order for element node#10958

Merged
thorn0 merged 5 commits intoprettier:mainfrom
dcyriller:10203
Jun 4, 2021
Merged

Preserve attributes order for element node#10958
thorn0 merged 5 commits intoprettier:mainfrom
dcyriller:10203

Conversation

@dcyriller
Copy link
Copy Markdown
Collaborator

@dcyriller dcyriller commented May 27, 2021

Description

Closes #10203

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@dcyriller dcyriller added lang:handlebars Issues affecting Handlebars (Glimmer) type:bug labels May 27, 2021
/* ElementNode print helpers */

function sortByLoc(a, b) {
if (a.loc.start.line < b.loc.start.line) {
Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Member

@fisker fisker May 28, 2021

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]], [])
Copy link
Copy Markdown
Member

@fisker fisker May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.reduce((acc, type) => [...acc, ...node[type]], [])
.flatMap((type) => node[type])

{{! this is a comment for arg 5}}
@arg5="hello"
...arguments
/>
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Collaborator Author

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

Copy link
Copy Markdown
Member

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

@dcyriller

This comment has been minimized.

@thorn0 thorn0 merged commit 3cd28ca into prettier:main Jun 4, 2021
@dcyriller dcyriller deleted the 10203 branch June 4, 2021 11:03
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jun 5, 2022
@fisker fisker removed the type:bug label Mar 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lang:handlebars Issues affecting Handlebars (Glimmer)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Glimmer parser destructively re-orders component modifiers and comments

3 participants