Skip to content

html / svg: shadowing definitions of onClick etc #32422

Open
@rakudrama

Description

Element and SvgElement both declare an onClick getter:

class Element extends Node ... {
...
  static const EventStreamProvider<MouseEvent> clickEvent =
      const EventStreamProvider<MouseEvent>('click');
...
  ElementStream<MouseEvent> get onClick => clickEvent.forElement(this);
class SvgElement extends Element implements GlobalEventHandlers {
...
  static const EventStreamProvider<MouseEvent> clickEvent =
      const EventStreamProvider<MouseEvent>('click');
...
  ElementStream<MouseEvent> get onClick => clickEvent.forElement(this);

These declarations are the same, so it would me more efficient if SvgElement inherited the onClick getter from Element.
With inheritance, there would be one declaration, which would allow get:onClick to be inlined (on dart2js).

We know the inlining is beneficial: onClick can currently be inlined when the receiver is known to be HtmlElement, and the inlined code avoids an allocation.

Metadata

Assignees

No one assigned

    Labels

    area-webUse area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop.library-htmltype-enhancementA request for a change that isn't a bugweb-librariesIssues impacting dart:html, etc., libraries

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions