Skip to content

Commit

Permalink
fix(react): rendering of react for screenreaders (#220)
Browse files Browse the repository at this point in the history
* Fix rendering of react for screenreaders

* Fix rendering of react for screenreaders (#1)

Co-authored-by: WAI YAU <waister@ip-192-168-1-52.eu-west-1.compute.internal>

* Tweak

* Change code to be the source instead of the result

---------

Co-authored-by: WAI YAU <waister@ip-192-168-1-52.eu-west-1.compute.internal>
Co-authored-by: richardmtsr <richard.moss@thestudentroom.com>
  • Loading branch information
3 people authored Mar 27, 2024
1 parent 383d436 commit e875c78
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions packages/bbob-react/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,28 @@ function tagToReactElement(node, index) {
}

function renderToReactNodes(nodes) {
let content = '';
const els = [].concat(nodes).reduce((arr, node, index) => {
if (isTagNode(node)) {
if (content !== '') {
arr.push(content);
content = '';
}
arr.push(tagToReactElement(node, index));
} else if (isStringNode(node)) {
arr.push(node);
if (content === '') {
content = node;
} else {
content += node;
}
}

if (index === nodes.length - 1 && content !== '') {
arr.push(content);
}

return arr;
}, []);

return els;
}

Expand Down

0 comments on commit e875c78

Please sign in to comment.