Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions integration_tests/specs/dom/elements/custom-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,4 +576,22 @@ describe('custom html element', () => {
done();
}, 800);
});

it('unmount widgetElements should works when contains image', async (done) => {
let container = document.createElement('flutter-container');
let img = document.createElement('img');
img.src = 'https://gw.alicdn.com/tfs/TB1CxCYq5_1gK0jSZFqXXcpaXXa-128-90.png';
let wrapper = createElement('div', {}, [
img
]);
container.appendChild(wrapper);
document.body.appendChild(container);

img.onload = async () => {
requestAnimationFrame(() => {
document.body.removeChild(container);
done();
});
};
});
});
2 changes: 1 addition & 1 deletion webf/lib/src/html/img.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ImageElement extends Element {
RenderReplaced renderReplaced = renderBoxModel as RenderReplaced;
renderReplaced.child = null;

_renderImage?.dispose();
ownerDocument.inactiveRenderObjects.add(_renderImage);
_renderImage = null;
}
}
Expand Down
4 changes: 1 addition & 3 deletions webf/lib/src/widget/element_flutter_element_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ class WebFHTMLElementToFlutterElementAdaptor extends MultiChildRenderObjectEleme
void unmount() {
// Flutter element unmount call dispose of _renderObject, so we should not call dispose in unmountRenderObject.
dom.Element element = widget.webFElement;

super.unmount();

element.unmountRenderObject(dispose: false, fromFlutterWidget: true);
super.unmount();
}

@override
Expand Down