[fix] setNativeProps inline styles

Inline styles are preserved when using 'setNativeProps'. Adds unit tests
for the resolution logic required by 'setNativeProps'/'resolveStateful'
in a DOM context.

Fix #439
This commit is contained in:
Nicolas Gallagher
2017-04-23 21:24:27 -07:00
parent 64d2d34367
commit a3362e1f38
5 changed files with 117 additions and 67 deletions

View File

@@ -67,12 +67,15 @@ const NativeMethodsMixin = {
* the initial styles from the DOM node and merge them with incoming props.
*/
setNativeProps(nativeProps: Object) {
// DOM state
// Copy of existing DOM state
const node = findNodeHandle(this);
const classList = Array.prototype.slice.call(node.classList);
const style = { ...node.style };
const domStyleProps = { classList, style };
// Next DOM state
const domProps = createDOMProps(nativeProps, style =>
StyleRegistry.resolveStateful(style, classList)
StyleRegistry.resolveStateful(style, domStyleProps)
);
UIManager.updateView(node, domProps, this);
}