jbeard4 / SCION

SCXML/Statecharts in JavaScript, moved to gitlab: https://gitlab.com/scion-scxml/scion
https://scion.scxml.io
Apache License 2.0
149 stars 29 forks source link

Can't set scxml/@initial to a nested state #327

Closed mattoshry closed 9 years ago

mattoshry commented 9 years ago

<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="s2">

<state id="uber"> <state id="s1"> <onentry> <log expr="'onentry s1 _sessionid=' + _sessionid" label="TEST"/> </onentry> <transition event="ev1" target="s2"/> </state>

<state id="s2"> <onentry> <log expr="'onentry s2 _sessionid=' + _sessionid" label="TEST"/> </onentry> </state> </state> </scxml>

Scion throws here: /Users/matto/git/scxml/node_modules/scxml/node_modules/scion-core/lib/scion.js:190 if(!state.initialRef) throw new Error('Unable to locate initia ^ Error: Unable to locate initial state for composite state: undefined

jbeard4 commented 9 years ago

The issue is in the model initialization code in SCION-CORE here https://github.com/jbeard4/SCION-CORE/blob/master/lib/scion.js#L187 Which assumes that the initial state will be a substate. This is an erroneous assumption.

The solution will be to hook the initial state logic into connectTransitionGraph: https://github.com/jbeard4/SCION-CORE/blob/master/lib/scion.js#L216

ETA Monday

jbeard4 commented 9 years ago

Fixed in PR #335