-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathparent.js
More file actions
27 lines (26 loc) · 957 Bytes
/
parent.js
File metadata and controls
27 lines (26 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { api, LightningElement } from 'lwc';
export default class extends LightningElement {
@api children = [{ uid: '1', name: 'child1' }];
connectedCallback() {
window.timingBuffer.push('parent:connectedCallback');
}
renderedCallback() {
window.timingBuffer.push('parent:renderedCallback');
}
disconnectedCallback() {
// This component could get disconnected by our Karma `test-setup.js` after `window.timingBuffer` has
// already been cleared; we don't care about the `disconnectedCallback`s in that case.
if (window.timingBuffer) {
window.timingBuffer.push('parent:disconnectedCallback');
}
}
@api
addChild() {
const uid = this.children.length + 1;
this.children = [...this.children, { uid, name: `child${uid}` }];
}
@api
disconnectLastChild() {
this.children = this.children.slice(0, this.children.length - 1);
}
}