bemto-components
Advanced tools
Comparing version 2.3.4 to 2.3.5
## Bemto-components changelog | ||
### v2.3.5 (2018-04-06) | ||
- Fixed the state passed to `optional` option. | ||
### v2.3.1–v2.3.4 (2018-04-05) | ||
@@ -4,0 +8,0 @@ |
@@ -373,3 +373,3 @@ const React = require('react'); | ||
if (elemName || item.omitTag || item.tag || item.tagString || item.className || item.props || item.content) { | ||
const optional = typeof item.optional === 'function' ? item.optional(props) : item.optional; | ||
const optional = typeof item.optional === 'function' ? item.optional(props, component.state, component) : item.optional; | ||
if (props['__' + elemName] === false || props['__' + elemName] === null || optional && !elemProp) { | ||
@@ -376,0 +376,0 @@ return; |
{ | ||
"name": "bemto-components", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"description": "Smart components for using parts of BEM methodology with React", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -2075,1 +2075,23 @@ const React = require('react'); | ||
}); | ||
test('optionality of an element based on state', () => { | ||
testSnapshot( | ||
bemto('.myBlock', { | ||
initialState: { foo: true }, | ||
content: [ | ||
{ | ||
optional: (props, state) => !state.foo, | ||
elem: 'Helper', | ||
content: 'helper' | ||
}, | ||
{ | ||
children: true | ||
} | ||
] | ||
}), | ||
{ | ||
}, | ||
'hello there' | ||
); | ||
}); |
Sorry, the diff of this file is not supported yet
1178769
6101