Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class Bar extends HTMLAnchorElement {
disconnectedCallback() {
disconnectedCallbackSpy();
}
}
const name = defineCBE(Bar, 'a');
class Foo extends HTMLElement {
constructor() {
super();
const root = this.attachShadow({mode: 'open'});
root.innerHTML = `<a is=""></a>`;
}
}
const tag = defineCE(Foo);
const foo = await fixture(`<${tag}>`);
// eslint-disable-next-line prefer-destructuring
const bar = foo.shadowRoot.children[0];
const promise = waitForMutationObserverChange(
foo.shadowRoot,
observeChildren,
);
bar.parentNode.removeChild(bar);
await promise;
expect(disconnectedCallbackSpy).toHaveBeenCalledTimes(1);
});
}
}
const name = defineCBE(Bar, 'a');
class Foo extends HTMLElement {
constructor() {
super();
const root = this.attachShadow({mode: 'open'});
root.innerHTML =
`<a is=""></a><div>` +
`<div><a is=""></a></div></div>`;
}
}
defineCE(Foo);
const foo = new Foo();
expect(foo.shadowRoot.children[0] instanceof Bar).toBeTruthy();
expect(connectedCallbackSpy).not.toHaveBeenCalled();
});
expect(() => defineCE(Foo)).toThrowError(
'Not supported in this environment',