mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-06 07:06:11 +00:00
fix: FeMerge on paper (#2384)
# Summary Use empty string (`""`) instead of `undefined` for previous filter result in `FeMergeNode`
This commit is contained in:
@@ -6,7 +6,6 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import com.facebook.react.bridge.ReactContext;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableType;
|
||||
import java.util.HashMap;
|
||||
|
||||
@SuppressLint("ViewConstructor")
|
||||
@@ -29,10 +28,9 @@ class FeMergeView extends FilterPrimitiveView {
|
||||
Canvas canvas = new Canvas(result);
|
||||
int nodesSize = this.mNodes.size();
|
||||
for (int i = 0; i < nodesSize; i++) {
|
||||
Bitmap sourceFromResults =
|
||||
this.mNodes.getType(i) == ReadableType.String
|
||||
? resultsMap.get(this.mNodes.getString(i))
|
||||
: prevResult;
|
||||
String nodeKey = this.mNodes.getString(i);
|
||||
Bitmap sourceFromResults = nodeKey.isEmpty() ? prevResult : resultsMap.get(nodeKey);
|
||||
|
||||
if (sourceFromResults != null) {
|
||||
canvas.drawBitmap(sourceFromResults, 0, 0, new Paint());
|
||||
}
|
||||
|
||||
@@ -39,8 +39,6 @@ using namespace facebook::react;
|
||||
id json = RNSVGConvertFollyDynamicToId(node);
|
||||
if ([json isKindOfClass:[NSString class]]) {
|
||||
[nodesArray addObject:[json stringValue]];
|
||||
} else {
|
||||
[nodesArray addObject:[NSNull null]];
|
||||
}
|
||||
}
|
||||
self.nodes = nodesArray;
|
||||
@@ -78,8 +76,7 @@ using namespace facebook::react;
|
||||
|
||||
for (int i = 0; i < [self.nodes count]; i++) {
|
||||
NSString *nodeKey = [self.nodes objectAtIndex:i];
|
||||
CIImage *inputImage =
|
||||
[nodeKey isEqual:[NSNull null]] ? previous : [results objectForKey:[self.nodes objectAtIndex:i]];
|
||||
CIImage *inputImage = [nodeKey isEqual:@""] ? previous : [results objectForKey:nodeKey];
|
||||
if (inputImage == nil) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ interface FilterPrimitiveCommonProps {
|
||||
}
|
||||
|
||||
export interface NativeProps extends ViewProps, FilterPrimitiveCommonProps {
|
||||
nodes?: ReadonlyArray<UnsafeMixed<string | undefined>>;
|
||||
nodes?: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
export default codegenNativeComponent<NativeProps>('RNSVGFeMerge');
|
||||
|
||||
@@ -95,7 +95,7 @@ export const extractFeMerge = (
|
||||
props: FeMergeComponentProps,
|
||||
parent: unknown
|
||||
): FeMergeNativeProps => {
|
||||
const nodes: Array<string | undefined> = [];
|
||||
const nodes: Array<string> = [];
|
||||
const childArray = props.children
|
||||
? React.Children.map(props.children, (child) =>
|
||||
React.cloneElement(child, { parent })
|
||||
@@ -106,7 +106,7 @@ export const extractFeMerge = (
|
||||
const {
|
||||
props: { in: in1 },
|
||||
} = childArray[i];
|
||||
nodes.push(in1);
|
||||
nodes.push(in1 || '');
|
||||
}
|
||||
|
||||
return { nodes };
|
||||
|
||||
Reference in New Issue
Block a user