knockout.punches icon indicating copy to clipboard operation
knockout.punches copied to clipboard

Attribute binding only works with all lowercase binding names

Open cpdog opened this issue 3 years ago • 2 comments

I'm not entirely sure why this line is here https://github.com/mbest/knockout.punches/blob/70ed98d292bb33324aee4986b495c57326d084b6/src/interpolationMarkup.js#L146

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?

cpdog avatar Mar 20 '21 16:03 cpdog

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.

mbest avatar Mar 21 '21 20:03 mbest

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.

cpdog avatar Mar 22 '21 12:03 cpdog