MCPcopy
hub / github.com/mdn/web-components-examples / addListItem

Method addListItem

editable-list/main.js:66–85  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

64
65 // add items to the list
66 addListItem(e) {
67 const textInput = this.shadowRoot.querySelector('.add-new-list-item-input');
68
69 if (textInput.value) {
70 const li = document.createElement('li');
71 const button = document.createElement('button');
72 const childrenLength = this.itemList.children.length;
73
74 li.textContent = textInput.value;
75 button.classList.add('editable-list-remove-item', 'icon');
76 button.innerHTML = '⊖';
77
78 this.itemList.appendChild(li);
79 this.itemList.children[childrenLength].appendChild(button);
80
81 this.handleRemoveItemListeners([button]);
82
83 textInput.value = '';
84 }
85 }
86
87 // fires after the element has been attached to the DOM
88 connectedCallback() {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected