Open DrSensor opened 2 years ago
/// script.js export default class Global { static count = 0 count = 0 increment() { Global.count++ this.count++ } }
<!-- page.html --> <render-scope id="1"> <button onclick:="increment"> <script type="module" src="script.js"></script> <input value:="^count"> <input value:="count"> </render-scope> <render-scope id="2"> <script type="module" src="script.js"></script> <input value:="^count"> <input value:="count"> </render-scope>
import { page } from "test:page.html" const scope = page.$$('render-scope') , increment_button1 = scope[0].$("button") , [ static_input1 , input1 ] = scope[0].$$('input[type="button"]') , [ static_input2 , input2 ] = scope[1].$$('input[type="button"]') assert(static_input1.value === "0") assert(input1.value === "0") assert(static_input2.value === "0") assert(input2.value === "0") increment_button1.click() assert(static_input1.value === "1") assert(input1.value === "1") assert(static_input2.value === "1") assert(input2.value === "0") // no change