Description
Change Intent
We intend to disallow extending HtmlElement
and other native types, this entails removing the .created
constructors for types in dart:html
and eventually marking those classes with the interface class
modifier.
Justification
Historically, all native types were sealed within the SDK and couldn't be extended (using tricks like only providing factory constructors publicly). This was relaxed only to support custom elements v0.5 long time ago. Last year we deprecated and removed support for custom element (see #49536).
Now we would like to do some additional cleanup in our compilers to remove technical debt related to custom elements. To ensure users don't accidentally trip over old unsupported logic, we would like to make it a static error to use the unsupported patterns. Namely, that would be to make it a static error to extend from HtmlElement going forward.
Impact
Code like:
class A extends HtmlElement {
A.created() : super.created();
}
will now give a compile-time error.
These classes could only be used in combination with the registerElement
API that was removed with Dart 3.0, because of that we believe the impact of this change is limited. The change can affect only developers that removed calls to registerElement
but left intact the classes associated with those calls on the previous breaking change. Note that those classes cannot be instantiated anymore, as such we think the impact of this change is pretty low. Given the correlation of the two APIs, we believe it will be rare for developers to encounter the breaking change.
Mitigation
The recommended mitigation is to remove the subclass,. In the rare case that such subclasses were used for mocking in tests, developers can use implements
instead of extends
to achieve their goals.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status