Open petergreendr opened 1 month ago
In the current design, data must be an object or array.
Accepting simple data like a number or a string may make sense in some cases. Let's study this possibility and see how to implement it in different situations:
function data() { return 1}
.<script type="data">1</script>
<g-composer data="1">
gComponent.data = 1
This new feature has been added in version 1.0.0-beta.3.
Now it's possible:
to include simple data in the data=""
attribute:
<g-composer data="1>
</g-composer>
to include simple data in the <script type="data"></script>
tag:
<g-composer>
<script type="data">1</script>
</g-composer>
to return simple data in the function data() {}
:
<g-composer>
<script type="methods">
function data() {
return 1;
}
</script>
</g-composer>
to load simple data from a URL:
<g-composer data-src="./datum.txt">
</g-composer>
to assign simple data to .data
property:
document.querySelector('g-composer').data = 1;
The data supported are:
string
number
boolean
Please confirm that this new feature fits your needs.
Something is wrong, the example doesn't work.
Something is wrong, the example doesn't work.
Sorry @petergreendr, it's an error in the Playground, now is fixed. Please try again and don't forget to refresh your browser cache.
It's fine now. Congrats.
Sorry, the docs need to be updated.
I try to run this code:
https://playground.graphane.dev/editor/g221b784/
The
console
shows this error:What is the problem?