Tweak error logging

pull/5623/head
Jonatan Svennberg 5 years ago
parent dd0a07b062
commit 19782d4f61

@ -199,7 +199,7 @@ export function claim_element(nodes, name, attributes, svg) {
return node; return node;
} else { } else {
// Ignore hydration errors caused by empty text nodes // Ignore hydration errors caused by empty text nodes
if (node.nodeType !== 3 || !node.data.match(/\s+/)) { if (node.nodeType !== 3 || (node.data !== ' ' && node.data !== '')) {
console.error(`Hydration error: Expected node "${name}" but found`, node); console.error(`Hydration error: Expected node "${name}" but found`, node);
} }
detach(node); detach(node);
@ -211,15 +211,19 @@ export function claim_element(nodes, name, attributes, svg) {
export function claim_text(nodes, data) { export function claim_text(nodes, data) {
const node = nodes[0]; const node = nodes[0];
if (node) { if (node) {
if (node.nodeType === 3) { if (node.nodeType === 3) {
node.data = '' + data; node.data = '' + data;
return nodes.shift(); return nodes.shift();
} else if (!data.match(/\s+/)) { } else if (data !== ' ' && data !== '') {
console.error(`Hydration error: Expected text node "${data}" but found`, node); console.error(
detach(node); `Hydration error: Expected text node "${data}" but found`,
node
);
} }
} }
return text(data); return text(data);
} }

Loading…
Cancel
Save