Skip to content

Commit 1aac15e

Browse files
authored
Revised Conventions & Tips
1 parent e1eccb7 commit 1aac15e

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

README.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -368,26 +368,29 @@ me().on("click", event => {
368368
* `e`, `ev`, `evt` = event
369369
* `f`, `fn` = function
370370
371-
#### Scope functions and variables inside `<script>`
372-
* ⭐ Use a block `{ let note = "hi"; function hey(text) { alert(text) }; me().on('click', ev => { hey(note) }) }`
373-
* `let` and `function` is scoped within `{ }`
374-
* ⭐ Use `me()`
371+
#### Scoping
372+
* ⭐ Scope with block `{` ... `}`
373+
* `{ let note = "hi"; function hey(text) { alert(text) }; me().on('click', ev => { hey(note) }) }`
374+
* `let` and `function` are scoped within `{ }`
375+
* ⭐ Scope with `me()` block
375376
* `me().hey = (text) => { alert(text) }`
376377
* `me().on('click', (ev) => { me(ev).hey("hi") })`
377-
* ⭐ Use an event `me().on('click', ev => { /* add and call function here */ })`
378-
* Use an inline module: `<script type="module">`
379-
* Note: `me()` in modules will not see `parentElement`, explicit selectors are required: `me(".mybutton")`
378+
* ⭐ Scope with event block
379+
* `me().on('click', event => { /* ... */ })`
380+
* Scope with inline module
381+
* `<script type="module">`
382+
* Warning: `me()` will not see `parentElement`. Explicit selector required: `me(".mybutton")`
380383
381-
#### Select a void element like `<input type="text" />`
384+
#### Select a void elements (`<input type="text" />`)
382385
* Use: `me('-')` or `me('prev')` or `me('previous')`
383-
* 🔥 `<input type="text" /> <script>me('-').value = "hello"</script>`
386+
* `<input type="text" /> <script>me('-').value = "hello"</script>`
384387
* Inspired by the CSS "next sibling" combinator `+` but in reverse `-`
385388
* Or, use a relative start.
386-
* 🔥 `<form> <input type="text" n1 /> <script>me('[n1]', me()).value = "hello"</script> </form>`
389+
* `<form> <input type="text" n1 /> <script>me('[n1]', me()).value = "hello"</script> </form>`
387390
388-
#### Ignore call chain when element is missing.
389-
* 🔥 `me("#i_dont_exist")?.classAdd('active')`
390-
* No warnings: 🔥 `me("#i_dont_exist", document, false)?.classAdd('active')`
391+
#### Null safety. Ignore chain when element is missing!
392+
* `me("#i_dont_exist")?.classAdd('active')`
393+
* Silent warnings: `me("#i_dont_exist", document, false)?.classAdd('active')`
391394
392395
## <a name="plugins"></a>🔌 Your own plugin
393396

0 commit comments

Comments
 (0)