mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-02-08 22:42:40 +08:00
Cleanup mNativeChildren on react node cleanup.
Differential Revision: D2663443 fb-gh-sync-id: 7e6e7212103b738f6b6f535e54cc8b86e5def685
This commit is contained in:
committed by
facebook-github-bot-8
parent
0b46a0c13b
commit
337dc7e093
@@ -137,20 +137,22 @@ public class ReactShadowNode extends CSSNode {
|
||||
}
|
||||
|
||||
public void removeAllChildren() {
|
||||
int decrease = 0;
|
||||
for (int i = getChildCount() - 1; i >= 0; i--) {
|
||||
super.removeChildAt(i);
|
||||
ReactShadowNode removed = (ReactShadowNode) super.removeChildAt(i);
|
||||
decrease += removed.mIsLayoutOnly ? removed.mTotalNativeChildren : 1;
|
||||
}
|
||||
markUpdated();
|
||||
|
||||
updateNativeChildrenCountInParent(-mTotalNativeChildren);
|
||||
mTotalNativeChildren = 0;
|
||||
mTotalNativeChildren -= decrease;
|
||||
updateNativeChildrenCountInParent(-decrease);
|
||||
}
|
||||
|
||||
private void updateNativeChildrenCountInParent(int delta) {
|
||||
if (mIsLayoutOnly) {
|
||||
ReactShadowNode parent = getParent();
|
||||
while (parent != null) {
|
||||
parent.mTotalNativeChildren -= delta;
|
||||
parent.mTotalNativeChildren += delta;
|
||||
if (!parent.mIsLayoutOnly) {
|
||||
break;
|
||||
}
|
||||
@@ -289,6 +291,15 @@ public class ReactShadowNode extends CSSNode {
|
||||
return removed;
|
||||
}
|
||||
|
||||
public void removeAllNativeChildren() {
|
||||
if (mNativeChildren != null) {
|
||||
for (int i = mNativeChildren.size() - 1; i >= 0; i--) {
|
||||
mNativeChildren.get(i).mNativeParent = null;
|
||||
}
|
||||
mNativeChildren.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public int getNativeChildCount() {
|
||||
return mNativeChildren == null ? 0 : mNativeChildren.size();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user