-
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
Should automatic node finding convert id names with dashes? #1747
Comments
+1 for this enhancement |
+1. It would be nice to lose the brackets and still use dashes in id names. |
see also #150 |
That's already done in Polymer 1.0 for attributes. |
+1 agree with @dotDeeka |
It would be nice, but
How to choose? |
@kosiasik if I understand correctly HTML attributes are case insensitive, which is why Polymer converts camelCase JS properties in the first place. So, in your example the outer div has a property Does this make sense? |
@pensierinmusica |
I thought so, and was actually looking for an official reference to it but couldn't find it. The closest match I've found is this (which is an old document though, and suggests to treat values as case-insensitive anyways): @zoechi do you have a link to official HTML standard docs where it's stated that attribute values are case sensitive, or is it left to browser implementations? Thanks, cheers! |
@pensierinmusica I don't know an official doc where this is more explicitly stated but the W3C you linked to only talks about attribute names not values and it is also how Polymer treats attribute names and values. See https://www.polymer-project.org/1.0/docs/devguide/events.html#annotated-listeners |
I see, makes sense :) |
@kosiasik Good point. I didn't actually think of that. I'm not sure if this makes sense, but. If this is the sort of thing the component author would have to opt into they would be explicitly stating they want the dashed ids to change to camelCase. It doesn't solve the problem, but the developer is being explicit about the behavior they want. Also not sure if this makes sense, but if a component author opts in to transforming dashed ids to camel case and then adds an id that is camel case, throw an error? Thoughts? |
So, HTML attribute values are DOMStrings, which are case sensitive. There are various places in the spec that require values to be compared in a case-insensitive fashion (such as enumerated attributes), while others require them to be compared in a case-sensitive fashion (like fragment identifiers), The fact that the browser is required to match IDs in a case-sensitive fashion in fragment identifiers suggests that ... well, IDs must retain their original case. In fact, if attribute values weren't case sensitive in a given browser, hundreds of Polymer unit tests would fail: anything that uses https://github.com/Polymer/polymer/blob/master/test/unit/bind.html#L49 If you really want this mapping, you could add it as a behavior, like this: http://jsbin.com/fuyasah/8/edit?html,console,output Personally, I think doing this mapping where we don't need to would only add confusion to the library, and the next thing people would be wondering why |
@arthurevans yep I agree that sticking as close as possible to the platform's is a good guiding principle for a library like Polymer, that aims to get thinner and thinner as new features are natively integrated by the browser. |
Closing, as we are electing to not move forward with adding this feature per the above discussion. |
When mapping attribute names to property names, Polymer will convert the attribute some-cool-attr to someCoolAttr when assigning the property.
However, when using automatic node finding if the id has a dash in it Polymer does nothing. I understand these are two different things, but its not how I expected it to work. I was expecting more like
to be referenced
Have there already been discussions around this sort of thing I'm not aware of? Should I just suck it up and name my ids as camelCase?
Unfortunately this would be a breaking change of course.
The text was updated successfully, but these errors were encountered: