Skip to content

Commit

Permalink
[arrowheads] Warn if no strokeWidth is given
Browse files Browse the repository at this point in the history
For use of console.warn see:
mui/material-ui#15343
  • Loading branch information
Izhaki committed Sep 29, 2019
1 parent be083c4 commit e6875a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
},
rules: {
'no-alert': 'error',
// 'no-console': 'error',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-constant-condition': 'error',
'no-param-reassign': 'off',
'no-prototype-builtins': 'off',
Expand Down
8 changes: 7 additions & 1 deletion packages/arrowheads/src/withMarker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ export default WrappedComponent => {

withMarker.getTrim = (props, strokeWidth) => {
const { anchor } = WrappedComponent.getMarkerProps(props);
return (1 - anchor) * props.width * strokeWidth;
const trim = (1 - anchor) * props.width * (strokeWidth || 1);
if (trim !== 0 && !strokeWidth) {
console.warn(
`Regraph: a ${WrappedComponent.name} marker may not render correctly as no 'strokeWidth' property was provided to the connection.`
);
}
return trim;
};

withMarker.propTypes = {
Expand Down

0 comments on commit e6875a4

Please sign in to comment.