Releases: niklak/dom_query
0.16.0
Release Notes for 0.16.0 (2025-03-09) 🚀
✨ New Features
- Added
NodeRef::element_ref
, which returns a reference to the underlyingElement
if the node is an element node. - Added
NodeRef::qual_name_ref
, which returns a reference to the qualified name of the node. - Added
NodeRef::has_name
, which checks if the node is an element with the given local name. - Added
NodeRef::is_nonempty_text
, which checks if the node is a non-empty text node.
🔧 Changes
- Optimized element matching: when a single root node is present,
DescendantMatches
(usingDescendantNodes
) is now utilized as the internal iterator, improving performance by eliminating the need for duplicate checks. When multiple root nodes exist,Matches
remains in use, ensuring proper duplicate handling. - Updated
<NodeRef as selectors::Element>::is_link
to always returnfalse
as its impact on element matching was unclear and added unnecessary overhead.
Full Changelog: 0.15.2...0.16.0
0.15.0
Release Notes for 0.15.0 (2025-03-01) 🚀
✨ New Features
- Implemented the
markdown
feature, which allows serializing aDocument
orNodeRef
into Markdown text using themd()
method. - Implemented the
mini_selector
feature, providing a lightweight and faster alternative for element matching with limited CSS selector support. This includes additionalNodeRef
methods:find_descendants
,try_find_descendants
,mini_is
, andmini_match
.
🐛 Bug Fixes
Selection::select
now returns nodes in ascending order if there were multiple underlying root nodes. If there was only one root node, it still returns nodes in ascending order, just as before.
Full Changelog: 0.14.0...0.15.0
0.14.0
Release Notes for 0.14.0 (2025-02-16) 🚀
✨ New Features
- Implemented the
Node::id_attr
andNode::class
methods, which return theid
andclass
attributes of the node, respectively. TheSelection::id
andSelection::class
methods provide the same functionality for the first node in the selection.
🔧 Changes
- Replaced
foldhash::HashSet
withbit-set::BitSet
in theMatches::next
method. This ensures efficient duplicate detection while iterating over matches, asbit-set
offers better performance for this use case. - Revised the
NodeRef::formatted_text
implementation: moved related code to a separate module, extended the formatting logic, and added more test cases.
🐛 Bug Fixes
- Fixed an issue where
DescendantNodes
could traverse beyond the initial node when iterating over descendants, affectingNodeRef::descendants
andNodeRef::descendants_it
.
Full Changelog: 0.13.3...0.14.0
0.13.0
Release Notes for v0.13.0 (2025-02-02) 🚀
✨ New Features
- Text Processing Enhancements:
- Added
NodeRef::normalized_char_count
method to estimate character count in descendant nodes' text after normalization. - Introduced new formatted text retrieval methods across different levels:
Document::formatted_text
for document-level text formattingSelection::formatted_text
for handling formatted text in selectionsNodeRef::formatted_text
for node-specific formatted text extraction
- Added
Changelog
Full Changelog: 0.12.0...0.13.0
0.12.0
Release Notes for v0.12.0 (2025-01-16) 🚀
✨ New Features
-
NodeRef Enhancements:
- Added
NodeRef::is_match
andNodeRef::is
methods for checking if a node matches a given matcher (&Matcher
) or selector (&str
) without creating aSelection
object. - Introduced
NodeRef::find
, an experimental method for finding all descendant elements matching a given path. It is significantly faster thanSelection::select
.
- Added
-
Tree and Document Enhancements:
- Added
Document::base_uri
andNodeRef::base_uri
for retrieving the base URI of a document using thehref
attribute of the<base>
element. Inspired by Node: baseURI property.
- Added
🔨 Improvements
- Selection:
- Reduced usage of
RefCell::borrow
andRefCell::borrow_mut
to simplify internal code.
- Reduced usage of
- Matches:
- Optimized internal code to improve selection performance.
Full Changelog: 0.11.0...0.12.0
0.11.0
Release Notes for v0.11.0 (2024-12-10) 🚀
✨ New Features
-
Atomic Feature:
Added theatomic
feature, which replacesNodeData
's use ofStrTendril
withTendril<tendril::fmt::UTF8, tendril::Atomic>
.
This enablesNodeData
and related structures, includingDocument
, to implement theSend
trait. -
NodeRef Enhancements:
- Introduced
NodeRef::insert_siblings_after
, enabling the insertion of a node along with its siblings after a selected node. - Introduced
NodeRef::before_html
andNodeRef::after_html
for inserting HTML content before or after a specific node.
- Introduced
-
Selection Enhancements:
- Introduced
Selection::set_text
to set the content of each node in the selection to specified content. - Introduced
Selection::before_html
andSelection::after_html
to insert HTML content before or after each node in a selection. - Introduced
Selection::prepend_selection
, allowing nodes from one selection to be prepended to the current selection.
- Introduced
🔨 Improvements
- Internal code changes reduce calls to
RefCell::borrow
andRefCell::borrow_mut
.
Full Changelog: 0.10.0...0.11.0
0.10.0
Release Notes v0.10.0 (November 25, 2024) 🚀
✨ New Features
- Introduced new node manipulation methods:
NodeRef::insert_after
: Insert a node after the selected nodeNodeRef::descendants_it
: Iterate over all descendants of a nodeNodeRef::descendants
: Get a vector containing all descendants of a node
- Added normalization functionality:
NodeRef::normalize
: Merges adjacent text nodes and removes empty text nodes at node levelDocument::normalize
: Performs normalization across the entire document
⚠️ Deprecations
Several methods have been deprecated in favor of more consistently named alternatives:
NodeRef::append_prev_sibling
→NodeRef::insert_before
NodeRef::append_prev_siblings
→NodeRef::insert_siblings_before
Tree::append_prev_sibling_of
→Tree::insert_before_of
🔨 Improvements
- Modified
Document::from
andDocument::fragment
to disable scripting in HTML parser, enabling proper querying ofnoscript
elements
🐛 Fixed
Document::text
method now returns the text content, whereas previously it returned an empty string
🔧 Minor Changes
- Added support for ordered comparison of node IDs through implementation of
Ord
trait forNodeId
🔄 Migration Guide
Users are encouraged to update their code to use the new method names for better maintainability. The deprecated methods will be removed in a future release.
Full Changelog: 0.9.1...0.10.0
0.9.0
Release Notes v0.9.0 (November 9, 2024)
This release includes significant improvements to node selection and manipulation methods, new functionality for content prepending, and a critical bug fix
🔄 Changes
- Added reverse iteration support in
Tree::child_ids_of_it
andNodeRef::children_it
(userev: true
for reverse order) - Improved internal logic for selection operations (
Selection::append_selection
andSelection::replace_with_selection
)
✨ New Features
- Added new node prepending methods:
NodeRef::prepend_child
: Insert a single child at the startNodeRef::prepend_children
: Insert multiple children at the startNodeRef::prepend_html
: Parse and insert HTML content at the startSelection::prepend_html
: Parse and insert HTML at the start of all matched nodes
- Introduced new selection extension methods:
Selection::ancestors
: Get ancestors of matched elementsSelection::add_selection
: Add another selection to current selectionSelection::add_matcher
Selection::add
Selection::try_add
🐛 Bug Fixes
- Enhanced selection operations to properly handle multiple nodes and cross-tree selections:
- Fixed
Selection::append_selection
- Fixed
Selection::replace_with_selection
- Fixed
- Improved node attachment methods to automatically handle node detachment from previous parent:
Node::append_child
Node::append_children
Node::prepend_child
Node::prepend_children
⚠️ Critical Fix
Fixed a significant issue in NodeRef::first_element_child
where the method incorrectly checked the node itself instead of its children. This fix may affect existing code that relies on this method.
Impact:
- CSS selector
:has()
behavior could have been affected - First element child detection logic
- Code depending on this method's behavior
Action Required:
Please review any code that depends on NodeRef::first_element_child
after upgrading to ensure compatibility with the corrected behavior.
Full Changelog: 0.8.0...0.9.0
0.8.0
Release Notes v0.8.0 (November 3, 2024)
This release brings significant internal refactoring, new filtering capabilities, and improvements to node manipulation methods.
🔄 Major Changes
- Simplified internal architecture by replacing generic types with concrete
NodeData
type - Moved implementations from
Node
toNodeRef
(Node
is now an alias forNodeRef
) - Simplified the internal logic of several methods (
replace_with_html
,set_html
,append_html
) usingTree::merge
✨ New Features
- Added new Selection filtering methods:
Selection::filter
Selection::filter_matcher
Selection::try_filter
Selection::filter_selection
- Introduced new NodeRef manipulation methods:
NodeRef::replace_with
- replace a node with another oneNodeRef::replace_with_html
- replace a node with HTML contentNodeRef::set_text
- set node's text contentNodeRef::append_prev_siblings
- prepend nodes before selected node
- Added new
:only-text
pseudo-class for selecting nodes with single text child - Implemented
NodeIdProver
trait forNodeRef
andNode
to simplify API usage
🛠️ Minor Changes
- Simplified
Node::has_text
functionality
🐛 Bug Fixes
- Corrected
<NodeRef<'a> as selectors::Element>::is_empty
to handle line breaks and whitespace properly.
🗑️ Removals
The following deprecated methods have been removed:
Tree::append_children_from_another_tree
Tree::append_prev_siblings_from_another_tree
Node::append_children_from_another_tree
Node::append_prev_siblings_from_another_tree
Full Changelog: 0.7.0...0.8.0
0.7.0
Release Notes v0.7.0 (October 27, 2024)
🚀 New Features
Node Tree API
- Added
Node::ancestors
method to get all or limited number of node ancestors - New methods for working with related elements:
Node::element_children
: returns child nodes ofNodeData::Element
typeNode::children_it
: provides an iterator over child nodesNode::ancestors_it
: provides an iterator over ancestor nodes
- Added
Node::immediate_text
method to get node's text without descendants- Similarly,
Selection::immediate_text
does the same for every node in selection
- Similarly,
Tree API Extensions
- New methods for working with node IDs:
Tree:child_ids_of
andTree:child_ids_of_it
: get child node IDs as vec and as iterator respectivelyTree:ancestor_ids_of
andTree:ancestor_ids_of_it
: get ancestor node IDs as vec and as iterator respectively
Selector Improvements
- Enabled support for
:is()
and:where()
pseudo-classes - Implemented
:has
support from theselectors
crate - Added
From<Vec<Node>>
implementation forSelection
🔄 Changes
Performance Optimizations
- Improved performance for several core operations:
Document::from
Selection::select
- Other related methods
- Switched from
rustc-hash
tofoldhash
API Changes
- Exposed
Matcher::match_element
for use outside the crate - Updated
selectors::Element
implementation forNode<'a>::opaque
- Removed
&mut
requirement fromSelection
methods
Dependencies
- Updated to
selectors
v0.26.0
Full Changelog: 0.6.0...0.7.0