Skip to content

Commit

Permalink
fix root tagName change
Browse files Browse the repository at this point in the history
  • Loading branch information
sebkolind committed May 20, 2024
1 parent a981108 commit 0c92274
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.32] - 2024-05-20

### Fixed

- Fix when root node becomes a new tag ([#38](https://github.com/tentjs/tent/issues/38))

## [0.0.31] - 2024-05-20

### Fixed
Expand Down
6 changes: 6 additions & 0 deletions src/walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { addAttribute } from './attributes';
import { type Attrs, type TentNode } from './types';

function walker<A extends Attrs>(oldNode: TentNode<A>, newNode: TentNode<A>) {
if (oldNode.tagName !== newNode.tagName) {
oldNode.replaceWith(newNode);

return;
}

const nc = Array.from(newNode.childNodes, (n) => n as TentNode<A>);
const oc = Array.from(oldNode.childNodes, (n) => n as TentNode<A>);

Expand Down

0 comments on commit 0c92274

Please sign in to comment.