wallace 0.14.0 → 0.14.1
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/lib/component.js +4 -3
- package/lib/repeaters/keyed.js +9 -16
- package/lib/repeaters/sequential.js +4 -10
- package/package.json +3 -3
package/lib/component.js
CHANGED
|
@@ -35,7 +35,8 @@ const ComponentPrototype = {
|
|
|
35
35
|
const watches = this._w,
|
|
36
36
|
props = this.props,
|
|
37
37
|
previous = this._p,
|
|
38
|
-
elements = this._e
|
|
38
|
+
elements = this._e,
|
|
39
|
+
stash = this._s;
|
|
39
40
|
/*
|
|
40
41
|
Watches is an array of objects with keys:
|
|
41
42
|
e: the element index (number)
|
|
@@ -61,7 +62,7 @@ const ComponentPrototype = {
|
|
|
61
62
|
shouldBeVisible = displayToggle.r ? lookupTrue : !lookupTrue;
|
|
62
63
|
detacher = displayToggle.d;
|
|
63
64
|
if (detacher) {
|
|
64
|
-
detacher.apply(element, shouldBeVisible, elements,
|
|
65
|
+
detacher.apply(element, shouldBeVisible, elements, stash);
|
|
65
66
|
} else {
|
|
66
67
|
element.hidden = !shouldBeVisible;
|
|
67
68
|
}
|
|
@@ -74,7 +75,7 @@ const ComponentPrototype = {
|
|
|
74
75
|
callbacks = watch.c;
|
|
75
76
|
for (let key in callbacks) {
|
|
76
77
|
if (key === NO_LOOKUP) {
|
|
77
|
-
callbacks[key](element, props, this);
|
|
78
|
+
callbacks[key](element, props, this, stash);
|
|
78
79
|
} else {
|
|
79
80
|
const oldValue = prev[key],
|
|
80
81
|
newValue = this._q[key](props, this);
|
package/lib/repeaters/keyed.js
CHANGED
|
@@ -6,16 +6,9 @@ import { countOffset } from "../offsetter";
|
|
|
6
6
|
* COMPILER_MODS:
|
|
7
7
|
* if allowRepeaterSiblings is false the last two parameters are removed.
|
|
8
8
|
*/
|
|
9
|
-
export function KeyedRepeater(
|
|
10
|
-
componentDefinition,
|
|
11
|
-
pool,
|
|
12
|
-
key,
|
|
13
|
-
adjustmentTracker,
|
|
14
|
-
initialIndex
|
|
15
|
-
) {
|
|
9
|
+
export function KeyedRepeater(componentDefinition, key, adjustmentTracker, initialIndex) {
|
|
16
10
|
this.d = componentDefinition;
|
|
17
11
|
this.k = []; // array of keys as last set.
|
|
18
|
-
this.p = pool; // pool of component instances. Must be a Map.
|
|
19
12
|
if (typeof key === "function") {
|
|
20
13
|
this.f = key;
|
|
21
14
|
} else {
|
|
@@ -31,17 +24,17 @@ export function KeyedRepeater(
|
|
|
31
24
|
* Updates the element's childNodes to match the items.
|
|
32
25
|
* Performance is important.
|
|
33
26
|
*
|
|
34
|
-
* @param {DOMElement}
|
|
27
|
+
* @param {DOMElement} parent - The DOM element to patch.
|
|
35
28
|
* @param {Array} items - Array of items which will be passed as props.
|
|
29
|
+
* @param {Map} pool - pool of component instances.
|
|
36
30
|
* @param {any} ctrl - The parent item's controller.
|
|
37
31
|
*/
|
|
38
|
-
KeyedRepeater.prototype.patch = function (
|
|
39
|
-
const
|
|
40
|
-
componentDefinition = this.d,
|
|
32
|
+
KeyedRepeater.prototype.patch = function (parent, items, pool, ctrl) {
|
|
33
|
+
const componentDefinition = this.d,
|
|
41
34
|
keyName = this.n,
|
|
42
35
|
keyFn = this.f,
|
|
43
36
|
useKeyName = keyName !== undefined,
|
|
44
|
-
childNodes =
|
|
37
|
+
childNodes = parent.childNodes,
|
|
45
38
|
itemsLength = items.length,
|
|
46
39
|
previousKeys = this.k,
|
|
47
40
|
previousKeysLength = previousKeys.length,
|
|
@@ -92,7 +85,7 @@ KeyedRepeater.prototype.patch = function (e, items, ctrl) {
|
|
|
92
85
|
offset++;
|
|
93
86
|
} else {
|
|
94
87
|
if (itemKey !== previousKeys[i + offset]) {
|
|
95
|
-
|
|
88
|
+
parent.insertBefore(el, anchor);
|
|
96
89
|
untouched = false;
|
|
97
90
|
}
|
|
98
91
|
anchor = el;
|
|
@@ -103,12 +96,12 @@ KeyedRepeater.prototype.patch = function (e, items, ctrl) {
|
|
|
103
96
|
}
|
|
104
97
|
|
|
105
98
|
if (append) {
|
|
106
|
-
|
|
99
|
+
parent.insertBefore(frag, endAnchor);
|
|
107
100
|
}
|
|
108
101
|
|
|
109
102
|
let toStrip = previousKeysSet.size;
|
|
110
103
|
while (toStrip > 0) {
|
|
111
|
-
|
|
104
|
+
parent.removeChild(childNodes[adjustment]);
|
|
112
105
|
toStrip--;
|
|
113
106
|
}
|
|
114
107
|
|
|
@@ -6,14 +6,8 @@ import { countOffset } from "../offsetter";
|
|
|
6
6
|
* COMPILER_MODS:
|
|
7
7
|
* if allowRepeaterSiblings is false the last two parameters are removed.
|
|
8
8
|
*/
|
|
9
|
-
export function SequentialRepeater(
|
|
10
|
-
componentDefinition,
|
|
11
|
-
pool,
|
|
12
|
-
adjustmentTracker,
|
|
13
|
-
initialIndex
|
|
14
|
-
) {
|
|
9
|
+
export function SequentialRepeater(componentDefinition, adjustmentTracker, initialIndex) {
|
|
15
10
|
this.d = componentDefinition;
|
|
16
|
-
this.p = pool; // pool of component instances. Must be an Array.
|
|
17
11
|
this.c = 0; // Child count
|
|
18
12
|
if (wallaceConfig.flags.allowRepeaterSiblings) {
|
|
19
13
|
this.a = adjustmentTracker;
|
|
@@ -27,11 +21,11 @@ export function SequentialRepeater(
|
|
|
27
21
|
*
|
|
28
22
|
* @param {DOMElement} parent - The DOM element to patch.
|
|
29
23
|
* @param {Array} items - Array of items which will be passed as props.
|
|
24
|
+
* @param {Array} pool - pool of component instances.
|
|
30
25
|
* @param {any} ctrl - The parent item's controller.
|
|
31
26
|
*/
|
|
32
|
-
SequentialRepeater.prototype.patch = function (parent, items, ctrl) {
|
|
33
|
-
const
|
|
34
|
-
componentDefinition = this.d,
|
|
27
|
+
SequentialRepeater.prototype.patch = function (parent, items, pool, ctrl) {
|
|
28
|
+
const componentDefinition = this.d,
|
|
35
29
|
previousChildCount = this.c,
|
|
36
30
|
itemsLength = items.length,
|
|
37
31
|
childNodes = parent.childNodes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wallace",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"author": "Andrew Buchan",
|
|
5
5
|
"description": "An insanely small, fast, intuitive and extendable front-end framework",
|
|
6
6
|
"homepage": "https://wallace.js.org",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"test": "jest --clearCache && jest"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"babel-plugin-wallace": "^0.14.
|
|
18
|
+
"babel-plugin-wallace": "^0.14.1",
|
|
19
19
|
"browserify": "^17.0.1"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "c60384d682e38095780dd260004299e9c4038583"
|
|
22
22
|
}
|