PDA

View Full Version : [CLOSED][3.??] getStateId() bug



hghua
25 Jun 2009, 6:00 PM
Current function body is:
return this.stateId || ((this.id.indexOf('ext-comp-') == 0 || this.id.indexOf('ext-gen') == 0) ? null : this.id);

I think it should be:
return this.stateId || ((this.id.indexOf('ext-comp-') == 0 [B][COLOR=red]

mystix
25 Jun 2009, 6:18 PM
please post a test case as per 71015

mystix
25 Jun 2009, 6:33 PM
to add on:
your suggested code change makes no sense because a single string id cannot begin with both 'ext-comp-' and 'ext-gen'.

hghua
25 Jun 2009, 7:18 PM
Sorry, my mistake. If the logic is not to save auto-generated id, it's no problem.


to add on:
your suggested code change makes no sense because a single string id cannot begin with both 'ext-comp-' and 'ext-gen'.

mystix
25 Jun 2009, 7:31 PM
someString.indexOf(anotherString) returns 0 if someString begins with anotherString, and returns -1 if it doesn't.

additionally, Components whose ids begin with 'ext-comp' or 'ext-gen' should not return any stateId (i.e. we should only restore state to Components whose ids we set explicitly).

thus,


this.id.indexOf('ext-comp-') == 0 || // if this.id begins with 'ext-comp'
this.id.indexOf('ext-gen') == 0 ? // or this.id begins with 'ext-gen'
null : // return null
this.id // return this.id



[edit]
i see you see the light now. :)
closing this issue.