Skip to content

Commit

Permalink
Remove dart:html page (#6345)
Browse files Browse the repository at this point in the history
Fixes #6314

---------

Co-authored-by: Parker Lougheed <[email protected]>
  • Loading branch information
MaryaBelanger and parlough authored Jan 22, 2025
1 parent d9d877a commit 9b3d96a
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 22 deletions.
7 changes: 5 additions & 2 deletions examples/misc/test/language_tour/browser_test.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// ignore_for_file: unused_import

@Tags(['browser'])
@TestOn('browser')
library;

// #docregion dart-html-import
// #docregion dart-js-interop-import
import 'dart:js_interop';
// #enddocregion dart-js-interop-import
import 'dart:html';
// #enddocregion dart-html-import
// #docregion package-import
import 'package:test/test.dart';
// #enddocregion package-import
Expand Down
8 changes: 4 additions & 4 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@
{ "source": "/docs/spec/deferred-loading", "destination": "/language/libraries#lazily-loading-a-library", "type": 301 },
{ "source": "/docs/spec{,/**}", "destination": "/resources/language/spec", "type": 301 },
{ "source": "/docs/technical-overview{,/**}", "destination": "/overview", "type": 301 },
{ "source": "/docs/tutorials/add-elements", "destination": "/library/dart-html", "type": 301 },
{ "source": "/docs/tutorials/add-elements", "destination": "/interop/js-interop/package-web", "type": 301 },
{ "source": "/docs/tutorials/cmdline", "destination": "/tutorials/server/cmdline", "type": 301 },
{ "source": "/docs/tutorials/connect-dart-html", "destination": "/library/dart-html", "type": 301 },
{ "source": "/docs/tutorials/connect-dart-html", "destination": "/interop/js-interop/package-web", "type": 301 },
{ "source": "/docs/tutorials/fetchdata", "destination": "/tutorials/server/fetch-data", "type": 301 },
{ "source": "/docs/tutorials/futures", "destination": "/libraries/async/async-await", "type": 301 },
{ "source": "/docs/tutorials/get-started", "destination": "/tutorials/server/get-started", "type": 301 },
{ "source": "/docs/tutorials/httpserver", "destination": "/tutorials/server/httpserver", "type": 301 },
{ "source": "/docs/tutorials/remove-elements", "destination": "/library/dart-html", "type": 301 },
{ "source": "/docs/tutorials/remove-elements", "destination": "/interop/js-interop/package-web", "type": 301 },
{ "source": "/docs/tutorials/shared-pkgs", "destination": "/tools/pub/packages", "type": 301 },
{ "source": "/docs/tutorials/streams", "destination": "/libraries/async/using-streams", "type": 301 },
{ "source": "/docs/tutorials{,/**}", "destination": "/tutorials", "type": 301 },
Expand Down Expand Up @@ -436,7 +436,7 @@
{ "source": "/tutorials/web/fetch-data", "destination": "/tutorials/server/fetch-data", "type": 301 },
{ "source": "/tutorials/web/get-started", "destination": "/web/get-started", "type": 301 },
{ "source": "/tutorials/web/low-level-html", "destination": "/web/get-started", "type": 301 },
{ "source": "/tutorials/web/low-level-html/:rest*", "destination": "/libraries/dart-html", "type": 301 },
{ "source": "/tutorials/web/low-level-html/:rest*", "destination": "/interop/js-interop/package-web", "type": 301 },
{ "source": "/web/dart-2", "destination": "/tools/webdev", "type": 301 },
{ "source": "/web/js-interop", "destination": "/interop/js-interop", "type": 301 },
{ "source": "/{docs,tools}/{pub-package-manager,pub/cmd,pub/tools/pub}/glossary", "destination": "/tools/pub/glossary", "type": 301 }
Expand Down
5 changes: 3 additions & 2 deletions src/_data/sidenav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@
permalink: /libraries/dart-convert
- title: dart:io
permalink: /libraries/dart-io
- title: dart:html
permalink: /libraries/dart-html
- title: dart:js_interop
permalink: /interop/js-interop
match-page-url-exactly: true
- divider
- title: Iterable collections
permalink: /libraries/collections/iterables
Expand Down
3 changes: 3 additions & 0 deletions src/content/interop/js-interop/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
title: JavaScript interoperability
short-title: JS interop
description: Integrate JavaScript code into your Dart web app.
nextpage:
url: /interop/js-interop/usage
title: Usage
---

The [Dart web platform](/overview#web-platform) supports communication with
Expand Down
6 changes: 6 additions & 0 deletions src/content/interop/js-interop/js-types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
title: JS types
description: Usage information about the core types in JS interop.
prevpage:
url: /interop/js-interop/usage
title: Usage
nextpage:
url: /interop/js-interop/tutorials
title: JS interop tutorials
---

Dart values and JS values belong to separate language domains. When compiling to
Expand Down
3 changes: 3 additions & 0 deletions src/content/interop/js-interop/package-web.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
title: Migrate to package:web
description: How to migrate web interop code from dart:html to package:web.
prevpage:
url: /interop/js-interop/past-js-interop
title: Past JS interop
---

Dart's [`package:web`][] exposes access to browser APIs,
Expand Down
6 changes: 6 additions & 0 deletions src/content/interop/js-interop/past-js-interop.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
title: Past JS interop
description: Archive of Dart's previous JS interop support.
prevpage:
url: /interop/js-interop/tutorials
title: JS interop tutorials
nextpage:
url: /interop/js-interop/package-web/
title: Migrate to package:web
---

:::warning
Expand Down
6 changes: 6 additions & 0 deletions src/content/interop/js-interop/tutorials.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
title: JS interop tutorials
description: Tutorials for common JavaScript interop use cases in Dart.
prevpage:
url: /interop/js-interop/js-types
title: JS types
nextpage:
url: /interop/js-interop/past-js-interop
title: Past JS interop
---

## Tutorials
Expand Down
6 changes: 6 additions & 0 deletions src/content/interop/js-interop/usage.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
---
title: Usage
description: How to declare and use JS interop members.
prevpage:
url: /interop/js-interop/
title: JS interop
nextpage:
url: /interop/js-interop/js-types
title: JS types
---

JS interop provides the mechanisms to interact with JavaScript APIs from Dart.
Expand Down
8 changes: 4 additions & 4 deletions src/content/language/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ like `public` or `private`, consult
Use `import` to specify how a namespace from one library is used in the
scope of another library.

For example, Dart web apps generally use the [dart:html][]
For example, Dart web apps generally use the [`dart:js_interop`][]
library, which they can import like this:

<?code-excerpt "misc/test/language_tour/browser_test.dart (dart-html-import)"?>
<?code-excerpt "misc/test/language_tour/browser_test.dart (dart-js-interop-import)"?>
```dart
import 'dart:html';
import 'dart:js_interop';
```

The only required argument to `import` is a URI specifying the
Expand Down Expand Up @@ -178,6 +178,6 @@ for advice on how to implement a package, including:
* How to use conditional imports and exports to implement
a library that supports multiple platforms.

[dart:html]: {{site.dart-api}}/dart-html
[`dart:js_interop`]: {{site.dart-api}}/dart-js_interop/dart-js_interop-library.html
[doc comments]: /effective-dart/documentation#consider-writing-a-library-level-doc-comment
[metadata annotations]: /language/metadata
7 changes: 3 additions & 4 deletions src/content/libraries/dart-html.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ prevpage:
---

:::warning
`dart:html` is being replaced with [`package:web`][].
Package maintainers should migrate to `package:web` as
soon as possible to be compatible with Wasm.
Read the [Migrate to package:web][] page for guidance.
The `dart:html` library is deprecated.
Instead, use [`dart:js_interop`][] and [`package:web`][].
:::

Use the [dart:html][] library to program the browser, manipulate objects and
Expand All @@ -36,6 +34,7 @@ To use the HTML library in your web app, import dart:html:
import 'dart:html';
```

[`dart:js_interop`]: /interop/js-interop
[`package:web`]: {{site.pub-pkg}}/web
[Migrate to package:web]: /interop/js-interop/package-web

Expand Down
4 changes: 2 additions & 2 deletions src/content/libraries/dart-io.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ prevpage:
url: /libraries/dart-convert
title: dart:convert
nextpage:
url: /libraries/dart-html
title: dart:html
url: /interop/js-interop/
title: dart:js_interop
---

<?code-excerpt plaster="none"?>
Expand Down
6 changes: 3 additions & 3 deletions src/content/libraries/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ consult the [Dart API reference.][Dart API]
: I/O for programs that can use the Dart VM,
including Flutter apps, servers, and command-line scripts.

[dart:html](/libraries/dart-html)
: DOM and other APIs for browser-based apps.
We now recommend using `package:web` over `dart:html`.
[dart:js_interop](/interop/js-interop)
: APIs for interop with the web platform.
Along with `package:web`,`dart:js_interop` replaces `dart:html`.


As mentioned, these pages are just an overview;
Expand Down
2 changes: 1 addition & 1 deletion src/content/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ providing essentials for many everyday programming tasks:
(`dart:isolate`)
* HTML elements and other resources for web-based applications that need to
interact with the browser and the Document Object Model (DOM)
(`dart:html`)
(`dart:js_interop` and `package:web`)

Beyond the core libraries, many APIs are provided through
a comprehensive set of packages.
Expand Down

0 comments on commit 9b3d96a

Please sign in to comment.