Visitar URL original
fix(language-service): Correctly parse inputs and selectors with dollar signs by atscott · Pull Request #44268 · angular/angular · GitHub
The Wayback Machine - https://web.archive.org/web/20220206224750/https://github.com/angular/angular/pull/44268
Skip to content
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

fix(language-service): Correctly parse inputs and selectors with dollar signs #44268

Closed
wants to merge 1 commit into from

Conversation

@atscott
Copy link
Contributor

@atscott atscott commented Nov 24, 2021

When we are going to the definition of an input, we find both the
definition of the input and also look for any directives which have
a selector that matches the input. For example:

@Directive({
  selector: '[greeting]'
})
export class MyDir {
  @Input() greeting!: string;
}

With this commit, we now correctly handle the case where inputs and/or
selectors have a dollar sign in them. The dollar sign has special
meaning in CSS, but when we encounter the dollar in a template, we need
to escape it when used as a selector so that it is taken as a dollar
literal rather than a character with special meaning.

Previously, we were not escaping the dollar sign and the CSS parsing
logic would throw an error. The change in this commit prevents that
error from happening, but a try...catch is still added in case there
is another unhandled use-case. If this happens, we do not want the
goToDefinition operation to completely fail.

Fixes angular/vscode-ng-language-service#1574

@ngbot ngbot bot added this to the Backlog milestone Nov 24, 2021
@ngbot ngbot bot added this to the Backlog milestone Nov 24, 2021
@google-cla google-cla bot added the cla: yes label Nov 24, 2021
@atscott atscott force-pushed the catchInvalidSelectorErrors branch from 2deabf5 to 095dd79 Nov 24, 2021
@atscott atscott requested a review from JoostK Nov 29, 2021
JoostK
JoostK approved these changes Nov 29, 2021
Copy link
Member

@JoostK JoostK left a comment •

LGTM. Oh, there is a word missing between "Correctly" and "inputs" in the commit message!

packages/language-service/src/utils.ts Outdated Show resolved Hide resolved
@atscott atscott changed the title fix(language-service): Correctly inputs and selectors with dollar signs fix(language-service): Correctly parse inputs and selectors with dollar signs Nov 29, 2021
@atscott atscott force-pushed the catchInvalidSelectorErrors branch from 095dd79 to f255411 Nov 29, 2021
…ar signs

When we are going to the definition of an input, we find _both_ the
definition of the input _and_ also look for any directives which have
a selector that matches the input. For example:

```
@directive({
  selector: '[greeting]'
})
export class MyDir {
  @input() greeting!: string;
}
```

With this commit, we now correctly handle the case where inputs and/or
selectors have a dollar sign in them. The dollar sign has special
meaning in CSS, but when we encounter the dollar in a template, we need
to escape it when used as a selector so that it is taken as a dollar
literal rather than a character with special meaning.

Previously, we were not escaping the dollar sign and the CSS parsing
logic would throw an error. The change in this commit prevents that
error from happening, but a `try...catch` is still added in case there
is another unhandled use-case. If this happens, we do not want the
`goToDefinition` operation to completely fail.

Fixes angular/vscode-ng-language-service#1574
@atscott
Copy link
Contributor Author

@atscott atscott commented Nov 29, 2021

merge assistance: unrelated test failures (legacy saucelabs)

@dylhunn
Copy link
Contributor

@dylhunn dylhunn commented Nov 29, 2021

This PR was merged into the repository by commit 3aafa76.

dylhunn added a commit that referenced this issue Nov 29, 2021
…ar signs (#44268)

When we are going to the definition of an input, we find _both_ the
definition of the input _and_ also look for any directives which have
a selector that matches the input. For example:

```
@directive({
  selector: '[greeting]'
})
export class MyDir {
  @input() greeting!: string;
}
```

With this commit, we now correctly handle the case where inputs and/or
selectors have a dollar sign in them. The dollar sign has special
meaning in CSS, but when we encounter the dollar in a template, we need
to escape it when used as a selector so that it is taken as a dollar
literal rather than a character with special meaning.

Previously, we were not escaping the dollar sign and the CSS parsing
logic would throw an error. The change in this commit prevents that
error from happening, but a `try...catch` is still added in case there
is another unhandled use-case. If this happens, we do not want the
`goToDefinition` operation to completely fail.

Fixes angular/vscode-ng-language-service#1574

PR Close #44268
@dylhunn dylhunn closed this in 3aafa76 Nov 29, 2021
dimakuba added a commit to dimakuba/angular that referenced this issue Dec 28, 2021
…ar signs (angular#44268)

When we are going to the definition of an input, we find _both_ the
definition of the input _and_ also look for any directives which have
a selector that matches the input. For example:

```
@directive({
  selector: '[greeting]'
})
export class MyDir {
  @input() greeting!: string;
}
```

With this commit, we now correctly handle the case where inputs and/or
selectors have a dollar sign in them. The dollar sign has special
meaning in CSS, but when we encounter the dollar in a template, we need
to escape it when used as a selector so that it is taken as a dollar
literal rather than a character with special meaning.

Previously, we were not escaping the dollar sign and the CSS parsing
logic would throw an error. The change in this commit prevents that
error from happening, but a `try...catch` is still added in case there
is another unhandled use-case. If this happens, we do not want the
`goToDefinition` operation to completely fail.

Fixes angular/vscode-ng-language-service#1574

PR Close angular#44268
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Dec 30, 2021

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants