diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 33e261183a9..0c9b5d0ed92 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -13389,10 +13389,14 @@ class Element extends Node
} else if (alignment == ScrollAlignment.BOTTOM) {
this._scrollIntoView(false);
} else if (hasScrollIntoViewIfNeeded) {
+ // TODO(srujzs): This method shouldn't be calling out to
+ // `scrollIntoViewIfNeeded`. Remove this and make `scrollIntoView` match
+ // the browser definition. If you intend to use `scrollIntoViewIfNeeded`,
+ // use the `Element.scrollIntoViewIfNeeded` method.
if (alignment == ScrollAlignment.CENTER) {
- this._scrollIntoViewIfNeeded(true);
+ this.scrollIntoViewIfNeeded(true);
} else {
- this._scrollIntoViewIfNeeded();
+ this.scrollIntoViewIfNeeded();
}
} else {
this._scrollIntoView();
@@ -14896,8 +14900,18 @@ class Element extends Node
@JSName('scrollIntoView')
void _scrollIntoView([Object? arg]) native;
- @JSName('scrollIntoViewIfNeeded')
- void _scrollIntoViewIfNeeded([bool? centerIfNeeded]) native;
+ /**
+ * Nonstandard version of `scrollIntoView` that scrolls the current element
+ * into the visible area of the browser window if it's not already within the
+ * visible area of the browser window. If the element is already within the
+ * visible area of the browser window, then no scrolling takes place.
+ *
+ * ## Other resources
+ *
+ * * [Element.scrollIntoViewIfNeeded](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded)
+ * from MDN.
+ */
+ void scrollIntoViewIfNeeded([bool? centerIfNeeded]) native;
void scrollTo([options_OR_x, num? y]) {
if (options_OR_x == null && y == null) {
diff --git a/tools/dom/docs.json b/tools/dom/docs.json
index e1a453b6c60..2dfd29c508b 100644
--- a/tools/dom/docs.json
+++ b/tools/dom/docs.json
@@ -1270,6 +1270,19 @@
" * See [EventStreamProvider] for usage information.",
" */"
],
+ "scrollIntoViewIfNeeded": [
+ "/**",
+ " * Nonstandard version of `scrollIntoView` that scrolls the current element",
+ " * into the visible area of the browser window if it's not already within the",
+ " * visible area of the browser window. If the element is already within the",
+ " * visible area of the browser window, then no scrolling takes place.",
+ " *",
+ " * ## Other resources",
+ " *",
+ " * * [Element.scrollIntoViewIfNeeded](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded)",
+ " * from MDN.",
+ " */"
+ ],
"searchEvent": [
"/**",
" * Static factory designed to expose `search` events to event",
diff --git a/tools/dom/scripts/htmlrenamer.py b/tools/dom/scripts/htmlrenamer.py
index 30fa1af4dbf..13f18fb3b2a 100644
--- a/tools/dom/scripts/htmlrenamer.py
+++ b/tools/dom/scripts/htmlrenamer.py
@@ -403,7 +403,6 @@ private_html_members = monitored.Set(
'Element.getElementsByTagName',
'Element.insertAdjacentHTML',
'Element.scrollIntoView',
- 'Element.scrollIntoViewIfNeeded',
'Element.getAttribute',
'Element.getAttributeNS',
'Element.hasAttribute',
diff --git a/tools/dom/templates/html/impl/impl_Element.darttemplate b/tools/dom/templates/html/impl/impl_Element.darttemplate
index a0ce567b922..3ff4bcc4a57 100644
--- a/tools/dom/templates/html/impl/impl_Element.darttemplate
+++ b/tools/dom/templates/html/impl/impl_Element.darttemplate
@@ -1007,10 +1007,14 @@ $endif
} else if (alignment == ScrollAlignment.BOTTOM) {
this._scrollIntoView(false);
} else if (hasScrollIntoViewIfNeeded) {
+ // TODO(srujzs): This method shouldn't be calling out to
+ // `scrollIntoViewIfNeeded`. Remove this and make `scrollIntoView` match
+ // the browser definition. If you intend to use `scrollIntoViewIfNeeded`,
+ // use the `Element.scrollIntoViewIfNeeded` method.
if (alignment == ScrollAlignment.CENTER) {
- this._scrollIntoViewIfNeeded(true);
+ this.scrollIntoViewIfNeeded(true);
} else {
- this._scrollIntoViewIfNeeded();
+ this.scrollIntoViewIfNeeded();
}
} else {
this._scrollIntoView();