sprae 10.11.0 → 10.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/directive/value.js +32 -21
- package/dist/sprae.js +87 -139
- package/dist/sprae.js.map +2 -2
- package/dist/sprae.min.js +2 -2
- package/dist/sprae.min.js.map +3 -3
- package/dist/sprae.umd.js +91 -145
- package/dist/sprae.umd.js.map +2 -2
- package/dist/sprae.umd.min.js +2 -2
- package/dist/sprae.umd.min.js.map +3 -3
- package/package.json +1 -1
- package/readme.md +10 -9
package/readme.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
_Sprae_ is open & minimalistic progressive enhancement framework.<br/>
|
|
6
6
|
Perfect for small-scale websites, static pages, landings, prototypes, or lightweight UI.<br/>
|
|
7
|
-
A light alternative to alpine, petite-vue etc.
|
|
7
|
+
A light alternative to alpine, petite-vue etc (see [why](#justification)).
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
10
10
|
|
|
@@ -14,7 +14,7 @@ A light alternative to alpine, petite-vue etc.
|
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
<script type="module">
|
|
17
|
-
import sprae from './sprae.js'
|
|
17
|
+
import sprae from './sprae.js' // https://unpkg.com/sprae/dist/sprae.min.js
|
|
18
18
|
|
|
19
19
|
// init
|
|
20
20
|
const container = document.querySelector('#container');
|
|
@@ -370,23 +370,24 @@ sprae.use({ compile })
|
|
|
370
370
|
|
|
371
371
|
* To prevent [FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content) add `<style>[:each],[:if],[:else] {visibility: hidden}</style>`.
|
|
372
372
|
* Attributes order matters, eg. `<li :each="el in els" :text="el.name"></li>` is not the same as `<li :text="el.name" :each="el in els"></li>`.
|
|
373
|
+
* Watch out for self-closing tags, it's tempting to use `<a :text="item" />` but that's invalid html, it will create rendering errors.
|
|
373
374
|
* Properties prefixed with `_` are untracked: `let state = sprae(el, {_x:2}); state._x++; // no effect`.
|
|
374
375
|
* To destroy state and detach sprae handlers, call `element[Symbol.dispose]()`.
|
|
375
376
|
* State getters/setters work as computed effects, eg. `sprae(el, { x:1, get x2(){ return this.x * 2} })`.
|
|
376
|
-
* `this`
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
377
|
+
* `this` is not used, to get access to current element use `<input :ref="el" :text="el.value"/>`.
|
|
378
|
+
* `event` is not used, `:on*` attributes expect a function with event object as first argument `:onevt="event => handle()"`, see [#46](https://github.com/dy/sprae/issues/46).
|
|
379
|
+
* `key` is not used, `:each` uses direct list mapping instead of dom diffing.
|
|
380
|
+
* `await` is not supported in attributes, it’s a strong indicator you need to put these methods into state.
|
|
380
381
|
|
|
381
382
|
## Justification
|
|
382
383
|
|
|
383
|
-
Modern frontend stack is unhealthy like non-organic
|
|
384
|
+
Modern frontend stack is unhealthy, like non-organic processed food. There are alternatives, but:
|
|
384
385
|
|
|
385
386
|
* [Template-parts](https://github.com/dy/template-parts) is stuck with native HTML quirks ([parsing table](https://github.com/github/template-parts/issues/24), [SVG attributes](https://github.com/github/template-parts/issues/25), [liquid syntax](https://shopify.github.io/liquid/tags/template/#raw) conflict etc).
|
|
386
387
|
* [Alpine](https://github.com/alpinejs/alpine) / [petite-vue](https://github.com/vuejs/petite-vue) / [lucia](https://github.com/aidenyabi/lucia) escape native HTML quirks, but have excessive API (`:`, `x-`, `{}`, `@`, `$`), tend to [self-encapsulate](https://github.com/alpinejs/alpine/discussions/3223) and not care about size/performance.
|
|
387
388
|
|
|
388
|
-
_Sprae_ holds open
|
|
389
|
-
* Slim `:` API
|
|
389
|
+
_Sprae_ holds open & minimalistic philosophy:
|
|
390
|
+
* Slim `:` API, _signals_ for reactivity.
|
|
390
391
|
* Pluggable directives & configurable internals.
|
|
391
392
|
* Small, safe & performant.
|
|
392
393
|
* Bits of organic sugar.
|