Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($resource) add @ support for properties names #11473

Closed
wants to merge 1 commit into from

Conversation

mustela
Copy link
Contributor

@mustela mustela commented Mar 31, 2015

Add support for properties that starts with @. This is useful when working with BadgerFish convention.

@gkalpak
Copy link
Member

gkalpak commented Apr 1, 2015

@mustela, thx for the PR. It generally looks good to me (with a couple of concenrs; see below).
It would be nice to change the commit message though, adding Closes #10533 at the end, in order to automatically close that related issue when/if this is merged.

I wonder:

  • Is there any particular reason why the original MEMBER_NAME_REGEX only allowed a-zA-Z_$ ?
    (I.e. did someone knew something we don't ?)
  • Since we are allowing a pahth segment to start with @ why not allow it to contain @ ?
    I think it is better to allow @ anywhere in the path (if it doesn't hurt at the beginning, I doubt it will hurt anywhere else).

@mustela
Copy link
Contributor Author

mustela commented Apr 1, 2015

@gkalpak those are valid comments, and maybe the patter come from the emac standard (?), take a look to this section.

This standard specifies specific character additions: The dollar sign ($) and the underscore (_) are permitted anywhere in an IdentifierName.

Wondering if this decision really come from that and how strict is angular about it. If we must follow the standard, then this is no longer a bug :)

Also about the commit message. I didn't see nothing related to use the "Closes #xxx" sintaxis to automatically close issues. So should it be placed in the header or the body?

Thanks

@gkalpak
Copy link
Member

gkalpak commented Apr 1, 2015

@mustela:
The section you link to (7.6) is about Identifiers. But this is not the same as object PropertyNames (e.g. take a look at section 11.1.5). A PropertyName can be an IdentifierName or a StringLiteral or a NumericLiteral.

What this means is:

var _test;   // OK, because Identifiers are allowed to start with `_`
var @test;   // NOT OK, because Identifiers are not allowed to start with `@`

var obj = {_test: null};   // OK, because PropertyName can be an Identifier and
                           // Identifiers are allowed to start with `_`
var obj = {@test: null};   // NOT OK, because PropertyName can be an Identifier, but
                           // Identifiers are NOT allowed to start with `@`

var obj = {'@test': null};   // OK, because PropertyName can be a StringLiteral and
                             // '@test' is a valid StringLiteral

So, from that perspective, I think it is pretty safe to allow @ (both at the beginning and anywhere in the property name).

Regarding the Closes #xxx, is should go in the footer (at the very bottom of the commit message).
For more info you can take a look at CONTRIBUTING.md#footer and this doc.

@mustela
Copy link
Contributor Author

mustela commented Apr 1, 2015

@gkalpak you are right, sorry to point the wrong link.

I update the branch with the changes. Let me know if you want me to do anything else.

Thanks!

@gkalpak
Copy link
Member

gkalpak commented Apr 1, 2015

Thx @mustela !

It generally LGTM...buuuut (since you ask for it), I would feel safer having a test that actually uses a @prop...
(But I would merge even without the test.)

Add support for properties that starts with @. This is useful when working with BadgerFish convention.

Closes angular#10533
@mustela
Copy link
Contributor Author

mustela commented Apr 1, 2015

@gkalpak your wish is my command! Let me know if thats ok.

Thanks!

@gkalpak
Copy link
Member

gkalpak commented Apr 2, 2015

👍 @geni... ehrr... @mustela. This looks great !

Now we just sit back and wait for someone from the team to give the green light.
(Actually, you sit back; I go pull some strings :P)

@mustela
Copy link
Contributor Author

mustela commented Apr 2, 2015

Thanks @gkalpak!

@gkalpak gkalpak closed this in 3621dbc Apr 2, 2015
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
Add support for properties that starts with @. This is useful when working with BadgerFish convention.

Closes angular#10533
Closes angular#11473
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants