Skip to content

Commit 225da98

Browse files
committed
test(wtr): hoist function definition
1 parent ec5293d commit 225da98

File tree

1 file changed

+22
-18
lines changed
  • packages/@lwc/integration-not-karma/test/custom-elements-registry

1 file changed

+22
-18
lines changed

packages/@lwc/integration-not-karma/test/custom-elements-registry/index.spec.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,28 @@ const injectableCreateVanilla = String(function createVanilla({ skipInject = fal
8888
}
8989
});
9090

91+
/**
92+
* The text of a function that creates a vanilla custom element with an `adoptedCallback`.
93+
* The function is injected into an iframe, and must not reference any variables in this file.
94+
*/
95+
const injectableDefineVanillaAdopted = String(function defineVanillaAdopted() {
96+
customElements.define(
97+
'x-adopted',
98+
class extends HTMLElement {
99+
constructor() {
100+
super();
101+
// avoid class properties so Babel doesn't transform this class
102+
this._adopted = false;
103+
}
104+
105+
adoptedCallback() {
106+
this._adopted = true;
107+
}
108+
}
109+
);
110+
document.body.appendChild(document.createElement('x-adopted'));
111+
});
112+
91113
describe('custom elements registry', () => {
92114
let iframe;
93115
let engineCode;
@@ -263,24 +285,6 @@ describe('custom elements registry', () => {
263285

264286
describe('adoptedCallback', () => {
265287
describe('calls adoptedCallback when element moves between documents', () => {
266-
const injectableDefineVanillaAdopted = String(function defineVanillaAdopted() {
267-
customElements.define(
268-
'x-adopted',
269-
class extends HTMLElement {
270-
constructor() {
271-
super();
272-
// avoid class properties so Babel doesn't transform this class
273-
this._adopted = false;
274-
}
275-
276-
adoptedCallback() {
277-
this._adopted = true;
278-
}
279-
}
280-
);
281-
document.body.appendChild(document.createElement('x-adopted'));
282-
});
283-
284288
const scenarios = [
285289
{
286290
name: 'element defined before engine loads',

0 commit comments

Comments
 (0)