dont use data- attributes as default

This commit is contained in:
Philipp Kühn 2020-10-27 11:54:58 +01:00
parent 4b046d7034
commit 2c52f0ce06
3 changed files with 2 additions and 14 deletions

View File

@ -8,7 +8,7 @@ export default function getRenderedAttributes(nodeOrMark: Node | Mark, extension
.map(item => {
if (!item.attribute.renderHTML) {
return {
[`data-${item.name}`]: nodeOrMark.attrs[item.name],
[item.name]: nodeOrMark.attrs[item.name],
}
}

View File

@ -23,7 +23,7 @@ export default function injectExtensionAttributesToParseRule(parseRule: ParseRul
const attributes = item.attribute.parseHTML
? item.attribute.parseHTML(node as HTMLElement)
: {
[item.name]: (node as HTMLElement).dataset[item.name],
[item.name]: (node as HTMLElement).getAttribute(item.name),
}
const filteredAttributes = Object.fromEntries(Object.entries(attributes)

View File

@ -26,21 +26,9 @@ const Link = createMark({
return {
href: {
default: null,
renderHTML: attributes => ({
href: attributes.href,
}),
parseHTML: node => ({
href: node.getAttribute('href'),
}),
},
target: {
default: this.options.target,
renderHTML: attributes => ({
target: attributes.target,
}),
parseHTML: node => ({
target: node.getAttribute('target'),
}),
},
}
},