Skip to content

Commit

Permalink
Add filtering on the props passed through to root div wrapping render…
Browse files Browse the repository at this point in the history
…ed text

This prevents warnings from being printed to console, eg when trying to attack the sort_tie_breaker function to DOM element - and also prevents the text/styling from being written as strings to the DOM elements as HTML attributes
  • Loading branch information
jnterry committed May 31, 2020
1 parent bf9a366 commit 096c9dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/OverlappingMarkup.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,15 @@ export default function OverlappingMarkup(props) {

// Return the element set and wrap in container which has the className, styling and onEvent
// handlers specified by props
// We can't just pass props directly since it would cause extra props such as text, styling and
// sort_tie_breaker to be rendered to the DOM (which in the case of sort_tie_breaker, emits
// warnings as we can't very well render a function into the DOM as a HTML attribute)
let div_props = { className: props.className, style: props.style };
for(let k of Object.keys(props)){
if(k.startsWith('on')){ div_props[k] = props[k]; }
}
return (
<div {...props}>
<div {...div_props}>
{ elements }
</div>
);
Expand Down

0 comments on commit 096c9dc

Please sign in to comment.