question about variable scoping

This issue has been tracked since 2022-07-30.

let's assume that there is a behavior B used by multiple DOM elements.

Will a "local" variable V then be shared among usages of B (similar to a static class variable in JS)?
Will individual variables have to be element-scoped (like non-static class variables in JS)?

dz4k wrote this answer on 2022-08-18

Local variables (those declared with no sigil) will never be shared.

Element-scoped variables (declared with :, or top-level set) will be shared across handlers on an element. However, behaviors will be isolated from each other and the element's inline code. This is to avoid name collisions.

If you install a behavior in multiple places, they will not share :-variables.

Does this answer your questions?

rozek wrote this answer on 2022-08-18

Yes, indeed, thanks.

The important phrase was "...behaviors will be isolated from each other and the element's inline code..."

More Details About Repo
Owner Name bigskysoftware
Repo Name _hyperscript
Full Name bigskysoftware/_hyperscript
Language JavaScript
Created Date 2020-05-27
Updated Date 2022-11-25
Star Count 1265
Watcher Count 18
Fork Count 75
Issue Count 86

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date