Skip to content

Commit

Permalink
Deprecate a few more things before we launch v2 (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo authored Feb 26, 2025
1 parent 6538aca commit 222164b
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 13 deletions.
5 changes: 5 additions & 0 deletions web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.1.1

- Deprecated `Node.text` extension. Use `Node.textContent` instead.
- Deprecated `[]` extensions on `Storage`.

## 1.1.0

- Added `HttpStatus` class that declares http status codes. This is a copy of
Expand Down
1 change: 0 additions & 1 deletion web/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ linter:
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_runtimeType_toString
- package_api_docs
- prefer_const_declarations
- prefer_final_locals
- unnecessary_await_in_return
Expand Down
2 changes: 1 addition & 1 deletion web/example/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import 'package:web/web.dart';

void main() {
final div = document.querySelector('div')!;
div.text = 'Text set at ${DateTime.now()}';
div.textContent = 'Text set at ${DateTime.now()}';
}
4 changes: 2 additions & 2 deletions web/lib/src/helpers/events/streams.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ class _EventStreamSubscription<T extends html.Event>
// `dart:html` it would have printed 1, 2, 4, 3
//
// ```dart
// import 'package:web/helpers.dart';
// import 'package:web/web.dart';
//
// main() {
// void main() {
// print('1');
// final body = document.body!;
// body.onTouchStart.first.whenComplete(() {
Expand Down
9 changes: 6 additions & 3 deletions web/lib/src/helpers/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ extension HTMLCanvasElementGlue on HTMLCanvasElement {
}

extension CanvasRenderingContext2DGlue on CanvasRenderingContext2D {
@Deprecated('See CanvasRenderingContext2D.drawImage')
void drawImageScaled(
CanvasImageSource image,
double dx,
Expand All @@ -70,6 +71,7 @@ extension CanvasRenderingContext2DGlue on CanvasRenderingContext2D {
}

extension NodeGlue on Node {
@Deprecated('See Node.textContent')
set text(String s) => textContent = s;
@Deprecated('See Node.appendChild()')
Node append(Node other) => appendChild(other);
Expand Down Expand Up @@ -98,7 +100,9 @@ extension TouchGlue on Touch {
}

extension StorageGlue on Storage {
@Deprecated('Use Storage.getItem instead')
String? operator [](String key) => getItem(key);
@Deprecated('Use Storage.setItem instead')
void operator []=(String key, String value) => setItem(key, value);
}

Expand All @@ -119,9 +123,8 @@ extension XMLHttpRequestGlue on XMLHttpRequest {
// from Closure's goog.net.Xhrio.getResponseHeaders.
final headers = <String, String>{};
final headersString = getAllResponseHeaders();
final headersList =
LineSplitter.split(headersString).where((header) => header.isNotEmpty);
for (final header in headersList) {
for (final header in LineSplitter.split(headersString)
.where((header) => header.isNotEmpty)) {
final split = header.split(': ');
if (split.length <= 1) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion web/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: web
version: 1.1.0
version: 1.1.1
description: Lightweight browser API bindings built around JS interop.
repository: https://github.com/dart-lang/web

Expand Down
6 changes: 3 additions & 3 deletions web/test/helpers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ void main() {

test('Converts a JS list to a dart list using JSImmutableListWrapper', () {
final div = (document.createElement('div'))
..append(document.createElement('div')..text = '1')
..append(document.createElement('div')..text = '2')
..append(document.createElement('div')..text = '3');
..append(document.createElement('div')..textContent = '1')
..append(document.createElement('div')..textContent = '2')
..append(document.createElement('div')..textContent = '3');

final List<Node> dartList =
JSImmutableListWrapper<NodeList, Node>(div.querySelectorAll('div'));
Expand Down
1 change: 0 additions & 1 deletion web_generator/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ linter:
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- no_runtimeType_toString
- package_api_docs
- prefer_const_declarations
- prefer_final_locals
- unnecessary_await_in_return
Expand Down
4 changes: 3 additions & 1 deletion web_generator/lib/src/translator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,9 @@ class _PartialInterfacelike {
}
final isStatic = operation.special == 'static';
if (shouldQueryMDN &&
!_shouldGenerateMember(operationName, isStatic: isStatic)) break;
!_shouldGenerateMember(operationName, isStatic: isStatic)) {
break;
}
final docs = shouldQueryMDN
? mdnInterface?.propertyFor(operationName, isStatic: isStatic)
: null;
Expand Down

0 comments on commit 222164b

Please sign in to comment.