WebReflection / linkedom

A triple-linked lists based DOM implementation.
https://webreflection.medium.com/linkedom-a-jsdom-alternative-53dd8f699311
ISC License
1.71k stars 82 forks source link

[bug] document shortcut element properties lose their children #283

Open TechQuery opened 3 months ago

TechQuery commented 3 months ago

What happened

@WebReflection the following test case in Jest:

it('should be the same <body /> element', () => {
  const { document } = parseHTML(`<body><div class="whatever"></div></body>`);
  const body = document.querySelector('body'),

  expect(body).toBe(document.body);
});

outputs this kind of result:

- Expected  - 0
+ Received  + 6

+ <body>
+   <head />
    <body />
+   <div
+     class="whatever"
+   />
+ </body>

Real world

https://github.com/freeCodeCamp-China/article-webpage-to-markdown-action/pull/32/files#diff-5cdb43bc3113537f238168168c0a52ab488039b63c51cbfc7938b22a2b589c53