[dart:html] Deprecate custom element registration APIs.

The `registerElement` APIs in `dart:html` are legacy APIs based on a
deprecated Web Components v0.5 specification. These methods don't work
on modern browsers and can only be used with a polyfill.

The latest Web Components specification is supported indirectly via
JSInterop and doesn't have an explicit API in the `dart:html` library.

This change marks these APIs as deprecated. We intend to remove them in
the future (see https://github.com/dart-lang/sdk/issues/49536)

Fixes https://github.com/dart-lang/sdk/issues/48973

Change-Id: I2e96d36e95c9971b59cde80bc4da49b63d12b17c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252840
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
This commit is contained in:
Sigmund Cherem 2022-07-28 16:07:30 +00:00 committed by Commit Bot
parent a8c4ccc783
commit b62e612dc8
5 changed files with 49 additions and 2 deletions

View file

@ -29,6 +29,14 @@
[`MirrorsUsed`]: https://api.dart.dev/stable/dart-mirrors/MirrorsUsed-class.html
[`Comment`]: https://api.dart.dev/stable/dart-mirrors/Comment-class.html
#### `dart:html`
- Deprecated `registerElement` and `registerElement2` in `Document` and
`HtmlDocument`. These APIs were based on the deprecated Web Components v0.5
specification and are not supported by browsers today. These APIs are expected
to be deleted in a future release. See the related breaking change
request [#49536](https://github.com/dart-lang/sdk/issues/49536).
### Tools
#### Linter

View file

@ -10113,6 +10113,7 @@ class Document extends Node {
String queryCommandValue(String commandId) native;
@deprecated
Function registerElement2(String type, [Map? options]) {
if (options != null) {
var options_1 = convertDartToNative_Dictionary(options);
@ -10122,8 +10123,10 @@ class Document extends Node {
}
@JSName('registerElement')
@deprecated
Function _registerElement2_1(type, options) native;
@JSName('registerElement')
@deprecated
Function _registerElement2_2(type) native;
@JSName('webkitExitFullscreen')
@ -10423,6 +10426,7 @@ class Document extends Node {
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));
/// Checks if [registerElement] is supported on the current platform.
@deprecated
bool get supportsRegisterElement {
return JS('bool', '("registerElement" in #)', this);
}
@ -10431,6 +10435,13 @@ class Document extends Node {
@deprecated
bool get supportsRegister => supportsRegisterElement;
/// **Deprecated**: This is a legacy API based on a deprecated Web Components
/// v0.5 specification. Web Components v0.5 doesn't work on modern browsers
/// and can only be used with a polyfill.
///
/// The latest Web Components specification is supported indirectly via
/// JSInterop and doesn't have an explicit API in the `dart:html` library.
@deprecated
void registerElement(String tag, Type customElementClass,
{String? extendsTag}) {
registerElement2(
@ -17831,6 +17842,15 @@ class HtmlDocument extends Document {
}
/**
* **Deprecated**: This is a legacy API based on a deprecated Web Components
* v0.5 specification. This method doesn't work on modern browsers and can
* only be used with a polyfill.
*
* The latest Web Components specification is supported indirectly via
* JSInterop and doesn't have an explicit API in the `dart:html` library.
*
* *Original documentation before deprecation*:
*
* Register a custom subclass of Element to be instantiatable by the DOM.
*
* This is necessary to allow the construction of any custom elements.
@ -17871,6 +17891,7 @@ class HtmlDocument extends Document {
* `<input is="x-bar"></input>`
*
*/
@deprecated
Function registerElement2(String tag, [Map? options]) {
return _registerCustomElement(JS('', 'window'), this, tag, options);
}

View file

@ -6737,10 +6737,10 @@
"readyState": {},
"referrer": {},
"registerElement": {
"support_level": "untriaged"
"support_level": "deprecated"
},
"registerElement2": {
"support_level": "untriaged"
"support_level": "deprecated"
},
"rootElement": {
"support_level": "untriaged"

View file

@ -28,6 +28,7 @@ $!MEMBERS
new _FrozenElementList<T>._wrap(_querySelectorAll(selectors));
/// Checks if [registerElement] is supported on the current platform.
@deprecated
bool get supportsRegisterElement {
return JS('bool', '("registerElement" in #)', this);
}
@ -36,6 +37,13 @@ $!MEMBERS
@deprecated
bool get supportsRegister => supportsRegisterElement;
/// **Deprecated**: This is a legacy API based on a deprecated Web Components
/// v0.5 specification. Web Components v0.5 doesn't work on modern browsers
/// and can only be used with a polyfill.
///
/// The latest Web Components specification is supported indirectly via
/// JSInterop and doesn't have an explicit API in the `dart:html` library.
@deprecated
void registerElement(String tag, Type customElementClass,
{String$NULLABLE extendsTag}) {
registerElement2(tag, {'prototype': customElementClass, 'extends': extendsTag});

View file

@ -63,6 +63,15 @@ $!MEMBERS
/**
* **Deprecated**: This is a legacy API based on a deprecated Web Components
* v0.5 specification. This method doesn't work on modern browsers and can
* only be used with a polyfill.
*
* The latest Web Components specification is supported indirectly via
* JSInterop and doesn't have an explicit API in the `dart:html` library.
*
* *Original documentation before deprecation*:
*
* Register a custom subclass of Element to be instantiatable by the DOM.
*
* This is necessary to allow the construction of any custom elements.
@ -103,6 +112,7 @@ $!MEMBERS
* `<input is="x-bar"></input>`
*
*/
@deprecated
Function registerElement2(String tag, [Map$NULLABLE options]) {
return _registerCustomElement(JS('', 'window'), this, tag, options);
}