mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-15 15:30:00 -04:00
25 lines
No EOL
587 B
TypeScript
25 lines
No EOL
587 B
TypeScript
export default class Clone {
|
|
el: HTMLElement;
|
|
copy: HTMLElement
|
|
|
|
constructor(element: HTMLElement) {
|
|
this.el = element;
|
|
this.copy = document.createElement(element.tagName);
|
|
|
|
for (const attr of element.getAttributeNames()) {
|
|
this.copy.setAttribute(attr, element.getAttribute(attr));
|
|
}
|
|
|
|
if (element.innerHTML) {
|
|
this.copy.innerHTML = element.innerHTML;
|
|
}
|
|
}
|
|
|
|
insertCopy() {
|
|
this.el.insertAdjacentElement("afterend", this.copy);
|
|
}
|
|
|
|
removeElement() {
|
|
this.el.remove();
|
|
}
|
|
} |