improve attributes

This commit is contained in:
Philipp Kühn
2020-10-26 20:04:55 +01:00
parent dd95a75a05
commit 4a139f5651
2 changed files with 5 additions and 3 deletions

View File

@@ -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,
} }
}, {}) }, {})

View File

@@ -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,
}), }),
}, },
} }