4c - the label trim, the segment tail, the break run and the guard's spread stop re-walking

This commit is contained in:
2026-09-18 18:04:44 +02:00
parent 538e0ce665
commit 503efa4f82
6 changed files with 60 additions and 15 deletions
+6
View File
@@ -77,3 +77,9 @@ test('accepts the JSON values an attribute may hold', () => {
assert.equal(isAdfDocument({ content: [{ attrs: { a: [1, 'x', null, true, { b: 2 }] }, type: 'paragraph' }], type: 'doc', version: 1 }), true)
assert.equal(isAdfDocument({ content: [{ attrs: { a: [() => 1] }, type: 'paragraph' }], type: 'doc', version: 1 }), false)
})
test("reads a node's siblings as a walk rather than as one call's arguments", () => {
const wide = { content: [{ content: Array.from({ length: 200000 }, () => ({ type: 'rule' })), type: 'blockquote' }], type: 'doc', version: 1 }
assert.equal(isAdfDocument(wide), true)
assert.equal(fault(wide), 'accepted')
})
+2 -2
View File
@@ -96,7 +96,7 @@ function isNodeArray(value: readonly unknown[]): value is readonly AdfNode[] {
if ('content' in node) {
const content = node['content']
if (!Array.isArray(content)) return false
pending.push(...content)
for (const child of content) pending.push(child)
}
}
return true
@@ -109,7 +109,7 @@ function nestingFault(nodes: readonly AdfNode[]): ConvertFault | undefined {
if (node === undefined) continue
const fault = attributesFault(nodeAttrs(node), node.type) ?? marksFault(nodeMarks(node))
if (fault !== undefined) return fault
pending.push(...nodeContent(node))
for (const child of nodeContent(node)) pending.push(child)
}
return undefined
}