Skip to content

Commit

Permalink
Better explanation of scoped functions and variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
gnat authored Aug 28, 2024
1 parent a3d690a commit e0448e4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,16 +368,14 @@ me().on("click", async event => {
* `f`, `fn` = function
#### Scope functions and variables inside `<script>`
* ⭐ Use a block
* `{ let scoped = 1; function hey(text) { alert(text) }; me().on('click', ev => { hey("hi") }) }`
* `let` is scoped in `{ }` blocks!
* ⭐ Use a block `{ let note = "hi"; function hey(text) { alert(text) }; me().on('click', ev => { hey(note) }) }`
* `let` and `function` is scoped within `{ }`
* ⭐ Use `me()`
* `me().hey = (text) => { alert(text) }`
* `me().on('click', (ev) => { me(ev).hey("hi") })`
* ⭐ Use an event
* `me().on('click', ev => { /* add and call function here */ })`
* ⭐ Use an event `me().on('click', ev => { /* add and call function here */ })`
* Use an inline module: `<script type="module">`
* Warning: When using a module `me()` can no longer see `parentElement`, this means explicit selectors are required: `me(".mybutton")`
* Note: `me()` in modules will not see `parentElement`, explicit selectors are required: `me(".mybutton")`
#### Select a void element like `<input type="text" />`
* Use: `me('-')` or `me('prev')` or `me('previous')`
Expand Down

0 comments on commit e0448e4

Please sign in to comment.