-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
aio: autolinking fixes #20512
aio: autolinking fixes #20512
Conversation
e55c3dc
to
c4d5b29
Compare
You can preview c4d5b29 at https://pr20512-c4d5b29.ngbuilds.io/. |
@@ -1,3 +1,5 @@ | |||
const CssSelectorParser = require('css-selector-parser').CssSelectorParser; |
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.
OMG, extra whitespace after const
😱
const selectorAST = cssParser.parse(stripQuotes(selectors)); | ||
const rules = selectorAST.selectors ? selectorAST.selectors.map(ruleSet => ruleSet.rule) : [selectorAST.rule]; | ||
return rules.reduce((aliases, rule) => { | ||
const tagAliases = rule.tagName? [rule.tagName] : []; |
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.
Missing whitespace before ?
😢
expect(filterAmbiguousDirectiveAliases(docs, words, 2)).toEqual(filteredDocs); | ||
}); | ||
|
||
it('should filter out docs that do not match (case-insensitively) their class name to the matching word', () => { |
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 description seems a little off.
if (docs.length > 1) { | ||
|
||
// Capture the first doc's docType | ||
const docType = docs[0].docType; |
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.
What is the reasoning for caring only about the first doc?
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.
because we don't try to do any filtering if the docs are not all of the same 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.
And what is the reasoning for not trying to do any filtering if the docs are not all of the same type? 😁
|
||
if (docs.every(doc => | ||
// if all the matched docs are of the same type (directives or components) | ||
doc.docType === docType && |
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.
So, if the first one is of type component
we don't filter if any of the rest is of type directive
?
Why is that?
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.
In the core docs there are not really many components (if any) so I don't think that this really matters either way. I guess we can be more relaxed and allow any collection of directives and components (just nothing else).
// if all the matched docs are of the same type (directives or components) | ||
doc.docType === docType && | ||
// and the matching word is in the selector for all of them | ||
doc[docType + 'Options'].selector.indexOf(word) != -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.
Should we take word boundaries into account. E.g. ['ngModelStatus'].indexOf('ngModel') !== -1
, but should that count as a match?
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 are saying that you think it should not?
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 wonder if this is likely to be a problem...?
For a doc
to appear in the original docs
list that is passed to the filter function, the matching word must appear as an alias
of the doc
. So I think that it is unlikely that the matching word does not appear in the selector at all.
Having duplicates was causing the code auto-linking to ignore `ngForm` directives.
c4d5b29
to
dad6f35
Compare
You can preview dad6f35 at https://pr20512-dad6f35.ngbuilds.io/. |
The Travis failures are unrelated to the PR. |
@petebacondarwin please add target label in the future. in general for docs, bug fixes and infrastructure changes we should always try to cherrypick the commit to the stable branch |
Ooops! I added the |
@IgorMinar yes, I normally add the target to my own PRs when I add the merge label. I didn't realise that @gkalpak had added the merge label when he approved it. |
Having duplicates was causing the code auto-linking to ignore `ngForm` directives. PR Close #20512
Having duplicates was causing the code auto-linking to ignore `ngForm` directives. PR Close #20512
Having duplicates was causing the code auto-linking to ignore `ngForm` directives. PR Close angular#20512
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. |
Closes #20466