rvx
Version:
A signal based rendering library
34 lines • 1.12 kB
JavaScript
import { ENV } from "../core/env.js";
import { View } from "../core/view.js";
export function assertViewState(view) {
if (!(view instanceof View)) {
throw new Error("view is not a View");
}
const env = ENV.current;
if (!(view.first instanceof env.Node)) {
throw new Error("view.first is not a Node");
}
if (!(view.last instanceof env.Node)) {
throw new Error("view.last is not a Node");
}
if (view.first !== view.last) {
const parent = view.first.parentNode;
if (!(parent instanceof env.Node)) {
throw new Error("view.first.parent is not a Node");
}
let node = view.first.nextSibling;
nodes: for (;;) {
if (node === null) {
throw new Error("view is unterminated");
}
if (!(node instanceof env.Node)) {
throw new Error("view contains non-Node");
}
if (node === view.last) {
break nodes;
}
node = node.nextSibling;
}
}
}
//# sourceMappingURL=assert-view-state.js.map