Releases: niklak/dom_query
Releases · niklak/dom_query
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
0.6.0
[0.6.0] - 2024-10-19
Changed
- Exposed
Document::tree
. Selection
methods that required&mut
now doesn't require&mut
.- Changed the project structure, now modules are divided based on the
struct
implementations.
Added
- Added
Node::append_html
andNode::set_html
methods for creating children nodes of a single selected node. - Added
Tree<NodeData>::new_element
, an easy way to create an empty element with a given name. - Added
NodeRef::last_child
. - Added
Node::has_attr
method, which returnstrue
if an attribute exists on the node element.
Selection::has_attr
does the same thing for the first node inside selection. - Added
Node::remove_all_attrs
method for removing all attributes of a node.
Selection::remove_all_attrs
does the same thing for the every node inside selection. - Added
Node::remove_attrs
method, a convenient way to remove multiple attributes from the node element.
Selection::remove_attrs
does the same thing for the every node inside selection. - Added
Node::rename
method, which allows to change node's name.
Selection::rename
does the same thing for the every node inside selection.
Full Changelog: 0.5.0...0.6.0
0.5.0
[0.5.0] - 2024-10-10
Added
- Added
select_single_matcher
andselect_single
methods forDocument
andSelection
. - Added
Document::fragment
which allows to create a document fragment.
Changed
- Update documentation
- A small breaking change:
From
implementation forDocument
, now it is based onInto<StrTendril>
and because of that, previousFrom<&String>
implementation will not work anymore (they are in config). If your code consumes&String
, you should useString::as_str()
instead. - Refactored the code (
NodeData::Element
).