@cocreate/render 1.46.0 → 1.46.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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.46.1](https://github.com/CoCreate-app/CoCreate-render/compare/v1.46.0...v1.46.1) (2026-03-01)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * optimize data handling in render function to prevent unnecessary updates ([a6f7202](https://github.com/CoCreate-app/CoCreate-render/commit/a6f720282744f2e393e1921fea5bccceb466f617))
7
+
1
8
  # [1.46.0](https://github.com/CoCreate-app/CoCreate-render/compare/v1.45.6...v1.46.0) (2026-03-01)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/render",
3
- "version": "1.46.0",
3
+ "version": "1.46.1",
4
4
  "description": "A simple render component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "render",
package/src/index.js CHANGED
@@ -164,24 +164,25 @@ async function render({
164
164
  }
165
165
  }
166
166
 
167
- let sourceData = sources.get(source);
168
- if (!sourceData) {
169
- sourceData = { element: source, data: { ...data } };
170
- sources.set(source, sourceData);
171
- } else if (sourceData.data) {
172
- sourceData.data = { ...data };
173
- } else {
174
- // TODO: Most effiecientway to comapre too objects or array of objects
175
- if (data === sourceData.data) return;
176
- sourceData.data = { ...data };
177
- }
178
-
179
167
  if (data.$filter) {
180
168
  index = index || data.$filter.startingIndex || data.$filter.index;
181
169
  update = update || data.$filter.update;
182
170
  remove = remove || data.$filter.remove;
183
171
  }
184
172
 
173
+ let isMutation = remove || update || (data.$filter && data.$filter.create);
174
+
175
+ let sourceData = sources.get(source);
176
+ if (!sourceData) {
177
+ sourceData = { element: source, data: { ...data } };
178
+ sources.set(source, sourceData);
179
+ } else if (!isMutation) {
180
+ // Only overwrite the master list if this is a full read, not a patch/mutation!
181
+ if (data !== sourceData.data) {
182
+ sourceData.data = { ...data };
183
+ }
184
+ }
185
+
185
186
  if (
186
187
  !Array.isArray(element) &&
187
188
  !(element instanceof HTMLCollection) &&
@@ -241,7 +242,7 @@ async function render({
241
242
  }
242
243
 
243
244
  clone = clones.get(cloneKey);
244
- if (!clone) return;
245
+ if (!clone) continue;
245
246
 
246
247
  clones.delete(cloneKey);
247
248
  renderedNodes.delete(clone);
@@ -261,7 +262,7 @@ async function render({
261
262
 
262
263
  if (!currentIndex) currentIndex = data.$filter.currentIndex;
263
264
 
264
- if (!clone) return;
265
+ if (!clone) continue;
265
266
 
266
267
  await renderValues(clone, { object: data[key][j] });
267
268
  if (currentIndex >= 0)