@fruit-ui/core 1.1.0 → 1.2.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/README.md +5 -5
- package/package.json +1 -1
- package/src/index.js +11 -3
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ FRUIT's features include:
|
|
|
51
51
|
- Keys to preserve state among re-ordered siblings
|
|
52
52
|
- An on-mount listener and handler methods
|
|
53
53
|
- Bindings to elements within components
|
|
54
|
+
- "Memo" options to make child components rerender conditionally
|
|
54
55
|
|
|
55
56
|
with all special functional features (state, controlled rerendering, bindings) accessed through the `this` argument.
|
|
56
57
|
|
|
@@ -63,16 +64,15 @@ Smaller apps don't always warrant heavyweight frameworks, but interfacing with t
|
|
|
63
64
|
## Getting started
|
|
64
65
|
|
|
65
66
|
There are three ways to use FRUIT in your projects:
|
|
66
|
-
- Download and copy the [Terser-compressed JS file](https://github.com/asantagata/fruit-ui/blob/main/dist/index.js) file into your project. (This is a compressed version built with Terser; you can just as well use the [non-compressed version](https://github.com/asantagata/fruit-ui/blob/main/src/index.js) which uses JSDoc annotations.) Then you can use `import
|
|
67
|
-
- Access via browser loading, i.e., `import
|
|
68
|
-
- With NPM installed, run `npm install @fruit-ui/core`. Then use `import
|
|
67
|
+
- Download and copy the [Terser-compressed JS file](https://github.com/asantagata/fruit-ui/blob/main/dist/index.js) file into your project. (This is a compressed version built with Terser; you can just as well use the [non-compressed version](https://github.com/asantagata/fruit-ui/blob/main/src/index.js) which uses JSDoc annotations.) Then you can use `import \* as fruit from "./modules/fruit.js"` or `<script type="module" src="./modules/fruit.js">` to access FRUIT in your JS apps.
|
|
68
|
+
- Access via browser loading, i.e., `import \* as fruit from "https://cdn.jsdelivr.net/npm/@fruit-ui/core@latest/src/index.js"`.
|
|
69
|
+
- With NPM installed, run `npm install @fruit-ui/core`. Then use `import \* as fruit from "@fruit-ui/core"`.
|
|
69
70
|
|
|
70
71
|
## Contributing
|
|
71
72
|
|
|
72
73
|
Ongoing development on FRUIT focuses on:
|
|
73
74
|
- Thorough, interactive, user-facing documentation (available [here](https://asantagata.github.io/fruit-ui/))
|
|
74
|
-
- Benchmarks
|
|
75
|
-
- A "useMemo" equivalent
|
|
75
|
+
- Benchmarks against other JS frameworks
|
|
76
76
|
- Basic built-in components
|
|
77
77
|
|
|
78
78
|
This project's initial release is currently not yet finished, so contributions aren't currently being sought out.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -734,7 +734,7 @@ function create(elementable, includeOnMounts = false) {
|
|
|
734
734
|
function replaceWith(element, elementable) {
|
|
735
735
|
const {element: newElement, onMounts} = create(elementable, true);
|
|
736
736
|
element.replaceWith(newElement);
|
|
737
|
-
onMounts
|
|
737
|
+
handleOnMounts(onMounts);
|
|
738
738
|
}
|
|
739
739
|
|
|
740
740
|
/**
|
|
@@ -745,7 +745,7 @@ function replaceWith(element, elementable) {
|
|
|
745
745
|
function appendChild(element, elementable) {
|
|
746
746
|
const {element: newElement, onMounts} = create(elementable, true);
|
|
747
747
|
element.appendChild(newElement);
|
|
748
|
-
onMounts
|
|
748
|
+
handleOnMounts(onMounts);
|
|
749
749
|
}
|
|
750
750
|
|
|
751
751
|
/**
|
|
@@ -757,7 +757,15 @@ function appendChild(element, elementable) {
|
|
|
757
757
|
function insertBefore(parentElement, nextSiblingElement, elementable) {
|
|
758
758
|
const {element: newElement, onMounts} = create(elementable, true);
|
|
759
759
|
parentElement.insertBefore(newElement, nextSiblingElement);
|
|
760
|
+
handleOnMounts(onMounts);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Handles onMounts functions returned by `create` with `includeOnMounts = true`.
|
|
765
|
+
* @param {Function[]} onMounts
|
|
766
|
+
*/
|
|
767
|
+
function handleOnMounts(onMounts) {
|
|
760
768
|
onMounts.forEach(om => om());
|
|
761
769
|
}
|
|
762
770
|
|
|
763
|
-
export { create, replaceWith, appendChild, insertBefore };
|
|
771
|
+
export { create, replaceWith, appendChild, insertBefore, handleOnMounts };
|