From acf0bebdd764d2400dc4e9e18577813c0f9e90c3 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 7 Dec 2023 14:48:15 -0800 Subject: [PATCH] fixes to the return types of several Node helper extension methods (#121) * fixes to the return types of several Node helper extension methods * update changelog * Update lib/src/helpers/extensions.dart * deprecated two helper extension methods --- CHANGELOG.md | 9 ++++++--- lib/src/helpers.dart | 1 + lib/src/helpers/extensions.dart | 7 +++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71f5ee7a..e809f5ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,12 @@ - Exported the helper libraries from `web.dart`. - Deprecated the `helpers.dart` library in favor of `web.dart`. - Updated the readme to include usage info and package status. -- Add an example. -- `src/helpers.dart`: - - Added event extensions for `WebSocket` +- Added an example. +- Added event extensions for `WebSocket` +- Fixes to the return types of the `append()` and `clone()` extension methods on + `Node`. +- Deprecated `NodeGlue.append` in favor of `Node.appendChild`. +- Deprecated `NodeGlue.clone` in favor of `Node.cloneNode`. ## 0.4.0 diff --git a/lib/src/helpers.dart b/lib/src/helpers.dart index d3d6b974..2771bf5e 100644 --- a/lib/src/helpers.dart +++ b/lib/src/helpers.dart @@ -9,6 +9,7 @@ /// to have from `dart:html`. /// /// This helper layer serves two purposes: +/// /// * provide useful functionality in environments where `dart:html` is not /// available (like on Wasm). /// * help bridge the gap in functionality from the past, which may reduce diff --git a/lib/src/helpers/extensions.dart b/lib/src/helpers/extensions.dart index 54513b7f..01356444 100644 --- a/lib/src/helpers/extensions.dart +++ b/lib/src/helpers/extensions.dart @@ -7,6 +7,7 @@ /// /// The extensions here are added by hand over time, depending on needs and use /// cases. They currently consist of: +/// /// * renames: methods that provide the same functionality, but use a more /// idiomatic Dart name. Typically these renames match the names used in /// `dart:html` in the past. @@ -66,8 +67,10 @@ extension CanvasRenderingContext2DGlue on CanvasRenderingContext2D { extension NodeGlue on Node { set text(String s) => textContent = s; - void append(Node other) => appendChild(other); - void clone(bool deep) => cloneNode(deep); + @Deprecated('See Node.appendChild()') + Node append(Node other) => appendChild(other); + @Deprecated('See Node.cloneNode()') + Node clone(bool? deep) => cloneNode(deep ?? false); } extension EventGlue on MouseEvent {