forked from dasistdaniel/heiseminus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tag.js
31 lines (27 loc) · 842 Bytes
/
tag.js
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
28
29
30
31
class Tag {
constructor(config) {
this.#setAttributes(config)
this.#createLocalFileURL()
this.#createNewRawElement()
this.#addAttributesToRawElement()
}
#setAttributes(attributes) {
for (const [key, value] of Object.entries(attributes)) {
this[key] = value
}
}
#createLocalFileURL() {
this.src = chrome.extension.getURL(this.localFilePath)
}
#createNewRawElement() {
this.rawElement = document.createElement(this.tagName)
}
#addAttributesToRawElement() {
for (const [key, value] of Object.entries(this)) {
if (key !== "rawElement" && key !== "tagName" && key !== "localFilePath") {
this.rawElement.setAttribute(key, value)
}
};
this.tag = this.rawElement
}
}