mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00
FIX: ListView items' dom-nodes are disposed before remove (#4369)
* FIX: ListView items' dom nodes are disposed before remove * Extend property black list * More attribute changed checks
This commit is contained in:

committed by
GitHub

parent
c62e79e17b
commit
114b969986
@ -18,14 +18,19 @@ const propertyBlacklist = [
|
|||||||
"effectiveBorderBottomWidth",
|
"effectiveBorderBottomWidth",
|
||||||
"effectiveBorderLeftWidth",
|
"effectiveBorderLeftWidth",
|
||||||
"effectiveMinWidth",
|
"effectiveMinWidth",
|
||||||
|
"effectiveMinHeight",
|
||||||
"nodeName",
|
"nodeName",
|
||||||
"nodeType",
|
"nodeType",
|
||||||
"decodeWidth",
|
"decodeWidth",
|
||||||
"decodeHeight"
|
"decodeHeight",
|
||||||
]
|
"ng-reflect-items",
|
||||||
|
"domNode",
|
||||||
|
"touchListenerIsSet",
|
||||||
|
"bindingContext"
|
||||||
|
];
|
||||||
|
|
||||||
function notifyInspector(callback: (inspector: Inspector) => void) {
|
function notifyInspector(callback: (inspector: Inspector) => void) {
|
||||||
const ins = (<any>global).__inspector
|
const ins = (<any>global).__inspector;
|
||||||
if (ins) {
|
if (ins) {
|
||||||
callback(ins);
|
callback(ins);
|
||||||
}
|
}
|
||||||
@ -35,9 +40,9 @@ function valueToString(value: any): string {
|
|||||||
if (typeof value === "undefined" || value === null) {
|
if (typeof value === "undefined" || value === null) {
|
||||||
return "";
|
return "";
|
||||||
} else if (value instanceof Color) {
|
} else if (value instanceof Color) {
|
||||||
return value.toString()
|
return value.toString();
|
||||||
} else if (typeof value === "object") {
|
} else if (typeof value === "object" && value.unit) {
|
||||||
return PercentLength.convertToString(value)
|
return PercentLength.convertToString(value);
|
||||||
} else {
|
} else {
|
||||||
return value + "";
|
return value + "";
|
||||||
}
|
}
|
||||||
@ -76,7 +81,7 @@ export class DOMNode {
|
|||||||
nodeType;
|
nodeType;
|
||||||
nodeName;
|
nodeName;
|
||||||
localName;
|
localName;
|
||||||
nodeValue = '';
|
nodeValue = "";
|
||||||
attributes: string[] = [];
|
attributes: string[] = [];
|
||||||
viewRef: WeakRef<ViewBase>;
|
viewRef: WeakRef<ViewBase>;
|
||||||
|
|
||||||
@ -89,7 +94,7 @@ export class DOMNode {
|
|||||||
|
|
||||||
// Load all attributes
|
// Load all attributes
|
||||||
this.loadAttributes();
|
this.loadAttributes();
|
||||||
|
|
||||||
registerNode(this);
|
registerNode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +126,6 @@ export class DOMNode {
|
|||||||
onChildAdded(childView: ViewBase): void {
|
onChildAdded(childView: ViewBase): void {
|
||||||
notifyInspector((ins) => {
|
notifyInspector((ins) => {
|
||||||
const view = this.viewRef.get();
|
const view = this.viewRef.get();
|
||||||
childView.ensureDomNode();
|
|
||||||
|
|
||||||
let previousChild: ViewBase;
|
let previousChild: ViewBase;
|
||||||
view.eachChild((child) => {
|
view.eachChild((child) => {
|
||||||
@ -135,19 +139,22 @@ export class DOMNode {
|
|||||||
});
|
});
|
||||||
const index = !!previousChild ? previousChild._domId : 0;
|
const index = !!previousChild ? previousChild._domId : 0;
|
||||||
|
|
||||||
|
childView.ensureDomNode();
|
||||||
ins.childNodeInserted(this.nodeId, index, childView.domNode.toJSON());
|
ins.childNodeInserted(this.nodeId, index, childView.domNode.toJSON());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onChildRemoved(view: ViewBase): void {
|
onChildRemoved(view: ViewBase): void {
|
||||||
notifyInspector((ins) => {
|
notifyInspector((ins) => {
|
||||||
ins.childNodeRemoved(this.nodeId, view.domNode.nodeId);
|
ins.childNodeRemoved(this.nodeId, view._domId);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
attributeModified(name: string, value: any) {
|
attributeModified(name: string, value: any) {
|
||||||
notifyInspector((ins) => {
|
notifyInspector((ins) => {
|
||||||
ins.attributeModified(this.nodeId, name, valueToString(value));
|
if (propertyBlacklist.indexOf(name) < 0) {
|
||||||
|
ins.attributeModified(this.nodeId, name, valueToString(value));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,5 +200,5 @@ export class DOMNode {
|
|||||||
children: this.children.map(c => c.toObject()),
|
children: this.children.map(c => c.toObject()),
|
||||||
attributes: this.attributes
|
attributes: this.attributes
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user