Skip to content

Releases: niklak/dom_query

0.11.0

11 Dec 09:32
Compare
Choose a tag to compare

Release Notes for v0.11.0 (2024-12-10) 🚀

📚 Check out examples

✨ New Features

  • Atomic Feature:
    Added the atomic feature, which replaces NodeData's use of StrTendril with Tendril<tendril::fmt::UTF8, tendril::Atomic>.
    This enables NodeData and related structures, including Document, to implement the Send 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 and NodeRef::after_html for inserting HTML content before or after a specific node.
  • Selection Enhancements:

    • Introduced Selection::set_text to set the content of each node in the selection to specified content.
    • Introduced Selection::before_html and Selection::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.

🔨 Improvements

  • Internal code changes reduce calls to RefCell::borrow and RefCell::borrow_mut.

Changelog

Full Changelog: 0.10.0...0.11.0

0.10.0

25 Nov 10:08
Compare
Choose a tag to compare

Release Notes v0.10.0 (November 25, 2024) 🚀

📚 Check out examples

✨ New Features

  • Introduced new node manipulation methods:
    • NodeRef::insert_after: Insert a node after the selected node
    • NodeRef::descendants_it: Iterate over all descendants of a node
    • NodeRef::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 level
    • Document::normalize: Performs normalization across the entire document

⚠️ Deprecations

Several methods have been deprecated in favor of more consistently named alternatives:

  • NodeRef::append_prev_siblingNodeRef::insert_before
  • NodeRef::append_prev_siblingsNodeRef::insert_siblings_before
  • Tree::append_prev_sibling_ofTree::insert_before_of

🔨 Improvements

  • Modified Document::from and Document::fragment to disable scripting in HTML parser, enabling proper querying of noscript 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 for NodeId

🔄 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.

Changelog

Full Changelog: 0.9.1...0.10.0

0.9.0

09 Nov 18:01
Compare
Choose a tag to compare

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 and NodeRef::children_it (use rev: true for reverse order)
  • Improved internal logic for selection operations (Selection::append_selection and Selection::replace_with_selection)

✨ New Features

  • Added new node prepending methods:
    • NodeRef::prepend_child: Insert a single child at the start
    • NodeRef::prepend_children: Insert multiple children at the start
    • NodeRef::prepend_html: Parse and insert HTML content at the start
    • Selection::prepend_html: Parse and insert HTML at the start of all matched nodes
  • Introduced new selection extension methods:
    • Selection::ancestors: Get ancestors of matched elements
    • Selection::add_selection: Add another selection to current selection
    • Selection::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
  • 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.

Changelog

Full Changelog: 0.8.0...0.9.0

0.8.0

03 Nov 15:35
Compare
Choose a tag to compare

Release Notes v0.8.0 (November 3, 2024)

This release brings significant internal refactoring, new filtering capabilities, and improvements to node manipulation methods.

📚 Check out examples

🔄 Major Changes

  • Simplified internal architecture by replacing generic types with concrete NodeData type
  • Moved implementations from Node to NodeRef (Node is now an alias for NodeRef)
  • Simplified the internal logic of several methods (replace_with_html, set_html, append_html) using Tree::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 one
    • NodeRef::replace_with_html - replace a node with HTML content
    • NodeRef::set_text - set node's text content
    • NodeRef::append_prev_siblings - prepend nodes before selected node
  • Added new :only-text pseudo-class for selecting nodes with single text child
  • Implemented NodeIdProver trait for NodeRef and Node 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

Changelog

Full Changelog: 0.7.0...0.8.0

0.7.0

27 Oct 11:14
Compare
Choose a tag to compare

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 of NodeData::Element type
    • Node::children_it: provides an iterator over child nodes
    • Node::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

Tree API Extensions

  • New methods for working with node IDs:
    • Tree:child_ids_of and Tree:child_ids_of_it: get child node IDs as vec and as iterator respectively
    • Tree:ancestor_ids_of and Tree: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 the selectors crate
  • Added From<Vec<Node>> implementation for Selection

🔄 Changes

Performance Optimizations

  • Improved performance for several core operations:
    • Document::from
    • Selection::select
    • Other related methods
  • Switched from rustc-hash to foldhash

API Changes

  • Exposed Matcher::match_element for use outside the crate
  • Updated selectors::Element implementation for Node<'a>::opaque
  • Removed &mut requirement from Selection methods

Dependencies

  • Updated to selectors v0.26.0

Changelog

Full Changelog: 0.6.0...0.7.0

0.6.0

19 Oct 16:36
Compare
Choose a tag to compare

[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 and Node::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 returns true 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.

Changelog

Full Changelog: 0.5.0...0.6.0

0.5.0

10 Oct 13:26
Compare
Choose a tag to compare

[0.5.0] - 2024-10-10

Added

  • Added select_single_matcher and select_single methods for Document and Selection.
  • Added Document::fragment which allows to create a document fragment.

Changed

  • Update documentation
  • A small breaking change: From implementation for Document, now it is based on Into<StrTendril> and because of that, previous From<&String> implementation will not work anymore (they are in config). If your code consumes &String, you should use String::as_str() instead.
  • Refactored the code (NodeData::Element).

Changelog