Data Context

I post this in the bug section because I don’t know if this is a bug or a feature :wink:

The Data Context is defined through a JavaScript tag under a node. Ok. But not every JS tag is a data context. So what qualifiers a JS tag as a data context?

Right now just the JS tag changes the data context for every following (? or nested?) node. Even if there is no export within the tag…

But not every JS tag means a data context change?!

This will display ‘Hello world!’

<App Theme="Basic">
    <JavaScript>
        var text = 'Hello world!';
        module.exports = {
            caption: text
        }
    </JavaScript>
    ...
    <Panel>
        <Text Value="{caption}" />
    ...    

This will display NOT ‘Hello world!’

<App Theme="Basic">
    <JavaScript>
        var text = 'Hello world!';
        module.exports = {
            caption: text
        }
    </JavaScript>
    ...
    <Panel>
        <JavaScript>
        </JavaScript>
        <Text Value="{caption}" />
    ...    

The empty JS tag leads to a data context change although the tag is empty.

Is that the expected behavior or do I miss something?

If I understand correctly you have a data context for a node. When you look for your data context you will look upwards in your parents to find your data context if your current node doesn’t have a data context (JS). I’m not sure what you mean with “Not every JS tag is a change in data context”.

In the above sample I create an application wide data context. This context ist broken through a JS tag. This JS tag does nothing but breaks the context from above. Also if I fill the JS tag with code an place it there because of different reasons I will break the context. Let’s say I have an outer data context and a inner context. Right now I have to repeat the outer context in the inner context to have the binding in the inner context to work (if I bind inner and outer context).

I’m a little bit confused about it. In my opinion I would be better to control the data context so I would be able to code something like this:

<App Theme="Basic">
      <JavaScript>
        var text = 'Hello world!';
        module.exports = {
            dataContext: 'outer',
              caption: text
        }
      </JavaScript>
      ...
      <Panel>
        <JavaScript>
            var text = 'Hello world!';
            module.exports = {
                dataContext: 'inner',
                  caption: text
            }

        </JavaScript>
        <Text Value="{outer.caption}" />
        <Text Value="{inner.caption}" />
          ...

Right now I have to code something like this:

<App Theme="Basic">
      <JavaScript>
        var text = 'Hello world!';
        module.exports = {
              oCaption: text
        }
      </JavaScript>
      ...
      <Panel>
        <JavaScript>
            var text = 'Hello world!';
            module.exports = {
                outerCaption: oCaption,
                  innerCaption: text
            }

        </JavaScript>
        <Text Value="{outerCaption}" />
        <Text Value="{innerCaption}" />
          ...

The outer data context has to be transmitted to the inner context…

Please tell me if I’am on the wrong track.

I think you are on the wrong track. You can look at the data context as your function context. What you are trying to do is to try to create some sort of global variables, and global states, that magically works in a local context. The way Fuse solves it now, with both your examples not working is the way I prefer it to be. If you need different data contexts for the different parts, they should be really different, and not view upon as inner or outer.