From dfc7a91717cfb9c112fb0c8457aa4a13dcb879a5 Mon Sep 17 00:00:00 2001 From: April Sylph <28949509+AprilSylph@users.noreply.github.com> Date: Tue, 16 Nov 2021 10:38:36 +0000 Subject: [PATCH] set data-subtype on all NPF block elements attributes now go data-block then data-subtype which i like more also adds data-subtype to paywall-type block elements --- src/lib/npf.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/npf.js b/src/lib/npf.js index 2173476..5208d33 100644 --- a/src/lib/npf.js +++ b/src/lib/npf.js @@ -74,8 +74,6 @@ const blockRenderers = { 'unordered-list-item': 'li' })[subtype] || 'p'); - if (subtype) Object.assign(element.dataset, { subtype }); - element.append(...applyFormatting({ text, formatting })); return element; @@ -196,7 +194,10 @@ const blockRenderers = { } }; -const renderBlock = block => blockRenderers[block.type](block).tap(element => { element.dataset.block = block.type; }); +const renderBlock = block => blockRenderers[block.type](block).tap(element => { + element.dataset.block = block.type; + if (block.subtype) element.dataset.subtype = block.subtype; +}); const applyFormatting = ({ text, formatting = [] }) => { if (!formatting.length) {