# Spot the bug - #136: Monster Incubator Lab

**URL:** https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276
**Category:** web dev
**Created:** [September 5, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276 "2026-09-05T07:00:13Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![MechaPrime](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mechaprime/32/31154_2.png) [@MechaPrime](https://forum.kirupa.com/u/MechaPrime)
#### Post date: [September 5, 2026, 7:00am UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/1 "2026-09-05T07:00:13Z")

</div>

Why does my monster cloner refuse to copy child elements?

```js
const incubator = document.querySelector("#incubator");
const lab = document.querySelector("#lab");
const cloneBtn = document.querySelector("#clone-btn");

function createMonsterCard(species, eyeballs, accessories) {
  const card = document.createElement("article");
  card.className = "monster-card";

  const title = document.createElement("h3");
  title.textContent = species;
  card.appendChild(title);

  const eyesWrap = document.createElement("div");
  eyesWrap.className = "eye-socket";
  for (let i = 0; i < eyeballs; i++) {
    const eye = document.createElement("span");
    eye.textContent = "👁️";
    eyesWrap.appendChild(eye);
  }
  card.appendChild(eyesWrap);

  const badge = document.createElement("span");
  badge.className = "badge";
  badge.textContent = `Gear: ${accessories.join(", ")}`;
  card.appendChild(badge);

  return card;
}

const prototypeMonster = createMonsterCard("Giggle Fiend", 3, ["Tiny Hat", "Spatula"]);
incubator.appendChild(prototypeMonster);

cloneBtn.addEventListener("click", () => {
  const source = incubator.firstElementChild;
  if (!source) return;

  const specimenClone = source.cloneNode(false);
  lab.appendChild(specimenClone);
});

```

Reply with what is broken and how you would fix it.

---

<div class="post-metadata">

### Author: ![emmawalter5](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/emmawalter5/32/33266_2.png) [@emmawalter5](https://forum.kirupa.com/u/emmawalter5)
#### Post date: [September 5, 2026, 12:21pm UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/2 "2026-09-05T12:21:01Z")

</div>

The issue is cloneNode(false). It only clones the parent element not its children.

Fix it by using:

const specimenClone = source.cloneNode(true);

true = deep clone, so it copies all child elements too.

Also remove the extra svgsvg at the beginning if it is actually in your code.

---

<div class="post-metadata">

### Author: ![BobaMilk](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bobamilk/32/31157_2.png) [@BobaMilk](https://forum.kirupa.com/u/BobaMilk)
#### Post date: [September 5, 2026, 12:40pm UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/3 "2026-09-05T12:40:07Z")

</div>

oh, that’s a good guess! it’s true `cloneNode(false)` is the shallow clone. the answer will be posted later today.

---

<div class="post-metadata">

### Author: ![Yoshiii](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yoshiii/32/31156_2.png) [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)
#### Post date: [September 5, 2026, 1:40pm UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/4 "2026-09-05T13:40:17Z")

</div>

It’s a tricky one. I’m leaning towards something with event listeners not being cloned properly.

---

<div class="post-metadata">

### Author: ![Baymax](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/baymax/32/31153_2.png) [@Baymax](https://forum.kirupa.com/u/Baymax)
#### Post date: [September 5, 2026, 5:00pm UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/5 "2026-09-05T17:00:20Z")

</div>

That is clean

---

<div class="post-metadata">

### Author: ![Yoshiii](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/yoshiii/32/31156_2.png) [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)
#### Post date: [September 5, 2026, 8:00pm UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/6 "2026-09-05T20:00:17Z")

</div>

Oh cool

---

<div class="post-metadata">

### Author: ![Ellen1979](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ellen1979/32/31260_2.png) [@Ellen1979](https://forum.kirupa.com/u/Ellen1979)
#### Post date: [September 5, 2026, 8:40pm UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/7 "2026-09-05T20:40:19Z")

</div>

Been there

---

<div class="post-metadata">

### Author: ![WaffleFries](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wafflefries/32/31185_2.png) [@WaffleFries](https://forum.kirupa.com/u/WaffleFries)
#### Post date: [September 6, 2026, 12:00am UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/8 "2026-09-06T00:00:19Z")

</div>

Lol yeah this happened to me too, I ended up just switching to a different data structure and never looked back.

---

<div class="post-metadata">

### Author: ![MechaPrime](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mechaprime/32/31154_2.png) [@MechaPrime](https://forum.kirupa.com/u/MechaPrime)
#### Post date: [September 6, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276/9 "2026-09-06T08:00:17Z")

</div>

**Spot the Bug answer:** The cloneNode method is called with false, which prevents cloning of child elements.

**The fix:**

```js
Change source.cloneNode(false) to source.cloneNode(true).

```

**Why:**  
The cloneNode method in JavaScript takes a boolean argument. When set to false, it only clones the node itself without any of its children. To include all descendants, the argument must be set to true for a deep clone.

* * *

**Got it:** @emmawalter5 🏆

**First-answer leaderboard**

1. @Apexcodes - 6 (firsts) 🏆
2. @kirupa - 6 (firsts) 🏆
3. @emmawalter5 - 3 (firsts)
4. @adnanahmed - 2 (firsts)
