-
Notifications
You must be signed in to change notification settings - Fork 711
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up and fixes for dart:html usages in code excerpts (#6378)
- Migrated some usages to `package:web` - Added deprecation ignores to a few usages - Removed the excerpts for a few other usages
- Loading branch information
Showing
20 changed files
with
77 additions
and
74 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:web/web.dart' as web; | ||
|
||
void alarm([String? text]) { | ||
web.window.alert(text ?? message); | ||
} | ||
|
||
String get message => 'Hello world from the web!'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,8 @@ resolution: workspace | |
environment: | ||
sdk: ^3.6.1 | ||
|
||
dependencies: | ||
web: ^1.1.0 | ||
|
||
dev_dependencies: | ||
test: ^1.25.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
This package is not an app, it is a collection of code excerpts and associated | ||
tests used in the `dart:html` library tour. | ||
**Deprecated** collection of code excerpts used | ||
in the now-historical `dart:html` library tour. | ||
|
||
All usages of `dart:html` should migrate to `dart:js_interop` and `package:web`. | ||
To learn more, check out [Dart JS interop](https://dart.dev/interop/js-interop). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// ignore_for_file: deprecated_member_use | ||
|
||
@Tags(['browser']) | ||
@TestOn('browser') | ||
library; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,43 @@ | ||
// ignore_for_file: unused_import | ||
|
||
@Tags(['browser']) | ||
@TestOn('browser') | ||
library; | ||
|
||
// #docregion dart-js-interop-import | ||
import 'dart:js_interop'; | ||
// #enddocregion dart-js-interop-import | ||
import 'dart:html'; | ||
// #docregion package-import | ||
import 'package:test/test.dart'; | ||
// #enddocregion package-import | ||
import 'package:web/web.dart'; | ||
|
||
void main() { | ||
test('cascade-operator', () { | ||
final div = '<button id="confirm"></button>'; | ||
document.body?.appendHtml(div); | ||
document.body?.insertAdjacentHTML('beforeend', div.toJS); | ||
|
||
// #docregion cascade-operator | ||
querySelector('#confirm') // Get an object. | ||
?..text = 'Confirm' // Use its members. | ||
..classes.add('important') | ||
document.querySelector('#confirm') // Get an object. | ||
?..textContent = 'Confirm' // Use its members. | ||
..classList.add('important') | ||
..onClick.listen((e) => window.alert('Confirmed!')) | ||
..scrollIntoView(); | ||
// #enddocregion cascade-operator | ||
|
||
expect(document.querySelector('#confirm')?.text, 'Confirm'); | ||
expect(document.querySelector('#confirm')?.textContent, 'Confirm'); | ||
}); | ||
|
||
test('cascade-operator-example-expanded', () { | ||
final div = '<button id="confirm"></button>'; | ||
document.body?.appendHtml(div); | ||
document.body?.insertAdjacentHTML('beforeend', div.toJS); | ||
|
||
// #docregion cascade-operator-example-expanded | ||
var button = querySelector('#confirm'); | ||
button?.text = 'Confirm'; | ||
button?.classes.add('important'); | ||
final button = document.querySelector('#confirm'); | ||
button?.textContent = 'Confirm'; | ||
button?.classList.add('important'); | ||
button?.onClick.listen((e) => window.alert('Confirmed!')); | ||
button?.scrollIntoView(); | ||
// #enddocregion cascade-operator-example-expanded | ||
|
||
expect(document.querySelector('#confirm')?.text, 'Confirm'); | ||
expect(document.querySelector('#confirm')?.textContent, 'Confirm'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters