• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hybridsjs / hybrids / 19760852732

28 Nov 2025 10:18AM UTC coverage: 42.528% (-57.4%) from 99.915%
19760852732

Pull #296

github

web-flow
Merge 191660095 into 92ed729fc
Pull Request #296: fix(store): improve `store.record()` support & error messages while defining the model

819 of 1842 branches covered (44.46%)

9 of 9 new or added lines in 1 file covered. (100.0%)

1345 existing lines in 27 files now uncovered.

996 of 2342 relevant lines covered (42.53%)

76.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

1.89
/src/template/resolvers/array.js
1
import { getMeta, removeTemplate, getTemplateEnd } from "../utils.js";
2

3
export const arrayMap = new WeakMap();
2✔
4

5
function movePlaceholder(target, previousSibling) {
UNCOV
6
  const meta = getMeta(target);
×
UNCOV
7
  const startNode = meta.startNode;
×
UNCOV
8
  const endNode = getTemplateEnd(meta.endNode);
×
9

UNCOV
10
  previousSibling.parentNode.insertBefore(target, previousSibling.nextSibling);
×
11

UNCOV
12
  let prevNode = target;
×
UNCOV
13
  let node = startNode;
×
UNCOV
14
  while (node) {
×
UNCOV
15
    const nextNode = node.nextSibling;
×
UNCOV
16
    prevNode.parentNode.insertBefore(node, prevNode.nextSibling);
×
UNCOV
17
    prevNode = node;
×
UNCOV
18
    node = nextNode !== endNode.nextSibling && nextNode;
×
19
  }
20
}
21

22
export default function resolveArray(
23
  host,
24
  target,
25
  value,
26
  resolveValue,
27
  useLayout,
28
) {
UNCOV
29
  let lastEntries = arrayMap.get(target);
×
UNCOV
30
  const entries = value.map((item, index) => ({
×
31
    id: hasOwnProperty.call(item, "id") ? item.id : index,
×
32
    value: item,
33
    placeholder: null,
34
    available: true,
35
  }));
36

UNCOV
37
  arrayMap.set(target, entries);
×
38

UNCOV
39
  if (lastEntries) {
×
UNCOV
40
    const ids = new Set();
×
UNCOV
41
    for (const entry of entries) {
×
UNCOV
42
      ids.add(entry.id);
×
43
    }
44

UNCOV
45
    lastEntries = lastEntries.filter((entry) => {
×
UNCOV
46
      if (!ids.has(entry.id)) {
×
UNCOV
47
        removeTemplate(entry.placeholder);
×
UNCOV
48
        entry.placeholder.parentNode.removeChild(entry.placeholder);
×
UNCOV
49
        return false;
×
50
      }
51

UNCOV
52
      return true;
×
53
    });
54
  }
55

UNCOV
56
  let previousSibling = target;
×
UNCOV
57
  const lastIndex = value.length - 1;
×
UNCOV
58
  const meta = getMeta(target);
×
59

UNCOV
60
  for (let index = 0; index < entries.length; index += 1) {
×
UNCOV
61
    const entry = entries[index];
×
62
    let matchedEntry;
UNCOV
63
    if (lastEntries) {
×
UNCOV
64
      for (let i = 0; i < lastEntries.length; i += 1) {
×
UNCOV
65
        if (lastEntries[i].available && lastEntries[i].id === entry.id) {
×
UNCOV
66
          matchedEntry = lastEntries[i];
×
UNCOV
67
          break;
×
68
        }
69
      }
70
    }
71

UNCOV
72
    if (matchedEntry) {
×
UNCOV
73
      matchedEntry.available = false;
×
UNCOV
74
      entry.placeholder = matchedEntry.placeholder;
×
75

UNCOV
76
      if (entry.placeholder.previousSibling !== previousSibling) {
×
UNCOV
77
        movePlaceholder(entry.placeholder, previousSibling);
×
78
      }
UNCOV
79
      if (matchedEntry.value !== entry.value) {
×
UNCOV
80
        resolveValue(
×
81
          host,
82
          entry.placeholder,
83
          entry.value,
84
          matchedEntry.value,
85
          useLayout,
86
        );
87
      }
88
    } else {
UNCOV
89
      entry.placeholder = globalThis.document.createTextNode("");
×
UNCOV
90
      previousSibling.parentNode.insertBefore(
×
91
        entry.placeholder,
92
        previousSibling.nextSibling,
93
      );
UNCOV
94
      resolveValue(host, entry.placeholder, entry.value, undefined, useLayout);
×
95
    }
96

UNCOV
97
    previousSibling = getTemplateEnd(
×
98
      getMeta(entry.placeholder, {}).endNode || entry.placeholder,
×
99
    );
100

UNCOV
101
    if (index === 0) meta.startNode = entry.placeholder;
×
UNCOV
102
    if (index === lastIndex) meta.endNode = previousSibling;
×
103
  }
104

UNCOV
105
  if (lastEntries) {
×
UNCOV
106
    for (const entry of lastEntries) {
×
UNCOV
107
      if (entry.available) {
×
UNCOV
108
        removeTemplate(entry.placeholder);
×
UNCOV
109
        entry.placeholder.parentNode.removeChild(entry.placeholder);
×
110
      }
111
    }
112
  }
113
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc