diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec.mm b/AsyncDisplayKit/Layout/ASLayoutSpec.mm index a74dcd941d..e523643f52 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASLayoutSpec.mm @@ -81,8 +81,14 @@ static NSString * const kDefaultChildrenKey = @"kDefaultChildrenKey"; id finalLayoutable = [child finalLayoutable]; if (finalLayoutable != child) { - // Layout options state of child needs to be copied to final layoutable, but don't override customized values. - ASEnvironmentStatePropagateUp(finalLayoutable, child.environmentState.layoutOptionsState); + if (ASEnvironmentStatePropagationEnabled()) { + ASEnvironmentStatePropagateUp(finalLayoutable, child.environmentState.layoutOptionsState); + } else { + // If state propagation is not enabled the layout options state needs to be copied manually + ASEnvironmentState finalLayoutableEnvironmentState = finalLayoutable.environmentState; + finalLayoutableEnvironmentState.layoutOptionsState = child.environmentState.layoutOptionsState; + finalLayoutable.environmentState = finalLayoutableEnvironmentState; + } return finalLayoutable; } } diff --git a/AsyncDisplayKit/Private/ASEnvironmentInternal.h b/AsyncDisplayKit/Private/ASEnvironmentInternal.h index e69bed23a0..9bd2c305d4 100644 --- a/AsyncDisplayKit/Private/ASEnvironmentInternal.h +++ b/AsyncDisplayKit/Private/ASEnvironmentInternal.h @@ -12,7 +12,7 @@ #pragma once -enum class ASEnvironmentStatePropagation { DOWN, UP }; +BOOL ASEnvironmentStatePropagationEnabled(); #pragma mark - Set and get extensible values for layout options @@ -33,6 +33,11 @@ void ASEnvironmentPerformBlockOnObjectAndChildren(id object, void void ASEnvironmentPerformBlockOnObjectAndParents(id object, void(^block)(id object)); +#pragma mark - + +enum class ASEnvironmentStatePropagation { DOWN, UP }; + + #pragma mark - Merging static const struct ASEnvironmentStateExtensions ASEnvironmentDefaultStateExtensions = {}; diff --git a/AsyncDisplayKit/Private/ASEnvironmentInternal.mm b/AsyncDisplayKit/Private/ASEnvironmentInternal.mm index 1c83494683..08689548b2 100644 --- a/AsyncDisplayKit/Private/ASEnvironmentInternal.mm +++ b/AsyncDisplayKit/Private/ASEnvironmentInternal.mm @@ -17,6 +17,11 @@ #define AS_SUPPORT_PROPAGATION NO +BOOL ASEnvironmentStatePropagationEnabled() +{ + return AS_SUPPORT_PROPAGATION; +} + #pragma mark - Traversing an ASEnvironment Tree @@ -109,7 +114,7 @@ ASEnvironmentState ASEnvironmentMergeObjectAndState(ASEnvironmentState environme // Merge object and layout options state LOG(@"Merge object and state: %@ - ASEnvironmentLayoutOptionsState", object); - if (!AS_SUPPORT_PROPAGATION) { + if (!ASEnvironmentStatePropagationEnabled()) { return environmentState; }