gmac / backbone.epoxy

Declarative data binding and computed models for Backbone
http://epoxyjs.org
MIT License
615 stars 89 forks source link

Allow non-identifier keys in object notation without quoting twice #115

Closed rwaldin closed 8 years ago

rwaldin commented 9 years ago

When using object literal notation where keys are non-identifiers, the keys are typically quoted like this:

attr: {
    'data-something': 'propname'
}

However, with binding object notation, this results in a parsing error:

Error parsing bindings: "attr:{data-something:propname}"
>> SyntaxError: Unexpected token -

In order to workaround the parsing error the key needs to be quoted twice, like this:

attr: {
    '"data-something"': 'propname'
}

This pull request eliminates the need to twice quote non-identifier keys, allowing them to be written more naturally as in the first example above, without resulting in a parsing error. Keys that are already twice quoted will continue to work so any existing code that already uses the workaround can be left as is.

cgcardona commented 9 years ago

:+1:

+1