Derive a block directive's empty content from its node, and let readEmptyKeys own the attrs=empty-stands-alone rule
This commit is contained in:
@@ -16,7 +16,8 @@ export function spellsEmpty(value: DirectiveValue | undefined): boolean {
|
||||
return value?.spelling === emptyValue
|
||||
}
|
||||
|
||||
export function readEmptyKeys(attributes: DirectiveAttributes, keys: readonly EmptyKey[]): Read<EmptyKeysRead> {
|
||||
// `held` is whether the directive spells an attribute outside {attrs}: an argument or a content slot.
|
||||
export function readEmptyKeys(type: string, attributes: DirectiveAttributes, keys: readonly EmptyKey[], held: boolean): Read<EmptyKeysRead> {
|
||||
const rest = new Map(attributes)
|
||||
const empty = new Set<EmptyKey>()
|
||||
for (const key of keys) {
|
||||
@@ -26,5 +27,6 @@ export function readEmptyKeys(attributes: DirectiveAttributes, keys: readonly Em
|
||||
empty.add(key)
|
||||
rest.delete(key)
|
||||
}
|
||||
if (empty.has('attrs') && (held || [...rest.keys()].some((key) => key !== 'marks'))) return { fault: unsupportedNodeShape(`${type} spells attrs=empty beside an attribute it holds`) }
|
||||
return { value: { empty, rest } }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user