i have following piece of test code used jest load react component in "dom".
const actiondropdownerrornode =(data,mystyles={})=>{ let actiondropdownerr = testutils.renderintodocument( <div><actiondropdownerror data={data || <div></div>} styles={mystyles}/></div> ); return reactdom.finddomnode(actiondropdownerr).firstchild; };
now when check contents of element
<span classname={styles.solution || "solution"}>{data.solution}</span>
it returns text_node want if alter element to:
<span classname={styles.solution || "solution"}>{data.solution} </span>
it returns comment_node why ?
for reference purpose how data.solution out of element tag:
const elementcontent = node =>{ if (node.nodetype === 1 && node.firstchild !== null) { if (node.firstchild.nodetype ===3){ elements.push(node.firstchild.textcontent); } }
};
a space in jsx result empty string " "
:
so <span classname={styles.solution || "solution"}>{data.solution}</span>
result :
react.createelement( "span", { classname: styles.solution || "solution" }, data.solution );
and <span classname={styles.solution || "solution"}>{data.solution} </span>
result :
react.createelement( "span", { classname: styles.solution || "solution" }, data.solution, " " );
Comments
Post a Comment