Skip to content

Commit 788d760

Browse files
committed
document video card component class
1 parent 64c6cd3 commit 788d760

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

web-components/video-card/video-card.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,39 @@ function createComponent(html) {
4141
}
4242
}
4343

44-
// Web component class
44+
// Web component class representing a video card.
4545
class VideoCard extends HTMLElement {
4646

47-
// Creates element with default values
47+
// Creates an instance of VideoCard
4848
constructor() {
4949
super();
5050
this.level = 'Varies';
5151
this.time = 'Varies';
5252
this.linktext = 'now';
5353
}
5454

55-
// Return array of properties to observe
55+
/**
56+
* Returns an array of properties to observe.
57+
* @returns {Array} An array of property names.
58+
*/
5659
static get observedAttributes() {
5760
return ['name', 'desc', 'level', 'time', 'link', 'linktext', 'link2', 'linktext2', 'link3', 'linktext3'];
5861
}
5962

60-
// Called when an attribute is defined or changed
63+
/**
64+
* Called when an attribute is defined or changed.
65+
* @param {string} property - The name of the attribute.
66+
* @param {string} oldValue - The old value of the attribute.
67+
* @param {string} newValue - The new value of the attribute.
68+
*/
6169
attributeChangedCallback(property, oldValue, newValue) {
6270
if (oldValue === newValue) return;
6371
this[property] = newValue;
6472
}
6573

66-
// Invoked when element is added to document
74+
/**
75+
* Invoked when the element is added to the document.
76+
*/
6777
connectedCallback() {
6878
// Create shadow root for element
6979
const shadow = this.attachShadow({mode: 'closed'});
@@ -88,6 +98,7 @@ function createComponent(html) {
8898
}
8999
}
90100

101+
// Define new VideoCard element
91102
customElements.define('video-card', VideoCard);
92103
}
93104

0 commit comments

Comments
 (0)