-
Notifications
You must be signed in to change notification settings - Fork 6.8k
refactor(schematics): use parse5 for finding inputs and outputs #12524
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
refactor(schematics): use parse5 for finding inputs and outputs #12524
Conversation
import {findAttributeInElementWithAttrs, findAttributeInElementWithTag} from './elements'; | ||
|
||
/** Finds the specified Angular @Input in the given elements with tag name. */ | ||
export function findInputsInElementWithTag(html: string, name: string, tagNames: string[]) { |
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.
name
-> inputName
?
(similar for other functions)
import {findAttributeInElementWithAttrs, findAttributeInElementWithTag} from './elements'; | ||
|
||
/** Finds the specified Angular @Input in the given elements with tag name. */ | ||
export function findInputsInElementWithTag(html: string, name: string, tagNames: string[]) { |
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.
I would change the all of the function names from InElement
to OnElement
} | ||
|
||
/** Finds the specified Angular @Output in elements that have one of the specified attributes. */ | ||
export function findAllOutputsInElWithAttr(html: string, name: string, attrs: string[]) { |
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.
This should have element written out to be consistent with all the other functions (even if it makes the line wrap 😉)
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.
Yeah I actually forgot about that function at all. Should be findOutputsOnElementWithAttr
.
import {DefaultTreeDocument, DefaultTreeElement, parseFragment} from 'parse5'; | ||
|
||
/** | ||
* Parses a HTML fragment and travers all AST nodes in order find elements that include the |
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.
traverse
c983971
to
1c141e9
Compare
@jelbourn Addressed your feedback. Thanks |
* Parses a HTML fragment and traverses all AST nodes in order find elements that | ||
* include the specified attribute. | ||
*/ | ||
export function findElementWithAttribute(html: string, attributeName: string) { |
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.
This one is still InElement
instead of OnElement
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.
I guess you mean that this should be Element
s and the functions below should use OnElement
instead of InElement
. I've made those changes.
* No longer constructs a complex and unreadable RegExp for finding Angular inputs and outputs. Since we declared `parse5` as a dependency for the schematics, we could use `parse5`. * Adds types for parse5 as dev dependency since parse5 is often used in the schematics.
1c141e9
to
8e9c7e0
Compare
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.
LGTM
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
parse5
as a dependency for the schematics, we could useparse5
.Note: Adding tests for all those things when walking through all rules and updating them.