Skip to content

Commit e3fa588

Browse files
committed
100% code coverage, explained every single code ignore
1 parent 5fd6f35 commit e3fa588

14 files changed

Lines changed: 1196 additions & 1022 deletions

File tree

cjs/objects/Updates.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,28 @@ const create = (root, paths) => {
7474
// involved in the DOM update/change and dispatch
7575
// related information to them
7676
const dispatchAll = (nodes, type) => {
77-
const isConnected = type === CONNECTED;
77+
const event = new Event(type);
7878
const length = nodes.length;
79-
for (let event, i = 0; i < length; i++) {
79+
for (let i = 0; i < length; i++) {
8080
let node = nodes[i];
8181
if (node.nodeType === ELEMENT_NODE) {
82-
event = dispatchTarget(node, isConnected, type, event);
82+
dispatchTarget(node, event);
8383
}
8484
}
8585
};
8686

8787
// the way it's done is via the components weak set
8888
// and recursively looking for nested components too
89-
const dispatchTarget = (node, isConnected, type, event) => {
89+
const dispatchTarget = (node, event) => {
9090
if (components.has(node)) {
91-
if (!event) event = new Event(type);
9291
node.dispatchEvent(event);
93-
}
94-
else {
92+
} else {
9593
const children = node.children;
9694
const length = children.length;
9795
for (let i = 0; i < length; i++) {
98-
event = dispatchTarget(children[i], isConnected, type, event);
96+
dispatchTarget(children[i], event);
9997
}
10098
}
101-
return event;
10299
}
103100

104101
// finding all paths is a one-off operation performed
@@ -133,6 +130,11 @@ const find = (node, paths, parts) => {
133130
}
134131
break;
135132
case TEXT_NODE:
133+
// the following ignore is actually covered by browsers
134+
// only basicHTML ends up on previous COMMENT_NODE case
135+
// instead of TEXT_NODE because it knows nothing about
136+
// special style or textarea behavior
137+
/* istanbul ignore if */
136138
if (
137139
SHOULD_USE_TEXT_CONTENT.test(node.nodeName) &&
138140
trim.call(child.textContent) === UIDC
@@ -164,9 +166,15 @@ const findAttributes = (node, paths, parts) => {
164166
const attribute = array[i];
165167
if (attribute.value === UID) {
166168
const name = attribute.name;
169+
// the following ignore is covered by IE
170+
// and the IE9 double viewBox test
171+
/* istanbul ignore else */
167172
if (!(name in cache)) {
168173
const realName = parts.shift().replace(/^(?:|[\S\s]*?\s)(\S+?)=['"]?$/, '$1');
169174
cache[name] = attributes[realName] ||
175+
// the following ignore is covered by browsers
176+
// while basicHTML is already case-sensitive
177+
/* istanbul ignore next */
170178
attributes[realName.toLowerCase()];
171179
paths.push(Path.create('attr', cache[name], realName));
172180
}

cjs/shared/utils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,28 @@ exports.createFragment = createFragment;
6363
const cloneNode = hasDoomedCloneNode ?
6464
node => {
6565
const clone = node.cloneNode();
66-
const childNodes = node.childNodes || [];
66+
const childNodes = node.childNodes ||
67+
// this is an excess of caution
68+
// but some node, in IE, might not
69+
// have childNodes property.
70+
// The following fallback ensure working code
71+
// in older IE without compromising performance
72+
// or any other browser/engine involved.
73+
/* istanbul ignore next */
74+
[];
6775
const length = childNodes.length;
6876
for (let i = 0; i < length; i++) {
6977
clone.appendChild(cloneNode(childNodes[i]));
7078
}
7179
return clone;
7280
} :
81+
// the following ignore is due code-coverage
82+
// combination of not having document.importNode
83+
// but having a working node.cloneNode.
84+
// This shenario is common on older Android/WebKit browsers
85+
// but basicHTML here tests just two major cases:
86+
// with document.importNode or with broken cloneNode.
87+
/* istanbul ignore next */
7388
node => node.cloneNode(true);
7489

7590
// used to import html into fragments

coverage/coverage.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)