mbest/knockout.punches

Attribute binding only works with all lowercase binding names

cpdog opened this issue · 2 comments

cpdog commented

I'm not entirely sure why this line is here

var attrName = attr.name.toLowerCase();

but it means that any bindings that have names like this: someBinding won't work. A couple built in bindings happen to work, such as textInput, because they are actually aliased to have lower case versions as well. Obviously, a work around is to simply alias any binding that doesn't already have a lower case alias, but I'm not certain why that's necessary. Was this intentional?

mbest commented

Actually, the browser is supposed to lowercase the attributes. So this code just doubly ensures they are lowercase. The general method of converting camel-cased JavaScript to attributes is to add hyphens. Thus someBinding would become some-binding.

cpdog commented

Thus someBinding would become some-binding.

Agreed, that would be the best solution. Right now however, that doesn't work. Would it be reasonable to simply change kebab case to camel case where the lower case version isn't found? e.g., check for a binding named some-binding like it already does, if that fails, check for a binding named someBinding.