gmemstr.github.io/assets/app.js
2020-07-10 15:23:56 +01:00

23 lines
759 B
JavaScript

class GithubRepoElement extends HTMLElement {
constructor() {
super();
// Create a shadow root
var shadow = this.attachShadow({mode: 'open'});
// Create spans
var wrapper = document.createElement('a');
wrapper.setAttribute("class","github-repo");
const link = document.createAttribute("href");
link.value = `https://github.com/${this.innerHTML}`
wrapper.attributes.setNamedItem(link);
wrapper.innerText = this.innerHTML;
var style = document.createElement('style');
style.textContent = '.github-repo { color: #0FA0CE; }'
shadow.appendChild(style)
shadow.appendChild(wrapper);
}
}
customElements.define('github-repo', GithubRepoElement)