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

Loading…
Cancel
Save