-
Notifications
You must be signed in to change notification settings - Fork 191
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
Maintain relative order of attributes and comments within an ElementNode
#1266
Maintain relative order of attributes and comments within an ElementNode
#1266
Conversation
There are two major issues here:
|
ElementNode
@@ -53,3 +55,30 @@ export function escapeText(text: string): string { | |||
} | |||
return text; | |||
} | |||
|
|||
export function sortByLoc(a: ASTv1.Node, b: ASTv1.Node): -1 | 0 | 1 { |
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 you re-export this from the top level @glimmer/syntax
index file? That will ultimately allow me to remove the original code this is copied from (over in ember-template-recast).
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.
Done! Worth noting, the detection of whether a Node is invisible or not is slightly different from the original in ember-template-recast
, not sure if that will impact your ability to re-use it there.
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.
Ya, it definitely will but ember-template-recast has not yet updated to the latest @glimmer/syntax
yet. When it does, it'll need to deal with this new loc
format as well, so it should be good to go.
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.
FYI ember-template-lint/ember-template-recast@f9de578
EDIT: ember-template-lint/ember-template-recast#662 would be a possible implementation
Added in @glimmer/syntax v0.76.0: glimmerjs/glimmer-vm#1266
Added in @glimmer/syntax v0.76.0: glimmerjs/glimmer-vm#1266
Added in @glimmer/syntax v0.76.0: glimmerjs/glimmer-vm#1266
Added in @glimmer/syntax v0.76.0: glimmerjs/glimmer-vm#1266
Added in @glimmer/syntax v0.76.0: glimmerjs/glimmer-vm#1266
Info
Currently, if you have a comment in among the attributes of an angle bracket component, the Printer will output that comment at the end of the list (even if it was originally in a different location). This causes problems if you have a bare attribute (without a value), as the resulting template is now invalid:
Becomes
Which then fails to parse with the error:
Changes
Tested
ElementNode
ordering is preserved.