Skip to content

Commit

Permalink
fix(iframe-fixes): add test (#21)
Browse files Browse the repository at this point in the history
Fixes #18
  • Loading branch information
silbinarywolf authored Nov 28, 2019
1 parent df74f0e commit 5148446
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cypress/integration/unit/iframe-fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ describe('IframeFixes', () => {
cy.get('.bodyAppendChild').should('exist');
});

it('Check document.body.removeChild override is active', () => {
component.create(bootstrap);
cy.get('.bodyAppendAndRemoveChild').should('not.exist');
});

it('Check document.querySelector override is active', () => {
component.create(bootstrap);
cy.get('.documentQuerySelectorSuccess').should('exist');
Expand Down
2 changes: 1 addition & 1 deletion lib/iframe-fixes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function overrideSpecIFrameToApplyToAppIFrame(): void {
// end up causing "The node to be removed is not a child of this node." errors.
{
const bodyRemoveChild = function <T extends Node>(this: T): T {
return appDocument.body.removeChild.apply(appDocument, arguments as any) as T;
return appDocument.body.removeChild.apply(appDocument.body, arguments as any) as T;
};
if (specDocument.body.removeChild !== bodyRemoveChild) {
specDocument.body.removeChild = bodyRemoveChild;
Expand Down
7 changes: 7 additions & 0 deletions src/document-manipulator/document-manipulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export class DocumentManipulator {
document.body.appendChild(el);
}

{
const el = document.createElement('div');
el.classList.add('bodyAppendAndRemoveChild');
el.textContent = '- bodyAppendAndRemoveChild';
document.body.appendChild(el);
}

{
const el = document.querySelector('document-manipulator');
if (el) {
Expand Down

0 comments on commit 5148446

Please sign in to comment.