• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cheeriojs / cheerio / 47105190599
99%

Build:
DEFAULT BRANCH: main
Ran 03 Dec 2026 12:24PM UTC
Jobs 1
Files 16
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

03 Dec 2026 12:23PM UTC coverage: 99.49% (+0.005%) from 99.485%
47105190599

push

github

web-flow
fix(manipulation): wrap removed elements (#5563)

Fixes [#5562](https://github.com/cheeriojs/cheerio/issues/5562).

After `.remove()`, `.wrap()` and `.wrapAll()` left the elements unwrapped, and `.wrapInner()` with a selector found no wrapper:

```js
const $ = load('<main><span>hello</span></main>');
const item = $('span').remove();

item.wrap('<section class="wrapper"></section>');
item.parent().prop('outerHTML');
// before: undefined
// now:    '<section class="wrapper"><span>hello</span></section>'
```

The three methods now wrap elements that have no parent, as jQuery does:

- The wrapper stays detached with them, and the original document is unchanged. A wrapper that is part of the document is taken out of it, as it would be moved for an attached element.
- A selector wrapper is looked up in the loaded document, since a removed element has no ancestors to search. `.wrap()` and `.wrapInner()` use a copy of the match, as for attached elements, so the document keeps it. `.wrapAll()` takes the match itself out of the document and wraps with it, as it moves the match for attached elements.

The document root is still never wrapped. `wrapInner()` with a selector on the root finds no wrapper and changes nothing, and a `wrapAll()` callback is still called once for the root, as on main.

Tests cover each method on removed elements, with an existing wrapper and with a selector, and the document-root cases for all three, including the `wrapAll()` callback.

280 of 280 branches covered (100.0%)

Branch coverage included in aggregate %.

11 of 11 new or added lines in 1 file covered. (100.0%)

891 of 897 relevant lines covered (99.33%)

3308.59 hits per line

Jobs
ID Job ID Ran Files Coverage
1 47105190599.1 03 Dec 2026 12:24PM UTC 16
99.49
GitHub Action Run
Source Files on build 47105190599
  • Tree
  • List 16
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #47105190599
  • 8eaa0ebc on github
  • Prev Build on main (#47105014976)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc