angular: Non-simple selectors should throw error

@Directive({
  selector: 'parent child'
})

Should throw an error, since we don’t support selectors which cross elements.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 24 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Is there a good reason why “we don’t want to support complex selectors”? It would be a great feature though. The lack of this feature forces me to still use jquery to support already existing views with complex selector based behavior as i pointed out in my proposal #7278. It appears a bit senseless to me to write the behavior for my existing view components using jquery which will not do anything else as angular2 does anyways. Why not just support complex selectors and the world would be a better place!? At least parent > child selectors.

I think not only it should throw an error, but also an explanation for “what subset of selectors are supported” is missing in the docs. The term “(css) selector” has precise meaning in the web community and people are not going to assume a subset of css selectors are going to work when docs say:

@Directive requires a CSS selector to identify the HTML in the template that is associated with the directive

I’m almost sure a lot of developers are getting bit by this issue, specially the “parent child” selector not working and not throwing.

It’s fine if a lint check catches this to work around this shortcoming, but ultimately this is an incorrect behavior in Angular that should be fixed.

This is still relevant. The framework should never silently accept an input that it does not support.