diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 5de65567595..1d80781a2fb 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -404,9 +404,15 @@ impl EventTarget { }); match idx { - Some(idx) => { - entries[idx].listener = - EventListenerType::Inline(listener.unwrap_or(InlineEventListener::Null)); + Some(idx) => match listener { + // Replace if there's something to replace with, + // but remove entirely if there isn't. + Some(listener) => { + entries[idx].listener = EventListenerType::Inline(listener); + }, + None => { + entries.remove(idx); + }, }, None => { if let Some(listener) = listener { diff --git a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-removal.window.js.ini b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-removal.window.js.ini index 0a33b8d57c0..b89234a7182 100644 --- a/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-removal.window.js.ini +++ b/tests/wpt/metadata/html/webappapis/scripting/events/event-handler-removal.window.js.ini @@ -1,10 +1,3 @@ [event-handler-removal.window.html] [Event handler set through content attribute should be deactivated when the content attribute is removed.] expected: FAIL - - [Event handler set through IDL should be deactivated when the IDL attribute is set to null.] - expected: FAIL - - [Event handler set through content attribute should be removed when they are set to null.] - expected: FAIL -