Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: capricorn86/happy-dom
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v14.8.2
Choose a base ref
...
head repository: capricorn86/happy-dom
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v14.8.3
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Apr 13, 2024

  1. fix: [1406] Fixes issue with insertBefore and comment reference node

    mdafanasev committed Apr 13, 2024
    Copy the full SHA
    676c634 View commit details

Commits on May 6, 2024

  1. Merge branch 'master' into 1406-fix-issue-with-insertbefore-and-comme…

    …nt-node
    capricorn86 authored May 6, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    84cc397 View commit details
  2. Merge pull request #1407 from mdafanasev/1406-fix-issue-with-insertbe…

    …fore-and-comment-node
    
    fix: [1406] Fixes issue with insertBefore and comment reference node
    capricorn86 authored May 6, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d159d4d View commit details
Showing with 19 additions and 0 deletions.
  1. +7 −0 packages/happy-dom/src/nodes/element/ElementUtility.ts
  2. +12 −0 packages/happy-dom/test/nodes/element/Element.test.ts
7 changes: 7 additions & 0 deletions packages/happy-dom/src/nodes/element/ElementUtility.ts
Original file line number Diff line number Diff line change
@@ -171,6 +171,13 @@ export default class ElementUtility {
parentNodeChildren.splice(index, 1);
}
}
const parentChildNodes = (<Element>ancestorNode)[PropertySymbol.childNodes];
if (parentChildNodes) {
const index = parentChildNodes.indexOf(newNode);
if (index !== -1) {
parentChildNodes.splice(index, 1);
}
}
}

const ancestorNodeChildren = <HTMLCollection<HTMLElement>>(
12 changes: 12 additions & 0 deletions packages/happy-dom/test/nodes/element/Element.test.ts
Original file line number Diff line number Diff line change
@@ -1235,6 +1235,18 @@ describe('Element', () => {
expect(element.children['div'] === div).toBe(true);
expect(element.children['span2'] === span2).toBe(true);
});

it('Inserts correctly with comment reference node', () => {
const container = document.createElement('div');
const child = document.createElement('p');
child.textContent = 'A';
container.appendChild(child);
const comment = document.createComment('');
container.appendChild(comment);
container.insertBefore(child, comment);
const elements = container.querySelectorAll('p');
expect(elements.length).toBe(1);
});
});

describe('get previousElementSibling()', () => {