Skip to content

Commit

Permalink
fix(ios): roottag property should not be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonelmy authored and zoomchan-cxj committed Aug 1, 2022
1 parent 3e18e89 commit 34ca26f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ios/sdk/component/view/HippyShadowView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -727,10 +727,10 @@ - (NSDictionary *)mergeProps:(NSDictionary *)props {
NSMutableDictionary *needUpdatedProps = [[NSMutableDictionary alloc] initWithDictionary:props];
NSMutableArray<NSString *> *sameKeys = [NSMutableArray new];
[self.props enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key, id _Nonnull obj, __unused BOOL *stop) {
if ([key isEqualToString:@"rootTag"]) {
return;
}
if (needUpdatedProps[key] == nil) {
// HippyNilIfNull方法会将NULL转化为nil,对于数字类型属性则为0,导致实际上为kCFNull的属性,最终会转化为0
//比如view长宽属性,前端并没有设置其具体数值,而使用css需要终端计算大小,但由于上述机制,导致MTT排版引擎将其宽高设置为0,0,引发bug
//因此这里做个判断,遇到mergeprops时,如果需要删除的属性是布局相关类型,那一律将新值设置为默认值
needUpdatedProps[key] = [self defaultValueForKey:key];
} else {
if ([needUpdatedProps[key] isEqual:obj]) {
Expand Down
2 changes: 1 addition & 1 deletion ios/sdk/module/uimanager/HippyUIManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ - (void)updateViewWithHippyTag:(NSNumber *)hippyTag props:(NSDictionary *)pros {
NSDictionary *newProps = props;
NSDictionary *virtualProps = props;
if (shadowView) {
newProps = [shadowView mergeProps: props];
newProps = [shadowView mergeProps:props];
virtualProps = shadowView.props;
[componentData setProps:newProps forShadowView:shadowView];
}
Expand Down

0 comments on commit 34ca26f

Please sign in to comment.