0

I am playing around with variables in hyperscript. The docs say there are three different types of variables; local, element & global. Local has no prefix, while element & global use : & $ respectively. I have had success with implementing global and local variables in the following examples:

local

<section>
    <div _="on load set x to 'Bob' then put x into me">Bob</div>
</section>

global

<section>
    </div>  
        <div _="on load set $x to 'frank'"></div>
    </div>
    <output _="on load put $x into me">frank</output> 
</section>

But I have not had any luck with element scoped variables. I was under the impression it would provide all child elements access to the variable, but it returns null.

<section _="on load set :x to 'Jim'">
    <div _="on load put :x into me">null</div>
</section>

I would appreciate it if someone can show me what I am doing wrong.

Terry
  • 27
  • 5

0 Answers0