enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Node lib function parameters #7134

Open poi33 opened 5 years ago

poi33 commented 5 years ago

Only two of lib-bodes function have underscore parameters: Example: _name, _parentPath, _indexConfig.

Node.create() and Node.setRootPermissions() use these _params. (SetRootPermissions is missing from the lib-node docs)

Code https://github.com/enonic/xp/blob/32bbf4ff16883768c049429d7fac150cfdcdf060/modules/lib/lib-node/src/main/resources/lib/xp/node.js#L84-L91 and https://github.com/enonic/xp/blob/32bbf4ff16883768c049429d7fac150cfdcdf060/modules/lib/lib-node/src/main/resources/lib/xp/node.js#L396-L398

Can this be made consistent over all functions?

GlennRicaud commented 5 years ago

Okay for setRootPermissions but create should stay this way

poi33 commented 5 years ago

Create still uses the underscore parameters but all the other functions will not use them?

GlennRicaud commented 5 years ago

These underscores are not parameters but field names. And the reserved field names are starting with an underscore. You could in theory have both _name and name.

poi33 commented 5 years ago

That makes sence, but i don't think this should be exposed to the javascript function calls. I don't want to remember that some functions use the underscore, and others don't. Can we have them standardized when exposed to javascript? Or is there a reason why we need to keep the java variable names when exposing them to JS ?