improve attributes
This commit is contained in:
@@ -26,9 +26,12 @@ export default function injectExtensionAttributesToParseRule(parseRule: ParseRul
|
|||||||
[item.name]: (node as HTMLElement).dataset[item.name],
|
[item.name]: (node as HTMLElement).dataset[item.name],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const filteredAttributes = Object.fromEntries(Object.entries(attributes)
|
||||||
|
.filter(([, value]) => value !== undefined && value !== null))
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...items,
|
...items,
|
||||||
...attributes,
|
...filteredAttributes,
|
||||||
}
|
}
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ const Link = createMark({
|
|||||||
target: attributes.target,
|
target: attributes.target,
|
||||||
}),
|
}),
|
||||||
parseHTML: node => ({
|
parseHTML: node => ({
|
||||||
// TODO: always return default value on `null` or `undefined`
|
target: node.getAttribute('target'),
|
||||||
target: node.getAttribute('target') || this.options.target,
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user