question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Infra] Consistency in directive/component selectors

See original GitHub issue

Bug, feature request, or proposal:

I’m not sure what it’s. Maybe a proposal?

What is the expected behavior?

Maybe explain why some selectors are camelCase and others not?

What is the current behavior?

Currently there are kebab-case selectors, such as: md-button, md-icon-button and selectors in camelCase: mdInput, mdPrefix, mdSuffix.

I’m just wondering about the standard here. Why not make everything kebab-case or camelCase? Is there any reason behind the scenes?


Still about consistency, currently we use the native input (for inputs type text, number, etc.), native textarea and native button with their respective directives, but… for inputs type radio, checkbox, “slide-toggle” and also for select, option, etc, we have to use a, let’s call it, non-native way. Have you ever considered allowing us to use the native elements for them also?

As an example, for radio, we could have something like:

<div md-radio-group>
  <label><input type="radio" name="rad" value="0" md-ratio-button>0</label>
  <label><input type="radio" name="rad" value="1" md-ratio-button>1</label>
</div>

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
abdulhaq-ecommented, Sep 7, 2017

In my humble opinion, I think everything should be consistent regardless if it’s a component or a directive. Otherwise, it would be very confusing.

2reactions
michael-langcommented, Sep 5, 2017

For consistency as a developer using the angular material framework, why does it matter if it is a component or a directive? That’s an implementation detail most user’s won’t care about. Isn’t what matters when you are writing html code is weather or not it is an element or an attribute?

<button md-button [mdMenuTriggerFor]="optionMenu">Menu</button> <md-menu #optionMenu="mdMenu"> <button md-menu-item (click)="option1()">Option 1</button> <button md-menu-item (click)="option2()">Option 2</button> </md-menu>

It feels like md-button should be mdButton, and md-menu-item should be mdMenuItem.

Also, md-list-item is a component with selector 'md-list-item, mat-list-item, a[md-list-item], a[mat-list-item]'. Wouldn’t this fit into the developer mindset better as: 'md-list-item, mat-list-item, a[mdListItem], a[matListItem]'?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Directive
Directive classes, like component classes, can implement life-cycle hooks to influence their configuration and behavior. Further information is available in the ...
Read more >
Rule: directive-selector - codelyzer
Consistent conventions make it easy to quickly identify and reference assets of different types. Makes it easier to promote and share the directive...
Read more >
angular material readonly input
Angular Material Readonly Inputjs JavaScript library into the document. There are several ways how Angular components can pass data around: Using @Input and ......
Read more >
Understanding the Purpose and Use of the Selector in ...
Additionally, selectors are quite useful for maintaining consistency in terms of the names of the component selector and custom ...
Read more >
How To Use ViewChild in Angular to Access a Child ...
The ViewChild decorator returns the first element that matches a given directive, component, or template reference selector.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found