Skip to content

Commit 24628f0

Browse files
authored
Merge pull request #3171 from joseph2rs/widget_image_fix_revoke_object_url
fix: [Widget Image] Remove oldurl string check since it's always a string and prevent the ObjectURL cleaning resulting in a memory leak.
2 parents 8cf38cf + 1ca079e commit 24628f0

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

packages/controls/src/widget_audio.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export class AudioView extends DOMWidgetView {
6262
// Clean up the old objectURL
6363
const oldurl = this.el.src;
6464
this.el.src = url;
65-
if (oldurl && typeof oldurl !== 'string') {
65+
if (oldurl) {
6666
URL.revokeObjectURL(oldurl);
6767
}
6868

packages/controls/src/widget_image.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ export class ImageView extends DOMWidgetView {
6262
// Clean up the old objectURL
6363
const oldurl = this.el.src;
6464
this.el.src = url;
65-
if (oldurl && typeof oldurl !== 'string') {
65+
if (oldurl) {
6666
URL.revokeObjectURL(oldurl);
6767
}
68+
6869
const width = this.model.get('width');
6970
if (width !== undefined && width.length > 0) {
7071
this.el.setAttribute('width', width);

packages/controls/src/widget_video.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class VideoView extends DOMWidgetView {
6565
// Clean up the old objectURL
6666
const oldurl = this.el.src;
6767
this.el.src = url;
68-
if (oldurl && typeof oldurl !== 'string') {
68+
if (oldurl) {
6969
URL.revokeObjectURL(oldurl);
7070
}
7171

0 commit comments

Comments
 (0)