mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-22 11:16:55 +08:00
[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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user