Document accessing attributes with dot in the name #1101

Closed
whitecolor opened this Issue Jun 19, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@whitecolor
Contributor

whitecolor commented Jun 19, 2014

I actually can create a can.Map attribute without restrictions on characters in the name, like

var map = new can.Map({"some-very'strange.name": 1}) // name contains dot symbol
map["some-very'strange.name"] // -> 1, can access it
map.attr("some-very'strange.name") // can't access it, will throw

but I can not access such attribute with attr function because it treats dot symbol as separation between attributes. Such behaviour is not compatible with javascript objects restrictions (as I'm aware there is no restrictions on object property names)

So what do you think about this issue?

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jun 26, 2014

Contributor

You should be able to access the property using \ before the .:

map.attr("some-very'strange\.name") // can't access it, will throw

Here is a Fiddle: http://jsfiddle.net/s7cq8/
We'll definitely have to add this to the documentation. I thought it was but I couldn't find it anywhere.

Contributor

daffl commented Jun 26, 2014

You should be able to access the property using \ before the .:

map.attr("some-very'strange\.name") // can't access it, will throw

Here is a Fiddle: http://jsfiddle.net/s7cq8/
We'll definitely have to add this to the documentation. I thought it was but I couldn't find it anywhere.

@whitecolor

This comment has been minimized.

Show comment
Hide comment
@whitecolor

whitecolor Jun 26, 2014

Contributor

Ok, good, thanks.

Contributor

whitecolor commented Jun 26, 2014

Ok, good, thanks.

@daffl daffl added this to the 2.1.4 milestone Jun 26, 2014

@daffl daffl added the Documentation label Jun 26, 2014

@daffl daffl changed the title from Attributes with dot in the name to Document accessing attributes with dot in the name Jun 26, 2014

@daffl daffl modified the milestones: 2.1.3, 2.1.4 Jul 23, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment