-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0.8-preview] Throws exception if left-hand-side of a property binding contains a dash #1161
Comments
Soon, any left-hand side of a binding that includes dashes will be converted to camel-case, so:
will be interpreted as a request to bind Therefore it will be impossible to bind to a property that has dashes in it's name, and you will not hit this problem. If the user's actual intent is to bind to an attribute, then they must use
binds In particular, we expect |
This becomes strange for attributes that are named differently from their JS properties like "class" -> "className" and "for" -> "htmlFor". If I bind to an element's "class" and inside the element it sets "className", do I get notified? Should I even bind to "class" or use "className" instead? |
Those particular nasty bits are part of the HTML technical debt IMO. This case-sensitivity problem has historically been solved in an ad-hoc manner. We could (and may) add special-cases for such things (similar to As it stands now we have eschewed magic in favor of explicit rules, such that:
This is more complicated than we would like, but it is at least possible to express many cases without ambiguity. We're always looking for suggestions for improvement, but the best suggestions must consider all constraints. |
I find limiting the amount of magic makes this easier to follow. The bit that still seems magic is the translation of camel case to lower case for properties. That is implied for attributes because HTML attributes are not case-sensitive, but JS properties are. I'd expect:
and
|
@ssorallen I don't think it's possible to recover the original casing from DOM attributes (like when annotations are parsed)... |
@peterwmwong Yup good point. |
Yes, this entire bag of hurt comes from the fact that when we interrogate DOM for attribute names we only get lower-cased strings no matter what was in the original HTML. |
Yeah, a downside of using rendered HTML (as opposed to a string) for templating. You're bound by the rules of the HTML processor whether you want 'em or not. Thanks for the explanations. 👍 |
Properties starting with "on-" are interpreted as event listeners, but any other property containing a dash causes Polymer to throw an exception while binding:
This is because of the compiled effects assuming they can use dot notation on nodes:
The text was updated successfully, but these errors were encountered: