Lwc: (engine-restrictions) Lift restrictions on addEventListener's options param for host element

Created on 13 Apr 2020  路  4Comments  路  Source: salesforce/lwc

Description

Adding an event listener on the custom element with a third options argument logs an error.

This restriction should be on the component instance and not on the host element. From the outside world, a DOM element should behave per spec when addEventListener is invoked with the options param, regardless of whether the element is a standard html element or a native custom element or an LWC host element.

Steps to Reproduce

https://playground.lwcjs.org/projects/d1fzv_d_h/3/edit

import { LightningElement, track } from 'lwc';

export default class App extends LightningElement {
    renderedCallback() {
        this.addEventListener('foo', () => {}, { passive: true });
    }
}

Reference: https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

BUG P3

All 4 comments

This issue has been linked to a new work item: W-7446526

I'd have to dig in a little more but giving users the ability to subscribe to the capture phase of focusin might require us to refactor our delegatesFocus implementation. It might be fine as long as we always run first, not sure...

Looks like we only restrict this for the host element:
https://playground.lwcjs.org/projects/LY4Z_tvOv/1/edit

Was this page helpful?
0 / 5 - 0 ratings