mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-17 19:21:20 +03:00
fix(react): rendering of react for screenreaders (#220)
* 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>
This commit is contained in:
@@ -22,16 +22,28 @@ function tagToReactElement(node, index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderToReactNodes(nodes) {
|
function renderToReactNodes(nodes) {
|
||||||
|
let content = '';
|
||||||
const els = [].concat(nodes).reduce((arr, node, index) => {
|
const els = [].concat(nodes).reduce((arr, node, index) => {
|
||||||
if (isTagNode(node)) {
|
if (isTagNode(node)) {
|
||||||
|
if (content !== '') {
|
||||||
|
arr.push(content);
|
||||||
|
content = '';
|
||||||
|
}
|
||||||
arr.push(tagToReactElement(node, index));
|
arr.push(tagToReactElement(node, index));
|
||||||
} else if (isStringNode(node)) {
|
} 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 arr;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return els;
|
return els;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user