dojo / has

:rocket: Dojo 2 - feature detection library.
http://dojo.io
Other
3 stars 18 forks source link

Unregistered has() features fail silently... #18

Closed kitsonk closed 7 years ago

kitsonk commented 8 years ago

@kitsonk commented on Tue Jun 21 2016

Three challenges with the has() API:


@matt-gadd commented on Wed Jun 22 2016


@kitsonk commented on Wed Jun 22 2016

it does seem a bit opinion'y.

While I am on border on this upon further reflection, I found some issues when breaking out the shims where the feature was added as abc but was tested as abC. If we throw on missing features, then I think largely it negates this and while we might have our opinion about the feature naming conventions, we wouldn't have to enforce that on others.

It seems like we added the overwrite and no-overwrite paths for a reason, so I don't think i'd expect to get an error here?

But we have an exists() API... so in theory, if you were in doubt of it being registered. With that available, I cannot see the use case of just performing an add() without override "just in case"... clearly that is an error in the code and it would be better to throw, so that the developer addresses the logic error and doesn't depend upon things they think they have accomplished.


@matt-gadd commented on Wed Jun 22 2016

While I am on border on this upon further reflection, I found some issues when breaking out the shims where the feature was added as abc but was tested as abC. If we throw on missing features, then I think largely it negates this and while we might have our opinion about the feature naming conventions, we wouldn't have to enforce that on others.

the fact we've actually managed to fail at that in our own code does give more credence to the argument :).

But we have an exists() API... so in theory, if you were in doubt of it being registered. With that available, I cannot see the use case of just performing an add() without override "just in case"... clearly that is an error in the code and it would be better to throw, so that the developer addresses the logic error and doesn't depend upon things they think they have accomplished.

you could argue that the add function is already doing too much by having different behaviour based on a flag in the first place, and we should just pick the most common one as the api (both scenarios are possible via the exists api anyway).

kitsonk commented 8 years ago

We should settle this once and for all before the beta.

rishson commented 8 years ago

My 2p: 1) we should throw on undefined 2) we should throw on mis-spells, but we should coerce to lowercase and compare. If a misspell, we should throw a did you mean abC error 3) don't know enough about has and exists to have an opinion yet.

rorticus commented 7 years ago

I guess I won't do 1)...

image

kitsonk commented 7 years ago

You even have the blame on! :-D

If there is really nothing you think we can improve upon at the moment, feel free to close it.

dylans commented 7 years ago

has case sensitivity was addressed. Leaving open for now in case there's something else to consider. Feel free to close if we're done here.