check for rendered attribute

This commit is contained in:
Philipp Kühn
2020-10-21 23:35:12 +02:00
parent 6752d52541
commit 9fad9cd476
2 changed files with 4 additions and 2 deletions

View File

@@ -3,9 +3,10 @@ import { ExtensionAttribute } from '../types'
export default function getRenderedAttributes(node: Node, attributes: ExtensionAttribute[]) { export default function getRenderedAttributes(node: Node, attributes: ExtensionAttribute[]) {
return attributes return attributes
.map(attribute => { .filter(item => item.attribute.rendered)
.map(item => {
// TODO: fallback if renderHTML doesnt exist // TODO: fallback if renderHTML doesnt exist
return attribute.attribute.renderHTML(node.attrs) return item.attribute.renderHTML(node.attrs)
}) })
.reduce((accumulator, value) => { .reduce((accumulator, value) => {
// TODO: add support for "class" merge // TODO: add support for "class" merge

View File

@@ -69,6 +69,7 @@ export default createNode({
return { return {
id: { id: {
default: '123', default: '123',
rendered: true,
renderHTML: attributes => ({ class: `foo-${attributes.id}`, id: 'foo' }), renderHTML: attributes => ({ class: `foo-${attributes.id}`, id: 'foo' }),
}, },
} }